ZkPadSwapRouter
Source: contracts/src/periphery/ZkPadSwapRouter.sol · GPL-2.0-or-later.
Purpose
A minimal single-pool router used by the zk-pad UI. Swaps run inside vault.lock. The input is
pulled from the caller (ERC20 allowance) or wrapped from msg.value when the input currency is
WBNB, and a WBNB output can be unwrapped to native BNB. Every swap has a deadline and a slippage
bound; unused native value is refunded. Any other Infinity router works too, because the hook
ignores hookData.
Functions
struct ExactInputSingleParams {
PoolKey poolKey;
bool zeroForOne;
uint128 amountIn;
uint128 amountOutMinimum;
uint160 sqrtPriceLimitX96; // 0 = no limit
address recipient;
uint256 deadline;
bool unwrapOutput; // deliver WBNB output as BNB
bytes hookData;
}
function exactInputSingle(ExactInputSingleParams calldata) external payable returns (uint256 amountOut);
function exactOutputSingle(ExactOutputSingleParams calldata) external payable returns (uint256 amountIn);
ExactOutputSingleParams has amountOut and amountInMaximum instead of amountIn and
amountOutMinimum.
- To pay in BNB: input currency WBNB and
msg.value == amountIn(exact-in) ormsg.value == amountInMaximum(exact-out; the unused part is refunded). receive()accepts BNB only from WBNB (unwraps).
Events
Swap(sender, recipient, tokenIn, tokenOut, amountIn, amountOut).
Errors
DeadlinePassed(deadline), TooLittleReceived(minAmountOut, amountOut),
TooMuchRequested(maxAmountIn, amountIn), InvalidMsgValue, InvalidUnwrap,
NativeCurrencyNotSupported, OnlyVault, ZeroAddress, ZeroAmount, NativeTransferFailed,
NegativeOutput(delta).