@@ -417,67 +417,93 @@ GoldRushDecoder.on(
417
417
}
418
418
) ;
419
419
420
- // GoldRushDecoder.on(
421
- // "uniswap-v2:PairCreated",
422
- // ["eth-mainnet"],
423
- // FactoryABI as Abi,
424
- // async (log_event, tx, chain_name, covalent_client): Promise<EventType> => {
425
- // const { raw_log_data, raw_log_topics } = log_event;
426
-
427
- // const { args: decoded } = decodeEventLog({
428
- // abi: FactoryABI,
429
- // topics: raw_log_topics as [],
430
- // data: raw_log_data as `0x${string}`,
431
- // eventName: "LOL",
432
- // }) as {
433
- // eventName: "LOL";
434
- // args: {};
435
- // };
436
-
437
- // console.log(decoded);
420
+ GoldRushDecoder . on (
421
+ "uniswap-v2:PairCreated" ,
422
+ [ "eth-mainnet" ] ,
423
+ FactoryABI as Abi ,
424
+ async ( log_event , tx , chain_name , covalent_client ) : Promise < EventType > => {
425
+ const { raw_log_data, raw_log_topics } = log_event ;
438
426
439
- // let token0: Token | null = null,
440
- // token1: Token | null = null;
427
+ const { args : decoded } = decodeEventLog ( {
428
+ abi : FactoryABI ,
429
+ topics : raw_log_topics as [ ] ,
430
+ data : raw_log_data as `0x${string } `,
431
+ eventName : "PairCreated" ,
432
+ strict : false ,
433
+ } ) as {
434
+ eventName : "PairCreated" ;
435
+ args : {
436
+ token0 : string ;
437
+ token1 : string ;
438
+ pair : string ;
439
+ allPairsLength : bigint ;
440
+ } ;
441
+ } ;
441
442
442
- // // const { data } = await covalent_client.XykService.getPoolByAddress(
443
- // // chain_name,
444
- // // "uniswap_v2",
445
- // // decoded.pair
446
- // // );
447
- // // console.log(data)
448
- // // const { token_0, token_1 } = data?.items?.[0];
449
- // // if (token_0 && token_1) {
450
- // // [token0, token1] = [
451
- // // token_0,
452
- // // token_1,
453
- // // ];
454
- // // }
443
+ const { data } = await covalent_client . XykService . getPoolByAddress (
444
+ chain_name ,
445
+ "uniswap_v2" ,
446
+ decoded . pair
447
+ ) ;
455
448
456
- // return {
457
- // action: DECODED_ACTION.SWAPPED,
458
- // category: DECODED_EVENT_CATEGORY.DEX,
459
- // name: "Pair Created",
460
- // protocol: {
461
- // logo: log_event.sender_logo_url as string,
462
- // name: log_event.sender_name as string,
463
- // },
464
- // details: [
465
- // // {
466
- // // title: `${token0?.contract_name || ""} Symbol`, // USDC Name
467
- // // value: token0?.contract_ticker_symbol || "",
468
- // // type: "text",
469
- // // },
470
- // // {
471
- // // title: `${token0?.contract_name || ""} Decimals`,
472
- // // value: (token0?.contract_decimals ?? 18).toString(),
473
- // // type: "text",
474
- // // },
475
- // // {
476
- // // title: `${token0?.contract_name || ""} Address`,
477
- // // value: token0?.contract_address || "",
478
- // // type: "address",
479
- // // },
480
- // ],
481
- // };
482
- // }
483
- // );
449
+ return {
450
+ action : DECODED_ACTION . SWAPPED ,
451
+ category : DECODED_EVENT_CATEGORY . DEX ,
452
+ name : "Pair Created" ,
453
+ protocol : {
454
+ logo : log_event . sender_logo_url as string ,
455
+ name : log_event . sender_name as string ,
456
+ } ,
457
+ details : [
458
+ {
459
+ title : `${
460
+ data ?. items ?. [ 0 ] ?. token_0 ?. contract_name || ""
461
+ } Symbol`,
462
+ value :
463
+ data ?. items ?. [ 0 ] ?. token_0 ?. contract_ticker_symbol || "" ,
464
+ type : "text" ,
465
+ } ,
466
+ {
467
+ title : `${
468
+ data ?. items ?. [ 0 ] ?. token_0 ?. contract_name || ""
469
+ } Decimals`,
470
+ value : (
471
+ data ?. items ?. [ 0 ] ?. token_0 ?. contract_decimals ?? 18
472
+ ) . toString ( ) ,
473
+ type : "text" ,
474
+ } ,
475
+ {
476
+ title : `${
477
+ data ?. items ?. [ 0 ] ?. token_0 ?. contract_name || ""
478
+ } Address`,
479
+ value : data ?. items ?. [ 0 ] ?. token_0 ?. contract_address || "" ,
480
+ type : "address" ,
481
+ } ,
482
+ {
483
+ title : `${
484
+ data ?. items ?. [ 0 ] ?. token_1 ?. contract_name || ""
485
+ } Symbol`,
486
+ value :
487
+ data ?. items ?. [ 0 ] ?. token_1 ?. contract_ticker_symbol || "" ,
488
+ type : "text" ,
489
+ } ,
490
+ {
491
+ title : `${
492
+ data ?. items ?. [ 0 ] ?. token_1 ?. contract_name || ""
493
+ } Decimals`,
494
+ value : (
495
+ data ?. items ?. [ 0 ] ?. token_1 ?. contract_decimals ?? 18
496
+ ) . toString ( ) ,
497
+ type : "text" ,
498
+ } ,
499
+ {
500
+ title : `${
501
+ data ?. items ?. [ 0 ] ?. token_1 ?. contract_name || ""
502
+ } Address`,
503
+ value : data ?. items ?. [ 0 ] ?. token_1 ?. contract_address || "" ,
504
+ type : "address" ,
505
+ } ,
506
+ ] ,
507
+ } ;
508
+ }
509
+ ) ;
0 commit comments