-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use unscaled user fees for executed amounts (#2151)
# Description Market orders currently return incorrect executed amounts (cf. #2150) because we report the fee amount solvers are supposed to use for scoring (which add the 0.002 ETH gas subsidy we currently apply on user orders to compensate the gas overhead in the settlement contract). However, this fee amount is only used for scoring (to avoid solutions getting rejected because of negative scores) and is not what the user actually pays. # Changes - [ ] Rename current "solver_fee()" method on `Trade` to `scoring_fee()` as it captures more accurately what this specific value should be used for (I started renaming all occurrences of solver_fee which imply this semantic, but this diff is becoming huge. - [ ] Introduce a new `fee` method which returns the fee from the user perspective (namely the subsidised fee in the case of market orders) - [ ] Use 👆 when computing executed fee amount - [ ] Added integration tests for the fee amount behavior ## How to test Newly added tests ## Related Issues Fixes #2150
- Loading branch information
Showing
12 changed files
with
99 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use crate::{ | ||
domain::competition::order, | ||
tests::{ | ||
self, | ||
setup::{ab_order, ab_pool, ab_solution}, | ||
}, | ||
}; | ||
|
||
#[tokio::test] | ||
#[ignore] | ||
async fn rejects_unwarranted_solver_fee() { | ||
let test = tests::setup() | ||
.name("Solver fee on market order".to_string()) | ||
.pool(ab_pool()) | ||
.order( | ||
// A solver reporting a fee on a swap order | ||
ab_order() | ||
.user_fee(1000.into()) | ||
.solver_fee(Some(500.into())), | ||
) | ||
.solution(ab_solution()) | ||
.done() | ||
.await; | ||
|
||
test.solve().await.status(hyper::StatusCode::BAD_REQUEST); | ||
} | ||
|
||
#[tokio::test] | ||
#[ignore] | ||
async fn solver_fee() { | ||
for side in [order::Side::Buy, order::Side::Sell] { | ||
let test = tests::setup() | ||
.name(format!("Solver Fee: {side:?}")) | ||
.pool(ab_pool()) | ||
.order( | ||
ab_order() | ||
.kind(order::Kind::Limit) | ||
.side(side) | ||
.solver_fee(Some(500.into())), | ||
) | ||
.solution(ab_solution()) | ||
.done() | ||
.await; | ||
|
||
test.solve().await.ok().orders(&[ab_order().name]); | ||
} | ||
} | ||
|
||
#[tokio::test] | ||
#[ignore] | ||
async fn user_fee() { | ||
for side in [order::Side::Buy, order::Side::Sell] { | ||
let test = tests::setup() | ||
.name(format!("User Fee: {side:?}")) | ||
.pool(ab_pool()) | ||
.order(ab_order().side(side).user_fee(1000.into())) | ||
.solution(ab_solution()) | ||
.done() | ||
.await; | ||
|
||
test.solve().await.ok().orders(&[ab_order().name]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters