Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- NineInchSpotLimit
- Optimization enabled
- true
- Compiler version
- v0.8.19+commit.7dd6d404
- Optimization runs
- 999999
- EVM Version
- default
- Verified at
- 2023-10-26T12:47:28.836603Z
Constructor Arguments
0x000000000000000000000000172fa14891c971751ae324d0638cccd4aa5f360600000000000000000000000086efbd0b6736bed994962f9797049422a3a8e8ad0000000000000000000000008202d285f1ec08fb7787ec5f09f3da235f2a4325
Arg [0] (address) : 0x172fa14891c971751ae324d0638cccd4aa5f3606
Arg [1] (address) : 0x86efbd0b6736bed994962f9797049422a3a8e8ad
Arg [2] (address) : 0x8202d285f1ec08fb7787ec5f09f3da235f2a4325
contracts/swap/NineInchSpotLimitPLS.sol
// SPDX-License-Identifier: GPLv3
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./interfaces/INineInchRouter02.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
/**
* @title NineInchSpotLimit
* @notice It allows to create programmed swaps at a certain price, each order costs credits that, depending on the credits, increase the time of the open order.
* The accepted token to buy credits is LINK (Chainlink ERC 677), the amount of LINK is used to fund the keeper and execute the order
*/
contract NineInchSpotLimit is ReentrancyGuard, Pausable, Ownable {
//---------- Libraries ----------//
using SafeMath for uint256;
using SafeCast for uint256;
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.Bytes32Set;
//---------- Contracts ----------//
INineInchRouter02 private nineInchRouter; // JamonSwap Router contract.
IERC20 private immutable nineInch; // 9inch token contract.
//---------- Variables ----------//
uint256 public creditPrice; // Price of credit in creditToken.
uint256 public creditTime; // Time per credit to keep an open order.
bool public returnCredit; // Allow or not to return 1 credit when canceling.
address public keeper; // Address of the admin who can performKeep.
//---------- Storage -----------//
struct Order {
uint256 targetPrice;
uint256 amountIn;
address[] path;
address user;
uint16 slippage;
uint256 deadline;
}
mapping(bytes32 => Order) private orderBook; // Mapping from orderId to order.
EnumerableSet.Bytes32Set private orderIndex; // Mapping of ids of orders.
mapping(address => uint256) public credits; // Mapping of credits balances.
//---------- Events -----------//
event OrderCreated(
bytes32 indexed orderId,
uint256 currentPrice,
uint256 targetPrice,
uint256 amountIn,
address tokenIn,
address tokenOut,
address indexed user,
uint16 slippage,
uint256 deadline
);
event OrderCancelled(bytes32 indexed orderId);
event OrderExpired(bytes32 indexed orderId);
event OrderFilled(bytes32 indexed orderId, uint256 executionPrice);
event OrderFailed(bytes32 indexed orderId);
event BoughtCredit(address indexed wallet, uint256 amount);
event TransferCredit(
address indexed from,
address indexed to,
uint256 amount
);
//---------- Constructor ----------//
constructor(address router, address _keeper, address _creditToken) {
nineInchRouter = INineInchRouter02(router);
keeper = _keeper; // 0xC73896721b68ce58DDe039ef79E37FFf164FD355; pulse node admin
creditPrice = 0.20 ether; // creditToken
creditTime = 7 days;
returnCredit = true;
nineInch = ERC20Burnable(_creditToken);
}
//---------- Modifiers ----------//
/**
* @dev Reverts if the caller is not a keeper.
*/
modifier onlyKeeper() {
require(_msgSender() == keeper, "Only Node Admin");
_;
}
//----------- Internal Functions -----------//
/**
* @dev Convert two address in address array.
* @param tokenA First address.
* @param tokenB Last address.
* @return address[] path.
*/
function _getPath(
address tokenA,
address tokenB
) private pure returns (address[] memory) {
address[] memory path = new address[](2);
path[0] = tokenA;
path[1] = tokenB;
return path;
}
/**
* @dev Register an order and index it.
* @param orderId Order Identity.
* @param price Price at which the order is executed.
* @param amountIn Amount to swap.
* @param path Path to be performed by the swap.
* @param user Address of the order maker.
* @param slippage Swap tolerance percentage.
* @param deadline Expiration date if the order is not executed.
*/
function _createOrder(
bytes32 orderId,
uint256 price,
uint256 amountIn,
address[] calldata path,
address user,
uint16 slippage,
uint256 deadline
) private {
Order memory newOrder = Order(
price,
amountIn,
path,
user,
slippage,
deadline
);
orderIndex.add(orderId);
orderBook[orderId] = newOrder;
}
/**
* @dev Cancel a existent order.
* @param orderId Order Identity.
*/
function _deleteOrder(bytes32 orderId) private {
orderIndex.remove(orderId);
delete orderBook[orderId];
}
/**
* @dev Return funds if the order execution fails.
* @param amount Amount to return.
* @param token Address of the asset.
* @param user Address of the order maker.
*/
function _forceFail(uint256 amount, address token, address user) private {
//Interactions
if (token == address(nineInchRouter.WETH())) {
(bool success, ) = payable(user).call{value: amount}("");
require(success, "Transfer failed");
} else {
IERC20 _token = IERC20(token);
_token.safeTransfer(user, amount);
}
}
/**
* @dev Perform a swap once the target price is reached.
* @param orderId Order Identity.
* @param amountIn Amount to swap.
* @param path Path to be performed by the swap.
* @param user Address of the order maker.
* @param amountOutMin Minimum amount of tokens accepted to not revert.
*/
function _performSwap(
bytes32 orderId,
uint256 amountIn,
address[] memory path,
address user,
uint256 amountOutMin
) private {
address WETH = nineInchRouter.WETH();
address tokenIn = path[0];
address tokenOut = path[path.length - 1];
if (tokenIn == WETH) {
try
nineInchRouter.swapExactETHForTokens{value: amountIn}(
amountOutMin,
path,
user,
block.timestamp.add(300)
)
returns (uint256[] memory amounts) {
emit OrderFilled(orderId, amounts[path.length - 1]);
} catch {
_forceFail(amountIn, tokenIn, user);
emit OrderFailed(orderId);
}
} else if (tokenOut == WETH) {
try
nineInchRouter.swapExactTokensForETH(
amountIn,
amountOutMin,
path,
payable(user),
block.timestamp.add(300)
)
returns (uint256[] memory amounts) {
emit OrderFilled(orderId, amounts[path.length - 1]);
} catch {
_forceFail(amountIn, tokenIn, user);
emit OrderFailed(orderId);
}
} else {
try
nineInchRouter.swapExactTokensForTokens(
amountIn,
amountOutMin,
path,
user,
block.timestamp.add(300)
)
returns (uint256[] memory amounts) {
emit OrderFilled(orderId, amounts[path.length - 1]);
} catch {
_forceFail(amountIn, tokenIn, user);
emit OrderFailed(orderId);
}
}
}
/**
* @dev Calculate the amount of digits in a number.
* @param number Number to check.
* @return uint256 amount of difits.
*/
function _numDigits(uint256 number) private pure returns (uint256) {
uint256 digits = 0;
while (number != 0) {
number /= 10;
digits++;
}
return digits;
}
/**
* @dev Calculate the number of pages in proportion to 100 orders per page.
* @return book_ amount of pages.
* @return digitpage_ difits of pages.
*/
function _getPagination()
private
view
returns (uint256 book_, uint256 digitpage_)
{
uint256 _book = orderIndex.length().div(100);
uint256 remainder = _book.mul(100);
_book = remainder < orderIndex.length() ? _book.add(1) : _book;
return (_book, _numDigits(_book));
}
//----------- External Functions -----------//
/**
* @notice Show the number of total open orders.
* @return The number of orders.
*/
function totalOrders() external view returns (uint256) {
return orderIndex.length();
}
/**
* @notice Show the order in the searched index.
* @param index Index number for query.
* @return The id of the order.
*/
function getOrderAt(uint256 index) external view returns (bytes32) {
return orderIndex.at(index);
}
/**
* @notice Show data of the order.
* @param orderId ID for query.
* @return The data of the order.
*/
function getOrder(bytes32 orderId) external view returns (Order memory) {
require(orderIndex.contains(orderId), "Query for nonexistent order");
return orderBook[orderId];
}
/**
* @notice Show the amounts out of path.
* @param amountIn Amount to query.
* @param path Path to query.
* @return If exist and the amount out.
*/
function getPrice(
uint256 amountIn,
address[] memory path
) public view returns (bool, uint256) {
try nineInchRouter.getAmountsOut(amountIn, path) returns (
uint256[] memory result
) {
return (true, result[path.length - 1]);
} catch {
return (false, 0);
}
}
function creditPriceIn9Inch(
uint256 numCredits
) public view returns (uint256) {
// calculate required amount of eth for buy required linkAmount
uint256 linkAmount = creditPrice.mul(numCredits);
uint256 nineInchAmount = nineInchRouter.getAmountsIn(
linkAmount,
_getPath(address(nineInch), address(nineInchRouter.WETH()))
)[0];
return nineInchAmount;
}
/**
* @notice Show the start and end index for the keeper query, these indexes change according to the block number.
* This function is implemented so that keepers can read all open orders and not have a reduced limit.
* @return start index to check.
* @return end index to check.
*/
function getBatch() public view returns (uint256 start, uint256 end) {
if (orderIndex.length() != 0) {
(uint256 pages, uint256 batchDigits) = _getPagination();
uint256 blockTens = block.number.div(10);
uint256 underBlock = blockTens.div(10 ** batchDigits);
uint256 overBlock = underBlock.mul(10 ** batchDigits);
uint256 result = blockTens.sub(overBlock);
result = result == 0 ? 1 : result;
while (result > pages) {
result -= pages;
}
uint256 start_ = result.sub(1).mul(100);
uint256 end_ = result.mul(100) > orderIndex.length()
? orderIndex.length()
: result.mul(100);
return (start_, end_);
}
return (0, 0);
}
/**
* @notice Create new order.
* @param targetPrice_ Price at which the order is executed.
* @param amountIn_ Amount to swap.
* @param path_ Path to be performed by the swap.
* @param slippage_ Swap tolerance percentage.
* @param credits_ Amount of credits to use.
*/
function createOrder(
uint256 targetPrice_,
uint256 amountIn_,
address[] calldata path_,
uint16 slippage_,
uint256 credits_
) external payable whenNotPaused nonReentrant {
//Checks
require(slippage_ <= 10000, "Slippage out of bound");
require(amountIn_ != 0, "Zero amount in");
require(targetPrice_ > 0 && credits_ > 0, "Zero price");
require(path_.length >= 2, "Invalid path");
uint256 targetPrice = targetPrice_;
uint256 amountIn = amountIn_;
uint256 _credits = credits_;
address[] calldata path = path_;
address tokenIn = path[0];
address tokenOut = path[path_.length - 1];
uint16 slippage = slippage_;
address user = _msgSender();
require(
tokenIn != address(0x0) &&
tokenOut != address(0x0) &&
tokenIn != tokenOut,
"Invalid tokens"
);
// buy credits if user has not enough
if (credits[_msgSender()] < _credits) {
uint256 requiredCredits = _credits.sub(credits[_msgSender()]);
uint256 required9InchAmount = creditPriceIn9Inch(requiredCredits);
require(
nineInch.allowance(user, address(this)) >= required9InchAmount,
"Insufficient 9inch allowance"
);
nineInch.safeTransferFrom(user, address(this), required9InchAmount);
if (tokenIn == address(nineInchRouter.WETH())) {
require(
msg.value >= amountIn,
"Insufficient eth value for swap"
);
}
nineInch.approve(address(nineInchRouter), required9InchAmount);
nineInchRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
required9InchAmount,
0,
_getPath(address(nineInch), nineInchRouter.WETH()),
keeper,
block.timestamp.add(300)
);
unchecked {
credits[_msgSender()] += requiredCredits;
}
} else {
if (tokenIn == address(nineInchRouter.WETH())) {
require(
msg.value == amountIn,
"Insufficient eth value for swap"
);
}
}
(bool success, uint256 price) = getPrice(amountIn, path);
require(success && price < targetPrice, "Invalid target price");
uint256[3] memory prices;
prices[0] = price;
prices[1] = targetPrice;
prices[2] = amountIn;
bytes32 orderId = keccak256(
abi.encodePacked(
prices[0],
prices[1],
prices[2],
tokenIn,
tokenOut,
user,
slippage,
block.number
)
);
require(!orderIndex.contains(orderId), "Order id mistake");
unchecked {
credits[_msgSender()] -= _credits;
}
//Effects
uint256 deadline = block.timestamp.add(creditTime.mul(_credits));
_createOrder(
orderId,
prices[1],
prices[2],
path,
user,
slippage,
deadline
);
//Interactions
IERC20 token = IERC20(tokenIn);
if (token.allowance(address(this), address(nineInchRouter)) == 0) {
token.approve(address(nineInchRouter), ~uint256(0));
}
if (tokenIn != address(nineInchRouter.WETH())) {
token.transferFrom(user, address(this), prices[2]);
}
emit OrderCreated(
orderId,
prices[0],
prices[1],
prices[2],
tokenIn,
tokenOut,
user,
slippage,
deadline
);
}
/**
* @notice Cancel a existent order.
* @param orderId Order identity.
*/
function cancelOrder(bytes32 orderId) external nonReentrant {
//Checks
require(orderIndex.contains(orderId), "Order does not exist");
Order memory order = orderBook[orderId];
require(order.user == _msgSender(), "Invalid access");
address tokenIn = order.path[0];
//Effects
_deleteOrder(orderId);
//Interactions
if (tokenIn == address(nineInchRouter.WETH())) {
(bool success, ) = payable(order.user).call{value: order.amountIn}(
""
);
require(success, "Transfer failed");
} else {
IERC20 token = IERC20(tokenIn);
token.transfer(order.user, order.amountIn);
}
if (returnCredit) {
credits[order.user] += 1;
}
emit OrderCancelled(orderId);
}
/**
* @notice Check if any order need to be execute.
* @param checkData default data of keeper.
* @return If need to be execute and the order id.
*/
function checkUpkeep(
bytes calldata checkData
) external view returns (bool, bytes memory) {
(uint256 start, uint256 end) = getBatch();
for (uint256 i = start; i < end; i++) {
bytes32 orderId = orderIndex.at(i);
Order memory order = orderBook[orderId];
(bool success, uint256 price) = getPrice(
order.amountIn,
order.path
);
if (
(success == true && price >= order.targetPrice) ||
order.deadline <= block.timestamp
) {
return (true, abi.encodePacked(orderId));
}
}
return (false, checkData);
}
/**
* @notice Execute an order, only keepers can do this execution.
* @param performData order id to execute.
*/
function performUpkeep(
bytes calldata performData
) external nonReentrant onlyKeeper {
bytes32 orderId = abi.decode(performData, (bytes32));
require(orderIndex.contains(orderId), "Order does not exist");
Order memory order = orderBook[orderId];
address tokenIn = order.path[0];
if (order.deadline <= block.timestamp) {
//Effects
_deleteOrder(orderId);
//Interactions
if (tokenIn == address(nineInchRouter.WETH())) {
(bool transfered, ) = payable(order.user).call{
value: order.amountIn
}("");
require(transfered, "Transfer failed");
} else {
IERC20 token = IERC20(tokenIn);
token.transfer(order.user, order.amountIn);
}
emit OrderExpired(orderId);
} else {
//Checks
(bool success, uint256 price) = getPrice(
order.amountIn,
order.path
);
require(
success == true && price >= order.targetPrice,
"Target not reached"
);
uint256 amountOutMin = price.mul(10000 - order.slippage).div(10000);
//Effects
_deleteOrder(orderId);
//Interactions
_performSwap(
orderId,
order.amountIn,
order.path,
order.user,
amountOutMin
);
}
}
/**
* @notice Cancel a existent order by the contract owner.
* @param orderId_ Order identity.
*/
function forceCancelOrder(bytes32 orderId_) external onlyOwner {
//Checks
require(orderIndex.contains(orderId_), "Order does not exist");
Order memory order = orderBook[orderId_];
address tokenIn = order.path[0];
//Effects
_deleteOrder(orderId_);
//Interactions
if (tokenIn == address(nineInchRouter.WETH())) {
(bool success, ) = payable(order.user).call{value: order.amountIn}(
""
);
require(success, "Transfer failed");
} else {
IERC20 token = IERC20(tokenIn);
token.transfer(order.user, order.amountIn);
}
credits[order.user] += 1;
emit OrderCancelled(orderId_);
}
/**
* @notice Set if a credit is returned when canceling the order.
* @param return_ Determines whether or not to return.
*/
function setReturnCredit(bool return_) external onlyOwner {
returnCredit = return_;
}
/**
* @notice Set the time that extends an order per consumed credit.
* @param newTimeCredit_ The time in timestamp that extends an order.
*/
function setTimeCredit(uint256 newTimeCredit_) external onlyOwner {
require(newTimeCredit_ > 0, "Invalid time");
creditTime = newTimeCredit_;
}
/**
* @notice Set the link credit price.
* @param _creditPrice link credit price.
*/
function setCreditPrice(uint256 _creditPrice) external onlyOwner {
require(_creditPrice != 0, "Zero fee");
creditPrice = _creditPrice;
}
function updateRouter(address _router) external onlyOwner {
nineInchRouter = INineInchRouter02(_router);
}
function updateKeeper(address _keeper) external onlyOwner {
keeper = _keeper;
}
/**
* @notice Functions for pause and unpause the contract.
*/
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
}
@openzeppelin/contracts/security/Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
@openzeppelin/contracts/utils/math/SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
@openzeppelin/contracts/security/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
@openzeppelin/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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);
}
@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
@openzeppelin/contracts/utils/math/SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
@openzeppelin/contracts/utils/structs/EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
contracts/swap/interfaces/INineInchRouter01.sol
// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.19;
interface INineInchRouter01 {
function factory() external view returns (address);
function WETH() external view returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
)
external
payable
returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable returns (uint[] memory amounts);
function swapTokensForExactETH(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactTokensForETH(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapETHForExactTokens(
uint amountOut,
address[] calldata path,
address to,
uint deadline
) external payable returns (uint[] memory amounts);
function quote(
uint amountA,
uint reserveA,
uint reserveB
) external pure returns (uint amountB);
function getAmountOut(
uint amountIn,
uint reserveIn,
uint reserveOut
) external pure returns (uint amountOut);
function getAmountIn(
uint amountOut,
uint reserveIn,
uint reserveOut
) external pure returns (uint amountIn);
function getAmountsOut(
uint amountIn,
address[] calldata path
) external view returns (uint[] memory amounts);
function getAmountsIn(
uint amountOut,
address[] calldata path
) external view returns (uint[] memory amounts);
}
contracts/swap/interfaces/INineInchRouter02.sol
// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.19;
import "./INineInchRouter01.sol";
interface INineInchRouter02 is INineInchRouter01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":999999,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"router","internalType":"address"},{"type":"address","name":"_keeper","internalType":"address"},{"type":"address","name":"_creditToken","internalType":"address"}]},{"type":"event","name":"BoughtCredit","inputs":[{"type":"address","name":"wallet","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OrderCancelled","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"OrderCreated","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true},{"type":"uint256","name":"currentPrice","internalType":"uint256","indexed":false},{"type":"uint256","name":"targetPrice","internalType":"uint256","indexed":false},{"type":"uint256","name":"amountIn","internalType":"uint256","indexed":false},{"type":"address","name":"tokenIn","internalType":"address","indexed":false},{"type":"address","name":"tokenOut","internalType":"address","indexed":false},{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint16","name":"slippage","internalType":"uint16","indexed":false},{"type":"uint256","name":"deadline","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OrderExpired","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"OrderFailed","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"OrderFilled","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true},{"type":"uint256","name":"executionPrice","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"TransferCredit","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelOrder","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"},{"type":"bytes","name":"","internalType":"bytes"}],"name":"checkUpkeep","inputs":[{"type":"bytes","name":"checkData","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"createOrder","inputs":[{"type":"uint256","name":"targetPrice_","internalType":"uint256"},{"type":"uint256","name":"amountIn_","internalType":"uint256"},{"type":"address[]","name":"path_","internalType":"address[]"},{"type":"uint16","name":"slippage_","internalType":"uint16"},{"type":"uint256","name":"credits_","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"creditPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"creditPriceIn9Inch","inputs":[{"type":"uint256","name":"numCredits","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"creditTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"credits","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"forceCancelOrder","inputs":[{"type":"bytes32","name":"orderId_","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"start","internalType":"uint256"},{"type":"uint256","name":"end","internalType":"uint256"}],"name":"getBatch","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct NineInchSpotLimit.Order","components":[{"type":"uint256","name":"targetPrice","internalType":"uint256"},{"type":"uint256","name":"amountIn","internalType":"uint256"},{"type":"address[]","name":"path","internalType":"address[]"},{"type":"address","name":"user","internalType":"address"},{"type":"uint16","name":"slippage","internalType":"uint16"},{"type":"uint256","name":"deadline","internalType":"uint256"}]}],"name":"getOrder","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getOrderAt","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPrice","inputs":[{"type":"uint256","name":"amountIn","internalType":"uint256"},{"type":"address[]","name":"path","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"keeper","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"performUpkeep","inputs":[{"type":"bytes","name":"performData","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"returnCredit","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCreditPrice","inputs":[{"type":"uint256","name":"_creditPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setReturnCredit","inputs":[{"type":"bool","name":"return_","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTimeCredit","inputs":[{"type":"uint256","name":"newTimeCredit_","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalOrders","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateKeeper","inputs":[{"type":"address","name":"_keeper","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateRouter","inputs":[{"type":"address","name":"_router","internalType":"address"}]}]
Contract Creation Code
0x60a06040523480156200001157600080fd5b5060405162004b1d38038062004b1d833981016040819052620000349162000124565b60016000819055805460ff191690556200004e33620000ad565b600280546001600160a01b0319166001600160a01b03948516179055600580546702c68af0bb14000060035562093a806004556001600160a81b0319166101009385169390930260ff191692909217600117909155166080526200016e565b600180546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516001600160a01b03811681146200011f57600080fd5b919050565b6000806000606084860312156200013a57600080fd5b620001458462000107565b9250620001556020850162000107565b9150620001656040850162000107565b90509250925092565b608051614977620001a660003960008181611e9c01528181611f890152818161212d015281816121f30152612ad901526149776000f3fe6080604052600436106101ac5760003560e01c806395048d46116100ec578063ca6358cd1161008a578063ec57dd5911610064578063ec57dd59146104d6578063f2fde38b146104f6578063fab6d6d014610516578063fe5ff4681461053657600080fd5b8063ca6358cd14610486578063cb59e5c01461049c578063ebf63c1b146104b657600080fd5b8063ad17a0b3116100c6578063ad17a0b31461041d578063adfd43541461043d578063ae182dcd14610453578063c851cc321461046657600080fd5b806395048d46146103ab57806397790217146103cb578063aced1661146103eb57600080fd5b80635c975abb1161015957806373a423d01161013357806373a423d0146103055780637489ec23146103255780638456cb59146103455780638da5cb5b1461035a57600080fd5b80635c975abb1461029e5780636e04ff0d146102c2578063715018a6146102f057600080fd5b80633f4ba83a1161018a5780633f4ba83a1461023a5780634585e33b146102515780635778472a1461027157600080fd5b80630c0fa81a146101b15780631d834409146101ed5780633b1fee6c14610210575b600080fd5b3480156101bd57600080fd5b506101d16101cc366004614141565b610563565b6040805192151583526020830191909152015b60405180910390f35b3480156101f957600080fd5b50610202610661565b6040519081526020016101e4565b34801561021c57600080fd5b50610225610672565b604080519283526020830191909152016101e4565b34801561024657600080fd5b5061024f610778565b005b34801561025d57600080fd5b5061024f61026c3660046141ec565b61078a565b34801561027d57600080fd5b5061029161028c36600461425e565b610d3a565b6040516101e49190614277565b3480156102aa57600080fd5b5060015460ff165b60405190151581526020016101e4565b3480156102ce57600080fd5b506102e26102dd3660046141ec565b610ee3565b6040516101e49291906143a4565b3480156102fc57600080fd5b5061024f6110e6565b34801561031157600080fd5b5061020261032036600461425e565b6110f8565b34801561033157600080fd5b5061024f61034036600461425e565b61110b565b34801561035157600080fd5b5061024f6115f1565b34801561036657600080fd5b50600154610100900473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e4565b3480156103b757600080fd5b5061024f6103c636600461425e565b611601565b3480156103d757600080fd5b5061024f6103e63660046143bf565b611a3a565b3480156103f757600080fd5b5060055461038690610100900473ffffffffffffffffffffffffffffffffffffffff1681565b34801561042957600080fd5b5061024f61043836600461425e565b611a8e565b34801561044957600080fd5b5061020260045481565b61024f6104613660046143f3565b611b05565b34801561047257600080fd5b5061024f6104813660046143bf565b612a19565b34801561049257600080fd5b5061020260035481565b3480156104a857600080fd5b506005546102b29060ff1681565b3480156104c257600080fd5b506102026104d136600461425e565b612a68565b3480156104e257600080fd5b5061024f6104f13660046144a3565b612bcb565b34801561050257600080fd5b5061024f6105113660046143bf565b612c04565b34801561052257600080fd5b5061024f61053136600461425e565b612cb8565b34801561054257600080fd5b506102026105513660046143bf565b60096020526000908152604090205481565b6002546040517fd06ca61f000000000000000000000000000000000000000000000000000000008152600091829173ffffffffffffffffffffffffffffffffffffffff9091169063d06ca61f906105c09087908790600401614511565b600060405180830381865afa92505050801561061c57506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610619919081019061452a565b60015b61062b5750600090508061065a565b6001816001865161063c91906145df565b8151811061064c5761064c6145f2565b602002602001015192509250505b9250929050565b600061066d6007612d2f565b905090565b60008061067f6007612d2f565b1561076f5760008061068f612d39565b909250905060006106a143600a612d95565b905060006106ba6106b384600a614741565b8390612d95565b905060006106d36106cc85600a614741565b8390612da8565b905060006106e18483612db4565b905080156106ef57806106f2565b60015b90505b8581111561070e5761070786826145df565b90506106f5565b60006107266064610720846001612db4565b90612da8565b905060006107346007612d2f565b61073f846064612da8565b116107545761074f836064612da8565b61075e565b61075e6007612d2f565b919a91995090975050505050505050565b50600091829150565b610780612dc0565b610788612e47565b565b610792612ec4565b600554610100900473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610833576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f4f6e6c79204e6f64652041646d696e000000000000000000000000000000000060448201526064015b60405180910390fd5b60006108418284018461425e565b905061084e600782612f37565b6108b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7264657220646f6573206e6f74206578697374000000000000000000000000604482015260640161082a565b6000818152600660209081526040808320815160c0810183528154815260018201548185015260028201805484518187028101870186528181529295939486019383018282801561093b57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610910575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff8116602083015274010000000000000000000000000000000000000000900461ffff16604080830191909152600490920154606090910152810151805191925060009182906109ae576109ae6145f2565b60200260200101519050428260a0015111610c40576109cc83612f4f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5d919061474d565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610b67576000826060015173ffffffffffffffffffffffffffffffffffffffff16836020015160405160006040518083038185875af1925050503d8060008114610af1576040519150601f19603f3d011682016040523d82523d6000602084013e610af6565b606091505b5050905080610b61576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161082a565b50610c10565b606082015160208301516040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff92831660048201526024810191909152829182169063a9059cbb906044016020604051808303816000875af1158015610be9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0d919061476a565b50505b60405183907f2e775cae5028266ebbe90e46ca5ce1b333eb3c28eef104c52203add626c1ada890600090a2610d29565b600080610c5584602001518560400151610563565b90925090506001821515148015610c6d575083518110155b610cd3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f546172676574206e6f7420726561636865640000000000000000000000000000604482015260640161082a565b6000610d01612710610cfb8760800151612710610cf09190614787565b859061ffff16612da8565b90612d95565b9050610d0c86612f4f565b610d258686602001518760400151886060015185612fb7565b5050505b505050610d366001600055565b5050565b610d8d6040518060c00160405280600081526020016000815260200160608152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600061ffff168152602001600081525090565b610d98600783612f37565b610dfe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f517565727920666f72206e6f6e6578697374656e74206f726465720000000000604482015260640161082a565b600082815260066020908152604091829020825160c0810184528154815260018201548184015260028201805485518186028101860187528181529295939493860193830182828015610e8757602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610e5c575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff8116602083015274010000000000000000000000000000000000000000900461ffff16604082015260049091015460609091015292915050565b60006060600080610ef2610672565b9092509050815b8181101561109b576000610f0e60078361341d565b90506000600660008381526020019081526020016000206040518060c0016040529081600082015481526020016001820154815260200160028201805480602002602001604051908101604052809291908181526020018280548015610faa57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610f7f575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff81166020808401919091527401000000000000000000000000000000000000000090910461ffff1660408084019190915260049093015460609092019190915282015190820151919250600091829161102491610563565b9092509050600182151514801561103c575082518110155b8061104b5750428360a0015111155b156110845760018460405160200161106591815260200190565b604051602081830303815290604052985098505050505050505061065a565b505050508080611093906147a2565b915050610ef9565b506000868681818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959c929b50919950505050505050505050565b6110ee612dc0565b6107886000613429565b600061110560078361341d565b92915050565b611113612ec4565b61111e600782612f37565b611184576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7264657220646f6573206e6f74206578697374000000000000000000000000604482015260640161082a565b6000818152600660209081526040808320815160c0810183528154815260018201548185015260028201805484518187028101870186528181529295939486019383018282801561120b57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111e0575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff8116602083015274010000000000000000000000000000000000000000900461ffff16604082015260049091015460609091015290503373ffffffffffffffffffffffffffffffffffffffff16816060015173ffffffffffffffffffffffffffffffffffffffff16146112fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e76616c696420616363657373000000000000000000000000000000000000604482015260640161082a565b60008160400151600081518110611315576113156145f2565b6020026020010151905061132883612f4f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611395573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b9919061474d565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036114c3576000826060015173ffffffffffffffffffffffffffffffffffffffff16836020015160405160006040518083038185875af1925050503d806000811461144d576040519150601f19603f3d011682016040523d82523d6000602084013e611452565b606091505b50509050806114bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161082a565b5061156c565b606082015160208301516040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff92831660048201526024810191909152829182169063a9059cbb906044016020604051808303816000875af1158015611545573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611569919061476a565b50505b60055460ff16156115b757606082015173ffffffffffffffffffffffffffffffffffffffff1660009081526009602052604081208054600192906115b19084906147da565b90915550505b60405183907f5152abf959f6564662358c2e52b702259b78bac5ee7842a0f01937e670efcc7d90600090a250506115ee6001600055565b50565b6115f9612dc0565b6107886134a7565b611609612dc0565b611614600782612f37565b61167a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7264657220646f6573206e6f74206578697374000000000000000000000000604482015260640161082a565b6000818152600660209081526040808320815160c0810183528154815260018201548185015260028201805484518187028101870186528181529295939486019383018282801561170157602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116116d6575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff8116602083015274010000000000000000000000000000000000000000900461ffff1660408083019190915260049092015460609091015281015180519192506000918290611774576117746145f2565b6020026020010151905061178783612f4f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611818919061474d565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611922576000826060015173ffffffffffffffffffffffffffffffffffffffff16836020015160405160006040518083038185875af1925050503d80600081146118ac576040519150601f19603f3d011682016040523d82523d6000602084013e6118b1565b606091505b505090508061191c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161082a565b506119cb565b606082015160208301516040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff92831660048201526024810191909152829182169063a9059cbb906044016020604051808303816000875af11580156119a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c8919061476a565b50505b606082015173ffffffffffffffffffffffffffffffffffffffff166000908152600960205260408120805460019290611a059084906147da565b909155505060405183907f5152abf959f6564662358c2e52b702259b78bac5ee7842a0f01937e670efcc7d90600090a2505050565b611a42612dc0565b6005805473ffffffffffffffffffffffffffffffffffffffff909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b611a96612dc0565b80600003611b00576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f5a65726f20666565000000000000000000000000000000000000000000000000604482015260640161082a565b600355565b611b0d613500565b611b15612ec4565b6127108261ffff161115611b85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f536c697070616765206f7574206f6620626f756e640000000000000000000000604482015260640161082a565b84600003611bef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f5a65726f20616d6f756e7420696e000000000000000000000000000000000000604482015260640161082a565b600086118015611bff5750600081115b611c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f5a65726f20707269636500000000000000000000000000000000000000000000604482015260640161082a565b6002831015611cd0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f496e76616c696420706174680000000000000000000000000000000000000000604482015260640161082a565b8585828686600082828281611ce757611ce76145f2565b9050602002016020810190611cfc91906143bf565b905060008383611d0d60018d6145df565b818110611d1c57611d1c6145f2565b9050602002016020810190611d3191906143bf565b9050883373ffffffffffffffffffffffffffffffffffffffff841615801590611d6f575073ffffffffffffffffffffffffffffffffffffffff831615155b8015611da757508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b611e0d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e76616c696420746f6b656e73000000000000000000000000000000000000604482015260640161082a565b336000908152600960205260409020548711156123265733600090815260096020526040812054611e3f908990612db4565b90506000611e4c82612a68565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015230602483015291925082917f0000000000000000000000000000000000000000000000000000000000000000169063dd62ed3e90604401602060405180830381865afa158015611ee3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0791906147ed565b1015611f6f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f496e73756666696369656e742039696e636820616c6c6f77616e636500000000604482015260640161082a565b611fb173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001684308461356d565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561201e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612042919061474d565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16036120de57893410156120de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e73756666696369656e74206574682076616c756520666f72207377617000604482015260640161082a565b6002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390527f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303816000875af1158015612178573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219c919061476a565b50600254604080517fad5c4648000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9092169163791ac947918491600091612269917f000000000000000000000000000000000000000000000000000000000000000091879163ad5c4648916004808201926020929091908290030181865afa158015612240573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612264919061474d565b61364f565b600554610100900473ffffffffffffffffffffffffffffffffffffffff166122934261012c613703565b6040518663ffffffff1660e01b81526004016122b3959493929190614806565b600060405180830381600087803b1580156122cd57600080fd5b505af11580156122e1573d6000803e3d6000fd5b5050505081600960006122f13390565b73ffffffffffffffffffffffffffffffffffffffff168152602081019190915260400160002080549091019055506124529050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b7919061474d565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361245257873414612452576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e73756666696369656e74206574682076616c756520666f72207377617000604482015260640161082a565b6000806124928a89898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061056392505050565b915091508180156124a257508a81105b612508576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c696420746172676574207072696365000000000000000000000000604482015260640161082a565b612510613fa2565b81815260208082018d905260408083018d9052805191820184905281018d905260608082018d905288811b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000908116608084015288821b811660948401529086901b1660a882015260f086901b7fffff0000000000000000000000000000000000000000000000000000000000001660bc8201524360be82015260009060de01604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012090506125f3600782612f37565b1561265a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4f72646572206964206d697374616b6500000000000000000000000000000000604482015260640161082a565b33600090815260096020526040812080548d9003905560045461268890612681908e612da8565b4290613703565b90506126a882846001602002015185600260200201518e8e8b8d8861370f565b6002546040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91821660248201528a9182169063dd62ed3e90604401602060405180830381865afa15801561271f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061274391906147ed565b600003612808576002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248201529082169063095ea7b3906044016020604051808303816000875af11580156127e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612806919061476a565b505b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612875573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612899919061474d565b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff16146129735760408085015190517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff89811660048301523060248301526044820192909252908216906323b872dd906064016020604051808303816000875af115801561294d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612971919061476a565b505b835160208086015160408088015181519485529284019190915282015273ffffffffffffffffffffffffffffffffffffffff8b811660608301528a8116608083015261ffff8a1660a083015260c0820184905288169084907f99657a932d9c70d2828b20283c6695ec3f56fab0cba81f52b3e59c7cb67b49ac9060e00160405180910390a3505050505050505050505050505050612a116001600055565b505050505050565b612a21612dc0565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600080612a8083600354612da890919063ffffffff16565b600254604080517fad5c4648000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691631f00ca74918591612b25917f000000000000000000000000000000000000000000000000000000000000000091869163ad5c46489160048083019260209291908290030181865afa158015612240573d6000803e3d6000fd5b6040518363ffffffff1660e01b8152600401612b42929190614511565b600060405180830381865afa158015612b5f573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052612ba5919081019061452a565b600081518110612bb757612bb76145f2565b602002602001015190508092505050919050565b612bd3612dc0565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b612c0c612dc0565b73ffffffffffffffffffffffffffffffffffffffff8116612caf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161082a565b6115ee81613429565b612cc0612dc0565b60008111612d2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f496e76616c69642074696d650000000000000000000000000000000000000000604482015260640161082a565b600455565b6000611105825490565b6000806000612d4d6064610cfb6007612d2f565b90506000612d5c826064612da8565b9050612d686007612d2f565b8110612d745781612d7f565b612d7f826001613703565b915081612d8b8361385a565b9350935050509091565b6000612da1828461484f565b9392505050565b6000612da1828461488a565b6000612da182846145df565b60015473ffffffffffffffffffffffffffffffffffffffff610100909104163314610788576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161082a565b612e4f613883565b600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b600260005403612f30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161082a565b6002600055565b60008181526001830160205260408120541515612da1565b612f5a6007826138ef565b5060008181526006602052604081208181556001810182905590612f816002830182613fc0565b506003810180547fffffffffffffffffffff00000000000000000000000000000000000000000000169055600060049091015550565b600254604080517fad5c4648000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163ad5c46489160048083019260209291908290030181865afa158015613027573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304b919061474d565b9050600084600081518110613062576130626145f2565b602002602001015190506000856001875161307d91906145df565b8151811061308d5761308d6145f2565b602002602001015190508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361321a5760025473ffffffffffffffffffffffffffffffffffffffff16637ff36ab5888689896130f84261012c613703565b6040518663ffffffff1660e01b815260040161311794939291906148a1565b60006040518083038185885af19350505050801561317557506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052613172919081019061452a565b60015b6131b4576131848783876138fb565b60405188907fe1bf2a28c083b93b502e4140fe14e357c3d973a7ec3d8517b6022a70bfd3562690600090a2613413565b887ffec331350fce78ba658e082a71da20ac9f8d798a99b3c79681c8440cbfe77e078260018a516131e591906145df565b815181106131f5576131f56145f2565b602002602001015160405161320c91815260200190565b60405180910390a250613413565b8273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036132f65760025473ffffffffffffffffffffffffffffffffffffffff166318cbafe58886898961327b4261012c613703565b6040518663ffffffff1660e01b815260040161329b959493929190614806565b6000604051808303816000875af192505050801561317557506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052613172919081019061452a565b60025473ffffffffffffffffffffffffffffffffffffffff166338ed1739888689896133244261012c613703565b6040518663ffffffff1660e01b8152600401613344959493929190614806565b6000604051808303816000875af19250505080156133a257506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261339f919081019061452a565b60015b6133b1576131848783876138fb565b887ffec331350fce78ba658e082a71da20ac9f8d798a99b3c79681c8440cbfe77e078260018a516133e291906145df565b815181106133f2576133f26145f2565b602002602001015160405161340991815260200190565b60405180910390a2505b5050505050505050565b6000612da18383613aaf565b6001805473ffffffffffffffffffffffffffffffffffffffff8381166101008181027fffffffffffffffffffffff0000000000000000000000000000000000000000ff85161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6134af613500565b600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833612e9a565b60015460ff1615610788576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161082a565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526136499085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613ad9565b50505050565b604080516002808252606080830184529260009291906020830190803683370190505090508381600081518110613688576136886145f2565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505082816001815181106136d6576136d66145f2565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152905092915050565b6000612da182846147da565b60006040518060c0016040528089815260200188815260200187878080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525073ffffffffffffffffffffffffffffffffffffffff8616602082015261ffff85166040820152606001839052905061379760078a613be8565b50600089815260066020908152604091829020835181558184015160018201559183015180518493926137d1926002850192910190613fde565b506060820151600382018054608085015161ffff1674010000000000000000000000000000000000000000027fffffffffffffffffffff0000000000000000000000000000000000000000000090911673ffffffffffffffffffffffffffffffffffffffff9093169290921791909117905560a090910151600490910155505050505050505050565b6000805b82156111055761386f600a8461484f565b92508061387b816147a2565b91505061385e565b60015460ff16610788576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161082a565b6000612da18383613bf4565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015613968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061398c919061474d565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613a885760008173ffffffffffffffffffffffffffffffffffffffff168460405160006040518083038185875af1925050503d8060008114613a18576040519150601f19603f3d011682016040523d82523d6000602084013e613a1d565b606091505b5050905080613649576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161082a565b8161364973ffffffffffffffffffffffffffffffffffffffff82168386613cee565b505050565b6000826000018281548110613ac657613ac66145f2565b9060005260206000200154905092915050565b6000613b3b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16613d449092919063ffffffff16565b9050805160001480613b5c575080806020019051810190613b5c919061476a565b613aaa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161082a565b6000612da18383613d5b565b60008181526001830160205260408120548015613cdd576000613c186001836145df565b8554909150600090613c2c906001906145df565b9050818114613c91576000866000018281548110613c4c57613c4c6145f2565b9060005260206000200154905080876000018481548110613c6f57613c6f6145f2565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613ca257613ca26148e3565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611105565b6000915050611105565b5092915050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052613aaa9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016135c7565b6060613d538484600085613daa565b949350505050565b6000818152600183016020526040812054613da257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611105565b506000611105565b606082471015613e3c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161082a565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051613e659190614912565b60006040518083038185875af1925050503d8060008114613ea2576040519150601f19603f3d011682016040523d82523d6000602084013e613ea7565b606091505b5091509150613eb887838387613ec3565b979650505050505050565b60608315613f59578251600003613f525773ffffffffffffffffffffffffffffffffffffffff85163b613f52576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161082a565b5081613d53565b613d538383815115613f6e5781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a919061492e565b60405180606001604052806003906020820280368337509192915050565b50805460008255906000526020600020908101906115ee9190614068565b828054828255906000526020600020908101928215614058579160200282015b8281111561405857825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909116178255602090920191600190910190613ffe565b50614064929150614068565b5090565b5b808211156140645760008155600101614069565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156140f3576140f361407d565b604052919050565b600067ffffffffffffffff8211156141155761411561407d565b5060051b60200190565b73ffffffffffffffffffffffffffffffffffffffff811681146115ee57600080fd5b6000806040838503121561415457600080fd5b8235915060208084013567ffffffffffffffff81111561417357600080fd5b8401601f8101861361418457600080fd5b8035614197614192826140fb565b6140ac565b81815260059190911b820183019083810190888311156141b657600080fd5b928401925b828410156141dd5783356141ce8161411f565b825292840192908401906141bb565b80955050505050509250929050565b600080602083850312156141ff57600080fd5b823567ffffffffffffffff8082111561421757600080fd5b818501915085601f83011261422b57600080fd5b81358181111561423a57600080fd5b86602082850101111561424c57600080fd5b60209290920196919550909350505050565b60006020828403121561427057600080fd5b5035919050565b6000602080835260e08301845182850152818501516040850152604085015160c06060860152818151808452610100870191508483019350600092505b808310156142ea57835173ffffffffffffffffffffffffffffffffffffffff1682529284019260019290920191908401906142b4565b50606087015173ffffffffffffffffffffffffffffffffffffffff811660808801529350608087015161ffff811660a0880152935060a087015160c08701528094505050505092915050565b60005b83811015614351578181015183820152602001614339565b50506000910152565b60008151808452614372816020860160208601614336565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8215158152604060208201526000613d53604083018461435a565b6000602082840312156143d157600080fd5b8135612da18161411f565b803561ffff811681146143ee57600080fd5b919050565b60008060008060008060a0878903121561440c57600080fd5b8635955060208701359450604087013567ffffffffffffffff8082111561443257600080fd5b818901915089601f83011261444657600080fd5b81358181111561445557600080fd5b8a60208260051b850101111561446a57600080fd5b602083019650809550505050614482606088016143dc565b9150608087013590509295509295509295565b80151581146115ee57600080fd5b6000602082840312156144b557600080fd5b8135612da181614495565b600081518084526020808501945080840160005b8381101561450657815173ffffffffffffffffffffffffffffffffffffffff16875295820195908201906001016144d4565b509495945050505050565b828152604060208201526000613d5360408301846144c0565b6000602080838503121561453d57600080fd5b825167ffffffffffffffff81111561455457600080fd5b8301601f8101851361456557600080fd5b8051614573614192826140fb565b81815260059190911b8201830190838101908783111561459257600080fd5b928401925b82841015613eb857835182529284019290840190614597565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115611105576111056145b0565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600181815b8085111561467a57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115614660576146606145b0565b8085161561466d57918102915b93841c9390800290614626565b509250929050565b60008261469157506001611105565b8161469e57506000611105565b81600181146146b457600281146146be576146da565b6001915050611105565b60ff8411156146cf576146cf6145b0565b50506001821b611105565b5060208310610133831016604e8410600b84101617156146fd575081810a611105565b6147078383614621565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115614739576147396145b0565b029392505050565b6000612da18383614682565b60006020828403121561475f57600080fd5b8151612da18161411f565b60006020828403121561477c57600080fd5b8151612da181614495565b61ffff828116828216039080821115613ce757613ce76145b0565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036147d3576147d36145b0565b5060010190565b80820180821115611105576111056145b0565b6000602082840312156147ff57600080fd5b5051919050565b85815284602082015260a06040820152600061482560a08301866144c0565b73ffffffffffffffffffffffffffffffffffffffff94909416606083015250608001529392505050565b600082614885577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b8082028115828204841417611105576111056145b0565b8481526080602082015260006148ba60808301866144c0565b73ffffffffffffffffffffffffffffffffffffffff949094166040830152506060015292915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60008251614924818460208701614336565b9190910192915050565b602081526000612da1602083018461435a56fea264697066735822122090f6a8f0034fc88239df8191f7c4a0d7bd2fb97106c4507b93a00800a1ad418464736f6c63430008130033000000000000000000000000172fa14891c971751ae324d0638cccd4aa5f360600000000000000000000000086efbd0b6736bed994962f9797049422a3a8e8ad0000000000000000000000008202d285f1ec08fb7787ec5f09f3da235f2a4325
Deployed ByteCode
0x6080604052600436106101ac5760003560e01c806395048d46116100ec578063ca6358cd1161008a578063ec57dd5911610064578063ec57dd59146104d6578063f2fde38b146104f6578063fab6d6d014610516578063fe5ff4681461053657600080fd5b8063ca6358cd14610486578063cb59e5c01461049c578063ebf63c1b146104b657600080fd5b8063ad17a0b3116100c6578063ad17a0b31461041d578063adfd43541461043d578063ae182dcd14610453578063c851cc321461046657600080fd5b806395048d46146103ab57806397790217146103cb578063aced1661146103eb57600080fd5b80635c975abb1161015957806373a423d01161013357806373a423d0146103055780637489ec23146103255780638456cb59146103455780638da5cb5b1461035a57600080fd5b80635c975abb1461029e5780636e04ff0d146102c2578063715018a6146102f057600080fd5b80633f4ba83a1161018a5780633f4ba83a1461023a5780634585e33b146102515780635778472a1461027157600080fd5b80630c0fa81a146101b15780631d834409146101ed5780633b1fee6c14610210575b600080fd5b3480156101bd57600080fd5b506101d16101cc366004614141565b610563565b6040805192151583526020830191909152015b60405180910390f35b3480156101f957600080fd5b50610202610661565b6040519081526020016101e4565b34801561021c57600080fd5b50610225610672565b604080519283526020830191909152016101e4565b34801561024657600080fd5b5061024f610778565b005b34801561025d57600080fd5b5061024f61026c3660046141ec565b61078a565b34801561027d57600080fd5b5061029161028c36600461425e565b610d3a565b6040516101e49190614277565b3480156102aa57600080fd5b5060015460ff165b60405190151581526020016101e4565b3480156102ce57600080fd5b506102e26102dd3660046141ec565b610ee3565b6040516101e49291906143a4565b3480156102fc57600080fd5b5061024f6110e6565b34801561031157600080fd5b5061020261032036600461425e565b6110f8565b34801561033157600080fd5b5061024f61034036600461425e565b61110b565b34801561035157600080fd5b5061024f6115f1565b34801561036657600080fd5b50600154610100900473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e4565b3480156103b757600080fd5b5061024f6103c636600461425e565b611601565b3480156103d757600080fd5b5061024f6103e63660046143bf565b611a3a565b3480156103f757600080fd5b5060055461038690610100900473ffffffffffffffffffffffffffffffffffffffff1681565b34801561042957600080fd5b5061024f61043836600461425e565b611a8e565b34801561044957600080fd5b5061020260045481565b61024f6104613660046143f3565b611b05565b34801561047257600080fd5b5061024f6104813660046143bf565b612a19565b34801561049257600080fd5b5061020260035481565b3480156104a857600080fd5b506005546102b29060ff1681565b3480156104c257600080fd5b506102026104d136600461425e565b612a68565b3480156104e257600080fd5b5061024f6104f13660046144a3565b612bcb565b34801561050257600080fd5b5061024f6105113660046143bf565b612c04565b34801561052257600080fd5b5061024f61053136600461425e565b612cb8565b34801561054257600080fd5b506102026105513660046143bf565b60096020526000908152604090205481565b6002546040517fd06ca61f000000000000000000000000000000000000000000000000000000008152600091829173ffffffffffffffffffffffffffffffffffffffff9091169063d06ca61f906105c09087908790600401614511565b600060405180830381865afa92505050801561061c57506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610619919081019061452a565b60015b61062b5750600090508061065a565b6001816001865161063c91906145df565b8151811061064c5761064c6145f2565b602002602001015192509250505b9250929050565b600061066d6007612d2f565b905090565b60008061067f6007612d2f565b1561076f5760008061068f612d39565b909250905060006106a143600a612d95565b905060006106ba6106b384600a614741565b8390612d95565b905060006106d36106cc85600a614741565b8390612da8565b905060006106e18483612db4565b905080156106ef57806106f2565b60015b90505b8581111561070e5761070786826145df565b90506106f5565b60006107266064610720846001612db4565b90612da8565b905060006107346007612d2f565b61073f846064612da8565b116107545761074f836064612da8565b61075e565b61075e6007612d2f565b919a91995090975050505050505050565b50600091829150565b610780612dc0565b610788612e47565b565b610792612ec4565b600554610100900473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610833576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f4f6e6c79204e6f64652041646d696e000000000000000000000000000000000060448201526064015b60405180910390fd5b60006108418284018461425e565b905061084e600782612f37565b6108b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7264657220646f6573206e6f74206578697374000000000000000000000000604482015260640161082a565b6000818152600660209081526040808320815160c0810183528154815260018201548185015260028201805484518187028101870186528181529295939486019383018282801561093b57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610910575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff8116602083015274010000000000000000000000000000000000000000900461ffff16604080830191909152600490920154606090910152810151805191925060009182906109ae576109ae6145f2565b60200260200101519050428260a0015111610c40576109cc83612f4f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5d919061474d565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610b67576000826060015173ffffffffffffffffffffffffffffffffffffffff16836020015160405160006040518083038185875af1925050503d8060008114610af1576040519150601f19603f3d011682016040523d82523d6000602084013e610af6565b606091505b5050905080610b61576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161082a565b50610c10565b606082015160208301516040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff92831660048201526024810191909152829182169063a9059cbb906044016020604051808303816000875af1158015610be9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0d919061476a565b50505b60405183907f2e775cae5028266ebbe90e46ca5ce1b333eb3c28eef104c52203add626c1ada890600090a2610d29565b600080610c5584602001518560400151610563565b90925090506001821515148015610c6d575083518110155b610cd3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f546172676574206e6f7420726561636865640000000000000000000000000000604482015260640161082a565b6000610d01612710610cfb8760800151612710610cf09190614787565b859061ffff16612da8565b90612d95565b9050610d0c86612f4f565b610d258686602001518760400151886060015185612fb7565b5050505b505050610d366001600055565b5050565b610d8d6040518060c00160405280600081526020016000815260200160608152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600061ffff168152602001600081525090565b610d98600783612f37565b610dfe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f517565727920666f72206e6f6e6578697374656e74206f726465720000000000604482015260640161082a565b600082815260066020908152604091829020825160c0810184528154815260018201548184015260028201805485518186028101860187528181529295939493860193830182828015610e8757602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610e5c575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff8116602083015274010000000000000000000000000000000000000000900461ffff16604082015260049091015460609091015292915050565b60006060600080610ef2610672565b9092509050815b8181101561109b576000610f0e60078361341d565b90506000600660008381526020019081526020016000206040518060c0016040529081600082015481526020016001820154815260200160028201805480602002602001604051908101604052809291908181526020018280548015610faa57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610f7f575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff81166020808401919091527401000000000000000000000000000000000000000090910461ffff1660408084019190915260049093015460609092019190915282015190820151919250600091829161102491610563565b9092509050600182151514801561103c575082518110155b8061104b5750428360a0015111155b156110845760018460405160200161106591815260200190565b604051602081830303815290604052985098505050505050505061065a565b505050508080611093906147a2565b915050610ef9565b506000868681818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959c929b50919950505050505050505050565b6110ee612dc0565b6107886000613429565b600061110560078361341d565b92915050565b611113612ec4565b61111e600782612f37565b611184576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7264657220646f6573206e6f74206578697374000000000000000000000000604482015260640161082a565b6000818152600660209081526040808320815160c0810183528154815260018201548185015260028201805484518187028101870186528181529295939486019383018282801561120b57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111e0575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff8116602083015274010000000000000000000000000000000000000000900461ffff16604082015260049091015460609091015290503373ffffffffffffffffffffffffffffffffffffffff16816060015173ffffffffffffffffffffffffffffffffffffffff16146112fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e76616c696420616363657373000000000000000000000000000000000000604482015260640161082a565b60008160400151600081518110611315576113156145f2565b6020026020010151905061132883612f4f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611395573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b9919061474d565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036114c3576000826060015173ffffffffffffffffffffffffffffffffffffffff16836020015160405160006040518083038185875af1925050503d806000811461144d576040519150601f19603f3d011682016040523d82523d6000602084013e611452565b606091505b50509050806114bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161082a565b5061156c565b606082015160208301516040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff92831660048201526024810191909152829182169063a9059cbb906044016020604051808303816000875af1158015611545573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611569919061476a565b50505b60055460ff16156115b757606082015173ffffffffffffffffffffffffffffffffffffffff1660009081526009602052604081208054600192906115b19084906147da565b90915550505b60405183907f5152abf959f6564662358c2e52b702259b78bac5ee7842a0f01937e670efcc7d90600090a250506115ee6001600055565b50565b6115f9612dc0565b6107886134a7565b611609612dc0565b611614600782612f37565b61167a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7264657220646f6573206e6f74206578697374000000000000000000000000604482015260640161082a565b6000818152600660209081526040808320815160c0810183528154815260018201548185015260028201805484518187028101870186528181529295939486019383018282801561170157602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116116d6575b5050509183525050600382015473ffffffffffffffffffffffffffffffffffffffff8116602083015274010000000000000000000000000000000000000000900461ffff1660408083019190915260049092015460609091015281015180519192506000918290611774576117746145f2565b6020026020010151905061178783612f4f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611818919061474d565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611922576000826060015173ffffffffffffffffffffffffffffffffffffffff16836020015160405160006040518083038185875af1925050503d80600081146118ac576040519150601f19603f3d011682016040523d82523d6000602084013e6118b1565b606091505b505090508061191c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161082a565b506119cb565b606082015160208301516040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff92831660048201526024810191909152829182169063a9059cbb906044016020604051808303816000875af11580156119a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c8919061476a565b50505b606082015173ffffffffffffffffffffffffffffffffffffffff166000908152600960205260408120805460019290611a059084906147da565b909155505060405183907f5152abf959f6564662358c2e52b702259b78bac5ee7842a0f01937e670efcc7d90600090a2505050565b611a42612dc0565b6005805473ffffffffffffffffffffffffffffffffffffffff909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b611a96612dc0565b80600003611b00576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f5a65726f20666565000000000000000000000000000000000000000000000000604482015260640161082a565b600355565b611b0d613500565b611b15612ec4565b6127108261ffff161115611b85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f536c697070616765206f7574206f6620626f756e640000000000000000000000604482015260640161082a565b84600003611bef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f5a65726f20616d6f756e7420696e000000000000000000000000000000000000604482015260640161082a565b600086118015611bff5750600081115b611c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f5a65726f20707269636500000000000000000000000000000000000000000000604482015260640161082a565b6002831015611cd0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f496e76616c696420706174680000000000000000000000000000000000000000604482015260640161082a565b8585828686600082828281611ce757611ce76145f2565b9050602002016020810190611cfc91906143bf565b905060008383611d0d60018d6145df565b818110611d1c57611d1c6145f2565b9050602002016020810190611d3191906143bf565b9050883373ffffffffffffffffffffffffffffffffffffffff841615801590611d6f575073ffffffffffffffffffffffffffffffffffffffff831615155b8015611da757508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b611e0d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e76616c696420746f6b656e73000000000000000000000000000000000000604482015260640161082a565b336000908152600960205260409020548711156123265733600090815260096020526040812054611e3f908990612db4565b90506000611e4c82612a68565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015230602483015291925082917f0000000000000000000000008202d285f1ec08fb7787ec5f09f3da235f2a4325169063dd62ed3e90604401602060405180830381865afa158015611ee3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0791906147ed565b1015611f6f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f496e73756666696369656e742039696e636820616c6c6f77616e636500000000604482015260640161082a565b611fb173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000008202d285f1ec08fb7787ec5f09f3da235f2a43251684308461356d565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561201e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612042919061474d565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16036120de57893410156120de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e73756666696369656e74206574682076616c756520666f72207377617000604482015260640161082a565b6002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390527f0000000000000000000000008202d285f1ec08fb7787ec5f09f3da235f2a43259091169063095ea7b3906044016020604051808303816000875af1158015612178573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219c919061476a565b50600254604080517fad5c4648000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9092169163791ac947918491600091612269917f0000000000000000000000008202d285f1ec08fb7787ec5f09f3da235f2a432591879163ad5c4648916004808201926020929091908290030181865afa158015612240573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612264919061474d565b61364f565b600554610100900473ffffffffffffffffffffffffffffffffffffffff166122934261012c613703565b6040518663ffffffff1660e01b81526004016122b3959493929190614806565b600060405180830381600087803b1580156122cd57600080fd5b505af11580156122e1573d6000803e3d6000fd5b5050505081600960006122f13390565b73ffffffffffffffffffffffffffffffffffffffff168152602081019190915260400160002080549091019055506124529050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b7919061474d565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361245257873414612452576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e73756666696369656e74206574682076616c756520666f72207377617000604482015260640161082a565b6000806124928a89898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061056392505050565b915091508180156124a257508a81105b612508576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c696420746172676574207072696365000000000000000000000000604482015260640161082a565b612510613fa2565b81815260208082018d905260408083018d9052805191820184905281018d905260608082018d905288811b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000908116608084015288821b811660948401529086901b1660a882015260f086901b7fffff0000000000000000000000000000000000000000000000000000000000001660bc8201524360be82015260009060de01604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012090506125f3600782612f37565b1561265a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4f72646572206964206d697374616b6500000000000000000000000000000000604482015260640161082a565b33600090815260096020526040812080548d9003905560045461268890612681908e612da8565b4290613703565b90506126a882846001602002015185600260200201518e8e8b8d8861370f565b6002546040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91821660248201528a9182169063dd62ed3e90604401602060405180830381865afa15801561271f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061274391906147ed565b600003612808576002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248201529082169063095ea7b3906044016020604051808303816000875af11580156127e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612806919061476a565b505b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612875573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612899919061474d565b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff16146129735760408085015190517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff89811660048301523060248301526044820192909252908216906323b872dd906064016020604051808303816000875af115801561294d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612971919061476a565b505b835160208086015160408088015181519485529284019190915282015273ffffffffffffffffffffffffffffffffffffffff8b811660608301528a8116608083015261ffff8a1660a083015260c0820184905288169084907f99657a932d9c70d2828b20283c6695ec3f56fab0cba81f52b3e59c7cb67b49ac9060e00160405180910390a3505050505050505050505050505050612a116001600055565b505050505050565b612a21612dc0565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600080612a8083600354612da890919063ffffffff16565b600254604080517fad5c4648000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691631f00ca74918591612b25917f0000000000000000000000008202d285f1ec08fb7787ec5f09f3da235f2a432591869163ad5c46489160048083019260209291908290030181865afa158015612240573d6000803e3d6000fd5b6040518363ffffffff1660e01b8152600401612b42929190614511565b600060405180830381865afa158015612b5f573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052612ba5919081019061452a565b600081518110612bb757612bb76145f2565b602002602001015190508092505050919050565b612bd3612dc0565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b612c0c612dc0565b73ffffffffffffffffffffffffffffffffffffffff8116612caf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161082a565b6115ee81613429565b612cc0612dc0565b60008111612d2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f496e76616c69642074696d650000000000000000000000000000000000000000604482015260640161082a565b600455565b6000611105825490565b6000806000612d4d6064610cfb6007612d2f565b90506000612d5c826064612da8565b9050612d686007612d2f565b8110612d745781612d7f565b612d7f826001613703565b915081612d8b8361385a565b9350935050509091565b6000612da1828461484f565b9392505050565b6000612da1828461488a565b6000612da182846145df565b60015473ffffffffffffffffffffffffffffffffffffffff610100909104163314610788576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161082a565b612e4f613883565b600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b600260005403612f30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161082a565b6002600055565b60008181526001830160205260408120541515612da1565b612f5a6007826138ef565b5060008181526006602052604081208181556001810182905590612f816002830182613fc0565b506003810180547fffffffffffffffffffff00000000000000000000000000000000000000000000169055600060049091015550565b600254604080517fad5c4648000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163ad5c46489160048083019260209291908290030181865afa158015613027573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304b919061474d565b9050600084600081518110613062576130626145f2565b602002602001015190506000856001875161307d91906145df565b8151811061308d5761308d6145f2565b602002602001015190508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361321a5760025473ffffffffffffffffffffffffffffffffffffffff16637ff36ab5888689896130f84261012c613703565b6040518663ffffffff1660e01b815260040161311794939291906148a1565b60006040518083038185885af19350505050801561317557506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052613172919081019061452a565b60015b6131b4576131848783876138fb565b60405188907fe1bf2a28c083b93b502e4140fe14e357c3d973a7ec3d8517b6022a70bfd3562690600090a2613413565b887ffec331350fce78ba658e082a71da20ac9f8d798a99b3c79681c8440cbfe77e078260018a516131e591906145df565b815181106131f5576131f56145f2565b602002602001015160405161320c91815260200190565b60405180910390a250613413565b8273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036132f65760025473ffffffffffffffffffffffffffffffffffffffff166318cbafe58886898961327b4261012c613703565b6040518663ffffffff1660e01b815260040161329b959493929190614806565b6000604051808303816000875af192505050801561317557506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052613172919081019061452a565b60025473ffffffffffffffffffffffffffffffffffffffff166338ed1739888689896133244261012c613703565b6040518663ffffffff1660e01b8152600401613344959493929190614806565b6000604051808303816000875af19250505080156133a257506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261339f919081019061452a565b60015b6133b1576131848783876138fb565b887ffec331350fce78ba658e082a71da20ac9f8d798a99b3c79681c8440cbfe77e078260018a516133e291906145df565b815181106133f2576133f26145f2565b602002602001015160405161340991815260200190565b60405180910390a2505b5050505050505050565b6000612da18383613aaf565b6001805473ffffffffffffffffffffffffffffffffffffffff8381166101008181027fffffffffffffffffffffff0000000000000000000000000000000000000000ff85161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6134af613500565b600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833612e9a565b60015460ff1615610788576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161082a565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526136499085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613ad9565b50505050565b604080516002808252606080830184529260009291906020830190803683370190505090508381600081518110613688576136886145f2565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505082816001815181106136d6576136d66145f2565b73ffffffffffffffffffffffffffffffffffffffff90921660209283029190910190910152905092915050565b6000612da182846147da565b60006040518060c0016040528089815260200188815260200187878080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525073ffffffffffffffffffffffffffffffffffffffff8616602082015261ffff85166040820152606001839052905061379760078a613be8565b50600089815260066020908152604091829020835181558184015160018201559183015180518493926137d1926002850192910190613fde565b506060820151600382018054608085015161ffff1674010000000000000000000000000000000000000000027fffffffffffffffffffff0000000000000000000000000000000000000000000090911673ffffffffffffffffffffffffffffffffffffffff9093169290921791909117905560a090910151600490910155505050505050505050565b6000805b82156111055761386f600a8461484f565b92508061387b816147a2565b91505061385e565b60015460ff16610788576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161082a565b6000612da18383613bf4565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015613968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061398c919061474d565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613a885760008173ffffffffffffffffffffffffffffffffffffffff168460405160006040518083038185875af1925050503d8060008114613a18576040519150601f19603f3d011682016040523d82523d6000602084013e613a1d565b606091505b5050905080613649576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c65640000000000000000000000000000000000604482015260640161082a565b8161364973ffffffffffffffffffffffffffffffffffffffff82168386613cee565b505050565b6000826000018281548110613ac657613ac66145f2565b9060005260206000200154905092915050565b6000613b3b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16613d449092919063ffffffff16565b9050805160001480613b5c575080806020019051810190613b5c919061476a565b613aaa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161082a565b6000612da18383613d5b565b60008181526001830160205260408120548015613cdd576000613c186001836145df565b8554909150600090613c2c906001906145df565b9050818114613c91576000866000018281548110613c4c57613c4c6145f2565b9060005260206000200154905080876000018481548110613c6f57613c6f6145f2565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613ca257613ca26148e3565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611105565b6000915050611105565b5092915050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052613aaa9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016135c7565b6060613d538484600085613daa565b949350505050565b6000818152600183016020526040812054613da257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611105565b506000611105565b606082471015613e3c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161082a565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051613e659190614912565b60006040518083038185875af1925050503d8060008114613ea2576040519150601f19603f3d011682016040523d82523d6000602084013e613ea7565b606091505b5091509150613eb887838387613ec3565b979650505050505050565b60608315613f59578251600003613f525773ffffffffffffffffffffffffffffffffffffffff85163b613f52576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161082a565b5081613d53565b613d538383815115613f6e5781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a919061492e565b60405180606001604052806003906020820280368337509192915050565b50805460008255906000526020600020908101906115ee9190614068565b828054828255906000526020600020908101928215614058579160200282015b8281111561405857825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909116178255602090920191600190910190613ffe565b50614064929150614068565b5090565b5b808211156140645760008155600101614069565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156140f3576140f361407d565b604052919050565b600067ffffffffffffffff8211156141155761411561407d565b5060051b60200190565b73ffffffffffffffffffffffffffffffffffffffff811681146115ee57600080fd5b6000806040838503121561415457600080fd5b8235915060208084013567ffffffffffffffff81111561417357600080fd5b8401601f8101861361418457600080fd5b8035614197614192826140fb565b6140ac565b81815260059190911b820183019083810190888311156141b657600080fd5b928401925b828410156141dd5783356141ce8161411f565b825292840192908401906141bb565b80955050505050509250929050565b600080602083850312156141ff57600080fd5b823567ffffffffffffffff8082111561421757600080fd5b818501915085601f83011261422b57600080fd5b81358181111561423a57600080fd5b86602082850101111561424c57600080fd5b60209290920196919550909350505050565b60006020828403121561427057600080fd5b5035919050565b6000602080835260e08301845182850152818501516040850152604085015160c06060860152818151808452610100870191508483019350600092505b808310156142ea57835173ffffffffffffffffffffffffffffffffffffffff1682529284019260019290920191908401906142b4565b50606087015173ffffffffffffffffffffffffffffffffffffffff811660808801529350608087015161ffff811660a0880152935060a087015160c08701528094505050505092915050565b60005b83811015614351578181015183820152602001614339565b50506000910152565b60008151808452614372816020860160208601614336565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8215158152604060208201526000613d53604083018461435a565b6000602082840312156143d157600080fd5b8135612da18161411f565b803561ffff811681146143ee57600080fd5b919050565b60008060008060008060a0878903121561440c57600080fd5b8635955060208701359450604087013567ffffffffffffffff8082111561443257600080fd5b818901915089601f83011261444657600080fd5b81358181111561445557600080fd5b8a60208260051b850101111561446a57600080fd5b602083019650809550505050614482606088016143dc565b9150608087013590509295509295509295565b80151581146115ee57600080fd5b6000602082840312156144b557600080fd5b8135612da181614495565b600081518084526020808501945080840160005b8381101561450657815173ffffffffffffffffffffffffffffffffffffffff16875295820195908201906001016144d4565b509495945050505050565b828152604060208201526000613d5360408301846144c0565b6000602080838503121561453d57600080fd5b825167ffffffffffffffff81111561455457600080fd5b8301601f8101851361456557600080fd5b8051614573614192826140fb565b81815260059190911b8201830190838101908783111561459257600080fd5b928401925b82841015613eb857835182529284019290840190614597565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115611105576111056145b0565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600181815b8085111561467a57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115614660576146606145b0565b8085161561466d57918102915b93841c9390800290614626565b509250929050565b60008261469157506001611105565b8161469e57506000611105565b81600181146146b457600281146146be576146da565b6001915050611105565b60ff8411156146cf576146cf6145b0565b50506001821b611105565b5060208310610133831016604e8410600b84101617156146fd575081810a611105565b6147078383614621565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115614739576147396145b0565b029392505050565b6000612da18383614682565b60006020828403121561475f57600080fd5b8151612da18161411f565b60006020828403121561477c57600080fd5b8151612da181614495565b61ffff828116828216039080821115613ce757613ce76145b0565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036147d3576147d36145b0565b5060010190565b80820180821115611105576111056145b0565b6000602082840312156147ff57600080fd5b5051919050565b85815284602082015260a06040820152600061482560a08301866144c0565b73ffffffffffffffffffffffffffffffffffffffff94909416606083015250608001529392505050565b600082614885577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b8082028115828204841417611105576111056145b0565b8481526080602082015260006148ba60808301866144c0565b73ffffffffffffffffffffffffffffffffffffffff949094166040830152506060015292915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60008251614924818460208701614336565b9190910192915050565b602081526000612da1602083018461435a56fea264697066735822122090f6a8f0034fc88239df8191f7c4a0d7bd2fb97106c4507b93a00800a1ad418464736f6c63430008130033