From 93d209edd2b646972cee1bff67ea701eba0458b1 Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Mon, 15 Jan 2024 10:18:25 +0100 Subject: [PATCH 1/5] fix typo --- tests/queries/test_quote_rewards.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/queries/test_quote_rewards.py b/tests/queries/test_quote_rewards.py index 98a15bf9..5ee8baa1 100644 --- a/tests/queries/test_quote_rewards.py +++ b/tests/queries/test_quote_rewards.py @@ -6,16 +6,16 @@ from src.pg_client import MultiInstanceDBFetcher -class TestBatchRewards(unittest.TestCase): +class TestQuoteRewards(unittest.TestCase): def setUp(self) -> None: db_url = "postgres:postgres@localhost:5432/postgres" self.fetcher = MultiInstanceDBFetcher([db_url]) with open("./populate_test_db.sql", "r", encoding="utf-8") as file: self.fetcher.connections[0].execute(file.read()) - def test_get_batch_rewards(self): + def test_get_quote_rewards(self): start_block, end_block = "0", "100" - batch_rewards = self.fetcher.get_quote_rewards(start_block, end_block) + quote_rewards = self.fetcher.get_quote_rewards(start_block, end_block) expected = DataFrame( { "solver": [ @@ -30,7 +30,7 @@ def test_get_batch_rewards(self): ], } ) - self.assertIsNone(pandas.testing.assert_frame_equal(expected, batch_rewards)) + self.assertIsNone(pandas.testing.assert_frame_equal(expected, quote_rewards)) if __name__ == "__main__": From 49e887d1ed906f0c536a32d932b36097a2744180 Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Mon, 15 Jan 2024 17:32:07 +0100 Subject: [PATCH 2/5] simplify order quotes test database - use less data - use separate file --- tests/queries/quote_rewards_test_db.sql | 67 +++++++++++++++++++++++++ tests/queries/test_quote_rewards.py | 10 ++-- 2 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 tests/queries/quote_rewards_test_db.sql diff --git a/tests/queries/quote_rewards_test_db.sql b/tests/queries/quote_rewards_test_db.sql new file mode 100644 index 00000000..6121228c --- /dev/null +++ b/tests/queries/quote_rewards_test_db.sql @@ -0,0 +1,67 @@ +DROP TABLE IF EXISTS orders; +DROP TYPE IF EXISTS OrderKind; +DROP TABLE IF EXISTS order_quotes; +DROP TABLE IF EXISTS trades; + + +-- orders table +CREATE TYPE OrderKind AS ENUM ('buy', 'sell'); + +CREATE TABLE IF NOT EXISTS orders +( + uid bytea PRIMARY KEY, + sell_amount numeric(78,0) NOT NULL, + buy_amount numeric(78,0) NOT NULL, + fee_amount numeric(78,0) NOT NULL, + kind OrderKind NOT NULL, + partially_fillable boolean NOT NULL +); + +CREATE TABLE IF NOT EXISTS order_quotes +( + order_uid bytea PRIMARY KEY, + sell_amount numeric(78, 0) NOT NULL, + buy_amount numeric(78, 0) NOT NULL, + solver bytea NOT NULL +); + +CREATE TABLE IF NOT EXISTS trades +( + block_number bigint NOT NULL, + log_index bigint NOT NULL, + order_uid bytea NOT NULL, + sell_amount numeric(78, 0) NOT NULL, + buy_amount numeric(78, 0) NOT NULL, + + PRIMARY KEY (block_number, log_index) +); + + +TRUNCATE orders; +TRUNCATE order_quotes; +TRUNCATE trades; + + +INSERT INTO orders (uid, sell_amount, buy_amount, fee_amount, kind, partially_fillable) +VALUES ('\x01'::bytea, 95000000, 94000000000000000000, 5000000, 'sell', 'f'), -- normal sell market order +('\x02'::bytea, 101000000, 100000000000000000000, 5000000, 'buy', 'f'), -- normal buy market order +('\x03'::bytea, 100000000, 100000000000000000000, 0, 'sell', 't'), -- partially fillable sell limit order +('\x04'::bytea, 100000000, 100000000000000000000, 0, 'buy', 't'), -- partially fillable buy limit order +('\x05'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f'), -- in market sell limit order +('\x06'::bytea, 106000000, 100000000000000000000, 0, 'buy', 'f'); -- in market buy limit order + +INSERT INTO order_quotes (order_uid, sell_amount, buy_amount, solver) +VALUES ('\x01'::bytea, 95000000, 95000000000000000000, '\x01'::bytea), +('\x02'::bytea, 101000000, 100000000000000000000, '\x02'::bytea), +('\x03'::bytea, 100000000, 95000000000000000000, '\x03'::bytea), +('\x04'::bytea, 105000000, 100000000000000000000, '\x03'::bytea), +('\x05'::bytea, 100000000, 95000000000000000000, '\x03'::bytea), +('\x06'::bytea, 105000000, 100000000000000000000, '\x03'::bytea); + +INSERT INTO trades (block_number, log_index, order_uid, sell_amount, buy_amount) +VALUES (1, 0, '\x01'::bytea, 100000000, 95000000000000000000), +(2, 0, '\x02'::bytea, 106000000, 100000000000000000000), +(3, 0, '\x03'::bytea, 100000000, 101000000000000000000), +(4, 0, '\x04'::bytea, 99000000, 100000000000000000000), +(5, 0, '\x05'::bytea, 100000000, 95000000000000000000), +(6, 0, '\x06'::bytea, 105000000, 100000000000000000000); diff --git a/tests/queries/test_quote_rewards.py b/tests/queries/test_quote_rewards.py index 5ee8baa1..bc069150 100644 --- a/tests/queries/test_quote_rewards.py +++ b/tests/queries/test_quote_rewards.py @@ -10,7 +10,7 @@ class TestQuoteRewards(unittest.TestCase): def setUp(self) -> None: db_url = "postgres:postgres@localhost:5432/postgres" self.fetcher = MultiInstanceDBFetcher([db_url]) - with open("./populate_test_db.sql", "r", encoding="utf-8") as file: + with open("./tests/queries/quote_rewards_test_db.sql", "r", encoding="utf-8") as file: self.fetcher.connections[0].execute(file.read()) def test_get_quote_rewards(self): @@ -19,14 +19,14 @@ def test_get_quote_rewards(self): expected = DataFrame( { "solver": [ - "0x5111111111111111111111111111111111111111", - "0x5333333333333333333333333333333333333333", - "0x5444444444444444444444444444444444444444", + "0x01", + "0x02", + "0x03", ], "num_quotes": [ 1, - 2, 1, + 2, ], } ) From 907f46d582d9af675bf4d24cc1820b29593aeb90 Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Mon, 15 Jan 2024 17:36:40 +0100 Subject: [PATCH 3/5] move batch rewards test db setup --- tests/queries/batch_rewards_test_db.sql | 128 ++++++++++++++++++++++++ tests/queries/test_batch_rewards.py | 4 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 tests/queries/batch_rewards_test_db.sql diff --git a/tests/queries/batch_rewards_test_db.sql b/tests/queries/batch_rewards_test_db.sql new file mode 100644 index 00000000..c984e1d4 --- /dev/null +++ b/tests/queries/batch_rewards_test_db.sql @@ -0,0 +1,128 @@ +DROP TABLE IF EXISTS settlements; +DROP TABLE IF EXISTS auction_transaction; +DROP TABLE IF EXISTS auction_participants; +DROP TABLE IF EXISTS settlement_scores; +DROP TABLE IF EXISTS settlement_observations; + +CREATE TABLE IF NOT EXISTS settlements +( + block_number bigint NOT NULL, + log_index bigint NOT NULL, + solver bytea NOT NULL, + tx_hash bytea NOT NULL, + tx_from bytea NOT NULL, + tx_nonce bigint NOT NULL, + + PRIMARY KEY (block_number, log_index) +); + +CREATE INDEX settlements_tx_from_tx_nonce ON settlements (tx_from, tx_nonce); + +CREATE TABLE IF NOT EXISTS auction_transaction +( + auction_id bigint PRIMARY KEY, + tx_from bytea NOT NULL, + tx_nonce bigint NOT NULL, + UNIQUE (tx_from, tx_nonce) +); + +CREATE TABLE IF NOT EXISTS auction_participants +( + auction_id bigint, + participant bytea +); + +CREATE TABLE IF NOT EXISTS settlement_scores +( + auction_id bigint PRIMARY KEY, + winner bytea NOT NULL, + winning_score numeric(78, 0) NOT NULL, + reference_score numeric(78, 0) NOT NULL, + block_deadline bigint NOT NULL, + simulation_block bigint NOT NULL +); + +-- Populated after block finalization via transactionReceipt. +CREATE TABLE IF NOT EXISTS settlement_observations +( + block_number bigint NOT NULL, + log_index bigint NOT NULL, + gas_used numeric(78, 0) NOT NULL, + effective_gas_price numeric(78, 0) NOT NULL, + surplus numeric(78, 0) NOT NULL, + fee numeric(78, 0) NOT NULL, + + PRIMARY KEY (block_number, log_index) +); + + +TRUNCATE settlements; +TRUNCATE auction_transaction; +TRUNCATE auction_participants; +TRUNCATE settlement_scores; +TRUNCATE settlement_observations; + + +INSERT INTO settlements (block_number, log_index, solver, tx_hash, tx_from, tx_nonce) +VALUES (1, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7111'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 1), + (2, 10, '\x5222222222222222222222222222222222222222'::bytea, '\x7222'::bytea, '\x5222222222222222222222222222222222222222'::bytea, 1), + (5, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7333'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 2), + -- would the following entry be in the data base? (submitted too late) -- YES + (20, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7444'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 3), + (25, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7555'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 4), + (26, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7666'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 6); + +INSERT INTO auction_transaction (auction_id, tx_from, tx_nonce) +VALUES (1, '\x5111111111111111111111111111111111111111'::bytea, 1), + (2, '\x5222222222222222222222222222222222222222'::bytea, 1), + (5, '\x5111111111111111111111111111111111111111'::bytea, 2), + (6, '\x5111111111111111111111111111111111111111'::bytea, 3), -- would that entry be in the data base? (submitted too late) + (7, '\x5111111111111111111111111111111111111111'::bytea, 4), + (8, '\x5111111111111111111111111111111111111111'::bytea, 5), -- would that entry be in the data base? (failed transaction) + (9, '\x5111111111111111111111111111111111111111'::bytea, 6), + (10, '\x5333333333333333333333333333333333333333'::bytea, 1); -- would that entry be in the data base? (failed transaction) + +INSERT INTO auction_participants (auction_id, participant) +VALUES (1, '\x5222222222222222222222222222222222222222'::bytea), + (1, '\x5333333333333333333333333333333333333333'::bytea), + (1, '\x5111111111111111111111111111111111111111'::bytea), + (2, '\x5444444444444444444444444444444444444444'::bytea), + (2, '\x5333333333333333333333333333333333333333'::bytea), + (2, '\x5222222222222222222222222222222222222222'::bytea), + (3, '\x5444444444444444444444444444444444444444'::bytea), + (3, '\x5333333333333333333333333333333333333333'::bytea), + (3, '\x5111111111111111111111111111111111111111'::bytea), + (5, '\x5444444444444444444444444444444444444444'::bytea), + (5, '\x5333333333333333333333333333333333333333'::bytea), + (5, '\x5111111111111111111111111111111111111111'::bytea), + (6, '\x5444444444444444444444444444444444444444'::bytea), + (6, '\x5333333333333333333333333333333333333333'::bytea), + (6, '\x5111111111111111111111111111111111111111'::bytea), + (7, '\x5111111111111111111111111111111111111111'::bytea), + (8, '\x5111111111111111111111111111111111111111'::bytea), + (9, '\x5444444444444444444444444444444444444444'::bytea), + (9, '\x5333333333333333333333333333333333333333'::bytea), + (9, '\x5111111111111111111111111111111111111111'::bytea), + (10, '\x5444444444444444444444444444444444444444'::bytea), + (10, '\x5333333333333333333333333333333333333333'::bytea); + +INSERT INTO settlement_scores (auction_id, winning_score, reference_score, winner, block_deadline, simulation_block) +VALUES (1, 5000000000000000000, 4000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 10, 0), + (2, 6000000000000000000, 3000000000000000000, '\x5222222222222222222222222222222222222222'::bytea, 11, 1), + (3, 21000000000000000000, 3000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 12, 2), + (5, 5000000000000000000, 3000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 14, 4), -- jump in auction id + (6, 10000000000000000000, 9000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 15, 5), -- settled too late + (7, 5000000000000000000, 0, '\x5111111111111111111111111111111111111111'::bytea, 30, 6), -- no competition + (8, 5000000000000000000, 0, '\x5111111111111111111111111111111111111111'::bytea, 35, 7), -- no competition, failed transaction + (9, 5000000000000000000, 1000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 36, 8), -- score larger than quality + (10, 5000000000000000000, 4000000000000000000, '\x5333333333333333333333333333333333333333'::bytea, 37, 9); -- participant with net negative payment + +INSERT INTO settlement_observations (block_number, log_index, gas_used, effective_gas_price, surplus, fee) +VALUES (1, 10, 100000, 2000000000, 6000000000000000000, 200000000000000), + (2, 10, 150000, 3000000000, 12000000000000000000, 400000000000000), + (5, 10, 100000, 2000000000, 5000000000000000000, 250000000000000), + -- Depends on backend (setting surplus and fee to zero). + -- I would prefer to use the real numbers. What is backend gonna do. + (20, 10, 100000, 2000000000, 0, 0), -- would that entry be in the data base? (submitted too late) + (25, 10, 100000, 2000000000, 6000000000000000000, 200000000000000), + (26, 10, 100000, 2000000000, 0, 400000000000000); diff --git a/tests/queries/test_batch_rewards.py b/tests/queries/test_batch_rewards.py index f5c0d211..fc6f3fb2 100644 --- a/tests/queries/test_batch_rewards.py +++ b/tests/queries/test_batch_rewards.py @@ -10,7 +10,9 @@ class TestBatchRewards(unittest.TestCase): def setUp(self) -> None: db_url = "postgres:postgres@localhost:5432/postgres" self.fetcher = MultiInstanceDBFetcher([db_url]) - with open("./populate_test_db.sql", "r", encoding="utf-8") as file: + with open( + "./tests/queries/batch_rewards_test_db.sql", "r", encoding="utf-8" + ) as file: self.fetcher.connections[0].execute(file.read()) def test_get_batch_rewards(self): From e3ec33a092818447a15152a46d5bad98bd0790b7 Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Mon, 15 Jan 2024 17:36:46 +0100 Subject: [PATCH 4/5] black fix --- tests/queries/test_quote_rewards.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/queries/test_quote_rewards.py b/tests/queries/test_quote_rewards.py index bc069150..8bad030b 100644 --- a/tests/queries/test_quote_rewards.py +++ b/tests/queries/test_quote_rewards.py @@ -10,7 +10,9 @@ class TestQuoteRewards(unittest.TestCase): def setUp(self) -> None: db_url = "postgres:postgres@localhost:5432/postgres" self.fetcher = MultiInstanceDBFetcher([db_url]) - with open("./tests/queries/quote_rewards_test_db.sql", "r", encoding="utf-8") as file: + with open( + "./tests/queries/quote_rewards_test_db.sql", "r", encoding="utf-8" + ) as file: self.fetcher.connections[0].execute(file.read()) def test_get_quote_rewards(self): From 35b96ad11ed9b4b234732ba82393112b3df5ab1c Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Mon, 15 Jan 2024 17:37:29 +0100 Subject: [PATCH 5/5] remove old test database file --- populate_test_db.sql | 221 ------------------------------------------- 1 file changed, 221 deletions(-) delete mode 100644 populate_test_db.sql diff --git a/populate_test_db.sql b/populate_test_db.sql deleted file mode 100644 index 9e8c7f42..00000000 --- a/populate_test_db.sql +++ /dev/null @@ -1,221 +0,0 @@ -DROP TABLE IF EXISTS settlements; -DROP TABLE IF EXISTS auction_transaction; -DROP TABLE IF EXISTS auction_participants; -DROP TABLE IF EXISTS settlement_scores; -DROP TABLE IF EXISTS settlement_observations; -DROP TABLE IF EXISTS orders; -DROP TYPE IF EXISTS OrderKind; -DROP TYPE IF EXISTS SigningScheme; -DROP TYPE IF EXISTS TokenBalance; -DROP TYPE IF EXISTS OrderClass; -DROP TABLE IF EXISTS order_quotes; -DROP TABLE IF EXISTS trades; - -CREATE TABLE IF NOT EXISTS settlements -( - block_number bigint NOT NULL, - log_index bigint NOT NULL, - solver bytea NOT NULL, - tx_hash bytea NOT NULL, - tx_from bytea NOT NULL, - tx_nonce bigint NOT NULL, - - PRIMARY KEY (block_number, log_index) -); - -CREATE INDEX settlements_tx_from_tx_nonce ON settlements (tx_from, tx_nonce); - -CREATE TABLE IF NOT EXISTS auction_transaction -( - auction_id bigint PRIMARY KEY, - tx_from bytea NOT NULL, - tx_nonce bigint NOT NULL, - UNIQUE (tx_from, tx_nonce) -); - -CREATE TABLE IF NOT EXISTS auction_participants -( - auction_id bigint, - participant bytea -); - -CREATE TABLE IF NOT EXISTS settlement_scores -( - auction_id bigint PRIMARY KEY, - winner bytea NOT NULL, - winning_score numeric(78, 0) NOT NULL, - reference_score numeric(78, 0) NOT NULL, - block_deadline bigint NOT NULL, - simulation_block bigint NOT NULL -); - --- Populated after block finalization via transactionReceipt. -CREATE TABLE IF NOT EXISTS settlement_observations -( - block_number bigint NOT NULL, - log_index bigint NOT NULL, - gas_used numeric(78, 0) NOT NULL, - effective_gas_price numeric(78, 0) NOT NULL, - surplus numeric(78, 0) NOT NULL, - fee numeric(78, 0) NOT NULL, - - PRIMARY KEY (block_number, log_index) -); - --- orders table -CREATE TYPE OrderKind AS ENUM ('buy', 'sell'); -CREATE TYPE SigningScheme AS ENUM ('presign', 'eip712', 'ethsign'); -CREATE TYPE TokenBalance AS ENUM ('erc20', 'external'); -CREATE TYPE OrderClass AS ENUM ('market', 'limit'); - -CREATE TABLE orders ( - uid bytea PRIMARY KEY, - owner bytea NOT NULL, - creation_timestamp timestamptz NOT NULL, - sell_token bytea NOT NULL, - buy_token bytea NOT NULL, - sell_amount numeric(78,0) NOT NULL, - buy_amount numeric(78,0) NOT NULL, - valid_to bigint NOT NULL, - fee_amount numeric(78,0) NOT NULL, - kind OrderKind NOT NULL, - partially_fillable boolean NOT NULL, - signature bytea NOT NULL, - cancellation_timestamp timestamptz, - receiver bytea NOT NULL, - app_data bytea NOT NULL, - signing_scheme SigningScheme NOT NULL, - settlement_contract bytea NOT NULL, - sell_token_balance TokenBalance NOT NULL, - buy_token_balance TokenBalance NOT NULL, - full_fee_amount numeric(78,0) NOT NULL, - class OrderClass NOT NULL -); - -CREATE TABLE IF NOT EXISTS order_quotes -( - order_uid bytea PRIMARY KEY, - gas_amount double precision NOT NULL, - gas_price double precision NOT NULL, - sell_token_price double precision NOT NULL, - sell_amount numeric(78, 0) NOT NULL, - buy_amount numeric(78, 0) NOT NULL, - solver bytea NOT NULL -); - -CREATE TABLE IF NOT EXISTS trades -( - block_number bigint NOT NULL, - log_index bigint NOT NULL, - order_uid bytea NOT NULL, - sell_amount numeric(78, 0) NOT NULL, - buy_amount numeric(78, 0) NOT NULL, - fee_amount numeric(78, 0) NOT NULL, - - PRIMARY KEY (block_number, log_index) -); - - -TRUNCATE settlements; -TRUNCATE auction_transaction; -TRUNCATE auction_participants; -TRUNCATE settlement_scores; -TRUNCATE settlement_observations; -TRUNCATE orders; -TRUNCATE order_quotes; -TRUNCATE trades; - - -INSERT INTO settlements (block_number, log_index, solver, tx_hash, tx_from, tx_nonce) -VALUES (1, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7111'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 1), - (2, 10, '\x5222222222222222222222222222222222222222'::bytea, '\x7222'::bytea, '\x5222222222222222222222222222222222222222'::bytea, 1), - (5, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7333'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 2), - -- would the following entry be in the data base? (submitted too late) -- YES - (20, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7444'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 3), - (25, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7555'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 4), - (26, 10, '\x5111111111111111111111111111111111111111'::bytea, '\x7666'::bytea, '\x5111111111111111111111111111111111111111'::bytea, 6); - -INSERT INTO auction_transaction (auction_id, tx_from, tx_nonce) -VALUES (1, '\x5111111111111111111111111111111111111111'::bytea, 1), - (2, '\x5222222222222222222222222222222222222222'::bytea, 1), - (5, '\x5111111111111111111111111111111111111111'::bytea, 2), - (6, '\x5111111111111111111111111111111111111111'::bytea, 3), -- would that entry be in the data base? (submitted too late) - (7, '\x5111111111111111111111111111111111111111'::bytea, 4), - (8, '\x5111111111111111111111111111111111111111'::bytea, 5), -- would that entry be in the data base? (failed transaction) - (9, '\x5111111111111111111111111111111111111111'::bytea, 6), - (10, '\x5333333333333333333333333333333333333333'::bytea, 1); -- would that entry be in the data base? (failed transaction) - -INSERT INTO auction_participants (auction_id, participant) -VALUES (1, '\x5222222222222222222222222222222222222222'::bytea), - (1, '\x5333333333333333333333333333333333333333'::bytea), - (1, '\x5111111111111111111111111111111111111111'::bytea), - (2, '\x5444444444444444444444444444444444444444'::bytea), - (2, '\x5333333333333333333333333333333333333333'::bytea), - (2, '\x5222222222222222222222222222222222222222'::bytea), - (3, '\x5444444444444444444444444444444444444444'::bytea), - (3, '\x5333333333333333333333333333333333333333'::bytea), - (3, '\x5111111111111111111111111111111111111111'::bytea), - (5, '\x5444444444444444444444444444444444444444'::bytea), - (5, '\x5333333333333333333333333333333333333333'::bytea), - (5, '\x5111111111111111111111111111111111111111'::bytea), - (6, '\x5444444444444444444444444444444444444444'::bytea), - (6, '\x5333333333333333333333333333333333333333'::bytea), - (6, '\x5111111111111111111111111111111111111111'::bytea), - (7, '\x5111111111111111111111111111111111111111'::bytea), - (8, '\x5111111111111111111111111111111111111111'::bytea), - (9, '\x5444444444444444444444444444444444444444'::bytea), - (9, '\x5333333333333333333333333333333333333333'::bytea), - (9, '\x5111111111111111111111111111111111111111'::bytea), - (10, '\x5444444444444444444444444444444444444444'::bytea), - (10, '\x5333333333333333333333333333333333333333'::bytea); - -INSERT INTO settlement_scores (auction_id, winning_score, reference_score, winner, block_deadline, simulation_block) -VALUES (1, 5000000000000000000, 4000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 10, 0), - (2, 6000000000000000000, 3000000000000000000, '\x5222222222222222222222222222222222222222'::bytea, 11, 1), - (3, 21000000000000000000, 3000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 12, 2), - (5, 5000000000000000000, 3000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 14, 4), -- jump in auction id - (6, 10000000000000000000, 9000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 15, 5), -- settled too late - (7, 5000000000000000000, 0, '\x5111111111111111111111111111111111111111'::bytea, 30, 6), -- no competition - (8, 5000000000000000000, 0, '\x5111111111111111111111111111111111111111'::bytea, 35, 7), -- no competition, failed transaction - (9, 5000000000000000000, 1000000000000000000, '\x5111111111111111111111111111111111111111'::bytea, 36, 8), -- score larger than quality - (10, 5000000000000000000, 4000000000000000000, '\x5333333333333333333333333333333333333333'::bytea, 37, 9); -- participant with net negative payment - -INSERT INTO settlement_observations (block_number, log_index, gas_used, effective_gas_price, surplus, fee) -VALUES (1, 10, 100000, 2000000000, 6000000000000000000, 200000000000000), - (2, 10, 150000, 3000000000, 12000000000000000000, 400000000000000), - (5, 10, 100000, 2000000000, 5000000000000000000, 250000000000000), - -- Depends on backend (setting surplus and fee to zero). - -- I would prefer to use the real numbers. What is backend gonna do. - (20, 10, 100000, 2000000000, 0, 0), -- would that entry be in the data base? (submitted too late) - (25, 10, 100000, 2000000000, 6000000000000000000, 200000000000000), - (26, 10, 100000, 2000000000, 0, 400000000000000); - -INSERT INTO orders (uid, owner, creation_timestamp, sell_token, buy_token, sell_amount, buy_amount, valid_to, fee_amount, kind, partially_fillable, signature, cancellation_timestamp, receiver, app_data, signing_scheme, settlement_contract, sell_token_balance, buy_token_balance, full_fee_amount, class) -VALUES ('\x1111'::bytea, '\x1111111111'::bytea, '2024-01-01 00:00:00.000000+00 -', '\x11'::bytea, '\x22'::bytea, 6000000000000000000, 4000000000000000000, 1655195621, 100000000000000000, 'sell', 'f', '\x987987987987'::bytea, NULL, '\x12341234'::bytea, '\x1234512345'::bytea, 'presign', '\x123456123456'::bytea, 'erc20', 'external', 200000000000000000, 'market'), -- normal sell market order -('\x2222'::bytea, '\x1111111111'::bytea, '2024-01-01 00:00:00.000000+00 -', '\x11'::bytea, '\x22'::bytea, 6000000000000000000, 4000000000000000000, 1655195621, 100000000000000000, 'buy', 'f', '\x987987987987'::bytea, NULL, '\x12341234'::bytea, '\x1234512345'::bytea, 'presign', '\x123456123456'::bytea, 'erc20', 'external', 200000000000000000, 'market'), -- normal buy market order -('\x3333'::bytea, '\x1111111111'::bytea, '2024-01-01 00:00:00.000000+00 -', '\x11'::bytea, '\x22'::bytea, 6000000000000000000, 4000000000000000000, 1655195621, 100000000000000000, 'sell', 't', '\x987987987987'::bytea, NULL, '\x12341234'::bytea, '\x1234512345'::bytea, 'presign', '\x123456123456'::bytea, 'erc20', 'external', 200000000000000000, 'limit'), -- partially fillable sell limit order -('\x4444'::bytea, '\x1111111111'::bytea, '2024-01-01 00:00:00.000000+00 -', '\x11'::bytea, '\x22'::bytea, 6000000000000000000, 4000000000000000000, 1655195621, 0, 'buy', 't', '\x987987987987'::bytea, NULL, '\x12341234'::bytea, '\x1234512345'::bytea, 'presign', '\x123456123456'::bytea, 'erc20', 'external', 0, 'limit'), -- partially fillable buy limit order -('\x5555'::bytea, '\x1111111111'::bytea, '2024-01-01 00:00:00.000000+00 -', '\x11'::bytea, '\x22'::bytea, 6000000000000000000, 4000000000000000000, 1655195621, 0, 'sell', 'f', '\x987987987987'::bytea, NULL, '\x12341234'::bytea, '\x1234512345'::bytea, 'presign', '\x123456123456'::bytea, 'erc20', 'external', 0, 'limit'), -- in market sell limit order -('\x6666'::bytea, '\x1111111111'::bytea, '2024-01-01 00:00:00.000000+00 -', '\x11'::bytea, '\x22'::bytea, 6000000000000000000, 4000000000000000000, 1655195621, 0, 'buy', 'f', '\x987987987987'::bytea, NULL, '\x12341234'::bytea, '\x1234512345'::bytea, 'presign', '\x123456123456'::bytea, 'erc20', 'external', 0, 'limit'); -- in market buy limit order - -INSERT INTO order_quotes (order_uid, gas_amount, gas_price, sell_token_price, sell_amount, buy_amount, solver) -VALUES ('\x1111'::bytea, 200000, 110000000000, 0.123, 6000000000000000000, 4500000000000000000, '\x5111111111111111111111111111111111111111'::bytea), -('\x2222'::bytea, 200000, 110000000000, 0.123, 5500000000000000000, 4000000000000000000, '\x5333333333333333333333333333333333333333'::bytea), -('\x3333'::bytea, 200000, 110000000000, 0.123, 6000000000000000000, 3000000000000000000, '\x5222222222222222222222222222222222222222'::bytea), -('\x4444'::bytea, 200000, 110000000000, 0.123, 7000000000000000000, 4000000000000000000, '\x5222222222222222222222222222222222222222'::bytea), -('\x5555'::bytea, 200000, 110000000000, 0.123, 6000000000000000000, 4500000000000000000, '\x5333333333333333333333333333333333333333'::bytea), -('\x6666'::bytea, 200000, 110000000000, 0.123, 5500000000000000000, 4000000000000000000, '\x5444444444444444444444444444444444444444'::bytea); - -INSERT INTO trades (block_number, log_index, order_uid, sell_amount, buy_amount, fee_amount) -VALUES (1, 0, '\x1111'::bytea, 6200000000000000000, 4600000000000000000, 200000000000000000), -(2, 0, '\x2222'::bytea, 5600000000000000000, 4000000000000000000, 200000000000000000), -(2, 1, '\x3333'::bytea, 6200000000000000000, 4600000000000000000, 200000000000000000), -(5, 0, '\x4444'::bytea, 5600000000000000000, 4000000000000000000, 200000000000000000), -(5, 1, '\x5555'::bytea, 6200000000000000000, 4600000000000000000, 200000000000000000), -(20, 0, '\x6666'::bytea, 5600000000000000000, 4000000000000000000, 200000000000000000);