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. #2636

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,49 @@
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
`;
vincentwschau marked this conversation as resolved.
Show resolved Hide resolved
const TABLE_COLUMNS: string = `
"id",
${castToDouble('affiliateEarnings')},
"referredMakerTrades",
"referredTakerTrades",
"totalReferredUsers",
"firstReferralBlockHeight",
${castToDouble('referredTotalVolume')},
${castToDouble('totalReferredTakerFees')},
${castToDouble('totalReferredMakerFees')},
${castToDouble('totalReferredMakerFees')},
${castToDouble('totalReferredMakerRebates')}
`;
vincentwschau marked this conversation as resolved.
Show resolved Hide resolved

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,
);
}
vincentwschau marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {
getAthenaTableCreationStatement,
getExternalAthenaTableCreationStatement,
castToDouble,
} 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
`;
vincentwschau marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -37,6 +37,9 @@ import * as athenaTradingRewardAggregations from '../lib/athena-ddl-tables/tradi
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';
import * as athenaAffiliateInfo from '../lib/athena-ddl-tables/affiliate_info';
import * as athenaAffiliateReferredUsers from '../lib/athena-ddl-tables/affiliate_referred_users';
import * as athenaVaults from '../lib/athena-ddl-tables/vaults';

export const tablesToAddToAthena: { [table: string]: AthenaTableDDLQueries } = {
asset_positions: athenaAssetPositions,
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