Contract 0xf5d215d9c84778f85746d15762daf39b9e83a2d6 1

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x6efcb114953c608f37d2ce4042bd519ded28b8e696b840207f7f8cf70a086201Set Input Bound338790162022-10-03 12:53:337 hrs 52 mins ago0x7c8a5d20b22ce9b369c043a3e0091b5575b732d9 IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.001002087229 31.682545446
0x018f81d43136960dd1cf9236311601999c4ecbef320a4e72031d5cecbdbc9cc7Set Input Bound338789962022-10-03 12:52:537 hrs 52 mins ago0x7c8a5d20b22ce9b369c043a3e0091b5575b732d9 IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.0010815819 34.3
0x534bd454e7312ad18a23ecb137b019f72e9cb1aa163df75ea4f4ce1b2d4b7524Set Input Bound338789762022-10-03 12:52:137 hrs 53 mins ago0x7c8a5d20b22ce9b369c043a3e0091b5575b732d9 IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.001239856799 39.199999999
0x23395ad8a1c5edd8269d3a5e3d69c7a5f32a9cf4dcc792121777a2e12924c466Set Input Bound338788922022-10-03 12:49:177 hrs 56 mins ago0x7c8a5d20b22ce9b369c043a3e0091b5575b732d9 IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.00102326994 32.340000025
0xeec56c11774a24f835b0e552c33933da383dbfb87fbb213fd3faed94ad0b49efSet Input Bound338788872022-10-03 12:49:077 hrs 56 mins ago0x7c8a5d20b22ce9b369c043a3e0091b5575b732d9 IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.00094635 30.000000018
0x744386f6ec81e18d87be21f27eb10d9801223fbbe5ee87fe1fa8b961d407ab67Claim Ownership338786802022-10-03 12:42:018 hrs 3 mins ago0x7c8a5d20b22ce9b369c043a3e0091b5575b732d9 IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.00099816 30.000000018
0x49de1c36545975d25241cf3dcec8ff5ca27f7aa6784c8900a5d75deba73ac264Set Input Bound302128572022-07-01 11:59:3494 days 8 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.000948510005 30.000000174
0x8b8f04a3e5be2654d59a8a6fc92e23fc2af3bf064d903d811e6c12f44f7bfc74Transfer Ownersh...301599842022-06-30 3:11:0395 days 17 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.000920160002 30.000000066
0x5804aa4351cc95da69fb67930ae9cc06fc26991e4a298470d9daa2a8c814452dSet Token298703612022-06-22 14:31:01103 days 6 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.00353912867 37.970631719
0x6028b1ce57aa5c23e5548d1ad8ae9d45e17b7b85fe7bf5027cb8f148b982dc91Set Token298703422022-06-22 14:30:23103 days 6 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.003556154575 38.178695318
0x607d342f6572177cd9239fb355995ba74a8cbc84e9b7a94d7e8427b0bdcd8a04Set Token298703332022-06-22 14:30:01103 days 6 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.00357242114 40.634944438
0x7a1d6c5dde95cfd6e29d2e00e7c24690cc788a99ca364a631d51f7dfdceb636fSet Token298703242022-06-22 14:29:43103 days 6 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.003815613354 43.400176926
0x7c719ca312eea03712e354acc4c75a8ec0e2f56817f714215e65dca3e21add99Set Token298703052022-06-22 14:29:05103 days 6 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.004404124567 47.389299698
0x6da97dd724e99999b30cd63f5ec3d54ba794598d14ff90747a6cfed3e2e7dc78Set Global Bound298696442022-06-22 14:06:22103 days 6 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  0xf5d215d9c84778f85746d15762daf39b9e83a2d60 MATIC0.003629822402 79.065595038
0x1f0c8ffda544cb16e890a269d4c05107f1fd08e33a14e41884b8b6186a9aed8a0x60806040298596352022-06-22 7:40:59103 days 13 hrs ago0x97471c0fdddb5e5cc34cb08cb17961bd3a53f38f IN  Create: WooGuardian0 MATIC0.0620357640
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
WooGuardian

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 10 : WooGuardian.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.6.12;
pragma experimental ABIEncoderV2;

/*

░██╗░░░░░░░██╗░█████╗░░█████╗░░░░░░░███████╗██╗
░██║░░██╗░░██║██╔══██╗██╔══██╗░░░░░░██╔════╝██║
░╚██╗████╗██╔╝██║░░██║██║░░██║█████╗█████╗░░██║
░░████╔═████║░██║░░██║██║░░██║╚════╝██╔══╝░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝╚█████╔╝░░░░░░██║░░░░░██║
░░░╚═╝░░░╚═╝░░░╚════╝░░╚════╝░░░░░░░╚═╝░░░░░╚═╝

*
* MIT License
* ===========
*
* Copyright (c) 2020 WooTrade
*
* 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.
*/

