ActionSwapBT

ActionSwapBTV3 provides entry points for swapping tokens or FW to/from Bond Tokens via the Fira Market AMM.

circle-info

Source: src/fira_bonding/router/ActionSwapBTV3.sol

Functions

  • swapExactTokenForBt — User token → FW (mint) → FW sent to market → swap for BT

  • swapExactFwForBt — FW → BT via market swap

  • swapExactBtForToken — BT → FW (market swap) → redeem to user token

  • swapExactBtForFw — BT → FW via market swap

Swap amount calculation

The FW→BT direction uses MarketApproxBtOutLibV2.approxSwapExactFwForBtV2 with binary search and an off-chain hint (guessOffchain). This is needed because the market only supports exact-output BT swaps (swapFwForExactBt), so the approximation library finds the BT amount that uses exactly the available FW.

On-chain fallback

If guessOffchain == 0 and no limit orders are present, the facet delegates to ActionSimple which uses MarketApproxLibOnchain for a closed-form approximation instead.

Last updated