ETH Price: $2,739.45 (-7.31%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Transfer Governa...133692942021-10-07 2:57:341575 days ago1633575454IN
Origin: OGN Buyback
0 ETH0.00749176156.40431351

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Buyback

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
/**
 *Submitted for verification at Etherscan.io on 2021-10-07
*/

/*
 * Origin Protocol
 * https://originprotocol.com
 *
 * Released under the MIT license
 * https://github.com/OriginProtocol/origin-dollar
 *
 * Copyright 2020 Origin Protocol, Inc
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
// File: contracts/governance/Governable.sol

pragma solidity ^0.8.0;

/**
 * @title OUSD Governable Contract
 * @dev Copy of the openzeppelin Ownable.sol contract with nomenclature change
 *      from owner to governor and renounce methods removed. Does not use
 *      Context.sol like Ownable.sol does for simplification.
 * @author Origin Protocol Inc
 */
contract Governable {
    // Storage position of the owner and pendingOwner of the contract
    // keccak256("OUSD.governor");
    bytes32 private constant governorPosition =
        0x7bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4a;

    // keccak256("OUSD.pending.governor");
    bytes32 private constant pendingGovernorPosition =
        0x44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db;

    // keccak256("OUSD.reentry.status");
    bytes32 private constant reentryStatusPosition =
        0x53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535;

    // See OpenZeppelin ReentrancyGuard implementation
    uint256 constant _NOT_ENTERED = 1;
    uint256 constant _ENTERED = 2;

    event PendingGovernorshipTransfer(
        address indexed previousGovernor,
        address indexed newGovernor
    );

    event GovernorshipTransferred(
        address indexed previousGovernor,
        address indexed newGovernor
    );

    /**
     * @dev Initializes the contract setting the deployer as the initial Governor.
     */
    constructor() {
        _setGovernor(msg.sender);
        emit GovernorshipTransferred(address(0), _governor());
    }

    /**
     * @dev Returns the address of the current Governor.
     */
    function governor() public view returns (address) {
        return _governor();
    }

    /**
     * @dev Returns the address of the current Governor.
     */
    function _governor() internal view returns (address governorOut) {
        bytes32 position = governorPosition;
        assembly {
            governorOut := sload(position)
        }
    }

    /**
     * @dev Returns the address of the pending Governor.
     */
    function _pendingGovernor()
        internal
        view
        returns (address pendingGovernor)
    {
        bytes32 position = pendingGovernorPosition;
        assembly {
            pendingGovernor := sload(position)
        }
    }

    /**
     * @dev Throws if called by any account other than the Governor.
     */
    modifier onlyGovernor() {
        require(isGovernor(), "Caller is not the Governor");
        _;
    }

    /**
     * @dev Returns true if the caller is the current Governor.
     */
    function isGovernor() public view returns (bool) {
        return msg.sender == _governor();
    }

    function _setGovernor(address newGovernor) internal {
        bytes32 position = governorPosition;
        assembly {
            sstore(position, newGovernor)
        }
    }

    /**
     * @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() {
        bytes32 position = reentryStatusPosition;
        uint256 _reentry_status;
        assembly {
            _reentry_status := sload(position)
        }

        // On the first call to nonReentrant, _notEntered will be true
        require(_reentry_status != _ENTERED, "Reentrant call");

        // Any calls to nonReentrant after this point will fail
        assembly {
            sstore(position, _ENTERED)
        }

        _;

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

    function _setPendingGovernor(address newGovernor) internal {
        bytes32 position = pendingGovernorPosition;
        assembly {
            sstore(position, newGovernor)
        }
    }

    /**
     * @dev Transfers Governance of the contract to a new account (`newGovernor`).
     * Can only be called by the current Governor. Must be claimed for this to complete
     * @param _newGovernor Address of the new Governor
     */
    function transferGovernance(address _newGovernor) external onlyGovernor {
        _setPendingGovernor(_newGovernor);
        emit PendingGovernorshipTransfer(_governor(), _newGovernor);
    }

    /**
     * @dev Claim Governance of the contract to a new account (`newGovernor`).
     * Can only be called by the new Governor.
     */
    function claimGovernance() external {
        require(
            msg.sender == _pendingGovernor(),
            "Only the pending Governor can complete the claim"
        );
        _changeGovernor(msg.sender);
    }

    /**
     * @dev Change Governance of the contract to a new account (`newGovernor`).
     * @param _newGovernor Address of the new Governor
     */
    function _changeGovernor(address _newGovernor) internal {
        require(_newGovernor != address(0), "New Governor is address(0)");
        emit GovernorshipTransferred(_governor(), _newGovernor);
        _setGovernor(_newGovernor);
    }
}

// File: contracts/interfaces/chainlink/AggregatorV3Interface.sol

pragma solidity ^0.8.0;

interface AggregatorV3Interface {
    function decimals() external view returns (uint8);

    function description() external view returns (string memory);

    function version() external view returns (uint256);

    // getRoundData and latestRoundData should both raise "No data present"
    // if they do not have data to report, instead of returning unset values
    // which could be misinterpreted as actual reported values.
    function getRoundData(uint80 _roundId)
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


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: @openzeppelin/contracts/utils/Address.sol


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: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol


pragma solidity ^0.8.0;



/**
 * @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: @openzeppelin/contracts/utils/math/SafeMath.sol


pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

// File: contracts/interfaces/UniswapV3Router.sol

pragma solidity ^0.8.0;

// -- Solididy v0.5.x compatible interface
interface UniswapV3Router {
    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params)
        external
        payable
        returns (uint256 amountOut);
}

// File: contracts/buyback/Buyback.sol

pragma solidity ^0.8.0;







contract Buyback is Governable {
    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    event UniswapUpdated(address _address);
    event BuybackFailed(bytes data);

    // Address of Uniswap
    address public uniswapAddr;

    // Address of OUSD Vault
    address public immutable vaultAddr;

    // Swap from OUSD
    IERC20 immutable ousd;

    // Swap to OGN
    IERC20 immutable ogn;

    // USDT for Uniswap path
    IERC20 immutable usdt;

    // WETH for Uniswap path
    IERC20 immutable weth9;

    // Oracles
    address immutable ognEthOracle;
    address immutable ethUsdOracle;

    constructor(
        address _uniswapAddr,
        address _vaultAddr,
        address _ousd,
        address _ogn,
        address _usdt,
        address _weth9,
        address _ognEthOracle,
        address _ethUsdOracle
    ) {
        uniswapAddr = _uniswapAddr;
        vaultAddr = _vaultAddr;
        ousd = IERC20(_ousd);
        ogn = IERC20(_ogn);
        usdt = IERC20(_usdt);
        weth9 = IERC20(_weth9);
        ognEthOracle = _ognEthOracle;
        ethUsdOracle = _ethUsdOracle;
        // Give approval to Uniswap router for OUSD, this is handled
        // by setUniswapAddr in the production contract
        IERC20(_ousd).safeApprove(uniswapAddr, 0);
        IERC20(_ousd).safeApprove(uniswapAddr, type(uint256).max);
    }

    /**
     * @dev Verifies that the caller is the OUSD Vault.
     */
    modifier onlyVault() {
        require(vaultAddr == msg.sender, "Caller is not the Vault");
        _;
    }

    /**
     * @dev Set address of Uniswap for performing liquidation of strategy reward
     * tokens. Setting to 0x0 will pause swaps.
     * @param _address Address of Uniswap
     */
    function setUniswapAddr(address _address) external onlyGovernor {
        uniswapAddr = _address;
        if (uniswapAddr == address(0)) return;
        // Give Uniswap unlimited OUSD allowance
        ousd.safeApprove(uniswapAddr, 0);
        ousd.safeApprove(uniswapAddr, type(uint256).max);
        emit UniswapUpdated(_address);
    }

    /**
     * @dev Execute a swap of OGN for OUSD via Uniswap or Uniswap compatible
     * protocol (e.g. Sushiswap)
     **/
    function swap() external onlyVault nonReentrant {
        uint256 sourceAmount = ousd.balanceOf(address(this));
        if (sourceAmount < 1000 * 1e18) return;
        if (uniswapAddr == address(0)) return;
        // 97% should be the limits of our oracle errors.
        // If this swap sometimes skips when it should succeed, that’s okay,
        // the amounts will get get sold the next time this runs,
        // when presumably the oracles are more accurate.
        uint256 minExpected = expectedOgnPerOUSD(sourceAmount).mul(97).div(100);

        UniswapV3Router.ExactInputParams memory params = UniswapV3Router
            .ExactInputParams({
                path: abi.encodePacked(
                    ousd,
                    uint24(500), // Pool fee, ousd -> usdt
                    usdt,
                    uint24(3000), // Pool fee, usdt -> weth9
                    weth9,
                    uint24(3000), // Pool fee, weth9 -> ogn
                    ogn
                ),
                recipient: address(this),
                deadline: uint256(block.timestamp.add(1000)),
                amountIn: sourceAmount,
                amountOutMinimum: minExpected
            });

        // Don't revert everything, even if the buyback fails.
        // We want the overall transaction to continue regardless.
        // We don't need to look at the return data, since the amount will
        // be above the minExpected.
        (bool success, bytes memory data) = uniswapAddr.call(
            abi.encodeWithSignature(
                "exactInput((bytes,address,uint256,uint256,uint256))",
                params
            )
        );
        if (!success) {
            emit BuybackFailed(data);
        }
    }

    function expectedOgnPerOUSD(uint256 ousdAmount)
        public
        view
        returns (uint256)
    {
        return
            ousdAmount.mul(uint256(1e26)).div( // ognEth is 18 decimal. ethUsd is 8 decimal.
                _price(ognEthOracle).mul(_price(ethUsdOracle))
            );
    }

    function _price(address _feed) internal view returns (uint256) {
        require(_feed != address(0), "Asset not available");
        (, int256 _iprice, , , ) = AggregatorV3Interface(_feed)
            .latestRoundData();
        require(_iprice > 0, "Price must be greater than zero");
        return uint256(_iprice);
    }

    /**
     * @notice Owner function to withdraw a specific amount of a token
     * @param token token to be transferered
     * @param amount amount of the token to be transferred
     */
    function transferToken(address token, uint256 amount)
        external
        onlyGovernor
        nonReentrant
    {
        IERC20(token).safeTransfer(_governor(), amount);
    }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_uniswapAddr","type":"address"},{"internalType":"address","name":"_vaultAddr","type":"address"},{"internalType":"address","name":"_ousd","type":"address"},{"internalType":"address","name":"_ogn","type":"address"},{"internalType":"address","name":"_usdt","type":"address"},{"internalType":"address","name":"_weth9","type":"address"},{"internalType":"address","name":"_ognEthOracle","type":"address"},{"internalType":"address","name":"_ethUsdOracle","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"BuybackFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernor","type":"address"}],"name":"GovernorshipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernor","type":"address"}],"name":"PendingGovernorshipTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"}],"name":"UniswapUpdated","type":"event"},{"inputs":[],"name":"claimGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ousdAmount","type":"uint256"}],"name":"expectedOgnPerOUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isGovernor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"setUniswapAddr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newGovernor","type":"address"}],"name":"transferGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101606040523480156200001257600080fd5b506040516200195238038062001952833981016040819052620000359162000538565b6200004d336000805160206200193283398151915255565b60008051602062001932833981519152546040516001600160a01b03909116906000907fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a908290a3600080546001600160a01b0319166001600160a01b038a8116918217835560608a811b6001600160601b03199081166080528a821b811660a05289821b811660c05288821b811660e05287821b81166101005286821b8116610120529085901b1661014052620001169290891691906200014e602090811b6200093017901c565b60005462000140906001600160a01b0388811691166000196200014e602090811b6200093017901c565b5050505050505050620006a4565b801580620001dc5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156200019f57600080fd5b505afa158015620001b4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001da919062000604565b155b620002545760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152620002ac918591620002b116565b505050565b60006200030d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200038f60201b62000a8c179092919060201c565b805190915015620002ac57808060200190518101906200032e9190620005e0565b620002ac5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016200024b565b6060620003a08484600085620003aa565b90505b9392505050565b6060824710156200040d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016200024b565b843b6200045d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200024b565b600080866001600160a01b031685876040516200047b91906200061e565b60006040518083038185875af1925050503d8060008114620004ba576040519150601f19603f3d011682016040523d82523d6000602084013e620004bf565b606091505b509092509050620004d2828286620004dd565b979650505050505050565b60608315620004ee575081620003a3565b825115620004ff5782518084602001fd5b8160405162461bcd60e51b81526004016200024b91906200063c565b80516001600160a01b03811681146200053357600080fd5b919050565b600080600080600080600080610100898b0312156200055657600080fd5b62000561896200051b565b97506200057160208a016200051b565b96506200058160408a016200051b565b95506200059160608a016200051b565b9450620005a160808a016200051b565b9350620005b160a08a016200051b565b9250620005c160c08a016200051b565b9150620005d160e08a016200051b565b90509295985092959890939650565b600060208284031215620005f357600080fd5b81518015158114620003a357600080fd5b6000602082840312156200061757600080fd5b5051919050565b600082516200063281846020870162000671565b9190910192915050565b60208152600082518060208401526200065d81604085016020870162000671565b601f01601f19169190910160400192915050565b60005b838110156200068e57818101518382015260200162000674565b838111156200069e576000848401525b50505050565b60805160601c60a05160601c60c05160601c60e05160601c6101005160601c6101205160601c6101405160601c6112026200073060003960006107f30152600061081c015260006105650152600061052e0152600061059501526000818161040b015281816104f701528181610741015261077b015260008181610151015261031401526112026000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063aea173d511610066578063aea173d514610100578063bc8cb9ed14610113578063c7af335214610134578063d27567f21461014c578063d38bfff41461017357600080fd5b80630c340a24146100a35780631072cbea146100c8578063128a8b05146100dd5780635d36b190146100f05780638119c065146100f8575b600080fd5b6100ab610186565b6040516001600160a01b0390911681526020015b60405180910390f35b6100db6100d6366004610f55565b6101a3565b005b6000546100ab906001600160a01b031681565b6100db61026c565b6100db610312565b6100db61010e366004610f3a565b6106e6565b610126610121366004610fa1565b6107e6565b6040519081526020016100bf565b61013c61085b565b60405190151581526020016100bf565b6100ab7f000000000000000000000000000000000000000000000000000000000000000081565b6100db610181366004610f3a565b61088c565b600061019e6000805160206111ad8339815191525490565b905090565b6101ab61085b565b6101d05760405162461bcd60e51b81526004016101c79061107e565b60405180910390fd5b7f53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535805460028114156102355760405162461bcd60e51b815260206004820152600e60248201526d1499595b9d1c985b9d0818d85b1b60921b60448201526064016101c7565b600282556102636102526000805160206111ad8339815191525490565b6001600160a01b0386169085610aa5565b50600190555050565b7f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db546001600160a01b0316336001600160a01b0316146103075760405162461bcd60e51b815260206004820152603060248201527f4f6e6c79207468652070656e64696e6720476f7665726e6f722063616e20636f60448201526f6d706c6574652074686520636c61696d60801b60648201526084016101c7565b61031033610ad5565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316331461038a5760405162461bcd60e51b815260206004820152601760248201527f43616c6c6572206973206e6f7420746865205661756c7400000000000000000060448201526064016101c7565b7f53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535805460028114156103ef5760405162461bcd60e51b815260206004820152600e60248201526d1499595b9d1c985b9d0818d85b1b60921b60448201526064016101c7565b600282556040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a082319060240160206040518083038186803b15801561045557600080fd5b505afa158015610469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061048d9190610fba565b9050683635c9adc5dea000008110156104a657506106df565b6000546001600160a01b03166104bc57506106df565b60006104dd60646104d760616104d1866107e6565b90610b96565b90610ba2565b6040805160a0810182526bffffffffffffffffffffffff197f0000000000000000000000000000000000000000000000000000000000000000606090811b821660c0840152607d60ea1b60d48401527f0000000000000000000000000000000000000000000000000000000000000000811b821660d784015261017760eb1b60eb84018190527f0000000000000000000000000000000000000000000000000000000000000000821b831660ee8501526101028401527f0000000000000000000000000000000000000000000000000000000000000000901b16610105820152815180820360f90181526101198201835281523060208201529192506000919081016105eb426103e8610bae565b81526020810185905260409081018490526000805491519293509182916001600160a01b0316906106209085906024016110b5565b60408051601f198184030181529181526020820180516001600160e01b031663c04b8d5960e01b17905251610655919061104f565b6000604051808303816000865af19150503d8060008114610692576040519150601f19603f3d011682016040523d82523d6000602084013e610697565b606091505b5091509150816106d9577f05efc8fe6a4600417061165582d83817e94b2c27b1e228fc5d953de832637500816040516106d0919061106b565b60405180910390a15b50505050505b5060019055565b6106ee61085b565b61070a5760405162461bcd60e51b81526004016101c79061107e565b600080546001600160a01b0319166001600160a01b03831690811790915561072f5750565b6000805461076a916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116921690610930565b6000546107a6906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169116600019610930565b6040516001600160a01b03821681527fca20db57f4368388dd6766259da48cd22a485cba21ee6ec8c519007cb66dfd039060200160405180910390a15b50565b60006108556108406108177f0000000000000000000000000000000000000000000000000000000000000000610bba565b6104d17f0000000000000000000000000000000000000000000000000000000000000000610bba565b6104d7846a52b7d2dcc80cd2e4000000610b96565b92915050565b60006108736000805160206111ad8339815191525490565b6001600160a01b0316336001600160a01b031614905090565b61089461085b565b6108b05760405162461bcd60e51b81526004016101c79061107e565b6108d8817f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db55565b806001600160a01b03166108f86000805160206111ad8339815191525490565b6001600160a01b03167fa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d60405160405180910390a350565b8015806109b95750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561097f57600080fd5b505afa158015610993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b79190610fba565b155b610a245760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016101c7565b6040516001600160a01b038316602482015260448101829052610a8790849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610cd1565b505050565b6060610a9b8484600085610da3565b90505b9392505050565b6040516001600160a01b038316602482015260448101829052610a8790849063a9059cbb60e01b90606401610a50565b6001600160a01b038116610b2b5760405162461bcd60e51b815260206004820152601a60248201527f4e657720476f7665726e6f72206973206164647265737328302900000000000060448201526064016101c7565b806001600160a01b0316610b4b6000805160206111ad8339815191525490565b6001600160a01b03167fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a60405160405180910390a36107e3816000805160206111ad83398151915255565b6000610a9e8284611147565b6000610a9e8284611125565b6000610a9e828461110d565b60006001600160a01b038216610c085760405162461bcd60e51b81526020600482015260136024820152724173736574206e6f7420617661696c61626c6560681b60448201526064016101c7565b6000826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610c4357600080fd5b505afa158015610c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7b9190610fd3565b505050915050600081136108555760405162461bcd60e51b815260206004820152601f60248201527f5072696365206d7573742062652067726561746572207468616e207a65726f0060448201526064016101c7565b6000610d26826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610a8c9092919063ffffffff16565b805190915015610a875780806020019051810190610d449190610f7f565b610a875760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101c7565b606082471015610e045760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101c7565b843b610e525760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101c7565b600080866001600160a01b03168587604051610e6e919061104f565b60006040518083038185875af1925050503d8060008114610eab576040519150601f19603f3d011682016040523d82523d6000602084013e610eb0565b606091505b5091509150610ec0828286610ecb565b979650505050505050565b60608315610eda575081610a9e565b825115610eea5782518084602001fd5b8160405162461bcd60e51b81526004016101c7919061106b565b80356001600160a01b0381168114610f1b57600080fd5b919050565b805169ffffffffffffffffffff81168114610f1b57600080fd5b600060208284031215610f4c57600080fd5b610a9e82610f04565b60008060408385031215610f6857600080fd5b610f7183610f04565b946020939093013593505050565b600060208284031215610f9157600080fd5b81518015158114610a9e57600080fd5b600060208284031215610fb357600080fd5b5035919050565b600060208284031215610fcc57600080fd5b5051919050565b600080600080600060a08688031215610feb57600080fd5b610ff486610f20565b945060208601519350604086015192506060860151915061101760808701610f20565b90509295509295909350565b6000815180845261103b816020860160208601611166565b601f01601f19169290920160200192915050565b60008251611061818460208701611166565b9190910192915050565b602081526000610a9e6020830184611023565b6020808252601a908201527f43616c6c6572206973206e6f742074686520476f7665726e6f72000000000000604082015260600190565b602081526000825160a060208401526110d160c0840182611023565b905060018060a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b6000821982111561112057611120611196565b500190565b60008261114257634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561116157611161611196565b500290565b60005b83811015611181578181015183820152602001611169565b83811115611190576000848401525b50505050565b634e487b7160e01b600052601160045260246000fdfe7bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4aa2646970667358221220de42304322e5516310d41c13a9b1af62e2a67b053863813191a7ca7694b6884464736f6c634300080700337bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4a0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000e75d77b1865ae93c7eaa3040b038d7aa7bc02f700000000000000000000000002a8e1e676ec238d8a992307b495b45b3feaa5e860000000000000000000000008207c1ffc5b6804f6024322ccf34f29c3541ae26000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000002c881b6f3f6b5ff6c975813f87a4dad0b241c15b0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063aea173d511610066578063aea173d514610100578063bc8cb9ed14610113578063c7af335214610134578063d27567f21461014c578063d38bfff41461017357600080fd5b80630c340a24146100a35780631072cbea146100c8578063128a8b05146100dd5780635d36b190146100f05780638119c065146100f8575b600080fd5b6100ab610186565b6040516001600160a01b0390911681526020015b60405180910390f35b6100db6100d6366004610f55565b6101a3565b005b6000546100ab906001600160a01b031681565b6100db61026c565b6100db610312565b6100db61010e366004610f3a565b6106e6565b610126610121366004610fa1565b6107e6565b6040519081526020016100bf565b61013c61085b565b60405190151581526020016100bf565b6100ab7f000000000000000000000000e75d77b1865ae93c7eaa3040b038d7aa7bc02f7081565b6100db610181366004610f3a565b61088c565b600061019e6000805160206111ad8339815191525490565b905090565b6101ab61085b565b6101d05760405162461bcd60e51b81526004016101c79061107e565b60405180910390fd5b7f53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535805460028114156102355760405162461bcd60e51b815260206004820152600e60248201526d1499595b9d1c985b9d0818d85b1b60921b60448201526064016101c7565b600282556102636102526000805160206111ad8339815191525490565b6001600160a01b0386169085610aa5565b50600190555050565b7f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db546001600160a01b0316336001600160a01b0316146103075760405162461bcd60e51b815260206004820152603060248201527f4f6e6c79207468652070656e64696e6720476f7665726e6f722063616e20636f60448201526f6d706c6574652074686520636c61696d60801b60648201526084016101c7565b61031033610ad5565b565b7f000000000000000000000000e75d77b1865ae93c7eaa3040b038d7aa7bc02f706001600160a01b0316331461038a5760405162461bcd60e51b815260206004820152601760248201527f43616c6c6572206973206e6f7420746865205661756c7400000000000000000060448201526064016101c7565b7f53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535805460028114156103ef5760405162461bcd60e51b815260206004820152600e60248201526d1499595b9d1c985b9d0818d85b1b60921b60448201526064016101c7565b600282556040516370a0823160e01b81523060048201526000907f0000000000000000000000002a8e1e676ec238d8a992307b495b45b3feaa5e866001600160a01b0316906370a082319060240160206040518083038186803b15801561045557600080fd5b505afa158015610469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061048d9190610fba565b9050683635c9adc5dea000008110156104a657506106df565b6000546001600160a01b03166104bc57506106df565b60006104dd60646104d760616104d1866107e6565b90610b96565b90610ba2565b6040805160a0810182526bffffffffffffffffffffffff197f0000000000000000000000002a8e1e676ec238d8a992307b495b45b3feaa5e86606090811b821660c0840152607d60ea1b60d48401527f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7811b821660d784015261017760eb1b60eb84018190527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2821b831660ee8501526101028401527f0000000000000000000000008207c1ffc5b6804f6024322ccf34f29c3541ae26901b16610105820152815180820360f90181526101198201835281523060208201529192506000919081016105eb426103e8610bae565b81526020810185905260409081018490526000805491519293509182916001600160a01b0316906106209085906024016110b5565b60408051601f198184030181529181526020820180516001600160e01b031663c04b8d5960e01b17905251610655919061104f565b6000604051808303816000865af19150503d8060008114610692576040519150601f19603f3d011682016040523d82523d6000602084013e610697565b606091505b5091509150816106d9577f05efc8fe6a4600417061165582d83817e94b2c27b1e228fc5d953de832637500816040516106d0919061106b565b60405180910390a15b50505050505b5060019055565b6106ee61085b565b61070a5760405162461bcd60e51b81526004016101c79061107e565b600080546001600160a01b0319166001600160a01b03831690811790915561072f5750565b6000805461076a916001600160a01b037f0000000000000000000000002a8e1e676ec238d8a992307b495b45b3feaa5e868116921690610930565b6000546107a6906001600160a01b037f0000000000000000000000002a8e1e676ec238d8a992307b495b45b3feaa5e8681169116600019610930565b6040516001600160a01b03821681527fca20db57f4368388dd6766259da48cd22a485cba21ee6ec8c519007cb66dfd039060200160405180910390a15b50565b60006108556108406108177f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419610bba565b6104d17f0000000000000000000000002c881b6f3f6b5ff6c975813f87a4dad0b241c15b610bba565b6104d7846a52b7d2dcc80cd2e4000000610b96565b92915050565b60006108736000805160206111ad8339815191525490565b6001600160a01b0316336001600160a01b031614905090565b61089461085b565b6108b05760405162461bcd60e51b81526004016101c79061107e565b6108d8817f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db55565b806001600160a01b03166108f86000805160206111ad8339815191525490565b6001600160a01b03167fa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d60405160405180910390a350565b8015806109b95750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561097f57600080fd5b505afa158015610993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b79190610fba565b155b610a245760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016101c7565b6040516001600160a01b038316602482015260448101829052610a8790849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610cd1565b505050565b6060610a9b8484600085610da3565b90505b9392505050565b6040516001600160a01b038316602482015260448101829052610a8790849063a9059cbb60e01b90606401610a50565b6001600160a01b038116610b2b5760405162461bcd60e51b815260206004820152601a60248201527f4e657720476f7665726e6f72206973206164647265737328302900000000000060448201526064016101c7565b806001600160a01b0316610b4b6000805160206111ad8339815191525490565b6001600160a01b03167fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a60405160405180910390a36107e3816000805160206111ad83398151915255565b6000610a9e8284611147565b6000610a9e8284611125565b6000610a9e828461110d565b60006001600160a01b038216610c085760405162461bcd60e51b81526020600482015260136024820152724173736574206e6f7420617661696c61626c6560681b60448201526064016101c7565b6000826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610c4357600080fd5b505afa158015610c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7b9190610fd3565b505050915050600081136108555760405162461bcd60e51b815260206004820152601f60248201527f5072696365206d7573742062652067726561746572207468616e207a65726f0060448201526064016101c7565b6000610d26826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610a8c9092919063ffffffff16565b805190915015610a875780806020019051810190610d449190610f7f565b610a875760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101c7565b606082471015610e045760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101c7565b843b610e525760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101c7565b600080866001600160a01b03168587604051610e6e919061104f565b60006040518083038185875af1925050503d8060008114610eab576040519150601f19603f3d011682016040523d82523d6000602084013e610eb0565b606091505b5091509150610ec0828286610ecb565b979650505050505050565b60608315610eda575081610a9e565b825115610eea5782518084602001fd5b8160405162461bcd60e51b81526004016101c7919061106b565b80356001600160a01b0381168114610f1b57600080fd5b919050565b805169ffffffffffffffffffff81168114610f1b57600080fd5b600060208284031215610f4c57600080fd5b610a9e82610f04565b60008060408385031215610f6857600080fd5b610f7183610f04565b946020939093013593505050565b600060208284031215610f9157600080fd5b81518015158114610a9e57600080fd5b600060208284031215610fb357600080fd5b5035919050565b600060208284031215610fcc57600080fd5b5051919050565b600080600080600060a08688031215610feb57600080fd5b610ff486610f20565b945060208601519350604086015192506060860151915061101760808701610f20565b90509295509295909350565b6000815180845261103b816020860160208601611166565b601f01601f19169290920160200192915050565b60008251611061818460208701611166565b9190910192915050565b602081526000610a9e6020830184611023565b6020808252601a908201527f43616c6c6572206973206e6f742074686520476f7665726e6f72000000000000604082015260600190565b602081526000825160a060208401526110d160c0840182611023565b905060018060a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b6000821982111561112057611120611196565b500190565b60008261114257634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561116157611161611196565b500290565b60005b83811015611181578181015183820152602001611169565b83811115611190576000848401525b50505050565b634e487b7160e01b600052601160045260246000fdfe7bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4aa2646970667358221220de42304322e5516310d41c13a9b1af62e2a67b053863813191a7ca7694b6884464736f6c63430008070033

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

