Skip to content

Commit 9cd3132

Browse files
committed
fix: improved comments (QA-04)
1 parent 9868d57 commit 9cd3132

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
;; This contract implements a boot contract, deployed
2+
;; at epoch 3.2, which facilitates the mints and transfers
3+
;; described in SIP-031.
4+
;;
5+
;; There are three mechanisms for claiming STX from this contract:
6+
;; 1. An initial 100M STX, which is available immediately.
7+
;; 2. A linear vesting schedule of 100M STX over 24 months.
8+
;; 3. Per-tenure mints, which are transferred to this contract,
9+
;; are available as soon as they are received by this contract.
10+
;;
11+
;; This contract is written based on the assumption that the contract
12+
;; will have a balance of at least 200M STX upon deployment, which is
13+
;; handled during the epoch 3.2 transition.
14+
115
(define-constant ERR_NOT_ALLOWED u101)
216
(define-constant ERR_NOTHING_TO_CLAIM u102)
317

@@ -23,16 +37,17 @@
2337
;; burn height 907740, which is what is specified in SIP-031.
2438
(define-constant DEPLOY_BLOCK_HEIGHT (if is-in-mainnet u907740 burn-block-height))
2539

40+
;; The authorized recipient of the funds.
41+
;; Note than in production environments, `tx-sender` is
42+
;; replaced with a hard-coded address.
2643
(define-data-var recipient principal tx-sender)
2744

2845
(define-read-only (get-recipient) (var-get recipient))
2946

3047
(define-read-only (get-deploy-block-height) DEPLOY_BLOCK_HEIGHT)
3148

3249
;; Update the recipient of the funds.
33-
;;
34-
;; May only be called by the `recipient`.
35-
;;
50+
;; May only be called by the current `recipient`.
3651
;; Returns `true` if the recipient was updated.
3752
(define-public (update-recipient (new-recipient principal)) (begin
3853
(begin
@@ -66,14 +81,17 @@
6681
)
6782
)
6883

84+
;; Authorization check. Verify that the caller is the current `recipient`.
85+
;; This also prevents `recipient` calling into this contract
86+
;; via an indirect contract-call.
6987
(define-private (validate-caller)
7088
(if (is-eq (var-get recipient) contract-caller tx-sender)
7189
(ok true)
7290
(err ERR_NOT_ALLOWED))
7391
)
7492

7593
;; Returns the *total* vested amount at `burn-height`, i.e.
76-
;; immediate bucket + linear vesting so far ( DOES NOT subtract any claims ).
94+
;; immediate bucket + linear vesting so far (DOES NOT subtract any claims).
7795
(define-private (calc-total-vested (burn-height uint))
7896
(let
7997
(
@@ -83,7 +101,7 @@
83101
(vested-multiple (/ (* STX_PER_ITERATION diff) INITIAL_MINT_VESTING_ITERATION_BLOCKS))
84102

85103
;; If we have completed (or exceeded) the scheduled number of iterations,
86-
;; consider the *entire* vesting bucket unlocked. This avoids leaving a
104+
;; consider the *entire* vesting bucket unlocked. This avoids leaving a
87105
;; tiny remainder caused by integer-division truncation.
88106
(vested-amount (if (>= iterations INITIAL_MINT_VESTING_ITERATIONS)
89107
INITIAL_MINT_VESTING_AMOUNT

0 commit comments

Comments
 (0)