File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -127,12 +127,16 @@ export async function parseSwap({
127
127
const takerForGaslessApprovalSwap =
128
128
settlerArgs [ 0 ] . recipient . toLowerCase ( ) as Address ;
129
129
130
+ const msgSender = settlerArgs [ 3 ] ;
131
+
130
132
const nativeAmountToTaker = calculateNativeTransfer ( trace , {
131
133
recipient : takerForGaslessApprovalSwap ,
132
134
} ) ;
133
135
134
136
if ( nativeAmountToTaker === "0" ) {
135
- output = output = logs [ logs . length - 1 ] ;
137
+ [ output ] = logs . filter (
138
+ ( log ) => log . to . toLowerCase ( ) === msgSender . toLowerCase ( )
139
+ ) ;
136
140
} else {
137
141
output = {
138
142
symbol : NATIVE_SYMBOL_BY_CHAIN_ID [ chainId ] ,
Original file line number Diff line number Diff line change @@ -329,6 +329,37 @@ test("parse a gasless swap on Base (DAI for USDC)", async () => {
329
329
} ) ;
330
330
} ) ;
331
331
332
+ // https://basescan.org/tx/0xb1ac9977d28e750add3b1a1ebdc95e56a51a9af7fc3d66fa7c011686eac455e6
333
+ test ( "parse a gasless swap on Base (USDC for BRETT) via metaTxn multicall" , async ( ) => {
334
+ const publicClient = createPublicClient ( {
335
+ chain : base ,
336
+ transport : http (
337
+ `https://base-mainnet.g.alchemy.com/v2/${ process . env . ALCHEMY_API_KEY } `
338
+ ) ,
339
+ } ) as PublicClient < Transport , Chain > ;
340
+
341
+ const transactionHash =
342
+ "0xb1ac9977d28e750add3b1a1ebdc95e56a51a9af7fc3d66fa7c011686eac455e6" ;
343
+
344
+ const result = await parseSwap ( {
345
+ publicClient,
346
+ transactionHash,
347
+ } ) ;
348
+
349
+ expect ( result ) . toEqual ( {
350
+ tokenIn : {
351
+ symbol : "USDC" ,
352
+ amount : "1000" ,
353
+ address : "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" ,
354
+ } ,
355
+ tokenOut : {
356
+ symbol : "BRETT" ,
357
+ amount : "18260.873189681406728218" ,
358
+ address : "0x532f27101965dd16442E59d40670FaF5eBB142E4" ,
359
+ } ,
360
+ } ) ;
361
+ } ) ;
362
+
332
363
// https://basescan.org/tx/0xa09cb1606e30c3aed8a842723fd6c23cecd838a59f750ab3dbc5ef2c7486e696
333
364
test ( "parse a swap on Base (USDC for DAI)" , async ( ) => {
334
365
const publicClient = createPublicClient ( {
You can’t perform that action at this time.
0 commit comments