Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add athena tables for affiliates/vaults. (backport #2636) #2646

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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,
);
}
Original file line number Diff line number Diff line change
@@ -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,
);
}
38 changes: 38 additions & 0 deletions indexer/services/roundtable/src/lib/athena-ddl-tables/vaults.ts
Original file line number Diff line number Diff line change
@@ -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,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 } = {
Expand All @@ -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`;
Expand Down
Loading