Use a shared template
1. Encode the config params
bytes memory params = abi.encode(
routers, // address[] allowlisted swap routers
tokensIn, // address[] tokens the agent may sell
tokensOut, // address[] tokens the agent may buy
maxAmountPerTx, // uint256 per-swap input cap
maxSlippageBps, // uint256 max slippage in bps (< 10000)
priceOracle, // address IOracle; address(0) disables the oracle check
maxPriceAgeSec // uint256 required freshness bound if priceOracle != 0
);2. Configure + register in one transaction
factory.attach{value: registrationFee}(
account,
template, // the SharedBoundedSwapPermission deployment
params,
configureDeadline,
configureSig, // Permission Signer EIP-712 over Configure(account, keccak256(params), nonce, deadline)
kernelDeadline,
kernelSig // Permission Signer EIP-712 over RegisterPermission(account, template, nonce, deadline)
);3. Dispatch a swap
4. Reconfigure or replace
Last updated

