ETH Price: $3,163.90 (+0.34%)

Contract

0xb86d3eea67A8bcaF232Ee9643d5ae5C44525c57e
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x60e060401161277422024-02-13 19:57:4168 days ago1707854261IN
 Create: UniswapMarketMaker
0 ETH0.000523710.10043593

Advanced mode:
Parent Txn Hash Block From To Value
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
UniswapMarketMaker

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 34 : UniswapMarketMaker.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

// ====================================================================
// ===================== UniswapMarketMaker.sol =======================
// ====================================================================

/**
 * @title Uniswap Market Maker
 * @dev Implementation:
 * Mints a new LP.
 * Increases and decreases the liquidity for the LP created.
 * Collects fees from the LP.
 */

import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import { Stabilizer } from "../Stabilizer/Stabilizer.sol";
import { INonfungiblePositionManager } from "@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol";
import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import { IAMM } from "../AMM/IAMM.sol";
import { TransferHelper } from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import { OvnMath } from "../Libraries/OvnMath.sol";


contract UniswapMarketMaker is IERC721Receiver, Stabilizer {
    // Uniswap V3 Position Manager
    INonfungiblePositionManager private immutable nfpm;
    uint8 private constant TICKS_DELTA = 201;

    // Variables
    address public token0;
    address public token1;
    address public ammAddress;
    bool private immutable flag; // The sort status of tokens

    uint256 private constant PRECISION = 1e6;
    uint256 public tradePosition;
    uint256 public growPosition;
    uint256 public redeemPosition;
    uint32 public slippage;

    // Errors
    error NotMinted();
    error BadSlippage();

    event Collected(uint256 amount0, uint256 amount1);
    event LiquidityAdded(uint256 usdxAmount, uint256 sweepAmount);
    event SweepPurchased(uint256 sweeAmount);

    constructor(
        string memory _name,
        address _sweep,
        address _usdx,
        address _oracleUsdx,
        address _positionManager,
        address _borrower
    ) Stabilizer(_name, _sweep, _usdx, _oracleUsdx, _borrower) {
        slippage = 5000; // 0.5%
        flag = _usdx < _sweep;
        (token0, token1) = flag ? (_usdx, _sweep) : (_sweep, _usdx);
        nfpm = INonfungiblePositionManager(_positionManager);
    }

    /* ========== Views ========== */
    function tradeLiquidity() external view returns (uint128) {
        return _getLiquidity(tradePosition);
    }

    function growLiquidity() external view returns (uint128) {
        return _getLiquidity(growPosition);
    }

    function redeemLiquidity() external view returns (uint128) {
        return _getLiquidity(redeemPosition);
    }

    function amm() public view override returns (IAMM) {
        return IAMM(ammAddress);
    }

    /**
    /**
     * @notice Gets the asset price of AMM
     * @return the amm usdx amount
     */
    function assetValue() public view override returns (uint256) {
        uint256 usdxAmount;
        uint256 sweepAmount;
        uint256[3] memory positions = [tradePosition, growPosition, redeemPosition];

        for (uint i = 0; i < 3; i++) {
            if (positions[i] > 0) {
                (uint256 amount0, uint256 amount1,) = amm().getPositions(positions[i]);
                usdxAmount += amount0;
                sweepAmount += amount1;
            }
        }

        return _oracleUsdxToUsd(usdxAmount) + sweep.convertToUSD(sweepAmount);
    }

    function getBuyPrice() public view returns (uint256) {
        uint256 targetPrice = sweep.targetPrice();
        return targetPrice + ((sweep.arbSpread() * targetPrice) / PRECISION);
    }

    /* ========== Actions ========== */
    function setSlippage(uint32 newSlippage) external nonReentrant onlyBorrower {
        if(newSlippage > PRECISION) revert BadSlippage();
        slippage = newSlippage;
    }

    function setAMM(address newAmm) external nonReentrant onlyBorrower {
        if(newAmm == address(0)) revert ZeroAddressDetected();
        ammAddress = newAmm;
    }

    /**
     * @notice Collects the fees associated with provided liquidity
     * @dev The contract must hold the erc721 token before it can collect fees
     */
    function collectFees(uint256 position) external onlyBorrower whenNotPaused nonReentrant {
        _collect(position);
    }

    /**
     * @notice Implementing `onERC721Received` so this contract can receive custody of erc721 tokens
     */
    function onERC721Received(address, address, uint256, bytes calldata) external override pure returns (bytes4) {
        return this.onERC721Received.selector;
    }

    /**
     * @notice Burn trade NFT
     */
    function burnTradePosition() external onlyBorrower nonReentrant {
        if(tradePosition == 0) revert NotMinted();
        _removePosition(tradePosition);
        tradePosition = 0;
    }

    /**
     * @notice Burn redeem NFT
     */
    function burnRedeemPosition() external onlyBorrower nonReentrant {
        if(redeemPosition == 0) revert NotMinted();
        _removePosition(redeemPosition);
        redeemPosition = 0;
    }

    /**
     * @notice Burn grow NFT
     */
    function burnGrowPosition() external onlyBorrower nonReentrant {
        if(growPosition == 0) revert NotMinted();
        _removePosition(growPosition);
        growPosition = 0;
    }

    /**
     * @notice A function that decreases the current liquidity.
     * @param liquidityAmount Liquidity Amount to decrease
     */
    function removeLiquidity(uint256 tokenId, uint256 liquidityAmount, uint256 amountOut0, uint256 amountOut1)
        external onlyBorrower nonReentrant validAmount(liquidityAmount)
    {
        _decreaseLiquidity(tokenId, uint128(liquidityAmount), amountOut0, amountOut1);
    }

    function lpTrade(uint256 usdxAmount, uint256 sweepAmount, uint256 usdxSlippage, uint256 sweepSlippage, uint256 spread)
        external onlyBorrower whenNotPaused nonReentrant
    {
        if(tradePosition > 0) _removePosition(tradePosition);   
        _approveNFTManager(usdxAmount, sweepAmount);
        
        uint256 sweepPrice = sweep.targetPrice();
        uint256 minPrice = ((PRECISION - spread) * sweepPrice) / PRECISION;
        uint256 maxPrice = ((PRECISION + spread) * sweepPrice) / PRECISION;
        (int24 minTick, int24 maxTick) = _getTicks(minPrice, maxPrice);

        uint256 usdxMinIn = OvnMath.subBasisPoints(usdxAmount, usdxSlippage);
        uint256 sweepMinIn = OvnMath.subBasisPoints(sweepAmount, sweepSlippage);

        (usdxAmount, sweepAmount, usdxMinIn, sweepMinIn) = flag
            ? (usdxAmount, sweepAmount, usdxMinIn, sweepMinIn)
            : (sweepAmount, usdxAmount, sweepMinIn, usdxMinIn);

        tradePosition = _mintPosition(minTick, maxTick, usdxAmount, sweepAmount, usdxMinIn, sweepMinIn);
        _checkRatio();
    }

    function lpRedeem(uint256 usdxAmount, uint256 priceSpread, uint256 usdxSlippage)
        external onlyBorrower nonReentrant
    {
        if(redeemPosition > 0) _removePosition(redeemPosition);
        _approveNFTManager(usdxAmount, 0);

        uint256 targetPrice = sweep.targetPrice();
        uint256 ammPrice = amm().getPriceAtCurrentTick();
        uint256 maxPrice = (targetPrice < ammPrice ? targetPrice : ammPrice) - TICKS_DELTA;
        uint256 minPrice = ((PRECISION - priceSpread) * maxPrice) / PRECISION;

        redeemPosition = _addSingleSidedLiquidity(usdxAmount, 0, usdxSlippage, minPrice, maxPrice);
    }

    function lpGrow(uint256 sweepAmount, uint256 priceSpread, uint256 sweepSlippage)
        external onlyBorrower nonReentrant
    {
        if(growPosition > 0) _removePosition(growPosition);
        _approveNFTManager(0, sweepAmount);

        uint256 targetPrice = sweep.targetPrice();
        uint256 ammPrice = amm().getPriceAtCurrentTick();
        uint256 minPrice = (targetPrice > ammPrice ? targetPrice : ammPrice) + TICKS_DELTA;
        uint256 maxPrice = ((PRECISION + priceSpread) * minPrice) / PRECISION;

        growPosition = _addSingleSidedLiquidity(0, sweepAmount, sweepSlippage, minPrice, maxPrice);
        _checkRatio();
    }

    function buySweep(uint256 usdxAmount) external nonReentrant returns (uint256 sweepAmount) {
        if(tradePosition == 0) revert NotMinted();
        sweepAmount = (_oracleUsdxToUsd(usdxAmount) * (10 ** sweep.decimals())) / getBuyPrice();

        _borrow(sweepAmount * 2);

        uint256 usdxMinIn = OvnMath.subBasisPoints(usdxAmount, slippage);
        uint256 sweepMinIn = OvnMath.subBasisPoints(sweepAmount, slippage);

        TransferHelper.safeTransferFrom(address(usdx), msg.sender, address(this), usdxAmount);
        _addLiquidity(usdxAmount, sweepAmount, usdxMinIn, sweepMinIn);
        TransferHelper.safeTransfer(address(sweep), msg.sender, sweepAmount);

        _checkRatio();
        emit SweepPurchased(usdxAmount);
    }

    function addLiquidity(uint256 usdxAmount, uint256 sweepAmount, uint256 usdxMinIn, uint256 sweepMinIn)
        external onlyBorrower nonReentrant
    {
        _addLiquidity(usdxAmount, sweepAmount, usdxMinIn, sweepMinIn);
    }

    /* ========== Internals ========== */
    function _addLiquidity(uint256 usdxAmount, uint256 sweepAmount, uint256 usdxMinIn, uint256 sweepMinIn) internal {
        _approveNFTManager(usdxAmount, sweepAmount);

        (usdxAmount, sweepAmount, usdxMinIn, sweepMinIn) = flag
            ? (usdxAmount, sweepAmount, usdxMinIn, sweepMinIn)
            : (sweepAmount, usdxAmount, sweepMinIn, usdxMinIn);

        nfpm.increaseLiquidity(
            INonfungiblePositionManager.IncreaseLiquidityParams({
                tokenId: tradePosition,
                amount0Desired: usdxAmount,
                amount1Desired: sweepAmount,
                amount0Min: usdxMinIn,
                amount1Min: sweepMinIn,
                deadline: block.timestamp + 60
            })
        );

        emit LiquidityAdded(usdxAmount, sweepAmount);
    }

    function _addSingleSidedLiquidity(
        uint256 usdxAmount,
        uint256 sweepAmount,
        uint256 _slippage,
        uint256 minPrice,
        uint256 maxPrice
    ) internal returns (uint256) {
        (int24 minTick, int24 maxTick) = _getTicks(minPrice, maxPrice);

        (uint256 amount0Mint, uint256 amount1Mint) = flag ? (usdxAmount, sweepAmount) : (sweepAmount, usdxAmount);
        uint256 amount0Min = OvnMath.subBasisPoints(amount0Mint, _slippage);
        uint256 amount1Min = OvnMath.subBasisPoints(amount1Mint, _slippage);

        return _mintPosition(minTick, maxTick, amount0Mint, amount1Mint, amount0Min, amount1Min);
    }

    function _collect(uint256 id) internal {
        (uint256 amount0, uint256 amount1) = nfpm.collect(
            INonfungiblePositionManager.CollectParams({
                tokenId: id,
                recipient: address(this),
                amount0Max: type(uint128).max,
                amount1Max: type(uint128).max
            })
        );

        emit Collected(amount0, amount1);
    }

    function _removePosition(uint256 positionId) internal {
        (,,,,,,,uint128 _liquidity,,,,) = nfpm.positions(positionId);
        _decreaseLiquidity(positionId, _liquidity, 0, 0);
        nfpm.burn(positionId);
    }

    function _getLiquidity(uint256 position) internal view returns(uint128 liquidity) {
        if(position > 0)
            (,,,,,,, liquidity,,,,) = nfpm.positions(position);
    }

    function _decreaseLiquidity(uint256 positionId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min) internal {
        nfpm.decreaseLiquidity(
            INonfungiblePositionManager.DecreaseLiquidityParams({
                tokenId: positionId,
                liquidity: liquidity,
                amount0Min: amount0Min,
                amount1Min: amount1Min,
                deadline: block.timestamp
            })
        );
        _collect(positionId);
    }

    function _approveNFTManager(uint256 usdxAmount, uint256 sweepAmount) internal {
        if(usdxAmount > 0) TransferHelper.safeApprove(address(usdx), address(nfpm), usdxAmount);
        if(sweepAmount > 0) TransferHelper.safeApprove(address(sweep), address(nfpm), sweepAmount);
    }

    function _mintPosition(
        int24 minTick,
        int24 maxTick,
        uint256 amount0Desired,
        uint256 amount1Desired,
        uint256 amount0Min,
        uint256 amount1Min
    ) internal returns (uint256 tokenId){
        (tokenId,,,) = nfpm.mint(
            INonfungiblePositionManager.MintParams({
                token0: token0,
                token1: token1,
                fee: IUniswapV3Pool(amm().pool()).fee(),
                tickLower: minTick,
                tickUpper: maxTick,
                amount0Desired: amount0Desired,
                amount1Desired: amount1Desired,
                amount0Min: amount0Min,
                amount1Min: amount1Min,
                recipient: address(this),
                deadline: block.timestamp
            })
        );
    }

    function _getTicks(uint256 minPrice, uint256 maxPrice) internal view returns (int24 minTick, int24 maxTick) {
        int24 tickSpacing = IUniswapV3Pool(amm().pool()).tickSpacing();
        uint8 baseDecimals = usdx.decimals();
        uint8 sweepDecimals = sweep.decimals();

        minTick = amm().getTickFromPrice(((minPrice * 10 ** baseDecimals) / PRECISION), sweepDecimals, tickSpacing);
        maxTick = amm().getTickFromPrice(((maxPrice * 10 ** baseDecimals) / PRECISION), sweepDecimals, tickSpacing);
        (minTick, maxTick) = minTick < maxTick ? (minTick, maxTick) : (maxTick, minTick);
    }
}

File 2 of 34 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol)

pragma solidity ^0.8.0;

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

File 3 of 34 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 4 of 34 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

File 5 of 34 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 7 of 34 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 8 of 34 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 9 of 34 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 10 of 34 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

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

pragma solidity ^0.8.0;

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

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

File 12 of 34 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 14 of 34 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol';
import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol';
import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol';
import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol';
import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol';
import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol';
import {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol';

/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions,
    IUniswapV3PoolOwnerActions,
    IUniswapV3PoolErrors,
    IUniswapV3PoolEvents
{

}

File 15 of 34 : IUniswapV3PoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Collects tokens owed to a position
    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
    /// @param recipient The address which should receive the fees collected
    /// @param tickLower The lower tick of the position for which to collect fees
    /// @param tickUpper The upper tick of the position for which to collect fees
    /// @param amount0Requested How much token0 should be withdrawn from the fees owed
    /// @param amount1Requested How much token1 should be withdrawn from the fees owed
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
    /// @dev Fees must be collected separately via a call to #collect
    /// @param tickLower The lower tick of the position for which to burn liquidity
    /// @param tickUpper The upper tick of the position for which to burn liquidity
    /// @param amount How much liquidity to burn
    /// @return amount0 The amount of token0 sent to the recipient
    /// @return amount1 The amount of token1 sent to the recipient
    function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
    /// @param recipient The address to receive the output of the swap
    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
    /// @param data Any data to be passed through to the callback
    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external returns (int256 amount0, int256 amount1);

    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}

File 16 of 34 : IUniswapV3PoolDerivedState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
    /// snapshot is taken and the second snapshot is taken.
    /// @param tickLower The lower tick of the range
    /// @param tickUpper The upper tick of the range
    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range
    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
    /// @return secondsInside The snapshot of seconds per liquidity for the range
    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
        external
        view
        returns (
            int56 tickCumulativeInside,
            uint160 secondsPerLiquidityInsideX128,
            uint32 secondsInside
        );
}

File 17 of 34 : IUniswapV3PoolErrors.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Errors emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolErrors {
    error LOK();
    error TLU();
    error TLM();
    error TUM();
    error AI();
    error M0();
    error M1();
    error AS();
    error IIA();
    error L();
    error F0();
    error F1();
}

File 18 of 34 : IUniswapV3PoolEvents.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
    event Initialize(uint160 sqrtPriceX96, int24 tick);

    /// @notice Emitted when liquidity is minted for a given position
    /// @param sender The address that minted the liquidity
    /// @param owner The owner of the position and recipient of any minted liquidity
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity minted to the position range
    /// @param amount0 How much token0 was required for the minted liquidity
    /// @param amount1 How much token1 was required for the minted liquidity
    event Mint(
        address sender,
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted when fees are collected by the owner of a position
    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
    /// @param owner The owner of the position for which fees are collected
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount0 The amount of token0 fees collected
    /// @param amount1 The amount of token1 fees collected
    event Collect(
        address indexed owner,
        address recipient,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount0,
        uint128 amount1
    );

    /// @notice Emitted when a position's liquidity is removed
    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
    /// @param owner The owner of the position for which liquidity is removed
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity to remove
    /// @param amount0 The amount of token0 withdrawn
    /// @param amount1 The amount of token1 withdrawn
    event Burn(
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted by the pool for any swaps between token0 and token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the output of the swap
    /// @param amount0 The delta of the token0 balance of the pool
    /// @param amount1 The delta of the token1 balance of the pool
    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
    /// @param liquidity The liquidity of the pool after the swap
    /// @param tick The log base 1.0001 of price of the pool after the swap
    event Swap(
        address indexed sender,
        address indexed recipient,
        int256 amount0,
        int256 amount1,
        uint160 sqrtPriceX96,
        uint128 liquidity,
        int24 tick
    );

    /// @notice Emitted by the pool for any flashes of token0/token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the tokens from flash
    /// @param amount0 The amount of token0 that was flashed
    /// @param amount1 The amount of token1 that was flashed
    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
    event Flash(
        address indexed sender,
        address indexed recipient,
        uint256 amount0,
        uint256 amount1,
        uint256 paid0,
        uint256 paid1
    );

    /// @notice Emitted by the pool for increases to the number of observations that can be stored
    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
    /// just before a mint/swap/burn.
    /// @param observationCardinalityNextOld The previous value of the next observation cardinality
    /// @param observationCardinalityNextNew The updated value of the next observation cardinality
    event IncreaseObservationCardinalityNext(
        uint16 observationCardinalityNextOld,
        uint16 observationCardinalityNextNew
    );

    /// @notice Emitted when the protocol fee is changed by the pool
    /// @param feeProtocol0Old The previous value of the token0 protocol fee
    /// @param feeProtocol1Old The previous value of the token1 protocol fee
    /// @param feeProtocol0New The updated value of the token0 protocol fee
    /// @param feeProtocol1New The updated value of the token1 protocol fee
    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);

    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
    /// @param sender The address that collects the protocol fees
    /// @param recipient The address that receives the collected protocol fees
    /// @param amount0 The amount of token0 protocol fees that is withdrawn
    /// @param amount0 The amount of token1 protocol fees that is withdrawn
    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}

