Token
Buffer (BFR)
ERC-721
Overview
Max Total Supply
0 BFR
Holders
0
Market
Onchain Market Cap
-
Circulating Supply Market Cap
-
Other Info
Token Contract
Balance
0 BFRLoading...
Loading
Loading...
Loading
Loading...
Loading
Contract Name:
BufferBinaryOptions
Compiler Version
v0.8.4+commit.c7e474f2
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;
import "ReentrancyGuard.sol";
import "ERC721.sol";
import "AccessControl.sol";
import "SafeERC20.sol";
import "Interfaces.sol";
import "OptionMath.sol";
/**
* @author Heisenberg
* @title Buffer Options
* @notice Creates ERC721 Options
*/
contract BufferBinaryOptions is
IBufferBinaryOptions,
ReentrancyGuard,
ERC721,
AccessControl
{
using SafeERC20 for ERC20;
uint256 public nextTokenId = 0;
uint256 public override totalMarketOI;
bool public isPaused;
uint16 public stepSize = 25; // Factor of 1e2
string public override token0;
string public override token1;
ILiquidityPool public override pool;
IOptionsConfig public override config;
IReferralStorage public referral;
AssetCategory public assetCategory;
ERC20 public override tokenX;
struct Market {
bytes32 marketId;
uint256 contractsUp;
uint256 contractsDown;
int256 premiumUp;
int256 premiumDown;
uint256 strike;
uint256 expiration;
bool isValid;
}
mapping(uint256 => Option) public override options;
mapping(address => uint256[]) public userOptionIds;
mapping(address => bool) public approvedAddresses;
mapping(bytes32 => Market) public markets;
// IMarket public markets;
bytes32 public constant ROUTER_ROLE = keccak256("ROUTER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
constructor() ERC721("Buffer", "BFR") {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/************************************************
* INITIALIZATION FUNCTIONS
***********************************************/
function initialize(
ERC20 _tokenX,
ILiquidityPool _pool,
IOptionsConfig _config,
IReferralStorage _referral,
AssetCategory _category,
string memory _token0,
string memory _token1
) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (address(tokenX) == address(0)) {
tokenX = _tokenX;
pool = _pool;
config = _config;
referral = _referral;
assetCategory = _category;
token0 = _token0;
token1 = _token1;
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
emit CreateOptionsContract(
address(config),
address(pool),
address(tokenX),
token0,
token1,
assetCategory
);
} else {
revert("Already initialized");
}
}
function assetPair() external view override returns (string memory) {
return string(abi.encodePacked(token0, token1));
}
/**
* @notice Grants complete approval from the pool
*/
function approvePoolToTransferTokenX() public {
tokenX.approve(address(pool), ~uint256(0));
}
/**
* @notice Pauses/Unpauses the option creation
*/
function setIsPaused() public {
if (hasRole(PAUSER_ROLE, msg.sender)) {
isPaused = true;
} else if (hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) {
isPaused = !isPaused;
} else {
revert("Wrong role");
}
emit Pause(isPaused);
}
/************************************************
* ROUTER ONLY FUNCTIONS
***********************************************/
/**
* @notice Creates an option with the specified parameters
* @dev Can only be called by router
*/
function createFromRouter(
OptionParams calldata optionParams,
uint256 queuedTime
) external override onlyRole(ROUTER_ROLE) returns (uint256 optionID) {
bytes32 marketId = keccak256(
abi.encode(optionParams.strike, optionParams.expiration)
);
uint256 settlementFee = (optionParams.totalFee * optionParams.sf) / 1e4;
Option memory option = Option(
State.Active,
optionParams.strike,
optionParams.amount,
optionParams.amount,
optionParams.totalFee - settlementFee,
optionParams.expiration,
optionParams.totalFee,
queuedTime,
optionParams.isAbove
);
optionID = _generateTokenId();
userOptionIds[optionParams.user].push(optionID);
options[optionID] = option;
_mint(optionParams.user, optionID);
tokenX.safeTransfer(
config.settlementFeeDisbursalContract(),
settlementFee
);
pool.lock(optionID, option.lockedAmount, option.premium);
IOptionStorage(config.optionStorageContract()).save(
optionID,
address(this),
optionParams.user
);
totalMarketOI += optionParams.totalFee;
if (optionParams.isAbove) {
markets[marketId].contractsUp += optionParams.contracts;
markets[marketId].premiumUp += int256(
optionParams.totalFee - settlementFee
);
} else {
markets[marketId].contractsDown += optionParams.contracts;
markets[marketId].premiumDown += int256(
optionParams.totalFee - settlementFee
);
}
int256 skew = getSkew(marketId);
require(skew <= config.maxSkew(), "Loss too high");
emit Create(
optionParams.user,
optionID,
settlementFee,
optionParams.totalFee,
skew,
marketId
);
}
/**
* @notice Unlocks/Exercises the active options
* @dev Can only be called router
*/
function unlock(
uint256 optionID,
uint256 closingPrice
) external override onlyRole(ROUTER_ROLE) {
require(_exists(optionID), "O10");
Option storage option = options[optionID];
require(option.expiration <= block.timestamp, "O4");
require(option.state == State.Active, "O5");
uint256 payout;
if (
(option.isAbove && closingPrice > option.strike) ||
(!option.isAbove && closingPrice < option.strike)
) {
payout = _exercise(optionID, closingPrice, option.isAbove);
} else {
option.state = State.Expired;
pool.unlock(optionID);
_burn(optionID);
emit Expire(optionID, option.premium, closingPrice, option.isAbove);
}
totalMarketOI -= option.totalFee;
ICircuitBreaker(config.circuitBreakerContract()).update(
int256(payout) - int256(option.totalFee),
int256(option.totalFee - option.premium),
optionID
);
}
function isExpirationValid(uint256 expiration) public view returns (bool) {
if (expiration - block.timestamp < 12 hours) {
return false;
}
bool dayend = (expiration - block.timestamp) < (1 days + 36 hours) &&
(expiration + 16 hours) % 1 days == 0;
bool weekend = ((expiration - 1 days - 8 hours) % 1 weeks == 0) &&
(expiration - block.timestamp < 1 weeks + 36 hours); // Weekends at friday 8:00 AM UTC
return dayend || weekend;
}
function getMarketId(
uint256 strike,
uint256 expiration
) public pure returns (bytes32) {
return keccak256(abi.encode(strike, expiration));
}
function runInitialChecks(
uint256 strike,
uint256 expiration
) external override onlyRole(ROUTER_ROLE) {
bytes32 marketId = getMarketId(strike, expiration);
if (
expiration < block.timestamp ||
expiration - block.timestamp < 12 hours
) {
revert("Wrong expiry");
} else if (markets[marketId].isValid) {
return;
} else {
if (
isExpirationValid(expiration) &&
strike % config.strikeStepSize() == 0
) {
markets[marketId] = Market(
marketId,
markets[marketId].contractsUp,
markets[marketId].contractsDown,
markets[marketId].premiumUp,
markets[marketId].premiumDown,
strike,
expiration,
true
);
emit CreateMarket(strike, expiration, marketId, address(this));
} else {
revert("Invalid strike or expiration");
}
}
}
/************************************************
* READ ONLY FUNCTIONS
***********************************************/
/**
* @notice Returns decimals of the pool token
*/
function decimals() public view returns (uint256) {
return tokenX.decimals();
}
/**
* @notice Calculates the fees for buying an option
*/
function fees(
bool isAbove,
uint256 currentPrice,
uint256 strike,
uint256 period,
uint256 iv,
uint256 sf
)
public
view
returns (uint256 total, uint256 settlementFee, uint256 premium)
{
uint256 _baseFeePerContract = baseFeePerContract(
isAbove,
currentPrice,
strike,
period,
iv
);
settlementFee = (_baseFeePerContract * sf) / 1e4;
total = _baseFeePerContract + settlementFee;
premium = _baseFeePerContract - settlementFee;
}
/**
* @notice Calculates the fees for buying an option
*/
function baseFeePerContract(
bool isAbove,
uint256 currentPrice,
uint256 strike,
uint256 period,
uint256 iv
) public view returns (uint256) {
return
(OptionMath.blackScholesPriceBinary(
iv,
strike,
currentPrice,
period,
true,
isAbove
) * 10 ** decimals()) / 1e8;
}
function getSkew(bytes32 marketId) public view returns (int256) {
return
int256(
max(
markets[marketId].contractsUp,
markets[marketId].contractsDown
) * 10 ** decimals()
) - (markets[marketId].premiumDown + markets[marketId].premiumUp);
}
function getMaxPermissibleContracts(
bytes32 marketId,
uint256 _baseFeePerContract
) public view returns (uint256) {
return
uint256(config.maxSkew() - getSkew(marketId)) /
(config.payout() - _baseFeePerContract);
}
/**
* @notice Runs all the checks on the option parameters and
* returns the revised amount and fee
*/
function evaluateParams(
OptionParams calldata optionParams
)
external
view
override
returns (
uint256 amount,
uint256 fee,
uint256 revisedContracts,
uint256 revisedSf
)
{
require(!isPaused, "O33");
require(
assetCategory == AssetCategory.Crypto ||
ICreationWindowContract(config.creationWindowContract())
.isInCreationWindow(
optionParams.expiration - block.timestamp
),
"O30"
);
uint256 _baseFeePerContract = baseFeePerContract(
optionParams.isAbove,
optionParams.currentPrice,
optionParams.strike,
optionParams.expiration - block.timestamp,
optionParams.iv
);
require(
_baseFeePerContract > 5 * 10 ** (decimals() - 2),
"Fee too less"
);
require(
_baseFeePerContract < 95 * 10 ** (decimals() - 2),
"Fee too high"
);
bytes32 marketId = keccak256(
abi.encode(optionParams.strike, optionParams.expiration)
);
revisedSf = getSettlementFeePercentage(
referral.codeOwner(optionParams.referralCode),
optionParams.user,
optionParams.sf
);
fee = _baseFeePerContract + ((_baseFeePerContract * revisedSf) / 1e4);
uint256 maxContracts = getMaxPermissibleContracts(marketId, fee);
revisedContracts = min(
min(optionParams.contracts, maxContracts),
optionParams.totalFee / fee
);
if (optionParams.contracts != revisedContracts) {
require(optionParams.allowPartialFill, "O29");
}
fee = fee * revisedContracts;
amount = config.payout() * revisedContracts;
}
/************************************************
* ERC721 FUNCTIONS
***********************************************/
function _generateTokenId() internal returns (uint256) {
return nextTokenId++;
}
function abs(int x) private pure returns (int) {
return x >= 0 ? x : -x;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function supportsInterface(
bytes4 interfaceId
) public view override(ERC721, AccessControl) returns (bool) {
return super.supportsInterface(interfaceId);
}
function ownerOf(
uint256 tokenId
)
public
view
virtual
override(ERC721, IBufferBinaryOptions)
returns (address)
{
return super.ownerOf(tokenId);
}
/************************************************
* INTERNAL OPTION UTILITY FUNCTIONS
***********************************************/
/**
* @notice Exercises the ITM options
*/
function _exercise(
uint256 optionID,
uint256 closingPrice,
bool isAbove
) internal returns (uint256 profit) {
Option storage option = options[optionID];
address user = ownerOf(optionID);
profit = option.lockedAmount;
pool.send(optionID, address(this), option.lockedAmount);
tokenX.safeTransfer(user, profit);
if (profit < option.lockedAmount) {
tokenX.safeTransfer(address(pool), option.lockedAmount - profit);
}
if (profit <= option.premium)
emit LpProfit(optionID, option.premium - profit);
else emit LpLoss(optionID, profit - option.premium);
// Burn the option
_burn(optionID);
option.state = State.Exercised;
emit Exercise(user, optionID, profit, closingPrice, isAbove);
}
/**
* @notice Calculates the discount to be applied on settlement fee based on
* referrer tiers
*/
function _getReferralDiscount(
address referrer,
address user
) public view returns (uint256 referralDiscount) {
uint256 maxStep;
if (
referrer != user &&
referrer != address(0) &&
referrer.code.length == 0
) {
uint8 step = referral.referrerTierStep(
referral.referrerTier(referrer)
);
maxStep += step;
}
referralDiscount = (stepSize * maxStep);
}
/**
* @notice Returns the discounted settlement fee
*/
function getSettlementFeePercentage(
address referrer,
address user,
uint256 baseSettlementFeePercentage
) public view returns (uint256 settlementFeePercentage) {
settlementFeePercentage = baseSettlementFeePercentage;
uint256 referralDiscount = _getReferralDiscount(referrer, user);
settlementFeePercentage = settlementFeePercentage - referralDiscount;
}
function approveAddress(
address addressToApprove
) public onlyRole(DEFAULT_ADMIN_ROLE) {
approvedAddresses[addressToApprove] = true;
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
if (
from != address(0) &&
to != address(0) &&
approvedAddresses[to] == false &&
approvedAddresses[from] == false
) {
revert("Token transfer not allowed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "IERC721.sol";
import "IERC721Receiver.sol";
import "IERC721Metadata.sol";
import "Address.sol";
import "Context.sol";
import "Strings.sol";
import "ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_safeTransfer(from, to, tokenId, data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` has not been minted yet.
*/
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` 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 tokenId
) 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.
* - `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 tokenId
) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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
* ====
*
* [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "IAccessControl.sol";
import "Context.sol";
import "Strings.sol";
import "ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "IERC20.sol";
import "draft-IERC20Permit.sol";
import "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;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
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");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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);
}// SPDX-License-Identifier: BUSL-1.1
import "ERC20.sol";
pragma solidity 0.8.4;
interface ICircuitBreaker {
struct MarketPoolPair {
address market;
address pool;
}
struct Configs {
int256 value;
address contractAddress;
}
struct OverallStats {
address contractAddress;
int256 loss;
int256 sf;
int256 lp_sf;
int256 net_loss;
}
struct MarketStats {
address pool;
int256 loss;
int256 sf;
}
struct PoolStats {
address[] markets;
int256 loss;
int256 sf;
}
function update(int256 loss, int256 sf, uint256 option_id) external;
event Update(
int256 loss,
int256 sf,
address market,
address pool,
uint256 option_id
);
event MarketPaused(address market, address pool);
event PoolPaused(address pool);
}
interface IBooster {
struct UserBoostTrades {
uint256 totalBoostTrades;
uint256 totalBoostTradesUsed;
}
function getUserBoostData(
address user,
address token
) external view returns (UserBoostTrades memory);
function updateUserBoost(address user, address token) external;
function getBoostPercentage(
address user,
address token
) external view returns (uint256);
struct Permit {
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
bool shouldApprove;
}
event ApproveTokenX(
address user,
uint256 nonce,
uint256 value,
uint256 deadline,
address tokenX
);
event BuyCoupon(address indexed token, address indexed user, uint256 price);
event SetPrice(uint256 couponPrice);
event SetBoostPercentage(uint256 boost);
event UpdateBoostTradesUser(address indexed user, address indexed token);
event Configure(uint8[4] nftTierDiscounts);
}
interface IAccountRegistrar {
struct AccountMapping {
address oneCT;
uint256 nonce;
}
event RegisterAccount(
address indexed user,
address indexed oneCT,
uint256 nonce
);
event DeregisterAccount(address indexed account, uint256 nonce);
function accountMapping(
address
) external view returns (address oneCT, uint256 nonce);
function registerAccount(
address oneCT,
address user,
bytes memory signature
) external;
}
interface IBufferRouter {
struct QueuedTrade {
address user;
address targetContract;
uint256 strike;
uint256 expiration;
uint256 contracts;
bool allowPartialFill;
bool isQueued;
uint256 optionId;
bool isAbove;
uint256 queuedTime;
uint256 maxFeePerContract;
string referralCode;
}
struct OptionInfo {
uint256 queueId;
address signer;
uint256 nonce;
}
struct SignInfo {
bytes signature;
uint256 timestamp;
}
struct TradeInitiationParamas {
address targetContract;
bool allowPartialFill;
string referralCode;
bool isAbove;
uint256 contracts;
uint256 strike;
uint256 expiration;
uint256 maxFeePerContract;
}
struct ResolveTradeParams {
uint256 queueId;
uint256 iv;
uint256 sf;
SignInfo publisherSignInfo;
SignInfo sfSignInfo;
bytes[] priceUpdateData;
bytes32[] priceIds;
}
struct Register {
address oneCT;
bytes signature;
bool shouldRegister;
}
struct CloseTradeParams {
uint256 optionId;
address targetContract;
bytes[] priceUpdateData;
bytes32[] priceIds;
}
struct IdMapping {
uint256 id;
bool isSet;
}
event OpenTrade(
address indexed user,
uint256 indexed queueId,
uint256 indexed optionId,
address targetContract,
uint256 contracts
);
event CancelTrade(address indexed account, uint256 queueId, string reason);
event FailUnlock(
uint256 indexed optionId,
address targetContract,
string reason
);
event FailResolve(uint256 indexed queueId, string reason);
event FailRevoke(address indexed user, address tokenX, string reason);
event ContractRegistryUpdated(address targetContract, bool register);
event InitiateTrade(
address indexed user,
uint256 queueId,
uint256 timestamp
);
}
interface IBufferBinaryOptions {
event Create(
address indexed account,
uint256 indexed id,
uint256 settlementFee,
uint256 totalFee,
int256 skew,
bytes32 marketId
);
event CreateMarket(
uint256 strike,
uint256 expiration,
bytes32 marketId,
address optionsContract
);
event Exercise(
address indexed account,
uint256 indexed id,
uint256 profit,
uint256 priceAtExpiration,
bool isAbove
);
event Expire(
uint256 indexed id,
uint256 premium,
uint256 priceAtExpiration,
bool isAbove
);
event Pause(bool isPaused);
event UpdateReferral(
address user,
address referrer,
bool isReferralValid,
uint256 totalFee,
uint256 referrerFee,
uint256 rebate,
string referralCode
);
event LpProfit(uint256 indexed id, uint256 amount);
event LpLoss(uint256 indexed id, uint256 amount);
function createFromRouter(
OptionParams calldata optionParams,
uint256 queuedTime
) external returns (uint256 optionID);
function evaluateParams(
OptionParams calldata optionParams
)
external
view
returns (
uint256 amount,
uint256 fee,
uint256 revisedContracts,
uint256 revisedSf
);
function tokenX() external view returns (ERC20);
function pool() external view returns (ILiquidityPool);
function config() external view returns (IOptionsConfig);
function token0() external view returns (string memory);
function token1() external view returns (string memory);
function ownerOf(uint256 id) external view returns (address);
function assetPair() external view returns (string memory);
function totalMarketOI() external view returns (uint256);
enum State {
Inactive,
Active,
Exercised,
Expired
}
enum AssetCategory {
Forex,
Crypto,
Commodities
}
struct OptionExpiryData {
uint256 optionId;
uint256 priceAtExpiration;
}
event CreateOptionsContract(
address config,
address pool,
address tokenX,
string token0,
string token1,
AssetCategory category
);
struct Option {
State state;
uint256 strike;
uint256 amount;
uint256 lockedAmount;
uint256 premium;
uint256 expiration;
uint256 totalFee;
uint256 createdAt;
bool isAbove;
}
struct OptionParams {
address user;
uint256 sf;
uint256 iv;
bool allowPartialFill;
bool isAbove;
uint256 contracts;
uint256 strike;
uint256 expiration;
uint256 amount;
uint256 totalFee;
uint256 currentPrice;
string referralCode;
}
function options(
uint256 optionId
)
external
view
returns (
State state,
uint256 strike,
uint256 amount,
uint256 lockedAmount,
uint256 premium,
uint256 expiration,
uint256 totalFee,
uint256 createdAt,
bool isAbove
);
function unlock(uint256 optionID, uint256 closingPrice) external;
function runInitialChecks(uint256 strike, uint256 expiration) external;
}
interface IBufferBinaryOptionPauserV2_5 {
function isPaused() external view returns (bool);
function setIsPaused() external;
}
interface IBufferBinaryOptionPauserV2 {
function isPaused() external view returns (bool);
function toggleCreation() external;
}
interface ILiquidityPool {
struct LockedAmount {
uint256 timestamp;
uint256 amount;
}
struct ProvidedLiquidity {
uint256 unlockedAmount;
LockedAmount[] lockedAmounts;
uint256 nextIndexForUnlock;
}
struct LockedLiquidity {
uint256 amount;
uint256 premium;
bool locked;
}
event Profit(uint256 indexed id, uint256 amount);
event Loss(uint256 indexed id, uint256 amount);
event Provide(address indexed account, uint256 amount, uint256 writeAmount);
event UpdateMaxLiquidity(uint256 indexed maxLiquidity);
event Withdraw(
address indexed account,
uint256 amount,
uint256 writeAmount
);
function unlock(uint256 id) external;
function totalTokenXBalance() external view returns (uint256 amount);
function availableBalance() external view returns (uint256 balance);
function send(uint256 id, address account, uint256 amount) external;
function lock(uint256 id, uint256 tokenXAmount, uint256 premium) external;
}
interface IOptionsConfig {
event UpdateSettlementFeeDisbursalContract(address value);
event UpdatetraderNFTContract(address value);
event UpdateOptionStorageContract(address value);
event UpdateCreationWindowContract(address value);
event UpdatePlatformFee(uint256 _platformFee);
event UpdateIV(uint32 _iv);
event UpdateMaxSkew(int256 _maxSkew);
event UpdateIVFactorITM(uint256 ivFactorITM);
event UpdateIVFactorOTM(uint256 ivFactorOTM);
event UpdateCircuitBreakerContract(address _circuitBreakerContract);
event UpdateSf(uint256 sf);
event UpdatePayout(uint256 payout);
event UpdateStrikeStepSize(uint256 strikeStepSize);
function maxSkew() external view returns (int256);
function circuitBreakerContract() external view returns (address);
function settlementFeeDisbursalContract() external view returns (address);
function platformFee() external view returns (uint256);
function payout() external view returns (uint256);
function optionStorageContract() external view returns (address);
function creationWindowContract() external view returns (address);
function iv() external view returns (uint32);
function sf() external returns (uint256);
function getFactoredIv(bool isITM) external view returns (uint32);
function strikeStepSize() external view returns (uint256);
}
interface ITraderNFT {
function tokenOwner(uint256 id) external view returns (address user);
function tokenTierMappings(uint256 id) external view returns (uint8 tier);
event UpdateTiers(uint256[] tokenIds, uint8[] tiers, uint256[] batchIds);
}
interface IFakeTraderNFT {
function tokenOwner(uint256 id) external view returns (address user);
function tokenTierMappings(uint256 id) external view returns (uint8 tier);
event UpdateNftBasePrice(uint256 nftBasePrice);
event UpdateMaxNFTMintLimits(uint256 maxNFTMintLimit);
event UpdateBaseURI(string baseURI);
event Claim(address indexed account, uint256 claimTokenId);
event Mint(address indexed account, uint256 tokenId, uint8 tier);
}
interface IReferralStorage {
function codeOwner(string memory _code) external view returns (address);
function traderReferralCodes(address) external view returns (string memory);
function getTraderReferralInfo(
address user
) external view returns (string memory, address);
function setTraderReferralCode(address user, string memory _code) external;
function setReferrerTier(address, uint8) external;
function referrerTierStep(
uint8 referralTier
) external view returns (uint8 step);
function referrerTierDiscount(
uint8 referralTier
) external view returns (uint32 discount);
function referrerTier(address referrer) external view returns (uint8 tier);
struct ReferrerData {
uint256 tradeVolume;
uint256 rebate;
uint256 trades;
}
struct ReferreeData {
uint256 tradeVolume;
uint256 rebate;
}
struct ReferralData {
ReferrerData referrerData;
ReferreeData referreeData;
}
struct Tier {
uint256 totalRebate; // e.g. 2400 for 24%
uint256 discountShare; // 5000 for 50%/50%, 7000 for 30% rebates/70% discount
}
event UpdateTraderReferralCode(address indexed account, string code);
event UpdateReferrerTier(address referrer, uint8 tierId);
event RegisterCode(address indexed account, string code);
event SetCodeOwner(
address indexed account,
address newAccount,
string code
);
}
interface IOptionStorage {
function save(
uint256 optionId,
address optionsContract,
address user
) external;
}
interface ICreationWindowContract {
function isInCreationWindow(uint256 period) external view returns (bool);
}
interface IPoolOIStorage {
function updatePoolOI(bool isIncreased, uint256 interest) external;
function totalPoolOI() external view returns (uint256);
}
interface IPoolOIConfig {
function getMaxPoolOI() external view returns (uint256);
function getPoolOICap() external view returns (uint256);
}
interface IMarketOIConfig {
function getMaxMarketOI(
uint256 currentMarketOI
) external view returns (uint256);
function getMarketOICap() external view returns (uint256);
}
interface IMarket {
struct Market {
uint256 strike;
uint256 expiration;
uint256 maxSkew;
uint256 skewUp;
uint256 skewDown;
bool isEnabled;
}
function market(bytes32 marketId) external view returns (Market memory);
function updateMarketSkew(
bytes32 marketId,
bool isAbove,
uint256 loss
) external;
function maxContractsAllowed(
bytes32 marketId,
uint256 lossPerContract,
bool isAbove
) external view returns (uint256);
}
/// @title Consume prices from the Pyth Network (https://pyth.network/).
/// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices for how to consume prices safely.
/// @author Pyth Data Association
interface IPyth {
/// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time
function getValidTimePeriod() external view returns (uint validTimePeriod);
/// @notice Returns the price and confidence interval.
/// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds.
/// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval.
/// @return price - please read the documentation of Price to understand how to use this safely.
function getPrice(bytes32 id) external view returns (Price memory price);
/// @notice Returns the exponentially-weighted moving average price and confidence interval.
/// @dev Reverts if the EMA price is not available.
/// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval.
/// @return price - please read the documentation of Price to understand how to use this safely.
function getEmaPrice(bytes32 id) external view returns (Price memory price);
/// @notice Returns the price of a price feed without any sanity checks.
/// @dev This function returns the most recent price update in this contract without any recency checks.
/// This function is unsafe as the returned price update may be arbitrarily far in the past.
///
/// Users of this function should check the `publishTime` in the price to ensure that the returned price is
/// sufficiently recent for their application. If you are considering using this function, it may be
/// safer / easier to use either `getPrice` or `getPriceNoOlderThan`.
/// @return price - please read the documentation of Price to understand how to use this safely.
function getPriceUnsafe(
bytes32 id
) external view returns (Price memory price);
/// @notice Returns the price that is no older than `age` seconds of the current time.
/// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in
/// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
/// recently.
/// @return price - please read the documentation of Price to understand how to use this safely.
function getPriceNoOlderThan(
bytes32 id,
uint age
) external view returns (Price memory price);
/// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.
/// @dev This function returns the same price as `getEmaPrice` in the case where the price is available.
/// However, if the price is not recent this function returns the latest available price.
///
/// The returned price can be from arbitrarily far in the past; this function makes no guarantees that
/// the returned price is recent or useful for any particular application.
///
/// Users of this function should check the `publishTime` in the price to ensure that the returned price is
/// sufficiently recent for their application. If you are considering using this function, it may be
/// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.
/// @return price - please read the documentation of Price to understand how to use this safely.
function getEmaPriceUnsafe(
bytes32 id
) external view returns (Price memory price);
/// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds
/// of the current time.
/// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in
/// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
/// recently.
/// @return price - please read the documentation of Price to understand how to use this safely.
function getEmaPriceNoOlderThan(
bytes32 id,
uint age
) external view returns (Price memory price);
/// @notice Update price feeds with given update messages.
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
/// Prices will be updated if they are more recent than the current stored prices.
/// The call will succeed even if the update is not the most recent.
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.
/// @param updateData Array of price update data.
function updatePriceFeeds(bytes[] calldata updateData) external payable;
/// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is
/// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the
/// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`.
///
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
///
/// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime
/// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have
/// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.
/// Otherwise, it calls updatePriceFeeds method to update the prices.
///
/// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.
/// @param updateData Array of price update data.
/// @param priceIds Array of price ids.
/// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`
function updatePriceFeedsIfNecessary(
bytes[] calldata updateData,
bytes32[] calldata priceIds,
uint64[] calldata publishTimes
) external payable;
/// @notice Returns the required fee to update an array of price updates.
/// @param updateData Array of price update data.
/// @return feeAmount The required fee in Wei.
function getUpdateFee(
bytes[] calldata updateData
) external view returns (uint feeAmount);
/// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published
/// within `minPublishTime` and `maxPublishTime`.
///
/// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price;
/// otherwise, please consider using `updatePriceFeeds`. This method does not store the price updates on-chain.
///
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
///
///
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is
/// no update for any of the given `priceIds` within the given time range.
/// @param updateData Array of price update data.
/// @param priceIds Array of price ids.
/// @param minPublishTime minimum acceptable publishTime for the given `priceIds`.
/// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`.
/// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order).
function parsePriceFeedUpdates(
bytes[] calldata updateData,
bytes32[] calldata priceIds,
uint64 minPublishTime,
uint64 maxPublishTime
) external payable returns (PriceFeed[] memory priceFeeds);
struct Price {
// Price
int64 price;
// Confidence interval around the price
uint64 conf;
// Price exponent
int32 expo;
// Unix timestamp describing when the price was published
uint publishTime;
}
struct PriceFeed {
// The price ID.
bytes32 id;
// Latest available price
Price price;
// Latest available exponentially-weighted moving average price
Price emaPrice;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "IERC20.sol";
import "IERC20Metadata.sol";
import "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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* 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}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* 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 value {ERC20} uses, unless this function is
* 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;
}
_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;
_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;
}
_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 {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;
import "ABDKMath64x64.sol";
library OptionMath {
using ABDKMath64x64 for int128;
// 64x64 fixed point integer constants
int128 internal constant ONE_64x64 = 0x10000000000000000;
int128 internal constant THREE_64x64 = 0x30000000000000000;
// 64x64 fixed point constants used in Choudhury’s approximation of the Black-Scholes CDF
int128 private constant CDF_CONST_0 = 0x09109f285df452394; // 2260 / 3989
int128 private constant CDF_CONST_1 = 0x19abac0ea1da65036; // 6400 / 3989
int128 private constant CDF_CONST_2 = 0x0d3c84b78b749bd6b; // 3300 / 3989
/**
* @notice calculate Choudhury’s approximation of the Black-Scholes CDF
* @param input64x64 64x64 fixed point representation of random variable
* @return 64x64 fixed point representation of the approximated CDF of x
*/
function _N(int128 input64x64) internal pure returns (int128) {
// squaring via mul is cheaper than via pow
int128 inputSquared64x64 = input64x64.mul(input64x64);
int128 value64x64 = (-inputSquared64x64 >> 1).exp().div(
CDF_CONST_0.add(CDF_CONST_1.mul(input64x64.abs())).add(
CDF_CONST_2.mul(inputSquared64x64.add(THREE_64x64).sqrt())
)
);
return input64x64 > 0 ? ONE_64x64.sub(value64x64) : value64x64;
}
/**
* @notice calculate the price of an option using the Black-Scholes model
* @param impliedVol uint256 representation of annualized impliedVol with a factor of 1e4
* @param strike uint256 representation of strike price with a factor of 1e8
* @param spot uint256 representation of spot price with a factor of 1e8
* @param period uint256 representation of duration of option contract (in seconds)
* @param isYes whether to price "call" or "put" option
* @param isAbove whether to the user bets the price will stay above this strike or not
* @return uint256 representation of Black-Scholes option price with a factor of 1e8
*/
function blackScholesPriceBinary(
uint256 impliedVol,
uint256 strike,
uint256 spot,
uint256 period,
bool isYes,
bool isAbove
) internal pure returns (uint256) {
int128 D8 = ABDKMath64x64.fromUInt(10 ** 8);
int128 D4 = ABDKMath64x64.fromUInt(10 ** 4);
int128 impliedVol64x64 = ABDKMath64x64.fromUInt(impliedVol).div(D4);
int128 variance64x64 = impliedVol64x64.mul(impliedVol64x64);
int128 strike64x64 = ABDKMath64x64.fromUInt(strike).div(D8);
int128 spot64x64 = ABDKMath64x64.fromUInt(spot).div(D8);
int128 maturity64x64 = ABDKMath64x64.fromUInt(period).div(
ABDKMath64x64.fromUInt(365 days)
);
int128 premium64x64 = _blackScholesPriceBinary(
variance64x64,
strike64x64,
spot64x64,
maturity64x64,
isYes,
isAbove
);
return ABDKMath64x64.toUInt(premium64x64.mul(D8));
}
/**
* @notice calculate the price of an option using the Black-Scholes model
* @param varianceAnnualized64x64 64x64 fixed point representation of annualized variance
* @param strike64x64 64x64 fixed point representation of strike price
* @param spot64x64 64x64 fixed point representation of spot price
* @param timeToMaturity64x64 64x64 fixed point representation of duration of option contract (in years)
* @param isYes whether to price "call" or "put" option
* @param isAbove whether to the user bets the price will stay above this strike or not
* @return 64x64 fixed point representation of Black-Scholes option price
*/
function _blackScholesPriceBinary(
int128 varianceAnnualized64x64,
int128 strike64x64,
int128 spot64x64,
int128 timeToMaturity64x64,
bool isYes,
bool isAbove
) internal pure returns (int128) {
int128 cumulativeVariance64x64 = timeToMaturity64x64.mul(
varianceAnnualized64x64
);
int128 cumulativeVarianceSqrt64x64 = cumulativeVariance64x64.sqrt();
int128 d1_64x64 = spot64x64
.div(strike64x64)
.ln()
.add(cumulativeVariance64x64 >> 1)
.div(cumulativeVarianceSqrt64x64);
int128 d2_64x64 = d1_64x64.sub(cumulativeVarianceSqrt64x64);
if (isYes) {
if (isAbove) {
return _N(d2_64x64);
} else {
return _N(-d2_64x64);
}
} else {
if (isAbove) {
return ABDKMath64x64.fromUInt(1).sub(_N(d2_64x64));
} else {
return ABDKMath64x64.fromUInt(1).sub(_N(-d2_64x64));
}
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;
/**
* Smart contract library of mathematical functions operating with signed
* 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is
* basically a simple fraction whose numerator is signed 128-bit integer and
* denominator is 2^64. As long as denominator is always the same, there is no
* need to store it, thus in Solidity signed 64.64-bit fixed point numbers are
* represented by int128 type holding only the numerator.
*/
library ABDKMath64x64 {
/*
* Minimum value signed 64.64-bit fixed point number may have.
*/
int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;
/*
* Maximum value signed 64.64-bit fixed point number may have.
*/
int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
/**
* Convert signed 256-bit integer number into signed 64.64-bit fixed point
* number. Revert on overflow.
*
* @param x signed 256-bit integer number
* @return signed 64.64-bit fixed point number
*/
function fromInt(int256 x) internal pure returns (int128) {
unchecked {
require(x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);
return int128(x << 64);
}
}
/**
* Convert signed 64.64 fixed point number into signed 64-bit integer number
* rounding down.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64-bit integer number
*/
function toInt(int128 x) internal pure returns (int64) {
unchecked {
return int64(x >> 64);
}
}
/**
* Convert unsigned 256-bit integer number into signed 64.64-bit fixed point
* number. Revert on overflow.
*
* @param x unsigned 256-bit integer number
* @return signed 64.64-bit fixed point number
*/
function fromUInt(uint256 x) internal pure returns (int128) {
unchecked {
require(x <= 0x7FFFFFFFFFFFFFFF);
return int128(int256(x << 64));
}
}
/**
* Convert signed 64.64 fixed point number into unsigned 64-bit integer
* number rounding down. Revert on underflow.
*
* @param x signed 64.64-bit fixed point number
* @return unsigned 64-bit integer number
*/
function toUInt(int128 x) internal pure returns (uint64) {
unchecked {
require(x >= 0);
return uint64(uint128(x >> 64));
}
}
/**
* Convert signed 128.128 fixed point number into signed 64.64-bit fixed point
* number rounding down. Revert on overflow.
*
* @param x signed 128.128-bin fixed point number
* @return signed 64.64-bit fixed point number
*/
function from128x128(int256 x) internal pure returns (int128) {
unchecked {
int256 result = x >> 64;
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
/**
* Convert signed 64.64 fixed point number into signed 128.128 fixed point
* number.
*
* @param x signed 64.64-bit fixed point number
* @return signed 128.128 fixed point number
*/
function to128x128(int128 x) internal pure returns (int256) {
unchecked {
return int256(x) << 64;
}
}
/**
* Calculate x + y. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function add(int128 x, int128 y) internal pure returns (int128) {
unchecked {
int256 result = int256(x) + y;
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
/**
* Calculate x - y. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function sub(int128 x, int128 y) internal pure returns (int128) {
unchecked {
int256 result = int256(x) - y;
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
/**
* Calculate x * y rounding down. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function mul(int128 x, int128 y) internal pure returns (int128) {
unchecked {
int256 result = (int256(x) * y) >> 64;
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
/**
* Calculate x * y rounding towards zero, where x is signed 64.64 fixed point
* number and y is signed 256-bit integer number. Revert on overflow.
*
* @param x signed 64.64 fixed point number
* @param y signed 256-bit integer number
* @return signed 256-bit integer number
*/
function muli(int128 x, int256 y) internal pure returns (int256) {
unchecked {
if (x == MIN_64x64) {
require(
y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&
y <= 0x1000000000000000000000000000000000000000000000000
);
return -y << 63;
} else {
bool negativeResult = false;
if (x < 0) {
x = -x;
negativeResult = true;
}
if (y < 0) {
y = -y; // We rely on overflow behavior here
negativeResult = !negativeResult;
}
uint256 absoluteResult = mulu(x, uint256(y));
if (negativeResult) {
require(
absoluteResult <=
0x8000000000000000000000000000000000000000000000000000000000000000
);
return -int256(absoluteResult); // We rely on overflow behavior here
} else {
require(
absoluteResult <=
0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
);
return int256(absoluteResult);
}
}
}
}
/**
* Calculate x * y rounding down, where x is signed 64.64 fixed point number
* and y is unsigned 256-bit integer number. Revert on overflow.
*
* @param x signed 64.64 fixed point number
* @param y unsigned 256-bit integer number
* @return unsigned 256-bit integer number
*/
function mulu(int128 x, uint256 y) internal pure returns (uint256) {
unchecked {
if (y == 0) return 0;
require(x >= 0);
uint256 lo = (uint256(int256(x)) *
(y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
uint256 hi = uint256(int256(x)) * (y >> 128);
require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
hi <<= 64;
require(
hi <=
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -
lo
);
return hi + lo;
}
}
/**
* Calculate x / y rounding towards zero. Revert on overflow or when y is
* zero.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function div(int128 x, int128 y) internal pure returns (int128) {
unchecked {
require(y != 0);
int256 result = (int256(x) << 64) / y;
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
/**
* Calculate x / y rounding towards zero, where x and y are signed 256-bit
* integer numbers. Revert on overflow or when y is zero.
*
* @param x signed 256-bit integer number
* @param y signed 256-bit integer number
* @return signed 64.64-bit fixed point number
*/
function divi(int256 x, int256 y) internal pure returns (int128) {
unchecked {
require(y != 0);
bool negativeResult = false;
if (x < 0) {
x = -x; // We rely on overflow behavior here
negativeResult = true;
}
if (y < 0) {
y = -y; // We rely on overflow behavior here
negativeResult = !negativeResult;
}
uint128 absoluteResult = divuu(uint256(x), uint256(y));
if (negativeResult) {
require(absoluteResult <= 0x80000000000000000000000000000000);
return -int128(absoluteResult); // We rely on overflow behavior here
} else {
require(absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return int128(absoluteResult); // We rely on overflow behavior here
}
}
}
/**
* Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
* integer numbers. Revert on overflow or when y is zero.
*
* @param x unsigned 256-bit integer number
* @param y unsigned 256-bit integer number
* @return signed 64.64-bit fixed point number
*/
function divu(uint256 x, uint256 y) internal pure returns (int128) {
unchecked {
require(y != 0);
uint128 result = divuu(x, y);
require(result <= uint128(MAX_64x64));
return int128(result);
}
}
/**
* Calculate -x. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function neg(int128 x) internal pure returns (int128) {
unchecked {
require(x != MIN_64x64);
return -x;
}
}
/**
* Calculate |x|. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function abs(int128 x) internal pure returns (int128) {
unchecked {
require(x != MIN_64x64);
return x < 0 ? -x : x;
}
}
/**
* Calculate 1 / x rounding towards zero. Revert on overflow or when x is
* zero.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function inv(int128 x) internal pure returns (int128) {
unchecked {
require(x != 0);
int256 result = int256(0x100000000000000000000000000000000) / x;
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
/**
* Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function avg(int128 x, int128 y) internal pure returns (int128) {
unchecked {
return int128((int256(x) + int256(y)) >> 1);
}
}
/**
* Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.
* Revert on overflow or in case x * y is negative.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function gavg(int128 x, int128 y) internal pure returns (int128) {
unchecked {
int256 m = int256(x) * int256(y);
require(m >= 0);
require(
m <
0x4000000000000000000000000000000000000000000000000000000000000000
);
return int128(sqrtu(uint256(m)));
}
}
/**
* Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number
* and y is unsigned 256-bit integer number. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @param y uint256 value
* @return signed 64.64-bit fixed point number
*/
function pow(int128 x, uint256 y) internal pure returns (int128) {
unchecked {
bool negative = x < 0 && y & 1 == 1;
uint256 absX = uint128(x < 0 ? -x : x);
uint256 absResult;
absResult = 0x100000000000000000000000000000000;
if (absX <= 0x10000000000000000) {
absX <<= 63;
while (y != 0) {
if (y & 0x1 != 0) {
absResult = (absResult * absX) >> 127;
}
absX = (absX * absX) >> 127;
if (y & 0x2 != 0) {
absResult = (absResult * absX) >> 127;
}
absX = (absX * absX) >> 127;
if (y & 0x4 != 0) {
absResult = (absResult * absX) >> 127;
}
absX = (absX * absX) >> 127;
if (y & 0x8 != 0) {
absResult = (absResult * absX) >> 127;
}
absX = (absX * absX) >> 127;
y >>= 4;
}
absResult >>= 64;
} else {
uint256 absXShift = 63;
if (absX < 0x1000000000000000000000000) {
absX <<= 32;
absXShift -= 32;
}
if (absX < 0x10000000000000000000000000000) {
absX <<= 16;
absXShift -= 16;
}
if (absX < 0x1000000000000000000000000000000) {
absX <<= 8;
absXShift -= 8;
}
if (absX < 0x10000000000000000000000000000000) {
absX <<= 4;
absXShift -= 4;
}
if (absX < 0x40000000000000000000000000000000) {
absX <<= 2;
absXShift -= 2;
}
if (absX < 0x80000000000000000000000000000000) {
absX <<= 1;
absXShift -= 1;
}
uint256 resultShift = 0;
while (y != 0) {
require(absXShift < 64);
if (y & 0x1 != 0) {
absResult = (absResult * absX) >> 127;
resultShift += absXShift;
if (absResult > 0x100000000000000000000000000000000) {
absResult >>= 1;
resultShift += 1;
}
}
absX = (absX * absX) >> 127;
absXShift <<= 1;
if (absX >= 0x100000000000000000000000000000000) {
absX >>= 1;
absXShift += 1;
}
y >>= 1;
}
require(resultShift < 64);
absResult >>= 64 - resultShift;
}
int256 result = negative ? -int256(absResult) : int256(absResult);
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
/**
* Calculate sqrt (x) rounding down. Revert if x < 0.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function sqrt(int128 x) internal pure returns (int128) {
unchecked {
require(x >= 0);
return int128(sqrtu(uint256(int256(x)) << 64));
}
}
/**
* Calculate binary logarithm of x. Revert if x <= 0.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function log_2(int128 x) internal pure returns (int128) {
unchecked {
require(x > 0);
int256 msb = 0;
int256 xc = x;
if (xc >= 0x10000000000000000) {
xc >>= 64;
msb += 64;
}
if (xc >= 0x100000000) {
xc >>= 32;
msb += 32;
}
if (xc >= 0x10000) {
xc >>= 16;
msb += 16;
}
if (xc >= 0x100) {
xc >>= 8;
msb += 8;
}
if (xc >= 0x10) {
xc >>= 4;
msb += 4;
}
if (xc >= 0x4) {
xc >>= 2;
msb += 2;
}
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
int256 result = (msb - 64) << 64;
uint256 ux = uint256(int256(x)) << uint256(127 - msb);
for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {
ux *= ux;
uint256 b = ux >> 255;
ux >>= 127 + b;
result += bit * int256(b);
}
return int128(result);
}
}
/**
* Calculate natural logarithm of x. Revert if x <= 0.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function ln(int128 x) internal pure returns (int128) {
unchecked {
require(x > 0);
return
int128(
int256(
(uint256(int256(log_2(x))) *
0xB17217F7D1CF79ABC9E3B39803F2F6AF) >> 128
)
);
}
}
/**
* Calculate binary exponent of x. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function exp_2(int128 x) internal pure returns (int128) {
unchecked {
require(x < 0x400000000000000000); // Overflow
if (x < -0x400000000000000000) return 0; // Underflow
uint256 result = 0x80000000000000000000000000000000;
if (x & 0x8000000000000000 > 0)
result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;
if (x & 0x4000000000000000 > 0)
result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128;
if (x & 0x2000000000000000 > 0)
result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128;
if (x & 0x1000000000000000 > 0)
result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128;
if (x & 0x800000000000000 > 0)
result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128;
if (x & 0x400000000000000 > 0)
result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128;
if (x & 0x200000000000000 > 0)
result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128;
if (x & 0x100000000000000 > 0)
result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128;
if (x & 0x80000000000000 > 0)
result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128;
if (x & 0x40000000000000 > 0)
result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128;
if (x & 0x20000000000000 > 0)
result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128;
if (x & 0x10000000000000 > 0)
result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128;
if (x & 0x8000000000000 > 0)
result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128;
if (x & 0x4000000000000 > 0)
result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128;
if (x & 0x2000000000000 > 0)
result = (result * 0x1000162E525EE054754457D5995292026) >> 128;
if (x & 0x1000000000000 > 0)
result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128;
if (x & 0x800000000000 > 0)
result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128;
if (x & 0x400000000000 > 0)
result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128;
if (x & 0x200000000000 > 0)
result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;
if (x & 0x100000000000 > 0)
result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;
if (x & 0x80000000000 > 0)
result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128;
if (x & 0x40000000000 > 0)
result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128;
if (x & 0x20000000000 > 0)
result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128;
if (x & 0x10000000000 > 0)
result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128;
if (x & 0x8000000000 > 0)
result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128;
if (x & 0x4000000000 > 0)
result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128;
if (x & 0x2000000000 > 0)
result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128;
if (x & 0x1000000000 > 0)
result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128;
if (x & 0x800000000 > 0)
result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128;
if (x & 0x400000000 > 0)
result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128;
if (x & 0x200000000 > 0)
result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128;
if (x & 0x100000000 > 0)
result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;
if (x & 0x80000000 > 0)
result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128;
if (x & 0x40000000 > 0)
result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128;
if (x & 0x20000000 > 0)
result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;
if (x & 0x10000000 > 0)
result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128;
if (x & 0x8000000 > 0)
result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128;
if (x & 0x4000000 > 0)
result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128;
if (x & 0x2000000 > 0)
result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;
if (x & 0x1000000 > 0)
result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128;
if (x & 0x800000 > 0)
result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128;
if (x & 0x400000 > 0)
result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128;
if (x & 0x200000 > 0)
result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128;
if (x & 0x100000 > 0)
result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128;
if (x & 0x80000 > 0)
result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128;
if (x & 0x40000 > 0)
result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128;
if (x & 0x20000 > 0)
result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128;
if (x & 0x10000 > 0)
result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128;
if (x & 0x8000 > 0)
result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128;
if (x & 0x4000 > 0)
result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128;
if (x & 0x2000 > 0)
result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;
if (x & 0x1000 > 0)
result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;
if (x & 0x800 > 0)
result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;
if (x & 0x400 > 0)
result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;
if (x & 0x200 > 0)
result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128;
if (x & 0x100 > 0)
result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;
if (x & 0x80 > 0)
result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128;
if (x & 0x40 > 0)
result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;
if (x & 0x20 > 0)
result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;
if (x & 0x10 > 0)
result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;
if (x & 0x8 > 0)
result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128;
if (x & 0x4 > 0)
result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128;
if (x & 0x2 > 0)
result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128;
if (x & 0x1 > 0)
result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128;
result >>= uint256(int256(63 - (x >> 64)));
require(result <= uint256(int256(MAX_64x64)));
return int128(int256(result));
}
}
/**
* Calculate natural exponent of x. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function exp(int128 x) internal pure returns (int128) {
unchecked {
require(x < 0x400000000000000000); // Overflow
if (x < -0x400000000000000000) return 0; // Underflow
return
exp_2(
int128(
(int256(x) * 0x171547652B82FE1777D0FFDA0D23A7D12) >> 128
)
);
}
}
/**
* Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
* integer numbers. Revert on overflow or when y is zero.
*
* @param x unsigned 256-bit integer number
* @param y unsigned 256-bit integer number
* @return unsigned 64.64-bit fixed point number
*/
function divuu(uint256 x, uint256 y) private pure returns (uint128) {
unchecked {
require(y != 0);
uint256 result;
if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
result = (x << 64) / y;
else {
uint256 msb = 192;
uint256 xc = x >> 192;
if (xc >= 0x100000000) {
xc >>= 32;
msb += 32;
}
if (xc >= 0x10000) {
xc >>= 16;
msb += 16;
}
if (xc >= 0x100) {
xc >>= 8;
msb += 8;
}
if (xc >= 0x10) {
xc >>= 4;
msb += 4;
}
if (xc >= 0x4) {
xc >>= 2;
msb += 2;
}
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
result = (x << (255 - msb)) / (((y - 1) >> (msb - 191)) + 1);
require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
uint256 hi = result * (y >> 128);
uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
uint256 xh = x >> 192;
uint256 xl = x << 64;
if (xl < lo) xh -= 1;
xl -= lo; // We rely on overflow behavior here
lo = hi << 128;
if (xl < lo) xh -= 1;
xl -= lo; // We rely on overflow behavior here
assert(xh == hi >> 128);
result += xl / y;
}
require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return uint128(result);
}
}
/**
* Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer
* number.
*
* @param x unsigned 256-bit integer number
* @return unsigned 128-bit integer number
*/
function sqrtu(uint256 x) private pure returns (uint128) {
unchecked {
if (x == 0) return 0;
else {
uint256 xx = x;
uint256 r = 1;
if (xx >= 0x100000000000000000000000000000000) {
xx >>= 128;
r <<= 64;
}
if (xx >= 0x10000000000000000) {
xx >>= 64;
r <<= 32;
}
if (xx >= 0x100000000) {
xx >>= 32;
r <<= 16;
}
if (xx >= 0x10000) {
xx >>= 16;
r <<= 8;
}
if (xx >= 0x100) {
xx >>= 8;
r <<= 4;
}
if (xx >= 0x10) {
xx >>= 4;
r <<= 2;
}
if (xx >= 0x8) {
r <<= 1;
}
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1; // Seven iterations should be enough
uint256 r1 = x / r;
return uint128(r < r1 ? r : r1);
}
}
}
}{
"evmVersion": "istanbul",
"optimizer": {
"enabled": true,
"runs": 1
},
"libraries": {
"BufferBinaryOptions.sol": {}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"settlementFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalFee","type":"uint256"},{"indexed":false,"internalType":"int256","name":"skew","type":"int256"},{"indexed":false,"internalType":"bytes32","name":"marketId","type":"bytes32"}],"name":"Create","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"strike","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expiration","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"marketId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"optionsContract","type":"address"}],"name":"CreateMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"config","type":"address"},{"indexed":false,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"address","name":"tokenX","type":"address"},{"indexed":false,"internalType":"string","name":"token0","type":"string"},{"indexed":false,"internalType":"string","name":"token1","type":"string"},{"indexed":false,"internalType":"enum IBufferBinaryOptions.AssetCategory","name":"category","type":"uint8"}],"name":"CreateOptionsContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceAtExpiration","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isAbove","type":"bool"}],"name":"Exercise","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"premium","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceAtExpiration","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isAbove","type":"bool"}],"name":"Expire","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LpLoss","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LpProfit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"bool","name":"isReferralValid","type":"bool"},{"indexed":false,"internalType":"uint256","name":"totalFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"referrerFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rebate","type":"uint256"},{"indexed":false,"internalType":"string","name":"referralCode","type":"string"}],"name":"UpdateReferral","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROUTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"_getReferralDiscount","outputs":[{"internalType":"uint256","name":"referralDiscount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addressToApprove","type":"address"}],"name":"approveAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approvePoolToTransferTokenX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvedAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetCategory","outputs":[{"internalType":"enum IBufferBinaryOptions.AssetCategory","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetPair","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"iv","type":"uint256"}],"name":"baseFeePerContract","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"config","outputs":[{"internalType":"contract IOptionsConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"sf","type":"uint256"},{"internalType":"uint256","name":"iv","type":"uint256"},{"internalType":"bool","name":"allowPartialFill","type":"bool"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"contracts","type":"uint256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"string","name":"referralCode","type":"string"}],"internalType":"struct IBufferBinaryOptions.OptionParams","name":"optionParams","type":"tuple"},{"internalType":"uint256","name":"queuedTime","type":"uint256"}],"name":"createFromRouter","outputs":[{"internalType":"uint256","name":"optionID","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"sf","type":"uint256"},{"internalType":"uint256","name":"iv","type":"uint256"},{"internalType":"bool","name":"allowPartialFill","type":"bool"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"contracts","type":"uint256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"string","name":"referralCode","type":"string"}],"internalType":"struct IBufferBinaryOptions.OptionParams","name":"optionParams","type":"tuple"}],"name":"evaluateParams","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"revisedContracts","type":"uint256"},{"internalType":"uint256","name":"revisedSf","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"iv","type":"uint256"},{"internalType":"uint256","name":"sf","type":"uint256"}],"name":"fees","outputs":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"settlementFee","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"}],"name":"getMarketId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"marketId","type":"bytes32"},{"internalType":"uint256","name":"_baseFeePerContract","type":"uint256"}],"name":"getMaxPermissibleContracts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"baseSettlementFeePercentage","type":"uint256"}],"name":"getSettlementFeePercentage","outputs":[{"internalType":"uint256","name":"settlementFeePercentage","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"marketId","type":"bytes32"}],"name":"getSkew","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"_tokenX","type":"address"},{"internalType":"contract ILiquidityPool","name":"_pool","type":"address"},{"internalType":"contract IOptionsConfig","name":"_config","type":"address"},{"internalType":"contract IReferralStorage","name":"_referral","type":"address"},{"internalType":"enum IBufferBinaryOptions.AssetCategory","name":"_category","type":"uint8"},{"internalType":"string","name":"_token0","type":"string"},{"internalType":"string","name":"_token1","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"expiration","type":"uint256"}],"name":"isExpirationValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"markets","outputs":[{"internalType":"bytes32","name":"marketId","type":"bytes32"},{"internalType":"uint256","name":"contractsUp","type":"uint256"},{"internalType":"uint256","name":"contractsDown","type":"uint256"},{"internalType":"int256","name":"premiumUp","type":"int256"},{"internalType":"int256","name":"premiumDown","type":"int256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"bool","name":"isValid","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"options","outputs":[{"internalType":"enum IBufferBinaryOptions.State","name":"state","type":"uint8"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"lockedAmount","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint256","name":"createdAt","type":"uint256"},{"internalType":"bool","name":"isAbove","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract ILiquidityPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referral","outputs":[{"internalType":"contract IReferralStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"}],"name":"runInitialChecks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setIsPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stepSize","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenX","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMarketOI","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"optionID","type":"uint256"},{"internalType":"uint256","name":"closingPrice","type":"uint256"}],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userOptionIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60806040526000600855600a805462ffff0019166119001790553480156200002657600080fd5b506040805180820182526006815265213ab33332b960d11b60208083019182528351808501909452600384526221232960e91b9084015260016000819055825192939262000075929062000157565b5080516200008b90600290602084019062000157565b506200009d91506000905033620000a3565b6200023a565b620000af8282620000b3565b5050565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff16620000af5760008281526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001133390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b8280546200016590620001fd565b90600052602060002090601f016020900481019282620001895760008555620001d4565b82601f10620001a457805160ff1916838001178555620001d4565b82800160010185558215620001d4579182015b82811115620001d4578251825591602001919060010190620001b7565b50620001e2929150620001e6565b5090565b5b80821115620001e25760008155600101620001e7565b600181811c908216806200021257607f821691505b602082108114156200023457634e487b7160e01b600052602260045260246000fd5b50919050565b615735806200024a6000396000f3fe608060405234801561001057600080fd5b50600436106102725760003560e01c806301ffc9a71461027757806306fdde031461029f5780630814f2d1146102b4578063081812fc146102d5578063095ea7b3146102f55780630dfe16811461030a57806310082c75146103125780631441a5a91461031a57806316dc165b1461032d57806316f0115b146103405780631b3979c01461035357806320a6c8ba146103665780632313dd021461037957806323b872dd14610382578063248a9ca3146103955780632c26d8ee146103a85780632d293b63146103c95780632f2ff15d146103eb57806330d643b5146103fe578063313ce5671461041357806336568abe1461041b57806336ebafe91461042e578063409e22051461045457806342842e0e146104c757806356799e5f146104da5780635bfadb24146104e2578063617c6719146104f55780636352211e14610508578063645734e61461051b5780636c6a22a61461052357806370a08231146105365780637564912b1461054957806375794a3c146105da57806379502c55146105e35780638f29a3d4146105f657806391d148541461060957806395d89b411461061c5780639818cd3d14610624578063a217fddf14610637578063a22cb4651461063f578063a6512c3f14610652578063b187bd2614610665578063b88d4fde14610672578063c87b56dd14610685578063c962ca1214610698578063d115117e146106ab578063d21220a7146106be578063d45497f8146106c6578063d547741f146106d9578063e63ab1e9146106ec578063e779d5da14610701578063e985e9c514610724578063f136a87414610737578063fabf657a1461075a575b600080fd5b61028a610285366004614d1b565b61076d565b60405190151581526020015b60405180910390f35b6102a761077e565b6040516102969190615211565b6102c76102c2366004614cfa565b610810565b604051908152602001610296565b6102e86102e3366004614cbe565b61094d565b60405161029691906150b5565b610308610303366004614bcd565b610974565b005b6102a7610a8f565b6102a7610b1d565b600f546102e8906001600160a01b031681565b6010546102e8906001600160a01b031681565b600d546102e8906001600160a01b031681565b610308610361366004614d53565b610b48565b6102c7610374366004614ae4565b610ccc565b6102c760095481565b610308610390366004614ae4565b610cee565b6102c76103a3366004614cbe565b610d1f565b600f546103bc90600160a01b900460ff1681565b604051610296919061516b565b6103dc6103d7366004614c73565b610d34565b604051610296939291906151cc565b6103086103f9366004614cd6565b610d87565b6102c76000805160206156e083398151915281565b6102c7610da3565b610308610429366004614cd6565b610e28565b600a5461044190610100900461ffff1681565b60405161ffff9091168152602001610296565b6104b2610462366004614cbe565b60116020526000908152604090208054600182015460028301546003840154600485015460058601546006870154600788015460089098015460ff97881698969795969495939492939192911689565b60405161029699989796959493929190615179565b6103086104d5366004614ae4565b610ea6565b610308610ec1565b6103086104f0366004614cfa565b610f8a565b6102c7610503366004614aac565b6112b2565b6102e8610516366004614cbe565b611424565b61030861142f565b6102c7610531366004614cbe565b6114bc565b6102c7610544366004614a74565b611529565b61059d610557366004614cbe565b6014602052600090815260409020805460018201546002830154600384015460048501546005860154600687015460079097015495969495939492939192909160ff1688565b604080519889526020890197909752958701949094526060860192909252608085015260a084015260c0830152151560e082015261010001610296565b6102c760085481565b600e546102e8906001600160a01b031681565b61028a610604366004614cbe565b6115af565b61028a610617366004614cd6565b611654565b6102a761167f565b610308610632366004614cfa565b61168e565b6102c7600081565b61030861064d366004614ba0565b61198e565b6102c7610660366004614cfa565b611999565b600a5461028a9060ff1681565b610308610680366004614b24565b6119c5565b6102a7610693366004614cbe565b6119f7565b6102c76106a6366004614bcd565b611a6a565b6102c76106b9366004614e5d565b611a9b565b6102a76120e6565b6102c76106d4366004614c30565b6120f3565b6103086106e7366004614cd6565b61213a565b6102c76000805160206156a083398151915281565b61071461070f366004614e2b565b612156565b604051610296949392919061530e565b61028a610732366004614aac565b61264f565b61028a610745366004614a74565b60136020526000908152604090205460ff1681565b610308610768366004614a74565b61267d565b6000610778826126ad565b92915050565b60606001805461078d90615584565b80601f01602080910402602001604051908101604052809291908181526020018280546107b990615584565b80156108065780601f106107db57610100808354040283529160200191610806565b820191906000526020600020905b8154815290600101906020018083116107e957829003601f168201915b5050505050905090565b600081600e60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561086157600080fd5b505afa158015610875573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108999190614e13565b6108a3919061552a565b6108ac846114bc565b600e60009054906101000a90046001600160a01b03166001600160a01b03166350ec40e06040518163ffffffff1660e01b815260040160206040518083038186803b1580156108fa57600080fd5b505afa15801561090e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109329190614e13565b61093c91906154eb565b61094691906153cd565b9392505050565b6000610958826126d2565b506000908152600560205260409020546001600160a01b031690565b600061097f826126f7565b9050806001600160a01b0316836001600160a01b031614156109f25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610a0e5750610a0e813361264f565b610a805760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c000060648201526084016109e9565b610a8a838361272c565b505050565b600b8054610a9c90615584565b80601f0160208091040260200160405190810160405280929190818152602001828054610ac890615584565b8015610b155780601f10610aea57610100808354040283529160200191610b15565b820191906000526020600020905b815481529060010190602001808311610af857829003601f168201915b505050505081565b6060600b600c604051602001610b34929190615031565b604051602081830303815290604052905090565b6000610b538161279a565b6010546001600160a01b0316610c8457601080546001600160a01b03808b166001600160a01b031992831617909255600d80548a8416908316179055600e8054898416908316179055600f805492881691831682178155869290916001600160a81b031990911617600160a01b836002811115610be057634e487b7160e01b600052602160045260246000fd5b02179055508251610bf890600b90602086019061492f565b508151610c0c90600c90602085019061492f565b50610c186000336127a4565b600e54600d54601054600f546040517f13d3a1031aba66188cca5785e8045078864e8f69c24715761bf0449ef10304d694610c77946001600160a01b039182169490821693911691600b91600c91600160a01b90910460ff16906150c9565b60405180910390a1610cc2565b60405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016109e9565b5050505050505050565b806000610cd985856112b2565b9050610ce5818361552a565b95945050505050565b610cf833826127ae565b610d145760405162461bcd60e51b81526004016109e9906152a8565b610a8a83838361280c565b60009081526007602052604090206001015490565b600080600080610d478a8a8a8a8a6120f3565b9050612710610d5686836154cc565b610d6091906153cd565b9250610d6c83826153b5565b9350610d78838261552a565b91505096509650969350505050565b610d9082610d1f565b610d998161279a565b610a8a83836129a1565b6010546040805163313ce56760e01b815290516000926001600160a01b03169163313ce567916004808301926020929190829003018186803b158015610de857600080fd5b505afa158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e209190614e9f565b60ff16905090565b6001600160a01b0381163314610e985760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016109e9565b610ea28282612a27565b5050565b610a8a838383604051806020016040528060008152506119c5565b610ed96000805160206156a083398151915233611654565b15610ef057600a805460ff19166001179055610f4c565b610efb600033611654565b15610f1757600a805460ff19811660ff90911615179055610f4c565b60405162461bcd60e51b815260206004820152600a60248201526957726f6e6720726f6c6560b01b60448201526064016109e9565b600a5460405160ff909116151581527f9422424b175dda897495a07b091ef74a3ef715cf6d866fc972954c1c7f4593049060200160405180910390a1565b6000805160206156e0833981519152610fa28161279a565b610fab83612a8e565b610fdd5760405162461bcd60e51b815260206004820152600360248201526204f31360ec1b60448201526064016109e9565b600083815260116020526040902060058101544210156110245760405162461bcd60e51b815260206004820152600260248201526113cd60f21b60448201526064016109e9565b6001815460ff16600381111561104a57634e487b7160e01b600052602160045260246000fd5b1461107c5760405162461bcd60e51b81526020600482015260026024820152614f3560f01b60448201526064016109e9565b600881015460009060ff1680156110965750816001015484115b806110b45750600882015460ff161580156110b45750816001015484105b156110d55760088201546110ce908690869060ff16612aab565b9050611190565b815460ff19166003178255600d54604051636198e33960e01b8152600481018790526001600160a01b0390911690636198e33990602401600060405180830381600087803b15801561112657600080fd5b505af115801561113a573d6000803e3d6000fd5b5050505061114785612c8e565b6004820154600883015460405187927f06b9a7d5e559ec958118dcc25fab116916793fa9782acbf47186bf70bc4cf88e9261118792899160ff16906152f6565b60405180910390a25b8160060154600960008282546111a6919061552a565b9091555050600e546040805163488d8b8f60e11b815290516001600160a01b039092169163911b171e91600480820192602092909190829003018186803b1580156111f057600080fd5b505afa158015611204573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112289190614a90565b6001600160a01b0316633a5d92a883600601548361124691906154eb565b8460040154856006015461125a919061552a565b886040518463ffffffff1660e01b8152600401611279939291906151cc565b600060405180830381600087803b15801561129357600080fd5b505af11580156112a7573d6000803e3d6000fd5b505050505050505050565b600080826001600160a01b0316846001600160a01b0316141580156112df57506001600160a01b03841615155b80156112f357506001600160a01b0384163b155b1561140557600f5460405163010de89960e21b81526000916001600160a01b03169063ad1b1493908290630437a26490611331908a906004016150b5565b60206040518083038186803b15801561134957600080fd5b505afa15801561135d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113819190614e9f565b6040516001600160e01b031960e084901b16815260ff909116600482015260240160206040518083038186803b1580156113ba57600080fd5b505afa1580156113ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f29190614e9f565b905061140160ff8216836153b5565b9150505b600a5461141c908290610100900461ffff166154cc565b949350505050565b6000610778826126f7565b601054600d5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926114679291169060001990600401615152565b602060405180830381600087803b15801561148157600080fd5b505af1158015611495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b99190614c14565b50565b600081815260146020526040812060038101546004909101546114df9190615374565b6114e7610da3565b6114f290600a615424565b600084815260146020526040902060018101546002909101546115159190612d23565b61151f91906154cc565b61077891906154eb565b60006001600160a01b0382166115935760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016109e9565b506001600160a01b031660009081526004602052604090205490565b600061a8c06115be428461552a565b10156115cc57506000919050565b600062034bc06115dc428561552a565b1080156116005750620151806115f48461e1006153b5565b6115fe91906155d4565b155b9050600062093a80617080611618620151808761552a565b611622919061552a565b61162c91906155d4565b1580156116445750620b34c0611642428661552a565b105b9050818061141c57509392505050565b60009182526007602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606002805461078d90615584565b6000805160206156e08339815191526116a68161279a565b60006116b28484611999565b9050428310806116cc575061a8c06116ca428561552a565b105b156117085760405162461bcd60e51b815260206004820152600c60248201526b57726f6e672065787069727960a01b60448201526064016109e9565b60008181526014602052604090206007015460ff16156117285750505050565b611731836115af565b80156117ca5750600e60009054906101000a90046001600160a01b03166001600160a01b031663d63a95cf6040518163ffffffff1660e01b815260040160206040518083038186803b15801561178657600080fd5b505afa15801561179a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117be9190614e13565b6117c890856155d4565b155b1561194157604051806101000160405280828152602001601460008481526020019081526020016000206001015481526020016014600084815260200190815260200160002060020154815260200160146000848152602001908152602001600020600301548152602001601460008481526020019081526020016000206004015481526020018581526020018481526020016001151581525060146000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a81548160ff0219169083151502179055509050507f6ca25eaa4499ac325317dc06194c2e2084ab8546a6ea17b3d91f8deefe74d82b848483306040516119349493929190938452602084019290925260408301526001600160a01b0316606082015260800190565b60405180910390a1611988565b60405162461bcd60e51b815260206004820152601c60248201527b24b73b30b634b21039ba3934b5b29037b91032bc3834b930ba34b7b760211b60448201526064016109e9565b50505050565b610ea2338383612d39565b604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b6119cf33836127ae565b6119eb5760405162461bcd60e51b81526004016109e9906152a8565b61198884848484612e04565b6060611a02826126d2565b6000611a1960408051602081019091526000815290565b90506000815111611a395760405180602001604052806000815250610946565b80611a4384612e37565b604051602001611a54929190615002565b6040516020818303038152906040529392505050565b60126020528160005260406000208181548110611a8657600080fd5b90600052602060002001600091509150505481565b60006000805160206156e0833981519152611ab58161279a565b60008460c001358560e00135604051602001611adb929190918252602082015260400190565b60405160208183030381529060405280519060200120905060006127108660200135876101200135611b0d91906154cc565b611b1791906153cd565b9050600060405180610120016040528060016003811115611b4857634e487b7160e01b600052602160045260246000fd5b815260c08901356020820152610100890135604082018190526060820152608001611b78846101208b013561552a565b81526020018860e0013581526020018861012001358152602001878152602001886080016020810190611bab9190614bf8565b151590529050611bb9612f50565b945060126000611bcc60208a018a614a74565b6001600160a01b031681526020808201929092526040908101600090812080546001818101835591835284832001899055888252601190935220825181548493839160ff191690836003811115611c3357634e487b7160e01b600052602160045260246000fd5b0217905550602082810151600183015560408301516002830155606083015160038301556080830151600483015560a0830151600583015560c0830151600683015560e08301516007830155610100909201516008909101805460ff1916911515919091179055611cb090611caa90890189614a74565b86612f6a565b600e54604080516309b41a1b60e11b81529051611d41926001600160a01b0316916313683436916004808301926020929190829003018186803b158015611cf657600080fd5b505afa158015611d0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d2e9190614a90565b6010546001600160a01b03169084613096565b600d546060820151608083015160405163edd0d42160e01b81526001600160a01b039093169263edd0d42192611d7b928a926004016151cc565b600060405180830381600087803b158015611d9557600080fd5b505af1158015611da9573d6000803e3d6000fd5b50505050600e60009054906101000a90046001600160a01b03166001600160a01b03166395b12ea36040518163ffffffff1660e01b815260040160206040518083038186803b158015611dfb57600080fd5b505afa158015611e0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e339190614a90565b6001600160a01b031663710b28158630611e5060208c018c614a74565b6040516001600160e01b031960e086901b16815260048101939093526001600160a01b039182166024840152166044820152606401600060405180830381600087803b158015611e9f57600080fd5b505af1158015611eb3573d6000803e3d6000fd5b5050505086610120013560096000828254611ece91906153b5565b90915550611ee4905060a0880160808901614bf8565b15611f4f576000838152601460205260408120600101805460a08a01359290611f0e9084906153b5565b90915550611f2390508261012089013561552a565b60008481526014602052604081206003018054909190611f44908490615374565b90915550611fb09050565b6000838152601460205260408120600201805460a08a01359290611f749084906153b5565b90915550611f8990508261012089013561552a565b60008481526014602052604081206004018054909190611faa908490615374565b90915550505b6000611fbb846114bc565b9050600e60009054906101000a90046001600160a01b03166001600160a01b03166350ec40e06040518163ffffffff1660e01b815260040160206040518083038186803b15801561200b57600080fd5b505afa15801561201f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120439190614e13565b8113156120825760405162461bcd60e51b815260206004820152600d60248201526c098dee6e640e8dede40d0d2ced609b1b60448201526064016109e9565b8561209060208a018a614a74565b6001600160a01b03167ffa6101f13be10247a3f27ba031321ca444c4bf1eb56aade9f1c96f5e621164aa858b610120013585896040516120d3949392919061530e565b60405180910390a3505050505092915050565b600c8054610a9c90615584565b60006305f5e100612102610da3565b61210d90600a615424565b61211c8487898860018d6130ec565b61212691906154cc565b61213091906153cd565b9695505050505050565b61214382610d1f565b61214c8161279a565b610a8a8383612a27565b600a5460009081908190819060ff16156121985760405162461bcd60e51b81526020600482015260036024820152624f333360e81b60448201526064016109e9565b6001600f54600160a01b900460ff1660028111156121c657634e487b7160e01b600052602160045260246000fd5b14806122dd5750600e60009054906101000a90046001600160a01b03166001600160a01b0316632677327a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561221b57600080fd5b505afa15801561222f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122539190614a90565b6001600160a01b031663f7d52fa161226f4260e089013561552a565b6040518263ffffffff1660e01b815260040161228d91815260200190565b60206040518083038186803b1580156122a557600080fd5b505afa1580156122b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122dd9190614c14565b61230f5760405162461bcd60e51b815260206004820152600360248201526204f33360ec1b60448201526064016109e9565b600061234761232460a0880160808901614bf8565b61014088013560c089013561233d4260e08c013561552a565b8a604001356120f3565b90506002612353610da3565b61235d919061552a565b61236890600a615424565b6123739060056154cc565b81116123b05760405162461bcd60e51b815260206004820152600c60248201526b46656520746f6f206c65737360a01b60448201526064016109e9565b60026123ba610da3565b6123c4919061552a565b6123cf90600a615424565b6123da90605f6154cc565b81106124175760405162461bcd60e51b815260206004820152600c60248201526b08ccaca40e8dede40d0d2ced60a31b60448201526064016109e9565b60008660c001358760e0013560405160200161243d929190918252602082015260400190565b60408051601f198184030181529190528051602090910120600f549091506124ff906001600160a01b0316637d191bdb61247b6101608b018b615329565b6040518363ffffffff1660e01b81526004016124989291906151e2565b60206040518083038186803b1580156124b057600080fd5b505afa1580156124c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124e89190614a90565b6124f560208a018a614a74565b8960200135610ccc565b925061271061250e84846154cc565b61251891906153cd565b61252290836153b5565b945060006125308287610810565b90506125576125438960a00135836131bc565b612552886101208c01356153cd565b6131bc565b9450848860a00135146125a6576125746080890160608a01614bf8565b6125a65760405162461bcd60e51b81526020600482015260036024820152624f323960e81b60448201526064016109e9565b6125b085876154cc565b955084600e60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561260157600080fd5b505afa158015612615573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126399190614e13565b61264391906154cc565b96505050509193509193565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b60006126888161279a565b506001600160a01b03166000908152601360205260409020805460ff19166001179055565b60006001600160e01b03198216637965db0b60e01b14806107785750610778826131cb565b6126db81612a8e565b6114b95760405162461bcd60e51b81526004016109e990615276565b6000818152600360205260408120546001600160a01b0316806107785760405162461bcd60e51b81526004016109e990615276565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612761826126f7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6114b9813361321b565b610ea282826129a1565b6000806127ba836126f7565b9050806001600160a01b0316846001600160a01b031614806127e157506127e1818561264f565b8061141c5750836001600160a01b03166127fa8461094d565b6001600160a01b031614949350505050565b826001600160a01b031661281f826126f7565b6001600160a01b0316146128835760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016109e9565b6001600160a01b0382166128e55760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016109e9565b6128f083838361327f565b6128fb60008261272c565b6001600160a01b038316600090815260046020526040812080546001929061292490849061552a565b90915550506001600160a01b03821660009081526004602052604081208054600192906129529084906153b5565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716916000805160206156c083398151915291a4505050565b6129ab8282611654565b610ea25760008281526007602090815260408083206001600160a01b03851684529091529020805460ff191660011790556129e33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b612a318282611654565b15610ea25760008281526007602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000908152600360205260409020546001600160a01b0316151590565b600083815260116020526040812081612ac386611424565b6003830154600d546040516381b34f1560e01b8152600481018a9052306024820152604481018390529195509192506001600160a01b03909116906381b34f1590606401600060405180830381600087803b158015612b2157600080fd5b505af1158015612b35573d6000803e3d6000fd5b5050601054612b5192506001600160a01b031690508285613096565b8160030154831015612b9157600d546003830154612b91916001600160a01b031690612b7e90869061552a565b6010546001600160a01b03169190613096565b81600401548311612be457857fc88c04f82f76cf4112dc206d1a563be25c04a4a762a699eccd4d4abc6df0dff0848460040154612bce919061552a565b60405190815260200160405180910390a2612c28565b857fa569991d55d525eae5729bac6890aeb7c0bdcd198f36ca0d0a7da8c2c0a734fb836004015485612c16919061552a565b60405190815260200160405180910390a25b612c3186612c8e565b815460ff1916600217825560405186906001600160a01b038316907ff394088c7503260c927488ca4397d6b43146f13c239078415e6f14029e5cb7f890612c7d9087908a908a906152f6565b60405180910390a350509392505050565b6000612c99826126f7565b9050612ca78160008461327f565b612cb260008361272c565b6001600160a01b0381166000908152600460205260408120805460019290612cdb90849061552a565b909155505060008281526003602052604080822080546001600160a01b0319169055518391906001600160a01b038416906000805160206156c0833981519152908390a45050565b6000818311612d325781610946565b5090919050565b816001600160a01b0316836001600160a01b03161415612d975760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b60448201526064016109e9565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612e0f84848461280c565b612e1b84848484613333565b6119885760405162461bcd60e51b81526004016109e990615224565b606081612e5b5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612e855780612e6f816155b9565b9150612e7e9050600a836153cd565b9150612e5f565b6000816001600160401b03811115612ead57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612ed7576020820181803683370190505b5090505b841561141c57612eec60018361552a565b9150612ef9600a866155d4565b612f049060306153b5565b60f81b818381518110612f2757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612f49600a866153cd565b9450612edb565b6008805460009182612f61836155b9565b91905055905090565b6001600160a01b038216612fc05760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109e9565b612fc981612a8e565b156130155760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b60448201526064016109e9565b6130216000838361327f565b6001600160a01b038216600090815260046020526040812080546001929061304a9084906153b5565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392906000805160206156c0833981519152908290a45050565b610a8a8363a9059cbb60e01b84846040516024016130b5929190615152565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613447565b6000806130fc6305f5e100613519565b9050600061310b612710613519565b905060006131258261311c8c613519565b600f0b90613536565b90506000613137600f83900b8361359d565b905060006131488561311c8d613519565b905060006131598661311c8d613519565b9050600061317661316d6301e13380613519565b61311c8d613519565b90506000613188858585858f8f6135d3565b90506131a061319b600f83900b8a61359d565b6136aa565b6001600160401b03169f9e505050505050505050505050505050565b6000818310612d325781610946565b60006001600160e01b031982166380ac58cd60e01b14806131fc57506001600160e01b03198216635b5e139f60e01b145b8061077857506301ffc9a760e01b6001600160e01b0319831614610778565b6132258282611654565b610ea25761323d816001600160a01b031660146136c6565b6132488360206136c6565b604051602001613259929190615046565b60408051601f198184030181529082905262461bcd60e51b82526109e991600401615211565b6001600160a01b0383161580159061329f57506001600160a01b03821615155b80156132c457506001600160a01b03821660009081526013602052604090205460ff16155b80156132e957506001600160a01b03831660009081526013602052604090205460ff16155b15610a8a5760405162461bcd60e51b815260206004820152601a602482015279151bdad95b881d1c985b9cd9995c881b9bdd08185b1b1bddd95960321b60448201526064016109e9565b6000613347846001600160a01b03166138a7565b1561343c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061337e90339089908890889060040161511f565b602060405180830381600087803b15801561339857600080fd5b505af19250505080156133c8575060408051601f3d908101601f191682019092526133c591810190614d37565b60015b613422573d8080156133f6576040519150601f19603f3d011682016040523d82523d6000602084013e6133fb565b606091505b50805161341a5760405162461bcd60e51b81526004016109e990615224565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061141c565b506001949350505050565b600061349c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138b69092919063ffffffff16565b805190915015610a8a57808060200190518101906134ba9190614c14565b610a8a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109e9565b600060016001603f1b0382111561352f57600080fd5b5060401b90565b600081600f0b6000141561354957600080fd5b600082600f0b604085600f0b901b8161357257634e487b7160e01b600052601260045260246000fd5b05905060016001607f1b03198112801590613594575060016001607f1b038113155b61094657600080fd5b6000600f83810b9083900b0260401d60016001607f1b03198112801590613594575060016001607f1b0381131561094657600080fd5b6000806135e4600f86900b8961359d565b905060006135f482600f0b6138c5565b905060006136318261311c600186600f0b901d6136286136208e8e600f0b61353690919063ffffffff16565b600f0b6138e7565b600f0b90613921565b90506000613643600f83900b84613954565b905086156136765785156136655761365a81613987565b945050505050612130565b61365a613671826155e8565b613987565b851561369b5761365a61368882613987565b6136926001613519565b600f0b90613954565b61365a613688613671836155e8565b60008082600f0b12156136bc57600080fd5b50600f0b60401d90565b606060006136d58360026154cc565b6136e09060026153b5565b6001600160401b0381111561370557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561372f576020820181803683370190505b509050600360fc1b8160008151811061375857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061379557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006137b98460026154cc565b6137c49060016153b5565b90505b6001811115613858576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061380657634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061382a57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936138518161556d565b90506137c7565b5083156109465760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e9565b6001600160a01b03163b151590565b606061141c8484600085613a3e565b60008082600f0b12156138d757600080fd5b610778604083600f0b901b613b6d565b60008082600f0b136138f857600080fd5b608061390383613d4a565b600f0b6fb17217f7d1cf79abc9e3b39803f2f6af02901c9050919050565b6000600f83810b9083900b0160016001607f1b03198112801590613594575060016001607f1b0381131561094657600080fd5b6000600f82810b9084900b0360016001607f1b03198112801590613594575060016001607f1b0381131561094657600080fd5b600080613998600f84900b8461359d565b90506000613a1d613a026139d16139c26139ba600f87900b600360401b613921565b600f0b6138c5565b67d3c84b78b749bd6b9061359d565b6136286139f36139e389600f0b613e24565b68019abac0ea1da650369061359d565b679109f285df45239490613921565b61311c6001613a10866155e8565b600f0b901d600f0b613e57565b9050600084600f0b13613a30578061141c565b61141c600160401b82613954565b606082471015613a9f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109e9565b613aa8856138a7565b613af45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109e9565b600080866001600160a01b03168587604051613b109190614fe6565b60006040518083038185875af1925050503d8060008114613b4d576040519150601f19603f3d011682016040523d82523d6000602084013e613b52565b606091505b5091509150613b62828286613eaa565b979650505050505050565b600081613b7c57506000919050565b816001600160801b8210613b955760809190911c9060401b5b600160401b8210613bab5760409190911c9060201b5b600160201b8210613bc15760209190911c9060101b5b620100008210613bd65760109190911c9060081b5b6101008210613bea5760089190911c9060041b5b60108210613bfd5760049190911c9060021b5b60088210613c095760011b5b6001818581613c2857634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613c4e57634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613c7457634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613c9a57634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613cc057634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613ce657634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613d0c57634e487b7160e01b600052601260045260246000fd5b048201901c90506000818581613d3257634e487b7160e01b600052601260045260246000fd5b049050808210613d425780610ce5565b509392505050565b60008082600f0b13613d5b57600080fd5b6000600f83900b600160401b8112613d75576040918201911d5b600160201b8112613d88576020918201911d5b620100008112613d9a576010918201911d5b6101008112613dab576008918201911d5b60108112613dbb576004918201911d5b60048112613dcb576002918201911d5b60028112613dda576001820191505b603f19820160401b600f85900b607f8490031b6001603f1b5b6000811315613e195790800260ff81901c8281029390930192607f011c9060011d613df3565b509095945050505050565b6000600f82900b60016001607f1b03191415613e3f57600080fd5b600082600f0b12613e505781610778565b5060000390565b6000600160461b82600f0b12613e6c57600080fd5b6001600160461b031982600f0b1215613e8757506000919050565b610778608083600f0b700171547652b82fe1777d0ffda0d23a7d1202901d613ee3565b60608315613eb9575081610946565b825115613ec95782518084602001fd5b8160405162461bcd60e51b81526004016109e99190615211565b6000600160461b82600f0b12613ef857600080fd5b6001600160461b031982600f0b1215613f1357506000919050565b6001607f1b60006001603f1b8416600f0b1315613f415770016a09e667f3bcc908b2fb1366ea957d3e0260801c5b6000836001603e1b16600f0b1315613f6a577001306fe0a31b7152de8d5a46305c85edec0260801c5b6000836001603d1b16600f0b1315613f93577001172b83c7d517adcdf7c8c50eb14a791f0260801c5b6000836001603c1b16600f0b1315613fbc5770010b5586cf9890f6298b92b71842a983630260801c5b6000836001603b1b16600f0b1315613fe5577001059b0d31585743ae7c548eb68ca417fd0260801c5b6000836001603a1b16600f0b131561400e57700102c9a3e778060ee6f7caca4f7a29bde80260801c5b600083600160391b16600f0b13156140375770010163da9fb33356d84a66ae336dcdfa3f0260801c5b600083600160381b16600f0b131561406057700100b1afa5abcbed6129ab13ec11dc95430260801c5b600083600160371b16600f0b13156140895770010058c86da1c09ea1ff19d294cf2f679b0260801c5b600083600160361b16600f0b13156140b2577001002c605e2e8cec506d21bfc89a23a00f0260801c5b600083600160351b16600f0b13156140db57700100162f3904051fa128bca9c55c31e5df0260801c5b600083600160341b16600f0b1315614104577001000b175effdc76ba38e31671ca9397250260801c5b600083600160331b16600f0b131561412d57700100058ba01fb9f96d6cacd4b180917c3d0260801c5b600083600160321b16600f0b13156141565770010002c5cc37da9491d0985c348c68e7b30260801c5b600083600160311b16600f0b131561417f577001000162e525ee054754457d59952920260260801c5b600083600160301b16600f0b13156141a85770010000b17255775c040618bf4a4ade83fc0260801c5b6000836001602f1b16600f0b13156141d1577001000058b91b5bc9ae2eed81e9b7d4cfab0260801c5b6000836001602e1b16600f0b13156141fa57700100002c5c89d5ec6ca4d7c8acc017b7c90260801c5b6000836001602d1b16600f0b13156142235770010000162e43f4f831060e02d839a9d16d0260801c5b6000836001602c1b16600f0b131561424c57700100000b1721bcfc99d9f890ea069117630260801c5b6000836001602b1b16600f0b13156142755770010000058b90cf1e6d97f9ca14dbcc16280260801c5b6000836001602a1b16600f0b131561429e577001000002c5c863b73f016468f6bac5ca2b0260801c5b600083600160291b16600f0b13156142c757700100000162e430e5a18f6119e3c02282a50260801c5b600083600160281b16600f0b13156142f0577001000000b1721835514b86e6d96efd1bfe0260801c5b600083600160271b16600f0b131561431957700100000058b90c0b48c6be5df846c5b2ef0260801c5b600083600160261b16600f0b13156143425770010000002c5c8601cc6b9e94213c72737a0260801c5b600083600160251b16600f0b131561436b577001000000162e42fff037df38aa2b219f060260801c5b600083600160241b16600f0b13156143945770010000000b17217fba9c739aa5819f44f90260801c5b600083600160231b16600f0b13156143bd577001000000058b90bfcdee5acd3c1cedc8230260801c5b600083600160221b16600f0b13156143e657700100000002c5c85fe31f35a6a30da1be500260801c5b600083600160211b16600f0b131561440f5770010000000162e42ff0999ce3541b9fffcf0260801c5b600083600160201b16600f0b131561443857700100000000b17217f80f4ef5aadda455540260801c5b600083638000000016600f0b13156144615770010000000058b90bfbf8479bd5a81b51ad0260801c5b600083634000000016600f0b131561448a577001000000002c5c85fdf84bd62ae30a74cc0260801c5b600083632000000016600f0b13156144b357700100000000162e42fefb2fed257559bdaa0260801c5b600083631000000016600f0b13156144dc577001000000000b17217f7d5a7716bba4a9ae0260801c5b600083630800000016600f0b131561450557700100000000058b90bfbe9ddbac5e109cce0260801c5b600083630400000016600f0b131561452e5770010000000002c5c85fdf4b15de6f17eb0d0260801c5b600083630200000016600f0b1315614557577001000000000162e42fefa494f1478fde050260801c5b600083630100000016600f0b13156145805770010000000000b17217f7d20cf927c8e94c0260801c5b6000836280000016600f0b13156145a8577001000000000058b90bfbe8f71cb4e4b33d0260801c5b6000836240000016600f0b13156145d057700100000000002c5c85fdf477b662b269450260801c5b6000836220000016600f0b13156145f85770010000000000162e42fefa3ae53369388c0260801c5b6000836210000016600f0b131561462057700100000000000b17217f7d1d351a389d400260801c5b6000836208000016600f0b13156146485770010000000000058b90bfbe8e8b2d3d4ede0260801c5b6000836204000016600f0b1315614670577001000000000002c5c85fdf4741bea6e77e0260801c5b6000836202000016600f0b131561469857700100000000000162e42fefa39fe95583c20260801c5b6000836201000016600f0b13156146bf5769b17217f7d1cfb72b45e1600160801b010260801c5b60008361800016600f0b13156146e5576958b90bfbe8e7cc35c3f0600160801b010260801c5b60008361400016600f0b131561470b57692c5c85fdf473e242ea38600160801b010260801c5b60008361200016600f0b13156147315769162e42fefa39f02b772c600160801b010260801c5b60008361100016600f0b131561475757690b17217f7d1cf7d83c1a600160801b010260801c5b60008361080016600f0b131561477d5769058b90bfbe8e7bdcbe2e600160801b010260801c5b60008361040016600f0b13156147a3576902c5c85fdf473dea871f600160801b010260801c5b60008361020016600f0b13156147c957690162e42fefa39ef44d91600160801b010260801c5b60008361010016600f0b13156147ee5768b17217f7d1cf79e949600160801b010260801c5b600083608016600f0b1315614812576858b90bfbe8e7bce544600160801b010260801c5b600083604016600f0b131561483657682c5c85fdf473de6eca600160801b010260801c5b600083602016600f0b131561485a5768162e42fefa39ef366f600160801b010260801c5b600083601016600f0b131561487e57680b17217f7d1cf79afa600160801b010260801c5b600083600816600f0b13156148a25768058b90bfbe8e7bcd6d600160801b010260801c5b600083600416600f0b13156148c6576802c5c85fdf473de6b2600160801b010260801c5b600083600216600f0b13156148ea57680162e42fefa39ef358600160801b010260801c5b600083600116600f0b131561490d5767b17217f7d1cf79ab600160801b010260801c5b600f83810b60401d603f03900b1c60016001607f1b0381111561077857600080fd5b82805461493b90615584565b90600052602060002090601f01602090048101928261495d57600085556149a3565b82601f1061497657805160ff19168380011785556149a3565b828001600101855582156149a3579182015b828111156149a3578251825591602001919060010190614988565b506149af9291506149b3565b5090565b5b808211156149af57600081556001016149b4565b60006001600160401b03808411156149e2576149e2615650565b604051601f8501601f19908116603f01168101908282118183101715614a0a57614a0a615650565b81604052809350858152868686011115614a2357600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112614a4d578081fd5b610946838335602085016149c8565b60006101808284031215614a6e578081fd5b50919050565b600060208284031215614a85578081fd5b813561094681615666565b600060208284031215614aa1578081fd5b815161094681615666565b60008060408385031215614abe578081fd5b8235614ac981615666565b91506020830135614ad981615666565b809150509250929050565b600080600060608486031215614af8578081fd5b8335614b0381615666565b92506020840135614b1381615666565b929592945050506040919091013590565b60008060008060808587031215614b39578081fd5b8435614b4481615666565b93506020850135614b5481615666565b92506040850135915060608501356001600160401b03811115614b75578182fd5b8501601f81018713614b85578182fd5b614b94878235602084016149c8565b91505092959194509250565b60008060408385031215614bb2578182fd5b8235614bbd81615666565b91506020830135614ad98161567b565b60008060408385031215614bdf578182fd5b8235614bea81615666565b946020939093013593505050565b600060208284031215614c09578081fd5b81356109468161567b565b600060208284031215614c25578081fd5b81516109468161567b565b600080600080600060a08688031215614c47578283fd5b8535614c528161567b565b97602087013597506040870135966060810135965060800135945092505050565b60008060008060008060c08789031215614c8b578384fd5b8635614c968161567b565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b600060208284031215614ccf578081fd5b5035919050565b60008060408385031215614ce8578182fd5b823591506020830135614ad981615666565b60008060408385031215614d0c578182fd5b50508035926020909101359150565b600060208284031215614d2c578081fd5b813561094681615689565b600060208284031215614d48578081fd5b815161094681615689565b600080600080600080600060e0888a031215614d6d578485fd5b8735614d7881615666565b96506020880135614d8881615666565b95506040880135614d9881615666565b94506060880135614da881615666565b9350608088013560038110614dbb578182fd5b925060a08801356001600160401b0380821115614dd6578283fd5b614de28b838c01614a3d565b935060c08a0135915080821115614df7578283fd5b50614e048a828b01614a3d565b91505092959891949750929550565b600060208284031215614e24578081fd5b5051919050565b600060208284031215614e3c578081fd5b81356001600160401b03811115614e51578182fd5b61141c84828501614a5c565b60008060408385031215614e6f578182fd5b82356001600160401b03811115614e84578283fd5b614e9085828601614a5c565b95602094909401359450505050565b600060208284031215614eb0578081fd5b815160ff81168114610946578182fd5b60008151808452614ed8816020860160208601615541565b601f01601f19169290920160200192915050565b60038110614efc57614efc61563a565b9052565b60008154614f0d81615584565b808552602060018381168015614f2a5760018114614f3e57614f6c565b60ff19851688840152604088019550614f6c565b866000528260002060005b85811015614f645781548a8201860152908301908401614f49565b890184019650505b505050505092915050565b60008154614f8481615584565b60018281168015614f9c5760018114614fad57614fdc565b60ff19841687528287019450614fdc565b8560005260208060002060005b85811015614fd35781548a820152908401908201614fba565b50505082870194505b5050505092915050565b60008251614ff8818460208701615541565b9190910192915050565b60008351615014818460208801615541565b835190830190615028818360208801615541565b01949350505050565b600061141c6150408386614f77565b84614f77565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615078816017850160208801615541565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516150a9816028840160208801615541565b01602801949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b03878116825286811660208301528516604082015260c0606082018190526000906150fd90830186614f00565b828103608084015261510f8186614f00565b915050613b6260a0830184614eec565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061213090830184614ec0565b6001600160a01b03929092168252602082015260400190565b602081016107788284614eec565b610120810160048b1061518e5761518e61563a565b998152602081019890985260408801969096526060870194909452608086019290925260a085015260c084015260e083015215156101009091015290565b9283526020830191909152604082015260600190565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6020815260006109466020830184614ec0565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b92835260208301919091521515604082015260600190565b93845260208401929092526040830152606082015260800190565b6000808335601e1984360301811261533f578283fd5b8301803591506001600160401b03821115615358578283fd5b60200191503681900382131561536d57600080fd5b9250929050565b600080821280156001600160ff1b03849003851316156153965761539661560e565b600160ff1b83900384128116156153af576153af61560e565b50500190565b600082198211156153c8576153c861560e565b500190565b6000826153dc576153dc615624565b500490565b600181815b8085111561541c5781600019048211156154025761540261560e565b8085161561540f57918102915b93841c93908002906153e6565b509250929050565b6000610946838360008261543a57506001610778565b8161544757506000610778565b816001811461545d576002811461546757615483565b6001915050610778565b60ff8411156154785761547861560e565b50506001821b610778565b5060208310610133831016604e8410600b84101617156154a6575081810a610778565b6154b083836153e1565b80600019048211156154c4576154c461560e565b029392505050565b60008160001904831182151516156154e6576154e661560e565b500290565b60008083128015600160ff1b8501841216156155095761550961560e565b6001600160ff1b03840183138116156155245761552461560e565b50500390565b60008282101561553c5761553c61560e565b500390565b60005b8381101561555c578181015183820152602001615544565b838111156119885750506000910152565b60008161557c5761557c61560e565b506000190190565b600181811c9082168061559857607f821691505b60208210811415614a6e57634e487b7160e01b600052602260045260246000fd5b60006000198214156155cd576155cd61560e565b5060010190565b6000826155e3576155e3615624565b500690565b6000600f82900b60016001607f1b03198114156156075761560761560e565b9003919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146114b957600080fd5b80151581146114b957600080fd5b6001600160e01b0319811681146114b957600080fdfe65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862addf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2a2646970667358221220e955746c05f93493f7e45c45ab3fd19cc146d892ddae1494896d00baae56079364736f6c63430008040033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102725760003560e01c806301ffc9a71461027757806306fdde031461029f5780630814f2d1146102b4578063081812fc146102d5578063095ea7b3146102f55780630dfe16811461030a57806310082c75146103125780631441a5a91461031a57806316dc165b1461032d57806316f0115b146103405780631b3979c01461035357806320a6c8ba146103665780632313dd021461037957806323b872dd14610382578063248a9ca3146103955780632c26d8ee146103a85780632d293b63146103c95780632f2ff15d146103eb57806330d643b5146103fe578063313ce5671461041357806336568abe1461041b57806336ebafe91461042e578063409e22051461045457806342842e0e146104c757806356799e5f146104da5780635bfadb24146104e2578063617c6719146104f55780636352211e14610508578063645734e61461051b5780636c6a22a61461052357806370a08231146105365780637564912b1461054957806375794a3c146105da57806379502c55146105e35780638f29a3d4146105f657806391d148541461060957806395d89b411461061c5780639818cd3d14610624578063a217fddf14610637578063a22cb4651461063f578063a6512c3f14610652578063b187bd2614610665578063b88d4fde14610672578063c87b56dd14610685578063c962ca1214610698578063d115117e146106ab578063d21220a7146106be578063d45497f8146106c6578063d547741f146106d9578063e63ab1e9146106ec578063e779d5da14610701578063e985e9c514610724578063f136a87414610737578063fabf657a1461075a575b600080fd5b61028a610285366004614d1b565b61076d565b60405190151581526020015b60405180910390f35b6102a761077e565b6040516102969190615211565b6102c76102c2366004614cfa565b610810565b604051908152602001610296565b6102e86102e3366004614cbe565b61094d565b60405161029691906150b5565b610308610303366004614bcd565b610974565b005b6102a7610a8f565b6102a7610b1d565b600f546102e8906001600160a01b031681565b6010546102e8906001600160a01b031681565b600d546102e8906001600160a01b031681565b610308610361366004614d53565b610b48565b6102c7610374366004614ae4565b610ccc565b6102c760095481565b610308610390366004614ae4565b610cee565b6102c76103a3366004614cbe565b610d1f565b600f546103bc90600160a01b900460ff1681565b604051610296919061516b565b6103dc6103d7366004614c73565b610d34565b604051610296939291906151cc565b6103086103f9366004614cd6565b610d87565b6102c76000805160206156e083398151915281565b6102c7610da3565b610308610429366004614cd6565b610e28565b600a5461044190610100900461ffff1681565b60405161ffff9091168152602001610296565b6104b2610462366004614cbe565b60116020526000908152604090208054600182015460028301546003840154600485015460058601546006870154600788015460089098015460ff97881698969795969495939492939192911689565b60405161029699989796959493929190615179565b6103086104d5366004614ae4565b610ea6565b610308610ec1565b6103086104f0366004614cfa565b610f8a565b6102c7610503366004614aac565b6112b2565b6102e8610516366004614cbe565b611424565b61030861142f565b6102c7610531366004614cbe565b6114bc565b6102c7610544366004614a74565b611529565b61059d610557366004614cbe565b6014602052600090815260409020805460018201546002830154600384015460048501546005860154600687015460079097015495969495939492939192909160ff1688565b604080519889526020890197909752958701949094526060860192909252608085015260a084015260c0830152151560e082015261010001610296565b6102c760085481565b600e546102e8906001600160a01b031681565b61028a610604366004614cbe565b6115af565b61028a610617366004614cd6565b611654565b6102a761167f565b610308610632366004614cfa565b61168e565b6102c7600081565b61030861064d366004614ba0565b61198e565b6102c7610660366004614cfa565b611999565b600a5461028a9060ff1681565b610308610680366004614b24565b6119c5565b6102a7610693366004614cbe565b6119f7565b6102c76106a6366004614bcd565b611a6a565b6102c76106b9366004614e5d565b611a9b565b6102a76120e6565b6102c76106d4366004614c30565b6120f3565b6103086106e7366004614cd6565b61213a565b6102c76000805160206156a083398151915281565b61071461070f366004614e2b565b612156565b604051610296949392919061530e565b61028a610732366004614aac565b61264f565b61028a610745366004614a74565b60136020526000908152604090205460ff1681565b610308610768366004614a74565b61267d565b6000610778826126ad565b92915050565b60606001805461078d90615584565b80601f01602080910402602001604051908101604052809291908181526020018280546107b990615584565b80156108065780601f106107db57610100808354040283529160200191610806565b820191906000526020600020905b8154815290600101906020018083116107e957829003601f168201915b5050505050905090565b600081600e60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561086157600080fd5b505afa158015610875573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108999190614e13565b6108a3919061552a565b6108ac846114bc565b600e60009054906101000a90046001600160a01b03166001600160a01b03166350ec40e06040518163ffffffff1660e01b815260040160206040518083038186803b1580156108fa57600080fd5b505afa15801561090e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109329190614e13565b61093c91906154eb565b61094691906153cd565b9392505050565b6000610958826126d2565b506000908152600560205260409020546001600160a01b031690565b600061097f826126f7565b9050806001600160a01b0316836001600160a01b031614156109f25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610a0e5750610a0e813361264f565b610a805760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c000060648201526084016109e9565b610a8a838361272c565b505050565b600b8054610a9c90615584565b80601f0160208091040260200160405190810160405280929190818152602001828054610ac890615584565b8015610b155780601f10610aea57610100808354040283529160200191610b15565b820191906000526020600020905b815481529060010190602001808311610af857829003601f168201915b505050505081565b6060600b600c604051602001610b34929190615031565b604051602081830303815290604052905090565b6000610b538161279a565b6010546001600160a01b0316610c8457601080546001600160a01b03808b166001600160a01b031992831617909255600d80548a8416908316179055600e8054898416908316179055600f805492881691831682178155869290916001600160a81b031990911617600160a01b836002811115610be057634e487b7160e01b600052602160045260246000fd5b02179055508251610bf890600b90602086019061492f565b508151610c0c90600c90602085019061492f565b50610c186000336127a4565b600e54600d54601054600f546040517f13d3a1031aba66188cca5785e8045078864e8f69c24715761bf0449ef10304d694610c77946001600160a01b039182169490821693911691600b91600c91600160a01b90910460ff16906150c9565b60405180910390a1610cc2565b60405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016109e9565b5050505050505050565b806000610cd985856112b2565b9050610ce5818361552a565b95945050505050565b610cf833826127ae565b610d145760405162461bcd60e51b81526004016109e9906152a8565b610a8a83838361280c565b60009081526007602052604090206001015490565b600080600080610d478a8a8a8a8a6120f3565b9050612710610d5686836154cc565b610d6091906153cd565b9250610d6c83826153b5565b9350610d78838261552a565b91505096509650969350505050565b610d9082610d1f565b610d998161279a565b610a8a83836129a1565b6010546040805163313ce56760e01b815290516000926001600160a01b03169163313ce567916004808301926020929190829003018186803b158015610de857600080fd5b505afa158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e209190614e9f565b60ff16905090565b6001600160a01b0381163314610e985760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016109e9565b610ea28282612a27565b5050565b610a8a838383604051806020016040528060008152506119c5565b610ed96000805160206156a083398151915233611654565b15610ef057600a805460ff19166001179055610f4c565b610efb600033611654565b15610f1757600a805460ff19811660ff90911615179055610f4c565b60405162461bcd60e51b815260206004820152600a60248201526957726f6e6720726f6c6560b01b60448201526064016109e9565b600a5460405160ff909116151581527f9422424b175dda897495a07b091ef74a3ef715cf6d866fc972954c1c7f4593049060200160405180910390a1565b6000805160206156e0833981519152610fa28161279a565b610fab83612a8e565b610fdd5760405162461bcd60e51b815260206004820152600360248201526204f31360ec1b60448201526064016109e9565b600083815260116020526040902060058101544210156110245760405162461bcd60e51b815260206004820152600260248201526113cd60f21b60448201526064016109e9565b6001815460ff16600381111561104a57634e487b7160e01b600052602160045260246000fd5b1461107c5760405162461bcd60e51b81526020600482015260026024820152614f3560f01b60448201526064016109e9565b600881015460009060ff1680156110965750816001015484115b806110b45750600882015460ff161580156110b45750816001015484105b156110d55760088201546110ce908690869060ff16612aab565b9050611190565b815460ff19166003178255600d54604051636198e33960e01b8152600481018790526001600160a01b0390911690636198e33990602401600060405180830381600087803b15801561112657600080fd5b505af115801561113a573d6000803e3d6000fd5b5050505061114785612c8e565b6004820154600883015460405187927f06b9a7d5e559ec958118dcc25fab116916793fa9782acbf47186bf70bc4cf88e9261118792899160ff16906152f6565b60405180910390a25b8160060154600960008282546111a6919061552a565b9091555050600e546040805163488d8b8f60e11b815290516001600160a01b039092169163911b171e91600480820192602092909190829003018186803b1580156111f057600080fd5b505afa158015611204573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112289190614a90565b6001600160a01b0316633a5d92a883600601548361124691906154eb565b8460040154856006015461125a919061552a565b886040518463ffffffff1660e01b8152600401611279939291906151cc565b600060405180830381600087803b15801561129357600080fd5b505af11580156112a7573d6000803e3d6000fd5b505050505050505050565b600080826001600160a01b0316846001600160a01b0316141580156112df57506001600160a01b03841615155b80156112f357506001600160a01b0384163b155b1561140557600f5460405163010de89960e21b81526000916001600160a01b03169063ad1b1493908290630437a26490611331908a906004016150b5565b60206040518083038186803b15801561134957600080fd5b505afa15801561135d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113819190614e9f565b6040516001600160e01b031960e084901b16815260ff909116600482015260240160206040518083038186803b1580156113ba57600080fd5b505afa1580156113ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f29190614e9f565b905061140160ff8216836153b5565b9150505b600a5461141c908290610100900461ffff166154cc565b949350505050565b6000610778826126f7565b601054600d5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926114679291169060001990600401615152565b602060405180830381600087803b15801561148157600080fd5b505af1158015611495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b99190614c14565b50565b600081815260146020526040812060038101546004909101546114df9190615374565b6114e7610da3565b6114f290600a615424565b600084815260146020526040902060018101546002909101546115159190612d23565b61151f91906154cc565b61077891906154eb565b60006001600160a01b0382166115935760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016109e9565b506001600160a01b031660009081526004602052604090205490565b600061a8c06115be428461552a565b10156115cc57506000919050565b600062034bc06115dc428561552a565b1080156116005750620151806115f48461e1006153b5565b6115fe91906155d4565b155b9050600062093a80617080611618620151808761552a565b611622919061552a565b61162c91906155d4565b1580156116445750620b34c0611642428661552a565b105b9050818061141c57509392505050565b60009182526007602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606002805461078d90615584565b6000805160206156e08339815191526116a68161279a565b60006116b28484611999565b9050428310806116cc575061a8c06116ca428561552a565b105b156117085760405162461bcd60e51b815260206004820152600c60248201526b57726f6e672065787069727960a01b60448201526064016109e9565b60008181526014602052604090206007015460ff16156117285750505050565b611731836115af565b80156117ca5750600e60009054906101000a90046001600160a01b03166001600160a01b031663d63a95cf6040518163ffffffff1660e01b815260040160206040518083038186803b15801561178657600080fd5b505afa15801561179a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117be9190614e13565b6117c890856155d4565b155b1561194157604051806101000160405280828152602001601460008481526020019081526020016000206001015481526020016014600084815260200190815260200160002060020154815260200160146000848152602001908152602001600020600301548152602001601460008481526020019081526020016000206004015481526020018581526020018481526020016001151581525060146000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a81548160ff0219169083151502179055509050507f6ca25eaa4499ac325317dc06194c2e2084ab8546a6ea17b3d91f8deefe74d82b848483306040516119349493929190938452602084019290925260408301526001600160a01b0316606082015260800190565b60405180910390a1611988565b60405162461bcd60e51b815260206004820152601c60248201527b24b73b30b634b21039ba3934b5b29037b91032bc3834b930ba34b7b760211b60448201526064016109e9565b50505050565b610ea2338383612d39565b604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b6119cf33836127ae565b6119eb5760405162461bcd60e51b81526004016109e9906152a8565b61198884848484612e04565b6060611a02826126d2565b6000611a1960408051602081019091526000815290565b90506000815111611a395760405180602001604052806000815250610946565b80611a4384612e37565b604051602001611a54929190615002565b6040516020818303038152906040529392505050565b60126020528160005260406000208181548110611a8657600080fd5b90600052602060002001600091509150505481565b60006000805160206156e0833981519152611ab58161279a565b60008460c001358560e00135604051602001611adb929190918252602082015260400190565b60405160208183030381529060405280519060200120905060006127108660200135876101200135611b0d91906154cc565b611b1791906153cd565b9050600060405180610120016040528060016003811115611b4857634e487b7160e01b600052602160045260246000fd5b815260c08901356020820152610100890135604082018190526060820152608001611b78846101208b013561552a565b81526020018860e0013581526020018861012001358152602001878152602001886080016020810190611bab9190614bf8565b151590529050611bb9612f50565b945060126000611bcc60208a018a614a74565b6001600160a01b031681526020808201929092526040908101600090812080546001818101835591835284832001899055888252601190935220825181548493839160ff191690836003811115611c3357634e487b7160e01b600052602160045260246000fd5b0217905550602082810151600183015560408301516002830155606083015160038301556080830151600483015560a0830151600583015560c0830151600683015560e08301516007830155610100909201516008909101805460ff1916911515919091179055611cb090611caa90890189614a74565b86612f6a565b600e54604080516309b41a1b60e11b81529051611d41926001600160a01b0316916313683436916004808301926020929190829003018186803b158015611cf657600080fd5b505afa158015611d0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d2e9190614a90565b6010546001600160a01b03169084613096565b600d546060820151608083015160405163edd0d42160e01b81526001600160a01b039093169263edd0d42192611d7b928a926004016151cc565b600060405180830381600087803b158015611d9557600080fd5b505af1158015611da9573d6000803e3d6000fd5b50505050600e60009054906101000a90046001600160a01b03166001600160a01b03166395b12ea36040518163ffffffff1660e01b815260040160206040518083038186803b158015611dfb57600080fd5b505afa158015611e0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e339190614a90565b6001600160a01b031663710b28158630611e5060208c018c614a74565b6040516001600160e01b031960e086901b16815260048101939093526001600160a01b039182166024840152166044820152606401600060405180830381600087803b158015611e9f57600080fd5b505af1158015611eb3573d6000803e3d6000fd5b5050505086610120013560096000828254611ece91906153b5565b90915550611ee4905060a0880160808901614bf8565b15611f4f576000838152601460205260408120600101805460a08a01359290611f0e9084906153b5565b90915550611f2390508261012089013561552a565b60008481526014602052604081206003018054909190611f44908490615374565b90915550611fb09050565b6000838152601460205260408120600201805460a08a01359290611f749084906153b5565b90915550611f8990508261012089013561552a565b60008481526014602052604081206004018054909190611faa908490615374565b90915550505b6000611fbb846114bc565b9050600e60009054906101000a90046001600160a01b03166001600160a01b03166350ec40e06040518163ffffffff1660e01b815260040160206040518083038186803b15801561200b57600080fd5b505afa15801561201f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120439190614e13565b8113156120825760405162461bcd60e51b815260206004820152600d60248201526c098dee6e640e8dede40d0d2ced609b1b60448201526064016109e9565b8561209060208a018a614a74565b6001600160a01b03167ffa6101f13be10247a3f27ba031321ca444c4bf1eb56aade9f1c96f5e621164aa858b610120013585896040516120d3949392919061530e565b60405180910390a3505050505092915050565b600c8054610a9c90615584565b60006305f5e100612102610da3565b61210d90600a615424565b61211c8487898860018d6130ec565b61212691906154cc565b61213091906153cd565b9695505050505050565b61214382610d1f565b61214c8161279a565b610a8a8383612a27565b600a5460009081908190819060ff16156121985760405162461bcd60e51b81526020600482015260036024820152624f333360e81b60448201526064016109e9565b6001600f54600160a01b900460ff1660028111156121c657634e487b7160e01b600052602160045260246000fd5b14806122dd5750600e60009054906101000a90046001600160a01b03166001600160a01b0316632677327a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561221b57600080fd5b505afa15801561222f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122539190614a90565b6001600160a01b031663f7d52fa161226f4260e089013561552a565b6040518263ffffffff1660e01b815260040161228d91815260200190565b60206040518083038186803b1580156122a557600080fd5b505afa1580156122b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122dd9190614c14565b61230f5760405162461bcd60e51b815260206004820152600360248201526204f33360ec1b60448201526064016109e9565b600061234761232460a0880160808901614bf8565b61014088013560c089013561233d4260e08c013561552a565b8a604001356120f3565b90506002612353610da3565b61235d919061552a565b61236890600a615424565b6123739060056154cc565b81116123b05760405162461bcd60e51b815260206004820152600c60248201526b46656520746f6f206c65737360a01b60448201526064016109e9565b60026123ba610da3565b6123c4919061552a565b6123cf90600a615424565b6123da90605f6154cc565b81106124175760405162461bcd60e51b815260206004820152600c60248201526b08ccaca40e8dede40d0d2ced60a31b60448201526064016109e9565b60008660c001358760e0013560405160200161243d929190918252602082015260400190565b60408051601f198184030181529190528051602090910120600f549091506124ff906001600160a01b0316637d191bdb61247b6101608b018b615329565b6040518363ffffffff1660e01b81526004016124989291906151e2565b60206040518083038186803b1580156124b057600080fd5b505afa1580156124c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124e89190614a90565b6124f560208a018a614a74565b8960200135610ccc565b925061271061250e84846154cc565b61251891906153cd565b61252290836153b5565b945060006125308287610810565b90506125576125438960a00135836131bc565b612552886101208c01356153cd565b6131bc565b9450848860a00135146125a6576125746080890160608a01614bf8565b6125a65760405162461bcd60e51b81526020600482015260036024820152624f323960e81b60448201526064016109e9565b6125b085876154cc565b955084600e60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561260157600080fd5b505afa158015612615573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126399190614e13565b61264391906154cc565b96505050509193509193565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b60006126888161279a565b506001600160a01b03166000908152601360205260409020805460ff19166001179055565b60006001600160e01b03198216637965db0b60e01b14806107785750610778826131cb565b6126db81612a8e565b6114b95760405162461bcd60e51b81526004016109e990615276565b6000818152600360205260408120546001600160a01b0316806107785760405162461bcd60e51b81526004016109e990615276565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612761826126f7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6114b9813361321b565b610ea282826129a1565b6000806127ba836126f7565b9050806001600160a01b0316846001600160a01b031614806127e157506127e1818561264f565b8061141c5750836001600160a01b03166127fa8461094d565b6001600160a01b031614949350505050565b826001600160a01b031661281f826126f7565b6001600160a01b0316146128835760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016109e9565b6001600160a01b0382166128e55760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016109e9565b6128f083838361327f565b6128fb60008261272c565b6001600160a01b038316600090815260046020526040812080546001929061292490849061552a565b90915550506001600160a01b03821660009081526004602052604081208054600192906129529084906153b5565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716916000805160206156c083398151915291a4505050565b6129ab8282611654565b610ea25760008281526007602090815260408083206001600160a01b03851684529091529020805460ff191660011790556129e33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b612a318282611654565b15610ea25760008281526007602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000908152600360205260409020546001600160a01b0316151590565b600083815260116020526040812081612ac386611424565b6003830154600d546040516381b34f1560e01b8152600481018a9052306024820152604481018390529195509192506001600160a01b03909116906381b34f1590606401600060405180830381600087803b158015612b2157600080fd5b505af1158015612b35573d6000803e3d6000fd5b5050601054612b5192506001600160a01b031690508285613096565b8160030154831015612b9157600d546003830154612b91916001600160a01b031690612b7e90869061552a565b6010546001600160a01b03169190613096565b81600401548311612be457857fc88c04f82f76cf4112dc206d1a563be25c04a4a762a699eccd4d4abc6df0dff0848460040154612bce919061552a565b60405190815260200160405180910390a2612c28565b857fa569991d55d525eae5729bac6890aeb7c0bdcd198f36ca0d0a7da8c2c0a734fb836004015485612c16919061552a565b60405190815260200160405180910390a25b612c3186612c8e565b815460ff1916600217825560405186906001600160a01b038316907ff394088c7503260c927488ca4397d6b43146f13c239078415e6f14029e5cb7f890612c7d9087908a908a906152f6565b60405180910390a350509392505050565b6000612c99826126f7565b9050612ca78160008461327f565b612cb260008361272c565b6001600160a01b0381166000908152600460205260408120805460019290612cdb90849061552a565b909155505060008281526003602052604080822080546001600160a01b0319169055518391906001600160a01b038416906000805160206156c0833981519152908390a45050565b6000818311612d325781610946565b5090919050565b816001600160a01b0316836001600160a01b03161415612d975760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b60448201526064016109e9565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612e0f84848461280c565b612e1b84848484613333565b6119885760405162461bcd60e51b81526004016109e990615224565b606081612e5b5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612e855780612e6f816155b9565b9150612e7e9050600a836153cd565b9150612e5f565b6000816001600160401b03811115612ead57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612ed7576020820181803683370190505b5090505b841561141c57612eec60018361552a565b9150612ef9600a866155d4565b612f049060306153b5565b60f81b818381518110612f2757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612f49600a866153cd565b9450612edb565b6008805460009182612f61836155b9565b91905055905090565b6001600160a01b038216612fc05760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109e9565b612fc981612a8e565b156130155760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b60448201526064016109e9565b6130216000838361327f565b6001600160a01b038216600090815260046020526040812080546001929061304a9084906153b5565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392906000805160206156c0833981519152908290a45050565b610a8a8363a9059cbb60e01b84846040516024016130b5929190615152565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613447565b6000806130fc6305f5e100613519565b9050600061310b612710613519565b905060006131258261311c8c613519565b600f0b90613536565b90506000613137600f83900b8361359d565b905060006131488561311c8d613519565b905060006131598661311c8d613519565b9050600061317661316d6301e13380613519565b61311c8d613519565b90506000613188858585858f8f6135d3565b90506131a061319b600f83900b8a61359d565b6136aa565b6001600160401b03169f9e505050505050505050505050505050565b6000818310612d325781610946565b60006001600160e01b031982166380ac58cd60e01b14806131fc57506001600160e01b03198216635b5e139f60e01b145b8061077857506301ffc9a760e01b6001600160e01b0319831614610778565b6132258282611654565b610ea25761323d816001600160a01b031660146136c6565b6132488360206136c6565b604051602001613259929190615046565b60408051601f198184030181529082905262461bcd60e51b82526109e991600401615211565b6001600160a01b0383161580159061329f57506001600160a01b03821615155b80156132c457506001600160a01b03821660009081526013602052604090205460ff16155b80156132e957506001600160a01b03831660009081526013602052604090205460ff16155b15610a8a5760405162461bcd60e51b815260206004820152601a602482015279151bdad95b881d1c985b9cd9995c881b9bdd08185b1b1bddd95960321b60448201526064016109e9565b6000613347846001600160a01b03166138a7565b1561343c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061337e90339089908890889060040161511f565b602060405180830381600087803b15801561339857600080fd5b505af19250505080156133c8575060408051601f3d908101601f191682019092526133c591810190614d37565b60015b613422573d8080156133f6576040519150601f19603f3d011682016040523d82523d6000602084013e6133fb565b606091505b50805161341a5760405162461bcd60e51b81526004016109e990615224565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061141c565b506001949350505050565b600061349c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138b69092919063ffffffff16565b805190915015610a8a57808060200190518101906134ba9190614c14565b610a8a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109e9565b600060016001603f1b0382111561352f57600080fd5b5060401b90565b600081600f0b6000141561354957600080fd5b600082600f0b604085600f0b901b8161357257634e487b7160e01b600052601260045260246000fd5b05905060016001607f1b03198112801590613594575060016001607f1b038113155b61094657600080fd5b6000600f83810b9083900b0260401d60016001607f1b03198112801590613594575060016001607f1b0381131561094657600080fd5b6000806135e4600f86900b8961359d565b905060006135f482600f0b6138c5565b905060006136318261311c600186600f0b901d6136286136208e8e600f0b61353690919063ffffffff16565b600f0b6138e7565b600f0b90613921565b90506000613643600f83900b84613954565b905086156136765785156136655761365a81613987565b945050505050612130565b61365a613671826155e8565b613987565b851561369b5761365a61368882613987565b6136926001613519565b600f0b90613954565b61365a613688613671836155e8565b60008082600f0b12156136bc57600080fd5b50600f0b60401d90565b606060006136d58360026154cc565b6136e09060026153b5565b6001600160401b0381111561370557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561372f576020820181803683370190505b509050600360fc1b8160008151811061375857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061379557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006137b98460026154cc565b6137c49060016153b5565b90505b6001811115613858576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061380657634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061382a57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936138518161556d565b90506137c7565b5083156109465760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e9565b6001600160a01b03163b151590565b606061141c8484600085613a3e565b60008082600f0b12156138d757600080fd5b610778604083600f0b901b613b6d565b60008082600f0b136138f857600080fd5b608061390383613d4a565b600f0b6fb17217f7d1cf79abc9e3b39803f2f6af02901c9050919050565b6000600f83810b9083900b0160016001607f1b03198112801590613594575060016001607f1b0381131561094657600080fd5b6000600f82810b9084900b0360016001607f1b03198112801590613594575060016001607f1b0381131561094657600080fd5b600080613998600f84900b8461359d565b90506000613a1d613a026139d16139c26139ba600f87900b600360401b613921565b600f0b6138c5565b67d3c84b78b749bd6b9061359d565b6136286139f36139e389600f0b613e24565b68019abac0ea1da650369061359d565b679109f285df45239490613921565b61311c6001613a10866155e8565b600f0b901d600f0b613e57565b9050600084600f0b13613a30578061141c565b61141c600160401b82613954565b606082471015613a9f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109e9565b613aa8856138a7565b613af45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109e9565b600080866001600160a01b03168587604051613b109190614fe6565b60006040518083038185875af1925050503d8060008114613b4d576040519150601f19603f3d011682016040523d82523d6000602084013e613b52565b606091505b5091509150613b62828286613eaa565b979650505050505050565b600081613b7c57506000919050565b816001600160801b8210613b955760809190911c9060401b5b600160401b8210613bab5760409190911c9060201b5b600160201b8210613bc15760209190911c9060101b5b620100008210613bd65760109190911c9060081b5b6101008210613bea5760089190911c9060041b5b60108210613bfd5760049190911c9060021b5b60088210613c095760011b5b6001818581613c2857634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613c4e57634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613c7457634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613c9a57634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613cc057634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613ce657634e487b7160e01b600052601260045260246000fd5b048201901c90506001818581613d0c57634e487b7160e01b600052601260045260246000fd5b048201901c90506000818581613d3257634e487b7160e01b600052601260045260246000fd5b049050808210613d425780610ce5565b509392505050565b60008082600f0b13613d5b57600080fd5b6000600f83900b600160401b8112613d75576040918201911d5b600160201b8112613d88576020918201911d5b620100008112613d9a576010918201911d5b6101008112613dab576008918201911d5b60108112613dbb576004918201911d5b60048112613dcb576002918201911d5b60028112613dda576001820191505b603f19820160401b600f85900b607f8490031b6001603f1b5b6000811315613e195790800260ff81901c8281029390930192607f011c9060011d613df3565b509095945050505050565b6000600f82900b60016001607f1b03191415613e3f57600080fd5b600082600f0b12613e505781610778565b5060000390565b6000600160461b82600f0b12613e6c57600080fd5b6001600160461b031982600f0b1215613e8757506000919050565b610778608083600f0b700171547652b82fe1777d0ffda0d23a7d1202901d613ee3565b60608315613eb9575081610946565b825115613ec95782518084602001fd5b8160405162461bcd60e51b81526004016109e99190615211565b6000600160461b82600f0b12613ef857600080fd5b6001600160461b031982600f0b1215613f1357506000919050565b6001607f1b60006001603f1b8416600f0b1315613f415770016a09e667f3bcc908b2fb1366ea957d3e0260801c5b6000836001603e1b16600f0b1315613f6a577001306fe0a31b7152de8d5a46305c85edec0260801c5b6000836001603d1b16600f0b1315613f93577001172b83c7d517adcdf7c8c50eb14a791f0260801c5b6000836001603c1b16600f0b1315613fbc5770010b5586cf9890f6298b92b71842a983630260801c5b6000836001603b1b16600f0b1315613fe5577001059b0d31585743ae7c548eb68ca417fd0260801c5b6000836001603a1b16600f0b131561400e57700102c9a3e778060ee6f7caca4f7a29bde80260801c5b600083600160391b16600f0b13156140375770010163da9fb33356d84a66ae336dcdfa3f0260801c5b600083600160381b16600f0b131561406057700100b1afa5abcbed6129ab13ec11dc95430260801c5b600083600160371b16600f0b13156140895770010058c86da1c09ea1ff19d294cf2f679b0260801c5b600083600160361b16600f0b13156140b2577001002c605e2e8cec506d21bfc89a23a00f0260801c5b600083600160351b16600f0b13156140db57700100162f3904051fa128bca9c55c31e5df0260801c5b600083600160341b16600f0b1315614104577001000b175effdc76ba38e31671ca9397250260801c5b600083600160331b16600f0b131561412d57700100058ba01fb9f96d6cacd4b180917c3d0260801c5b600083600160321b16600f0b13156141565770010002c5cc37da9491d0985c348c68e7b30260801c5b600083600160311b16600f0b131561417f577001000162e525ee054754457d59952920260260801c5b600083600160301b16600f0b13156141a85770010000b17255775c040618bf4a4ade83fc0260801c5b6000836001602f1b16600f0b13156141d1577001000058b91b5bc9ae2eed81e9b7d4cfab0260801c5b6000836001602e1b16600f0b13156141fa57700100002c5c89d5ec6ca4d7c8acc017b7c90260801c5b6000836001602d1b16600f0b13156142235770010000162e43f4f831060e02d839a9d16d0260801c5b6000836001602c1b16600f0b131561424c57700100000b1721bcfc99d9f890ea069117630260801c5b6000836001602b1b16600f0b13156142755770010000058b90cf1e6d97f9ca14dbcc16280260801c5b6000836001602a1b16600f0b131561429e577001000002c5c863b73f016468f6bac5ca2b0260801c5b600083600160291b16600f0b13156142c757700100000162e430e5a18f6119e3c02282a50260801c5b600083600160281b16600f0b13156142f0577001000000b1721835514b86e6d96efd1bfe0260801c5b600083600160271b16600f0b131561431957700100000058b90c0b48c6be5df846c5b2ef0260801c5b600083600160261b16600f0b13156143425770010000002c5c8601cc6b9e94213c72737a0260801c5b600083600160251b16600f0b131561436b577001000000162e42fff037df38aa2b219f060260801c5b600083600160241b16600f0b13156143945770010000000b17217fba9c739aa5819f44f90260801c5b600083600160231b16600f0b13156143bd577001000000058b90bfcdee5acd3c1cedc8230260801c5b600083600160221b16600f0b13156143e657700100000002c5c85fe31f35a6a30da1be500260801c5b600083600160211b16600f0b131561440f5770010000000162e42ff0999ce3541b9fffcf0260801c5b600083600160201b16600f0b131561443857700100000000b17217f80f4ef5aadda455540260801c5b600083638000000016600f0b13156144615770010000000058b90bfbf8479bd5a81b51ad0260801c5b600083634000000016600f0b131561448a577001000000002c5c85fdf84bd62ae30a74cc0260801c5b600083632000000016600f0b13156144b357700100000000162e42fefb2fed257559bdaa0260801c5b600083631000000016600f0b13156144dc577001000000000b17217f7d5a7716bba4a9ae0260801c5b600083630800000016600f0b131561450557700100000000058b90bfbe9ddbac5e109cce0260801c5b600083630400000016600f0b131561452e5770010000000002c5c85fdf4b15de6f17eb0d0260801c5b600083630200000016600f0b1315614557577001000000000162e42fefa494f1478fde050260801c5b600083630100000016600f0b13156145805770010000000000b17217f7d20cf927c8e94c0260801c5b6000836280000016600f0b13156145a8577001000000000058b90bfbe8f71cb4e4b33d0260801c5b6000836240000016600f0b13156145d057700100000000002c5c85fdf477b662b269450260801c5b6000836220000016600f0b13156145f85770010000000000162e42fefa3ae53369388c0260801c5b6000836210000016600f0b131561462057700100000000000b17217f7d1d351a389d400260801c5b6000836208000016600f0b13156146485770010000000000058b90bfbe8e8b2d3d4ede0260801c5b6000836204000016600f0b1315614670577001000000000002c5c85fdf4741bea6e77e0260801c5b6000836202000016600f0b131561469857700100000000000162e42fefa39fe95583c20260801c5b6000836201000016600f0b13156146bf5769b17217f7d1cfb72b45e1600160801b010260801c5b60008361800016600f0b13156146e5576958b90bfbe8e7cc35c3f0600160801b010260801c5b60008361400016600f0b131561470b57692c5c85fdf473e242ea38600160801b010260801c5b60008361200016600f0b13156147315769162e42fefa39f02b772c600160801b010260801c5b60008361100016600f0b131561475757690b17217f7d1cf7d83c1a600160801b010260801c5b60008361080016600f0b131561477d5769058b90bfbe8e7bdcbe2e600160801b010260801c5b60008361040016600f0b13156147a3576902c5c85fdf473dea871f600160801b010260801c5b60008361020016600f0b13156147c957690162e42fefa39ef44d91600160801b010260801c5b60008361010016600f0b13156147ee5768b17217f7d1cf79e949600160801b010260801c5b600083608016600f0b1315614812576858b90bfbe8e7bce544600160801b010260801c5b600083604016600f0b131561483657682c5c85fdf473de6eca600160801b010260801c5b600083602016600f0b131561485a5768162e42fefa39ef366f600160801b010260801c5b600083601016600f0b131561487e57680b17217f7d1cf79afa600160801b010260801c5b600083600816600f0b13156148a25768058b90bfbe8e7bcd6d600160801b010260801c5b600083600416600f0b13156148c6576802c5c85fdf473de6b2600160801b010260801c5b600083600216600f0b13156148ea57680162e42fefa39ef358600160801b010260801c5b600083600116600f0b131561490d5767b17217f7d1cf79ab600160801b010260801c5b600f83810b60401d603f03900b1c60016001607f1b0381111561077857600080fd5b82805461493b90615584565b90600052602060002090601f01602090048101928261495d57600085556149a3565b82601f1061497657805160ff19168380011785556149a3565b828001600101855582156149a3579182015b828111156149a3578251825591602001919060010190614988565b506149af9291506149b3565b5090565b5b808211156149af57600081556001016149b4565b60006001600160401b03808411156149e2576149e2615650565b604051601f8501601f19908116603f01168101908282118183101715614a0a57614a0a615650565b81604052809350858152868686011115614a2357600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112614a4d578081fd5b610946838335602085016149c8565b60006101808284031215614a6e578081fd5b50919050565b600060208284031215614a85578081fd5b813561094681615666565b600060208284031215614aa1578081fd5b815161094681615666565b60008060408385031215614abe578081fd5b8235614ac981615666565b91506020830135614ad981615666565b809150509250929050565b600080600060608486031215614af8578081fd5b8335614b0381615666565b92506020840135614b1381615666565b929592945050506040919091013590565b60008060008060808587031215614b39578081fd5b8435614b4481615666565b93506020850135614b5481615666565b92506040850135915060608501356001600160401b03811115614b75578182fd5b8501601f81018713614b85578182fd5b614b94878235602084016149c8565b91505092959194509250565b60008060408385031215614bb2578182fd5b8235614bbd81615666565b91506020830135614ad98161567b565b60008060408385031215614bdf578182fd5b8235614bea81615666565b946020939093013593505050565b600060208284031215614c09578081fd5b81356109468161567b565b600060208284031215614c25578081fd5b81516109468161567b565b600080600080600060a08688031215614c47578283fd5b8535614c528161567b565b97602087013597506040870135966060810135965060800135945092505050565b60008060008060008060c08789031215614c8b578384fd5b8635614c968161567b565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b600060208284031215614ccf578081fd5b5035919050565b60008060408385031215614ce8578182fd5b823591506020830135614ad981615666565b60008060408385031215614d0c578182fd5b50508035926020909101359150565b600060208284031215614d2c578081fd5b813561094681615689565b600060208284031215614d48578081fd5b815161094681615689565b600080600080600080600060e0888a031215614d6d578485fd5b8735614d7881615666565b96506020880135614d8881615666565b95506040880135614d9881615666565b94506060880135614da881615666565b9350608088013560038110614dbb578182fd5b925060a08801356001600160401b0380821115614dd6578283fd5b614de28b838c01614a3d565b935060c08a0135915080821115614df7578283fd5b50614e048a828b01614a3d565b91505092959891949750929550565b600060208284031215614e24578081fd5b5051919050565b600060208284031215614e3c578081fd5b81356001600160401b03811115614e51578182fd5b61141c84828501614a5c565b60008060408385031215614e6f578182fd5b82356001600160401b03811115614e84578283fd5b614e9085828601614a5c565b95602094909401359450505050565b600060208284031215614eb0578081fd5b815160ff81168114610946578182fd5b60008151808452614ed8816020860160208601615541565b601f01601f19169290920160200192915050565b60038110614efc57614efc61563a565b9052565b60008154614f0d81615584565b808552602060018381168015614f2a5760018114614f3e57614f6c565b60ff19851688840152604088019550614f6c565b866000528260002060005b85811015614f645781548a8201860152908301908401614f49565b890184019650505b505050505092915050565b60008154614f8481615584565b60018281168015614f9c5760018114614fad57614fdc565b60ff19841687528287019450614fdc565b8560005260208060002060005b85811015614fd35781548a820152908401908201614fba565b50505082870194505b5050505092915050565b60008251614ff8818460208701615541565b9190910192915050565b60008351615014818460208801615541565b835190830190615028818360208801615541565b01949350505050565b600061141c6150408386614f77565b84614f77565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615078816017850160208801615541565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516150a9816028840160208801615541565b01602801949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b03878116825286811660208301528516604082015260c0606082018190526000906150fd90830186614f00565b828103608084015261510f8186614f00565b915050613b6260a0830184614eec565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061213090830184614ec0565b6001600160a01b03929092168252602082015260400190565b602081016107788284614eec565b610120810160048b1061518e5761518e61563a565b998152602081019890985260408801969096526060870194909452608086019290925260a085015260c084015260e083015215156101009091015290565b9283526020830191909152604082015260600190565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6020815260006109466020830184614ec0565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b92835260208301919091521515604082015260600190565b93845260208401929092526040830152606082015260800190565b6000808335601e1984360301811261533f578283fd5b8301803591506001600160401b03821115615358578283fd5b60200191503681900382131561536d57600080fd5b9250929050565b600080821280156001600160ff1b03849003851316156153965761539661560e565b600160ff1b83900384128116156153af576153af61560e565b50500190565b600082198211156153c8576153c861560e565b500190565b6000826153dc576153dc615624565b500490565b600181815b8085111561541c5781600019048211156154025761540261560e565b8085161561540f57918102915b93841c93908002906153e6565b509250929050565b6000610946838360008261543a57506001610778565b8161544757506000610778565b816001811461545d576002811461546757615483565b6001915050610778565b60ff8411156154785761547861560e565b50506001821b610778565b5060208310610133831016604e8410600b84101617156154a6575081810a610778565b6154b083836153e1565b80600019048211156154c4576154c461560e565b029392505050565b60008160001904831182151516156154e6576154e661560e565b500290565b60008083128015600160ff1b8501841216156155095761550961560e565b6001600160ff1b03840183138116156155245761552461560e565b50500390565b60008282101561553c5761553c61560e565b500390565b60005b8381101561555c578181015183820152602001615544565b838111156119885750506000910152565b60008161557c5761557c61560e565b506000190190565b600181811c9082168061559857607f821691505b60208210811415614a6e57634e487b7160e01b600052602260045260246000fd5b60006000198214156155cd576155cd61560e565b5060010190565b6000826155e3576155e3615624565b500690565b6000600f82900b60016001607f1b03198114156156075761560761560e565b9003919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146114b957600080fd5b80151581146114b957600080fd5b6001600160e01b0319811681146114b957600080fdfe65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862addf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2a2646970667358221220e955746c05f93493f7e45c45ab3fd19cc146d892ddae1494896d00baae56079364736f6c63430008040033
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.