Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mirror] Use scores instead of surplus for reward computation #104

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/sql/orderbook/barn_batch_rewards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ reward_data AS (
end as fee,
-- scores
winning_score,
case
when block_number is not null
and block_number <= block_deadline then winning_score
else 0
end as observed_score,
reference_score,
-- auction_participation
participating_solvers,
Expand Down Expand Up @@ -390,12 +395,12 @@ reward_per_auction as (
surplus,
protocol_fee, -- the protocol fee
fee - network_fee_correction as network_fee, -- the network fee
surplus + protocol_fee - reference_score as uncapped_payment,
observed_score - reference_score as uncapped_payment,
-- Capped Reward = CLAMP_[-E, E + exec_cost](uncapped_reward_eth)
LEAST(
GREATEST(
- {{EPSILON_LOWER}},
surplus + protocol_fee - reference_score
observed_score - reference_score
),
{{EPSILON_UPPER}}
) as capped_payment,
Expand Down
9 changes: 7 additions & 2 deletions src/sql/orderbook/prod_batch_rewards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ reward_data AS (
end as fee,
-- scores
winning_score,
case
when block_number is not null
and block_number <= block_deadline then winning_score
else 0
end as observed_score,
reference_score,
-- auction_participation
participating_solvers,
Expand Down Expand Up @@ -390,12 +395,12 @@ reward_per_auction as (
surplus,
protocol_fee, -- the protocol fee
fee - network_fee_correction as network_fee, -- the network fee
surplus + protocol_fee - reference_score as uncapped_payment,
observed_score - reference_score as uncapped_payment,
-- Capped Reward = CLAMP_[-E, E + exec_cost](uncapped_reward_eth)
LEAST(
GREATEST(
- {{EPSILON_LOWER}},
surplus + protocol_fee - reference_score
observed_score - reference_score
),
{{EPSILON_UPPER}}
) as capped_payment,
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_fetch_orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,22 +252,22 @@ def test_get_batch_rewards(self):
"8912931423922369",
],
"uncapped_payment_eth": [
"405658669881356",
"405658366132340",
"292618683544035",
"-13360904627424245",
"-12938581202699558",
"2823075137791897",
"9345865552057182",
"1607086130097916",
"1607086130097915",
],
"capped_payment": [
"405658669881356",
"405658366132340",
"292618683544035",
"-10000000000000000",
"-10000000000000000",
"2823075137791897",
"9345865552057182",
"1607086130097916",
"1607086130097915",
],
"winning_score": [
"11327955072945657",
Expand Down
Loading