File 19 of 34 : IUniswapV3PoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

File 20 of 34 : IUniswapV3PoolOwnerActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
    /// @notice Set the denominator of the protocol's % share of the fees
    /// @param feeProtocol0 new protocol fee for token0 of the pool
    /// @param feeProtocol1 new protocol fee for token1 of the pool
    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;

    /// @notice Collect the protocol fee accrued to the pool
    /// @param recipient The address to which collected protocol fees should be sent
    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
    /// @return amount0 The protocol fee collected in token0
    /// @return amount1 The protocol fee collected in token1
    function collectProtocol(
        address recipient,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);
}

File 21 of 34 : IUniswapV3PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// @return observationIndex The index of the last oracle observation that was written,
    /// @return observationCardinality The current maximum number of observations stored in the pool,
    /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// @return feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolFees() external view returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all ticks
    /// @return The liquidity at the current price of the pool
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
    /// tick upper
    /// @return liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// @return secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
    /// @return liquidity The amount of liquidity in the position,
    /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// @return initialized whether the observation has been initialized and the values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

File 22 of 34 : IERC721Permit.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';

/// @title ERC721 with permit
/// @notice Extension to ERC721 that includes a permit function for signature based approvals
interface IERC721Permit is IERC721 {
    /// @notice The permit typehash used in the permit signature
    /// @return The typehash for the permit
    function PERMIT_TYPEHASH() external pure returns (bytes32);

    /// @notice The domain separator used in the permit signature
    /// @return The domain seperator used in encoding of permit signature
    function DOMAIN_SEPARATOR() external view returns (bytes32);

    /// @notice Approve of a specific token ID for spending by spender via signature
    /// @param spender The account that is being approved
    /// @param tokenId The ID of the token that is being approved for spending
    /// @param deadline The deadline timestamp by which the call must be mined for the approve to work
    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
    function permit(
        address spender,
        uint256 tokenId,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable;
}

File 23 of 34 : INonfungiblePositionManager.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';

import './IPoolInitializer.sol';
import './IERC721Permit.sol';
import './IPeripheryPayments.sol';
import './IPeripheryImmutableState.sol';
import '../libraries/PoolAddress.sol';

/// @title Non-fungible token for positions
/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
interface INonfungiblePositionManager is
    IPoolInitializer,
    IPeripheryPayments,
    IPeripheryImmutableState,
    IERC721Metadata,
    IERC721Enumerable,
    IERC721Permit
{
    /// @notice Emitted when liquidity is increased for a position NFT
    /// @dev Also emitted when a token is minted
    /// @param tokenId The ID of the token for which liquidity was increased
    /// @param liquidity The amount by which liquidity for the NFT position was increased
    /// @param amount0 The amount of token0 that was paid for the increase in liquidity
    /// @param amount1 The amount of token1 that was paid for the increase in liquidity
    event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when liquidity is decreased for a position NFT
    /// @param tokenId The ID of the token for which liquidity was decreased
    /// @param liquidity The amount by which liquidity for the NFT position was decreased
    /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
    /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
    event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when tokens are collected for a position NFT
    /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
    /// @param tokenId The ID of the token for which underlying tokens were collected
    /// @param recipient The address of the account that received the collected tokens
    /// @param amount0 The amount of token0 owed to the position that was collected
    /// @param amount1 The amount of token1 owed to the position that was collected
    event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);

