How to execute and estimate LiquidCore swaps. Use the router for automatic pool discovery; direct pool calls are also supported.
Swap Function
Recommended: Execute swaps via the LiquidCore Router (0x625aC1D165c776121A52ff158e76e3544B4a0b8B). Approve the router for tokenIn, then call swap(tokenIn, tokenOut, amountIn, minAmountOut). The router discovers the correct pool automatically, so integrators don't need to update code when new pools are added. See Integration Guide.
Option: direct pool. You can call swap on a pool contract directly if you already know the pool address (see Overview). Approve the pool for tokenIn, then call:
error InvalidToken(); // Token not supported by pool
error ZeroAmount(); // Amount input is zero
error SlippageExceeded(); // Output below minAmountOut
error InsufficientReserve(); // Pool lacks sufficient tokens
error TransferFailed(); // Token transfer failed
error PriceDeviationTooLarge(); // Spot price too far from oracle