-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: public-pools-strategy-manager Dead Man's Switch #55
base: mainnet
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,13 @@ | |
;; SPDX-License-Identifier: BUSL-1.1 | ||
|
||
(define-constant err-unauthorised (err u3000)) | ||
(define-constant err-still-alive (err u3001)) | ||
|
||
(define-constant dms-activation-period u12960) ;; ~90 days | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one cycle is already bad. So 2100 bitcoin blocks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure we can do that, but then a manager must be sure to send a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pool manager has to extend if nobody else does it for us |
||
|
||
(define-map authorised-managers principal bool) | ||
(map-set authorised-managers tx-sender true) | ||
|
||
(define-data-var last-manager-action-height uint burn-block-height) | ||
|
||
(define-read-only (is-dao-or-extension) | ||
(ok (asserts! (or (is-eq tx-sender 'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lisa-dao) (contract-call? 'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lisa-dao is-extension contract-caller)) err-unauthorised)) | ||
|
@@ -17,14 +21,23 @@ | |
(define-public (fund-strategy (amounts (list 20 uint))) | ||
(begin | ||
(asserts! (is-authorised-manager tx-sender) err-unauthorised) | ||
(contract-call? 'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lqstx-vault fund-strategy .public-pools-strategy-v2 (unwrap-panic (to-consensus-buff? amounts))) | ||
(var-set last-manager-action-height burn-block-height) | ||
(contract-call? 'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lqstx-vault fund-strategy 'SM3KNVZS30WM7F89SXKVVFY4SN9RMPZZ9FX929N0V.public-pools-strategy-v2 (unwrap-panic (to-consensus-buff? amounts))) | ||
) | ||
) | ||
|
||
(define-public (refund-strategy (selection (list 20 bool))) | ||
(begin | ||
(asserts! (is-authorised-manager tx-sender) err-unauthorised) | ||
(contract-call? 'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lqstx-vault refund-strategy .public-pools-strategy-v2 (unwrap-panic (to-consensus-buff? selection))) | ||
(var-set last-manager-action-height burn-block-height) | ||
(contract-call? 'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lqstx-vault refund-strategy 'SM3KNVZS30WM7F89SXKVVFY4SN9RMPZZ9FX929N0V.public-pools-strategy-v2 (unwrap-panic (to-consensus-buff? selection))) | ||
) | ||
) | ||
|
||
(define-public (keep-alive) | ||
(begin | ||
(asserts! (is-authorised-manager tx-sender) err-unauthorised) | ||
(ok (var-set last-manager-action-height burn-block-height)) | ||
) | ||
) | ||
|
||
|
@@ -34,3 +47,23 @@ | |
(ok (map-set authorised-managers who enabled)) | ||
) | ||
) | ||
|
||
;; Dead Man's switch | ||
|
||
(define-read-only (dms-active) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dms-active sounds like the dms was pressed. Better "dms-inactive"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably, I don't understandthe term DMS not properly. It indicates that the manager was not active, correct? |
||
(ok (asserts! (< (+ (var-get last-manager-action-height) dms-activation-period) burn-block-height) err-still-alive)) | ||
) | ||
|
||
(define-public (dms-revoke-strategy) | ||
(begin | ||
(try! (dms-active)) | ||
(contract-call? 'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lqstx-vault fund-strategy 'SM3KNVZS30WM7F89SXKVVFY4SN9RMPZZ9FX929N0V.public-pools-strategy-v2 (unwrap-panic (to-consensus-buff? (list u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0)))) | ||
) | ||
) | ||
|
||
(define-public (dms-refund-strategy) | ||
(begin | ||
(try! (dms-active)) | ||
(contract-call? 'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lqstx-vault refund-strategy 'SM3KNVZS30WM7F89SXKVVFY4SN9RMPZZ9FX929N0V.public-pools-strategy-v2 (unwrap-panic (to-consensus-buff? (list true true true true true true true true true true true true true true true true true true true true)))) | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a requirement.