mirror of
git://holbrook.no/erc20-demurrage-token
synced 2024-09-28 21:07:21 +02:00
Compare commits
3 Commits
v0.5.3-bet
...
dev-0.5.6
Author | SHA1 | Date | |
---|---|---|---|
|
a40385a5a0 | ||
|
d7051b26c0 | ||
|
14fb2fe8ea |
@ -208,8 +208,9 @@ and the lower 64 bits represents the decimals part, each consecutive
|
|||||||
lesser bit halving the value of the previous bit.
|
lesser bit halving the value of the previous bit.
|
||||||
|
|
||||||
For example, The byte value `00000000 00000002 a0000000 00000000`,
|
For example, The byte value `00000000 00000002 a0000000 00000000`,
|
||||||
representing a zero-stripped binary value of $10.101$, translates to the
|
representing a zero-stripped binary value of $10.101$. This translates
|
||||||
(base 10) decimal value $2.625$.
|
to the (base 10) decimal value $2.625$. The decimal part is calculated
|
||||||
|
as, from left to right: $(1 * 0.5) + (0 * 0.25) + (1 * 0.125)$.
|
||||||
|
|
||||||
#### Calculating the demurrage parameter
|
#### Calculating the demurrage parameter
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ The initial @emph{Sink Address}. The address may be altered as long as the @code
|
|||||||
|
|
||||||
The @emph{input parameter} to the contract is a 128-bit positive fixed-point number, where the most significant 64 bits represent the integer part, and the lower 64 bits represents the decimals part, each consecutive lesser bit halving the value of the previous bit.
|
The @emph{input parameter} to the contract is a 128-bit positive fixed-point number, where the most significant 64 bits represent the integer part, and the lower 64 bits represents the decimals part, each consecutive lesser bit halving the value of the previous bit.
|
||||||
|
|
||||||
For example, The byte value @code{00000000 00000002 a0000000 00000000}, representing a zero-stripped binary value of @math{10.101}, translates to the (base 10) decimal value @math{2.625}.
|
For example, The byte value @code{00000000 00000002 a0000000 00000000}, representing a zero-stripped binary value of @math{10.101}. This translates to the (base 10) decimal value @math{2.625}. The decimal part is calculated as, from left to right: @math{(1 * 0.5) + (0 * 0.25) + (1 * 0.125)}.
|
||||||
|
|
||||||
@subsubsection Calculating the demurrage parameter
|
@subsubsection Calculating the demurrage parameter
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
- 0.5.5
|
||||||
|
* Make allowance method public
|
||||||
|
- 0.5.4
|
||||||
|
* Add Transfer() event emission to sweep() in contract
|
||||||
- 0.5.3
|
- 0.5.3
|
||||||
* Add texinfo documentation
|
* Add texinfo documentation
|
||||||
* Add man page for publish tool
|
* Add man page for publish tool
|
||||||
|
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
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = erc20-demurrage-token
|
name = erc20-demurrage-token
|
||||||
version = 0.5.3
|
version = 0.5.6
|
||||||
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
|
||||||
|
@ -308,6 +308,30 @@ class TestBasic(TestDemurrageDefault):
|
|||||||
self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_approve_max(self):
|
||||||
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
(tx_hash, o) = c.approve(self.address, self.accounts[0], self.accounts[1], int.from_bytes(b'\xff' * 32, byteorder='big'))
|
||||||
|
self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
(tx_hash, o) = c.approve(self.address, self.accounts[0], self.accounts[1], 0)
|
||||||
|
self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
self.backend.time_travel(self.start_time + (60 * 60 * 24 * 365 * 10))
|
||||||
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
(tx_hash, o) = c.approve(self.address, self.accounts[0], self.accounts[1], int.from_bytes(b'\xff' * 32, byteorder='big'))
|
||||||
|
self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
|
||||||
def test_transfer_from(self):
|
def test_transfer_from(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)
|
||||||
|
@ -6,6 +6,8 @@ import "aux/ABDKMath64x64.sol";
|
|||||||
|
|
||||||
contract DemurrageTokenSingleNocap {
|
contract DemurrageTokenSingleNocap {
|
||||||
|
|
||||||
|
uint256 constant VALUE_LIMIT = 1 << 63;
|
||||||
|
|
||||||
struct redistributionItem {
|
struct redistributionItem {
|
||||||
uint32 period;
|
uint32 period;
|
||||||
uint72 value;
|
uint72 value;
|
||||||
@ -73,7 +75,7 @@ contract DemurrageTokenSingleNocap {
|
|||||||
mapping (address => bool) minter;
|
mapping (address => bool) minter;
|
||||||
|
|
||||||
// Storage for ERC20 approve/transferFrom methods
|
// Storage for ERC20 approve/transferFrom methods
|
||||||
mapping (address => mapping (address => uint256 ) ) allowance; // holder -> spender -> amount (amount is subject to demurrage)
|
mapping (address => mapping (address => uint256 ) ) public allowance; // holder -> spender -> amount (amount is subject to demurrage)
|
||||||
|
|
||||||
// Address to send unallocated redistribution tokens
|
// Address to send unallocated redistribution tokens
|
||||||
address public sinkAddress;
|
address public sinkAddress;
|
||||||
@ -253,7 +255,7 @@ contract DemurrageTokenSingleNocap {
|
|||||||
|
|
||||||
// Implements Writer
|
// Implements Writer
|
||||||
function isWriter(address _minter) public view returns(bool) {
|
function isWriter(address _minter) public view returns(bool) {
|
||||||
return minter[_minter];
|
return minter[_minter] || _minter == owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements ERC20
|
/// Implements ERC20
|
||||||
@ -315,6 +317,7 @@ contract DemurrageTokenSingleNocap {
|
|||||||
v = account[msg.sender];
|
v = account[msg.sender];
|
||||||
account[msg.sender] = 0;
|
account[msg.sender] = 0;
|
||||||
account[_account] += v;
|
account[_account] += v;
|
||||||
|
emit Transfer(msg.sender, _account, v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +599,14 @@ contract DemurrageTokenSingleNocap {
|
|||||||
|
|
||||||
changePeriod();
|
changePeriod();
|
||||||
|
|
||||||
baseValue = toBaseAmount(_value);
|
// dex code will attempt uint256max approve, but contract cannot handle that size
|
||||||
|
// truncate to biggest possible value
|
||||||
|
if (_value <= VALUE_LIMIT) {
|
||||||
|
baseValue = toBaseAmount(_value);
|
||||||
|
} else {
|
||||||
|
baseValue = VALUE_LIMIT;
|
||||||
|
}
|
||||||
|
|
||||||
allowance[msg.sender][_spender] = baseValue;
|
allowance[msg.sender][_spender] = baseValue;
|
||||||
emit Approval(msg.sender, _spender, _value);
|
emit Approval(msg.sender, _spender, _value);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user