import './libraries/InitializableOwnable.sol';
import './libraries/DecimalMath.sol';
import './interfaces/IWooGuardian.sol';
import './interfaces/AggregatorV3Interface.sol';

import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/math/SafeMath.sol';

/// @title Woo guardian implementation.
contract WooGuardian is IWooGuardian, InitializableOwnable {
    using SafeMath for uint256;
    using DecimalMath for uint256;

    /* ----- Type declarations ----- */

    struct RefInfo {
        address chainlinkRefOracle; // chainlink oracle for price checking
        uint96 refPriceFixCoeff; // chainlink price fix coeff
        uint96 minInputAmount;
        uint96 maxInputAmount;
        uint64 bound;
    }

    /* ----- Events declarations ----- */
    event InputBoundUpdated(address indexed token, uint96 minInputAmount, uint96 maxInputAmount);

    /* ----- State variables ----- */

    uint96 constant MIN_INPUT_DEFAULT = 1e16; // 0.01 xToken

    uint96 constant MAX_INPUT_DEFAULT = 1e20; //  100 xToken

    mapping(address => RefInfo) public refInfo;

    // the bound for checking the price:
    // 1e18 = 100%, 1e17 = 10%, 1e16 = 1%, 1e15 = 0.1%, etc
    // NOTE:
    // globalBound <= 1e18 (100%)
    uint64 public globalBound;

    constructor() public {
        initOwner(msg.sender);
    }

    /* ----- External APIs ----- */

    function checkSwapPrice(
        uint256 price,
        address fromToken,
        address toToken
    ) external view override {
        require(fromToken != address(0), 'WooGuardian: fromToken_ZERO_ADDR');
        require(toToken != address(0), 'WooGuardian: toToken_ZERO_ADDR');

        if (refInfo[fromToken].chainlinkRefOracle == address(0) || refInfo[toToken].chainlinkRefOracle == address(0)) {
            return;
        }

        uint256 refPrice = _refPrice(fromToken, toToken);
        uint64 bound = _boundForTokens(fromToken, toToken);
        require(
            refPrice.mulFloor(1e18 - bound) <= price && price <= refPrice.mulCeil(1e18 + bound),
            'WooGuardian: PRICE_UNRELIABLE'
        );
    }

    function checkInputAmount(address token, uint256 inputAmount) external view override {
        require(token != address(0), 'WooGuardian: token_ZERO_ADDR');
        require(inputAmount < type(uint96).max, 'WooGuardian: inputAmount_uint96_OVERFLOW');
        RefInfo storage info = refInfo[token];
        uint96 minInputAmount = info.minInputAmount != 0 ? info.minInputAmount : MIN_INPUT_DEFAULT;
        uint96 maxInputAmount = info.maxInputAmount != 0 ? info.maxInputAmount : MAX_INPUT_DEFAULT;
        require(uint96(inputAmount) >= minInputAmount, 'WooGuardian: inputAmount_LTM');
        require(uint96(inputAmount) <= maxInputAmount, 'WooGuardian: inputAmount_GTM');
    }

    function checkSwapAmount(
        address fromToken,
        address toToken,
        uint256 fromAmount,
        uint256 toAmount
    ) external view override {
        require(fromToken != address(0), 'WooGuardian: fromToken_ZERO_ADDR');
        require(toToken != address(0), 'WooGuardian: toToken_ZERO_ADDR');

        if (refInfo[fromToken].chainlinkRefOracle == address(0) || refInfo[toToken].chainlinkRefOracle == address(0)) {
            return;
        }

        uint256 refPrice = _refPrice(fromToken, toToken);
        uint256 refToAmount = fromAmount.mulFloor(refPrice);
        uint64 bound = _boundForTokens(fromToken, toToken);
        require(
            refToAmount.mulFloor(1e18 - bound) <= toAmount && toAmount <= refToAmount.mulCeil(1e18 + bound),
            'WooGuardian: TO_AMOUNT_UNRELIABLE'
        );
    }

    function setToken(
        address token,
        address chainlinkRefOracle,
        uint96 minInputAmount,
        uint96 maxInputAmount
    ) external onlyOwner {
        require(token != address(0), 'WooGuardian: token_ZERO_ADDR');

        setInputBound(token, minInputAmount, maxInputAmount);

        RefInfo storage info = refInfo[token];
        info.chainlinkRefOracle = chainlinkRefOracle;
        info.refPriceFixCoeff = _refPriceFixCoeff(token, chainlinkRefOracle);
        emit ChainlinkRefOracleUpdated(token, chainlinkRefOracle);
    }

    function setInputBound(
        address token,
        uint96 minInputAmount,
        uint96 maxInputAmount
    ) public onlyOwner {
        require(token != address(0), 'WooGuardian: token_ZERO_ADDR');
        require(minInputAmount < maxInputAmount, 'WooGuardian: min_max_INVALID');
        RefInfo storage info = refInfo[token];
        info.minInputAmount = minInputAmount;
        info.maxInputAmount = maxInputAmount;
        emit InputBoundUpdated(token, minInputAmount, maxInputAmount);
    }

    function setGlobalBound(uint64 newBound) external onlyOwner {
        require(newBound <= 1e18, 'WooGuardian: newBound out of range');
        globalBound = newBound;
    }

    function setTokenBound(address token, uint64 newBound) external onlyOwner {
        require(token != address(0), 'WooGuardian: token_ZERO_ADDR');
        require(newBound <= 1e18, 'WooGuardian: newBound out of range');
        RefInfo storage info = refInfo[token];
        info.bound = newBound;
    }

    /* ----- Private Methods ----- */

    function _refPriceFixCoeff(address token, address chainlink) private view returns (uint96) {
        if (chainlink == address(0)) {
            return 0;
        }

        // About decimals:
        // For a sell base trade, we have quoteSize = baseSize * price
        // For calculation convenience, the decimals of price is 18-base.decimals+quote.decimals
        // If we have price = basePrice / quotePrice, then decimals of tokenPrice should be 36-token.decimals()
        // We use chainlink oracle price as token reference price, which decimals is chainlinkPrice.decimals()
        // We should multiply it by 10e(36-(token.decimals+chainlinkPrice.decimals)), which is refPriceFixCoeff
        uint256 decimalsToFix = uint256(ERC20(token).decimals()).add(
            uint256(AggregatorV3Interface(chainlink).decimals())
        );
        uint256 refPriceFixCoeff = 10**(uint256(36).sub(decimalsToFix));
        require(refPriceFixCoeff <= type(uint96).max);
        return uint96(refPriceFixCoeff);
    }

    function _refPrice(address fromToken, address toToken) private view returns (uint256) {
        RefInfo memory baseInfo = refInfo[fromToken];
        RefInfo memory quoteInfo = refInfo[toToken];

        require(baseInfo.chainlinkRefOracle != address(0), 'WooGuardian: fromToken_RefOracle_INVALID');
        require(quoteInfo.chainlinkRefOracle != address(0), 'WooGuardian: toToken_RefOracle_INVALID');

        (, int256 rawBaseRefPrice, , , ) = AggregatorV3Interface(baseInfo.chainlinkRefOracle).latestRoundData();
        require(rawBaseRefPrice >= 0, 'WooGuardian: INVALID_CHAINLINK_PRICE');
        (, int256 rawQuoteRefPrice, , , ) = AggregatorV3Interface(quoteInfo.chainlinkRefOracle).latestRoundData();
        require(rawQuoteRefPrice >= 0, 'WooGuardian: INVALID_CHAINLINK_QUOTE_PRICE');
        uint256 baseRefPrice = uint256(rawBaseRefPrice).mul(uint256(baseInfo.refPriceFixCoeff));
        uint256 quoteRefPrice = uint256(rawQuoteRefPrice).mul(uint256(quoteInfo.refPriceFixCoeff));

        return baseRefPrice.divFloor(quoteRefPrice);
    }

    function _boundForTokens(address token1, address token2) private view returns (uint64) {
        RefInfo storage info1 = refInfo[token1];
        uint64 bound1 = info1.bound != 0 ? info1.bound : globalBound;

        RefInfo storage info2 = refInfo[token2];
        uint64 bound2 = info2.bound != 0 ? info2.bound : globalBound;

        return bound1 > bound2 ? bound1 : bound2;
    }

    function boundForTokensForTest(address token1, address token2) external view returns (uint64) {
        return _boundForTokens(token1, token2);
    }
}

