generated from yuichiroaoki/typescript-hardhat
-
Notifications
You must be signed in to change notification settings - Fork 174
Supporting Dex Protocols
Yuichiro Aoki edited this page Apr 19, 2022
·
2 revisions
Protocol | Protocol Name |
---|---|
0 | Uniswap V3 |
1 | Sushiswap |
2 | Quickswap |
3 | Jetswap |
4 | Polycat |
5 | Apeswap |
6 | Waultswap |
8 | DODO |
Input a router address for a uniswapV2 fork protocol to swap.
data: ethers.utils.defaultAbiCoder.encode(
["address"],
[findRouterFromProtocol(1)]
),
Input a uniswapV3 router address and a pool fee of a uniswapV3 pool you swap tokens on.
Note: a pool fee has to be multiplied by 10,000.
data: ethers.utils.defaultAbiCoder.encode(
["address", "uint24"],
// 0.05 % => 500 (Input USDC/WETH pool fee)
[findRouterFromProtocol(0), 500]
),
USDC - WETH (100% Sushiswap) -> WETH - USDC (100% UniswapV3)
const tx = await Flashloan.dodoFlashLoan(
{
flashLoanPool: dodoV2Pool.WETH_USDC,
loanAmount: getBigNumber(1000, 6),
firstRoutes: [
{
hops: [
{
swaps: [
{
// protocol number
protocol: 1,
// trading ratio (100% -> 10000, 1% -> 100)
part: 10000,
// byte data used for swapping
data: ethers.utils.defaultAbiCoder.encode(
["address"],
[findRouterFromProtocol(1)]
),
},
],
path: [erc20Address.USDC, erc20Address.WETH],
},
],
part: 10000,
},
],
secondRoutes: [
{
hops: [
{
swaps: [
{
// UniswapV3
protocol: 0,
part: 10000,
data: ethers.utils.defaultAbiCoder.encode(
["address", "uint24"],
// 0.05 % => 500 (Input USDC/WETH pool fee)
[findRouterFromProtocol(0), 500]
),
},
],
path: [erc20Address.WETH, erc20Address.USDC],
},
],
part: 10000,
},
],
},
{
gasLimit: 1000000,
// refer to https://polygonscan.com/gastracker
gasPrice: ethers.utils.parseUnits("60", "gwei"),
}
);