ETH Price: $3,249.36 (-5.02%)

Contract

0xbd09366Bc8FBA86FA5391D5017806B49B4F1710b
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x608060401010499822023-05-24 12:24:40325 days ago1684931080IN
 Create: PoolRegistry
0 ETH0.00000140.001

Latest 25 internal transactions (View All)

Advanced mode:
Parent Txn Hash Block From To Value
1075578842023-07-30 10:55:45258 days ago1690714545
0xbd09366B...9B4F1710b
0 ETH
1075578842023-07-30 10:55:45258 days ago1690714545
0xbd09366B...9B4F1710b
0 ETH
1075578842023-07-30 10:55:45258 days ago1690714545
0xbd09366B...9B4F1710b
0 ETH
1075578842023-07-30 10:55:45258 days ago1690714545
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0xbd09366B...9B4F1710b
0 ETH
1075578152023-07-30 10:53:27258 days ago1690714407
0xbd09366B...9B4F1710b
0 ETH
1075578152023-07-30 10:53:27258 days ago1690714407
0xbd09366B...9B4F1710b
0 ETH
1075578152023-07-30 10:53:27258 days ago1690714407
0xbd09366B...9B4F1710b
0 ETH
1075578152023-07-30 10:53:27258 days ago1690714407
0xbd09366B...9B4F1710b
0 ETH
1075578152023-07-30 10:53:27258 days ago1690714407
0xbd09366B...9B4F1710b
0 ETH
1075578152023-07-30 10:53:27258 days ago1690714407
0xbd09366B...9B4F1710b
0 ETH
1075577942023-07-30 10:52:45258 days ago1690714365
0xbd09366B...9B4F1710b
0 ETH
1075577942023-07-30 10:52:45258 days ago1690714365
0xbd09366B...9B4F1710b
0 ETH
1075577942023-07-30 10:52:45258 days ago1690714365
0xbd09366B...9B4F1710b
0 ETH
1075577942023-07-30 10:52:45258 days ago1690714365
0xbd09366B...9B4F1710b
0 ETH
1075577942023-07-30 10:52:45258 days ago1690714365
0xbd09366B...9B4F1710b
0 ETH
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PoolRegistry

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 25 : PoolRegistry.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./dependencies/openzeppelin/security/ReentrancyGuard.sol";
import "./lib/WadRayMath.sol";
import "./storage/PoolRegistryStorage.sol";
import "./interfaces/IPool.sol";
import "./utils/Pauseable.sol";

error OracleIsNull();
error FeeCollectorIsNull();
error NativeTokenGatewayIsNull();
error AddressIsNull();
error AlreadyRegistered();
error UnregisteredPool();
error NewValueIsSameAsCurrent();

/**
 * @title PoolRegistry contract
 */
contract PoolRegistry is ReentrancyGuard, Pauseable, PoolRegistryStorageV1 {
    using WadRayMath for uint256;
    using EnumerableSet for EnumerableSet.AddressSet;

    string public constant VERSION = "1.2.0";

    /// @notice Emitted when fee collector is updated
    event FeeCollectorUpdated(address indexed oldFeeCollector, address indexed newFeeCollector);

    /// @notice Emitted when master oracle contract is updated
    event MasterOracleUpdated(IMasterOracle indexed oldOracle, IMasterOracle indexed newOracle);

    /// @notice Emitted when native token gateway is updated
    event NativeTokenGatewayUpdated(address indexed oldGateway, address indexed newGateway);

    /// @notice Emitted when a pool is registered
    event PoolRegistered(uint256 indexed id, address indexed pool);

    /// @notice Emitted when a pool is unregistered
    event PoolUnregistered(uint256 indexed id, address indexed pool);

    function initialize(IMasterOracle masterOracle_, address feeCollector_) external initializer {
        if (address(masterOracle_) == address(0)) revert OracleIsNull();
        if (feeCollector_ == address(0)) revert FeeCollectorIsNull();

        __ReentrancyGuard_init();
        __Pauseable_init();

        masterOracle = masterOracle_;
        feeCollector = feeCollector_;

        nextPoolId = 1;
    }

    /**
     * @notice Get all pools
     * @dev WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees.
     */
    function getPools() external view override returns (address[] memory) {
        return pools.values();
    }

    /**
     * @notice Check if pool is registered
     * @param pool_ Pool to check
     * @return true if exists
     */
    function isPoolRegistered(address pool_) external view override returns (bool) {
        return pools.contains(pool_);
    }

    /**
     * @notice Register pool
     */
    function registerPool(address pool_) external override onlyGovernor {
        if (pool_ == address(0)) revert AddressIsNull();
        if (!pools.add(pool_)) revert AlreadyRegistered();
        uint256 _id = idOfPool[pool_];
        if (_id == 0) {
            _id = nextPoolId++;
            idOfPool[pool_] = _id;
        }
        emit PoolRegistered(_id, pool_);
    }

    /**
     * @notice Unregister pool
     */
    function unregisterPool(address pool_) external override onlyGovernor {
        if (!pools.remove(pool_)) revert UnregisteredPool();
        emit PoolUnregistered(idOfPool[pool_], pool_);
    }

    /**
     * @notice Update fee collector
     */
    function updateFeeCollector(address newFeeCollector_) external override onlyGovernor {
        if (newFeeCollector_ == address(0)) revert FeeCollectorIsNull();
        address _currentFeeCollector = feeCollector;
        if (newFeeCollector_ == _currentFeeCollector) revert NewValueIsSameAsCurrent();
        emit FeeCollectorUpdated(_currentFeeCollector, newFeeCollector_);
        feeCollector = newFeeCollector_;
    }

    /**
     * @notice Update master oracle contract
     */
    function updateMasterOracle(IMasterOracle newMasterOracle_) external override onlyGovernor {
        if (address(newMasterOracle_) == address(0)) revert OracleIsNull();
        IMasterOracle _currentMasterOracle = masterOracle;
        if (newMasterOracle_ == _currentMasterOracle) revert NewValueIsSameAsCurrent();
        emit MasterOracleUpdated(_currentMasterOracle, newMasterOracle_);
        masterOracle = newMasterOracle_;
    }

    /**
     * @notice Update native token gateway
     */
    function updateNativeTokenGateway(address newGateway_) external override onlyGovernor {
        if (address(newGateway_) == address(0)) revert NativeTokenGatewayIsNull();
        address _currentGateway = nativeTokenGateway;
        if (newGateway_ == _currentGateway) revert NewValueIsSameAsCurrent();
        emit NativeTokenGatewayUpdated(_currentGateway, newGateway_);
        nativeTokenGateway = newGateway_;
    }
}

