Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 1.35 KB

File metadata and controls

37 lines (27 loc) · 1.35 KB

FlatOperator

We have one main operator called ZeroExOperator and he is responsible for swapping assets with 0x. However, the users may not want to swap everytime...

For example, the user wants to create a portfolio with 5 DAI and 5 USDC. But if the input is 10 DAI, he can't "swap 5 DAI for 5 DAI" with the ZeroExOperator. It makes no sense and will revert.

image

To resolve that, we created an operator "doing nothing", the FlatOperator. In fact, we just want to deposit or withdraw without swapping in some cases.

image

The FlatOperator will do nothing, and return to the factory that "input = output" (for the amount and token address). This way, it "simulates" a deposit (or withdraw in the case of some factory functions).

function transfer(address token, uint256 amount)
    external
    payable
    override
    returns (uint256[] memory amounts, address[] memory tokens)
{
    require(amount != 0, "FO: INVALID_AMOUNT");

    amounts = new uint256[](2);
    tokens = new address[](2);

    // Output amounts
    amounts[0] = amount;
    amounts[1] = amount;

    // Output token
    tokens[0] = token;
    tokens[1] = token;
}