diff --git a/queries/orderbook/quote_rewards.sql b/queries/orderbook/quote_rewards.sql index 592ffafa..4ea0d355 100644 --- a/queries/orderbook/quote_rewards.sql +++ b/queries/orderbook/quote_rewards.sql @@ -8,8 +8,7 @@ with winning_quotes as ( JOIN order_quotes oq ON t.order_uid = oq.order_uid WHERE ( - o.class = 'market' - OR ( + ( o.kind = 'sell' AND ( oq.sell_amount - oq.gas_amount * oq.gas_price / oq.sell_token_price diff --git a/tests/queries/batch_rewards_test_db.sql b/tests/queries/batch_rewards_test_db.sql index 6cd9168e..5ca8a1c4 100644 --- a/tests/queries/batch_rewards_test_db.sql +++ b/tests/queries/batch_rewards_test_db.sql @@ -60,7 +60,7 @@ CREATE TABLE IF NOT EXISTS auction_prices -- orders table CREATE TYPE OrderKind AS ENUM ('buy', 'sell'); -CREATE TYPE OrderClass AS ENUM ('market', 'limit'); +CREATE TYPE OrderClass AS ENUM ('limit'); CREATE TABLE orders ( uid bytea PRIMARY KEY, @@ -223,9 +223,7 @@ VALUES (51, '\x01', 500000000000000000000000000), (60, '\x02', 500000000000000); INSERT INTO orders (uid, sell_token, buy_token, sell_amount, buy_amount, fee_amount, kind, partially_fillable, full_fee_amount, class, app_data) -VALUES ('\x01'::bytea, '\x01'::bytea, '\x02'::bytea, 95000000, 94000000000000000000, 5000000, 'sell', 'f', 5000000, 'market', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- sell market order -('\x02'::bytea, '\x01'::bytea, '\x02'::bytea, 101000000, 100000000000000000000, 5000000, 'buy', 'f', 5000000, 'market', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- buy market order -('\x03'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 100000000000000000000, 0, 'sell', 't', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- partially fillable sell limit order +VALUES ('\x03'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 100000000000000000000, 0, 'sell', 't', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- partially fillable sell limit order ('\x04'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 100000000000000000000, 0, 'buy', 't', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- partially fillable buy limit order ('\x05'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit', '\xd3418777a6ec517d7310b05a2a22f3737524ae0302d1f88230f4e066a1768b74'::bytea), -- in market sell limit order with volume-based partner fee of 45bps. An example of a real order with same appdata can be found here: https://explorer.cow.fi/orders/0x398510f3b0b35c0712d3caef470f036a4fead3d21b5a37280698484a197a5da45543dc0694384bd9a7c585027d436c4daacc95c7661c7213?tab=overview ('\x06'::bytea, '\x01'::bytea, '\x02'::bytea, 106000000, 100000000000000000000, 0, 'buy', 'f', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- in market buy limit order diff --git a/tests/queries/quote_rewards_test_db.sql b/tests/queries/quote_rewards_test_db.sql index 35b8d57a..75dbc54b 100644 --- a/tests/queries/quote_rewards_test_db.sql +++ b/tests/queries/quote_rewards_test_db.sql @@ -8,7 +8,7 @@ DROP TABLE IF EXISTS trades; -- orders table CREATE TYPE OrderKind AS ENUM ('buy', 'sell'); -CREATE TYPE OrderClass AS ENUM ('market', 'limit'); +CREATE TYPE OrderClass AS ENUM ('limit'); CREATE TABLE IF NOT EXISTS orders ( @@ -50,25 +50,19 @@ TRUNCATE trades; INSERT INTO orders (uid, sell_amount, buy_amount, fee_amount, kind, partially_fillable, class) -VALUES ('\x01'::bytea, 95000000, 94000000000000000000, 5000000, 'sell', 'f', 'market'), -- normal sell market order -('\x02'::bytea, 101000000, 100000000000000000000, 5000000, 'buy', 'f', 'market'), -- normal buy market order -('\x03'::bytea, 100000000, 100000000000000000000, 0, 'sell', 't', 'limit'), -- partially fillable sell limit order +VALUES ('\x03'::bytea, 100000000, 100000000000000000000, 0, 'sell', 't', 'limit'), -- partially fillable sell limit order ('\x04'::bytea, 100000000, 100000000000000000000, 0, 'buy', 't', 'limit'), -- partially fillable buy limit order ('\x05'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 'limit'), -- in market sell limit order ('\x06'::bytea, 106000000, 100000000000000000000, 0, 'buy', 'f', '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 ('\x01'::bytea, 100000, 25000000000, 500000000., 95000000, 95000000000000000000, '\x01'::bytea), -('\x02'::bytea, 100000, 25000000000, 500000000., 100000000, 100000000000000000000, '\x02'::bytea), -('\x03'::bytea, 100000, 25000000000, 500000000., 100000000, 100000000000000000000, '\x03'::bytea), +VALUES ('\x03'::bytea, 100000, 25000000000, 500000000., 100000000, 100000000000000000000, '\x03'::bytea), ('\x04'::bytea, 100000, 25000000000, 500000000., 100000000, 100000000000000000000, '\x03'::bytea), ('\x05'::bytea, 100000, 25000000000, 500000000., 100000000, 100000000000000000000, '\x03'::bytea), ('\x06'::bytea, 100000, 25000000000, 500000000., 100000000, 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), +VALUES (3, 0, '\x03'::bytea, 100000000, 101000000000000000000), (4, 0, '\x04'::bytea, 99000000, 100000000000000000000), (5, 0, '\x05'::bytea, 100000000, 95000000000000000000), (6, 0, '\x06'::bytea, 105000000, 100000000000000000000);