File 2 of 25 : Governable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/proxy/utils/Initializable.sol";
import "../utils/TokenHolder.sol";
import "../interfaces/IGovernable.sol";

error SenderIsNotGovernor();
error ProposedGovernorIsNull();
error SenderIsNotTheProposedGovernor();

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (governor) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the governor account will be the one that deploys the contract. This
 * can later be changed with {transferGovernorship}.
 *
 */
abstract contract Governable is IGovernable, TokenHolder, Initializable {
    /**
     * @notice The governor
     * @dev By default the contract deployer is the initial governor
     */
    address public governor;

    /**
     * @notice The proposed governor
     * @dev It will be empty (address(0)) if there isn't a proposed governor
     */
    address public proposedGovernor;

    event UpdatedGovernor(address indexed previousGovernor, address indexed proposedGovernor);

    constructor() {
        governor = msg.sender;
        emit UpdatedGovernor(address(0), msg.sender);
    }

    /**
     * @dev If inheriting child is using proxy then child contract can use
     * __Governable_init() function to initialization this contract
     */
    // solhint-disable-next-line func-name-mixedcase
    function __Governable_init() internal initializer {
        governor = msg.sender;
        emit UpdatedGovernor(address(0), msg.sender);
    }

    /**
     * @dev Throws if called by any account other than the governor.
     */
    modifier onlyGovernor() {
        if (governor != msg.sender) revert SenderIsNotGovernor();
        _;
    }

    /// @inheritdoc TokenHolder
    // solhint-disable-next-line no-empty-blocks
    function _requireCanSweep() internal view override onlyGovernor {}

    /**
     * @notice Transfers governorship of the contract to a new account (`proposedGovernor`).
     * @dev Can only be called by the current owner.
     * @param proposedGovernor_ The new proposed governor
     */
    function transferGovernorship(address proposedGovernor_) external onlyGovernor {
        if (proposedGovernor_ == address(0)) revert ProposedGovernorIsNull();
        proposedGovernor = proposedGovernor_;
    }

    /**
     * @notice Allows new governor to accept governorship of the contract.
     */
    function acceptGovernorship() external {
        address _proposedGovernor = proposedGovernor;
        if (msg.sender != _proposedGovernor) revert SenderIsNotTheProposedGovernor();
        emit UpdatedGovernor(governor, _proposedGovernor);
        governor = _proposedGovernor;
        proposedGovernor = address(0);
    }
}

File 3 of 25 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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 a proxied contract can't have 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.
 *
 * 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.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 4 of 25 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal initializer {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 5 of 25 : IERC20.sol
// 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);
}

File 6 of 25 : IERC20Metadata.sol
// 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);
}

File 7 of 25 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 8 of 25 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

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

        (bool success, bytes memory returndata) = target.delegatecall(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);
            }
        }
    }
}

File 9 of 25 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 10 of 25 : IDebtToken.sol
// 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 borrower_, uint256 amount_) external returns (uint256 _issued, uint256 _fee);

    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;
}

File 11 of 25 : IDepositToken.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

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

interface IDepositToken is IERC20Metadata {
    function underlying() external view returns (IERC20);

    function collateralFactor() external view returns (uint256);

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

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

    function flashWithdraw(address account_, uint256 amount_) external returns (uint256 _withdrawn, uint256 _fee);

    function deposit(uint256 amount_, address onBehalfOf_) external returns (uint256 _deposited, uint256 _fee);

    function quoteDepositIn(uint256 amountToDeposit_) external view returns (uint256 _amount, uint256 _fee);

    function quoteDepositOut(uint256 amount_) external view returns (uint256 _amountToDeposit, uint256 _fee);

    function quoteWithdrawIn(uint256 amountToWithdraw_) external view returns (uint256 _amount, uint256 _fee);

    function quoteWithdrawOut(uint256 amount_) external view returns (uint256 _amountToWithdraw, uint256 _fee);

    function withdraw(uint256 amount_, address to_) external returns (uint256 _withdrawn, uint256 _fee);

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

    function updateCollateralFactor(uint128 newCollateralFactor_) external;

    function isActive() external view returns (bool);

    function toggleIsActive() external;

    function maxTotalSupply() external view returns (uint256);

    function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;
}

File 12 of 25 : IFeeProvider.sol
// 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);
}

File 13 of 25 : IGovernable.sol
// 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;
}

File 14 of 25 : IPauseable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

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

    function everythingStopped() external view returns (bool);
}

File 15 of 25 : IPool.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./IDepositToken.sol";
import "./IDebtToken.sol";
import "./ITreasury.sol";
import "./IRewardsDistributor.sol";
import "./IPoolRegistry.sol";
import "./IFeeProvider.sol";
import "./external/ISwapper.sol";
import "../interfaces/IFeeProvider.sol";

/**
 * @notice Pool interface
 */
interface IPool is IPauseable, IGovernable {
    function debtFloorInUsd() external view returns (uint256);

    function feeCollector() external view returns (address);

    function swapper() external view returns (ISwapper);

    function feeProvider() external view returns (IFeeProvider);

    function maxLiquidable() external view returns (uint256);

    function flashRepay(
        ISyntheticToken syntheticToken_,
        IDepositToken depositToken_,
        uint256 withdrawAmount_,
        uint256 repayAmountMin_
    ) external returns (uint256 _withdrawn, uint256 _repaid);

