preHooks
are executed on the Squid Multicall contract on the fromChain
before any swaps or bridging has occurred.
After preHooks
, the full balance on the Multicall will be swapped or bridged across chains.
The fromToken
and fromAmount
in your route request should be the amount of tokens you expect to on the Multicall after the preHooks
are executed.
Example: repay an AAVE loan before swapping
// Create contract interface and encode repay function for Aave
const aaveLendingPoolInterface = new ethers.utils.Interface(aavePoolAbi);
const repayEncodedData = aaveLendingPoolInterface.encodeFunctionData('repay', [
repayAsset,
repayAmount,
repayInterestRateMode,
repayOnBehalfOf,
]);
const preHooks = [
{
callType: 0, // SquidCallType.DEFAULT
target: aavePoolAddress,
value: '0',
callData: repayEncodedData,
estimatedGas: '50000',
payload: {
tokenAddress: repayAsset,
inputPos: 1,
},
},
]
Last updated