xdefilab / xdefi-governance-token

XDeFi Yield Farming & XDEX on Ethereum
https://farm.xdefi.com
MIT License
11 stars 3 forks source link

FundsToStream调用FundStream,解决Farm体验(部分立刻解锁) #5

Closed tturbulence closed 3 years ago

tturbulence commented 3 years ago

现在:

function fundsToStream(uint256 streamId, uint256 amount) public returns (bool result) { require(amount > 0, "amount is zero");

    /* Approve the XHalflife contract to spend. */
    _xdex.approve(address(halflife), amount);

    /* Transfer the tokens to this contract. */
    _xdex.transferFrom(msg.sender, address(this), amount);

    result = halflife.fundStream(streamId, amount);

    emit Fund(msg.sender, streamId, amount);
}

建议:

function fundsToStream(uint256 streamId, uint256 amount1, uint256 amount2)
    public
    returns (bool result)
{
    require(amount > 0, "amount is zero");

    /* Approve the XHalflife contract to spend. */
    _xdex.approve(address(halflife), amount1.add(amount2));

    /* Transfer the tokens to this contract. */
    _xdex.transferFrom(msg.sender, address(this), amount1.add(amount2));

    result = halflife.fundStream(streamId, amount1, amount2);

    emit Fund(msg.sender, streamId, amount1, amount2);
}

并且建议:

因此Fund日志也要分开amount1,amount2来分开打。approve和transfer可以一起做