Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0x9b6079607038257FDb6be657AA73B18d053cA1FE
Balance 0 ETH
Nonce 1
Code Size 6209 bytes
Indexed Transactions 0 (1 on-chain, 0.6% indexed)
External Etherscan · Sourcify

Contract Bytecode

6209 bytes
0x608060405234801561001057600080fd5b50600436106101375760003560e01c80637c0f59f4116100b8578063cfc0c69f1161007c578063cfc0c69f1461027e578063d2d6b5a31461029c578063daf635de146102af578063de170570146102c2578063e941fa78146102d7578063ffa1ad74146102e057600080fd5b80637c0f59f41461022957806388156a351461023257806388c2c07f14610245578063a8ffba6414610258578063afcff50f1461026b57600080fd5b806336407921116100ff57806336407921146101d4578063485cc955146101e757806357f2e581146101fa5780635cd24fd21461020d57806367a527931461022057600080fd5b8063017def571461013c578063039af9eb1461015157806303df739614610189578063285a7674146101a05780632a9133c1146101cb575b600080fd5b61014f61014a36600461137b565b610311565b005b61016461015f36600461137b565b610454565b604080516001600160801b039384168152929091166020830152015b60405180910390f35b61019260025481565b604051908152602001610180565b6009546101b3906001600160a01b031681565b6040516001600160a01b039091168152602001610180565b61019260045481565b61014f6101e236600461141b565b610489565b61014f6101f536600461150c565b6106b6565b61014f61020836600461137b565b6107c6565b61014f61021b366004611545565b610909565b61019260035481565b61019260065481565b61014f61024036600461137b565b610ace565b61014f61025336600461137b565b610c11565b61014f610266366004611545565b610d54565b6008546101b3906001600160a01b031681565b600754610164906001600160801b0380821691600160801b90041682565b6101926102aa366004611560565b610f11565b61014f6102bd36600461137b565b61108e565b6102ca6111d1565b60405161018091906115d7565b61019260055481565b610304604051806040016040528060058152602001640312e332e360dc1b81525081565b60405161018091906115ea565b600860009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b15801561035f57600080fd5b505afa158015610373573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610397919061163f565b6001600160a01b0316336001600160a01b0316146103c857604051634b98449160e11b815260040160405180910390fd5b6703782dace9d900008111156103f1576040516361b716bb60e11b815260040160405180910390fd5b6003548181141561041557604051630333a68160e41b815260040160405180910390fd5b60408051828152602081018490527f828cf983933545af35b9ba46eec951db1cb4c5433c3ec403aeced2963c264790910160405180910390a150600355565b6001818154811061046457600080fd5b6000918252602090912001546001600160801b038082169250600160801b9091041682565b600860009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b1580156104d757600080fd5b505afa1580156104eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050f919061163f565b6001600160a01b0316336001600160a01b03161461054057604051634b98449160e11b815260040160405180910390fd5b7f69e7d03bdd0009aaf816649f3df4329250186771260691fa1b13bae6419ead5460018260405161057292919061165c565b60405180910390a161058660016000611341565b805160005b818110156106b15760008382815181106105a7576105a76116c2565b60200260200101519050670de0b6b3a764000081602001516001600160801b031611156105e7576040516350e630a760e01b815260040160405180910390fd5b600082118015610630575080516001600160801b0316846106096001856116ee565b81518110610619576106196116c2565b6020026020010151600001516001600160801b0316115b1561064e576040516344eff01160e11b815260040160405180910390fd5b60018054808201825560009190915281516020909201516001600160801b03908116600160801b029216919091177fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6909101556106aa81611705565b905061058b565b505050565b60006106c26001611256565b905080156106da576000805461ff0019166101001790555b6001600160a01b03831661070157604051637cb62f2b60e11b815260040160405180910390fd5b600880546001600160a01b038086166001600160a01b03199283161790925560098054928516929091169190911790556040805180820190915267016345785d8a0000815267011c37937e08000060209091015277011c37937e0800000000000000000000016345785d8a00006007556608e1bc9bf0400060025580156106b1576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b600860009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b15801561081457600080fd5b505afa158015610828573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061084c919061163f565b6001600160a01b0316336001600160a01b03161461087d57604051634b98449160e11b815260040160405180910390fd5b6703782dace9d900008111156108a6576040516361b716bb60e11b815260040160405180910390fd5b600454818114156108ca57604051630333a68160e41b815260040160405180910390fd5b60408051828152602081018490527f7aef17a0caeda11810cdf2a40c79ac1340553588671fb35d5cc8d0a3fe2883be910160405180910390a150600455565b600860009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b15801561095757600080fd5b505afa15801561096b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098f919061163f565b6001600160a01b0316336001600160a01b0316146109c057604051634b98449160e11b815260040160405180910390fd5b604080518082019091526007546001600160801b03808216808452600160801b9092041660208301526703782dace9d90000906109fd9084611720565b6001600160801b03161115610a25576040516361b716bb60e11b815260040160405180910390fd5b80602001516001600160801b0316826001600160801b03161415610a5c57604051630333a68160e41b815260040160405180910390fd5b7fe0dac1dcc46eceed1fdb7416944e7161273637fb346a67d6f0fce8de3e952f2f816020015183604051610aa69291906001600160801b0392831681529116602082015260400190565b60405180910390a150600780546001600160801b03928316600160801b029216919091179055565b600860009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1c57600080fd5b505afa158015610b30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b54919061163f565b6001600160a01b0316336001600160a01b031614610b8557604051634b98449160e11b815260040160405180910390fd5b6703782dace9d90000811115610bae576040516361b716bb60e11b815260040160405180910390fd5b60065481811415610bd257604051630333a68160e41b815260040160405180910390fd5b60408051828152602081018490527fdd45ca427fa57d0870314eb55586e91bcdd31d7cd393e3278caaae9dfb749688910160405180910390a150600655565b600860009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b158015610c5f57600080fd5b505afa158015610c73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c97919061163f565b6001600160a01b0316336001600160a01b031614610cc857604051634b98449160e11b815260040160405180910390fd5b6703782dace9d90000811115610cf1576040516361b716bb60e11b815260040160405180910390fd5b60025481811415610d1557604051630333a68160e41b815260040160405180910390fd5b60408051828152602081018490527f1c2986e5350a71fed3feb3bdcbc3a7aaafd924f4b3dc18d90c17ccb885636be8910160405180910390a150600255565b600860009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b158015610da257600080fd5b505afa158015610db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dda919061163f565b6001600160a01b0316336001600160a01b031614610e0b57604051634b98449160e11b815260040160405180910390fd5b604080518082019091526007546001600160801b038082168352600160801b90910416602082018190526703782dace9d9000090610e499084611720565b6001600160801b03161115610e71576040516361b716bb60e11b815260040160405180910390fd5b80516001600160801b0383811691161415610e9f57604051630333a68160e41b815260040160405180910390fd5b8051604080516001600160801b03928316815291841660208301527f400289ff508344720ca1c0ffff41672b308ae46b4c8227282c2dea56d8595671910160405180910390a150600780546fffffffffffffffffffffffffffffffff19166001600160801b0392909216919091179055565b60015460009080610f26575050600254919050565b6009546040516370a0823160e01b81526001600160a01b03858116600483015260009216906370a082319060240160206040518083038186803b158015610f6c57600080fd5b505afa158015610f80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa4919061174b565b90506001600081548110610fba57610fba6116c2565b6000918252602090912001546001600160801b0316811015610fe157505060025492915050565b60015b828110156110765760018181548110610fff57610fff6116c2565b6000918252602090912001546001600160801b031682101561106e57611065600180830381548110611033576110336116c2565b600091825260209091200154600254906001600160801b03600160801b9091048116670de0b6b3a764000003166112ec565b95945050505050565b600101610fe4565b611065600180850381548110611033576110336116c2565b600860009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b1580156110dc57600080fd5b505afa1580156110f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611114919061163f565b6001600160a01b0316336001600160a01b03161461114557604051634b98449160e11b815260040160405180910390fd5b6703782dace9d9000081111561116e576040516361b716bb60e11b815260040160405180910390fd5b6005548181141561119257604051630333a68160e41b815260040160405180910390fd5b60408051828152602081018490527f733071ab8253b372ed26a6d1b04aec71c4bfcd209c93397df32bb77478cdd2c8910160405180910390a150600555565b60606001805480602002602001604051908101604052809291908181526020016000905b8282101561123e57600084815260209081902060408051808201909152908401546001600160801b038082168352600160801b90910416818301528252600190920191016111f5565b50505050905090565b6001600160a01b03163b151590565b60008054610100900460ff16156112a6578160ff1660011480156112795750303b155b61129e5760405162461bcd60e51b815260040161129590611764565b60405180910390fd5b506000919050565b60005460ff8084169116106112cd5760405162461bcd60e51b815260040161129590611764565b506000805460ff191660ff92909216919091179055600190565b919050565b60008215806112f9575081155b156113065750600061133b565b670de0b6b3a764000061131a6002826117b2565b61132484866117d4565b61132e91906117f3565b61133891906117b2565b90505b92915050565b508054600082559060005260206000209081019061135f9190611362565b50565b5b808211156113775760008155600101611363565b5090565b60006020828403121561138d57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156113cd576113cd611394565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156113fc576113fc611394565b604052919050565b80356001600160801b03811681146112e757600080fd5b6000602080838503121561142e57600080fd5b823567ffffffffffffffff8082111561144657600080fd5b818501915085601f83011261145a57600080fd5b81358181111561146c5761146c611394565b61147a848260051b016113d3565b818152848101925060069190911b83018401908782111561149a57600080fd5b928401925b818410156114ec57604084890312156114b85760008081fd5b6114c06113aa565b6114c985611404565b81526114d6868601611404565b818701528352604093909301929184019161149f565b979650505050505050565b6001600160a01b038116811461135f57600080fd5b6000806040838503121561151f57600080fd5b823561152a816114f7565b9150602083013561153a816114f7565b809150509250929050565b60006020828403121561155757600080fd5b61133882611404565b60006020828403121561157257600080fd5b813561157d816114f7565b9392505050565b600081518084526020808501945080840160005b838110156115cc57815180516001600160801b03908116895290840151168388015260409096019590820190600101611598565b509495945050505050565b6020815260006113386020830184611584565b600060208083528351808285015260005b81811015611617578581018301518582016040015282016115fb565b81811115611629576000604083870101525b50601f01601f1916929092016040019392505050565b60006020828403121561165157600080fd5b815161157d816114f7565b6000604080830181845280865480835260608601915087600052602092508260002060005b828110156116ae5781546001600160801b038116855260801c858501529285019260019182019101611681565b505050848103828601526114ec8187611584565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082821015611700576117006116d8565b500390565b6000600019821415611719576117196116d8565b5060010190565b60006001600160801b03808316818516808303821115611742576117426116d8565b01949350505050565b60006020828403121561175d57600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000826117cf57634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156117ee576117ee6116d8565b500290565b60008219821115611806576118066116d8565b50019056fea2646970667358221220384197dda42946df854ef414353f289738eba72bed857a66444e64af2cfd459c64736f6c63430008090033

