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

Contract is stuck if all tokens are sold and totalSupply and poolBalance are 0 #2

Open
balasan opened this issue Mar 23, 2018 · 0 comments

Comments

@balasan
Copy link
Contributor

balasan commented Mar 23, 2018

This is an edge case - in practice if everyone sells their tokens its probably OK that the contract is dead. However it would be nice to have a work around for this.

Proposed solution:
if totalSupply and poolBalance are 0 use a function similar to calculatePurchaceReturn to compute the number of tokens you would need to sell if you reduce the poolBalance from intialPoolBalance (poolBalance the contract was initialized with) to msg.value.

psudo code:

if ( tokenSupply_ == 0 || poolBalance == 0 ) {
  uint256 tokenDiff = calculateTokenSaleReturn(
    initialSupply,
    initialPoolBalance,
    reserveRatio,
    intialPoolBalance);
  uint256 tokensToMint = initialSupply - tokenDiff;
}

additional note - should probably also do this if tokenSupply < minTokenSupply or poolsBalance < minPoolBalance because BancorFormula behaves unpredictably with very small amounts.

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