From 2b85d50ae7a6476c1c54964038c02607a972411b Mon Sep 17 00:00:00 2001 From: Shubh Agarwal Date: Fri, 16 Aug 2024 12:42:21 -0400 Subject: [PATCH] added tables schema for clarity --- src/sql/schema.sql | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/sql/schema.sql diff --git a/src/sql/schema.sql b/src/sql/schema.sql new file mode 100644 index 0000000..e052c9c --- /dev/null +++ b/src/sql/schema.sql @@ -0,0 +1,35 @@ +-- Database Schema for Token Imbalances and Slippage + +-- Table: raw_token_imbalances (for storing raw token imbalances) +CREATE TABLE raw_token_imbalances ( + auction_id BIGINT NOT NULL, + chain_name VARCHAR(50) NOT NULL, + block_number BIGINT NOT NULL, + tx_hash BYTEA NOT NULL, + token_address BYTEA NOT NULL, + imbalance NUMERIC(78,0) +); + +-- Table: slippage_prices (for storing per unit token prices in ETH) +CREATE TABLE slippage_prices ( + chain_name VARCHAR(50) NOT NULL, + source VARCHAR(50) NOT NULL, + block_number BIGINT NOT NULL, + tx_hash BYTEA NOT NULL, + token_address BYTEA NOT NULL, + price NUMERIC(42,18), + PRIMARY KEY (tx_hash, token_address) +); + +-- Table: Stores fees (i.e. protocol fee, network fee on per token basis) +CREATE TABLE fees ( + chain_name VARCHAR(50) NOT NULL, + auction_id BIGINT NOT NULL, + block_number BIGINT NOT NULL, + tx_hash BYTEA NOT NULL, + token_address BYTEA NOT NULL, + fee_amount NUMERIC(78,0) NOT NULL, + fee_type VARCHAR(50) NOT NULL, -- e.g. "protocol" or "network" + PRIMARY KEY (tx_hash, token_address) +); +