Verified Source Code Full Match

Compiler: v0.8.9+commit.e5eed63a EVM: london Optimization: Yes (200 runs)
FeeProvider.sol 216 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./dependencies/openzeppelin-upgradeable/proxy/utils/Initializable.sol";
import "./storage/FeeProviderStorage.sol";
import "./lib/WadRayMath.sol";

error SenderIsNotGovernor();
error PoolRegistryIsNull();
error NewValueIsSameAsCurrent();
error FeeIsGreaterThanTheMax();
error TierDiscountTooHigh();
error TiersNotOrderedByMin();

/**
 * @title FeeProvider contract
 */
contract FeeProvider is Initializable, FeeProviderStorageV1 {
    using WadRayMath for uint256;

    string public constant VERSION = "1.3.0";

    uint256 internal constant MAX_FEE_VALUE = 0.25e18; // 25%
    uint256 internal constant MAX_FEE_DISCOUNT = 1e18; // 100%

    /// @notice Emitted when deposit fee is updated
    event DepositFeeUpdated(uint256 oldDepositFee, uint256 newDepositFee);

    /// @notice Emitted when issue fee is updated
    event IssueFeeUpdated(uint256 oldIssueFee, uint256 newIssueFee);

    /// @notice Emitted when liquidator incentive is updated
    event LiquidatorIncentiveUpdated(uint256 oldLiquidatorIncentive, uint256 newLiquidatorIncentive);

    /// @notice Emitted when protocol liquidation fee is updated
    event ProtocolLiquidationFeeUpdated(uint256 oldProtocolLiquidationFee, uint256 newProtocolLiquidationFee);

    /// @notice Emitted when repay fee is updated
    event RepayFeeUpdated(uint256 oldRepayFee, uint256 newRepayFee);

    /// @notice Emitted when swap fee is updated
    event SwapDefaultFeeUpdated(uint256 oldSwapFee, uint256 newSwapFee);

    /// @notice Emitted when tiers are updated
    event TiersUpdated(Tier[] oldTiers, Tier[] newTiers);

    /// @notice Emitted when withdraw fee is updated
    event WithdrawFeeUpdated(uint256 oldWithdrawFee, uint256 newWithdrawFee);

    /**
     * @notice Throws if caller isn't the governor
     */
    modifier onlyGovernor() {
        if (msg.sender != poolRegistry.governor()) revert SenderIsNotGovernor();
        _;
    }

    constructor() {
        _disableInitializers();
    }

    function initialize(IPoolRegistry poolRegistry_, IESMET esMET_) public initializer {
        if (address(poolRegistry_) == address(0)) revert PoolRegistryIsNull();

        poolRegistry = poolRegistry_;
        esMET = esMET_;

        liquidationFees = LiquidationFees({
            liquidatorIncentive: 1e17, // 10%
            protocolFee: 8e16 // 8%
        });
        defaultSwapFee = 25e14; // 0.25%
    }

    /**
     * @notice Get fee discount tiers
     */
    function getTiers() external view returns (Tier[] memory _tiers) {
        return tiers;
    }

    /**
     * @notice Get the swap fee for a given account
     * Fee discount are applied on top of the default swap fee depending on user's esMET balance
     * @param account_ The account address
     * @return _swapFee The account's swap fee
     */
    function swapFeeFor(address account_) external view override returns (uint256 _swapFee) {
        uint256 _len = tiers.length;

        if (_len == 0) {
            return defaultSwapFee;
        }

        uint256 _balance = esMET.balanceOf(account_);

        if (_balance < tiers[0].min) {
            return defaultSwapFee;
        }

        uint256 i = 1;
        while (i < _len) {
            if (_balance < tiers[i].min) {
                unchecked {
                    // Note: `discount` is always <= `1e18`
                    return defaultSwapFee.wadMul(1e18 - tiers[i - 1].discount);
                }
            }

            unchecked {
                ++i;
            }
        }

        unchecked {
            // Note: `discount` is always <= `1e18`
            return defaultSwapFee.wadMul(1e18 - tiers[_len - 1].discount);
        }
    }

    /**
     * @notice Update deposit fee
     */
    function updateDepositFee(uint256 newDepositFee_) external onlyGovernor {
        if (newDepositFee_ > MAX_FEE_VALUE) revert FeeIsGreaterThanTheMax();
        uint256 _currentDepositFee = depositFee;
        if (newDepositFee_ == _currentDepositFee) revert NewValueIsSameAsCurrent();
        emit DepositFeeUpdated(_currentDepositFee, newDepositFee_);
        depositFee = newDepositFee_;
    }

    /**
     * @notice Update issue fee
     */
    function updateIssueFee(uint256 newIssueFee_) external onlyGovernor {
        if (newIssueFee_ > MAX_FEE_VALUE) revert FeeIsGreaterThanTheMax();
        uint256 _currentIssueFee = issueFee;
        if (newIssueFee_ == _currentIssueFee) revert NewValueIsSameAsCurrent();
        emit IssueFeeUpdated(_currentIssueFee, newIssueFee_);
        issueFee = newIssueFee_;
    }

    /**
     * @notice Update liquidator incentive
     * @dev liquidatorIncentive + protocolFee can't surpass max
     */
    function updateLiquidatorIncentive(uint128 newLiquidatorIncentive_) external onlyGovernor {
        LiquidationFees memory _current = liquidationFees;
        if (newLiquidatorIncentive_ + _current.protocolFee > MAX_FEE_VALUE) revert FeeIsGreaterThanTheMax();
        if (newLiquidatorIncentive_ == _current.liquidatorIncentive) revert NewValueIsSameAsCurrent();
        emit LiquidatorIncentiveUpdated(_current.liquidatorIncentive, newLiquidatorIncentive_);
        liquidationFees.liquidatorIncentive = newLiquidatorIncentive_;
    }

    /**
     * @notice Update protocol liquidation fee
     * @dev liquidatorIncentive + protocolFee can't surpass max
     */
    function updateProtocolLiquidationFee(uint128 newProtocolLiquidationFee_) external onlyGovernor {
        LiquidationFees memory _current = liquidationFees;
        if (newProtocolLiquidationFee_ + _current.liquidatorIncentive > MAX_FEE_VALUE) revert FeeIsGreaterThanTheMax();
        if (newProtocolLiquidationFee_ == _current.protocolFee) revert NewValueIsSameAsCurrent();
        emit ProtocolLiquidationFeeUpdated(_current.protocolFee, newProtocolLiquidationFee_);
        liquidationFees.protocolFee = newProtocolLiquidationFee_;
    }

    /**
     * @notice Update repay fee
     */
    function updateRepayFee(uint256 newRepayFee_) external onlyGovernor {
        if (newRepayFee_ > MAX_FEE_VALUE) revert FeeIsGreaterThanTheMax();
        uint256 _currentRepayFee = repayFee;
        if (newRepayFee_ == _currentRepayFee) revert NewValueIsSameAsCurrent();
        emit RepayFeeUpdated(_currentRepayFee, newRepayFee_);
        repayFee = newRepayFee_;
    }

    /**
     * @notice Update swap fee
     */
    function updateDefaultSwapFee(uint256 newDefaultSwapFee_) external onlyGovernor {
        if (newDefaultSwapFee_ > MAX_FEE_VALUE) revert FeeIsGreaterThanTheMax();
        uint256 _current = defaultSwapFee;
        if (newDefaultSwapFee_ == _current) revert NewValueIsSameAsCurrent();
        emit SwapDefaultFeeUpdated(_current, newDefaultSwapFee_);
        defaultSwapFee = newDefaultSwapFee_;
    }

    /**
     * @notice Update fee discount tiers
     */
    function updateTiers(Tier[] memory tiers_) external onlyGovernor {
        emit TiersUpdated(tiers, tiers_);
        delete tiers;

        uint256 _len = tiers_.length;
        for (uint256 i; i < _len; ++i) {
            Tier memory _tier = tiers_[i];
            if (_tier.discount > MAX_FEE_DISCOUNT) revert TierDiscountTooHigh();
            if (i > 0 && tiers_[i - 1].min > _tier.min) revert TiersNotOrderedByMin();
            tiers.push(_tier);
        }
    }

    /**
     * @notice Update withdraw fee
     */
    function updateWithdrawFee(uint256 newWithdrawFee_) external onlyGovernor {
        if (newWithdrawFee_ > MAX_FEE_VALUE) revert FeeIsGreaterThanTheMax();
        uint256 _currentWithdrawFee = withdrawFee;
        if (newWithdrawFee_ == _currentWithdrawFee) revert NewValueIsSameAsCurrent();
        emit WithdrawFeeUpdated(_currentWithdrawFee, newWithdrawFee_);
        withdrawFee = newWithdrawFee_;
    }
}
WadRayMath.sol 42 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @title Math library
 * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)
 * @dev Based on https://github.com/dapphub/ds-math/blob/master/src/math.sol
 */
