-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define protocol fee params and forward to driver (#2098)
# Description Tackles #2083 and #2084. Defines fee policy configuration parameters. Based on them, we can take the protocol fee as a cut from price improvement or as a percent of the order volume (fixed fee in absolute value will be implemented later). On top of that, we also need two flags, for skipping in-market limit orders and twap orders, since default initial configuration will be to run the fee experiment only for out-of-market limit orders. Note that the quote is not forwarded to the `driver` at this moment, since it is not needed for out-of-market limit orders. Also note that I am missing the cap for absolute value of protocol fee (default value 1000$ or 0.5ETH) but this cap is still discussed (will be added later if needed). Skipping forwarding protocol fee parameters for in-market limit orders will be done in a separate PR. # Changes <!-- List of detailed changes (how the change is accomplished) --> - [ ] Defines basic parameters for protocol fee calculation. - [ ] Forwards protocol fee parameters to the driver.
- Loading branch information
Showing
10 changed files
with
225 additions
and
5 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#[derive(Clone, Debug)] | ||
pub enum FeePolicy { | ||
/// If the order receives more than expected (positive deviation from quoted | ||
/// amounts) pay the protocol a factor of the achieved improvement. | ||
/// The fee is taken in `sell` token for `buy` orders and in `buy` | ||
/// token for `sell` orders. | ||
PriceImprovement { | ||
/// Factor of price improvement the protocol charges as a fee. | ||
/// Price improvement is the difference between executed price and | ||
/// limit price or quoted price (whichever is better) | ||
/// | ||
/// E.g. if a user received 2000USDC for 1ETH while having been quoted | ||
/// 1990USDC, their price improvement is 10USDC. A factor of 0.5 | ||
/// requires the solver to pay 5USDC to the protocol for | ||
/// settling this order. | ||
factor: f64, | ||
/// Cap protocol fee with a percentage of the order's volume. | ||
max_volume_factor: f64, | ||
}, | ||
/// How much of the order's volume should be taken as a protocol fee. | ||
/// The fee is taken in `sell` token for `sell` orders and in `buy` | ||
/// token for `buy` orders. | ||
Volume { | ||
/// Percentage of the order's volume should be taken as a protocol | ||
/// fee. | ||
factor: f64, | ||
}, | ||
} |
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.