From ea9df41567805d65d698432ce2949a8eb7448666 Mon Sep 17 00:00:00 2001 From: Kollan House Date: Thu, 24 Oct 2024 10:38:46 -0700 Subject: [PATCH 1/3] feat: removes takes constraint on order sig for old order book data --- .../database/drizzle/0008_stormy_spirit.sql | 18 + .../database/drizzle/meta/0008_snapshot.json | 3610 +++++++++++++++++ packages/database/drizzle/meta/_journal.json | 7 + packages/database/lib/schema.ts | 5 +- 4 files changed, 3637 insertions(+), 3 deletions(-) create mode 100644 packages/database/drizzle/0008_stormy_spirit.sql create mode 100644 packages/database/drizzle/meta/0008_snapshot.json diff --git a/packages/database/drizzle/0008_stormy_spirit.sql b/packages/database/drizzle/0008_stormy_spirit.sql new file mode 100644 index 0000000..2407dbf --- /dev/null +++ b/packages/database/drizzle/0008_stormy_spirit.sql @@ -0,0 +1,18 @@ +/* + Unfortunately in current drizzle-kit version we can't automatically get name for primary key. + We are working on making it available! + + Meanwhile you can: + 1. Check pk name in your database, by running + SELECT constraint_name FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'takes' + AND constraint_type = 'PRIMARY KEY'; + 2. Uncomment code below and paste pk name manually + + Hope to release this update as soon as possible +*/ + +ALTER TABLE "takes" DROP CONSTRAINT "takes_pkey";--> statement-breakpoint +ALTER TABLE "takes" ALTER COLUMN "order_tx_sig" DROP NOT NULL;--> statement-breakpoint +ALTER TABLE "takes" ADD COLUMN "take_id" uuid DEFAULT gen_random_uuid() NOT NULL; \ No newline at end of file diff --git a/packages/database/drizzle/meta/0008_snapshot.json b/packages/database/drizzle/meta/0008_snapshot.json new file mode 100644 index 0000000..91550c9 --- /dev/null +++ b/packages/database/drizzle/meta/0008_snapshot.json @@ -0,0 +1,3610 @@ +{ + "id": "46750075-91a4-4e4d-b00a-3f3ab69abf22", + "prevId": "2f29ee7d-b2cb-458c-9e8f-5e1278f5a691", + "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": "numeric", + "primaryKey": false, + "notNull": true + }, + "open": { + "name": "open", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "high": { + "name": "high", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "low": { + "name": "low", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "close": { + "name": "close", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "candle_average": { + "name": "candle_average", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "cond_market_twap": { + "name": "cond_market_twap", + "type": "numeric", + "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": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": false + }, + "twap_max_observation_change_per_update": { + "name": "twap_max_observation_change_per_update", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "min_quote_futarchic_liquidity": { + "name": "min_quote_futarchic_liquidity", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "min_base_futarchic_liquidity": { + "name": "min_base_futarchic_liquidity", + "type": "numeric", + "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": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": true + }, + "filled_base_amount": { + "name": "filled_base_amount", + "type": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": true + }, + "quote_lot_size": { + "name": "quote_lot_size", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "quote_tick_size": { + "name": "quote_tick_size", + "type": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": false + }, + "inactive_slot": { + "name": "inactive_slot", + "type": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": true + }, + "filled_base_amount": { + "name": "filled_base_amount", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "quote_price": { + "name": "quote_price", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": true + }, + "order_block": { + "name": "order_block", + "type": "numeric", + "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": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": true + }, + "base_amount": { + "name": "base_amount", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "quote_amount": { + "name": "quote_amount", + "type": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": true + }, + "end_slot": { + "name": "end_slot", + "type": "numeric", + "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": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": false + }, + "twap_max_observation_change_per_update": { + "name": "twap_max_observation_change_per_update", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "min_quote_futarchic_liquidity": { + "name": "min_quote_futarchic_liquidity", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "min_base_futarchic_liquidity": { + "name": "min_base_futarchic_liquidity", + "type": "numeric", + "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": {} + }, + "signature_accounts": { + "name": "signature_accounts", + "schema": "", + "columns": { + "signature": { + "name": "signature", + "type": "varchar(88)", + "primaryKey": false, + "notNull": true + }, + "account": { + "name": "account", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "inserted_at": { + "name": "inserted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_index": { + "name": "account_index", + "columns": [ + "account" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "signature_accounts_signature_account_pk": { + "name": "signature_accounts_signature_account_pk", + "columns": [ + "signature", + "account" + ] + } + }, + "uniqueConstraints": {} + }, + "signatures": { + "name": "signatures", + "schema": "", + "columns": { + "signature": { + "name": "signature", + "type": "varchar(88)", + "primaryKey": true, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "did_err": { + "name": "did_err", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "err": { + "name": "err", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "block_time": { + "name": "block_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "inserted_at": { + "name": "inserted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "seq_num": { + "name": "seq_num", + "type": "bigserial", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slot_index": { + "name": "slot_index", + "columns": [ + "slot" + ], + "isUnique": false + }, + "sequence_num_index": { + "name": "sequence_num_index", + "columns": [ + "seq_num" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "signatures_seq_num_unique": { + "name": "signatures_seq_num_unique", + "nullsNotDistinct": false, + "columns": [ + "seq_num" + ] + } + } + }, + "takes": { + "name": "takes", + "schema": "", + "columns": { + "take_id": { + "name": "take_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "order_tx_sig": { + "name": "order_tx_sig", + "type": "varchar(88)", + "primaryKey": false, + "notNull": false + }, + "base_amount": { + "name": "base_amount", + "type": "numeric", + "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": "numeric", + "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": "numeric", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delta": { + "name": "delta", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "0" + }, + "slot": { + "name": "slot", + "type": "numeric", + "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": "numeric", + "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": "numeric", + "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": "numeric", + "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": "numeric", + "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": "numeric", + "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": false + }, + "updated_slot": { + "name": "updated_slot", + "type": "numeric", + "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": "numeric", + "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": "numeric", + "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": {} + }, + "v0_4_amms": { + "name": "v0_4_amms", + "schema": "", + "columns": { + "amm_addr": { + "name": "amm_addr", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "created_at_slot": { + "name": "created_at_slot", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "lp_mint_addr": { + "name": "lp_mint_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "base_mint_addr": { + "name": "base_mint_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "quote_mint_addr": { + "name": "quote_mint_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "base_reserves": { + "name": "base_reserves", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "quote_reserves": { + "name": "quote_reserves", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "latest_amm_seq_num_applied": { + "name": "latest_amm_seq_num_applied", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "inserted_at": { + "name": "inserted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "v0_4_amms_lp_mint_addr_tokens_mint_acct_fk": { + "name": "v0_4_amms_lp_mint_addr_tokens_mint_acct_fk", + "tableFrom": "v0_4_amms", + "tableTo": "tokens", + "columnsFrom": [ + "lp_mint_addr" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_amms_base_mint_addr_tokens_mint_acct_fk": { + "name": "v0_4_amms_base_mint_addr_tokens_mint_acct_fk", + "tableFrom": "v0_4_amms", + "tableTo": "tokens", + "columnsFrom": [ + "base_mint_addr" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_amms_quote_mint_addr_tokens_mint_acct_fk": { + "name": "v0_4_amms_quote_mint_addr_tokens_mint_acct_fk", + "tableFrom": "v0_4_amms", + "tableTo": "tokens", + "columnsFrom": [ + "quote_mint_addr" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "v0_4_conditional_vaults": { + "name": "v0_4_conditional_vaults", + "schema": "", + "columns": { + "conditional_vault_addr": { + "name": "conditional_vault_addr", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "question_addr": { + "name": "question_addr", + "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 + }, + "pda_bump": { + "name": "pda_bump", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "latest_vault_seq_num_applied": { + "name": "latest_vault_seq_num_applied", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "v0_4_conditional_vaults_question_addr_v0_4_questions_question_addr_fk": { + "name": "v0_4_conditional_vaults_question_addr_v0_4_questions_question_addr_fk", + "tableFrom": "v0_4_conditional_vaults", + "tableTo": "v0_4_questions", + "columnsFrom": [ + "question_addr" + ], + "columnsTo": [ + "question_addr" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_conditional_vaults_underlying_mint_acct_tokens_mint_acct_fk": { + "name": "v0_4_conditional_vaults_underlying_mint_acct_tokens_mint_acct_fk", + "tableFrom": "v0_4_conditional_vaults", + "tableTo": "tokens", + "columnsFrom": [ + "underlying_mint_acct" + ], + "columnsTo": [ + "mint_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_conditional_vaults_underlying_token_acct_token_accts_token_acct_fk": { + "name": "v0_4_conditional_vaults_underlying_token_acct_token_accts_token_acct_fk", + "tableFrom": "v0_4_conditional_vaults", + "tableTo": "token_accts", + "columnsFrom": [ + "underlying_token_acct" + ], + "columnsTo": [ + "token_acct" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "v0_4_merges": { + "name": "v0_4_merges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "vault_addr": { + "name": "vault_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "vault_seq_num": { + "name": "vault_seq_num", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "signature": { + "name": "signature", + "type": "varchar(88)", + "primaryKey": false, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "numeric", + "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()" + } + }, + "indexes": { + "merge_vault_index": { + "name": "merge_vault_index", + "columns": [ + "vault_addr" + ], + "isUnique": false + }, + "merge_signature_index": { + "name": "merge_signature_index", + "columns": [ + "signature" + ], + "isUnique": false + }, + "merge_seq_num_vault_index": { + "name": "merge_seq_num_vault_index", + "columns": [ + "vault_seq_num", + "vault_addr" + ], + "isUnique": false + } + }, + "foreignKeys": { + "v0_4_merges_vault_addr_v0_4_conditional_vaults_conditional_vault_addr_fk": { + "name": "v0_4_merges_vault_addr_v0_4_conditional_vaults_conditional_vault_addr_fk", + "tableFrom": "v0_4_merges", + "tableTo": "v0_4_conditional_vaults", + "columnsFrom": [ + "vault_addr" + ], + "columnsTo": [ + "conditional_vault_addr" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_merges_signature_signatures_signature_fk": { + "name": "v0_4_merges_signature_signatures_signature_fk", + "tableFrom": "v0_4_merges", + "tableTo": "signatures", + "columnsFrom": [ + "signature" + ], + "columnsTo": [ + "signature" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "v0_4_metric_decisions": { + "name": "v0_4_metric_decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "dao_id": { + "name": "dao_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient": { + "name": "recipient", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "outcome_question_addr": { + "name": "outcome_question_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "metric_question_addr": { + "name": "metric_question_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "outcome_vault_addr": { + "name": "outcome_vault_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "metric_vault_addr": { + "name": "metric_vault_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "amm_addr": { + "name": "amm_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "market_opened": { + "name": "market_opened", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "grant_awarded": { + "name": "grant_awarded", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "committee_evaluation": { + "name": "committee_evaluation", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "score_term": { + "name": "score_term", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'effective'" + }, + "score_unit": { + "name": "score_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "score_max_value": { + "name": "score_max_value", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": false + }, + "score_min_value": { + "name": "score_min_value", + "type": "numeric(40, 20)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "v0_4_metric_decisions_dao_id_dao_details_dao_id_fk": { + "name": "v0_4_metric_decisions_dao_id_dao_details_dao_id_fk", + "tableFrom": "v0_4_metric_decisions", + "tableTo": "dao_details", + "columnsFrom": [ + "dao_id" + ], + "columnsTo": [ + "dao_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_metric_decisions_outcome_question_addr_v0_4_questions_question_addr_fk": { + "name": "v0_4_metric_decisions_outcome_question_addr_v0_4_questions_question_addr_fk", + "tableFrom": "v0_4_metric_decisions", + "tableTo": "v0_4_questions", + "columnsFrom": [ + "outcome_question_addr" + ], + "columnsTo": [ + "question_addr" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_metric_decisions_metric_question_addr_v0_4_questions_question_addr_fk": { + "name": "v0_4_metric_decisions_metric_question_addr_v0_4_questions_question_addr_fk", + "tableFrom": "v0_4_metric_decisions", + "tableTo": "v0_4_questions", + "columnsFrom": [ + "metric_question_addr" + ], + "columnsTo": [ + "question_addr" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_metric_decisions_outcome_vault_addr_v0_4_conditional_vaults_conditional_vault_addr_fk": { + "name": "v0_4_metric_decisions_outcome_vault_addr_v0_4_conditional_vaults_conditional_vault_addr_fk", + "tableFrom": "v0_4_metric_decisions", + "tableTo": "v0_4_conditional_vaults", + "columnsFrom": [ + "outcome_vault_addr" + ], + "columnsTo": [ + "conditional_vault_addr" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_metric_decisions_metric_vault_addr_v0_4_conditional_vaults_conditional_vault_addr_fk": { + "name": "v0_4_metric_decisions_metric_vault_addr_v0_4_conditional_vaults_conditional_vault_addr_fk", + "tableFrom": "v0_4_metric_decisions", + "tableTo": "v0_4_conditional_vaults", + "columnsFrom": [ + "metric_vault_addr" + ], + "columnsTo": [ + "conditional_vault_addr" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_metric_decisions_amm_addr_v0_4_amms_amm_addr_fk": { + "name": "v0_4_metric_decisions_amm_addr_v0_4_amms_amm_addr_fk", + "tableFrom": "v0_4_metric_decisions", + "tableTo": "v0_4_amms", + "columnsFrom": [ + "amm_addr" + ], + "columnsTo": [ + "amm_addr" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "v0_4_questions": { + "name": "v0_4_questions", + "schema": "", + "columns": { + "question_addr": { + "name": "question_addr", + "type": "varchar(44)", + "primaryKey": true, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "oracle_addr": { + "name": "oracle_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "num_outcomes": { + "name": "num_outcomes", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "payout_numerators": { + "name": "payout_numerators", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "payout_denominator": { + "name": "payout_denominator", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "question_id": { + "name": "question_id", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "v0_4_splits": { + "name": "v0_4_splits", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "vault_addr": { + "name": "vault_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "vault_seq_num": { + "name": "vault_seq_num", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "signature": { + "name": "signature", + "type": "varchar(88)", + "primaryKey": false, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "numeric", + "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()" + } + }, + "indexes": { + "split_vault_index": { + "name": "split_vault_index", + "columns": [ + "vault_addr" + ], + "isUnique": false + }, + "split_signature_index": { + "name": "split_signature_index", + "columns": [ + "signature" + ], + "isUnique": false + }, + "split_seq_num_vault_index": { + "name": "split_seq_num_vault_index", + "columns": [ + "vault_seq_num", + "vault_addr" + ], + "isUnique": false + } + }, + "foreignKeys": { + "v0_4_splits_vault_addr_v0_4_conditional_vaults_conditional_vault_addr_fk": { + "name": "v0_4_splits_vault_addr_v0_4_conditional_vaults_conditional_vault_addr_fk", + "tableFrom": "v0_4_splits", + "tableTo": "v0_4_conditional_vaults", + "columnsFrom": [ + "vault_addr" + ], + "columnsTo": [ + "conditional_vault_addr" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v0_4_splits_signature_signatures_signature_fk": { + "name": "v0_4_splits_signature_signatures_signature_fk", + "tableFrom": "v0_4_splits", + "tableTo": "signatures", + "columnsFrom": [ + "signature" + ], + "columnsTo": [ + "signature" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "v0_4_swaps": { + "name": "v0_4_swaps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigserial", + "primaryKey": true, + "notNull": true + }, + "signature": { + "name": "signature", + "type": "varchar(88)", + "primaryKey": false, + "notNull": true + }, + "slot": { + "name": "slot", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "block_time": { + "name": "block_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "swap_type": { + "name": "swap_type", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "amm_addr": { + "name": "amm_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "user_addr": { + "name": "user_addr", + "type": "varchar(44)", + "primaryKey": false, + "notNull": true + }, + "amm_seq_num": { + "name": "amm_seq_num", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "input_amount": { + "name": "input_amount", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "output_amount": { + "name": "output_amount", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "amm_index": { + "name": "amm_index", + "columns": [ + "amm_addr" + ], + "isUnique": false + }, + "signature_index": { + "name": "signature_index", + "columns": [ + "signature" + ], + "isUnique": false + }, + "seq_num_amm_index": { + "name": "seq_num_amm_index", + "columns": [ + "amm_seq_num", + "amm_addr" + ], + "isUnique": false + } + }, + "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 7dd90a6..76675b2 100644 --- a/packages/database/drizzle/meta/_journal.json +++ b/packages/database/drizzle/meta/_journal.json @@ -57,6 +57,13 @@ "when": 1729556995543, "tag": "0007_dark_the_fallen", "breakpoints": true + }, + { + "idx": 8, + "version": "5", + "when": 1729791097640, + "tag": "0008_stormy_spirit", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/database/lib/schema.ts b/packages/database/lib/schema.ts index b620af8..c05b799 100644 --- a/packages/database/lib/schema.ts +++ b/packages/database/lib/schema.ts @@ -559,9 +559,9 @@ export const makes = pgTable( export const takes = pgTable( "takes", { + takeId: uuid("take_id").notNull().defaultRandom().primaryKey(), orderTxSig: transaction("order_tx_sig") - .references(() => orders.orderTxSig) - .primaryKey(), + .references(() => orders.orderTxSig), baseAmount: biggerTokenAmount("base_amount").notNull(), quotePrice: numeric("quote_price", { precision: 40, @@ -571,7 +571,6 @@ export const takes = pgTable( takerQuoteFee: tokenAmount("taker_quote_fee") .notNull() .default(0 as unknown as bigint), - // Maker fields will be NULL on pure AMMs makerOrderTxSig: transaction("maker_order_tx_sig").references( () => makes.orderTxSig From 9a2491f1996c076739fef1e176dd99a000af6907 Mon Sep 17 00:00:00 2001 From: Kollan House Date: Sat, 26 Oct 2024 21:07:22 -0700 Subject: [PATCH 2/3] fix: not having user account.... --- packages/indexer/src/builders/swaps.ts | 51 +++++++++++++++---- .../amm-market-logs-subscribe-indexer.ts | 4 +- .../indexer/src/indexers/amm-market/utils.ts | 28 ++++++---- .../autocrat/autocrat-proposal-indexer.ts | 6 ++- .../jupiter/jupiter-quotes-indexer.ts | 5 ++ packages/indexer/src/types/errors.ts | 1 + 6 files changed, 70 insertions(+), 25 deletions(-) diff --git a/packages/indexer/src/builders/swaps.ts b/packages/indexer/src/builders/swaps.ts index 59919d3..b0c1bd3 100644 --- a/packages/indexer/src/builders/swaps.ts +++ b/packages/indexer/src/builders/swaps.ts @@ -66,6 +66,25 @@ export class SwapPersistable { )}` ); } + // Insert user if they aren't already in the database + const insertUsersResult = (await usingDb((db) => + db + .insert(schema.users) + .values({ userAcct: this.ordersRecord.actorAcct }) + .onConflictDoNothing() + .returning({ userAcct: schema.users.userAcct }) + )) ?? []; + if ( + insertUsersResult.length !== 1 || + insertUsersResult[0].userAcct !== this.ordersRecord.actorAcct + ) { + logger.warn( + `Failed to upsert user ${this.ordersRecord.actorAcct}. ${JSON.stringify( + this.ordersRecord + )}` + ); + } + // const priceInsertRes = // (await usingDb((db) => // db @@ -164,11 +183,14 @@ export class SwapBuilder { const mintIx = tx.instructions?.find( (i) => i.name === "mintConditionalTokens" ); + // What if there's more than one? const mergeIx = tx.instructions?.find((i) => i.name === "mergeConditionalTokensForUnderlyingTokens"); + if (mergeIx && mintIx) { console.error("ARB TRANSACTION DETECTED") return Err({ type: SwapPersistableError.ArbTransactionError }); } + const result = await this.buildOrderFromSwapIx(swapIx, tx, mintIx); if (!result.success) { return Err(result.error); @@ -344,16 +366,23 @@ export class SwapBuilder { return Err({ type: AmmInstructionIndexerError.MissingMarket }); } - const ammPrice = - quoteAmount.toString() && baseAmount.toString() - ? quoteAmount.mul(new BN(10).pow(new BN(12))).div(baseAmount) - : new BN(0); + let price: number | null = null; + + if (quoteAmount.toString() && baseAmount.toString()) { + console.log(quoteAmount.toString(), baseAmount.toString()); + try{ + const ammPrice = quoteAmount.mul(new BN(10).pow(new BN(12))).div(baseAmount) - const price = getHumanPrice( - ammPrice, - baseToken[0].decimals, - quoteToken[0].decimals - ); + price = getHumanPrice( + ammPrice, + baseToken[0].decimals, + quoteToken[0].decimals + ); + } catch (e) { + logger.error("error getting price", e); + return Err({ type: SwapPersistableError.GeneralError }); + } + } // TODO: Need to likely handle rounding..... // index a swap here @@ -365,7 +394,7 @@ export class SwapBuilder { orderBlock: tx.slot.toString(), orderTime: now, orderTxSig: signature, - quotePrice: price.toString(), + quotePrice: price?.toString() ?? "0", actorAcct: userAcct.pubkey, // TODO: If and only if the transaction is SUCCESSFUL does this value equal this.. filledBaseAmount: baseAmount.toString(), @@ -384,7 +413,7 @@ export class SwapBuilder { orderBlock: tx.slot.toString(), orderTime: now, orderTxSig: signature, - quotePrice: price.toString(), + quotePrice: price?.toString() ?? "0", // TODO: this is coded into the market, in the case of our AMM, it's 1% // this fee is based on the INPUT value (so if we're buying its USDC, selling its TOKEN) takerBaseFee: BigInt(0), diff --git a/packages/indexer/src/indexers/amm-market/amm-market-logs-subscribe-indexer.ts b/packages/indexer/src/indexers/amm-market/amm-market-logs-subscribe-indexer.ts index 9c6db1b..1946b6b 100644 --- a/packages/indexer/src/indexers/amm-market/amm-market-logs-subscribe-indexer.ts +++ b/packages/indexer/src/indexers/amm-market/amm-market-logs-subscribe-indexer.ts @@ -20,7 +20,9 @@ export const AmmMarketLogsSubscribeIndexer: AccountLogsIndexer = { buildRes.error.type === SwapPersistableError.AlreadyPersistedSwap || (buildRes.error.type === SwapPersistableError.TransactionParseError && buildRes.error.value?.type === - GetTransactionErrorType.NullGetTransactionResponse) + GetTransactionErrorType.NullGetTransactionResponse) || + buildRes.error.type === SwapPersistableError.PriceError || + buildRes.error.type === SwapPersistableError.ArbTransactionError ) { logger.error( `error with indexing amm logs, signature: ${logs.signature}`, diff --git a/packages/indexer/src/indexers/amm-market/utils.ts b/packages/indexer/src/indexers/amm-market/utils.ts index 0f46fb9..eeb1194 100644 --- a/packages/indexer/src/indexers/amm-market/utils.ts +++ b/packages/indexer/src/indexers/amm-market/utils.ts @@ -18,6 +18,7 @@ export enum AmmMarketAccountIndexingErrors { MarketMissingError = "MarketMissingError", AmmV4TwapIndexError = "AmmV4TwapIndexError", AmmTwapPriceError = "AmmTwapPriceError", + AmmTwapNoInsertError = "AmmTwapNoInsertError", } export async function indexAmmMarketAccountWithContext( @@ -77,24 +78,29 @@ export async function indexAmmMarketAccountWithContext( lastPrice: ammMarketAccount.oracle.lastPrice.toString(), }; + try{ // TODO batch commits across inserts - maybe with event queue - const twapUpsertResult = await usingDb((db) => - db - .insert(schema.twaps) - .values(newTwap) - .onConflictDoNothing() - .returning({ marketAcct: schema.twaps.marketAcct }) - ); + const twapUpsertResult = await usingDb((db) => + db + .insert(schema.twaps) + .values(newTwap) + .onConflictDoNothing() + .returning({ marketAcct: schema.twaps.marketAcct }) + ); - if (twapUpsertResult === undefined || twapUpsertResult.length === 0) { - logger.error("failed to upsert twap"); - return Err({ type: AmmMarketAccountIndexingErrors.AmmTwapIndexError }); + if (twapUpsertResult === undefined || twapUpsertResult.length === 0) { + logger.error("failed to upsert twap", newTwap); + // return Err({ type: AmmMarketAccountIndexingErrors.AmmTwapNoInsertError }); + } + } catch (e) { + logger.error("failed to upsert twap", e); + return Err({ type: AmmMarketAccountIndexingErrors.AmmTwapNoInsertError }); } } let priceFromReserves: BN; - if (ammMarketAccount.baseAmount.toString() === "0" || ammMarketAccount.baseAmount.toString() === "0") { + if (ammMarketAccount.baseAmount.toNumber() === 0 || ammMarketAccount.baseAmount.toNumber() === 0) { logger.error("NO RESERVES", ammMarketAccount); return Ok("no price from reserves"); } diff --git a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts index d64da51..84047d2 100644 --- a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts +++ b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts @@ -76,7 +76,8 @@ export const AutocratProposalIndexer: IntervalFetchIndexer = { ) )?.[0] ?? {}; - if (!currentSlot || !currentTime) return; + console.log("currentSlot", currentSlot); + if (!currentSlot || !currentTime) return Err({ type: AutocratDaoIndexerError.MissingParamError }); logger.log("Autocrat proposal indexer"); const dbProposals: ProposalRecord[] = @@ -94,7 +95,8 @@ export const AutocratProposalIndexer: IntervalFetchIndexer = { for (const proposal of onChainProposals) { if ( !dbProposals.find((dbProposal) => - new PublicKey(dbProposal.proposalAcct).equals(proposal.publicKey) + new PublicKey(dbProposal.proposalAcct).equals(proposal.publicKey) && + dbProposal.endedAt === null ) ) { proposalsToInsert.push(proposal); diff --git a/packages/indexer/src/indexers/jupiter/jupiter-quotes-indexer.ts b/packages/indexer/src/indexers/jupiter/jupiter-quotes-indexer.ts index d734979..743529d 100644 --- a/packages/indexer/src/indexers/jupiter/jupiter-quotes-indexer.ts +++ b/packages/indexer/src/indexers/jupiter/jupiter-quotes-indexer.ts @@ -110,6 +110,11 @@ export const fetchQuoteFromJupe = async ( .where(eq(schema.tokens.mintAcct, quoteMint)) .execute() )) ?? []; + + if (baseToken.length === 0 || quoteToken.length === 0) { + console.log("quote or base token not found in db for jupiter quotes indexer", acct); + return null; + } const amountVal = 1 * 10 ** baseToken[0].decimals; diff --git a/packages/indexer/src/types/errors.ts b/packages/indexer/src/types/errors.ts index 56385ce..461ff26 100644 --- a/packages/indexer/src/types/errors.ts +++ b/packages/indexer/src/types/errors.ts @@ -10,4 +10,5 @@ export enum SwapPersistableError { NonSwapTransaction = "NonSwapTransaction", TransactionParseError = "TransactionParseError", ArbTransactionError = "ArbTransactionError", + PriceError = "PriceError", } From 99ad3a87ebdab691c8f71dc1d308b3898a228e5f Mon Sep 17 00:00:00 2001 From: Kollan House Date: Sun, 27 Oct 2024 12:57:59 -0700 Subject: [PATCH 3/3] fix: crashing with better handling, update swaps for verbosity --- packages/database/lib/index.ts | 87 +++++++++++++++++++------- packages/indexer/src/builders/swaps.ts | 3 + 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/packages/database/lib/index.ts b/packages/database/lib/index.ts index ab8e08c..441e011 100644 --- a/packages/database/lib/index.ts +++ b/packages/database/lib/index.ts @@ -5,38 +5,81 @@ import "dotenv/config"; let connectionString = process.env.FUTARCHY_PG_URL; -const pool = new Pool({ +// Add retry configuration +const RETRY_ATTEMPTS = 5; +const INITIAL_RETRY_DELAY = 100; // Start with shorter delay +const MAX_RETRY_DELAY = 2000; // Max backoff delay +const ACQUIRE_TIMEOUT = 10000; // 10 second timeout for acquiring connection + +// Add connection pool configuration +const poolConfig = { connectionString: connectionString, - // https://stackoverflow.com/a/73997522 - // I noticed that there was always a connection timeout error after 9 loops of the startWatchers interval; - // it repeats every 5 seconds and immediately after service start. - // That's a consistent error after 40 seconds. So I'm seeing if idle timeout of 20 seconds works. I suspect it won't though - // since the connection is never idle for more than 5 seconds and yet we still get a connection error. - min: 0, - idleTimeoutMillis: 20 * 1000, - max: 1000, + min: 20, + max: 1000, // Reduced from 1000 to a more reasonable number + idleTimeoutMillis: 30 * 1000, + connectionTimeoutMillis: 5000, + // Add error handling for the pool + async errorHandler(err: Error) { + console.error('Pool error:', err); + } +}; + +const pool = new Pool(poolConfig); + +// Add pool error listeners +pool.on('error', (err) => { + console.error('Unexpected pool error:', err); }); export async function getClient() { return pool.connect(); } +// Modified usingDb function with retry logic export async function usingDb( fn: (connection: NodePgDatabase) => Promise ): Promise { - let client: PoolClient; - try { - client = await pool.connect(); - } catch (e) { - console.error(e); - return; - } - try { - const connection = drizzle(pool, { schema: schemaDefs }); - const result = await fn(connection); - return result; - } finally { - client.release(); + let client: PoolClient | undefined; + let attempts = 0; + + while (attempts < RETRY_ATTEMPTS) { + try { + // Add timeout to connection acquisition + const acquirePromise = pool.connect(); + client = await Promise.race([ + acquirePromise, + new Promise((_, reject) => + setTimeout(() => reject(new Error('Connection acquisition timeout')), ACQUIRE_TIMEOUT) + ) + ]); + + const connection = drizzle(pool, { schema: schemaDefs }); + const result = await fn(connection); + return result; + } catch (e) { + attempts++; + if (attempts === RETRY_ATTEMPTS) { + console.error('Final database connection attempt failed:', e); + throw e; + } + + // Exponential backoff with jitter + const delay = Math.min( + INITIAL_RETRY_DELAY * Math.pow(2, attempts - 1) + Math.random() * 100, + MAX_RETRY_DELAY + ); + + console.warn( + `Database connection attempt ${attempts} failed, retrying in ${delay}ms:`, + e instanceof Error ? e.message : e + ); + + await new Promise(resolve => setTimeout(resolve, delay)); + } finally { + if (client) { + client.release(); + } + } } } diff --git a/packages/indexer/src/builders/swaps.ts b/packages/indexer/src/builders/swaps.ts index b0c1bd3..8981a0b 100644 --- a/packages/indexer/src/builders/swaps.ts +++ b/packages/indexer/src/builders/swaps.ts @@ -83,6 +83,9 @@ export class SwapPersistable { this.ordersRecord )}` ); + if(insertUsersResult.length <= 0) { + logger.warn(`User already exists in db: ${this.ordersRecord.actorAcct}`); + } } // const priceInsertRes =