library WadRayMath {
    uint256 internal constant WAD = 1e18;
    uint256 internal constant HALF_WAD = WAD / 2;

    uint256 internal constant RAY = 1e27;
    uint256 internal constant HALF_RAY = RAY / 2;

    uint256 internal constant WAD_RAY_RATIO = 1e9;

    /**
     * @dev Multiplies two wad, rounding half up to the nearest wad
     * @param a Wad
     * @param b Wad
     * @return The result of a*b, in wad
     */
    function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0 || b == 0) {
            return 0;
        }

        return (a * b + HALF_WAD) / WAD;
    }

    /**
     * @dev Divides two wad, rounding half up to the nearest wad
     * @param a Wad
     * @param b Wad
     * @return The result of a/b, in wad
     */
    function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        return (a * WAD + b / 2) / b;
    }
}
IQuoter.sol 32 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./IPoolRegistry.sol";
import "./IProxyOFT.sol";

interface IQuoter {
    function quoteCrossChainFlashRepayNativeFee(
        IProxyOFT proxyOFT_,
        bytes calldata lzArgs_
    ) external view returns (uint256 _nativeFee);

    function quoteCrossChainLeverageNativeFee(
        IProxyOFT proxyOFT_,
        bytes calldata lzArgs_
    ) external view returns (uint256 _nativeFee);

