-
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
PASCAL - Slippage isn't implmented properly on mint() and burn() functions #105
Comments
Reason for escalation is clearly stated in impact |
Escalate On behalf of @Pascal4me |
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. |
Invalid, the issue itself states that slippage is provided by a user when he calls |
The codebase only provides a slippage check for price movement, which is insufficient to prevent receiving tokens in an amount less than expected. |
BOB has no public mempool so positions can't be frontrun either way |
I mentioned in my comment: "The report states that a frontrunned (not malicious) closing position can reduce the amount received." |
I'm not sure I understand how the current slippage works in the protocol, could you please elaborate on it? |
Answering your question wang; the current slippage is just for price movement. Let's say you come with 1 bitcoin to add to the Btc/usdt (base/quote) LP, the amount of LP given to you(minted) is calculated based on the total value of the tokens in the pool as quote token present in the pool that is all btc are converted to usdt with the current oracle price to calculate how many Lp tokens you will be minted. So the current slippage implemented by the protocol only enforces price movements. So if btc is currently $60k you can put a slippage of $500, then if the oracle returns a price that is < $59500 and >$60,500 the transaction reverts. |
this issue talks about LP token price and as we know LP token price depend on pool reserve and LP total supply |
After additionally considering this issue and based on the discussion under #74, I agree this issue is valid and indeed, the slippage is checked only on the Oracle price, but when it comes to conversions, there can be slippage-related issues due to a decrease of pool reserves. Planning to accept the escalation and duplicate with #74. |
According to the rules slippages are high severity |
The rules don't say any slippage related issues are necessarily high and I believe that here the medium is more appropriate. The reasons are the following:
Hence, medium severity. The decision remains, accept the escalation and validate with medium severity and duplicate with #74. |
@WangSecurity #65 is dup of #105 |
Unfortunately, 65 is not a sufficient duplicate of 105. 65 just states that the Moreover, 65 doesn't show a definite loss of funds with a detailed explanation, which is required:
|
Result: |
Escalations have been resolved successfully! Escalation status:
|
PASCAL
High
Slippage isn't implmented properly on mint() and burn() functions
Summary
Slippage isn't implmented properly on
mint()
andburn()
functions especially onburn()
function.Vulnerability Detail
Slippage is enforced by using price discreprancy in
oracle.vy
(current price, desired price and slippage ), so current slippage implementation helps check sudden price movement not actual token payout. But inpool.vy
the actual amount thatcore.vy
pays out the LP provider when minting and burning LP tokens is calculated using the total pool value in the form of quote tokens and current circulating LP tokens https://github.com/sherlock-audit/2024-08-velar-artha/blob/main/gl-sherlock/contracts/pools.vy#L163-L178 ,https://github.com/sherlock-audit/2024-08-velar-artha/blob/main/gl-sherlock/contracts/pools.vy#L213-L228 , the issue is that current circulating LP tokens and pool reserve will be changing constantly because of minting, burning and closing positions (especially profitable ones).
Proof of concept and impact
Let's look at this scenario ; User wants to burn 100 Lp tokens he currently checks
pool.calc_burn()
a view function for how much USDT he will get in return (converting pool value to usdt) . Let's assign some varaibles; lp token total supply = 1000; pool reserve value in usdt = 2000.Using the calculation in the link I pasted above (lp * pv) /ts = (100 * 2000) / 1000 = 200 usdt will be returned as the result.
Happy with the result he goes ahead to call burn in
apy.vy
to burn 100 lp tokens but before he called it a profitable trader closed their positions taking out a net 1,000 usdt value out of the pool (I used 'net' because the collateral the trader deposited is absorbed into the pool reserve ).Then as the user that wants to burn calls
burn()
new pay out value is calculated as (100 * 1000)/ 1000 = 100. So Lp provider ends up getting 100 USDT instead of 200 and there was no slippage to ensure he will get 200 as the price of tokens do not affect the value in the pool.Tools Used
Manual Review
Recommendation
Set a minimum amount of quote/LP tokens user is supposed to expect
Duplicate of #74
The text was updated successfully, but these errors were encountered: