use alloy_sol_types::sol;
sol! {
interface IAlgebraPeripheryRouter {
function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
function unwrapWNativeToken(uint256 amountMinimum, address recipient) external payable;
function refundNativeToken() external payable;
function sweepToken(address token, uint256 amountMinimum, address recipient) external payable;
}
}
#[cfg(test)]
mod tests {
use super::*;
use alloy_sol_types::SolCall;
#[test]
fn multicall_selector_locked() {
assert_eq!(
IAlgebraPeripheryRouter::multicallCall::SELECTOR,
[0xac, 0x96, 0x50, 0xd8],
"multicall(bytes[]) selector must remain 0xac9650d8 (shared with V3 SwapRouter / NFPM)"
);
}
#[test]
fn unwrap_wnative_token_selector_locked() {
assert_eq!(
IAlgebraPeripheryRouter::unwrapWNativeTokenCall::SELECTOR,
[0x69, 0xbc, 0x35, 0xb2],
"unwrapWNativeToken(uint256,address) selector must remain 0x69bc35b2"
);
}
#[test]
fn refund_native_token_selector_locked() {
assert_eq!(
IAlgebraPeripheryRouter::refundNativeTokenCall::SELECTOR,
[0x41, 0x86, 0x52, 0x70],
"refundNativeToken() selector must remain 0x41865270"
);
}
#[test]
fn sweep_token_selector_locked() {
assert_eq!(
IAlgebraPeripheryRouter::sweepTokenCall::SELECTOR,
[0xdf, 0x2a, 0xb5, 0xbb],
"sweepToken(address,uint256,address) selector must remain 0xdf2ab5bb"
);
}
#[test]
fn real_quickswap_polygon_multicall_empty_array_decodes() {
let raw = alloy_primitives::hex!(
"0000000000000000000000000000000000000000000000000000000000000020" "0000000000000000000000000000000000000000000000000000000000000000" );
let decoded = IAlgebraPeripheryRouter::multicallCall::abi_decode_returns(&raw)
.expect("decode bytes[] return");
assert!(
decoded.is_empty(),
"multicall([]) must return empty bytes[]; got len {}",
decoded.len()
);
}
}