Transferring the remainder to a user
const SquidCallType = {
"DEFAULT": 0,
"FULL_TOKEN_BALANCE": 1,
"FULL_NATIVE_BALANCE": 2,
"COLLECT_TOKEN_BALANCE": 3
}Transferring remainder if the token is an ERC20:
const erc20ContractInterface = new ethers.utils.Interface(erc20Abi);
const transferRemainingEncodeData = erc20ContractInterface.encodeFunctionData(
"transfer",
[signer.address, "0"] // amount is set to zero, but full balance is used, see comment below
);
{
callType: SquidCallType.FULL_TOKEN_BALANCE,
target: erc20TokenAddress,
value: "0",
callData: transferRemainingEncodeData,
payload: {
tokenAddress: erc20TokenAddress,
inputPos: 1, // argument position of amount
},
estimatedGas: "50000",
}, Transferring remainder if the token is native:
Last updated