Package Exports
- wido
- wido/dist/wido.js
- wido/dist/wido.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wido) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
wido
JavaScript library for interacting with the Wido protocol which allows you to seamlessly move liquidity across vaults and chains.
With the help of this package you can enable omni-chain zaps into your dApp.
Learn more about Wido on https://joinwido.com.
Installation
yarn add widoor
npm install --save widoUsage
import { Wido } from "wido"
const fantomChainId = 250
const tokenList = await Wido.getSupportedTokens(fantomChainId)
console.log(tokenList)
// [
// "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75",
// ...
// ]
const widoContractAddress = Wido.getWidoContractAddress(fantomChainId)
console.log(widoContractAddress)
// "0x17C794cA661bC52F9673a65818d0FB15DBb049d0"
const provider = new JsonRpcProvider({ url: "http://localhost:8545" }) // hardhat network (fantom fork)
const signer = new Wallet("0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", provider) // hardhat test account
const userAddress = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" // hardhat test account
const wido = new Wido({ provider, signer })
const { hash: approveTxHash } = await wido.approve({
tokenAddress: "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75", // USDC
spenderAddress: widoContractAddress,
amount: "1234000000", // $1234
})
const allowance = await wido.getTokenAllowance({
tokenAddress: "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75", // USDC
accountAddress: userAddress,
spenderAddress: widoContractAddress,
})
console.log(allowance)
// "1234000000"
const { hash: depositTxHash } = await wido.execute({
user: userAddress,
fromChainId: fantomChainId,
fromToken: "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75", // USDC
toChainId: fantomChainId,
toToken: "0xd02a30d33153877bc20e5721ee53dedee0422b2f", // g3CRV
amount: "1234000000",
options: {
txOverrides: {
gasLimit: 2500000,
},
},
})
console.log(depositTxHash)
// "0x66acd87c5e..."
await wido.approve({
tokenAddress: "0xd02a30d33153877bc20e5721ee53dedee0422b2f", // g3CRV
spenderAddress: widoContractAddress,
amount: "1111000000",
})
const avalancheChainId = 43114
const { hash: withdrawalTxHash } = await wido.execute({
user: userAddress,
fromChainId: fantomChainId,
fromToken: "0xd02a30d33153877bc20e5721ee53dedee0422b2f", // g3CRV on Fantom
toChainId: avalancheChainId,
toToken: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e", // USDC on Avalanche
amount: "11111000000",
})Features
- Typescript ✅
- ES modules ✅
- Docs generated with typedoc ✅
Test
yarn test
yarn coverageBuild
yarn buildDebugging
To debug in VS Code:
Choose a file > Add a breakpoint > Press F5
Read more: https://vitest.dev/guide/debugging.html
Publish
yarn publishLink locally to your app
yalc publishAnd then, in your app, run:
yalc add wido