Skip to content

Commit 8f3387b

Browse files
committed
add merkl rewards for uniswap
1 parent 976f765 commit 8f3387b

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

protocols/uniswap.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
11
import { manualCliff, manualLinear } from "../adapters/manual";
22
import adapter from "../adapters/uniswap/uniswap";
3-
import { Protocol } from "../types/adapters";
4-
import { periodToSeconds } from "../utils/time";
3+
import { CliffAdapterResult, Protocol } from "../types/adapters";
4+
import { queryCustom } from "../utils/queries";
5+
import { periodToSeconds, readableToSeconds } from "../utils/time";
56

67
// some missing from uni somewhere
78
const start = 1600106400;
9+
10+
const merklRewards = async (): Promise<CliffAdapterResult[]> => {
11+
const data = await queryCustom(`
12+
SELECT
13+
toStartOfDay(timestamp) AS date,
14+
SUM(reinterpretAsUInt256(reverse(unhex(substring(data, 3))))) / 1e18 AS amount
15+
FROM evm_indexer.logs
16+
PREWHERE topic0 = '0xf7a40077ff7a04c7e61f6f26fb13774259ddf1b6bce9ecf26a8276cdd3992683'
17+
AND address IN (
18+
'0x3ef3d8ba38ebe18db133cec108f4d14ce00dd9ae'
19+
)
20+
WHERE topic2 IN (
21+
'0x0000000000000000000000001f9840a85d5af5bf1d1762f925bdaddc4201f984',
22+
'0x0000000000000000000000008f187aa05619a017077f5308904739877ce9ea21'
23+
)
24+
GROUP BY date
25+
ORDER BY date DESC;
26+
27+
`, {});
28+
29+
const result: CliffAdapterResult[] = [];
30+
for (let i = 0; i < data.length; i++) {
31+
result.push({
32+
type: "cliff",
33+
start: readableToSeconds(data[i].date),
34+
amount: Number(data[i].amount),
35+
isUnlock: false,
36+
});
37+
}
38+
return result;
39+
};
40+
841
function uniswap(): Protocol {
942
const community = async () =>
1043
Promise.all(
@@ -17,6 +50,7 @@ function uniswap(): Protocol {
1750
);
1851
return {
1952
community,
53+
incentives: merklRewards,
2054
airdrop: manualCliff(start, 150000000),
2155
"LP staking": manualLinear(
2256
start,
@@ -30,9 +64,10 @@ function uniswap(): Protocol {
3064
sources: ["https://uniswap.org/blog/uni"],
3165
token: "ethereum:0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
3266
protocolIds: ["2196", "2197", "2198"],
67+
notes: ["We track incentives when user claimed their rewards"]
3368
},
3469
categories: {
35-
farming: ["community"],
70+
farming: ["community", "incentives"],
3671
airdrop: ["airdrop"],
3772
privateSale: ["investors"],
3873
insiders: ["team","advisors"],

0 commit comments

Comments
 (0)