Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Mirror changes from solver rewards (#108)
Browse files Browse the repository at this point in the history
This PR mirrors changes to solver rewards from #372 and #381.

Tests were adapted since the computation of rewards was changed from
recomputing the winning score to using what the driver reports.
  • Loading branch information
fhenneke authored Aug 15, 2024
1 parent 2b44096 commit bb1727e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
20 changes: 4 additions & 16 deletions src/sql/orderbook/barn_batch_rewards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -344,26 +344,14 @@ reward_data AS (
coalesce(os.solver, winner) as solver,
block_number as settlement_block,
block_deadline,
case
when block_number is not null
and block_number > block_deadline then 0
else coalesce(execution_cost, 0) -- if block_number is null, execution cost is 0
end as execution_cost,
case
when block_number is not null
and block_number > block_deadline then 0
else coalesce(surplus, 0) -- if block_number is null, surplus is 0
end as surplus,
case
when block_number is not null
and block_number > block_deadline then 0
else coalesce(fee, 0) -- if block_number is null, fee is 0
end as fee,
coalesce(execution_cost, 0) as execution_cost,
coalesce(surplus, 0) as surplus,
coalesce(fee, 0) as fee,
-- scores
winning_score,
case
when block_number is not null
and block_number <= block_deadline then winning_score
and block_number <= block_deadline + 1 then winning_score -- this includes a grace period of one block for settling a batch
else 0
end as observed_score,
reference_score,
Expand Down
20 changes: 4 additions & 16 deletions src/sql/orderbook/prod_batch_rewards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -344,26 +344,14 @@ reward_data AS (
coalesce(os.solver, winner) as solver,
block_number as settlement_block,
block_deadline,
case
when block_number is not null
and block_number > block_deadline then 0
else coalesce(execution_cost, 0) -- if block_number is null, execution cost is 0
end as execution_cost,
case
when block_number is not null
and block_number > block_deadline then 0
else coalesce(surplus, 0) -- if block_number is null, surplus is 0
end as surplus,
case
when block_number is not null
and block_number > block_deadline then 0
else coalesce(fee, 0) -- if block_number is null, fee is 0
end as fee,
coalesce(execution_cost, 0) as execution_cost,
coalesce(surplus, 0) as surplus,
coalesce(fee, 0) as fee,
-- scores
winning_score,
case
when block_number is not null
and block_number <= block_deadline then winning_score
and block_number <= block_deadline + 1 then winning_score -- this includes a grace period of one block for settling a batch
else 0
end as observed_score,
reference_score,
Expand Down

0 comments on commit bb1727e

Please sign in to comment.