Skip to content

Commit

Permalink
asserts updated
Browse files Browse the repository at this point in the history
let block reverted to begin
  • Loading branch information
noumanahmads committed Nov 1, 2021
1 parent c3485a7 commit fba974a
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions clarity/contracts/pool/collateral-rebalancing-pool.clar
Original file line number Diff line number Diff line change
Expand Up @@ -557,20 +557,19 @@

;; 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))
(let
(
(token-x (contract-of collateral))
(token-y (contract-of token))
)
(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 token-y token-x)) ERR-INVALID-POOL-ERR)
(asserts! (not (is-eq token collateral)) ERR-INVALID-POOL-ERR)
(let
(
(token-x (contract-of collateral))
(token-y (contract-of token))
(pool (unwrap! (map-get? pools-data-map { token-x: token-x, token-y: token-y, expiry: expiry }) ERR-INVALID-POOL-ERR))
(strike (get strike pool))
(bs-vol (get bs-vol pool))
Expand Down Expand Up @@ -612,20 +611,17 @@
)

(define-public (swap-y-for-x (token <ft-trait>) (collateral <ft-trait>) (expiry uint) (dy uint))
(let
(
(token-x (contract-of collateral))
(token-y (contract-of token))
)
(begin
;; TODO : Check whether dy or dx value is valid
;; (asserts! (< min-dy dy) too-much-slippage-err)
(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 token-y token-x)) ERR-INVALID-POOL-ERR)
(asserts! (not (is-eq token collateral)) ERR-INVALID-POOL-ERR)
(let
(

(token-x (contract-of collateral))
(token-y (contract-of token))
(pool (unwrap! (map-get? pools-data-map { token-x: token-x, token-y: token-y, expiry: expiry }) ERR-INVALID-POOL-ERR))
(strike (get strike pool))
(bs-vol (get bs-vol pool))
Expand Down

0 comments on commit fba974a

Please sign in to comment.