Skip to content

Commit

Permalink
Merge pull request #38 from darkforestry/fix/v2-amount-out
Browse files Browse the repository at this point in the history
Updated v2 swap fee to be dynamic
  • Loading branch information
0xKitsune authored Jun 20, 2023
2 parents 6861201 + 4fc1fde commit 171d7ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions src/amm/uniswap_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ impl UniswapV2Pool {
if amount_in.is_zero() || reserve_in.is_zero() || reserve_out.is_zero() {
return U256::zero();
}

let amount_in_with_fee = amount_in * U256::from(997);
let fee = (10000 - (self.fee / 10)) / 10; //Fee of 300 => (10,000 - 30) / 10 = 997
let amount_in_with_fee = amount_in * U256::from(fee);
let numerator = amount_in_with_fee * reserve_out;
let denominator = reserve_in * U256::from(1000) + amount_in_with_fee;

Expand Down

0 comments on commit 171d7ea

Please sign in to comment.