diff --git a/indexer/services/roundtable/src/lib/athena-ddl-tables/affiliate_info.ts b/indexer/services/roundtable/src/lib/athena-ddl-tables/affiliate_info.ts new file mode 100644 index 0000000000..fc0faea66f --- /dev/null +++ b/indexer/services/roundtable/src/lib/athena-ddl-tables/affiliate_info.ts @@ -0,0 +1,48 @@ +import { + getAthenaTableCreationStatement, + getExternalAthenaTableCreationStatement, + castToDouble, +} from '../../helpers/sql'; + +const TABLE_NAME: string = 'affiliate_info'; +const RAW_TABLE_COLUMNS: string = ` + \`address\` string, + \`affiliateEarnings\` string, + \`referredMakerTrades\` int, + \`referredTakerTrades\` int, + \`totalReferredUsers\` int, + \`firstReferralBlockHeight\` bigint, + \`referredTotalVolume\` string, + \`totalReferredTakerFees\` string, + \`totalReferredMakerFees\` string, + \`totalReferredMakerRebates\` string +`; +const TABLE_COLUMNS: string = ` + "address", + ${castToDouble('affiliateEarnings')}, + "referredMakerTrades", + "referredTakerTrades", + "totalReferredUsers", + "firstReferralBlockHeight", + ${castToDouble('referredTotalVolume')}, + ${castToDouble('totalReferredTakerFees')}, + ${castToDouble('totalReferredMakerFees')}, + ${castToDouble('totalReferredMakerRebates')} +`; + +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, + ); +} diff --git a/indexer/services/roundtable/src/lib/athena-ddl-tables/affiliate_referred_users.ts b/indexer/services/roundtable/src/lib/athena-ddl-tables/affiliate_referred_users.ts new file mode 100644 index 0000000000..49b5c93293 --- /dev/null +++ b/indexer/services/roundtable/src/lib/athena-ddl-tables/affiliate_referred_users.ts @@ -0,0 +1,33 @@ +import { + getAthenaTableCreationStatement, + getExternalAthenaTableCreationStatement, +} from '../../helpers/sql'; + +const TABLE_NAME: string = 'affiliate_referred_users'; +const RAW_TABLE_COLUMNS: string = ` + \`referredAddress\` string, + \`affiliateAddress\` string, + \`referredAtBlock\` bigint +`; +const TABLE_COLUMNS: string = ` + "referredAddress", + "affiliateAddress", + "referredAtBlock" +`; + +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, + ); +} diff --git a/indexer/services/roundtable/src/lib/athena-ddl-tables/vaults.ts b/indexer/services/roundtable/src/lib/athena-ddl-tables/vaults.ts new file mode 100644 index 0000000000..75bd67bf62 --- /dev/null +++ b/indexer/services/roundtable/src/lib/athena-ddl-tables/vaults.ts @@ -0,0 +1,38 @@ +import { + castToTimestamp, + getAthenaTableCreationStatement, + getExternalAthenaTableCreationStatement, +} from '../../helpers/sql'; + +const TABLE_NAME: string = 'vaults'; +const RAW_TABLE_COLUMNS: string = ` + \`address\` string, + \`clobPairId\` bigint, + \`status\` string, + \`createdAt\` string, + \`updatedAt\` string +`; +const TABLE_COLUMNS: string = ` + "address", + "clobPairId", + "status", + ${castToTimestamp('createdAt')}, + ${castToTimestamp('updatedAt')} +`; + +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, + ); +} diff --git a/indexer/services/roundtable/src/tasks/update-research-environment.ts b/indexer/services/roundtable/src/tasks/update-research-environment.ts index 91c4741c47..24427bfd8c 100644 --- a/indexer/services/roundtable/src/tasks/update-research-environment.ts +++ b/indexer/services/roundtable/src/tasks/update-research-environment.ts @@ -18,6 +18,8 @@ import { startAthenaQuery, } from '../helpers/aws'; import { AthenaTableDDLQueries } from '../helpers/types'; +import * as athenaAffiliateInfo from '../lib/athena-ddl-tables/affiliate_info'; +import * as athenaAffiliateReferredUsers from '../lib/athena-ddl-tables/affiliate_referred_users'; import * as athenaAssetPositions from '../lib/athena-ddl-tables/asset_positions'; import * as athenaAssets from '../lib/athena-ddl-tables/assets'; import * as athenaBlocks from '../lib/athena-ddl-tables/blocks'; @@ -36,6 +38,7 @@ import * as athenaTendermintEvents from '../lib/athena-ddl-tables/tendermint_eve 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 athenaVaults from '../lib/athena-ddl-tables/vaults'; import * as athenaWallets from '../lib/athena-ddl-tables/wallets'; export const tablesToAddToAthena: { [table: string]: AthenaTableDDLQueries } = { @@ -58,6 +61,9 @@ export const tablesToAddToAthena: { [table: string]: AthenaTableDDLQueries } = { transfers: athenaTransfers, liquidity_tiers: athenaLiquidityTiers, wallets: athenaWallets, + affiliate_info: athenaAffiliateInfo, + affiliate_referred_users: athenaAffiliateReferredUsers, + vaults: athenaVaults, }; const statStart: string = `${config.SERVICE_NAME}.update_research_environment`;