2021-02-03 15:22:45 +01:00
# RedistributedDemurrageToken
2021-02-04 08:41:01 +01:00
## Use Case
* Network / Basic Income Token
* 100 Sarafu is distributed to anyone in Kenya after user validation by the owner of a faucet which mints new Sarafu.
2021-02-04 13:43:04 +01:00
* Validated users are those that validate their phone number in Kenya.
* A monthly Sarafu holding tax (demurrage) of 2% is deducted from users
* Each month (after a number of blocks) the total amount tax is distributed evenly out to _active_ users.
* any single transaction by a user is considered _active_ (heartbeat) (possibly add minimum size of heartbeat in constructor (TODO))
2021-02-04 15:02:12 +01:00
* This is meant to result in a disincentivization to hold (hodl) the Sarafu token and increase its usage as a medium of exchange rather than a store of value.
* This token can be added to liquidity pools with other ERC20 tokens and or Community Inclusion Currencies (CICs) - and thereby act as a central network token and connect various tokens and CICs together.
2021-02-04 08:41:01 +01:00
2021-02-04 13:43:04 +01:00
## Variables
2021-02-04 08:41:01 +01:00
2021-02-04 13:43:04 +01:00
* Inputs to Constructor (Set only once during contract deployment can't be changed )
2021-02-04 15:02:12 +01:00
* `Demurrage` aka Decay amount: A percentage of token supply that will be charged once per - aka `period` and evenly redistributed to _active_ users
* Demurrage Period (blocks)- aka `period` : The number of blocks (equivalent to a time frame) over which a new Holding Fee is applied and redistributed.
2021-02-04 13:43:04 +01:00
* Inflated Balance: The inflated balance of each user is stored for bookkeeping.
* Number of Decimals: Resolution on token (TODO) (Default 6)
2021-02-04 14:04:29 +01:00
* Minimum Activity Volume: (TODO) the minimum transaction amount to be considered active
2021-02-04 14:02:31 +01:00
* Sink Token Address: Rounding errors and if no one trades the tax goes to this address
2021-02-04 08:41:01 +01:00
2021-02-03 15:22:45 +01:00
## Ownership
* Contract creator is owner
2021-02-04 13:43:04 +01:00
* Ownership can be transferred (also to ownership void contract "no more changes can be made")
2021-02-03 15:22:45 +01:00
## Mint
* Owner can add minters
2021-02-04 13:43:04 +01:00
- A faucet contract would be a minter and choose the amount of tokens to mint and distribute to new _validated_ users.
- The interface says the amount and is at the caller's discretion per contract call. _validation_ is outside of this contract.
2021-02-03 15:22:45 +01:00
* Minters can mint any amount
## Demurrage
2021-02-04 14:02:31 +01:00
* Holding Tax (`demurrage`) is applied when a **mint** or **transfer** is triggered for first time/block in a new `period` ; (it can also be triggered explicitly)
2021-02-03 15:22:45 +01:00
- Supply _stays the same_ .
2021-02-04 13:43:04 +01:00
- Updates `demurrageModifier` which represents the accumulated tax value and is an exponential decay step (of size `demurrage` ) for each `period`
- `demurrageModifier = (1-demurrage)^period`
- e.g. a `demurrage` of 2% at a `period` of 0 would be give a `demurrageModifier= (1-0.02)^0 = 1-1 = 0` .
- e.g. a `demurrage` of 2% at a `period` of 1 would be give a `demurrageModifier = (1-0.02)^1 = 0.98` .
- e.g. a `demurrage` of 2% at a `period` of 2 would be give a `demurrageModifier = (1-0.02)^2 = 0.9604` .
2021-02-03 15:22:45 +01:00
* All client-facing values (_balance output_ , _transfer inputs_ ) are adjusted with `demurrageModifier` .
2021-02-04 13:43:04 +01:00
- e.g. `_balance output_ = user_balance - user_balance * demurrageModifier`
2021-02-03 15:22:45 +01:00
* Edge case: `approve` call, which may be called on either side of a period.
## Redistribution
* One redistribution entry is added to storage for each period;
- When `mint` is triggered, the new totalsupply is stored to the entry
2021-02-04 13:43:04 +01:00
- When `transfer` is triggered, and the account did not yet participate in the `period` , the entry's participant count is incremented.
2021-02-03 15:22:45 +01:00
* Account must have "participated" in a period to be redistribution beneficiary.
* Redistribution is applied when an account triggers a **transfer** for the first time in a new period;
2021-02-04 13:43:04 +01:00
- Check if user has participated in `period` . (_active_ user heartbeat)
- Each _active_ user balance is increased by `(total supply at end of period * demurrageModifier ) / number_of_active_participants` via minting
- Participation field is zeroed out for that user.
2021-02-03 15:22:45 +01:00
* Fractions must be rounded down (TODO)
2021-02-04 13:43:04 +01:00
- Remainder is "dust" and should be sent to a dedicated "sink" token address (TODO)
- If no one is _active_ all taxes go to the same sink address
2021-02-03 15:22:45 +01:00
## Data structures
* One word per account:
- bits 000-159: value
- bits 160-255: period
- (we have more room here in case we want to cram something else in)
* One word per redistribution period:
- bits 000-055: period
- bits 056-215: supply
- bits 216-253: participant count
2021-02-04 15:02:12 +01:00
- bits 254: Set if individual redistribution amounts are fractions (TODO)
2021-02-03 15:22:45 +01:00
- bits 255: Set if "dust" has been transferred to sink (TODO)
## QA
* Basic python tests in place
* How to determine and generate test vectors, and how to adapt them to scripts.
* Audit sources?