Skip to content

Insufficient internal ReservePool causing Hatchers to loose all tokens #16

@EnchanterIO

Description

@EnchanterIO

Description

Currently, there is no way for a hatcher to claim ALL of his tokens due to a bug in reserve pool business logic.

The reserve pool is minted at the end of hatching period as:

uint256 amountReserveInternal = (initialRaise / p0) * (DENOMINATOR_PPM - theta) / DENOMINATOR_PPM;

_mint(address(this), amountReserveInternal);
  • notice the FundingPool THETA substraction

BUT

Each hatcher is assigned tokens based on full allocation (including the theta) as:

initialContributions[msg.sender].lockedInternal += contributed * p0;

Claiming tokens fail because there is insufficient reserve and no tokens what so ever can be claimed causing the hatcher to fully LOST his original hatch contribution.

claim() {
     _transfer(address(this), msg.sender, toUnlock);

With the following contract ~state (for better problem visualization):

6500000000000000000000)   // total supply
6500000000000000000000)   // CommonsStack balance
10000000000000000000000) // Hatcher unlocked tokens
  • whooops, 35% FundingPool theta missing causing all hatchers to loose tokens

Steps to reproduce

  1. Hatch the CommonsToken
  2. Generate so much in funding pool fees by buying and selling that all hatchers tokens are unlocked
  3. Try to claim tokens

I created the following test reproducing the problem: https://github.com/lightstreams-network/genesis-contracts/blob/master/test/06_insufficient_reserve.js

Proposed solution

Calculate the reserve in the following way:

// Mint INTERNAL tokens to the reserve:
_mint(address(this), initialRaise * p0);

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