{"tx_id":"0x30983a9e382f1d76390a8b56993661de7c46791957b14d845e068e9eccd405d3","canonical":true,"contract_id":"SPV9K21TBFAK4KNRJXF5DFP8N7W46G4V9RCJDC22.sbtc-stx-jingswap","block_height":7178630,"clarity_version":4,"source_code":"(use-trait pyth-storage-trait 'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-traits-v2.storage-trait)\n(use-trait pyth-decoder-trait 'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-traits-v2.decoder-trait)\n(use-trait wormhole-core-trait 'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.wormhole-traits-v2.core-trait)\n(define-constant DEPOSIT_MIN_BLOCKS u150)\n\n(define-constant BUFFER_BLOCKS u30)\n(define-constant CANCEL_THRESHOLD u500)\n(define-constant PHASE_DEPOSIT u0)\n(define-constant PHASE_BUFFER u1)\n(define-constant PHASE_SETTLE u2)\n(define-constant MAX_DEPOSITORS u50)\n(define-constant FEE_BPS u10)\n(define-constant BPS_PRECISION u10000)\n(define-constant PRICE_PRECISION u100000000)\n\n(define-constant DECIMAL_FACTOR u100)\n\n(define-constant BTC_USD_FEED 0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43)\n(define-constant STX_USD_FEED 0xec7a775f46379b5e943c3526b1c8d54cd49749176b0b98e02dde68d1bd335c17)\n(define-constant MAX_STALENESS u60)\n(define-constant MAX_CONF_RATIO u50)\n(define-constant MAX_DEX_DEVIATION u10)\n(define-constant DEX_SOURCE_XYK u1)\n(define-constant DEX_SOURCE_DLMM u2)\n(define-constant ERR_DEPOSIT_TOO_SMALL (err u1001))\n(define-constant ERR_NOT_DEPOSIT_PHASE (err u1002))\n(define-constant ERR_NOT_SETTLE_PHASE (err u1003))\n(define-constant ERR_ALREADY_SETTLED (err u1004))\n(define-constant ERR_STALE_PRICE (err u1005))\n(define-constant ERR_PRICE_UNCERTAIN (err u1006))\n(define-constant ERR_PRICE_DEX_DIVERGENCE (err u1007))\n(define-constant ERR_NOTHING_TO_WITHDRAW (err u1008))\n(define-constant ERR_ZERO_PRICE (err u1009))\n(define-constant ERR_PAUSED (err u1010))\n(define-constant ERR_NOT_AUTHORIZED (err u1011))\n(define-constant ERR_NOTHING_TO_SETTLE (err u1012))\n(define-constant ERR_QUEUE_FULL (err u1013))\n(define-constant ERR_CANCEL_TOO_EARLY (err u1014))\n(define-constant ERR_CLOSE_TOO_EARLY (err u1015))\n(define-constant ERR_ALREADY_CLOSED (err u1016))\n\n(define-data-var treasury principal tx-sender)\n(define-data-var contract-owner principal tx-sender)\n(define-data-var paused bool false)\n(define-data-var dex-source uint DEX_SOURCE_XYK)\n(define-data-var min-stx-deposit uint u1000000)\n(define-data-var min-sbtc-deposit uint u1000)\n(define-data-var current-cycle uint u0)\n(define-data-var cycle-start-block uint stacks-block-height)\n\n(define-data-var deposits-closed-block uint u0)\n\n(define-data-var settle-stx-cleared uint u0)\n(define-data-var settle-sbtc-cleared uint u0)\n(define-data-var settle-total-stx uint u0)\n(define-data-var settle-total-sbtc uint u0)\n(define-data-var settle-sbtc-after-fee uint u0)\n(define-data-var settle-stx-after-fee uint u0)\n(define-data-var bumped-stx-principal principal tx-sender)\n(define-data-var bumped-sbtc-principal principal tx-sender)\n\n(define-map stx-deposits\n  { cycle: uint, depositor: principal }\n  uint)\n\n(define-map sbtc-deposits\n  { cycle: uint, depositor: principal }\n  uint)\n\n(define-map stx-depositor-list\n  uint\n  (list 50 principal))\n\n(define-map sbtc-depositor-list\n  uint\n  (list 50 principal))\n\n(define-map cycle-totals\n  uint\n  { total-stx: uint, total-sbtc: uint })\n\n(define-map settlements\n  uint\n  { price: uint,\n    stx-cleared: uint,\n    sbtc-cleared: uint,\n    stx-fee: uint,\n    sbtc-fee: uint,\n    settled-at: uint })\n\n(define-read-only (get-current-cycle)\n  (var-get current-cycle))\n\n(define-read-only (get-cycle-start-block)\n  (var-get cycle-start-block))\n\n(define-read-only (get-blocks-elapsed)\n  (- stacks-block-height (var-get cycle-start-block)))\n\n(define-read-only (get-cycle-phase)\n  (let ((closed-block (var-get deposits-closed-block)))\n    (if (is-eq closed-block u0)\n      PHASE_DEPOSIT\n      (if (< stacks-block-height (+ closed-block BUFFER_BLOCKS))\n        PHASE_BUFFER\n        PHASE_SETTLE))))\n\n(define-read-only (get-cycle-totals (cycle uint))\n  (default-to { total-stx: u0, total-sbtc: u0 }\n    (map-get? cycle-totals cycle)))\n\n(define-read-only (get-settlement (cycle uint))\n  (map-get? settlements cycle))\n\n(define-read-only (get-stx-deposit (cycle uint) (depositor principal))\n  (default-to u0 (map-get? stx-deposits { cycle: cycle, depositor: depositor })))\n\n(define-read-only (get-sbtc-deposit (cycle uint) (depositor principal))\n  (default-to u0 (map-get? sbtc-deposits { cycle: cycle, depositor: depositor })))\n\n(define-read-only (get-stx-depositors (cycle uint))\n  (default-to (list) (map-get? stx-depositor-list cycle)))\n\n(define-read-only (get-sbtc-depositors (cycle uint))\n  (default-to (list) (map-get? sbtc-depositor-list cycle)))\n\n(define-read-only (get-dex-source)\n  (var-get dex-source))\n\n(define-read-only (get-min-deposits)\n  { min-stx: (var-get min-stx-deposit), min-sbtc: (var-get min-sbtc-deposit) })\n\n(define-private (advance-cycle)\n  (begin\n    (var-set current-cycle (+ (var-get current-cycle) u1))\n    (var-set cycle-start-block stacks-block-height)\n    (var-set deposits-closed-block u0)))\n\n(define-private (find-smallest-stx-fold\n  (depositor principal)\n  (acc { cycle: uint, smallest: uint, smallest-principal: principal }))\n  (let ((amount (get-stx-deposit (get cycle acc) depositor)))\n    (if (< amount (get smallest acc))\n      (merge acc { smallest: amount, smallest-principal: depositor })\n      acc)))\n\n(define-private (find-smallest-sbtc-fold\n  (depositor principal)\n  (acc { cycle: uint, smallest: uint, smallest-principal: principal }))\n  (let ((amount (get-sbtc-deposit (get cycle acc) depositor)))\n    (if (< amount (get smallest acc))\n      (merge acc { smallest: amount, smallest-principal: depositor })\n      acc)))\n\n(define-private (not-eq-bumped-stx (entry principal))\n  (not (is-eq entry (var-get bumped-stx-principal))))\n\n(define-private (not-eq-bumped-sbtc (entry principal))\n  (not (is-eq entry (var-get bumped-sbtc-principal))))\n(define-private (roll-stx-depositor (depositor principal))\n  (let ((cycle (var-get current-cycle)))\n    (map-set stx-deposits { cycle: (+ cycle u1), depositor: depositor }\n      (get-stx-deposit cycle depositor))\n    (map-delete stx-deposits { cycle: cycle, depositor: depositor })))\n\n(define-private (roll-sbtc-depositor (depositor principal))\n  (let ((cycle (var-get current-cycle)))\n    (map-set sbtc-deposits { cycle: (+ cycle u1), depositor: depositor }\n      (get-sbtc-deposit cycle depositor))\n    (map-delete sbtc-deposits { cycle: cycle, depositor: depositor })))\n(define-private (roll-depositor-lists (cycle uint))\n  (begin\n    (map-set stx-depositor-list (+ cycle u1) (get-stx-depositors cycle))\n    (map-set sbtc-depositor-list (+ cycle u1) (get-sbtc-depositors cycle))\n    (map-delete stx-depositor-list cycle)\n    (map-delete sbtc-depositor-list cycle)))\n\n(define-public (deposit-stx (amount uint))\n  (let (\n    (cycle (var-get current-cycle))\n    (existing (get-stx-deposit cycle tx-sender))\n    (totals (get-cycle-totals cycle))\n    (depositors (get-stx-depositors cycle))\n  )\n    (asserts! (not (var-get paused)) ERR_PAUSED)\n    (asserts! (is-eq (get-cycle-phase) PHASE_DEPOSIT) ERR_NOT_DEPOSIT_PHASE)\n    (asserts! (>= amount (var-get min-stx-deposit)) ERR_DEPOSIT_TOO_SMALL)\n\n    (if (and (is-eq existing u0) (>= (len depositors) MAX_DEPOSITORS))\n      (let (\n        (smallest-info (fold find-smallest-stx-fold depositors\n          { cycle: cycle, smallest: u999999999999999999, smallest-principal: tx-sender }))\n        (smallest-amount (get smallest smallest-info))\n        (smallest-who (get smallest-principal smallest-info))\n      )\n        (asserts! (> amount smallest-amount) ERR_QUEUE_FULL)\n        (try! (as-contract? ((with-stx smallest-amount))\n          (try! (stx-transfer? smallest-amount current-contract smallest-who))))\n        (try! (stx-transfer? amount tx-sender current-contract))\n        (var-set bumped-stx-principal smallest-who)\n        (map-set stx-depositor-list cycle\n          (unwrap-panic (as-max-len? (append (filter not-eq-bumped-stx depositors) tx-sender) u50)))\n        (map-delete stx-deposits { cycle: cycle, depositor: smallest-who })\n        (map-set stx-deposits { cycle: cycle, depositor: tx-sender } amount)\n        (map-set cycle-totals cycle\n          (merge totals { total-stx: (+ (- (get total-stx totals) smallest-amount) amount) }))\n        (print { event: \"deposit-stx\", depositor: tx-sender, amount: amount, cycle: cycle,\n                 bumped: smallest-who, bumped-amount: smallest-amount })\n        (ok amount))\n      (begin\n        (try! (stx-transfer? amount tx-sender current-contract))\n        (map-set stx-deposits { cycle: cycle, depositor: tx-sender } (+ existing amount))\n        (map-set cycle-totals cycle\n          (merge totals { total-stx: (+ (get total-stx totals) amount) }))\n        (if (is-eq existing u0)\n          (map-set stx-depositor-list cycle\n            (unwrap-panic (as-max-len? (append depositors tx-sender) u50)))\n          true)\n        (print { event: \"deposit-stx\", depositor: tx-sender, amount: (+ existing amount), cycle: cycle })\n        (ok amount)))))\n\n(define-public (deposit-sbtc (amount uint))\n  (let (\n    (cycle (var-get current-cycle))\n    (existing (get-sbtc-deposit cycle tx-sender))\n    (totals (get-cycle-totals cycle))\n    (depositors (get-sbtc-depositors cycle))\n  )\n    (asserts! (not (var-get paused)) ERR_PAUSED)\n    (asserts! (is-eq (get-cycle-phase) PHASE_DEPOSIT) ERR_NOT_DEPOSIT_PHASE)\n    (asserts! (>= amount (var-get min-sbtc-deposit)) ERR_DEPOSIT_TOO_SMALL)\n    (if (and (is-eq existing u0) (>= (len depositors) MAX_DEPOSITORS))\n      (let (\n        (smallest-info (fold find-smallest-sbtc-fold depositors\n          { cycle: cycle, smallest: u999999999999999999, smallest-principal: tx-sender }))\n        (smallest-amount (get smallest smallest-info))\n        (smallest-who (get smallest-principal smallest-info))\n      )\n        (asserts! (> amount smallest-amount) ERR_QUEUE_FULL)\n        (try! (as-contract? ((with-ft 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token \"sbtc-token\" smallest-amount))\n          (try! (contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token\n            transfer smallest-amount current-contract smallest-who none))))\n        (try! (contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token\n          transfer amount tx-sender current-contract none))\n        (var-set bumped-sbtc-principal smallest-who)\n        (map-set sbtc-depositor-list cycle\n          (unwrap-panic (as-max-len? (append (filter not-eq-bumped-sbtc depositors) tx-sender) u50)))\n        (map-delete sbtc-deposits { cycle: cycle, depositor: smallest-who })\n        (map-set sbtc-deposits { cycle: cycle, depositor: tx-sender } amount)\n        (map-set cycle-totals cycle\n          (merge totals { total-sbtc: (+ (- (get total-sbtc totals) smallest-amount) amount) }))\n        (print { event: \"deposit-sbtc\", depositor: tx-sender, amount: amount, cycle: cycle,\n                 bumped: smallest-who, bumped-amount: smallest-amount })\n        (ok amount))\n      (begin\n        (try! (contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token\n          transfer amount tx-sender current-contract none))\n        (map-set sbtc-deposits { cycle: cycle, depositor: tx-sender } (+ existing amount))\n        (map-set cycle-totals cycle\n          (merge totals { total-sbtc: (+ (get total-sbtc totals) amount) }))\n        (if (is-eq existing u0)\n          (map-set sbtc-depositor-list cycle\n            (unwrap-panic (as-max-len? (append depositors tx-sender) u50)))\n          true)\n        (print { event: \"deposit-sbtc\", depositor: tx-sender, amount: (+ existing amount), cycle: cycle })\n        (ok amount)))))\n(define-public (cancel-stx-deposit)\n  (let (\n    (cycle (var-get current-cycle))\n    (caller tx-sender)\n    (amount (get-stx-deposit cycle caller))\n    (totals (get-cycle-totals cycle))\n  )\n    (asserts! (is-eq (get-cycle-phase) PHASE_DEPOSIT) ERR_NOT_DEPOSIT_PHASE)\n    (asserts! (> amount u0) ERR_NOTHING_TO_WITHDRAW)\n    (try! (as-contract? ((with-stx amount))\n      (try! (stx-transfer? amount current-contract caller))))\n    (map-delete stx-deposits { cycle: cycle, depositor: caller })\n    (var-set bumped-stx-principal caller)\n    (map-set stx-depositor-list cycle (filter not-eq-bumped-stx (get-stx-depositors cycle)))\n    (map-set cycle-totals cycle\n      (merge totals { total-stx: (- (get total-stx totals) amount) }))\n    (print { event: \"refund-stx\", depositor: caller, amount: amount, cycle: cycle })\n    (ok amount)))\n\n(define-public (cancel-sbtc-deposit)\n  (let (\n    (cycle (var-get current-cycle))\n    (caller tx-sender)\n    (amount (get-sbtc-deposit cycle caller))\n    (totals (get-cycle-totals cycle))\n  )\n    (asserts! (is-eq (get-cycle-phase) PHASE_DEPOSIT) ERR_NOT_DEPOSIT_PHASE)\n    (asserts! (> amount u0) ERR_NOTHING_TO_WITHDRAW)\n    (try! (as-contract? ((with-ft 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token \"sbtc-token\" amount))\n      (try! (contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token\n        transfer amount current-contract caller none))))\n    (map-delete sbtc-deposits { cycle: cycle, depositor: caller })\n    (var-set bumped-sbtc-principal caller)\n    (map-set sbtc-depositor-list cycle (filter not-eq-bumped-sbtc (get-sbtc-depositors cycle)))\n    (map-set cycle-totals cycle\n      (merge totals { total-sbtc: (- (get total-sbtc totals) amount) }))\n    (print { event: \"refund-sbtc\", depositor: caller, amount: amount, cycle: cycle })\n    (ok amount)))\n\n(define-public (close-deposits)\n  (let (\n    (elapsed (get-blocks-elapsed))\n    (totals (get-cycle-totals (var-get current-cycle)))\n  )\n    (asserts! (is-eq (get-cycle-phase) PHASE_DEPOSIT) ERR_ALREADY_CLOSED)\n    (asserts! (>= elapsed DEPOSIT_MIN_BLOCKS) ERR_CLOSE_TOO_EARLY)\n    (asserts! (and (>= (get total-stx totals) (var-get min-stx-deposit))\n                   (>= (get total-sbtc totals) (var-get min-sbtc-deposit))) ERR_NOTHING_TO_SETTLE)\n    (var-set deposits-closed-block stacks-block-height)\n    (print { event: \"close-deposits\",\n             cycle: (var-get current-cycle),\n             closed-at-block: stacks-block-height,\n             elapsed-blocks: elapsed })\n    (ok true)))\n(define-public (settle)\n  (let (\n    (btc-feed (unwrap! (contract-call?\n      'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-storage-v4\n      get-price BTC_USD_FEED) ERR_ZERO_PRICE))\n    (stx-feed (unwrap! (contract-call?\n      'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-storage-v4\n      get-price STX_USD_FEED) ERR_ZERO_PRICE))\n    (cycle (var-get current-cycle))\n  )\n    (try! (execute-settlement cycle btc-feed stx-feed))\n    (map distribute-to-stx-depositor (get-stx-depositors cycle))\n    (map distribute-to-sbtc-depositor (get-sbtc-depositors cycle))\n    (advance-cycle)\n    (ok true)))\n(define-public (settle-with-refresh\n  (btc-vaa (buff 8192))\n  (stx-vaa (buff 8192))\n  (pyth-storage <pyth-storage-trait>)\n  (pyth-decoder <pyth-decoder-trait>)\n  (wormhole-core <wormhole-core-trait>))\n  (begin\n    (try! (contract-call?\n      'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-oracle-v4\n      verify-and-update-price-feeds btc-vaa\n      { pyth-storage-contract: pyth-storage,\n        pyth-decoder-contract: pyth-decoder,\n        wormhole-core-contract: wormhole-core }))\n    (try! (contract-call?\n      'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-oracle-v4\n      verify-and-update-price-feeds stx-vaa\n      { pyth-storage-contract: pyth-storage,\n        pyth-decoder-contract: pyth-decoder,\n        wormhole-core-contract: wormhole-core }))\n    (let (\n      (btc-feed (unwrap! (contract-call?\n        'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-storage-v4\n        get-price BTC_USD_FEED) ERR_ZERO_PRICE))\n      (stx-feed (unwrap! (contract-call?\n        'SP1CGXWEAMG6P6FT04W66NVGJ7PQWMDAC19R7PJ0Y.pyth-storage-v4\n        get-price STX_USD_FEED) ERR_ZERO_PRICE))\n      (cycle (var-get current-cycle))\n    )\n      (try! (execute-settlement cycle btc-feed stx-feed))\n      (map distribute-to-stx-depositor (get-stx-depositors cycle))\n      (map distribute-to-sbtc-depositor (get-sbtc-depositors cycle))\n      (advance-cycle)\n      (ok true))))\n(define-public (cancel-cycle)\n  (let (\n    (cycle (var-get current-cycle))\n    (closed-block (var-get deposits-closed-block))\n    (totals (get-cycle-totals cycle))\n  )\n    (asserts! (> closed-block u0) ERR_NOT_SETTLE_PHASE)\n    (asserts! (>= stacks-block-height\n                  (+ closed-block BUFFER_BLOCKS CANCEL_THRESHOLD))\n              ERR_CANCEL_TOO_EARLY)\n    (asserts! (is-none (map-get? settlements cycle)) ERR_ALREADY_SETTLED)\n    (map-set cycle-totals (+ cycle u1) totals)\n    (map-delete cycle-totals cycle)\n    (map roll-stx-depositor (get-stx-depositors cycle))\n    (map roll-sbtc-depositor (get-sbtc-depositors cycle))\n    (roll-depositor-lists cycle)\n    (advance-cycle)\n    (print { event: \"cancel-cycle\", cycle: cycle,\n             stx-rolled: (get total-stx totals),\n             sbtc-rolled: (get total-sbtc totals) })\n    (ok true)))\n\n(define-private (execute-settlement\n  (cycle uint)\n  (btc-feed { price: int, conf: uint, expo: int, ema-price: int,\n              ema-conf: uint, publish-time: uint, prev-publish-time: uint })\n  (stx-feed { price: int, conf: uint, expo: int, ema-price: int,\n              ema-conf: uint, publish-time: uint, prev-publish-time: uint }))\n  (let (\n    (totals (get-cycle-totals cycle))\n    (total-stx (get total-stx totals))\n    (total-sbtc (get total-sbtc totals))\n    (btc-price (to-uint (get price btc-feed)))\n    (stx-price (to-uint (get price stx-feed)))\n    (oracle-price (/ (* btc-price PRICE_PRECISION) stx-price))\n    (dex-price (get-dex-price))\n    (stx-value-of-sbtc (/ (* total-sbtc oracle-price) (* PRICE_PRECISION DECIMAL_FACTOR)))\n    (sbtc-is-binding (<= stx-value-of-sbtc total-stx))\n    (stx-clearing (if sbtc-is-binding stx-value-of-sbtc total-stx))\n    (sbtc-clearing (if sbtc-is-binding total-sbtc (/ (* total-stx (* PRICE_PRECISION DECIMAL_FACTOR)) oracle-price)))\n    (stx-fee (/ (* stx-clearing FEE_BPS) BPS_PRECISION))\n    (sbtc-fee (/ (* sbtc-clearing FEE_BPS) BPS_PRECISION))\n    (stx-unfilled (- total-stx stx-clearing))\n    (sbtc-unfilled (- total-sbtc sbtc-clearing))\n    (min-freshness (- stacks-block-time MAX_STALENESS))\n  )\n    (asserts! (not (var-get paused)) ERR_PAUSED)\n    (asserts! (is-eq (get-cycle-phase) PHASE_SETTLE) ERR_NOT_SETTLE_PHASE)\n    (asserts! (is-none (map-get? settlements cycle)) ERR_ALREADY_SETTLED)\n    (asserts! (and (>= total-stx (var-get min-stx-deposit))\n                   (>= total-sbtc (var-get min-sbtc-deposit))) ERR_NOTHING_TO_SETTLE)\n    (asserts! (> btc-price u0) ERR_ZERO_PRICE)\n    (asserts! (> stx-price u0) ERR_ZERO_PRICE)\n\n    (asserts! (> (get publish-time btc-feed) min-freshness) ERR_STALE_PRICE)\n    (asserts! (> (get publish-time stx-feed) min-freshness) ERR_STALE_PRICE)\n\n    (asserts! (< (get conf btc-feed) (/ btc-price MAX_CONF_RATIO)) ERR_PRICE_UNCERTAIN)\n    (asserts! (< (get conf stx-feed) (/ stx-price MAX_CONF_RATIO)) ERR_PRICE_UNCERTAIN)\n\n    (asserts! (< (if (> oracle-price dex-price) \n                    (- oracle-price dex-price) (- dex-price oracle-price))\n                 (/ oracle-price MAX_DEX_DEVIATION)) ERR_PRICE_DEX_DIVERGENCE)\n\n    (map-set settlements cycle\n      { price: oracle-price,\n        stx-cleared: stx-clearing,\n        sbtc-cleared: sbtc-clearing,\n        stx-fee: stx-fee,\n        sbtc-fee: sbtc-fee,\n        settled-at: stacks-block-height })\n\n    (if (> stx-fee u0)\n      (try! (as-contract? ((with-stx stx-fee))\n        (try! (stx-transfer? stx-fee current-contract (var-get treasury)))))\n      true)\n    (if (> sbtc-fee u0)\n      (try! (as-contract? ((with-ft 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token \"sbtc-token\" sbtc-fee))\n        (try! (contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token\n         transfer sbtc-fee current-contract (var-get treasury) none))))\n      true)\n\n    (map-set cycle-totals (+ cycle u1)\n      { total-stx: stx-unfilled, total-sbtc: sbtc-unfilled })\n\n    (var-set settle-stx-cleared stx-clearing)\n    (var-set settle-sbtc-cleared sbtc-clearing)\n    (var-set settle-total-stx total-stx)\n    (var-set settle-total-sbtc total-sbtc)\n    (var-set settle-sbtc-after-fee (- sbtc-clearing sbtc-fee))\n    (var-set settle-stx-after-fee (- stx-clearing stx-fee))\n    (print {\n      event: \"settlement\",\n      cycle: cycle,\n      price: oracle-price,\n      stx-cleared: stx-clearing,\n      sbtc-cleared: sbtc-clearing,\n      stx-unfilled: stx-unfilled,\n      sbtc-unfilled: sbtc-unfilled,\n      stx-fee: stx-fee,\n      sbtc-fee: sbtc-fee,\n      binding-side: (if sbtc-is-binding \"sbtc\" \"stx\")\n    })\n    (ok true)))\n(define-private (distribute-to-stx-depositor (depositor principal))\n  (let (\n    (cycle (var-get current-cycle))\n    (my-deposit (get-stx-deposit cycle depositor))\n    (total-stx (var-get settle-total-stx))\n    (my-sbtc-received (if (> total-stx u0) (/ (* my-deposit (var-get settle-sbtc-after-fee)) total-stx) u0))\n    (my-stx-unfilled (if (> total-stx u0) (/ (* my-deposit (- total-stx (var-get settle-stx-cleared))) total-stx) u0))\n    (next-cycle (+ cycle u1))\n  )\n    (map-delete stx-deposits { cycle: cycle, depositor: depositor })\n    (if (> my-sbtc-received u0)\n      (try! (as-contract? ((with-ft 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token \"sbtc-token\" my-sbtc-received))\n        (try! (contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token\n          transfer my-sbtc-received current-contract depositor none))))\n      true)\n    (if (> my-stx-unfilled u0)\n      (begin\n        (map-set stx-deposits\n          { cycle: next-cycle, depositor: depositor } my-stx-unfilled)\n        (map-set stx-depositor-list next-cycle\n              (unwrap-panic (as-max-len? (append (get-stx-depositors next-cycle) depositor) u50)))\n        true)\n      true)\n    (print {\n      event: \"distribute-stx-depositor\",\n      depositor: depositor,\n      cycle: cycle,\n      sbtc-received: my-sbtc-received,\n      stx-rolled: my-stx-unfilled\n    })\n    (ok true)))\n(define-private (distribute-to-sbtc-depositor (depositor principal))\n  (let (\n    (cycle (var-get current-cycle))\n    (my-deposit (get-sbtc-deposit cycle depositor))\n    (total-sbtc (var-get settle-total-sbtc))\n    (my-stx-received (if (> total-sbtc u0) (/ (* my-deposit (var-get settle-stx-after-fee)) total-sbtc) u0))\n    (my-sbtc-unfilled (if (> total-sbtc u0) (/ (* my-deposit (- total-sbtc (var-get settle-sbtc-cleared))) total-sbtc) u0))\n    (next-cycle (+ cycle u1))\n  )\n    (map-delete sbtc-deposits { cycle: cycle, depositor: depositor })\n    (if (> my-stx-received u0)\n      (try! (as-contract? ((with-stx my-stx-received))\n        (try! (stx-transfer? my-stx-received current-contract depositor))))\n      true)\n    (if (> my-sbtc-unfilled u0)\n      (begin\n        (map-set sbtc-deposits\n          { cycle: next-cycle, depositor: depositor } my-sbtc-unfilled)\n        (map-set sbtc-depositor-list next-cycle\n          (unwrap-panic (as-max-len? (append (get-sbtc-depositors next-cycle) depositor) u50)))\n        true)\n      true)\n    (print {\n      event: \"distribute-sbtc-depositor\",\n      depositor: depositor,\n      cycle: cycle,\n      stx-received: my-stx-received,\n      sbtc-rolled: my-sbtc-unfilled\n    })\n    (ok true)))\n\n(define-read-only (get-dex-price)\n  (if (is-eq (var-get dex-source) DEX_SOURCE_XYK)\n    (get-xyk-price)\n    (get-dlmm-price)))\n\n(define-read-only (get-xyk-price)\n  (let ((pool (unwrap-panic (contract-call?\n    'SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-pool-sbtc-stx-v-1-1\n    get-pool))))\n    (/ (* (get y-balance pool) u100 PRICE_PRECISION) (get x-balance pool))))\n\n(define-read-only (get-dlmm-price)\n  (let ((pool (unwrap-panic (contract-call?\n    'SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-pool-stx-sbtc-v-1-bps-15\n    get-pool))))\n    (unwrap-panic (contract-call?\n      'SP1PFR4V08H1RAZXREBGFFQ59WB739XM8VVGTFSEA.dlmm-core-v-1-1\n      get-bin-price (get initial-price pool) (get bin-step pool) (get active-bin-id pool)))))\n\n(define-public (set-treasury (new-treasury principal))\n  (begin\n    (asserts! (is-eq tx-sender (var-get contract-owner)) ERR_NOT_AUTHORIZED)\n    (ok (var-set treasury new-treasury))))\n\n(define-public (set-paused (is-paused bool))\n  (begin\n    (asserts! (is-eq tx-sender (var-get contract-owner)) ERR_NOT_AUTHORIZED)\n    (ok (var-set paused is-paused))))\n\n(define-public (set-contract-owner (new-owner principal))\n  (begin\n    (asserts! (is-eq tx-sender (var-get contract-owner)) ERR_NOT_AUTHORIZED)\n    (ok (var-set contract-owner new-owner))))\n\n(define-public (set-dex-source (source uint))\n  (begin\n    (asserts! (is-eq tx-sender (var-get contract-owner)) ERR_NOT_AUTHORIZED)\n    (asserts! (or (is-eq source DEX_SOURCE_XYK) (is-eq source DEX_SOURCE_DLMM)) ERR_NOT_AUTHORIZED)\n    (ok (var-set dex-source source))))\n\n(define-public (set-min-stx-deposit (amount uint))\n  (begin\n    (asserts! (is-eq tx-sender (var-get contract-owner)) ERR_NOT_AUTHORIZED)\n    (ok (var-set min-stx-deposit amount))))\n\n(define-public (set-min-sbtc-deposit (amount uint))\n  (begin\n    (asserts! (is-eq tx-sender (var-get contract-owner)) ERR_NOT_AUTHORIZED)\n    (ok (var-set min-sbtc-deposit amount))))","abi":"{\"maps\":[{\"key\":\"uint128\",\"name\":\"cycle-totals\",\"value\":{\"tuple\":[{\"name\":\"total-sbtc\",\"type\":\"uint128\"},{\"name\":\"total-stx\",\"type\":\"uint128\"}]}},{\"key\":\"uint128\",\"name\":\"sbtc-depositor-list\",\"value\":{\"list\":{\"type\":\"principal\",\"length\":50}}},{\"key\":{\"tuple\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"depositor\",\"type\":\"principal\"}]},\"name\":\"sbtc-deposits\",\"value\":\"uint128\"},{\"key\":\"uint128\",\"name\":\"settlements\",\"value\":{\"tuple\":[{\"name\":\"price\",\"type\":\"uint128\"},{\"name\":\"sbtc-cleared\",\"type\":\"uint128\"},{\"name\":\"sbtc-fee\",\"type\":\"uint128\"},{\"name\":\"settled-at\",\"type\":\"uint128\"},{\"name\":\"stx-cleared\",\"type\":\"uint128\"},{\"name\":\"stx-fee\",\"type\":\"uint128\"}]}},{\"key\":\"uint128\",\"name\":\"stx-depositor-list\",\"value\":{\"list\":{\"type\":\"principal\",\"length\":50}}},{\"key\":{\"tuple\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"depositor\",\"type\":\"principal\"}]},\"name\":\"stx-deposits\",\"value\":\"uint128\"}],\"epoch\":\"Epoch33\",\"functions\":[{\"args\":[],\"name\":\"advance-cycle\",\"access\":\"private\",\"outputs\":{\"type\":\"bool\"}},{\"args\":[{\"name\":\"depositor\",\"type\":\"principal\"}],\"name\":\"distribute-to-sbtc-depositor\",\"access\":\"private\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"depositor\",\"type\":\"principal\"}],\"name\":\"distribute-to-stx-depositor\",\"access\":\"private\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"btc-feed\",\"type\":{\"tuple\":[{\"name\":\"conf\",\"type\":\"uint128\"},{\"name\":\"ema-conf\",\"type\":\"uint128\"},{\"name\":\"ema-price\",\"type\":\"int128\"},{\"name\":\"expo\",\"type\":\"int128\"},{\"name\":\"prev-publish-time\",\"type\":\"uint128\"},{\"name\":\"price\",\"type\":\"int128\"},{\"name\":\"publish-time\",\"type\":\"uint128\"}]}},{\"name\":\"stx-feed\",\"type\":{\"tuple\":[{\"name\":\"conf\",\"type\":\"uint128\"},{\"name\":\"ema-conf\",\"type\":\"uint128\"},{\"name\":\"ema-price\",\"type\":\"int128\"},{\"name\":\"expo\",\"type\":\"int128\"},{\"name\":\"prev-publish-time\",\"type\":\"uint128\"},{\"name\":\"price\",\"type\":\"int128\"},{\"name\":\"publish-time\",\"type\":\"uint128\"}]}}],\"name\":\"execute-settlement\",\"access\":\"private\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"depositor\",\"type\":\"principal\"},{\"name\":\"acc\",\"type\":{\"tuple\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"smallest\",\"type\":\"uint128\"},{\"name\":\"smallest-principal\",\"type\":\"principal\"}]}}],\"name\":\"find-smallest-sbtc-fold\",\"access\":\"private\",\"outputs\":{\"type\":{\"tuple\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"smallest\",\"type\":\"uint128\"},{\"name\":\"smallest-principal\",\"type\":\"principal\"}]}}},{\"args\":[{\"name\":\"depositor\",\"type\":\"principal\"},{\"name\":\"acc\",\"type\":{\"tuple\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"smallest\",\"type\":\"uint128\"},{\"name\":\"smallest-principal\",\"type\":\"principal\"}]}}],\"name\":\"find-smallest-stx-fold\",\"access\":\"private\",\"outputs\":{\"type\":{\"tuple\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"smallest\",\"type\":\"uint128\"},{\"name\":\"smallest-principal\",\"type\":\"principal\"}]}}},{\"args\":[{\"name\":\"entry\",\"type\":\"principal\"}],\"name\":\"not-eq-bumped-sbtc\",\"access\":\"private\",\"outputs\":{\"type\":\"bool\"}},{\"args\":[{\"name\":\"entry\",\"type\":\"principal\"}],\"name\":\"not-eq-bumped-stx\",\"access\":\"private\",\"outputs\":{\"type\":\"bool\"}},{\"args\":[{\"name\":\"cycle\",\"type\":\"uint128\"}],\"name\":\"roll-depositor-lists\",\"access\":\"private\",\"outputs\":{\"type\":\"bool\"}},{\"args\":[{\"name\":\"depositor\",\"type\":\"principal\"}],\"name\":\"roll-sbtc-depositor\",\"access\":\"private\",\"outputs\":{\"type\":\"bool\"}},{\"args\":[{\"name\":\"depositor\",\"type\":\"principal\"}],\"name\":\"roll-stx-depositor\",\"access\":\"private\",\"outputs\":{\"type\":\"bool\"}},{\"args\":[],\"name\":\"cancel-cycle\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[],\"name\":\"cancel-sbtc-deposit\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"uint128\",\"error\":\"uint128\"}}}},{\"args\":[],\"name\":\"cancel-stx-deposit\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"uint128\",\"error\":\"uint128\"}}}},{\"args\":[],\"name\":\"close-deposits\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"deposit-sbtc\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"uint128\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"deposit-stx\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"uint128\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"new-owner\",\"type\":\"principal\"}],\"name\":\"set-contract-owner\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"source\",\"type\":\"uint128\"}],\"name\":\"set-dex-source\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"set-min-sbtc-deposit\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"set-min-stx-deposit\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"is-paused\",\"type\":\"bool\"}],\"name\":\"set-paused\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"new-treasury\",\"type\":\"principal\"}],\"name\":\"set-treasury\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[],\"name\":\"settle\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[{\"name\":\"btc-vaa\",\"type\":{\"buffer\":{\"length\":8192}}},{\"name\":\"stx-vaa\",\"type\":{\"buffer\":{\"length\":8192}}},{\"name\":\"pyth-storage\",\"type\":\"trait_reference\"},{\"name\":\"pyth-decoder\",\"type\":\"trait_reference\"},{\"name\":\"wormhole-core\",\"type\":\"trait_reference\"}],\"name\":\"settle-with-refresh\",\"access\":\"public\",\"outputs\":{\"type\":{\"response\":{\"ok\":\"bool\",\"error\":\"uint128\"}}}},{\"args\":[],\"name\":\"get-blocks-elapsed\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[],\"name\":\"get-current-cycle\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[],\"name\":\"get-cycle-phase\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[],\"name\":\"get-cycle-start-block\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[{\"name\":\"cycle\",\"type\":\"uint128\"}],\"name\":\"get-cycle-totals\",\"access\":\"read_only\",\"outputs\":{\"type\":{\"tuple\":[{\"name\":\"total-sbtc\",\"type\":\"uint128\"},{\"name\":\"total-stx\",\"type\":\"uint128\"}]}}},{\"args\":[],\"name\":\"get-dex-price\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[],\"name\":\"get-dex-source\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[],\"name\":\"get-dlmm-price\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[],\"name\":\"get-min-deposits\",\"access\":\"read_only\",\"outputs\":{\"type\":{\"tuple\":[{\"name\":\"min-sbtc\",\"type\":\"uint128\"},{\"name\":\"min-stx\",\"type\":\"uint128\"}]}}},{\"args\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"depositor\",\"type\":\"principal\"}],\"name\":\"get-sbtc-deposit\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[{\"name\":\"cycle\",\"type\":\"uint128\"}],\"name\":\"get-sbtc-depositors\",\"access\":\"read_only\",\"outputs\":{\"type\":{\"list\":{\"type\":\"principal\",\"length\":50}}}},{\"args\":[{\"name\":\"cycle\",\"type\":\"uint128\"}],\"name\":\"get-settlement\",\"access\":\"read_only\",\"outputs\":{\"type\":{\"optional\":{\"tuple\":[{\"name\":\"price\",\"type\":\"uint128\"},{\"name\":\"sbtc-cleared\",\"type\":\"uint128\"},{\"name\":\"sbtc-fee\",\"type\":\"uint128\"},{\"name\":\"settled-at\",\"type\":\"uint128\"},{\"name\":\"stx-cleared\",\"type\":\"uint128\"},{\"name\":\"stx-fee\",\"type\":\"uint128\"}]}}}},{\"args\":[{\"name\":\"cycle\",\"type\":\"uint128\"},{\"name\":\"depositor\",\"type\":\"principal\"}],\"name\":\"get-stx-deposit\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}},{\"args\":[{\"name\":\"cycle\",\"type\":\"uint128\"}],\"name\":\"get-stx-depositors\",\"access\":\"read_only\",\"outputs\":{\"type\":{\"list\":{\"type\":\"principal\",\"length\":50}}}},{\"args\":[],\"name\":\"get-xyk-price\",\"access\":\"read_only\",\"outputs\":{\"type\":\"uint128\"}}],\"variables\":[{\"name\":\"BPS_PRECISION\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"BTC_USD_FEED\",\"type\":{\"buffer\":{\"length\":32}},\"access\":\"constant\"},{\"name\":\"BUFFER_BLOCKS\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"CANCEL_THRESHOLD\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"DECIMAL_FACTOR\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"DEPOSIT_MIN_BLOCKS\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"DEX_SOURCE_DLMM\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"DEX_SOURCE_XYK\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"ERR_ALREADY_CLOSED\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_ALREADY_SETTLED\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_CANCEL_TOO_EARLY\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_CLOSE_TOO_EARLY\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_DEPOSIT_TOO_SMALL\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_NOTHING_TO_SETTLE\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_NOTHING_TO_WITHDRAW\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_NOT_AUTHORIZED\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_NOT_DEPOSIT_PHASE\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_NOT_SETTLE_PHASE\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_PAUSED\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_PRICE_DEX_DIVERGENCE\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_PRICE_UNCERTAIN\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_QUEUE_FULL\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_STALE_PRICE\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"ERR_ZERO_PRICE\",\"type\":{\"response\":{\"ok\":\"none\",\"error\":\"uint128\"}},\"access\":\"constant\"},{\"name\":\"FEE_BPS\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"MAX_CONF_RATIO\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"MAX_DEPOSITORS\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"MAX_DEX_DEVIATION\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"MAX_STALENESS\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"PHASE_BUFFER\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"PHASE_DEPOSIT\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"PHASE_SETTLE\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"PRICE_PRECISION\",\"type\":\"uint128\",\"access\":\"constant\"},{\"name\":\"STX_USD_FEED\",\"type\":{\"buffer\":{\"length\":32}},\"access\":\"constant\"},{\"name\":\"bumped-sbtc-principal\",\"type\":\"principal\",\"access\":\"variable\"},{\"name\":\"bumped-stx-principal\",\"type\":\"principal\",\"access\":\"variable\"},{\"name\":\"contract-owner\",\"type\":\"principal\",\"access\":\"variable\"},{\"name\":\"current-cycle\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"cycle-start-block\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"deposits-closed-block\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"dex-source\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"min-sbtc-deposit\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"min-stx-deposit\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"paused\",\"type\":\"bool\",\"access\":\"variable\"},{\"name\":\"settle-sbtc-after-fee\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"settle-sbtc-cleared\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"settle-stx-after-fee\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"settle-stx-cleared\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"settle-total-sbtc\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"settle-total-stx\",\"type\":\"uint128\",\"access\":\"variable\"},{\"name\":\"treasury\",\"type\":\"principal\",\"access\":\"variable\"}],\"clarity_version\":\"Clarity4\",\"fungible_tokens\":[],\"non_fungible_tokens\":[]}"}