|
7 | 7 | import { decodeEventLog, type Abi } from "viem";
|
8 | 8 | import FactoryABI from "./abis/uniswap-v3.factory.abi.json";
|
9 | 9 | import PairABI from "./abis/uniswap-v3.pair.abi.json";
|
| 10 | +import PositionManagerABI from "./abis/uniswap-v3.NonfungiblePositionManager.abi.json"; |
10 | 11 | import { TimestampParser } from "../../../../utils/functions";
|
11 | 12 |
|
12 | 13 | GoldRushDecoder.on(
|
@@ -396,6 +397,250 @@ GoldRushDecoder.on(
|
396 | 397 | },
|
397 | 398 | ];
|
398 | 399 |
|
| 400 | + return { |
| 401 | + action: DECODED_ACTION.SWAPPED, |
| 402 | + category: DECODED_EVENT_CATEGORY.DEX, |
| 403 | + name: "Collect Fees", |
| 404 | + protocol: { |
| 405 | + logo: log_event.sender_logo_url as string, |
| 406 | + name: "Uniswap V3", |
| 407 | + }, |
| 408 | + details, |
| 409 | + }; |
| 410 | + } |
| 411 | +); |
| 412 | + |
| 413 | +GoldRushDecoder.on( |
| 414 | + "uniswap-v3:Flash", |
| 415 | + ["eth-mainnet"], |
| 416 | + PairABI as Abi, |
| 417 | + async (log_event, tx, chain_name, covalent_client): Promise<EventType> => { |
| 418 | + const { raw_log_data, raw_log_topics } = log_event; |
| 419 | + |
| 420 | + const { args: decoded } = decodeEventLog({ |
| 421 | + abi: PairABI, |
| 422 | + topics: raw_log_topics as [], |
| 423 | + data: raw_log_data as `0x${string}`, |
| 424 | + eventName: "Flash", |
| 425 | + }) as { |
| 426 | + eventName: "Flash"; |
| 427 | + args: { |
| 428 | + sender: string; |
| 429 | + recipient: string; |
| 430 | + amount0: bigint; |
| 431 | + amount1: bigint; |
| 432 | + paid0: bigint; |
| 433 | + paid1: bigint; |
| 434 | + }; |
| 435 | + }; |
| 436 | + |
| 437 | + const details: EventDetails = [ |
| 438 | + { |
| 439 | + heading: "sender", |
| 440 | + value: decoded.sender, |
| 441 | + type: "address" |
| 442 | + }, |
| 443 | + { |
| 444 | + heading: "recipient", |
| 445 | + value: decoded.recipient, |
| 446 | + type: "address" |
| 447 | + }, |
| 448 | + { |
| 449 | + heading: "amount0", |
| 450 | + value: decoded.amount0.toString(), |
| 451 | + type: "text" |
| 452 | + }, |
| 453 | + { |
| 454 | + heading: "amount1", |
| 455 | + value: decoded.amount1.toString(), |
| 456 | + type: "text" |
| 457 | + }, |
| 458 | + { |
| 459 | + heading: "paid0", |
| 460 | + value: decoded.paid0.toString(), |
| 461 | + type: "text" |
| 462 | + }, |
| 463 | + { |
| 464 | + heading: "paid1", |
| 465 | + value: decoded.paid1.toString(), |
| 466 | + type: "text" |
| 467 | + }, |
| 468 | + ]; |
| 469 | + |
| 470 | + return { |
| 471 | + action: DECODED_ACTION.SWAPPED, |
| 472 | + category: DECODED_EVENT_CATEGORY.DEX, |
| 473 | + name: "Flash Loan", |
| 474 | + protocol: { |
| 475 | + logo: log_event.sender_logo_url as string, |
| 476 | + name: "Uniswap V3", |
| 477 | + }, |
| 478 | + details, |
| 479 | + }; |
| 480 | + } |
| 481 | +); |
| 482 | + |
| 483 | +GoldRushDecoder.on( |
| 484 | + "uniswap-v3:DecreaseLiquidity", |
| 485 | + ["eth-mainnet"], |
| 486 | + PositionManagerABI as Abi, |
| 487 | + async (log_event, tx, chain_name, covalent_client): Promise<EventType> => { |
| 488 | + const { raw_log_data, raw_log_topics } = log_event; |
| 489 | + |
| 490 | + const { args: decoded } = decodeEventLog({ |
| 491 | + abi: PositionManagerABI, |
| 492 | + topics: raw_log_topics as [], |
| 493 | + data: raw_log_data as `0x${string}`, |
| 494 | + eventName: "DecreaseLiquidity", |
| 495 | + }) as { |
| 496 | + eventName: "DecreaseLiquidity"; |
| 497 | + args: { |
| 498 | + tokenId: bigint; |
| 499 | + liquidity: bigint; |
| 500 | + amount0: bigint; |
| 501 | + amount1: bigint; |
| 502 | + }; |
| 503 | + }; |
| 504 | + |
| 505 | + const details: EventDetails = [ |
| 506 | + { |
| 507 | + heading: "tokenId", |
| 508 | + value: decoded.tokenId.toString(), |
| 509 | + type: "text" |
| 510 | + }, |
| 511 | + { |
| 512 | + heading: "liquidity", |
| 513 | + value: decoded.liquidity.toString(), |
| 514 | + type: "text" |
| 515 | + }, |
| 516 | + { |
| 517 | + heading: "amount0", |
| 518 | + value: decoded.amount0.toString(), |
| 519 | + type: "text" |
| 520 | + }, |
| 521 | + { |
| 522 | + heading: "amount1", |
| 523 | + value: decoded.amount1.toString(), |
| 524 | + type: "text" |
| 525 | + }, |
| 526 | + ]; |
| 527 | + |
| 528 | + return { |
| 529 | + action: DECODED_ACTION.SWAPPED, |
| 530 | + category: DECODED_EVENT_CATEGORY.DEX, |
| 531 | + name: "Decrease Liquidity", |
| 532 | + protocol: { |
| 533 | + logo: log_event.sender_logo_url as string, |
| 534 | + name: "Uniswap V3", |
| 535 | + }, |
| 536 | + details, |
| 537 | + }; |
| 538 | + } |
| 539 | +); |
| 540 | + |
| 541 | +GoldRushDecoder.on( |
| 542 | + "uniswap-v3:IncreaseLiquidity", |
| 543 | + ["eth-mainnet"], |
| 544 | + PositionManagerABI as Abi, |
| 545 | + async (log_event, tx, chain_name, covalent_client): Promise<EventType> => { |
| 546 | + const { raw_log_data, raw_log_topics } = log_event; |
| 547 | + |
| 548 | + const { args: decoded } = decodeEventLog({ |
| 549 | + abi: PositionManagerABI, |
| 550 | + topics: raw_log_topics as [], |
| 551 | + data: raw_log_data as `0x${string}`, |
| 552 | + eventName: "IncreaseLiquidity", |
| 553 | + }) as { |
| 554 | + eventName: "IncreaseLiquidity"; |
| 555 | + args: { |
| 556 | + tokenId: bigint; |
| 557 | + liquidity: bigint; |
| 558 | + amount0: bigint; |
| 559 | + amount1: bigint; |
| 560 | + }; |
| 561 | + }; |
| 562 | + |
| 563 | + const details: EventDetails = [ |
| 564 | + { |
| 565 | + heading: "tokenId", |
| 566 | + value: decoded.tokenId.toString(), |
| 567 | + type: "text" |
| 568 | + }, |
| 569 | + { |
| 570 | + heading: "liquidity", |
| 571 | + value: decoded.liquidity.toString(), |
| 572 | + type: "text" |
| 573 | + }, |
| 574 | + { |
| 575 | + heading: "amount0", |
| 576 | + value: decoded.amount0.toString(), |
| 577 | + type: "text" |
| 578 | + }, |
| 579 | + { |
| 580 | + heading: "amount1", |
| 581 | + value: decoded.amount1.toString(), |
| 582 | + type: "text" |
| 583 | + }, |
| 584 | + ]; |
| 585 | + |
| 586 | + return { |
| 587 | + action: DECODED_ACTION.SWAPPED, |
| 588 | + category: DECODED_EVENT_CATEGORY.DEX, |
| 589 | + name: "Increase Liquidity", |
| 590 | + protocol: { |
| 591 | + logo: log_event.sender_logo_url as string, |
| 592 | + name: "Uniswap V3", |
| 593 | + }, |
| 594 | + details, |
| 595 | + }; |
| 596 | + } |
| 597 | +); |
| 598 | + |
| 599 | +GoldRushDecoder.on( |
| 600 | + "uniswap-v3:Collect", |
| 601 | + ["eth-mainnet"], |
| 602 | + PositionManagerABI as Abi, |
| 603 | + async (log_event, tx, chain_name, covalent_client): Promise<EventType> => { |
| 604 | + const { raw_log_data, raw_log_topics } = log_event; |
| 605 | + |
| 606 | + const { args: decoded } = decodeEventLog({ |
| 607 | + abi: PositionManagerABI, |
| 608 | + topics: raw_log_topics as [], |
| 609 | + data: raw_log_data as `0x${string}`, |
| 610 | + eventName: "Collect", |
| 611 | + }) as { |
| 612 | + eventName: "Collect"; |
| 613 | + args: { |
| 614 | + tokenId: bigint; |
| 615 | + recipient: string; |
| 616 | + amount0: bigint; |
| 617 | + amount1: bigint; |
| 618 | + }; |
| 619 | + }; |
| 620 | + |
| 621 | + const details: EventDetails = [ |
| 622 | + { |
| 623 | + heading: "tokenId", |
| 624 | + value: decoded.tokenId.toString(), |
| 625 | + type: "text" |
| 626 | + }, |
| 627 | + { |
| 628 | + heading: "recipient", |
| 629 | + value: decoded.recipient, |
| 630 | + type: "address" |
| 631 | + }, |
| 632 | + { |
| 633 | + heading: "amount0", |
| 634 | + value: decoded.amount0.toString(), |
| 635 | + type: "text" |
| 636 | + }, |
| 637 | + { |
| 638 | + heading: "amount1", |
| 639 | + value: decoded.amount1.toString(), |
| 640 | + type: "text" |
| 641 | + }, |
| 642 | + ]; |
| 643 | + |
399 | 644 | return {
|
400 | 645 | action: DECODED_ACTION.SWAPPED,
|
401 | 646 | category: DECODED_EVENT_CATEGORY.DEX,
|
|
0 commit comments