Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6939b33

Browse files
committedFeb 21, 2024·
added all remaining Uniswap V3 events
1 parent 91f9341 commit 6939b33

File tree

4 files changed

+1523
-0
lines changed

4 files changed

+1523
-0
lines changed
 

‎services/decoder/protocols/uniswap-v3/abis/uniswap-v3.NonfungiblePositionManager.abi.json

+1,221
Large diffs are not rendered by default.

‎services/decoder/protocols/uniswap-v3/uniswap-v3.configs.ts

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ const configs: Configs = [
1313
protocol_name: "uniswap-v3",
1414
chain_name: "eth-mainnet",
1515
},
16+
{
17+
address: "0xc36442b4a4522e871399cd717abdd847ab11fe88",
18+
is_factory: false,
19+
protocol_name: "uniswap-v3",
20+
chain_name: "eth-mainnet",
21+
},
1622
];
1723

1824
export default configs;

‎services/decoder/protocols/uniswap-v3/uniswap-v3.decoders.ts

+245
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { decodeEventLog, type Abi } from "viem";
88
import FactoryABI from "./abis/uniswap-v3.factory.abi.json";
99
import PairABI from "./abis/uniswap-v3.pair.abi.json";
10+
import PositionManagerABI from "./abis/uniswap-v3.NonfungiblePositionManager.abi.json";
1011
import { TimestampParser } from "../../../../utils/functions";
1112

1213
GoldRushDecoder.on(
@@ -396,6 +397,250 @@ GoldRushDecoder.on(
396397
},
397398
];
398399

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+
399644
return {
400645
action: DECODED_ACTION.SWAPPED,
401646
category: DECODED_EVENT_CATEGORY.DEX,

‎services/decoder/protocols/uniswap-v3/uniswap-v3.test.ts

+51
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,55 @@ describe("uniswap-v3", () => {
8787
const testAdded: boolean = false;
8888
expect(testAdded).toEqual(true);
8989
});
90+
91+
test("eth-mainnet:Flash", async () => {
92+
const res = await request(app)
93+
.post("/api/v1/tx/decode")
94+
.set({ "x-covalent-api-key": process.env.TEST_COVALENT_API_KEY })
95+
.send({
96+
chain_name: "eth-mainnet",
97+
tx_hash: "0xe3fcabe33a5ebf9ed6450f11b907da4a5d72f2e58917e8b2ae20fb259be385d4",
98+
});
99+
const { events } = res.body as { events: EventType[] };
100+
const event = events.find(({ name }) => name === "Flash");
101+
if (!event) {
102+
throw Error("Event not found");
103+
}
104+
const testAdded: boolean = false;
105+
expect(testAdded).toEqual(true);
106+
});
107+
108+
test("eth-mainnet:DecreaseLiquidity", async () => {
109+
const res = await request(app)
110+
.post("/api/v1/tx/decode")
111+
.set({ "x-covalent-api-key": process.env.TEST_COVALENT_API_KEY })
112+
.send({
113+
chain_name: "eth-mainnet",
114+
tx_hash: "0x509ffb3e2e1338991b27284d6365a93bdf36ac50a9a89e6260b5f791bf0e50e6",
115+
});
116+
const { events } = res.body as { events: EventType[] };
117+
const event = events.find(({ name }) => name === "DecreaseLiquidity");
118+
if (!event) {
119+
throw Error("Event not found");
120+
}
121+
const testAdded: boolean = false;
122+
expect(testAdded).toEqual(true);
123+
});
124+
125+
test("eth-mainnet:IncreaseLiquidity", async () => {
126+
const res = await request(app)
127+
.post("/api/v1/tx/decode")
128+
.set({ "x-covalent-api-key": process.env.TEST_COVALENT_API_KEY })
129+
.send({
130+
chain_name: "eth-mainnet",
131+
tx_hash: "0x509ffb3e2e1338991b27284d6365a93bdf36ac50a9a89e6260b5f791bf0e50e6",
132+
});
133+
const { events } = res.body as { events: EventType[] };
134+
const event = events.find(({ name }) => name === "IncreaseLiquidity");
135+
if (!event) {
136+
throw Error("Event not found");
137+
}
138+
const testAdded: boolean = false;
139+
expect(testAdded).toEqual(true);
140+
});
90141
});

0 commit comments

Comments
 (0)
Please sign in to comment.