APE Price: $0.64 (-9.17%)

Contract

0x189CBD80EC8Cb4d93D7d9Bb15E585295569c22CD

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0 APE

APE Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FlashLoan

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
london EvmVersion
File 1 of 13 : FlashLoan.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "openzeppelin-contracts/contracts/access/Ownable.sol";
import "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IERC3156FlashLender.sol";
import "../interfaces/IDeferLiquidityCheck.sol";
import "../interfaces/IApeFinance.sol";
import "../libraries/PauseFlags.sol";

contract FlashLoan is Ownable, IERC3156FlashLender, IDeferLiquidityCheck {
    using SafeERC20 for IERC20;
    using PauseFlags for DataTypes.MarketConfig;

    /// @notice The standard signature for ERC-3156 borrower
    bytes32 public constant CALLBACK_SUCCESS = keccak256("ERC3156FlashBorrower.onFlashLoan");

    /// @notice The maximum flash loan fee rate
    uint16 internal constant MAX_FEE_RATE = 1000; // 10%

    /// @notice The ApeFinance contract
    address public immutable apeFinance;

    /// @notice The flash loan fee rate
    uint16 public feeRate;

    /// @dev The deferred liquidity check flag
    bool internal _isDeferredLiquidityCheck;

    event FeeRateSet(uint16 feeRate);

    event TokenSeized(address token, uint256 amount);

    constructor(address apeFinance_) {
        apeFinance = apeFinance_;
    }

    /// @inheritdoc IERC3156FlashLender
    function maxFlashLoan(address token) external view override returns (uint256) {
        if (!IApeFinance(apeFinance).isMarketListed(token)) {
            return 0;
        }

        DataTypes.MarketConfig memory config = IApeFinance(apeFinance).getMarketConfiguration(token);
        if (config.isBorrowPaused()) {
            return 0;
        }

        uint256 totalCash = IApeFinance(apeFinance).getTotalCash(token);
        uint256 totalBorrow = IApeFinance(apeFinance).getTotalBorrow(token);

        uint256 maxBorrowAmount;
        if (config.borrowCap == 0) {
            maxBorrowAmount = totalCash;
        } else if (config.borrowCap > totalBorrow) {
            uint256 gap = config.borrowCap - totalBorrow;
            maxBorrowAmount = gap < totalCash ? gap : totalCash;
        }

        return maxBorrowAmount;
    }

    /// @inheritdoc IERC3156FlashLender
    function flashFee(address token, uint256 amount) external view override returns (uint256) {
        amount;

        require(IApeFinance(apeFinance).isMarketListed(token), "token not listed");

        DataTypes.MarketConfig memory config = IApeFinance(apeFinance).getMarketConfiguration(token);
        require(!config.isBorrowPaused(), "borrow is paused");

        return _flashFee(amount);
    }

    /// @inheritdoc IERC3156FlashLender
    function flashLoan(IERC3156FlashBorrower receiver, address token, uint256 amount, bytes calldata data)
        external
        override
        returns (bool)
    {
        require(IApeFinance(apeFinance).isMarketListed(token), "token not listed");

        if (!_isDeferredLiquidityCheck) {
            IApeFinance(apeFinance).deferLiquidityCheck(
                address(this), abi.encode(receiver, token, amount, data, msg.sender)
            );
            _isDeferredLiquidityCheck = false;
        } else {
            _loan(receiver, token, amount, data, msg.sender);
        }

        return true;
    }

    /// @inheritdoc IDeferLiquidityCheck
    function onDeferredLiquidityCheck(bytes memory encodedData) external override {
        require(msg.sender == apeFinance, "untrusted message sender");
        (IERC3156FlashBorrower receiver, address token, uint256 amount, bytes memory data, address msgSender) =
            abi.decode(encodedData, (IERC3156FlashBorrower, address, uint256, bytes, address));

        _isDeferredLiquidityCheck = true;
        _loan(receiver, token, amount, data, msgSender);
    }

    /* ========== RESTRICTED FUNCTIONS ========== */

    /**
     * @notice Set the flash loan fee rate.
     * @param _feeRate The fee rate
     */
    function setFeeRate(uint16 _feeRate) external onlyOwner {
        require(_feeRate <= MAX_FEE_RATE, "invalid fee rate");

        feeRate = _feeRate;
        emit FeeRateSet(_feeRate);
    }

    /**
     * @notice Seize the token from the contract.
     * @param token The address of the token
     * @param amount The amount to seize
     * @param recipient The address of the recipient
     */
    function seize(address token, uint256 amount, address recipient) external onlyOwner {
        IERC20(token).safeTransfer(recipient, amount);
        emit TokenSeized(token, amount);
    }

    /* ========== INTERNAL FUNCTIONS ========== */

    /**
     * @dev Get the flash loan fee.
     * @param amount The amount to flash loan
     */
    function _flashFee(uint256 amount) internal view returns (uint256) {
        return amount * feeRate / 10000;
    }

    /**
     * @dev Flash borrow from ApeFinance to the receiver.
     * @param receiver The receiver of the flash loan
     * @param token The token to borrow
     * @param amount The amount to borrow
     * @param data Arbitrary data that is passed to the receiver
     * @param msgSender The original caller
     */
    function _loan(IERC3156FlashBorrower receiver, address token, uint256 amount, bytes memory data, address msgSender)
        internal
    {
        uint256 fee = _flashFee(amount);

        IApeFinance(apeFinance).borrow(address(this), address(receiver), token, amount);

        require(receiver.onFlashLoan(msgSender, token, amount, fee, data) == CALLBACK_SUCCESS, "callback failed");

        // Collect repayment from the receiver with fee.
        IERC20(token).safeTransferFrom(address(receiver), address(this), amount + fee);

        uint256 allowance = IERC20(token).allowance(address(this), apeFinance);
        if (allowance < amount) {
            IERC20(token).safeApprove(apeFinance, type(uint256).max);
        }

        // Only repay the principal amount to ApeFinance.
        IApeFinance(apeFinance).repay(address(this), address(this), token, amount);
    }
}

