⚡Zap SDK
Wido Router enables single transaction swaps of any token, including non-liquid tokens like vaults, pools or farms. It is available on all EVM chains.
Pivot alert: Wido has become Walnut. This docs as well as the Wido Zap API will be discontinued. Read full announcement.
Wido JavaScript SDK enables integration with full control over the UX. If speed is important to you, try the Wido Widget.
Demo
You can see it live here. For example, try swapping DAI for yvcrvstETH.
API Reference
The API Reference docs can be found at https://unpkg.com/wido@latest/docs/index.html.
Getting Started
In this guide, we will let the user deposit any token into a pool of choice. We will use Wido Router to find the most efficient route to deposit the user's token into the pool, create a transaction bundle and execute the whole bundle as a single transaction.
Approve Wido Smart Contract for the Swap
Request quote and transaction details from the Wido API
Enable the user to execute the transaction from their wallet
Preparation: Install Wido SDK using NPM
Step 1: Approve Wido for the Swap transaction
In this step, create an approve
transaction to allow the Wido Contract to access the token being transferred (the input token
).
If you have custom approve logic and cannot use Wido'sapprove
method, check out the getWidoSpender
method below, which you can use to get the address which needs to be approved for spending tokens on the user's behalf.
https://docs.joinwido.com/api-guides/router#get-the-contract-address-for-approvals
RunKit example: https://runkit.com/wido/approve.
Step 2: Receive a Quote
Request a quote for the Zap transaction.
Note: steps
object contains details about the transaction route.
We do our best to provide accurate pricing (for fromTokenUsdPrice
and toTokenUsdPrice
), but it might not be available for some tokens. Please reach out if you want dedicated pricing support. Read more on pricing here: https://docs.joinwido.com/api-guides/pricing.
Step 3: Execute the Swap transaction
In this step, execute the Zap transaction using data received from calling the quote
.
RunKit example: https://runkit.com/wido/quote.
Get list of Supported Tokens
Get the list of supported tokens on all chains or on a specific chain. Zap between any supported token is possible in and across the supported chains.
See the API reference: https://unpkg.com/wido@latest/docs/functions/getSupportedTokens.html.
Edit and run this example on RunKit: https://runkit.com/wido/get-supported-tokens.
Get list of User Balances
Get the list of supported tokens found in the user's wallet, on all chains or on a specific chain, that can be used for depositing. Zap between any supported token is possible in and across the supported chains.
We do our best to provide accurate pricing (for balanceUsdValue
and usdPrice
), but it might not be available for some tokens. Please reach out if you want dedicated pricing support. Read more on pricing here: https://docs.joinwido.com/api-guides/pricing.
Get token allowance
Get the number of tokens that the Wido contract can spend on the user's behalf, as per the ERC-20 standard.
See the API reference: https://unpkg.com/wido@latest/docs/functions/getTokenAllowance.html.
Edit and run this example on RunKit: https://runkit.com/wido/get-token-allowance.
Get the contract address for approvals
Get contract address that the user needs to approve before zapping. As per the ERC20 standard, Wido needs permission to spend tokens on behalf of user
.
See the API reference: https://unpkg.com/wido@latest/docs/functions/getWidoSpender.html.
Edit and run this example on RunKit: https://runkit.com/wido/get-wido-spender.
Warning: WidoTokenManager and WidoRouter are two separate contracts. ERC-20 approvals are made to WidoTokenManager and orders are sent to WidoRouter.
When you call approve
always send the transaction to the to
address returned in the response.
When you call quote
always send the transaction to the to
address returned in the response.
Last updated