    /// @notice Returns the position information associated with a given token ID.
    /// @dev Throws if the token ID is not valid.
    /// @param tokenId The ID of the token that represents the position
    /// @return nonce The nonce for permits
    /// @return operator The address that is approved for spending
    /// @return token0 The address of the token0 for a specific pool
    /// @return token1 The address of the token1 for a specific pool
    /// @return fee The fee associated with the pool
    /// @return tickLower The lower end of the tick range for the position
    /// @return tickUpper The higher end of the tick range for the position
    /// @return liquidity The liquidity of the position
    /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
    /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
    /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
    /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
    function positions(uint256 tokenId)
        external
        view
        returns (
            uint96 nonce,
            address operator,
            address token0,
            address token1,
            uint24 fee,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    struct MintParams {
        address token0;
        address token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        address recipient;
        uint256 deadline;
    }

    /// @notice Creates a new position wrapped in a NFT
    /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
    /// a method does not exist, i.e. the pool is assumed to be initialized.
    /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
    /// @return tokenId The ID of the token that represents the minted position
    /// @return liquidity The amount of liquidity for this position
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function mint(MintParams calldata params)
        external
        payable
        returns (
            uint256 tokenId,
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct IncreaseLiquidityParams {
        uint256 tokenId;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
    /// @param params tokenId The ID of the token for which liquidity is being increased,
    /// amount0Desired The desired amount of token0 to be spent,
    /// amount1Desired The desired amount of token1 to be spent,
    /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
    /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return liquidity The new liquidity amount as a result of the increase
    /// @return amount0 The amount of token0 to acheive resulting liquidity
    /// @return amount1 The amount of token1 to acheive resulting liquidity
    function increaseLiquidity(IncreaseLiquidityParams calldata params)
        external
        payable
        returns (
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct DecreaseLiquidityParams {
        uint256 tokenId;
        uint128 liquidity;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Decreases the amount of liquidity in a position and accounts it to the position
    /// @param params tokenId The ID of the token for which liquidity is being decreased,
    /// amount The amount by which liquidity will be decreased,
    /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
    /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return amount0 The amount of token0 accounted to the position's tokens owed
    /// @return amount1 The amount of token1 accounted to the position's tokens owed
    function decreaseLiquidity(DecreaseLiquidityParams calldata params)
        external
        payable
        returns (uint256 amount0, uint256 amount1);

    struct CollectParams {
        uint256 tokenId;
        address recipient;
        uint128 amount0Max;
        uint128 amount1Max;
    }

    /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
    /// @param params tokenId The ID of the NFT for which tokens are being collected,
    /// recipient The account that should receive the tokens,
    /// amount0Max The maximum amount of token0 to collect,
    /// amount1Max The maximum amount of token1 to collect
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);

    /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
    /// must be collected first.
    /// @param tokenId The ID of the token that is being burned
    function burn(uint256 tokenId) external payable;
}

File 24 of 34 : IPeripheryImmutableState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Immutable state
/// @notice Functions that return immutable state of the router
interface IPeripheryImmutableState {
    /// @return Returns the address of the Uniswap V3 factory
    function factory() external view returns (address);

    /// @return Returns the address of WETH9
    function WETH9() external view returns (address);
}

File 25 of 34 : IPeripheryPayments.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
    /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
    /// @param amountMinimum The minimum amount of WETH9 to unwrap
    /// @param recipient The address receiving ETH
    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;

    /// @notice Refunds any ETH balance held by this contract to the `msg.sender`
    /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
    /// that use ether for the input amount
    function refundETH() external payable;

    /// @notice Transfers the full amount of a token held by this contract to recipient
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
    /// @param token The contract address of the token which will be transferred to `recipient`
    /// @param amountMinimum The minimum amount of token required for a transfer
    /// @param recipient The destination address of the token
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable;
}

File 26 of 34 : IPoolInitializer.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
interface IPoolInitializer {
    /// @notice Creates a new pool if it does not exist, then initializes if not initialized
    /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
    /// @param token0 The contract address of token0 of the pool
    /// @param token1 The contract address of token1 of the pool
    /// @param fee The fee amount of the v3 pool for the specified token pair
    /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
    /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
    function createAndInitializePoolIfNecessary(
        address token0,
        address token1,
        uint24 fee,
        uint160 sqrtPriceX96
    ) external payable returns (address pool);
}

File 27 of 34 : PoolAddress.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
library PoolAddress {
    bytes32 internal constant POOL_INIT_CODE_HASH = 0xa598dd2fba360510c5a8f02f44423a4468e902df5857dbce3ca162a43a3a31ff;

    /// @notice The identifying key of the pool
    struct PoolKey {
        address token0;
        address token1;
        uint24 fee;
    }

    /// @notice Returns PoolKey: the ordered tokens with the matched fee levels
    /// @param tokenA The first token of a pool, unsorted
    /// @param tokenB The second token of a pool, unsorted
    /// @param fee The fee level of the pool
    /// @return Poolkey The pool details with ordered token0 and token1 assignments
    function getPoolKey(
        address tokenA,
        address tokenB,
        uint24 fee
    ) internal pure returns (PoolKey memory) {
        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
        return PoolKey({token0: tokenA, token1: tokenB, fee: fee});
    }

    /// @notice Deterministically computes the pool address given the factory and PoolKey
    /// @param factory The Uniswap V3 factory contract address
    /// @param key The PoolKey
    /// @return pool The contract address of the V3 pool
    function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
        require(key.token0 < key.token1);
        pool = address(
            uint160(
                uint256(
                    keccak256(
                        abi.encodePacked(
                            hex'ff',
                            factory,
                            keccak256(abi.encode(key.token0, key.token1, key.fee)),
                            POOL_INIT_CODE_HASH
                        )
                    )
                )
            )
        );
    }
}

File 28 of 34 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 29 of 34 : IAMM.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

interface IAMM {
    function swapExactInput(
        address tokenA,
        address tokenB,
        uint24 fee,
        uint256 amountIn,
        uint256 amountOutMin
    ) external returns (uint256);

    function swap(
        address tokenA,
        address tokenB,
        uint256 amountIn,
        uint256 amountOutMin,
        address poolAddress
    ) external returns (uint256);

    function buySweep(
        address token,
        uint256 amountIn,
        uint256 amountOutMin
    ) external returns (uint256);

    function sellSweep(
        address token,
        uint256 amountIn,
        uint256 amountOutMin
    ) external returns (uint256);

    function sequencer() external view returns (address);

    function pool() external view returns (address);

    function getTWAPrice() external view returns (uint256 twaPrice);

    function getPrice() external view returns (uint256 price);
    
    function getRate() external view returns (uint256 rate);

    function getPositions(uint256) external view returns (uint256 usdxAmount, uint256 sweepAmount, uint256 lp);

    function getPriceAtTick(int24) external view returns (uint256 price);

    function getPriceAtCurrentTick() external view returns (uint256 price);

    function getTickFromPrice(uint256 price, uint8 decimals, int24 tickSpacing) external view returns (int24);
}

File 30 of 34 : Owned.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.19;

// ==========================================================
// ======================= Owned.sol ========================
// ==========================================================

import "../Sweep/ISweep.sol";

contract Owned {
    ISweep public immutable sweep;

    // Errors
    error NotGovernance();
    error NotMultisigOrGov();
    error ZeroAddressDetected();

    constructor(address _sweep) {
        if(_sweep == address(0)) revert ZeroAddressDetected();

        sweep = ISweep(_sweep);
    }

    modifier onlyGov() {
        if (msg.sender != sweep.owner()) revert NotGovernance();
        _;
    }

    modifier onlyMultisigOrGov() {
        if (msg.sender != sweep.fastMultisig() && msg.sender != sweep.owner())
            revert NotMultisigOrGov();
        _;
    }
}

File 31 of 34 : Chainlink.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

interface IPriceFeed {
    function latestAnswer() external view returns (int256);

    function latestTimestamp() external view returns (uint256);

    function latestRound() external view returns (uint256);

    function getAnswer(uint256 roundId) external view returns (int256);

    function getTimestamp(uint256 roundId) external view returns (uint256);

    function decimals() external view returns (uint8);

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

    function version() external view returns (uint256);

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

library ChainlinkLibrary {
    uint8 constant USD_DECIMALS = 6;

    function getDecimals(IPriceFeed oracle) internal view returns (uint8) {
        return oracle.decimals();
    }

    function getPrice(IPriceFeed oracle) internal view returns (uint256) {
        (
            uint80 roundID,
            int256 price,
            ,
            uint256 timeStamp,
            uint80 answeredInRound
        ) = oracle.latestRoundData();
        require(answeredInRound >= roundID, "Old data");
        require(timeStamp > 0, "Round not complete");

        return uint256(price);
    }

    function getPrice(
        IPriceFeed oracle,
        IPriceFeed sequencerOracle,
        uint256 frequency
    ) internal view returns (uint256) {
        if (address(sequencerOracle) != address(0))
            checkUptime(sequencerOracle);

        (uint256 roundId, int256 price, , uint256 updatedAt, ) = oracle
            .latestRoundData();
        require(price > 0 && roundId != 0 && updatedAt != 0, "Invalid Price");
        if (frequency > 0)
            require(block.timestamp - updatedAt <= frequency, "Stale Price");

        return uint256(price);
    }

    function checkUptime(IPriceFeed sequencerOracle) internal view {
        (, int256 answer, uint256 startedAt, , ) = sequencerOracle
            .latestRoundData();
        require(answer <= 0, "Sequencer Down"); // 0: Sequencer is up, 1: Sequencer is down
        require(block.timestamp - startedAt > 1 hours, "Grace Period Not Over");
    }

    function convertTokenToToken(
        uint256 amount0,
        uint8 token0Decimals,
        uint8 token1Decimals,
        IPriceFeed oracle0,
        IPriceFeed oracle1
    ) internal view returns (uint256 amount1) {
        uint256 price0 = getPrice(oracle0);
        uint256 price1 = getPrice(oracle1);
        amount1 =
            (amount0 * price0 * (10 ** token1Decimals)) /
            (price1 * (10 ** token0Decimals));
    }

    function convertTokenToUsd(
        uint256 amount,
        uint8 tokenDecimals,
        IPriceFeed oracle
    ) internal view returns (uint256 amountUsd) {
        uint8 decimals = getDecimals(oracle);
        uint256 price = getPrice(oracle);

        amountUsd =
            (amount * price * (10 ** USD_DECIMALS)) /
            10 ** (decimals + tokenDecimals);
    }

    function convertUsdToToken(
        uint256 amountUsd,
        uint256 tokenDecimals,
        IPriceFeed oracle
    ) internal view returns (uint256 amount) {
        uint8 decimals = getDecimals(oracle);
        uint256 price = getPrice(oracle);

        amount =
            (amountUsd * 10 ** (decimals + tokenDecimals)) /
            (price * (10 ** USD_DECIMALS));
    }
}

File 32 of 34 : OvnMath.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

library OvnMath {
    uint256 constant BASIS_DENOMINATOR = 1e6;

    function abs(uint256 x, uint256 y) internal pure returns (uint256) {
        return (x > y) ? (x - y) : (y - x);
    }

    function addBasisPoints(
        uint256 amount,
        uint256 basisPoints
    ) internal pure returns (uint256) {
        return (amount * (BASIS_DENOMINATOR + basisPoints)) / BASIS_DENOMINATOR;
    }

    function reverseAddBasisPoints(
        uint256 amount,
        uint256 basisPoints
    ) internal pure returns (uint256) {
        return (amount * BASIS_DENOMINATOR) / (BASIS_DENOMINATOR + basisPoints);
    }

    function subBasisPoints(
        uint256 amount,
        uint256 basisPoints
    ) internal pure returns (uint256) {
        return (amount * (BASIS_DENOMINATOR - basisPoints)) / BASIS_DENOMINATOR;
    }

    function reverseSubBasisPoints(
        uint256 amount,
        uint256 basisPoints
    ) internal pure returns (uint256) {
        return (amount * BASIS_DENOMINATOR) / (BASIS_DENOMINATOR - basisPoints);
    }
}

File 33 of 34 : Stabilizer.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

// ====================================================================
// ====================== Stabilizer.sol ==============================
// ====================================================================

/**
 * @title Stabilizer
 * @dev Implementation:
 * Allows to take debt by minting sweep and repaying by burning sweep
 * Allows to buy and sell sweep in an AMM
 * Allows auto invest according the borrower configuration
 * Allows auto repays by the balancer to control sweep price
 * Allow liquidate the Asset when is defaulted
 * Repayments made by burning sweep
 * EquityRatio = Junior / (Junior + Senior)
 */

import { IAMM } from "../AMM/IAMM.sol";
import { Owned } from "../Common/Owned.sol";
import { ChainlinkLibrary, IPriceFeed } from "../Libraries/Chainlink.sol";
import { OvnMath } from "../Libraries/OvnMath.sol";
import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { TransferHelper } from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract Stabilizer is Owned, Pausable, ReentrancyGuard {
    using Math for uint256;

    IERC20Metadata public usdx;
    IPriceFeed public oracleUsdx;

    // Variables
    string public name;
    address public borrower;
    int256 public minEquityRatio; // Minimum Equity Ratio. 10000 is 1%
    uint256 public sweepBorrowed;
    uint256 public loanLimit;

    uint256 public callTime;
    uint256 public callDelay; // 86400 is 1 day
    uint256 public callAmount;

    uint256 public protocolFee; // 10000 is 1%
    uint256 public spreadDate;
    string public link;

    int256 public autoInvestMinRatio; // 10000 is 1%
    uint256 public autoInvestMinAmount;
    bool public autoInvestEnabled;

    bool public settingsEnabled;

    uint256 public startingTime;
    uint256 public startingPrice;
    uint256 public decreaseFactor; // 10000 is 1%
    uint256 public minLiquidationRatio; // 100000 is 10%
    bool public auctionAllowed;

    // Constants for various precisions
    uint256 private constant DAY_SECONDS = 60 * 60 * 24; // seconds of Day
    uint256 private constant DAYS_ONE_YEAR = 365; // days of Year
    uint256 private constant PRECISION = 1e6;
    uint256 private constant ORACLE_FREQUENCY = 1 days;

    /* ========== Events ========== */

    event Borrowed(uint256 indexed sweepAmount);
    event Repaid(uint256 indexed sweepAmount);
    event Withdrawn(address indexed token, uint256 indexed amount);
    event PayFee(uint256 indexed sweepAmount);
    event Bought(uint256 indexed sweepAmount);
    event Sold(uint256 indexed sweepAmount);
    event BoughtSWEEP(uint256 indexed sweepAmount);
    event SoldSWEEP(uint256 indexed usdxAmount);
    event LoanLimitChanged(uint256 loanLimit);
    event Proposed(address indexed borrower);
    event Rejected(address indexed borrower);
    event SweepBorrowedChanged(uint256 indexed sweepAmount);

    event Liquidated(address indexed user);

    event AutoCalled(uint256 indexed sweepAmount);
    event AutoInvested(uint256 indexed sweepAmount);
    event CallCancelled(uint256 indexed sweepAmount);

    event ConfigurationChanged(
        int256 indexed minEquityRatio,
        uint256 indexed protocolFee,
        uint256 loanLimit,
        uint256 decreaseFactor,
        uint256 callDelay,
        int256 autoInvestMinRatio,
        uint256 autoInvestMinAmount,
        uint256 minLiquidationRatio,
        bool autoInvestEnabled,
        bool _auctionAllowed,
        string link
    );

    /* ========== Errors ========== */

    error NotBorrower();
    error NotBalancer();
    error NotSweep();
    error SettingsDisabled();
    error OverZero();
    error AssetDefaulted();
    error AuctionNotActive();
    error ActionNotAllowed();
    error InvalidMinter();
    error NotEnoughBalance();
    error EquityRatioExcessed();
    error InvalidToken();
    error SpreadNotEnough();
    error NotDefaulted();
    error NotAutoInvest();
    error NotAutoInvestMinAmount();
    error NotAutoInvestMinRatio();

    /* ========== Modifies ========== */

    modifier onlyBorrower() {
        _onlyBorrower();
        _;
    }

    modifier onlySettingsEnabled() {
        _onlySettingsEnabled();
        _;
    }

    modifier validAmount(uint256 amount) {
        _validAmount(amount);
        _;
    }

    constructor(
        string memory _name,
        address _sweep,
        address _usdx,
        address _oracleUsdx,
        address _borrower
    ) Owned(_sweep) {
        if (_borrower == address(0)) revert ZeroAddressDetected();
        name = _name;
        usdx = IERC20Metadata(_usdx);
        oracleUsdx = IPriceFeed(_oracleUsdx);
        borrower = _borrower;
        settingsEnabled = true;
    }

    /* ========== Views ========== */

    /**
     * @notice Defaulted
     * @return bool that tells if stabilizer is in default.
     */
    function isDefaulted() public view returns (bool) {
        return
            (callDelay > 0 && callAmount > 0 && block.timestamp > callTime) ||
            (sweepBorrowed > 0 && getEquityRatio() < minEquityRatio);
    }

    /**
     * @notice Get Equity Ratio
     * @return the current equity ratio based in the internal storage.
     * @dev this value have a precision of 6 decimals.
     */
    function getEquityRatio() public view returns (int256) {
        uint256 totalValue = currentValue();

        if (totalValue == 0) {
            if (sweepBorrowed > 0) return -1e6;
            else return 0;
        }

        uint256 seniorTrancheInUsd = sweep.convertToUSD(sweepBorrowed);
        // 1e6 are decimals of the percentage result
        int256 equityRatio = ((int256(totalValue) - int256(seniorTrancheInUsd)) * 1e6) / int256(totalValue);

        if (equityRatio < -1e6) equityRatio = -1e6;
        return equityRatio;
    }

    /**
     * @notice Get Spread Amount
     * fee = borrow_amount * spread_ratio * (time / time_per_year)
     * @return uint256 calculated spread amount.
     */
    function accruedFee() public view returns (uint256) {
        if (sweepBorrowed > 0) {
            uint256 period = (block.timestamp - spreadDate) / DAY_SECONDS;
            return
                (sweepBorrowed * protocolFee * period) /
                (DAYS_ONE_YEAR * PRECISION);
        }

        return 0;
    }

    /**
     * @notice Get Debt Amount
     * debt = borrow_amount + spread fee
     * @return uint256 calculated debt amount.
     */
    function getDebt() public view returns (uint256) {
        return sweepBorrowed + accruedFee();
    }

    /**
     * @notice Get Current Value
     * value = sweep balance + usdx balance
     * @return uint256.
     */
    function currentValue() public view returns (uint256) {
        (uint256 usdxBalance, uint256 sweepBalance) = _balances();
        uint256 sweepInUsd = sweep.convertToUSD(sweepBalance);
        uint256 usdxInUsd = _oracleUsdxToUsd(usdxBalance);
        uint256 accruedFeeInUSD = sweep.convertToUSD(accruedFee());

        return assetValue() + usdxInUsd + sweepInUsd - accruedFeeInUSD;
    }

    /**
     * @notice Get AMM from Sweep
     * @return address.
     */
    function amm() public view virtual returns (IAMM) {
        return IAMM(sweep.amm());
    }

    /**
     * @notice Get Junior Tranche Value
     * @return int256 calculated junior tranche amount.
     */
    function getJuniorTrancheValue() external view returns (int256) {
        uint256 seniorTrancheInUSD = sweep.convertToUSD(sweepBorrowed);
        uint256 totalValue = currentValue();

        return int256(totalValue) - int256(seniorTrancheInUSD);
    }

    /**
     * @notice Returns the SWEEP required to liquidate the stabilizer in the auction.
     * @return auctionPrice
     */
    function getAuctionAmount() public view returns (uint256) {
        uint256 minPrice = sweepBorrowed * (PRECISION - minLiquidationRatio) / PRECISION;
        uint256 timeElapsed = (block.timestamp - startingTime) / 5 minutes;
        uint256 ratio = timeElapsed * decreaseFactor;

        if(ratio > PRECISION) return minPrice;

        uint256 decreaseRatio = PRECISION - ratio;
        uint256 auctionPrice = (startingPrice * decreaseRatio) / PRECISION;

        return minPrice > auctionPrice ? minPrice : auctionPrice;
    }

    /* ========== Settings ========== */

    /**
     * @notice Pause
     * @dev Stops investment actions.
     */
    function pause() external onlyMultisigOrGov {
        _pause();
    }

    /**
     * @notice Unpause
     * @dev Start investment actions.
     */
    function unpause() external onlyMultisigOrGov {
        _unpause();
    }

    function changeBorrower(address newBorrower) external onlyGov {
        if(newBorrower == address(0)) revert ZeroAddressDetected();
        borrower = newBorrower;
    }

    /**
     * @notice Configure intial settings
     * @param _minEquityRatio The minimum equity ratio can be negative.
     * @param _protocolFee The fee that the protocol will get for providing the loan when the stabilizer takes debt
     * @param _loanLimit How much debt a Stabilizer can take in SWEEP.
     * @param _decreaseFactor A percentage that will be discounted from the price as time passes from the auction start.
     * @param _callDelay Time in seconds after AutoCall until the Stabilizer gets defaulted if the debt is not paid in that period
     * @param _autoInvestMinRatio Minimum equity ratio that should be kept to allow the execution of an auto invest
     * @param _autoInvestMinAmount Minimum amount to be invested to allow the execution of an auto invest
     * @param _autoInvestEnabled Represents if an auto invest execution is allowed or not
     * @param _auctionAllowed Represents if an auction is allowed or not
     * @param _link A URL link to a Web page that describes the borrower and the asset
     * @dev Sets the initial configuration of the Stabilizer.
     * This configuration will be analyzed by the protocol and if accepted,
     * used to include the Stabilizer in the minter's whitelist of Sweep.
     * The minimum equity ratio can not be less than 1%
     */
    function configure(
        int256 _minEquityRatio,
        uint256 _protocolFee,
        uint256 _loanLimit,
        uint256 _decreaseFactor,
        uint256 _callDelay,
        int256 _autoInvestMinRatio,
        uint256 _autoInvestMinAmount,
        uint256 _minLiquidationRatio,
        bool _autoInvestEnabled,
        bool _auctionAllowed,
        string calldata _link
    ) external onlyBorrower onlySettingsEnabled {
        minEquityRatio = _minEquityRatio;
        protocolFee = _protocolFee;
        loanLimit = _loanLimit;
        decreaseFactor = _decreaseFactor;
        callDelay = _callDelay;
        autoInvestMinRatio = _autoInvestMinRatio;
        autoInvestMinAmount = _autoInvestMinAmount;
        minLiquidationRatio = _minLiquidationRatio;
        autoInvestEnabled = _autoInvestEnabled;
        auctionAllowed = _auctionAllowed;
        link = _link;

        emit ConfigurationChanged(
            _minEquityRatio,
            _protocolFee,
            _loanLimit,
            decreaseFactor,
            _callDelay,
            _autoInvestMinRatio,
            _autoInvestMinAmount,
            _minLiquidationRatio,
            _autoInvestEnabled,
            _auctionAllowed,
            _link
        );
    }

    /**
     * @notice Changes the account that control the global configuration to the protocol/governance admin
     * @dev after disable settings by admin
     * the protocol will evaluate adding the stabilizer to the minter list.
     */
    function propose() external onlyBorrower {
        settingsEnabled = false;

        emit Proposed(borrower);
    }

    /**
     * @notice Changes the account that control the global configuration to the borrower
     * @dev after enable settings for the borrower
     * he/she should edit the values to align to the protocol requirements
     */
    function reject() external onlyGov {
        settingsEnabled = true;
        _pause();

        emit Rejected(borrower);
    }

    /* ========== Actions ========== */

    /**
     * @notice Borrows Sweep
     * Asks the stabilizer to mint a certain amount of sweep token.
     * @param sweepAmount.
     * @dev Increases the sweepBorrowed (senior tranche).
     */
    function borrow(
        uint256 sweepAmount
    )
        public
        onlyBorrower
        whenNotPaused
        validAmount(sweepAmount)
        nonReentrant
    {
        _borrow(sweepAmount);
        _checkRatio();
    }

    /**
     * @notice Repays Sweep
     * Burns the sweep amount to reduce the debt (senior tranche).
     * @param sweepAmount Amount to be burnt by Sweep.
     * @dev Decreases the sweep borrowed.
     */
    function repay(uint256 sweepAmount) external onlyBorrower nonReentrant {
        _repay(sweepAmount);
    }

    /**
     * @notice Pay the spread to the treasury
     */
    function payFee() external onlyBorrower nonReentrant {
        uint256 feeAmount = accruedFee();
        spreadDate = block.timestamp;

        uint256 sweepBalance = sweep.balanceOf(address(this));

        if (feeAmount > sweepBalance) revert SpreadNotEnough();

        if (feeAmount > 0) {
            TransferHelper.safeTransfer(
                address(sweep),
                sweep.treasury(),
                feeAmount
            );

            emit PayFee(feeAmount);
        }
    }

    /**
     * @notice Set Loan Limit.
     * @param newLoanLimit.
     * @dev How much debt an Stabilizer can take in SWEEP.
     */
    function setLoanLimit(uint256 newLoanLimit) external {
        if (msg.sender != sweep.balancer()) revert NotBalancer();
        loanLimit = newLoanLimit;

        emit LoanLimitChanged(newLoanLimit);
    }

    /**
     * @notice Update Sweep Borrowed Amount.
     * @param amount.
     */
    function updateSweepBorrowed(uint256 amount) external {
        if (msg.sender != address(sweep)) revert NotSweep();
        sweepBorrowed = amount;

        emit SweepBorrowedChanged(amount);
    }

    /**
     * @notice Auto Call.
     * @param sweepAmount to repay.
     * @dev Strategy:
     * 1) repays debt with SWEEP balance
     * 2) repays remaining debt by divesting
     * 3) repays remaining debt by buying on SWEEP in the AMM
     */
    function autoCall(
        uint256 sweepAmount,
        uint256,
        uint256 slippage
    ) external nonReentrant {
        if (msg.sender != sweep.balancer()) revert NotBalancer();
        (uint256 usdxBalance, uint256 sweepBalance) = _balances();
        uint256 repayAmount = sweepAmount.min(getDebt());

        if (callDelay > 0) {
            callTime = block.timestamp + callDelay;
            callAmount = repayAmount;
        }

        if (sweepBalance < repayAmount) {
            uint256 missingSweep = repayAmount - sweepBalance;
            uint256 sweepInUsd = sweep.convertToUSD(missingSweep);
            uint256 missingUsdx = _oracleUsdToUsdx(sweepInUsd);

            if (missingUsdx > usdxBalance) {
                _divest(missingUsdx - usdxBalance, slippage);
            }

            if (usdx.balanceOf(address(this)) > 0) {
                _buy(missingUsdx, slippage);
            }
        }

        if (sweep.balanceOf(address(this)) > 0 && repayAmount > 0) {
            _repay(repayAmount);
        }

        emit AutoCalled(sweepAmount);
    }

    /**
     * @notice Cancel Call
     * @dev Cancels the auto call request by clearing variables for an asset
     * that has a callDelay: meaning that it does not autorepay.
     */
    function cancelCall() external {
        if (msg.sender != sweep.balancer()) revert NotBalancer();
        callAmount = 0;
        callTime = 0;
        emit CallCancelled(callAmount);
    }

    /**
     * @notice Auto Invest.
     * @param sweepAmount to mint.
     * @param slippage.
     */
    function autoInvest(
        uint256 sweepAmount,
        uint256,
        uint256 slippage
    ) external nonReentrant {
        if (msg.sender != sweep.balancer()) revert NotBalancer();
        if (!autoInvestEnabled) revert NotAutoInvest();
        if (sweepAmount < autoInvestMinAmount) revert NotAutoInvestMinAmount();

        _borrow(sweepAmount);
        uint256 usdxAmount = _sell(sweepAmount, slippage);
        _invest(usdxAmount, 0, slippage);

        if (getEquityRatio() < autoInvestMinRatio){
            revert NotAutoInvestMinRatio();
        }

        emit AutoInvested(sweepAmount);
    }

    /**
     * @notice Buy
     * Buys sweep amount from the stabilizer's balance to the AMM (swaps USDX to SWEEP).
     * @param usdxAmount Amount to be changed in the AMM.
     * @param slippage Minimum amount out.
     * @dev Increases the sweep balance and decrease usdx balance.
     */
    function buySweepOnAMM(
        uint256 usdxAmount,
        uint256 slippage
    )
        external
        onlyBorrower
        whenNotPaused
        nonReentrant
        returns (uint256 sweepAmount)
    {
        sweepAmount = _buy(usdxAmount, slippage);
        emit Bought(sweepAmount);
    }

    /**
     * @notice Sell Sweep
     * Sells sweep amount from the stabilizer's balance to the AMM (swaps SWEEP to USDX).
     * @param sweepAmount.
     * @param slippage Minimum amount out.
     * @dev Decreases the sweep balance and increase usdx balance
     */
    function sellSweepOnAMM(
        uint256 sweepAmount,
        uint256 slippage
    )
        external
        onlyBorrower
        whenNotPaused
        nonReentrant
        returns (uint256 usdxAmount)
    {
        usdxAmount = _sell(sweepAmount, slippage);
        emit Sold(sweepAmount);
    }

    function oneStepInvest(uint256 sweepAmount, uint256 slippage, bool useAMM) 
        external onlyBorrower whenNotPaused validAmount(sweepAmount) nonReentrant
        returns(uint256 usdxAmount)
    {
        _borrow(sweepAmount);
        
        if(useAMM) {
            usdxAmount = _sell(sweepAmount, slippage);
        } else {
            usdxAmount = sweep.convertToUSD(sweepAmount);
        }

        _invest(usdxAmount, 0, slippage);
        _checkRatio();
    }

    function oneStepDivest(uint256 usdxAmount, uint256 slippage, bool useAMM)
        external onlyBorrower whenNotPaused validAmount(usdxAmount) nonReentrant
        returns(uint256 sweepAmount)
    {
        _divest(usdxAmount, slippage);

        if(useAMM) {
            sweepAmount = _buy(usdxAmount, slippage);
        } else {
            sweepAmount = sweep.convertToSWEEP(usdxAmount);
        }

        _repay(sweepAmount);
    }

    /**
     * @notice Withdraw SWEEP
     * Takes out sweep balance if the new equity ratio is higher than the minimum equity ratio.
     * @param token.
     * @param amount.
     * @dev Decreases the sweep balance.
     */
    function withdraw(address token, uint256 amount) 
        external onlyBorrower whenNotPaused validAmount(amount) nonReentrant
    {
        uint256 balance = IERC20Metadata(token).balanceOf(address(this));
        if (amount > balance) amount = balance;

        TransferHelper.safeTransfer(token, msg.sender, amount);

        if (sweepBorrowed > 0) _checkRatio();

        emit Withdrawn(token, amount);
    }

    /**
     * @notice Start auction
     * Initiates a dutch auction for liquidation.
     */
    function startAuction() external nonReentrant {
        if (!isDefaulted()) revert NotDefaulted();
        if(!auctionAllowed || startingPrice > 0) revert ActionNotAllowed();

        startingTime = block.timestamp;
        uint256 minEquity = (PRECISION - uint256(minEquityRatio));
        startingPrice = getDebt() * PRECISION / minEquity;
    }

    /**
     * @notice Buy auction
     * Allows a user to participate in the auction by buying assets
     */
    function buyAuction() external nonReentrant {
        if(startingTime == 0) revert AuctionNotActive();
        uint256 debt = getAuctionAmount();
        address token = _getToken();
        _liquidate(token, debt);
    }

    /* ========== Internals ========== */

    function assetValue() public view virtual returns (uint256) { return 0; }

    /**
     * @notice Invest To Asset.
     */
    function _invest(uint256, uint256, uint256) internal virtual {}

    /**
     * @notice Divest From Asset.
     */
    function _divest(uint256, uint256) internal virtual {}

    /**
     * @notice Get asset address to liquidate.
     */
    function _getToken() internal view virtual returns (address) {}

    /**
     * @notice Stop the auction.
     */
    function _stopAuction() internal {
        startingTime = 0;
        startingPrice = 0;
    }

    /**
     * @notice Liquidates
     * A liquidator repays the debt in sweep and gets the same value
     * of the assets that the stabilizer holds at a discount
     */
    function _liquidate(
        address token,
        uint256 debt
    ) internal {
        if (!isDefaulted()) revert NotDefaulted();
        address self = address(this);
        uint256 usdxBalance = usdx.balanceOf(self);
        uint256 tokenBalance = IERC20Metadata(token).balanceOf(self);
        uint256 sweepBalance = sweep.balanceOf(self);
        if(debt > sweepBalance) {
            // Takes SWEEP from the liquidator and repays debt
            TransferHelper.safeTransferFrom(
                address(sweep),
                msg.sender,
                self,
                debt - sweepBalance
            );
        }

        // Gives all the assets to the liquidator
        TransferHelper.safeTransfer(address(usdx), msg.sender, usdxBalance);
        TransferHelper.safeTransfer(token, msg.sender, tokenBalance);

        _repay(debt);

        emit Liquidated(msg.sender);
    }

    function _buy(
        uint256 usdxAmount, 
        uint256 slippage
    ) internal returns (uint256 sweepAmount) {
        uint256 usdxBalance = usdx.balanceOf(address(this));
        usdxAmount = usdxAmount.min(usdxBalance);
        if (usdxAmount == 0) revert NotEnoughBalance();

        sweepAmount = sweep.convertToSWEEP(_oracleUsdxToUsd(usdxAmount));
        uint256 minAmountOut = OvnMath.subBasisPoints(sweepAmount, slippage);

        IAMM _amm = amm();
        TransferHelper.safeApprove(address(usdx), address(_amm), usdxAmount);
        sweepAmount = _amm.buySweep(
            address(usdx),
            usdxAmount,
            minAmountOut
        );

        return sweepAmount;
    }

    function _sell(
        uint256 sweepAmount,
        uint256 slippage
    ) internal returns (uint256 usdxAmount) {
        uint256 sweepBalance = sweep.balanceOf(address(this));
        sweepAmount = sweepAmount.min(sweepBalance);
        if (sweepAmount == 0) revert NotEnoughBalance();

        usdxAmount = _oracleUsdToUsdx(sweep.convertToUSD(sweepAmount));
        uint256 minAmountOut = OvnMath.subBasisPoints(usdxAmount, slippage);

        IAMM _amm = amm();
        TransferHelper.safeApprove(address(sweep), address(_amm), sweepAmount);
        usdxAmount = _amm.sellSweep(
            address(usdx),
            sweepAmount,
            minAmountOut
        );

        return usdxAmount;
    }

    function _borrow(uint256 sweepAmount) internal {
        if (!sweep.isValidMinter(address(this))) revert InvalidMinter();
        uint256 sweepAvailable = loanLimit - sweepBorrowed;
        if (sweepAvailable < sweepAmount) revert NotEnoughBalance();

        uint256 spreadAmount = accruedFee();
        sweep.mint(sweepAmount);
        sweepBorrowed += sweepAmount;
        spreadDate = block.timestamp;

        if (spreadAmount > 0) {
            TransferHelper.safeTransfer(
                address(sweep),
                sweep.treasury(),
                spreadAmount
            );
            emit PayFee(spreadAmount);
        }

        emit Borrowed(sweepAmount);
    }

    function _repay(uint256 sweepAmount) internal {
        sweepAmount = sweepAmount.min(sweep.balanceOf(address(this)));
        sweepAmount = sweepAmount.min(getDebt());

        if (sweepAmount == 0) revert NotEnoughBalance();

        callAmount = (callAmount > sweepAmount)
            ? (callAmount - sweepAmount)
            : 0;

        if (callDelay > 0 && callAmount == 0) callTime = 0;

        uint256 spreadAmount = accruedFee();
        spreadDate = block.timestamp;

        sweepAmount = sweepAmount - spreadAmount;
        if (sweepBorrowed < sweepAmount) {
            sweepAmount = sweepBorrowed;
            sweepBorrowed = 0;
        } else {
            sweepBorrowed -= sweepAmount;
        }

        TransferHelper.safeTransfer(
            address(sweep),
            sweep.treasury(),
            spreadAmount
        );

        TransferHelper.safeApprove(address(sweep), address(this), sweepAmount);
        sweep.burn(sweepAmount);

        emit Repaid(sweepAmount);
        if(!isDefaulted()) _stopAuction();
    }

    

    /**
     * @notice Get Balances of the usdx and SWEEP.
     **/
    function _balances()
        internal
        view
        returns (uint256 usdxBalance, uint256 sweepBalance)
    {
        usdxBalance = usdx.balanceOf(address(this));
        sweepBalance = sweep.balanceOf(address(this));
    }

    function _onlyBorrower() internal view {
        if (msg.sender != borrower) revert NotBorrower();
    }

    function _onlySettingsEnabled() internal view {
        if (!settingsEnabled) revert SettingsDisabled();
    }

    function _validAmount(uint256 amount) internal pure {
        if (amount == 0) revert OverZero();
    }

    function _oracleUsdxToUsd(
        uint256 usdxAmount
    ) internal view returns (uint256) {
        return
            ChainlinkLibrary.convertTokenToUsd(
                usdxAmount,
                usdx.decimals(),
                oracleUsdx
            );
    }

    function _oracleUsdToUsdx(
        uint256 usdAmount
    ) internal view returns (uint256) {
        return
            ChainlinkLibrary.convertUsdToToken(
                usdAmount,
                usdx.decimals(),
                oracleUsdx
            );
    }

    function _checkRatio() internal view {
        if (getEquityRatio() < minEquityRatio) revert EquityRatioExcessed();
    }
}

File 34 of 34 : ISweep.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

interface ISweep {
    struct Minter {
        uint256 maxAmount;
        uint256 mintedAmount;
        bool isListed;
        bool isEnabled;
    }

    function isMintingAllowed() external view returns (bool);

    function DEFAULT_ADMIN_ADDRESS() external view returns (address);

    function balancer() external view returns (address);

    function treasury() external view returns (address);

    function allowance(
        address holder,
        address spender
    ) external view returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

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

    function decimals() external view returns (uint8);

    function decreaseAllowance(
        address spender,
        uint256 subtractedValue
    ) external returns (bool);

    function isValidMinter(address) external view returns (bool);

    function amm() external view returns (address);

    function ammPrice() external view returns (uint256);

    function twaPrice() external view returns (uint256);

    function increaseAllowance(
        address spender,
        uint256 addedValue
    ) external returns (bool);

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

    function owner() external view returns (address);

    function fastMultisig() external view returns (address);

    function burn(uint256 amount) external;

    function mint(uint256 amount) external;

    function minters(address minterAaddress) external returns (Minter memory);

    function minterAddresses(uint256 index) external view returns (address);

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

    function targetPrice() external view returns (uint256);

    function interestRate() external view returns (int256);

    function periodStart() external view returns (uint256);

    function stepValue() external view returns (int256);

    function arbSpread() external view returns (uint256);

    function refreshInterestRate(int256 newInterestRate, uint256 newPeriodStart) external;

    function setTargetPrice(
        uint256 currentTargetPrice,
        uint256 nextTargetPrice
    ) external;

    function setInterestRate(
        int256 currentInterestRate,
        int256 nextInterestRate
    ) external;

    function setPeriodStart(
        uint256 currentPeriodStart,
        uint256 nextPeriodStart
    ) external;

    function startNewPeriod() external;

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

    function totalSupply() external view returns (uint256);

    function convertToUSD(uint256 amount) external view returns (uint256);

    function convertToSWEEP(uint256 amount) external view returns (uint256);

    function transfer(
        address recipient,
        uint256 amount
    ) external returns (bool);

    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_sweep","type":"address"},{"internalType":"address","name":"_usdx","type":"address"},{"internalType":"address","name":"_oracleUsdx","type":"address"},{"internalType":"address","name":"_positionManager","type":"address"},{"internalType":"address","name":"_borrower","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ActionNotAllowed","type":"error"},{"inputs":[],"name":"AssetDefaulted","type":"error"},{"inputs":[],"name":"AuctionNotActive","type":"error"},{"inputs":[],"name":"BadSlippage","type":"error"},{"inputs":[],"name":"EquityRatioExcessed","type":"error"},{"inputs":[],"name":"InvalidMinter","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"NotAutoInvest","type":"error"},{"inputs":[],"name":"NotAutoInvestMinAmount","type":"error"},{"inputs":[],"name":"NotAutoInvestMinRatio","type":"error"},{"inputs":[],"name":"NotBalancer","type":"error"},{"inputs":[],"name":"NotBorrower","type":"error"},{"inputs":[],"name":"NotDefaulted","type":"error"},{"inputs":[],"name":"NotEnoughBalance","type":"error"},{"inputs":[],"name":"NotGovernance","type":"error"},{"inputs":[],"name":"NotMinted","type":"error"},{"inputs":[],"name":"NotMultisigOrGov","type":"error"},{"inputs":[],"name":"NotSweep","type":"error"},{"inputs":[],"name":"OverZero","type":"error"},{"inputs":[],"name":"SettingsDisabled","type":"error"},{"inputs":[],"name":"SpreadNotEnough","type":"error"},{"inputs":[],"name":"ZeroAddressDetected","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"AutoCalled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"AutoInvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"Borrowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"Bought","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"BoughtSWEEP","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"CallCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Collected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"int256","name":"minEquityRatio","type":"int256"},{"indexed":true,"internalType":"uint256","name":"protocolFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"decreaseFactor","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"callDelay","type":"uint256"},{"indexed":false,"internalType":"int256","name":"autoInvestMinRatio","type":"int256"},{"indexed":false,"internalType":"uint256","name":"autoInvestMinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minLiquidationRatio","type":"uint256"},{"indexed":false,"internalType":"bool","name":"autoInvestEnabled","type":"bool"},{"indexed":false,"internalType":"bool","name":"_auctionAllowed","type":"bool"},{"indexed":false,"internalType":"string","name":"link","type":"string"}],"name":"ConfigurationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"Liquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"LiquidityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"loanLimit","type":"uint256"}],"name":"LoanLimitChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"PayFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"}],"name":"Proposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"}],"name":"Rejected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"Repaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"Sold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"usdxAmount","type":"uint256"}],"name":"SoldSWEEP","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"SweepBorrowedChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"sweeAmount","type":"uint256"}],"name":"SweepPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"accruedFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"usdxMinIn","type":"uint256"},{"internalType":"uint256","name":"sweepMinIn","type":"uint256"}],"name":"addLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"amm","outputs":[{"internalType":"contract IAMM","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ammAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"}],"name":"autoCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"}],"name":"autoInvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"autoInvestEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"autoInvestMinAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"autoInvestMinRatio","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"borrower","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burnGrowPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burnRedeemPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burnTradePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"}],"name":"buySweep","outputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"}],"name":"buySweepOnAMM","outputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"callAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"callDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"callTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newBorrower","type":"address"}],"name":"changeBorrower","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"position","type":"uint256"}],"name":"collectFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256","name":"_minEquityRatio","type":"int256"},{"internalType":"uint256","name":"_protocolFee","type":"uint256"},{"internalType":"uint256","name":"_loanLimit","type":"uint256"},{"internalType":"uint256","name":"_decreaseFactor","type":"uint256"},{"internalType":"uint256","name":"_callDelay","type":"uint256"},{"internalType":"int256","name":"_autoInvestMinRatio","type":"int256"},{"internalType":"uint256","name":"_autoInvestMinAmount","type":"uint256"},{"internalType":"uint256","name":"_minLiquidationRatio","type":"uint256"},{"internalType":"bool","name":"_autoInvestEnabled","type":"bool"},{"internalType":"bool","name":"_auctionAllowed","type":"bool"},{"internalType":"string","name":"_link","type":"string"}],"name":"configure","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decreaseFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAuctionAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBuyPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEquityRatio","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getJuniorTrancheValue","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"growLiquidity","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"growPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isDefaulted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"link","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"loanLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"priceSpread","type":"uint256"},{"internalType":"uint256","name":"sweepSlippage","type":"uint256"}],"name":"lpGrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"priceSpread","type":"uint256"},{"internalType":"uint256","name":"usdxSlippage","type":"uint256"}],"name":"lpRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"usdxSlippage","type":"uint256"},{"internalType":"uint256","name":"sweepSlippage","type":"uint256"},{"internalType":"uint256","name":"spread","type":"uint256"}],"name":"lpTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minEquityRatio","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minLiquidationRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"bool","name":"useAMM","type":"bool"}],"name":"oneStepDivest","outputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"bool","name":"useAMM","type":"bool"}],"name":"oneStepInvest","outputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"oracleUsdx","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"payFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"propose","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"protocolFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemLiquidity","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reject","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"liquidityAmount","type":"uint256"},{"internalType":"uint256","name":"amountOut0","type":"uint256"},{"internalType":"uint256","name":"amountOut1","type":"uint256"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sweepAmount","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"}],"name":"sellSweepOnAMM","outputs":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAmm","type":"address"}],"name":"setAMM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newLoanLimit","type":"uint256"}],"name":"setLoanLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newSlippage","type":"uint32"}],"name":"setSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"settingsEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"slippage","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"spreadDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startingPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startingTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sweep","outputs":[{"internalType":"contract ISweep","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sweepBorrowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradeLiquidity","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradePosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateSweepBorrowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdx","outputs":[{"internalType":"contract IERC20Metadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60e06040523480156200001157600080fd5b5060405162005f9538038062005f958339810160408190526200003491620001ad565b8585858584836001600160a01b0381166200006257604051632887dd7560e11b815260040160405180910390fd5b6001600160a01b039081166080526000805460ff191690556001805581166200009e57604051632887dd7560e11b815260040160405180910390fd5b6004620000ac86826200036d565b50600280546001600160a01b039485166001600160a01b031991821617909155600380549385169382169390931790925560058054918416919092161790556011805461ff001916610100179055601c805463ffffffff19166113881790558781169087161060c081905291506200012890505784846200012b565b83855b601780546001600160a01b0319166001600160a01b0392831617905560168054610100600160a81b03191661010093831693909302929092179091559190911660a05250620004399350505050565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b0381168114620001a857600080fd5b919050565b60008060008060008060c08789031215620001c757600080fd5b86516001600160401b0380821115620001df57600080fd5b818901915089601f830112620001f457600080fd5b8151818111156200020957620002096200017a565b604051601f8201601f19908116603f011681019083821181831017156200023457620002346200017a565b81604052828152602093508c848487010111156200025157600080fd5b600091505b8282101562000275578482018401518183018501529083019062000256565b6000848483010152809a5050505062000290818a0162000190565b96505050620002a26040880162000190565b9350620002b26060880162000190565b9250620002c26080880162000190565b9150620002d260a0880162000190565b90509295509295509295565b600181811c90821680620002f357607f821691505b6020821081036200031457634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200036857600081815260208120601f850160051c81016020861015620003435750805b601f850160051c820191505b8181101562000364578281556001016200034f565b5050505b505050565b81516001600160401b038111156200038957620003896200017a565b620003a1816200039a8454620002de565b846200031a565b602080601f831160018114620003d95760008415620003c05750858301515b600019600386901b1c1916600185901b17855562000364565b600085815260208120601f198616915b828110156200040a57888601518255948401946001909101908401620003e9565b5085821015620004295787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c051615996620005ff600039600081816128ed015281816134eb0152613e10015260008181613339015281816133dd0152818161345d015281816134ae01528181613e7f01528181613fab015281816142ce015281816147cb0152614a0f01526000818161060b0152818161091c015281816109a501528181610b3101528181610c8001528181610dec01528181610f05015281816110ea0152818161118a015281816111ab01528181611273015281816112e6015281816113f90152818161149701528181611555015281816116eb01528181611769015281816118690152818161198301528181611a9f01528181611b4f01528181611ca701528181611d3001528181611e9f01528181611f3d015281816121b9015281816123ff0152818161252c01528181612656015281816127ee015281816129a501528181612e5301528181612f3b01528181612fc501528181612fe6015281816130ea0152818161319e015281816132410152818161348d01528181613668015281816137a2015281816137c3015281816138240152818161386001528181613a3b01528181613bd70152818161415d015281816141d7015261458501526159966000f3fe608060405234801561001057600080fd5b506004361061046a5760003560e01c80637df1f1b91161024c578063bc5477ad11610146578063e3d24dea116100c3578063f48af70111610087578063f48af701146108d3578063f686138d146108db578063f69aa3d5146108e4578063f88bf15a146108f7578063f95c1b261461090a57600080fd5b8063e3d24dea14610889578063ea8364aa14610891578063f046d966146108a4578063f2674f22146108ad578063f3fef3a3146108c057600080fd5b8063c602be861161010a578063c602be8614610849578063c6beb5861461085c578063d21220a714610865578063d366a41f14610878578063d6fbf2021461088057600080fd5b8063bc5477ad14610801578063c0f4a00514610814578063c198f8ba14610826578063c32abfff1461082e578063c5ebeaec1461083657600080fd5b8063a6a8f1f9116101d4578063b0e21e8a11610198578063b0e21e8a146107cc578063b17acdcd146107d5578063b5d52bf5146107e8578063ba2d0344146107f0578063bb352120146107f857600080fd5b8063a6a8f1f91461078c578063a71891c314610795578063aa8ea3a01461079d578063ad81fced146107b0578063aebf3e41146107b957600080fd5b80638456cb591161021b5780638456cb59146107585780638d1d7c6114610760578063a195166514610773578063a38aaa901461077c578063a516ed021461078457600080fd5b80637df1f1b9146106ff578063804aa9391461071257806381680d0a146107325780638351faf51461074557600080fd5b80632a9439451161036857806348dcacab116102e557806369ae990b116102a957806369ae990b146106c05780636b64c769146106d35780637148ff34146106db578063717e794d146106e457806371dbc900146106ec57600080fd5b806348dcacab146106895780634dc415de146106925780635c975abb1461069a57806361ab077f146106a5578063698996f8146106b857600080fd5b8063371fd8e61161032c578063371fd8e61461062d57806339518b5e146106405780633e032a3b146106495780633f4ba83a1461066e5780634837e2041461067657600080fd5b80632a943945146105c65780632d76643c146105d7578063311176d7146105e05780633168b03f146105f357806335faa4161461060657600080fd5b8063150b7a02116103f657806326f0c8e0116103ba57806326f0c8e0146105735780632716f6bd14610586578063296102521461058e5780632982db001461059657806329b154c3146105b357600080fd5b8063150b7a021461050d5780631c4695f4146105455780631de01bc91461054d5780632164bba314610556578063234439441461056b57600080fd5b80630dfe16811161043d5780630dfe1681146104bb5780630e5f5dbd146104eb5780630f5e07c7146104f357806312f21a1a146104fc57806314a6bf0f1461050557600080fd5b8063018a25e81461046f57806306fdde031461048a57806308a3b85f1461049f578063095559aa146104a8575b600080fd5b610477610917565b6040519081526020015b60405180910390f35b610492610a49565b6040516104819190614e1a565b610477601a5481565b6104776104b6366004614e5b565b610ad7565b6016546104d39061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610481565b610477610bc0565b61047760095481565b610477600d5481565b610477610c25565b61052c61051b366004614ef2565b630a85bd0160e11b95945050505050565b6040516001600160e01b03199091168152602001610481565b610492610c41565b610477600a5481565b610569610564366004614f65565b610c4e565b005b610569610dea565b610569610581366004614f65565b610ed3565b610569611063565b6105696110b1565b6016546105a39060ff1681565b6040519015158152602001610481565b6105696105c1366004614f91565b611268565b6018546001600160a01b03166104d3565b61047760075481565b6002546104d3906001600160a01b031681565b610569610601366004614f91565b6112e4565b6104d37f000000000000000000000000000000000000000000000000000000000000000081565b61056961063b366004614f91565b6113d2565b61047760125481565b601c546106599063ffffffff1681565b60405163ffffffff9091168152602001610481565b6105696113f7565b6018546104d3906001600160a01b031681565b610477600b5481565b610569611553565b60005460ff166105a3565b6104776106b3366004614faa565b611657565b6104776116b8565b6104776106ce366004614f91565b611832565b6105696119f4565b61047760195481565b610477611a9a565b6105696106fa366004614fcc565b611b4d565b6005546104d3906001600160a01b031681565b61071a611c49565b6040516001600160801b039091168152602001610481565b610477610740366004614e5b565b611c56565b610569610753366004614f65565b611d26565b610569611e9d565b6003546104d3906001600160a01b031681565b61047760105481565b6105a3611ff9565b61056961203f565b61047760155481565b610477612082565b6105696107ab366004614fcc565b612247565b61047760085481565b6105696107c7366004614fe9565b6122a0565b610477600c5481565b6105696107e3366004614f91565b6122cb565b6105696122ec565b610477612338565b61047760145481565b61056961080f366004614f65565b6123f5565b6011546105a390610100900460ff1681565b61056961271b565b61071a612768565b610569610844366004614f91565b612775565b61056961085736600461501b565b6127b5565b61047760065481565b6017546104d3906001600160a01b031681565b610477612958565b61047760135481565b610569612a5f565b61056961089f366004615056565b612aab565b610477601b5481565b6105696108bb36600461511d565b612b6a565b6105696108ce366004615143565b612bc0565b61071a612cb6565b610477600f5481565b6104776108f2366004614faa565b612cc3565b610569610905366004614fe9565b612d1e565b6011546105a39060ff1681565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663dc38679c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c919061516f565b9050620f4240817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e19538476040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a25919061516f565b610a2f919061519e565b610a3991906151cb565b610a4390826151df565b91505090565b60048054610a56906151f2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a82906151f2565b8015610acf5780601f10610aa457610100808354040283529160200191610acf565b820191906000526020600020905b815481529060010190602001808311610ab257829003601f168201915b505050505081565b6000610ae1612d4e565b610ae9612d79565b83610af381612dc4565b610afb612de5565b610b0485612e3e565b8215610b1b57610b1485856130c8565b9150610ba7565b60405163113b4fbf60e31b8152600481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906389da7df890602401602060405180830381865afa158015610b80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba4919061516f565b91505b610baf6132f0565b610bb860018055565b509392505050565b60075460009015610c1f57600062015180600d5442610bdf919061522c565b610be991906151cb565b9050610bfa620f424061016d61519e565b81600c54600754610c0b919061519e565b610c15919061519e565b610a4391906151cb565b50600090565b6000610c2f610bc0565b600754610c3c91906151df565b905090565b600e8054610a56906151f2565b610c56612d4e565b610c5e612de5565b601a5415610c7157610c71601a54613320565b610c7c600084613445565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663dc38679c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d00919061516f565b90506000610d166018546001600160a01b031690565b6001600160a01b031663bf56c3fb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d77919061516f565b9050600060c9828411610d8a5782610d8c565b835b610d9691906151df565b90506000620f424082610da988836151df565b610db3919061519e565b610dbd91906151cb565b9050610dcd6000888785856134d3565b601a55610dd86132f0565b50505050610de560018055565b505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6c919061524a565b6001600160a01b0316336001600160a01b031614610e9d5760405163698bba4b60e01b815260040160405180910390fd5b6000600b81905560098190556040517f219124ae95cc25cf220d998f2867d37fb4ab4908cce7c51adfa33ce747aa5747908290a2565b610edb612d4e565b610ee3612de5565b601b5415610ef657610ef6601b54613320565b610f01836000613445565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663dc38679c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f85919061516f565b90506000610f9b6018546001600160a01b031690565b6001600160a01b031663bf56c3fb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffc919061516f565b9050600060c982841061100f5782611011565b835b61101b919061522c565b90506000620f42408261102e888361522c565b611038919061519e565b61104291906151cb565b90506110528760008784866134d3565b601b5550610de5925061331a915050565b61106b612d4e565b611073612de5565b601a5460000361109657604051634d5e5fb360e01b815260040160405180910390fd5b6110a1601a54613320565b6000601a556110af60018055565b565b6110b9612d4e565b6110c1612de5565b60006110cb610bc0565b42600d556040516370a0823160e01b81523060048201529091506000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611139573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115d919061516f565b90508082111561117f576040516206230160eb1b815260040160405180910390fd5b811561125d576112317f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611207573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122b919061524a565b84613556565b60405182907fda0ff68ccd5fb797a8f86207386ea961ca6990c15ace2424ab51eb871ed4959990600090a25b50506110af60018055565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146112b15760405163bc9eca6160e01b815260040160405180910390fd5b600781905560405181907f35ba42ee3c2daa6cf14836eefff16b184565798767ec1e5d723008848aeaf7e390600090a250565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611342573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611366919061524a565b6001600160a01b0316336001600160a01b0316146113975760405163698bba4b60e01b815260040160405180910390fd5b60088190556040518181527f7760d892a7883522367f0eaea35e968381a018418c249cd9aaaca190fe5d88179060200160405180910390a150565b6113da612d4e565b6113e2612de5565b6113eb8161364f565b6113f460018055565b50565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa158015611455573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611479919061524a565b6001600160a01b0316336001600160a01b03161415801561152d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611517919061524a565b6001600160a01b0316336001600160a01b031614155b1561154b57604051631e1c735b60e21b815260040160405180910390fd5b6110af61390a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115d5919061524a565b6001600160a01b0316336001600160a01b03161461160657604051632d5be4cb60e21b815260040160405180910390fd5b6011805461ff00191661010017905561161d61395c565b6005546040516001600160a01b03909116907faf77f8960cf590e245ec8b6d41c193a5dcacad8986ae4eb57ac9e5be7b6af03190600090a2565b6000611661612d4e565b611669612d79565b611671612de5565b61167b8383613999565b60405190915081907f4e08ba899977cf7d4c2964bce71c6b9a7ef76ee5166a4c1249a1e08016e33ef190600090a26116b260018055565b92915050565b60008060006116c5613b4e565b60405163113b4fbf60e31b81526004810182905291935091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906389da7df890602401602060405180830381865afa158015611732573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611756919061516f565b9050600061176384613c50565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166389da7df861179e610bc0565b6040518263ffffffff1660e01b81526004016117bc91815260200190565b602060405180830381865afa1580156117d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fd919061516f565b905080838361180a612082565b61181491906151df565b61181e91906151df565b611828919061522c565b9550505050505090565b600061183c612de5565b60195460000361185f57604051634d5e5fb360e01b815260040160405180910390fd5b611867610917565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e99190615267565b6118f490600a61536e565b6118fd84613c50565b611907919061519e565b61191191906151cb565b905061192661192182600261519e565b612e3e565b601c5460009061193d90849063ffffffff16613cde565b601c5490915060009061195790849063ffffffff16613cde565b600254909150611972906001600160a01b0316333087613d02565b61197e84848484613e04565b6119a97f00000000000000000000000000000000000000000000000000000000000000003385613556565b6119b16132f0565b6040518481527f6e19477745f02fa64cb79e709afd8b6a5da159ef7b135546eafd67c38e425c439060200160405180910390a150506119ef60018055565b919050565b6119fc612de5565b611a04611ff9565b611a215760405163038cbd4b60e31b815260040160405180910390fd5b60165460ff161580611a3557506000601354115b15611a535760405163829e373360e01b815260040160405180910390fd5b42601255600654600090611a6a90620f424061522c565b905080620f4240611a79610c25565b611a83919061519e565b611a8d91906151cb565b601355506110af60018055565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166389da7df86007546040518263ffffffff1660e01b8152600401611aed91815260200190565b602060405180830381865afa158015611b0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2e919061516f565b90506000611b3a6116b8565b9050611b46828261537d565b9250505090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcf919061524a565b6001600160a01b0316336001600160a01b031614611c0057604051632d5be4cb60e21b815260040160405180910390fd5b6001600160a01b038116611c2757604051632887dd7560e11b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000610c3c601954613f8d565b6000611c60612d4e565b611c68612d79565b83611c7281612dc4565b611c7a612de5565b8215611c9157611c8a8585613999565b9150611d1d565b604051633068b6b560e21b8152600481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063c1a2dad490602401602060405180830381865afa158015611cf6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1a919061516f565b91505b610baf8261364f565b611d2e612de5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db0919061524a565b6001600160a01b0316336001600160a01b031614611de15760405163698bba4b60e01b815260040160405180910390fd5b60115460ff16611e04576040516305b02a1960e01b815260040160405180910390fd5b601054831015611e27576040516312cd610d60e21b815260040160405180910390fd5b611e3083612e3e565b6000611e3c84836130c8565b9050600f54611e49612958565b1215611e68576040516378764b0f60e01b815260040160405180910390fd5b60405184907f8f77e6a87a8210bff9857b08990b1f360b73d6e92d422a9a0e2c78e449682a9c90600090a250610de560018055565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa158015611efb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1f919061524a565b6001600160a01b0316336001600160a01b031614158015611fd357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fbd919061524a565b6001600160a01b0316336001600160a01b031614155b15611ff157604051631e1c735b60e21b815260040160405180910390fd5b6110af61395c565b600080600a5411801561200e57506000600b54115b801561201b575060095442115b80610c3c57506000600754118015610c3c5750600654612039612958565b12905090565b612047612de5565b60125460000361206a576040516334dc687f60e11b815260040160405180910390fd5b6000612074612338565b9050600061125d8183614031565b60008060008060405180606001604052806019548152602001601a548152602001601b54815250905060005b60038110156121a25760008282600381106120cb576120cb6153a4565b60200201511115612190576000806120eb6018546001600160a01b031690565b6001600160a01b03166330e0059685856003811061210b5761210b6153a4565b60200201516040518263ffffffff1660e01b815260040161212e91815260200190565b606060405180830381865afa15801561214b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216f91906153ba565b50909250905061217f82876151df565b955061218b81866151df565b945050505b8061219a816153e8565b9150506120ae565b5060405163113b4fbf60e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906389da7df890602401602060405180830381865afa158015612208573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222c919061516f565b61223584613c50565b61223f91906151df565b935050505090565b61224f612de5565b612257612d4e565b6001600160a01b03811661227e57604051632887dd7560e11b815260040160405180910390fd5b601880546001600160a01b0319166001600160a01b0383161790556001805550565b6122a8612d4e565b6122b0612de5565b6122bc84848484613e04565b6122c560018055565b50505050565b6122d3612d4e565b6122db612d79565b6122e3612de5565b6113eb81614265565b6122f4612d4e565b6122fc612de5565b60195460000361231f57604051634d5e5fb360e01b815260040160405180910390fd5b61232a601954613320565b60006019556110af60018055565b600080620f4240601554620f4240612350919061522c565b60075461235d919061519e565b61236791906151cb565b9050600061012c6012544261237c919061522c565b61238691906151cb565b9050600060145482612398919061519e565b9050620f42408111156123ad57509092915050565b60006123bc82620f424061522c565b90506000620f4240826013546123d2919061519e565b6123dc91906151cb565b90508085116123eb5780611828565b5092949350505050565b6123fd612de5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561245b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247f919061524a565b6001600160a01b0316336001600160a01b0316146124b05760405163698bba4b60e01b815260040160405180910390fd5b6000806124bb613b4e565b9150915060006124d36124cc610c25565b8790614380565b600a54909150156124f457600a546124eb90426151df565b600955600b8190555b8082101561263e576000612508838361522c565b60405163113b4fbf60e31b8152600481018290529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906389da7df890602401602060405180830381865afa158015612573573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612597919061516f565b905060006125a482614396565b9050858111156125bb576125bb6113f4878361522c565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612604573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612628919061516f565b111561263a576126388188613999565b505b5050505b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156126a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c9919061516f565b1180156126d65750600081115b156126e4576126e48161364f565b60405186907fdfcd68ceed46252749a4089f344aec4b4ee7f28a068f704c21799355325f3da990600090a2505050610de560018055565b612723612d4e565b6011805461ff00191690556005546040516001600160a01b03909116907facf29ad8d63913d38e7e1176963a4afb76bf0918516051da68408ecb6f98065d90600090a2565b6000610c3c601b54613f8d565b61277d612d4e565b612785612d79565b8061278f81612dc4565b612797612de5565b6127a082612e3e565b6127a86132f0565b6127b160018055565b5050565b6127bd612d4e565b6127c5612d79565b6127cd612de5565b601954156127e0576127e0601954613320565b6127ea8585613445565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663dc38679c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561284a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061286e919061516f565b90506000620f424082612881858361522c565b61288b919061519e565b61289591906151cb565b90506000620f4240836128a886836151df565b6128b2919061519e565b6128bc91906151cb565b90506000806128cb848461442b565b9150915060006128db8b8a613cde565b905060006128e98b8a613cde565b90507f0000000000000000000000000000000000000000000000000000000000000000612919578a8c828461291e565b8b8b83835b929e50909c509250905061293684848e8e868661479c565b6019556129416132f0565b5050505050505061295160018055565b5050505050565b6000806129636116b8565b905080600003612988576007541561298057620f423f1991505090565b600091505090565b60075460405163113b4fbf60e31b81526000916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916389da7df8916129dc9160040190815260200190565b602060405180830381865afa1580156129f9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1d919061516f565b9050600082612a2c838261537d565b612a3990620f4240615401565b612a439190615431565b9050620f423f19811215612a585750620f423f195b9392505050565b612a67612d4e565b612a6f612de5565b601b54600003612a9257604051634d5e5fb360e01b815260040160405180910390fd5b612a9d601b54613320565b6000601b556110af60018055565b612ab3612d4e565b612abb614980565b60068c9055600c8b905560088a90556014899055600a889055600f879055601086905560158590556011805460ff199081168615151790915560168054909116841515179055600e612b0e8284836154bb565b508a8c7fed1352796b02006c8bf7ef68956cb9fc55c08f9193eee9cec7ee590840bbbaad8c6014548c8c8c8c8c8c8c8c604051612b549a9998979695949392919061557b565b60405180910390a3505050505050505050505050565b612b72612de5565b612b7a612d4e565b620f42408163ffffffff161115612ba457604051630f4ec00b60e01b815260040160405180910390fd5b601c805463ffffffff191663ffffffff83161790556001805550565b612bc8612d4e565b612bd0612d79565b80612bda81612dc4565b612be2612de5565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015612c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4d919061516f565b905080831115612c5b578092505b612c66843385613556565b60075415612c7657612c766132f0565b60405183906001600160a01b038616907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d590600090a350610de560018055565b6000610c3c601a54613f8d565b6000612ccd612d4e565b612cd5612d79565b612cdd612de5565b612ce783836130c8565b60405190915083907f92f64ca637d023f354075a4be751b169c1a8a9ccb6d33cdd0cb352054399572790600090a26116b260018055565b612d26612d4e565b612d2e612de5565b82612d3881612dc4565b612d44858585856149a8565b506122c560018055565b6005546001600160a01b031633146110af57604051631963d1e760e31b815260040160405180910390fd5b60005460ff16156110af5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064015b60405180910390fd5b806000036113f457604051639d635cff60e01b815260040160405180910390fd5b600260015403612e375760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401612dbb565b6002600155565b60405163b67e9df760e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b67e9df790602401602060405180830381865afa158015612ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ec691906155ec565b612ee35760405163d8d5894f60e01b815260040160405180910390fd5b6000600754600854612ef5919061522c565b905081811015612f185760405163569d45cf60e11b815260040160405180910390fd5b6000612f22610bc0565b60405163140e25ad60e31b8152600481018590529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a0712d6890602401600060405180830381600087803b158015612f8757600080fd5b505af1158015612f9b573d6000803e3d6000fd5b505050508260076000828254612fb191906151df565b909155505042600d5580156130985761306c7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613042573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613066919061524a565b83613556565b60405181907fda0ff68ccd5fb797a8f86207386ea961ca6990c15ace2424ab51eb871ed4959990600090a25b60405183907f69c0ed5a77051ba5f0c42418bb6db6d3f73884dea69811c50bf320298df6ca5c90600090a2505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015613131573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613155919061516f565b90506131618482614380565b9350836000036131845760405163569d45cf60e11b815260040160405180910390fd5b60405163113b4fbf60e31b815260048101859052613216907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906389da7df890602401602060405180830381865afa1580156131ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613211919061516f565b614396565b915060006132248385613cde565b9050600061323a6018546001600160a01b031690565b90506132677f00000000000000000000000000000000000000000000000000000000000000008288614a8e565b600254604051631c6d209760e11b81526001600160a01b0391821660048201526024810188905260448101849052908216906338da412e906064015b6020604051808303816000875af11580156132c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132e6919061516f565b9695505050505050565b6006546132fb612958565b12156110af5760405163374c72ff60e11b815260040160405180910390fd5b60018055565b60405163133f757160e31b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906399fbab889060240161018060405180830381865afa158015613389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ad9190615645565b505050509750505050505050506133c782826000806149a8565b604051630852cd8d60e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b15801561342957600080fd5b505af115801561343d573d6000803e3d6000fd5b505050505050565b811561348257600254613482906001600160a01b03167f000000000000000000000000000000000000000000000000000000000000000084614a8e565b80156127b1576127b17f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000083614a8e565b60008060006134e2858561442b565b915091506000807f000000000000000000000000000000000000000000000000000000000000000061351557888a613518565b89895b915091506000613528838a613cde565b90506000613536838b613cde565b905061354686868686868661479c565b9c9b505050505050505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916135b29190615726565b6000604051808303816000865af19150503d80600081146135ef576040519150601f19603f3d011682016040523d82523d6000602084013e6135f4565b606091505b509150915081801561361e57508051158061361e57508080602001905181019061361e91906155ec565b6129515760405162461bcd60e51b815260206004820152600260248201526114d560f21b6044820152606401612dbb565b6040516370a0823160e01b81523060048201526136e2907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156136b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136db919061516f565b8290614380565b90506136ef6136db610c25565b9050806000036137125760405163569d45cf60e11b815260040160405180910390fd5b80600b5411613722576000613730565b80600b54613730919061522c565b600b55600a54158015906137445750600b54155b1561374f5760006009555b6000613759610bc0565b42600d559050613769818361522c565b915081600754101561378557600780546000909155915061379d565b8160076000828254613797919061522c565b90915550505b61381f7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613042573d6000803e3d6000fd5b61384a7f00000000000000000000000000000000000000000000000000000000000000003084614a8e565b604051630852cd8d60e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b1580156138ac57600080fd5b505af11580156138c0573d6000803e3d6000fd5b50506040518492507f33a382daad6aace935340a474d09fec82af4bec7e2b69518d283231b03a65f249150600090a26138f7611ff9565b6127b1576127b160006012819055601355565b613912614b87565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b613964612d79565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861393f3390565b6002546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156139e6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a0a919061516f565b9050613a168482614380565b935083600003613a395760405163569d45cf60e11b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c1a2dad4613a7186613c50565b6040518263ffffffff1660e01b8152600401613a8f91815260200190565b602060405180830381865afa158015613aac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ad0919061516f565b91506000613ade8385613cde565b90506000613af46018546001600160a01b031690565b600254909150613b0e906001600160a01b03168288614a8e565b60025460405163231831c760e21b81526001600160a01b039182166004820152602481018890526044810184905290821690638c60c71c906064016132a3565b6002546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa158015613b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bbf919061516f565b6040516370a0823160e01b81523060048201529092507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015613c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c4a919061516f565b90509091565b60006116b282600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ca9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ccd9190615267565b6003546001600160a01b0316614bd0565b6000620f4240613cee838261522c565b613cf8908561519e565b612a5891906151cb565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092839290881691613d669190615726565b6000604051808303816000865af19150503d8060008114613da3576040519150601f19603f3d011682016040523d82523d6000602084013e613da8565b606091505b5091509150818015613dd2575080511580613dd2575080806020019051810190613dd291906155ec565b61343d5760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b6044820152606401612dbb565b613e0e8484613445565b7f0000000000000000000000000000000000000000000000000000000000000000613e3c5782848284613e41565b838383835b6040805160c0810182526019548152602081018690529081018490526060810183905260808101829052939750919550935091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063219f5d179060a08101613eb542603c6151df565b9052604080516001600160e01b031960e085901b1681528251600482015260208301516024820152908201516044820152606082015160648201526080820151608482015260a09091015160a482015260c4016060604051808303816000875af1158015613f27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f4b9190615742565b505060408051868152602081018690527f38f8a0c92f4c5b0b6877f878cb4c0c8d348a47b76d716c8e78f425043df9515b92500160405180910390a150505050565b600081156119ef5760405163133f757160e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906399fbab889060240161018060405180830381865afa158015613ffb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061401f9190615645565b50929c9b505050505050505050505050565b614039611ff9565b6140565760405163038cbd4b60e31b815260040160405180910390fd5b6002546040516370a0823160e01b81523060048201819052916000916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156140a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140c8919061516f565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918616906370a0823190602401602060405180830381865afa158015614114573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614138919061516f565b6040516370a0823160e01b81526001600160a01b0385811660048301529192506000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156141a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141c8919061516f565b905080851115614207576142077f00000000000000000000000000000000000000000000000000000000000000003386614202858a61522c565b613d02565b60025461421e906001600160a01b03163385613556565b614229863384613556565b6142328561364f565b60405133907f1e1ef858062a7196d1891e397a5cde9891e6ddf61a81e9d269a3aaa7a95dacd890600090a2505050505050565b6040805160808101825282815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b0390811660248501529151811660448401529251909216606482015260009182917f00000000000000000000000000000000000000000000000000000000000000009091169063fc6f78659060840160408051808303816000875af1158015614318573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061433c9190615777565b60408051838152602081018390529294509092507f099830bf72bfd4281b6dd74da06794aabc4a2fc97ed1e35c125293c6a2dccd00910160405180910390a1505050565b600081831061438f5781612a58565b5090919050565b60006116b282600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156143ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144139190615267565b60035460ff91909116906001600160a01b0316614c2a565b60008060006144426018546001600160a01b031690565b6001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561447f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144a3919061524a565b6001600160a01b031663d0c93a7c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156144e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614504919061579b565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561455b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061457f9190615267565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156145e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146059190615267565b90506146196018546001600160a01b031690565b6001600160a01b031663f4f7fd25620f424061463685600a61536e565b614640908b61519e565b61464a91906151cb565b6040516001600160e01b031960e084901b168152600481019190915260ff84166024820152600286900b6044820152606401602060405180830381865afa158015614699573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146bd919061579b565b94506146d16018546001600160a01b031690565b6001600160a01b031663f4f7fd25620f42406146ee85600a61536e565b6146f8908a61519e565b61470291906151cb565b6040516001600160e01b031960e084901b168152600481019190915260ff84166024820152600286900b6044820152606401602060405180830381865afa158015614751573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614775919061579b565b93508360020b8560020b1261478b57838561478e565b84845b909890975095505050505050565b604080516101608101825260165461010090046001600160a01b039081168252601754811660208301526000927f0000000000000000000000000000000000000000000000000000000000000000919091169163883164569181016148096018546001600160a01b031690565b6001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614846573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061486a919061524a565b6001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148cb91906157b6565b62ffffff1681526020018a60020b81526020018960020b8152602001888152602001878152602001868152602001858152602001306001600160a01b03168152602001428152506040518263ffffffff1660e01b815260040161492e91906157d1565b6080604051808303816000875af115801561494d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149719190615895565b50919998505050505050505050565b601154610100900460ff166110af57604051634e751a9560e11b815260040160405180910390fd5b6040805160a0810182528581526001600160801b03858116602083019081528284018681526060840186815242608086019081529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c49ccbe9060a40160408051808303816000875af1158015614a5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a839190615777565b50506122c584614265565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691614aea9190615726565b6000604051808303816000865af19150503d8060008114614b27576040519150601f19603f3d011682016040523d82523d6000602084013e614b2c565b606091505b5091509150818015614b56575080511580614b56575080806020019051810190614b5691906155ec565b6129515760405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606401612dbb565b60005460ff166110af5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401612dbb565b600080614bdc83614c7d565b90506000614be984614ce1565b9050614bf585836158d1565b614c0090600a61536e565b614c0c6006600a61536e565b614c16838961519e565b614c20919061519e565b6132e691906151cb565b600080614c3683614c7d565b90506000614c4384614ce1565b9050614c516006600a61536e565b614c5b908261519e565b614c688660ff85166151df565b614c7390600a6158ea565b614c20908861519e565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015614cbd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b29190615267565b6000806000806000856001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015614d27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d4b9190615910565b9450945050935093508369ffffffffffffffffffff168169ffffffffffffffffffff161015614da75760405162461bcd60e51b81526020600482015260086024820152674f6c64206461746160c01b6044820152606401612dbb565b60008211614dec5760405162461bcd60e51b8152602060048201526012602482015271526f756e64206e6f7420636f6d706c65746560701b6044820152606401612dbb565b5090949350505050565b60005b83811015614e11578181015183820152602001614df9565b50506000910152565b6020815260008251806020840152614e39816040850160208701614df6565b601f01601f19169190910160400192915050565b80151581146113f457600080fd5b600080600060608486031215614e7057600080fd5b83359250602084013591506040840135614e8981614e4d565b809150509250925092565b6001600160a01b03811681146113f457600080fd5b60008083601f840112614ebb57600080fd5b50813567ffffffffffffffff811115614ed357600080fd5b602083019150836020828501011115614eeb57600080fd5b9250929050565b600080600080600060808688031215614f0a57600080fd5b8535614f1581614e94565b94506020860135614f2581614e94565b935060408601359250606086013567ffffffffffffffff811115614f4857600080fd5b614f5488828901614ea9565b969995985093965092949392505050565b600080600060608486031215614f7a57600080fd5b505081359360208301359350604090920135919050565b600060208284031215614fa357600080fd5b5035919050565b60008060408385031215614fbd57600080fd5b50508035926020909101359150565b600060208284031215614fde57600080fd5b8135612a5881614e94565b60008060008060808587031215614fff57600080fd5b5050823594602084013594506040840135936060013592509050565b600080600080600060a0868803121561503357600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b6000806000806000806000806000806000806101608d8f03121561507957600080fd5b8c359b5060208d01359a5060408d0135995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506150bc6101008e0135614e4d565b6101008d013593506150d26101208e0135614e4d565b6101208d0135925067ffffffffffffffff6101408e013511156150f457600080fd5b6151058e6101408f01358f01614ea9565b81935080925050509295989b509295989b509295989b565b60006020828403121561512f57600080fd5b813563ffffffff81168114612a5857600080fd5b6000806040838503121561515657600080fd5b823561516181614e94565b946020939093013593505050565b60006020828403121561518157600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176116b2576116b2615188565b634e487b7160e01b600052601260045260246000fd5b6000826151da576151da6151b5565b500490565b808201808211156116b2576116b2615188565b600181811c9082168061520657607f821691505b60208210810361522657634e487b7160e01b600052602260045260246000fd5b50919050565b818103818111156116b2576116b2615188565b80516119ef81614e94565b60006020828403121561525c57600080fd5b8151612a5881614e94565b60006020828403121561527957600080fd5b815160ff81168114612a5857600080fd5b600181815b808511156152c55781600019048211156152ab576152ab615188565b808516156152b857918102915b93841c939080029061528f565b509250929050565b6000826152dc575060016116b2565b816152e9575060006116b2565b81600181146152ff576002811461530957615325565b60019150506116b2565b60ff84111561531a5761531a615188565b50506001821b6116b2565b5060208310610133831016604e8410600b8410161715615348575081810a6116b2565b615352838361528a565b806000190482111561536657615366615188565b029392505050565b6000612a5860ff8416836152cd565b818103600083128015838313168383128216171561539d5761539d615188565b5092915050565b634e487b7160e01b600052603260045260246000fd5b6000806000606084860312156153cf57600080fd5b8351925060208401519150604084015190509250925092565b6000600182016153fa576153fa615188565b5060010190565b80820260008212600160ff1b8414161561541d5761541d615188565b81810583148215176116b2576116b2615188565b600082615440576154406151b5565b600160ff1b82146000198414161561545a5761545a615188565b500590565b634e487b7160e01b600052604160045260246000fd5b601f821115610de557600081815260208120601f850160051c8101602086101561549c5750805b601f850160051c820191505b8181101561343d578281556001016154a8565b67ffffffffffffffff8311156154d3576154d361545f565b6154e7836154e183546151f2565b83615475565b6000601f84116001811461551b57600085156155035750838201355b600019600387901b1c1916600186901b178355612951565b600083815260209020601f19861690835b8281101561554c578685013582556020948501946001909201910161552c565b50868210156155695760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60006101208c83528b60208401528a60408401528960608401528860808401528760a084015286151560c084015285151560e0840152806101008401528381840152506101408385828501376000838501820152601f909301601f19169091019091019a9950505050505050505050565b6000602082840312156155fe57600080fd5b8151612a5881614e4d565b805162ffffff811681146119ef57600080fd5b8051600281900b81146119ef57600080fd5b80516001600160801b03811681146119ef57600080fd5b6000806000806000806000806000806000806101808d8f03121561566857600080fd5b8c516bffffffffffffffffffffffff8116811461568457600080fd5b9b5061569260208e0161523f565b9a506156a060408e0161523f565b99506156ae60608e0161523f565b98506156bc60808e01615609565b97506156ca60a08e0161561c565b96506156d860c08e0161561c565b95506156e660e08e0161562e565b94506101008d015193506101208d015192506157056101408e0161562e565b91506157146101608e0161562e565b90509295989b509295989b509295989b565b60008251615738818460208701614df6565b9190910192915050565b60008060006060848603121561575757600080fd5b6157608461562e565b925060208401519150604084015190509250925092565b6000806040838503121561578a57600080fd5b505080516020909101519092909150565b6000602082840312156157ad57600080fd5b612a588261561c565b6000602082840312156157c857600080fd5b612a5882615609565b81516001600160a01b03168152610160810160208301516157fd60208401826001600160a01b03169052565b506040830151615814604084018262ffffff169052565b506060830151615829606084018260020b9052565b50608083015161583e608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151615884828501826001600160a01b03169052565b505061014092830151919092015290565b600080600080608085870312156158ab57600080fd5b845193506158bb6020860161562e565b6040860151606090960151949790965092505050565b60ff81811683821601908111156116b2576116b2615188565b6000612a5883836152cd565b805169ffffffffffffffffffff811681146119ef57600080fd5b600080600080600060a0868803121561592857600080fd5b615931866158f6565b9450602086015193506040860151925060608601519150615954608087016158f6565b9050929550929590935056fea2646970667358221220e78d627cf914c51398ca9bb3324c9185bb6d17d20e16bb4ad6a6dd56299f294964736f6c6343000813003300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435740000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff8500000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f3000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88000000000000000000000000e0585bdaee364dead2683c5aa1520b87f1d2fbad0000000000000000000000000000000000000000000000000000000000000014556e6973776170204d61726b6574204d616b6572000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061046a5760003560e01c80637df1f1b91161024c578063bc5477ad11610146578063e3d24dea116100c3578063f48af70111610087578063f48af701146108d3578063f686138d146108db578063f69aa3d5146108e4578063f88bf15a146108f7578063f95c1b261461090a57600080fd5b8063e3d24dea14610889578063ea8364aa14610891578063f046d966146108a4578063f2674f22146108ad578063f3fef3a3146108c057600080fd5b8063c602be861161010a578063c602be8614610849578063c6beb5861461085c578063d21220a714610865578063d366a41f14610878578063d6fbf2021461088057600080fd5b8063bc5477ad14610801578063c0f4a00514610814578063c198f8ba14610826578063c32abfff1461082e578063c5ebeaec1461083657600080fd5b8063a6a8f1f9116101d4578063b0e21e8a11610198578063b0e21e8a146107cc578063b17acdcd146107d5578063b5d52bf5146107e8578063ba2d0344146107f0578063bb352120146107f857600080fd5b8063a6a8f1f91461078c578063a71891c314610795578063aa8ea3a01461079d578063ad81fced146107b0578063aebf3e41146107b957600080fd5b80638456cb591161021b5780638456cb59146107585780638d1d7c6114610760578063a195166514610773578063a38aaa901461077c578063a516ed021461078457600080fd5b80637df1f1b9146106ff578063804aa9391461071257806381680d0a146107325780638351faf51461074557600080fd5b80632a9439451161036857806348dcacab116102e557806369ae990b116102a957806369ae990b146106c05780636b64c769146106d35780637148ff34146106db578063717e794d146106e457806371dbc900146106ec57600080fd5b806348dcacab146106895780634dc415de146106925780635c975abb1461069a57806361ab077f146106a5578063698996f8146106b857600080fd5b8063371fd8e61161032c578063371fd8e61461062d57806339518b5e146106405780633e032a3b146106495780633f4ba83a1461066e5780634837e2041461067657600080fd5b80632a943945146105c65780632d76643c146105d7578063311176d7146105e05780633168b03f146105f357806335faa4161461060657600080fd5b8063150b7a02116103f657806326f0c8e0116103ba57806326f0c8e0146105735780632716f6bd14610586578063296102521461058e5780632982db001461059657806329b154c3146105b357600080fd5b8063150b7a021461050d5780631c4695f4146105455780631de01bc91461054d5780632164bba314610556578063234439441461056b57600080fd5b80630dfe16811161043d5780630dfe1681146104bb5780630e5f5dbd146104eb5780630f5e07c7146104f357806312f21a1a146104fc57806314a6bf0f1461050557600080fd5b8063018a25e81461046f57806306fdde031461048a57806308a3b85f1461049f578063095559aa146104a8575b600080fd5b610477610917565b6040519081526020015b60405180910390f35b610492610a49565b6040516104819190614e1a565b610477601a5481565b6104776104b6366004614e5b565b610ad7565b6016546104d39061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610481565b610477610bc0565b61047760095481565b610477600d5481565b610477610c25565b61052c61051b366004614ef2565b630a85bd0160e11b95945050505050565b6040516001600160e01b03199091168152602001610481565b610492610c41565b610477600a5481565b610569610564366004614f65565b610c4e565b005b610569610dea565b610569610581366004614f65565b610ed3565b610569611063565b6105696110b1565b6016546105a39060ff1681565b6040519015158152602001610481565b6105696105c1366004614f91565b611268565b6018546001600160a01b03166104d3565b61047760075481565b6002546104d3906001600160a01b031681565b610569610601366004614f91565b6112e4565b6104d37f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357481565b61056961063b366004614f91565b6113d2565b61047760125481565b601c546106599063ffffffff1681565b60405163ffffffff9091168152602001610481565b6105696113f7565b6018546104d3906001600160a01b031681565b610477600b5481565b610569611553565b60005460ff166105a3565b6104776106b3366004614faa565b611657565b6104776116b8565b6104776106ce366004614f91565b611832565b6105696119f4565b61047760195481565b610477611a9a565b6105696106fa366004614fcc565b611b4d565b6005546104d3906001600160a01b031681565b61071a611c49565b6040516001600160801b039091168152602001610481565b610477610740366004614e5b565b611c56565b610569610753366004614f65565b611d26565b610569611e9d565b6003546104d3906001600160a01b031681565b61047760105481565b6105a3611ff9565b61056961203f565b61047760155481565b610477612082565b6105696107ab366004614fcc565b612247565b61047760085481565b6105696107c7366004614fe9565b6122a0565b610477600c5481565b6105696107e3366004614f91565b6122cb565b6105696122ec565b610477612338565b61047760145481565b61056961080f366004614f65565b6123f5565b6011546105a390610100900460ff1681565b61056961271b565b61071a612768565b610569610844366004614f91565b612775565b61056961085736600461501b565b6127b5565b61047760065481565b6017546104d3906001600160a01b031681565b610477612958565b61047760135481565b610569612a5f565b61056961089f366004615056565b612aab565b610477601b5481565b6105696108bb36600461511d565b612b6a565b6105696108ce366004615143565b612bc0565b61071a612cb6565b610477600f5481565b6104776108f2366004614faa565b612cc3565b610569610905366004614fe9565b612d1e565b6011546105a39060ff1681565b6000807f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663dc38679c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c919061516f565b9050620f4240817f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e19538476040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a25919061516f565b610a2f919061519e565b610a3991906151cb565b610a4390826151df565b91505090565b60048054610a56906151f2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a82906151f2565b8015610acf5780601f10610aa457610100808354040283529160200191610acf565b820191906000526020600020905b815481529060010190602001808311610ab257829003601f168201915b505050505081565b6000610ae1612d4e565b610ae9612d79565b83610af381612dc4565b610afb612de5565b610b0485612e3e565b8215610b1b57610b1485856130c8565b9150610ba7565b60405163113b4fbf60e31b8152600481018690527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906389da7df890602401602060405180830381865afa158015610b80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba4919061516f565b91505b610baf6132f0565b610bb860018055565b509392505050565b60075460009015610c1f57600062015180600d5442610bdf919061522c565b610be991906151cb565b9050610bfa620f424061016d61519e565b81600c54600754610c0b919061519e565b610c15919061519e565b610a4391906151cb565b50600090565b6000610c2f610bc0565b600754610c3c91906151df565b905090565b600e8054610a56906151f2565b610c56612d4e565b610c5e612de5565b601a5415610c7157610c71601a54613320565b610c7c600084613445565b60007f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663dc38679c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d00919061516f565b90506000610d166018546001600160a01b031690565b6001600160a01b031663bf56c3fb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d77919061516f565b9050600060c9828411610d8a5782610d8c565b835b610d9691906151df565b90506000620f424082610da988836151df565b610db3919061519e565b610dbd91906151cb565b9050610dcd6000888785856134d3565b601a55610dd86132f0565b50505050610de560018055565b505050565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6c919061524a565b6001600160a01b0316336001600160a01b031614610e9d5760405163698bba4b60e01b815260040160405180910390fd5b6000600b81905560098190556040517f219124ae95cc25cf220d998f2867d37fb4ab4908cce7c51adfa33ce747aa5747908290a2565b610edb612d4e565b610ee3612de5565b601b5415610ef657610ef6601b54613320565b610f01836000613445565b60007f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663dc38679c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f85919061516f565b90506000610f9b6018546001600160a01b031690565b6001600160a01b031663bf56c3fb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffc919061516f565b9050600060c982841061100f5782611011565b835b61101b919061522c565b90506000620f42408261102e888361522c565b611038919061519e565b61104291906151cb565b90506110528760008784866134d3565b601b5550610de5925061331a915050565b61106b612d4e565b611073612de5565b601a5460000361109657604051634d5e5fb360e01b815260040160405180910390fd5b6110a1601a54613320565b6000601a556110af60018055565b565b6110b9612d4e565b6110c1612de5565b60006110cb610bc0565b42600d556040516370a0823160e01b81523060048201529091506000907f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906370a0823190602401602060405180830381865afa158015611139573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115d919061516f565b90508082111561117f576040516206230160eb1b815260040160405180910390fd5b811561125d576112317f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435747f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611207573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122b919061524a565b84613556565b60405182907fda0ff68ccd5fb797a8f86207386ea961ca6990c15ace2424ab51eb871ed4959990600090a25b50506110af60018055565b336001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416146112b15760405163bc9eca6160e01b815260040160405180910390fd5b600781905560405181907f35ba42ee3c2daa6cf14836eefff16b184565798767ec1e5d723008848aeaf7e390600090a250565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611342573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611366919061524a565b6001600160a01b0316336001600160a01b0316146113975760405163698bba4b60e01b815260040160405180910390fd5b60088190556040518181527f7760d892a7883522367f0eaea35e968381a018418c249cd9aaaca190fe5d88179060200160405180910390a150565b6113da612d4e565b6113e2612de5565b6113eb8161364f565b6113f460018055565b50565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa158015611455573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611479919061524a565b6001600160a01b0316336001600160a01b03161415801561152d57507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611517919061524a565b6001600160a01b0316336001600160a01b031614155b1561154b57604051631e1c735b60e21b815260040160405180910390fd5b6110af61390a565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115d5919061524a565b6001600160a01b0316336001600160a01b03161461160657604051632d5be4cb60e21b815260040160405180910390fd5b6011805461ff00191661010017905561161d61395c565b6005546040516001600160a01b03909116907faf77f8960cf590e245ec8b6d41c193a5dcacad8986ae4eb57ac9e5be7b6af03190600090a2565b6000611661612d4e565b611669612d79565b611671612de5565b61167b8383613999565b60405190915081907f4e08ba899977cf7d4c2964bce71c6b9a7ef76ee5166a4c1249a1e08016e33ef190600090a26116b260018055565b92915050565b60008060006116c5613b4e565b60405163113b4fbf60e31b81526004810182905291935091506000906001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416906389da7df890602401602060405180830381865afa158015611732573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611756919061516f565b9050600061176384613c50565b905060007f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166389da7df861179e610bc0565b6040518263ffffffff1660e01b81526004016117bc91815260200190565b602060405180830381865afa1580156117d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fd919061516f565b905080838361180a612082565b61181491906151df565b61181e91906151df565b611828919061522c565b9550505050505090565b600061183c612de5565b60195460000361185f57604051634d5e5fb360e01b815260040160405180910390fd5b611867610917565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e99190615267565b6118f490600a61536e565b6118fd84613c50565b611907919061519e565b61191191906151cb565b905061192661192182600261519e565b612e3e565b601c5460009061193d90849063ffffffff16613cde565b601c5490915060009061195790849063ffffffff16613cde565b600254909150611972906001600160a01b0316333087613d02565b61197e84848484613e04565b6119a97f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435743385613556565b6119b16132f0565b6040518481527f6e19477745f02fa64cb79e709afd8b6a5da159ef7b135546eafd67c38e425c439060200160405180910390a150506119ef60018055565b919050565b6119fc612de5565b611a04611ff9565b611a215760405163038cbd4b60e31b815260040160405180910390fd5b60165460ff161580611a3557506000601354115b15611a535760405163829e373360e01b815260040160405180910390fd5b42601255600654600090611a6a90620f424061522c565b905080620f4240611a79610c25565b611a83919061519e565b611a8d91906151cb565b601355506110af60018055565b6000807f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166389da7df86007546040518263ffffffff1660e01b8152600401611aed91815260200190565b602060405180830381865afa158015611b0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2e919061516f565b90506000611b3a6116b8565b9050611b46828261537d565b9250505090565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcf919061524a565b6001600160a01b0316336001600160a01b031614611c0057604051632d5be4cb60e21b815260040160405180910390fd5b6001600160a01b038116611c2757604051632887dd7560e11b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000610c3c601954613f8d565b6000611c60612d4e565b611c68612d79565b83611c7281612dc4565b611c7a612de5565b8215611c9157611c8a8585613999565b9150611d1d565b604051633068b6b560e21b8152600481018690527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03169063c1a2dad490602401602060405180830381865afa158015611cf6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1a919061516f565b91505b610baf8261364f565b611d2e612de5565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db0919061524a565b6001600160a01b0316336001600160a01b031614611de15760405163698bba4b60e01b815260040160405180910390fd5b60115460ff16611e04576040516305b02a1960e01b815260040160405180910390fd5b601054831015611e27576040516312cd610d60e21b815260040160405180910390fd5b611e3083612e3e565b6000611e3c84836130c8565b9050600f54611e49612958565b1215611e68576040516378764b0f60e01b815260040160405180910390fd5b60405184907f8f77e6a87a8210bff9857b08990b1f360b73d6e92d422a9a0e2c78e449682a9c90600090a250610de560018055565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa158015611efb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1f919061524a565b6001600160a01b0316336001600160a01b031614158015611fd357507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fbd919061524a565b6001600160a01b0316336001600160a01b031614155b15611ff157604051631e1c735b60e21b815260040160405180910390fd5b6110af61395c565b600080600a5411801561200e57506000600b54115b801561201b575060095442115b80610c3c57506000600754118015610c3c5750600654612039612958565b12905090565b612047612de5565b60125460000361206a576040516334dc687f60e11b815260040160405180910390fd5b6000612074612338565b9050600061125d8183614031565b60008060008060405180606001604052806019548152602001601a548152602001601b54815250905060005b60038110156121a25760008282600381106120cb576120cb6153a4565b60200201511115612190576000806120eb6018546001600160a01b031690565b6001600160a01b03166330e0059685856003811061210b5761210b6153a4565b60200201516040518263ffffffff1660e01b815260040161212e91815260200190565b606060405180830381865afa15801561214b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216f91906153ba565b50909250905061217f82876151df565b955061218b81866151df565b945050505b8061219a816153e8565b9150506120ae565b5060405163113b4fbf60e31b8152600481018390527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906389da7df890602401602060405180830381865afa158015612208573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222c919061516f565b61223584613c50565b61223f91906151df565b935050505090565b61224f612de5565b612257612d4e565b6001600160a01b03811661227e57604051632887dd7560e11b815260040160405180910390fd5b601880546001600160a01b0319166001600160a01b0383161790556001805550565b6122a8612d4e565b6122b0612de5565b6122bc84848484613e04565b6122c560018055565b50505050565b6122d3612d4e565b6122db612d79565b6122e3612de5565b6113eb81614265565b6122f4612d4e565b6122fc612de5565b60195460000361231f57604051634d5e5fb360e01b815260040160405180910390fd5b61232a601954613320565b60006019556110af60018055565b600080620f4240601554620f4240612350919061522c565b60075461235d919061519e565b61236791906151cb565b9050600061012c6012544261237c919061522c565b61238691906151cb565b9050600060145482612398919061519e565b9050620f42408111156123ad57509092915050565b60006123bc82620f424061522c565b90506000620f4240826013546123d2919061519e565b6123dc91906151cb565b90508085116123eb5780611828565b5092949350505050565b6123fd612de5565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561245b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247f919061524a565b6001600160a01b0316336001600160a01b0316146124b05760405163698bba4b60e01b815260040160405180910390fd5b6000806124bb613b4e565b9150915060006124d36124cc610c25565b8790614380565b600a54909150156124f457600a546124eb90426151df565b600955600b8190555b8082101561263e576000612508838361522c565b60405163113b4fbf60e31b8152600481018290529091506000906001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416906389da7df890602401602060405180830381865afa158015612573573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612597919061516f565b905060006125a482614396565b9050858111156125bb576125bb6113f4878361522c565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612604573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612628919061516f565b111561263a576126388188613999565b505b5050505b6040516370a0823160e01b81523060048201526000907f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906370a0823190602401602060405180830381865afa1580156126a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c9919061516f565b1180156126d65750600081115b156126e4576126e48161364f565b60405186907fdfcd68ceed46252749a4089f344aec4b4ee7f28a068f704c21799355325f3da990600090a2505050610de560018055565b612723612d4e565b6011805461ff00191690556005546040516001600160a01b03909116907facf29ad8d63913d38e7e1176963a4afb76bf0918516051da68408ecb6f98065d90600090a2565b6000610c3c601b54613f8d565b61277d612d4e565b612785612d79565b8061278f81612dc4565b612797612de5565b6127a082612e3e565b6127a86132f0565b6127b160018055565b5050565b6127bd612d4e565b6127c5612d79565b6127cd612de5565b601954156127e0576127e0601954613320565b6127ea8585613445565b60007f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663dc38679c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561284a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061286e919061516f565b90506000620f424082612881858361522c565b61288b919061519e565b61289591906151cb565b90506000620f4240836128a886836151df565b6128b2919061519e565b6128bc91906151cb565b90506000806128cb848461442b565b9150915060006128db8b8a613cde565b905060006128e98b8a613cde565b90507f0000000000000000000000000000000000000000000000000000000000000001612919578a8c828461291e565b8b8b83835b929e50909c509250905061293684848e8e868661479c565b6019556129416132f0565b5050505050505061295160018055565b5050505050565b6000806129636116b8565b905080600003612988576007541561298057620f423f1991505090565b600091505090565b60075460405163113b4fbf60e31b81526000916001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416916389da7df8916129dc9160040190815260200190565b602060405180830381865afa1580156129f9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1d919061516f565b9050600082612a2c838261537d565b612a3990620f4240615401565b612a439190615431565b9050620f423f19811215612a585750620f423f195b9392505050565b612a67612d4e565b612a6f612de5565b601b54600003612a9257604051634d5e5fb360e01b815260040160405180910390fd5b612a9d601b54613320565b6000601b556110af60018055565b612ab3612d4e565b612abb614980565b60068c9055600c8b905560088a90556014899055600a889055600f879055601086905560158590556011805460ff199081168615151790915560168054909116841515179055600e612b0e8284836154bb565b508a8c7fed1352796b02006c8bf7ef68956cb9fc55c08f9193eee9cec7ee590840bbbaad8c6014548c8c8c8c8c8c8c8c604051612b549a9998979695949392919061557b565b60405180910390a3505050505050505050505050565b612b72612de5565b612b7a612d4e565b620f42408163ffffffff161115612ba457604051630f4ec00b60e01b815260040160405180910390fd5b601c805463ffffffff191663ffffffff83161790556001805550565b612bc8612d4e565b612bd0612d79565b80612bda81612dc4565b612be2612de5565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015612c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4d919061516f565b905080831115612c5b578092505b612c66843385613556565b60075415612c7657612c766132f0565b60405183906001600160a01b038616907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d590600090a350610de560018055565b6000610c3c601a54613f8d565b6000612ccd612d4e565b612cd5612d79565b612cdd612de5565b612ce783836130c8565b60405190915083907f92f64ca637d023f354075a4be751b169c1a8a9ccb6d33cdd0cb352054399572790600090a26116b260018055565b612d26612d4e565b612d2e612de5565b82612d3881612dc4565b612d44858585856149a8565b506122c560018055565b6005546001600160a01b031633146110af57604051631963d1e760e31b815260040160405180910390fd5b60005460ff16156110af5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064015b60405180910390fd5b806000036113f457604051639d635cff60e01b815260040160405180910390fd5b600260015403612e375760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401612dbb565b6002600155565b60405163b67e9df760e01b81523060048201527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03169063b67e9df790602401602060405180830381865afa158015612ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ec691906155ec565b612ee35760405163d8d5894f60e01b815260040160405180910390fd5b6000600754600854612ef5919061522c565b905081811015612f185760405163569d45cf60e11b815260040160405180910390fd5b6000612f22610bc0565b60405163140e25ad60e31b8152600481018590529091507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03169063a0712d6890602401600060405180830381600087803b158015612f8757600080fd5b505af1158015612f9b573d6000803e3d6000fd5b505050508260076000828254612fb191906151df565b909155505042600d5580156130985761306c7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435747f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613042573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613066919061524a565b83613556565b60405181907fda0ff68ccd5fb797a8f86207386ea961ca6990c15ace2424ab51eb871ed4959990600090a25b60405183907f69c0ed5a77051ba5f0c42418bb6db6d3f73884dea69811c50bf320298df6ca5c90600090a2505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416906370a0823190602401602060405180830381865afa158015613131573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613155919061516f565b90506131618482614380565b9350836000036131845760405163569d45cf60e11b815260040160405180910390fd5b60405163113b4fbf60e31b815260048101859052613216907f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906389da7df890602401602060405180830381865afa1580156131ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613211919061516f565b614396565b915060006132248385613cde565b9050600061323a6018546001600160a01b031690565b90506132677f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435748288614a8e565b600254604051631c6d209760e11b81526001600160a01b0391821660048201526024810188905260448101849052908216906338da412e906064015b6020604051808303816000875af11580156132c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132e6919061516f565b9695505050505050565b6006546132fb612958565b12156110af5760405163374c72ff60e11b815260040160405180910390fd5b60018055565b60405163133f757160e31b8152600481018290526000907f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b0316906399fbab889060240161018060405180830381865afa158015613389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ad9190615645565b505050509750505050505050506133c782826000806149a8565b604051630852cd8d60e31b8152600481018390527f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b0316906342966c6890602401600060405180830381600087803b15801561342957600080fd5b505af115801561343d573d6000803e3d6000fd5b505050505050565b811561348257600254613482906001600160a01b03167f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8884614a8e565b80156127b1576127b17f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435747f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8883614a8e565b60008060006134e2858561442b565b915091506000807f000000000000000000000000000000000000000000000000000000000000000161351557888a613518565b89895b915091506000613528838a613cde565b90506000613536838b613cde565b905061354686868686868661479c565b9c9b505050505050505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916135b29190615726565b6000604051808303816000865af19150503d80600081146135ef576040519150601f19603f3d011682016040523d82523d6000602084013e6135f4565b606091505b509150915081801561361e57508051158061361e57508080602001905181019061361e91906155ec565b6129515760405162461bcd60e51b815260206004820152600260248201526114d560f21b6044820152606401612dbb565b6040516370a0823160e01b81523060048201526136e2907f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906370a0823190602401602060405180830381865afa1580156136b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136db919061516f565b8290614380565b90506136ef6136db610c25565b9050806000036137125760405163569d45cf60e11b815260040160405180910390fd5b80600b5411613722576000613730565b80600b54613730919061522c565b600b55600a54158015906137445750600b54155b1561374f5760006009555b6000613759610bc0565b42600d559050613769818361522c565b915081600754101561378557600780546000909155915061379d565b8160076000828254613797919061522c565b90915550505b61381f7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435747f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613042573d6000803e3d6000fd5b61384a7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435743084614a8e565b604051630852cd8d60e31b8152600481018390527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906342966c6890602401600060405180830381600087803b1580156138ac57600080fd5b505af11580156138c0573d6000803e3d6000fd5b50506040518492507f33a382daad6aace935340a474d09fec82af4bec7e2b69518d283231b03a65f249150600090a26138f7611ff9565b6127b1576127b160006012819055601355565b613912614b87565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b613964612d79565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861393f3390565b6002546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156139e6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a0a919061516f565b9050613a168482614380565b935083600003613a395760405163569d45cf60e11b815260040160405180910390fd5b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663c1a2dad4613a7186613c50565b6040518263ffffffff1660e01b8152600401613a8f91815260200190565b602060405180830381865afa158015613aac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ad0919061516f565b91506000613ade8385613cde565b90506000613af46018546001600160a01b031690565b600254909150613b0e906001600160a01b03168288614a8e565b60025460405163231831c760e21b81526001600160a01b039182166004820152602481018890526044810184905290821690638c60c71c906064016132a3565b6002546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa158015613b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bbf919061516f565b6040516370a0823160e01b81523060048201529092507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906370a0823190602401602060405180830381865afa158015613c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c4a919061516f565b90509091565b60006116b282600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ca9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ccd9190615267565b6003546001600160a01b0316614bd0565b6000620f4240613cee838261522c565b613cf8908561519e565b612a5891906151cb565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092839290881691613d669190615726565b6000604051808303816000865af19150503d8060008114613da3576040519150601f19603f3d011682016040523d82523d6000602084013e613da8565b606091505b5091509150818015613dd2575080511580613dd2575080806020019051810190613dd291906155ec565b61343d5760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b6044820152606401612dbb565b613e0e8484613445565b7f0000000000000000000000000000000000000000000000000000000000000001613e3c5782848284613e41565b838383835b6040805160c0810182526019548152602081018690529081018490526060810183905260808101829052939750919550935091506001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88169063219f5d179060a08101613eb542603c6151df565b9052604080516001600160e01b031960e085901b1681528251600482015260208301516024820152908201516044820152606082015160648201526080820151608482015260a09091015160a482015260c4016060604051808303816000875af1158015613f27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f4b9190615742565b505060408051868152602081018690527f38f8a0c92f4c5b0b6877f878cb4c0c8d348a47b76d716c8e78f425043df9515b92500160405180910390a150505050565b600081156119ef5760405163133f757160e31b8152600481018390527f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b0316906399fbab889060240161018060405180830381865afa158015613ffb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061401f9190615645565b50929c9b505050505050505050505050565b614039611ff9565b6140565760405163038cbd4b60e31b815260040160405180910390fd5b6002546040516370a0823160e01b81523060048201819052916000916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156140a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140c8919061516f565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918616906370a0823190602401602060405180830381865afa158015614114573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614138919061516f565b6040516370a0823160e01b81526001600160a01b0385811660048301529192506000917f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416906370a0823190602401602060405180830381865afa1580156141a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141c8919061516f565b905080851115614207576142077f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435743386614202858a61522c565b613d02565b60025461421e906001600160a01b03163385613556565b614229863384613556565b6142328561364f565b60405133907f1e1ef858062a7196d1891e397a5cde9891e6ddf61a81e9d269a3aaa7a95dacd890600090a2505050505050565b6040805160808101825282815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b0390811660248501529151811660448401529251909216606482015260009182917f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe889091169063fc6f78659060840160408051808303816000875af1158015614318573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061433c9190615777565b60408051838152602081018390529294509092507f099830bf72bfd4281b6dd74da06794aabc4a2fc97ed1e35c125293c6a2dccd00910160405180910390a1505050565b600081831061438f5781612a58565b5090919050565b60006116b282600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156143ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144139190615267565b60035460ff91909116906001600160a01b0316614c2a565b60008060006144426018546001600160a01b031690565b6001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561447f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144a3919061524a565b6001600160a01b031663d0c93a7c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156144e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614504919061579b565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561455b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061457f9190615267565b905060007f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156145e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146059190615267565b90506146196018546001600160a01b031690565b6001600160a01b031663f4f7fd25620f424061463685600a61536e565b614640908b61519e565b61464a91906151cb565b6040516001600160e01b031960e084901b168152600481019190915260ff84166024820152600286900b6044820152606401602060405180830381865afa158015614699573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146bd919061579b565b94506146d16018546001600160a01b031690565b6001600160a01b031663f4f7fd25620f42406146ee85600a61536e565b6146f8908a61519e565b61470291906151cb565b6040516001600160e01b031960e084901b168152600481019190915260ff84166024820152600286900b6044820152606401602060405180830381865afa158015614751573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614775919061579b565b93508360020b8560020b1261478b57838561478e565b84845b909890975095505050505050565b604080516101608101825260165461010090046001600160a01b039081168252601754811660208301526000927f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88919091169163883164569181016148096018546001600160a01b031690565b6001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614846573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061486a919061524a565b6001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148cb91906157b6565b62ffffff1681526020018a60020b81526020018960020b8152602001888152602001878152602001868152602001858152602001306001600160a01b03168152602001428152506040518263ffffffff1660e01b815260040161492e91906157d1565b6080604051808303816000875af115801561494d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149719190615895565b50919998505050505050505050565b601154610100900460ff166110af57604051634e751a9560e11b815260040160405180910390fd5b6040805160a0810182528581526001600160801b03858116602083019081528284018681526060840186815242608086019081529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201527f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031690630c49ccbe9060a40160408051808303816000875af1158015614a5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a839190615777565b50506122c584614265565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691614aea9190615726565b6000604051808303816000865af19150503d8060008114614b27576040519150601f19603f3d011682016040523d82523d6000602084013e614b2c565b606091505b5091509150818015614b56575080511580614b56575080806020019051810190614b5691906155ec565b6129515760405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606401612dbb565b60005460ff166110af5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401612dbb565b600080614bdc83614c7d565b90506000614be984614ce1565b9050614bf585836158d1565b614c0090600a61536e565b614c0c6006600a61536e565b614c16838961519e565b614c20919061519e565b6132e691906151cb565b600080614c3683614c7d565b90506000614c4384614ce1565b9050614c516006600a61536e565b614c5b908261519e565b614c688660ff85166151df565b614c7390600a6158ea565b614c20908861519e565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015614cbd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b29190615267565b6000806000806000856001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015614d27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d4b9190615910565b9450945050935093508369ffffffffffffffffffff168169ffffffffffffffffffff161015614da75760405162461bcd60e51b81526020600482015260086024820152674f6c64206461746160c01b6044820152606401612dbb565b60008211614dec5760405162461bcd60e51b8152602060048201526012602482015271526f756e64206e6f7420636f6d706c65746560701b6044820152606401612dbb565b5090949350505050565b60005b83811015614e11578181015183820152602001614df9565b50506000910152565b6020815260008251806020840152614e39816040850160208701614df6565b601f01601f19169190910160400192915050565b80151581146113f457600080fd5b600080600060608486031215614e7057600080fd5b83359250602084013591506040840135614e8981614e4d565b809150509250925092565b6001600160a01b03811681146113f457600080fd5b60008083601f840112614ebb57600080fd5b50813567ffffffffffffffff811115614ed357600080fd5b602083019150836020828501011115614eeb57600080fd5b9250929050565b600080600080600060808688031215614f0a57600080fd5b8535614f1581614e94565b94506020860135614f2581614e94565b935060408601359250606086013567ffffffffffffffff811115614f4857600080fd5b614f5488828901614ea9565b969995985093965092949392505050565b600080600060608486031215614f7a57600080fd5b505081359360208301359350604090920135919050565b600060208284031215614fa357600080fd5b5035919050565b60008060408385031215614fbd57600080fd5b50508035926020909101359150565b600060208284031215614fde57600080fd5b8135612a5881614e94565b60008060008060808587031215614fff57600080fd5b5050823594602084013594506040840135936060013592509050565b600080600080600060a0868803121561503357600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b6000806000806000806000806000806000806101608d8f03121561507957600080fd5b8c359b5060208d01359a5060408d0135995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506150bc6101008e0135614e4d565b6101008d013593506150d26101208e0135614e4d565b6101208d0135925067ffffffffffffffff6101408e013511156150f457600080fd5b6151058e6101408f01358f01614ea9565b81935080925050509295989b509295989b509295989b565b60006020828403121561512f57600080fd5b813563ffffffff81168114612a5857600080fd5b6000806040838503121561515657600080fd5b823561516181614e94565b946020939093013593505050565b60006020828403121561518157600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176116b2576116b2615188565b634e487b7160e01b600052601260045260246000fd5b6000826151da576151da6151b5565b500490565b808201808211156116b2576116b2615188565b600181811c9082168061520657607f821691505b60208210810361522657634e487b7160e01b600052602260045260246000fd5b50919050565b818103818111156116b2576116b2615188565b80516119ef81614e94565b60006020828403121561525c57600080fd5b8151612a5881614e94565b60006020828403121561527957600080fd5b815160ff81168114612a5857600080fd5b600181815b808511156152c55781600019048211156152ab576152ab615188565b808516156152b857918102915b93841c939080029061528f565b509250929050565b6000826152dc575060016116b2565b816152e9575060006116b2565b81600181146152ff576002811461530957615325565b60019150506116b2565b60ff84111561531a5761531a615188565b50506001821b6116b2565b5060208310610133831016604e8410600b8410161715615348575081810a6116b2565b615352838361528a565b806000190482111561536657615366615188565b029392505050565b6000612a5860ff8416836152cd565b818103600083128015838313168383128216171561539d5761539d615188565b5092915050565b634e487b7160e01b600052603260045260246000fd5b6000806000606084860312156153cf57600080fd5b8351925060208401519150604084015190509250925092565b6000600182016153fa576153fa615188565b5060010190565b80820260008212600160ff1b8414161561541d5761541d615188565b81810583148215176116b2576116b2615188565b600082615440576154406151b5565b600160ff1b82146000198414161561545a5761545a615188565b500590565b634e487b7160e01b600052604160045260246000fd5b601f821115610de557600081815260208120601f850160051c8101602086101561549c5750805b601f850160051c820191505b8181101561343d578281556001016154a8565b67ffffffffffffffff8311156154d3576154d361545f565b6154e7836154e183546151f2565b83615475565b6000601f84116001811461551b57600085156155035750838201355b600019600387901b1c1916600186901b178355612951565b600083815260209020601f19861690835b8281101561554c578685013582556020948501946001909201910161552c565b50868210156155695760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60006101208c83528b60208401528a60408401528960608401528860808401528760a084015286151560c084015285151560e0840152806101008401528381840152506101408385828501376000838501820152601f909301601f19169091019091019a9950505050505050505050565b6000602082840312156155fe57600080fd5b8151612a5881614e4d565b805162ffffff811681146119ef57600080fd5b8051600281900b81146119ef57600080fd5b80516001600160801b03811681146119ef57600080fd5b6000806000806000806000806000806000806101808d8f03121561566857600080fd5b8c516bffffffffffffffffffffffff8116811461568457600080fd5b9b5061569260208e0161523f565b9a506156a060408e0161523f565b99506156ae60608e0161523f565b98506156bc60808e01615609565b97506156ca60a08e0161561c565b96506156d860c08e0161561c565b95506156e660e08e0161562e565b94506101008d015193506101208d015192506157056101408e0161562e565b91506157146101608e0161562e565b90509295989b509295989b509295989b565b60008251615738818460208701614df6565b9190910192915050565b60008060006060848603121561575757600080fd5b6157608461562e565b925060208401519150604084015190509250925092565b6000806040838503121561578a57600080fd5b505080516020909101519092909150565b6000602082840312156157ad57600080fd5b612a588261561c565b6000602082840312156157c857600080fd5b612a5882615609565b81516001600160a01b03168152610160810160208301516157fd60208401826001600160a01b03169052565b506040830151615814604084018262ffffff169052565b506060830151615829606084018260020b9052565b50608083015161583e608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151615884828501826001600160a01b03169052565b505061014092830151919092015290565b600080600080608085870312156158ab57600080fd5b845193506158bb6020860161562e565b6040860151606090960151949790965092505050565b60ff81811683821601908111156116b2576116b2615188565b6000612a5883836152cd565b805169ffffffffffffffffffff811681146119ef57600080fd5b600080600080600060a0868803121561592857600080fd5b615931866158f6565b9450602086015193506040860151925060608601519150615954608087016158f6565b9050929550929590935056fea2646970667358221220e78d627cf914c51398ca9bb3324c9185bb6d17d20e16bb4ad6a6dd56299f294964736f6c63430008130033

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

00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435740000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff8500000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f3000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88000000000000000000000000e0585bdaee364dead2683c5aa1520b87f1d2fbad0000000000000000000000000000000000000000000000000000000000000014556e6973776170204d61726b6574204d616b6572000000000000000000000000

-----Decoded View---------------
Arg [0] : _name (string): Uniswap Market Maker
Arg [1] : _sweep (address): 0xB88a5Ac00917a02d82c7cd6CEBd73E2852d43574
Arg [2] : _usdx (address): 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85
Arg [3] : _oracleUsdx (address): 0x16a9FA2FDa030272Ce99B29CF780dFA30361E0f3
Arg [4] : _positionManager (address): 0xC36442b4a4522E871399CD717aBDD847Ab11FE88
Arg [5] : _borrower (address): 0xE0585bDaee364deAd2683c5Aa1520B87F1d2FBAD

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [1] : 000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d43574
Arg [2] : 0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85
Arg [3] : 00000000000000000000000016a9fa2fda030272ce99b29cf780dfa30361e0f3
Arg [4] : 000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88
Arg [5] : 000000000000000000000000e0585bdaee364dead2683c5aa1520b87f1d2fbad
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000014
Arg [7] : 556e6973776170204d61726b6574204d616b6572000000000000000000000000


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

Validator Index Block Amount
View All Withdrawals

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

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.