File 2 of 10 : InitializableOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.6.12;
pragma experimental ABIEncoderV2;

/**
 * @title Ownable initializable contract.
 *
 * @notice Ownership related functions
 */
contract InitializableOwnable {
    address public _OWNER_;
    address public _NEW_OWNER_;
    bool internal _INITIALIZED_;

    // ============ Events ============

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

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

    // ============ Modifiers ============

    modifier notInitialized() {
        require(!_INITIALIZED_, 'InitializableOwnable: SHOULD_NOT_BE_INITIALIZED');
        _;
    }

    modifier onlyOwner() {
        require(msg.sender == _OWNER_, 'InitializableOwnable: NOT_OWNER');
        _;
    }

    // ============ Functions ============

    /// @dev Init _OWNER_ from newOwner and set _INITIALIZED_ as true
    /// @param newOwner new owner address
    function initOwner(address newOwner) public notInitialized {
        _INITIALIZED_ = true;
        _OWNER_ = newOwner;
    }

    /// @dev Set _NEW_OWNER_ from newOwner
    /// @param newOwner new owner address
    function transferOwnership(address newOwner) public onlyOwner {
        emit OwnershipTransferPrepared(_OWNER_, newOwner);
        _NEW_OWNER_ = newOwner;
    }

    /// @dev Set _OWNER_ from _NEW_OWNER_ and set _NEW_OWNER_ equal zero address
    function claimOwnership() public {
        require(msg.sender == _NEW_OWNER_, 'InitializableOwnable: INVALID_CLAIM');
        emit OwnershipTransferred(_OWNER_, _NEW_OWNER_);
        _OWNER_ = _NEW_OWNER_;
        _NEW_OWNER_ = address(0);
    }
}

