Add rate of change definition
This commit is contained in:
parent
0fba11aeaf
commit
80671fdfaa
52
README.md
52
README.md
@ -133,7 +133,7 @@ Attached to `ERC20` and `ERC721` tokens that may be *burned*.
|
||||
Implements the `burn(...)` part of `ERC5679` for interoperability.
|
||||
|
||||
ERC165 Interface identifier
|
||||
bc4babdd
|
||||
b1110c1b
|
||||
|
||||
Solidity interface definition
|
||||
interface IBurner {
|
||||
@ -144,10 +144,11 @@ Solidity interface definition
|
||||
function burn(address _from, uint256 _amount, bytes calldata _data) external;
|
||||
|
||||
// Burn given amount of tokens held by signer.
|
||||
function burn(uint256 _burn) external returns (bool);
|
||||
function burn(uint256 _amount) external returns (bool);
|
||||
|
||||
// Burn all tokens held by signer.
|
||||
function burn() external returns (bool);
|
||||
// Returns the amount of tokens burned.
|
||||
function burn() external returns (uint256);
|
||||
|
||||
// Total amount of tokens that have been burned.
|
||||
function totalBurned() external returns (uint256);
|
||||
@ -588,6 +589,45 @@ Solidity interface definition
|
||||
Example implementation
|
||||
<https://git.grassecon.net/cicnet/erc20-demurrage-token.git>
|
||||
|
||||
### TokenRateChange
|
||||
|
||||
Enables detection of properties for CIC tokens that change value over
|
||||
time, e.g. through demurrage.
|
||||
|
||||
It allows defining the granularity of the rate of change, aswell as a
|
||||
frequency for which the rate of change is applied.
|
||||
|
||||
A method for canonical value change calculations is also provided.
|
||||
|
||||
ERC165 Interface identifier
|
||||
b716af03
|
||||
|
||||
Solidity interface definition
|
||||
interface ITokenChangeRate {
|
||||
// Time unit resolution for rate of change.
|
||||
// A value of 0 indicates no rate of change,
|
||||
function changeTimeUnit() external view returns(uint256);
|
||||
|
||||
// Rate of change per changeTimeUnit(), signed integer.
|
||||
// An effective value of 0 indicates no rate of change.
|
||||
function changeRate() external view returns (int256);
|
||||
|
||||
// Number of decimals with which the changeRate is defined.
|
||||
// changeRate() should be divided by 10 ** changeRateDecimals() to obtain effective value
|
||||
function changeRateDecimals() external view returns(uint8);
|
||||
|
||||
// Timestamp from when rate of change should be applied.
|
||||
// A value of 0 indicates no rate of change,
|
||||
function changeStartTime() external view returns(uint256);
|
||||
|
||||
// Calculate value with change rate applied for given amount of time units.
|
||||
// Will calculate compounded change over the given amount of time units
|
||||
function applyChange(int256 _value, uint256 _changeTimeUnits) external view returns(int256);
|
||||
}
|
||||
|
||||
Reference implementations
|
||||
- <git://holbrook.no/erc20-demurrage-token.git>
|
||||
|
||||
### TokenVend
|
||||
|
||||
This interface defines the mechanism for which a specific ERC20 token
|
||||
@ -633,7 +673,7 @@ Voted tokens **SHOULD** be locked until the voting has finalized.
|
||||
Finalization of voting should be callable by anyone.
|
||||
|
||||
ERC165 Interface identifier
|
||||
28091366
|
||||
f2e0bfeb
|
||||
|
||||
Solidity interface definition
|
||||
interface ITokenVote {
|
||||
@ -655,8 +695,8 @@ Solidity interface definition
|
||||
// * _blockWait blocks from now.
|
||||
function propose(bytes32 _description, uint256 _blockWait, uint24 _targetVotePpm) external returns (uint256);
|
||||
|
||||
// Same as propose(...), but provide options to vote on.
|
||||
function proposeMulti(bytes32 _description, bytes32[] memory _options, uint256 _blockWait, uint24 _targetVotePpm) external returns (uint256);
|
||||
// Add a voting option to a proposal
|
||||
function addOption(uint256 _proposalIdx, bytes32 _description) external;
|
||||
|
||||
// Get number of options available for the proposal.
|
||||
// This decides the boundary of the index that can be used with voteOptions(...)
|
||||
|
@ -74,6 +74,8 @@ The following well-known solidity interfaces are partially implemented in CIC na
|
||||
|
||||
@include seal.sol.texi
|
||||
|
||||
@include tokenratechange.sol.texi
|
||||
|
||||
@include tokenvend.sol.texi
|
||||
|
||||
@include tokenvote.sol.texi
|
||||
|
19
doc/texinfo/tokenratechange.sol.texi
Normal file
19
doc/texinfo/tokenratechange.sol.texi
Normal file
@ -0,0 +1,19 @@
|
||||
@subsection TokenRateChange
|
||||
|
||||
Enables detection of properties for CIC tokens that change value over time, e.g. through demurrage.
|
||||
|
||||
It allows defining the granularity of the rate of change, aswell as a frequency for which the rate of change is applied.
|
||||
|
||||
A method for canonical value change calculations is also provided.
|
||||
|
||||
@table @dfn
|
||||
@item ERC165 Interface identifier
|
||||
@include ../../build/TokenRateChange.interface
|
||||
@item Solidity interface definition
|
||||
@include ../../build/contract_TokenRateChange.texi
|
||||
@item Reference implementations
|
||||
@itemize
|
||||
@item
|
||||
@uref{git://holbrook.no/erc20-demurrage-token.git,}
|
||||
@end itemize
|
||||
@end table
|
@ -133,7 +133,7 @@ Attached to `ERC20` and `ERC721` tokens that may be *burned*.
|
||||
Implements the `burn(...)` part of `ERC5679` for interoperability.
|
||||
|
||||
ERC165 Interface identifier
|
||||
bc4babdd
|
||||
b1110c1b
|
||||
|
||||
Solidity interface definition
|
||||
interface IBurner {
|
||||
@ -144,10 +144,11 @@ Solidity interface definition
|
||||
function burn(address _from, uint256 _amount, bytes calldata _data) external;
|
||||
|
||||
// Burn given amount of tokens held by signer.
|
||||
function burn(uint256 _burn) external returns (bool);
|
||||
function burn(uint256 _amount) external returns (bool);
|
||||
|
||||
// Burn all tokens held by signer.
|
||||
function burn() external returns (bool);
|
||||
// Returns the amount of tokens burned.
|
||||
function burn() external returns (uint256);
|
||||
|
||||
// Total amount of tokens that have been burned.
|
||||
function totalBurned() external returns (uint256);
|
||||
@ -588,6 +589,45 @@ Solidity interface definition
|
||||
Example implementation
|
||||
<https://git.grassecon.net/cicnet/erc20-demurrage-token.git>
|
||||
|
||||
### TokenRateChange
|
||||
|
||||
Enables detection of properties for CIC tokens that change value over
|
||||
time, e.g. through demurrage.
|
||||
|
||||
It allows defining the granularity of the rate of change, aswell as a
|
||||
frequency for which the rate of change is applied.
|
||||
|
||||
A method for canonical value change calculations is also provided.
|
||||
|
||||
ERC165 Interface identifier
|
||||
b716af03
|
||||
|
||||
Solidity interface definition
|
||||
interface ITokenChangeRate {
|
||||
// Time unit resolution for rate of change.
|
||||
// A value of 0 indicates no rate of change,
|
||||
function changeTimeUnit() external view returns(uint256);
|
||||
|
||||
// Rate of change per changeTimeUnit(), signed integer.
|
||||
// An effective value of 0 indicates no rate of change.
|
||||
function changeRate() external view returns (int256);
|
||||
|
||||
// Number of decimals with which the changeRate is defined.
|
||||
// changeRate() should be divided by 10 ** changeRateDecimals() to obtain effective value
|
||||
function changeRateDecimals() external view returns(uint8);
|
||||
|
||||
// Timestamp from when rate of change should be applied.
|
||||
// A value of 0 indicates no rate of change,
|
||||
function changeStartTime() external view returns(uint256);
|
||||
|
||||
// Calculate value with change rate applied for given amount of time units.
|
||||
// Will calculate compounded change over the given amount of time units
|
||||
function applyChange(int256 _value, uint256 _changeTimeUnits) external view returns(int256);
|
||||
}
|
||||
|
||||
Reference implementations
|
||||
- <git://holbrook.no/erc20-demurrage-token.git>
|
||||
|
||||
### TokenVend
|
||||
|
||||
This interface defines the mechanism for which a specific ERC20 token
|
||||
@ -633,7 +673,7 @@ Voted tokens **SHOULD** be locked until the voting has finalized.
|
||||
Finalization of voting should be callable by anyone.
|
||||
|
||||
ERC165 Interface identifier
|
||||
28091366
|
||||
f2e0bfeb
|
||||
|
||||
Solidity interface definition
|
||||
interface ITokenVote {
|
||||
@ -655,8 +695,8 @@ Solidity interface definition
|
||||
// * _blockWait blocks from now.
|
||||
function propose(bytes32 _description, uint256 _blockWait, uint24 _targetVotePpm) external returns (uint256);
|
||||
|
||||
// Same as propose(...), but provide options to vote on.
|
||||
function proposeMulti(bytes32 _description, bytes32[] memory _options, uint256 _blockWait, uint24 _targetVotePpm) external returns (uint256);
|
||||
// Add a voting option to a proposal
|
||||
function addOption(uint256 _proposalIdx, bytes32 _description) external;
|
||||
|
||||
// Get number of options available for the proposal.
|
||||
// This decides the boundary of the index that can be used with voteOptions(...)
|
||||
|
29
solidity/TokenRateChange.sol
Normal file
29
solidity/TokenRateChange.sol
Normal file
@ -0,0 +1,29 @@
|
||||
pragma solidity >=0.6.12;
|
||||
|
||||
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
// File-version: 1
|
||||
|
||||
// Methods to detect tokens that are subject to continuous change, and
|
||||
|
||||
interface ITokenChangeRate {
|
||||
// Time unit resolution for rate of change.
|
||||
// A value of 0 indicates no rate of change,
|
||||
function changeTimeUnit() external view returns(uint256);
|
||||
|
||||
// Rate of change per changeTimeUnit(), signed integer.
|
||||
// An effective value of 0 indicates no rate of change.
|
||||
function changeRate() external view returns (int256);
|
||||
|
||||
// Number of decimals with which the changeRate is defined.
|
||||
// changeRate() should be divided by 10 ** changeRateDecimals() to obtain effective value
|
||||
function changeRateDecimals() external view returns(uint8);
|
||||
|
||||
// Timestamp from when rate of change should be applied.
|
||||
// A value of 0 indicates no rate of change,
|
||||
function changeStartTime() external view returns(uint256);
|
||||
|
||||
// Calculate value with change rate applied for given amount of time units.
|
||||
// Will calculate compounded change over the given amount of time units
|
||||
function applyChange(int256 _value, uint256 _changeTimeUnits) external view returns(int256);
|
||||
}
|
@ -2,7 +2,7 @@ pragma solidity >=0.6.12;
|
||||
|
||||
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
// File-version: 1
|
||||
// File-version: 2
|
||||
|
||||
|
||||
interface ITokenVote {
|
||||
@ -24,8 +24,8 @@ interface ITokenVote {
|
||||
// * _blockWait blocks from now.
|
||||
function propose(bytes32 _description, uint256 _blockWait, uint24 _targetVotePpm) external returns (uint256);
|
||||
|
||||
// Same as propose(...), but provide options to vote on.
|
||||
function proposeMulti(bytes32 _description, bytes32[] memory _options, uint256 _blockWait, uint24 _targetVotePpm) external returns (uint256);
|
||||
// Add a voting option to a proposal
|
||||
function addOption(uint256 _proposalIdx, bytes32 _description) external;
|
||||
|
||||
// Get number of options available for the proposal.
|
||||
// This decides the boundary of the index that can be used with voteOptions(...)
|
||||
|
Loading…
Reference in New Issue
Block a user