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 a different callType

export enum SquidCallType {
  DEFAULT = 0,
  FULL_TOKEN_BALANCE = 1,
  FULL_NATIVE_BALANCE = 2,
  COLLECT_TOKEN_BALANCE = 3, // unused in hooks
}
const repayLoanCall = {		
	callType: SquidCallType.DEFAULT, 0
	target: aavePoolAddress,
	value: '0',
	callData: repayEncodedData,
	estimatedGas: '50000',
	payload: {
		tokenAddress: repayAsset,
		inputPos: 1,
}

Last updated