Skip to content

Commit 8a37640

Browse files
working
1 parent cd5221a commit 8a37640

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

clarity/contracts/auto-token/auto-alex-v3-1-endpoint.clar

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@
121121
(let (
122122
(current-cycle (unwrap! (get-reward-cycle block-height) ERR-STAKING-NOT-AVAILABLE))
123123
(start-cycle (get-start-cycle))
124-
(check-start-cycle (asserts! (<= start-cycle current-cycle) ERR-NOT-ACTIVATED))
125-
(auto-alex-v2-bal (unwrap-panic (contract-call? .auto-alex-v2 get-balance-fixed .auto-alex-v3-1)))
126-
(auto-alex-v3-wrapped-bal (unwrap-panic (contract-call? .auto-alex-v3-1-wrapped get-balance-fixed .auto-alex-v3-1))))
124+
(check-start-cycle (asserts! (<= start-cycle current-cycle) ERR-NOT-ACTIVATED)))
125+
;; (auto-alex-v2-bal (unwrap-panic (contract-call? .auto-alex-v2 get-balance-fixed .auto-alex-v3-1)))
126+
;; (auto-alex-v3-wrapped-bal (unwrap-panic (contract-call? .auto-alex-v3-1-wrapped get-balance-fixed .auto-alex-v3-1))))
127127
(and (> current-cycle start-cycle) (not (is-cycle-staked (- current-cycle u1))) (try! (claim-and-stake (- current-cycle u1))))
128128
;; (print { notification: "next-base", payload: {
129129
;; ;; amount-staked: (get amount-staked (as-contract (get-staker-at-cycle (+ current-cycle u1)))),
@@ -178,12 +178,8 @@
178178
(sender tx-sender))
179179
(asserts! (> dx u0) ERR-INVALID-LIQUIDITY)
180180
(asserts! (not (is-create-paused)) ERR-PAUSED)
181-
182-
;; transfer dx to contract to stake for max cycles
183181
(try! (contract-call? .age000-governance-token transfer-fixed dx sender .auto-alex-v3-1 none))
184182
(try! (fold stake-tokens-iter REWARD-CYCLE-INDEXES (ok { current-cycle: current-cycle, remaining: dx })))
185-
186-
;; mint pool token and send to tx-sender
187183
(as-contract (try! (contract-call? .auto-alex-v3-1 mint-fixed dx sender)))
188184
(print { notification: "position-added", payload: { new-supply: dx } })
189185
(rebase)))
@@ -197,12 +193,8 @@
197193
(asserts! (> intrinsic-dx u0) ERR-INVALID-LIQUIDITY)
198194
(asserts! (not (is-create-paused)) ERR-PAUSED)
199195
(asserts! (< end-cycle-v2 (+ current-cycle u32)) ERR-END-CYCLE-V2) ;; auto-alex-v2 is not configured correctly
200-
201-
;; transfer dx to contract to stake for max cycles
202196
(try! (contract-call? .auto-alex-v2 transfer-fixed dx sender .auto-alex-v3-1 none))
203197
(and (< end-cycle-v2 current-cycle) (begin (as-contract (try! (reduce-position-v2))) true))
204-
205-
;; mint pool token and send to tx-sender
206198
(as-contract (try! (contract-call? .auto-alex-v3-1 mint-fixed intrinsic-dx sender)))
207199
(print { notification: "upgrade-position-added", payload: { new-supply: intrinsic-dx } })
208200
(rebase)))

clarity/tests/auto-alex-v3_test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Clarinet.test({
3333
result.expectOk();
3434
result = alexToken.mintFixed(deployer, wallet_3.address, dx);
3535
result.expectOk();
36+
result = alexToken.mintFixed(deployer, wallet_4.address, dx);
37+
result.expectOk();
3638

3739
let block = chain.mineBlock([
3840
Tx.contractCall(
@@ -50,11 +52,11 @@ Clarinet.test({
5052
reservePool.setCoinbaseAmount(
5153
deployer,
5254
alexTokenAddress,
53-
0,
54-
0,
55-
0,
56-
0,
57-
0
55+
1e8,
56+
1e8,
57+
1e8,
58+
1e8,
59+
1e8
5860
),
5961
yieldVault.setStartCycle(deployer, 0),
6062
yieldVault.setBountyInFixed(deployer, 1),
@@ -123,17 +125,19 @@ Clarinet.test({
123125

124126
block = chain.mineBlock([
125127
Tx.contractCall('auto-alex-v3-1-endpoint', 'rebase', [], deployer.address),
126-
Tx.contractCall('auto-alex-v3-1-endpoint', 'revoke-redeem', [types.uint(3)], wallet_3.address),
128+
Tx.contractCall('auto-alex-v3-1-endpoint', 'revoke-redeem', [types.uint(3)], wallet_3.address),
127129
]);
128130
console.log(block.receipts[0].events);
129131
block.receipts[0].result.expectOk();
130132
block.receipts[1].result.expectErr(10019);
131133

132134
console.log(chain.callReadOnlyFn('age000-governance-token', 'get-balance-fixed', [types.principal(deployer.address + '.auto-alex-v3-1')], wallet_1.address));
133135
console.log(chain.callReadOnlyFn('auto-alex-v3-1-endpoint', 'get-redeem-request-or-fail', [types.uint(2)], wallet_1.address).result);
136+
console.log(chain.callReadOnlyFn('auto-alex-v3-1-endpoint', 'get-redeem-request-or-fail', [types.uint(3)], wallet_1.address).result);
134137
console.log(chain.callReadOnlyFn('auto-alex-v3-1-endpoint', 'get-intrinsic', [], wallet_1.address));
135138

136139
block = chain.mineBlock([
140+
Tx.contractCall('auto-alex-v3-1-endpoint', 'finalize-redeem', [types.uint(3)], wallet_3.address),
137141
Tx.contractCall('auto-alex-v3-1-endpoint', 'finalize-redeem', [types.uint(2)], wallet_2.address),
138142
]);
139143
block.receipts.forEach(e => { e.result.expectOk() });

0 commit comments

Comments
 (0)