Protocols / Dexs
Bitflow
The main DEX on Stacks (Bitcoin L2). Agents can swap and LP through HODLMM (bin-based concentrated liquidity, DLMM), XYK constant-product pools and StableSwap pools, or get the best route across Bitflow and other Stacks DEXs from Bitflow's public Quote API, which returns ready-made contract-call parameters.
On-chain + APIMIXED9 contractsWebsite · Docs
get_protocol({ "protocol": "bitflow" })Risks an agent should know
- 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.
- Stacks transactions should use Deny-mode post-conditions; without them a malicious token trait could move more funds than expected. Only pass token/pool traits that match the pool's own x-token/y-token.
- Many listed tokens are bridged (sBTC, aeUSDC, USDCx, pBTC etc.) and carry their bridge's risk.
What an agent 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. |
Contracts
stacks
| Contract | Address | Key functions | Try |
|---|---|---|---|
| HODLMM (DLMM) swap router v1.2 router | SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-swap-router-v-1-2 source | writeswap-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)) writeswap-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)) writeswap-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)) writeswap-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)) writeswap-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)) writeswap-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)) | |
| HODLMM (DLMM) liquidity router v1.2 router | SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-liquidity-router-v-1-2 source | writeadd-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)) writeadd-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)) writewithdraw-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)) writewithdraw-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)) writewithdraw-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)) writemove-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)) writemove-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)) | |
| HODLMM pool sBTC/USDCx (bin step 10) pool | SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD.dlmm-pool-sbtc-usdcx-v-1-bps-10 source | readget-pool() readget-active-bin-id() readget-bin-balances(id uint) readget-user-bins(user principal) readget-balance(token-id uint, user principal) readget-overall-balance(user principal) | |
| XYK core v1.2 (constant-product AMM) router | SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-core-v-1-2 source | readget-dy(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint) readget-dx(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, y-amount uint) readget-dlp(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint) writeswap-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) writeswap-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) writeadd-liquidity(pool-trait <xyk-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, min-dlp uint) writewithdraw-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) readget-pool-by-id(id uint) +1 more via get_protocol | |
| XYK multi-hop swap helper v1.2 router | SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-swap-helper-v-1-2 source | writeswap-helper-a(amount uint, min-received uint, xyk-tokens {a: <xyk-ft-trait>, b: <xyk-ft-trait>}, xyk-pools {a: <xyk-pool-trait>}) writeswap-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>}) readget-quote-a(amount uint, xyk-tokens {a: <xyk-ft-trait>, b: <xyk-ft-trait>}, xyk-pools {a: <xyk-pool-trait>}) readget-swap-status() | |
| STX SIP-010 wrapper for XYK v1.2 (token-stx-v-1-2) token | SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.token-stx-v-1-2 source | writetransfer(amount uint, sender principal, recipient principal, memo (optional (buff 34))) readget-balance(address principal) | |
| StableSwap core v1.2 (Curve-style pools) router | SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.stableswap-core-v-1-2 source | readget-dy(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint) readget-dx(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, y-amount uint) readget-dlp(pool-trait <stableswap-pool-trait>, x-token-trait <sip-010-trait>, y-token-trait <sip-010-trait>, x-amount uint, y-amount uint) writeswap-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) writeswap-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) writeadd-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) writewithdraw-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) readget-pool-by-id(id uint) | |
| StableSwap STX/stSTX v1.2 (legacy pair contract) pool | SPQC38PW542EQJ5M11CR25P7BS1CA6QT4TBXGB3M.stableswap-stx-ststx-v-1-2 source | readget-dy(y-token <sip-010-trait>, lp-token <lp-trait>, x-amount uint) readget-dx(y-token <sip-010-trait>, lp-token <lp-trait>, y-amount uint) writeswap-x-for-y(y-token <sip-010-trait>, lp-token <lp-trait>, x-amount uint, min-y-amount uint) writeswap-y-for-x(y-token <sip-010-trait>, lp-token <lp-trait>, y-amount uint, min-x-amount uint) writeadd-liquidity(y-token <sip-010-trait>, lp-token <lp-trait>, x-amount-added uint, y-amount-added uint, min-lp-amount uint) writewithdraw-liquidity(y-token <sip-010-trait>, lp-token <lp-trait>, lp-amount uint, min-x-amount uint, min-y-amount uint) readget-pair-data(y-token <sip-010-trait>, lp-token <sip-010-trait>) | |
| XYK core v1.1 (legacy) router | SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-core-v-1-1 source | writeswap-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) writewithdraw-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) readget-pool-by-id(id uint) |
APIs
| Bitflow Quote/App API v2 (HODLMM engine and aggregator) auth: none | https://bff.bitflowapis.finance/api GET /quotes/v2/pools, /quotes/v2/tokens, /quotes/v2/bins/{pool_id}; POST /quotes/v2/quote (best route incl. other Stacks DEXs) then /quotes/v2/swap or /quotes/v2/agg/swap for contract_address, function_name, args and Deny-mode post-conditions; GET /app/v2/users/{user}/positions/{pool_id}/current-bins to size LP withdrawals. Check /quotes/v2/status tip_lag == 0 first. 100 req/s per IP without a key. |
| Bitflow public ticker auth: none | https://bitflow-sdk-api-gateway-7owjsmt8.uc.gateway.dev/ticker 24h prices, volumes and USD liquidity per pair. |
| Bitflow SDK (@bitflowlabs/core-sdk) auth: none | https://www.npmjs.com/package/@bitflowlabs/core-sdk TypeScript SDK for token lists, routes, quotes and swap execution; API keys optional (500 req/min per IP default). |
Notes
Stacks is a Clarity-VM chain, so vm is 'mixed', chainId is null and addresses are contract principals. Signatures are Clarity (name(arg type, ...)); trait arguments are passed as contract principals. Sources: the DLMM swap/liquidity routers are named in the official HODLMM API docs (v1 page), the sBTC/USDCx pool in the v2 docs, stableswap-stx-ststx-v-1-2 and xyk-core-v-1-1 on the docs 'Deployed Contracts > Stacks' page, and xyk-core-v-1-2, xyk-swap-helper-v-1-2, stableswap-core-v-1-2 and token-stx-v-1-2 in Bitflow's official npm SDK (@bitflowlabs/core-sdk 4.2.0, dist/src/keeper/types.js ALLOWED_CONTRACTS, and pool data) — the docs deployed-contracts page has not been updated for these v1.2 contracts, but they are the active ones (xyk-core-v-1-2 ~144k txs vs v1.1 ~10k). Every contract was confirmed via the Hiro API (interface/source) on 2026-11-25 and signatures were taken from the deployed Clarity source. Left out: dlmm-core-v-1-1 (the routers call SP1PFR4V08H1RAZXREBGFFQ59WB739XM8VVGTFSEA.dlmm-core-v-1-1, but that address is not listed on any official page I could find), Bitflow's agg-* aggregator routers (only agg-treasury-v-1-1 is named in docs; the Quote API returns the router to call), the other legacy StableSwap pairs/earn/LP-token contracts and the old cross-DEX routers/wrappers on the deployed-contracts page (still listed there; see that page), keeper contracts, and individual pool contracts beyond one HODLMM example (discover pools via GET /quotes/v2/pools or core get-pool-by-id).
Sources
- https://defillama.com/protocol/bitflow
- https://api.llama.fi/protocol/bitflow
- https://docs.bitflow.finance/bitflow-documentation/llms.txt
- https://docs.bitflow.finance/bitflow-documentation/developers/deployed-contracts/stacks
- https://docs.bitflow.finance/bitflow-documentation/developers/hodlmm-api-documentation
- https://docs.bitflow.finance/bitflow-documentation/developers/hodlmm-api-documentation-v2
- https://docs.bitflow.finance/bitflow-documentation/developers/public-api-documentation
- https://docs.bitflow.finance/bitflow-documentation/developers/bitflow-sdk
- https://docs.bitflow.finance/bitflow-documentation/developers/public-repositories
- https://docs.bitflow.finance/bitflow-documentation/resources/audits
- https://docs.bitflow.finance/bitflow-documentation/resources/bug-bounty-program
- https://www.npmjs.com/package/@bitflowlabs/core-sdk
- https://registry.npmjs.org/@bitflowlabs/core-sdk/-/core-sdk-4.2.0.tgz
- https://github.com/BitflowFinance/bitflow-dlmm
- https://github.com/BitflowFinance/bitflow-stableswap
- https://bff.bitflowapis.finance/api/quotes/v2/status
- https://bff.bitflowapis.finance/api/quotes/v2/pools
- https://api.hiro.so/v2/contracts/interface/SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD/dlmm-swap-router-v-1-2
- https://api.hiro.so/v2/contracts/source/SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD/dlmm-liquidity-router-v-1-2
- https://api.hiro.so/v2/contracts/source/SM1FKXGNZJWSTWDWXQZJNF7B5TV5ZB235JTCXYXKD/dlmm-pool-sbtc-usdcx-v-1-bps-10
- https://api.hiro.so/v2/contracts/source/SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR/xyk-core-v-1-2
- https://api.hiro.so/v2/contracts/source/SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR/xyk-swap-helper-v-1-2
- https://api.hiro.so/v2/contracts/interface/SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR/stableswap-core-v-1-2
- https://api.hiro.so/v2/contracts/source/SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR/token-stx-v-1-2
- https://api.hiro.so/v2/contracts/source/SPQC38PW542EQJ5M11CR25P7BS1CA6QT4TBXGB3M/stableswap-stx-ststx-v-1-2
- https://api.hiro.so/v2/contracts/interface/SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR/xyk-core-v-1-1
Researched 2026-11-25. Addresses are copied from the official sources above; check them before moving large amounts.