-
Notifications
You must be signed in to change notification settings - Fork 5
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
pashap9990 - Lp amount will be minted lower than what it really expected in mint function #104
Comments
Escalate loss = $228[22%]
|
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
After additionally considering this issue, indeed, the slippage is checked only on the oracle price and doesn't catch the pool reserves, leading to the situation where regardless of user-set slippage, they can get fewer tokens after |
Result: |
Escalations have been resolved successfully! Escalation status:
|
pashap9990
Medium
Lp amount will be minted lower than what it really expected in mint function
Summary
LPs may receive fewer tokens than expected when minting due to fluctuating pool reserves. Without specifying a minimum LP amount, this can lead to unexpected fund losses for LPs. Adding a min_lp_amount parameter to the Api::mint function can prevent this issue
Internal pre-conditions
Consider change config in tests/conftest.py
I do it for better understanding,Fee doesn't important in this issue
Code Snippet
https://github.com/sherlock-audit/2024-08-velar-artha/blob/main/gl-sherlock/contracts/api.vy#L75
Impact
Lp amount will be minted lower than what it really expected
PoC
Textual PoC:
we assume protocol fee is zero in this example
1-Alice opens long position when price is $2
2-Joe opens a short position when price is $2
3-Price goes down to $1
4-Bob calls
Pools::calc_mint
and he realize if he provide 1000 VEL to pool,he gets 1000 LP5-Bob send his tx to network
6-liquidator bot liquids Alice's position
7-Bob's tx will be executed and Bob get 952 lp instead of 1000
8-Joe closes his position and gets his profit,hence pool's reserve will be deducted
9-Bob burns his LPs token,and he gets 772 VEL instead of 1000 VEL
Coded PoC:
Place below test in
tests/test_positions.py
and runpytest -k test_get_less_lp_amt_than_expected - s
Mitigation
Api::mint
should have another parameter like min_lp_amount which can be checked when the lp token wants to be mintDuplicate of #74
The text was updated successfully, but these errors were encountered: