|
| 1 | +import { manualCliff, manualLinear } from "../adapters/manual"; |
| 2 | +import { CliffAdapterResult, Protocol } from "../types/adapters"; |
| 3 | +import { queryCustom } from "../utils/queries"; |
| 4 | +import { readableToSeconds } from "../utils/time"; |
| 5 | + |
| 6 | +const rewards = async (): Promise<CliffAdapterResult[]> => { |
| 7 | + const result: CliffAdapterResult[] = []; |
| 8 | + const data = await queryCustom(` |
| 9 | +SELECT |
| 10 | + toStartOfDay(timestamp) AS date, |
| 11 | + SUM(reinterpretAsUInt256(reverse(unhex(substring(data, 3))))) / 1e18 AS amount |
| 12 | +FROM evm_indexer.logs |
| 13 | +PREWHERE chain = '43114' |
| 14 | +AND topic0 = '0xc9695243a805adb74c91f28311176c65b417e842d5699893cef56d18bfa48cba' |
| 15 | +AND address IN ( |
| 16 | + SELECT concat('0x', substr(topic1,-40)) as gauge |
| 17 | + FROM evm_indexer.logs |
| 18 | + PREWHERE chain = '43114' |
| 19 | + WHERE address = '0x59aa177312ff6bdf39c8af6f46dae217bf76cbf6' |
| 20 | + AND topic0 = '0xa4d97e9e7c65249b4cd01acb82add613adea98af32daf092366982f0a0d4e453' |
| 21 | +) |
| 22 | +GROUP BY date |
| 23 | +ORDER BY date DESC;`, {}) |
| 24 | + |
| 25 | + for (let i = 0; i < data.length; i++) { |
| 26 | + result.push({ |
| 27 | + type: "cliff", |
| 28 | + start: readableToSeconds(data[i].date), |
| 29 | + amount: Number(data[i].amount) |
| 30 | + }); |
| 31 | + } |
| 32 | + return result; |
| 33 | +} |
| 34 | + |
| 35 | +const blackhole: Protocol = { |
| 36 | + Rewards: rewards, |
| 37 | + meta: { |
| 38 | + sources: [ |
| 39 | + ], |
| 40 | + token: "coingecko:blackhole", |
| 41 | + protocolIds: ["parent#blackhole"], |
| 42 | + notes: ["Rewards data are calculated from gauges claim events"] |
| 43 | + }, |
| 44 | + categories: { |
| 45 | + farming: ["Rewards"], |
| 46 | + }, |
| 47 | +}; |
| 48 | + |
| 49 | +export default blackhole; |
0 commit comments