|
| 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 | + |
1 | 15 | (define-constant ERR_NOT_ALLOWED u101)
|
2 | 16 | (define-constant ERR_NOTHING_TO_CLAIM u102)
|
3 | 17 |
|
|
23 | 37 | ;; burn height 907740, which is what is specified in SIP-031.
|
24 | 38 | (define-constant DEPLOY_BLOCK_HEIGHT (if is-in-mainnet u907740 burn-block-height))
|
25 | 39 |
|
| 40 | +;; The authorized recipient of the funds. |
| 41 | +;; Note than in production environments, `tx-sender` is |
| 42 | +;; replaced with a hard-coded address. |
26 | 43 | (define-data-var recipient principal tx-sender)
|
27 | 44 |
|
28 | 45 | (define-read-only (get-recipient) (var-get recipient))
|
29 | 46 |
|
30 | 47 | (define-read-only (get-deploy-block-height) DEPLOY_BLOCK_HEIGHT)
|
31 | 48 |
|
32 | 49 | ;; 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`. |
36 | 51 | ;; Returns `true` if the recipient was updated.
|
37 | 52 | (define-public (update-recipient (new-recipient principal)) (begin
|
38 | 53 | (begin
|
|
66 | 81 | )
|
67 | 82 | )
|
68 | 83 |
|
| 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. |
69 | 87 | (define-private (validate-caller)
|
70 | 88 | (if (is-eq (var-get recipient) contract-caller tx-sender)
|
71 | 89 | (ok true)
|
72 | 90 | (err ERR_NOT_ALLOWED))
|
73 | 91 | )
|
74 | 92 |
|
75 | 93 | ;; 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). |
77 | 95 | (define-private (calc-total-vested (burn-height uint))
|
78 | 96 | (let
|
79 | 97 | (
|
|
83 | 101 | (vested-multiple (/ (* STX_PER_ITERATION diff) INITIAL_MINT_VESTING_ITERATION_BLOCKS))
|
84 | 102 |
|
85 | 103 | ;; 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 |
87 | 105 | ;; tiny remainder caused by integer-division truncation.
|
88 | 106 | (vested-amount (if (>= iterations INITIAL_MINT_VESTING_ITERATIONS)
|
89 | 107 | INITIAL_MINT_VESTING_AMOUNT
|
|
0 commit comments