-
Notifications
You must be signed in to change notification settings - Fork 45
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
Filter surge cases for unbalanced liquidity #1259
Conversation
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.
Looks good!
Co-authored-by: EndymionJkb <[email protected]>
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.
LGTM!
address pool, | ||
uint256 staticSwapFeePercentage | ||
) public view returns (uint256) { | ||
uint256 amountCalculatedScaled18 = StablePool(pool).onSwap(params); |
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 may be a very stupid idea, and maybe it's too late for this.
This line is an approximation, since the real amount calculated will be affected by the surge fee. If this is an approximation, why don't we use the linear math instead of the pool math, which is cheaper in terms of gas? The result of the linear math will be more pessimist, so the fee tends to be a bit higher, which favors the vault and LPs. Besides, the math is simpler.
Description
PoC: allow unbalanced liquidity for stable surge, blocking operations that would make the pool surge past the threshold (proportional excluded).
Using
after
hooks because it's easier to reconstruct original balances without caring about the operation kind. Also prevents reloading balances unnecessarily at the vault.Type of change
Checklist:
main
, or there's a description of how to mergeIssue Resolution