File 3 of 10 : DecimalMath.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.6.12;
pragma experimental ABIEncoderV2;

import '@openzeppelin/contracts/math/SafeMath.sol';

/**
 * @title DecimalMath
 *
 * @notice Functions for fixed point number with 18 decimals
 */
library DecimalMath {
    using SafeMath for uint256;

    uint256 internal constant ONE = 10**18;
    uint256 internal constant TWO = 2 * 10**18;
    uint256 internal constant ONE2 = 10**36;

    function mulFloor(uint256 target, uint256 d) internal pure returns (uint256) {
        return target.mul(d) / (10**18);
    }

    function mulCeil(uint256 target, uint256 d) internal pure returns (uint256) {
        return _divCeil(target.mul(d), 10**18);
    }

    function divFloor(uint256 target, uint256 d) internal pure returns (uint256) {
        return target.mul(10**18).div(d);
    }

    function divCeil(uint256 target, uint256 d) internal pure returns (uint256) {
        return _divCeil(target.mul(10**18), d);
    }

    function reciprocalFloor(uint256 target) internal pure returns (uint256) {
        return uint256(10**36).div(target);
    }

    function reciprocalCeil(uint256 target) internal pure returns (uint256) {
        return _divCeil(uint256(10**36), target);
    }

    function _divCeil(uint256 a, uint256 b) private pure returns (uint256) {
        uint256 quotient = a.div(b);
        uint256 remainder = a - quotient * b;
        if (remainder > 0) {
            return quotient + 1;
        } else {
            return quotient;
        }
    }
}

File 4 of 10 : IWooGuardian.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.6.12;
pragma experimental ABIEncoderV2;

/*

░██╗░░░░░░░██╗░█████╗░░█████╗░░░░░░░███████╗██╗
░██║░░██╗░░██║██╔══██╗██╔══██╗░░░░░░██╔════╝██║
░╚██╗████╗██╔╝██║░░██║██║░░██║█████╗█████╗░░██║
░░████╔═████║░██║░░██║██║░░██║╚════╝██╔══╝░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝╚█████╔╝░░░░░░██║░░░░░██║
░░░╚═╝░░░╚═╝░░░╚════╝░░╚════╝░░░░░░░╚═╝░░░░░╚═╝

*
* MIT License
* ===========
*
* Copyright (c) 2020 WooTrade
*
* 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.
*/

import '../interfaces/IWooPP.sol';

/// @title Guardian interface to ensure the trading price and volume correct
interface IWooGuardian {
    event ChainlinkRefOracleUpdated(address indexed token, address indexed chainlinkRefOracle);

    /* ----- Main check APIs ----- */

    function checkSwapPrice(
        uint256 price,
        address fromToken,
        address toToken
    ) external view;

    function checkInputAmount(address token, uint256 inputAmount) external view;

    function checkSwapAmount(
        address fromToken,
        address toToken,
        uint256 fromAmount,
        uint256 toAmount
    ) external view;
}

File 5 of 10 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.6.12;
pragma experimental ABIEncoderV2;

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 6 of 10 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

File 7 of 10 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
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) {
        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) {
        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) {
        // 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) {
        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) {
        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) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @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) {
        require(b <= a, "SafeMath: subtraction overflow");
        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) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @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. 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) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        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) {
        require(b > 0, "SafeMath: modulo by zero");
        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) {
        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.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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) {
        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) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 8 of 10 : IWooPP.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.6.12;
pragma experimental ABIEncoderV2;

