Skip to content

Commit 06f7faf

Browse files
committed
fix: support sellEthForTokenToUniswapV3 multihop
1 parent 7c17ba1 commit 06f7faf

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/parsers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export async function sellEthForTokenToUniswapV3({
198198
}) {
199199
const logs = await transferLogs({ publicClient, transactionReceipt });
200200
const from = getAddress(transactionReceipt.from);
201-
const inputLog = logs.find((log) => from !== log.to);
201+
const inputLog = logs.find((log) => log.address === CONTRACTS.weth);
202202
const outputLog = logs.find((log) => from === log.to);
203203

204204
if (inputLog && outputLog) {
Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, it } from "vitest";
22
import { parseSwap } from "../index";
33
import { NATIVE_ASSET } from "../constants";
4-
import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"
4+
import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi";
55

66
require("dotenv").config();
77

@@ -11,24 +11,48 @@ if (!ETH_MAINNET_RPC) {
1111
throw new Error("Missing environment variable `ETH_MAINNET_RPC`");
1212
}
1313

14-
// https://etherscan.io/tx/0xc552e83ef96c5d523f69494ae61b7235a6304ab439e127eb0121d33bbcdaa1ff
14+
// https://etherscan.io/tx/0x54362c24134d62243ea80dd0e7f77f0c62718f25fbffc6caafdd7b52f702359c
1515
it("parses swap from sellEthForTokenToUniswapV3", async () => {
1616
const data = await parseSwap({
1717
exchangeProxyAbi,
1818
rpcUrl: ETH_MAINNET_RPC,
19-
transactionHash: '0xc552e83ef96c5d523f69494ae61b7235a6304ab439e127eb0121d33bbcdaa1ff',
19+
transactionHash:
20+
"0x54362c24134d62243ea80dd0e7f77f0c62718f25fbffc6caafdd7b52f702359c",
21+
});
22+
23+
expect(data).toEqual({
24+
tokenIn: {
25+
symbol: "ETH",
26+
amount: "0.098091206429872",
27+
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
28+
},
29+
tokenOut: {
30+
symbol: "똥코인",
31+
amount: "49330077428.84485198095946916",
32+
address: "0x4208Aa4d7A9a10f4f8bb7f6400c1b2161D946969",
33+
},
34+
});
35+
});
36+
37+
// https://etherscan.io/tx/0x93e0e2967309835c4eb5443b67b6c886839b6a5c0626d33c7df976153cb224d7
38+
it("parses swap from sellEthForTokenToUniswapV3", async () => {
39+
const data = await parseSwap({
40+
exchangeProxyAbi,
41+
rpcUrl: ETH_MAINNET_RPC,
42+
transactionHash:
43+
"0x93e0e2967309835c4eb5443b67b6c886839b6a5c0626d33c7df976153cb224d7",
2044
});
2145

2246
expect(data).toEqual({
2347
tokenIn: {
2448
symbol: NATIVE_ASSET.symbol,
25-
amount: "2.749441612813630418",
49+
amount: "0.12864375786794413",
2650
address: NATIVE_ASSET.address,
2751
},
2852
tokenOut: {
29-
symbol: "HEX",
30-
amount: "50249.93952297",
31-
address: '0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39',
53+
symbol: "CGPT",
54+
amount: "3895.128022043192070174",
55+
address: "0x25931894a86D47441213199621F1F2994e1c39Aa",
3256
},
3357
});
3458
});

0 commit comments

Comments
 (0)