centrifuge / tinlake-erc20

Minimal ERC20 token for use in Tinlake. Copied from dai.sol
GNU Affero General Public License v3.0
2 stars 8 forks source link

Implement a members-only ERC20 token #2

Closed lucasvo closed 3 years ago

lucasvo commented 4 years ago

Summary

This spec describes how we need to modify our standard DROP & TIN ERC20 contract to support the necessary functionality needed to comply with the securities restrictions most of our users use.

There are three key features:

Members List

The members list is a simple contract that exposes a list of members that are allowed to receive tokens.

We should add a list of administrators to the token that can modify the member lists but not add or remove administrators.

contract MemberList {
    // use wards and ds-note
    constant uint48 minimumDelay = 60*60*24*7; // 7 day delay  
    mapping (address => uint48) members public;

    function updateMember(address usr, uint48 validUntil) public auth note {
        require(add(now, minimumDelay) < validUntil);
        members[usr] = validUntil;
    }

    function member(address usr) public {
        require(members[usr] >= now);
    }
}

contract MemberListLike {
    function members(address) public returns (uint48);
}

Members-Only ERC20

We should modify the transfer, transferFrom, mint function to verify that the to address is a valid member.

contract MembersOnlyERC20 {
    MemberListLike public memberlist;
    modifier checkMember(address user) { memberlist.member(usr); _; }

    function transferFrom(address from, address to, uint wad) checkMember(to) {
        //...
    }
}
philipstanislaus commented 4 years ago

LGTM, maybe we can call time => lifetime or validUntil and minimumDelay => minLifetimeFromNow or minValidFromNow?

lucasvo commented 4 years ago

I changed it to validUntil but the other variable shouldn't be renamed IMO.

philipstanislaus commented 4 years ago

Okay, no strong feelings :)