ExchangeHelper

Helper contract to buy/sell G$ at GoodReserve with any token supported by Uniswap V2. Since reserve only supports cDAI.

Events

TokenPurchased

Emitted when G$ tokens are purchased.

event TokenPurchased(
    address indexed caller,
    address indexed inputToken,
    uint256 inputAmount,
    uint256 actualReturn,
    address indexed receiverAddress
);

TokenSold

Emitted when G$ tokens are sold.

event TokenSold(
    address indexed caller,
    address indexed outputToken,
    uint256 gdAmount,
    uint256 contributionAmount,
    uint256 actualReturn,
    address indexed receiverAddress
);

buy

The function converts any "buyWith" tokens to DAI. Then call to reserve's buy function is occured. It is to convert the tokens to G$ tokens.

Returns: how much G$ tokens were transferred.

function buy(
    address[] memory _buyPath,
    uint256 _tokenAmount,
    uint256 _minReturn,
    uint256 _minDAIAmount,
    address _targetAddress
) public payable returns (uint256);

sell

The function converts G$ tokens to cDAI through reserve then it makes further transactions according to desired _sellTo token. The user could either send cDAI or DAI directly or desired token through Uniswap V2.

Returns: how much "sellTo" tokens were transferred.

function sell(
    address[] memory _sellPath,
    uint256 _gdAmount,
    uint256 _minReturn,
    uint256 _minTokenReturn,
    address _targetAddress
) public returns (uint256);

Last updated