    function quoteLeverageCallbackNativeFee(uint16 dstChainId_) external view returns (uint256 _callbackTxNativeFee);

    function quoteFlashRepayCallbackNativeFee(uint16 dstChainId_) external view returns (uint256 _callbackTxNativeFee);

    function getFlashRepaySwapAndCallbackLzArgs(
        uint16 srcChainId_,
        uint16 dstChainId_
    ) external view returns (bytes memory lzArgs_);

    function getLeverageSwapAndCallbackLzArgs(
        uint16 srcChainId_,
        uint16 dstChainId_
    ) external view returns (bytes memory lzArgs_);
}
IProxyOFT.sol 9 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/@layerzerolabs/solidity-examples/contracts-upgradeable/token/oft/composable/IComposableOFTCoreUpgradeable.sol";

interface IProxyOFT is IComposableOFTCoreUpgradeable {
    function getProxyOFTOf(uint16 chainId_) external view returns (address _proxyOFT);
}
IDebtToken.sol 50 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol";
import "./ISyntheticToken.sol";

interface IDebtToken is IERC20Metadata {
    function lastTimestampAccrued() external view returns (uint256);

    function isActive() external view returns (bool);

    function syntheticToken() external view returns (ISyntheticToken);

    function accrueInterest() external;

    function debtIndex() external returns (uint256 debtIndex_);

