redeem stake token may be Dos because there is not enough balance in stake pool.
Summary
Funds will be transferred to portfolio vault if the staker stake via MINT_COLLATERAL, and be transferred to stake LP Pool if the staker stake via MINT. When LP holdrers redeem tokens, all tokens will come from LP Pool. This can lead to redeem reverted because there is not enough balance.
Vulnerability Detail
When liquidity providers want to stake liquidity, liquidity providers can stake via MINT_COLLATERAL or MINT. The liquidity will be transferred to different vault, depending on mint method.
Liquidity will be transferred to portfolio vault when isCollateral = true, otherwise will be transferred to stake LP Pool at last.
function depositToVault(DepositParams calldata params) public returns (address) {
IVault vault = IVault(address(this));
address targetAddress;
// get related vault
if (DepositFrom.MANUAL == params.from || DepositFrom.MINT_COLLATERAL == params.from) {
targetAddress = vault.getPortfolioVaultAddress();
} else if (DepositFrom.ORDER == params.from) {
targetAddress = vault.getTradeVaultAddress();
} else if (DepositFrom.MINT == params.from) {
targetAddress = vault.getLpVaultAddress();
}
The vulnerability is that when LP holders try to redeem tokens, all redeem tokens will come from LP Vault. This could lead to redeem reverted because there may not be enough balance.
The hacker can deposit via isCollateral = true to transfer tokens to portfolio vault and increase LP pool's share amount. And then the hacker can redeem tokens from LP pool. This will cause other normal LP holders cannot redeem tokens. Even if there is no hacker, the system may meet this case in normal scenairo.
Poc
Add this test case into mintStakeToken.test.ts, user0 stake with isCollateral = true, and then user1 stakes with isCollateral = false. Then user1 redeems tokens, and after that, user0 cannot redeem his tokens.
jennifer37
High
redeem stake token may be Dos because there is not enough balance in stake pool.
Summary
Funds will be transferred to portfolio vault if the staker stake via
MINT_COLLATERAL
, and be transferred to stake LP Pool if the staker stake viaMINT
. When LP holdrers redeem tokens, all tokens will come from LP Pool. This can lead to redeem reverted because there is not enough balance.Vulnerability Detail
When liquidity providers want to stake liquidity, liquidity providers can stake via
MINT_COLLATERAL
orMINT
. The liquidity will be transferred to different vault, depending on mint method. Liquidity will be transferred to portfolio vault whenisCollateral
= true, otherwise will be transferred to stake LP Pool at last.The vulnerability is that when LP holders try to redeem tokens, all redeem tokens will come from LP Vault. This could lead to redeem reverted because there may not be enough balance.
The hacker can deposit via
isCollateral
= true to transfer tokens to portfolio vault and increase LP pool's share amount. And then the hacker can redeem tokens from LP pool. This will cause other normal LP holders cannot redeem tokens. Even if there is no hacker, the system may meet this case in normal scenairo.Poc
Add this test case into mintStakeToken.test.ts, user0 stake with
isCollateral
= true, and then user1 stakes withisCollateral
= false. Then user1 redeems tokens, and after that, user0 cannot redeem his tokens.Impact
LP holders can not redeem tokens.
Code Snippet
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/main/elfi-perp-contracts/contracts/facets/StakeFacet.sol#L44-L55
Tool used
Manual Review
Recommendation
transfer funds from the portfolio vault to the market vault during the minting process