Skip to content

Commit

Permalink
Enums camel case (#9)
Browse files Browse the repository at this point in the history
Must be released and tested together with
cowprotocol/services#2171
  • Loading branch information
squadgazzz authored Jan 5, 2024
1 parent a9a9696 commit 484bb1c
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 31 deletions.
14 changes: 7 additions & 7 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ components:
properties:
kind:
type: string
enum: [constantproduct]
enum: [constantProduct]
tokens:
description: |
A mapping of token address to its reserve amounts.
Expand All @@ -266,7 +266,7 @@ components:
properties:
kind:
type: string
enum: [weightedproduct]
enum: [weightedProduct]
tokens:
description: |
A mapping of token address to its reserve amounts with weights.
Expand All @@ -286,7 +286,7 @@ components:
$ref: "#/components/schemas/Decimal"
version:
type: string
enum: ["v0", "v3plus"]
enum: ["v0", "v3Plus"]

StablePool:
description: |
Expand Down Expand Up @@ -334,7 +334,7 @@ components:
properties:
kind:
type: string
enum: [concentratedliquidity]
enum: [concentratedLiquidity]
tokens:
type: array
items:
Expand All @@ -350,7 +350,7 @@ components:
A map of tick indices to their liquidity values.
type: object
additionalProperties:
$ref: "#/components/schemas/TokenAmount"
$ref: "#/components/schemas/BigInt"
fee:
$ref: "#/components/schemas/Decimal"

Expand All @@ -369,7 +369,7 @@ components:
properties:
kind:
type: string
enum: [limitorder]
enum: [limitOrder]
hash:
$ref: "#/components/schemas/Digest"
makerToken:
Expand Down Expand Up @@ -735,7 +735,7 @@ components:
properties:
kind:
type: string
enum: [riskadjusted]
enum: [riskAdjusted]
successProbability:
description: |
The revert probability of the solution. Used by the driver to compute a risk-adjusted score.
Expand Down
8 changes: 4 additions & 4 deletions src/api/routes/solve/dto/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ struct Order {
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
enum Kind {
Sell,
Buy,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
enum Class {
Market,
Limit,
Expand All @@ -146,7 +146,7 @@ struct Token {

#[allow(clippy::enum_variant_names)]
#[derive(Debug, Deserialize)]
#[serde(tag = "kind", rename_all = "lowercase", deny_unknown_fields)]
#[serde(tag = "kind", rename_all = "camelCase", deny_unknown_fields)]
enum Liquidity {
ConstantProduct(ConstantProductPool),
WeightedProduct(WeightedProductPool),
Expand Down Expand Up @@ -227,7 +227,7 @@ struct WeightedProductReserve {
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
enum WeightedProductVersion {
V0,
V3Plus,
Expand Down
14 changes: 7 additions & 7 deletions src/api/routes/solve/dto/solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ struct Solution {
}

#[derive(Debug, Serialize)]
#[serde(tag = "kind", rename_all = "lowercase")]
#[serde(tag = "kind", rename_all = "camelCase")]
enum Trade {
Fulfillment(Fulfillment),
Jit(JitTrade),
Expand Down Expand Up @@ -207,14 +207,14 @@ struct JitOrder {
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
enum Kind {
Sell,
Buy,
}

#[derive(Debug, Serialize)]
#[serde(tag = "kind", rename_all = "lowercase")]
#[serde(tag = "kind", rename_all = "camelCase")]
enum Interaction {
Liquidity(LiquidityInteraction),
Custom(CustomInteraction),
Expand Down Expand Up @@ -284,7 +284,7 @@ struct Allowance {
}

#[derive(Debug, Default, Serialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
enum SellTokenBalance {
#[default]
Erc20,
Expand All @@ -293,15 +293,15 @@ enum SellTokenBalance {
}

#[derive(Debug, Default, Serialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
enum BuyTokenBalance {
#[default]
Erc20,
Internal,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
enum SigningScheme {
Eip712,
EthSign,
Expand All @@ -312,7 +312,7 @@ enum SigningScheme {
/// A score for a solution. The score is used to rank solutions.
#[serde_as]
#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase", tag = "kind")]
#[serde(rename_all = "camelCase", tag = "kind")]
pub enum Score {
Solver {
#[serde_as(as = "serialize::U256")]
Expand Down
3 changes: 2 additions & 1 deletion src/domain/solver/dex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use {
crate::{
boundary::rate_limiter::{RateLimiter, RateLimiterError},
domain::{
self, auction,
self,
auction,
dex::{self, slippage},
order::{self, Order},
solution,
Expand Down
2 changes: 1 addition & 1 deletion src/infra/dex/balancer/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
};

#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
pub enum OrderKind {
Sell,
Buy,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/balancer/market_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async fn sell() {
}
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}]
Expand Down Expand Up @@ -314,7 +314,7 @@ async fn buy() {
}
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}]
Expand Down
6 changes: 3 additions & 3 deletions src/tests/dex/partial_fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ endpoint = 'http://{}/sor'
}
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}]
Expand Down Expand Up @@ -581,7 +581,7 @@ endpoint = 'http://{}/sor'
}
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}]
Expand Down Expand Up @@ -849,7 +849,7 @@ async fn market() {
}
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}]
Expand Down
2 changes: 1 addition & 1 deletion src/tests/oneinch/market_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ async fn sell() {
}
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/paraswap/market_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async fn sell() {
}
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}
Expand Down Expand Up @@ -491,7 +491,7 @@ async fn buy() {
}
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/zeroex/market_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async fn sell() {
},
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}]
Expand Down Expand Up @@ -369,7 +369,7 @@ async fn buy() {
},
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}]
Expand Down
2 changes: 1 addition & 1 deletion src/tests/zeroex/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ enable-slippage-protection = true
},
],
"score": {
"kind": "riskadjusted",
"kind": "riskAdjusted",
"successProbability": 0.5,
}
}]
Expand Down

0 comments on commit 484bb1c

Please sign in to comment.