What you can do
| swap (best route) | Swap any supported token pair at the best price across Bitflow and other Stacks venues. | POST /quotes/v2/quote {input_token, output_token, amount_in (base units, string), slippage_tolerance}; take an executable route; POST /quotes/v2/swap (or /quotes/v2/agg/swap for agg_buildable routes); sign a Stacks contract-call with the returned contract, function, args and post-conditions (Deny mode). |
| swap in one HODLMM pool | Direct DLMM swap. | Read pool get-pool for x-token/y-token; dlmm-swap-router-v-1-2.swap-x-for-y-simple-multi(pool, x-token, y-token, amount, min-out, (some deadline)) with post-conditions on the token sent. |
| swap in an XYK pool | Constant-product swap. | xyk-core-v-1-2.get-dy(pool, x, y, amount) read-only; then swap-x-for-y(pool, x, y, amount, quote*(1-slippage)). Use token-stx-v-1-2 for STX. |
| add HODLMM liquidity | Provide liquidity in bins around the price. | Get bins from /quotes/v2/bins/{pool}; build positions (Y below active bin, X above); dlmm-liquidity-router-v-1-2.add-relative-liquidity-same-multi(positions, pool, x, y, (some {expected-bin-id, max-deviation}), deadline). |
| remove HODLMM liquidity | Withdraw bin shares. | GET /app/v2/users/{you}/positions/{pool}/current-bins (require clean, complete, tipLag 0); withdraw-liquidity-same-multi with signed bin ids (unsigned - 500) and per-bin share amounts. |
Admin powers: XYK/StableSwap core admins (up to 5 principals) can disable pools (set-pool-status), change protocol/provider fees and fee addresses; the swap helper has an on/off switch; HODLMM pools have variable-fee managers and are administered via the DLMM core. A disabled pool makes swaps revert (e.g. legacy xyk-pool-stx-aeusdc-v-1-1/v-1-2 returned err u1010 POOL_DISABLED at research time).
Contracts are versioned, not upgradeable: new versions (v-1-1 -> v-1-2) replace old ones, so integrations must follow current addresses; old pools may be disabled or drained of liquidity.
Audits listed in docs: Clarity Alliance (XYK June 2024, StableSwap Sept 2024, StableSwap staking Sept 2024, StableSwap Midpoint Mar/Apr 2025), CoinFabrik (Dec 2023), StrataLabs (June 2023). No HODLMM/DLMM audit is listed on the docs audits page. Immunefi bug bounty is live.
HODLMM quotes and position data come from an off-chain engine that can lag the chain (check tip_lag); strict-mode transactions revert if the active bin moves, simple-mode ones execute at the then-current bin.
Contracts
Read any function, or build a write and sign it. Amounts are in base units (1 USDC = 1000000).HODLMM (DLMM) swap router v1.2router on stacksSM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-swap-router-v-1-2
write swap-x-for-y-simple-multi(pool-trait <dlmm-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, min-dy uint, deadline-time (optional uint))
Swap x-amount of the pool's X token for Y in one DLMM pool, walking up to 319 bins. Token traits must be the pool's x-token/y-token (read pool get-pool). Reverts err u2003 if output < min-dy, err u2012 if stacks-block-time (unix seconds) > deadline. Returns (ok {in, out}). Add post-conditions (Deny mode) for the tokens sent.
write swap-y-for-x-simple-multi(pool-trait <dlmm-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, y-amount uint, min-dx uint, deadline-time (optional uint))
Reverse direction: Y in, X out, same rules.
write swap-x-for-y-simple-range-multi(pool-trait <dlmm-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, min-dy uint, max-steps uint, deadline-time (optional uint))
Same as swap-x-for-y-simple-multi but caps the number of bins traversed at max-steps (1-319) to bound execution cost.
write swap-y-for-x-simple-range-multi(pool-trait <dlmm-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, y-amount uint, min-dx uint, max-steps uint, deadline-time (optional uint))
Y-for-X with a max-steps cap.
write swap-simple-multi(swaps (list 5 {pool-trait: <dlmm-pool-trait>, x-token-trait: <sip-010-trait>, y-token-trait: <sip-010-trait>, amount: uint, min-received: uint, x-for-y: bool, max-steps: uint}), deadline-time (optional uint))
Up to 5 single-pool swaps in one call (the form the Quote API returns as function_name swap-simple-multi; total max-steps should stay <= ~290 per docs). Each entry has its own min-received. Returns (ok {results: list of {in, out}}).
write swap-multi(swaps (list 319 {pool-trait: <dlmm-pool-trait>, x-token-trait: <sip-010-trait>, y-token-trait: <sip-010-trait>, expected-bin-id: int, amount: uint, min-received: uint, x-for-y: bool}), max-unfavorable-bins uint, deadline-time (optional uint))
Strict per-bin swap: each entry swaps in a specific expected-bin-id (signed, -500..500); fails with err u2002 if more than max-unfavorable-bins bins moved against you. Use the Quote API's 'full' parameters to build it.
HODLMM (DLMM) liquidity router v1.2router on stacksSM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-liquidity-router-v-1-2
write add-relative-liquidity-same-multi(positions (list 288 {active-bin-id-offset: int, x-amount: uint, y-amount: uint, min-dlp: uint, max-x-liquidity-fee: uint, max-y-liquidity-fee: uint}), pool-trait <dlmm-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, active-bin-tolerance (optional {expected-bin-id: int, max-deviation: uint}), deadline-time (optional uint))
'Simple mode' add: deposit into bins at offsets from the active bin at execution time. Only Y may go below the active bin, only X above it. min-dlp = minimum bin shares per position; max-*-liquidity-fee cap the fee charged for adding to the active bin. Optional tolerance reverts if the active bin moved more than max-deviation from expected-bin-id. Returns (ok {results, active-bin-id, active-bin-id-delta}). Broadcast in Allow mode per docs.
write add-liquidity-multi(positions (list 333 {pool-trait: <dlmm-pool-trait>, x-token-trait: <sip-010-trait>, y-token-trait: <sip-010-trait>, bin-id: int, x-amount: uint, y-amount: uint, min-dlp: uint, max-x-liquidity-fee: uint, max-y-liquidity-fee: uint}), deadline-time (optional uint))
'Strict mode' add to exact bins. bin-id is SIGNED (-500..500) here; the API's prepare helpers output unsigned ids (0..1000) and the official executing code converts back (signed = unsigned - 500). Reverts if state changed. Returns (ok list of shares minted).
write withdraw-liquidity-same-multi(positions (list 326 {pool-trait: <dlmm-pool-trait>, bin-id: int, amount: uint, min-x-amount: uint, min-y-amount: uint}), x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, min-x-amount-total uint, min-y-amount-total uint, deadline-time (optional uint))
Burn `amount` bin shares from each signed bin-id of one pool; totals are checked against min-x/y-amount-total. Size from the API's current-bins endpoint (userShares). Returns (ok {results, x-amount, y-amount}).
write withdraw-relative-liquidity-same-multi(positions (list 300 {pool-trait: <dlmm-pool-trait>, active-bin-id-offset: int, amount: uint, min-x-amount: uint, min-y-amount: uint}), x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, min-x-amount-total uint, min-y-amount-total uint, deadline-time (optional uint))
Simple-mode withdraw by offset from the active bin.
write withdraw-liquidity-multi(positions (list 326 {pool-trait: <dlmm-pool-trait>, x-token-trait: <sip-010-trait>, y-token-trait: <sip-010-trait>, bin-id: int, amount: uint, min-x-amount: uint, min-y-amount: uint}), deadline-time (optional uint))
Withdraw across several pools/bins (per-position minimums).
write move-liquidity-multi(positions (list 220 {pool-trait: <dlmm-pool-trait>, x-token-trait: <sip-010-trait>, y-token-trait: <sip-010-trait>, from-bin-id: int, to-bin-id: int, amount: uint, min-dlp: uint, max-x-liquidity-fee: uint, max-y-liquidity-fee: uint}), deadline-time (optional uint))
Move `amount` shares from one bin to another (rebalancing a range) without leaving the pool.
write move-relative-liquidity-multi(positions (list 208 {pool-trait: <dlmm-pool-trait>, x-token-trait: <sip-010-trait>, y-token-trait: <sip-010-trait>, from-bin-id: int, active-bin-id-offset: int, amount: uint, min-dlp: uint, max-x-liquidity-fee: uint, max-y-liquidity-fee: uint}), deadline-time (optional uint))
Move shares to a bin at an offset from the active bin.
HODLMM pool sBTC/USDCx (bin step 10)pool on stacksSM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-pool-sbtc-usdcx-v-1-bps-10
read get-pool()
Full pool state: x-token (sBTC), y-token (USDCx), bin-step, active-bin-id (signed), protocol/provider/variable fees per side, core-address, pool status data. Other HODLMM pools (list via GET /quotes/v2/pools) expose the same interface.
read get-active-bin-id()
Active bin, signed int (-500..500).
read get-bin-balances(id uint)
{x-balance, y-balance, bin-shares} for a bin. NOTE: this map is keyed by UNSIGNED id (signed + 500).
read get-user-bins(user principal)
List of (unsigned) bin ids where the user holds shares.
read get-balance(token-id uint, user principal)
SIP-013 share balance of a user in one bin (token-id = unsigned bin id).
read get-overall-balance(user principal)
User's total shares across all bins.
XYK core v1.2 (constant-product AMM)router on stacksSM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-core-v-1-2
read get-dy(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint)
Quote Y out for x-amount of X (fees included). Declared public (takes traits) but makes no writes, so call it read-only via the Hiro call-read endpoint. Returns err u1010 if the pool is disabled.
read get-dx(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, y-amount uint)
Quote X out for y-amount of Y.
read get-dlp(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint)
LP preview for adding x-amount: {dlp, y-amount required}.
write swap-x-for-y(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, min-dy uint)
Swap X for Y in an XYK v1.2 pool (pool contracts named xyk-pool-*-v-1-2 etc. under SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR; get the list from get-pool-by-id or the Quote API). Token traits must equal the pool's x-token/y-token; STX pools use token-stx-v-1-2 as the STX trait. min-dy must be > 0 and output >= min-dy (err u1020). Returns (ok dy).
write swap-y-for-x(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, y-amount uint, min-dx uint)
Swap Y for X; min-dx > 0.
write add-liquidity(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, min-dlp uint)
Add liquidity proportional to reserves: you supply x-amount and the contract pulls y-amount = x-amount * y-balance / x-balance. min-dlp (> 0) is the minimum LP tokens (the pool contract is the LP token). Returns (ok dlp).
write withdraw-liquidity(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, amount uint, min-x-amount uint, min-y-amount uint)
Burn `amount` LP tokens for both tokens. Returns (ok {x-amount, y-amount}).
read get-pool-by-id(id uint)
{id, name, symbol, pool-contract} for pool id 1..get-last-pool-id() (45 at research time).
read get-last-pool-id()
Number of XYK v1.2 pools created.
XYK multi-hop swap helper v1.2router on stacksSM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-swap-helper-v-1-2
write swap-helper-a(amount uint, min-received uint, xyk-tokens {a: <xyk-ft-trait>, b: <xyk-ft-trait>}, xyk-pools {a: <xyk-pool-trait>})
Swap token a -> b through one XYK v1.2 pool, detecting the direction itself. Reverts if result < min-received. Returns (ok received).
write swap-helper-b(amount uint, min-received uint, xyk-tokens {a: <xyk-ft-trait>, b: <xyk-ft-trait>, c: <xyk-ft-trait>, d: <xyk-ft-trait>}, xyk-pools {a: <xyk-pool-trait>, b: <xyk-pool-trait>})
Two hops: a->b in pool a, then c->d in pool b (normally b = c). swap-helper-c/-d/-e extend to 3/4/5 hops.
read get-quote-a(amount uint, xyk-tokens {a: <xyk-ft-trait>, b: <xyk-ft-trait>}, xyk-pools {a: <xyk-pool-trait>})
Quote for swap-helper-a (public, no writes; call read-only). get-quote-b..e match the multi-hop helpers.
read get-swap-status()
false if admins disabled the helper.
STX SIP-010 wrapper for XYK v1.2 (token-stx-v-1-2)token on stacksSM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.token-stx-v-1-2
write transfer(amount uint, sender principal, recipient principal, memo (optional (buff 34)))
Moves native STX (micro-STX, 6 decimals) behind a SIP-010 interface. Pass this contract as the STX token trait in XYK/stableswap v1.2 pools; you do not need to call it directly. Add an STX post-condition.
read get-balance(address principal)
Native STX balance of an address (micro-STX).
StableSwap core v1.2 (Curve-style pools)router on stacksSM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.stableswap-core-v-1-2
read get-dy(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint)
Quote Y out for X in a stableswap v1.2 pool (public with no writes; call read-only).
read get-dx(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, y-amount uint)
Quote X out for Y.
read get-dlp(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, y-amount uint)
LP tokens for an (imbalanced) deposit.
write swap-x-for-y(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, min-dy uint)
Swap X for Y; reverts if output < min-dy. Returns (ok dy).
write swap-y-for-x(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, y-amount uint, min-dx uint)
Swap Y for X.
write add-liquidity(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, y-amount uint, min-dlp uint)
Add any mix of X and Y (the pool applies its liquidity-fee to imbalanced adds). Returns (ok dlp).
write withdraw-liquidity(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, amount uint, min-x-amount uint, min-y-amount uint)
Burn LP for both tokens proportionally.
read get-pool-by-id(id uint)
Pool registry (2 pools at research time; see get-last-pool-id).
StableSwap STX/stSTX v1.2 (legacy pair contract)pool on stacksSPQC38PW542EQJ5M11CR25P7BS1CA6QT4TBXGB3M.stableswap-stx-ststx-v-1-2
read get-dy(y-token <sip-010-trait>, lp-token <lp-trait>, x-amount uint)
Quote stSTX out for x-amount micro-STX. Use y-token = SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token, lp-token = SPQC38PW542EQJ5M11CR25P7BS1CA6QT4TBXGB3M.stx-ststx-lp-token-v-1-2 (e.g. 1 STX -> 0.839722 stSTX at research time).
read get-dx(y-token <sip-010-trait>, lp-token <lp-trait>, y-amount uint)
Quote STX out for y-amount micro-stSTX (sell direction carries extra fees).
write swap-x-for-y(y-token <sip-010-trait>, lp-token <lp-trait>, x-amount uint, min-y-amount uint)
Swap native STX (x) for stSTX. Returns (ok dy); errors are string-ascii messages. Add an STX post-condition.
write swap-y-for-x(y-token <sip-010-trait>, lp-token <lp-trait>, y-amount uint, min-x-amount uint)
Swap stSTX for STX.
write add-liquidity(y-token <sip-010-trait>, lp-token <lp-trait>, x-amount-added uint, y-amount-added uint, min-lp-amount uint)
Add STX and/or stSTX; mints stx-ststx-lp-token-v-1-2.
write withdraw-liquidity(y-token <sip-010-trait>, lp-token <lp-trait>, lp-amount uint, min-x-amount uint, min-y-amount uint)
Burn LP for STX and stSTX.
read get-pair-data(y-token <sip-010-trait>, lp-token <sip-010-trait>)
Pair state: balances, amplification coefficient, total shares, approval, decimals.
XYK core v1.1 (legacy)router on stacksSM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-core-v-1-1
write swap-x-for-y(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, min-dy uint)
Legacy v1.1 XYK swap (pools like xyk-pool-stx-aeusdc-v-1-1). Prefer v1.2; v1.1 pools may be disabled (last core call was set-pool-status).
write withdraw-liquidity(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, amount uint, min-x-amount uint, min-y-amount uint)
Remove liquidity from a legacy v1.1 pool.
read get-pool-by-id(id uint)
Legacy pool registry.