Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to unlock depositing after a 100% seize on the pool #234

Open
pdyraga opened this issue Jun 8, 2023 · 0 comments
Open

How to unlock depositing after a 100% seize on the pool #234

pdyraga opened this issue Jun 8, 2023 · 0 comments

Comments

@pdyraga
Copy link
Member

pdyraga commented Jun 8, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant