Skip to content

Commit 59407c9

Browse files
fiftyeightandeightzhigang1992caoer
authored
amm-swap-pool-helper: assert pool does not exist (#773)
* merge non-breaking dev to main (#707) * feat: swap-helper-bridged-v1-1 (#686) * feat: add deps * feat: flash-loan susdt-xusd (#687) * Feat/flash loan susdt xusd (#688) * feat: flash-loan susdt-xusd * flashloan user added * conflict fixed * feat: launchpad v1-03 (#689) * chore: ordinals-bluewheel (#690) * feat: launchpad v1-03 * chore: ordinals-bluewheel * feat: event-claim-helper * feat: event claim helper (#692) * TODO: test suite * feat: event claim helper (#693) * working * working; * TODO: test suite * test working * working * feat: event claim helper (#694) * Update Clarinet.json * feat: non-breaking dev into main (#635) * feat: stable-swap-pool anchored to xusd * minor refactoring; test added * tests added * minor refactoring * chore: diasable non-prod contract tests * ci updated * ci updated * ci updated * feat: wip ci * feat: use curl for clarity manager * feat: fix path issue * curl added to ci * clean up ci * requirement changed to mainnet contract * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * Revert "feat: stable-swap-pool" * Revert "Revert "feat: stable-swap-pool"" (#633) * chore: short intro comments added to stable-swap-pool * fix: oracle returns proper price (#634) * tests updated to clarinet 1.0.0 requirements * Revert "tests updated to clarinet 1.0.0 requirements" This reverts commit 3b95b93. * Revert "Revert "tests updated to clarinet 1.0.0 requirements"" This reverts commit 6677cd4. * feat: merge dev * ci updated * fix: ci (#636) Co-authored-by: Zitao Xiong <caoer115@gmail.com> * working * working; * TODO: test suite * test working * working * claim-for-claimer * set-temp-timestamp * set-temp-timestamp * test added --------- Co-authored-by: Zitao Xiong <caoer115@gmail.com> * feat: event claim helper v1 01 (#695) * Update Clarinet.json * feat: non-breaking dev into main (#635) * feat: stable-swap-pool anchored to xusd * minor refactoring; test added * tests added * minor refactoring * chore: diasable non-prod contract tests * ci updated * ci updated * ci updated * feat: wip ci * feat: use curl for clarity manager * feat: fix path issue * curl added to ci * clean up ci * requirement changed to mainnet contract * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * auto-alex test updated * Revert "feat: stable-swap-pool" * Revert "Revert "feat: stable-swap-pool"" (#633) * chore: short intro comments added to stable-swap-pool * fix: oracle returns proper price (#634) * tests updated to clarinet 1.0.0 requirements * Revert "tests updated to clarinet 1.0.0 requirements" This reverts commit 3b95b93. * Revert "Revert "tests updated to clarinet 1.0.0 requirements"" This reverts commit 6677cd4. * feat: merge dev * ci updated * fix: ci (#636) Co-authored-by: Zitao Xiong <caoer115@gmail.com> * working * working; * TODO: test suite * test working * working * claim-for-claimer * set-temp-timestamp * set-temp-timestamp * test added * even-claim-helper-v1-01 * test --------- Co-authored-by: Zitao Xiong <caoer115@gmail.com> * feat: bridge tokens (#697) * feat: add contracts from bridge * fix: even claim helper test (#698) * fix: event-claim-helper test * fix: event-claim-helper test * fix: event-claim-helper test * fix: timestamp * chore: amm-swap-pool comments --------- Co-authored-by: fiftyeightandeight <alexd@alexgo.io> * feat: launchpad with liquidity lock (#700) * initial coding done * launchpad-liquidity-lock => liquidity-launchpad * feat: brc20-chax (#702) * chore: launchpad-with-pool-lock (#703) * feat: brc20-chax * liquidity-launchpad => launchpad-with-pool-lock * feat: bridged-apower-helper (#704) * feat: bridged-apower-helper * ci * feat: bridge-apower-helper-v1-01 (#705) * remove bridge-apower-helper-v1-01 * feat: missing file (#706) * feat: add clarinet for brc20-chax * clarinet.toml --------- Co-authored-by: fiftyeightandeight <443225+fiftyeightandeight@users.noreply.github.com> * fix: auto-fwp-alex-usda-100x_test (#709) --------- Co-authored-by: Kyle Fang <zhigang1992@gmail.com> Co-authored-by: Zitao Xiong <caoer115@gmail.com> * amm-swap-pool-helper * amm-swap-pool-helper * feat: setup amm-pool-helper * assert pool doesnt exist --------- Co-authored-by: Kyle Fang <zhigang1992@gmail.com> Co-authored-by: Zitao Xiong <caoer115@gmail.com>
1 parent e8be64e commit 59407c9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clarity/contracts/helpers/amm-swap-pool-helper.clar

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(define-constant err-request-not-found (err u1004))
88
(define-constant err-request-not-approved (err u1005))
99
(define-constant err-request-already-processed (err u1006))
10+
(define-constant err-pool-exists (err u1007))
1011

1112
(define-constant MAX_UINT u340282366920938463463374607431768211455)
1213

@@ -64,6 +65,10 @@
6465
(asserts! (is-eq (get token-x request-details) (contract-of token-x-trait)) err-token-mismatch)
6566
(asserts! (get approved token-details) err-token-not-approved)
6667
(asserts! (>= (get bal-x request-details) (get min-x token-details)) err-insufficient-balance)
68+
(asserts! (and
69+
(is-none (contract-call? .amm-swap-pool-v1-1 get-pool-exists (get token-x request-details) (get token-y request-details) (get factor request-details)))
70+
(is-none (contract-call? .amm-swap-pool-v1-1 get-pool-exists (get token-y request-details) (get token-x request-details) (get factor request-details))))
71+
err-pool-exists)
6772
(try! (contract-call? token-x-trait transfer-fixed (get bal-x request-details) tx-sender (as-contract tx-sender) none))
6873
(map-set requests next-nonce updated-request-details)
6974
(var-set request-nonce next-nonce)
@@ -100,7 +105,7 @@
100105
(request-details (try! (get-request-or-fail request-id)))
101106
(updated-request-details (merge request-details { token-y: wrapped-token-y, status: APPROVED, status-memo: memo })))
102107
(try! (check-is-approved))
103-
(asserts! (and (not (is-eq (get status request-details) FINALIZED)) (not (is-eq (get status request-details) REJECTED))) err-request-already-processed)
108+
(asserts! (is-eq (get status request-details) PENDING) err-request-already-processed)
104109
(map-set requests request-id updated-request-details)
105110
(print { notification: "approve-request", payload: updated-request-details })
106111
(ok true)))

0 commit comments

Comments
 (0)