/*

░██╗░░░░░░░██╗░█████╗░░█████╗░░░░░░░███████╗██╗
░██║░░██╗░░██║██╔══██╗██╔══██╗░░░░░░██╔════╝██║
░╚██╗████╗██╔╝██║░░██║██║░░██║█████╗█████╗░░██║
░░████╔═████║░██║░░██║██║░░██║╚════╝██╔══╝░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝╚█████╔╝░░░░░░██║░░░░░██║
░░░╚═╝░░░╚═╝░░░╚════╝░░╚════╝░░░░░░░╚═╝░░░░░╚═╝

*
* MIT License
* ===========
*
* Copyright (c) 2020 WooTrade
*
* 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.
*/

/// @title Woo private pool for swap.
/// @notice Use this contract to directly interfact with woo's synthetic proactive
///         marketing making pool.
/// @author woo.network
interface IWooPP {
    /* ----- Type declarations ----- */

    /// @dev struct info to store the token info
    struct TokenInfo {
        uint112 reserve; // Token balance
        uint112 threshold; // Threshold for reserve update
        uint32 lastResetTimestamp; // Timestamp for last param update
        uint64 lpFeeRate; // Fee rate: e.g. 0.001 = 0.1%
        uint64 R; // Rebalance coefficient [0, 1]
        uint112 target; // Targeted balance for pricing
        bool isValid; // is this token info valid
    }

    /* ----- Events ----- */

    event StrategistUpdated(address indexed strategist, bool flag);
    event RewardManagerUpdated(address indexed newRewardManager);
    event WooracleUpdated(address indexed newWooracle);
    event WooGuardianUpdated(address indexed newWooGuardian);
    event ParametersUpdated(address indexed baseToken, uint256 newThreshold, uint256 newLpFeeRate, uint256 newR);
    event Withdraw(address indexed token, address indexed to, uint256 amount);
    event WooSwap(
        address indexed fromToken,
        address indexed toToken,
        uint256 fromAmount,
        uint256 toAmount,
        address from,
        address indexed to
    );

    /* ----- External Functions ----- */

    /// @dev Swap baseToken into quoteToken
    /// @param baseToken the base token
    /// @param baseAmount amount of baseToken that user want to swap
    /// @param minQuoteAmount minimum amount of quoteToken that user accept to receive
    /// @param to quoteToken receiver address
    /// @param rebateTo the wallet address for rebate
    /// @return quoteAmount the swapped amount of quote token
    function sellBase(
        address baseToken,
        uint256 baseAmount,
        uint256 minQuoteAmount,
        address to,
        address rebateTo
    ) external returns (uint256 quoteAmount);

    /// @dev Swap quoteToken into baseToken
    /// @param baseToken the base token
    /// @param quoteAmount amount of quoteToken that user want to swap
    /// @param minBaseAmount minimum amount of baseToken that user accept to receive
    /// @param to baseToken receiver address
    /// @param rebateTo the wallet address for rebate
    /// @return baseAmount the swapped amount of base token
    function sellQuote(
        address baseToken,
        uint256 quoteAmount,
        uint256 minBaseAmount,
        address to,
        address rebateTo
    ) external returns (uint256 baseAmount);

    /// @dev Query the amount for selling the base token amount.
    /// @param baseToken the base token to sell
    /// @param baseAmount the amount to sell
    /// @return quoteAmount the swapped quote amount
    function querySellBase(address baseToken, uint256 baseAmount) external view returns (uint256 quoteAmount);

    /// @dev Query the amount for selling the quote token.
    /// @param baseToken the base token to receive (buy)
    /// @param quoteAmount the amount to sell
    /// @return baseAmount the swapped base token amount
    function querySellQuote(address baseToken, uint256 quoteAmount) external view returns (uint256 baseAmount);

    /// @dev get the quote token address
    /// @return address of quote token
    function quoteToken() external view returns (address);
}

