From 741038134400770502601cb0c59cac5e395f2bf9 Mon Sep 17 00:00:00 2001 From: Felix Leupold Date: Tue, 19 Dec 2023 16:00:13 +0100 Subject: [PATCH] Remove unused balancer SOR API fields (#2183) # Description The balancer team is looking into removing some fields from their API so they want to make sure they are not breaking any integrations ([context](https://cowservices.slack.com/archives/C035TDPHQAJ/p1702636556729949)) In order to better reason about which fields are needed, we remove the ones that are not needed. cc @squadgazzz as this may be ported to the new repo. # Changes - [ ] Remove unused API response fields ## How to test CI tests still passing --- crates/shared/src/balancer_sor_api.rs | 32 +------------------ .../solver/src/solver/balancer_sor_solver.rs | 2 -- crates/solvers/src/infra/dex/balancer/dto.rs | 25 --------------- 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/crates/shared/src/balancer_sor_api.rs b/crates/shared/src/balancer_sor_api.rs index 98bb2e6b78..02301c7312 100644 --- a/crates/shared/src/balancer_sor_api.rs +++ b/crates/shared/src/balancer_sor_api.rs @@ -8,11 +8,10 @@ use { anyhow::{Context, Result}, ethcontract::{H160, H256, U256}, model::order::OrderKind, - num::BigInt, number::serialization::HexOrDecimalU256, reqwest::{Client, IntoUrl, StatusCode, Url}, serde::{Deserialize, Serialize}, - serde_with::{serde_as, DisplayFromStr}, + serde_with::serde_as, }; /// Trait for mockable Balancer SOR API. @@ -119,42 +118,17 @@ pub struct Quote { /// In sell token for sell orders or buy token for buy orders. #[serde_as(as = "HexOrDecimalU256")] pub swap_amount: U256, - /// The real swapped amount for certain kinds of wrapped tokens. - /// - /// Some wrapped tokens like stETH/wstETH support wrapping and unwrapping at - /// a conversion rate before trading using a Relayer. In those cases, this - /// amount represents the value of the real token before wrapping. - /// - /// This amount is useful for informational purposes and not intended to be - /// used when calling `singleSwap` an `batchSwap` on the Vault. - #[serde_as(as = "HexOrDecimalU256")] - pub swap_amount_for_swaps: U256, /// The returned token amount. /// /// In buy token for sell orders or sell token for buy orders. #[serde_as(as = "HexOrDecimalU256")] pub return_amount: U256, - /// The real returned amount. - /// - /// See `swap_amount_for_swap` for more details. - #[serde_as(as = "HexOrDecimalU256")] - pub return_amount_from_swaps: U256, - /// The received considering fees. - /// - /// This can be negative when quoting small sell amounts at high gas costs - /// or greater than `U256::MAX` when quoting large buy amounts at high - /// gas costs. - #[serde_as(as = "DisplayFromStr")] - pub return_amount_considering_fees: BigInt, /// The input (sell) token. #[serde(with = "address_default_when_empty")] pub token_in: H160, /// The output (buy) token. #[serde(with = "address_default_when_empty")] pub token_out: H160, - /// The price impact (i.e. market slippage). - #[serde_as(as = "DisplayFromStr")] - pub market_sp: f64, } /// A swap included in a larger batched swap. @@ -322,13 +296,9 @@ mod tests { }, ], swap_amount: 1_000_000_000_000_000_000_u128.into(), - swap_amount_for_swaps: 1_000_000_000_000_000_000_u128.into(), return_amount: 15_520_274_244_171_816_967_u128.into(), - return_amount_from_swaps: 15_520_274_244_171_816_967_u128.into(), - return_amount_considering_fees: 15_517_420_194_930_649_326_u128.into(), token_in: addr!("ba100000625a3754423978a60c9317c58a424e3d"), token_out: addr!("6b175474e89094c44da98b954eedeac495271d0f"), - market_sp: 0.06443180020713868, }, ); } diff --git a/crates/solver/src/solver/balancer_sor_solver.rs b/crates/solver/src/solver/balancer_sor_solver.rs index 82294d165b..29e5d15446 100644 --- a/crates/solver/src/solver/balancer_sor_solver.rs +++ b/crates/solver/src/solver/balancer_sor_solver.rs @@ -318,7 +318,6 @@ mod tests { user_data: Default::default(), }, ], - ..Default::default() })) }); @@ -437,7 +436,6 @@ mod tests { amount: buy_amount, user_data: Default::default(), }], - ..Default::default() })) }); diff --git a/crates/solvers/src/infra/dex/balancer/dto.rs b/crates/solvers/src/infra/dex/balancer/dto.rs index 816d23e682..a3be55723b 100644 --- a/crates/solvers/src/infra/dex/balancer/dto.rs +++ b/crates/solvers/src/infra/dex/balancer/dto.rs @@ -67,42 +67,17 @@ pub struct Quote { /// In sell token for sell orders or buy token for buy orders. #[serde_as(as = "serialize::U256")] pub swap_amount: U256, - /// The real swapped amount for certain kinds of wrapped tokens. - /// - /// Some wrapped tokens like stETH/wstETH support wrapping and unwrapping at - /// a conversion rate before trading using a Relayer. In those cases, this - /// amount represents the value of the real token before wrapping. - /// - /// This amount is useful for informational purposes and not intended to be - /// used when calling `singleSwap` an `batchSwap` on the Vault. - #[serde_as(as = "serialize::U256")] - pub swap_amount_for_swaps: U256, /// The returned token amount. /// /// In buy token for sell orders or sell token for buy orders. #[serde_as(as = "serialize::U256")] pub return_amount: U256, - /// The real returned amount. - /// - /// See `swap_amount_for_swap` for more details. - #[serde_as(as = "serialize::U256")] - pub return_amount_from_swaps: U256, - /// The received considering fees. - /// - /// This can be negative when quoting small sell amounts at high gas costs - /// or greater than `U256::MAX` when quoting large buy amounts at high - /// gas costs. - #[serde_as(as = "serde_with::DisplayFromStr")] - pub return_amount_considering_fees: num::BigInt, /// The input (sell) token. #[serde(with = "address_default_when_empty")] pub token_in: H160, /// The output (buy) token. #[serde(with = "address_default_when_empty")] pub token_out: H160, - /// The price impact (i.e. market slippage). - #[serde_as(as = "serde_with::DisplayFromStr")] - pub market_sp: f64, } impl Quote {