Skip to content

Commit

Permalink
Merge pull request #305 from noumanahmads/fix/275/refactor-swap
Browse files Browse the repository at this point in the history
fix# 275 / Refactor swap
  • Loading branch information
fiftyeightandeight authored Nov 1, 2021
2 parents 1d9fa4d + 40d479a commit ab202be
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions clarity/contracts/pool/collateral-rebalancing-pool.clar
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,14 @@
;; split of balance to yield and key is transparent to traders
(define-public (swap-x-for-y (token <ft-trait>) (collateral <ft-trait>) (expiry uint) (dx uint) (min-dy (optional uint)))
(begin

;; TODO : Check whether dy or dx value is valid
;; (asserts! (< min-dy dy) too-much-slippage-err)
(asserts! (> dx u0) ERR-INVALID-LIQUIDITY)
;; (asserts! (<= (* block-height ONE_8) expiry) ERR-EXPIRY)

;; swap is supported only if token /= collateral
(asserts! (not (is-eq (contract-of token) (contract-of collateral))) ERR-INVALID-POOL-ERR)
(asserts! (not (is-eq token collateral)) ERR-INVALID-POOL-ERR)
(let
(
(token-x (contract-of collateral))
Expand Down Expand Up @@ -613,7 +616,7 @@
(asserts! (> dy u0) ERR-INVALID-LIQUIDITY)
;; (asserts! (<= (* block-height ONE_8) expiry) ERR-EXPIRY)
;; swap is supported only if token /= collateral
(asserts! (not (is-eq (contract-of token) (contract-of collateral))) ERR-INVALID-POOL-ERR)
(asserts! (not (is-eq token collateral)) ERR-INVALID-POOL-ERR)
(let
(
(token-x (contract-of collateral))
Expand Down

0 comments on commit ab202be

Please sign in to comment.