Execute a Trade
Direct settlement calls multiswap on the Dispatcher.
function multiswap(
address pool,
Amount[] payAssets,
Allocation[] receiveAssets
) external payable;
For direct execution, msg.sender is the payer, recipient, and native-value source.
Settlement structs
type Amount = {
tokenAddress: Address;
amount: bigint; // token base units
};
type Allocation = {
tokenAddress: Address;
allocation: bigint; // 1_000_000 = 100%
minAmount: bigint; // token base units
};
Unlike the quote ABI, these fields do not use packed Float encoding.
Viem example
const hash = await walletClient.writeContract({
account,
address: dispatcher,
abi: multiswapAbi,
functionName: "multiswap",
args: [
pool,
[{ tokenAddress: usdc, amount: 1_000_000n }],
[{ tokenAddress: usdt, allocation: 1_000_000n, minAmount }],
],
value: 0n,
});
ERC-20 approvals
For an external ERC-20 pay asset, the payer must approve the Dispatcher to transfer at least the submitted amount. Approve the exact trade amount when practical and do not approve a module implementation address.
Native assets
Multiswap represents the native asset internally with:
0xE0092BfAe8c1A1d8CB953ed67bd42A4861E423F9
When paying the native asset:
- use that sentinel as
tokenAddress, - set transaction
valueto the sum of native pay amounts, - do not use the zero address,
- do not include extra native value.
Settlement enforces the expected native value exactly.
Before submission
Verify:
- chain ID and Dispatcher,
- pool identity,
- token addresses and decimals,
- receive allocations sum to
1_000_000, - every
minAmountis derived from a fresh settlement quote, - ERC-20 allowance or native
valueis sufficient.
Wait for the transaction receipt and compare realized transfers with the signed minimums and quoted accounting output.