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

Error correction related to singlepool implementation (liquidity update in crossing, swap with type(int256).max as amountSpecified)) #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xben12
Copy link

@xben12 xben12 commented Oct 14, 2023

Related Issue

  1. TWAMM SinglePool LiquidityNet update formula is incorrect. link: [Bug]: TWAMM SinglePool LiquidityNet update formula is incorrect #66
  2. swap with type(int256).max as amountSpecified

Description of changes

  1. update of the formula on liquidity update when price cross the tick. ( [Bug]: TWAMM SinglePool LiquidityNet update formula is incorrect #66)
  2. calcuate the uppper limit for amountSpecified to prevent errors where backed out amount_to_swap is larger than the total selling amount In single sell mode.
  3. added 3 test function & 2 setting functions for the above 2 issues:
  • 2 test case related to price crossing, and
  • one related to backout amount > total selling amount).
    Screenshot 2023-10-14 at 4 47 07 PM

Run test using: forge test --match-test testTWAMM_OrderFill_SingleSide -vv
========================Results=========================
[⠒] Compiling...
No files changed, compilation skipped

Running 3 tests for test/TWAMM.t.sol:TWAMMTest
[PASS] testTWAMM_OrderFill_SingleSide_OneForZero_Crosstick() (gas: 567406)
[PASS] testTWAMM_OrderFill_SingleSide_ZeroForOne_Crosstick() (gas: 600276)
[PASS] testTWAMM_OrderFill_SingleSide_ZeroForOne_NoCross() (gas: 509822)
Test result: ok. 3 passed; 0 failed; 0 skipped; finished in 12.63ms
Ran 1 test suites: 3 tests passed, 0 failed, 0 skipped (3 total tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant