Skip to content
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

CCIP-019 PoX-4 Stacking #67

Closed
wants to merge 11 commits into from
Closed
11 changes: 1 addition & 10 deletions .github/workflows/test-contracts.yaml
friedger marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ jobs:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Check contract syntax"
uses: docker://hirosystems/clarinet:1.8.0
uses: docker://hirosystems/clarinet:2.6.0
with:
args: check
- name: "Run all contract tests"
uses: docker://hirosystems/clarinet:1.8.0
with:
args: test --coverage
- name: "Upload code coverage"
uses: codecov/codecov-action@v4
with:
files: ./coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}
33 changes: 24 additions & 9 deletions Clarinet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ path = "contracts/extensions/ccd002-treasury.clar"
[contracts.ccd002-treasury-mia-mining-v2]
path = "contracts/extensions/ccd002-treasury-v2.clar"

# [contracts.ccd002-treasury-mia-mining-v3]
# path = "contracts/extensions/ccd002-treasury-v3.clar"
[contracts.ccd002-treasury-mia-mining-v3]
path = "contracts/extensions/ccd002-treasury-v3.clar"
clarity_version = 2
epoch = 2.5

[contracts.ccd002-treasury-mia-stacking]
path = "contracts/extensions/ccd002-treasury.clar"
Expand All @@ -104,8 +106,10 @@ path = "contracts/extensions/ccd002-treasury.clar"
[contracts.ccd002-treasury-nyc-mining-v2]
path = "contracts/extensions/ccd002-treasury-v2.clar"

# [contracts.ccd002-treasury-nyc-mining-v3]
# path = "contracts/extensions/ccd002-treasury-v3.clar"
[contracts.ccd002-treasury-nyc-mining-v3]
path = "contracts/extensions/ccd002-treasury-v3.clar"
clarity_version = 2
epoch = 2.5
friedger marked this conversation as resolved.
Show resolved Hide resolved

[contracts.ccd002-treasury-nyc-stacking]
path = "contracts/extensions/ccd002-treasury.clar"
Expand Down Expand Up @@ -140,6 +144,11 @@ path = "contracts/extensions/ccd010-core-v2-adapter.clar"
[contracts.ccd011-stacking-payouts]
path = "contracts/extensions/ccd011-stacking-payouts.clar"

[contracts.ccip019-rewards-treasury]
path = "contracts/extensions/ccip019-rewards-treasury.clar"
clarity_version = 2
epoch = 2.5
friedger marked this conversation as resolved.
Show resolved Hide resolved

[contracts.ccip012-bootstrap]
path = "contracts/proposals/ccip012-bootstrap.clar"

Expand Down Expand Up @@ -174,6 +183,11 @@ path = "contracts/proposals/ccip021-extend-sunset-period-2.clar"
clarity_version = 2
epoch = 2.4

[contracts.ccip019-pox-4-stacking]
path = "contracts/proposals/ccip019-pox-4-stacking.clar"
clarity_version = 2
epoch = 2.5

# CITYCOINS PROTOCOL TRAITS

[contracts.extension-trait]
Expand All @@ -197,6 +211,12 @@ path = "contracts/traits/ccd007-trait.clar"
[contracts.ccip015-trait]
path = "contracts/traits/ccip015-trait.clar"

[contracts.ccip019-proxy-trait]
path = "contracts/traits/ccip019-proxy-trait.clar"
clarity_version = 2
epoch = 2.5
friedger marked this conversation as resolved.
Show resolved Hide resolved


# CITYCOINS EXTERNAL CONTRACTS

[contracts.citycoin-vrf-v2]
Expand Down Expand Up @@ -517,11 +537,6 @@ path = "tests/contracts/proposals/test-ccip014-pox-3-001.clar"
[contracts.test-ccip014-pox-3-002]
path = "tests/contracts/proposals/test-ccip014-pox-3-002.clar"

[contracts.test-ccip020-shutdown-001]
path = "tests/contracts/proposals/test-ccip020-shutdown-001.clar"
clarity_version = 2
epoch = 2.4
friedger marked this conversation as resolved.
Show resolved Hide resolved

