Consider the following scenario:
- 1 T is deposited into the asset pool.
- The risk manager seizes 1 T (100% of the pool).
- There is 1 covT in existence and 0 T deposited in the asset pool.
When someone tries to deposit in this state, the transaction will revert because collateralBalance is 0:
|
/// @dev Calculates underwriter tokens to mint. |
|
function _calculateTokensToMint(uint256 amountToDeposit) |
|
internal |
|
returns (uint256) |
|
{ |
|
rewardsPool.withdraw(); |
|
|
|
uint256 covSupply = underwriterToken.totalSupply(); |
|
uint256 collateralBalance = collateralToken.balanceOf(address(this)); |
|
|
|
if (covSupply == 0) { |
|
return amountToDeposit; |
|
} |
|
|
|
return (amountToDeposit * covSupply) / collateralBalance; |
|
} |
The pool can be unlocked by depositing some amount of T and I think this was the original intention when implementing this piece of code - it is hard to come up with _calculateTokensToMint value if there is nothing deposited but the covT supply is non-zero.
We should revisit this decision or at least make it clear in the docs what should be done after the 100% seize event.
Consider the following scenario:
When someone tries to deposit in this state, the transaction will revert because
collateralBalanceis 0:coverage-pools/contracts/AssetPool.sol
Lines 584 to 599 in 71047ca
The pool can be unlocked by depositing some amount of T and I think this was the original intention when implementing this piece of code - it is hard to come up with
_calculateTokensToMintvalue if there is nothing deposited but the covT supply is non-zero.We should revisit this decision or at least make it clear in the docs what should be done after the 100% seize event.