File 2 of 13 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 4 of 13 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.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));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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 5 of 13 : IERC3156FlashLender.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC3156FlashBorrower.sol";

interface IERC3156FlashLender {
    /**
     * @dev The amount of currency available to be lent.
     * @param token The loan currency.
     * @return The amount of `token` that can be borrowed.
     */
    function maxFlashLoan(address token) external view returns (uint256);

    /**
     * @dev The fee to be charged for a given loan.
     * @param token The loan currency.
     * @param amount The amount of tokens lent.
     * @return The amount of `token` to be charged for the loan, on top of the returned principal.
     */
    function flashFee(address token, uint256 amount) external view returns (uint256);

    /**
     * @dev Initiate a flash loan.
     * @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
     * @param token The loan currency.
     * @param amount The amount of tokens lent.
     * @param data Arbitrary data structure, intended to contain user-defined parameters.
     */
    function flashLoan(IERC3156FlashBorrower receiver, address token, uint256 amount, bytes calldata data)
        external
        returns (bool);
}

File 6 of 13 : IDeferLiquidityCheck.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IDeferLiquidityCheck {
    /**
     * @dev The callback function that deferLiquidityCheck will invoke.
     * @param data The arbitrary data that was passed in by the caller
     */
    function onDeferredLiquidityCheck(bytes memory data) external;
}

File 7 of 13 : IApeFinance.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../libraries/DataTypes.sol";

interface IApeFinance {
    /* ========== USER INTERFACES ========== */

    function accrueInterest(address market) external;

    function supply(address from, address to, address market, uint256 amount) external;

    function borrow(address from, address to, address asset, uint256 amount) external;

    function redeem(address from, address to, address asset, uint256 amount) external returns (uint256);

    function repay(address from, address to, address asset, uint256 amount) external returns (uint256);

    function liquidate(
        address liquidator,
        address borrower,
        address marketBorrow,
        address marketCollateral,
        uint256 repayAmount
    ) external returns (uint256, uint256);

    function deferLiquidityCheck(address user, bytes memory data) external;

    function getBorrowBalance(address user, address market) external view returns (uint256);

    function getATokenBalance(address user, address market) external view returns (uint256);

    function getSupplyBalance(address user, address market) external view returns (uint256);

    function isMarketListed(address market) external view returns (bool);

    function getExchangeRate(address market) external view returns (uint256);

    function getTotalSupply(address market) external view returns (uint256);

    function getTotalBorrow(address market) external view returns (uint256);

    function getTotalCash(address market) external view returns (uint256);

    function getTotalReserves(address market) external view returns (uint256);

    function getAccountLiquidity(address user) external view returns (uint256, uint256, uint256);

    function isAllowedExtension(address user, address extension) external view returns (bool);

    function transferAToken(address market, address from, address to, uint256 amount) external;

    function setSubAccountExtension(address primary, uint256 subAccountId, bool allowed) external;

