2828 crate :: domain:: {
2929 self ,
3030 auction:: order,
31- competition:: { Participant , RankType , Ranked , Score , Solution , TradedOrder , Unscored } ,
31+ competition:: { Bid , RankType , Ranked , Score , Solution , TradedOrder , Unscored } ,
3232 eth:: { self , WrappedNativeToken } ,
3333 fee,
3434 } ,
@@ -45,7 +45,7 @@ pub struct Arbitrator(winsel::Arbitrator);
4545/// 3. compute reference scores
4646///
4747/// The functions assume the `Arbitrator` is the only one
48- /// changing the ordering or the `participants `.
48+ /// changing the ordering or the `bids `.
4949impl Arbitrator {
5050 pub fn new ( max_winners : usize , wrapped_native_token : WrappedNativeToken ) -> Self {
5151 let token: eth:: TokenAddress = wrapped_native_token. into ( ) ;
@@ -56,19 +56,15 @@ impl Arbitrator {
5656 }
5757
5858 /// Runs the entire auction mechanism on the passed in solutions.
59- pub fn arbitrate (
60- & self ,
61- participants : Vec < Participant < Unscored > > ,
62- auction : & domain:: Auction ,
63- ) -> Ranking {
59+ pub fn arbitrate ( & self , bids : Vec < Bid < Unscored > > , auction : & domain:: Auction ) -> Ranking {
6460 let context = auction. into ( ) ;
65- let mut participant_by_key = HashMap :: with_capacity ( participants . len ( ) ) ;
66- let mut solutions = Vec :: with_capacity ( participants . len ( ) ) ;
61+ let mut bid_by_key = HashMap :: with_capacity ( bids . len ( ) ) ;
62+ let mut solutions = Vec :: with_capacity ( bids . len ( ) ) ;
6763
68- for participant in participants {
69- let key = SolutionKey :: from ( participant . solution ( ) ) ;
70- let solution = participant . solution ( ) . into ( ) ;
71- participant_by_key . insert ( key, participant ) ;
64+ for bid in bids {
65+ let key = SolutionKey :: from ( bid . solution ( ) ) ;
66+ let solution = bid . solution ( ) . into ( ) ;
67+ bid_by_key . insert ( key, bid ) ;
7268 solutions. push ( solution) ;
7369 }
7470
@@ -85,27 +81,25 @@ impl Arbitrator {
8581 let mut filtered_out = Vec :: with_capacity ( ws_ranking. filtered_out . len ( ) ) ;
8682 for ws_solution in ws_ranking. filtered_out {
8783 let key = SolutionKey :: from ( & ws_solution) ;
88- let participant = participant_by_key
84+ let bid = bid_by_key
8985 . remove ( & key)
90- . expect ( "every ranked solution has a matching participant " ) ;
86+ . expect ( "every ranked solution has a matching bid " ) ;
9187 let score = ws_solution. score ( ) ;
9288 filtered_out. push (
93- participant
94- . with_score ( Score ( eth:: Ether ( score) ) )
89+ bid. with_score ( Score ( eth:: Ether ( score) ) )
9590 . with_rank ( RankType :: FilteredOut ) ,
9691 ) ;
9792 }
9893
9994 let mut ranked = Vec :: with_capacity ( ws_ranking. ranked . len ( ) ) ;
10095 for ranked_solution in ws_ranking. ranked {
10196 let key = SolutionKey :: from ( & ranked_solution) ;
102- let participant = participant_by_key
97+ let bid = bid_by_key
10398 . remove ( & key)
104- . expect ( "every ranked solution has a matching participant " ) ;
99+ . expect ( "every ranked solution has a matching bid " ) ;
105100 let score = ranked_solution. score ( ) ;
106101 ranked. push (
107- participant
108- . with_score ( Score ( eth:: Ether ( score) ) )
102+ bid. with_score ( Score ( eth:: Ether ( score) ) )
109103 . with_rank ( ranked_solution. state ( ) . rank_type ) ,
110104 ) ;
111105 }
@@ -242,34 +236,34 @@ impl<S> From<&winsel::Solution<S>> for SolutionKey {
242236pub struct Ranking {
243237 /// Solutions that were discarded because they were malformed
244238 /// in some way or deemed unfair by the selection mechanism.
245- filtered_out : Vec < Participant < Ranked > > ,
239+ filtered_out : Vec < Bid < Ranked > > ,
246240 /// Final ranking of the solutions that passed the fairness
247241 /// check. Winners come before non-winners and higher total
248242 /// scores come before lower scores.
249- ranked : Vec < Participant < Ranked > > ,
243+ ranked : Vec < Bid < Ranked > > ,
250244 /// Reference scores for each winning solver, used to compute rewards.
251245 reference_scores : HashMap < eth:: Address , Score > ,
252246}
253247
254248impl Ranking {
255249 /// All solutions including the ones that got filtered out.
256- pub fn all ( & self ) -> impl Iterator < Item = & Participant < Ranked > > {
250+ pub fn all ( & self ) -> impl Iterator < Item = & Bid < Ranked > > {
257251 self . ranked . iter ( ) . chain ( & self . filtered_out )
258252 }
259253
260254 /// Enumerates all solutions. The index is used as solution UID.
261- pub fn enumerated ( & self ) -> impl Iterator < Item = ( usize , & Participant < Ranked > ) > {
255+ pub fn enumerated ( & self ) -> impl Iterator < Item = ( usize , & Bid < Ranked > ) > {
262256 self . all ( ) . enumerate ( )
263257 }
264258
265259 /// All solutions that won the right to get executed.
266- pub fn winners ( & self ) -> impl Iterator < Item = & Participant < Ranked > > {
267- self . ranked . iter ( ) . filter ( |p| p . is_winner ( ) )
260+ pub fn winners ( & self ) -> impl Iterator < Item = & Bid < Ranked > > {
261+ self . ranked . iter ( ) . filter ( |b| b . is_winner ( ) )
268262 }
269263
270264 /// All solutions that were not filtered out but also did not win.
271- pub fn non_winners ( & self ) -> impl Iterator < Item = & Participant < Ranked > > {
272- self . ranked . iter ( ) . filter ( |p | !p . is_winner ( ) )
265+ pub fn non_winners ( & self ) -> impl Iterator < Item = & Bid < Ranked > > {
266+ self . ranked . iter ( ) . filter ( |b | !b . is_winner ( ) )
273267 }
274268
275269 /// Reference scores for each winning solver, used to compute rewards.
@@ -278,7 +272,7 @@ impl Ranking {
278272 }
279273
280274 /// All solutions that passed the filtering step.
281- pub fn ranked ( & self ) -> impl Iterator < Item = & Participant < Ranked > > {
275+ pub fn ranked ( & self ) -> impl Iterator < Item = & Bid < Ranked > > {
282276 self . ranked . iter ( )
283277 }
284278}
@@ -295,7 +289,7 @@ mod tests {
295289 Price ,
296290 order:: { self , AppDataHash } ,
297291 } ,
298- competition:: { Participant , Solution , TradedOrder , Unscored } ,
292+ competition:: { Bid , Solution , TradedOrder , Unscored } ,
299293 eth:: { self , TokenAddress } ,
300294 } ,
301295 infra:: Driver ,
@@ -998,7 +992,7 @@ mod tests {
998992 // map (solver id -> solver address) for later reference during the test
999993 let mut solver_map = HashMap :: new ( ) ;
1000994
1001- // map (solution id -> participant ) for later reference during the test
995+ // map (solution id -> bid ) for later reference during the test
1002996 let mut solution_map = HashMap :: new ( ) ;
1003997 for ( solution_id, solution) in & self . solutions {
1004998 // generate solver address deterministically from the id
@@ -1021,13 +1015,13 @@ mod tests {
10211015 let solution_uid = hash ( solution_id) ;
10221016 solution_map. insert (
10231017 solution_id,
1024- create_solution ( solution_uid, solver_address, trades, None ) . await ,
1018+ create_bid ( solution_uid, solver_address, trades, None ) . await ,
10251019 ) ;
10261020 }
10271021
10281022 // filter solutions
1029- let participants = solution_map. values ( ) . cloned ( ) . collect ( ) ;
1030- let ranking = arbitrator. arbitrate ( participants , & auction) ;
1023+ let bids = solution_map. values ( ) . cloned ( ) . collect ( ) ;
1024+ let ranking = arbitrator. arbitrate ( bids , & auction) ;
10311025 assert_eq ! ( ranking. ranked. len( ) , self . expected_fair_solutions. len( ) ) ;
10321026 for solution_id in & self . expected_fair_solutions {
10331027 let solution_uid = solution_map. get ( & solution_id) . unwrap ( ) . solution ( ) . id ;
@@ -1199,12 +1193,12 @@ mod tests {
11991193 }
12001194 }
12011195
1202- async fn create_solution (
1196+ async fn create_bid (
12031197 solution_id : u64 ,
12041198 solver_address : Address ,
12051199 trades : Vec < ( OrderUid , TradedOrder ) > ,
12061200 prices : Option < HashMap < TokenAddress , Price > > ,
1207- ) -> Participant < Unscored > {
1201+ ) -> Bid < Unscored > {
12081202 // The prices of the tokens do not affect the result but they keys must exist
12091203 // for every token of every trade
12101204 let prices = prices. unwrap_or ( {
@@ -1230,7 +1224,7 @@ mod tests {
12301224 . await
12311225 . unwrap ( ) ;
12321226
1233- Participant :: new ( solution, std:: sync:: Arc :: new ( driver) )
1227+ Bid :: new ( solution, std:: sync:: Arc :: new ( driver) )
12341228 }
12351229
12361230 fn amount ( value : u128 ) -> String {
@@ -1242,8 +1236,8 @@ mod tests {
12421236 value * 10u128 . pow ( 15 )
12431237 }
12441238
1245- fn filter_winners ( solutions : & [ Participant ] ) -> Vec < & Participant > {
1246- solutions . iter ( ) . filter ( |s| s . is_winner ( ) ) . collect ( )
1239+ fn filter_winners ( bids : & [ Bid ] ) -> Vec < & Bid > {
1240+ bids . iter ( ) . filter ( |b| b . is_winner ( ) ) . collect ( )
12471241 }
12481242
12491243 // Used to generate deterministic identifiers (e.g., UIDs, addresses) from
0 commit comments