mirror of
git://holbrook.no/erc20-demurrage-token
synced 2024-11-16 14:16:46 +01:00
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
|
||||
* Settable demurrage steps for apply demurrage cli tool
|
||||
- 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):
|
||||
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
|
||||
try:
|
||||
period = getattr(self, 'period')
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = erc20-demurrage-token
|
||||
version = 0.1.1
|
||||
version = 0.1.2
|
||||
description = ERC20 token with redistributed continual demurrage
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
|
@ -33,7 +33,6 @@ class TestBurn(TestDemurrage):
|
||||
super(TestBurn, self).setUp()
|
||||
|
||||
|
||||
# tax_level = ppm
|
||||
def deploy(self, tax_level=None):
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
@ -51,7 +50,8 @@ class TestBurn(TestDemurrage):
|
||||
|
||||
logg.info('deployed with mode {}'.format(self.mode))
|
||||
|
||||
|
||||
|
||||
# Burn tokens and immediately check balances and supply
|
||||
def test_burn_basic(self):
|
||||
self.deploy()
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
@ -92,6 +92,7 @@ class TestBurn(TestDemurrage):
|
||||
self.assertEqual(burned, 600000)
|
||||
|
||||
|
||||
# burn tokens and check sink balance and supply after first redistribution period
|
||||
def test_burned_redistribution(self):
|
||||
self.deploy()
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
@ -149,7 +150,7 @@ class TestBurn(TestDemurrage):
|
||||
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):
|
||||
self.deploy()
|
||||
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?
|
||||
|
||||
|
||||
# verify expected results of balance and supply after multiple redistribution periods
|
||||
def test_burn_accumulate(self):
|
||||
self.deploy(tax_level=2/1000)
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
|
@ -40,6 +40,7 @@ class TestDemurragePeriods(TestDemurrage):
|
||||
logg.info('deployed with mode {}'.format(self.mode))
|
||||
|
||||
|
||||
# verify that tax level calculation is in ppm as expected
|
||||
def test_ppm(self):
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
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):
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
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
|
||||
// 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) {
|
||||
bytes32 currentRedistribution;
|
||||
bytes32 nextRedistribution;
|
||||
uint256 currentPeriod;
|
||||
//uint256 currentDemurrageAmount;
|
||||
uint256 lastDemurrageAmount;
|
||||
bytes32 lastRedistribution;
|
||||
uint256 nextRedistributionDemurrage;
|
||||
uint256 demurrageCounts;
|
||||
//uint256 periodTimestamp;
|
||||
uint256 nextPeriod;
|
||||
|
||||
applyDemurrage();
|
||||
@ -373,23 +372,14 @@ contract DemurrageTokenSingleCap {
|
||||
return false;
|
||||
}
|
||||
|
||||
// calculate the decay from previous redistributino
|
||||
lastRedistribution = redistributions[lastPeriod];
|
||||
currentPeriod = toRedistributionPeriod(currentRedistribution);
|
||||
nextPeriod = currentPeriod + 1;
|
||||
//periodTimestamp = getPeriodTimeDelta(currentPeriod);
|
||||
|
||||
//currentDemurrageAmount = demurrageAmount;
|
||||
|
||||
//demurrageCounts = demurrageCycles(periodTimestamp);
|
||||
//if (demurrageCounts > 0) {
|
||||
// nextRedistributionDemurrage = growBy(currentDemurrageAmount, demurrageCounts);
|
||||
//} else {
|
||||
// nextRedistributionDemurrage = currentDemurrageAmount;
|
||||
//}
|
||||
lastDemurrageAmount = toRedistributionDemurrageModifier(lastRedistribution);
|
||||
demurrageCounts = periodDuration / 60;
|
||||
nextRedistributionDemurrage = decayBy(lastDemurrageAmount, demurrageCounts);
|
||||
|
||||
|
||||
nextRedistribution = toRedistribution(0, nextRedistributionDemurrage, totalSupply(), nextPeriod);
|
||||
redistributions.push(nextRedistribution);
|
||||
|
||||
@ -499,6 +489,7 @@ contract DemurrageTokenSingleCap {
|
||||
}
|
||||
|
||||
// Explicitly and irretrievably burn tokens
|
||||
// Only token minters can burn tokens
|
||||
function burn(uint256 _value) public {
|
||||
require(minter[msg.sender]);
|
||||
require(_value <= account[msg.sender]);
|
||||
|
@ -33,6 +33,10 @@ test: all
|
||||
python ../python/tests/test_pure.py
|
||||
|
||||
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/
|
||||
|
||||
.PHONY: test install
|
||||
|
Loading…
Reference in New Issue
Block a user