erc20-demurrage-token

ERC20 token with redistributed continual demurrage
Log | Files | Refs | README

commit f338510a1d1839061e873ef802401054aca62e78
parent 5dcf7287016630372971c32774e828449d87edb1
Author: nolash <dev@holbrook.no>
Date:   Sat,  5 Jun 2021 12:05:38 +0200

Remove commented code

Diffstat:
Msolidity/DemurrageTokenSingleCap.sol | 38+++++---------------------------------
Msolidity/DemurrageTokenSingleNocap.sol | 34+++-------------------------------
2 files changed, 8 insertions(+), 64 deletions(-)

diff --git a/solidity/DemurrageTokenSingleCap.sol b/solidity/DemurrageTokenSingleCap.sol @@ -2,7 +2,7 @@ pragma solidity > 0.6.11; // SPDX-License-Identifier: GPL-3.0-or-later -contract DemurrageTokenSingleNocap { +contract DemurrageTokenSingleCap { // Redistribution bit field, with associated shifts and masks // (Uses sub-byte boundaries) @@ -437,13 +437,7 @@ contract DemurrageTokenSingleNocap { nextRedistribution = toRedistribution(0, nextRedistributionDemurrage, totalSupply, nextPeriod); redistributions.push(nextRedistribution); - //currentParticipants = toRedistributionParticipants(currentRedistribution); - //if (currentParticipants == 0) { currentRemainder = applyDefaultRedistribution(currentRedistribution); - //} else { - // currentRemainder = remainder(currentParticipants, totalSupply); // we can use totalSupply directly because it will always be the same as the recorded supply on the current redistribution - // applyRemainderOnPeriod(currentRemainder, currentPeriod); - //} emit Period(nextPeriod); return true; } @@ -480,40 +474,21 @@ contract DemurrageTokenSingleNocap { // If the given account is participating in a period and that period has been crossed // THEN increase the base value of the account with its share of the value reduction of the period function applyRedistributionOnAccount(address _account) public returns (bool) { -// bytes32 periodRedistribution; -// uint256 supply; -// uint256 participants; -// uint256 baseValue; -// uint256 value; uint256 period; -// uint256 demurrage; -// + period = accountPeriod(_account); if (period == 0 || period >= actualPeriod()) { return false; } -// periodRedistribution = redistributions[period-1]; -// participants = toRedistributionParticipants(periodRedistribution); -// if (participants == 0) { -// return false; -// } -// -// supply = toRedistributionSupply(periodRedistribution); -// demurrage = toRedistributionDemurrageModifier(periodRedistribution); -// baseValue = ((supply / participants) * (taxLevel / 1000000)) / ppmDivider; -// value = (baseValue * demurrage) / 1000000; -// -// // zero out period for the account + + // zero out period for the account account[_account] &= bytes32(~maskAccountPeriod); -// increaseBaseBalance(_account, value); -// -// emit Redistribution(_account, period, value); + return true; } // Inflates the given amount according to the current demurrage modifier function toBaseAmount(uint256 _value) public view returns (uint256) { - //return (_value * ppmDivider * 1000000) / toDemurrageAmount(demurrageModifier); return (_value * ppmDivider * 1000000) / demurrageAmount; } @@ -522,7 +497,6 @@ contract DemurrageTokenSingleNocap { uint256 baseValue; changePeriod(); - //applyRedistributionOnAccount(msg.sender); baseValue = toBaseAmount(_value); allowance[msg.sender][_spender] += baseValue; @@ -536,7 +510,6 @@ contract DemurrageTokenSingleNocap { bool result; changePeriod(); - //applyRedistributionOnAccount(msg.sender); baseValue = toBaseAmount(_value); result = transferBase(msg.sender, _to, baseValue); @@ -551,7 +524,6 @@ contract DemurrageTokenSingleNocap { bool result; changePeriod(); - //applyRedistributionOnAccount(msg.sender); baseValue = toBaseAmount(_value); require(allowance[_from][msg.sender] >= baseValue); diff --git a/solidity/DemurrageTokenSingleNocap.sol b/solidity/DemurrageTokenSingleNocap.sol @@ -432,13 +432,7 @@ contract DemurrageTokenSingleNocap { nextRedistribution = toRedistribution(0, nextRedistributionDemurrage, totalSupply, nextPeriod); redistributions.push(nextRedistribution); - //currentParticipants = toRedistributionParticipants(currentRedistribution); - //if (currentParticipants == 0) { currentRemainder = applyDefaultRedistribution(currentRedistribution); - //} else { - // currentRemainder = remainder(currentParticipants, totalSupply); // we can use totalSupply directly because it will always be the same as the recorded supply on the current redistribution - // applyRemainderOnPeriod(currentRemainder, currentPeriod); - //} emit Period(nextPeriod); return true; } @@ -475,34 +469,15 @@ contract DemurrageTokenSingleNocap { // If the given account is participating in a period and that period has been crossed // THEN increase the base value of the account with its share of the value reduction of the period function applyRedistributionOnAccount(address _account) public returns (bool) { -// bytes32 periodRedistribution; -// uint256 supply; -// uint256 participants; -// uint256 baseValue; -// uint256 value; uint256 period; -// uint256 demurrage; -// + period = accountPeriod(_account); if (period == 0 || period >= actualPeriod()) { return false; } -// periodRedistribution = redistributions[period-1]; -// participants = toRedistributionParticipants(periodRedistribution); -// if (participants == 0) { -// return false; -// } -// -// supply = toRedistributionSupply(periodRedistribution); -// demurrage = toRedistributionDemurrageModifier(periodRedistribution); -// baseValue = ((supply / participants) * (taxLevel / 1000000)) / ppmDivider; -// value = (baseValue * demurrage) / 1000000; -// -// // zero out period for the account + // zero out period for the account account[_account] &= bytes32(~maskAccountPeriod); -// increaseBaseBalance(_account, value); -// -// emit Redistribution(_account, period, value); + return true; } @@ -517,7 +492,6 @@ contract DemurrageTokenSingleNocap { uint256 baseValue; changePeriod(); - //applyRedistributionOnAccount(msg.sender); baseValue = toBaseAmount(_value); allowance[msg.sender][_spender] += baseValue; @@ -531,7 +505,6 @@ contract DemurrageTokenSingleNocap { bool result; changePeriod(); - //applyRedistributionOnAccount(msg.sender); baseValue = toBaseAmount(_value); result = transferBase(msg.sender, _to, baseValue); @@ -546,7 +519,6 @@ contract DemurrageTokenSingleNocap { bool result; changePeriod(); - //applyRedistributionOnAccount(msg.sender); baseValue = toBaseAmount(_value); require(allowance[_from][msg.sender] >= baseValue);