File 9 of 10 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 10 of 10 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"chainlinkRefOracle","type":"address"}],"name":"ChainlinkRefOracleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint96","name":"minInputAmount","type":"uint96"},{"indexed":false,"internalType":"uint96","name":"maxInputAmount","type":"uint96"}],"name":"InputBoundUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferPrepared","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"},{"inputs":[],"name":"_NEW_OWNER_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_OWNER_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token1","type":"address"},{"internalType":"address","name":"token2","type":"address"}],"name":"boundForTokensForTest","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"}],"name":"checkInputAmount","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"}],"name":"checkSwapAmount","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"}],"name":"checkSwapPrice","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"globalBound","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"initOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"refInfo","outputs":[{"internalType":"address","name":"chainlinkRefOracle","type":"address"},{"internalType":"uint96","name":"refPriceFixCoeff","type":"uint96"},{"internalType":"uint96","name":"minInputAmount","type":"uint96"},{"internalType":"uint96","name":"maxInputAmount","type":"uint96"},{"internalType":"uint64","name":"bound","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"newBound","type":"uint64"}],"name":"setGlobalBound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint96","name":"minInputAmount","type":"uint96"},{"internalType":"uint96","name":"maxInputAmount","type":"uint96"}],"name":"setInputBound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"chainlinkRefOracle","type":"address"},{"internalType":"uint96","name":"minInputAmount","type":"uint96"},{"internalType":"uint96","name":"maxInputAmount","type":"uint96"}],"name":"setToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint64","name":"newBound","type":"uint64"}],"name":"setTokenBound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5061001a3361001f565b6100d7565b600154600160a01b900460ff16156100525760405162461bcd60e51b815260040161004990610088565b60405180910390fd5b6001805460ff60a01b1916600160a01b179055600080546001600160a01b039092166001600160a01b0319909216919091179055565b6020808252602f908201527f496e697469616c697a61626c654f776e61626c653a2053484f554c445f4e4f5460408201526e17d09157d253925512505312569151608a1b606082015260800190565b611a3b806100e66000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80635ab971eb11610097578063927e40cf11610066578063927e40cf146101d5578063aa197245146101e8578063f2fde38b146101fb578063fc1f691f1461020e576100f5565b80635ab971eb146101835780636c685e3e146101a75780638456db15146101ba5780638b828440146101c2576100f5565b80632ab6f78f116100d35780632ab6f78f146101425780633ff61305146101555780634bd33c57146101685780634e71e0c81461017b576100f5565b80630d009297146100fa57806316048bc41461010f5780631d5c3f571461012d575b600080fd5b61010d6101083660046111c9565b610221565b005b61011761028a565b604051610124919061143f565b60405180910390f35b610135610299565b60405161012491906119aa565b61010d610150366004611218565b6102a8565b61010d61016336600461125b565b6103d6565b61010d6101763660046112de565b6104c2565b61010d610585565b6101966101913660046111c9565b610613565b604051610124959493929190611453565b61010d6101b53660046113a6565b610667565b6101176106e5565b61010d6101d03660046112b4565b6106f4565b61010d6101e3366004611365565b61083a565b61010d6101f6366004611320565b610955565b61010d6102093660046111c9565b610a76565b61013561021c3660046111e4565b610afb565b600154600160a01b900460ff16156102545760405162461bcd60e51b815260040161024b9061172f565b60405180910390fd5b6001805460ff60a01b1916600160a01b179055600080546001600160a01b039092166001600160a01b0319909216919091179055565b6000546001600160a01b031681565b6003546001600160401b031681565b6001600160a01b0384166102ce5760405162461bcd60e51b815260040161024b90611907565b6001600160a01b0383166102f45760405162461bcd60e51b815260040161024b9061193c565b6001600160a01b0384811660009081526002602052604090205416158061033357506001600160a01b0383811660009081526002602052604090205416155b1561033d576103d0565b60006103498585610b10565b905060006103578483610df7565b905060006103658787610e1b565b905083610386836001600160401b03670de0b6b3a764000085900316610df7565b111580156103b057506103ac826001600160401b03670de0b6b3a7640000840116610eff565b8411155b6103cc5760405162461bcd60e51b815260040161024b906114dd565b5050505b50505050565b6000546001600160a01b031633146104005760405162461bcd60e51b815260040161024b906116f8565b6001600160a01b0384166104265760405162461bcd60e51b815260040161024b9061151e565b610431848383610955565b6001600160a01b03848116600090815260026020526040902080546001600160a01b0319169185169190911781556104698585610f1c565b81546001600160601b0391909116600160a01b026001600160a01b03918216178255604051858216918716907fc83d07d9a138ee90bed5ee0972577f6a4f6921e748efc51d92f44fd96a1569b790600090a35050505050565b6000546001600160a01b031633146104ec5760405162461bcd60e51b815260040161024b906116f8565b6001600160a01b0382166105125760405162461bcd60e51b815260040161024b9061151e565b670de0b6b3a7640000816001600160401b031611156105435760405162461bcd60e51b815260040161024b906117bf565b6001600160a01b03909116600090815260026020526040902060010180546001600160401b03909216600160c01b026001600160c01b03909216919091179055565b6001546001600160a01b031633146105af5760405162461bcd60e51b815260040161024b90611849565b600154600080546040516001600160a01b0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a360018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b600260205260009081526040902080546001909101546001600160a01b03821691600160a01b90046001600160601b039081169181811691600160601b82041690600160c01b90046001600160401b031685565b6000546001600160a01b031633146106915760405162461bcd60e51b815260040161024b906116f8565b670de0b6b3a7640000816001600160401b031611156106c25760405162461bcd60e51b815260040161024b906117bf565b6003805467ffffffffffffffff19166001600160401b0392909216919091179055565b6001546001600160a01b031681565b6001600160a01b03821661071a5760405162461bcd60e51b815260040161024b9061151e565b6001600160601b0381106107405760405162461bcd60e51b815260040161024b90611801565b6001600160a01b038216600090815260026020526040812060018101549091906001600160601b031661077a57662386f26fc10000610789565b60018201546001600160601b03165b6001830154909150600090600160601b90046001600160601b03166107b75768056bc75e2d631000006107cd565b6001830154600160601b90046001600160601b03165b9050816001600160601b0316846001600160601b031610156108015760405162461bcd60e51b815260040161024b90611973565b806001600160601b0316846001600160601b031611156108335760405162461bcd60e51b815260040161024b906118d0565b5050505050565b6001600160a01b0382166108605760405162461bcd60e51b815260040161024b90611907565b6001600160a01b0381166108865760405162461bcd60e51b815260040161024b9061193c565b6001600160a01b038281166000908152600260205260409020541615806108c557506001600160a01b0381811660009081526002602052604090205416155b156108cf57610950565b60006108db8383610b10565b905060006108e98484610e1b565b90508461090a836001600160401b03670de0b6b3a764000085900316610df7565b111580156109345750610930826001600160401b03670de0b6b3a7640000840116610eff565b8511155b6108335760405162461bcd60e51b815260040161024b906116c1565b505050565b6000546001600160a01b0316331461097f5760405162461bcd60e51b815260040161024b906116f8565b6001600160a01b0383166109a55760405162461bcd60e51b815260040161024b9061151e565b806001600160601b0316826001600160601b0316106109d65760405162461bcd60e51b815260040161024b9061168a565b6001600160a01b038316600081815260026020526040908190206001810180546001600160601b03868116600160601b026bffffffffffffffffffffffff60601b199189166bffffffffffffffffffffffff19909316929092171617905590519091907fd38bfe56780b7577f91cb7a084921efdbc35d2c1cd10e5f3a66b271988d5a1b290610a6890869086906119be565b60405180910390a250505050565b6000546001600160a01b03163314610aa05760405162461bcd60e51b815260040161024b906116f8565b600080546040516001600160a01b03808516939216917fdcf55418cee3220104fef63f979ff3c4097ad240c0c43dcb33ce837748983e6291a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b078383610e1b565b90505b92915050565b6000610b1a611153565b506001600160a01b03838116600090815260026020908152604091829020825160a08101845281549485168152600160a01b9094046001600160601b03908116928501929092526001015480821692840192909252600160601b8204166060830152600160c01b90046001600160401b03166080820152610b99611153565b506001600160a01b03838116600090815260026020908152604091829020825160a08101845281548086168252600160a01b90046001600160601b039081169382019390935260019091015480831693820193909352600160601b83049091166060820152600160c01b9091046001600160401b031660808201528251909116610c355760405162461bcd60e51b815260040161024b90611495565b80516001600160a01b0316610c5c5760405162461bcd60e51b815260040161024b9061160d565b600082600001516001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610c9b57600080fd5b505afa158015610caf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd391906113cd565b5050509150506000811215610cfa5760405162461bcd60e51b815260040161024b9061188c565b600082600001516001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610d3957600080fd5b505afa158015610d4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7191906113cd565b5050509150506000811215610d985760405162461bcd60e51b815260040161024b9061158c565b6000610dba85602001516001600160601b03168461105790919063ffffffff16565b90506000610dde85602001516001600160601b03168461105790919063ffffffff16565b9050610dea8282611091565b9998505050505050505050565b6000670de0b6b3a7640000610e0c8484611057565b81610e1357fe5b049392505050565b6001600160a01b038216600090815260026020526040812060018101548290600160c01b90046001600160401b0316610e5f576003546001600160401b0316610e75565b6001820154600160c01b90046001600160401b03165b6001600160a01b0385166000908152600260205260408120600181015492935091600160c01b90046001600160401b0316610ebb576003546001600160401b0316610ed1565b6001820154600160c01b90046001600160401b03165b9050806001600160401b0316836001600160401b031611610ef25780610ef4565b825b979650505050505050565b6000610b07610f0e8484611057565b670de0b6b3a76400006110af565b60006001600160a01b038216610f3457506000610b0a565b6000611027836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610f7257600080fd5b505afa158015610f86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610faa919061141e565b60ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610fe657600080fd5b505afa158015610ffa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101e919061141e565b60ff16906110dc565b90506000611036602483611101565b600a0a90506001600160601b0381111561104f57600080fd5b949350505050565b60008261106657506000610b0a565b8282028284828161107357fe5b0414610b075760405162461bcd60e51b815260040161024b9061177e565b6000610b07826110a985670de0b6b3a7640000611057565b90611129565b6000806110bc8484611129565b9050828102840380156110d457506001019050610b0a565b509050610b0a565b600082820183811015610b075760405162461bcd60e51b815260040161024b90611555565b6000828211156111235760405162461bcd60e51b815260040161024b906115d6565b50900390565b600080821161114a5760405162461bcd60e51b815260040161024b90611653565b818381610e1357fe5b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b80356001600160a01b0381168114610b0a57600080fd5b805169ffffffffffffffffffff81168114610b0a57600080fd5b80356001600160601b0381168114610b0a57600080fd5b6000602082840312156111da578081fd5b610b078383611181565b600080604083850312156111f6578081fd5b6112008484611181565b915061120f8460208501611181565b90509250929050565b6000806000806080858703121561122d578182fd5b6112378686611181565b93506112468660208701611181565b93969395505050506040820135916060013590565b60008060008060808587031215611270578384fd5b61127a8686611181565b93506112898660208701611181565b92506040850135611299816119f0565b915060608501356112a9816119f0565b939692955090935050565b600080604083850312156112c6578182fd5b6112d08484611181565b946020939093013593505050565b600080604083850312156112f0578182fd5b6112fa8484611181565b915060208301356001600160401b0381168114611315578182fd5b809150509250929050565b600080600060608486031215611334578283fd5b61133e8585611181565b925061134d85602086016111b2565b915061135c85604086016111b2565b90509250925092565b600080600060608486031215611379578283fd5b83359250602084013561138b816119d8565b9150604084013561139b816119d8565b809150509250925092565b6000602082840312156113b7578081fd5b81356001600160401b0381168114610b07578182fd5b600080600080600060a086880312156113e4578081fd5b6113ee8787611198565b94506020860151935060408601519250606086015191506114128760808801611198565b90509295509295909350565b60006020828403121561142f578081fd5b815160ff81168114610b07578182fd5b6001600160a01b0391909116815260200190565b6001600160a01b039590951685526001600160601b039384166020860152918316604085015290911660608301526001600160401b0316608082015260a00190565b60208082526028908201527f576f6f477561726469616e3a2066726f6d546f6b656e5f5265664f7261636c6560408201526717d253959053125160c21b606082015260800190565b60208082526021908201527f576f6f477561726469616e3a20544f5f414d4f554e545f554e52454c4941424c6040820152604560f81b606082015260800190565b6020808252601c908201527f576f6f477561726469616e3a20746f6b656e5f5a45524f5f4144445200000000604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252602a908201527f576f6f477561726469616e3a20494e56414c49445f434841494e4c494e4b5f51604082015269554f54455f505249434560b01b606082015260800190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b60208082526026908201527f576f6f477561726469616e3a20746f546f6b656e5f5265664f7261636c655f4960408201526513959053125160d21b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b6020808252601c908201527f576f6f477561726469616e3a206d696e5f6d61785f494e56414c494400000000604082015260600190565b6020808252601d908201527f576f6f477561726469616e3a2050524943455f554e52454c4941424c45000000604082015260600190565b6020808252601f908201527f496e697469616c697a61626c654f776e61626c653a204e4f545f4f574e455200604082015260600190565b6020808252602f908201527f496e697469616c697a61626c654f776e61626c653a2053484f554c445f4e4f5460408201526e17d09157d253925512505312569151608a1b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526022908201527f576f6f477561726469616e3a206e6577426f756e64206f7574206f662072616e604082015261676560f01b606082015260800190565b60208082526028908201527f576f6f477561726469616e3a20696e707574416d6f756e745f75696e7439365f6040820152674f564552464c4f5760c01b606082015260800190565b60208082526023908201527f496e697469616c697a61626c654f776e61626c653a20494e56414c49445f434c60408201526241494d60e81b606082015260800190565b60208082526024908201527f576f6f477561726469616e3a20494e56414c49445f434841494e4c494e4b5f506040820152635249434560e01b606082015260800190565b6020808252601c908201527f576f6f477561726469616e3a20696e707574416d6f756e745f47544d00000000604082015260600190565b6020808252818101527f576f6f477561726469616e3a2066726f6d546f6b656e5f5a45524f5f41444452604082015260600190565b6020808252601e908201527f576f6f477561726469616e3a20746f546f6b656e5f5a45524f5f414444520000604082015260600190565b6020808252601c908201527f576f6f477561726469616e3a20696e707574416d6f756e745f4c544d00000000604082015260600190565b6001600160401b0391909116815260200190565b6001600160601b0392831681529116602082015260400190565b6001600160a01b03811681146119ed57600080fd5b50565b6001600160601b03811681146119ed57600080fdfea2646970667358221220d48290f99fa2843e6e2e9d01624bef7fe96b2e81299808d57c2cc4ea182a747264736f6c634300060c0033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.