-
Notifications
You must be signed in to change notification settings - Fork 5
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
Remove restriction on quote rewards for limit orders #328
Conversation
before this change only market orders were eligible for quote rewards and only in that case a quote_solver was fetched. with this change, a quote_solver is always fetched (if it exists)
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.
Looks good!
queries/orderbook/quote_rewards.sql
Outdated
@@ -3,8 +3,7 @@ with winning_quotes as (SELECT concat('0x', encode(oq.solver, 'hex')) as solver, | |||
FROM trades t | |||
INNER JOIN orders o ON order_uid = uid | |||
JOIN order_quotes oq ON t.order_uid = oq.order_uid | |||
WHERE o.class = 'market' | |||
AND block_number BETWEEN {{start_block}} AND {{end_block}} | |||
WHERE block_number BETWEEN {{start_block}} AND {{end_block}} |
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.
Just be careful with between since it uses a closed interval block_number in [start, end]
while in other places we have block_number in (start, end]
. Probably wouldn't hurt to eliminate all uses of BETWEEN.
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.
True. I created a draft PR handling that here: #329
I am now thinking whether we should implement this change so that there is no change in the rewards paid,in the sense of paying rewards only for "in-market" limit orders. Specifically, instead of dropping the condition about whether the order is market or limit, we could replace it with the following
|
Using the restriction It is not equivalent to the original result though in some experiments I did: with winning_quotes as (SELECT concat('0x', encode(oq.solver, 'hex')) as solver,
oq.order_uid
FROM trades t
INNER JOIN orders o ON order_uid = uid
JOIN order_quotes oq ON t.order_uid = oq.order_uid
WHERE o.class = 'market'
AND block_number BETWEEN 18933106 - 10000 AND 18933106
AND oq.solver != '\x0000000000000000000000000000000000000000')
SELECT solver, count(*) AS num_quotes
FROM winning_quotes gives different results compared to with winning_quotes as (SELECT concat('0x', encode(oq.solver, 'hex')) as solver,
oq.order_uid
FROM trades t
INNER JOIN orders o ON order_uid = uid
JOIN order_quotes oq ON t.order_uid = oq.order_uid
WHERE ((o.kind = 'sell' AND o.buy_amount <= oq.buy_amount)
OR (o.kind='buy' AND o.sell_amount >= oq.sell_amount))
AND block_number BETWEEN 18933106 - 10000 AND 18933106
AND oq.solver != '\x0000000000000000000000000000000000000000')
SELECT solver, count(*) AS num_quotes
FROM winning_quotes I did not drill into why that is though. |
Co-authored-by: Felix Henneke <[email protected]>
Co-authored-by: Felix Henneke <[email protected]>
If we want to push it a bit more, we could also exclude all partially fillable orders, so I would actually go with this.
|
…to zero_fee_quote_rewards
- only orders where the amounts are below quoted amounts are eligible - only orders which are not partially fillable are eligible
I added the restriction from your last comment. Should we change the query in dyne sync too or change the dune query on period rewards? |
- only orders where the amounts are below quoted amounts are eligible - only orders which are not partially fillable are eligible this makes it consistent with the new code in cowprotocol/solver-rewards#328
Oh good. We can first merge PR #330, then rebase this PR so that there is not all this noise here and finally fix the dune-sync. I suspect then that the only thing that might be needed is to manually run the payouts next week in order to pinpoint the block where the Dune data changed, so that we align our script with the Dune dashboard |
When switching to all orders being limit orders we need to adapt how we compute quote rewards. At the moment, only market orders are eligible for quote rewards. With the current code this would mean that no quotes would receive rewards.
This PR removes testing the kind of an order when querying for quote solvers. This means that all quotes associated with executed orders are elibible for rewards.
The impact of rewarding more quotes is expected to be small.
This change has to be done merged toether with a PR on syncing quote solvers to dune.