    /* ========== MARKET CONFIGURATOR INTERFACES ========== */

    function getMarketConfiguration(address market) external view returns (DataTypes.MarketConfig memory);

    function listMarket(address market, DataTypes.MarketConfig calldata config) external;

    function delistMarket(address market) external;

    function setMarketConfiguration(address market, DataTypes.MarketConfig calldata config) external;

    /* ========== CREDIT LIMIT MANAGER INTERFACES ========== */

    function getCreditLimit(address user, address market) external view returns (uint256);

    function getUserCreditMarkets(address user) external view returns (address[] memory);

    function isCreditAccount(address user) external view returns (bool);

    function setCreditLimit(address user, address market, uint256 credit) external;

    /* ========== RESERVE MANAGER INTERFACES ========== */

    function absorbToReserves(address market) external;

    function reduceReserves(address market, uint256 aTokenAmount, address recipient) external;
}

File 8 of 13 : PauseFlags.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./DataTypes.sol";

library PauseFlags {
    /// @dev Mask for specific actions in the pause flag bit array
    uint8 internal constant PAUSE_SUPPLY_MASK = 0xFE;
    uint8 internal constant PAUSE_BORROW_MASK = 0xFD;
    uint8 internal constant PAUSE_TRANSFER_MASK = 0xFB;

    /// @dev Offsets for specific actions in the pause flag bit array
    uint8 internal constant PAUSE_SUPPLY_OFFSET = 0;
    uint8 internal constant PAUSE_BORROW_OFFSET = 1;
    uint8 internal constant PAUSE_TRANSFER_OFFSET = 2;

    /// @dev Sets the market supply paused.
    function setSupplyPaused(DataTypes.MarketConfig memory self, bool paused) internal pure {
        self.pauseFlags = (self.pauseFlags & PAUSE_SUPPLY_MASK) | (toUInt8(paused) << PAUSE_SUPPLY_OFFSET);
    }

    /// @dev Returns true if the market supply is paused, and false otherwise.
    function isSupplyPaused(DataTypes.MarketConfig memory self) internal pure returns (bool) {
        return toBool(self.pauseFlags & ~PAUSE_SUPPLY_MASK);
    }

    /// @dev Sets the market borrow paused.
    function setBorrowPaused(DataTypes.MarketConfig memory self, bool paused) internal pure {
        self.pauseFlags = (self.pauseFlags & PAUSE_BORROW_MASK) | (toUInt8(paused) << PAUSE_BORROW_OFFSET);
    }

    /// @dev Returns true if the market borrow is paused, and false otherwise.
    function isBorrowPaused(DataTypes.MarketConfig memory self) internal pure returns (bool) {
        return toBool(self.pauseFlags & ~PAUSE_BORROW_MASK);
    }

    /// @dev Sets the market transfer paused.
    function setTransferPaused(DataTypes.MarketConfig memory self, bool paused) internal pure {
        self.pauseFlags = (self.pauseFlags & PAUSE_TRANSFER_MASK) | (toUInt8(paused) << PAUSE_TRANSFER_OFFSET);
    }

    /// @dev Returns true if the market transfer is paused, and false otherwise.
    function isTransferPaused(DataTypes.MarketConfig memory self) internal pure returns (bool) {
        return toBool(self.pauseFlags & ~PAUSE_TRANSFER_MASK);
    }

    /// @dev Casts a boolean to uint8.
    function toUInt8(bool x) internal pure returns (uint8) {
        return x ? 1 : 0;
    }

    /// @dev Casts a uint8 to boolean.
    function toBool(uint8 x) internal pure returns (bool) {
        return x != 0;
    }
}

File 9 of 13 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 10 of 13 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 11 of 13 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 12 of 13 : IERC3156FlashBorrower.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IERC3156FlashBorrower {
    /**
     * @dev Receive a flash loan.
     * @param initiator The initiator of the loan.
     * @param token The loan currency.
     * @param amount The amount of tokens lent.
     * @param fee The additional amount of tokens to repay.
     * @param data Arbitrary data structure, intended to contain user-defined parameters.
     * @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan"
     */
    function onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes calldata data)
        external
        returns (bytes32);
}

File 13 of 13 : DataTypes.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

