# OGC Diario UBI
## Problems
### UBI needs a focal point
We need to make it easy for people everywhere to consciously and directly support Universal Basic Income. We can't wait for governments to implement UBI.
### National currencies have failed
National currencies prioritize national goals over human needs. Competing currencies inefficiently use banks and other intermediaries for exchange. Trade is impeded and political conflicts arise through the international use of national currencies.
## Objective
Focus the global consciousness on UBI through a fairly-distributed currency that's global, democratic, useful for everyday expenses, and avoids the problems inherent in national currencies.
### The role of money councils
A money council [has important responsibilites](#Money-Councils) related to the ongoing deployment of *our global currency* (OGC). It can coexist with other [money councils](#Money-Councils), providing alternatives in case of corruption or mismanagement.
## OGC features
* Participants are oracles.
* [Aura](https://brightid.gitbook.io/aura) ensures the honesty of [participant-oracles](#Participant-oracles).
* Multichain (using participant-oracles instead of bridges).
* Prices are measured in terms of the median global cost of living.
* Costs of living are submitted by participant-oracles.
* Median vote is used to aggregate submissions.
* Distributed via [Unitap](#UBI-fund).
* Aura ensures fair distribution.
* [The goal](#Ramp-up) is for each person to claim one [Diario](#Pricing-in-Diario) (the global median daily cost of living) per day.
* [Value held in OGC is protected against loss](#Locking-tokens-for-downside-protection) from people paying living expenses in outside currencies.
* Protection is proportional to how much outside currency is used for living expenses.
* Cost of living and outside currency information is submitted by participant-oracles.
## OGC operation
*"[Our Global Currency](https://drive.google.com/file/d/1ATvVD5he8ZIovT3YXinrBgTL0HO2e1y3/view?usp=drive_link)" is a presentation with examples and diagrams.*
### Smart contract
OGC is created as a smart contract token and deployed to multiple chains.
#### Participant-oracles
Each person (verified with Aura) submits to all chains the daily average of their cost of living, priced in OGC, as well as the proportion of expenses they needed to pay in outside currency (not OGC). A convenient time to update this submission is when a person makes a purchase.
The smart contracts on each chain keep a running median of these submissions. The median for each day is finalized at the end of the day and used to calculate inflation (or deflation) and downside protection. See the footnote[^runningMedian] for an outline of a gas-efficient way to compute a running median.
Smart contracts also keep a running median (and daily value) of the proportion of outside currency used, which is also used to calculate downside protection.
[Money councils](#Money-Councils) approve the software for tracking personal costs of living and preparing smart contract submissions. They also determine the components included in the cost of living.
[Participant-oracles collectively earn the majority of OGC deployed on a new network as compensation for their participation](#Preminted-tokens).
#### Locking tokens for downside protection
Once a day, a user may claim a downside protection payment if the median global cost of living (priced in OGC) went up the previous day (compared to two days ago) and they locked tokens on that day or before.
##### Eligible locked tokens
When a user locks tokens, the number they locked that day permanently goes up, while the total number they currently have locked temporarily goes up. The number of eligible tokens is the total number locked minus the number locked on the day of the claim.
Transferring tokens automatically claims any unclaimed downside protection payments for the sending address for the previous day and then unlocks them and transfers them. This means the sender of locked tokens can claim downside protection for the previous day and the receiver--if they lock the tokens upon receipt--can claim downside protection tomorrow for the current day (if the median global cost of living goes up on the relevant days).
##### Claim amount
The claim amount is the number of eligible locked tokens, times the increase in the median global cost of living in OGC between two days ago and yesterday, times the proportion of global living expenses that used outside currency.
To maximize the amount received, OGC holders should claim downside protection payments the day after price inflation.
To give an example, if X has locked 10,000 tokens yesterday or before, and the median global cost of living (in OGC) has increased by 0.1% (between two days ago and yesterday) and 10% of the median global cost of living expenses are priced in an outside currency (USD, GBP, EUR, etc.), then X can claim 10,000 * 0.001 * 0.1 = 1 OGC.
## Prices for goods and services
### Pricing in Diario
Diario isn't a currency; it's a convenient way to set prices using a cost of living index. One Diario is the median global cost of living for one person for the most recently completed day. For example, a meal costing 0.1 Diario would use 10% of the median global daily living expenses for a person.
If a merchant sets prices in Diario, they won't need to update the prices if there's a stable rate of price inflation or deflation in OGC. If inflation does temporarily change, but a merchant is slow to change their prices, prices in Diario are more likely to become correct again than prices in OGC.
Software can help merchants accept OGC tokens while setting prices in Diario.
Merchants accepting Diario can [lock income against price downswings](#Locking-tokens-for-downside-protection) until they can buy inputs for their products.
### Costs requiring outside currency
A producer or seller may have costs that must be paid for with a currency other than OGC. Such costs might include parts, shipping, and taxes.
A seller may pass these costs onto buyers as split prices, e.g. 1 Diario + $50. This allows participant oracles to report on the market's need for outside currency in their personal costs of living submissions.
## Universal Basic Income
### UBI fund
[Unitap](https://unitap.app) is a universal distributor and will be used to distribute the UBI fund.
Each [Aura-verified](https://brightid.gitbook.io/aura) person can use Unitap to claim their UBI to any blockchain where OGC is deployed.
### Ramp up
Each person on Earth can claim one [Diario](#Pricing-in-Diario) (the global median daily cost of living). After most people have claimed one Diario (as judged by a [money council](#Money-Councils)), everyone can claim a second Diario, etc. When the cadence reaches once per day, we will have achieved global UBI.
### UBI certificates
A UBI certificate is a visible receipt of payment into the UBI fund. It represents a choice to support UBI.
Certificates are purchased with OGC, all of which goes to the [UBI fund](#UBI-fund).
#### Denomination
There are 21 different UBI Certificate images denominated similarly to paper currency. The denominations are 1 Diario, 5 Diario, 10 Diario, 50 Diario, 100 Diario, etc. up to 10,000,000,000 Diario.
When someone sends OGC to the certificate contract, it will read the OGC contract to find out how many Diario the OGC is worth and then mint certificates for the sender totaling the number of Diario they sent and refund any leftover OGC under one Diario.
For example, if Alice sends 70,011.55 Diario worth of OGC, she would get one 50,000 certificate, two 10,000 certificates, one 10 certificate, and one 1 certificate and get 0.55 Diario worth of OGC back.
### UBI matching
To ensure an adequate supply of OGC, [UBI certificate](UBI-certificates) holders can vote to increase the supply by setting a "matching" variable.
When the value of the matching is positive, additional OGC will be minted into the [UBI fund](#UBI-fund) every time OGC is added from a purchased UBI certificate.
Matching is expressed as a percentage from 0 to 1 trillion. If the matching were set to 10%, then purchasing a 1 Diario certificate would result in 1.1 Diario worth of OGC added to the UBI fund. If the matching were set to 1000% then purchasing a 1 Diario certificate would result in 10 Diario worth of OGC added.
#### Voting
The vote is a continuous [median vote](https://en.wikipedia.org/wiki/Median_mechanism)--meaning participants can update their vote at any time. Participants must be [Aura](https://brightid.gitbook.io/aura)-verified as unique and hold at least one UBI certificate[^3].
### How to succeed
The success of OGC on a [new network](#Deploying-to-a-new-chain) (and in general) depends on recipients and earners donating excess wealth to the UBI fund (by buying [UBI Certificates](#UBI-certificates)). This dependency creates a UBI culture where allowing others to receive UBI is a conscious decision everyone makes.
Buying UBI Certificates is one focal point. [Accepting Diario as a merchant](#Pricing-in-Diario) is another. Becoming a [participant oracle](#Participant-oracles) is another. Each of these activities should be easy and worthwhile to do: Using excess OGC to buy UBI Certificates visibly shows one's support for UBI. Merchants accepting Diario can [lock income against price downswings](#Locking-tokens-for-downside-protection) until they can buy inputs for their products. Participant-oracles can get [monetary rewards as OGC expands to new networks](#Preminted-tokens).
## Deploying to a new chain
The OGC [smart contract](#Smart-contract) is deployed and enough OGC tokens are preminted to fulfill the requirements in this section.
The [UBI Certificate](#UBI-certificates) contract is deployed on the new chain.
### Preminted tokens
The deployer mints a number of OGC equal to the median number of OGC on existing deployed chains. The deployer distributes 95% of the OGC equally to active [participant-oracles](#Participant-oracles). In the spirit of [creating a UBI culture, we allow the success of OGC/Diario/UBI](#How-to-succeed) to depend on participant-oracles giving back to the UBI fund (by purchasing [UBI Certificates](#UBI-certificates)). If culture weren't crucial to OGC/Diario/UBI, these tokens could have instead been minted directly to the UBI fund.
The deployer adds the remaining five percent to an automated market maker OGC / DAI[^2] pool at a starting price equal to the median price of OGC across existing chains, with a range from just above the current OGC price to infinity. Only OGC is needed to provide this starting liquidity. Doing this makes OGC available to buy and sets a starting price for participant-oracles to use.
### Inclusion in frontend software
Once the money council has inspected the completed deployment and token transfers, the tokens and chain are added to the recommended frontend software.
## Money Councils
### Responsibilities
* Approve frontend software for submitting living costs and currency adoption.
* Approve deployments onto new chains.
* Select components of the cost of living index.
* [Set the cadence for claiming Diarios as UBI](#Ramp-up).
### Features
* Volunteer only.
* Decentralized.
* Competing money councils can co-exist.
* Participants choose which money councils they trust by choosing which tokens and frontend software to use.
* The member list is updated by a simple majority vote that can happen any time. This makes it simple to automate the member list using a multisig or DAO.
## Money Council Alpha member list
| Nym | Affiliations | Voting address |
| -------- | -------- | -------- |
| Adam Stallard | BrightID, Aura, Unitap | 0xdC0046B52e2E38AEe2271B6171ebb65cCD337518 |
| Abram Symons | BrightID, Muon | 0xE8FB09228d1373f931007ca7894a08344B80901c |
[^runningMedian]: The technique for keeping a running median vote on chain is as follows.
Keep a min heap and a max heap in two solidity arrays. If a new vote is greater than root of the min heap, insert it there, otherwise insert it in the max heap. If the difference of the sizes of the heaps is one or less, you're done, otherwise remove the root from the larger one and insert it into the smaller one.
Find the current median by looking at the root of the larger heap. If they're the same size, take the average of the two roots.
After you insert or remove an item, you need to preserve the heap property, which requires up to log(n) updates, so that could be triggered up to 3 times when you vote (once to insert your vote and once more per heap if a value needs to be moved from one heap to the other).
We should also keep the locations of all values in a map, so votes can be located in the heap to be updated. That means that any update to a heap would also require an update to the map.
Voting would require up to two inserts and up to 6 * log(n) updates.
Replacing your vote would require up to 6 * log(n) updates with no inserts.
Updating a value costs 1/4 as much as inserting. See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2200.md
So adding a vote to a list of votes that already had 10 billion votes in it would require one or two inserts and 0 to 200 updates. The max gas for that would be 1 million (200 * 5000), but 30,000 (6 * 5000) is more likely. So if gas is 10 gwei that puts the cost in the range of .0003 to .01 currency units. (xdai, eth, etc.) This is affordable on all chains except mainnet.
[^2]: Or whatever token is judged by the money council to be most useful for converting to outside currency.
[^3]: If possible, the vote will be weighted by the square root of the Diario count of the certificates held by the voter (though this might require a different mechanism than a median vote).