-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds changes to solver rewards due to the introduction of protocol fees. The implementation in this PR is intended to make solvers oblivious to protocol fees. This means that the quality of a solution as defined in CIP-20 in our accounting is needs to be equal to what the solver computed without knowledge of protocol fees. CIP-20 specifies that `quality = surplus + fee` in ETH. With protocol fees, the surplus is reduced by some amount, the protocol fee. This means that the quality is now something like `quality = surplus + protocol_fee + fee` in ETH. Here, `surplus` refers to the surplus users receive, `protocol_fee` is the fee the protocol charges, and `fee` is a fee set by solvers or the protocol for covering network costs. All token amounts are converted to ETH using native prices of the auction. One problem is, that fees set by solvers for covering network costs are not directly observable for the autopilot. For those orders, the autopilot only computes a total fee in the sell token by comparing what a user did send to the protocol to what they would have sent to receive the same amount of buy tokens if they had traded at uniform clearing prices. Let us call this term `total_fee` and it is in the sell token. Let us further use the term `total_surplus` for the surplus a solver perceives who is oblivious to protocol fees. The inconsistency corrected in this PR comes from the fact that the solver perceives a quality of `total_surplus * surplus_native_price + fee * sell_native_price`. This is different from `surplus * surplus_native_price + total_fee * sell_native_price`. Instead, the reward script needs to compute `surplus * surplus_native_price + protocol_fee * protocol_fee_native_price + fee * sell_native_price`. The fee for network costs needs to be reconstructed from observations. The driver currently computes the total fee in the sell token as `total_fee = fee + protocol_fee * protocol_fee_clearing_price / sell_clearing_price`. Thus the network fee is `total_fee - protocol_fee * protocol_fee_clearing_price / sell_clearing_price`. Since the ratio of clearing prices is equal to the ratio of traded amount _if there were no fee at all,_ `protocol_fee_clearing_price / sell_clearing_price = (amount_sent - total_fee) / amount_received`, the correction to the total fee to compute the actual fee for network costs becomes `network_fee_correction = (amount_sent - total_fee) / amount_received * protocol_fee`. The implementation in this PR depends on the current implementation of protocol fees in the driver. With drivers ran by solvers, this is not possible anymore. By then we should be ready to rank by `surplus + protocol_fee`. This value is easy to compute for the driver and no correction of network fees is required anymore.
- Loading branch information
Showing
5 changed files
with
351 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.