    function burn(address from_, uint256 amount_) external;

    function issue(uint256 amount_, address to_) external returns (uint256 _issued, uint256 _fee);

    function flashIssue(address to_, uint256 amount_) external returns (uint256 _issued, uint256 _fee);

    function mint(address to_, uint256 amount_) external;

    function repay(address onBehalfOf_, uint256 amount_) external returns (uint256 _repaid, uint256 _fee);

    function repayAll(address onBehalfOf_) external returns (uint256 _repaid, uint256 _fee);

    function quoteIssueIn(uint256 amountToIssue_) external view returns (uint256 _amount, uint256 _fee);

    function quoteIssueOut(uint256 amount_) external view returns (uint256 _amountToIssue, uint256 _fee);

    function quoteRepayIn(uint256 amountToRepay_) external view returns (uint256 _amount, uint256 _fee);

    function quoteRepayOut(uint256 amount_) external view returns (uint256 _amountToRepay, uint256 _fee);

    function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;

    function updateInterestRate(uint256 newInterestRate_) external;

    function maxTotalSupply() external view returns (uint256);

    function interestRate() external view returns (uint256);

    function interestRatePerSecond() external view returns (uint256);

    function toggleIsActive() external;
}
IPauseable.sol 9 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface IPauseable {
    function paused() external view returns (bool);

    function everythingStopped() external view returns (bool);
}
IGovernable.sol 12 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @notice Governable interface
 */
interface IGovernable {
    function governor() external view returns (address _governor);

    function transferGovernorship(address _proposedGovernor) external;
}
IFeeProvider.sol 27 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @notice FeeProvider interface
 */
interface IFeeProvider {
    struct LiquidationFees {
        uint128 liquidatorIncentive;
        uint128 protocolFee;
    }

    function defaultSwapFee() external view returns (uint256);

    function depositFee() external view returns (uint256);

    function issueFee() external view returns (uint256);

    function liquidationFees() external view returns (uint128 liquidatorIncentive, uint128 protocolFee);

    function repayFee() external view returns (uint256);

    function swapFeeFor(address account_) external view returns (uint256);

    function withdrawFee() external view returns (uint256);
}
IPoolRegistry.sol 41 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./external/IMasterOracle.sol";
import "./IPauseable.sol";
import "./IGovernable.sol";
import "./ISyntheticToken.sol";
import "./external/ISwapper.sol";
import "./IQuoter.sol";
import "./ICrossChainDispatcher.sol";

interface IPoolRegistry is IPauseable, IGovernable {
    function feeCollector() external view returns (address);

    function isPoolRegistered(address pool_) external view returns (bool);

    function nativeTokenGateway() external view returns (address);

    function getPools() external view returns (address[] memory);

    function registerPool(address pool_) external;

    function unregisterPool(address pool_) external;