    function doesSyntheticTokenExist(ISyntheticToken syntheticToken_) external view returns (bool);

    function doesDebtTokenExist(IDebtToken debtToken_) external view returns (bool);

    function doesDepositTokenExist(IDepositToken depositToken_) external view returns (bool);

    function depositTokenOf(IERC20 underlying_) external view returns (IDepositToken);

    function debtTokenOf(ISyntheticToken syntheticToken_) external view returns (IDebtToken);

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

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

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

    function debtOf(address account_) external view returns (uint256 _debtInUsd);

    function depositOf(address account_) external view returns (uint256 _depositInUsd, uint256 _issuableLimitInUsd);

    function debtPositionOf(
        address account_
    )
        external
        view
        returns (
            bool _isHealthy,
            uint256 _depositInUsd,
            uint256 _debtInUsd,
            uint256 _issuableLimitInUsd,
            uint256 _issuableInUsd
        );

    function leverage(
        IERC20 tokenIn_,
        IDepositToken depositToken_,
        ISyntheticToken syntheticToken_,
        uint256 amountIn_,
        uint256 leverage_,
        uint256 depositAmountMin_
    ) external returns (uint256 _deposited, uint256 _issued);

    function liquidate(
        ISyntheticToken syntheticToken_,
        address account_,
        uint256 amountToRepay_,
        IDepositToken depositToken_
    ) external returns (uint256 _totalSeized, uint256 _toLiquidator, uint256 _fee);

    function quoteLiquidateIn(
        ISyntheticToken syntheticToken_,
        uint256 totalToSeized_,
        IDepositToken depositToken_
    ) external view returns (uint256 _amountToRepay, uint256 _toLiquidator, uint256 _fee);

    function quoteLiquidateMax(
        ISyntheticToken syntheticToken_,
        address account_,
        IDepositToken depositToken_
    ) external view returns (uint256 _maxAmountToRepay);

    function quoteLiquidateOut(
        ISyntheticToken syntheticToken_,
        uint256 amountToRepay_,
        IDepositToken depositToken_
    ) external view returns (uint256 _totalSeized, uint256 _toLiquidator, uint256 _fee);

    function quoteSwapIn(
        ISyntheticToken syntheticTokenIn_,
        ISyntheticToken syntheticTokenOut_,
        uint256 amountOut_
    ) external view returns (uint256 _amountIn, uint256 _fee);

    function quoteSwapOut(
        ISyntheticToken syntheticTokenIn_,
        ISyntheticToken syntheticTokenOut_,
        uint256 amountIn_
    ) external view returns (uint256 _amountOut, uint256 _fee);

    function swap(
        ISyntheticToken syntheticTokenIn_,
        ISyntheticToken syntheticTokenOut_,
        uint256 amountIn_
    ) external returns (uint256 _amountOut, uint256 _fee);

    function treasury() external view returns (ITreasury);

    function masterOracle() external view returns (IMasterOracle);

    function poolRegistry() external view returns (IPoolRegistry);

    function addToDepositTokensOfAccount(address account_) external;

    function removeFromDepositTokensOfAccount(address account_) external;

    function addToDebtTokensOfAccount(address account_) external;

    function removeFromDebtTokensOfAccount(address account_) external;

    function getDepositTokensOfAccount(address account_) external view returns (address[] memory);

    function getDebtTokensOfAccount(address account_) external view returns (address[] memory);

    function isSwapActive() external view returns (bool);
}

File 16 of 25 : IPoolRegistry.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./external/IMasterOracle.sol";
import "./IPauseable.sol";
import "./IGovernable.sol";
import "./ISyntheticToken.sol";

interface IPoolRegistry is IPauseable, IGovernable {
    function isPoolRegistered(address pool_) external view returns (bool);

    function feeCollector() external view returns (address);

    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 updateMasterOracle(IMasterOracle newOracle_) external;

    function updateFeeCollector(address newFeeCollector_) external;

    function updateNativeTokenGateway(address newGateway_) external;

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

    function nextPoolId() external view returns (uint256);
}

File 17 of 25 : IRewardsDistributor.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

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

/**
 * @notice Reward Distributor interface
 */
interface IRewardsDistributor {
    function rewardToken() external view returns (IERC20);

    function tokenSpeeds(IERC20 token_) external view returns (uint256);

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

    function updateBeforeMintOrBurn(IERC20 token_, address account_) external;

    function updateBeforeTransfer(IERC20 token_, address from_, address to_) external;

    function claimable(address account_) external view returns (uint256 _claimable);

    function claimable(address account_, IERC20 token_) external view returns (uint256 _claimable);

    function claimRewards(address account_) external;

    function claimRewards(address account_, IERC20[] memory tokens_) external;

    function claimRewards(address[] memory accounts_, IERC20[] memory tokens_) external;

    function updateTokenSpeed(IERC20 token_, uint256 newSpeed_) external;

    function updateTokenSpeeds(IERC20[] calldata tokens_, uint256[] calldata speeds_) external;

    function tokens(uint256) external view returns (IERC20);

    function tokenStates(IERC20) external view returns (uint224 index, uint32 timestamp);

    function accountIndexOf(IERC20, address) external view returns (uint256);
}

File 18 of 25 : ISyntheticToken.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol";
import "./IDebtToken.sol";
import "./IPoolRegistry.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 returns (IPoolRegistry);

    function toggleIsActive() external;

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

    function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;

    function maxTotalSupply() external view returns (uint256);
}

File 19 of 25 : ITreasury.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface ITreasury {
    function pull(address to_, uint256 amount_) external;

    function migrateTo(address newTreasury_) external;
}

File 20 of 25 : IMasterOracle.sol
// 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);
}

File 21 of 25 : ISwapper.sol
// 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);
}

File 22 of 25 : WadRayMath.sol
// 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;
    }
}

