DemocracyEarth / ubi

Universal Basic Income token.
225 stars 38 forks source link

Stream tokens directly to humans #51

Closed auryn-macmillan closed 3 years ago

auryn-macmillan commented 3 years ago

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.

santisiri commented 3 years ago

Will definitely explore this possibility. This is a great idea @auryn-macmillan !

mdalie commented 3 years ago

That sounds pretty awesome @auryn-macmillan, we would be glad to help you integrate Superfluid. @santisiri join our Discord so we can talk about it.

santisiri commented 3 years ago

Working my way through the documentation to test superTokens.. stuck here for time being: https://github.com/superfluid-finance/protocol-monorepo/issues/230

mdalie commented 3 years ago

I see on Discord that you and our champion @pi0neerpat are on it, shout if you have any issues.

santisiri commented 3 years ago

Been testing this out and looking at the contracts. Since we know that our ubi contract can mint tokens throughout time to valid identities, been thinking we could simply implement the functionality related to realtimeBalanceOf:

function balanceOf(
        address account
    )
        public
        view
        override
        returns(uint256 balance)
    {
        // solhint-disable-next-line not-rely-on-time
        (int256 availableBalance, , ) = super.realtimeBalanceOf(account, block.timestamp);
        return availableBalance < 0 ? 0 : uint256(availableBalance);
    }

Though for this I'd like to have a clearer picture for security precautions we need to consider. Probably making this optional on a first version makes sense cc @epiqueras.

santisiri commented 3 years ago

Implemented a very simple version that directly displays accrued value on balanceOf — pull available here: https://github.com/DemocracyEarth/ubi/pull/73

santisiri commented 3 years ago

eppur si muove: https://twitter.com/santisiri/status/1363503509145079811

thanks for pushing me in this direction @auryn-macmillan !

auryn-macmillan commented 3 years ago

This is awesome!

santisiri commented 3 years ago

Feature implemented, audited and tested. Closing.