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
- Hatch the CommonsToken
- Generate so much in funding pool fees by buying and selling that all hatchers tokens are unlocked
- 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);
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:
BUT
Each hatcher is assigned tokens based on full allocation (including the theta) as:
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.
With the following contract ~state (for better problem visualization):
Steps to reproduce
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: