From abb78614b8510d31f6f7540a6e662016ba22e7c7 Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Thu, 22 Feb 2024 18:33:02 +0100 Subject: [PATCH] feat: add `end-of-cycle-id` to synthetic pox events --- pox-locking/src/events.rs | 40 +++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/pox-locking/src/events.rs b/pox-locking/src/events.rs index baf78161a..c290e5fd8 100644 --- a/pox-locking/src/events.rs +++ b/pox-locking/src/events.rs @@ -115,6 +115,9 @@ fn create_event_info_data_code( "stack-stx" => { format!( r#" + (let ( + (unlock-burn-height (reward-cycle-to-burn-height (+ (current-pox-reward-cycle) u1 {lock_period}))) + ) {{ data: {{ ;; amount of ustx to lock. @@ -122,7 +125,7 @@ fn create_event_info_data_code( lock-amount: {lock_amount}, ;; burnchain height when the unlock finishes. ;; derived from args[3] - unlock-burn-height: (reward-cycle-to-burn-height (+ (current-pox-reward-cycle) u1 {lock_period})), + unlock-burn-height: unlock-burn-height, ;; PoX address tuple. ;; equal to args[1]. pox-addr: {pox_addr}, @@ -140,8 +143,10 @@ fn create_event_info_data_code( max-amount: {max_amount}, ;; equal to args[7] auth-id: {auth_id}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle unlock-burn-height), }} - }} + }}) "#, lock_amount = &args[0], lock_period = &args[3], @@ -156,6 +161,9 @@ fn create_event_info_data_code( "delegate-stack-stx" => { format!( r#" + (let ( + (unlock-burn-height (reward-cycle-to-burn-height (+ (current-pox-reward-cycle) u1 {lock_period}))) + ) {{ data: {{ ;; amount of ustx to lock. @@ -163,7 +171,7 @@ fn create_event_info_data_code( lock-amount: {lock_amount}, ;; burnchain height when the unlock finishes. ;; derived from args[4] - unlock-burn-height: (reward-cycle-to-burn-height (+ (current-pox-reward-cycle) u1 {lock_period})), + unlock-burn-height: unlock-burn-height, ;; PoX address tuple. ;; equal to args[2] pox-addr: {pox_addr}, @@ -178,8 +186,10 @@ fn create_event_info_data_code( ;; stacker ;; equal to args[0] stacker: '{stacker}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle unlock-burn-height), }} - }} + }}) "#, stacker = &args[0], lock_amount = &args[1], @@ -210,6 +220,8 @@ fn create_event_info_data_code( max-amount: {max_amount}, ;; equal to args[4] auth-id: {auth_id}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle (get unlock-height (stx-account tx-sender))), }} }} "#, @@ -239,7 +251,9 @@ fn create_event_info_data_code( delegator: tx-sender, ;; stacker ;; equal to args[0] - stacker: '{stacker} + stacker: '{stacker}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle (get unlock-height (stx-account '{stacker}))), }} }} "#, @@ -281,6 +295,8 @@ fn create_event_info_data_code( max-amount: {max_amount}, ;; equal to args[5] auth-id: {auth_id}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle new-unlock-ht), }} }}) "#, @@ -320,7 +336,9 @@ fn create_event_info_data_code( delegator: tx-sender, ;; stacker ;; equal to args[0] - stacker: '{stacker} + stacker: '{stacker}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle new-unlock-ht), }} }}) "#, @@ -354,6 +372,8 @@ fn create_event_info_data_code( max-amount: {max_amount}, ;; equal to args[5] auth-id: {auth_id}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle (get unlock-height (stx-account tx-sender))), }} }} "#, @@ -383,7 +403,9 @@ fn create_event_info_data_code( ;; delegator (this is the caller) delegator: tx-sender, ;; equal to args[2] - reward-cycle-index: {reward_cycle_index} + reward-cycle-index: {reward_cycle_index}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle (get unlock-height (stx-account tx-sender))), }} }} "#, @@ -408,7 +430,9 @@ fn create_event_info_data_code( unlock-burn-height: {until_burn_height}, ;; optional PoX address tuple. ;; equal to args[3]. - pox-addr: {pox_addr} + pox-addr: {pox_addr}, + ;; Get end cycle ID + end-cycle-id: (burn-height-to-reward-cycle {until_burn_height}), }} }} "#,