Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC] Add test cases of bin math #99

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
247511
247511
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerBytecodeSize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24762
24759
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerBytecodeSize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24839
24829
Original file line number Diff line number Diff line change
@@ -1 +1 @@
149801
149782
16 changes: 16 additions & 0 deletions test/pool-bin/libraries/BinHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ contract BinHelperTest is BinTestHelper {
}
}

// run test via: forge test --match-test testLiquidityPOC -vvv
function testLiquidityPOC() external {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can set pure , or will get warning.
Screenshot 2024-07-18 at 13 05 15

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this is a POC 😂

uint24 binId = 8_393_426;
uint16 binStep = 10;
uint256 price = PriceHelper.getPriceFromId(binId, binStep);
assertEq(price, 41997625866672948725687173685150666229626);
console2.log("price: ", price);

uint128 amtX = 1e18;
uint128 amtY = 2e18;
bytes32 amounts = amtX.encode(amtY);
uint256 liquidity = BinHelper.getLiquidity(amounts, price);
console2.log("liquidity :", liquidity);
assertEq(liquidity, 42678190600514825652613922900014202652538000000000000000000);
}

function testFuzz_getSharesAndEffectiveAmountsIn(
uint128 binReserveX,
uint128 binReserveY,
Expand Down
Loading