Skip to content

Commit

Permalink
Remove user_fee (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunce86 authored Apr 9, 2024
1 parent 57c8374 commit b41c021
Show file tree
Hide file tree
Showing 22 changed files with 7 additions and 56 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ contracts = { git = "https://github.com/cowprotocol/services.git", tag = "v2.237
ethrpc = { git = "https://github.com/cowprotocol/services.git", tag = "v2.237.0", package = "ethrpc" }
observe = { git = "https://github.com/cowprotocol/services.git", tag = "v2.237.0", package = "observe" }
shared = { git = "https://github.com/cowprotocol/services.git", tag = "v2.237.0", package = "shared" }
dto = { git = "https://github.com/cowprotocol/services.git", tag = "v2.253.0", package = "solvers-dto" }
dto = { git = "https://github.com/cowprotocol/services.git", tag = "v2.253.1", package = "solvers-dto" }

[dev-dependencies]
glob = "0.3"
Expand Down
6 changes: 0 additions & 6 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ components:
- buyToken
- sellAmount
- buyAmount
- feeAmount
- kind
- partiallyFillable
- class
Expand All @@ -211,8 +210,6 @@ components:
$ref: "#/components/schemas/TokenAmount"
buyAmount:
$ref: "#/components/schemas/TokenAmount"
feeAmount:
$ref: "#/components/schemas/TokenAmount"
kind:
$ref: "#/components/schemas/OrderKind"
partiallyFillable:
Expand Down Expand Up @@ -486,7 +483,6 @@ components:
- buyAmount
- validTo
- appData
- feeAmount
- kind
- partiallyFillable
- sellTokenBalance
Expand All @@ -508,8 +504,6 @@ components:
type: integer
appData:
$ref: "#/components/schemas/AppData"
feeAmount:
$ref: "#/components/schemas/TokenAmount"
kind:
$ref: "#/components/schemas/OrderKind"
partiallyFillable:
Expand Down
1 change: 0 additions & 1 deletion src/api/routes/solve/dto/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub fn to_domain(auction: &Auction) -> Result<auction::Auction, Error> {
Class::Limit => order::Class::Limit,
Class::Liquidity => order::Class::Liquidity,
},
fee: order::Fee(order.fee_amount),
partially_fillable: order.partially_fillable,
})
.collect(),
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/solve/dto/solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn from_domain(solutions: &[solution::Solution]) -> super::Solutions {
receiver: trade.order.receiver,
valid_to: trade.order.valid_to,
app_data: trade.order.app_data.0,
fee_amount: trade.order.fee.0,
fee_amount: 0.into(),
kind: match trade.order.side {
crate::domain::order::Side::Buy => Kind::Buy,
crate::domain::order::Side::Sell => Kind::Sell,
Expand Down
3 changes: 1 addition & 2 deletions src/domain/dex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ impl Swap {
}

pub fn satisfies(&self, order: &domain::order::Order) -> bool {
self.output.amount * (order.sell.amount + order.fee.0)
>= self.input.amount * order.buy.amount
self.output.amount * order.sell.amount >= self.input.amount * order.buy.amount
}
}

Expand Down
16 changes: 1 addition & 15 deletions src/domain/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use {
crate::{domain::eth, util},
ethereum_types::{Address, H256, U256},
ethereum_types::{Address, H256},
std::fmt::{self, Debug, Display, Formatter},
};

Expand All @@ -12,7 +12,6 @@ pub struct Order {
pub uid: Uid,
pub sell: eth::Asset,
pub buy: eth::Asset,
pub fee: Fee,
pub side: Side,
pub class: Class,
pub partially_fillable: bool,
Expand All @@ -26,14 +25,6 @@ impl Order {
bytes.into()
}

/// Returns the order's fee amount as an asset.
pub fn fee(&self) -> eth::Asset {
eth::Asset {
token: self.sell.token,
amount: self.fee.0,
}
}

/// Returns `true` if the order expects a solver-computed fee.
pub fn solver_determines_fee(&self) -> bool {
self.class == Class::Limit
Expand All @@ -58,10 +49,6 @@ impl Display for Uid {
}
}

/// An order fee amount, denominated in its sell token.
#[derive(Clone, Copy, Debug)]
pub struct Fee(pub U256);

/// The trading side of an order.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Side {
Expand Down Expand Up @@ -138,7 +125,6 @@ pub struct JitOrder {
pub signature: Signature,
pub sell: eth::Asset,
pub buy: eth::Asset,
pub fee: Fee,
pub side: Side,
pub class: Class,
pub partially_fillable: bool,
Expand Down
2 changes: 0 additions & 2 deletions src/tests/balancer/market_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ async fn sell() {
"buyToken": "0xba100000625a3754423978a60c9317c58a424e3D",
"sellAmount": "1000000000000000000",
"buyAmount": "200000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down Expand Up @@ -229,7 +228,6 @@ async fn buy() {
"buyToken": "0xba100000625a3754423978a60c9317c58a424e3D",
"sellAmount": "1000000000000000000",
"buyAmount": "100000000000000000000",
"feeAmount": "1000000000000000",
"kind": "buy",
"partiallyFillable": false,
"class": "market",
Expand Down
1 change: 0 additions & 1 deletion src/tests/balancer/not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ async fn test() {
"buyToken": "0x2222222222222222222222222222222222222222",
"sellAmount": "1000000000000000000",
"buyAmount": "1000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down
2 changes: 0 additions & 2 deletions src/tests/balancer/out_of_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ async fn sell() {
"sellAmount": "1000000000000000000",
// Way too much...
"buyAmount": "1000000000000000000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down Expand Up @@ -167,7 +166,6 @@ async fn buy() {
// Way too little...
"sellAmount": "1",
"buyAmount": "100000000000000000000",
"feeAmount": "1000000000000000",
"kind": "buy",
"partiallyFillable": false,
"class": "market",
Expand Down
6 changes: 0 additions & 6 deletions src/tests/dex/partial_fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ endpoint = 'http://{}/sor'
"buyToken": "0xba100000625a3754423978a60c9317c58a424e3D",
"sellAmount": "16000000000000000000",
"buyAmount": "3630944624685908136768",
"feeAmount": "0",
"kind": "sell",
"partiallyFillable": true,
"class": "limit",
Expand Down Expand Up @@ -373,8 +372,6 @@ async fn tested_amounts_wrap_around() {
"buyToken": "0xba100000625a3754423978a60c9317c58a424e3D",
"sellAmount": "60000000000000000",
"buyAmount": "16000000000000000000",
// Let's just assume 0 fee to not further complicate the math.
"feeAmount": "0",
"kind": "buy",
"partiallyFillable": true,
"class": "limit",
Expand Down Expand Up @@ -527,7 +524,6 @@ endpoint = 'http://{}/sor'
"buyToken": "0xba100000625a3754423978a60c9317c58a424e3D",
"sellAmount": "2000000000000000000",
"buyAmount": "1",
"feeAmount": "0",
"kind": "sell",
"partiallyFillable": true,
"class": "limit",
Expand Down Expand Up @@ -701,7 +697,6 @@ async fn insufficient_room_for_surplus_fee() {
"buyToken": "0xba100000625a3754423978a60c9317c58a424e3D",
"sellAmount": "1000000000000000000",
"buyAmount": "227598784442065388110",
"feeAmount": "10000000000000000",
"kind": "sell",
"partiallyFillable": true,
"class": "limit",
Expand Down Expand Up @@ -802,7 +797,6 @@ async fn market() {
"buyToken": "0xba100000625a3754423978a60c9317c58a424e3D",
"sellAmount": "1000000000000000000",
"buyAmount": "227598784442065388110",
"feeAmount": "10000000000000000",
"kind": "sell",
"partiallyFillable": true,
"class": "market",
Expand Down
1 change: 0 additions & 1 deletion src/tests/dex/wrong_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ async fn test() {
"buyToken": "0xba100000625a3754423978a60c9317c58a424e3D",
"sellAmount": "1000000000000000000",
"buyAmount": "227598784442065388110",
"feeAmount": "10000000000000000",
"kind": side,
"partiallyFillable": false,
"class": "market",
Expand Down
2 changes: 0 additions & 2 deletions src/tests/oneinch/market_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ async fn sell() {
"buyToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"sellAmount": "1000000000000000000",
"buyAmount": "200000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down Expand Up @@ -287,7 +286,6 @@ async fn buy_not_supported() {
"buyToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"sellAmount": "1000000000000000000",
"buyAmount": "200000000000000000000",
"feeAmount": "1000000000000000",
"kind": "buy",
"partiallyFillable": false,
"class": "market",
Expand Down
1 change: 0 additions & 1 deletion src/tests/oneinch/not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ async fn test() {
"buyToken": "0x2222222222222222222222222222222222222222",
"sellAmount": "1000000000000000000",
"buyAmount": "1000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down
1 change: 0 additions & 1 deletion src/tests/oneinch/out_of_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ async fn sell() {
"sellAmount": "1000000000000000000",
// Way too much...
"buyAmount": "1000000000000000000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down
2 changes: 0 additions & 2 deletions src/tests/paraswap/market_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ async fn sell() {
"buyToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"sellAmount": "1000000000000000000",
"buyAmount": "200000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down Expand Up @@ -430,7 +429,6 @@ async fn buy() {
"buyToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"sellAmount": "200000000000000000",
"buyAmount": "1000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "buy",
"partiallyFillable": false,
"class": "market",
Expand Down
1 change: 0 additions & 1 deletion src/tests/paraswap/not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ async fn test() {
"buyToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"sellAmount": "1000000000000000000",
"buyAmount": "200000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down
2 changes: 0 additions & 2 deletions src/tests/paraswap/out_of_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ async fn sell() {
"sellAmount": "1000000000000000000",
// Way too much...
"buyAmount": "1000000000000000000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down Expand Up @@ -391,7 +390,6 @@ async fn buy() {
// Way too little...
"sellAmount": "1",
"buyAmount": "1000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "buy",
"partiallyFillable": false,
"class": "market",
Expand Down
2 changes: 0 additions & 2 deletions src/tests/zeroex/market_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ async fn sell() {
"buyToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"sellAmount": "1000000000000000000",
"buyAmount": "200000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down Expand Up @@ -297,7 +296,6 @@ async fn buy() {
"buyToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"sellAmount": "200000000000000000",
"buyAmount": "1000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "buy",
"partiallyFillable": false,
"class": "market",
Expand Down
1 change: 0 additions & 1 deletion src/tests/zeroex/not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async fn test() {
"buyToken": "0x2222222222222222222222222222222222222222",
"sellAmount": "1000000000000000000",
"buyAmount": "1000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down
1 change: 0 additions & 1 deletion src/tests/zeroex/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ enable-slippage-protection = true
"buyToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"sellAmount": "1000000000000000000",
"buyAmount": "5000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down
2 changes: 0 additions & 2 deletions src/tests/zeroex/out_of_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ async fn sell() {
"sellAmount": "1000000000000000000",
// Way too much...
"buyAmount": "1000000000000000000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "sell",
"partiallyFillable": false,
"class": "market",
Expand Down Expand Up @@ -229,7 +228,6 @@ async fn buy() {
// Way too little...
"sellAmount": "1",
"buyAmount": "1000000000000000000000",
"feeAmount": "1000000000000000",
"kind": "buy",
"partiallyFillable": false,
"class": "market",
Expand Down

0 comments on commit b41c021

Please sign in to comment.