File 23 of 25 : PoolRegistryStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/utils/structs/EnumerableSet.sol";
import "../interfaces/IPoolRegistry.sol";
import "../interfaces/external/IMasterOracle.sol";

abstract contract PoolRegistryStorageV1 is IPoolRegistry {
    /**
     * @notice Pools collection
     */
    EnumerableSet.AddressSet internal pools;

    /**
     * @notice Prices' oracle
     */
    IMasterOracle public override masterOracle;

    /**
     * @notice Fee collector address
     */
    address public override feeCollector;

    /**
     * @notice Native token gateway address
     */
    address public override nativeTokenGateway;

    /**
     * @notice Map of the ids of the pools
     */
    mapping(address => uint256) public override idOfPool;

    /**
     * @notice Counter of ids of the pools
     */
    uint256 public override nextPoolId;
}

File 24 of 25 : Pauseable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../interfaces/IPauseable.sol";
import "../access/Governable.sol";

error IsPaused();
error IsShutdown();
error IsNotPaused();
error IsNotShutdown();

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 */
abstract contract Pauseable is IPauseable, Governable {
    /// @notice Emitted when contract is turned on
    event Open(address indexed caller);

    /// @notice Emitted when contract is paused
    event Paused(address indexed caller);

    /// @notice Emitted when contract is shuted down
    event Shutdown(address indexed caller);

    /// @notice Emitted when contract is unpaused
    event Unpaused(address indexed caller);

    bool private _paused;
    bool private _everythingStopped;

    /**
     * @dev Throws if contract is paused
     */
    modifier whenNotPaused() {
        if (paused()) revert IsPaused();
        _;
    }

    /**
     * @dev Throws if contract is shutdown
     */
    modifier whenNotShutdown() {
        if (everythingStopped()) revert IsShutdown();
        _;
    }

    /**
     * @dev Throws if contract is not paused
     */
    modifier whenPaused() {
        if (!paused()) revert IsNotPaused();
        _;
    }

    /**
     * @dev Throws if contract is not shutdown
     */
    modifier whenShutdown() {
        if (!everythingStopped()) revert IsNotShutdown();
        _;
    }

    /**
     * @dev If inheriting child is using proxy then child contract can use
     * __Pauseable_init() function to initialization this contract
     */
    // solhint-disable-next-line func-name-mixedcase
    function __Pauseable_init() internal initializer {
        __Governable_init();
    }

    /**
     * @notice Return `true` if contract is shutdown
     */
    function everythingStopped() public view virtual returns (bool) {
        return _everythingStopped;
    }

    /**
     * @notice Return `true` if contract is paused
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Open contract operations, if contract is in shutdown state
     */
    function open() external virtual whenShutdown onlyGovernor {
        _everythingStopped = false;
        emit Open(msg.sender);
    }

    /**
     * @dev Suspend deposit feature, if contract is not paused.
     */
    function pause() external virtual whenNotPaused onlyGovernor {
        _paused = true;
        emit Paused(msg.sender);
    }

    /**
     * @dev Suspend all features (issue, repay, deposit, withdraw, liquidate and swap), if not already shutdown.
     */
    function shutdown() external virtual whenNotShutdown onlyGovernor {
        _everythingStopped = true;
        _paused = true;
        emit Shutdown(msg.sender);
    }

    /**
     * @dev Unpause contract operations, allow only if contract is paused and not shutdown.
     */
    function unpause() external virtual whenPaused whenNotShutdown onlyGovernor {
        _paused = false;
        emit Unpaused(msg.sender);
    }
}

File 25 of 25 : TokenHolder.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/token/ERC20/utils/SafeERC20.sol";

error FallbackIsNotAllowed();
error ReceiveIsNotAllowed();

/**
 * @title Utils contract that handles tokens sent to it
 */
abstract contract TokenHolder {
    using SafeERC20 for IERC20;

    /**
     * @dev Revert fallback calls
     */
    fallback() external payable {
        revert FallbackIsNotAllowed();
    }

    /**
     * @dev Revert when receiving by default
     */
    receive() external payable virtual {
        revert ReceiveIsNotAllowed();
    }

    /**
     * @notice ERC20 recovery in case of stuck tokens due direct transfers to the contract address.
     * @param token_ The token to transfer
     * @param to_ The recipient of the transfer
     * @param amount_ The amount to send
     */
    function sweep(IERC20 token_, address to_, uint256 amount_) external {
        _requireCanSweep();

        if (address(token_) == address(0)) {
            Address.sendValue(payable(to_), amount_);
        } else {
            token_.safeTransfer(to_, amount_);
        }
    }

    /**
     * @notice Function that reverts if the caller isn't allowed to sweep tokens
     * @dev Usually requires the owner or governor as the caller
     */
    function _requireCanSweep() internal view virtual;
}

