Skip to content

Commit

Permalink
test: update tests with solver changes
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Apr 26, 2024
1 parent 30882d3 commit 1d86f3b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/G3M/unit/Update.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract G3MUpdateTest is G3MSetUp {
assertEq(params.swapFee, TEST_SWAP_FEE);

uint256 newSwapFee = 0.004 ether;
bytes memory data = solver.prepareFeeUpdate(newSwapFee);
bytes memory data = solver.prepareSwapFeeUpdate(newSwapFee);
dfmm.update(POOL_ID, data);

params = solver.getPoolParams(POOL_ID);
Expand Down
10 changes: 7 additions & 3 deletions test/LogNormal/LogNormalTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
computeNextLiquidity,
computeLGivenX,
computeYGivenL,
computeTradingFunction
computeTradingFunction,
computePriceGivenY,
computePriceGivenX
} from "src/LogNormal/LogNormalMath.sol";

contract LogNormalTest is Test {
Expand Down Expand Up @@ -177,8 +179,10 @@ contract LogNormalTest is Test {
function test_price_formulas() public basic {
(uint256[] memory reserves, uint256 L) =
solver.getReservesAndLiquidity(POOL_ID);
uint256 priceGivenX = solver.getPriceGivenXL(POOL_ID, reserves[0], L);
uint256 priceGivenY = solver.getPriceGivenYL(POOL_ID, reserves[1], L);
uint256 priceGivenX =
computePriceGivenX(reserves[0], L, solver.getPoolParams(POOL_ID));
uint256 priceGivenY =
computePriceGivenY(reserves[1], L, solver.getPoolParams(POOL_ID));
assertApproxEqAbs(priceGivenY, priceGivenX, 100);
}

Expand Down
10 changes: 8 additions & 2 deletions test/LogNormal/unit/Init.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ pragma solidity ^0.8.13;

import "./SetUp.sol";
import "forge-std/Test.sol";
import {
computePriceGivenY,
computePriceGivenX
} from "src/LogNormal/LogNormalMath.sol";

contract LogNormalInitTest is LogNormalSetUp {
function test_LogNormal_init_StoresPoolParameters() public init {
Expand Down Expand Up @@ -44,8 +48,10 @@ contract LogNormalInitTest is LogNormalSetUp {
function test_LogNormal_init_ReturnsPriceOfOne() public init {
(uint256[] memory reserves, uint256 L) =
solver.getReservesAndLiquidity(POOL_ID);
uint256 priceGivenYL = solver.getPriceGivenYL(POOL_ID, reserves[1], L);
uint256 priceGivenXL = solver.getPriceGivenXL(POOL_ID, reserves[0], L);
uint256 priceGivenYL =
computePriceGivenY(reserves[1], L, solver.getPoolParams(POOL_ID));
uint256 priceGivenXL =
computePriceGivenX(reserves[0], L, solver.getPoolParams(POOL_ID));

assertApproxEqAbs(priceGivenXL, ONE, 10);
assertApproxEqAbs(priceGivenYL, ONE, 10);
Expand Down
3 changes: 2 additions & 1 deletion test/LogNormal/unit/Swap.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ contract LogNormalSwapTest is LogNormalSetUp {

uint256 ry = reserves[1] + amountIn;
uint256 L = startL + deltaLiquidity;
uint256 approxPrice = solver.getPriceGivenYL(POOL_ID, ry, L);
uint256 approxPrice =
computePriceGivenY(ry, L, solver.getPoolParams(POOL_ID));

uint256 rx = solver.getNextReserveX(POOL_ID, ry, L, approxPrice);

Expand Down
2 changes: 1 addition & 1 deletion test/LogNormal/unit/Update.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract LogNormalUpdateTest is LogNormalSetUp {
assertEq(params.swapFee, TEST_SWAP_FEE);

uint256 newSwapFee = 0.004 ether;
bytes memory data = solver.prepareFeeUpdate(newSwapFee);
bytes memory data = solver.prepareSwapFeeUpdate(newSwapFee);
dfmm.update(POOL_ID, data);

params = solver.getPoolParams(POOL_ID);
Expand Down

0 comments on commit 1d86f3b

Please sign in to comment.