This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
0xvj - Admins cannot be able to create a new market with same insurance token and strikePrice but a different underlyingAsset token #376
Labels
Non-Reward
This issue will not receive a payout
0xvj
medium
Admins cannot be able to create a new market with same insurance token and strikePrice but a different underlyingAsset token
Summary
Admins cannot be able to create a new market with same
token
andstrikePrice
but a differentunderlyingAsset
token as themarketId
of a new market is being calculated using just token address and strikePrice as inputs.Vulnerability Detail
The
VaultFactoryV2.createNewMarket
function creates a new market by calculating amarketId
using thegetMarketId
function, which takes the token address and strike price as inputs. However, if an admin attempts to create a new market with the same token and strike price but a different underlying asset token, the VaultFactoryV2.createNewMarket function will fail and revert. This is because the new market would also receive the samemarketId
, causing a conflict.To clarify, when the
VaultFactoryV2.createNewMarket
function is used to create a new market, it first calls thegetMarketId
function, which takes the token address and strike price as inputs and returns a unique market identifier. However, since thegetMarketId
function only takes these two parameters into account, it is not able to differentiate between markets with the same token and strike price but different underlying asset tokens. As a result, attempting to create a new market with these parameters will cause a conflict, leading to the function reverting.Steps:
stETH
as collateral and premium instead ofWETH
.createNewMarket
function will revert while creating the new market with stETH as both markets have same token and stike price because of the below check.Impact
The inability to create a new market with a different underlying asset token may render the protocol unusable in the future if users prefer to use a different token as the underlying asset, particularly if that token is more popular and widely owned by most users(ex: stETH).
Code Snippet
https://github.com/Y2K-Finance/Earthquake/blob/736b2e1e51bef6daa6a5ecd1decb7d156316d795/src/v2/VaultFactoryV2.sol#L375-L381
https://github.com/Y2K-Finance/Earthquake/blob/736b2e1e51bef6daa6a5ecd1decb7d156316d795/src/v2/VaultFactoryV2.sol#L58-L128
Tool used
Manual Review
Recommendation
Consider calculating the marketId from
_marketCalldata.underlyingAsset
_marketCalldata.token
and_marketCalldata.strikePrice
instead of calculating it from_marketCalldata.underlyingAsset
and_marketCalldata.token
inVaultFactoryV2.createNewMarket
function.Chane the getMarketId function as below.
Duplicate of #300
The text was updated successfully, but these errors were encountered: