mirror of
git://holbrook.no/erc20-demurrage-token
synced 2024-11-25 17:26:45 +01:00
test basic passes
This commit is contained in:
parent
f785925eb5
commit
e74a9cb594
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -219,7 +219,7 @@ class TestBasic(TestDemurrageDefault):
|
|||||||
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
||||||
self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
|
|
||||||
self.backend.time_travel(self.start_time + 61)
|
self.backend.time_travel(self.start_time + (60 * 43200))
|
||||||
(tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
(tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
||||||
r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
o = c.to_base_amount(self.address, 1000, sender_address=self.accounts[0])
|
o = c.to_base_amount(self.address, 1000, sender_address=self.accounts[0])
|
||||||
|
@ -455,93 +455,92 @@ contract DemurrageTokenSingleCap {
|
|||||||
// Inflates the given amount according to the current demurrage modifier
|
// Inflates the given amount according to the current demurrage modifier
|
||||||
function toBaseAmount(uint256 _value) public view returns (uint256) {
|
function toBaseAmount(uint256 _value) public view returns (uint256) {
|
||||||
int128 r;
|
int128 r;
|
||||||
//return (_value * resolutionFactor) / (demurrageAmount * 10000000000);
|
r = ABDKMath64x64.div(ABDKMath64x64.fromUInt(_value), demurrageAmount);
|
||||||
r = ABDKMath64x64.mul(demurrageAmount, ABDKMath64x64.fromUInt(_value));
|
|
||||||
return ABDKMath64x64.toUInt(r);
|
return ABDKMath64x64.toUInt(r);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// // Implements ERC20, triggers tax and/or redistribution
|
// Implements ERC20, triggers tax and/or redistribution
|
||||||
// function approve(address _spender, uint256 _value) public returns (bool) {
|
function approve(address _spender, uint256 _value) public returns (bool) {
|
||||||
// uint256 baseValue;
|
uint256 baseValue;
|
||||||
//
|
|
||||||
// if (allowance[msg.sender][_spender] > 0) {
|
if (allowance[msg.sender][_spender] > 0) {
|
||||||
// require(_value == 0, 'ZERO_FIRST');
|
require(_value == 0, 'ZERO_FIRST');
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// changePeriod();
|
changePeriod();
|
||||||
//
|
|
||||||
// baseValue = toBaseAmount(_value);
|
baseValue = toBaseAmount(_value);
|
||||||
// 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;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Reduce allowance by amount
|
// Reduce allowance by amount
|
||||||
// function decreaseAllowance(address _spender, uint256 _value) public returns (bool) {
|
function decreaseAllowance(address _spender, uint256 _value) public returns (bool) {
|
||||||
// uint256 baseValue;
|
uint256 baseValue;
|
||||||
//
|
|
||||||
// baseValue = toBaseAmount(_value);
|
baseValue = toBaseAmount(_value);
|
||||||
// require(allowance[msg.sender][_spender] >= baseValue);
|
require(allowance[msg.sender][_spender] >= baseValue);
|
||||||
//
|
|
||||||
// changePeriod();
|
changePeriod();
|
||||||
//
|
|
||||||
// allowance[msg.sender][_spender] -= baseValue;
|
allowance[msg.sender][_spender] -= baseValue;
|
||||||
// emit Approval(msg.sender, _spender, allowance[msg.sender][_spender]);
|
emit Approval(msg.sender, _spender, allowance[msg.sender][_spender]);
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Increase allowance by amount
|
// Increase allowance by amount
|
||||||
// function increaseAllowance(address _spender, uint256 _value) public returns (bool) {
|
function increaseAllowance(address _spender, uint256 _value) public returns (bool) {
|
||||||
// uint256 baseValue;
|
uint256 baseValue;
|
||||||
//
|
|
||||||
// changePeriod();
|
changePeriod();
|
||||||
//
|
|
||||||
// baseValue = toBaseAmount(_value);
|
baseValue = toBaseAmount(_value);
|
||||||
//
|
|
||||||
// allowance[msg.sender][_spender] += baseValue;
|
allowance[msg.sender][_spender] += baseValue;
|
||||||
// emit Approval(msg.sender, _spender, allowance[msg.sender][_spender]);
|
emit Approval(msg.sender, _spender, allowance[msg.sender][_spender]);
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Implements ERC20, triggers tax and/or redistribution
|
// Implements ERC20, triggers tax and/or redistribution
|
||||||
// function transfer(address _to, uint256 _value) public returns (bool) {
|
function transfer(address _to, uint256 _value) public returns (bool) {
|
||||||
// uint256 baseValue;
|
uint256 baseValue;
|
||||||
// bool result;
|
bool result;
|
||||||
//
|
|
||||||
// changePeriod();
|
changePeriod();
|
||||||
//
|
|
||||||
// baseValue = toBaseAmount(_value);
|
baseValue = toBaseAmount(_value);
|
||||||
// result = transferBase(msg.sender, _to, baseValue);
|
result = transferBase(msg.sender, _to, baseValue);
|
||||||
// emit Transfer(msg.sender, _to, _value);
|
emit Transfer(msg.sender, _to, _value);
|
||||||
// return result;
|
return result;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Implements ERC20, triggers tax and/or redistribution
|
// Implements ERC20, triggers tax and/or redistribution
|
||||||
// function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
||||||
// uint256 baseValue;
|
uint256 baseValue;
|
||||||
// bool result;
|
bool result;
|
||||||
//
|
|
||||||
// changePeriod();
|
changePeriod();
|
||||||
//
|
|
||||||
// baseValue = toBaseAmount(_value);
|
baseValue = toBaseAmount(_value);
|
||||||
// require(allowance[_from][msg.sender] >= baseValue);
|
require(allowance[_from][msg.sender] >= baseValue);
|
||||||
//
|
|
||||||
// allowance[_from][msg.sender] -= baseValue;
|
allowance[_from][msg.sender] -= baseValue;
|
||||||
// result = transferBase(_from, _to, baseValue);
|
result = transferBase(_from, _to, baseValue);
|
||||||
//
|
|
||||||
// emit Transfer(_from, _to, _value);
|
emit Transfer(_from, _to, _value);
|
||||||
// return result;
|
return result;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // ERC20 transfer backend for transfer, transferFrom
|
// ERC20 transfer backend for transfer, transferFrom
|
||||||
// function transferBase(address _from, address _to, uint256 _value) private returns (bool) {
|
function transferBase(address _from, address _to, uint256 _value) private returns (bool) {
|
||||||
// uint256 period;
|
uint256 period;
|
||||||
//
|
|
||||||
// decreaseBaseBalance(_from, _value);
|
decreaseBaseBalance(_from, _value);
|
||||||
// increaseBaseBalance(_to, _value);
|
increaseBaseBalance(_to, _value);
|
||||||
//
|
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Implements EIP173
|
// Implements EIP173
|
||||||
function transferOwnership(address _newOwner) public returns (bool) {
|
function transferOwnership(address _newOwner) public returns (bool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user