--- name: avax-lfj description: Build LFJ Liquidity Book v2.2 swaps with exact bin paths, enum versions and full-fill checks. --- # LFJ Liquidity Book v2.2 1. Select version/surface from [Avalanche deployments](https://developers.lfj.gg/deployment-addresses/avalanche). V1, LB v2.0/v2.1/v2.2 and aggregation differ. `examples/protocols/lfj/recipe.mjs` uses v2.2 router 0x18556DA13313f3532c54711497A8FedAC273220E and factory 0xb43120c4745967fa9b93E79C149E66B0f2D6Fe0c. Paths/commands resolve from the executable bundle root. 2. Call `inspect({provider,blockTag,amountIn})` on chain43114. Verify runtime, router factory/WNATIVE, pair factory/tokenX/tokenY/binStep and factory record/routing eligibility. Sample pair: 0x864d4e5Ee7318e97483DB7EB0912E09F161516EA, WAVAX/native USDC, step10. Clone runtime and implementation ABI provenance are separate. 3. Quote exact raw input through getSwapOut. Default '10000000000000000' is 0.01 WAVAX. Inspected X=WAVAX, Y=USDC means swapForY=true. Returned uint128 fields are amountInLeft, amountOut, fee. Reject any positive leftover: partial output is not proceeds of spending the full requested input. Require positive full-fill output. 4. Encode swapExactTokensForTokens path as pairBinSteps:uint256[], versions:uint8[], tokenPath:address[]. One hop lengths are1,1,2. Enum: V1=0, V2=1, V2_1=2, V2_2=3. The number2 does NOT meanv2.2. Bin step is not a fee tier. Preserve per-hop versions from broader LBQuoter routes instead of replacing them with this fixture. 5. Build `plan(input,evidence)`: action:'swap', chainId:43114, owner, recipient, exact token addresses, integer-string amountIn/amountOutMinimum, slippageBps, deadline. Require fresh matching chain/block/amount/full-fill evidence, exact pair/bin/version/direction, nonzero owner/recipient and bounded slippage/minimum. Return reset allowance, exact router approval and unsigned swap value0. 6. For native AVAX use a separately reviewed payable native method; never attach AVAX to this ERC20 call. Requote/simulate after approval or changed input. Run the commands below and verify actual token deltas, allowance consumption and LBRouter__InsufficientAmountOut rejection. ```sh node --test examples/protocols/lfj/recipe.test.mjs node research/parity-dexes/run-live.mjs node research/parity-dexes/fork-execution.mjs ``` ## Extend deliberately Canonical WAVAX (wrapped native AVAX) is 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7; native USDC is 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E. Recheck source/runtime/decimals rather than selecting tickers. For new pairs discover from the correct factory, check ignoredForRouting, X/Y and bin step, then quote the requested size. Dynamic fees and traversed liquidity are state-dependent. This sample excludes arbitrary multihop, fee-on-transfer/rebasing assets, LP minting and rewards. LB positions are bin balances, not V3 NFTs; version-matched liquidity ABIs and minimum-return constraints need their own proof. Evidence expires after300 seconds; reject future/mixed observations, recheck after state changes, and use a future deadline within600 seconds. Quotes and archived fixtures are not price feeds. **Deliver:** versioned pair identity; token direction; full-fill quote; exact spender/calldata; simulation/local deltas; scope. Local-fork receipts are not mainnet transactions. Sources: [deployments](https://developers.lfj.gg/deployment-addresses/avalanche), [swaps](https://developers.lfj.gg/guides/swap-tokens), [liquidity](https://developers.lfj.gg/guides/add-remove-liquidity), [pinned ILBRouter](https://github.com/lfj-gg/joe-v2/blob/067c6ccf5b8ff1526d03fa3e4c65ec45d01c1f73/src/interfaces/ILBRouter.sol).