0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000e75d77b1865ae93c7eaa3040b038d7aa7bc02f700000000000000000000000002a8e1e676ec238d8a992307b495b45b3feaa5e860000000000000000000000008207c1ffc5b6804f6024322ccf34f29c3541ae26000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000002c881b6f3f6b5ff6c975813f87a4dad0b241c15b0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419

-----Decoded View---------------
Arg [0] : _uniswapAddr (address): 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
Arg [1] : _vaultAddr (address): 0xE75D77B1865Ae93c7eaa3040B038D7aA7BC02F70
Arg [2] : _ousd (address): 0x2A8e1E676Ec238d8A992307B495b45B3fEAa5e86
Arg [3] : _ogn (address): 0x8207c1FfC5B6804F6024322CcF34F29c3541Ae26
Arg [4] : _usdt (address): 0xdAC17F958D2ee523a2206206994597C13D831ec7
Arg [5] : _weth9 (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [6] : _ognEthOracle (address): 0x2c881B6f3f6B5ff6C975813F87A4dad0b241C15b
Arg [7] : _ethUsdOracle (address): 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d
Arg [1] : 000000000000000000000000e75d77b1865ae93c7eaa3040b038d7aa7bc02f70
Arg [2] : 0000000000000000000000002a8e1e676ec238d8a992307b495b45b3feaa5e86
Arg [3] : 0000000000000000000000008207c1ffc5b6804f6024322ccf34f29c3541ae26
Arg [4] : 000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7
Arg [5] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [6] : 0000000000000000000000002c881b6f3f6b5ff6c975813f87a4dad0b241c15b
Arg [7] : 0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.