Skip to content

Commit

Permalink
Make operator priority explicit with brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
fedgiac committed Jan 31, 2024
1 parent 421509c commit a0c316d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ConstantProduct.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ contract ConstantProduct is IConditionalOrderGenerator {
// Note on the order price: The buy amount is not optimal for the AMM
// given the sell amount. This is intended because we want to force
// solvers to maximize the surplus for this order with the price that
// isn't the AMM best price.
// isn't the AMM best price.
uint256 selfReserve0TimesUniswapReserve1 = selfReserve0 * uniswapReserve1;
uint256 selfReserve1TimesUniswapReserve0 = selfReserve1 * uniswapReserve0;
if (selfReserve1TimesUniswapReserve0 < selfReserve0TimesUniswapReserve1) {
Expand All @@ -98,7 +98,7 @@ contract ConstantProduct is IConditionalOrderGenerator {
sellAmount = selfReserve0 / 2 - Math.ceilDiv(selfReserve1TimesUniswapReserve0, 2 * uniswapReserve1);
buyAmount = Math.mulDiv(
sellAmount,
selfReserve1TimesUniswapReserve0 + uniswapReserve1 * sellAmount,
selfReserve1TimesUniswapReserve0 + (uniswapReserve1 * sellAmount),
uniswapReserve0 * selfReserve0,
Math.Rounding.Up
);
Expand All @@ -108,7 +108,7 @@ contract ConstantProduct is IConditionalOrderGenerator {
sellAmount = selfReserve1 / 2 - Math.ceilDiv(selfReserve0TimesUniswapReserve1, 2 * uniswapReserve0);
buyAmount = Math.mulDiv(
sellAmount,
selfReserve0TimesUniswapReserve1 + uniswapReserve0 * sellAmount,
selfReserve0TimesUniswapReserve1 + (uniswapReserve0 * sellAmount),
uniswapReserve1 * selfReserve1,
Math.Rounding.Up
);
Expand Down

0 comments on commit a0c316d

Please sign in to comment.