From 53743b35381d5d3360129b77ea56e5ba8a028792 Mon Sep 17 00:00:00 2001 From: Kollan House Date: Sat, 17 Aug 2024 19:41:50 -0600 Subject: [PATCH 1/4] fix: use UTC string vs tolocale --- .../indexers/autocrat/autocrat-proposal-indexer.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts index 3c96f54d..f8f82202 100644 --- a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts +++ b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts @@ -213,15 +213,23 @@ export const AutocratProposalIndexer: IntervalFetchIndexer = { ) )[0]; + const endSlot: BN = onChainProposal.account.slotEnqueued + .add(new BN(dbDao.slotsPerProposal?.valueOf())) + const slotDifference = onChainProposal.account.slotEnqueued .add(new BN(dbDao.slotsPerProposal?.valueOf())) .sub(new BN(currentSlot)); - + const lowHoursEstimate = Math.floor( (slotDifference.toNumber() * 400) / 1000 / 60 / 60 ); - const endedAt = new Date(currentTime.toLocaleString()); + // Our check to ensure we're actually updating the time correctly. + if(currentSlot <= endSlot.toNumber() && lowHoursEstimate <= 0){ + console.error('Issue with slot update contact administrator') + } + + const endedAt = new Date(currentTime.toUTCString()); endedAt.setHours(endedAt.getHours() + lowHoursEstimate); await usingDb((db) => From 480d8f605a3ef4bdb5fc7fb2c44afe27aff1c29a Mon Sep 17 00:00:00 2001 From: Kollan House Date: Sat, 17 Aug 2024 21:48:52 -0600 Subject: [PATCH 2/4] feat: adds performance structure for resolving market and maths --- packages/database/lib/schema.ts | 16 ++++++++ .../autocrat/autocrat-proposal-indexer.ts | 37 +++++++++++++++---- packages/indexer/src/types/index.ts | 4 ++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/packages/database/lib/schema.ts b/packages/database/lib/schema.ts index 60e9b7fd..bb222efc 100644 --- a/packages/database/lib/schema.ts +++ b/packages/database/lib/schema.ts @@ -832,6 +832,22 @@ export const userPerformance = pgTable( precision: 40, scale: 20, }).notNull(), + tokensBoughtResolvingMarket: numeric("tokens_bought_resolving_market", { + precision: 40, + scale: 20, + }).notNull(), + tokensSoldResolvingMarket: numeric("tokens_sold_resolving_market", { + precision: 40, + scale: 20, + }).notNull(), + volumeBoughtResolvingMarket: numeric("volume_bought_resolving_market", { + precision: 40, + scale: 20, + }).notNull(), + volumeSoldResolvingMarket: numeric("volume_sold_resolving_market", { + precision: 40, + scale: 20, + }).notNull(), createdAt: timestamp("created_at", { withTimezone: true }) .notNull() .default(sql`now()`), diff --git a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts index f8f82202..0cebc2d7 100644 --- a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts +++ b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts @@ -662,7 +662,7 @@ async function calculateUserPerformance( const { proposals, quote_tokens, base_tokens } = proposal; - const orders = await usingDb((db) => { + const allOrders = await usingDb((db) => { return db .select() .from(schema.orders) @@ -681,6 +681,8 @@ async function calculateUserPerformance( proposalFinalizedAtMinus2Minutes.setMinutes( proposalFinalizedAt.getMinutes() - 2 ); + + const resolvingMarket = proposals.status === ProposalStatus.Passed ? proposals.passMarketAcct : proposals.failMarketAcct; // TODO: Get spot price at proposal finalization or even current spot price // if the proposal is still active (this would be UNREALISED P&L) // TODO: If this is 0 we really need to throw and error and alert someone, we shouldn't have missing spot data @@ -700,19 +702,24 @@ async function calculateUserPerformance( .execute(); }); - let actors = orders.reduce((current, next) => { + let actors = allOrders.reduce((current, next) => { const actor = next.actorAcct; let totals = current.get(actor); if (!totals) { totals = { - tokensBought: 0, + tokensBought: 0, // Aggregate value for reporting tokensSold: 0, volumeBought: 0, volumeSold: 0, + tokensBoughtResolvingMarket: 0, // P/F market buy quantity + tokensSoldResolvingMarket: 0, // P/F market sell quantity + volumeBoughtResolvingMarket: 0, // P/F market buy volume + volumeSoldResolvingMarket: 0, // P/F market sell volume }; } + // Token Decimals used for nomalizing results const baseTokenDecimals = base_tokens?.decimals; const quoteTokenDecimals = quote_tokens?.decimals ?? 6; // NOTE: Safe for now @@ -729,12 +736,24 @@ async function calculateUserPerformance( // Amount or notional const amount = Number(next.quotePrice).valueOf() * size; + // Buy Side if (next.side === "BID") { totals.tokensBought = totals.tokensBought + size; totals.volumeBought = totals.volumeBought + amount; + // If this is the resolving market then we want to keep a running tally for that for P&L + if(next.marketAcct === resolvingMarket){ + totals.tokensBoughtResolvingMarket = totals.tokensBoughtResolvingMarket + size; + totals.volumeBoughtResolvingMarket = totals.volumeBoughtResolvingMarket + amount; + } + // Sell Side } else if (next.side === "ASK") { totals.tokensSold = totals.tokensSold + size; totals.volumeSold = totals.volumeSold + amount; + // If this is the resolving market then we want to keep a running tally for that for P&L + if(next.marketAcct === resolvingMarket){ + totals.tokensSoldResolvingMarket = totals.tokensSoldResolvingMarket + size; + totals.volumeSoldResolvingMarket = totals.volumeSoldResolvingMarket + amount; + } } current.set(actor, totals); @@ -748,10 +767,10 @@ async function calculateUserPerformance( const [actor, values] = k; // NOTE: this gets us the delta, whereas we need to know the direction at the very end - const tradeSizeDelta = Math.abs(values.tokensBought - values.tokensSold); + const tradeSizeDelta = Math.abs(values.tokensBoughtResolvingMarket - values.tokensSoldResolvingMarket); // NOTE: Directionally orients our last leg - const needsSellToExit = values.tokensBought > values.tokensSold; // boolean + const needsSellToExit = values.tokensBoughtResolvingMarket > values.tokensSoldResolvingMarket; // boolean // We need to complete the round trip / final leg if (tradeSizeDelta !== 0) { @@ -763,9 +782,9 @@ async function calculateUserPerformance( // We've bought more than we've sold, therefore when we exit the position calulcation // we need to count the remaining volume as a sell at spot price when conditional // market is finalized. - values.volumeSold = values.volumeSold + lastLegNotional; + values.volumeSoldResolvingMarket = values.volumeSoldResolvingMarket + lastLegNotional; } else { - values.volumeBought = values.volumeBought + lastLegNotional; + values.volumeBoughtResolvingMarket = values.volumeBoughtResolvingMarket + lastLegNotional; } } @@ -776,6 +795,10 @@ async function calculateUserPerformance( tokensSold: values.tokensSold.toString(), volumeBought: values.volumeBought.toString(), volumeSold: values.volumeSold.toString(), + tokensBoughtResolvingMarket: values.tokensBoughtResolvingMarket.toString(), + tokensSoldResolvingMarket: values.tokensSoldResolvingMarket.toString(), + volumeBoughtResolvingMarket: values.volumeBoughtResolvingMarket.toString(), + volumeSoldResolvingMarket: values.volumeSoldResolvingMarket.toString(), }; }); diff --git a/packages/indexer/src/types/index.ts b/packages/indexer/src/types/index.ts index 0ef261a7..10371a99 100644 --- a/packages/indexer/src/types/index.ts +++ b/packages/indexer/src/types/index.ts @@ -27,6 +27,10 @@ export type UserPerformanceTotals = { tokensSold: number; volumeBought: number; volumeSold: number; + tokensBoughtResolvingMarket: number; + tokensSoldResolvingMarket: number; + volumeBoughtResolvingMarket: number; + volumeSoldResolvingMarket: number; }; export type UserPerformance = { From 1331f211a1f2d040496fadfd2e4ed039ae0366ea Mon Sep 17 00:00:00 2001 From: Kollan House Date: Sun, 18 Aug 2024 11:40:33 -0600 Subject: [PATCH 3/4] fix: adds count, dao and others --- .../drizzle/0063_wonderful_blue_shield.sql | 4 +- .../drizzle/0064_living_iron_monger.sql | 14 + .../database/drizzle/meta/0064_snapshot.json | 2716 +++++++++++++++++ packages/database/drizzle/meta/_journal.json | 7 + packages/database/lib/schema.ts | 24 +- packages/database/sql/native-queries.sql | 39 + .../autocrat/autocrat-proposal-indexer.ts | 7 + packages/indexer/src/types/index.ts | 2 + 8 files changed, 2806 insertions(+), 7 deletions(-) create mode 100644 packages/database/drizzle/0064_living_iron_monger.sql create mode 100644 packages/database/drizzle/meta/0064_snapshot.json create mode 100644 packages/database/sql/native-queries.sql diff --git a/packages/database/drizzle/0063_wonderful_blue_shield.sql b/packages/database/drizzle/0063_wonderful_blue_shield.sql index f5612878..bc8a845b 100644 --- a/packages/database/drizzle/0063_wonderful_blue_shield.sql +++ b/packages/database/drizzle/0063_wonderful_blue_shield.sql @@ -2,5 +2,5 @@ ALTER TABLE "user_performance" ALTER COLUMN "tokens_bought" SET DATA TYPE numeri ALTER TABLE "user_performance" ALTER COLUMN "tokens_sold" SET DATA TYPE numeric(40, 20);--> statement-breakpoint ALTER TABLE "user_performance" ALTER COLUMN "volume_bought" SET DATA TYPE numeric(40, 20);--> statement-breakpoint ALTER TABLE "user_performance" ALTER COLUMN "volume_sold" SET DATA TYPE numeric(40, 20);--> statement-breakpoint -ALTER TABLE "user_performance" ADD COLUMN "total_volume" numeric(40, 20) NOT NULL; -ALTER TABLE "user_performance" ADD COLUMN "updated_at" timestamp with time zone DEFAULT now() NOT NULL; \ No newline at end of file +-- ALTER TABLE "user_performance" ADD COLUMN "total_volume" numeric(40, 20) NOT NULL; +-- ALTER TABLE "user_performance" ADD COLUMN "updated_at" timestamp with time zone DEFAULT now() NOT NULL; \ No newline at end of file diff --git a/packages/database/drizzle/0064_living_iron_monger.sql b/packages/database/drizzle/0064_living_iron_monger.sql new file mode 100644 index 00000000..0835350f --- /dev/null +++ b/packages/database/drizzle/0064_living_iron_monger.sql @@ -0,0 +1,14 @@ +ALTER TABLE "user_performance" ADD COLUMN "dao_acct" varchar(44);--> statement-breakpoint +ALTER TABLE "user_performance" ADD COLUMN "total_volume" numeric(40, 20) DEFAULT '0.0' NOT NULL;--> statement-breakpoint +ALTER TABLE "user_performance" ADD COLUMN "tokens_bought_resolving_market" numeric(40, 20) DEFAULT '0.0' NOT NULL;--> statement-breakpoint +ALTER TABLE "user_performance" ADD COLUMN "tokens_sold_resolving_market" numeric(40, 20) DEFAULT '0.0' NOT NULL;--> statement-breakpoint +ALTER TABLE "user_performance" ADD COLUMN "volume_bought_resolving_market" numeric(40, 20) DEFAULT '0.0' NOT NULL;--> statement-breakpoint +ALTER TABLE "user_performance" ADD COLUMN "volume_sold_resolving_market" numeric(40, 20) DEFAULT '0.0' NOT NULL;--> statement-breakpoint +ALTER TABLE "user_performance" ADD COLUMN "buy_orders_count" bigint DEFAULT 0 NOT NULL;--> statement-breakpoint +ALTER TABLE "user_performance" ADD COLUMN "sell_orders_count" bigint DEFAULT 0 NOT NULL;--> statement-breakpoint +-- ALTER TABLE "user_performance" ADD COLUMN "updated_at" timestamp with time zone DEFAULT now() NOT NULL;--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "user_performance" ADD CONSTRAINT "user_performance_dao_acct_daos_dao_acct_fk" FOREIGN KEY ("dao_acct") REFERENCES "daos"("dao_acct") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; diff --git a/packages/database/drizzle/meta/0064_snapshot.json b/packages/database/drizzle/meta/0064_snapshot.json new file mode 100644 index 00000000..5976606d --- /dev/null +++ b/packages/database/drizzle/meta/0064_snapshot.json @@ -0,0 +1,2716 @@ +{ + "id": "a29e421d-abf4-4f54-bf5b-29de3865110f", + "prevId": "0f3736b2-d3da-469b-824d-1b16eb7aee24", + "version": "5", + "dialect": "pg", + "tables": { + "candles": { + "name": "candles", + "schema": "", + "columns": { + "market_acct": { + "name": "market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "candle_duration": { + "name": "candle_duration", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "volume": { + "name": "volume", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "open": { + "name": "open", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "high": { + "name": "high", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "low": { + "name": "low", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "close": { + "name": "close", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "candle_average": { + "name": "candle_average", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "cond_market_twap": { + "name": "cond_market_twap", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "candles_market_acct_markets_market_acct_fk": { + "name": "candles_market_acct_markets_market_acct_fk", + "tableFrom": "candles", + "tableTo": "markets", + "columnsFrom": [ + "market_acct" + ], + "columnsTo": [ + "market_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "candles_market_acct_candle_duration_timestamp_pk": { + "name": "candles_market_acct_candle_duration_timestamp_pk", + "columns": [ + "market_acct", + "candle_duration", + "timestamp" + ] + } + }, + "uniqueConstraints": {} + }, + "comments": { + "name": "comments", + "schema": "", + "columns": { + "comment_id": { + "name": "comment_id", + "type": "bigint", + "primaryKey": true, + "notNull": true + }, + "commentor_acct": { + "name": "commentor_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "proposal_acct": { + "name": "proposal_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "responding_comment_id": { + "name": "responding_comment_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "comments_proposal_acct_proposals_proposal_acct_fk": { + "name": "comments_proposal_acct_proposals_proposal_acct_fk", + "tableFrom": "comments", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_acct" + ], + "columnsTo": [ + "proposal_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "comments_responding_comment_id_comments_comment_id_fk": { + "name": "comments_responding_comment_id_comments_comment_id_fk", + "tableFrom": "comments", + "tableTo": "comments", + "columnsFrom": [ + "responding_comment_id" + ], + "columnsTo": [ + "comment_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "comments_comment_id_unique": { + "name": "comments_comment_id_unique", + "nullsNotDistinct": false, + "columns": [ + "comment_id" + ] + } + } + }, + "conditional_vaults": { + "name": "conditional_vaults", + "schema": "", + "columns": { + "cond_vault_acct": { + "name": "cond_vault_acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "settlement_authority": { + "name": "settlement_authority", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "underlying_mint_acct": { + "name": "underlying_mint_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "underlying_token_acct": { + "name": "underlying_token_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "nonce": { + "name": "nonce", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "cond_finalize_token_mint_acct": { + "name": "cond_finalize_token_mint_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "cond_revert_token_mint_acct": { + "name": "cond_revert_token_mint_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "conditional_vaults_underlying_mint_acct_tokens_mint_acct_fk": { + "name": "conditional_vaults_underlying_mint_acct_tokens_mint_acct_fk", + "tableFrom": "conditional_vaults", + "tableTo": "tokens", + "columnsFrom": [ + "underlying_mint_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "dao_details": { + "name": "dao_details", + "schema": "", + "columns": { + "dao_id": { + "name": "dao_id", + "type": "bigint", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "x_account": { + "name": "x_account", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "github": { + "name": "github", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "creator_acct": { + "name": "creator_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "admin_accts": { + "name": "admin_accts", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_image_url": { + "name": "token_image_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "pass_token_image_url": { + "name": "pass_token_image_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "fail_token_image_url": { + "name": "fail_token_image_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "lp_token_image_url": { + "name": "lp_token_image_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "is_hide": { + "name": "is_hide", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "socials": { + "name": "socials", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "dao_details_name_unique": { + "name": "dao_details_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + }, + "dao_details_slug_unique": { + "name": "dao_details_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + }, + "dao_details_url_unique": { + "name": "dao_details_url_unique", + "nullsNotDistinct": false, + "columns": [ + "url" + ] + }, + "dao_details_x_account_unique": { + "name": "dao_details_x_account_unique", + "nullsNotDistinct": false, + "columns": [ + "x_account" + ] + }, + "dao_details_github_unique": { + "name": "dao_details_github_unique", + "nullsNotDistinct": false, + "columns": [ + "github" + ] + }, + "id_name_url": { + "name": "id_name_url", + "nullsNotDistinct": false, + "columns": [ + "dao_id", + "url", + "name" + ] + } + } + }, + "daos": { + "name": "daos", + "schema": "", + "columns": { + "dao_acct": { + "name": "dao_acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "program_acct": { + "name": "program_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "dao_id": { + "name": "dao_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "base_acct": { + "name": "base_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "quote_acct": { + "name": "quote_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "treasury_acct": { + "name": "treasury_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "slots_per_proposal": { + "name": "slots_per_proposal", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "pass_threshold_bps": { + "name": "pass_threshold_bps", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "twap_initial_observation": { + "name": "twap_initial_observation", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "twap_max_observation_change_per_update": { + "name": "twap_max_observation_change_per_update", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "min_quote_futarchic_liquidity": { + "name": "min_quote_futarchic_liquidity", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "min_base_futarchic_liquidity": { + "name": "min_base_futarchic_liquidity", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "daos_program_acct_programs_program_acct_fk": { + "name": "daos_program_acct_programs_program_acct_fk", + "tableFrom": "daos", + "tableTo": "programs", + "columnsFrom": [ + "program_acct" + ], + "columnsTo": [ + "program_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "daos_dao_id_dao_details_dao_id_fk": { + "name": "daos_dao_id_dao_details_dao_id_fk", + "tableFrom": "daos", + "tableTo": "dao_details", + "columnsFrom": [ + "dao_id" + ], + "columnsTo": [ + "dao_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "daos_base_acct_tokens_mint_acct_fk": { + "name": "daos_base_acct_tokens_mint_acct_fk", + "tableFrom": "daos", + "tableTo": "tokens", + "columnsFrom": [ + "base_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "daos_quote_acct_tokens_mint_acct_fk": { + "name": "daos_quote_acct_tokens_mint_acct_fk", + "tableFrom": "daos", + "tableTo": "tokens", + "columnsFrom": [ + "quote_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "daos_treasury_acct_unique": { + "name": "daos_treasury_acct_unique", + "nullsNotDistinct": false, + "columns": [ + "treasury_acct" + ] + }, + "dao_acct_program": { + "name": "dao_acct_program", + "nullsNotDistinct": false, + "columns": [ + "dao_acct", + "program_acct" + ] + } + } + }, + "indexer_account_dependencies": { + "name": "indexer_account_dependencies", + "schema": "", + "columns": { + "name": { + "name": "name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "acct": { + "name": "acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "latest_tx_sig_processed": { + "name": "latest_tx_sig_processed", + "type": "varchar(88)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "varchar", + "primaryKey": false, + "notNull": false, + "default": "'active'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "indexer_account_dependencies_name_indexers_name_fk": { + "name": "indexer_account_dependencies_name_indexers_name_fk", + "tableFrom": "indexer_account_dependencies", + "tableTo": "indexers", + "columnsFrom": [ + "name" + ], + "columnsTo": [ + "name" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "indexer_account_dependencies_latest_tx_sig_processed_transactions_tx_sig_fk": { + "name": "indexer_account_dependencies_latest_tx_sig_processed_transactions_tx_sig_fk", + "tableFrom": "indexer_account_dependencies", + "tableTo": "transactions", + "columnsFrom": [ + "latest_tx_sig_processed" + ], + "columnsTo": [ + "tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "indexer_account_dependencies_name_acct_pk": { + "name": "indexer_account_dependencies_name_acct_pk", + "columns": [ + "name", + "acct" + ] + } + }, + "uniqueConstraints": {} + }, + "indexers": { + "name": "indexers", + "schema": "", + "columns": { + "name": { + "name": "name", + "type": "varchar(100)", + "primaryKey": true, + "notNull": true + }, + "implementation": { + "name": "implementation", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "latest_slot_processed": { + "name": "latest_slot_processed", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "indexer_type": { + "name": "indexer_type", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "makes": { + "name": "makes", + "schema": "", + "columns": { + "order_tx_sig": { + "name": "order_tx_sig", + "type": "varchar(88)", + "primaryKey": true, + "notNull": true + }, + "market_acct": { + "name": "market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "unfilled_base_amount": { + "name": "unfilled_base_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "filled_base_amount": { + "name": "filled_base_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "quote_price": { + "name": "quote_price", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "market_index": { + "name": "market_index", + "columns": [ + "market_acct" + ], + "isUnique": false + } + }, + "foreignKeys": { + "makes_order_tx_sig_orders_order_tx_sig_fk": { + "name": "makes_order_tx_sig_orders_order_tx_sig_fk", + "tableFrom": "makes", + "tableTo": "orders", + "columnsFrom": [ + "order_tx_sig" + ], + "columnsTo": [ + "order_tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "makes_market_acct_markets_market_acct_fk": { + "name": "makes_market_acct_markets_market_acct_fk", + "tableFrom": "makes", + "tableTo": "markets", + "columnsFrom": [ + "market_acct" + ], + "columnsTo": [ + "market_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "markets": { + "name": "markets", + "schema": "", + "columns": { + "market_acct": { + "name": "market_acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "market_type": { + "name": "market_type", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "create_tx_sig": { + "name": "create_tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": true + }, + "proposal_acct": { + "name": "proposal_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "base_mint_acct": { + "name": "base_mint_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "quote_mint_acct": { + "name": "quote_mint_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "base_lot_size": { + "name": "base_lot_size", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "quote_lot_size": { + "name": "quote_lot_size", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "quote_tick_size": { + "name": "quote_tick_size", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "bids_token_acct": { + "name": "bids_token_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "asks_token_acct": { + "name": "asks_token_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "base_maker_fee": { + "name": "base_maker_fee", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "base_taker_fee": { + "name": "base_taker_fee", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "quote_maker_fee": { + "name": "quote_maker_fee", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "quote_taker_fee": { + "name": "quote_taker_fee", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "active_slot": { + "name": "active_slot", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "inactive_slot": { + "name": "inactive_slot", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "markets_proposal_acct_proposals_proposal_acct_fk": { + "name": "markets_proposal_acct_proposals_proposal_acct_fk", + "tableFrom": "markets", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_acct" + ], + "columnsTo": [ + "proposal_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "markets_base_mint_acct_tokens_mint_acct_fk": { + "name": "markets_base_mint_acct_tokens_mint_acct_fk", + "tableFrom": "markets", + "tableTo": "tokens", + "columnsFrom": [ + "base_mint_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "markets_quote_mint_acct_tokens_mint_acct_fk": { + "name": "markets_quote_mint_acct_tokens_mint_acct_fk", + "tableFrom": "markets", + "tableTo": "tokens", + "columnsFrom": [ + "quote_mint_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "markets_bids_token_acct_token_accts_token_acct_fk": { + "name": "markets_bids_token_acct_token_accts_token_acct_fk", + "tableFrom": "markets", + "tableTo": "token_accts", + "columnsFrom": [ + "bids_token_acct" + ], + "columnsTo": [ + "token_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "markets_asks_token_acct_token_accts_token_acct_fk": { + "name": "markets_asks_token_acct_token_accts_token_acct_fk", + "tableFrom": "markets", + "tableTo": "token_accts", + "columnsFrom": [ + "asks_token_acct" + ], + "columnsTo": [ + "token_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "orders": { + "name": "orders", + "schema": "", + "columns": { + "order_tx_sig": { + "name": "order_tx_sig", + "type": "varchar(88)", + "primaryKey": true, + "notNull": true + }, + "market_acct": { + "name": "market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "actor_acct": { + "name": "actor_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "side": { + "name": "side", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "unfilled_base_amount": { + "name": "unfilled_base_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "filled_base_amount": { + "name": "filled_base_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "quote_price": { + "name": "quote_price", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "order_block": { + "name": "order_block", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "order_time": { + "name": "order_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "cancel_tx_sig": { + "name": "cancel_tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": false + }, + "cancel_block": { + "name": "cancel_block", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cancel_time": { + "name": "cancel_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "actor_index": { + "name": "actor_index", + "columns": [ + "market_acct", + "actor_acct" + ], + "isUnique": false + } + }, + "foreignKeys": { + "orders_order_tx_sig_transactions_tx_sig_fk": { + "name": "orders_order_tx_sig_transactions_tx_sig_fk", + "tableFrom": "orders", + "tableTo": "transactions", + "columnsFrom": [ + "order_tx_sig" + ], + "columnsTo": [ + "tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_market_acct_markets_market_acct_fk": { + "name": "orders_market_acct_markets_market_acct_fk", + "tableFrom": "orders", + "tableTo": "markets", + "columnsFrom": [ + "market_acct" + ], + "columnsTo": [ + "market_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_actor_acct_users_user_acct_fk": { + "name": "orders_actor_acct_users_user_acct_fk", + "tableFrom": "orders", + "tableTo": "users", + "columnsFrom": [ + "actor_acct" + ], + "columnsTo": [ + "user_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "prices": { + "name": "prices", + "schema": "", + "columns": { + "market_acct": { + "name": "market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "updated_slot": { + "name": "updated_slot", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "base_amount": { + "name": "base_amount", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "quote_amount": { + "name": "quote_amount", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "price": { + "name": "price", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prices_type": { + "name": "prices_type", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "prices_market_acct_markets_market_acct_fk": { + "name": "prices_market_acct_markets_market_acct_fk", + "tableFrom": "prices", + "tableTo": "markets", + "columnsFrom": [ + "market_acct" + ], + "columnsTo": [ + "market_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "prices_created_at_market_acct_pk": { + "name": "prices_created_at_market_acct_pk", + "columns": [ + "created_at", + "market_acct" + ] + } + }, + "uniqueConstraints": {} + }, + "program_system": { + "name": "program_system", + "schema": "", + "columns": { + "system_version": { + "name": "system_version", + "type": "double precision", + "primaryKey": true, + "notNull": true + }, + "autocrat_acct": { + "name": "autocrat_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "conditional_vault_acct": { + "name": "conditional_vault_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "pricing_model_acct": { + "name": "pricing_model_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "migrator_acct": { + "name": "migrator_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "program_system_autocrat_acct_programs_program_acct_fk": { + "name": "program_system_autocrat_acct_programs_program_acct_fk", + "tableFrom": "program_system", + "tableTo": "programs", + "columnsFrom": [ + "autocrat_acct" + ], + "columnsTo": [ + "program_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "program_system_conditional_vault_acct_programs_program_acct_fk": { + "name": "program_system_conditional_vault_acct_programs_program_acct_fk", + "tableFrom": "program_system", + "tableTo": "programs", + "columnsFrom": [ + "conditional_vault_acct" + ], + "columnsTo": [ + "program_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "program_system_pricing_model_acct_programs_program_acct_fk": { + "name": "program_system_pricing_model_acct_programs_program_acct_fk", + "tableFrom": "program_system", + "tableTo": "programs", + "columnsFrom": [ + "pricing_model_acct" + ], + "columnsTo": [ + "program_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "program_system_migrator_acct_programs_program_acct_fk": { + "name": "program_system_migrator_acct_programs_program_acct_fk", + "tableFrom": "program_system", + "tableTo": "programs", + "columnsFrom": [ + "migrator_acct" + ], + "columnsTo": [ + "program_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "programs": { + "name": "programs", + "schema": "", + "columns": { + "program_acct": { + "name": "program_acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "version": { + "name": "version", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "program_name": { + "name": "program_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deployed_at": { + "name": "deployed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "program_version": { + "name": "program_version", + "nullsNotDistinct": false, + "columns": [ + "program_acct", + "version" + ] + } + } + }, + "proposal_details": { + "name": "proposal_details", + "schema": "", + "columns": { + "proposal_id": { + "name": "proposal_id", + "type": "bigint", + "primaryKey": true, + "notNull": true + }, + "proposal_acct": { + "name": "proposal_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "proposer_acct": { + "name": "proposer_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "base_cond_vault_acct": { + "name": "base_cond_vault_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "quote_cond_vault_acct": { + "name": "quote_cond_vault_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "pass_market_acct": { + "name": "pass_market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "fail_market_acct": { + "name": "fail_market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "proposal_details_proposal_acct_proposals_proposal_acct_fk": { + "name": "proposal_details_proposal_acct_proposals_proposal_acct_fk", + "tableFrom": "proposal_details", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_acct" + ], + "columnsTo": [ + "proposal_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "proposal_details_slug_unique": { + "name": "proposal_details_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + } + }, + "proposals": { + "name": "proposals", + "schema": "", + "columns": { + "proposal_acct": { + "name": "proposal_acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "dao_acct": { + "name": "dao_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "proposal_num": { + "name": "proposal_num", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "autocrat_version": { + "name": "autocrat_version", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "proposer_acct": { + "name": "proposer_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "initial_slot": { + "name": "initial_slot", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "end_slot": { + "name": "end_slot", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "description_url": { + "name": "description_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "pricing_model_pass_acct": { + "name": "pricing_model_pass_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "pricing_model_fail_acct": { + "name": "pricing_model_fail_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "pass_market_acct": { + "name": "pass_market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "fail_market_acct": { + "name": "fail_market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "base_vault": { + "name": "base_vault", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "quote_vault": { + "name": "quote_vault", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "duration_in_slots": { + "name": "duration_in_slots", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "pass_threshold_bps": { + "name": "pass_threshold_bps", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "twap_initial_observation": { + "name": "twap_initial_observation", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "twap_max_observation_change_per_update": { + "name": "twap_max_observation_change_per_update", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "min_quote_futarchic_liquidity": { + "name": "min_quote_futarchic_liquidity", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "min_base_futarchic_liquidity": { + "name": "min_base_futarchic_liquidity", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "proposals_dao_acct_daos_dao_acct_fk": { + "name": "proposals_dao_acct_daos_dao_acct_fk", + "tableFrom": "proposals", + "tableTo": "daos", + "columnsFrom": [ + "dao_acct" + ], + "columnsTo": [ + "dao_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "proposals_base_vault_conditional_vaults_cond_vault_acct_fk": { + "name": "proposals_base_vault_conditional_vaults_cond_vault_acct_fk", + "tableFrom": "proposals", + "tableTo": "conditional_vaults", + "columnsFrom": [ + "base_vault" + ], + "columnsTo": [ + "cond_vault_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "proposals_quote_vault_conditional_vaults_cond_vault_acct_fk": { + "name": "proposals_quote_vault_conditional_vaults_cond_vault_acct_fk", + "tableFrom": "proposals", + "tableTo": "conditional_vaults", + "columnsFrom": [ + "quote_vault" + ], + "columnsTo": [ + "cond_vault_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "reactions": { + "name": "reactions", + "schema": "", + "columns": { + "reaction_id": { + "name": "reaction_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "reactor_acct": { + "name": "reactor_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "comment_id": { + "name": "comment_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "proposal_acct": { + "name": "proposal_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "reaction": { + "name": "reaction", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "reactions_comment_id_comments_comment_id_fk": { + "name": "reactions_comment_id_comments_comment_id_fk", + "tableFrom": "reactions", + "tableTo": "comments", + "columnsFrom": [ + "comment_id" + ], + "columnsTo": [ + "comment_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reactions_proposal_acct_proposals_proposal_acct_fk": { + "name": "reactions_proposal_acct_proposals_proposal_acct_fk", + "tableFrom": "reactions", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_acct" + ], + "columnsTo": [ + "proposal_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_acct": { + "name": "user_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_acct_users_user_acct_fk": { + "name": "sessions_user_acct_users_user_acct_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_acct" + ], + "columnsTo": [ + "user_acct" + ], + "onDelete": "restrict", + "onUpdate": "restrict" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "takes": { + "name": "takes", + "schema": "", + "columns": { + "order_tx_sig": { + "name": "order_tx_sig", + "type": "varchar(88)", + "primaryKey": true, + "notNull": true + }, + "base_amount": { + "name": "base_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "quote_price": { + "name": "quote_price", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "taker_base_fee": { + "name": "taker_base_fee", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "taker_quote_fee": { + "name": "taker_quote_fee", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "maker_order_tx_sig": { + "name": "maker_order_tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": false + }, + "maker_base_fee": { + "name": "maker_base_fee", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "maker_quote_fee": { + "name": "maker_quote_fee", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "market_acct": { + "name": "market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "order_block": { + "name": "order_block", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "order_time": { + "name": "order_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "block_index": { + "name": "block_index", + "columns": [ + "market_acct", + "order_block" + ], + "isUnique": false + }, + "time_index": { + "name": "time_index", + "columns": [ + "market_acct", + "order_time" + ], + "isUnique": false + }, + "maker_index": { + "name": "maker_index", + "columns": [ + "maker_order_tx_sig" + ], + "isUnique": false + } + }, + "foreignKeys": { + "takes_order_tx_sig_orders_order_tx_sig_fk": { + "name": "takes_order_tx_sig_orders_order_tx_sig_fk", + "tableFrom": "takes", + "tableTo": "orders", + "columnsFrom": [ + "order_tx_sig" + ], + "columnsTo": [ + "order_tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "takes_maker_order_tx_sig_makes_order_tx_sig_fk": { + "name": "takes_maker_order_tx_sig_makes_order_tx_sig_fk", + "tableFrom": "takes", + "tableTo": "makes", + "columnsFrom": [ + "maker_order_tx_sig" + ], + "columnsTo": [ + "order_tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "takes_market_acct_markets_market_acct_fk": { + "name": "takes_market_acct_markets_market_acct_fk", + "tableFrom": "takes", + "tableTo": "markets", + "columnsFrom": [ + "market_acct" + ], + "columnsTo": [ + "market_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "token_acct_balances": { + "name": "token_acct_balances", + "schema": "", + "columns": { + "token_acct": { + "name": "token_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "mint_acct": { + "name": "mint_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "owner_acct": { + "name": "owner_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delta": { + "name": "delta", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "0" + }, + "slot": { + "name": "slot", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "tx_sig": { + "name": "tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "acct_amount_created": { + "name": "acct_amount_created", + "columns": [ + "token_acct", + "created_at", + "amount" + ], + "isUnique": false + } + }, + "foreignKeys": { + "token_acct_balances_token_acct_token_accts_token_acct_fk": { + "name": "token_acct_balances_token_acct_token_accts_token_acct_fk", + "tableFrom": "token_acct_balances", + "tableTo": "token_accts", + "columnsFrom": [ + "token_acct" + ], + "columnsTo": [ + "token_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "token_acct_balances_mint_acct_tokens_mint_acct_fk": { + "name": "token_acct_balances_mint_acct_tokens_mint_acct_fk", + "tableFrom": "token_acct_balances", + "tableTo": "tokens", + "columnsFrom": [ + "mint_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "token_acct_balances_tx_sig_transactions_tx_sig_fk": { + "name": "token_acct_balances_tx_sig_transactions_tx_sig_fk", + "tableFrom": "token_acct_balances", + "tableTo": "transactions", + "columnsFrom": [ + "tx_sig" + ], + "columnsTo": [ + "tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "token_acct_balances_token_acct_mint_acct_amount_created_at_pk": { + "name": "token_acct_balances_token_acct_mint_acct_amount_created_at_pk", + "columns": [ + "token_acct", + "mint_acct", + "amount", + "created_at" + ] + } + }, + "uniqueConstraints": {} + }, + "token_accts": { + "name": "token_accts", + "schema": "", + "columns": { + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "mint_acct": { + "name": "mint_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "owner_acct": { + "name": "owner_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar", + "primaryKey": false, + "notNull": false, + "default": "'enabled'" + }, + "token_acct": { + "name": "token_acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "token_accts_mint_acct_tokens_mint_acct_fk": { + "name": "token_accts_mint_acct_tokens_mint_acct_fk", + "tableFrom": "token_accts", + "tableTo": "tokens", + "columnsFrom": [ + "mint_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "tokens": { + "name": "tokens", + "schema": "", + "columns": { + "mint_acct": { + "name": "mint_acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true + }, + "symbol": { + "name": "symbol", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "supply": { + "name": "supply", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "decimals": { + "name": "decimals", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "transaction_watcher_transactions": { + "name": "transaction_watcher_transactions", + "schema": "", + "columns": { + "watcher_acct": { + "name": "watcher_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "tx_sig": { + "name": "tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "watcher_slot_index": { + "name": "watcher_slot_index", + "columns": [ + "watcher_acct", + "slot" + ], + "isUnique": false + } + }, + "foreignKeys": { + "transaction_watcher_transactions_watcher_acct_transaction_watchers_acct_fk": { + "name": "transaction_watcher_transactions_watcher_acct_transaction_watchers_acct_fk", + "tableFrom": "transaction_watcher_transactions", + "tableTo": "transaction_watchers", + "columnsFrom": [ + "watcher_acct" + ], + "columnsTo": [ + "acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "transaction_watcher_transactions_tx_sig_transactions_tx_sig_fk": { + "name": "transaction_watcher_transactions_tx_sig_transactions_tx_sig_fk", + "tableFrom": "transaction_watcher_transactions", + "tableTo": "transactions", + "columnsFrom": [ + "tx_sig" + ], + "columnsTo": [ + "tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "transaction_watcher_transactions_watcher_acct_tx_sig_pk": { + "name": "transaction_watcher_transactions_watcher_acct_tx_sig_pk", + "columns": [ + "watcher_acct", + "tx_sig" + ] + } + }, + "uniqueConstraints": {} + }, + "transaction_watchers": { + "name": "transaction_watchers", + "schema": "", + "columns": { + "acct": { + "name": "acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "latest_tx_sig": { + "name": "latest_tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": false + }, + "first_tx_sig": { + "name": "first_tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": false + }, + "checked_up_to_slot": { + "name": "checked_up_to_slot", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "serializer_logic_version": { + "name": "serializer_logic_version", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar", + "primaryKey": false, + "notNull": true, + "default": "'disabled'" + }, + "failure_log": { + "name": "failure_log", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "transaction_watchers_latest_tx_sig_transactions_tx_sig_fk": { + "name": "transaction_watchers_latest_tx_sig_transactions_tx_sig_fk", + "tableFrom": "transaction_watchers", + "tableTo": "transactions", + "columnsFrom": [ + "latest_tx_sig" + ], + "columnsTo": [ + "tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "transaction_watchers_first_tx_sig_transactions_tx_sig_fk": { + "name": "transaction_watchers_first_tx_sig_transactions_tx_sig_fk", + "tableFrom": "transaction_watchers", + "tableTo": "transactions", + "columnsFrom": [ + "first_tx_sig" + ], + "columnsTo": [ + "tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "transactions": { + "name": "transactions", + "schema": "", + "columns": { + "tx_sig": { + "name": "tx_sig", + "type": "varchar(88)", + "primaryKey": true, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "block_time": { + "name": "block_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "failed": { + "name": "failed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "serializer_logic_version": { + "name": "serializer_logic_version", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "main_ix_type": { + "name": "main_ix_type", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "txn_slot_index": { + "name": "txn_slot_index", + "columns": [ + "slot" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "twaps": { + "name": "twaps", + "schema": "", + "columns": { + "market_acct": { + "name": "market_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "proposal_acct": { + "name": "proposal_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "updated_slot": { + "name": "updated_slot", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "observation_agg": { + "name": "observation_agg", + "type": "numeric(40, 0)", + "primaryKey": false, + "notNull": true + }, + "last_observation": { + "name": "last_observation", + "type": "numeric(40, 0)", + "primaryKey": false, + "notNull": false + }, + "last_price": { + "name": "last_price", + "type": "numeric(40, 0)", + "primaryKey": false, + "notNull": false + }, + "token_amount": { + "name": "token_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "twaps_market_acct_markets_market_acct_fk": { + "name": "twaps_market_acct_markets_market_acct_fk", + "tableFrom": "twaps", + "tableTo": "markets", + "columnsFrom": [ + "market_acct" + ], + "columnsTo": [ + "market_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "twaps_proposal_acct_proposals_proposal_acct_fk": { + "name": "twaps_proposal_acct_proposals_proposal_acct_fk", + "tableFrom": "twaps", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_acct" + ], + "columnsTo": [ + "proposal_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "twaps_updated_slot_market_acct_pk": { + "name": "twaps_updated_slot_market_acct_pk", + "columns": [ + "updated_slot", + "market_acct" + ] + } + }, + "uniqueConstraints": {} + }, + "user_deposits": { + "name": "user_deposits", + "schema": "", + "columns": { + "tx_sig": { + "name": "tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": true + }, + "user_acct": { + "name": "user_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "token_amount": { + "name": "token_amount", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "mint_acct": { + "name": "mint_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_deposits_tx_sig_transactions_tx_sig_fk": { + "name": "user_deposits_tx_sig_transactions_tx_sig_fk", + "tableFrom": "user_deposits", + "tableTo": "transactions", + "columnsFrom": [ + "tx_sig" + ], + "columnsTo": [ + "tx_sig" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_deposits_user_acct_users_user_acct_fk": { + "name": "user_deposits_user_acct_users_user_acct_fk", + "tableFrom": "user_deposits", + "tableTo": "users", + "columnsFrom": [ + "user_acct" + ], + "columnsTo": [ + "user_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_deposits_mint_acct_tokens_mint_acct_fk": { + "name": "user_deposits_mint_acct_tokens_mint_acct_fk", + "tableFrom": "user_deposits", + "tableTo": "tokens", + "columnsFrom": [ + "mint_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user_performance": { + "name": "user_performance", + "schema": "", + "columns": { + "proposal_acct": { + "name": "proposal_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "user_acct": { + "name": "user_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "dao_acct": { + "name": "dao_acct", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "tokens_bought": { + "name": "tokens_bought", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "tokens_sold": { + "name": "tokens_sold", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "volume_bought": { + "name": "volume_bought", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "volume_sold": { + "name": "volume_sold", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "total_volume": { + "name": "total_volume", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true, + "default": "'0.0'" + }, + "tokens_bought_resolving_market": { + "name": "tokens_bought_resolving_market", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true, + "default": "'0.0'" + }, + "tokens_sold_resolving_market": { + "name": "tokens_sold_resolving_market", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true, + "default": "'0.0'" + }, + "volume_bought_resolving_market": { + "name": "volume_bought_resolving_market", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true, + "default": "'0.0'" + }, + "volume_sold_resolving_market": { + "name": "volume_sold_resolving_market", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true, + "default": "'0.0'" + }, + "buy_orders_count": { + "name": "buy_orders_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "sell_orders_count": { + "name": "sell_orders_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_performance_proposal_acct_proposals_proposal_acct_fk": { + "name": "user_performance_proposal_acct_proposals_proposal_acct_fk", + "tableFrom": "user_performance", + "tableTo": "proposals", + "columnsFrom": [ + "proposal_acct" + ], + "columnsTo": [ + "proposal_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_performance_user_acct_users_user_acct_fk": { + "name": "user_performance_user_acct_users_user_acct_fk", + "tableFrom": "user_performance", + "tableTo": "users", + "columnsFrom": [ + "user_acct" + ], + "columnsTo": [ + "user_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_performance_dao_acct_daos_dao_acct_fk": { + "name": "user_performance_dao_acct_daos_dao_acct_fk", + "tableFrom": "user_performance", + "tableTo": "daos", + "columnsFrom": [ + "dao_acct" + ], + "columnsTo": [ + "dao_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_performance_proposal_acct_user_acct_pk": { + "name": "user_performance_proposal_acct_user_acct_pk", + "columns": [ + "proposal_acct", + "user_acct" + ] + } + }, + "uniqueConstraints": {} + }, + "users": { + "name": "users", + "schema": "", + "columns": { + "user_acct": { + "name": "user_acct", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/database/drizzle/meta/_journal.json b/packages/database/drizzle/meta/_journal.json index 254bb20b..e0958eba 100644 --- a/packages/database/drizzle/meta/_journal.json +++ b/packages/database/drizzle/meta/_journal.json @@ -449,6 +449,13 @@ "when": 1723861131459, "tag": "0063_wonderful_blue_shield", "breakpoints": true + }, + { + "idx": 64, + "version": "5", + "when": 1724001296288, + "tag": "0064_living_iron_monger", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/database/lib/schema.ts b/packages/database/lib/schema.ts index bb222efc..7081850c 100644 --- a/packages/database/lib/schema.ts +++ b/packages/database/lib/schema.ts @@ -812,6 +812,9 @@ export const userPerformance = pgTable( userAcct: pubkey("user_acct") .notNull() .references(() => users.userAcct), + daoAcct: pubkey("dao_acct") + .notNull() + .references(() => daos.daoAcct), tokensBought: numeric("tokens_bought", { precision: 40, scale: 20, @@ -831,23 +834,34 @@ export const userPerformance = pgTable( totalVolume: numeric("total_volume", { precision: 40, scale: 20, - }).notNull(), + }).notNull() + .default("0.0"), tokensBoughtResolvingMarket: numeric("tokens_bought_resolving_market", { precision: 40, scale: 20, - }).notNull(), + }).notNull() + .default("0.0"), tokensSoldResolvingMarket: numeric("tokens_sold_resolving_market", { precision: 40, scale: 20, - }).notNull(), + }).notNull() + .default("0.0"), volumeBoughtResolvingMarket: numeric("volume_bought_resolving_market", { precision: 40, scale: 20, - }).notNull(), + }).notNull() + .default("0.0"), volumeSoldResolvingMarket: numeric("volume_sold_resolving_market", { precision: 40, scale: 20, - }).notNull(), + }).notNull() + .default("0.0"), + buyOrdersCount: bigint("buy_orders_count", { mode: "bigint" }) + .notNull() + .default(0 as unknown as bigint), + sellOrdersCount: bigint("sell_orders_count", { mode: "bigint" }) + .notNull() + .default(0 as unknown as bigint), createdAt: timestamp("created_at", { withTimezone: true }) .notNull() .default(sql`now()`), diff --git a/packages/database/sql/native-queries.sql b/packages/database/sql/native-queries.sql new file mode 100644 index 00000000..ed60039d --- /dev/null +++ b/packages/database/sql/native-queries.sql @@ -0,0 +1,39 @@ +-- user_count_and_trade_count_per_proposal +-- WITH market_actors AS ( +-- SELECT +-- market_acct, +-- actor_acct, +-- COUNT(*) AS countOrders +-- FROM +-- orders +-- GROUP BY +-- market_acct, actor_acct +-- ), distinct_users_by_proposal AS ( +-- SELECT +-- proposal_acct, +-- COUNT(DISTINCT actor_acct) AS uniqueUsersCount, +-- SUM(countOrders) AS totalTrades +-- FROM market_actors +-- JOIN markets ON markets.market_acct = market_actors.market_acct +-- GROUP BY proposal_acct +-- ) +-- SELECT +-- proposal_acct, +-- uniqueUsersCount AS user_count, +-- totalTrades AS trade_count +-- FROM distinct_users_by_proposal +-- WHERE +-- CASE +-- WHEN {{proposal_acct}} IS NOT NULL +-- THEN proposal_acct = {{proposal_acct}} +-- ELSE 1 = 1 +-- END; + +--top_dao_traders +-- select up.user_acct::TEXT, sum(up.total_volume)::BIGINT as "total_volume" from user_performance up +-- join proposals p on up.proposal_acct = p.proposal_acct +-- join daos d on p.dao_acct = d.dao_acct +-- join dao_details dd on dd.dao_id = d.dao_id +-- where dd.slug = {{dao_slug}} +-- group by dd.slug, up.user_acct +-- order by sum(up.total_volume) desc; \ No newline at end of file diff --git a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts index 0cebc2d7..27a66b05 100644 --- a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts +++ b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts @@ -716,6 +716,8 @@ async function calculateUserPerformance( tokensSoldResolvingMarket: 0, // P/F market sell quantity volumeBoughtResolvingMarket: 0, // P/F market buy volume volumeSoldResolvingMarket: 0, // P/F market sell volume + buyOrderCount: 0, + sellOrderCount: 0, }; } @@ -740,6 +742,7 @@ async function calculateUserPerformance( if (next.side === "BID") { totals.tokensBought = totals.tokensBought + size; totals.volumeBought = totals.volumeBought + amount; + totals.buyOrderCount = totals.buyOrderCount + 1; // If this is the resolving market then we want to keep a running tally for that for P&L if(next.marketAcct === resolvingMarket){ totals.tokensBoughtResolvingMarket = totals.tokensBoughtResolvingMarket + size; @@ -749,6 +752,7 @@ async function calculateUserPerformance( } else if (next.side === "ASK") { totals.tokensSold = totals.tokensSold + size; totals.volumeSold = totals.volumeSold + amount; + totals.sellOrderCount = totals.sellOrderCount + 1; // If this is the resolving market then we want to keep a running tally for that for P&L if(next.marketAcct === resolvingMarket){ totals.tokensSoldResolvingMarket = totals.tokensSoldResolvingMarket + size; @@ -790,6 +794,7 @@ async function calculateUserPerformance( return { proposalAcct: onChainProposal.publicKey.toString(), + daoAcct: proposals.daoAcct, userAcct: actor, tokensBought: values.tokensBought.toString(), tokensSold: values.tokensSold.toString(), @@ -799,6 +804,8 @@ async function calculateUserPerformance( tokensSoldResolvingMarket: values.tokensSoldResolvingMarket.toString(), volumeBoughtResolvingMarket: values.volumeBoughtResolvingMarket.toString(), volumeSoldResolvingMarket: values.volumeSoldResolvingMarket.toString(), + buyOrdersCount: values.buyOrderCount as unknown as bigint, + sellOrdersCount: values.sellOrderCount as unknown as bigint, }; }); diff --git a/packages/indexer/src/types/index.ts b/packages/indexer/src/types/index.ts index 10371a99..f01d7ba7 100644 --- a/packages/indexer/src/types/index.ts +++ b/packages/indexer/src/types/index.ts @@ -31,6 +31,8 @@ export type UserPerformanceTotals = { tokensSoldResolvingMarket: number; volumeBoughtResolvingMarket: number; volumeSoldResolvingMarket: number; + buyOrderCount: number; + sellOrderCount: number; }; export type UserPerformance = { From 38b3c309390759f47d1cd03b68f99cddb380c5f8 Mon Sep 17 00:00:00 2001 From: Kollan House Date: Sun, 18 Aug 2024 11:49:26 -0600 Subject: [PATCH 4/4] feat: gitignore --- .gitignore | 3 +- .../hasura/metadata/databases/databases.yaml | 30 +++++++++++++++++++ .../futarchy/tables/public_daos.yaml | 7 +++++ .../futarchy/tables/public_tokens.yaml | 7 +++++ .../futarchy/tables/public_transactions.yaml | 7 +++++ .../futarchy/tables/public_user_deposits.yaml | 10 +++++++ .../tables/public_user_performance.yaml | 15 ++++++++-- .../futarchy/tables/public_users.yaml | 7 +++++ 8 files changed, 83 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8163ede0..203e0951 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules .vscode/launch.json .env* -.history \ No newline at end of file +.history +.DS_Store \ No newline at end of file diff --git a/packages/hasura/metadata/databases/databases.yaml b/packages/hasura/metadata/databases/databases.yaml index e30f04af..b88b89e8 100644 --- a/packages/hasura/metadata/databases/databases.yaml +++ b/packages/hasura/metadata/databases/databases.yaml @@ -24,6 +24,28 @@ - total_volume filter: {} role: anonymous + - fields: + - name: proposal_acct + type: + nullable: false + scalar: varchar + - name: user_count + type: + nullable: true + scalar: bigint + - name: trade_count + type: + nullable: true + scalar: numeric + name: proposal_statistics + select_permissions: + - permission: + columns: + - proposal_acct + - user_count + - trade_count + filter: {} + role: anonymous native_queries: - arguments: dao_slug: @@ -33,4 +55,12 @@ code: "select up.user_acct::TEXT, sum(up.total_volume)::BIGINT as \"total_volume\" from user_performance up\r\njoin proposals p on up.proposal_acct = p.proposal_acct \r\njoin daos d on p.dao_acct = d.dao_acct\r\njoin dao_details dd on dd.dao_id = d.dao_id \r\nwhere dd.slug = {{dao_slug}}\r\ngroup by dd.slug, up.user_acct\r\norder by sum(up.total_volume) desc;" returns: dao_trader root_field_name: top_dao_traders + - arguments: + proposal_acct: + description: the proposal account + nullable: true + type: varchar + code: "WITH market_actors AS (\n SELECT \n market_acct,\n actor_acct,\n COUNT(*) AS countOrders\n FROM \n orders\n GROUP BY \n market_acct, actor_acct\n), distinct_users_by_proposal AS (\n SELECT\n proposal_acct,\n COUNT(DISTINCT actor_acct) AS uniqueUsersCount,\n SUM(countOrders) AS totalTrades\n FROM market_actors\n JOIN markets ON markets.market_acct = market_actors.market_acct\n GROUP BY proposal_acct\n)\nSELECT\n\tproposal_acct,\n\tuniqueUsersCount AS user_count,\n\ttotalTrades AS trade_count\nFROM distinct_users_by_proposal\nWHERE \n CASE \n WHEN {{proposal_acct}} IS NOT NULL \n THEN proposal_acct = {{proposal_acct}} \n ELSE 1 = 1 \n END;" + returns: proposal_statistics + root_field_name: user_count_and_trade_count_per_proposal tables: "!include futarchy/tables/tables.yaml" diff --git a/packages/hasura/metadata/databases/futarchy/tables/public_daos.yaml b/packages/hasura/metadata/databases/futarchy/tables/public_daos.yaml index a139f4d8..5cefbfad 100644 --- a/packages/hasura/metadata/databases/futarchy/tables/public_daos.yaml +++ b/packages/hasura/metadata/databases/futarchy/tables/public_daos.yaml @@ -31,6 +31,13 @@ array_relationships: table: name: proposals schema: public + - name: user_performances + using: + foreign_key_constraint_on: + column: dao_acct + table: + name: user_performance + schema: public select_permissions: - role: anonymous permission: diff --git a/packages/hasura/metadata/databases/futarchy/tables/public_tokens.yaml b/packages/hasura/metadata/databases/futarchy/tables/public_tokens.yaml index a78bcd06..834f41fb 100644 --- a/packages/hasura/metadata/databases/futarchy/tables/public_tokens.yaml +++ b/packages/hasura/metadata/databases/futarchy/tables/public_tokens.yaml @@ -70,6 +70,13 @@ array_relationships: table: name: token_accts schema: public + - name: user_deposits + using: + foreign_key_constraint_on: + column: mint_acct + table: + name: user_deposits + schema: public select_permissions: - role: anonymous permission: diff --git a/packages/hasura/metadata/databases/futarchy/tables/public_transactions.yaml b/packages/hasura/metadata/databases/futarchy/tables/public_transactions.yaml index 5c343ab4..e1eb2bb4 100644 --- a/packages/hasura/metadata/databases/futarchy/tables/public_transactions.yaml +++ b/packages/hasura/metadata/databases/futarchy/tables/public_transactions.yaml @@ -45,6 +45,13 @@ array_relationships: table: name: transaction_watchers schema: public + - name: user_deposits + using: + foreign_key_constraint_on: + column: tx_sig + table: + name: user_deposits + schema: public select_permissions: - role: anonymous permission: diff --git a/packages/hasura/metadata/databases/futarchy/tables/public_user_deposits.yaml b/packages/hasura/metadata/databases/futarchy/tables/public_user_deposits.yaml index 31074a68..0ad88731 100644 --- a/packages/hasura/metadata/databases/futarchy/tables/public_user_deposits.yaml +++ b/packages/hasura/metadata/databases/futarchy/tables/public_user_deposits.yaml @@ -1,6 +1,16 @@ table: name: user_deposits schema: public +object_relationships: + - name: token + using: + foreign_key_constraint_on: mint_acct + - name: transaction + using: + foreign_key_constraint_on: tx_sig + - name: user + using: + foreign_key_constraint_on: user_acct select_permissions: - role: anonymous permission: diff --git a/packages/hasura/metadata/databases/futarchy/tables/public_user_performance.yaml b/packages/hasura/metadata/databases/futarchy/tables/public_user_performance.yaml index ecbc316b..90a6d8b0 100644 --- a/packages/hasura/metadata/databases/futarchy/tables/public_user_performance.yaml +++ b/packages/hasura/metadata/databases/futarchy/tables/public_user_performance.yaml @@ -2,6 +2,9 @@ table: name: user_performance schema: public object_relationships: + - name: dao + using: + foreign_key_constraint_on: dao_acct - name: proposal using: foreign_key_constraint_on: proposal_acct @@ -12,14 +15,22 @@ select_permissions: - role: anonymous permission: columns: + - buy_orders_count + - sell_orders_count + - dao_acct - proposal_acct - user_acct - tokens_bought - - tokens_sold + - tokens_bought_resolving_market + - tokens_sold_resolving_market + - total_volume - volume_bought + - volume_bought_resolving_market - volume_sold - - total_volume + - volume_sold_resolving_market - created_at + - updated_at + - tokens_sold filter: {} allow_aggregations: true comment: "" diff --git a/packages/hasura/metadata/databases/futarchy/tables/public_users.yaml b/packages/hasura/metadata/databases/futarchy/tables/public_users.yaml index 40ae4c0c..bc786fe5 100644 --- a/packages/hasura/metadata/databases/futarchy/tables/public_users.yaml +++ b/packages/hasura/metadata/databases/futarchy/tables/public_users.yaml @@ -16,6 +16,13 @@ array_relationships: table: name: sessions schema: public + - name: user_deposits + using: + foreign_key_constraint_on: + column: user_acct + table: + name: user_deposits + schema: public - name: user_performances using: foreign_key_constraint_on: