diff --git a/Clarinet.toml b/Clarinet.toml index d8b1e58..5822f23 100644 --- a/Clarinet.toml +++ b/Clarinet.toml @@ -83,11 +83,6 @@ path = 'contracts/dao/extensions/aibtc-action-proposals-v2.clar' clarity_version = 3 epoch = 3.1 -[contracts.aibtc-dao-charter] -path = 'contracts/dao/extensions/aibtc-dao-charter.clar' -clarity_version = 3 -epoch = 3.1 - [contracts.aibtc-core-proposals] path = 'contracts/dao/extensions/aibtc-core-proposals.clar' clarity_version = 2 @@ -98,6 +93,26 @@ path = 'contracts/dao/extensions/aibtc-core-proposals-v2.clar' clarity_version = 3 epoch = 3.1 +[contracts.aibtc-dao-charter] +path = 'contracts/dao/extensions/aibtc-dao-charter.clar' +clarity_version = 3 +epoch = 3.1 + +[contracts.aibtc-dao-epoch] +path = 'contracts/dao/extensions/aibtc-dao-epoch.clar' +clarity_version = 3 +epoch = 3.1 + +[contracts.aibtc-dao-assets] +path = 'contracts/dao/extensions/aibtc-dao-assets.clar' +clarity_version = 3 +epoch = 3.1 + +[contracts.aibtc-dao-users] +path = 'contracts/dao/extensions/aibtc-dao-users.clar' +clarity_version = 3 +epoch = 3.1 + [contracts.aibtc-onchain-messaging] path = 'contracts/dao/extensions/aibtc-onchain-messaging.clar' clarity_version = 3 diff --git a/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-dao.clar b/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-dao.clar index 93a647f..9f3d8eb 100644 --- a/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-dao.clar +++ b/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-dao.clar @@ -1,10 +1,26 @@ +;; title: aibtc-action-configure-timed-vault-dao +;; version: 1.0.0 +;; summary: A predefined action to configure the DAO timed vaults. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) -(define-constant CFG_MESSAGE "Executed Action Proposal: Updated configuration in <%= it.dao_token_name %> timed vault extension") +;; template variables +;; + +(define-constant CFG_MESSAGE "Executed Action Proposal: Updated configuration in DAO timed vault extension") + +;; public functions +;; (define-public (callback (sender principal) (memo (buff 34))) (ok true)) @@ -49,8 +65,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-sbtc.clar b/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-sbtc.clar index 72f884c..64e39d5 100644 --- a/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-sbtc.clar +++ b/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-sbtc.clar @@ -1,11 +1,27 @@ +;; title: aibtc-action-configure-timed-vault-sbtc +;; version: 1.0.0 +;; summary: A predefined action to configure the BTC timed vaults. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; template variables +;; (define-constant CFG_MESSAGE "Executed Action Proposal: Updated configuration in BTC timed vault extension") +;; public functions +;; + (define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (run (parameters (buff 2048))) @@ -49,8 +65,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-stx.clar b/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-stx.clar index dce93dd..bdd31cf 100644 --- a/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-stx.clar +++ b/contracts/dao/extensions/actions/aibtc-action-configure-timed-vault-stx.clar @@ -1,11 +1,27 @@ +;; title: aibtc-action-configure-timed-vault-stx +;; version: 1.0.0 +;; summary: A predefined action to configure the STX timed vaults. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; template variables +;; (define-constant CFG_MESSAGE "Executed Action Proposal: Updated configuration in STX timed vault extension") +;; public functions +;; + (define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (run (parameters (buff 2048))) @@ -49,8 +65,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-pmt-dao-add-resource.clar b/contracts/dao/extensions/actions/aibtc-action-pmt-dao-add-resource.clar index e18b29f..45d9b56 100644 --- a/contracts/dao/extensions/actions/aibtc-action-pmt-dao-add-resource.clar +++ b/contracts/dao/extensions/actions/aibtc-action-pmt-dao-add-resource.clar @@ -1,11 +1,27 @@ +;; title: aibtc-action-pmt-dao-add-resource +;; version: 1.0.0 +;; summary: A predefined action to add a resource in the DAO payment processor extension. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; template variables +;; (define-constant CFG_MESSAGE "Executed Action Proposal: Added a resource in the DAO payment processor extension") +;; public functions +;; + (define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (run (parameters (buff 2048))) @@ -22,8 +38,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-pmt-dao-toggle-resource.clar b/contracts/dao/extensions/actions/aibtc-action-pmt-dao-toggle-resource.clar index 133b870..5ca2df5 100644 --- a/contracts/dao/extensions/actions/aibtc-action-pmt-dao-toggle-resource.clar +++ b/contracts/dao/extensions/actions/aibtc-action-pmt-dao-toggle-resource.clar @@ -1,11 +1,27 @@ +;; title: aibtc-action-pmt-dao-toggle-resource +;; version: 1.0.0 +;; summary: A predefined action to toggle a resource in the DAO payment processor extension. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; template variables +;; (define-constant CFG_MESSAGE "Executed Action Proposal: Toggled resource status by name in the DAO payment processor extension") +;; public functions +;; + (define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (run (parameters (buff 2048))) @@ -19,8 +35,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-pmt-sbtc-add-resource.clar b/contracts/dao/extensions/actions/aibtc-action-pmt-sbtc-add-resource.clar index df9fe17..5a39d39 100644 --- a/contracts/dao/extensions/actions/aibtc-action-pmt-sbtc-add-resource.clar +++ b/contracts/dao/extensions/actions/aibtc-action-pmt-sbtc-add-resource.clar @@ -1,11 +1,27 @@ +;; title: aibtc-action-pmt-sbtc-add-resource +;; version: 1.0.0 +;; summary: A predefined action to add a resource in the BTC payment processor extension. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; template variables +;; (define-constant CFG_MESSAGE "Executed Action Proposal: Added a resource in the BTC payment processor extension") +;; public functions +;; + (define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (run (parameters (buff 2048))) @@ -22,8 +38,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-pmt-sbtc-toggle-resource.clar b/contracts/dao/extensions/actions/aibtc-action-pmt-sbtc-toggle-resource.clar index 505d8c9..b50c74c 100644 --- a/contracts/dao/extensions/actions/aibtc-action-pmt-sbtc-toggle-resource.clar +++ b/contracts/dao/extensions/actions/aibtc-action-pmt-sbtc-toggle-resource.clar @@ -1,11 +1,27 @@ +;; title: aibtc-action-pmt-sbtc-toggle-resource +;; version: 1.0.0 +;; summary: A predefined action to toggle a resource in the BTC payment processor extension. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; template variables +;; (define-constant CFG_MESSAGE "Executed Action Proposal: Toggled resource status by name in the BTC payment processor extension") +;; public functions +;; + (define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (run (parameters (buff 2048))) @@ -19,8 +35,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-pmt-stx-add-resource.clar b/contracts/dao/extensions/actions/aibtc-action-pmt-stx-add-resource.clar index baac0e9..1dd6aff 100644 --- a/contracts/dao/extensions/actions/aibtc-action-pmt-stx-add-resource.clar +++ b/contracts/dao/extensions/actions/aibtc-action-pmt-stx-add-resource.clar @@ -1,11 +1,27 @@ +;; title: aibtc-action-pmt-stx-add-resource +;; version: 1.0.0 +;; summary: A predefined action to add a resource in the STX payment processor extension. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; template variables +;; (define-constant CFG_MESSAGE "Executed Action Proposal: Added a resource in the STX payment processor extension") +;; public functions +;; + (define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (run (parameters (buff 2048))) @@ -22,8 +38,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-pmt-stx-toggle-resource.clar b/contracts/dao/extensions/actions/aibtc-action-pmt-stx-toggle-resource.clar index 6372dcb..44b6c71 100644 --- a/contracts/dao/extensions/actions/aibtc-action-pmt-stx-toggle-resource.clar +++ b/contracts/dao/extensions/actions/aibtc-action-pmt-stx-toggle-resource.clar @@ -1,11 +1,27 @@ +;; title: aibtc-action-pmt-stx-toggle-resource +;; version: 1.0.0 +;; summary: A predefined action to toggle a resource in the STX payment processor extension. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; template variables +;; (define-constant CFG_MESSAGE "Executed Action Proposal: Toggled resource status by name in the STX payment processor extension") +;; public functions +;; + (define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (run (parameters (buff 2048))) @@ -19,8 +35,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-send-message.clar b/contracts/dao/extensions/actions/aibtc-action-send-message.clar index d264728..fa4e47d 100644 --- a/contracts/dao/extensions/actions/aibtc-action-send-message.clar +++ b/contracts/dao/extensions/actions/aibtc-action-send-message.clar @@ -1,8 +1,21 @@ +;; title: aibtc-action-send-message +;; version: 1.0.0 +;; summary: A predefined action to send a message through the onchain messaging system. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) + +;; public functions +;; (define-public (callback (sender principal) (memo (buff 34))) (ok true)) @@ -16,8 +29,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/actions/aibtc-action-treasury-allow-asset.clar b/contracts/dao/extensions/actions/aibtc-action-treasury-allow-asset.clar index 740fdff..cbf45cf 100644 --- a/contracts/dao/extensions/actions/aibtc-action-treasury-allow-asset.clar +++ b/contracts/dao/extensions/actions/aibtc-action-treasury-allow-asset.clar @@ -1,10 +1,26 @@ +;; title: aibtc-action-treasury-allow-asset +;; version: 1.0.0 +;; summary: A predefined action to allow or enable an asset for use in the treasury. + +;; traits +;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.action) -(define-constant ERR_UNAUTHORIZED (err u10001)) -(define-constant ERR_INVALID_PARAMS (err u10002)) +;; constants +;; + +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u1100)) +(define-constant ERR_INVALID_PARAMS (err u1101)) -(define-constant CFG_MESSAGE "Executed Action Proposal: Allowed or enabled asset for use in the treasury") +;; template variables +;; + +(define-constant CFG_MESSAGE "Executed Action Proposal: Allowed or updated asset for use in the treasury") + +;; public functions +;; (define-public (callback (sender principal) (memo (buff 34))) (ok true)) @@ -19,8 +35,11 @@ ) ) +;; private functions +;; + (define-private (is-dao-or-extension) (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) - (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION )) ) diff --git a/contracts/dao/extensions/aibtc-dao-assets.clar b/contracts/dao/extensions/aibtc-dao-assets.clar new file mode 100644 index 0000000..fe34872 --- /dev/null +++ b/contracts/dao/extensions/aibtc-dao-assets.clar @@ -0,0 +1,71 @@ +;; title: aibtc-dao-assets +;; version: 1.0.0 +;; summary: An extension that tracks the allowed asset contracts for the DAO. + +;; traits +;; + +(impl-trait .aibtc-dao-traits-v3.extension) +;; TODO - add dao-assets trait (impl-trait .aibtc-dao-traits-v3.dao-assets) + +;; constants +;; + +;; contract details +(define-constant DEPLOYED_BURN_BLOCK burn-block-height) +(define-constant DEPLOYED_STACKS_BLOCK stacks-block-height) +(define-constant SELF (as-contract tx-sender)) + +;; error messages +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u8200)) ;; similar to dao-charter + +;; data maps +;; + +;; central tracking for DAO allowed assets +(define-map AllowedAssetContracts principal bool) + +;; public functions +;; + +(define-public (callback (sender principal) (memo (buff 34))) (ok true)) + +;; enable or disable asset on the allowed list +(define-public (configure-dao-asset (assetContract principal) (enabled bool)) + (begin + (try! (is-dao-or-extension)) + (print { + notification: "dao-assets-configure-dao-asset", + payload: { + assetContract: assetContract, + enabled: enabled, + contractCaller: contract-caller, + txSender: tx-sender + } + }) + (ok (map-set AllowedAssetContracts assetContract enabled)) + ) +) + +;; read only functions +;; + +;; returns boolean if the asset is allowed +(define-read-only (is-allowed-asset (assetContract principal)) + (default-to false (get-allowed-asset assetContract)) +) + +;; returns (some boolean) if the asset is registered or none if unknown +(define-read-only (get-allowed-asset (assetContract principal)) + (map-get? AllowedAssetContracts assetContract) +) + +;; private functions +;; + +;; returns ok if the caller is the DAO or an extension or err if not +(define-private (is-dao-or-extension) + (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION + )) +) \ No newline at end of file diff --git a/contracts/dao/extensions/aibtc-dao-charter.clar b/contracts/dao/extensions/aibtc-dao-charter.clar index 5ea9179..714e2ae 100644 --- a/contracts/dao/extensions/aibtc-dao-charter.clar +++ b/contracts/dao/extensions/aibtc-dao-charter.clar @@ -1,16 +1,19 @@ ;; title: aibtc-dao-charter ;; version: 1.0.0 ;; summary: An extension that manages the DAO charter and records the DAO's mission and values on-chain. -;; description: This contract allows the DAO to define its mission and values on-chain, which can be used to guide decision-making and proposals. -;; The charter is editable by the DAO through proposal with revisions stored on-chain. ;; traits ;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.charter) ;; constants ;; + +;; contract details +(define-constant DEPLOYED_BURN_BLOCK burn-block-height) +(define-constant DEPLOYED_STACKS_BLOCK stacks-block-height) (define-constant SELF (as-contract tx-sender)) ;; error codes @@ -21,11 +24,13 @@ ;; data vars ;; + (define-data-var daoCharter (string-ascii 4096) "") (define-data-var currentVersion uint u0) ;; data maps ;; + (define-map CharterVersions uint ;; version number { @@ -40,9 +45,8 @@ ;; public functions ;; -(define-public (callback (sender principal) (memo (buff 34))) - (ok true) -) + +(define-public (callback (sender principal) (memo (buff 34))) (ok true)) (define-public (set-dao-charter (charter (string-ascii 4096)) (inscriptionId (optional (buff 33)))) (let @@ -65,7 +69,7 @@ }) ERR_SAVING_CHARTER) ;; print charter info (print { - notification: "set-dao-charter", + notification: "dao-charter-set-dao-charter", payload: { burnHeight: burn-block-height, createdAt: stacks-block-height, diff --git a/contracts/dao/extensions/aibtc-dao-epoch.clar b/contracts/dao/extensions/aibtc-dao-epoch.clar new file mode 100644 index 0000000..1e24b2b --- /dev/null +++ b/contracts/dao/extensions/aibtc-dao-epoch.clar @@ -0,0 +1,38 @@ +;; title: aibtc-dao-epoch +;; version: 1.0.0 +;; summary: An extension that tracks the current epoch of the DAO. + +;; traits +;; + +(impl-trait .aibtc-dao-traits-v3.extension) +;; TODO - add dao-epoch trait (impl-trait .aibtc-dao-traits-v3.dao-epoch) + +;; constants +;; + +;; contract details +(define-constant DEPLOYED_BURN_BLOCK burn-block-height) +(define-constant DEPLOYED_STACKS_BLOCK stacks-block-height) +(define-constant SELF (as-contract tx-sender)) + +;; track epochs by BTC block height +(define-constant EPOCH_LENGTH u4320) ;; 30 days in BTC blocks + +;; public functions +;; + +(define-public (callback (sender principal) (memo (buff 34))) (ok true)) + +;; read only functions +;; + +;; returns the current epoch based on deployed burn block +(define-read-only (get-current-dao-epoch) + (/ (- burn-block-height DEPLOYED_BURN_BLOCK) EPOCH_LENGTH) +) + +;; returns the epoch length +(define-read-only (get-dao-epoch-length) + EPOCH_LENGTH +) diff --git a/contracts/dao/extensions/aibtc-dao-users.clar b/contracts/dao/extensions/aibtc-dao-users.clar new file mode 100644 index 0000000..e1d61af --- /dev/null +++ b/contracts/dao/extensions/aibtc-dao-users.clar @@ -0,0 +1,85 @@ +;; title: aibtc-dao-users +;; version: 1.0.0 +;; summary: An extension that tracks the current users and their reputation in the DAO. + +;; traits +;; + +(impl-trait .aibtc-dao-traits-v3.extension) +;; TODO - add dao-users trait (impl-trait .aibtc-dao-traits-v3.dao-users) + +;; constants +;; + +;; contract details +(define-constant DEPLOYED_BURN_BLOCK burn-block-height) +(define-constant DEPLOYED_STACKS_BLOCK stacks-block-height) +(define-constant SELF (as-contract tx-sender)) + +;; error messages +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u8100)) ;; similar to dao-charter + +;; data vars +;; + +(define-data-var userCount uint u0) ;; total number of users + +;; data maps +;; + +;; central tracking for DAO users +(define-map UserIndexes principal uint) +(define-map UserData + uint ;; user index + { + address: principal, + createdAt: uint, + reputation: int, ;; increases/decreases from proposal bonds + } +) + +;; public functions +;; + +(define-public (callback (sender principal) (memo (buff 34))) (ok true)) + +(define-public (get-or-create-user (address principal)) + (ok true) +) + +(define-public (update-user-reputation (address principal) (amount int)) + (ok true) +) + +;; read only functions +;; + +;; returns the unique user count +(define-read-only (get-user-count) + (var-get userCount) +) + +;; returns (some data) if the user exists or none if unknown +(define-read-only (get-user-index (address principal)) + (map-get? UserIndexes address) +) + +;; returns (some data) if the user exists or none if unknown +(define-read-only (get-user-data-by-index (userIndex uint)) + (map-get? UserData userIndex) +) + +;; returns (some data) if the user exists or none if unknown +(define-read-only (get-user-data-by-address (address principal)) + (get-user-data-by-index (unwrap! (get-user-index address) none)) +) + +;; private functions +;; + +;; returns ok if the caller is the DAO or an extension or err if not +(define-private (is-dao-or-extension) + (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION + )) +) \ No newline at end of file diff --git a/contracts/dao/extensions/aibtc-operating-fund.clar b/contracts/dao/extensions/aibtc-operating-fund.clar new file mode 100644 index 0000000..a27bbd4 --- /dev/null +++ b/contracts/dao/extensions/aibtc-operating-fund.clar @@ -0,0 +1,68 @@ +;; title: aibtc-operating-fund +;; version: 2.0.0 +;; summary: An operations fund for the dao with a 2% allocation of the total supply. + +;; TODO - remove notes +;; this contract receives 2% of total supply at launch +;; this contract can receive DAO token, sBTC or STX from treasury +;; this contract can fund a timed vault when initialized + +;; traits +;; + +(impl-trait .aibtc-dao-traits-v3.extension) +(impl-trait .aibtc-dao-traits-v3.operating-fund) + +(use-trait ft-trait 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard.sip-010-trait) + +;; constants +;; + +;; error messages +(define-constant ERR_NOT_DAO_OR_EXTENSION (err u10000)) +(define-constant ERR_UNKNOWN_ASSET (err u10001)) +(define-constant ERR_FETCHING_ASSET (err u10002)) + +;; contract details +(define-constant DEPLOYED_BURN_BLOCK burn-block-height) +(define-constant DEPLOYED_STACKS_BLOCK stacks-block-height) +(define-constant SELF (as-contract tx-sender)) + +;; track epochs by BTC block height +(define-constant EPOCH_BPS u5000) ;; 50% of own supply +(define-constant EPOCH_BPS_DIVISOR u10000) ;; 10000 BP = 100% + +;; template variables +;; +;; /g/find/replace + +;; data maps +;; + +;; track transfers per period +;; TODO - track amount instead of bool? +(define-map StxClaims + uint ;; period + uint ;; claimed amount +) +(define-map FtClaims + { contract: principal, period: uint } + uint ;; claimed amount +) + +;; public functions +;; + +(define-public (callback (sender principal) (memo (buff 34))) (ok true)) + +;; read only functions +;; + +;; private functions +;; + +(define-private (is-dao-or-extension) + (ok (asserts! (or (is-eq tx-sender .aibtc-base-dao) + (contract-call? .aibtc-base-dao is-extension contract-caller)) ERR_NOT_DAO_OR_EXTENSION + )) +) diff --git a/contracts/dao/extensions/aibtc-treasury.clar b/contracts/dao/extensions/aibtc-treasury.clar index 8a08c3f..a0a1426 100644 --- a/contracts/dao/extensions/aibtc-treasury.clar +++ b/contracts/dao/extensions/aibtc-treasury.clar @@ -1,43 +1,76 @@ ;; title: aibtc-treasury -;; version: 1.0.0 -;; summary: An extension that manages STX, SIP-009 NFTs, and SIP-010 FTs. +;; version: 2.0.0 +;; summary: A secure treasury contract that controls the funds of the DAO. ;; traits ;; + (impl-trait .aibtc-dao-traits-v3.extension) (impl-trait .aibtc-dao-traits-v3.treasury) (use-trait ft-trait 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard.sip-010-trait) -(use-trait nft-trait 'SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait.nft-trait) ;; constants ;; +;; error messages (define-constant ERR_NOT_DAO_OR_EXTENSION (err u6000)) -(define-constant ERR_UNKNOWN_ASSSET (err u6001)) -(define-constant TREASURY (as-contract tx-sender)) +(define-constant ERR_UNKNOWN_ASSET (err u6001)) +(define-constant ERR_FETCHING_ASSET (err u6002)) +(define-constant ERR_PERIOD_ALREADY_CLAIMED (err u6003)) + +;; contract details +(define-constant DEPLOYED_BURN_BLOCK burn-block-height) +(define-constant DEPLOYED_STACKS_BLOCK stacks-block-height) +(define-constant SELF (as-contract tx-sender)) + +;; track periods by BTC block height +(define-constant PERIOD_BPS u200) ;; 2% of own supply +(define-constant PERIOD_BPS_DIVISOR u10000) ;; 10000 BP = 100% +(define-constant PERIOD_LENGTH u4320) ;; 30 days in BTC blocks +(define-constant PERIOD_MIN_BTC u100) ;; 0.00000100 BTC or 100 sats (8 decimals) +(define-constant PERIOD_MIN_STX u1000000) ;; 1 STX (6 decimals) + +;; template variables +;; + +;; /g/STV9K21TBFAK4KNRJXF5DFP8N7W46G4V9RJ5XDY2.sbtc-token/sbtc_token_contract +(define-constant CFG_SBTC_TOKEN 'STV9K21TBFAK4KNRJXF5DFP8N7W46G4V9RJ5XDY2.sbtc-token) +;; /g/.aibtc-token/dao_token_contract +(define-constant CFG_DAO_TOKEN .aibtc-token) +;; /g/.aibtc-operating-fund/operating_fund_contract +(define-constant CFG_OPERATING_FUND .aibtc-operating-fund) ;; data maps ;; +;; track allowed assets for deposit/transfer (define-map AllowedAssets principal bool) +;; track transfers per period +(define-map StxClaims + uint ;; period + uint ;; claimed amount +) +(define-map FtClaims + { contract: principal, period: uint } + uint ;; claimed amount +) + ;; public functions ;; -(define-public (callback (sender principal) (memo (buff 34))) - (ok true) -) +(define-public (callback (sender principal) (memo (buff 34))) (ok true)) ;; add or update an asset to the allowed list (define-public (allow-asset (token principal) (enabled bool)) (begin (try! (is-dao-or-extension)) (print { - notification: "allow-asset", + notification: "treasury-allow-asset", payload: { - enabled: enabled, token: token, + enabled: enabled, contractCaller: contract-caller, txSender: tx-sender } @@ -46,139 +79,101 @@ ) ) -;; add or update a list of assets to the allowed list -(define-public (allow-assets (allowList (list 100 {token: principal, enabled: bool}))) - (begin - (try! (is-dao-or-extension)) - (map allow-assets-iter allowList) - (ok true) - ) -) - ;; deposit STX to the treasury -(define-public (deposit-stx (amount uint)) +(define-public (deposit-stx (amount uint)) (begin + ;; no auth - anyone can deposit (print { - notification: "deposit-stx", + notification: "treasury-deposit-stx", payload: { amount: amount, + recipient: SELF, contractCaller: contract-caller, - recipient: TREASURY, txSender: tx-sender, - balance: (stx-get-balance TREASURY) } }) - (stx-transfer? amount tx-sender TREASURY) + (stx-transfer? amount tx-sender SELF) ) ) ;; deposit FT to the treasury (define-public (deposit-ft (ft ) (amount uint)) (begin - (asserts! (is-allowed-asset (contract-of ft)) ERR_UNKNOWN_ASSSET) + ;; no auth - anyone can deposit if token allowed + (asserts! (is-allowed-asset (contract-of ft)) ERR_UNKNOWN_ASSET) (print { - notification: "deposit-ft", + notification: "treasury-deposit-ft", payload: { amount: amount, + recipient: SELF, assetContract: (contract-of ft), contractCaller: contract-caller, - recipient: TREASURY, txSender: tx-sender } }) - (contract-call? ft transfer amount tx-sender TREASURY none) + (contract-call? ft transfer amount tx-sender SELF none) ) ) -;; deposit NFT to the treasury -(define-public (deposit-nft (nft ) (id uint)) - (begin - (asserts! (is-allowed-asset (contract-of nft)) ERR_UNKNOWN_ASSSET) - (print { - notification: "deposit-nft", - payload: { - assetContract: (contract-of nft), - contractCaller: contract-caller, - recipient: TREASURY, - txSender: tx-sender, - tokenId: id - } - }) - (contract-call? nft transfer id tx-sender TREASURY) - ) -) - -;; withdraw STX from the treasury -(define-public (withdraw-stx (amount uint) (recipient principal)) - (begin +;; transfer STX from treasury to operating fund +(define-public (transfer-stx-to-operating-fund) + (let + ( + (amount (unwrap-panic (get-stx-claim-amount))) + ) (try! (is-dao-or-extension)) + (try! (update-claim-stx amount)) (print { - notification: "withdraw-stx", + notification: "treasury-transfer-stx-to-operating-fund", payload: { amount: amount, + recipient: CFG_OPERATING_FUND, contractCaller: contract-caller, - recipient: recipient, txSender: tx-sender, - balance: (stx-get-balance TREASURY) } }) - (as-contract (stx-transfer? amount TREASURY recipient)) + (as-contract (stx-transfer? amount SELF CFG_OPERATING_FUND)) ) ) -;; withdraw FT from the treasury -(define-public (withdraw-ft (ft ) (amount uint) (recipient principal)) - (begin - (try! (is-dao-or-extension)) - (asserts! (is-allowed-asset (contract-of ft)) ERR_UNKNOWN_ASSSET) - (print { - notification: "withdraw-ft", - payload: { - assetContract: (contract-of ft), - contractCaller: contract-caller, - recipient: recipient, - txSender: tx-sender, - amount: amount - } - }) - (as-contract (contract-call? ft transfer amount TREASURY recipient none)) - ) -) - -;; withdraw NFT from the treasury -(define-public (withdraw-nft (nft ) (id uint) (recipient principal)) - (begin +;; transfer FT from treasury to operating fund +(define-public (transfer-ft-to-operating-fund (ft )) + (let + ( + (assetContract (contract-of ft)) + (amount (try! (get-ft-claim-amount ft))) + ) (try! (is-dao-or-extension)) - (asserts! (is-allowed-asset (contract-of nft)) ERR_UNKNOWN_ASSSET) + (asserts! (is-allowed-asset assetContract) ERR_UNKNOWN_ASSET) + (try! (update-claim-ft amount assetContract)) (print { - notification: "withdraw-nft", + notification: "treasury-transfer-ft-to-operating-fund", payload: { - assetContract: (contract-of nft), + amount: amount, + recipient: CFG_OPERATING_FUND, + assetContract: assetContract, contractCaller: contract-caller, - recipient: recipient, txSender: tx-sender, - tokenId: id, - amount: u1 } }) - (as-contract (contract-call? nft transfer id TREASURY recipient)) + (as-contract (contract-call? ft transfer amount SELF CFG_OPERATING_FUND none)) ) ) ;; delegate STX for stacking -(define-public (delegate-stx (maxAmount uint) (to principal)) +(define-public (delegate-stx (maxAmount uint) (delegateTo principal)) (begin (try! (is-dao-or-extension)) (print { - notification: "delegate-stx", + notification: "treasury-delegate-stx", payload: { - amount: maxAmount, + maxAmount: maxAmount, + delegateTo: delegateTo, contractCaller: contract-caller, - delegate: to, txSender: tx-sender } }) - (match (as-contract (contract-call? 'SP000000000000000000002Q6VF78.pox-4 delegate-stx maxAmount to none none)) + (match (as-contract (contract-call? 'SP000000000000000000002Q6VF78.pox-4 delegate-stx maxAmount delegateTo none none)) success (ok success) err (err (to-uint err)) ) @@ -190,7 +185,7 @@ (begin (try! (is-dao-or-extension)) (print { - notification: "revoke-delegate-stx", + notification: "treasury-revoke-delegate-stx", payload: { contractCaller: contract-caller, txSender: tx-sender @@ -214,6 +209,48 @@ (map-get? AllowedAssets assetContract) ) +(define-read-only (get-current-period) + (/ (- burn-block-height DEPLOYED_BURN_BLOCK) PERIOD_LENGTH) +) + +(define-read-only (get-claim-stx (period uint)) + (map-get? StxClaims period) +) + +(define-read-only (get-claim-ft (period uint) (assetContract principal) ) + (map-get? FtClaims { contract: assetContract, period: period }) +) + +;; TODO: consider splitting dynamic/static info, easier to cache on client side +(define-read-only (get-contract-info) + (let + ( + (currentPeriod (get-current-period)) + (lastPeriod (if (> currentPeriod u0) (- currentPeriod u1) u0)) + ) + ;; return contract info object + { + self: SELF, + deployedBurnBlock: DEPLOYED_BURN_BLOCK, + deployedStacksBlock: DEPLOYED_STACKS_BLOCK, + periodBps: PERIOD_BPS, + periodLength: PERIOD_LENGTH, + lastPeriod: { + period: lastPeriod, + btcClaimed: (get-claim-ft lastPeriod CFG_SBTC_TOKEN), + daoClaimed: (get-claim-ft lastPeriod CFG_DAO_TOKEN), + stxClaimed: (get-claim-stx lastPeriod), + }, + currentPeriod: { + period: currentPeriod, + btcClaimed: (get-claim-ft currentPeriod CFG_SBTC_TOKEN), + daoClaimed: (get-claim-ft currentPeriod CFG_DAO_TOKEN), + stxClaimed: (get-claim-stx currentPeriod), + }, + } + ) +) + ;; private functions ;; @@ -223,18 +260,75 @@ )) ) -(define-private (allow-assets-iter (item {token: principal, enabled: bool})) +;; helper that will update the claim status for STX +;; and error if the period was already claimed +(define-private (update-claim-stx (amount uint)) + (begin + (print { + notification: "treasury-update-claim-stx", + payload: { + period: (get-current-period), + claimed: true, + contractCaller: contract-caller, + txSender: tx-sender + } + }) + (ok (asserts! + (map-insert StxClaims (get-current-period) amount) + ERR_PERIOD_ALREADY_CLAIMED + )) + ) +) + +;; helper that will return 2% of the current balance for STX +(define-private (get-stx-claim-amount) + (let + ( + (balance (stx-get-balance SELF)) + (claimAmount (/ (* balance PERIOD_BPS) u10000)) + ) + (if (< claimAmount PERIOD_MIN_STX) + (ok PERIOD_MIN_STX) ;; 1 STX minimum + (ok claimAmount) ;; 2% of balance + ) + ) +) + +;; helper that will update the claim status for FT +;; and error if the period was already claimed +(define-private (update-claim-ft (amount uint) (assetContract principal)) (begin (print { - notification: "allow-asset", + notification: "treasury-update-claim-ft", payload: { - enabled: (get enabled item), - token: (get token item), + period: (get-current-period), + claimed: true, contractCaller: contract-caller, txSender: tx-sender } }) - (map-set AllowedAssets (get token item) (get enabled item)) + (ok (asserts! + (map-insert FtClaims { contract: contract-caller, period: (get-current-period) } amount) + ERR_PERIOD_ALREADY_CLAIMED + )) ) ) +;; helper that will return 2% of the current balance for FT +(define-private (get-ft-claim-amount (ft )) + (let + ( + (balance (unwrap! (contract-call? ft get-balance SELF) ERR_FETCHING_ASSET)) + (decimals (unwrap! (contract-call? ft get-decimals) ERR_FETCHING_ASSET)) + (minAmount (if (is-eq (contract-of ft) CFG_SBTC_TOKEN) + PERIOD_MIN_BTC ;; 100 sats, specific to BTC + (pow u10 decimals) ;; 1 whole FT minimum otherwise + )) + (claimAmount (/ (* balance PERIOD_BPS) u10000)) + ) + (if (< claimAmount minAmount) + (ok minAmount) ;; 1 FT minimum + (ok claimAmount) ;; 2% of balance + ) + ) +) diff --git a/contracts/dao/proposals/aibtc-timed-vault-dao-initialize-new-vault.clar b/contracts/dao/proposals/aibtc-timed-vault-dao-initialize-new-vault.clar index 7c298f9..0177211 100644 --- a/contracts/dao/proposals/aibtc-timed-vault-dao-initialize-new-vault.clar +++ b/contracts/dao/proposals/aibtc-timed-vault-dao-initialize-new-vault.clar @@ -16,7 +16,7 @@ (try! (contract-call? .aibtc-base-dao set-extension .aibtc-timed-vault-dao true)) ;; fund the extension from the treasury (and (> CFG_AMOUNT_TO_FUND_DAO u0) - (try! (contract-call? .aibtc-treasury withdraw-ft .aibtc-token CFG_AMOUNT_TO_FUND_DAO .aibtc-timed-vault-dao))) + (try! (contract-call? .aibtc-treasury withdraw-ft .aibtc-token CFG_AMOUNT_TO_FUND_DAO))) (ok true) ) ) diff --git a/contracts/dao/proposals/aibtc-timed-vault-sbtc-initialize-new-vault.clar b/contracts/dao/proposals/aibtc-timed-vault-sbtc-initialize-new-vault.clar index eb14796..5238962 100644 --- a/contracts/dao/proposals/aibtc-timed-vault-sbtc-initialize-new-vault.clar +++ b/contracts/dao/proposals/aibtc-timed-vault-sbtc-initialize-new-vault.clar @@ -16,7 +16,7 @@ (try! (contract-call? .aibtc-base-dao set-extension .aibtc-timed-vault-sbtc true)) ;; fund the extension from the treasury (and (> CFG_AMOUNT_TO_FUND_SBTC u0) - (try! (contract-call? .aibtc-treasury withdraw-ft 'STV9K21TBFAK4KNRJXF5DFP8N7W46G4V9RJ5XDY2.sbtc-token CFG_AMOUNT_TO_FUND_SBTC .aibtc-timed-vault-sbtc))) + (try! (contract-call? .aibtc-treasury withdraw-ft 'STV9K21TBFAK4KNRJXF5DFP8N7W46G4V9RJ5XDY2.sbtc-token CFG_AMOUNT_TO_FUND_SBTC))) (ok true) ) ) diff --git a/contracts/dao/proposals/aibtc-timed-vault-stx-initialize-new-vault.clar b/contracts/dao/proposals/aibtc-timed-vault-stx-initialize-new-vault.clar index 8354ac6..7148c3f 100644 --- a/contracts/dao/proposals/aibtc-timed-vault-stx-initialize-new-vault.clar +++ b/contracts/dao/proposals/aibtc-timed-vault-stx-initialize-new-vault.clar @@ -17,9 +17,9 @@ (try! (contract-call? .aibtc-base-dao set-extension .aibtc-timed-vault-stx true)) ;; CFG_BASE_DAO, CFG_NEW_TIMED_VAULT_CONTRACT ;; fund the extension from the treasury (and (> CFG_AMOUNT_TO_FUND_STX u0) - (try! (contract-call? .aibtc-treasury withdraw-stx CFG_AMOUNT_TO_FUND_STX .aibtc-timed-vault-stx))) ;; CFG_TREASURY_CONTRACT, CFG_NEW_TIMED_VAULT_CONTRACT + (try! (contract-call? .aibtc-treasury withdraw-stx CFG_AMOUNT_TO_FUND_STX))) ;; CFG_TREASURY_CONTRACT, CFG_NEW_TIMED_VAULT_CONTRACT (and (> CFG_AMOUNT_TO_FUND_FT u0) - (try! (contract-call? .aibtc-treasury withdraw-ft .aibtc-token CFG_AMOUNT_TO_FUND_FT .aibtc-timed-vault-stx))) ;; CFG_TREASURY_CONTRACT, CFG_TOKEN_CONTRACT, CFG_NEW_TIMED_VAULT_CONTRACT + (try! (contract-call? .aibtc-treasury withdraw-ft .aibtc-token CFG_AMOUNT_TO_FUND_FT))) ;; CFG_TREASURY_CONTRACT, CFG_TOKEN_CONTRACT, CFG_NEW_TIMED_VAULT_CONTRACT (ok true) ) ) diff --git a/contracts/dao/proposals/aibtc-treasury-withdraw-ft.clar b/contracts/dao/proposals/aibtc-treasury-withdraw-ft.clar index 84fab03..4276573 100644 --- a/contracts/dao/proposals/aibtc-treasury-withdraw-ft.clar +++ b/contracts/dao/proposals/aibtc-treasury-withdraw-ft.clar @@ -4,16 +4,12 @@ ;; (define-constant CFG_MESSAGE "Executed Core Proposal: Withdrew fungible tokens in the treasury extension") (define-constant CFG_TOKEN_AMOUNT u1000) ;; in microFT -(define-constant CFG_RECIPIENT 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM) -;; was CFG_MESSAGE_CONTRACT .aibtc-onchain-messaging -;; was CFG_TREASURY_CONTRACT .aibtc-treasury -;; was CFG_TOKEN_CONTRACT .aibtc-token (define-public (execute (sender principal)) (begin ;; send a message from the dao (try! (contract-call? .aibtc-onchain-messaging send CFG_MESSAGE true)) ;; withdraw fungible tokens from the treasury - (contract-call? .aibtc-treasury withdraw-ft .aibtc-token CFG_TOKEN_AMOUNT CFG_RECIPIENT) + (contract-call? .aibtc-treasury withdraw-ft .aibtc-token CFG_TOKEN_AMOUNT) ) ) diff --git a/contracts/dao/proposals/aibtc-treasury-withdraw-stx.clar b/contracts/dao/proposals/aibtc-treasury-withdraw-stx.clar index 9dd4575..e74cf98 100644 --- a/contracts/dao/proposals/aibtc-treasury-withdraw-stx.clar +++ b/contracts/dao/proposals/aibtc-treasury-withdraw-stx.clar @@ -4,15 +4,12 @@ ;; (define-constant CFG_MESSAGE "Executed Core Proposal: Withdrew STX in the treasury extension") (define-constant CFG_STX_AMOUNT u1000000) ;; in microSTX -(define-constant CFG_RECIPIENT 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM) -;; was CFG_MESSAGE_CONTRACT .aibtc-onchain-messaging -;; was CFG_TREASURY_CONTRACT .aibtc-treasury (define-public (execute (sender principal)) (begin ;; send a message from the dao (try! (contract-call? .aibtc-onchain-messaging send CFG_MESSAGE true)) ;; withdraw STX from the treasury - (contract-call? .aibtc-treasury withdraw-stx CFG_STX_AMOUNT CFG_RECIPIENT) + (contract-call? .aibtc-treasury withdraw-stx CFG_STX_AMOUNT) ) ) diff --git a/contracts/dao/traits/aibtc-dao-traits-v3.clar b/contracts/dao/traits/aibtc-dao-traits-v3.clar index e35b70c..9088a65 100644 --- a/contracts/dao/traits/aibtc-dao-traits-v3.clar +++ b/contracts/dao/traits/aibtc-dao-traits-v3.clar @@ -1,5 +1,5 @@ ;; title: aibtc-dao-traits -;; version: 3.0.0 +;; version: 3.1.0 ;; summary: A collection of traits for all aibtc daos. ;; IMPORTS @@ -206,10 +206,6 @@ ;; @param enabled whether the asset is allowed ;; @returns (response bool uint) (allow-asset (principal bool) (response bool uint)) - ;; allow multiple assets for deposit/withdrawal - ;; @param allowList a list of asset contracts and enabled status - ;; @returns (response bool uint) - (allow-assets ((list 100 {token:principal,enabled:bool})) (response bool uint)) ;; deposit STX to the treasury ;; @param amount amount of microSTX to deposit ;; @returns (response bool uint) @@ -219,28 +215,13 @@ ;; @param amount amount of tokens to deposit ;; @returns (response bool uint) (deposit-ft ( uint) (response bool uint)) - ;; deposit NFT to the treasury - ;; @param nft the non-fungible token contract principal - ;; @param id the ID of the token to deposit - ;; @returns (response bool uint) - (deposit-nft ( uint) (response bool uint)) - ;; withdraw STX from the treasury - ;; @param amount amount of microSTX to withdraw - ;; @param recipient the recipient of the STX + ;; transfer STX from treasury to operating fund ;; @returns (response bool uint) - (withdraw-stx (uint principal) (response bool uint)) - ;; withdraw FT from the treasury + (transfer-stx-to-operating-fund () (response bool uint)) + ;; transfer FT from treasury to operating fund ;; @param ft the fungible token contract principal - ;; @param amount amount of tokens to withdraw - ;; @param recipient the recipient of the tokens - ;; @returns (response bool uint) - (withdraw-ft ( uint principal) (response bool uint)) - ;; withdraw NFT from the treasury - ;; @param nft the non-fungible token contract principal - ;; @param id the ID of the token to withdraw - ;; @param recipient the recipient of the token ;; @returns (response bool uint) - (withdraw-nft ( uint principal) (response bool uint)) + (transfer-ft-to-operating-fund () (response bool uint)) ;; delegate STX for stacking in PoX ;; @param amount max amount of microSTX that can be delegated ;; @param to the address to delegate to diff --git a/contracts/test/aibtc-treasury.clar b/contracts/test/aibtc-treasury.clar index d62b857..149980e 100644 --- a/contracts/test/aibtc-treasury.clar +++ b/contracts/test/aibtc-treasury.clar @@ -1,5 +1,5 @@ ;; test treasury contract implementing treasury trait -(impl-trait .aibtcdev-dao-traits-v1.treasury) +;; (impl-trait .aibtcdev-dao-traits-v1.treasury) (impl-trait .aibtc-dao-traits-v3.treasury) (use-trait ft-trait 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard.sip-010-trait) @@ -29,11 +29,11 @@ (ok true) ) -(define-public (withdraw-stx (amount uint) (recipient principal)) +(define-public (withdraw-stx (amount uint)) (ok true) ) -(define-public (withdraw-ft (ft ) (amount uint) (recipient principal)) +(define-public (withdraw-ft (ft ) (amount uint)) (ok true) ) diff --git a/tests/error-codes.ts b/tests/error-codes.ts index ff767ef..c27b762 100644 --- a/tests/error-codes.ts +++ b/tests/error-codes.ts @@ -41,7 +41,7 @@ export enum ActionProposalsV2ErrCode { } export enum ActionErrCode { - ERR_UNAUTHORIZED = 10001, + ERR_UNAUTHORIZED = 1100, ERR_INVALID_PARAMS, } @@ -113,7 +113,9 @@ export enum PaymentProcessorErrCode { export enum TreasuryErrCode { ERR_NOT_DAO_OR_EXTENSION = 6000, - ERR_UNKNOWN_ASSSET, + ERR_UNKNOWN_ASSET, + ERR_FETCHING_ASSET, + ERR_PERIOD_ALREADY_CLAIMED, } export enum TokenOwnerErrCode { @@ -127,6 +129,23 @@ export enum DaoCharterErrCode { ERR_CHARTER_TOO_LONG, } +export enum UserAgentAccountErrCode { + ERR_UNAUTHORIZED = 9000, + ERR_UNKNOWN_ASSET, + ERR_OPERATION_FAILED, + ERR_BUY_SELL_NOT_ALLOWED, +} + +export enum OperatingFundErrCode { + ERR_NOT_DAO_OR_EXTENSION = 10000, + ERR_UNKNOWN_ASSET, + ERR_FETCHING_ASSET, +} + +export enum DaoRegistryErrCode { + ERR_NOT_DAO_OR_EXTENSION = 11000, +} + export enum TokenFaktoryErrCode { ERR_NOT_AUTHORIZED = 401, ERR_NOT_OWNER, @@ -141,10 +160,3 @@ export enum TokenFaktoryDexErrCode { ERR_FETCHING_SELL_INFO, ERR_TOKEN_NOT_AUTH = 401, } - -export enum UserAgentAccountErrCode { - ERR_UNAUTHORIZED = 9000, - ERR_UNKNOWN_ASSET, - ERR_OPERATION_FAILED, - ERR_BUY_SELL_NOT_ALLOWED, -}