Skip to content

Commit

Permalink
Add is_winner to solver competition endpoints (#3127)
Browse files Browse the repository at this point in the history
# Description
Add is_winner to solver competition endpoints

# Changes
Add is_winner boolean to each solution json object.

## How to test
1. e2e test
2. Regression test

## Related Issues

Fixes #3070
  • Loading branch information
m-lord-renkse authored Dec 9, 2024
1 parent 78a1b81 commit c47c80c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ impl RunLoop {
.iter()
.map(|(token, price)| (token.0, price.get().into()))
.collect(),
is_winner: participant.is_winner(),
})
.collect(),
};
Expand Down
2 changes: 2 additions & 0 deletions crates/e2e/tests/e2e/solver_competition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ async fn solver_competition(web3: Web3) {

// Non winning candidate
assert!(competition.common.solutions[0].ranking == 2);
assert!(!competition.common.solutions[0].is_winner);
// Winning candidate
assert!(competition.common.solutions[1].ranking == 1);
assert!(competition.common.solutions[1].is_winner);
}

async fn fairness_check(web3: Web3) {
Expand Down
19 changes: 14 additions & 5 deletions crates/model/src/solver_competition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pub struct SolverSettlement {
#[serde_as(as = "BTreeMap<_, HexOrDecimalU256>")]
pub clearing_prices: BTreeMap<H160, U256>,
pub orders: Vec<Order>,
#[serde(default)]
pub is_winner: bool,
}

#[serde_as]
Expand Down Expand Up @@ -165,6 +167,7 @@ mod tests {
"executedAmount": "14",
}
],
"isWinner": true,
},
],
});
Expand Down Expand Up @@ -206,6 +209,7 @@ mod tests {
executed_amount: 14.into(),
},
],
is_winner: true,
}],
},
};
Expand Down Expand Up @@ -271,7 +275,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32666943622",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": true,
},
{
"orders": [
Expand All @@ -292,7 +297,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32652483021",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -313,7 +319,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "100000",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "60721701581190944"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -334,7 +341,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32725026283",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -355,7 +363,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32752835446",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
}
],
"transactionHashes": ["0x044499c2a830890cb0a8ecf9aec6c5621e8310092a58d369cdef726254d3d108"],
Expand Down
5 changes: 4 additions & 1 deletion crates/orderbook/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ paths:
"200":
description: Version
content:
text/plain: {}
text/plain: { }
"/api/v1/app_data/{app_data_hash}":
get:
summary: Get the full `appData` from contract `appDataHash`.
Expand Down Expand Up @@ -1661,6 +1661,9 @@ components:
$ref: "#/components/schemas/UID"
executedAmount:
$ref: "#/components/schemas/BigUint"
isWinner:
type: boolean
description: whether the solution is a winner (received the right to get executed) or not
NativePriceResponse:
description: |
The estimated native price for the token
Expand Down

0 comments on commit c47c80c

Please sign in to comment.