Skip to content

Commit

Permalink
feat: changing max to 100% and fixing typos in test tree
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Jul 16, 2024
1 parent 7bc9015 commit 9c90725
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/contracts/BConst.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract BConst {
/// @notice The minimum swap fee that can be set.
uint256 public constant MIN_FEE = BONE / 10 ** 6;
/// @notice The maximum swap fee that can be set.
uint256 public constant MAX_FEE = BONE - MIN_FEE;
uint256 public constant MAX_FEE = BONE;
/// @notice The immutable exit fee percentage
uint256 public constant EXIT_FEE = 0;

Expand Down
10 changes: 9 additions & 1 deletion test/unit/BMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,15 @@ contract BMathTest is Test, BConst {
bMath.calcPoolInGivenSingleOut(_balanceOut, weightOut, poolSupply, totalWeight, amountOut, swapFee);
}

function test_CalcPoolInGivenSingleOutRevertWhen_SwapFeeIs1AndTokenWeightOutIsZero() external {
function test_CalcPoolInGivenSingleOutRevertWhen_SwapFeeGreaterThanBONE() external {
// it should revert
// subtraction underflow
vm.expectRevert(BNum.BNum_SubUnderflow.selector);

bMath.calcPoolInGivenSingleOut(balanceOut, weightOut, poolSupply, totalWeight, amountOut, BONE + 1);
}

function test_CalcPoolInGivenSingleOutRevertWhen_SwapFeeEqualsBONEAndTokenWeightOutIsZero() external {
uint256 _swapFee = BONE;
uint256 _weightOut = 0;

Expand Down
16 changes: 9 additions & 7 deletions test/unit/BMath.tree
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ BMathTest::calcSpotPrice
│ └── it should revert // division by zero
├── when weighted token balance out is zero
│ └── it should revert // division by zero
├── when swapFee greater than BONE
├── when swap fee greater than BONE
│ └── it should revert // subtraction underflow
├── when swapFee equals BONE
├── when swap fee equals BONE
│ └── it should revert // division by zero
├── when swap fee is zero
│ └── it should return correct value
Expand All @@ -26,9 +26,9 @@ BMathTest::calcOutGivenIn
├── when token amount in too big
│ └── it should revert // ai * (1 - sf) > uint256 max
├── when token balance in and amount in are zero
│ └── it should revert // bi + (ai * (1 - swapFee)) = 0
│ └── it should revert // bi + (ai * (1 - sf)) = 0
├── when token balance in is zero and swap fee equals BONE
│ └── it should revert // bi + (ai * (1 - swapFee)) = 0
│ └── it should revert // bi + (ai * (1 - sf)) = 0
├── when token weight in is zero
│ └── it should return zero
├── when token weights are equal
Expand All @@ -53,9 +53,9 @@ BMathTest::calcInGivenOut
│ └── it should revert // subtraction underflow
├── when token amount out equals token balance out
│ └── it should revert // division by zero
├── when swapFee greater than BONE
├── when swap fee greater than BONE
│ └── it should revert // subtraction underflow
├── when swapFee equals BONE
├── when swap fee equals BONE
│ └── it should revert // division by zero
├── when token weight out is zero
│ └── it should return zero
Expand Down Expand Up @@ -91,6 +91,8 @@ BMathTest::calcPoolOutGivenSingleIn
BMathTest::calcSingleInGivenPoolOut
├── when total weight is zero
│ └── it should revert // division by zero
├── when swap fee greater than BONE
│ └── it should revert // subtraction underflow
├── when swap fee is zero
│ └── it should return correct value
│ └── (((pS + ao) / pS) ^ (wT/wi))*bi - bi
Expand Down Expand Up @@ -121,7 +123,7 @@ BMathTest::calcSingleOutGivenPoolIn
BMathTest::calcPoolInGivenSingleOut
├── when token balance out is zero
│ └── it should revert // subtraction underflow
├── when swap fee is 1 and token weight out is zero
├── when swap fee greater than BONE
│ └── it should revert // division by zero
├── when token amount out is zero
│ └── it should return zero
Expand Down

0 comments on commit 9c90725

Please sign in to comment.