    function masterOracle() external view returns (IMasterOracle);

    function updateFeeCollector(address newFeeCollector_) external;

    function idOfPool(address pool_) external view returns (uint256);

    function nextPoolId() external view returns (uint256);

    function swapper() external view returns (ISwapper);

    function quoter() external view returns (IQuoter);

    function crossChainDispatcher() external view returns (ICrossChainDispatcher);

    function doesSyntheticTokenExist(ISyntheticToken syntheticToken_) external view returns (bool _exists);
}
ISyntheticToken.sol 30 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol";
import "./IDebtToken.sol";
import "./IPoolRegistry.sol";
import "../interfaces/IProxyOFT.sol";

interface ISyntheticToken is IERC20Metadata {
    function isActive() external view returns (bool);

    function mint(address to_, uint256 amount_) external;

    function burn(address from_, uint256 amount) external;

    function poolRegistry() external view returns (IPoolRegistry);

    function toggleIsActive() external;

    function seize(address from_, address to_, uint256 amount_) external;

    function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;

    function updateProxyOFT(IProxyOFT newProxyOFT_) external;

    function maxTotalSupply() external view returns (uint256);

    function proxyOFT() external view returns (IProxyOFT);
}
IESMET.sol 25 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../../dependencies/openzeppelin/token/ERC20/IERC20.sol";

interface IESMET is IERC20 {
    struct LockPosition {
        uint256 lockedAmount; // MET locked
        uint256 boostedAmount; // based on the `lockPeriod`
        uint256 unlockTime; // now + `lockPeriod`
    }

    function positions(uint256) external view returns (LockPosition memory);

    function MINIMUM_LOCK_PERIOD() external view returns (uint256);

    function MAXIMUM_LOCK_PERIOD() external view returns (uint256);

    function balanceOf(address account_) external view returns (uint256);

    function lock(uint256 amount_, uint256 lockPeriod_) external;

    function lockFor(address to_, uint256 amount_, uint256 lockPeriod_) external;
}
FeeProviderStorage.sol 65 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../interfaces/IFeeProvider.sol";
import "../interfaces/IPoolRegistry.sol";
import "../interfaces/external/IESMET.sol";

abstract contract FeeProviderStorageV1 is IFeeProvider {
    struct Tier {
        uint128 min; // esMET min balance needed to be eligible for `discount`
        uint128 discount; // discount in percentage to apply. Use 18 decimals (e.g. 1e16 = 1%)
    }

    /**
     * @notice The fee discount tiers
     */
    Tier[] public tiers;

    /**
     * @notice The default fee charged when swapping synthetic tokens
     * @dev Use 18 decimals (e.g. 1e16 = 1%)
     */
    uint256 public override defaultSwapFee;

    /**
     * @notice The fee charged when depositing collateral
     * @dev Use 18 decimals (e.g. 1e16 = 1%)
     */
    uint256 public override depositFee;

    /**
     * @notice The fee charged when minting a synthetic token
     * @dev Use 18 decimals (e.g. 1e16 = 1%)
     */
    uint256 public override issueFee;

    /**
     * @notice The fee charged when withdrawing collateral
     * @dev Use 18 decimals (e.g. 1e16 = 1%)
     */
    uint256 public override withdrawFee;

    /**
     * @notice The fee charged when repaying debt
     * @dev Use 18 decimals (e.g. 1e16 = 1%)
     */
    uint256 public override repayFee;

    /**
     * @notice The fees charged when liquidating a position
     * @dev Use 18 decimals (e.g. 1e16 = 1%)
     */
    LiquidationFees public override liquidationFees;

    /**
     * @dev The Pool Registry
     */
    IPoolRegistry public poolRegistry;

    /**
     * @notice The esMET contract
     */
    IESMET public esMET;
}
ISwapper.sol 13 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface ISwapper {
    function swapExactInput(
        address tokenIn_,
        address tokenOut_,
        uint256 amountIn_,
        uint256 amountOutMin_,
        address receiver_
    ) external returns (uint256 _amountOut);
}
ICrossChainDispatcher.sol 51 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/@layerzerolabs/solidity-examples/contracts-upgradeable/token/oft/composable/IOFTReceiverUpgradeable.sol";
import "../dependencies/stargate-protocol/interfaces/IStargateReceiver.sol";
import "../dependencies/stargate-protocol/interfaces/IStargateRouter.sol";
import "../dependencies/stargate-protocol/interfaces/IStargateComposer.sol";
import "./IProxyOFT.sol";

interface ICrossChainDispatcher is IStargateReceiver, IOFTReceiverUpgradeable {
    function crossChainDispatcherOf(uint16 chainId_) external view returns (address);

    function triggerFlashRepaySwap(
        uint256 id_,
        address payable account_,
        address tokenIn_,
        address tokenOut_,
        uint256 amountIn_,
        uint256 amountOutMin_,
        bytes calldata lzArgs_
    ) external payable;

    function triggerLeverageSwap(
        uint256 id_,
        address payable account_,
        address tokenIn_,
        address tokenOut_,
        uint256 amountIn_,
        uint256 amountOutMin,
        bytes calldata lzArgs_
    ) external payable;

