Skip to content

Add TokenTrade scheme #774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 22, 2020
Merged

Add TokenTrade scheme #774

merged 7 commits into from
Jul 22, 2020

Conversation

ben-kaufman
Copy link
Contributor

No description provided.

* - A member can donate to a dao.
*/
contract TokenTrade is VotingMachineCallbacks, ProposalExecuteInterface {
using SafeMath for uint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint -> unit256

* @param _voteParamsHash voting machine parameters.
*/
function initialize(
Avatar _avatar,
Copy link
Contributor

@orenyodfat orenyodfat Jul 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should get also the inTradingToken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not allow any token? What's the reason to limit it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. easy in the UI.
  2. simple code
  3. more secure

"Token address must not be null"
);
require(_sendTokenAmount > 0 && _receiveTokenAmount > 0, "Token amount must be greater than 0");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a way to lock the recieve token in the scheme.. so there will not be a case where the proposal execute and the dao cannot pay .
so maybe upon proposal the scheme will ask the receive token amount from the avatar.. ,if not enough exist will revert.
if proposal is accepted the user will redeem (from the scheme) .
if proposal is rejected the allocated token will be sent back to the avatar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bad because an attacker can open dummy proposal and lock the avatar's balance. The way I handled that case is that if upon execution the DAO doesn't have enough funds, the proposal will be canceled as if it was rejected, and the user will get his tokens back.

@orenyodfat orenyodfat changed the base branch from arc-factory to master-2 July 19, 2020 05:33
uint256 sendTokenAmount;
IERC20 receiveToken;
uint256 receiveTokenAmount;
bool exist;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the exist var is really needed ?
does checking other filed like beneficiary or sendToken is not enough ?

require(_sendTokenAmount > 0 && _receiveTokenAmount > 0, "Token amount must be greater than 0");

_sendToken.safeTransferFrom(msg.sender, address(this), _sendTokenAmount);
bytes32 proposalId = votingMachine.propose(2, voteParamsHash, msg.sender, address(avatar));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* @title A scheme for join in a dao.
* - A member can be proposed to join in by sending a min amount of fee.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment should be updated

function execute(bytes32 _proposalId) public {
Proposal storage proposal = proposals[_proposalId];
require(address(_sendToken) != address(0), "must be a live proposal");
require(proposal.decided, "must be a decided proposal");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this condition is not enough ? why need the previous one ?

@orenyodfat orenyodfat merged commit 13d2a22 into master-2 Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants