Skip to content

Commit

Permalink
fix: using funny spot prices
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Jul 22, 2024
1 parent 9853016 commit 5709a95
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions test/unit/BPool/BPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract BPool is BPoolBase, BMath {
// sP = 10 / 20 = 0.5e18
// sPf = (10 / 20) * (1 / (1-0.1)) = 0.555...e18 (round-up)
uint256 public spotPriceWithoutFee = 0.5e18;
uint256 public spotPrice = bmul(spotPriceWithoutFee, bdiv(BONE, bsub(BONE, swapFee)));
uint256 public spotPrice = 0.555555555555555556e18;

function setUp() public virtual override {
super.setUp();
Expand Down Expand Up @@ -336,8 +336,7 @@ contract BPool is BPoolBase, BMath {
vm.mockCall(tokens[1], abi.encodePacked(IERC20.balanceOf.selector), abi.encode(balanceTokenOut));
vm.expectCall(tokens[1], abi.encodeWithSelector(IERC20.balanceOf.selector));
// it returns spot price
uint256 _spotPrice = 0.555555555555555556e18;
assertEq(bPool.getSpotPrice(tokens[0], tokens[1]), _spotPrice);
assertEq(bPool.getSpotPrice(tokens[0], tokens[1]), spotPrice);
}

function test_GetSpotPriceSansFeeRevertWhen_ReentrancyLockIsSet() external {
Expand Down Expand Up @@ -367,8 +366,7 @@ contract BPool is BPoolBase, BMath {
vm.mockCall(tokens[1], abi.encodePacked(IERC20.balanceOf.selector), abi.encode(balanceTokenOut));
vm.expectCall(tokens[1], abi.encodeWithSelector(IERC20.balanceOf.selector));
// it returns spot price
uint256 _spotPrice = 0.5e18;
assertEq(bPool.getSpotPriceSansFee(tokens[0], tokens[1]), _spotPrice);
assertEq(bPool.getSpotPriceSansFee(tokens[0], tokens[1]), spotPriceWithoutFee);
}

function test_FinalizeRevertWhen_CallerIsNotController(address _caller) external {
Expand Down

0 comments on commit 5709a95

Please sign in to comment.