|
| 1 | +import { Dependencies, FetchOptions, SimpleAdapter } from "../../adapters/types"; |
| 2 | +import { CHAIN } from "../../helpers/chains"; |
| 3 | +import { getSqlFromFile, queryDuneSql } from "../../helpers/dune"; |
| 4 | +import ADDRESSES from "../../helpers/coreAssets.json"; |
| 5 | + |
| 6 | +const STAKE_POOL_RESERVE_ACCOUNT = "FFtERWBSCkScg8spA2mNB9zN5SdH16NqQywXw3bbB1aJ"; |
| 7 | +const STAKE_POOL_WITHDRAW_AUTHORITY = "4cpnpiwgBfUgELVwNYiecwGti45YHSH3R72CPkFTiwJt"; |
| 8 | +const LST_FEE_TOKEN_ACCOUNT = "GhN6PpyP6Ln4ycWcyvqsNcowLfYjpUcA9uWKAcFBjj2D"; |
| 9 | +const LST_MINT = ADDRESSES.solana.DZSOL; |
| 10 | + |
| 11 | +const fetch = async (_a: any, _b: any, options: FetchOptions) => { |
| 12 | + |
| 13 | + const query = getSqlFromFile("helpers/queries/sol-lst.sql", { |
| 14 | + start: options.startTimestamp, |
| 15 | + end: options.endTimestamp, |
| 16 | + stake_pool_reserve_account: STAKE_POOL_RESERVE_ACCOUNT, |
| 17 | + stake_pool_withdraw_authority: STAKE_POOL_WITHDRAW_AUTHORITY, |
| 18 | + lst_fee_token_account: LST_FEE_TOKEN_ACCOUNT, |
| 19 | + lst_mint: LST_MINT |
| 20 | + }); |
| 21 | + |
| 22 | + const results = await queryDuneSql(options, query); |
| 23 | + |
| 24 | + const dailyFees = options.createBalances(); |
| 25 | + const dailyRevenue = options.createBalances(); |
| 26 | + |
| 27 | + results.forEach((row: any) => { |
| 28 | + if (row.metric_type === 'dailyFees') { |
| 29 | + dailyFees.addCGToken("solana", row.amount || 0); |
| 30 | + } else if (row.metric_type === 'dailyRevenue') { |
| 31 | + dailyRevenue.addCGToken("doublezero-staked-sol", row.amount || 0); |
| 32 | + } |
| 33 | + }); |
| 34 | + |
| 35 | + return { |
| 36 | + dailyFees, |
| 37 | + dailyRevenue, |
| 38 | + dailyProtocolRevenue: dailyRevenue |
| 39 | + }; |
| 40 | +}; |
| 41 | + |
| 42 | +const methodology = { |
| 43 | + Fees: 'Staking rewards from staked SOL on doublezero staked solana', |
| 44 | + Revenue: 'Includes withdrawal fees and management fees collected by fee collector', |
| 45 | + ProtocolRevenue: 'Revenue going to treasury/team', |
| 46 | +} |
| 47 | + |
| 48 | +const adapter: SimpleAdapter = { |
| 49 | + version: 1, |
| 50 | + methodology, |
| 51 | + fetch, |
| 52 | + dependencies: [Dependencies.DUNE], |
| 53 | + chains: [CHAIN.SOLANA], |
| 54 | + start: "2025-10-01", |
| 55 | + isExpensiveAdapter: true |
| 56 | +}; |
| 57 | + |
| 58 | +export default adapter; |
0 commit comments