library DataTypes {
    struct UserBorrow {
        uint256 borrowBalance;
        uint256 borrowIndex;
    }

    struct MarketConfig {
        // 1 + 1 + 2 + 2 + 2 + 2 + 1 + 1 = 12
        bool isListed;
        uint8 pauseFlags;
        uint16 collateralFactor;
        uint16 liquidationThreshold;
        uint16 liquidationBonus;
        uint16 reserveFactor;
        bool isPToken;
        bool isDelisted;
        // 20 + 20 + 20 + 32 + 32 + 32
        address aTokenAddress;
        address debtTokenAddress;
        address interestRateModelAddress;
        uint256 supplyCap;
        uint256 borrowCap;
        uint256 initialExchangeRate;
    }

    struct Market {
        MarketConfig config;
        uint40 lastUpdateTimestamp;
        uint256 totalCash;
        uint256 totalBorrow;
        uint256 totalSupply;
        uint256 totalReserves;
        uint256 borrowIndex;
        mapping(address => UserBorrow) userBorrows;
        mapping(address => uint256) userSupplies;
    }
}

Settings
{
  "remappings": [
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"apeFinance_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"feeRate","type":"uint16"}],"name":"FeeRateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenSeized","type":"event"},{"inputs":[],"name":"CALLBACK_SUCCESS","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"apeFinance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"flashFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC3156FlashBorrower","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"flashLoan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"maxFlashLoan","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedData","type":"bytes"}],"name":"onDeferredLiquidityCheck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"seize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_feeRate","type":"uint16"}],"name":"setFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a060405234801561001057600080fd5b50604051611a60380380611a6083398101604081905261002f91610099565b61003833610049565b6001600160a01b03166080526100c9565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100ab57600080fd5b81516001600160a01b03811681146100c257600080fd5b9392505050565b60805161192161013f60003960008181610198015281816102d401528181610393015281816104bf0152818161055a015281816106030152818161069501528181610776015281816108b80152818161098601528181610b6501528181610cd901528181610d690152610dc301526119216000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063978bbdb911610071578063978bbdb91461016b5780639b6899db14610193578063a15db5c5146101ba578063c04fb7c3146101cd578063d9d98ce4146101e0578063f2fde38b146101f357600080fd5b806329ff0773146100b95780635cffe9de146100ce578063613255ab146100f6578063715018a6146101175780638237e5381461011f5780638da5cb5b14610146575b600080fd5b6100cc6100c7366004611282565b610206565b005b6100e16100dc3660046112bb565b6102b2565b60405190151581526020015b60405180910390f35b61010961010436600461135a565b61049d565b6040519081526020016100ed565b6100cc610757565b6101097f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd981565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100ed565b60005461018090600160a01b900461ffff1681565b60405161ffff90911681526020016100ed565b6101537f000000000000000000000000000000000000000000000000000000000000000081565b6100cc6101c8366004611410565b61076b565b6100cc6101db366004611490565b610833565b6101096101ee3660046114d2565b610896565b6100cc61020136600461135a565b610a50565b61020e610ac9565b6103e861ffff8216111561025c5760405162461bcd60e51b815260206004820152601060248201526f696e76616c696420666565207261746560801b60448201526064015b60405180910390fd5b6000805461ffff60a01b1916600160a01b61ffff8416908102919091179091556040519081527fa7e573bcaa01c752d835735eaf6642539f905efcbc1117da708c2ce84aa302bb9060200160405180910390a150565b604051633d98a1e560e01b81526001600160a01b0385811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690633d98a1e590602401602060405180830381865afa15801561031d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103419190611513565b6103805760405162461bcd60e51b815260206004820152601060248201526f1d1bdad95b881b9bdd081b1a5cdd195960821b6044820152606401610253565b600054600160b01b900460ff1661044d577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166389b7b7a6308888888888336040516020016103dc9695949392919061152e565b6040516020818303038152906040526040518363ffffffff1660e01b81526004016104089291906115e1565b600060405180830381600087803b15801561042257600080fd5b505af1158015610436573d6000803e3d6000fd5b50506000805460ff60b01b19169055506104919050565b61049186868686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250339250610b23915050565b50600195945050505050565b604051633d98a1e560e01b81526001600160a01b0382811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690633d98a1e590602401602060405180830381865afa158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c9190611513565b61053857506000919050565b604051632d1046a960e11b81526001600160a01b0383811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690635a208d52906024016101c060405180830381865afa1580156105a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c8919061162c565b90506105d381610e3a565b156105e15750600092915050565b604051634dcc86b960e11b81526001600160a01b0384811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690639b990d7290602401602060405180830381865afa15801561064c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106709190611729565b60405163429c68a760e11b81526001600160a01b0386811660048301529192506000917f00000000000000000000000000000000000000000000000000000000000000001690638538d14e90602401602060405180830381865afa1580156106dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107009190611729565b905060008361018001516000141561071957508161074e565b81846101800151111561074e576000828561018001516107399190611758565b9050838110610748578361074a565b805b9150505b95945050505050565b61075f610ac9565b6107696000610e4e565b565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146107e35760405162461bcd60e51b815260206004820152601860248201527f756e74727573746564206d6573736167652073656e64657200000000000000006044820152606401610253565b6000806000806000858060200190518101906107ff919061176f565b6000805460ff60b01b1916600160b01b17905593985091965094509250905061082b8585858585610b23565b505050505050565b61083b610ac9565b61084f6001600160a01b0384168284610e9e565b604080516001600160a01b0385168152602081018490527fb930d7c3c6896f70ea10a959f1d9a7c04e0467138efa4c7040570d4b8f4894b6910160405180910390a1505050565b604051633d98a1e560e01b81526001600160a01b0383811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690633d98a1e590602401602060405180830381865afa158015610901573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109259190611513565b6109645760405162461bcd60e51b815260206004820152601060248201526f1d1bdad95b881b9bdd081b1a5cdd195960821b6044820152606401610253565b604051632d1046a960e11b81526001600160a01b0384811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690635a208d52906024016101c060405180830381865afa1580156109d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f4919061162c565b90506109ff81610e3a565b15610a3f5760405162461bcd60e51b815260206004820152601060248201526f189bdc9c9bddc81a5cc81c185d5cd95960821b6044820152606401610253565b610a4883610f06565b949350505050565b610a58610ac9565b6001600160a01b038116610abd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610253565b610ac681610e4e565b50565b6000546001600160a01b031633146107695760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610253565b6000610b2e84610f06565b60405163afef7efd60e01b81523060048201526001600160a01b0388811660248301528781166044830152606482018790529192507f00000000000000000000000000000000000000000000000000000000000000009091169063afef7efd90608401600060405180830381600087803b158015610bab57600080fd5b505af1158015610bbf573d6000803e3d6000fd5b50506040516323e30c8b60e01b81527f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd992506001600160a01b03891691506323e30c8b90610c199086908a908a9088908b90600401611829565b6020604051808303816000875af1158015610c38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5c9190611729565b14610c9b5760405162461bcd60e51b815260206004820152600f60248201526e18d85b1b189858dac819985a5b1959608a1b6044820152606401610253565b610cbc8630610caa8488611863565b6001600160a01b038916929190610f2d565b604051636eb1769f60e11b81523060048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660248301526000919087169063dd62ed3e90604401602060405180830381865afa158015610d2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d509190611729565b905084811015610d9057610d906001600160a01b0387167f0000000000000000000000000000000000000000000000000000000000000000600019610f6b565b60405163c035bd2160e01b8152306004820181905260248201526001600160a01b038781166044830152606482018790527f0000000000000000000000000000000000000000000000000000000000000000169063c035bd21906084016020604051808303816000875af1158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e309190611729565b5050505050505050565b602081015160009060021615155b92915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b038316602482015260448101829052610f0190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611080565b505050565b6000805461271090610f2390600160a01b900461ffff168461187b565b610e48919061189a565b6040516001600160a01b0380851660248301528316604482015260648101829052610f659085906323b872dd60e01b90608401610eca565b50505050565b801580610fe55750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610fbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe39190611729565b155b6110505760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610253565b6040516001600160a01b038316602482015260448101829052610f0190849063095ea7b360e01b90606401610eca565b60006110d5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111529092919063ffffffff16565b805190915015610f0157808060200190518101906110f39190611513565b610f015760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610253565b6060610a48848460008585600080866001600160a01b0316858760405161117991906118bc565b60006040518083038185875af1925050503d80600081146111b6576040519150601f19603f3d011682016040523d82523d6000602084013e6111bb565b606091505b50915091506111cc878383876111d7565b979650505050505050565b6060831561124357825161123c576001600160a01b0385163b61123c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610253565b5081610a48565b610a4883838151156112585781518083602001fd5b8060405162461bcd60e51b815260040161025391906118d8565b61ffff81168114610ac657600080fd5b60006020828403121561129457600080fd5b813561129f81611272565b9392505050565b6001600160a01b0381168114610ac657600080fd5b6000806000806000608086880312156112d357600080fd5b85356112de816112a6565b945060208601356112ee816112a6565b935060408601359250606086013567ffffffffffffffff8082111561131257600080fd5b818801915088601f83011261132657600080fd5b81358181111561133557600080fd5b89602082850101111561134757600080fd5b9699959850939650602001949392505050565b60006020828403121561136c57600080fd5b813561129f816112a6565b634e487b7160e01b600052604160045260246000fd5b6040516101c0810167ffffffffffffffff811182821017156113b1576113b1611377565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156113e0576113e0611377565b604052919050565b600067ffffffffffffffff82111561140257611402611377565b50601f01601f191660200190565b60006020828403121561142257600080fd5b813567ffffffffffffffff81111561143957600080fd5b8201601f8101841361144a57600080fd5b803561145d611458826113e8565b6113b7565b81815285602083850101111561147257600080fd5b81602084016020830137600091810160200191909152949350505050565b6000806000606084860312156114a557600080fd5b83356114b0816112a6565b92506020840135915060408401356114c7816112a6565b809150509250925092565b600080604083850312156114e557600080fd5b82356114f0816112a6565b946020939093013593505050565b8051801515811461150e57600080fd5b919050565b60006020828403121561152557600080fd5b61129f826114fe565b600060018060a01b038089168352808816602084015286604084015260a060608401528460a0840152848660c0850137600083860160c0908101919091529316608083015250601f909201601f191690910101949350505050565b60005b838110156115a457818101518382015260200161158c565b83811115610f655750506000910152565b600081518084526115cd816020860160208601611589565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090610a48908301846115b5565b805160ff8116811461150e57600080fd5b805161150e81611272565b805161150e816112a6565b60006101c0828403121561163f57600080fd5b61164761138d565b611650836114fe565b815261165e60208401611605565b602082015261166f60408401611616565b604082015261168060608401611616565b606082015261169160808401611616565b60808201526116a260a08401611616565b60a08201526116b360c084016114fe565b60c08201526116c460e084016114fe565b60e08201526101006116d7818501611621565b908201526101206116e9848201611621565b908201526101406116fb848201611621565b90820152610160838101519082015261018080840151908201526101a0928301519281019290925250919050565b60006020828403121561173b57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008282101561176a5761176a611742565b500390565b600080600080600060a0868803121561178757600080fd5b8551611792816112a6565b60208701519095506117a3816112a6565b60408701516060880151919550935067ffffffffffffffff8111156117c757600080fd5b8601601f810188136117d857600080fd5b80516117e6611458826113e8565b8181528960208385010111156117fb57600080fd5b61180c826020830160208601611589565b935061181d91505060808701611621565b90509295509295909350565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906111cc908301846115b5565b6000821982111561187657611876611742565b500190565b600081600019048311821515161561189557611895611742565b500290565b6000826118b757634e487b7160e01b600052601260045260246000fd5b500490565b600082516118ce818460208701611589565b9190910192915050565b60208152600061129f60208301846115b556fea26469706673582212209f094b46122f46b3f211c8a4705cfc8035b98f78e2b13a1b51807f05b25be2d564736f6c634300080a00330000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063978bbdb911610071578063978bbdb91461016b5780639b6899db14610193578063a15db5c5146101ba578063c04fb7c3146101cd578063d9d98ce4146101e0578063f2fde38b146101f357600080fd5b806329ff0773146100b95780635cffe9de146100ce578063613255ab146100f6578063715018a6146101175780638237e5381461011f5780638da5cb5b14610146575b600080fd5b6100cc6100c7366004611282565b610206565b005b6100e16100dc3660046112bb565b6102b2565b60405190151581526020015b60405180910390f35b61010961010436600461135a565b61049d565b6040519081526020016100ed565b6100cc610757565b6101097f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd981565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100ed565b60005461018090600160a01b900461ffff1681565b60405161ffff90911681526020016100ed565b6101537f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb81565b6100cc6101c8366004611410565b61076b565b6100cc6101db366004611490565b610833565b6101096101ee3660046114d2565b610896565b6100cc61020136600461135a565b610a50565b61020e610ac9565b6103e861ffff8216111561025c5760405162461bcd60e51b815260206004820152601060248201526f696e76616c696420666565207261746560801b60448201526064015b60405180910390fd5b6000805461ffff60a01b1916600160a01b61ffff8416908102919091179091556040519081527fa7e573bcaa01c752d835735eaf6642539f905efcbc1117da708c2ce84aa302bb9060200160405180910390a150565b604051633d98a1e560e01b81526001600160a01b0385811660048301526000917f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb90911690633d98a1e590602401602060405180830381865afa15801561031d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103419190611513565b6103805760405162461bcd60e51b815260206004820152601060248201526f1d1bdad95b881b9bdd081b1a5cdd195960821b6044820152606401610253565b600054600160b01b900460ff1661044d577f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb6001600160a01b03166389b7b7a6308888888888336040516020016103dc9695949392919061152e565b6040516020818303038152906040526040518363ffffffff1660e01b81526004016104089291906115e1565b600060405180830381600087803b15801561042257600080fd5b505af1158015610436573d6000803e3d6000fd5b50506000805460ff60b01b19169055506104919050565b61049186868686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250339250610b23915050565b50600195945050505050565b604051633d98a1e560e01b81526001600160a01b0382811660048301526000917f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb90911690633d98a1e590602401602060405180830381865afa158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c9190611513565b61053857506000919050565b604051632d1046a960e11b81526001600160a01b0383811660048301526000917f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb90911690635a208d52906024016101c060405180830381865afa1580156105a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c8919061162c565b90506105d381610e3a565b156105e15750600092915050565b604051634dcc86b960e11b81526001600160a01b0384811660048301526000917f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb90911690639b990d7290602401602060405180830381865afa15801561064c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106709190611729565b60405163429c68a760e11b81526001600160a01b0386811660048301529192506000917f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb1690638538d14e90602401602060405180830381865afa1580156106dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107009190611729565b905060008361018001516000141561071957508161074e565b81846101800151111561074e576000828561018001516107399190611758565b9050838110610748578361074a565b805b9150505b95945050505050565b61075f610ac9565b6107696000610e4e565b565b336001600160a01b037f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb16146107e35760405162461bcd60e51b815260206004820152601860248201527f756e74727573746564206d6573736167652073656e64657200000000000000006044820152606401610253565b6000806000806000858060200190518101906107ff919061176f565b6000805460ff60b01b1916600160b01b17905593985091965094509250905061082b8585858585610b23565b505050505050565b61083b610ac9565b61084f6001600160a01b0384168284610e9e565b604080516001600160a01b0385168152602081018490527fb930d7c3c6896f70ea10a959f1d9a7c04e0467138efa4c7040570d4b8f4894b6910160405180910390a1505050565b604051633d98a1e560e01b81526001600160a01b0383811660048301526000917f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb90911690633d98a1e590602401602060405180830381865afa158015610901573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109259190611513565b6109645760405162461bcd60e51b815260206004820152601060248201526f1d1bdad95b881b9bdd081b1a5cdd195960821b6044820152606401610253565b604051632d1046a960e11b81526001600160a01b0384811660048301526000917f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb90911690635a208d52906024016101c060405180830381865afa1580156109d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f4919061162c565b90506109ff81610e3a565b15610a3f5760405162461bcd60e51b815260206004820152601060248201526f189bdc9c9bddc81a5cc81c185d5cd95960821b6044820152606401610253565b610a4883610f06565b949350505050565b610a58610ac9565b6001600160a01b038116610abd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610253565b610ac681610e4e565b50565b6000546001600160a01b031633146107695760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610253565b6000610b2e84610f06565b60405163afef7efd60e01b81523060048201526001600160a01b0388811660248301528781166044830152606482018790529192507f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb9091169063afef7efd90608401600060405180830381600087803b158015610bab57600080fd5b505af1158015610bbf573d6000803e3d6000fd5b50506040516323e30c8b60e01b81527f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd992506001600160a01b03891691506323e30c8b90610c199086908a908a9088908b90600401611829565b6020604051808303816000875af1158015610c38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5c9190611729565b14610c9b5760405162461bcd60e51b815260206004820152600f60248201526e18d85b1b189858dac819985a5b1959608a1b6044820152606401610253565b610cbc8630610caa8488611863565b6001600160a01b038916929190610f2d565b604051636eb1769f60e11b81523060048201526001600160a01b037f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb811660248301526000919087169063dd62ed3e90604401602060405180830381865afa158015610d2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d509190611729565b905084811015610d9057610d906001600160a01b0387167f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb600019610f6b565b60405163c035bd2160e01b8152306004820181905260248201526001600160a01b038781166044830152606482018790527f0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb169063c035bd21906084016020604051808303816000875af1158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e309190611729565b5050505050505050565b602081015160009060021615155b92915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b038316602482015260448101829052610f0190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611080565b505050565b6000805461271090610f2390600160a01b900461ffff168461187b565b610e48919061189a565b6040516001600160a01b0380851660248301528316604482015260648101829052610f659085906323b872dd60e01b90608401610eca565b50505050565b801580610fe55750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610fbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe39190611729565b155b6110505760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610253565b6040516001600160a01b038316602482015260448101829052610f0190849063095ea7b360e01b90606401610eca565b60006110d5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111529092919063ffffffff16565b805190915015610f0157808060200190518101906110f39190611513565b610f015760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610253565b6060610a48848460008585600080866001600160a01b0316858760405161117991906118bc565b60006040518083038185875af1925050503d80600081146111b6576040519150601f19603f3d011682016040523d82523d6000602084013e6111bb565b606091505b50915091506111cc878383876111d7565b979650505050505050565b6060831561124357825161123c576001600160a01b0385163b61123c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610253565b5081610a48565b610a4883838151156112585781518083602001fd5b8060405162461bcd60e51b815260040161025391906118d8565b61ffff81168114610ac657600080fd5b60006020828403121561129457600080fd5b813561129f81611272565b9392505050565b6001600160a01b0381168114610ac657600080fd5b6000806000806000608086880312156112d357600080fd5b85356112de816112a6565b945060208601356112ee816112a6565b935060408601359250606086013567ffffffffffffffff8082111561131257600080fd5b818801915088601f83011261132657600080fd5b81358181111561133557600080fd5b89602082850101111561134757600080fd5b9699959850939650602001949392505050565b60006020828403121561136c57600080fd5b813561129f816112a6565b634e487b7160e01b600052604160045260246000fd5b6040516101c0810167ffffffffffffffff811182821017156113b1576113b1611377565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156113e0576113e0611377565b604052919050565b600067ffffffffffffffff82111561140257611402611377565b50601f01601f191660200190565b60006020828403121561142257600080fd5b813567ffffffffffffffff81111561143957600080fd5b8201601f8101841361144a57600080fd5b803561145d611458826113e8565b6113b7565b81815285602083850101111561147257600080fd5b81602084016020830137600091810160200191909152949350505050565b6000806000606084860312156114a557600080fd5b83356114b0816112a6565b92506020840135915060408401356114c7816112a6565b809150509250925092565b600080604083850312156114e557600080fd5b82356114f0816112a6565b946020939093013593505050565b8051801515811461150e57600080fd5b919050565b60006020828403121561152557600080fd5b61129f826114fe565b600060018060a01b038089168352808816602084015286604084015260a060608401528460a0840152848660c0850137600083860160c0908101919091529316608083015250601f909201601f191690910101949350505050565b60005b838110156115a457818101518382015260200161158c565b83811115610f655750506000910152565b600081518084526115cd816020860160208601611589565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090610a48908301846115b5565b805160ff8116811461150e57600080fd5b805161150e81611272565b805161150e816112a6565b60006101c0828403121561163f57600080fd5b61164761138d565b611650836114fe565b815261165e60208401611605565b602082015261166f60408401611616565b604082015261168060608401611616565b606082015261169160808401611616565b60808201526116a260a08401611616565b60a08201526116b360c084016114fe565b60c08201526116c460e084016114fe565b60e08201526101006116d7818501611621565b908201526101206116e9848201611621565b908201526101406116fb848201611621565b90820152610160838101519082015261018080840151908201526101a0928301519281019290925250919050565b60006020828403121561173b57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008282101561176a5761176a611742565b500390565b600080600080600060a0868803121561178757600080fd5b8551611792816112a6565b60208701519095506117a3816112a6565b60408701516060880151919550935067ffffffffffffffff8111156117c757600080fd5b8601601f810188136117d857600080fd5b80516117e6611458826113e8565b8181528960208385010111156117fb57600080fd5b61180c826020830160208601611589565b935061181d91505060808701611621565b90509295509295909350565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906111cc908301846115b5565b6000821982111561187657611876611742565b500190565b600081600019048311821515161561189557611895611742565b500290565b6000826118b757634e487b7160e01b600052601260045260246000fd5b500490565b600082516118ce818460208701611589565b9190910192915050565b60208152600061129f60208301846115b556fea26469706673582212209f094b46122f46b3f211c8a4705cfc8035b98f78e2b13a1b51807f05b25be2d564736f6c634300080a0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb

-----Decoded View---------------
Arg [0] : apeFinance_ (address): 0x9Cf2c7dD1bB947e398f9e12000f81656e4d65adB

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000009cf2c7dd1bb947e398f9e12000f81656e4d65adb


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.