/
stacking-dao-genesis-nft-minter.clar
94 lines (76 loc) · 2.54 KB
/
stacking-dao-genesis-nft-minter.clar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
;; @contract Stacking DAO Genesis NFT
;; @version 1
;;
;; Stacking DAO Genesis NFT minter
;;
;;-------------------------------------
;; Constants
;;-------------------------------------
(define-constant ERR_NOT_AUTHORIZED u1101)
(define-constant ERR_CANNOT_CLAIM u1102)
(define-constant ERR_ALREADY_CLAIMED u1103)
(define-constant DEPLOYER tx-sender)
;;-------------------------------------
;; Maps
;;-------------------------------------
(define-map claims principal bool)
;;-------------------------------------
;; Variables
;;-------------------------------------
(define-data-var cycle-end-block uint u135418)
;;-------------------------------------
;; Getters
;;-------------------------------------
;; If people held at least 100 stSTX throughout cycle 74/75, they can claim a Stacking DAO Genesis NFT
(define-read-only (can-claim (account principal))
(let (
(balances (contract-call? .block-info-v1 get-user-ststx-at-block account (var-get cycle-end-block)))
(ststx-balance (get ststx-balance balances))
(lp-balance (get lp-balance balances))
)
(>= (+ ststx-balance lp-balance) u99000000)
)
)
(define-read-only (has-claimed (account principal))
(default-to false (map-get? claims account))
)
(define-read-only (get-cycle-end-block)
(var-get cycle-end-block)
)
;;-------------------------------------
;; Setters
;;-------------------------------------
(define-public (set-cycle-end-block (end-block uint))
(ok (var-set cycle-end-block end-block))
)
;;-------------------------------------
;; Claim
;;-------------------------------------
(define-public (claim)
(begin
(asserts! (can-claim tx-sender) (err ERR_CANNOT_CLAIM))
(asserts! (not (has-claimed tx-sender)) (err ERR_ALREADY_CLAIMED))
(try! (contract-call? .stacking-dao-genesis-nft mint-for-protocol tx-sender u0))
(map-set claims tx-sender true)
(ok true)
)
)
(define-public (airdrop (info (tuple (recipient principal) (type uint))))
(let (
(recipient (get recipient info))
(type (get type info))
)
(asserts! (is-eq tx-sender DEPLOYER) (err ERR_NOT_AUTHORIZED))
(asserts! (can-claim recipient) (err ERR_CANNOT_CLAIM))
(asserts! (not (has-claimed recipient)) (err ERR_ALREADY_CLAIMED))
(try! (contract-call? .stacking-dao-genesis-nft mint-for-protocol recipient type))
(map-set claims recipient true)
(ok true)
)
)
(define-public (airdrop-many (recipients (list 25 (tuple (recipient principal) (type uint)))))
(begin
(asserts! (is-eq tx-sender DEPLOYER) (err ERR_NOT_AUTHORIZED))
(ok (map airdrop recipients))
)
)