S Price: $0.601457 (-0.71%)

Contract Diff Checker

Contract Name:
AggregatorConnector

Contract Source Code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {
    ILiquidityConnector,
    AddLiquidityParams,
    RemoveLiquidityParams,
    SwapParams,
    GetAmountOutParams
} from "contracts/interfaces/ILiquidityConnector.sol";

struct AggregatorExtraData {
    bytes data;
}

contract AggregatorConnector is ILiquidityConnector {
    error AggregatorSwapFailed(bytes error);
    error NotImplemented();

    address public immutable router;

    constructor(
        address router_
    ) {
        router = router_;
    }

    function addLiquidity(
        AddLiquidityParams memory
    ) external payable override {
        revert NotImplemented();
    }

    function removeLiquidity(
        RemoveLiquidityParams memory
    ) external pure override {
        revert NotImplemented();
    }

    function swapExactTokensForTokens(
        SwapParams memory swap
    ) external payable override {
        AggregatorExtraData memory extraData =
            abi.decode(swap.extraData, (AggregatorExtraData));
        (bool success, bytes memory error) = router.call(extraData.data);
        if (!success) {
            revert AggregatorSwapFailed(error);
        }
    }

    function getAmountOut(
        GetAmountOutParams memory
    ) external pure override returns (uint256) {
        revert NotImplemented();
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {
    AddLiquidityParams,
    RemoveLiquidityParams,
    SwapParams,
    GetAmountOutParams
} from "contracts/structs/LiquidityStructs.sol";

interface ILiquidityConnector {
    function addLiquidity(
        AddLiquidityParams memory addLiquidityParams
    ) external payable;

    function removeLiquidity(
        RemoveLiquidityParams memory removeLiquidityParams
    ) external;

    function swapExactTokensForTokens(
        SwapParams memory swap
    ) external payable;

    function getAmountOut(
        GetAmountOutParams memory getAmountOutParams
    ) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

struct AddLiquidityParams {
    address router;
    address lpToken;
    address[] tokens;
    uint256[] desiredAmounts;
    uint256[] minAmounts;
    bytes extraData;
}

struct RemoveLiquidityParams {
    address router;
    address lpToken;
    address[] tokens;
    uint256 lpAmountIn;
    uint256[] minAmountsOut;
    bytes extraData;
}

struct SwapParams {
    address router;
    uint256 amountIn;
    uint256 minAmountOut;
    address tokenIn;
    bytes extraData;
}

struct GetAmountOutParams {
    address router;
    address lpToken;
    address tokenIn;
    address tokenOut;
    uint256 amountIn;
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):