Skip to content

Commit

Permalink
Fix math for exact out swaps for CPP
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPereira committed Dec 22, 2024
1 parent 7cb2282 commit e56765f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/foundry/contracts/pools/ConstantProductPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ contract ConstantProductPool is BalancerPoolToken, IBasePool {
amountCalculatedScaled18 = (poolBalancetokenOut * amountTokenIn) / (poolBalancetokenIn + amountTokenIn);
} else {
uint256 amountTokenOut = params.amountGivenScaled18; // dy
// dx = (X * dy) / (Y + dx)
amountCalculatedScaled18 = (poolBalancetokenIn * amountTokenOut) / (poolBalancetokenOut + amountTokenOut);
// dx = (X * dy) / (Y - dy)
amountCalculatedScaled18 = (poolBalancetokenIn * amountTokenOut) / (poolBalancetokenOut - amountTokenOut);
}
}

Expand Down

0 comments on commit e56765f

Please sign in to comment.