Skip to content

Commit

Permalink
test: adding big swapFee delta
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Jul 26, 2024
1 parent 810e129 commit d62ad75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crytic-export/combined_solc.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions test/invariants/fuzz/BMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ contract FuzzBMath is EchidnaTest {
// assert(tokenAmountIn <= calc_tokenAmountIn);
// }

uint256 constant SWAP_FEE_DELTA = 0.1e18;

// calcPoolOutGivenSingleIn * calcSingleOutGivenPoolIn should be equal to calcOutGivenIn
function fuzz_testIndirectSwaps_CalcOutGivenIn(
uint256 tokenBalanceIn,
Expand Down Expand Up @@ -170,10 +172,14 @@ contract FuzzBMath is EchidnaTest {
emit Log('poolSupply', poolSupply);
emit Log('swapFee', swapFee);

swapFee = swapFee * SWAP_FEE_DELTA / BONE;

uint256 calc_tokenAmountOut =
bmath.calcOutGivenIn(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, tokenAmountIn, swapFee);
emit Log('calc_tokenAmountOut', calc_tokenAmountOut);

swapFee = swapFee * BONE / SWAP_FEE_DELTA;

uint256 calc_inv_poolAmountOut =
bmath.calcPoolOutGivenSingleIn(tokenBalanceIn, tokenWeightIn, poolSupply, totalWeight, tokenAmountIn, swapFee);
emit Log('calc_inv_poolAmountOut', calc_inv_poolAmountOut);
Expand Down Expand Up @@ -216,10 +222,14 @@ contract FuzzBMath is EchidnaTest {
emit Log('poolSupply', poolSupply);
emit Log('swapFee', swapFee);

swapFee = swapFee * SWAP_FEE_DELTA / BONE;

uint256 calc_tokenAmountIn =
bmath.calcInGivenOut(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, tokenAmountOut, swapFee);
emit Log('calc_tokenAmountIn', calc_tokenAmountIn);

swapFee = swapFee * BONE / SWAP_FEE_DELTA;

uint256 calc_inv_tokenAmountIn =
bmath.calcPoolInGivenSingleOut(tokenBalanceOut, tokenWeightOut, poolSupply, totalWeight, tokenAmountOut, swapFee);
emit Log('calc_inv_tokenAmountIn', calc_inv_tokenAmountIn);
Expand Down

0 comments on commit d62ad75

Please sign in to comment.