Skip to content

Commit

Permalink
Merge branch 'main' into extend_default_min_transfers_to_all_networks
Browse files Browse the repository at this point in the history
  • Loading branch information
harisang authored Dec 28, 2024
2 parents fe30553 + 11e2d8a commit df32bc5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions queries/orderbook/barn_batch_rewards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ trade_data_unprocessed as (
od.buy_token,
t.sell_amount, -- the total amount the user sends
t.buy_amount, -- the total amount the user receives
oe.surplus_fee as observed_fee, -- the total discrepancy between what the user sends and what they would have send if they traded at clearing price
oe.executed_fee as observed_fee, -- the total discrepancy between what the user sends and what they would have send if they traded at clearing price
od.kind,
case
when od.kind = 'sell' then od.buy_token
Expand All @@ -63,7 +63,7 @@ trade_data_unprocessed as (
on s.block_number = t.block_number -- given the join that follows with the order execution table, this works even when multiple txs appear in the same block
inner join order_data as od -- contains tokens and limit amounts
on t.order_uid = od.uid
inner join order_execution as oe -- contains surplus fee
inner join order_execution as oe -- contains executed fee
on t.order_uid = oe.order_uid and s.auction_id = oe.auction_id
left outer join app_data as ad -- contains full app data
on od.app_data = ad.contract_app_data
Expand Down
6 changes: 3 additions & 3 deletions queries/orderbook/order_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ trade_data_unprocessed as (
od.buy_token,
t.sell_amount, -- the total amount the user sends
t.buy_amount, -- the total amount the user receives
oe.surplus_fee as observed_fee, -- the total discrepancy between what the user sends and what they would have send if they traded at clearing price
oe.executed_fee as observed_fee, -- the total discrepancy between what the user sends and what they would have send if they traded at clearing price
od.kind,
case
when od.kind = 'sell' then od.buy_token
Expand All @@ -85,7 +85,7 @@ trade_data_unprocessed as (
on s.block_number = t.block_number -- given the join that follows with the order execution table, this works even when multiple txs appear in the same block
inner join order_data as od -- contains tokens and limit amounts
on t.order_uid = od.uid
inner join order_execution as oe -- contains surplus fee
inner join order_execution as oe -- contains executed fee
on t.order_uid = oe.order_uid and s.auction_id = oe.auction_id
left outer join app_data as ad -- contains full app data
on od.app_data = ad.contract_app_data
Expand Down Expand Up @@ -192,7 +192,7 @@ select
concat('0x', encode(trade_hashes.solver, 'hex')) as solver,
quote_solver,
concat('0x', encode(trade_hashes.tx_hash, 'hex')) as tx_hash,
cast(coalesce(surplus_fee, 0) as text) as surplus_fee,
cast(coalesce(executed_fee, 0) as text) as surplus_fee,
coalesce(reward, 0.0) as amount,
cast(coalesce(cast(protocol_fee as numeric(78, 0)), 0) as text) as protocol_fee,
case
Expand Down
4 changes: 2 additions & 2 deletions queries/orderbook/prod_batch_rewards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ trade_data_unprocessed as (
od.buy_token,
t.sell_amount, -- the total amount the user sends
t.buy_amount, -- the total amount the user receives
oe.surplus_fee as observed_fee, -- the total discrepancy between what the user sends and what they would have send if they traded at clearing price
oe.executed_fee as observed_fee, -- the total discrepancy between what the user sends and what they would have send if they traded at clearing price
od.kind,
case
when od.kind = 'sell' then od.buy_token
Expand All @@ -63,7 +63,7 @@ trade_data_unprocessed as (
on s.block_number = t.block_number -- given the join that follows with the order execution table, this works even when multiple txs appear in the same block
inner join order_data as od -- contains tokens and limit amounts
on t.order_uid = od.uid
inner join order_execution as oe -- contains surplus fee
inner join order_execution as oe -- contains executed fee
on t.order_uid = oe.order_uid and s.auction_id = oe.auction_id
left outer join app_data as ad -- contains full app data
on od.app_data = ad.contract_app_data
Expand Down
4 changes: 2 additions & 2 deletions tests/queries/batch_rewards_test_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ CREATE TABLE IF NOT EXISTS order_execution
order_uid bytea NOT NULL,
auction_id bigint NOT NULL,
reward double precision NOT NULL,
surplus_fee numeric(78, 0) NOT NULL,
executed_fee numeric(78, 0) NOT NULL,
protocol_fee_amounts numeric(78, 0)[],

PRIMARY KEY (order_uid, auction_id)
Expand Down Expand Up @@ -246,7 +246,7 @@ VALUES (51, 0, '\x01'::bytea, 100000000, 95000000000000000000, 5000000),
(59, 0, '\x09'::bytea, 100000000, 95000000000000000000, 0),
(60, 0, '\x0a'::bytea, 100000000, 94500000000000000000, 0);

INSERT INTO order_execution (order_uid, auction_id, reward, surplus_fee, protocol_fee_amounts)
INSERT INTO order_execution (order_uid, auction_id, reward, executed_fee, protocol_fee_amounts)
VALUES ('\x03'::bytea, 53, 0, 6000000, ARRAY[1000000000000000000]),
('\x04'::bytea, 54, 0, 6000000, ARRAY[1000000]),
('\x05'::bytea, 55, 0, 6000000, ARRAY[1000000000000000000, 500000000000000000]),
Expand Down

0 comments on commit df32bc5

Please sign in to comment.