Velvet-Capital / Velvet-v4

V4 (thena+venus) on top of v3
Other
0 stars 0 forks source link

Evaluate Integration of Gamma's Deposit Check for Price Change Security #22

Closed langnavina97 closed 1 week ago

langnavina97 commented 1 month ago

Background:

Gamma is a decentralized finance (DeFi) protocol designed to manage concentrated liquidity on automated market makers (AMMs) like Uniswap V3. It actively manages liquidity ranges to optimize capital efficiency, reduce impermanent loss, and maximize fee generation for liquidity providers. Gamma is known for its automated vaults that handle liquidity management tasks, such as rebalancing and compounding, while providing a more passive experience for liquidity providers. While Gamma does not serve as an oracle provider, it does integrate price-checking mechanisms to ensure secure operations and protect against price manipulation attacks during processes like deposits.

Gamma's deposit process includes a price check feature implemented via the clearDeposit function, which leverages oracle data to monitor price changes and avoid deposit exploits. This mechanism is a key part of their security architecture, designed to protect against front-running and other price manipulation tactics.

Relevant Contracts:

Key Function:

The checkPriceChange function in ClearingV2.sol serves as the main security feature, ensuring that no significant price fluctuations occur during the deposit process. This function leverages oracles to compare prices and block deposits if the price change exceeds a predefined threshold, thereby preventing exploits.

Considerations:

Pool Address Mapping:

Gamma's Approach:

Limitations:

https://docs.gamma.xyz/gamma/learn/scans

langnavina97 commented 1 month ago

Further findings:

Gamma’s Price Change Check:

Gamma's Compatibility with Your Custom Price Ranges:

getDepositAmount Function:

Oracle Usage:

One-sided Liquidity Management:

Havoc19 commented 1 month ago

To implement something like - clearDeposit similar to Gamma Stratergy, we anyway need priceOracle, in that case we can use uniswap Twap to expand no.of tokens, if we are going in that direction

I am not sure, how much insecure it will be if there is no priceOracle. Is there issue, like front-running, would like to know the reason

langnavina97 commented 1 month ago

Only the fee amount is being affected as described here: https://github.com/Velvet-Capital/Velvet-v4/issues/9

aj07 commented 3 weeks ago

Is there scenario of --> Manipulators might use flash loans to temporarily influence asset prices and exploit the system.

Also, I feel priceOracle is bit needed here

langnavina97 commented 3 weeks ago

I think sandwich attack would also be a concern..

I agree, this would restrict the Thena positions to only Chainlink supported assets but our Core protocol would still support any ERC20 tokens independent on any oracle..