ActionSimple
ActionSimple provides gas-optimized swap and liquidity functions using on-chain approximation instead of off-chain hints.
Last updated
ActionSimple provides gas-optimized swap and liquidity functions using on-chain approximation instead of off-chain hints.
Source: src/fira_bonding/router/ActionSimple.sol
A parallel set of swap and liquidity functions that use MarketApproxLibOnchain instead of the off-chain binary search approximation. These are called internally by the main action facets when guessOffchain == 0 and no limit orders are present.
The main facets (ActionSwapBTV3, ActionSwapCTV3, etc.) check canUseOnchainApproximation() in ActionDelegateBase. If true, they delegate to ActionSimple via address(this).delegatecall(...), which runs ActionSimple's code in the router's storage context.
swapExactFwForBtSimple — FW → BT using on-chain closed-form approximation
swapExactTokenForBtSimple — Token → FW → BT
swapExactTokenForCtSimple / swapExactCtForTokenSimple — CT swaps
addLiquiditySingleBtSimple / addLiquiditySingleFwSimple — Single-sided LP
addLiquiditySingleTokenSimple / addLiquiditySingleTokenKeepCtSimple — Token-based LP
On-chain approximation provides a simpler code path with lower gas cost for straightforward operations, at the expense of slightly less precise swap amounts compared to the off-chain binary search method.
Last updated