Skip to content

Commit

Permalink
[IND-553]: Add support for trading reward tables in Athena (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher-Li authored Jan 5, 2024
1 parent a495f46 commit 06146b0
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
getAthenaTableCreationStatement,
getExternalAthenaTableCreationStatement,
} from '../../helpers/sql';

const TABLE_NAME: string = 'trading_reward_aggregations';
const RAW_TABLE_COLUMNS: string = `
\`id\` binary,
\`address\` string,
\`startedAt\` string,
\`startedAtHeight\` bigint,
\`endedAt\` string,
\`endedAtHeight\` bigint,
\`period\` string,
\`amount\` string
`;
const TABLE_COLUMNS: string = `
"id",
"address",
"startedAt",
"startedAtHeight",
"endedAt",
"endedAtHeight",
"period",
"amount"
`;

export function generateRawTable(tablePrefix: string, rdsExportIdentifier: string): string {
return getExternalAthenaTableCreationStatement(
tablePrefix,
rdsExportIdentifier,
TABLE_NAME,
RAW_TABLE_COLUMNS,
);
}

export function generateTable(tablePrefix: string): string {
return getAthenaTableCreationStatement(
tablePrefix,
TABLE_NAME,
TABLE_COLUMNS,
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
getAthenaTableCreationStatement,
getExternalAthenaTableCreationStatement,
} from '../../helpers/sql';

const TABLE_NAME: string = 'trading_rewards';
const RAW_TABLE_COLUMNS: string = `
\`id\` binary,
\`address\` string,
\`blockTime\` string,
\`blockHeight\` bigint,
\`amount\` string
`;
const TABLE_COLUMNS: string = `
"id",
"address",
"blockTime",
"blockHeight",
"amount"
`;

export function generateRawTable(tablePrefix: string, rdsExportIdentifier: string): string {
return getExternalAthenaTableCreationStatement(
tablePrefix,
rdsExportIdentifier,
TABLE_NAME,
RAW_TABLE_COLUMNS,
);
}

export function generateTable(tablePrefix: string): string {
return getAthenaTableCreationStatement(
tablePrefix,
TABLE_NAME,
TABLE_COLUMNS,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import * as athenaPerpetualPositions from '../lib/athena-ddl-tables/perpetual_po
import * as athenaPnlTicks from '../lib/athena-ddl-tables/pnl_ticks';
import * as athenaSubaccounts from '../lib/athena-ddl-tables/subaccounts';
import * as athenaTendermintEvents from '../lib/athena-ddl-tables/tendermint_events';
import * as athenaTradingRewardAggregations from '../lib/athena-ddl-tables/trading_reward_aggregations';
import * as athenaTradingRewards from '../lib/athena-ddl-tables/trading_rewards';
import * as athenaTransfers from '../lib/athena-ddl-tables/transfers';
import * as athenaWallets from '../lib/athena-ddl-tables/wallets';

Expand All @@ -51,6 +53,8 @@ export const tablesToAddToAthena: { [table: string]: AthenaTableDDLQueries } = {
pnl_ticks: athenaPnlTicks,
subaccounts: athenaSubaccounts,
tendermint_events: athenaTendermintEvents,
trading_rewards: athenaTradingRewards,
trading_reward_aggregation: athenaTradingRewardAggregations,
transfers: athenaTransfers,
liquidity_tiers: athenaLiquidityTiers,
wallets: athenaWallets,
Expand Down

0 comments on commit 06146b0

Please sign in to comment.