-
Notifications
You must be signed in to change notification settings - Fork 74
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
Use external prices for conversion of fees in autopilot #2863
Conversation
assert_eq!( | ||
solution.native_fee(&auction.prices).0, | ||
eth::U256::from(6890975030480504u128) | ||
eth::U256::from(6752697350740628u128) |
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.
Here we see that for this specific example, difference is ~2% if we use external prices vector for conversion. Seems acceptable.
@fhenneke FYI this change affects: I don't expect this to have any significant effect on solver scripts. |
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 already trust external price vectors for the surplus computation, so I think it make sense to use them for fee computation as well.
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.
LGTM
This will probably impact slippage and/or solver rewards. If we want to reconstruct network fees (in sell token and in ETH) given protocol fees (in surplus token) and the total fee (in ETH), would we need external prices for all buy and sell tokens? |
Not sure what's the context of the question but given the protocol fees in surplus token, you need at least external price of buy token if you want to convert protocol fee to ETH for sell orders. |
But this is not an issue, is it? The autopilot filters out orders for which we cannot determine the price of the buy or sell token (which is required for evaluating surplus in ETH) |
I think we don't give strong guarantees for COW AMM orders:
This can be resolved with #2720 |
The slippage query will have to be adapted (it uses surplus_fee for exactly computing network fees) and we might need to upload additional data to dune. At the moment, external prices are uploaded for protocol fee tokens only. With this PR we need it for sell and buy tokens. The midterm plan is to compute slippage off-chain and then it does not make as much of a difference. |
yes, if we cannot compute native prices the AMM should not tradable because we won't be able to compute surplus. That's a bug. |
# Description Fixes #2863 (comment) Do not send cow amm order owner to driver if auction prices don't contain prices for that cow amm traded tokens.
Description
Related to discussion in the issue: #2862 (comment)
Use external price vector to convert "fee in surplus token" into "fee in sell token" (instead of uniform clearing prices).
This is important so that we make sure that it's always true:
total_fee = executed_surplus_fee + protocol fees
If we use uniform clearing prices for
executed_surplus_fee
and external prices forprotocol fees
I think above equation won't stand.How to test
Existing unit test