-
Notifications
You must be signed in to change notification settings - Fork 46
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
fix: [hexen-r9] add overflow check for bin liquidity #211
Conversation
a9c86c5
to
8c00656
Compare
|
@@ -168,6 +169,14 @@ library BinPool { | |||
amountsInWithFees = amountsInWithFees.sub(pFee); | |||
} | |||
|
|||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can i trouble you to try to add some test cases for swap/mint case? would be good exercise to further our knowledge on bin related especially with #213 issue
src/pool-bin/libraries/BinPool.sol
Outdated
@@ -168,6 +169,14 @@ library BinPool { | |||
amountsInWithFees = amountsInWithFees.sub(pFee); | |||
} | |||
|
|||
if ( | |||
(binReserves.add(amountsInWithFees).sub(amountsOutOfBin)).getLiquidity( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1/ i wonder if it will be cheaper in gas if you cast a variable to store binReserves.add(amountsInWithFees).sub(amountsOutOfBin)
like how u did elsewhere
2/ or if we apply the changes within BinHelper.getAmountsOut
and Binhelper.getAmountsIn
instead (as the price is already computed, we don't need to compute again like what we did here swapState.activeId.getPriceFromId(params.binStep)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, that's actually what i did before, what it failed the forge coverage 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But let me try option 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did help on gas, thx 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks fine 👍 just some minor comments
No description provided.