-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com-facuspagnuolo:mimic-fi/v3-core in…
…to connectors/implement_hop_swap_connector
- Loading branch information
Showing
21 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import axios, { AxiosError } from 'axios' | ||
import { BigNumber, Contract } from 'ethers' | ||
|
||
const ONE_INCH_URL = 'https://api.1inch.io/v5.0' | ||
|
||
export type SwapResponse = { data: { tx: { data: string } } } | ||
|
||
export async function get1inchSwapData( | ||
chainId: number, | ||
sender: Contract, | ||
tokenIn: Contract, | ||
tokenOut: Contract, | ||
amountIn: BigNumber, | ||
slippage: number | ||
): Promise<string> { | ||
try { | ||
const response = await getSwap(chainId, sender, tokenIn, tokenOut, amountIn, slippage) | ||
return response.data.tx.data | ||
} catch (error) { | ||
if (error instanceof AxiosError) throw Error(error.toString() + ' - ' + error.response?.data?.description) | ||
else throw error | ||
} | ||
} | ||
|
||
async function getSwap( | ||
chainId: number, | ||
sender: Contract, | ||
tokenIn: Contract, | ||
tokenOut: Contract, | ||
amountIn: BigNumber, | ||
slippage: number | ||
): Promise<SwapResponse> { | ||
return axios.get(`${ONE_INCH_URL}/${chainId}/swap`, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
}, | ||
params: { | ||
disableEstimate: true, | ||
fromAddress: sender.address, | ||
fromTokenAddress: tokenIn.address, | ||
toTokenAddress: tokenOut.address, | ||
amount: amountIn.toString(), | ||
slippage: slippage < 1 ? slippage * 100 : slippage, | ||
}, | ||
}) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/connectors/test/helpers/paraswap-v5/fixtures/42161/105116582/USDC-WETH.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"data": "0xa6886da90000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000004891e1cf3a2e1aeb000000000000000000000000000000000000000000000000494d8995d881517e010000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000649995f30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007973573d1113c256fee02ccf1b1e1be0eb93aad00000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000220690000a4f9c94f57be0c88dde4dca79e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bff970a61a04b1ca14834a43f5de4533ebddb5cc80001f482af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"sig": "0x7bdfe0635d4a2a21ff15455ae33b35e6a8cacbe14d3fee51e0bf9b1e148954ce5cfe94c8ae6e11763a1d53462a0a55b4a8300a578ee57848ffd2b2897eb4f4e21b", | ||
"signer": "0x6278c27CF5534F07fA8f1Ab6188a155cb8750FFA", | ||
"tokenIn": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", | ||
"tokenOut": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", | ||
"amountIn": "10000000000", | ||
"minAmountOut": "5229208922504436459", | ||
"expectedAmountOut": "5282029214650945918" | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/connectors/test/helpers/paraswap-v5/fixtures/42161/105116582/WBTC-USDC.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"data": "0x46c67b6d00000000000000000000000000000000000000000000000000000000000000200000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f0000000000000000000000000000000000000000000000000000000005f5e10000000000000000000000000000000000000000000000000000000007051905d3000000000000000000000000000000000000000000000000000000071740103900000000000000000000000007973573d1113c256fee02ccf1b1e1be0eb93aad0000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000d400000000000000000000000000000000000000000000000000000000064999602960a7daba2c545bfabe2437bd7af9292000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000005600000000000000000000000000000000000000000000000000000000000002328000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000280000000000000000000000000745ec73855cec7249e5ff4c9dd81cc65b4d297a9000000000000000000000000000000000000000000000000000000000000037900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000064a2d060000000000000000000000000000000000000000000000000000000000000002b2f2a2543b76a4166549f7aab2e75bef0aefc5b0f0001f4ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000000000000000000000000000000000000000000000003ad7f275e27ac579ca88e0b4765828242a9e8c49000000000000000000000000000000000000000000000000000000000000239700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000eff23b4be1091b53205e35f3afcd9c7182bf3062000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000320000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000745ec73855cec7249e5ff4c9dd81cc65b4d297a9000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000064a2d060000000000000000000000000000000000000000000000000000000000000002b2f2a2543b76a4166549f7aab2e75bef0aefc5b0f0001f482af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000000000000000000000000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000745ec73855cec7249e5ff4c9dd81cc65b4d297a9000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000fa58b8024b49836772180f2df902f231ba712f72000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000064a2d060000000000000000000000000000000000000000000000000000000000000002882af49447d8a07e3bd95bd0d56f35241523fbab1ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"sig": "0xa044506f1764c9f1152b797c7be49ffcf2b5b01e8bbdc458efb74898676e67be1d23f87072e2f3376d37254dab32ffc83b9d53a7290f29019c429f4b6a579a7e1b", | ||
"signer": "0x6278c27CF5534F07fA8f1Ab6188a155cb8750FFA", | ||
"tokenIn": "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f", | ||
"tokenOut": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", | ||
"amountIn": "100000000", | ||
"minAmountOut": "30150297043", | ||
"expectedAmountOut": "30454845497" | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/connectors/test/helpers/paraswap-v5/fixtures/42161/105116582/WETH-USDC.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"data": "0x54e3f31b000000000000000000000000000000000000000000000000000000000000002000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000006f9f5bfb0000000000000000000000000000000000000000000000000000000070bfffd100000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000007973573d1113c256fee02ccf1b1e1be0eb93aad00000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000649995f83da4e0439a4a4a59bf7c961a70a911f4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000fa58b8024b49836772180f2df902f231ba712f720000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000000000000000000000000000000000000064a2d04c0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002882af49447d8a07e3bd95bd0d56f35241523fbab1ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"sig": "0xf7846923136f7899cef3ca36cfc36420d4c98c8c48c1b6409b9aa20631bcbe4d4c6880e1539a24b4227ea31ed7536b14e537c6e74983e243f7a44118fb4ed6371b", | ||
"signer": "0x6278c27CF5534F07fA8f1Ab6188a155cb8750FFA", | ||
"tokenIn": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", | ||
"tokenOut": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", | ||
"amountIn": "1000000000000000000", | ||
"minAmountOut": "1872714747", | ||
"expectedAmountOut": "1891631057" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.