diff --git a/src/parsers/index.ts b/src/parsers/index.ts index a3d6391..cb79a54 100644 --- a/src/parsers/index.ts +++ b/src/parsers/index.ts @@ -149,7 +149,7 @@ export async function sellTokenForEthToUniswapV3({ const logs = await transferLogs({ publicClient, transactionReceipt }); const from = getAddress(transactionReceipt.from); const inputLog = logs.find((log) => log.from === from); - const outputLog = logs.find((log) => log.from !== from); + const outputLog = logs.find((log) => log.address === CONTRACTS.weth); if (inputLog && outputLog) { outputLog.symbol = NATIVE_ASSET.symbol; diff --git a/src/tests/sellTokenForEthToUniswapV3.test.ts b/src/tests/sellTokenForEthToUniswapV3.test.ts index f8451e7..bc1f7fb 100644 --- a/src/tests/sellTokenForEthToUniswapV3.test.ts +++ b/src/tests/sellTokenForEthToUniswapV3.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; import { parseSwap } from "../index"; import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" +import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; require("dotenv").config(); @@ -17,14 +17,15 @@ describe("parseSwap", () => { const data = await parseSwap({ exchangeProxyAbi, rpcUrl: ETH_MAINNET_RPC, - transactionHash: '0x822d38c0746b19544cedddd9a1ebaacadd3e5da55dc293738ae135fc595e269b', + transactionHash: + "0x822d38c0746b19544cedddd9a1ebaacadd3e5da55dc293738ae135fc595e269b", }); expect(data).toEqual({ tokenIn: { symbol: "✺RUG", amount: "56322.215316673764925169", - address: '0xD2d8D78087D0E43BC4804B6F946674b2Ee406b80', + address: "0xD2d8D78087D0E43BC4804B6F946674b2Ee406b80", }, tokenOut: { symbol: NATIVE_ASSET.symbol, @@ -33,4 +34,26 @@ describe("parseSwap", () => { }, }); }); + + it("parses swap from sellTokenForEthToUniswapV3", async () => { + const data = await parseSwap({ + exchangeProxyAbi, + rpcUrl: ETH_MAINNET_RPC, + transactionHash: + "0xf6271c6ae709c31b2679f9190798bc64e636feb8b49d498e6239f171783884df", + }); + + expect(data).toEqual({ + tokenIn: { + symbol: "ETHFI", + amount: "609.2", + address: "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB", + }, + tokenOut: { + symbol: NATIVE_ASSET.symbol, + amount: "0.519590258364550926", + address: NATIVE_ASSET.address, + }, + }); + }); });