Overview
POL Balance
POL Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
YearnV3Asset
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)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.19; // ==================================================================== // ========================== YearnV3Asset.sol ======================== // ==================================================================== /** * @title YearnV3 Asset * @dev Representation of an on-chain investment */ import "@openzeppelin/contracts/interfaces/IERC4626.sol"; import { Stabilizer, IERC20Metadata, IAMM, TransferHelper, OvnMath } from "../Stabilizer/Stabilizer.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import { ISwapRouter } from "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol"; contract YearnV3Asset is Stabilizer { // Variables IERC4626 public immutable asset; IERC20Metadata private immutable usdc_e; ISwapRouter private immutable router; // Events event Invested(uint256 indexed tokenAmount); event Divested(uint256 indexed usdxAmount); error UnexpectedAmount(); uint16 private constant DEADLINE_GAP = 15 minutes; constructor( string memory _name, address _sweep, address _usdx, address _usdc_e, address _asset, address _oracleUsdx, address _borrower, address _router ) Stabilizer(_name, _sweep, _usdx, _oracleUsdx, _borrower) { asset = IERC4626(_asset); usdc_e = IERC20Metadata(_usdc_e); router = ISwapRouter(_router); } /* ========== Views ========== */ /** * @notice Asset Value of investment. * @return the Returns the value of the investment in the USD coin * @dev the price is obtained from the target asset */ function assetValue() public view virtual override returns (uint256) { uint256 sharesBalance = asset.balanceOf(address(this)); uint256 assetsBalance = asset.convertToAssets(sharesBalance); return _oracleUsdxToUsd(assetsBalance); } /* ========== Actions ========== */ /** * @notice Invest. * @param usdxAmount Amount to be invested * @dev Sends usdx to the target asset to get shares. */ function invest(uint256 usdxAmount, uint256 slippage) external onlyBorrower whenNotPaused nonReentrant validAmount(usdxAmount) { _invest(usdxAmount, 0, slippage); } /** * @notice Divest. * @param usdxAmount Amount to be divested. * @dev Gets usdx back by redeeming shares. */ function divest(uint256 usdxAmount, uint256 slippage) external onlyBorrower nonReentrant validAmount(usdxAmount) { _divest(usdxAmount, slippage); } /** * @notice Liquidate */ function liquidate() external nonReentrant { if(auctionAllowed) revert ActionNotAllowed(); _liquidate(_getToken(), getDebt()); } function _getToken() internal view override returns (address) { return address(asset); } /* ========== Internals ========== */ function _invest(uint256 usdxAmount, uint256, uint256 slippage) internal override { uint256 usdxBalance = usdx.balanceOf(address(this)); if (usdxBalance == 0) revert NotEnoughBalance(); if (usdxBalance < usdxAmount) usdxAmount = usdxBalance; uint256 amountOutMin = OvnMath.subBasisPoints(usdxAmount, slippage); uint256 usdceAmount = swap(address(usdx), address(usdc_e), usdxAmount, amountOutMin); TransferHelper.safeApprove(address(usdc_e), address(asset), usdceAmount); uint256 shares = asset.deposit(usdceAmount, address(this)); if(shares < asset.convertToShares(usdceAmount)) revert UnexpectedAmount(); emit Invested(usdceAmount); } function _divest(uint256 usdxAmount, uint256 slippage) internal override { uint256 sharesBalance = asset.balanceOf(address(this)); if (sharesBalance == 0) revert NotEnoughBalance(); uint256 sharesAmount = asset.convertToShares(usdxAmount); if (sharesBalance < sharesAmount) sharesAmount = sharesBalance; uint256 usdceAmount = asset.convertToAssets(sharesAmount); asset.withdraw(usdceAmount, address(this), address(this)); usdceAmount = usdc_e.balanceOf(address(this)); uint256 amountOutMin = OvnMath.subBasisPoints(usdceAmount, slippage); uint256 usdcAmount = swap(address(usdc_e), address(usdx), usdceAmount, amountOutMin); emit Divested(usdcAmount); } /** * @notice Swap tokenA into tokenB using uniV3Router.ExactInputSingle() * @param tokenA Address to in * @param tokenB Address to out * @param amountIn Amount of _tokenA * @param amountOutMin Minimum amount out. */ function swap(address tokenA, address tokenB, uint256 amountIn, uint256 amountOutMin) private returns (uint256 amountOut) { TransferHelper.safeApprove(tokenA, address(router), amountIn); ISwapRouter.ExactInputSingleParams memory swapParams = ISwapRouter .ExactInputSingleParams({ tokenIn: tokenA, tokenOut: tokenB, fee: 100, recipient: address(this), deadline: block.timestamp + DEADLINE_GAP, amountIn: amountIn, amountOutMinimum: amountOutMin, sqrtPriceLimitX96: 0 }); amountOut = router.exactInputSingle(swapParams); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../token/ERC20/extensions/IERC20Metadata.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol"; import "../token/ERC20/extensions/IERC20Metadata.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * _Available since v4.7._ */ interface IERC4626 is IERC20, IERC20Metadata { event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /** * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. * * - MUST be an ERC-20 token contract. * - MUST NOT revert. */ function asset() external view returns (address assetTokenAddress); /** * @dev Returns the total amount of the underlying asset that is “managed” by Vault. * * - SHOULD include any compounding that occurs from yield. * - MUST be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT revert. */ function totalAssets() external view returns (uint256 totalManagedAssets); /** * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToShares(uint256 assets) external view returns (uint256 shares); /** * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, * through a deposit call. * * - MUST return a limited value if receiver is subject to some deposit limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. * - MUST NOT revert. */ function maxDeposit(address receiver) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given * current on-chain conditions. * * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called * in the same transaction. * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the * deposit would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewDeposit(uint256 assets) external view returns (uint256 shares); /** * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * deposit execution, and are accounted for during deposit. * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares); /** * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. * - MUST return a limited value if receiver is subject to some mint limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. * - MUST NOT revert. */ function maxMint(address receiver) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given * current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the * same transaction. * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint * would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by minting. */ function previewMint(uint256 shares) external view returns (uint256 assets); /** * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint * execution, and are accounted for during mint. * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function mint(uint256 shares, address receiver) external returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the * Vault, through a withdraw call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST NOT revert. */ function maxWithdraw(address owner) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, * given current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if * called * in the same transaction. * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though * the withdrawal would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewWithdraw(uint256 assets) external view returns (uint256 shares); /** * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * withdraw execution, and are accounted for during withdraw. * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function withdraw( uint256 assets, address receiver, address owner ) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, * through a redeem call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. * - MUST NOT revert. */ function maxRedeem(address owner) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, * given current on-chain conditions. * * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the * same transaction. * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the * redemption would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by redeeming. */ function previewRedeem(uint256 shares) external view returns (uint256 assets); /** * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * redeem execution, and are accounted for during redeem. * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function redeem( uint256 shares, address receiver, address owner ) external returns (uint256 assets); }
// 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()); } }
// 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; } }
// 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); }
// 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); }
// 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; } }
// 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); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; }
// 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 { }
// 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; }
// 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 ); }
// 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(); }
// 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); }
// 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); }
// 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); }
// 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 ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol'; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// 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'); } }
// 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); }
// 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(); _; } }
// 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)); } }
// 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); } }
// 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(); } }
// 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); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_sweep","type":"address"},{"internalType":"address","name":"_usdx","type":"address"},{"internalType":"address","name":"_usdc_e","type":"address"},{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_oracleUsdx","type":"address"},{"internalType":"address","name":"_borrower","type":"address"},{"internalType":"address","name":"_router","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ActionNotAllowed","type":"error"},{"inputs":[],"name":"AssetDefaulted","type":"error"},{"inputs":[],"name":"AuctionNotActive","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":"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":"UnexpectedAmount","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":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":"uint256","name":"usdxAmount","type":"uint256"}],"name":"Divested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"Invested","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":"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":"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":[],"name":"amm","outputs":[{"internalType":"contract IAMM","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"contract IERC4626","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":"buyAuction","outputs":[],"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":"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":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"}],"name":"divest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAuctionAmount","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":[{"internalType":"uint256","name":"usdxAmount","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"}],"name":"invest","outputs":[],"stateMutability":"nonpayable","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":"liquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"loanLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"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":"reject","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":"uint256","name":"newLoanLimit","type":"uint256"}],"name":"setLoanLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"settingsEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"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"}]
Contract Creation Code
6101006040523480156200001257600080fd5b5060405162004b9b38038062004b9b83398101604081905262000035916200014c565b8787878585836001600160a01b0381166200006357604051632887dd7560e11b815260040160405180910390fd5b6001600160a01b039081166080526000805460ff191690556001805581166200009f57604051632887dd7560e11b815260040160405180910390fd5b6004620000ad868262000333565b50600280546001600160a01b039485166001600160a01b031991821617909155600380549385169382169390931790925560058054918416919092161790556011805461ff00191661010017905595861660a052505093831660c05250501660e05250620003ff915050565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200014757600080fd5b919050565b600080600080600080600080610100898b0312156200016a57600080fd5b88516001600160401b03808211156200018257600080fd5b818b0191508b601f8301126200019757600080fd5b815181811115620001ac57620001ac62000119565b604051601f8201601f19908116603f01168101908382118183101715620001d757620001d762000119565b81604052828152602093508e84848701011115620001f457600080fd5b600091505b82821015620002185784820184015181830185015290830190620001f9565b6000848483010152809c5050505062000233818c016200012f565b985050506200024560408a016200012f565b95506200025560608a016200012f565b94506200026560808a016200012f565b93506200027560a08a016200012f565b92506200028560c08a016200012f565b91506200029560e08a016200012f565b90509295985092959890939650565b600181811c90821680620002b957607f821691505b602082108103620002da57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200032e57600081815260208120601f850160051c81016020861015620003095750805b601f850160051c820191505b818110156200032a5782815560010162000315565b5050505b505050565b81516001600160401b038111156200034f576200034f62000119565b6200036781620003608454620002a4565b84620002e0565b602080601f8311600181146200039f5760008415620003865750858301515b600019600386901b1c1916600185901b1785556200032a565b600085815260208120601f198616915b82811015620003d057888601518255948401946001909101908401620003af565b5085821015620003ef5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516145e8620005b3600039600081816139a70152613a9801526000818161286a015281816128970152818161334001526133d00152600081816104dd01528181610a0b0152818161190b01528181611956015281816119e5015281816128b8015281816128fc0152818161298a015281816130d4015281816131830152818161321c01526132b50152600081816104a3015281816107c2015281816108f301528181610a7b01528181610b1b01528181610b3c01528181610c0401528181610c7901528181610cfb01528181610e0e01528181610eac01528181610f9c01528181611132015281816111b001528181611324015281816113d401528181611529015281816115b201528181611732015281816117d001528181611b2201528181611c4f01528181611d7f01528181611f1a01528181612317015281816123ff01528181612489015281816124aa015281816125ae01528181612662015281816126fb01528181612ba701528181612c2101528181612dc801528181612f0201528181612f2301528181612f8401528181612fc00152818161351601526136a801526145e86000f3fe608060405234801561001057600080fd5b506004361061038e5760003560e01c8063717e794d116101de578063ba2d03441161010f578063d366a41f116100ad578063f3fef3a31161007c578063f3fef3a31461069e578063f686138d146106b1578063f69aa3d5146106ba578063f95c1b26146106cd57600080fd5b8063d366a41f14610667578063d6fbf2021461066f578063d87aa64314610678578063ea8364aa1461068b57600080fd5b8063c0f4a005116100e9578063c0f4a00514610631578063c198f8ba14610643578063c5ebeaec1461064b578063c6beb5861461065e57600080fd5b8063ba2d03441461060d578063bb35212014610615578063bc5477ad1461061e57600080fd5b8063a19516651161017c578063a6a8f1f911610156578063a6a8f1f9146105ea578063a71891c3146105f3578063ad81fced146105fb578063b0e21e8a1461060457600080fd5b8063a1951665146105d1578063a38aaa90146105da578063a516ed02146105e257600080fd5b806381680d0a116101b857806381680d0a146105905780638351faf5146105a35780638456cb59146105b65780638d1d7c61146105be57600080fd5b8063717e794d1461056257806371dbc9001461056a5780637df1f1b91461057d57600080fd5b80632d76643c116102c35780633f4ba83a116102615780635c975abb116102305780635c975abb1461053457806361ab077f1461053f578063698996f8146105525780636b64c7691461055a57600080fd5b80633f4ba83a146105085780634696c7491461051057806348dcacab146105235780634dc415de1461052c57600080fd5b806335faa4161161029d57806335faa4161461049e578063371fd8e6146104c557806338d52e0f146104d857806339518b5e146104ff57600080fd5b80632d76643c1461046f578063311176d7146104785780633168b03f1461048b57600080fd5b80631de01bc911610330578063296102521161030a57806329610252146104175780632982db001461041f57806329b154c31461043c5780632a9439451461044f57600080fd5b80631de01bc9146103fc578063234439441461040557806328a070251461040f57600080fd5b80630f5e07c71161036c5780630f5e07c7146103da57806312f21a1a146103e357806314a6bf0f146103ec5780631c4695f4146103f457600080fd5b806306fdde0314610393578063095559aa146103b15780630e5f5dbd146103d2575b600080fd5b61039b6106da565b6040516103a89190613e81565b60405180910390f35b6103c46103bf366004613ec2565b610768565b6040519081526020016103a8565b6103c461085d565b6103c460095481565b6103c4600d5481565b6103c46108c8565b61039b6108e4565b6103c4600a5481565b61040d6108f1565b005b61040d6109da565b61040d610a42565b60165461042c9060ff1681565b60405190151581526020016103a8565b61040d61044a366004613efb565b610bf9565b610457610c75565b6040516001600160a01b0390911681526020016103a8565b6103c460075481565b600254610457906001600160a01b031681565b61040d610499366004613efb565b610cf9565b6104577f000000000000000000000000000000000000000000000000000000000000000081565b61040d6104d3366004613efb565b610de7565b6104577f000000000000000000000000000000000000000000000000000000000000000081565b6103c460125481565b61040d610e0c565b61040d61051e366004613f14565b610f68565b6103c4600b5481565b61040d610f9a565b60005460ff1661042c565b6103c461054d366004613f14565b61109e565b6103c46110ff565b61040d611279565b6103c461131f565b61040d610578366004613f4b565b6113d2565b600554610457906001600160a01b031681565b6103c461059e366004613ec2565b6114ce565b61040d6105b1366004613f68565b6115a8565b61040d611730565b600354610457906001600160a01b031681565b6103c460105481565b61042c61188c565b61040d6118d2565b6103c460155481565b6103c4611934565b6103c460085481565b6103c4600c5481565b6103c4611a5b565b6103c460145481565b61040d61062c366004613f68565b611b18565b60115461042c90610100900460ff1681565b61040d611e44565b61040d610659366004613efb565b611e91565b6103c460065481565b6103c4611ecd565b6103c460135481565b61040d610686366004613f14565b611fd4565b61040d610699366004613fdd565b612002565b61040d6106ac3660046140a4565b6120c1565b6103c4600f5481565b6103c46106c8366004613f14565b6121b7565b60115461042c9060ff1681565b600480546106e7906140d0565b80601f0160208091040260200160405190810160405280929190818152602001828054610713906140d0565b80156107605780601f1061073557610100808354040283529160200191610760565b820191906000526020600020905b81548152906001019060200180831161074357829003601f168201915b505050505081565b6000610772612212565b61077a61223d565b8361078481612288565b61078c6122a9565b61079585612302565b82156107ac576107a5858561258c565b9150610838565b60405163113b4fbf60e31b8152600481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906389da7df890602401602060405180830381865afa158015610811573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610835919061410a565b91505b610844826000866127aa565b61084c612a51565b61085560018055565b509392505050565b600754600090156108c257600062015180600d544261087c9190614139565b6108869190614162565b9050610897620f424061016d614176565b81600c546007546108a89190614176565b6108b29190614176565b6108bc9190614162565b91505090565b50600090565b60006108d261085d565b6007546108df919061418d565b905090565b600e80546106e7906140d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561094f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097391906141a0565b6001600160a01b0316336001600160a01b0316146109a45760405163698bba4b60e01b815260040160405180910390fd5b6000600b81905560098190556040517f219124ae95cc25cf220d998f2867d37fb4ab4908cce7c51adfa33ce747aa5747908290a2565b6109e26122a9565b60165460ff1615610a065760405163829e373360e01b815260040160405180910390fd5b610a377f0000000000000000000000000000000000000000000000000000000000000000610a326108c8565b612a7b565b610a4060018055565b565b610a4a612212565b610a526122a9565b6000610a5c61085d565b42600d556040516370a0823160e01b81523060048201529091506000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610aca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aee919061410a565b905080821115610b10576040516206230160eb1b815260040160405180910390fd5b8115610bee57610bc27f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbc91906141a0565b84612caf565b60405182907fda0ff68ccd5fb797a8f86207386ea961ca6990c15ace2424ab51eb871ed4959990600090a25b5050610a4060018055565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610c425760405163bc9eca6160e01b815260040160405180910390fd5b600781905560405181907f35ba42ee3c2daa6cf14836eefff16b184565798767ec1e5d723008848aeaf7e390600090a250565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632a9439456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cd5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108df91906141a0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7b91906141a0565b6001600160a01b0316336001600160a01b031614610dac5760405163698bba4b60e01b815260040160405180910390fd5b60088190556040518181527f7760d892a7883522367f0eaea35e968381a018418c249cd9aaaca190fe5d88179060200160405180910390a150565b610def612212565b610df76122a9565b610e0081612daf565b610e0960018055565b50565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8e91906141a0565b6001600160a01b0316336001600160a01b031614158015610f4257507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2c91906141a0565b6001600160a01b0316336001600160a01b031614155b15610f6057604051631e1c735b60e21b815260040160405180910390fd5b610a4061306a565b610f70612212565b610f786122a9565b81610f8281612288565b610f8c83836130bc565b50610f9660018055565b5050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ff8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101c91906141a0565b6001600160a01b0316336001600160a01b03161461104d57604051632d5be4cb60e21b815260040160405180910390fd5b6011805461ff001916610100179055611064613437565b6005546040516001600160a01b03909116907faf77f8960cf590e245ec8b6d41c193a5dcacad8986ae4eb57ac9e5be7b6af03190600090a2565b60006110a8612212565b6110b061223d565b6110b86122a9565b6110c28383613474565b60405190915081907f4e08ba899977cf7d4c2964bce71c6b9a7ef76ee5166a4c1249a1e08016e33ef190600090a26110f960018055565b92915050565b600080600061110c61361f565b60405163113b4fbf60e31b81526004810182905291935091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906389da7df890602401602060405180830381865afa158015611179573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119d919061410a565b905060006111aa84613721565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166389da7df86111e561085d565b6040518263ffffffff1660e01b815260040161120391815260200190565b602060405180830381865afa158015611220573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611244919061410a565b9050808383611251611934565b61125b919061418d565b611265919061418d565b61126f9190614139565b9550505050505090565b6112816122a9565b61128961188c565b6112a65760405163038cbd4b60e31b815260040160405180910390fd5b60165460ff1615806112ba57506000601354115b156112d85760405163829e373360e01b815260040160405180910390fd5b426012556006546000906112ef90620f4240614139565b905080620f42406112fe6108c8565b6113089190614176565b6113129190614162565b60135550610a4060018055565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166389da7df86007546040518263ffffffff1660e01b815260040161137291815260200190565b602060405180830381865afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b3919061410a565b905060006113bf6110ff565b90506113cb82826141bd565b9250505090565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611430573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145491906141a0565b6001600160a01b0316336001600160a01b03161461148557604051632d5be4cb60e21b815260040160405180910390fd5b6001600160a01b0381166114ac57604051632887dd7560e11b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b60006114d8612212565b6114e061223d565b836114ea81612288565b6114f26122a9565b6114fc85856130bc565b82156115135761150c8585613474565b915061159f565b604051633068b6b560e21b8152600481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063c1a2dad490602401602060405180830381865afa158015611578573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159c919061410a565b91505b61084c82612daf565b6115b06122a9565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561160e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163291906141a0565b6001600160a01b0316336001600160a01b0316146116635760405163698bba4b60e01b815260040160405180910390fd5b60115460ff16611686576040516305b02a1960e01b815260040160405180910390fd5b6010548310156116a9576040516312cd610d60e21b815260040160405180910390fd5b6116b283612302565b60006116be848361258c565b90506116cc816000846127aa565b600f546116d7611ecd565b12156116f6576040516378764b0f60e01b815260040160405180910390fd5b60405184907f8f77e6a87a8210bff9857b08990b1f360b73d6e92d422a9a0e2c78e449682a9c90600090a25061172b60018055565b505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa15801561178e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117b291906141a0565b6001600160a01b0316336001600160a01b03161415801561186657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561182c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185091906141a0565b6001600160a01b0316336001600160a01b031614155b1561188457604051631e1c735b60e21b815260040160405180910390fd5b610a40613437565b600080600a541180156118a157506000600b54115b80156118ae575060095442115b806108df575060006007541180156108df57506006546118cc611ecd565b12905090565b6118da6122a9565b6012546000036118fd576040516334dc687f60e11b815260040160405180910390fd5b6000611907611a5b565b90507f0000000000000000000000000000000000000000000000000000000000000000610bee8183612a7b565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa15801561199d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c1919061410a565b6040516303d1689d60e11b8152600481018290529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906307a2d13a90602401602060405180830381865afa158015611a2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a50919061410a565b90506113cb81613721565b600080620f4240601554620f4240611a739190614139565b600754611a809190614176565b611a8a9190614162565b9050600061012c60125442611a9f9190614139565b611aa99190614162565b9050600060145482611abb9190614176565b9050620f4240811115611ad057509092915050565b6000611adf82620f4240614139565b90506000620f424082601354611af59190614176565b611aff9190614162565b9050808511611b0e578061126f565b5092949350505050565b611b206122a9565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba291906141a0565b6001600160a01b0316336001600160a01b031614611bd35760405163698bba4b60e01b815260040160405180910390fd5b600080611bde61361f565b915091506000611bf6611bef6108c8565b87906137af565b600a5490915015611c1757600a54611c0e904261418d565b600955600b8190555b80821015611d67576000611c2b8383614139565b60405163113b4fbf60e31b8152600481018290529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906389da7df890602401602060405180830381865afa158015611c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cba919061410a565b90506000611cc7826137c5565b905085811115611ce457611ce4611cde8783614139565b886130bc565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d51919061410a565b1115611d6357611d618188613474565b505b5050505b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df2919061410a565b118015611dff5750600081115b15611e0d57611e0d81612daf565b60405186907fdfcd68ceed46252749a4089f344aec4b4ee7f28a068f704c21799355325f3da990600090a250505061172b60018055565b611e4c612212565b6011805461ff00191690556005546040516001600160a01b03909116907facf29ad8d63913d38e7e1176963a4afb76bf0918516051da68408ecb6f98065d90600090a2565b611e99612212565b611ea161223d565b80611eab81612288565b611eb36122a9565b611ebc82612302565b611ec4612a51565b610f9660018055565b600080611ed86110ff565b905080600003611efd5760075415611ef557620f423f1991505090565b600091505090565b60075460405163113b4fbf60e31b81526000916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916389da7df891611f519160040190815260200190565b602060405180830381865afa158015611f6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f92919061410a565b9050600082611fa183826141bd565b611fae90620f42406141e4565b611fb89190614214565b9050620f423f19811215611fcd5750620f423f195b9392505050565b611fdc612212565b611fe461223d565b611fec6122a9565b81611ff681612288565b610f8c836000846127aa565b61200a612212565b61201261385a565b60068c9055600c8b905560088a90556014899055600a889055600f879055601086905560158590556011805460ff199081168615151790915560168054909116841515179055600e61206582848361429e565b508a8c7fed1352796b02006c8bf7ef68956cb9fc55c08f9193eee9cec7ee590840bbbaad8c6014548c8c8c8c8c8c8c8c6040516120ab9a9998979695949392919061435e565b60405180910390a3505050505050505050505050565b6120c9612212565b6120d161223d565b806120db81612288565b6120e36122a9565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561212a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214e919061410a565b90508083111561215c578092505b612167843385612caf565b6007541561217757612177612a51565b60405183906001600160a01b038616907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d590600090a35061172b60018055565b60006121c1612212565b6121c961223d565b6121d16122a9565b6121db838361258c565b60405190915083907f92f64ca637d023f354075a4be751b169c1a8a9ccb6d33cdd0cb352054399572790600090a26110f960018055565b6005546001600160a01b03163314610a4057604051631963d1e760e31b815260040160405180910390fd5b60005460ff1615610a405760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064015b60405180910390fd5b80600003610e0957604051639d635cff60e01b815260040160405180910390fd5b6002600154036122fb5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161227f565b6002600155565b60405163b67e9df760e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b67e9df790602401602060405180830381865afa158015612366573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238a91906143cf565b6123a75760405163d8d5894f60e01b815260040160405180910390fd5b60006007546008546123b99190614139565b9050818110156123dc5760405163569d45cf60e11b815260040160405180910390fd5b60006123e661085d565b60405163140e25ad60e31b8152600481018590529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a0712d6890602401600060405180830381600087803b15801561244b57600080fd5b505af115801561245f573d6000803e3d6000fd5b505050508260076000828254612475919061418d565b909155505042600d55801561255c576125307f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612506573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061252a91906141a0565b83612caf565b60405181907fda0ff68ccd5fb797a8f86207386ea961ca6990c15ace2424ab51eb871ed4959990600090a25b60405183907f69c0ed5a77051ba5f0c42418bb6db6d3f73884dea69811c50bf320298df6ca5c90600090a2505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156125f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612619919061410a565b905061262584826137af565b9350836000036126485760405163569d45cf60e11b815260040160405180910390fd5b60405163113b4fbf60e31b8152600481018590526126da907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906389da7df890602401602060405180830381865afa1580156126b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126d5919061410a565b6137c5565b915060006126e88385613882565b905060006126f4610c75565b90506127217f000000000000000000000000000000000000000000000000000000000000000082886138a6565b600254604051631c6d209760e11b81526001600160a01b0391821660048201526024810188905260448101849052908216906338da412e906064015b6020604051808303816000875af115801561277c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a0919061410a565b9695505050505050565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156127f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612817919061410a565b90508060000361283a5760405163569d45cf60e11b815260040160405180910390fd5b83811015612846578093505b60006128528584613882565b600254909150600090612890906001600160a01b03167f0000000000000000000000000000000000000000000000000000000000000000888561399f565b90506128dd7f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000836138a6565b604051636e553f6560e01b8152600481018290523060248201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636e553f65906044016020604051808303816000875af115801561294d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612971919061410a565b6040516363737ac960e11b8152600481018490529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063c6e6f59290602401602060405180830381865afa1580156129d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fd919061410a565b811015612a1d57604051631897b7fd60e11b815260040160405180910390fd5b60405182907fac9f7997c30b6a3cc9c74953898b5de154359339c7ec0d6d70ceb98e55db1a4b90600090a250505050505050565b600654612a5c611ecd565b1215610a405760405163374c72ff60e11b815260040160405180910390fd5b612a8361188c565b612aa05760405163038cbd4b60e31b815260040160405180910390fd5b6002546040516370a0823160e01b81523060048201819052916000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015612aee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b12919061410a565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918616906370a0823190602401602060405180830381865afa158015612b5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b82919061410a565b6040516370a0823160e01b81526001600160a01b0385811660048301529192506000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015612bee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c12919061410a565b905080851115612c5157612c517f00000000000000000000000000000000000000000000000000000000000000003386612c4c858a614139565b613ae4565b600254612c68906001600160a01b03163385612caf565b612c73863384612caf565b612c7c85612daf565b60405133907f1e1ef858062a7196d1891e397a5cde9891e6ddf61a81e9d269a3aaa7a95dacd890600090a2505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092839290871691612d0b91906143ec565b6000604051808303816000865af19150503d8060008114612d48576040519150601f19603f3d011682016040523d82523d6000602084013e612d4d565b606091505b5091509150818015612d77575080511580612d77575080806020019051810190612d7791906143cf565b612da85760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640161227f565b5050505050565b6040516370a0823160e01b8152306004820152612e42907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015612e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e3b919061410a565b82906137af565b9050612e4f612e3b6108c8565b905080600003612e725760405163569d45cf60e11b815260040160405180910390fd5b80600b5411612e82576000612e90565b80600b54612e909190614139565b600b55600a5415801590612ea45750600b54155b15612eaf5760006009555b6000612eb961085d565b42600d559050612ec98183614139565b9150816007541015612ee5576007805460009091559150612efd565b8160076000828254612ef79190614139565b90915550505b612f7f7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612506573d6000803e3d6000fd5b612faa7f000000000000000000000000000000000000000000000000000000000000000030846138a6565b604051630852cd8d60e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b15801561300c57600080fd5b505af1158015613020573d6000803e3d6000fd5b50506040518492507f33a382daad6aace935340a474d09fec82af4bec7e2b69518d283231b03a65f249150600090a261305761188c565b610f9657610f9660006012819055601355565b613072613bee565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015613123573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613147919061410a565b90508060000361316a5760405163569d45cf60e11b815260040160405180910390fd5b6040516363737ac960e11b8152600481018490526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063c6e6f59290602401602060405180830381865afa1580156131d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131f6919061410a565b9050808210156132035750805b6040516303d1689d60e11b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906307a2d13a90602401602060405180830381865afa15801561326b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061328f919061410a565b604051632d182be560e21b815260048101829052306024820181905260448201529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b460af94906064016020604051808303816000875af1158015613306573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061332a919061410a565b506040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa15801561338f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b3919061410a565b905060006133c18286613882565b600254909150600090613400907f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b0316858561399f565b60405190915081907f0dbc40ccd4fca1b5bf46f23e99aaefe371e661e9ca0c45dc1b79e5e321d3b99d90600090a250505050505050565b61343f61223d565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861309f3390565b6002546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156134c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e5919061410a565b90506134f184826137af565b9350836000036135145760405163569d45cf60e11b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c1a2dad461354c86613721565b6040518263ffffffff1660e01b815260040161356a91815260200190565b602060405180830381865afa158015613587573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ab919061410a565b915060006135b98385613882565b905060006135c5610c75565b6002549091506135df906001600160a01b031682886138a6565b60025460405163231831c760e21b81526001600160a01b039182166004820152602481018890526044810184905290821690638c60c71c9060640161275d565b6002546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561366c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613690919061410a565b6040516370a0823160e01b81523060048201529092507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156136f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061371b919061410a565b90509091565b60006110f982600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561377a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379e9190614408565b6003546001600160a01b0316613c37565b60008183106137be5781611fcd565b5090919050565b60006110f982600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561381e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138429190614408565b60035460ff91909116906001600160a01b0316613c91565b601154610100900460ff16610a4057604051634e751a9560e11b815260040160405180910390fd5b6000620f42406138928382614139565b61389c9085614176565b611fcd9190614162565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b179052915160009283929087169161390291906143ec565b6000604051808303816000865af19150503d806000811461393f576040519150601f19603f3d011682016040523d82523d6000602084013e613944565b606091505b509150915081801561396e57508051158061396e57508080602001905181019061396e91906143cf565b612da85760405162461bcd60e51b8152602060048201526002602482015261534160f01b604482015260640161227f565b60006139cc857f0000000000000000000000000000000000000000000000000000000000000000856138a6565b60408051610100810182526001600160a01b0380881682528616602082015260649181019190915230606082015260009060808101613a0d6103844261418d565b8152602080820187905260408083018790526000606093840152805163414bf38960e01b815284516001600160a01b03908116600483015292850151831660248201529084015162ffffff16604482015291830151811660648301526080830151608483015260a083015160a483015260c083015160c483015260e0830151811660e48301529192507f00000000000000000000000000000000000000000000000000000000000000009091169063414bf38990610104016020604051808303816000875af115801561277c573d6000803e3d6000fd5b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092839290881691613b4891906143ec565b6000604051808303816000865af19150503d8060008114613b85576040519150601f19603f3d011682016040523d82523d6000602084013e613b8a565b606091505b5091509150818015613bb4575080511580613bb4575080806020019051810190613bb491906143cf565b613be65760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161227f565b505050505050565b60005460ff16610a405760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161227f565b600080613c4383613ce4565b90506000613c5084613d48565b9050613c5c858361442b565b613c6790600a614528565b613c736006600a614528565b613c7d8389614176565b613c879190614176565b6127a09190614162565b600080613c9d83613ce4565b90506000613caa84613d48565b9050613cb86006600a614528565b613cc29082614176565b613ccf8660ff851661418d565b613cda90600a614537565b613c879088614176565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d24573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f99190614408565b6000806000806000856001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015613d8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613db29190614562565b9450945050935093508369ffffffffffffffffffff168169ffffffffffffffffffff161015613e0e5760405162461bcd60e51b81526020600482015260086024820152674f6c64206461746160c01b604482015260640161227f565b60008211613e535760405162461bcd60e51b8152602060048201526012602482015271526f756e64206e6f7420636f6d706c65746560701b604482015260640161227f565b5090949350505050565b60005b83811015613e78578181015183820152602001613e60565b50506000910152565b6020815260008251806020840152613ea0816040850160208701613e5d565b601f01601f19169190910160400192915050565b8015158114610e0957600080fd5b600080600060608486031215613ed757600080fd5b83359250602084013591506040840135613ef081613eb4565b809150509250925092565b600060208284031215613f0d57600080fd5b5035919050565b60008060408385031215613f2757600080fd5b50508035926020909101359150565b6001600160a01b0381168114610e0957600080fd5b600060208284031215613f5d57600080fd5b8135611fcd81613f36565b600080600060608486031215613f7d57600080fd5b505081359360208301359350604090920135919050565b60008083601f840112613fa657600080fd5b50813567ffffffffffffffff811115613fbe57600080fd5b602083019150836020828501011115613fd657600080fd5b9250929050565b6000806000806000806000806000806000806101608d8f03121561400057600080fd5b8c359b5060208d01359a5060408d0135995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506140436101008e0135613eb4565b6101008d013593506140596101208e0135613eb4565b6101208d0135925067ffffffffffffffff6101408e0135111561407b57600080fd5b61408c8e6101408f01358f01613f94565b81935080925050509295989b509295989b509295989b565b600080604083850312156140b757600080fd5b82356140c281613f36565b946020939093013593505050565b600181811c908216806140e457607f821691505b60208210810361410457634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561411c57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156110f9576110f9614123565b634e487b7160e01b600052601260045260246000fd5b6000826141715761417161414c565b500490565b80820281158282048414176110f9576110f9614123565b808201808211156110f9576110f9614123565b6000602082840312156141b257600080fd5b8151611fcd81613f36565b81810360008312801583831316838312821617156141dd576141dd614123565b5092915050565b80820260008212600160ff1b8414161561420057614200614123565b81810583148215176110f9576110f9614123565b6000826142235761422361414c565b600160ff1b82146000198414161561423d5761423d614123565b500590565b634e487b7160e01b600052604160045260246000fd5b601f82111561172b57600081815260208120601f850160051c8101602086101561427f5750805b601f850160051c820191505b81811015613be65782815560010161428b565b67ffffffffffffffff8311156142b6576142b6614242565b6142ca836142c483546140d0565b83614258565b6000601f8411600181146142fe57600085156142e65750838201355b600019600387901b1c1916600186901b178355612da8565b600083815260209020601f19861690835b8281101561432f578685013582556020948501946001909201910161430f565b508682101561434c5760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60006101208c83528b60208401528a60408401528960608401528860808401528760a084015286151560c084015285151560e0840152806101008401528381840152506101408385828501376000838501820152601f909301601f19169091019091019a9950505050505050505050565b6000602082840312156143e157600080fd5b8151611fcd81613eb4565b600082516143fe818460208701613e5d565b9190910192915050565b60006020828403121561441a57600080fd5b815160ff81168114611fcd57600080fd5b60ff81811683821601908111156110f9576110f9614123565b600181815b8085111561447f57816000190482111561446557614465614123565b8085161561447257918102915b93841c9390800290614449565b509250929050565b600082614496575060016110f9565b816144a3575060006110f9565b81600181146144b957600281146144c3576144df565b60019150506110f9565b60ff8411156144d4576144d4614123565b50506001821b6110f9565b5060208310610133831016604e8410600b8410161715614502575081810a6110f9565b61450c8383614444565b806000190482111561452057614520614123565b029392505050565b6000611fcd60ff841683614487565b6000611fcd8383614487565b805169ffffffffffffffffffff8116811461455d57600080fd5b919050565b600080600080600060a0868803121561457a57600080fd5b61458386614543565b94506020860151935060408601519250606086015191506145a660808701614543565b9050929550929590935056fea2646970667358221220c4dc41a36de2dd373fa908eb7428da8c29ac2df042c578c6bbc115678bfe266464736f6c634300081300330000000000000000000000000000000000000000000000000000000000000100000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435740000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa0000000000000000000000000fe4a8cc5b5b2366c1b58bea3858e81843581b2f700000000000000000000000047671b43b6e05fc6f423595f625716a06d76d9ec000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000000e596561726e205633204173736574000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061038e5760003560e01c8063717e794d116101de578063ba2d03441161010f578063d366a41f116100ad578063f3fef3a31161007c578063f3fef3a31461069e578063f686138d146106b1578063f69aa3d5146106ba578063f95c1b26146106cd57600080fd5b8063d366a41f14610667578063d6fbf2021461066f578063d87aa64314610678578063ea8364aa1461068b57600080fd5b8063c0f4a005116100e9578063c0f4a00514610631578063c198f8ba14610643578063c5ebeaec1461064b578063c6beb5861461065e57600080fd5b8063ba2d03441461060d578063bb35212014610615578063bc5477ad1461061e57600080fd5b8063a19516651161017c578063a6a8f1f911610156578063a6a8f1f9146105ea578063a71891c3146105f3578063ad81fced146105fb578063b0e21e8a1461060457600080fd5b8063a1951665146105d1578063a38aaa90146105da578063a516ed02146105e257600080fd5b806381680d0a116101b857806381680d0a146105905780638351faf5146105a35780638456cb59146105b65780638d1d7c61146105be57600080fd5b8063717e794d1461056257806371dbc9001461056a5780637df1f1b91461057d57600080fd5b80632d76643c116102c35780633f4ba83a116102615780635c975abb116102305780635c975abb1461053457806361ab077f1461053f578063698996f8146105525780636b64c7691461055a57600080fd5b80633f4ba83a146105085780634696c7491461051057806348dcacab146105235780634dc415de1461052c57600080fd5b806335faa4161161029d57806335faa4161461049e578063371fd8e6146104c557806338d52e0f146104d857806339518b5e146104ff57600080fd5b80632d76643c1461046f578063311176d7146104785780633168b03f1461048b57600080fd5b80631de01bc911610330578063296102521161030a57806329610252146104175780632982db001461041f57806329b154c31461043c5780632a9439451461044f57600080fd5b80631de01bc9146103fc578063234439441461040557806328a070251461040f57600080fd5b80630f5e07c71161036c5780630f5e07c7146103da57806312f21a1a146103e357806314a6bf0f146103ec5780631c4695f4146103f457600080fd5b806306fdde0314610393578063095559aa146103b15780630e5f5dbd146103d2575b600080fd5b61039b6106da565b6040516103a89190613e81565b60405180910390f35b6103c46103bf366004613ec2565b610768565b6040519081526020016103a8565b6103c461085d565b6103c460095481565b6103c4600d5481565b6103c46108c8565b61039b6108e4565b6103c4600a5481565b61040d6108f1565b005b61040d6109da565b61040d610a42565b60165461042c9060ff1681565b60405190151581526020016103a8565b61040d61044a366004613efb565b610bf9565b610457610c75565b6040516001600160a01b0390911681526020016103a8565b6103c460075481565b600254610457906001600160a01b031681565b61040d610499366004613efb565b610cf9565b6104577f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357481565b61040d6104d3366004613efb565b610de7565b6104577f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa081565b6103c460125481565b61040d610e0c565b61040d61051e366004613f14565b610f68565b6103c4600b5481565b61040d610f9a565b60005460ff1661042c565b6103c461054d366004613f14565b61109e565b6103c46110ff565b61040d611279565b6103c461131f565b61040d610578366004613f4b565b6113d2565b600554610457906001600160a01b031681565b6103c461059e366004613ec2565b6114ce565b61040d6105b1366004613f68565b6115a8565b61040d611730565b600354610457906001600160a01b031681565b6103c460105481565b61042c61188c565b61040d6118d2565b6103c460155481565b6103c4611934565b6103c460085481565b6103c4600c5481565b6103c4611a5b565b6103c460145481565b61040d61062c366004613f68565b611b18565b60115461042c90610100900460ff1681565b61040d611e44565b61040d610659366004613efb565b611e91565b6103c460065481565b6103c4611ecd565b6103c460135481565b61040d610686366004613f14565b611fd4565b61040d610699366004613fdd565b612002565b61040d6106ac3660046140a4565b6120c1565b6103c4600f5481565b6103c46106c8366004613f14565b6121b7565b60115461042c9060ff1681565b600480546106e7906140d0565b80601f0160208091040260200160405190810160405280929190818152602001828054610713906140d0565b80156107605780601f1061073557610100808354040283529160200191610760565b820191906000526020600020905b81548152906001019060200180831161074357829003601f168201915b505050505081565b6000610772612212565b61077a61223d565b8361078481612288565b61078c6122a9565b61079585612302565b82156107ac576107a5858561258c565b9150610838565b60405163113b4fbf60e31b8152600481018690527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906389da7df890602401602060405180830381865afa158015610811573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610835919061410a565b91505b610844826000866127aa565b61084c612a51565b61085560018055565b509392505050565b600754600090156108c257600062015180600d544261087c9190614139565b6108869190614162565b9050610897620f424061016d614176565b81600c546007546108a89190614176565b6108b29190614176565b6108bc9190614162565b91505090565b50600090565b60006108d261085d565b6007546108df919061418d565b905090565b600e80546106e7906140d0565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561094f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097391906141a0565b6001600160a01b0316336001600160a01b0316146109a45760405163698bba4b60e01b815260040160405180910390fd5b6000600b81905560098190556040517f219124ae95cc25cf220d998f2867d37fb4ab4908cce7c51adfa33ce747aa5747908290a2565b6109e26122a9565b60165460ff1615610a065760405163829e373360e01b815260040160405180910390fd5b610a377f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa0610a326108c8565b612a7b565b610a4060018055565b565b610a4a612212565b610a526122a9565b6000610a5c61085d565b42600d556040516370a0823160e01b81523060048201529091506000907f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906370a0823190602401602060405180830381865afa158015610aca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aee919061410a565b905080821115610b10576040516206230160eb1b815260040160405180910390fd5b8115610bee57610bc27f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435747f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbc91906141a0565b84612caf565b60405182907fda0ff68ccd5fb797a8f86207386ea961ca6990c15ace2424ab51eb871ed4959990600090a25b5050610a4060018055565b336001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435741614610c425760405163bc9eca6160e01b815260040160405180910390fd5b600781905560405181907f35ba42ee3c2daa6cf14836eefff16b184565798767ec1e5d723008848aeaf7e390600090a250565b60007f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316632a9439456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cd5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108df91906141a0565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7b91906141a0565b6001600160a01b0316336001600160a01b031614610dac5760405163698bba4b60e01b815260040160405180910390fd5b60088190556040518181527f7760d892a7883522367f0eaea35e968381a018418c249cd9aaaca190fe5d88179060200160405180910390a150565b610def612212565b610df76122a9565b610e0081612daf565b610e0960018055565b50565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8e91906141a0565b6001600160a01b0316336001600160a01b031614158015610f4257507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2c91906141a0565b6001600160a01b0316336001600160a01b031614155b15610f6057604051631e1c735b60e21b815260040160405180910390fd5b610a4061306a565b610f70612212565b610f786122a9565b81610f8281612288565b610f8c83836130bc565b50610f9660018055565b5050565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ff8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101c91906141a0565b6001600160a01b0316336001600160a01b03161461104d57604051632d5be4cb60e21b815260040160405180910390fd5b6011805461ff001916610100179055611064613437565b6005546040516001600160a01b03909116907faf77f8960cf590e245ec8b6d41c193a5dcacad8986ae4eb57ac9e5be7b6af03190600090a2565b60006110a8612212565b6110b061223d565b6110b86122a9565b6110c28383613474565b60405190915081907f4e08ba899977cf7d4c2964bce71c6b9a7ef76ee5166a4c1249a1e08016e33ef190600090a26110f960018055565b92915050565b600080600061110c61361f565b60405163113b4fbf60e31b81526004810182905291935091506000906001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416906389da7df890602401602060405180830381865afa158015611179573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119d919061410a565b905060006111aa84613721565b905060007f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166389da7df86111e561085d565b6040518263ffffffff1660e01b815260040161120391815260200190565b602060405180830381865afa158015611220573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611244919061410a565b9050808383611251611934565b61125b919061418d565b611265919061418d565b61126f9190614139565b9550505050505090565b6112816122a9565b61128961188c565b6112a65760405163038cbd4b60e31b815260040160405180910390fd5b60165460ff1615806112ba57506000601354115b156112d85760405163829e373360e01b815260040160405180910390fd5b426012556006546000906112ef90620f4240614139565b905080620f42406112fe6108c8565b6113089190614176565b6113129190614162565b60135550610a4060018055565b6000807f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166389da7df86007546040518263ffffffff1660e01b815260040161137291815260200190565b602060405180830381865afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b3919061410a565b905060006113bf6110ff565b90506113cb82826141bd565b9250505090565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611430573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145491906141a0565b6001600160a01b0316336001600160a01b03161461148557604051632d5be4cb60e21b815260040160405180910390fd5b6001600160a01b0381166114ac57604051632887dd7560e11b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b60006114d8612212565b6114e061223d565b836114ea81612288565b6114f26122a9565b6114fc85856130bc565b82156115135761150c8585613474565b915061159f565b604051633068b6b560e21b8152600481018690527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03169063c1a2dad490602401602060405180830381865afa158015611578573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159c919061410a565b91505b61084c82612daf565b6115b06122a9565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561160e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163291906141a0565b6001600160a01b0316336001600160a01b0316146116635760405163698bba4b60e01b815260040160405180910390fd5b60115460ff16611686576040516305b02a1960e01b815260040160405180910390fd5b6010548310156116a9576040516312cd610d60e21b815260040160405180910390fd5b6116b283612302565b60006116be848361258c565b90506116cc816000846127aa565b600f546116d7611ecd565b12156116f6576040516378764b0f60e01b815260040160405180910390fd5b60405184907f8f77e6a87a8210bff9857b08990b1f360b73d6e92d422a9a0e2c78e449682a9c90600090a25061172b60018055565b505050565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663baf4a3126040518163ffffffff1660e01b8152600401602060405180830381865afa15801561178e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117b291906141a0565b6001600160a01b0316336001600160a01b03161415801561186657507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561182c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185091906141a0565b6001600160a01b0316336001600160a01b031614155b1561188457604051631e1c735b60e21b815260040160405180910390fd5b610a40613437565b600080600a541180156118a157506000600b54115b80156118ae575060095442115b806108df575060006007541180156108df57506006546118cc611ecd565b12905090565b6118da6122a9565b6012546000036118fd576040516334dc687f60e11b815260040160405180910390fd5b6000611907611a5b565b90507f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa0610bee8183612a7b565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa016906370a0823190602401602060405180830381865afa15801561199d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c1919061410a565b6040516303d1689d60e11b8152600481018290529091506000906001600160a01b037f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa016906307a2d13a90602401602060405180830381865afa158015611a2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a50919061410a565b90506113cb81613721565b600080620f4240601554620f4240611a739190614139565b600754611a809190614176565b611a8a9190614162565b9050600061012c60125442611a9f9190614139565b611aa99190614162565b9050600060145482611abb9190614176565b9050620f4240811115611ad057509092915050565b6000611adf82620f4240614139565b90506000620f424082601354611af59190614176565b611aff9190614162565b9050808511611b0e578061126f565b5092949350505050565b611b206122a9565b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663e563037e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba291906141a0565b6001600160a01b0316336001600160a01b031614611bd35760405163698bba4b60e01b815260040160405180910390fd5b600080611bde61361f565b915091506000611bf6611bef6108c8565b87906137af565b600a5490915015611c1757600a54611c0e904261418d565b600955600b8190555b80821015611d67576000611c2b8383614139565b60405163113b4fbf60e31b8152600481018290529091506000906001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416906389da7df890602401602060405180830381865afa158015611c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cba919061410a565b90506000611cc7826137c5565b905085811115611ce457611ce4611cde8783614139565b886130bc565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d51919061410a565b1115611d6357611d618188613474565b505b5050505b6040516370a0823160e01b81523060048201526000907f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906370a0823190602401602060405180830381865afa158015611dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df2919061410a565b118015611dff5750600081115b15611e0d57611e0d81612daf565b60405186907fdfcd68ceed46252749a4089f344aec4b4ee7f28a068f704c21799355325f3da990600090a250505061172b60018055565b611e4c612212565b6011805461ff00191690556005546040516001600160a01b03909116907facf29ad8d63913d38e7e1176963a4afb76bf0918516051da68408ecb6f98065d90600090a2565b611e99612212565b611ea161223d565b80611eab81612288565b611eb36122a9565b611ebc82612302565b611ec4612a51565b610f9660018055565b600080611ed86110ff565b905080600003611efd5760075415611ef557620f423f1991505090565b600091505090565b60075460405163113b4fbf60e31b81526000916001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416916389da7df891611f519160040190815260200190565b602060405180830381865afa158015611f6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f92919061410a565b9050600082611fa183826141bd565b611fae90620f42406141e4565b611fb89190614214565b9050620f423f19811215611fcd5750620f423f195b9392505050565b611fdc612212565b611fe461223d565b611fec6122a9565b81611ff681612288565b610f8c836000846127aa565b61200a612212565b61201261385a565b60068c9055600c8b905560088a90556014899055600a889055600f879055601086905560158590556011805460ff199081168615151790915560168054909116841515179055600e61206582848361429e565b508a8c7fed1352796b02006c8bf7ef68956cb9fc55c08f9193eee9cec7ee590840bbbaad8c6014548c8c8c8c8c8c8c8c6040516120ab9a9998979695949392919061435e565b60405180910390a3505050505050505050505050565b6120c9612212565b6120d161223d565b806120db81612288565b6120e36122a9565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561212a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214e919061410a565b90508083111561215c578092505b612167843385612caf565b6007541561217757612177612a51565b60405183906001600160a01b038616907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d590600090a35061172b60018055565b60006121c1612212565b6121c961223d565b6121d16122a9565b6121db838361258c565b60405190915083907f92f64ca637d023f354075a4be751b169c1a8a9ccb6d33cdd0cb352054399572790600090a26110f960018055565b6005546001600160a01b03163314610a4057604051631963d1e760e31b815260040160405180910390fd5b60005460ff1615610a405760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064015b60405180910390fd5b80600003610e0957604051639d635cff60e01b815260040160405180910390fd5b6002600154036122fb5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161227f565b6002600155565b60405163b67e9df760e01b81523060048201527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03169063b67e9df790602401602060405180830381865afa158015612366573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238a91906143cf565b6123a75760405163d8d5894f60e01b815260040160405180910390fd5b60006007546008546123b99190614139565b9050818110156123dc5760405163569d45cf60e11b815260040160405180910390fd5b60006123e661085d565b60405163140e25ad60e31b8152600481018590529091507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03169063a0712d6890602401600060405180830381600087803b15801561244b57600080fd5b505af115801561245f573d6000803e3d6000fd5b505050508260076000828254612475919061418d565b909155505042600d55801561255c576125307f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435747f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612506573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061252a91906141a0565b83612caf565b60405181907fda0ff68ccd5fb797a8f86207386ea961ca6990c15ace2424ab51eb871ed4959990600090a25b60405183907f69c0ed5a77051ba5f0c42418bb6db6d3f73884dea69811c50bf320298df6ca5c90600090a2505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416906370a0823190602401602060405180830381865afa1580156125f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612619919061410a565b905061262584826137af565b9350836000036126485760405163569d45cf60e11b815260040160405180910390fd5b60405163113b4fbf60e31b8152600481018590526126da907f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906389da7df890602401602060405180830381865afa1580156126b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126d5919061410a565b6137c5565b915060006126e88385613882565b905060006126f4610c75565b90506127217f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357482886138a6565b600254604051631c6d209760e11b81526001600160a01b0391821660048201526024810188905260448101849052908216906338da412e906064015b6020604051808303816000875af115801561277c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a0919061410a565b9695505050505050565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156127f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612817919061410a565b90508060000361283a5760405163569d45cf60e11b815260040160405180910390fd5b83811015612846578093505b60006128528584613882565b600254909150600090612890906001600160a01b03167f0000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174888561399f565b90506128dd7f0000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841747f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa0836138a6565b604051636e553f6560e01b8152600481018290523060248201526000907f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa06001600160a01b031690636e553f65906044016020604051808303816000875af115801561294d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612971919061410a565b6040516363737ac960e11b8152600481018490529091507f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa06001600160a01b03169063c6e6f59290602401602060405180830381865afa1580156129d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fd919061410a565b811015612a1d57604051631897b7fd60e11b815260040160405180910390fd5b60405182907fac9f7997c30b6a3cc9c74953898b5de154359339c7ec0d6d70ceb98e55db1a4b90600090a250505050505050565b600654612a5c611ecd565b1215610a405760405163374c72ff60e11b815260040160405180910390fd5b612a8361188c565b612aa05760405163038cbd4b60e31b815260040160405180910390fd5b6002546040516370a0823160e01b81523060048201819052916000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015612aee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b12919061410a565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918616906370a0823190602401602060405180830381865afa158015612b5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b82919061410a565b6040516370a0823160e01b81526001600160a01b0385811660048301529192506000917f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357416906370a0823190602401602060405180830381865afa158015612bee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c12919061410a565b905080851115612c5157612c517f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435743386612c4c858a614139565b613ae4565b600254612c68906001600160a01b03163385612caf565b612c73863384612caf565b612c7c85612daf565b60405133907f1e1ef858062a7196d1891e397a5cde9891e6ddf61a81e9d269a3aaa7a95dacd890600090a2505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092839290871691612d0b91906143ec565b6000604051808303816000865af19150503d8060008114612d48576040519150601f19603f3d011682016040523d82523d6000602084013e612d4d565b606091505b5091509150818015612d77575080511580612d77575080806020019051810190612d7791906143cf565b612da85760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640161227f565b5050505050565b6040516370a0823160e01b8152306004820152612e42907f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906370a0823190602401602060405180830381865afa158015612e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e3b919061410a565b82906137af565b9050612e4f612e3b6108c8565b905080600003612e725760405163569d45cf60e11b815260040160405180910390fd5b80600b5411612e82576000612e90565b80600b54612e909190614139565b600b55600a5415801590612ea45750600b54155b15612eaf5760006009555b6000612eb961085d565b42600d559050612ec98183614139565b9150816007541015612ee5576007805460009091559150612efd565b8160076000828254612ef79190614139565b90915550505b612f7f7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435747f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612506573d6000803e3d6000fd5b612faa7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d4357430846138a6565b604051630852cd8d60e31b8152600481018390527f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906342966c6890602401600060405180830381600087803b15801561300c57600080fd5b505af1158015613020573d6000803e3d6000fd5b50506040518492507f33a382daad6aace935340a474d09fec82af4bec7e2b69518d283231b03a65f249150600090a261305761188c565b610f9657610f9660006012819055601355565b613072613bee565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa06001600160a01b0316906370a0823190602401602060405180830381865afa158015613123573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613147919061410a565b90508060000361316a5760405163569d45cf60e11b815260040160405180910390fd5b6040516363737ac960e11b8152600481018490526000907f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa06001600160a01b03169063c6e6f59290602401602060405180830381865afa1580156131d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131f6919061410a565b9050808210156132035750805b6040516303d1689d60e11b8152600481018290526000907f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa06001600160a01b0316906307a2d13a90602401602060405180830381865afa15801561326b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061328f919061410a565b604051632d182be560e21b815260048101829052306024820181905260448201529091507f000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa06001600160a01b03169063b460af94906064016020604051808303816000875af1158015613306573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061332a919061410a565b506040516370a0823160e01b81523060048201527f0000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841746001600160a01b0316906370a0823190602401602060405180830381865afa15801561338f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b3919061410a565b905060006133c18286613882565b600254909150600090613400907f0000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174906001600160a01b0316858561399f565b60405190915081907f0dbc40ccd4fca1b5bf46f23e99aaefe371e661e9ca0c45dc1b79e5e321d3b99d90600090a250505050505050565b61343f61223d565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861309f3390565b6002546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156134c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e5919061410a565b90506134f184826137af565b9350836000036135145760405163569d45cf60e11b815260040160405180910390fd5b7f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b031663c1a2dad461354c86613721565b6040518263ffffffff1660e01b815260040161356a91815260200190565b602060405180830381865afa158015613587573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ab919061410a565b915060006135b98385613882565b905060006135c5610c75565b6002549091506135df906001600160a01b031682886138a6565b60025460405163231831c760e21b81526001600160a01b039182166004820152602481018890526044810184905290821690638c60c71c9060640161275d565b6002546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561366c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613690919061410a565b6040516370a0823160e01b81523060048201529092507f000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435746001600160a01b0316906370a0823190602401602060405180830381865afa1580156136f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061371b919061410a565b90509091565b60006110f982600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561377a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379e9190614408565b6003546001600160a01b0316613c37565b60008183106137be5781611fcd565b5090919050565b60006110f982600260009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561381e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138429190614408565b60035460ff91909116906001600160a01b0316613c91565b601154610100900460ff16610a4057604051634e751a9560e11b815260040160405180910390fd5b6000620f42406138928382614139565b61389c9085614176565b611fcd9190614162565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b179052915160009283929087169161390291906143ec565b6000604051808303816000865af19150503d806000811461393f576040519150601f19603f3d011682016040523d82523d6000602084013e613944565b606091505b509150915081801561396e57508051158061396e57508080602001905181019061396e91906143cf565b612da85760405162461bcd60e51b8152602060048201526002602482015261534160f01b604482015260640161227f565b60006139cc857f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564856138a6565b60408051610100810182526001600160a01b0380881682528616602082015260649181019190915230606082015260009060808101613a0d6103844261418d565b8152602080820187905260408083018790526000606093840152805163414bf38960e01b815284516001600160a01b03908116600483015292850151831660248201529084015162ffffff16604482015291830151811660648301526080830151608483015260a083015160a483015260c083015160c483015260e0830151811660e48301529192507f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615649091169063414bf38990610104016020604051808303816000875af115801561277c573d6000803e3d6000fd5b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092839290881691613b4891906143ec565b6000604051808303816000865af19150503d8060008114613b85576040519150601f19603f3d011682016040523d82523d6000602084013e613b8a565b606091505b5091509150818015613bb4575080511580613bb4575080806020019051810190613bb491906143cf565b613be65760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161227f565b505050505050565b60005460ff16610a405760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161227f565b600080613c4383613ce4565b90506000613c5084613d48565b9050613c5c858361442b565b613c6790600a614528565b613c736006600a614528565b613c7d8389614176565b613c879190614176565b6127a09190614162565b600080613c9d83613ce4565b90506000613caa84613d48565b9050613cb86006600a614528565b613cc29082614176565b613ccf8660ff851661418d565b613cda90600a614537565b613c879088614176565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d24573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f99190614408565b6000806000806000856001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015613d8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613db29190614562565b9450945050935093508369ffffffffffffffffffff168169ffffffffffffffffffff161015613e0e5760405162461bcd60e51b81526020600482015260086024820152674f6c64206461746160c01b604482015260640161227f565b60008211613e535760405162461bcd60e51b8152602060048201526012602482015271526f756e64206e6f7420636f6d706c65746560701b604482015260640161227f565b5090949350505050565b60005b83811015613e78578181015183820152602001613e60565b50506000910152565b6020815260008251806020840152613ea0816040850160208701613e5d565b601f01601f19169190910160400192915050565b8015158114610e0957600080fd5b600080600060608486031215613ed757600080fd5b83359250602084013591506040840135613ef081613eb4565b809150509250925092565b600060208284031215613f0d57600080fd5b5035919050565b60008060408385031215613f2757600080fd5b50508035926020909101359150565b6001600160a01b0381168114610e0957600080fd5b600060208284031215613f5d57600080fd5b8135611fcd81613f36565b600080600060608486031215613f7d57600080fd5b505081359360208301359350604090920135919050565b60008083601f840112613fa657600080fd5b50813567ffffffffffffffff811115613fbe57600080fd5b602083019150836020828501011115613fd657600080fd5b9250929050565b6000806000806000806000806000806000806101608d8f03121561400057600080fd5b8c359b5060208d01359a5060408d0135995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506140436101008e0135613eb4565b6101008d013593506140596101208e0135613eb4565b6101208d0135925067ffffffffffffffff6101408e0135111561407b57600080fd5b61408c8e6101408f01358f01613f94565b81935080925050509295989b509295989b509295989b565b600080604083850312156140b757600080fd5b82356140c281613f36565b946020939093013593505050565b600181811c908216806140e457607f821691505b60208210810361410457634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561411c57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156110f9576110f9614123565b634e487b7160e01b600052601260045260246000fd5b6000826141715761417161414c565b500490565b80820281158282048414176110f9576110f9614123565b808201808211156110f9576110f9614123565b6000602082840312156141b257600080fd5b8151611fcd81613f36565b81810360008312801583831316838312821617156141dd576141dd614123565b5092915050565b80820260008212600160ff1b8414161561420057614200614123565b81810583148215176110f9576110f9614123565b6000826142235761422361414c565b600160ff1b82146000198414161561423d5761423d614123565b500590565b634e487b7160e01b600052604160045260246000fd5b601f82111561172b57600081815260208120601f850160051c8101602086101561427f5750805b601f850160051c820191505b81811015613be65782815560010161428b565b67ffffffffffffffff8311156142b6576142b6614242565b6142ca836142c483546140d0565b83614258565b6000601f8411600181146142fe57600085156142e65750838201355b600019600387901b1c1916600186901b178355612da8565b600083815260209020601f19861690835b8281101561432f578685013582556020948501946001909201910161430f565b508682101561434c5760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60006101208c83528b60208401528a60408401528960608401528860808401528760a084015286151560c084015285151560e0840152806101008401528381840152506101408385828501376000838501820152601f909301601f19169091019091019a9950505050505050505050565b6000602082840312156143e157600080fd5b8151611fcd81613eb4565b600082516143fe818460208701613e5d565b9190910192915050565b60006020828403121561441a57600080fd5b815160ff81168114611fcd57600080fd5b60ff81811683821601908111156110f9576110f9614123565b600181815b8085111561447f57816000190482111561446557614465614123565b8085161561447257918102915b93841c9390800290614449565b509250929050565b600082614496575060016110f9565b816144a3575060006110f9565b81600181146144b957600281146144c3576144df565b60019150506110f9565b60ff8411156144d4576144d4614123565b50506001821b6110f9565b5060208310610133831016604e8410600b8410161715614502575081810a6110f9565b61450c8383614444565b806000190482111561452057614520614123565b029392505050565b6000611fcd60ff841683614487565b6000611fcd8383614487565b805169ffffffffffffffffffff8116811461455d57600080fd5b919050565b600080600080600060a0868803121561457a57600080fd5b61458386614543565b94506020860151935060408601519250606086015191506145a660808701614543565b9050929550929590935056fea2646970667358221220c4dc41a36de2dd373fa908eb7428da8c29ac2df042c578c6bbc115678bfe266464736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d435740000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa0000000000000000000000000fe4a8cc5b5b2366c1b58bea3858e81843581b2f700000000000000000000000047671b43b6e05fc6f423595f625716a06d76d9ec000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000000e596561726e205633204173736574000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _name (string): Yearn V3 Asset
Arg [1] : _sweep (address): 0xB88a5Ac00917a02d82c7cd6CEBd73E2852d43574
Arg [2] : _usdx (address): 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359
Arg [3] : _usdc_e (address): 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
Arg [4] : _asset (address): 0xA013Fbd4b711f9ded6fB09C1c0d358E2FbC2EAA0
Arg [5] : _oracleUsdx (address): 0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7
Arg [6] : _borrower (address): 0x47671b43B6E05FC6f423595F625716A06d76D9Ec
Arg [7] : _router (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [1] : 000000000000000000000000b88a5ac00917a02d82c7cd6cebd73e2852d43574
Arg [2] : 0000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359
Arg [3] : 0000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174
Arg [4] : 000000000000000000000000a013fbd4b711f9ded6fb09c1c0d358e2fbc2eaa0
Arg [5] : 000000000000000000000000fe4a8cc5b5b2366c1b58bea3858e81843581b2f7
Arg [6] : 00000000000000000000000047671b43b6e05fc6f423595f625716a06d76d9ec
Arg [7] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [8] : 000000000000000000000000000000000000000000000000000000000000000e
Arg [9] : 596561726e205633204173736574000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
OP | 100.00% | $0.999841 | 0.8041 | $0.804 |
Loading...
Loading
Loading...
Loading
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.