Giter Club home page Giter Club logo

ubi's Introduction

Universal Basic Income.

UBI Coin

A standard for Universal Basic Income tokens.

Built in collaboration with Kleros and the Proof of Humanity project.

Build Status Coverage Status

Features

  • ERC20 token that can mint new supply for verified humans over time at a given rate.
  • Tokens get streamed directly to a users wallet.
  • Interfaces with ProofOfHumanity to get curated list of verified humans.
  • ProofOfHumanity registry can be updated with governance mechanism.
  • Implements ERC20Upgradeable contracts with OpenZeppelin proxy libraries.

Built with Hardhat.

Latest release is version 0.2.0

Setup

  1. Clone Repository

    $ git clone https://github.com/DemocracyEarth/ubi.git
    $ cd ubi
  2. Install Dependencies

    $ npm install
  3. Run Tests

    $ npx hardhat test

    To compute their code coverage run npx hardhat coverage.

Deploy

  1. On hardhat.config.js configure the following constants for the kovan testnet:

    INFURA_API_KEY
    KOVAN_PRIVATE_KEY
    
  2. Deploy on Ethereum kovan testnet:

    $ npx hardhat run scripts/deploy.js --network kovan
  3. Interact with the console:

    $ npx hardhat console --network kovan

    Initalize the token with:

     const UBI = await ethers.getContractFactory("UBI")
     const ubi = await UBI.attach('0x703960D03533B1D34fF4996DC6604f0Bc74ED198') // Replace with your token address

Upgrade

  1. Deploy new contract in a fresh address:

    $ npx hardhat run scripts/prepare.js --network kovan
  2. Upgrade the proxy contract with the freshly deployed address:

    $ npx hardhat run scripts/upgrade.js --network kovan

Verify

  1. On hardhat.config.js configure your Etherscan API key:

    ETHERSCAN_API_KEY
    
  2. Verify the contract by running:

    $ npx hardhat verify --network kovan <ADDRESS>

Contribute

These contracts are free, open source and censorship resistant. Support us via Open Collective.

License

This software is under an MIT License. This is a free software built by Democracy Earth Foundation between 2020 and 2021. Democracy Earth Foundation is a 501 (c) 3 not for profit corporation from San Francisco, California with no political affiliations.

ubi's People

Contributors

0xaztor avatar 0xferit avatar 0xvayes avatar auryn-macmillan avatar clesaege avatar donosonaumczuk avatar fvictorio avatar juanumusic avatar merlinegalite avatar santisiri avatar sliferkamen avatar unknownunknown1 avatar yonadaaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ubi's Issues

Investor update

Hi Santi, first off, I apologize for using a github issue as a medium for communication. I had no luck trying the @democracy.earth emails or twitter account, which I emailed several times in 2020.

I was wondering if you could give an investor update. You can reach out to me directly and for reference, my address is 0x365...065.

The last update (in 2019) detailed plans for a $VOTE token architecture, which seemed to have been abandoned. I understand, but as a backer, I'm wondering at this point what I've funded. I'd prefer to have my funds returned or at the very least, a plan, a reply, really anything.

Stream tokens directly to humans

The current token design requires humans to call mintAccrued(address human) any time they want to claim their outstanding UBI balance. With the current gas price swings, that transaction is likely to cost tens to hundreds of dollars.

An alternate option is to have the ERC20 balanceOf() be a computed variable, based on incoming and outgoing streams to the address. Superfluid has built out this functionality already, so implementing this would be really simple.

UBI Stream cancellation test failing

Steps to reproduce

Following the readme.md instrctions:

  1. Clone Repository

    $ git clone https://github.com/DemocracyEarth/ubi.git
    $ cd ubi
  2. Install Dependencies

    $ npm install
  3. Run Tests

    $ npx hardhat test

Issue

Seems that there is a failing test at /test/sUBI.ts file:

  91 passing (1m)
  1 failing

  1) sUBI.sol
       UBI Stream cancellation
         happy path - when reportRemoval is executed, all existing and future streams should cancel and canceller balance should increase :

      There should be no active streams after reportRemoval
      + expected - actual

      -3
      +0

UBIv v2 fails to get delegator balance after delegated withdraws

Steps to reproduce:
user 1:

  1. registers on POH
  2. execute startAcrruing
  3. Creates stream with parameters:
  • destination: user 2. (not registered on POH)
  • ubiPerSecond : 10000000000000 (0.00001 UBI)
  1. After some time, user 2 executes withdrawFromStream
  2. try to get balance of UBI from user 1
    Expected result: Should correctly fetch UBI balance for user 1
    Actual result: Fails with the following error:
Error: VM Exception while processing transaction: revert SafeMath: subtraction overflow
      at UBI.sub (@openzeppelin/contracts/math/SafeMath.sol:102)
      at UBI.getDelegatedAccruedValue (contracts/UBI.sol:761)
      at UBI.balanceOf (contracts/UBI.sol:342)

Quadratic Voting for governance

I assume that since Sybil resistance is baked in, the UBI project would prefer to use a democratic governance model (e.g. 1p1v or quadratic voting (QV)), rather than a plutocratic governance model (e.g. token weighted voting).

For a UBI system, QV with the UBI token used as voice credits seems optimal.
UBI tokens spent on voting could be either:

  1. Burned, putting deflationary pressure on the token supply.
  2. Reallocated to public goods for the benefit of UBI token's ecosystem.

I'm not aware of any DAO frameworks that have implemented QV, yet. I'd suggest that one way to start might be to set up a Gnosis Safe multi-sig controlled by a geographically diverse set of known humans who agree to sign in accordance with a Snapshot instance with a QV template. Post launch, one focus that the DAO might take is to build a QV system that can eliminate the need for/dependence on the multi-sig signers, with the eventual goal of removing them.

I imagine the initial snapshot template working something like this:

  1. burn() should have an optional parameter to add some extra data, the snapshot proposal hash (e.g. QmfYNxnWf62q988H7c8UzDnsp8XaNwBjjf1JXVSyyngkcf)
  2. To get "voice credits" for a proposal, humans burn some amount of UBI tokens, including the appropriate proposal hash.
  3. To vote, users sign a message via the snapshot interface

Note: burning could be replaced with a transfer to some public goods fund allocation mechanism, like an instance of clr.fund, for example.

Packing balance and accruedSince in the same slot

instead of having:

mapping (address => uint256) private ubiBalance;
(...)
mapping(address => uint256) public accruedSince;

you can do this:

struct UbiAccount {
  uint224 balance;
  uint32 timestamp;
}

mapping(address => uint256) public ubiAccounts;

and update everything to support this new structure (cast uint256s to uint224s, etc)

Rationale

Every time you transfer, you need to write to both slots. Assuming best case (non-zero to non-zero), the updateBalance(...) that is called will incur:

(2900 + 2100) * 2 = 10_000

if you however have both the balance and accruedSince in the same slot, you rewrite on dirty and hot:

(2900 + 2100) + (100 + 100) = 5_200

all in all, this amounts to 4_800 gas saved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.