Skip to content

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

Description

@balasan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions