Skip to content

Instantly share code, notes, and snippets.

@adklempner
Last active May 13, 2020 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adklempner/c40335d641140e596495ac002c1402b5 to your computer and use it in GitHub Desktop.
Save adklempner/c40335d641140e596495ac002c1402b5 to your computer and use it in GitHub Desktop.
Research Collective Staking Mechanism

Goal

An Aragon application which creates a vote to mint an ERC721 once a user stakes a minimum amount of an ERC20 (in this case DAI).

User Flow

A user interested in adding a listing to the Research Collective's knowledge registry calls the contract with a URI that points to the appropriate metadata as an argument The contract transfers DAI from the sender to the contract (or the token manager address?) The DAI is minted into rDAI, with the interest going to the DAO (probably Agent, double check how interest is redeemed in rtoken). A vote is created to use the Agent application to call the mint function on an ERC721 contract.

DAO Members cast their votes on whether or not to mint the proposed ERC721. On the social side, this should involve some sort of discussion around the metadata submitted.

If the vote is not approved, the token is not minted, and the user can now withdraw their stake in rDai. The interest should continue to be payed to the DAO until the rDai is redeemed to Dai.

If the vote is approved, the token is minted, and its metadata becomes available in the Research Collective knowledge base. The user is able to withdraw the rDai.

In either case, there can be additional side-effects (like the user earning reputation if the token is minted)

Questions

  • What's the best way to setup a development environment for an Aragon application that will make use of the Voting and Agent apps to interact with other contracts (ERC721, DAI, rDAI)?
// Pseudocode
contract Staking is AragonApp {
ERC20 stakingToken;
ERC721 listingToken;
IRToken rToken;
Agent agent;
uint256 stakeAmount;
function initialize(ERC20 _stakingToken, ERC721 _listingToken, IRToken _rToken, Agent _agent, uint256 _stakeAmount) public onlyInit {
stakingToken = _stakingToken;
listingToken = _listingToken;
rToken = _rToken;
agent = _agent;
stakeAmount = _stakeAmount;
initialized();
}
function proposeListing(string memory _tokenURI, uint256 tokenId) public {
// validate tokenId does not exist
// TODO: user should not have to pass a tokenId. Instead,
// ERC721 contract should implement mint without tokenId as a parameter.
require(!listingToken.exists(tokenId));
// transfer DAI from sender to contract
// todo: check for success
stakingToken.transferFrom(msg.sender, address(this), stakeAmount);
// mint rTokens
// todo: check for success
rToken.mint(stakeAmount);
// create a proposal to mint a new token for sender
// by calling the agent app
// should this use forward() instead of execute() ?
agent.execute(
listingToken.address,
0,
abi.encodeWithSelector(
bytes4(keccak256("mint(address,uint256,string)")),
msg.sender, tokenId, _tokenURI
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment