Skip to content

Commit

Permalink
Merge pull request #33 from cowprotocol/add-schema
Browse files Browse the repository at this point in the history
Add schema
  • Loading branch information
shubhagarwal03 authored Aug 16, 2024
2 parents 1db9cb2 + 2b85d50 commit dd8d756
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/sql/schema.sql
Original file line number Diff line number Diff line change
@@ -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)
);

0 comments on commit dd8d756

Please sign in to comment.