Settings
{
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"AddressIsNull","type":"error"},{"inputs":[],"name":"AlreadyRegistered","type":"error"},{"inputs":[],"name":"FallbackIsNotAllowed","type":"error"},{"inputs":[],"name":"FeeCollectorIsNull","type":"error"},{"inputs":[],"name":"IsNotPaused","type":"error"},{"inputs":[],"name":"IsNotShutdown","type":"error"},{"inputs":[],"name":"IsPaused","type":"error"},{"inputs":[],"name":"IsShutdown","type":"error"},{"inputs":[],"name":"NativeTokenGatewayIsNull","type":"error"},{"inputs":[],"name":"NewValueIsSameAsCurrent","type":"error"},{"inputs":[],"name":"OracleIsNull","type":"error"},{"inputs":[],"name":"ProposedGovernorIsNull","type":"error"},{"inputs":[],"name":"ReceiveIsNotAllowed","type":"error"},{"inputs":[],"name":"SenderIsNotGovernor","type":"error"},{"inputs":[],"name":"SenderIsNotTheProposedGovernor","type":"error"},{"inputs":[],"name":"UnregisteredPool","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldFeeCollector","type":"address"},{"indexed":true,"internalType":"address","name":"newFeeCollector","type":"address"}],"name":"FeeCollectorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IMasterOracle","name":"oldOracle","type":"address"},{"indexed":true,"internalType":"contract IMasterOracle","name":"newOracle","type":"address"}],"name":"MasterOracleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldGateway","type":"address"},{"indexed":true,"internalType":"address","name":"newGateway","type":"address"}],"name":"NativeTokenGatewayUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"Open","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"PoolRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"PoolUnregistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"Shutdown","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"proposedGovernor","type":"address"}],"name":"UpdatedGovernor","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptGovernorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"everythingStopped","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPools","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"idOfPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IMasterOracle","name":"masterOracle_","type":"address"},{"internalType":"address","name":"feeCollector_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pool_","type":"address"}],"name":"isPoolRegistered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"masterOracle","outputs":[{"internalType":"contract IMasterOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nativeTokenGateway","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextPoolId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"open","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposedGovernor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool_","type":"address"}],"name":"registerPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shutdown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"proposedGovernor_","type":"address"}],"name":"transferGovernorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pool_","type":"address"}],"name":"unregisterPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newFeeCollector_","type":"address"}],"name":"updateFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IMasterOracle","name":"newMasterOracle_","type":"address"}],"name":"updateMasterOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGateway_","type":"address"}],"name":"updateNativeTokenGateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b50600280546001600160a01b031916339081179091556040516000907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d0908290a361180d806100606000396000f3fe60806040526004361061016a5760003560e01c8063abc9b45e116100d1578063d2c35ce81161008a578063f3b27bc311610064578063f3b27bc314610467578063fc0e74d11461047c578063fcfff16f14610491578063ffa1ad74146104a657610188565b8063d2c35ce814610408578063eaada38214610428578063ecf3a3f91461044857610188565b8063abc9b45e14610348578063abd9084614610368578063ada61cc314610388578063b6aa515b146103a8578063c415b95c146103c8578063c673bdaf146103e857610188565b80635c975abb116101235780635c975abb1461028657806362c06767146102b1578063673a2a1f146102d157806374042229146102f35780638456cb59146103135780638a11a3701461032857610188565b80630c340a24146101a157806318e56131146101de578063193d7d841461020257806336074a06146102225780633f4ba83a1461024f578063485cc9551461026657610188565b3661018857604051636436c22d60e11b815260040160405180910390fd5b60405163a0152e6360e01b815260040160405180910390fd5b3480156101ad57600080fd5b506002546101c1906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101ea57600080fd5b506101f4600a5481565b6040519081526020016101d5565b34801561020e57600080fd5b506008546101c1906001600160a01b031681565b34801561022e57600080fd5b506101f461023d366004611590565b60096020526000908152604090205481565b34801561025b57600080fd5b506102646104e4565b005b34801561027257600080fd5b506102646102813660046115ad565b61059e565b34801561029257600080fd5b50600354600160a01b900460ff165b60405190151581526020016101d5565b3480156102bd57600080fd5b506102646102cc3660046115e6565b6106a8565b3480156102dd57600080fd5b506102e66106dc565b6040516101d59190611627565b3480156102ff57600080fd5b5061026461030e366004611590565b6106ed565b34801561031f57600080fd5b506102646107d3565b34801561033457600080fd5b506003546101c1906001600160a01b031681565b34801561035457600080fd5b50610264610363366004611590565b610869565b34801561037457600080fd5b50610264610383366004611590565b61094f565b34801561039457600080fd5b506102646103a3366004611590565b610a53565b3480156103b457600080fd5b506102646103c3366004611590565b610aea565b3480156103d457600080fd5b506007546101c1906001600160a01b031681565b3480156103f457600080fd5b506102a1610403366004611590565b610b5e565b34801561041457600080fd5b50610264610423366004611590565b610b71565b34801561043457600080fd5b506006546101c1906001600160a01b031681565b34801561045457600080fd5b50600354600160a81b900460ff166102a1565b34801561047357600080fd5b50610264610c57565b34801561048857600080fd5b50610264610ce6565b34801561049d57600080fd5b50610264610d7e565b3480156104b257600080fd5b506104d7604051806040016040528060058152602001640312e322e360dc1b81525081565b6040516101d591906116a4565b600354600160a01b900460ff1661050e5760405163bc871ce560e01b815260040160405180910390fd5b600354600160a81b900460ff161561053957604051631b0e923f60e11b815260040160405180910390fd5b6002546001600160a01b0316331461056457604051634b98449160e11b815260040160405180910390fd5b6003805460ff60a01b1916905560405133907f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa90600090a2565b600054610100900460ff16806105b7575060005460ff16155b6105dc5760405162461bcd60e51b81526004016105d3906116d7565b60405180910390fd5b600054610100900460ff161580156105fe576000805461ffff19166101011790555b6001600160a01b03831661062557604051634cc5e93360e11b815260040160405180910390fd5b6001600160a01b03821661064c5760405163d7d925af60e01b815260040160405180910390fd5b610654610e0d565b61065c610e7d565b600680546001600160a01b038086166001600160a01b03199283161790925560078054928516929091169190911790556001600a5580156106a3576000805461ff00191690555b505050565b6106b0610ef0565b6001600160a01b0383166106c8576106a38282610f1d565b6106a36001600160a01b0384168383611036565b60606106e86004611088565b905090565b6002546001600160a01b0316331461071857604051634b98449160e11b815260040160405180910390fd5b6001600160a01b03811661073f57604051632b8962df60e21b815260040160405180910390fd5b6008546001600160a01b0390811690821681141561077057604051630333a68160e41b815260040160405180910390fd5b816001600160a01b0316816001600160a01b03167f981f8692d39ed552e61144c73b1f608b9f86a04d56656a1dc248cc21dfce42c360405160405180910390a350600880546001600160a01b0319166001600160a01b0392909216919091179055565b600354600160a01b900460ff16156107fe57604051631309a56360e01b815260040160405180910390fd5b6002546001600160a01b0316331461082957604051634b98449160e11b815260040160405180910390fd5b6003805460ff60a01b1916600160a01b17905560405133907f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25890600090a2565b6002546001600160a01b0316331461089457604051634b98449160e11b815260040160405180910390fd5b6001600160a01b0381166108bb57604051634cc5e93360e11b815260040160405180910390fd5b6006546001600160a01b039081169082168114156108ec57604051630333a68160e41b815260040160405180910390fd5b816001600160a01b0316816001600160a01b03167fc96bca3f57d35a1057a3357bced51fac157918147faa56845639671c516ec69c60405160405180910390a350600680546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b0316331461097a57604051634b98449160e11b815260040160405180910390fd5b6001600160a01b0381166109a15760405163fb7566d760e01b815260040160405180910390fd5b6109ac60048261109c565b6109c957604051630ea075bf60e21b815260040160405180910390fd5b6001600160a01b03811660009081526009602052604090205480610a1957600a80549060006109f78361173b565b909155506001600160a01b038316600090815260096020526040902081905590505b6040516001600160a01b0383169082907f403a01572a6930b9303134960bb6e5d695084d389779d4554842553846135ffd90600090a35050565b6002546001600160a01b03163314610a7e57604051634b98449160e11b815260040160405180910390fd5b610a896004826110b1565b610aa657604051630282c45560e31b815260040160405180910390fd5b6001600160a01b03811660008181526009602052604080822054905190917ff8a85b30c450aae09b266730946d2e1c61a36e77d194bf4e50205060a816307991a350565b6002546001600160a01b03163314610b1557604051634b98449160e11b815260040160405180910390fd5b6001600160a01b038116610b3c57604051634c267bfb60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b6b6004836110c6565b92915050565b6002546001600160a01b03163314610b9c57604051634b98449160e11b815260040160405180910390fd5b6001600160a01b038116610bc35760405163d7d925af60e01b815260040160405180910390fd5b6007546001600160a01b03908116908216811415610bf457604051630333a68160e41b815260040160405180910390fd5b816001600160a01b0316816001600160a01b03167f5d16ad41baeb009cd23eb8f6c7cde5c2e0cd5acf4a33926ab488875c37c37f3860405160405180910390a350600780546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b0316338114610c835760405163038cdbad60e31b815260040160405180910390fd5b6002546040516001600160a01b038084169216907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d090600090a3600280546001600160a01b039092166001600160a01b0319928316179055600380549091169055565b600354600160a81b900460ff1615610d1157604051631b0e923f60e11b815260040160405180910390fd5b6002546001600160a01b03163314610d3c57604051634b98449160e11b815260040160405180910390fd5b6003805461ffff60a01b191661010160a01b17905560405133907f28b4c24cb1012c094cd2f59f98e89d791973295f8fda6eaa118022d6d318960a90600090a2565b600354600160a81b900460ff16610da857604051636e2cff4560e01b815260040160405180910390fd5b6002546001600160a01b03163314610dd357604051634b98449160e11b815260040160405180910390fd5b6003805460ff60a81b1916905560405133907fece7583a70a505ef0e36d4dec768f5ae597713e09c26011022599ee01abdabfc90600090a2565b600054610100900460ff1680610e26575060005460ff16155b610e425760405162461bcd60e51b81526004016105d3906116d7565b600054610100900460ff16158015610e64576000805461ffff19166101011790555b600180558015610e7a576000805461ff00191690555b50565b600054610100900460ff1680610e96575060005460ff16155b610eb25760405162461bcd60e51b81526004016105d3906116d7565b600054610100900460ff16158015610ed4576000805461ffff19166101011790555b610edc6110e8565b8015610e7a576000805461ff001916905550565b6002546001600160a01b03163314610f1b57604051634b98449160e11b815260040160405180910390fd5b565b80471015610f6d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016105d3565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610fba576040519150601f19603f3d011682016040523d82523d6000602084013e610fbf565b606091505b50509050806106a35760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016105d3565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526106a3908490611193565b6060600061109583611265565b9392505050565b6000611095836001600160a01b0384166112c1565b6000611095836001600160a01b038416611310565b6001600160a01b03811660009081526001830160205260408120541515611095565b600054610100900460ff1680611101575060005460ff16155b61111d5760405162461bcd60e51b81526004016105d3906116d7565b600054610100900460ff1615801561113f576000805461ffff19166101011790555b600280546001600160a01b031916339081179091556040516000907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d0908290a38015610e7a576000805461ff001916905550565b60006111e8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114039092919063ffffffff16565b8051909150156106a357808060200190518101906112069190611756565b6106a35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105d3565b6060816000018054806020026020016040519081016040528092919081815260200182805480156112b557602002820191906000526020600020905b8154815260200190600101908083116112a1575b50505050509050919050565b600081815260018301602052604081205461130857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b6b565b506000610b6b565b600081815260018301602052604081205480156113f9576000611334600183611778565b855490915060009061134890600190611778565b90508181146113ad5760008660000182815481106113685761136861178f565b906000526020600020015490508087600001848154811061138b5761138b61178f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806113be576113be6117a5565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b6b565b6000915050610b6b565b6060611412848460008561141a565b949350505050565b60608247101561147b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105d3565b843b6114c95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105d3565b600080866001600160a01b031685876040516114e591906117bb565b60006040518083038185875af1925050503d8060008114611522576040519150601f19603f3d011682016040523d82523d6000602084013e611527565b606091505b5091509150611537828286611542565b979650505050505050565b60608315611551575081611095565b8251156115615782518084602001fd5b8160405162461bcd60e51b81526004016105d391906116a4565b6001600160a01b0381168114610e7a57600080fd5b6000602082840312156115a257600080fd5b81356110958161157b565b600080604083850312156115c057600080fd5b82356115cb8161157b565b915060208301356115db8161157b565b809150509250929050565b6000806000606084860312156115fb57600080fd5b83356116068161157b565b925060208401356116168161157b565b929592945050506040919091013590565b6020808252825182820181905260009190848201906040850190845b818110156116685783516001600160a01b031683529284019291840191600101611643565b50909695505050505050565b60005b8381101561168f578181015183820152602001611677565b8381111561169e576000848401525b50505050565b60208152600082518060208401526116c3816040850160208701611674565b601f01601f19169190910160400192915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600060001982141561174f5761174f611725565b5060010190565b60006020828403121561176857600080fd5b8151801515811461109557600080fd5b60008282101561178a5761178a611725565b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600082516117cd818460208701611674565b919091019291505056fea2646970667358221220a2813f54c92967c52eeb8fbc00a1d8310abaeb3b3fe896f29cecfb96f91b271464736f6c63430008090033