    function isBridgingActive() external view returns (bool);

    function flashRepayCallbackTxGasLimit() external view returns (uint64);

    function flashRepaySwapTxGasLimit() external view returns (uint64);

    function leverageCallbackTxGasLimit() external view returns (uint64);

    function leverageSwapTxGasLimit() external view returns (uint64);

    function lzBaseGasLimit() external view returns (uint256);

    function stargateComposer() external view returns (IStargateComposer);

    function stargateSlippage() external view returns (uint256);

    function stargatePoolIdOf(address token_) external view returns (uint256);
}
IMasterOracle.sol 11 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface IMasterOracle {
    function quoteTokenToUsd(address _asset, uint256 _amount) external view returns (uint256 _amountInUsd);

    function quoteUsdToToken(address _asset, uint256 _amountInUsd) external view returns (uint256 _amount);

    function quote(address _assetIn, address _assetOut, uint256 _amountIn) external view returns (uint256 _amountOut);
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
IStargateRouter.sol 75 lines
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.9;

interface IStargateRouter {
    struct lzTxObj {
        uint256 dstGasForCall;
        uint256 dstNativeAmount;
        bytes dstNativeAddr;
    }

    function addLiquidity(uint256 _poolId, uint256 _amountLD, address _to) external;

    function swap(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLD,
        uint256 _minAmountLD,
        lzTxObj memory _lzTxParams,
        bytes calldata _to,
        bytes calldata _payload
    ) external payable;

    function redeemRemote(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLP,
        uint256 _minAmountLD,
        bytes calldata _to,
        lzTxObj memory _lzTxParams
    ) external payable;

    function instantRedeemLocal(uint16 _srcPoolId, uint256 _amountLP, address _to) external returns (uint256);

    function redeemLocal(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLP,
        bytes calldata _to,
        lzTxObj memory _lzTxParams
    ) external payable;

    function sendCredits(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress
    ) external payable;

    function quoteLayerZeroFee(
        uint16 _dstChainId,
        uint8 _functionType,
        bytes calldata _toAddress,
        bytes calldata _transferAndCallPayload,
        lzTxObj memory _lzTxParams
    ) external view returns (uint256, uint256);

    function clearCachedSwap(uint16 _srcChainId, bytes calldata _srcAddress, uint256 _nonce) external;

    function factory() external view returns (address);

    function bridge() external view returns (address);

    function cachedSwapLookup(
        uint16 _chainId_,
        bytes calldata _srcAddress,
        uint256 _nonce
    ) external view returns (address token, uint256 amountLD, address to, bytes memory payload);
}
IStargateComposer.sol 35 lines
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.9;

import "./IStargateRouter.sol";

interface IStargateComposer {
    function swap(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLD,
        uint256 _minAmountLD,
        IStargateRouter.lzTxObj memory _lzTxParams,
        bytes calldata _to,
        bytes calldata _payload
    ) external payable;

    function factory() external view returns (address);

    function stargateBridge() external view returns (address);

    function stargateRouter() external view returns (IStargateRouter);

    function quoteLayerZeroFee(
        uint16 _dstChainId,
        uint8 _functionType,
        bytes calldata _toAddress,
        bytes calldata _transferAndCallPayload,
        IStargateRouter.lzTxObj memory _lzTxParams
    ) external view returns (uint256, uint256);

    function peers(uint16 _chainId) external view returns (address);
}
IStargateReceiver.sol 14 lines
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.9;

interface IStargateReceiver {
    function sgReceive(
        uint16 _chainId,
        bytes memory _srcAddress,
        uint256 _nonce,
        address _token,
        uint256 amountLD,
        bytes memory payload
    ) external;
}
AddressUpgradeable.sol 195 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
Initializable.sol 149 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = _setInitializedVersion(1);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        bool isTopLevelCall = _setInitializedVersion(version);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(version);
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        _setInitializedVersion(type(uint8).max);
    }

    function _setInitializedVersion(uint8 version) private returns (bool) {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
        // of initializers, because in other contexts the contract may have been reentered.
        if (_initializing) {
            require(
                version == 1 && !AddressUpgradeable.isContract(address(this)),
                "Initializable: contract is already initialized"
            );
            return false;
        } else {
            require(_initialized < version, "Initializable: contract is already initialized");
            _initialized = version;
            return true;
        }
    }
}
IERC20Metadata.sol 27 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
IERC165Upgradeable.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IOFTCoreUpgradeable.sol 70 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.2;

import "../../../../../openzeppelin-upgradeable/utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Interface of the IOFT core standard
 */
interface IOFTCoreUpgradeable is IERC165Upgradeable {
    /**
     * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`)
     * _dstChainId - L0 defined chain id to send tokens too
     * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
     * _amount - amount of the tokens to transfer
     * _useZro - indicates to use zro to pay L0 fees
     * _adapterParam - flexible bytes array to indicate messaging adapter services in L0
     */
    function estimateSendFee(
        uint16 _dstChainId,
        bytes calldata _toAddress,
        uint _amount,
        bool _useZro,
        bytes calldata _adapterParams
    ) external view returns (uint nativeFee, uint zroFee);

