/**
@dev Batch claiming of tokens for owners
@param _count The amount of owners to claim tokens for
*/
function batchClaim(uint256 _count) public onlyPoolOwner() {
uint claimed = distribution << 128 >> 128;
uint to = _count.add(claimed);
require(_count.add(claimed) <= ownerMap.size(), "To value is greater than the amount of owners");
for (uint256 i = claimed; i < to; i++) {
claimTokens(i);
}
claimed = claimed.add(_count);
if (claimed == ownerMap.size()) {
distributionActive = false;
emit TokenDistributionComplete(dToken, distribution >> 128, ownerMap.size());
} else {
distribution = distribution >> 128 << 128 | claimed;
}
}
/**
@dev Claim the tokens for the next owner in the map
*/
function claimTokens(uint _i) private {
address owner = address(ownerMap.getKey(_i));
uint o = ownerMap.get(uint(owner));
require(o >> 128 > 0, "You need to have a share to claim tokens");
require(distributionActive, "Distribution isn't active");
uint256 tokenAmount = (distribution >> 128).mul(o >> 128).div(100000);
require(ERC20(dToken).transfer(owner, tokenAmount), "ERC20 transfer failed");
}
Created
October 26, 2018 10:41
-
-
Save jleeh/dec95d618a92f7a049170067f7da2558 to your computer and use it in GitHub Desktop.
New PoolOwners Claiming Process
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment