Add comments, remove dead code, remove make install for dead contracts
This commit is contained in:
parent
97415dbed2
commit
2ec72bbc55
5
CAVEAT
Normal file
5
CAVEAT
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
The contract is intended for slow rates of decay (e.g. 2% per month). Very high levels of decay (2% per minute) will lead to overflows, and will need a more flexible implementation to support it.
|
||||||
|
|
||||||
|
The contract is written with frequent usage in mind. If used for tokens with low usage freqency (e.g. several days idle), it is recommended to run a continuous process triggering the changePeriod() contract call, to reduce the amount of exponential calculation the application of demurrage will trigger.
|
||||||
|
|
||||||
|
When changing the period, the supply for the consecutive period will be taken at the time of code execution, and thus not necessarily at the time when the redistribution period threshold was crossed.
|
8
ROADMAP
Normal file
8
ROADMAP
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
- 0.1.3
|
||||||
|
* Snapshot supply for crossed redistribution thresholds before minting new tokens.
|
||||||
|
- 0.1.4
|
||||||
|
* Implement natural logarithm
|
||||||
|
- 0.1.5
|
||||||
|
* Port changes from SingleNocap to SingleCap
|
||||||
|
- 0.2.0
|
||||||
|
* Make decay resolutions configurable, to support high levels of decay.
|
@ -1,3 +1,7 @@
|
|||||||
|
- 0.1.2
|
||||||
|
* Add token burn function
|
||||||
|
* Fix gas leak when calculating decay on period change
|
||||||
|
* Remove all but SingleNocap contract in make install
|
||||||
- 0.1.1
|
- 0.1.1
|
||||||
* Settable demurrage steps for apply demurrage cli tool
|
* Settable demurrage steps for apply demurrage cli tool
|
||||||
- 0.1.0
|
- 0.1.0
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -95,13 +95,6 @@ class TestDemurrage(EthTesterCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDemurrage, self).setUp()
|
super(TestDemurrage, self).setUp()
|
||||||
# token_deploy = TestTokenDeploy()
|
|
||||||
# self.settings = token_deploy.settings
|
|
||||||
# self.sink_address = token_deploy.sink_address
|
|
||||||
# self.start_block = token_deploy.start_block
|
|
||||||
# self.start_time = token_deploy.start_time
|
|
||||||
# self.default_supply = self.default_supply
|
|
||||||
# self.default_supply_cap = self.default_supply_cap
|
|
||||||
period = PERIOD
|
period = PERIOD
|
||||||
try:
|
try:
|
||||||
period = getattr(self, 'period')
|
period = getattr(self, 'period')
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = erc20-demurrage-token
|
name = erc20-demurrage-token
|
||||||
version = 0.1.1
|
version = 0.1.2
|
||||||
description = ERC20 token with redistributed continual demurrage
|
description = ERC20 token with redistributed continual demurrage
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
@ -33,7 +33,6 @@ class TestBurn(TestDemurrage):
|
|||||||
super(TestBurn, self).setUp()
|
super(TestBurn, self).setUp()
|
||||||
|
|
||||||
|
|
||||||
# tax_level = ppm
|
|
||||||
def deploy(self, tax_level=None):
|
def deploy(self, tax_level=None):
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
@ -52,6 +51,7 @@ class TestBurn(TestDemurrage):
|
|||||||
logg.info('deployed with mode {}'.format(self.mode))
|
logg.info('deployed with mode {}'.format(self.mode))
|
||||||
|
|
||||||
|
|
||||||
|
# Burn tokens and immediately check balances and supply
|
||||||
def test_burn_basic(self):
|
def test_burn_basic(self):
|
||||||
self.deploy()
|
self.deploy()
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
@ -92,6 +92,7 @@ class TestBurn(TestDemurrage):
|
|||||||
self.assertEqual(burned, 600000)
|
self.assertEqual(burned, 600000)
|
||||||
|
|
||||||
|
|
||||||
|
# burn tokens and check sink balance and supply after first redistribution period
|
||||||
def test_burned_redistribution(self):
|
def test_burned_redistribution(self):
|
||||||
self.deploy()
|
self.deploy()
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
@ -149,7 +150,7 @@ class TestBurn(TestDemurrage):
|
|||||||
self.assert_within_lower(bal, 500000000, 0.0025)
|
self.assert_within_lower(bal, 500000000, 0.0025)
|
||||||
|
|
||||||
|
|
||||||
|
# burn tokens and check sink and taxed balance and supply after first redistribution period
|
||||||
def test_burned_other_redistribution(self):
|
def test_burned_other_redistribution(self):
|
||||||
self.deploy()
|
self.deploy()
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
@ -218,6 +219,7 @@ class TestBurn(TestDemurrage):
|
|||||||
self.assert_within_lower(sink_bal, bal, 0.09) # TODO is this ok variance, 1.0 is ppm?
|
self.assert_within_lower(sink_bal, bal, 0.09) # TODO is this ok variance, 1.0 is ppm?
|
||||||
|
|
||||||
|
|
||||||
|
# verify expected results of balance and supply after multiple redistribution periods
|
||||||
def test_burn_accumulate(self):
|
def test_burn_accumulate(self):
|
||||||
self.deploy(tax_level=2/1000)
|
self.deploy(tax_level=2/1000)
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
|
@ -40,6 +40,7 @@ class TestDemurragePeriods(TestDemurrage):
|
|||||||
logg.info('deployed with mode {}'.format(self.mode))
|
logg.info('deployed with mode {}'.format(self.mode))
|
||||||
|
|
||||||
|
|
||||||
|
# verify that tax level calculation is in ppm as expected
|
||||||
def test_ppm(self):
|
def test_ppm(self):
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
@ -72,6 +73,7 @@ class TestDemurragePeriods(TestDemurrage):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# verify balances and supply after multiple demurrage periods
|
||||||
def test_over_time(self):
|
def test_over_time(self):
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
@ -355,16 +355,15 @@ contract DemurrageTokenSingleCap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recalculate the demurrage modifier for the new period
|
// Recalculate the demurrage modifier for the new period
|
||||||
|
// Note that the supply for the consecutive period will be taken at the time of code execution, and thus not necessarily at the time when the redistribution period threshold was crossed.
|
||||||
function changePeriod() public returns (bool) {
|
function changePeriod() public returns (bool) {
|
||||||
bytes32 currentRedistribution;
|
bytes32 currentRedistribution;
|
||||||
bytes32 nextRedistribution;
|
bytes32 nextRedistribution;
|
||||||
uint256 currentPeriod;
|
uint256 currentPeriod;
|
||||||
//uint256 currentDemurrageAmount;
|
|
||||||
uint256 lastDemurrageAmount;
|
uint256 lastDemurrageAmount;
|
||||||
bytes32 lastRedistribution;
|
bytes32 lastRedistribution;
|
||||||
uint256 nextRedistributionDemurrage;
|
uint256 nextRedistributionDemurrage;
|
||||||
uint256 demurrageCounts;
|
uint256 demurrageCounts;
|
||||||
//uint256 periodTimestamp;
|
|
||||||
uint256 nextPeriod;
|
uint256 nextPeriod;
|
||||||
|
|
||||||
applyDemurrage();
|
applyDemurrage();
|
||||||
@ -373,19 +372,10 @@ contract DemurrageTokenSingleCap {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calculate the decay from previous redistributino
|
||||||
lastRedistribution = redistributions[lastPeriod];
|
lastRedistribution = redistributions[lastPeriod];
|
||||||
currentPeriod = toRedistributionPeriod(currentRedistribution);
|
currentPeriod = toRedistributionPeriod(currentRedistribution);
|
||||||
nextPeriod = currentPeriod + 1;
|
nextPeriod = currentPeriod + 1;
|
||||||
//periodTimestamp = getPeriodTimeDelta(currentPeriod);
|
|
||||||
|
|
||||||
//currentDemurrageAmount = demurrageAmount;
|
|
||||||
|
|
||||||
//demurrageCounts = demurrageCycles(periodTimestamp);
|
|
||||||
//if (demurrageCounts > 0) {
|
|
||||||
// nextRedistributionDemurrage = growBy(currentDemurrageAmount, demurrageCounts);
|
|
||||||
//} else {
|
|
||||||
// nextRedistributionDemurrage = currentDemurrageAmount;
|
|
||||||
//}
|
|
||||||
lastDemurrageAmount = toRedistributionDemurrageModifier(lastRedistribution);
|
lastDemurrageAmount = toRedistributionDemurrageModifier(lastRedistribution);
|
||||||
demurrageCounts = periodDuration / 60;
|
demurrageCounts = periodDuration / 60;
|
||||||
nextRedistributionDemurrage = decayBy(lastDemurrageAmount, demurrageCounts);
|
nextRedistributionDemurrage = decayBy(lastDemurrageAmount, demurrageCounts);
|
||||||
@ -499,6 +489,7 @@ contract DemurrageTokenSingleCap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly and irretrievably burn tokens
|
// Explicitly and irretrievably burn tokens
|
||||||
|
// Only token minters can burn tokens
|
||||||
function burn(uint256 _value) public {
|
function burn(uint256 _value) public {
|
||||||
require(minter[msg.sender]);
|
require(minter[msg.sender]);
|
||||||
require(_value <= account[msg.sender]);
|
require(_value <= account[msg.sender]);
|
||||||
|
@ -33,6 +33,10 @@ test: all
|
|||||||
python ../python/tests/test_pure.py
|
python ../python/tests/test_pure.py
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
|
#cp -v DemurrageToken*.{json,bin} ../python/erc20_demurrage_token/data/
|
||||||
|
cp -v DemurrageTokenSingleNocap.{json,bin} ../python/erc20_demurrage_token/data/
|
||||||
|
|
||||||
|
install-broken: all
|
||||||
cp -v DemurrageToken*.{json,bin} ../python/erc20_demurrage_token/data/
|
cp -v DemurrageToken*.{json,bin} ../python/erc20_demurrage_token/data/
|
||||||
|
|
||||||
.PHONY: test install
|
.PHONY: test install
|
||||||
|
Reference in New Issue
Block a user