-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
Tests affected by the changes in this repo pass locally. The test which fails is testing ipfs, which is unrelated. See #60 |
- fix small bug in sql query - add comment for eth cap
uses one of the test batches on staging
src/sql/orderbook/batch_rewards.sql
Outdated
-- Uncapped Reward = CLAMP_[-E, E + exec_cost](uncapped_payment_eth) | ||
LEAST(GREATEST(-10000000000000000, surplus + fee - reference_score), | ||
10000000000000000 + execution_cost) as capped_payment, | ||
protocol_fee + fee - network_fee_correction as fee,-- total fee for ranking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call this something different? I am a bit confused as two lines later you use a fee
term in the uncapped_payment_eth
computation, and it is probably not referring to this total fee. What exactly are you trying to compute here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could to corrected_fee
and later select corrected_fee as fee
for the uploading. Changing the name for what we upload might be breaking dune queries (but not the queries we use for payments, I guess, which only depend on capped_payment
).
Another alternative is to repurpose the fee
field to just be something like network fees. We do not use the field directly in the payment queries, so there it should be fine. Since protocol fees are synced explicitly, we can still recover the corrected quality on dune, quality = surplus + protocol_fee + fee
.
With the implementation in this PR, we would still be able to do quality = surplus + fees
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query now computes protocol_fee
and network_fee
separately. The payment is thus by quality = surplus + protocol_fee + network_fee
.
On dune, the entry network_fee
is still called just fee
for now to not break existing queries.
Comments have been addressed. This is ready to be merged now. |
This PR adds protocol fees to dune.
It adds the changes which were also done to the solver rewards repo (here) to the dune sync repo.
The data uploaded to dune changes for
batch_rewards
andorders_rewards
.protocol_fee
which contains the ETH value of all protocol fees in a batch. Additionally, fees are reduced by network fees. We correct for the fact that thesettlement_observations
table calculates fees from surplus in the sell token while the protocol fee might be taken in the buy token.protocol_fee
: The protocol fee in the token it was charged in.protocol_fee_token
: The token in which the fee is charged, i.e., sell token for volume based fees and surplus token for surplus based fees. It isNULL
when there was no protocol fee.protocol_fee_native_price
: The native price of the protocol fee token in the auction which was settled. It is0.0
if there is no protocol fee.