-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from cowprotocol/add-schema
Add schema
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); | ||
|