Skip to content

Commit

Permalink
fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Jun 30, 2023
1 parent f11d0dd commit 41e7d10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions fees/y2k-finance-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ const fetch = async (timestamp: number): Promise<FetchResultFees> => {
chain: CHAIN.ARBITRUM
})).output as ITx[];
const transactionHash = [...new Set(logs.map((e:ITx) => e.transactionHash.toLowerCase()))]
if (transactionHash.length == 0) {
return {
dailyFees: `${0}`,
dailyRevenue: `${0}`,
timestamp
}
}

const query_tx_ether = `
SELECT contract_address, raw_amount from arbitrum.core.fact_token_transfers
Expand Down
10 changes: 6 additions & 4 deletions fees/y2k-finance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,19 @@ const fetch = (chain: Chain) => {
`

const value: string[] = (await queryFlipside(query)).flat();
const query_tx_ether = `
let withdrawFeesAmount = 0;
if (value.length !== 0) {
const query_tx_ether = `
SELECT data from arbitrum.core.fact_event_logs
WHERE topics[0] = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
and topics[2] = '0x0000000000000000000000005c84cf4d91dc0acde638363ec804792bb2108258'
and contract_address = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'
and tx_hash in (${value.map(a => `'${a.toLowerCase()}'`).join(',')})
and BLOCK_NUMBER > ${startblock} AND BLOCK_NUMBER < ${endblock}
`
const ether_tx_value: string[] = (await queryFlipside(query_tx_ether)).flat();
const withdrawFeesAmount: number = ether_tx_value.map((e: string) => Number(e) / 1e18).reduce((a: number, b: number) => a + b, 0)

const ether_tx_value: string[] = (await queryFlipside(query_tx_ether)).flat();
withdrawFeesAmount = ether_tx_value.map((e: string) => Number(e) / 1e18).reduce((a: number, b: number) => a + b, 0)
}

const rawLogsData: number[] = logs.map((tx: ITx) => {
const insrFinalTvl = Number('0x' + tx.data.slice(256, 320)) / 10 ** 18; // 4
Expand Down

0 comments on commit 41e7d10

Please sign in to comment.