Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Cart
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 9999
- EVM Version
- default
- Verified at
- 2025-05-27T12:19:36.556104Z
Constructor Arguments
0x0000000000000000000000009cb1fe9470b1dcc91d9c0c0e50c42680c06a7926000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000100000000000000000000000088532a901475b3ddf370386ae22c2067846f7d7a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000088532a901475b3ddf370386ae22c2067846f7d7a
contracts/Cart.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma abicoder v2;
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/security/Pausable.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol';
import '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';
import './IWETH.sol';
contract BaseCart is Ownable, Pausable, ReentrancyGuard, IERC721Receiver, IERC1155Receiver {
using SafeERC20 for IERC20;
using SafeERC20 for IWETH;
struct Market {
bool directCall; // t for call; f for delegate call (helpers)
bool active;
}
struct ERC20Approval {
IERC20 token;
address target;
}
struct ERC20Transfer {
uint256 amount;
IERC20 token;
}
struct MarketOrder {
address addr;
uint256 value;
uint256 passthrough;
bool requireSuccess;
bytes data;
}
struct ERC721Token {
IERC721 token;
uint256 tokenId;
}
struct ERC1155Token {
IERC1155 token;
uint256 tokenId;
uint256 amount;
}
event Result(uint256 index, bool success, uint256 passthrough);
event MarketUpdate(address market);
event ApprovalAddrUpdate(address addr);
uint256 public maxApproval = type(uint256).max - 1;
IWETH public immutable weth;
mapping(address => Market) public markets;
mapping(address => bool) public erc20ApprovalAddresses;
receive() external payable {}
constructor(
IWETH _weth,
address[] memory _marketAddrs,
Market[] memory _markets,
address[] memory _approvalAddresses
) {
weth = _weth;
require(_markets.length == _marketAddrs.length, 'Constructor: length check');
for (uint256 i = 0; i < _markets.length; i++) {
markets[_marketAddrs[i]] = _markets[i];
emit MarketUpdate(_marketAddrs[i]);
}
for (uint256 i = 0; i < _approvalAddresses.length; i++) {
erc20ApprovalAddresses[_approvalAddresses[i]] = true;
emit ApprovalAddrUpdate(_approvalAddresses[i]);
}
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
function buyOS(
uint256 weth2Eth,
MarketOrder[] memory marketOrders
) external payable nonReentrant whenNotPaused {
if (weth2Eth > 0) {
IERC20(address(weth)).safeTransferFrom(msg.sender, address(this), weth2Eth);
weth.withdraw(weth2Eth);
}
_executeOrder(marketOrders);
uint256 balance = address(this).balance;
if (balance > 0) {
msg.sender.call{value: balance}('');
}
}
function buy(
uint256 weth2Eth,
uint256 eth2Weth,
ERC20Approval[] memory erc20Approvals,
ERC20Transfer[] memory erc20Transfers,
MarketOrder[] memory marketOrders,
ERC721Token[] memory erc721Tokens,
ERC1155Token[] memory erc1155Tokens,
IERC20[] memory moreDustTokens
) external payable nonReentrant whenNotPaused {
require(marketOrders.length > 0, 'Sender: no order specified');
if (weth2Eth > 0) {
IERC20(address(weth)).safeTransferFrom(msg.sender, address(this), weth2Eth);
weth.withdraw(weth2Eth);
}
if (eth2Weth > 0) {
weth.deposit{value: eth2Weth}();
}
_transferTokens(erc20Transfers);
_approveTokens(erc20Approvals);
_executeOrder(marketOrders);
_transferERC721Tokens(erc721Tokens);
_transferERC1155Tokens(erc1155Tokens);
_returnDusts(erc20Transfers, moreDustTokens);
}
function _executeOrder(MarketOrder[] memory marketOrders) internal {
for (uint256 i = 0; i < marketOrders.length; i++) {
MarketOrder memory m = marketOrders[i];
require(markets[m.addr].active, 'Execute: inactive market');
bool directCall = markets[m.addr].directCall;
(bool success, ) = directCall
? m.addr.call{value: m.value}(m.data)
: m.addr.delegatecall(m.data);
if (m.requireSuccess && !success) {
revert('Execution failure: require success call');
}
emit Result(i, success, m.passthrough);
}
}
function _transferERC721Tokens(ERC721Token[] memory erc721Tokens) internal {
for (uint256 i = 0; i < erc721Tokens.length; i++) {
ERC721Token memory x = erc721Tokens[i];
address(x.token).call(
abi.encodeWithSelector(
0x23b872dd, // transferFrom(address,address,uint256)
address(this),
msg.sender,
x.tokenId
)
);
}
}
function _transferERC1155Tokens(ERC1155Token[] memory erc1155Tokens) internal {
for (uint256 i = 0; i < erc1155Tokens.length; i++) {
ERC1155Token memory x = erc1155Tokens[i];
uint256 balance = x.token.balanceOf(address(this), x.tokenId);
if (balance > x.amount) {
balance = x.amount;
}
if (balance > 0) {
address(x.token).call(
abi.encodeWithSelector(
0xf242432a, // safeTransferFrom(address,address,uint256,uint256,bytes)
address(this),
msg.sender,
x.tokenId,
balance,
bytes('')
)
);
}
}
}
function _approveTokens(ERC20Approval[] memory erc20Approvals) internal {
for (uint256 i = 0; i < erc20Approvals.length; i++) {
ERC20Approval memory a = erc20Approvals[i];
require(erc20ApprovalAddresses[a.target], 'Approve: unable to approve token');
a.token.approve(a.target, maxApproval);
}
}
function _transferTokens(ERC20Transfer[] memory erc20Transfers) internal {
for (uint256 i = 0; i < erc20Transfers.length; i++) {
ERC20Transfer memory t = erc20Transfers[i];
if (t.amount > 0) {
t.token.safeTransferFrom(msg.sender, address(this), t.amount);
}
}
}
function _returnDusts(ERC20Transfer[] memory dusts, IERC20[] memory moreDusts) internal {
uint256 ethBalance = address(this).balance;
if (ethBalance > 0) {
msg.sender.call{value: ethBalance}('');
}
for (uint256 i = 0; i < dusts.length; i++) {
IERC20 t = dusts[i].token;
uint256 balance = t.balanceOf(address(this));
if (balance > 0) {
// transfer(address,uint256)
address(t).call(abi.encodeWithSelector(0xa9059cbb, msg.sender, balance));
}
}
for (uint256 i = 0; i < moreDusts.length; i++) {
IERC20 t = moreDusts[i];
uint256 balance = t.balanceOf(address(this));
if (balance > 0) {
// transfer(address,uint256)
address(t).call(abi.encodeWithSelector(0xa9059cbb, msg.sender, balance));
}
}
}
// settings
function updateMarkets(
address[] memory _marketAddrs,
Market[] memory _markets
) external onlyOwner {
require(_markets.length == _marketAddrs.length, 'Owner: length check');
for (uint256 i = 0; i < _markets.length; i++) {
markets[_marketAddrs[i]] = _markets[i];
emit MarketUpdate(_marketAddrs[i]);
}
}
function disableMarkets(address[] memory _markets) external onlyOwner {
for (uint256 i = 0; i < _markets.length; i++) {
delete markets[_markets[i]].active;
}
}
function batchApprove(
IERC20[] memory tokens,
address[] memory tos,
bool disapprove
) external onlyOwner {
for (uint256 i = 0; i < tokens.length; i++) {
IERC20 t = tokens[i];
for (uint256 j = 0; j < tos.length; j++) {
address to = tos[j];
uint256 approval = disapprove ? 0 : maxApproval;
t.approve(to, approval);
}
}
}
function updateApprovalAddresses(
address[] memory toAdd,
address[] memory toRemove
) external onlyOwner {
for (uint256 i = 0; i < toAdd.length; i++) {
erc20ApprovalAddresses[toAdd[i]] = true;
emit ApprovalAddrUpdate(toAdd[i]);
}
for (uint256 i = 0; i < toRemove.length; i++) {
delete erc20ApprovalAddresses[toRemove[i]];
emit ApprovalAddrUpdate(toRemove[i]);
}
}
// safety
function ethStuck(
address[] memory tos,
uint256[] memory amounts
) external onlyOwner nonReentrant {
require(tos.length == amounts.length, 'Owner: length check');
for (uint256 i = 0; i < tos.length; i++) {
// ignore result
tos[i].call{value: amounts[i]}('');
}
}
function erc20Stuck(
address[] memory tos,
IERC20[] memory tokens,
uint256[] memory amounts
) external onlyOwner nonReentrant {
require(tos.length == tokens.length, 'Owner: length check');
require(tokens.length == amounts.length, 'Owner: length check');
for (uint256 i = 0; i < tos.length; i++) {
address(tokens[i]).call(
abi.encodeWithSelector(IERC20.transfer.selector, tos[i], amounts[i])
);
}
}
function erc721Stuck(
address[] memory tos,
IERC721[] memory tokens,
uint256[] memory tokenIds
) external onlyOwner nonReentrant {
require(tos.length == tokens.length, 'Owner: length check');
require(tokens.length == tokenIds.length, 'Owner: length check');
for (uint256 i = 0; i < tos.length; i++) {
tokens[i].safeTransferFrom(address(this), tos[i], tokenIds[i]);
}
}
function erc1155Stuck(
address[] memory tos,
IERC1155[] memory tokens,
uint256[] memory tokenIds,
uint256[] memory amounts
) external onlyOwner nonReentrant {
require(tos.length == tokens.length, 'Owner: length check');
require(tokens.length == tokenIds.length, 'Owner: length check');
require(amounts.length == tokenIds.length, 'Owner: length check');
for (uint256 i = 0; i < tos.length; i++) {
tokens[i].safeTransferFrom(address(this), tos[i], tokenIds[i], amounts[i], '');
}
}
// receivers
function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId;
}
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external pure override returns (bytes4) {
return this.onERC721Received.selector;
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) external pure override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] calldata,
uint256[] calldata,
bytes calldata
) external pure override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}
contract Cart is BaseCart {
constructor(
IWETH _weth,
address[] memory _marketAddrs,
Market[] memory _markets,
address[] memory _approvalAddresses
) BaseCart(_weth, _marketAddrs, _markets, _approvalAddresses) {}
}
contracts/IWETH.sol
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.0;
pragma abicoder v2;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint256 wad) external;
}
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC3156 FlashBorrower, as defined in
* https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
*
* _Available since v4.1._
*/
interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}
@openzeppelin/contracts/security/Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
@openzeppelin/contracts/security/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
@openzeppelin/contracts/token/ERC1155/IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* 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;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.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);
}
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol
// 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);
}
@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
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");
}
}
}
@openzeppelin/contracts/token/ERC721/ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.2) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/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 = _ownerOf(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 or 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 or 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 or 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 the owner of the `tokenId`. Does NOT revert if token doesn't exist
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @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 _ownerOf(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, 1);
// Check that tokenId was not minted by `_beforeTokenTransfer` hook
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
// Will not overflow unless all 2**256 token ids are minted to the same owner.
// Given that tokens are minted one by one, it is impossible in practice that
// this ever happens. Might change if we allow batch minting.
// The ERC fails to describe this case.
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
// Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
owner = ERC721.ownerOf(tokenId);
// Clear approvals
delete _tokenApprovals[tokenId];
unchecked {
// Cannot overflow, as that would require more tokens to be burned/transferred
// out than the owner initially received through minting and transferring in.
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
/**
* @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, 1);
// Check that tokenId was not transferred by `_beforeTokenTransfer` hook
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
// Clear approvals from the previous owner
delete _tokenApprovals[tokenId];
unchecked {
// `_balances[from]` cannot overflow for the same reason as described in `_burn`:
// `from`'s balance is the number of token held, which is at least one before the current
// transfer.
// `_balances[to]` could overflow in the conditions described in `_mint`. That would require
// all 2**256 token ids to be minted, which in practice is impossible.
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
/**
* @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. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
* - When `from` is zero, the tokens will be minted for `to`.
* - When `to` is zero, ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
* - When `from` is zero, the tokens were minted for `to`.
* - When `to` is zero, ``from``'s tokens were burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual {}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
* being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
* that `ownerOf(tokenId)` is `a`.
*/
// solhint-disable-next-line func-name-mixedcase
function __unsafe_increaseBalance(address account, uint256 amount) internal {
_balances[account] += amount;
}
}
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev See {ERC721-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual override {
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
if (batchSize > 1) {
// Will only trigger during construction. Batch transferring (minting) is not available afterwards.
revert("ERC721Enumerable: consecutive transfers not supported");
}
uint256 tokenId = firstTokenId;
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _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) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @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] = _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);
}
}
@openzeppelin/contracts/utils/cryptography/ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
@openzeppelin/contracts/utils/introspection/ERC165.sol
// 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;
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata","devdoc","userdoc","storageLayout","evm.gasEstimates"],"":["ast"]}},"optimizer":{"runs":9999,"enabled":true},"metadata":{"useLiteralContent":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_weth","internalType":"contract IWETH"},{"type":"address[]","name":"_marketAddrs","internalType":"address[]"},{"type":"tuple[]","name":"_markets","internalType":"struct BaseCart.Market[]","components":[{"type":"bool","name":"directCall","internalType":"bool"},{"type":"bool","name":"active","internalType":"bool"}]},{"type":"address[]","name":"_approvalAddresses","internalType":"address[]"}]},{"type":"event","name":"ApprovalAddrUpdate","inputs":[{"type":"address","name":"addr","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"MarketUpdate","inputs":[{"type":"address","name":"market","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Result","inputs":[{"type":"uint256","name":"index","internalType":"uint256","indexed":false},{"type":"bool","name":"success","internalType":"bool","indexed":false},{"type":"uint256","name":"passthrough","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"batchApprove","inputs":[{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"tos","internalType":"address[]"},{"type":"bool","name":"disapprove","internalType":"bool"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buy","inputs":[{"type":"uint256","name":"weth2Eth","internalType":"uint256"},{"type":"uint256","name":"eth2Weth","internalType":"uint256"},{"type":"tuple[]","name":"erc20Approvals","internalType":"struct BaseCart.ERC20Approval[]","components":[{"type":"address","name":"token","internalType":"contract IERC20"},{"type":"address","name":"target","internalType":"address"}]},{"type":"tuple[]","name":"erc20Transfers","internalType":"struct BaseCart.ERC20Transfer[]","components":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"token","internalType":"contract IERC20"}]},{"type":"tuple[]","name":"marketOrders","internalType":"struct BaseCart.MarketOrder[]","components":[{"type":"address","name":"addr","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint256","name":"passthrough","internalType":"uint256"},{"type":"bool","name":"requireSuccess","internalType":"bool"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"tuple[]","name":"erc721Tokens","internalType":"struct BaseCart.ERC721Token[]","components":[{"type":"address","name":"token","internalType":"contract IERC721"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"tuple[]","name":"erc1155Tokens","internalType":"struct BaseCart.ERC1155Token[]","components":[{"type":"address","name":"token","internalType":"contract IERC1155"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"address[]","name":"moreDustTokens","internalType":"contract IERC20[]"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buyOS","inputs":[{"type":"uint256","name":"weth2Eth","internalType":"uint256"},{"type":"tuple[]","name":"marketOrders","internalType":"struct BaseCart.MarketOrder[]","components":[{"type":"address","name":"addr","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint256","name":"passthrough","internalType":"uint256"},{"type":"bool","name":"requireSuccess","internalType":"bool"},{"type":"bytes","name":"data","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"disableMarkets","inputs":[{"type":"address[]","name":"_markets","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"erc1155Stuck","inputs":[{"type":"address[]","name":"tos","internalType":"address[]"},{"type":"address[]","name":"tokens","internalType":"contract IERC1155[]"},{"type":"uint256[]","name":"tokenIds","internalType":"uint256[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"erc20ApprovalAddresses","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"erc20Stuck","inputs":[{"type":"address[]","name":"tos","internalType":"address[]"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"erc721Stuck","inputs":[{"type":"address[]","name":"tos","internalType":"address[]"},{"type":"address[]","name":"tokens","internalType":"contract IERC721[]"},{"type":"uint256[]","name":"tokenIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"ethStuck","inputs":[{"type":"address[]","name":"tos","internalType":"address[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"directCall","internalType":"bool"},{"type":"bool","name":"active","internalType":"bool"}],"name":"markets","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxApproval","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC1155BatchReceived","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC1155Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateApprovalAddresses","inputs":[{"type":"address[]","name":"toAdd","internalType":"address[]"},{"type":"address[]","name":"toRemove","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateMarkets","inputs":[{"type":"address[]","name":"_marketAddrs","internalType":"address[]"},{"type":"tuple[]","name":"_markets","internalType":"struct BaseCart.Market[]","components":[{"type":"bool","name":"directCall","internalType":"bool"},{"type":"bool","name":"active","internalType":"bool"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IWETH"}],"name":"weth","inputs":[]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60a060405262000013600160001962000328565b6002553480156200002357600080fd5b5060405162003cf638038062003cf683398101604081905262000046916200048b565b838383836200005533620002c2565b6000805460ff60a01b19169055600180556001600160a01b0384166080528251825114620000c95760405162461bcd60e51b815260206004820152601960248201527f436f6e7374727563746f723a206c656e67746820636865636b00000000000000604482015260640160405180910390fd5b60005b8251811015620001d357828181518110620000eb57620000eb620005c6565b6020026020010151600360008684815181106200010c576200010c620005c6565b6020908102919091018101516001600160a01b031682528181019290925260400160002082518154939092015115156101000261ff00199215159290921661ffff199093169290921717905583517faa011e70873e4cc6356380c483b5f70548ef2eb4cb1363d7766f5077c4da1c5490859083908110620001915762000191620005c6565b6020026020010151604051620001b691906001600160a01b0391909116815260200190565b60405180910390a180620001ca81620005dc565b915050620000cc565b5060005b8151811015620002b357600160046000848481518110620001fc57620001fc620005c6565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f3bc9c657df9654d419ca570822f2fb292ced3f90f338ee28fc3e488cd00f235c828281518110620002715762000271620005c6565b60200260200101516040516200029691906001600160a01b0391909116815260200190565b60405180910390a180620002aa81620005dc565b915050620001d7565b505050505050505050620005f8565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b634e487b7160e01b600052601160045260246000fd5b818103818111156200033e576200033e62000312565b92915050565b6001600160a01b03811681146200035a57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156200039857620003986200035d565b60405290565b604051601f8201601f191681016001600160401b0381118282101715620003c957620003c96200035d565b604052919050565b60006001600160401b03821115620003ed57620003ed6200035d565b5060051b60200190565b600082601f8301126200040957600080fd5b81516020620004226200041c83620003d1565b6200039e565b82815260059290921b840181019181810190868411156200044257600080fd5b8286015b848110156200046a5780516200045c8162000344565b835291830191830162000446565b509695505050505050565b805180151581146200048657600080fd5b919050565b60008060008060808587031215620004a257600080fd5b8451620004af8162000344565b602086810151919550906001600160401b0380821115620004cf57600080fd5b620004dd89838a01620003f7565b9550604091508188015181811115620004f557600080fd5b8801601f81018a136200050757600080fd5b8051620005186200041c82620003d1565b81815260069190911b8201850190858101908c8311156200053857600080fd5b928601925b828410156200058f5785848e031215620005575760008081fd5b6200056162000373565b6200056c8562000475565b81526200057b88860162000475565b81890152825292850192908601906200053d565b60608c0151909850955050505080831115620005aa57600080fd5b5050620005ba87828801620003f7565b91505092959194509250565b634e487b7160e01b600052603260045260246000fd5b600060018201620005f157620005f162000312565b5060010190565b6080516136bf6200063760003960008181610315015281816109e701528181610a3e01528181610b7e01528181610bd50152610c4201526136bf6000f3fe60806040526004361061018f5760003560e01c80637c6ea412116100d6578063bc197c811161007f578063dbe921a211610059578063dbe921a214610545578063f23a6e6114610575578063f2fde38b146105bb57600080fd5b8063bc197c81146104bd578063be4f797a14610505578063c9d4264e1461052557600080fd5b80638da5cb5b116100b05780638da5cb5b1461042f5780638e8f294b1461044d578063938e0e2e1461049d57600080fd5b80637c6ea412146103da5780637fb32ea4146103fa5780638456cb591461041a57600080fd5b80633fc8cef311610138578063624f295b11610112578063624f295b146103925780636b84600e146103a5578063715018a6146103c557600080fd5b80633fc8cef31461030357806344a9bf5d1461034f5780635c975abb1461036257600080fd5b8063205639021161016957806320563902146102aa578063247fb1ac146102ca5780633f4ba83a146102ee57600080fd5b806301ffc9a71461019b578063114a7a1214610212578063150b7a021461023457600080fd5b3661019657005b600080fd5b3480156101a757600080fd5b506101fd6101b6366004612633565b7fffffffff00000000000000000000000000000000000000000000000000000000167f4e2312e0000000000000000000000000000000000000000000000000000000001490565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004612871565b6105db565b005b34801561024057600080fd5b5061027961024f3660046129c4565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610209565b3480156102b657600080fd5b506102326102c5366004612a45565b61081e565b3480156102d657600080fd5b506102e060025481565b604051908152602001610209565b3480156102fa57600080fd5b506102326109b2565b34801561030f57600080fd5b506103377f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610209565b61023261035d366004612ca9565b6109c4565b34801561036e57600080fd5b5060005474010000000000000000000000000000000000000000900460ff166101fd565b6102326103a0366004612f92565b610b0a565b3480156103b157600080fd5b506102326103c036600461309c565b610cff565b3480156103d157600080fd5b50610232610d84565b3480156103e657600080fd5b506102326103f53660046130d1565b610d96565b34801561040657600080fd5b50610232610415366004613149565b610ebf565b34801561042657600080fd5b50610232610fc4565b34801561043b57600080fd5b506000546001600160a01b0316610337565b34801561045957600080fd5b506104866104683660046131a3565b60036020526000908152604090205460ff8082169161010090041682565b604080519215158352901515602083015201610209565b3480156104a957600080fd5b506102326104b83660046131c0565b610fd4565b3480156104c957600080fd5b506102796104d836600461328d565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b34801561051157600080fd5b5061023261052036600461334c565b6111fa565b34801561053157600080fd5b5061023261054036600461341a565b6113aa565b34801561055157600080fd5b506101fd6105603660046131a3565b60046020526000908152604090205460ff1681565b34801561058157600080fd5b50610279610590366004613474565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b3480156105c757600080fd5b506102326105d63660046131a3565b611552565b6105e36115e2565b6105eb61163c565b82518451146106415760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b0000000000000000000000000060448201526064015b60405180910390fd5b81518351146106925760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b81518151146106e35760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b845181101561080e57838181518110610701576107016134f0565b60200260200101516001600160a01b031663f242432a3087848151811061072a5761072a6134f0565b6020026020010151868581518110610744576107446134f0565b602002602001015186868151811061075e5761075e6134f0565b60209081029190910101516040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b1681526001600160a01b0394851660048201529390921660248401526044830152606482015260a06084820152600060a482015260c401600060405180830381600087803b1580156107e357600080fd5b505af11580156107f7573d6000803e3d6000fd5b5050505080806108069061351f565b9150506106e6565b5061081860018055565b50505050565b6108266115e2565b81518151146108775760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b81518110156109ad57818181518110610895576108956134f0565b6020026020010151600360008584815181106108b3576108b36134f0565b6020908102919091018101516001600160a01b03168252818101929092526040016000208251815493909201511515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff921515929092167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009093169290921717905582517faa011e70873e4cc6356380c483b5f70548ef2eb4cb1363d7766f5077c4da1c549084908390811061096f5761096f6134f0565b602002602001015160405161099391906001600160a01b0391909116815260200190565b60405180910390a1806109a58161351f565b91505061087a565b505050565b6109ba6115e2565b6109c2611695565b565b6109cc61163c565b6109d4611705565b8115610aa357610a0f6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333085611770565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610a8a57600080fd5b505af1158015610a9e573d6000803e3d6000fd5b505050505b610aac816117f8565b478015610afc5760405133908290600081818185875af1925050503d8060008114610af3576040519150601f19603f3d011682016040523d82523d6000602084013e610af8565b606091505b5050505b50610b0660018055565b5050565b610b1261163c565b610b1a611705565b6000845111610b6b5760405162461bcd60e51b815260206004820152601a60248201527f53656e6465723a206e6f206f72646572207370656369666965640000000000006044820152606401610638565b8715610c3a57610ba66001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308b611770565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018990527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610c2157600080fd5b505af1158015610c35573d6000803e3d6000fd5b505050505b8615610cb5577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0886040518263ffffffff1660e01b81526004016000604051808303818588803b158015610c9b57600080fd5b505af1158015610caf573d6000803e3d6000fd5b50505050505b610cbe85611a67565b610cc786611ad1565b610cd0846117f8565b610cd983611c18565b610ce282611d2a565b610cec8582611ee6565b610cf560018055565b5050505050505050565b610d076115e2565b60005b8151811015610b065760036000838381518110610d2957610d296134f0565b6020908102919091018101516001600160a01b0316825281019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905580610d7c8161351f565b915050610d0a565b610d8c6115e2565b6109c26000612266565b610d9e6115e2565b60005b8351811015610818576000848281518110610dbe57610dbe6134f0565b6020026020010151905060005b8451811015610eaa576000858281518110610de857610de86134f0565b60200260200101519050600085610e0157600254610e04565b60005b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152602482018390529192509085169063095ea7b3906044016020604051808303816000875af1158015610e70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e94919061357e565b5050508080610ea29061351f565b915050610dcb565b50508080610eb79061351f565b915050610da1565b610ec76115e2565b610ecf61163c565b8051825114610f205760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b8251811015610afc57828181518110610f3e57610f3e6134f0565b60200260200101516001600160a01b0316828281518110610f6157610f616134f0565b602002602001015160405160006040518083038185875af1925050503d8060008114610fa9576040519150601f19603f3d011682016040523d82523d6000602084013e610fae565b606091505b5050508080610fbc9061351f565b915050610f23565b610fcc6115e2565b6109c26122ce565b610fdc6115e2565b610fe461163c565b81518351146110355760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b80518251146110865760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b83518110156111f0578281815181106110a4576110a46134f0565b60200260200101516001600160a01b031663a9059cbb60e01b8583815181106110cf576110cf6134f0565b60200260200101518484815181106110e9576110e96134f0565b60209081029190910101516040516001600160a01b0390921660248301526044820152606401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317909252905161119891906135bf565b6000604051808303816000865af19150503d80600081146111d5576040519150601f19603f3d011682016040523d82523d6000602084013e6111da565b606091505b50505080806111e89061351f565b915050611089565b506109ad60018055565b6112026115e2565b61120a61163c565b815183511461125b5760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b80518251146112ac5760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b83518110156111f0578281815181106112ca576112ca6134f0565b60200260200101516001600160a01b03166342842e0e308684815181106112f3576112f36134f0565b602002602001015185858151811061130d5761130d6134f0565b60209081029190910101516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561137f57600080fd5b505af1158015611393573d6000803e3d6000fd5b5050505080806113a29061351f565b9150506112af565b6113b26115e2565b60005b8251811015611486576001600460008584815181106113d6576113d66134f0565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f3bc9c657df9654d419ca570822f2fb292ced3f90f338ee28fc3e488cd00f235c838281518110611448576114486134f0565b602002602001015160405161146c91906001600160a01b0391909116815260200190565b60405180910390a18061147e8161351f565b9150506113b5565b5060005b81518110156109ad57600460008383815181106114a9576114a96134f0565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81549060ff02191690557f3bc9c657df9654d419ca570822f2fb292ced3f90f338ee28fc3e488cd00f235c828281518110611514576115146134f0565b602002602001015160405161153891906001600160a01b0391909116815260200190565b60405180910390a18061154a8161351f565b91505061148a565b61155a6115e2565b6001600160a01b0381166115d65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610638565b6115df81612266565b50565b6000546001600160a01b031633146109c25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610638565b60026001540361168e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610638565b6002600155565b61169d61233d565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60005474010000000000000000000000000000000000000000900460ff16156109c25760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610638565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526108189085906123a7565b60005b8151811015610b06576000828281518110611818576118186134f0565b60209081029190910181015180516001600160a01b031660009081526003909252604090912054909150610100900460ff166118965760405162461bcd60e51b815260206004820152601860248201527f457865637574653a20696e616374697665206d61726b657400000000000000006044820152606401610638565b80516001600160a01b031660009081526003602052604081205460ff16908161191f5782600001516001600160a01b031683608001516040516118d991906135bf565b600060405180830381855af49150503d8060008114611914576040519150601f19603f3d011682016040523d82523d6000602084013e611919565b606091505b50611988565b82600001516001600160a01b03168360200151846080015160405161194491906135bf565b60006040518083038185875af1925050503d8060008114611981576040519150601f19603f3d011682016040523d82523d6000602084013e611986565b606091505b505b5090508260600151801561199a575080155b15611a0d5760405162461bcd60e51b815260206004820152602760248201527f457865637574696f6e206661696c7572653a207265717569726520737563636560448201527f73732063616c6c000000000000000000000000000000000000000000000000006064820152608401610638565b60408084015181518681528315156020820152918201527f7f7fada35ff88375ea593f0562f5b1e9ccff03eee332b78315ecfd8a9fe2af9a9060600160405180910390a15050508080611a5f9061351f565b9150506117fb565b60005b8151811015610b06576000828281518110611a8757611a876134f0565b60200260200101519050600081600001511115611abe5780516020820151611abe916001600160a01b039091169033903090611770565b5080611ac98161351f565b915050611a6a565b60005b8151811015610b06576000828281518110611af157611af16134f0565b602090810291909101810151808201516001600160a01b03166000908152600490925260409091205490915060ff16611b6c5760405162461bcd60e51b815260206004820181905260248201527f417070726f76653a20756e61626c6520746f20617070726f766520746f6b656e6044820152606401610638565b805160208201516002546040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b039283166004820152602481019190915291169063095ea7b3906044016020604051808303816000875af1158015611bdf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c03919061357e565b50508080611c109061351f565b915050611ad4565b60005b8151811015610b06576000828281518110611c3857611c386134f0565b6020908102919091018101518051818301516040805130602482015233604482015260648082019390935281518082039093018352608401815293810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905292519193506001600160a01b031691611cd1916135bf565b6000604051808303816000865af19150503d8060008114611d0e576040519150601f19603f3d011682016040523d82523d6000602084013e611d13565b606091505b505050508080611d229061351f565b915050611c1b565b60005b8151811015610b06576000828281518110611d4a57611d4a6134f0565b6020908102919091018101518051918101516040517efdd58e00000000000000000000000000000000000000000000000000000000815230600482015260248101919091529092506000916001600160a01b03169062fdd58e90604401602060405180830381865afa158015611dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de891906135db565b90508160400151811115611dfd575060408101515b8015611ed157815160208084015160408051928301815260008352516001600160a01b039093169263f242432a92611e3d9230923392889160240161363e565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051611e8b91906135bf565b6000604051808303816000865af19150503d8060008114611ec8576040519150601f19603f3d011682016040523d82523d6000602084013e611ecd565b606091505b5050505b50508080611ede9061351f565b915050611d2d565b478015611f365760405133908290600081818185875af1925050503d8060008114611f2d576040519150601f19603f3d011682016040523d82523d6000602084013e611f32565b606091505b5050505b60005b83518110156120cf576000848281518110611f5657611f566134f0565b60209081029190910181015101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611fc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611feb91906135db565b905080156120ba5760408051336024820152604480820184905282518083039091018152606490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905290516001600160a01b03841691612074916135bf565b6000604051808303816000865af19150503d80600081146120b1576040519150601f19603f3d011682016040523d82523d6000602084013e6120b6565b606091505b5050505b505080806120c79061351f565b915050611f39565b5060005b82518110156108185760008382815181106120f0576120f06134f0565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561215e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218291906135db565b905080156122515760408051336024820152604480820184905282518083039091018152606490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905290516001600160a01b0384169161220b916135bf565b6000604051808303816000865af19150503d8060008114612248576040519150601f19603f3d011682016040523d82523d6000602084013e61224d565b606091505b5050505b5050808061225e9061351f565b9150506120d3565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6122d6611705565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586116e83390565b60005474010000000000000000000000000000000000000000900460ff166109c25760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610638565b60006123fc826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661248c9092919063ffffffff16565b8051909150156109ad578080602001905181019061241a919061357e565b6109ad5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610638565b606061249b84846000856124a3565b949350505050565b60608247101561251b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610638565b600080866001600160a01b0316858760405161253791906135bf565b60006040518083038185875af1925050503d8060008114612574576040519150601f19603f3d011682016040523d82523d6000602084013e612579565b606091505b509150915061258a87838387612595565b979650505050505050565b606083156126045782516000036125fd576001600160a01b0385163b6125fd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610638565b508161249b565b61249b83838151156126195781518083602001fd5b8060405162461bcd60e51b81526004016106389190613676565b60006020828403121561264557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461267557600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156126ce576126ce61267c565b60405290565b60405160a0810167ffffffffffffffff811182821017156126ce576126ce61267c565b6040516060810167ffffffffffffffff811182821017156126ce576126ce61267c565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156127615761276161267c565b604052919050565b600067ffffffffffffffff8211156127835761278361267c565b5060051b60200190565b6001600160a01b03811681146115df57600080fd5b600082601f8301126127b357600080fd5b813560206127c86127c383612769565b61271a565b82815260059290921b840181019181810190868411156127e757600080fd5b8286015b8481101561280b5780356127fe8161278d565b83529183019183016127eb565b509695505050505050565b600082601f83011261282757600080fd5b813560206128376127c383612769565b82815260059290921b8401810191818101908684111561285657600080fd5b8286015b8481101561280b578035835291830191830161285a565b6000806000806080858703121561288757600080fd5b843567ffffffffffffffff8082111561289f57600080fd5b6128ab888389016127a2565b95506020915081870135818111156128c257600080fd5b8701601f810189136128d357600080fd5b80356128e16127c382612769565b81815260059190911b8201840190848101908b83111561290057600080fd5b928501925b828410156129275783356129188161278d565b82529285019290850190612905565b9750505050604087013591508082111561294057600080fd5b61294c88838901612816565b9350606087013591508082111561296257600080fd5b5061296f87828801612816565b91505092959194509250565b60008083601f84011261298d57600080fd5b50813567ffffffffffffffff8111156129a557600080fd5b6020830191508360208285010111156129bd57600080fd5b9250929050565b6000806000806000608086880312156129dc57600080fd5b85356129e78161278d565b945060208601356129f78161278d565b935060408601359250606086013567ffffffffffffffff811115612a1a57600080fd5b612a268882890161297b565b969995985093965092949392505050565b80151581146115df57600080fd5b6000806040808486031215612a5957600080fd5b833567ffffffffffffffff80821115612a7157600080fd5b612a7d878388016127a2565b9450602091508186013581811115612a9457600080fd5b86019050601f81018713612aa757600080fd5b8035612ab56127c382612769565b81815260069190911b82018301908381019089831115612ad457600080fd5b928401925b82841015612b265785848b031215612af15760008081fd5b612af96126ab565b8435612b0481612a37565b815284860135612b1381612a37565b8187015282529285019290840190612ad9565b8096505050505050509250929050565b600082601f830112612b4757600080fd5b81356020612b576127c383612769565b82815260059290921b84018101918181019086841115612b7657600080fd5b8286015b8481101561280b57803567ffffffffffffffff80821115612b9b5760008081fd5b818901915060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08181858e03011215612bd55760008081fd5b612bdd6126d4565b88850135612bea8161278d565b81526040858101358a83015260608087013582840152608080880135612c0f81612a37565b84830152948701359486861115612c2857600091508182fd5b85880197508f603f890112612c3f57600095508586fd5b8b880135955086861115612c5557612c5561267c565b612c658c86601f8901160161271a565b96508587528f83878a01011115612c7e57600094508485fd5b858389018d89013760009587018c019590955250509182019290925285525050918301918301612b7a565b60008060408385031215612cbc57600080fd5b82359150602083013567ffffffffffffffff811115612cda57600080fd5b612ce685828601612b36565b9150509250929050565b600082601f830112612d0157600080fd5b81356020612d116127c383612769565b82815260069290921b84018101918181019086841115612d3057600080fd5b8286015b8481101561280b5760408189031215612d4d5760008081fd5b612d556126ab565b8135612d608161278d565b815281850135612d6f8161278d565b81860152835291830191604001612d34565b600082601f830112612d9257600080fd5b81356020612da26127c383612769565b82815260069290921b84018101918181019086841115612dc157600080fd5b8286015b8481101561280b5760408189031215612dde5760008081fd5b612de66126ab565b8135815284820135612df78161278d565b81860152835291830191604001612dc5565b600082601f830112612e1a57600080fd5b81356020612e2a6127c383612769565b82815260069290921b84018101918181019086841115612e4957600080fd5b8286015b8481101561280b5760408189031215612e665760008081fd5b612e6e6126ab565b8135612e798161278d565b81528185013585820152835291830191604001612e4d565b600082601f830112612ea257600080fd5b81356020612eb26127c383612769565b82815260609283028501820192828201919087851115612ed157600080fd5b8387015b85811015612f215781818a031215612eed5760008081fd5b612ef56126f7565b8135612f008161278d565b81528186013586820152604080830135908201528452928401928101612ed5565b5090979650505050505050565b600082601f830112612f3f57600080fd5b81356020612f4f6127c383612769565b82815260059290921b84018101918181019086841115612f6e57600080fd5b8286015b8481101561280b578035612f858161278d565b8352918301918301612f72565b600080600080600080600080610100898b031215612faf57600080fd5b8835975060208901359650604089013567ffffffffffffffff80821115612fd557600080fd5b612fe18c838d01612cf0565b975060608b0135915080821115612ff757600080fd5b6130038c838d01612d81565b965060808b013591508082111561301957600080fd5b6130258c838d01612b36565b955060a08b013591508082111561303b57600080fd5b6130478c838d01612e09565b945060c08b013591508082111561305d57600080fd5b6130698c838d01612e91565b935060e08b013591508082111561307f57600080fd5b5061308c8b828c01612f2e565b9150509295985092959890939650565b6000602082840312156130ae57600080fd5b813567ffffffffffffffff8111156130c557600080fd5b61249b848285016127a2565b6000806000606084860312156130e657600080fd5b833567ffffffffffffffff808211156130fe57600080fd5b61310a87838801612f2e565b9450602086013591508082111561312057600080fd5b5061312d868287016127a2565b925050604084013561313e81612a37565b809150509250925092565b6000806040838503121561315c57600080fd5b823567ffffffffffffffff8082111561317457600080fd5b613180868387016127a2565b9350602085013591508082111561319657600080fd5b50612ce685828601612816565b6000602082840312156131b557600080fd5b81356126758161278d565b6000806000606084860312156131d557600080fd5b833567ffffffffffffffff808211156131ed57600080fd5b6131f9878388016127a2565b9450602086013591508082111561320f57600080fd5b61321b87838801612f2e565b9350604086013591508082111561323157600080fd5b5061323e86828701612816565b9150509250925092565b60008083601f84011261325a57600080fd5b50813567ffffffffffffffff81111561327257600080fd5b6020830191508360208260051b85010111156129bd57600080fd5b60008060008060008060008060a0898b0312156132a957600080fd5b88356132b48161278d565b975060208901356132c48161278d565b9650604089013567ffffffffffffffff808211156132e157600080fd5b6132ed8c838d01613248565b909850965060608b013591508082111561330657600080fd5b6133128c838d01613248565b909650945060808b013591508082111561332b57600080fd5b506133388b828c0161297b565b999c989b5096995094979396929594505050565b60008060006060848603121561336157600080fd5b833567ffffffffffffffff8082111561337957600080fd5b613385878388016127a2565b945060209150818601358181111561339c57600080fd5b8601601f810188136133ad57600080fd5b80356133bb6127c382612769565b81815260059190911b8201840190848101908a8311156133da57600080fd5b928501925b828410156134015783356133f28161278d565b825292850192908501906133df565b9650505050604086013591508082111561323157600080fd5b6000806040838503121561342d57600080fd5b823567ffffffffffffffff8082111561344557600080fd5b613451868387016127a2565b9350602085013591508082111561346757600080fd5b50612ce6858286016127a2565b60008060008060008060a0878903121561348d57600080fd5b86356134988161278d565b955060208701356134a88161278d565b94506040870135935060608701359250608087013567ffffffffffffffff8111156134d257600080fd5b6134de89828a0161297b565b979a9699509497509295939492505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613577577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60006020828403121561359057600080fd5b815161267581612a37565b60005b838110156135b657818101518382015260200161359e565b50506000910152565b600082516135d181846020870161359b565b9190910192915050565b6000602082840312156135ed57600080fd5b5051919050565b6000815180845261360c81602086016020860161359b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a0608083015261258a60a08301846135f4565b60208152600061267560208301846135f456fea264697066735822122027f7de0d7205aa9aa13f0dc81c2ce78bf1bb0fd314cc6b4b14759420e30b106064736f6c634300081100330000000000000000000000009cb1fe9470b1dcc91d9c0c0e50c42680c06a7926000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000100000000000000000000000088532a901475b3ddf370386ae22c2067846f7d7a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000088532a901475b3ddf370386ae22c2067846f7d7a
Deployed ByteCode
0x60806040526004361061018f5760003560e01c80637c6ea412116100d6578063bc197c811161007f578063dbe921a211610059578063dbe921a214610545578063f23a6e6114610575578063f2fde38b146105bb57600080fd5b8063bc197c81146104bd578063be4f797a14610505578063c9d4264e1461052557600080fd5b80638da5cb5b116100b05780638da5cb5b1461042f5780638e8f294b1461044d578063938e0e2e1461049d57600080fd5b80637c6ea412146103da5780637fb32ea4146103fa5780638456cb591461041a57600080fd5b80633fc8cef311610138578063624f295b11610112578063624f295b146103925780636b84600e146103a5578063715018a6146103c557600080fd5b80633fc8cef31461030357806344a9bf5d1461034f5780635c975abb1461036257600080fd5b8063205639021161016957806320563902146102aa578063247fb1ac146102ca5780633f4ba83a146102ee57600080fd5b806301ffc9a71461019b578063114a7a1214610212578063150b7a021461023457600080fd5b3661019657005b600080fd5b3480156101a757600080fd5b506101fd6101b6366004612633565b7fffffffff00000000000000000000000000000000000000000000000000000000167f4e2312e0000000000000000000000000000000000000000000000000000000001490565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004612871565b6105db565b005b34801561024057600080fd5b5061027961024f3660046129c4565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610209565b3480156102b657600080fd5b506102326102c5366004612a45565b61081e565b3480156102d657600080fd5b506102e060025481565b604051908152602001610209565b3480156102fa57600080fd5b506102326109b2565b34801561030f57600080fd5b506103377f0000000000000000000000009cb1fe9470b1dcc91d9c0c0e50c42680c06a792681565b6040516001600160a01b039091168152602001610209565b61023261035d366004612ca9565b6109c4565b34801561036e57600080fd5b5060005474010000000000000000000000000000000000000000900460ff166101fd565b6102326103a0366004612f92565b610b0a565b3480156103b157600080fd5b506102326103c036600461309c565b610cff565b3480156103d157600080fd5b50610232610d84565b3480156103e657600080fd5b506102326103f53660046130d1565b610d96565b34801561040657600080fd5b50610232610415366004613149565b610ebf565b34801561042657600080fd5b50610232610fc4565b34801561043b57600080fd5b506000546001600160a01b0316610337565b34801561045957600080fd5b506104866104683660046131a3565b60036020526000908152604090205460ff8082169161010090041682565b604080519215158352901515602083015201610209565b3480156104a957600080fd5b506102326104b83660046131c0565b610fd4565b3480156104c957600080fd5b506102796104d836600461328d565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b34801561051157600080fd5b5061023261052036600461334c565b6111fa565b34801561053157600080fd5b5061023261054036600461341a565b6113aa565b34801561055157600080fd5b506101fd6105603660046131a3565b60046020526000908152604090205460ff1681565b34801561058157600080fd5b50610279610590366004613474565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b3480156105c757600080fd5b506102326105d63660046131a3565b611552565b6105e36115e2565b6105eb61163c565b82518451146106415760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b0000000000000000000000000060448201526064015b60405180910390fd5b81518351146106925760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b81518151146106e35760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b845181101561080e57838181518110610701576107016134f0565b60200260200101516001600160a01b031663f242432a3087848151811061072a5761072a6134f0565b6020026020010151868581518110610744576107446134f0565b602002602001015186868151811061075e5761075e6134f0565b60209081029190910101516040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b1681526001600160a01b0394851660048201529390921660248401526044830152606482015260a06084820152600060a482015260c401600060405180830381600087803b1580156107e357600080fd5b505af11580156107f7573d6000803e3d6000fd5b5050505080806108069061351f565b9150506106e6565b5061081860018055565b50505050565b6108266115e2565b81518151146108775760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b81518110156109ad57818181518110610895576108956134f0565b6020026020010151600360008584815181106108b3576108b36134f0565b6020908102919091018101516001600160a01b03168252818101929092526040016000208251815493909201511515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff921515929092167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009093169290921717905582517faa011e70873e4cc6356380c483b5f70548ef2eb4cb1363d7766f5077c4da1c549084908390811061096f5761096f6134f0565b602002602001015160405161099391906001600160a01b0391909116815260200190565b60405180910390a1806109a58161351f565b91505061087a565b505050565b6109ba6115e2565b6109c2611695565b565b6109cc61163c565b6109d4611705565b8115610aa357610a0f6001600160a01b037f0000000000000000000000009cb1fe9470b1dcc91d9c0c0e50c42680c06a792616333085611770565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018390527f0000000000000000000000009cb1fe9470b1dcc91d9c0c0e50c42680c06a79266001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610a8a57600080fd5b505af1158015610a9e573d6000803e3d6000fd5b505050505b610aac816117f8565b478015610afc5760405133908290600081818185875af1925050503d8060008114610af3576040519150601f19603f3d011682016040523d82523d6000602084013e610af8565b606091505b5050505b50610b0660018055565b5050565b610b1261163c565b610b1a611705565b6000845111610b6b5760405162461bcd60e51b815260206004820152601a60248201527f53656e6465723a206e6f206f72646572207370656369666965640000000000006044820152606401610638565b8715610c3a57610ba66001600160a01b037f0000000000000000000000009cb1fe9470b1dcc91d9c0c0e50c42680c06a79261633308b611770565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018990527f0000000000000000000000009cb1fe9470b1dcc91d9c0c0e50c42680c06a79266001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610c2157600080fd5b505af1158015610c35573d6000803e3d6000fd5b505050505b8615610cb5577f0000000000000000000000009cb1fe9470b1dcc91d9c0c0e50c42680c06a79266001600160a01b031663d0e30db0886040518263ffffffff1660e01b81526004016000604051808303818588803b158015610c9b57600080fd5b505af1158015610caf573d6000803e3d6000fd5b50505050505b610cbe85611a67565b610cc786611ad1565b610cd0846117f8565b610cd983611c18565b610ce282611d2a565b610cec8582611ee6565b610cf560018055565b5050505050505050565b610d076115e2565b60005b8151811015610b065760036000838381518110610d2957610d296134f0565b6020908102919091018101516001600160a01b0316825281019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905580610d7c8161351f565b915050610d0a565b610d8c6115e2565b6109c26000612266565b610d9e6115e2565b60005b8351811015610818576000848281518110610dbe57610dbe6134f0565b6020026020010151905060005b8451811015610eaa576000858281518110610de857610de86134f0565b60200260200101519050600085610e0157600254610e04565b60005b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152602482018390529192509085169063095ea7b3906044016020604051808303816000875af1158015610e70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e94919061357e565b5050508080610ea29061351f565b915050610dcb565b50508080610eb79061351f565b915050610da1565b610ec76115e2565b610ecf61163c565b8051825114610f205760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b8251811015610afc57828181518110610f3e57610f3e6134f0565b60200260200101516001600160a01b0316828281518110610f6157610f616134f0565b602002602001015160405160006040518083038185875af1925050503d8060008114610fa9576040519150601f19603f3d011682016040523d82523d6000602084013e610fae565b606091505b5050508080610fbc9061351f565b915050610f23565b610fcc6115e2565b6109c26122ce565b610fdc6115e2565b610fe461163c565b81518351146110355760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b80518251146110865760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b83518110156111f0578281815181106110a4576110a46134f0565b60200260200101516001600160a01b031663a9059cbb60e01b8583815181106110cf576110cf6134f0565b60200260200101518484815181106110e9576110e96134f0565b60209081029190910101516040516001600160a01b0390921660248301526044820152606401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317909252905161119891906135bf565b6000604051808303816000865af19150503d80600081146111d5576040519150601f19603f3d011682016040523d82523d6000602084013e6111da565b606091505b50505080806111e89061351f565b915050611089565b506109ad60018055565b6112026115e2565b61120a61163c565b815183511461125b5760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b80518251146112ac5760405162461bcd60e51b815260206004820152601360248201527f4f776e65723a206c656e67746820636865636b000000000000000000000000006044820152606401610638565b60005b83518110156111f0578281815181106112ca576112ca6134f0565b60200260200101516001600160a01b03166342842e0e308684815181106112f3576112f36134f0565b602002602001015185858151811061130d5761130d6134f0565b60209081029190910101516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561137f57600080fd5b505af1158015611393573d6000803e3d6000fd5b5050505080806113a29061351f565b9150506112af565b6113b26115e2565b60005b8251811015611486576001600460008584815181106113d6576113d66134f0565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f3bc9c657df9654d419ca570822f2fb292ced3f90f338ee28fc3e488cd00f235c838281518110611448576114486134f0565b602002602001015160405161146c91906001600160a01b0391909116815260200190565b60405180910390a18061147e8161351f565b9150506113b5565b5060005b81518110156109ad57600460008383815181106114a9576114a96134f0565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81549060ff02191690557f3bc9c657df9654d419ca570822f2fb292ced3f90f338ee28fc3e488cd00f235c828281518110611514576115146134f0565b602002602001015160405161153891906001600160a01b0391909116815260200190565b60405180910390a18061154a8161351f565b91505061148a565b61155a6115e2565b6001600160a01b0381166115d65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610638565b6115df81612266565b50565b6000546001600160a01b031633146109c25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610638565b60026001540361168e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610638565b6002600155565b61169d61233d565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60005474010000000000000000000000000000000000000000900460ff16156109c25760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610638565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526108189085906123a7565b60005b8151811015610b06576000828281518110611818576118186134f0565b60209081029190910181015180516001600160a01b031660009081526003909252604090912054909150610100900460ff166118965760405162461bcd60e51b815260206004820152601860248201527f457865637574653a20696e616374697665206d61726b657400000000000000006044820152606401610638565b80516001600160a01b031660009081526003602052604081205460ff16908161191f5782600001516001600160a01b031683608001516040516118d991906135bf565b600060405180830381855af49150503d8060008114611914576040519150601f19603f3d011682016040523d82523d6000602084013e611919565b606091505b50611988565b82600001516001600160a01b03168360200151846080015160405161194491906135bf565b60006040518083038185875af1925050503d8060008114611981576040519150601f19603f3d011682016040523d82523d6000602084013e611986565b606091505b505b5090508260600151801561199a575080155b15611a0d5760405162461bcd60e51b815260206004820152602760248201527f457865637574696f6e206661696c7572653a207265717569726520737563636560448201527f73732063616c6c000000000000000000000000000000000000000000000000006064820152608401610638565b60408084015181518681528315156020820152918201527f7f7fada35ff88375ea593f0562f5b1e9ccff03eee332b78315ecfd8a9fe2af9a9060600160405180910390a15050508080611a5f9061351f565b9150506117fb565b60005b8151811015610b06576000828281518110611a8757611a876134f0565b60200260200101519050600081600001511115611abe5780516020820151611abe916001600160a01b039091169033903090611770565b5080611ac98161351f565b915050611a6a565b60005b8151811015610b06576000828281518110611af157611af16134f0565b602090810291909101810151808201516001600160a01b03166000908152600490925260409091205490915060ff16611b6c5760405162461bcd60e51b815260206004820181905260248201527f417070726f76653a20756e61626c6520746f20617070726f766520746f6b656e6044820152606401610638565b805160208201516002546040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b039283166004820152602481019190915291169063095ea7b3906044016020604051808303816000875af1158015611bdf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c03919061357e565b50508080611c109061351f565b915050611ad4565b60005b8151811015610b06576000828281518110611c3857611c386134f0565b6020908102919091018101518051818301516040805130602482015233604482015260648082019390935281518082039093018352608401815293810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905292519193506001600160a01b031691611cd1916135bf565b6000604051808303816000865af19150503d8060008114611d0e576040519150601f19603f3d011682016040523d82523d6000602084013e611d13565b606091505b505050508080611d229061351f565b915050611c1b565b60005b8151811015610b06576000828281518110611d4a57611d4a6134f0565b6020908102919091018101518051918101516040517efdd58e00000000000000000000000000000000000000000000000000000000815230600482015260248101919091529092506000916001600160a01b03169062fdd58e90604401602060405180830381865afa158015611dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de891906135db565b90508160400151811115611dfd575060408101515b8015611ed157815160208084015160408051928301815260008352516001600160a01b039093169263f242432a92611e3d9230923392889160240161363e565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051611e8b91906135bf565b6000604051808303816000865af19150503d8060008114611ec8576040519150601f19603f3d011682016040523d82523d6000602084013e611ecd565b606091505b5050505b50508080611ede9061351f565b915050611d2d565b478015611f365760405133908290600081818185875af1925050503d8060008114611f2d576040519150601f19603f3d011682016040523d82523d6000602084013e611f32565b606091505b5050505b60005b83518110156120cf576000848281518110611f5657611f566134f0565b60209081029190910181015101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611fc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611feb91906135db565b905080156120ba5760408051336024820152604480820184905282518083039091018152606490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905290516001600160a01b03841691612074916135bf565b6000604051808303816000865af19150503d80600081146120b1576040519150601f19603f3d011682016040523d82523d6000602084013e6120b6565b606091505b5050505b505080806120c79061351f565b915050611f39565b5060005b82518110156108185760008382815181106120f0576120f06134f0565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561215e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218291906135db565b905080156122515760408051336024820152604480820184905282518083039091018152606490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905290516001600160a01b0384169161220b916135bf565b6000604051808303816000865af19150503d8060008114612248576040519150601f19603f3d011682016040523d82523d6000602084013e61224d565b606091505b5050505b5050808061225e9061351f565b9150506120d3565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6122d6611705565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586116e83390565b60005474010000000000000000000000000000000000000000900460ff166109c25760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610638565b60006123fc826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661248c9092919063ffffffff16565b8051909150156109ad578080602001905181019061241a919061357e565b6109ad5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610638565b606061249b84846000856124a3565b949350505050565b60608247101561251b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610638565b600080866001600160a01b0316858760405161253791906135bf565b60006040518083038185875af1925050503d8060008114612574576040519150601f19603f3d011682016040523d82523d6000602084013e612579565b606091505b509150915061258a87838387612595565b979650505050505050565b606083156126045782516000036125fd576001600160a01b0385163b6125fd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610638565b508161249b565b61249b83838151156126195781518083602001fd5b8060405162461bcd60e51b81526004016106389190613676565b60006020828403121561264557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461267557600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156126ce576126ce61267c565b60405290565b60405160a0810167ffffffffffffffff811182821017156126ce576126ce61267c565b6040516060810167ffffffffffffffff811182821017156126ce576126ce61267c565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156127615761276161267c565b604052919050565b600067ffffffffffffffff8211156127835761278361267c565b5060051b60200190565b6001600160a01b03811681146115df57600080fd5b600082601f8301126127b357600080fd5b813560206127c86127c383612769565b61271a565b82815260059290921b840181019181810190868411156127e757600080fd5b8286015b8481101561280b5780356127fe8161278d565b83529183019183016127eb565b509695505050505050565b600082601f83011261282757600080fd5b813560206128376127c383612769565b82815260059290921b8401810191818101908684111561285657600080fd5b8286015b8481101561280b578035835291830191830161285a565b6000806000806080858703121561288757600080fd5b843567ffffffffffffffff8082111561289f57600080fd5b6128ab888389016127a2565b95506020915081870135818111156128c257600080fd5b8701601f810189136128d357600080fd5b80356128e16127c382612769565b81815260059190911b8201840190848101908b83111561290057600080fd5b928501925b828410156129275783356129188161278d565b82529285019290850190612905565b9750505050604087013591508082111561294057600080fd5b61294c88838901612816565b9350606087013591508082111561296257600080fd5b5061296f87828801612816565b91505092959194509250565b60008083601f84011261298d57600080fd5b50813567ffffffffffffffff8111156129a557600080fd5b6020830191508360208285010111156129bd57600080fd5b9250929050565b6000806000806000608086880312156129dc57600080fd5b85356129e78161278d565b945060208601356129f78161278d565b935060408601359250606086013567ffffffffffffffff811115612a1a57600080fd5b612a268882890161297b565b969995985093965092949392505050565b80151581146115df57600080fd5b6000806040808486031215612a5957600080fd5b833567ffffffffffffffff80821115612a7157600080fd5b612a7d878388016127a2565b9450602091508186013581811115612a9457600080fd5b86019050601f81018713612aa757600080fd5b8035612ab56127c382612769565b81815260069190911b82018301908381019089831115612ad457600080fd5b928401925b82841015612b265785848b031215612af15760008081fd5b612af96126ab565b8435612b0481612a37565b815284860135612b1381612a37565b8187015282529285019290840190612ad9565b8096505050505050509250929050565b600082601f830112612b4757600080fd5b81356020612b576127c383612769565b82815260059290921b84018101918181019086841115612b7657600080fd5b8286015b8481101561280b57803567ffffffffffffffff80821115612b9b5760008081fd5b818901915060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08181858e03011215612bd55760008081fd5b612bdd6126d4565b88850135612bea8161278d565b81526040858101358a83015260608087013582840152608080880135612c0f81612a37565b84830152948701359486861115612c2857600091508182fd5b85880197508f603f890112612c3f57600095508586fd5b8b880135955086861115612c5557612c5561267c565b612c658c86601f8901160161271a565b96508587528f83878a01011115612c7e57600094508485fd5b858389018d89013760009587018c019590955250509182019290925285525050918301918301612b7a565b60008060408385031215612cbc57600080fd5b82359150602083013567ffffffffffffffff811115612cda57600080fd5b612ce685828601612b36565b9150509250929050565b600082601f830112612d0157600080fd5b81356020612d116127c383612769565b82815260069290921b84018101918181019086841115612d3057600080fd5b8286015b8481101561280b5760408189031215612d4d5760008081fd5b612d556126ab565b8135612d608161278d565b815281850135612d6f8161278d565b81860152835291830191604001612d34565b600082601f830112612d9257600080fd5b81356020612da26127c383612769565b82815260069290921b84018101918181019086841115612dc157600080fd5b8286015b8481101561280b5760408189031215612dde5760008081fd5b612de66126ab565b8135815284820135612df78161278d565b81860152835291830191604001612dc5565b600082601f830112612e1a57600080fd5b81356020612e2a6127c383612769565b82815260069290921b84018101918181019086841115612e4957600080fd5b8286015b8481101561280b5760408189031215612e665760008081fd5b612e6e6126ab565b8135612e798161278d565b81528185013585820152835291830191604001612e4d565b600082601f830112612ea257600080fd5b81356020612eb26127c383612769565b82815260609283028501820192828201919087851115612ed157600080fd5b8387015b85811015612f215781818a031215612eed5760008081fd5b612ef56126f7565b8135612f008161278d565b81528186013586820152604080830135908201528452928401928101612ed5565b5090979650505050505050565b600082601f830112612f3f57600080fd5b81356020612f4f6127c383612769565b82815260059290921b84018101918181019086841115612f6e57600080fd5b8286015b8481101561280b578035612f858161278d565b8352918301918301612f72565b600080600080600080600080610100898b031215612faf57600080fd5b8835975060208901359650604089013567ffffffffffffffff80821115612fd557600080fd5b612fe18c838d01612cf0565b975060608b0135915080821115612ff757600080fd5b6130038c838d01612d81565b965060808b013591508082111561301957600080fd5b6130258c838d01612b36565b955060a08b013591508082111561303b57600080fd5b6130478c838d01612e09565b945060c08b013591508082111561305d57600080fd5b6130698c838d01612e91565b935060e08b013591508082111561307f57600080fd5b5061308c8b828c01612f2e565b9150509295985092959890939650565b6000602082840312156130ae57600080fd5b813567ffffffffffffffff8111156130c557600080fd5b61249b848285016127a2565b6000806000606084860312156130e657600080fd5b833567ffffffffffffffff808211156130fe57600080fd5b61310a87838801612f2e565b9450602086013591508082111561312057600080fd5b5061312d868287016127a2565b925050604084013561313e81612a37565b809150509250925092565b6000806040838503121561315c57600080fd5b823567ffffffffffffffff8082111561317457600080fd5b613180868387016127a2565b9350602085013591508082111561319657600080fd5b50612ce685828601612816565b6000602082840312156131b557600080fd5b81356126758161278d565b6000806000606084860312156131d557600080fd5b833567ffffffffffffffff808211156131ed57600080fd5b6131f9878388016127a2565b9450602086013591508082111561320f57600080fd5b61321b87838801612f2e565b9350604086013591508082111561323157600080fd5b5061323e86828701612816565b9150509250925092565b60008083601f84011261325a57600080fd5b50813567ffffffffffffffff81111561327257600080fd5b6020830191508360208260051b85010111156129bd57600080fd5b60008060008060008060008060a0898b0312156132a957600080fd5b88356132b48161278d565b975060208901356132c48161278d565b9650604089013567ffffffffffffffff808211156132e157600080fd5b6132ed8c838d01613248565b909850965060608b013591508082111561330657600080fd5b6133128c838d01613248565b909650945060808b013591508082111561332b57600080fd5b506133388b828c0161297b565b999c989b5096995094979396929594505050565b60008060006060848603121561336157600080fd5b833567ffffffffffffffff8082111561337957600080fd5b613385878388016127a2565b945060209150818601358181111561339c57600080fd5b8601601f810188136133ad57600080fd5b80356133bb6127c382612769565b81815260059190911b8201840190848101908a8311156133da57600080fd5b928501925b828410156134015783356133f28161278d565b825292850192908501906133df565b9650505050604086013591508082111561323157600080fd5b6000806040838503121561342d57600080fd5b823567ffffffffffffffff8082111561344557600080fd5b613451868387016127a2565b9350602085013591508082111561346757600080fd5b50612ce6858286016127a2565b60008060008060008060a0878903121561348d57600080fd5b86356134988161278d565b955060208701356134a88161278d565b94506040870135935060608701359250608087013567ffffffffffffffff8111156134d257600080fd5b6134de89828a0161297b565b979a9699509497509295939492505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613577577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60006020828403121561359057600080fd5b815161267581612a37565b60005b838110156135b657818101518382015260200161359e565b50506000910152565b600082516135d181846020870161359b565b9190910192915050565b6000602082840312156135ed57600080fd5b5051919050565b6000815180845261360c81602086016020860161359b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a0608083015261258a60a08301846135f4565b60208152600061267560208301846135f456fea264697066735822122027f7de0d7205aa9aa13f0dc81c2ce78bf1bb0fd314cc6b4b14759420e30b106064736f6c63430008110033