Developer Guides

Wire BTR into a contract, a bot, or a front end, from Solidity, TypeScript, Python or Rust. Quotes and routes are computed off chain; a chosen path is then settled either by calling each pool from the caller’s own wallet, or in one transaction through the Router. Find your intent in the action matrix, then follow the link. Every call below is runnable and tested in the integration examples.

Addresses for every chain come from GET /v1/venues; never hardcode them. See deployed instances for the current fleet.


1. Sections

SectionContents
5.1. On-chain IntegrationSolidity: swap, deposit, withdraw, liability swap · pool deployment · hooks · flash · consuming price feeds
5.2. API & SDKGateway HTTP reference · @btr-protocol/sdk · quotes & routing · recipes
5.3. OperationsWhite-label fronts · protocol fee collection · liquidity incentivization

New to the protocol? Start with Basic Operations §10: addresses, faucet, first swap.


2. Action matrix

On-chain names are authoritative.

IntentPreferOn-chain callNotes
Market swapPOST /v1/routeplanToLegsbuildSwapCallsPool.swap × N, or Router.swapMulti-pool and split fills. Quotes & Routing
Multi-hop in one transactionbuild Part[] + Floor[] off chainRouter.swapOne signature, all or nothing, end-to-end floors. Composability §2
Single-pool swapgetSwapQuote + swapPool.swapFixed venue, aggregator hop
Deposit (same asset)deposit / buildDepositCallsPool.depositOpening a leg sinks deadLp
Dual-route mintrankDepositbuildDepositCallsswap then deposit, or the reverseMarket-first vs deposit-first
Withdraw (same asset)withdrawPool.withdrawHaircut below 100% coverage
Cross-asset exitrankRedeembuildRedeemCallswithdrawTo, or swapLiability + withdrawCookbook §3
Transfer liabilityencode via POOL_ABIPool.swapLiabilityMoves an LP claim across legs; no reserve move
Donateencode via POOL_ABIPool.donateRaises the LP index. Seed the leg first (Incentivization §3)
Flash loanFlash.flashLoanERC-3156-style, postFlashLoanComposability §1
Collect protocol feesAdmin.collectProtocolFeescaller must be pool.treasury()Protocol Fee Collection
Deploy a poolPoolFactory.createPoolbeacon proxyPermissionless; tokens must be non-empty. Listing needs the AC owner. Deployment & Curation
Read a BTR price feedIOracle.getFeed + isFeedFreshExternalOracleV4.getFeedThird-party consumers. Gate on freshness and the pause bit. Consuming Price Feeds
Custom mark adapterimplement IOracleADD_ASSET with EXTERNAL modeOracle configuration
Yield / dual ledgerhook + AdminUPDATE_HOOKHooks
Depth ladderPOST /v1/depth-Off-chain only. Quotes & Routing §5

Limit and stop orders are front-end constructs, not on-chain order types.


3. Non-negotiables

  1. Route selection is off chain. Best execution is a search over every pool’s curve, coverage and marks, so it is computed off chain and the result is brought to the contracts. Settle it as approve + Pool.swap calls batched with EIP-5792 wallet_sendCalls, or hand the whole path to Router.swap in one transaction. The Router executes a path; it never searches for one. Plans and legs are per chain.
  2. Multicall3 cannot swap. Pool.swap pulls tokenIn from msg.sender, which under Multicall3 is the multicall contract. Calls must originate from the user.
  3. IPool.sol does not declare the trading functions. They live on Pool.sol. Use the interface block in Basic Operations §1 or a live ABI from /v1/abis/Pool.
  4. createPool is permissionless; administration is not. Listing assets, oracles, curves and hooks all resolve to the chain’s single AccessControl owner (Ownership model).
  5. Prefer EXTERNAL marks. EXTERNAL reads IOracle.getFeed; INTERNAL is a 1.0 peg helper for cash-collateralized 1:1 tokens only (Oracles).
  6. Always pass a real minAmountOut. Nothing bounds the quoted spread from above (Basic Operations §7).

4. Call graph

User wallet

EIP-5792 wallet_sendCalls or sequential txs

ERC-20 approve

WETH deposit / withdraw

Pool.swap

Router.swap (multi-hop, one tx)

Pool.deposit

Pool.withdraw / withdrawTo

Pool.swapLiability

Flash.flashLoan

Pool.flashPrepare / flashSend

AC owner

Admin.addAsset / requestOp

Anyone

PoolFactory.createPool

LayerRole
POST /v1/quote, /v1/route, /v1/depthStateless pricing kernels. Same integer arithmetic as the contracts, run on state you supply
GET /v1/venues, /v1/abis/{name}Addresses and ABIs, live per chain
@btr-protocol/sdkCalldata builders, on-chain reads, off-chain AIMM replica
Pool / Router / Admin / Flash / PoolFactoryOn-chain entry points, one set per chain