Using the full ERC20 or Native balance in a call
The Squid Multicall can update the value of a param on-chain before or after the Swap or bridge has occurred. This lets you do the following:
Send the remainder of tokens to the user's address, after minting or buying something at a fixed price
Stake the full amount received from a swap
Unstake, then swap the full amount across chains
This is designated by using callType
export enum SquidCallType {
DEFAULT = 0,
FULL_TOKEN_BALANCE = 1,
FULL_NATIVE_BALANCE = 2,
COLLECT_TOKEN_BALANCE = 3, // unused in hooks
}
const sendRemainderToUserCall = {
callType: SquidCallType.FULL_TOKEN_BALANCE, // transfer any remaining MAGIC to the user's account
target: magicToken,
value: "0",
callData: transferMagicEncodeData,
payload: {
tokenAddress: magicToken,
inputPos: 1,
},
estimatedGas: "50000",
},
Last updated