Chainflip Vault Swap Approvals: How to Estimate the Amount
Estimate a Chainflip vault swap approval by comparing the token allowance for the Vault with the quoted input amount; native assets need no ERC-20 approval.
Crypto Bulletin Newsroom 2 min read
A Chainflip EVM vault swap needs an ERC-20 approval only if the wallet’s allowance for the Vault is below the quoted input amount, according to Chainflip’s SDK documentation. Native assets such as ETH do not need token approval; for ERC-20s, the SDK’s example approves the quoted deposit amount.
That check is separate from the swap itself: an approval lets the Vault contract spend tokens from the wallet, while the swap transaction calls the Vault with the encoded swap details. For route and tracking details beyond this check, see the fuller guide to choosing and tracking a native Chainflip swap.
How do you calculate the approval amount?
Compare the token’s current allowance with the input amount in the quote, using the token’s smallest units. Chainflip’s SDK example uses a 500 USDC input represented as 500 million units, then passes the quote’s deposit amount to the token’s approve function.
Read the allowance for the wallet address and the exact Vault spender address returned with the encoded swap data. If the allowance is lower than the required amount, the shortfall is the additional approval needed; if it is equal or higher, no new approval is required.
- Check the source chain and token contract address.
- Use the quoted deposit amount in base units, not a rounded display amount.
- Check allowance for your wallet and the returned Vault address.
- Compare the allowance and required amount before signing.
How many transactions should you expect?
For an ERC-20 input with insufficient allowance, plan for an approval transaction followed by the vault swap transaction, as shown in Chainflip’s SDK flow. If the allowance already covers the quote, the swap can be the only transaction; a native-asset swap also skips the ERC-20 approval.
Estimate gas for each transaction separately, since the approval and swap are distinct calls. The exact gas cost depends on the chain, token contract, and network conditions, so a wallet’s estimate is more useful than a fixed figure.
Should you approve the exact amount or more?
An exact approval limits the Vault’s allowance to the amount needed for this swap, while a larger or unlimited allowance can avoid another approval transaction on a later swap. Chainflip’s example uses the quote’s deposit amount, which keeps the permission tied to the current input.
For a one-off swap, approving only the amount required is the simpler estimate: check whether the existing allowance already covers it, then approve the shortfall or exact input as appropriate. Confirm that the wallet prompt names the token and intended Vault address; some token contracts may also require allowance changes in a particular sequence.
Chainflip’s SDK documentation says deposit channels can avoid token approvals and may cost less, while vault swaps use a direct contract call. The choice depends on the route and quote: compare the vault-swap quote with the available deposit-channel option before deciding how to send the input.