Deployed Bytecode

0x60806040526004361061016a5760003560e01c8063abc9b45e116100d1578063d2c35ce81161008a578063f3b27bc311610064578063f3b27bc314610467578063fc0e74d11461047c578063fcfff16f14610491578063ffa1ad74146104a657610188565b8063d2c35ce814610408578063eaada38214610428578063ecf3a3f91461044857610188565b8063abc9b45e14610348578063abd9084614610368578063ada61cc314610388578063b6aa515b146103a8578063c415b95c146103c8578063c673bdaf146103e857610188565b80635c975abb116101235780635c975abb1461028657806362c06767146102b1578063673a2a1f146102d157806374042229146102f35780638456cb59146103135780638a11a3701461032857610188565b80630c340a24146101a157806318e56131146101de578063193d7d841461020257806336074a06146102225780633f4ba83a1461024f578063485cc9551461026657610188565b3661018857604051636436c22d60e11b815260040160405180910390fd5b60405163a0152e6360e01b815260040160405180910390fd5b3480156101ad57600080fd5b506002546101c1906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101ea57600080fd5b506101f4600a5481565b6040519081526020016101d5565b34801561020e57600080fd5b506008546101c1906001600160a01b031681565b34801561022e57600080fd5b506101f461023d366004611590565b60096020526000908152604090205481565b34801561025b57600080fd5b506102646104e4565b005b34801561027257600080fd5b506102646102813660046115ad565b61059e565b34801561029257600080fd5b50600354600160a01b900460ff165b60405190151581526020016101d5565b3480156102bd57600080fd5b506102646102cc3660046115e6565b6106a8565b3480156102dd57600080fd5b506102e66106dc565b6040516101d59190611627565b3480156102ff57600080fd5b5061026461030e366004611590565b6106ed565b34801561031f57600080fd5b506102646107d3565b34801561033457600080fd5b506003546101c1906001600160a01b031681565b34801561035457600080fd5b50610264610363366004611590565b610869565b34801561037457600080fd5b50610264610383366004611590565b61094f565b34801561039457600080fd5b506102646103a3366004611590565b610a53565b3480156103b457600080fd5b506102646103c3366004611590565b610aea565b3480156103d457600080fd5b506007546101c1906001600160a01b031681565b3480156103f457600080fd5b506102a1610403366004611590565b610b5e565b34801561041457600080fd5b50610264610423366004611590565b610b71565b34801561043457600080fd5b506006546101c1906001600160a01b031681565b34801561045457600080fd5b50600354600160a81b900460ff166102a1565b34801561047357600080fd5b50610264610c57565b34801561048857600080fd5b50610264610ce6565b34801561049d57600080fd5b50610264610d7e565b3480156104b257600080fd5b506104d7604051806040016040528060058152602001640312e322e360dc1b81525081565b6040516101d591906116a4565b600354600160a01b900460ff1661050e5760405163bc871ce560e01b815260040160405180910390fd5b600354600160a81b900460ff161561053957604051631b0e923f60e11b815260040160405180910390fd5b6002546001600160a01b0316331461056457604051634b98449160e11b815260040160405180910390fd5b6003805460ff60a01b1916905560405133907f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa90600090a2565b600054610100900460ff16806105b7575060005460ff16155b6105dc5760405162461bcd60e51b81526004016105d3906116d7565b60405180910390fd5b600054610100900460ff161580156105fe576000805461ffff19166101011790555b6001600160a01b03831661062557604051634cc5e93360e11b815260040160405180910390fd5b6001600160a01b03821661064c5760405163d7d925af60e01b815260040160405180910390fd5b610654610e0d565b61065c610e7d565b600680546001600160a01b038086166001600160a01b03199283161790925560078054928516929091169190911790556001600a5580156106a3576000805461ff00191690555b505050565b6106b0610ef0565b6001600160a01b0383166106c8576106a38282610f1d565b6106a36001600160a01b0384168383611036565b60606106e86004611088565b905090565b6002546001600160a01b0316331461071857604051634b98449160e11b815260040160405180910390fd5b6001600160a01b03811661073f57604051632b8962df60e21b815260040160405180910390fd5b6008546001600160a01b0390811690821681141561077057604051630333a68160e41b815260040160405180910390fd5b816001600160a01b0316816001600160a01b03167f981f8692d39ed552e61144c73b1f608b9f86a04d56656a1dc248cc21dfce42c360405160405180910390a350600880546001600160a01b0319166001600160a01b0392909216919091179055565b600354600160a01b900460ff16156107fe57604051631309a56360e01b815260040160405180910390fd5b6002546001600160a01b0316331461082957604051634b98449160e11b815260040160405180910390fd5b6003805460ff60a01b1916600160a01b17905560405133907f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25890600090a2565b6002546001600160a01b0316331461089457604051634b98449160e11b815260040160405180910390fd5b6001600160a01b0381166108bb57604051634cc5e93360e11b815260040160405180910390fd5b6006546001600160a01b039081169082168114156108ec57604051630333a68160e41b815260040160405180910390fd5b816001600160a01b0316816001600160a01b03167fc96bca3f57d35a1057a3357bced51fac157918147faa56845639671c516ec69c60405160405180910390a350600680546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b0316331461097a57604051634b98449160e11b815260040160405180910390fd5b6001600160a01b0381166109a15760405163fb7566d760e01b815260040160405180910390fd5b6109ac60048261109c565b6109c957604051630ea075bf60e21b815260040160405180910390fd5b6001600160a01b03811660009081526009602052604090205480610a1957600a80549060006109f78361173b565b909155506001600160a01b038316600090815260096020526040902081905590505b6040516001600160a01b0383169082907f403a01572a6930b9303134960bb6e5d695084d389779d4554842553846135ffd90600090a35050565b6002546001600160a01b03163314610a7e57604051634b98449160e11b815260040160405180910390fd5b610a896004826110b1565b610aa657604051630282c45560e31b815260040160405180910390fd5b6001600160a01b03811660008181526009602052604080822054905190917ff8a85b30c450aae09b266730946d2e1c61a36e77d194bf4e50205060a816307991a350565b6002546001600160a01b03163314610b1557604051634b98449160e11b815260040160405180910390fd5b6001600160a01b038116610b3c57604051634c267bfb60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b6b6004836110c6565b92915050565b6002546001600160a01b03163314610b9c57604051634b98449160e11b815260040160405180910390fd5b6001600160a01b038116610bc35760405163d7d925af60e01b815260040160405180910390fd5b6007546001600160a01b03908116908216811415610bf457604051630333a68160e41b815260040160405180910390fd5b816001600160a01b0316816001600160a01b03167f5d16ad41baeb009cd23eb8f6c7cde5c2e0cd5acf4a33926ab488875c37c37f3860405160405180910390a350600780546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b0316338114610c835760405163038cdbad60e31b815260040160405180910390fd5b6002546040516001600160a01b038084169216907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d090600090a3600280546001600160a01b039092166001600160a01b0319928316179055600380549091169055565b600354600160a81b900460ff1615610d1157604051631b0e923f60e11b815260040160405180910390fd5b6002546001600160a01b03163314610d3c57604051634b98449160e11b815260040160405180910390fd5b6003805461ffff60a01b191661010160a01b17905560405133907f28b4c24cb1012c094cd2f59f98e89d791973295f8fda6eaa118022d6d318960a90600090a2565b600354600160a81b900460ff16610da857604051636e2cff4560e01b815260040160405180910390fd5b6002546001600160a01b03163314610dd357604051634b98449160e11b815260040160405180910390fd5b6003805460ff60a81b1916905560405133907fece7583a70a505ef0e36d4dec768f5ae597713e09c26011022599ee01abdabfc90600090a2565b600054610100900460ff1680610e26575060005460ff16155b610e425760405162461bcd60e51b81526004016105d3906116d7565b600054610100900460ff16158015610e64576000805461ffff19166101011790555b600180558015610e7a576000805461ff00191690555b50565b600054610100900460ff1680610e96575060005460ff16155b610eb25760405162461bcd60e51b81526004016105d3906116d7565b600054610100900460ff16158015610ed4576000805461ffff19166101011790555b610edc6110e8565b8015610e7a576000805461ff001916905550565b6002546001600160a01b03163314610f1b57604051634b98449160e11b815260040160405180910390fd5b565b80471015610f6d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016105d3565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610fba576040519150601f19603f3d011682016040523d82523d6000602084013e610fbf565b606091505b50509050806106a35760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016105d3565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526106a3908490611193565b6060600061109583611265565b9392505050565b6000611095836001600160a01b0384166112c1565b6000611095836001600160a01b038416611310565b6001600160a01b03811660009081526001830160205260408120541515611095565b600054610100900460ff1680611101575060005460ff16155b61111d5760405162461bcd60e51b81526004016105d3906116d7565b600054610100900460ff1615801561113f576000805461ffff19166101011790555b600280546001600160a01b031916339081179091556040516000907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d0908290a38015610e7a576000805461ff001916905550565b60006111e8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114039092919063ffffffff16565b8051909150156106a357808060200190518101906112069190611756565b6106a35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105d3565b6060816000018054806020026020016040519081016040528092919081815260200182805480156112b557602002820191906000526020600020905b8154815260200190600101908083116112a1575b50505050509050919050565b600081815260018301602052604081205461130857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b6b565b506000610b6b565b600081815260018301602052604081205480156113f9576000611334600183611778565b855490915060009061134890600190611778565b90508181146113ad5760008660000182815481106113685761136861178f565b906000526020600020015490508087600001848154811061138b5761138b61178f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806113be576113be6117a5565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b6b565b6000915050610b6b565b6060611412848460008561141a565b949350505050565b60608247101561147b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105d3565b843b6114c95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105d3565b600080866001600160a01b031685876040516114e591906117bb565b60006040518083038185875af1925050503d8060008114611522576040519150601f19603f3d011682016040523d82523d6000602084013e611527565b606091505b5091509150611537828286611542565b979650505050505050565b60608315611551575081611095565b8251156115615782518084602001fd5b8160405162461bcd60e51b81526004016105d391906116a4565b6001600160a01b0381168114610e7a57600080fd5b6000602082840312156115a257600080fd5b81356110958161157b565b600080604083850312156115c057600080fd5b82356115cb8161157b565b915060208301356115db8161157b565b809150509250929050565b6000806000606084860312156115fb57600080fd5b83356116068161157b565b925060208401356116168161157b565b929592945050506040919091013590565b6020808252825182820181905260009190848201906040850190845b818110156116685783516001600160a01b031683529284019291840191600101611643565b50909695505050505050565b60005b8381101561168f578181015183820152602001611677565b8381111561169e576000848401525b50505050565b60208152600082518060208401526116c3816040850160208701611674565b601f01601f19169190910160400192915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600060001982141561174f5761174f611725565b5060010190565b60006020828403121561176857600080fd5b8151801515811461109557600080fd5b60008282101561178a5761178a611725565b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600082516117cd818460208701611674565b919091019291505056fea2646970667358221220a2813f54c92967c52eeb8fbc00a1d8310abaeb3b3fe896f29cecfb96f91b271464736f6c63430008090033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.