#46984 [SC-Low] Incomplete Token Supply Check After Token Share Recalculation in `_selfCloseExitTo`
Description
Brief/Intro
Vulnerability Details
function _selfCloseExitTo(
uint256 _tokenShare,
bool _redeemToCollateral,
address payable _recipient,
string memory _redeemerUnderlyingAddress,
address payable _executor
)
private
{
require(_tokenShare > 0, "token share is zero");
require(_tokenShare <= token.balanceOf(msg.sender), "token balance too low");
AssetData memory assetData = _getAssetData();
@> require(assetData.poolTokenSupply == _tokenShare ||
assetData.poolTokenSupply - _tokenShare >= MIN_TOKEN_SUPPLY_AFTER_EXIT,
"token supply left after exit is too low and non-zero");
uint256 natShare = assetData.poolNatBalance.mulDiv(
_tokenShare, assetData.poolTokenSupply); // poolTokenSupply >= _tokenShare > 0
require(natShare > 0, "amount of sent tokens is too small");
require(assetData.poolNatBalance == natShare ||
assetData.poolNatBalance - natShare >= MIN_NAT_BALANCE_AFTER_EXIT,
"collateral left after exit is too low and non-zero");
uint256 maxAgentRedemption = assetManager.maxRedemptionFromAgent(agentVault);
uint256 requiredFAssets = _getFAssetRequiredToNotSpoilCR(assetData, natShare);
// rare case: if agent has too many low-valued open tickets they can't redeem the requiredFAssets
// in one transaction. In that case we lower/correct the amount of spent tokens and nat share.
...........Impact Details
Recommended Fix
Proof of Concept
Proof of Concept
Previous#46982 [SC-Insight] Spread calculation discrepancy allows wildly divergent prices to be acceptedNext#46985 [SC-High] CollateralPool::totalCollateral can be increased to arbitrary value
Was this helpful?