-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update_solver_engine_api
- Loading branch information
Showing
43 changed files
with
456 additions
and
343 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,50 @@ | ||
//! Protocol fee implementation. | ||
//! | ||
//! The protocol fee is a fee that is defined by the protocol and for each order | ||
//! in the auction we define the way to calculate the protocol fee based on the | ||
//! configuration parameters. | ||
use { | ||
crate::{ | ||
arguments, | ||
driver_model::solve::{fee_policy_to_dto, FeePolicy}, | ||
}, | ||
model::{ | ||
auction::Auction, | ||
order::{OrderClass, OrderUid}, | ||
}, | ||
std::collections::HashMap, | ||
}; | ||
|
||
pub struct Policies { | ||
policies: HashMap<OrderUid, Vec<FeePolicy>>, | ||
} | ||
|
||
impl Policies { | ||
pub fn new(auction: &Auction, config: arguments::FeePolicy) -> Self { | ||
Self { | ||
policies: auction | ||
.orders | ||
.iter() | ||
.filter_map(|order| { | ||
match order.metadata.class { | ||
OrderClass::Market => None, | ||
OrderClass::Liquidity => None, | ||
// TODO: https://github.com/cowprotocol/services/issues/2092 | ||
// skip protocol fee for limit orders with in-market price | ||
|
||
// TODO: https://github.com/cowprotocol/services/issues/2115 | ||
// skip protocol fee for TWAP limit orders | ||
OrderClass::Limit(_) => { | ||
Some((order.metadata.uid, vec![fee_policy_to_dto(&config)])) | ||
} | ||
} | ||
}) | ||
.collect(), | ||
} | ||
} | ||
|
||
pub fn get(&self, order: &OrderUid) -> Option<Vec<FeePolicy>> { | ||
self.policies.get(order).cloned() | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
//! A top-level containing implementations of clients to other CoW Protocol | ||
//! components. | ||
pub mod fee; | ||
pub mod orderbook; | ||
|
||
pub use self::orderbook::Orderbook; |
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.