Skip to main content

What if token allowance is too low?

If the user spends an ERC-20 through the router and allowance is too low, submit the approval or preTransactions first, then the route transaction. Use the spender returned in the response.

J
Written by Javier Diaz

If the user is spending an ERC-20 through the Enso router and allowance is too low, submit the approval (or any preTransactions) first, then submit the route transaction. Use the spender returned in the response, not a hardcoded address.

Definition

An ERC-20 allowance is permission for a spender contract to move a token from the user’s wallet. With the router strategy, that approval is required when allowance is not already high enough. It is not required for every strategy: delegate does not need a prior approval.

How it works

  1. Read the quote. If an approval is required, show the token, spender, amount, and chain.

  2. Submit the approval transaction and wait for confirmation.

  3. Submit the returned route or bundle tx as-is.

  4. If execution reverts because allowance is still too low, do not skip the approval or point it at an address from a deployments list.

How Enso does this

For a typical EOA flow, use routingStrategy: "router" and, when needed, GET https://api.enso.build/api/v1/wallet/approve. Approve the spender returned in approvals, not an address copied from the deployments page. The Route or Bundle response’s tx.to is the execution contract for that request. See Core Concepts and Contracts and Deployments.

FAQ

Why is approval required again?

Allowance may be below this input, the spender may differ by strategy or chain, or a previous approval was for a different token. Follow the response’s approval instructions.

Do smart-wallet flows need this?

The delegate strategy is built for smart wallets and does not require a prior approval. Some actions, including borrow, harvest, and repay, must use delegate.

Related articles

  • Why did the transaction fail on-chain after I got a quote?

  • Should I hardcode Enso contract addresses?

  • How do I handle token approvals in a routing flow?

  • How do I add a same-chain swap to my app?

  • What is a routing strategy?

Sources

Did this answer your question?