    /**
     * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from`
     * `_from` the owner of token
     * `_dstChainId` the destination chain identifier
     * `_toAddress` can be any size depending on the `dstChainId`.
     * `_amount` the quantity of tokens in wei
     * `_refundAddress` the address LayerZero refunds if too much message fee is sent
     * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token)
     * `_adapterParams` is a flexible bytes array to indicate messaging adapter services
     */
    function sendFrom(
        address _from,
        uint16 _dstChainId,
        bytes calldata _toAddress,
        uint _amount,
        address payable _refundAddress,
        address _zroPaymentAddress,
        bytes calldata _adapterParams
    ) external payable;

    /**
     * @dev returns the circulating amount of tokens on current chain
     */
    function circulatingSupply() external view returns (uint);

    /**
     * @dev returns the address of the ERC20 token
     */
    function token() external view returns (address);

    /**
     * @dev Emitted when `_amount` tokens are moved from the `_sender` to (`_dstChainId`, `_toAddress`)
     * `_nonce` is the outbound nonce
     */
    event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes _toAddress, uint _amount);

    /**
     * @dev Emitted when `_amount` tokens are received from `_srcChainId` into the `_toAddress` on the local chain.
     * `_nonce` is the inbound nonce.
     */
    event ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint _amount);

    event SetUseCustomAdapterParams(bool _useCustomAdapterParams);
}
IOFTReceiverUpgradeable.sol 23 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

interface IOFTReceiverUpgradeable {
    /**
     * @dev Called by the OFT contract when tokens are received from source chain.
     * @param _srcChainId The chain id of the source chain.
     * @param _srcAddress The address of the OFT token contract on the source chain.
     * @param _nonce The nonce of the transaction on the source chain.
     * @param _from The address of the account who calls the sendAndCall() on the source chain.
     * @param _amount The amount of tokens to transfer.
     * @param _payload Additional data with no specified format.
     */
    function onOFTReceived(
        uint16 _srcChainId,
        bytes calldata _srcAddress,
        uint64 _nonce,
        bytes calldata _from,
        uint _amount,
        bytes calldata _payload
    ) external;
}
IComposableOFTCoreUpgradeable.sol 59 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

import "../IOFTCoreUpgradeable.sol";

/**
 * @dev Interface of the composable OFT core standard
 */
interface IComposableOFTCoreUpgradeable is IOFTCoreUpgradeable {
    function estimateSendAndCallFee(
        uint16 _dstChainId,
        bytes calldata _toAddress,
        uint _amount,
        bytes calldata _payload,
        uint64 _dstGasForCall,
        bool _useZro,
        bytes calldata _adapterParams
    ) external view returns (uint nativeFee, uint zroFee);

    function sendAndCall(
        address _from,
        uint16 _dstChainId,
        bytes calldata _toAddress,
        uint _amount,
        bytes calldata _payload,
        uint64 _dstGasForCall,
        address payable _refundAddress,
        address _zroPaymentAddress,
        bytes calldata _adapterParams
    ) external payable;

    function retryOFTReceived(
        uint16 _srcChainId,
        bytes calldata _srcAddress,
        uint64 _nonce,
        bytes calldata _from,
        address _to,
        uint _amount,
        bytes calldata _payload
    ) external;

    event CallOFTReceivedFailure(
        uint16 indexed _srcChainId,
        bytes _srcAddress,
        uint64 _nonce,
        bytes _from,
        address indexed _to,
        uint _amount,
        bytes _payload,
        bytes _reason
    );

    event CallOFTReceivedSuccess(uint16 indexed _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _hash);

    event RetryOFTReceivedSuccess(bytes32 _messageHash);

    event NonContractAddress(address _address);
}

Read Contract

VERSION 0xffa1ad74 → string
defaultSwapFee 0x03df7396 → uint256
depositFee 0x67a52793 → uint256
esMET 0x285a7674 → address
getTiers 0xde170570 → tuple[]
issueFee 0x2a9133c1 → uint256
liquidationFees 0xcfc0c69f → uint128, uint128
poolRegistry 0xafcff50f → address
repayFee 0x7c0f59f4 → uint256
swapFeeFor 0xd2d6b5a3 → uint256
tiers 0x039af9eb → uint128, uint128
withdrawFee 0xe941fa78 → uint256

Write Contract 9 functions

These functions modify contract state and require a wallet transaction to execute.

initialize 0x485cc955
address poolRegistry_
address esMET_
updateDefaultSwapFee 0x88c2c07f
uint256 newDefaultSwapFee_
updateDepositFee 0x017def57
uint256 newDepositFee_
updateIssueFee 0x57f2e581
uint256 newIssueFee_
updateLiquidatorIncentive 0xa8ffba64
uint128 newLiquidatorIncentive_
updateProtocolLiquidationFee 0x5cd24fd2
uint128 newProtocolLiquidationFee_
updateRepayFee 0x88156a35
uint256 newRepayFee_
updateTiers 0xd6bbb363
tuple[] tiers_
updateWithdrawFee 0xdaf635de
uint256 newWithdrawFee_

Recent Transactions

This address has 1 on-chain transactions, but only 0.6% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →