Skip to content

Commit cd8af2c

Browse files
committed
use liquidSupply in conclude-proposal
1 parent 4b225ce commit cd8af2c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

contracts/dao/extensions/aibtc-action-proposals.clar

+6-5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
endBlock: uint, ;; block height
7070
votesFor: uint, ;; total votes for
7171
votesAgainst: uint, ;; total votes against
72+
liquidTokens: uint, ;; liquid tokens
7273
concluded: bool, ;; has the proposal concluded
7374
passed: bool, ;; did the proposal pass
7475
}
@@ -114,6 +115,7 @@
114115
(
115116
(newId (+ (var-get proposalCount) u1))
116117
(voterBalance (unwrap! (contract-call? .aibtc-token get-balance tx-sender) ERR_FETCHING_TOKEN_DATA))
118+
(liquidTokens (contract-call? .aibtc-token get-liquid-supply))
117119
)
118120
;; required variables must be set
119121
(asserts! (is-initialized) ERR_NOT_INITIALIZED)
@@ -142,6 +144,7 @@
142144
endBlock: (+ burn-block-height VOTING_PERIOD),
143145
votesFor: u0,
144146
votesAgainst: u0,
147+
liquidTokens: liquidTokens,
145148
concluded: false,
146149
passed: false,
147150
}) ERR_SAVING_PROPOSAL)
@@ -194,17 +197,15 @@
194197
(let
195198
(
196199
(proposalRecord (unwrap! (map-get? Proposals proposalId) ERR_PROPOSAL_NOT_FOUND))
197-
(tokenTotalSupply (unwrap! (contract-call? .aibtc-token get-total-supply) ERR_FETCHING_TOKEN_DATA))
198-
(treasuryContract (contract-of treasury))
199-
(treasuryBalance (unwrap! (contract-call? .aibtc-token get-balance treasuryContract) ERR_FETCHING_TOKEN_DATA))
200-
(votePassed (> (get votesFor proposalRecord) (* tokenTotalSupply (- u100 treasuryBalance) VOTING_QUORUM)))
200+
;; if VOTING_QUORUM <= ((votesFor * 100) / liquidTokens)
201+
(votePassed (<= VOTING_QUORUM (/ (* (get votesFor proposalRecord) u100) (get liquidTokens proposalRecord))))
201202
)
202203
;; required variables must be set
203204
(asserts! (is-initialized) ERR_NOT_INITIALIZED)
204205
;; verify extension still active in dao
205206
(try! (as-contract (is-dao-or-extension)))
206207
;; verify treasury matches protocol treasury
207-
(asserts! (is-eq treasuryContract (var-get protocolTreasury)) ERR_TREASURY_MISMATCH)
208+
(asserts! (is-eq (contract-of treasury) (var-get protocolTreasury)) ERR_TREASURY_MISMATCH)
208209
;; proposal past end block height
209210
(asserts! (>= burn-block-height (get endBlock proposalRecord)) ERR_PROPOSAL_STILL_ACTIVE)
210211
;; proposal not already concluded

0 commit comments

Comments
 (0)