[repl]
costs_version = 2
parser_version = 2
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/ccd002-treasury-v3.clar
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
;; MAINNET: 'SP000000000000000000002Q6VF78.pox-4
;; TESTNET: 'ST000000000000000000002AMW42H.pox-4
(match (as-contract (contract-call? 'ST000000000000000000002AMW42H.pox-4 revoke-delegate-stx))
success (ok success)
success (begin (print success) (ok true))
err (err (to-uint err))
)
)
Expand Down
35 changes: 35 additions & 0 deletions contracts/extensions/ccip019-rewards-treasury.clar
friedger marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

friedger marked this conversation as resolved.
Show resolved Hide resolved
(use-trait proxy-trait .ccip019-proxy-trait.proxy-trait)
(use-trait sip-010-trait 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard.sip-010-trait)

(define-constant ERR_UNAUTHORIZED (err u10000))
friedger marked this conversation as resolved.
Show resolved Hide resolved

(define-public (is-dao-or-extension)
(ok (asserts! (or (is-eq tx-sender .base-dao)
(contract-call? .base-dao is-extension contract-caller)) ERR_UNAUTHORIZED
))
)

(define-public (stx-transfer (amount uint) (recipient principal) (memo (optional (buff 34))))
friedger marked this conversation as resolved.
Show resolved Hide resolved
(begin
(try! (is-dao-or-extension))
(as-contract (match memo
to-print (stx-transfer-memo? amount tx-sender recipient to-print)
(stx-transfer? amount tx-sender recipient)
))
)
)

(define-public (sip010-transfer (amount uint) (recipient principal) (memo (optional (buff 34))) (sip010 <sip-010-trait>))
friedger marked this conversation as resolved.
Show resolved Hide resolved
(begin
(try! (is-dao-or-extension))
(contract-call? sip010 transfer amount (as-contract tx-sender) recipient memo)
)
)

(define-public (proxy-call (proxy <proxy-trait>) (payload (buff 2048)))
friedger marked this conversation as resolved.
Show resolved Hide resolved
(begin
(try! (is-dao-or-extension))
(as-contract (contract-call? proxy proxy-call payload))
)
)
67 changes: 67 additions & 0 deletions contracts/proposals/ccip019-pox-4-stacking.clar
whoabuddy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
;; TRAITS

(impl-trait .proposal-trait.proposal-trait)

;; ERRORS

(define-constant ERR_PANIC (err u1400))

;; CONSTANTS

(define-constant SELF (as-contract tx-sender))
(define-constant CCIP_019 {
name: "PoX-4 Stacking",
link: "",
friedger marked this conversation as resolved.
Show resolved Hide resolved
hash: "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be the hash of citycoins/governance#35 CCIP md file once ready.

})


;; PUBLIC FUNCTIONS

(define-public (execute (sender principal))
(let
(
(miaId (unwrap! (contract-call? .ccd004-city-registry get-city-id "mia") ERR_PANIC))
(nycId (unwrap! (contract-call? .ccd004-city-registry get-city-id "nyc") ERR_PANIC))
(miaBalance (contract-call? .ccd002-treasury-mia-mining-v2 get-balance-stx))
(nycBalance (contract-call? .ccd002-treasury-nyc-mining-v2 get-balance-stx))
friedger marked this conversation as resolved.
Show resolved Hide resolved
)

;; enable new treasuries in the DAO
(try! (contract-call? .base-dao set-extensions
(list
{extension: .ccd002-treasury-mia-mining-v3, enabled: true}
{extension: .ccd002-treasury-nyc-mining-v3, enabled: true}
{extension: .ccd012-rewards-treasury, enabled: true}
friedger marked this conversation as resolved.
Show resolved Hide resolved
)
))

;; allow MIA/NYC in respective treasuries
;; MAINNET: 'SP1H1733V5MZ3SZ9XRW9FKYGEZT0JDGEB8Y634C7R.miamicoin-token-v2
;; MAINNET: 'SPSCWDV3RKV5ZRN1FQD84YE1NQFEDJ9R1F4DYQ11.newyorkcitycoin-token-v2
(try! (contract-call? .ccd002-treasury-mia-mining-v3 set-allowed 'ST1H1733V5MZ3SZ9XRW9FKYGEZT0JDGEB8WRH7C6H.miamicoin-token-v2 true))
(try! (contract-call? .ccd002-treasury-nyc-mining-v3 set-allowed 'STSCWDV3RKV5ZRN1FQD84YE1NQFEDJ9R1D64KKHQ.newyorkcitycoin-token-v2 true))
friedger marked this conversation as resolved.
Show resolved Hide resolved

;; transfer funds to new treasury extensions
(try! (contract-call? .ccd002-treasury-mia-mining-v2 withdraw-stx miaBalance .ccd002-treasury-mia-mining-v3))
(try! (contract-call? .ccd002-treasury-nyc-mining-v2 withdraw-stx nycBalance .ccd002-treasury-nyc-mining-v3))
friedger marked this conversation as resolved.
Show resolved Hide resolved

;; delegate stack the STX in the mining treasuries (up to 50M STX each)
;; MAINNET: SP21YTSM60CAY6D011EZVEVNKXVW8FVZE198XEFFP.pox4-fast-pool-v3
;; MAINNET: SP21YTSM60CAY6D011EZVEVNKXVW8FVZE198XEFFP.pox4-fast-pool-v3
(try! (contract-call? .ccd002-treasury-mia-mining-v3 delegate-stx u50000000000000 'ST1XQXW9JNQ1W4A7PYTN3HCHPEY7SHM6KPA085ES6))
(try! (contract-call? .ccd002-treasury-nyc-mining-v3 delegate-stx u50000000000000 'ST1XQXW9JNQ1W4A7PYTN3HCHPEY7SHM6KPA085ES6))

;; add treasuries to ccd005-city-data
(try! (contract-call? .ccd005-city-data add-treasury miaId .ccd002-treasury-mia-mining-v3 "mining-v2"))
(try! (contract-call? .ccd005-city-data add-treasury nycId .ccd002-treasury-nyc-mining-v3 "mining-v2"))
friedger marked this conversation as resolved.
Show resolved Hide resolved

(ok true)
)
)

;; READ ONLY FUNCTIONS

(define-read-only (get-proposal-info)
(some CCIP_019)
)
3 changes: 3 additions & 0 deletions contracts/traits/ccip019-proxy-trait.clar
friedger marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(define-trait proxy-trait
((proxy-call ((buff 2048)) (response bool uint)))
)