|
| 1 | +import { CHAIN } from "../helpers/chains"; |
| 2 | +import { FetchOptions, FetchResultV2, SimpleAdapter } from "../adapters/types"; |
| 3 | + |
| 4 | +const EXCHANGE_CONTRACT = '0x835Ba5b1B202773A94Daaa07168b26B22584637a'; |
| 5 | +const QUOTE_TOKEN = '0x203A662b0BD271A6ed5a60EdFbd04bFce608FD36'; |
| 6 | + |
| 7 | +const ABIS = { |
| 8 | + TradeExecuted: 'event TradeExecuted (address buyWallet, address sellWallet, string baseAssetSymbol, string quoteAssetSymbol, uint64 baseQuantity, uint64 quoteQuantity, uint8 makerSide, int64 makerFeeQuantity, uint64 takerFeeQuantity)', |
| 9 | +} |
| 10 | + |
| 11 | +async function fetch(options: FetchOptions): Promise<FetchResultV2> { |
| 12 | + const dailyVolume = options.createBalances(); |
| 13 | + const dailyFees = options.createBalances(); |
| 14 | + |
| 15 | + const logs = await options.getLogs({ target: EXCHANGE_CONTRACT, eventAbi: ABIS.TradeExecuted }); |
| 16 | + for (const log of logs) { |
| 17 | + dailyVolume.add(QUOTE_TOKEN, log.quoteQuantity); |
| 18 | + dailyFees.add(QUOTE_TOKEN, Math.abs(Number(log.makerFeeQuantity)), 'Maker Fees'); |
| 19 | + dailyFees.add(QUOTE_TOKEN, log.takerFeeQuantity, 'Taker Fees'); |
| 20 | + } |
| 21 | + |
| 22 | + return { |
| 23 | + dailyVolume, |
| 24 | + dailyFees, |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +const adapter: SimpleAdapter = { |
| 29 | + version: 2, |
| 30 | + pullHourly: true, |
| 31 | + fetch, |
| 32 | + start: '2026-01-12', |
| 33 | + chains: [CHAIN.KATANA], |
| 34 | + skipBreakdownValidation: true, |
| 35 | + methodology: { |
| 36 | + Volume: 'Count trade size from TradeExecuted from exchange contract', |
| 37 | + Fees: 'Total fees paid by makers and takers', |
| 38 | + }, |
| 39 | + breakdownMethodology: { |
| 40 | + Fees: { |
| 41 | + 'Maker Fees': 'Fees paid by makers on trades', |
| 42 | + 'Taker Fees': 'Fees paid by takers on trades', |
| 43 | + }, |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +export default adapter; |
0 commit comments