Skip to content

Commit 7575db8

Browse files
committed
fix: remove vested-claimed-amount
1 parent 41f7146 commit 7575db8

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

contrib/core-contract-tests/tests/clarigen-types.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4607,12 +4607,6 @@ export const contracts = {
46074607
args: [],
46084608
outputs: { type: "principal" },
46094609
} as TypedAbiFunction<[], string>,
4610-
getVestedClaimedAmount: {
4611-
name: "get-vested-claimed-amount",
4612-
access: "read_only",
4613-
args: [],
4614-
outputs: { type: "uint128" },
4615-
} as TypedAbiFunction<[], bigint>,
46164610
},
46174611
maps: {},
46184612
variables: {
@@ -4659,18 +4653,13 @@ export const contracts = {
46594653
deployBlockHeight: {
46604654
name: "deploy-block-height",
46614655
type: "uint128",
4662-
access: "variable",
4656+
access: "constant",
46634657
} as TypedAbiVariable<bigint>,
46644658
recipient: {
46654659
name: "recipient",
46664660
type: "principal",
46674661
access: "variable",
46684662
} as TypedAbiVariable<string>,
4669-
vestedClaimedAmount: {
4670-
name: "vested-claimed-amount",
4671-
type: "uint128",
4672-
access: "variable",
4673-
} as TypedAbiVariable<bigint>,
46744663
},
46754664
constants: {
46764665
ERR_NOTHING_TO_CLAIM: 102n,
@@ -4683,7 +4672,6 @@ export const contracts = {
46834672
STX_PER_ITERATION: 4_166_666_666_666n,
46844673
deployBlockHeight: 3n,
46854674
recipient: "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM",
4686-
vestedClaimedAmount: 0n,
46874675
},
46884676
non_fungible_tokens: [],
46894677
fungible_tokens: [],

contrib/core-contract-tests/tests/sip-031/sip-031.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ test('updated recipient can claim', () => {
9393
});
9494

9595
test('calculating vested amounts at a block height', () => {
96+
mintInitial();
9697
const deployBlockHeight = rov(contract.getDeployBlockHeight());
9798

9899
const initialMintAmount = 200_000_000n * 1000000n; // 200,000,000 STX

stackslib/src/chainstate/stacks/boot/sip-031.clar

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121

2222
(define-data-var recipient principal tx-sender)
2323

24-
(define-data-var deploy-block-height uint burn-block-height)
25-
26-
(define-data-var vested-claimed-amount uint u0)
24+
;; The block height at which vesting starts. On Mainnet, this is
25+
;; burn height 907740, which is what is specified in SIP-031.
26+
(define-constant deploy-block-height (if is-in-mainnet u907740 burn-block-height))
2727

2828
(define-read-only (get-recipient) (var-get recipient))
2929

30-
(define-read-only (get-deploy-block-height) (var-get deploy-block-height))
31-
32-
(define-read-only (get-vested-claimed-amount) (var-get vested-claimed-amount))
30+
(define-read-only (get-deploy-block-height) deploy-block-height)
3331

3432
;; Update the recipient of the funds.
3533
;;
@@ -49,7 +47,6 @@
4947
(
5048
(balance (stx-get-balance (as-contract tx-sender)))
5149
(total-vested (calc-total-vested burn-block-height))
52-
(vested-claimed (var-get vested-claimed-amount))
5350
;; Portion of the initial mint that is *still* locked (not yet vested)
5451
(reserved (- INITIAL_MINT_AMOUNT total-vested))
5552
;; Free balance = everything the caller may withdraw right now
@@ -60,7 +57,6 @@
6057
)
6158
(try! (validate-caller))
6259
(asserts! (> claimable u0) (err ERR_NOTHING_TO_CLAIM))
63-
(var-set vested-claimed-amount (+ vested-claimed total-vested))
6460

6561
(try! (as-contract (stx-transfer? claimable tx-sender (var-get recipient))))
6662
(ok claimable)
@@ -76,7 +72,7 @@
7672
(define-private (calc-total-vested (burn-height uint))
7773
(let
7874
(
79-
(diff (- burn-height (var-get deploy-block-height)))
75+
(diff (- burn-height deploy-block-height))
8076
;; Note: this rounds down
8177
(iterations (/ diff INITIAL_MINT_VESTING_ITERATION_BLOCKS))
8278
(vested-multiple (* STX_PER_ITERATION iterations))
@@ -98,7 +94,13 @@
9894
(let
9995
(
10096
(total-vested (calc-total-vested burn-height))
97+
(reserved (- INITIAL_MINT_AMOUNT total-vested))
98+
(balance (stx-get-balance (as-contract tx-sender)))
99+
(claimable
100+
(if (> balance reserved)
101+
(- balance reserved)
102+
u0))
101103
)
102-
(- total-vested (var-get vested-claimed-amount))
104+
claimable
103105
)
104106
)

0 commit comments

Comments
 (0)