ERC-1155
Source Code
Overview
Max Total Supply
0
Holders
381
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
Contract Name:
Ocean
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 10000000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
// Cowri Labs Inc.
// All solidity behavior related comments are in reference to this version of
// the solc compiler.
pragma solidity ^0.8.19;
// OpenZeppelin ERC Interfaces
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
// OpenZeppelin Utility Library
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// ShellV2 Interfaces, Data Structures, and Library
import { IOceanInteractions, Interaction, InteractionType } from "./Interactions.sol";
import { IOceanFeeChange } from "./IOceanFeeChange.sol";
import { IOceanPrimitive } from "./IOceanPrimitive.sol";
import { BalanceDelta, LibBalanceDelta } from "./BalanceDelta.sol";
// ShellV2 ERC-1155 with logic related to public multitoken ledger management.
import { OceanERC1155 } from "./OceanERC1155.sol";
/**
* @title A public multitoken ledger for DeFi
* @author Cowri Labs Team
* @dev The Ocean is designed to interact with contracts that implement IERC20,
* IERC721, IERC-1155, or IOceanPrimitive.
* @dev The Ocean is three things.
* 1. At the highest level, it is a defi framework[0]. Users provide a list
* of interactions, and the Ocean executes those interactions. Each
* interaction involves a call to an external contract. These calls result
* in updates to the Ocean's accounting system.
* 2. Suporting this defi framework is an accounting system that can transfer,
* mint, or burn tokens. Each token in the accounting system is identified by
* its oceanId. Every oceanId is uniquely derived from an external contract
* address. This external contract is the only contract able to cause mints
* or burns of this token[1].
* 3. Supporting this accounting system is an ERC-1155 ledger with all the
* standard ERC-1155 features. Users and primitives can interact with their
* tokens using both the defi framework and the ERC-1155 functions.
*
* [0] We call it a framework because the Ocean calls predefined functions on
* external contracts at certain points in its exection. The lifecycle is
* managed by the Ocean, while the business logic is managed by external
* contracts. Conceptually this is quite similar to a typical web framework.
* [1] For example, when a user wraps an ERC-20 token into the Ocean, the
* framework calls the ERC-20 transfer function, and upon success, mints the
* wrapped token to the user. In another case, when a user deposits a base
* token into a liquidity pool to recieve liquidity provider tokens, the
* framework calls the liquidity pool, tells it how much of the base token it
* will receive, and asks it how much of the liquidity provider token it
* would like to mint. When the pool responds, the framework mints this
* amount to the user.
*
* @dev Getting started tips:
* 1. Check out Interactions.sol
* 2. Read through the implementation of Ocean.doInteraction(), glossing over
* the function call to _executeInteraction().
* 3. Read through the imlementation of Ocean.doMultipleInteractions(), again
* glossing over the function call to _executeInteraction(). When you
* encounter calls to LibBalanceDelta, check out their implementations.
* 4. Read through _executeInteraction() and all the functions it calls.
* Understand how this is the line separating the accounting for the external
* contracts and the accounting for the current user.
* You can read the implementations of the specific interactions in any
* order, but it might be good to go through them in order of increasing
* complexity. The called functions, in order of increasing complexity, are:
* wrapErc721, unwrapErc721, wrapErc1155, unwrapErc1155, computeOutputAmount,
* computeInputAmount, unwrapErc20, and wrapErc20. When you get to
* computeOutputAmount, check out IOceanPrimitive, IOceanToken, and the
* function registerNewTokens() in OceanERC1155.
*/
contract Ocean is IOceanInteractions, IOceanFeeChange, OceanERC1155, IERC721Receiver, IERC1155Receiver {
using LibBalanceDelta for BalanceDelta[];
/// @notice this is the oceanId used for shETH
/// @dev hexadecimal(ascii("shETH"))
uint256 immutable WRAPPED_ETHER_ID;
/// @dev this is equivalent to 5 basis points: 1 / 2000 = 0.05%
/// @dev When limited to 5 bips or less an integer divisor is an efficient
/// and precise method of calculating a fee.
/// @notice As the divisor shrinks, the fee charged grows
uint256 constant MIN_UNWRAP_FEE_DIVISOR = 2000;
/// @notice wrapped ERC20 tokens are stored in an 18 decimal representation
/// @dev this makes it easier to implement AMMs between similar tokens
uint8 constant NORMALIZED_DECIMALS = 18;
/// @notice When the specifiedAmount is equal to this value, we set
/// specifiedAmount to the balance delta.
uint256 constant GET_BALANCE_DELTA = type(uint256).max;
/// @dev Determines if a transfer callback is expected.
/// @dev adapted from OpenZeppelin Reentrancy Guard
uint256 constant NOT_INTERACTION = 1;
uint256 constant INTERACTION = 2;
uint256 constant MAX_UNWRAP_FEE = type(uint256).max;
/// @notice Used to calculate the unwrap fee
/// unwrapFee = unwrapAmount / unwrapFeeDivisor
/// Because this uses integer division, the fee is always rounded down
/// If unwrapAmount < unwrapFeeDivisor, unwrapFee == 0
uint256 public unwrapFeeDivisor;
uint256 _ERC1155InteractionStatus;
uint256 _ERC721InteractionStatus;
event ChangeUnwrapFee(uint256 indexed oldFee, uint256 indexed newFee, address sender);
event Erc20Wrap(address indexed erc20Token, uint256 transferredAmount, uint256 wrappedAmount, uint256 dust, address indexed user, uint256 indexed oceanId);
event Erc20Unwrap(address indexed erc20Token, uint256 transferredAmount, uint256 unwrappedAmount, uint256 feeCharged, address indexed user, uint256 indexed oceanId);
event Erc721Wrap(address indexed erc721Token, uint256 erc721id, address indexed user, uint256 indexed oceanId);
event Erc721Unwrap(address indexed erc721Token, uint256 erc721Id, address indexed user, uint256 indexed oceanId);
event Erc1155Wrap(address indexed erc1155Token, uint256 erc1155Id, uint256 amount, address indexed user, uint256 indexed oceanId);
event Erc1155Unwrap(address indexed erc1155Token, uint256 erc1155Id, uint256 amount, uint256 feeCharged, address indexed user, uint256 indexed oceanId);
event EtherWrap(uint256 amount, address indexed user);
event EtherUnwrap(uint256 indexed amount, uint256 indexed feeCharged, address indexed user);
event ComputeOutputAmount(address primitive, uint256 indexed inputToken, uint256 indexed outputToken, uint256 indexed inputAmount, uint256 outputAmount, address user);
event ComputeInputAmount(address primitive, uint256 indexed inputToken, uint256 indexed outputToken, uint256 indexed inputAmount, uint256 outputAmount, address user);
event OceanTransaction(address indexed user, uint256 indexed numberOfInteractions);
event ForwardedOceanTransaction(address indexed forwarder, address indexed user, uint256 numberOfInteractions);
/**
* @dev Creates custom ERC-1155 with passed uri_, sets DAO address, and
* initializes ERC-1155 transfer guard.
* @notice initializes the fee divisor to uint256 max, which results in
* a fee of zero unless unwrapAmount == type(uint256).max, in which
* case the fee is one part in 1.16 * 10^77.
*/
constructor(string memory uri_) OceanERC1155(uri_) {
unwrapFeeDivisor = MAX_UNWRAP_FEE;
_ERC1155InteractionStatus = NOT_INTERACTION;
_ERC721InteractionStatus = NOT_INTERACTION;
WRAPPED_ETHER_ID = _calculateOceanId(address(0x4574686572), 0); // hexadecimal(ascii("Ether"))
}
/**
* @dev ERC1155 Approvals also function as permission to execute
* interactions on a user's behalf
* @param userAddress the address passed by the forwarder
*
* Because poorly chosen interactions are vulnerable to economic attacks,
* calling do{Interaction|MultipleInteractions} on a user's behalf must
* require the same level of trust as direct balance transfers.
*/
modifier onlyApprovedForwarder(address userAddress) {
if (!isApprovedForAll(userAddress, msg.sender)) revert FORWARDER_NOT_APPROVED();
_;
}
/**
* @notice this changes the unwrap fee immediately
* @notice The governance structure must appropriately handle any
* time lock or other mechanism for managing fee changes
* @param nextUnwrapFeeDivisor the reciprocal of the next fee percentage.
*/
function changeUnwrapFee(uint256 nextUnwrapFeeDivisor) external override onlyOwner {
/// @notice as the divisor gets smaller, the fee charged gets larger
if (MIN_UNWRAP_FEE_DIVISOR > nextUnwrapFeeDivisor) revert();
emit ChangeUnwrapFee(unwrapFeeDivisor, nextUnwrapFeeDivisor, msg.sender);
unwrapFeeDivisor = nextUnwrapFeeDivisor;
}
/**
* @notice Execute interactions `interaction`
* @notice Does not need ids because a single interaction does not require
* the accounting system
* @dev call to _doInteraction() binds msg.sender to userAddress
* @param interaction Executed to produce a set of balance updates
*/
function doInteraction(Interaction calldata interaction) external payable override returns (uint256 burnId, uint256 burnAmount, uint256 mintId, uint256 mintAmount) {
emit OceanTransaction(msg.sender, 1);
return _doInteraction(interaction, msg.sender);
}
/**
* @notice Execute interactions `interactions` with tokens `ids`
* @notice ids must include all tokens invoked during the transaction
* @notice ids are used for memory allocation in the intra-transaction
* accounting system.
* @dev call to _doMultipleInteractions() binds msg.sender to userAddress
* @param interactions Executed to produce a set of balance updates
* @param ids Ocean IDs of the tokens invoked by the interactions.
*/
function doMultipleInteractions(
Interaction[] calldata interactions,
uint256[] calldata ids
)
external
payable
override
returns (uint256[] memory burnIds, uint256[] memory burnAmounts, uint256[] memory mintIds, uint256[] memory mintAmounts)
{
emit OceanTransaction(msg.sender, interactions.length);
return _doMultipleInteractions(interactions, ids, msg.sender);
}
/**
* @notice Execute interactions `interactions` on behalf of `userAddress`
* @notice Does not need ids because a single interaction does not require
* the overhead of the intra-transaction accounting system
* @dev MUST HAVE onlyApprovedForwarder modifer.
* @dev call to _doMultipleInteractions() forwards the userAddress
* @param interaction Executed to produce a set of balance updates
* @param userAddress interactions are executed on behalf of this address
*/
function forwardedDoInteraction(Interaction calldata interaction, address userAddress) external payable override onlyApprovedForwarder(userAddress) returns (uint256 burnId, uint256 burnAmount, uint256 mintId, uint256 mintAmount) {
emit ForwardedOceanTransaction(msg.sender, userAddress, 1);
return _doInteraction(interaction, userAddress);
}
/**
* @notice Execute interactions `interactions` with tokens `ids` on behalf of `userAddress`
* @notice ids must include all tokens invoked during the transaction
* @notice ids are used for memory allocation in the intra-transaction
* accounting system.
* @dev MUST HAVE onlyApprovedForwarder modifer.
* @dev call to _doMultipleInteractions() forwards the userAddress
* @param interactions Executed to produce a set of balance updates
* @param ids Ocean IDs of the tokens invoked by the interactions.
* @param userAddress interactions are executed on behalf of this address
*/
function forwardedDoMultipleInteractions(
Interaction[] calldata interactions,
uint256[] calldata ids,
address userAddress
)
external
payable
override
onlyApprovedForwarder(userAddress)
returns (uint256[] memory burnIds, uint256[] memory burnAmounts, uint256[] memory mintIds, uint256[] memory mintAmounts)
{
emit ForwardedOceanTransaction(msg.sender, userAddress, interactions.length);
return _doMultipleInteractions(interactions, ids, userAddress);
}
/**
* @dev This callback is part of IERC1155Receiver, which we must implement
* to wrap ERC-1155 tokens.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(OceanERC1155, IERC165) returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
}
function onERC721Received(address, address, uint256, bytes calldata) external view override returns (bytes4) {
if (_ERC721InteractionStatus == INTERACTION) {
return IERC721Receiver.onERC721Received.selector;
} else {
return 0;
}
}
/**
* @dev This callback is part of IERC1155Receiver, which we must implement
* to wrap ERC-1155 tokens.
* @dev The Ocean only accepts ERC1155 transfers initiated by the Ocean
* while executing interactions.
* @dev We don't revert, prefering to let the external contract
* decide what it wants to do when safeTransfer is called on a contract
* that does not return the expected selector.
*/
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external view override returns (bytes4) {
if (_ERC1155InteractionStatus == INTERACTION) {
return IERC1155Receiver.onERC1155Received.selector;
} else {
return 0;
}
}
/**
* @dev This callback is part of IERC1155Receiver, which we must implement
* to wrap ERC-1155 tokens.
* @dev The Ocean never initiates ERC1155 Batch Transfers.
* @dev We don't revert, prefering to let the external contract
* decide what it wants to do when safeTransfer is called on a contract
* that does not return the expected selector.
*/
function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) external pure override returns (bytes4) {
return 0;
}
/**
* @dev This function handles both forwarded and non-forwarded single
* interactions
* @dev the external functions that pass through their arguments to this
* function have more information about the arguments.
* @param interaction the current interaction passed by the caller
* @param userAddress In the case of a forwarded interaction, this value
* is passed by the caller, and this value must be validated against the
* approvals set on this address and the caller's address (`msg.sender`)
* In the case of a non-forwarded interaction, this value is the caller's
* address.
*/
function _doInteraction(Interaction calldata interaction, address userAddress) internal returns (uint256 inputToken, uint256 inputAmount, uint256 outputToken, uint256 outputAmount) {
// Ether payments are push only. We always wrap ERC-X tokens using pull
// payments, so we cannot wrap Ether using the same pattern.
// We unwrap ERC-X tokens using push payments, so we can unwrap Ether
// the same way.
if (msg.value != 0) {
inputToken = 0;
inputAmount = 0;
outputToken = WRAPPED_ETHER_ID;
outputAmount = msg.value;
emit EtherWrap(msg.value, userAddress);
} else {
// Begin by unpacking the interaction type and the external contract
(InteractionType interactionType, address externalContract) = _unpackInteractionTypeAndAddress(interaction);
// Determine the specified token based on the interaction type and the
// interaction's external contract address, inputToken, outputToken,
// and metadata fields. The specified token is the token
// whose amount the user specifies.
uint256 specifiedToken = _getSpecifiedToken(interactionType, externalContract, interaction);
// Here we call _executeInteraction(), which is just a big
// if... else if... block branching on interaction type.
// Each branch sets the inputToken and outputToken and their
// respective amounts. This abstraction is what lets us treat
// interactions uniformly.
(inputToken, inputAmount, outputToken, outputAmount) = _executeInteraction(interaction, interactionType, externalContract, specifiedToken, interaction.specifiedAmount, userAddress);
}
// if _executeInteraction returned a positive value for inputAmount,
// this amount must be deducted from the user's Ocean balance
if (inputAmount > 0) {
// since uint, same as (inputAmount != 0)
_burn(userAddress, inputToken, inputAmount);
}
// if _executeInteraction returned a positive value for outputAmount,
// this amount must be credited to the user's Ocean balance
if (outputAmount > 0) {
// since uint, same as (outputAmount != 0)
_mint(userAddress, outputToken, outputAmount);
}
}
/**
* @dev This function handles both forwarded and non-forwarded multiple
* interactions
* @dev the external functions that pass through their arguments to this
* function have more information about the arguments.
* @param interactions The interactions passed by the caller
* @param ids the ids passed by the caller
* @param userAddress In the case of a forwarded interaction, this value
* is passed by the caller, and this value must be validated against the
* approvals set on this address and the caller's address (`msg.sender`)
* In the case of a non-forwarded interaction, this value is the caller's
* address.
*/
function _doMultipleInteractions(
Interaction[] calldata interactions,
uint256[] calldata ids,
address userAddress
)
internal
returns (uint256[] memory burnIds, uint256[] memory burnAmounts, uint256[] memory mintIds, uint256[] memory mintAmounts)
{
// Use the passed ids to create an array of balance deltas, used in
// the intra-transaction accounting system.
BalanceDelta[] memory balanceDeltas = new BalanceDelta[](ids.length);
uint256 _idLength = ids.length;
for (uint256 i = 0; i < _idLength;) {
balanceDeltas[i] = BalanceDelta(ids[i], 0);
unchecked {
++i;
}
}
// Ether payments are push only. We always wrap ERC-X tokens using pull
// payments, so we cannot wrap Ether using the same pattern.
// We unwrap ERC-X tokens using push payments, so we can unwrap Ether
// the same way.
if (msg.value != 0) {
// If msg.value != 0 and the user did not pass the WRAPPED_ETHER_ID
// as an id in the ids array, the balance delta library will revert
// This protects users who accidentally provide a msg.value.
balanceDeltas.increaseBalanceDelta(WRAPPED_ETHER_ID, msg.value);
emit EtherWrap(msg.value, userAddress);
}
// Execute the interactions
{
/**
* @dev Solidity does not reuse memory that has gone out of scope
* and the gas cost of memory usage grows quadratically.
* @dev We passed interactions as calldata to lower memory usage.
* However, accessing the members of a calldata structure uses
* more local identifiers than accessing the members of an
* in-memory structure. We're right up against the limit on
* local identifiers. To solve this, we allocate a single
* structure in memory and copy the calldata structures over one
* by one as we process them.
*/
Interaction memory interaction;
// This pulls the user's address to the top of the stack, above
// the ids array, which we won't need again. We're right up against
// the locals limit and this does the trick. Is there a better way?
address userAddress_ = userAddress;
for (uint256 i = 0; i < interactions.length;) {
interaction = interactions[i];
(InteractionType interactionType, address externalContract) = _unpackInteractionTypeAndAddress(interaction);
// specifiedToken is the token whose amount the user specifies
uint256 specifiedToken = _getSpecifiedToken(interactionType, externalContract, interaction);
// A user can pass uint256.max as the specifiedAmount when they
// want to use the total amount of the token held in the
// balance delta. Otherwise, the specifiedAmount is just the
// amount the user passed for this interaction.
uint256 specifiedAmount;
if (interaction.specifiedAmount == GET_BALANCE_DELTA) {
specifiedAmount = balanceDeltas.getBalanceDelta(interactionType, specifiedToken);
} else {
specifiedAmount = interaction.specifiedAmount;
}
(uint256 inputToken, uint256 inputAmount, uint256 outputToken, uint256 outputAmount) = _executeInteraction(interaction, interactionType, externalContract, specifiedToken, specifiedAmount, userAddress_);
// inputToken is given up by the user during the interaction
if (inputAmount > 0) {
// equivalent to (inputAmount != 0)
balanceDeltas.decreaseBalanceDelta(inputToken, inputAmount);
}
// outputToken is gained by the user during the interaction
if (outputAmount > 0) {
// equivalent to (outputAmount != 0)
balanceDeltas.increaseBalanceDelta(outputToken, outputAmount);
}
unchecked {
++i;
}
}
}
// Persist intra-transaction balance deltas to the Ocean's public ledger
{
// Place positive deltas into mintIds and mintAmounts
// Place negative deltas into burnIds and burnAmounts
(mintIds, mintAmounts, burnIds, burnAmounts) = balanceDeltas.createMintAndBurnArrays();
// Here we should know that uint[] memory arr = new uint[](0);
// produces a reference to an empty array called arr with property
// (arr.length == 0)
// mint the positive deltas to the user's balances
if (mintIds.length == 1) {
// if there's only one we can just use the more semantically
// appropriate _mint
_mint(userAddress, mintIds[0], mintAmounts[0]);
} else if (mintIds.length > 1) {
// if there's more than one we use _mintBatch
_mintBatch(userAddress, mintIds, mintAmounts);
} // if there are none, we do nothing
// burn the positive deltas from the user's balances
if (burnIds.length == 1) {
// if there's only one we can just use the more semantically
// appropriate _burn
_burn(userAddress, burnIds[0], burnAmounts[0]);
} else if (burnIds.length > 1) {
// if there's more than one we use _burnBatch
_burnBatch(userAddress, burnIds, burnAmounts);
} // if there are none, we do nothing
}
}
/**
* @dev Here is the core logic shared between doInteraction and
* doMultipleInteractions
* @dev State mutations on the external ledgers happen during wraps/unwraps
* @dev State mutations on the Ocean's ledger for the externalContract
* happen during computeInputAmount/computeOutputAmount
* @dev State mutations for the userAddress MUST happen in the calling
* context based on the return values of this function.
* @param interaction the current interaction passed from calldata
* @param interactionType the type of interaction unpacked by caller
* @param externalContract the address of the external contract parsed by caller
* @param specifiedToken the token in this interaction that specifiedAmount
* refers to
* @param specifiedAmount the amount of specifiedToken being used in this
* interaction
* @param userAddress the address of the user this interaction is being
* executed on behalf of. This is passed to the external contract.
* @return inputToken The token on the Ocean that the user is giving up
* @return inputAmount The amount of inputToken that the user is giving up
* @return outputToken The token on the Ocean that the user is gaining
* @return outputAmount The amount of ouputToken that the user is gaining
*/
function _executeInteraction(
Interaction memory interaction,
InteractionType interactionType,
address externalContract,
uint256 specifiedToken,
uint256 specifiedAmount,
address userAddress
)
internal
returns (uint256 inputToken, uint256 inputAmount, uint256 outputToken, uint256 outputAmount)
{
if (interactionType == InteractionType.ComputeOutputAmount) {
inputToken = specifiedToken;
inputAmount = specifiedAmount;
outputToken = interaction.outputToken;
outputAmount = _computeOutputAmount(externalContract, inputToken, outputToken, inputAmount, userAddress, interaction.metadata);
} else if (interactionType == InteractionType.ComputeInputAmount) {
inputToken = interaction.inputToken;
outputToken = specifiedToken;
outputAmount = specifiedAmount;
inputAmount = _computeInputAmount(externalContract, inputToken, outputToken, outputAmount, userAddress, interaction.metadata);
} else if (interactionType == InteractionType.WrapErc20) {
inputToken = 0;
inputAmount = 0;
outputToken = specifiedToken;
outputAmount = specifiedAmount;
_erc20Wrap(externalContract, outputAmount, userAddress, outputToken);
} else if (interactionType == InteractionType.UnwrapErc20) {
inputToken = specifiedToken;
inputAmount = specifiedAmount;
outputToken = 0;
outputAmount = 0;
_erc20Unwrap(externalContract, inputAmount, userAddress, inputToken);
} else if (interactionType == InteractionType.WrapErc721) {
// An ERC-20 or ERC-1155 contract can have a transfer with
// any amount including zero. Here, we need to require that
// the specifiedAmount is equal to one, since the external
// call to the ERC-721 contract does not include an amount,
// and the ledger is mutated based on the specifiedAmount.
if (specifiedAmount != 1) revert INVALID_ERC721_AMOUNT();
inputToken = 0;
inputAmount = 0;
outputToken = specifiedToken;
outputAmount = specifiedAmount;
_erc721Wrap(externalContract, uint256(interaction.metadata), userAddress, outputToken);
} else if (interactionType == InteractionType.UnwrapErc721) {
// See the comment in the preceeding else if block.
if (specifiedAmount != 1) revert INVALID_ERC721_AMOUNT();
inputToken = specifiedToken;
inputAmount = specifiedAmount;
outputToken = 0;
outputAmount = 0;
_erc721Unwrap(externalContract, uint256(interaction.metadata), userAddress, inputToken);
} else if (interactionType == InteractionType.WrapErc1155) {
inputToken = 0;
inputAmount = 0;
outputToken = specifiedToken;
outputAmount = specifiedAmount;
_erc1155Wrap(externalContract, uint256(interaction.metadata), outputAmount, userAddress, outputToken);
} else if (interactionType == InteractionType.UnwrapErc1155) {
inputToken = specifiedToken;
inputAmount = specifiedAmount;
outputToken = 0;
outputAmount = 0;
_erc1155Unwrap(externalContract, uint256(interaction.metadata), inputAmount, userAddress, inputToken);
} else {
assert(interactionType == InteractionType.UnwrapEther && specifiedToken == WRAPPED_ETHER_ID);
inputToken = specifiedToken;
inputAmount = specifiedAmount;
outputToken = 0;
outputAmount = 0;
_etherUnwrap(inputAmount, userAddress);
}
}
/**
* @param interaction the interaction
* @dev the first byte contains the interactionType
* @dev the next eleven bytes are IGNORED
* @dev the final twenty bytes are the address targeted by the interaction
*/
function _unpackInteractionTypeAndAddress(Interaction memory interaction) internal pure returns (InteractionType interactionType, address externalContract) {
bytes32 interactionTypeAndAddress = interaction.interactionTypeAndAddress;
interactionType = InteractionType(uint8(interactionTypeAndAddress[0]));
externalContract = address(uint160(uint256(interactionTypeAndAddress)));
}
/**
* @param interactionType determines how we derive the specifiedToken
* @param externalContract is the target of the interaction's external call
* @param interaction the interaction's fields are interpreted based on
* the Interaction type. See the declarations in Interactions.sol
* @return specifiedToken is the Ocean's internal ID for the token in a
* interaction that's amount is specified by the user.
*/
function _getSpecifiedToken(InteractionType interactionType, address externalContract, Interaction memory interaction) internal view returns (uint256 specifiedToken) {
if (interactionType == InteractionType.WrapErc20 || interactionType == InteractionType.UnwrapErc20) {
specifiedToken = _calculateOceanId(externalContract, 0);
} else if (interactionType == InteractionType.WrapErc721 || interactionType == InteractionType.WrapErc1155 || interactionType == InteractionType.UnwrapErc721 || interactionType == InteractionType.UnwrapErc1155) {
specifiedToken = _calculateOceanId(externalContract, uint256(interaction.metadata));
} else if (interactionType == InteractionType.ComputeInputAmount) {
specifiedToken = interaction.outputToken;
} else if (interactionType == InteractionType.ComputeOutputAmount) {
specifiedToken = interaction.inputToken;
} else {
assert(interactionType == InteractionType.UnwrapEther);
specifiedToken = WRAPPED_ETHER_ID;
}
}
/**
* @dev A primitive is an external smart contract that establishes a market
* between two or more tokens.
* @dev the external contract's Ocean balances are mutated
* immediately after the external call returns. If the external
* contract does not want to receive the inputToken, it should revert
* the transaction.
* @param primitive A contract that implements IOceanPrimitive
* @param inputToken The token offered to the contract
* @param outputToken The token requested from the contract
* @param inputAmount The amount of the inputToken offered
* @param userAddress The address of the user whose balances are being
* updated during the transaction.
* @param metadata The function of this parameter is up to the contract
* it is the responsibility of the caller to know what the called contract
* expects.
* @return outputAmount the amount of the outputToken the contract gives
* in return for the inputAmount of the inputToken.
*/
function _computeOutputAmount(address primitive, uint256 inputToken, uint256 outputToken, uint256 inputAmount, address userAddress, bytes32 metadata) internal returns (uint256 outputAmount) {
// mint before making a external call to the primitive to integrate with external protocol primitive adapters
_increaseBalanceOfPrimitive(primitive, inputToken, inputAmount);
outputAmount = IOceanPrimitive(primitive).computeOutputAmount(inputToken, outputToken, inputAmount, userAddress, metadata);
_decreaseBalanceOfPrimitive(primitive, outputToken, outputAmount);
emit ComputeOutputAmount(primitive, inputToken, outputToken, inputAmount, outputAmount, userAddress);
}
/**
* @dev A primitive is an external smart contract that establishes a market
* between two or more tokens.
* @dev the external contract's Ocean balances are mutated
* immediately after the external call returns. If the external
* contract does not want to receive the outputToken, it should revert
* the transaction.
* @param primitive A contract that implements IOceanPrimitive
* @param inputToken The token offered to the contract
* @param outputToken The token requested from the contract
* @param outputAmount The amount of the outputToken offered
* @param userAddress The address of the user whose balances are being
* updated during the transaction.
* @param metadata The function of this parameter is up to the contract
* it is the responsibility of the caller to know what the called contract
* expects.
* @return inputAmount the amount of the inputToken the contract gives
* in return for the outputAmount of the outputToken.
*/
function _computeInputAmount(address primitive, uint256 inputToken, uint256 outputToken, uint256 outputAmount, address userAddress, bytes32 metadata) internal returns (uint256 inputAmount) {
// burn before making a external call to the primitive to integrate with external protocol primitive adapters
_decreaseBalanceOfPrimitive(primitive, outputToken, outputAmount);
inputAmount = IOceanPrimitive(primitive).computeInputAmount(inputToken, outputToken, outputAmount, userAddress, metadata);
_increaseBalanceOfPrimitive(primitive, inputToken, inputAmount);
emit ComputeInputAmount(primitive, inputToken, outputToken, inputAmount, outputAmount, userAddress);
}
/**
* @dev Wrap an ERC-20 token into the Ocean. The Ocean ID is
* derived from the contract address and a tokenId of 0.
* @notice Token amounts are normalized to 18 decimal places.
* @dev This means that to wrap 5 units of token A, which has 6 decimals,
* and 5 units of token B, which has 18 decimals, the user would specify
* 5 * 10**18 for both token A and B.
* @param tokenAddress address of the ERC-20 token
* @param amount amount of the ERC-20 token to be wrapped, in terms of
* 18-decimal fixed point
* @param userAddress the address of the user who is wrapping the token
*/
function _erc20Wrap(address tokenAddress, uint256 amount, address userAddress, uint256 outputToken) private {
try IERC20Metadata(tokenAddress).decimals() returns (uint8 decimals) {
/// @dev the amount passed as an argument to the external token
uint256 transferAmount;
/// @dev the leftover amount accumulated by the Ocean.
uint256 dust;
(transferAmount, dust) = _determineTransferAmount(amount, decimals);
// If the user is unwrapping a delta, the residual dust could be
// written to the user's ledger balance. However, it costs the
// same amount of gas to place the dust on the owner's balance,
// and accumulation of dust may eventually result in
// transferrable units again.
_grantFeeToOcean(outputToken, dust);
SafeERC20.safeTransferFrom(IERC20(tokenAddress), userAddress, address(this), transferAmount);
emit Erc20Wrap(tokenAddress, transferAmount, amount, dust, userAddress, outputToken);
} catch {
revert NO_DECIMAL_METHOD();
}
}
/**
* @dev Unwrap an ERC-20 token out of the Ocean. The Ocean ID is
* derived from the contract address and a tokenId of 0.
* @notice tokens are normalized to 18 decimal places.
* @notice unwrap amounts may be subject to a fee that reduces the amount
* moved on the external token's ledger. To unwrap an exact amount, the
* caller should compute off-chain what specifiedAmount results in the
* desired unwrap amount.
* @dev This means that to wrap 5 units of token A, which has 6 decimals,
* and 5 units of token B, which has 18 decimals, when the fee is zero,
* the user would specify 5 * 10**18 for both token A and B.
* @dev If the fee is 1 basis point, the user would specify
* 5000500050005000500
* This value was found by solving for x in the equation:
* x - Floor[x * (1/10000)] = 5000000000000000000
* @param tokenAddress address of the ERC-20 token
* @param amount amount of the ERC-20 token to be unwrapped, in terms of
* 18-decimal fixed point
* @param userAddress the address of the user who is unwrapping the token
*/
function _erc20Unwrap(address tokenAddress, uint256 amount, address userAddress, uint256 inputToken) private {
try IERC20Metadata(tokenAddress).decimals() returns (uint8 decimals) {
uint256 feeCharged = _calculateUnwrapFee(amount);
uint256 amountRemaining = amount - feeCharged;
(uint256 transferAmount, uint256 truncated) = _convertDecimals(NORMALIZED_DECIMALS, decimals, amountRemaining);
feeCharged += truncated;
_grantFeeToOcean(inputToken, feeCharged);
SafeERC20.safeTransfer(IERC20(tokenAddress), userAddress, transferAmount);
emit Erc20Unwrap(tokenAddress, transferAmount, amount, feeCharged, userAddress, inputToken);
} catch {
revert NO_DECIMAL_METHOD();
}
}
/**
* @dev wrap an ERC-721 NFT into the Ocean. The Ocean ID is derived from
* tokenAddress and tokenId.
* @param tokenAddress address of the ERC-721 contract
* @param tokenId ID of the NFT on the ERC-721 ledger
* @param userAddress the address of the user who is wrapping the NFT
*/
function _erc721Wrap(address tokenAddress, uint256 tokenId, address userAddress, uint256 oceanId) private {
_ERC721InteractionStatus = INTERACTION;
IERC721(tokenAddress).safeTransferFrom(userAddress, address(this), tokenId);
_ERC721InteractionStatus = NOT_INTERACTION;
emit Erc721Wrap(tokenAddress, tokenId, userAddress, oceanId);
}
/**
* @dev Unwrap an ERC-721 NFT out of the Ocean. The Ocean ID is derived
* from tokenAddress and tokenId.
* @param tokenAddress address of the ERC-721 contract
* @param tokenId ID of the NFT on the ERC-721 ledger
* @param userAddress the address of the user who is unwrapping the NFT
*/
function _erc721Unwrap(address tokenAddress, uint256 tokenId, address userAddress, uint256 oceanId) private {
IERC721(tokenAddress).safeTransferFrom(address(this), userAddress, tokenId);
emit Erc721Unwrap(tokenAddress, tokenId, userAddress, oceanId);
}
/**
* @dev Wrap an ERC-1155 token into the Ocean. The Ocean ID is derived
* from tokenAddress and tokenId.
* @notice ERC-1155 amounts and in-Ocean amounts are equal. If a token
* implemented using ERC-1155 should have the same value as other tokens
* implemented using ERC-20, the ERC-1155 should use an 18-decimal
* representation.
* @param tokenAddress address of the ERC-1155 contract
* @param tokenId ID of the token on the ERC-1155 ledger
* @param amount the amount of the token being wrapped.
* @param userAddress the address of the user who is wrapping the token
*/
function _erc1155Wrap(address tokenAddress, uint256 tokenId, uint256 amount, address userAddress, uint256 oceanId) private {
if (tokenAddress == address(this)) revert NO_RECURSIVE_WRAPS();
_ERC1155InteractionStatus = INTERACTION;
IERC1155(tokenAddress).safeTransferFrom(userAddress, address(this), tokenId, amount, "");
_ERC1155InteractionStatus = NOT_INTERACTION;
emit Erc1155Wrap(tokenAddress, tokenId, amount, userAddress, oceanId);
}
/**
* @dev Unwrap an ERC-1155 token out of the Ocean. The Ocean ID is derived
* from tokenAddress and tokenId.
* @notice ERC-1155 amounts and in-Ocean amounts are equal. If a token
* implemented using ERC-1155 should have the same value as other tokens
* implemented using ERC-20, the ERC-1155 should use an 18-decimal
* representation.
* @notice unwrap amounts may be subject to a fee that reduces the amount
* moved on the external token's ledger. To unwrap an exact amount, the
* caller should compute off-chain what specifiedAmount results in the
* desired unwrap amount. If the user wants to receive 100_000 of a token
* and the fee is 1 basis point, the user should specify 100_010
* This value was found by solving for x in the equation:
* x - Floor[x * (1/10000)] = 100000
* @param tokenAddress address of the ERC-1155 contract
* @param tokenId ID of the token on the ERC-1155 ledger
* @param amount the amount of the token being wrapped.
* @param userAddress the address of the user who is wrapping the token
*/
function _erc1155Unwrap(address tokenAddress, uint256 tokenId, uint256 amount, address userAddress, uint256 oceanId) private {
if (tokenAddress == address(this)) revert NO_RECURSIVE_UNWRAPS();
uint256 feeCharged = _calculateUnwrapFee(amount);
uint256 amountRemaining = amount - feeCharged;
_grantFeeToOcean(oceanId, feeCharged);
IERC1155(tokenAddress).safeTransferFrom(address(this), userAddress, tokenId, amountRemaining, "");
emit Erc1155Unwrap(tokenAddress, tokenId, amount, feeCharged, userAddress, oceanId);
}
/**
* @dev Unwrap Ether out of the Ocean. The Ocean ID of shETH is computed
* in the constructor using the address of the Ocean and a tokenId of 0.
* @param amount The amount of Ether to unwrap.
* @param userAddress The user performing the unwrap.
*/
function _etherUnwrap(uint256 amount, address userAddress) private {
uint256 feeCharged = _calculateUnwrapFee(amount);
_grantFeeToOcean(WRAPPED_ETHER_ID, feeCharged);
uint256 transferAmount = amount - feeCharged;
payable(userAddress).transfer(transferAmount);
emit EtherUnwrap(transferAmount, feeCharged, userAddress);
}
/**
* @notice If the primitive registered the inputToken, it does not
* receive any of the inputToken.
* @notice look at the public function registerNewTokens()
* @notice We cannot keep the primitive's balance changes in memory.
* A primitive relies on the Ocean for its accounting, so it must always
* receive a correct answer when it queries balanceOf() or
* balanceOfBatch().
* When the Ocean receives a balanceOf() call, this call has its own
* memory space. The Ocean cannot reach down through the call stack to
* get a delta stored in the memory of an earlier call.
* primitive -> ocean.balanceOf(address(this), token) [mem_space_2]
* Ocean -> primitive.computeOutputAmount() [mem_space_1]
* EOA -> ocean.doMultipleInteractions() [mem_space_0]
* Because we have no way of maintaining coherence between dirty memory
* and stale storage, our only option is to always have up-to-date values
* in storage.
*/
function _increaseBalanceOfPrimitive(address primitive, uint256 inputToken, uint256 inputAmount) internal {
// If the input token is not one of the primitive's registered tokens,
// the primitive receives the input amount it was passed.
// Otherwise, the tokens will be implicitly burned by the primitive
// later in the transaction
if (_isNotTokenOfPrimitive(inputToken, primitive) && (inputAmount > 0)) {
// Since the primitive consented to receiving this token by not
// reverting when it was called, we mint the token without
// doing a safe transfer acceptance check. This breaks the
// ERC1155 specification but in a way we hope is inconsequential, since
// all primitives are developed by people who must be
// aware of how the Ocean works.
_mintWithoutSafeTransferAcceptanceCheck(primitive, inputToken, inputAmount);
}
}
/**
* @notice If the primitive registered the outputToken, it does not
* lose any of the outputToken.
* @notice look at the public function registerNewTokens()
* @notice We cannot keep the primitive's balance changes in memory.
* A primitive relies on the Ocean for its accounting, so it must always
* receive a correct answer when it queries balanceOf() or
* balanceOfBatch().
* When the Ocean receives a balanceOf() call, this call has its own
* memory space. The Ocean cannot reach down through the call stack to
* get a delta stored in the memory of an earlier call.
* primitive -> ocean.balanceOf(address(this), token) [mem_space_2]
* Ocean -> primitive.computeOutputAmount() [mem_space_1]
* EOA -> ocean.doMultipleInteractions() [mem_space_0]
* Because we have no way of maintaining coherence between dirty memory
* and stale storage, our only option is to always have up-to-date values
* in storage.
*/
function _decreaseBalanceOfPrimitive(address primitive, uint256 outputToken, uint256 outputAmount) internal {
// If the output token is not one of the primitive's tokens, the
// primitive loses the output amount it just computed.
// Otherwise, the tokens will be implicitly minted by the primitive
// later in the transaction
if (_isNotTokenOfPrimitive(outputToken, primitive) && (outputAmount > 0)) {
_burn(primitive, outputToken, outputAmount);
}
}
/**
* @dev This function determines the correct argument to pass to
* the external token contract
* @dev Say the in-Ocean unwrap amount (in 18-decimal) is 0.123456789012345678
* If the external token uses decimals == 6:
* transferAmount == 123456
* dust == 789012345678
* If the external token uses decimals == 18:
* transferAmount == 123456789012345678
* dust == 0
* If the external token uses decimals == 21:
* transferAmount == 123456789012345678000
* dust == 0
* @param amount the amount of in-Ocean tokens being unwrapped
* @param decimals returned by IERC20(token).decimals()
* @return transferAmount the amount passed to SafeERC20.safeTransfer()
* @return dust The amount of in-Ocean token that are not unwrapped
* due to the mismatch between the external token's decimal basis and the
* Ocean's NORMALIZED_DECIMALS basis.
*/
function _determineTransferAmount(uint256 amount, uint8 decimals) private pure returns (uint256 transferAmount, uint256 dust) {
// if (decimals < 18), then converting 18-decimal amount to decimals
// transferAmount will likely result in amount being truncated. This
// case is most likely to occur when a user is wrapping a delta as the
// final interaction in a transaction.
uint256 truncated;
(transferAmount, truncated) = _convertDecimals(NORMALIZED_DECIMALS, decimals, amount);
if (truncated > 0) {
// Here, FLOORish(x) is not to the nearest integer less than `x`,
// but rather to the nearest value with `decimals` precision less
// than `x`. Likewise with CEILish(x).
// When truncating, transferAmount is FLOORish(amount), but to
// fully cover a potential delta, we need to transfer CEILish(amount)
// if truncated == 0, FLOORish(amount) == CEILish(amount)
// When truncated > 0, FLOORish(amount) + 1 == CEILish(AMOUNT)
transferAmount += 1;
// Now that we are transferring enough to cover the delta, we
// need to determine how much of the token the user is actually
// wrapping, in terms of 18-decimals.
(uint256 normalizedTransferAmount, uint256 normalizedTruncatedAmount) = _convertDecimals(decimals, NORMALIZED_DECIMALS, transferAmount);
// If we truncated earlier, converting the other direction is adding
// precision, which cannot truncate.
assert(normalizedTruncatedAmount == 0);
assert(normalizedTransferAmount > amount);
dust = normalizedTransferAmount - amount;
} else {
// if truncated == 0, then we don't need to do anything fancy to
// determine transferAmount, the result _convertDecimals() returns
// is correct.
dust = 0;
}
}
/**
* @dev convert a uint256 from one fixed point decimal basis to another,
* returning the truncated amount if a truncation occurs.
* @dev fn(from, to, a) => b
* @dev a = (x * 10**from) => b = (x * 10**to), where x is constant.
* @param amountToConvert the amount being converted
* @param decimalsFrom the fixed decimal basis of amountToConvert
* @param decimalsTo the fixed decimal basis of the returned convertedAmount
* @return convertedAmount the amount after conversion
* @return truncatedAmount if (from > to), there may be some truncation, it
* is up to the caller to decide what to do with the truncated amount.
*/
function _convertDecimals(uint8 decimalsFrom, uint8 decimalsTo, uint256 amountToConvert) internal pure returns (uint256 convertedAmount, uint256 truncatedAmount) {
if (decimalsFrom == decimalsTo) {
// no shift
convertedAmount = amountToConvert;
truncatedAmount = 0;
} else if (decimalsFrom < decimalsTo) {
// Decimal shift left (add precision)
uint256 shift = 10 ** (uint256(decimalsTo - decimalsFrom));
convertedAmount = amountToConvert * shift;
truncatedAmount = 0;
} else {
// Decimal shift right (remove precision) -> truncation
uint256 shift = 10 ** (uint256(decimalsFrom - decimalsTo));
convertedAmount = amountToConvert / shift;
truncatedAmount = amountToConvert % shift;
}
}
/**
* @dev Divides an amount by the unwrapFeeDivisor state variable to
* determine the amount to deduct from the unwrap.
* @dev when unwrapFeeDivisor > unwrapAmount, feeCharged == 0 due to floor
* behavior of integer division
* @param unwrapAmount the amount being unwrapped
* @return feeCharged the amount to be deducted from the unwrapAmount and
* granted to the Ocean's owner.
*/
function _calculateUnwrapFee(uint256 unwrapAmount) private view returns (uint256 feeCharged) {
feeCharged = unwrapAmount / unwrapFeeDivisor;
}
/**
* @dev Updates the DAO's balance of a token when the fee is assessed.
* @dev We only call the mint function when the fee amount is non-zero.
*/
function _grantFeeToOcean(uint256 oceanId, uint256 amount) private {
if (amount > 0) {
// since uint, same as (amount != 0)
_mintWithoutSafeTransferAcceptanceCheck(owner(), oceanId, amount);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.0;
import "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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;
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
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].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// Cowri Labs Inc.
pragma solidity ^0.8.19;
import { InteractionType } from "./Interactions.sol";
/**
* A BalanceDelta structure tracks a user's intra-transaction balance change
* for a particular token
* @param tokenId ID of the tracked token in the accounting system
* @param delta a signed integer that records the user's accumulated debit
* or credit.
*
* Examples:
* BalanceDelta positiveDelta = BalanceDelta(0xDE..AD, 100);
* BalanceDelta negativeDelta = BalanceDelta(0xBE..EF, -100);
*
* At the end of the transaction the deltas are applied to the user's balances
* to persist the effects of the transaction.
*/
struct BalanceDelta {
uint256 tokenId;
int256 delta;
}
/**
* @dev Functions relating to the intra-transaction accounting system.
* @dev This library relies on the fact that arrays in solidity are passed by
* reference, rather than by value.
*
* `self` is an array of BalanceDelta structures.
*
* @dev each function uses a greedy linear search, so if there are duplicate
* deltas for the same tokenId, only the first delta is operated on. The
* duplicates will always have {tokenID: $DUPLICATE, delta: 0}. If an tokenId
* is missing, the library functions will revert the transaction. If there is
* an unecessary tokenId or a duplicated tokenId, the only consequence is
* wasted gas, so the incentive for the user is to provide the minimal set of
* tokenIds.
*
* Because the delta is a signed integer, it can be positive or negative.
*
* At the end of the transaction, positive deltas are minted to the user and
* negative deltas are burned from the user. This is done using the ERC-1155's
* _mintBatch() and _burnBatch(). Each take an array of IDs and an array
* of amounts. BalanceDelta => (ids[i], amounts[i])
*/
library LibBalanceDelta {
//*********************************************************************//
// --------------------------- custom errors ------------------------- //
//*********************************************************************//
error CAST_AMOUNT_EXCEEDED();
error DELTA_AMOUNT_IS_NEGATIVE();
error DELTA_AMOUNT_IS_POSITIVE();
error MISSING_TOKEN_ID();
/**
* @dev a BalanceDelta holds an int256 delta while the caller passes
* a uint256. We need to make sure the cast won't silently truncate
* the most significant bit.
* @dev because solidity numbers are two's complement representation,
* the absolute value of the maximum value is one unit higher than the
* maximum value of the minimum value. By testing against
* type(int256).max, we know that amount will safely cast to both positive
* and negative int256 values.
*/
modifier safeCast(uint256 amount) {
if (uint256(type(int256).max) <= amount) revert CAST_AMOUNT_EXCEEDED();
_;
}
/**
* @dev increase a given tokenId's delta by an amount.
*/
function increaseBalanceDelta(BalanceDelta[] memory self, uint256 tokenId, uint256 amount) internal pure safeCast(amount) {
uint256 index = _findIndexOfTokenId(self, tokenId);
self[index].delta += int256(amount);
return;
}
/**
* @dev decrease a given tokenId's delta by an amount.
*/
function decreaseBalanceDelta(BalanceDelta[] memory self, uint256 tokenId, uint256 amount) internal pure safeCast(amount) {
uint256 index = _findIndexOfTokenId(self, tokenId);
self[index].delta -= int256(amount);
return;
}
/**
* @dev This function returns an unsigned amount given a tokenId and an
* interaction type.
* @dev This function reverts when the sign of the tokenId's delta
* does not match the sign expected by the interaction type.
*
* - All interaction types expect unsigned amounts as arguments.
* - Some interaction types, like wraps, increase a user's balance.
* - Others, like unwraps, decrease a user's balance.
* - The interactions that increase a user's balance can take a negative
* delta as an input. In effect, the debit represented by the delta is
* offset by the credit from the interaction.
* - Similarly, interactions that decrease a user's balance can take
* a positive delta as an input.
* - When a delta is of the wrong sign for the interaction type, we need
* to revert the transaction.
*
* EXAMPLE 1. Convert 100 DAI into as many USDC as possible
* [0] BalanceDelta[] = [ BalanceDelta(DAI, 0), BalanceDelta(USDC, 0) ]
* wrap(token: DAI, amount: 100)
* [1] BalanceDelta[] = [ BalanceDelta(DAI, 100), BalanceDelta(USDC, 0) ]
* computeOutputAmount(input: DAI, output: USDC, amount: GET_BALANCE_DELTA)
* [2] BalanceDelta[] = [ BalanceDelta(DAI, 0), BalanceDelta(USDC, 99.997) ]
* unwrap(token: USDC, amount: GET_BALANCE_DELTA)
*
* EXAMPLE 2. Convert as few DAI as possible into exactly 100 USDC
* [0] BalanceDelta[] = [ BalanceDelta(DAI, 0), BalanceDelta(USDC, 0) ]
* unwrap(token: USDC, amount: 100)
* [1] BalanceDelta[] = [ BalanceDelta(DAI, 0), BalanceDelta(USDC, -100) ]
* computeInputAmount(input: DAI, output: USDC, amount: GET_BALANCE_DELTA)
* [2] BalanceDelta[] = [ BalanceDelta(DAI, -100.003), BalanceDelta(USDC, 0) ]
* wrap(token: DAI, amount: GET_BALANCE_DELTA)
*
* EXAMPLE 3. Unwrap DAI twice (reverts)
* [0] BalanceDelta[] = [ BalanceDelta(DAI, 0), ]
* unwrap(token: DAI, amount: 100)
* [1] BalanceDelta[] = [ BalanceDelta(DAI, -100), ]
* unwrap(token: DAI, amount: GET_BALANCE_DELTA)
* !!! Throw("PosDelta :: amount < 0") !!!
*/
function getBalanceDelta(BalanceDelta[] memory self, InteractionType interaction, uint256 tokenId) internal pure returns (uint256) {
if (
interaction == InteractionType.UnwrapErc20 || interaction == InteractionType.UnwrapErc721 || interaction == InteractionType.UnwrapErc1155 || interaction == InteractionType.UnwrapEther
|| interaction == InteractionType.ComputeOutputAmount
) {
return _getPositiveBalanceDelta(self, tokenId);
} else {
// interaction == (Wrap* || ComputeInputAmount)
return _getNegativeBalanceDelta(self, tokenId);
}
}
/**
* @dev This function transforms the accumulated deltas into the arguments
* expected by ERC-1155 _mintBatch() and _burnBatch so that the caller
* can apply the deltas to the ledger.
* @dev ERC-1155 expects an array of ids and an array of amounts, paired by
* index.
* +-------+-------+-----------+
* | index | ids[] | amounts[] |
* +-------+-------+-----------+
* | 0 | 808 | 35 | <= BalanceDelta(tokenId: 808, delta: 35)
* | 1 | 310 | 12 | <= BalanceDelta(tokenId: 310, delta: 12)
* | 2 | 408 | 19 | <= BalanceDelta(tokenId: 408, delta: 19)
* +-------+-------+-----------+
* @dev Positive deltas are minted to the user's balances
* @dev Negative deltas are burned from the user's balances
* @dev for an entry where (delta == 0), nothing is done
* @notice the returned arrays may be empty (arr.length == 0) or singleton
* arrays (arr.length == 1).
* @return mintIds array of IDs expected by ERC-1155 _mintBatch
* @return mintAmounts array of amounts expected by ERC-1155 _mintBatch
* @return burnIds array of IDs expected by ERC-1155 _burnBatch
* @return burnAmounts array of amounts expected by ERC-1155 _burnBatch
*/
function createMintAndBurnArrays(BalanceDelta[] memory self) internal pure returns (uint256[] memory mintIds, uint256[] memory mintAmounts, uint256[] memory burnIds, uint256[] memory burnAmounts) {
(uint256 numberOfMints, uint256 numberOfBurns) = _getMintsAndBurns(self);
mintIds = new uint256[](numberOfMints);
mintAmounts = new uint256[](numberOfMints);
burnIds = new uint256[](numberOfBurns);
burnAmounts = new uint256[](numberOfBurns);
_copyDeltasToMintAndBurnArrays(self, mintIds, mintAmounts, burnIds, burnAmounts);
}
/**
* @dev Count the number of positive deltas and the number of negative
* deltas among the accumulated deltas.
* @dev The return values of this function are used to allocate memory
* arrays. This function is necessary because in-memory arrays in
* solidity do not support push() and pop() style operations.
* @return numberOfMints the number of positive deltas
* @return numberOfBurns the number of negative deltas
*/
function _getMintsAndBurns(BalanceDelta[] memory self) private pure returns (uint256 numberOfMints, uint256 numberOfBurns) {
uint256 numberOfZeros = 0;
for (uint256 i = 0; i < self.length; ++i) {
int256 delta = self[i].delta;
if (delta > 0) {
++numberOfMints;
} else if (delta < 0) {
++numberOfBurns;
} else {
++numberOfZeros;
}
}
assert((numberOfMints + numberOfBurns + numberOfZeros) == self.length);
}
/**
* @dev Now that we have allocated a pair of mint arrays and a pair of burn
* arrays, we iterate over the balance deltas again, this time moving the
* positive deltas, along with their assosciated tokenIds into the mints
* arrays, and moving the negative deltas and their assosciated tokenIds
* into the burns arrays.
*/
function _copyDeltasToMintAndBurnArrays(BalanceDelta[] memory self, uint256[] memory mintIds, uint256[] memory mintAmounts, uint256[] memory burnIds, uint256[] memory burnAmounts) private pure {
uint256 mintsSoFar = 0;
uint256 burnsSoFar = 0;
for (uint256 i = 0; i < self.length; ++i) {
int256 delta = self[i].delta;
if (delta > 0) {
mintIds[mintsSoFar] = self[i].tokenId;
mintAmounts[mintsSoFar] = uint256(delta);
mintsSoFar += 1;
} else if (delta < 0) {
burnIds[burnsSoFar] = self[i].tokenId;
burnAmounts[burnsSoFar] = uint256(-delta);
burnsSoFar += 1;
}
}
assert((mintsSoFar == mintIds.length) && (burnsSoFar == burnIds.length));
}
/**
* @dev returns a delta for a interaction type that expects a positive delta
*
* SteInterps that take a positive delta:
* Unwrap*
* ComputeOutputAmount
*/
function _getPositiveBalanceDelta(BalanceDelta[] memory self, uint256 tokenId) private pure returns (uint256) {
uint256 index = _findIndexOfTokenId(self, tokenId);
int256 amount = self[index].delta;
if (amount < 0) revert DELTA_AMOUNT_IS_NEGATIVE();
return uint256(amount);
}
/**
* @dev returns a delta for a interaction type that expects a negative delta
*
* Interactions that take a negative delta:
* Wrap*
* ComputeInputAmount
*/
function _getNegativeBalanceDelta(BalanceDelta[] memory self, uint256 tokenId) private pure returns (uint256) {
uint256 index = _findIndexOfTokenId(self, tokenId);
int256 amount = self[index].delta;
if (amount > 0) revert DELTA_AMOUNT_IS_POSITIVE();
return uint256(-amount);
}
/**
* @dev a linear search for the first BalanceDelta with a certain tokenId
* @param tokenId the key we're searching for
* @return index the location of the key
*/
function _findIndexOfTokenId(BalanceDelta[] memory self, uint256 tokenId) private pure returns (uint256 index) {
for (index = 0; index < self.length; ++index) {
if (self[index].tokenId == tokenId) {
return index;
}
}
revert MISSING_TOKEN_ID();
}
}// SPDX-License-Identifier: MIT
// Cowri Labs Inc.
pragma solidity ^0.8.19;
abstract contract ERC1155PermitSignatureExtension {
/// @notice EIP-712 Ethereum typed structured data hashing and signing
bytes32 public immutable DOMAIN_SEPARATOR;
bytes32 public immutable SETPERMITFORALL_TYPEHASH;
/// @notice Nonces used for EIP-2612 sytle permits
mapping(address => uint256) public approvalNonces;
constructor(bytes memory name, bytes memory version) {
bytes memory EIP712Domain = bytes("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
DOMAIN_SEPARATOR = keccak256(abi.encode(keccak256(EIP712Domain), keccak256(name), keccak256(version), block.chainid, address(this)));
SETPERMITFORALL_TYPEHASH = keccak256("SetPermitForAll(address owner,address operator,bool approved,uint256 nonce,uint256 deadline)");
}
function setPermitForAll(address owner, address operator, bool approved, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external {
require(_signaturesEnabled(), "Permit Signature Disabled");
require(deadline >= block.timestamp);
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode(SETPERMITFORALL_TYPEHASH, owner, operator, approved, approvalNonces[owner]++, deadline))));
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner);
_setApprovalForAll(owner, operator, approved);
}
function _signaturesEnabled() internal virtual returns (bool);
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual;
}// SPDX-License-Identifier: unlicensed
// Cowri Labs Inc.
pragma solidity ^0.8.19;
/**
* @param interactionTypeAndAddress the type of interaction and the external
* contract called during this interaction.
* @param inputToken this field is ignored except when the interaction type
* begins with "Compute". During a "Compute" interaction, this token is given
* to the external contract.
* @param outputToken this field is ignored except when the interaction type
* begins with "Compute". During a "Compute" interaction, this token is
* received from the external contract.
* @param specifiedAmount This value is the amount of the specified token.
* See the comment above the declaration for InteractionType for information
* on specified tokens. When this value is equal to type(uint256).max, it is
* a request by the user to use the intra-transaction delta of the specified
* token as the specified amount. See LibBalanceDelta for more information
* about this. When the Ocean executes an interaction, it resolves the
* specifiedAmount before calling the external contract. During a "721"
* interaction, the resolved specifiedAmount must be identically "1".
* @param metadata This value is used in two ways. During "Compute"
* interactions, it is forwarded to the external contract. The external
* contract can define whatever expectations it wants for these 32 bytes. The
* caller is expected to be aware of the expectations of the external contract
* invoked during the interaction. During 721/1155 and wraps and unwraps,
* these bytes are cast to uint256 and used as the external ledger's token ID
* for the interaction.
*/
struct Interaction {
bytes32 interactionTypeAndAddress;
uint256 inputToken;
uint256 outputToken;
uint256 specifiedAmount;
bytes32 metadata;
}
/**
* InteractionType determines how the properties of Interaction are interpreted
*
* The interface implemented by the external contract, the specified token
* for the interaction, and what sign (+/-) of delta can be used are
* determined by the InteractionType.
*
* @param WrapErc20
* type(externalContract).interfaceId == IERC20
* specifiedToken == calculateOceanId(externalContract, 0)
* negative delta can be used as specifiedAmount
*
* @param UnwrapErc20
* type(externalContract).interfaceId == IERC20
* specifiedToken == calculateOceanId(externalContract, 0)
* positive delta can be used as specifiedAmount
*
* @param WrapErc721
* type(externalContract).interfaceId == IERC721
* specifiedToken == calculateOceanId(externalContract, metadata)
* negative delta can be used as specifiedAmount
*
* @param UnwrapErc721
* type(externalContract).interfaceId == IERC721
* specifiedToken == calculateOceanId(externalContract, metadata)
* positive delta can be used as specifiedAmount
*
* @param WrapErc1155
* type(externalContract).interfaceId == IERC1155
* specifiedToken == calculateOceanId(externalContract, metadata)
* negative delta can be used as specifiedAmount
*
* @param WrapErc1155
* type(externalContract).interfaceId == IERC1155
* specifiedToken == calculateOceanId(externalContract, metadata)
* positive delta can be used as specifiedAmount
*
* @param ComputeInputAmount
* type(externalContract).interfaceId == IOceanexternalContract
* specifiedToken == outputToken
* negative delta can be used as specifiedAmount
*
* @param ComputeOutputAmount
* type(externalContract).interfaceId == IOceanexternalContract
* specifiedToken == inputToken
* positive delta can be used as specifiedAmount
*/
enum InteractionType {
WrapErc20,
UnwrapErc20,
WrapErc721,
UnwrapErc721,
WrapErc1155,
UnwrapErc1155,
ComputeInputAmount,
ComputeOutputAmount,
UnwrapEther
}
interface IOceanInteractions {
function unwrapFeeDivisor() external view returns (uint256);
function doMultipleInteractions(Interaction[] calldata interactions, uint256[] calldata ids) external payable returns (uint256[] memory burnIds, uint256[] memory burnAmounts, uint256[] memory mintIds, uint256[] memory mintAmounts);
function forwardedDoMultipleInteractions(
Interaction[] calldata interactions,
uint256[] calldata ids,
address userAddress
)
external
payable
returns (uint256[] memory burnIds, uint256[] memory burnAmounts, uint256[] memory mintIds, uint256[] memory mintAmounts);
function doInteraction(Interaction calldata interaction) external payable returns (uint256 burnId, uint256 burnAmount, uint256 mintId, uint256 mintAmount);
function forwardedDoInteraction(Interaction calldata interaction, address userAddress) external payable returns (uint256 burnId, uint256 burnAmount, uint256 mintId, uint256 mintAmount);
}// SPDX-License-Identifier: unlicensed
// Cowri Labs Inc.
pragma solidity ^0.8.19;
/// @notice to be implemented by a contract that is the Ocean.owner()
interface IOceanFeeChange {
function changeUnwrapFee(uint256 nextUnwrapFeeDivisor) external;
}// SPDX-License-Identifier: unlicensed
// Cowri Labs Inc.
pragma solidity ^0.8.19;
/// @notice Implementing this allows a primitive to be called by the Ocean's
/// defi framework.
interface IOceanPrimitive {
function computeOutputAmount(uint256 inputToken, uint256 outputToken, uint256 inputAmount, address userAddress, bytes32 metadata) external returns (uint256 outputAmount);
function computeInputAmount(uint256 inputToken, uint256 outputToken, uint256 outputAmount, address userAddress, bytes32 metadata) external returns (uint256 inputAmount);
function getTokenSupply(uint256 tokenId) external view returns (uint256 totalSupply);
}// SPDX-License-Identifier: unlicensed
// Cowri Labs Inc.
pragma solidity ^0.8.19;
/**
* @title Interface for external contracts that issue tokens on the Ocean's
* public multitoken ledger
* @dev Implemented by OceanERC1155.
*/
interface IOceanToken {
function registerNewTokens(uint256 currentNumberOfTokens, uint256 numberOfAdditionalTokens) external returns (uint256[] memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.3.2 (token/ERC1155/ERC1155.sol)
// Cowri Labs, Inc., modifications licensed under: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
// OpenZeppelin Inherited Contracts
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
// ShellV2 Interface
import { IOceanToken } from "./IOceanToken.sol";
// ShellV2 Permit Signature
import { ERC1155PermitSignatureExtension } from "./ERC1155PermitSignatureExtension.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
* @dev modifications include removing unused hooks, creating a minting
* function that does not do a safeTransferAcceptanceCheck, and adding a
* mapping and functions to register and manage authority over tokens.
* @dev Registered Tokens are Ocean-native issuances, such as Liquidity
* Provider tokens issued by an AMM built on top of the Ocean.
*/
contract OceanERC1155 is Context, ERC165, ERC1155PermitSignatureExtension, IERC1155, IERC1155MetadataURI, IOceanToken, Ownable, ReentrancyGuard {
//*********************************************************************//
// --------------------------- custom errors ------------------------- //
//*********************************************************************//
error FORWARDER_NOT_APPROVED();
error INVALID_ERC721_AMOUNT();
error NO_DECIMAL_METHOD();
error NO_RECURSIVE_WRAPS();
error NO_RECURSIVE_UNWRAPS();
using Address for address;
/// @notice Mapping from token ID to address with authority over token's issuance
mapping(uint256 => address) public tokensToPrimitives;
uint256 constant FUSE_INTACT = 1;
uint256 constant FUSE_BROKEN = 0;
uint256 public permitFuse;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
event PermitFuseBroken(address indexed breakerAddress);
event NewTokensRegistered(address indexed creator, uint256[] tokens, uint256[] nonces);
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) ERC1155PermitSignatureExtension(bytes("shell-protocol-ocean"), bytes("1")) {
_setURI(uri_);
permitFuse = FUSE_INTACT;
}
function breakPermitFuse() external onlyOwner {
permitFuse = FUSE_BROKEN;
emit PermitFuseBroken(msg.sender);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "balanceOf(address(0))");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) {
require(accounts.length == ids.length, "accounts.length != ids.length");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) public virtual override nonReentrant {
require(from == _msgSender() || isApprovedForAll(from, _msgSender()), "not owner nor approved");
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public virtual override nonReentrant {
require(from == _msgSender() || isApprovedForAll(from, _msgSender()), "not owner nor approved");
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Registered Tokens are tokens issued directly on the Ocean's 1155 ledger.
* @dev These are tokens that cannot be wrapped or unwrapped.
* @dev We don't validate the inputs. The happy path usage is for callers
* to obtain authority over tokens that have their ids derived from
* successive nonces.
*
* registerNewTokens(0, n):
* _calculateOceanId(caller, 0)
* _calculateOceanId(caller, 1)
* ...
* _calculateOceanId(caller, n)
*
* Since the ocean tracks the one to one relationship of:
* token => authority
* but not the one to many relationship of:
* authority => tokens
* it is nice UX to be able to re-derive the tokens on the fly from the
* authority's address and successive (predictable) nonces are used.
*
* However, if the caller wants to use this interface in a different way,
* they could easily make a call like:
* registerNewTokens($SOME_NUMBER, 1); to use $SOME_NUMBER
* as the nonce. A user could request to buy an in-Ocean nft with a
* specific seed value, and the external contract gains authority over
* this id on the fly in order to sell it.
*
* If the caller tries to reassert authority over a token they've already
* registered, they just waste gas. If a caller expects to create
* new tokens over time, it should track how many tokens it has already
* created
* @dev the guiding philosophy is to track only essential information in
* the Ocean's state, and let users (both EOAs and contracts) track other
* information as they see fit.
* @param currentNumberOfTokens the starting nonce
* @param numberOfAdditionalTokens the number of new tokens registered
* @return oceanIds Ocean IDs of the tokens the caller now has authority over
*/
function registerNewTokens(uint256 currentNumberOfTokens, uint256 numberOfAdditionalTokens) external override returns (uint256[] memory oceanIds) {
oceanIds = new uint256[](numberOfAdditionalTokens);
uint256[] memory nonces = new uint256[](numberOfAdditionalTokens);
for (uint256 i = 0; i < numberOfAdditionalTokens; ++i) {
uint256 tokenNonce = currentNumberOfTokens + i;
uint256 newToken = _calculateOceanId(msg.sender, tokenNonce);
nonces[i] = tokenNonce;
oceanIds[i] = newToken;
tokensToPrimitives[newToken] = msg.sender;
}
emit NewTokensRegistered(msg.sender, oceanIds, nonces);
}
function _signaturesEnabled() internal view override returns (bool) {
return bool(permitFuse == FUSE_INTACT);
}
/**
* @dev returns true when a primitive did NOT register an ID
*
* Used to determine if the Ocean needs to explicitly mint/burn tokens
* balance a transaction.
*/
function _isNotTokenOfPrimitive(uint256 oceanId, address primitive) internal view returns (bool) {
return (tokensToPrimitives[oceanId] != primitive);
}
/**
* @dev calculates a collision-resistant token ID
*
* OceanIds are derived from their origin. The origin can be:
* - ERC20 contracts that have their token wrapped into the Ocean
* - ERC721 contracts that have tokens with IDs wrapped into the Ocean
* - ERC1155 contracts that have tokens with IDs wrapped into the Ocean
* - Contracts that issue Ocean-native tokens
* When a contract registers a new token, the token has an associated
* nonce, which functions just like an ERC721 or ERC1155 token ID.
*
* The oceanId is calculated by using the contract address of the origin
* and the relevant ID. For ERC20 tokens, the ID is always 0.
*/
function _calculateOceanId(address tokenContract, uint256 tokenId) internal pure returns (uint256) {
return uint256(keccak256(abi.encodePacked(tokenContract, tokenId)));
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `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 memory data) internal virtual {
require(to != address(0), "transfer to the zero address");
address operator = _msgSender();
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "insufficient balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - 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[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual {
require(ids.length == amounts.length, "ids.length != amounts.length");
require(to != address(0), "transfer to the zero address");
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "insufficient balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - Should only be called by
* - _mint(...)
* - LiquidityOcean._computeOutputAmount(...)
* - LiquidityOcean._computeInputAmount(...)
* - LiquidityOcean._grantFeeToOcean(...)
*
* - When called by _mint(...) this function complies with the ERC-1155 spec
* - When called by the LiquidityOcean functions, this function breaks the
* ERC-1155 spec deliberately. The contract that is the target of a
* compute*() call can revert the transaction if it does not want to
* receive the tokens, so the safeTransferAcceptanceCheck is redundant.
* The address receiving the fees (immutable DAO) is required to handle
* receiving fees without a safeTransferCheck. By avoiding an SLOAD
* and an external call during the fee assignment, we save users gas.
*/
function _mintWithoutSafeTransferAcceptanceCheck(address to, uint256 id, uint256 amount) internal returns (address) {
address operator = _msgSender();
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
return operator;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(address to, uint256 id, uint256 amount) internal virtual {
assert(to != address(0));
address operator = _mintWithoutSafeTransferAcceptanceCheck(to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* 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 _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts) internal virtual {
assert(to != address(0));
assert(ids.length == amounts.length);
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, "");
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(address from, uint256 id, uint256 amount) internal virtual {
assert(from != address(0));
address operator = _msgSender();
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual {
assert(from != address(0));
assert(ids.length == amounts.length);
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal override {
require(owner != operator, "Set approval for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _doSafeTransferAcceptanceCheck(address operator, address from, address to, uint256 id, uint256 amount, bytes memory data) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155Receiver rejected");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("non-ERC1155Receiver");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155Receiver rejected");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("non-ERC1155Receiver");
}
}
}
}{
"optimizer": {
"enabled": true,
"runs": 10000000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"string","name":"uri_","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CAST_AMOUNT_EXCEEDED","type":"error"},{"inputs":[],"name":"DELTA_AMOUNT_IS_NEGATIVE","type":"error"},{"inputs":[],"name":"DELTA_AMOUNT_IS_POSITIVE","type":"error"},{"inputs":[],"name":"FORWARDER_NOT_APPROVED","type":"error"},{"inputs":[],"name":"INVALID_ERC721_AMOUNT","type":"error"},{"inputs":[],"name":"MISSING_TOKEN_ID","type":"error"},{"inputs":[],"name":"NO_DECIMAL_METHOD","type":"error"},{"inputs":[],"name":"NO_RECURSIVE_UNWRAPS","type":"error"},{"inputs":[],"name":"NO_RECURSIVE_WRAPS","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldFee","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newFee","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"ChangeUnwrapFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"primitive","type":"address"},{"indexed":true,"internalType":"uint256","name":"inputToken","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"outputToken","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"inputAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outputAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"ComputeInputAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"primitive","type":"address"},{"indexed":true,"internalType":"uint256","name":"inputToken","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"outputToken","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"inputAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outputAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"ComputeOutputAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc1155Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc1155Id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeCharged","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"oceanId","type":"uint256"}],"name":"Erc1155Unwrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc1155Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc1155Id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"oceanId","type":"uint256"}],"name":"Erc1155Wrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc20Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"transferredAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unwrappedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeCharged","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"oceanId","type":"uint256"}],"name":"Erc20Unwrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc20Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"transferredAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"wrappedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dust","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"oceanId","type":"uint256"}],"name":"Erc20Wrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc721Id","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"oceanId","type":"uint256"}],"name":"Erc721Unwrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc721id","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"oceanId","type":"uint256"}],"name":"Erc721Wrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"feeCharged","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"EtherUnwrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"EtherWrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"forwarder","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"numberOfInteractions","type":"uint256"}],"name":"ForwardedOceanTransaction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokens","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"nonces","type":"uint256[]"}],"name":"NewTokensRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"numberOfInteractions","type":"uint256"}],"name":"OceanTransaction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"breakerAddress","type":"address"}],"name":"PermitFuseBroken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SETPERMITFORALL_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvalNonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"breakPermitFuse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nextUnwrapFeeDivisor","type":"uint256"}],"name":"changeUnwrapFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"interactionTypeAndAddress","type":"bytes32"},{"internalType":"uint256","name":"inputToken","type":"uint256"},{"internalType":"uint256","name":"outputToken","type":"uint256"},{"internalType":"uint256","name":"specifiedAmount","type":"uint256"},{"internalType":"bytes32","name":"metadata","type":"bytes32"}],"internalType":"struct Interaction","name":"interaction","type":"tuple"}],"name":"doInteraction","outputs":[{"internalType":"uint256","name":"burnId","type":"uint256"},{"internalType":"uint256","name":"burnAmount","type":"uint256"},{"internalType":"uint256","name":"mintId","type":"uint256"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"interactionTypeAndAddress","type":"bytes32"},{"internalType":"uint256","name":"inputToken","type":"uint256"},{"internalType":"uint256","name":"outputToken","type":"uint256"},{"internalType":"uint256","name":"specifiedAmount","type":"uint256"},{"internalType":"bytes32","name":"metadata","type":"bytes32"}],"internalType":"struct Interaction[]","name":"interactions","type":"tuple[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"doMultipleInteractions","outputs":[{"internalType":"uint256[]","name":"burnIds","type":"uint256[]"},{"internalType":"uint256[]","name":"burnAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"mintIds","type":"uint256[]"},{"internalType":"uint256[]","name":"mintAmounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"interactionTypeAndAddress","type":"bytes32"},{"internalType":"uint256","name":"inputToken","type":"uint256"},{"internalType":"uint256","name":"outputToken","type":"uint256"},{"internalType":"uint256","name":"specifiedAmount","type":"uint256"},{"internalType":"bytes32","name":"metadata","type":"bytes32"}],"internalType":"struct Interaction","name":"interaction","type":"tuple"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"forwardedDoInteraction","outputs":[{"internalType":"uint256","name":"burnId","type":"uint256"},{"internalType":"uint256","name":"burnAmount","type":"uint256"},{"internalType":"uint256","name":"mintId","type":"uint256"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"interactionTypeAndAddress","type":"bytes32"},{"internalType":"uint256","name":"inputToken","type":"uint256"},{"internalType":"uint256","name":"outputToken","type":"uint256"},{"internalType":"uint256","name":"specifiedAmount","type":"uint256"},{"internalType":"bytes32","name":"metadata","type":"bytes32"}],"internalType":"struct Interaction[]","name":"interactions","type":"tuple[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"forwardedDoMultipleInteractions","outputs":[{"internalType":"uint256[]","name":"burnIds","type":"uint256[]"},{"internalType":"uint256[]","name":"burnAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"mintIds","type":"uint256[]"},{"internalType":"uint256[]","name":"mintAmounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permitFuse","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"currentNumberOfTokens","type":"uint256"},{"internalType":"uint256","name":"numberOfAdditionalTokens","type":"uint256"}],"name":"registerNewTokens","outputs":[{"internalType":"uint256[]","name":"oceanIds","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"setPermitForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokensToPrimitives","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unwrapFeeDivisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60e06040523480156200001157600080fd5b5060405162005a2938038062005a29833981016040819052620000349162000216565b806040518060400160405280601481526020017f7368656c6c2d70726f746f636f6c2d6f6365616e000000000000000000000000815250604051806040016040528060018152602001603160f81b8152506000604051806080016040528060528152602001620059d760529139805160208083019190912085518683012085518684012060408051948501939093529183015260608201524660808201523060a082015290915060c00160408051808303601f19018152919052805160209091012060805250507f7aea62eb64c80d70d6f7fceb0f80c4901e6585fbeca774ca10ae898d1af3af6760a052506200012b336200019c565b60016002556200013b81620001ee565b50600160048190556000196008556009819055600a55604080517045746865720000000000000000000000006020808301919091526000603480840191909152835180840390910181526054909201909252805191012060c0525062000446565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6007620001fc82826200037a565b5050565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156200022a57600080fd5b82516001600160401b03808211156200024257600080fd5b818501915085601f8301126200025757600080fd5b8151818111156200026c576200026c62000200565b604051601f8201601f19908116603f0116810190838211818310171562000297576200029762000200565b816040528281528886848701011115620002b057600080fd5b600093505b82841015620002d45784840186015181850187015292850192620002b5565b600086848301015280965050505050505092915050565b600181811c908216806200030057607f821691505b6020821081036200032157634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200037557600081815260208120601f850160051c81016020861015620003505750805b601f850160051c820191505b8181101562000371578281556001016200035c565b5050505b505050565b81516001600160401b0381111562000396576200039662000200565b620003ae81620003a78454620002eb565b8462000327565b602080601f831160018114620003e65760008415620003cd5750858301515b600019600386901b1c1916600185901b17855562000371565b600085815260208120601f198616915b828110156200041757888601518255948401946001909101908401620003f6565b5085821015620004365787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c051615537620004a06000396000818161146401528181611b98015281816121dc015281816124690152613a670152600081816102300152610c8c0152600081816103640152610c6a01526155376000f3fe6080604052600436106101b65760003560e01c8063739653ba116100ec578063d44f70b41161008a578063e985e9c511610064578063e985e9c51461058a578063f23a6e61146105e0578063f242432a14610600578063f2fde38b1461062057600080fd5b8063d44f70b41461052a578063e36383991461053d578063e4288c071461055d57600080fd5b8063a22cb465116100c6578063a22cb4651461047b578063b369799e1461049b578063bc197c81146104be578063c7d15f84146104e757600080fd5b8063739653ba146104065780638da5cb5b146104195780638fec80091461046557600080fd5b80632eb2c2d6116101595780634b7ac8d4116101335780634b7ac8d41461039b5780634e1273f4146103bb5780636f6e25c7146103db578063715018a6146103f157600080fd5b80632eb2c2d6146103305780633644e5151461035257806343d8e5061461038657600080fd5b80630e89341c116101955780630e89341c14610252578063150b7a021461027f578063215835b3146102d0578063286450f1146102fd57600080fd5b8062fdd58e146101bb57806301ffc9a7146101ee57806306bea5451461021e575b600080fd5b3480156101c757600080fd5b506101db6101d63660046144b3565b610640565b6040519081526020015b60405180910390f35b3480156101fa57600080fd5b5061020e61020936600461450b565b6106fc565b60405190151581526020016101e5565b34801561022a57600080fd5b506101db7f000000000000000000000000000000000000000000000000000000000000000081565b34801561025e57600080fd5b5061027261026d366004614528565b610752565b6040516101e591906145af565b34801561028b57600080fd5b5061029f61029a36600461460b565b6107e6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016101e5565b3480156102dc57600080fd5b506102f06102eb36600461467a565b610826565b6040516101e591906146d7565b61031061030b366004614702565b6109ff565b6040805194855260208501939093529183015260608201526080016101e5565b34801561033c57600080fd5b5061035061034b3660046148d7565b610ada565b005b34801561035e57600080fd5b506101db7f000000000000000000000000000000000000000000000000000000000000000081565b34801561039257600080fd5b50610350610b8f565b3480156103a757600080fd5b506103506103b636600461499e565b610bc8565b3480156103c757600080fd5b506102f06103d6366004614a14565b610e82565b3480156103e757600080fd5b506101db60045481565b3480156103fd57600080fd5b50610350610fb4565b610310610414366004614adf565b610fc8565b34801561042557600080fd5b5060015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e5565b34801561047157600080fd5b506101db60085481565b34801561048757600080fd5b50610350610496366004614afb565b61102c565b6104ae6104a9366004614bbc565b61103b565b6040516101e59493929190614c3d565b3480156104ca57600080fd5b5061029f6104d9366004614c8a565b600098975050505050505050565b3480156104f357600080fd5b50610440610502366004614528565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6104ae610538366004614d45565b61111e565b34801561054957600080fd5b50610350610558366004614528565b611173565b34801561056957600080fd5b506101db610578366004614db1565b60006020819052908152604090205481565b34801561059657600080fd5b5061020e6105a5366004614dcc565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260066020908152604080832093909416825291909152205460ff1690565b3480156105ec57600080fd5b5061029f6105fb366004614df6565b6111c8565b34801561060c57600080fd5b5061035061061b366004614e6e565b611209565b34801561062c57600080fd5b5061035061063b366004614db1565b6112ad565b600073ffffffffffffffffffffffffffffffffffffffff83166106c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f62616c616e63654f66286164647265737328302929000000000000000000000060448201526064015b60405180910390fd5b50600081815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020545b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806106f657506106f682611364565b60606007805461076190614ed3565b80601f016020809104026020016040519081016040528092919081815260200182805461078d90614ed3565b80156107da5780601f106107af576101008083540402835291602001916107da565b820191906000526020600020905b8154815290600101906020018083116107bd57829003601f168201915b50505050509050919050565b60006002600a540361081957507f150b7a020000000000000000000000000000000000000000000000000000000061081d565b5060005b95945050505050565b60608167ffffffffffffffff81111561084157610841614736565b60405190808252806020026020018201604052801561086a578160200160208202803683370190505b50905060008267ffffffffffffffff81111561088857610888614736565b6040519080825280602002602001820160405280156108b1578160200160208202803683370190505b50905060005b838110156109a75760006108cb8287614f4f565b604080513360601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602080830191909152603480830185905283518084039091018152605490920190925280519101209091508184848151811061093357610933614f62565b6020026020010181815250508085848151811061095257610952614f62565b6020908102919091018101919091526000918252600390526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055506109a081614f91565b90506108b7565b503373ffffffffffffffffffffffffffffffffffffffff167f69f4cd026fceaa224d78e03ab43e6c20f9d54eae52f88e23573a5ac5bc9c4cd783836040516109f0929190614fc9565b60405180910390a25092915050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600660209081526040808320338452909152812054819081908190859060ff16610a71576040517fb8e05a7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040516001815273ffffffffffffffffffffffffffffffffffffffff87169033907f6eb0debd3c0f189ccf977863c81ba259fe0eb500503c3f78777771a68bf8e4899060200160405180910390a3610ac98787611447565b929a91995097509095509350505050565b610ae2611563565b73ffffffffffffffffffffffffffffffffffffffff8516331480610b0b5750610b0b85336105a5565b610b71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6e6f74206f776e6572206e6f7220617070726f7665640000000000000000000060448201526064016106bb565b610b7e85858585856115d4565b610b886001600255565b5050505050565b610b9761189f565b6000600481905560405133917f6a48aa731704180ea30bb9c36eb6e31f04c276642647d76c25f20caaa50f884791a2565b600454600114610c34576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5065726d6974205369676e61747572652044697361626c65640000000000000060448201526064016106bb565b42841015610c4157600080fd5b73ffffffffffffffffffffffffffffffffffffffff8716600090815260208190526040812080547f0000000000000000000000000000000000000000000000000000000000000000917f0000000000000000000000000000000000000000000000000000000000000000918b918b918b9187610cbc83614f91565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff948516908601529290911660608401521515608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001610d5f9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610de8573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610e6357508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610e6c57600080fd5b610e77898989611920565b505050505050505050565b60608151835114610eef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f6163636f756e74732e6c656e67746820213d206964732e6c656e67746800000060448201526064016106bb565b6000835167ffffffffffffffff811115610f0b57610f0b614736565b604051908082528060200260200182016040528015610f34578160200160208202803683370190505b50905060005b8451811015610fac57610f7f858281518110610f5857610f58614f62565b6020026020010151858381518110610f7257610f72614f62565b6020026020010151610640565b828281518110610f9157610f91614f62565b6020908102919091010152610fa581614f91565b9050610f3a565b509392505050565b610fbc61189f565b610fc66000611a4d565b565b60008060008060013373ffffffffffffffffffffffffffffffffffffffff167f1ae805a3773324a90592b8a87b99151f93a76c32229b924c6a8199c2acda49f960405160405180910390a361101d8533611447565b93509350935093509193509193565b611037338383611920565b5050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600660209081526040808320338452909152902054606090819081908190859060ff166110b0576040517fb8e05a7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405189815273ffffffffffffffffffffffffffffffffffffffff87169033907f6eb0debd3c0f189ccf977863c81ba259fe0eb500503c3f78777771a68bf8e4899060200160405180910390a361110a8a8a8a8a8a611ac4565b929d919c509a509098509650505050505050565b604051606090819081908190879033907f1ae805a3773324a90592b8a87b99151f93a76c32229b924c6a8199c2acda49f990600090a36111618888888833611ac4565b929b919a509850909650945050505050565b61117b61189f565b806107d0111561118a57600080fd5b6008546040513381528291907f418da9cf3f702319d14530681ec7bf242aeb71f4959c849ad3de431599b43cc49060200160405180910390a3600855565b60006002600954036111fb57507ff23a6e61000000000000000000000000000000000000000000000000000000006111ff565b5060005b9695505050505050565b611211611563565b73ffffffffffffffffffffffffffffffffffffffff851633148061123a575061123a85336105a5565b6112a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6e6f74206f776e6572206e6f7220617070726f7665640000000000000000000060448201526064016106bb565b610b7e8585858585611e10565b6112b561189f565b73ffffffffffffffffffffffffffffffffffffffff8116611358576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106bb565b61136181611a4d565b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fd9b67a260000000000000000000000000000000000000000000000000000000014806113f757507fffffffff0000000000000000000000000000000000000000000000000000000082167f0e89341c00000000000000000000000000000000000000000000000000000000145b806106f657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146106f6565b600080808034156114ce57505060405134808252600093508392507f00000000000000000000000000000000000000000000000000000000000000009173ffffffffffffffffffffffffffffffffffffffff8616907f55f83f01c0664bd25aad3d627119249b43acc06873e584be1db2ddd46ca3bdeb9060200160405180910390a2611538565b6000806114e86114e3368a90038a018a614fee565b611feb565b909250905060006115088383611503368d90038d018d614fee565b61200f565b905061152a61151c368b90038b018b614fee565b8484848d606001358d612203565b929950909750955093505050505b8215611549576115498585856124ba565b801561155a5761155a8583836125f4565b92959194509250565b60028054036115ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106bb565b60028055565b815183511461163f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f6964732e6c656e67746820213d20616d6f756e74732e6c656e6774680000000060448201526064016106bb565b73ffffffffffffffffffffffffffffffffffffffff84166116bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016106bb565b3360005b845181101561180a5760008582815181106116dd576116dd614f62565b6020026020010151905060008583815181106116fb576116fb614f62565b602090810291909101810151600084815260058352604080822073ffffffffffffffffffffffffffffffffffffffff8e1683529093529190912054909150818110156117a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f696e73756666696369656e742062616c616e636500000000000000000000000060448201526064016106bb565b600083815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff8e8116855292528083208585039055908b168252812080548492906117ef908490614f4f565b925050819055505050508061180390614f91565b90506116c0565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611881929190614fc9565b60405180910390a461189781878787878761264a565b505050505050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610fc6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106bb565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036119b5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f53657420617070726f76616c20666f722073656c66000000000000000000000060448201526064016106bb565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526006602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b606080808060008667ffffffffffffffff811115611ae457611ae4614736565b604051908082528060200260200182016040528015611b2957816020015b6040805180820190915260008082526020820152815260200190600190039081611b025790505b5090508660005b81811015611b8b5760405180604001604052808b8b84818110611b5557611b55614f62565b9050602002013581526020016000815250838281518110611b7857611b78614f62565b6020908102919091010152600101611b30565b503415611c0e57611bbd827f000000000000000000000000000000000000000000000000000000000000000034612888565b8673ffffffffffffffffffffffffffffffffffffffff167f55f83f01c0664bd25aad3d627119249b43acc06873e584be1db2ddd46ca3bdeb34604051611c0591815260200190565b60405180910390a25b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091528760005b8c811015611d28578d8d82818110611c5757611c57614f62565b905060a00201803603810190611c6d9190614fee565b9250600080611c7b85611feb565b915091506000611c8c83838861200f565b905060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff876060015103611ccd57611cc6898584612925565b9050611cd4565b5060608601515b600080600080611ce88b898989898f612203565b93509350935093506000831115611d0457611d048d85856129c5565b8015611d1557611d158d8383612888565b8860010198505050505050505050611c3d565b505050611d3482612a58565b835191995097509195509350600103611d8b57611d868785600081518110611d5e57611d5e614f62565b602002602001015185600081518110611d7957611d79614f62565b60200260200101516125f4565b611da0565b600184511115611da057611da0878585612b98565b8551600103611ded57611de88787600081518110611dc057611dc0614f62565b602002602001015187600081518110611ddb57611ddb614f62565b60200260200101516124ba565b611e02565b600186511115611e0257611e02878787612d1f565b505095509550955095915050565b73ffffffffffffffffffffffffffffffffffffffff8416611e8d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016106bb565b600083815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff89168452909152902054339083811015611f29576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f696e73756666696369656e742062616c616e636500000000000000000000000060448201526064016106bb565b600085815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff8b8116855292528083208785039055908816825281208054869290611f75908490614f4f565b9091555050604080518681526020810186905273ffffffffffffffffffffffffffffffffffffffff808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611fe2828888888888612f04565b50505050505050565b8051600090819080821a60088111156120065761200661505e565b94909350915050565b6000808460088111156120245761202461505e565b14806120415750600184600881111561203f5761203f61505e565b145b156120a45760408051606085901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602080830191909152600060348084019190915283518084039091018152605490920190925280519101205b90506121fc565b60028460088111156120b8576120b861505e565b14806120d5575060048460088111156120d3576120d361505e565b145b806120f1575060038460088111156120ef576120ef61505e565b145b8061210d5750600584600881111561210b5761210b61505e565b145b1561217057608082015160408051606086901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602080830191909152603480830194909452825180830390940184526054909101909152815191012061209d565b60068460088111156121845761218461505e565b03612194575060408101516121fc565b60078460088111156121a8576121a861505e565b036121b8575060208101516121fc565b60088460088111156121cc576121cc61505e565b146121d9576121d961508d565b507f00000000000000000000000000000000000000000000000000000000000000005b9392505050565b6000808080600789600881111561221c5761221c61505e565b03612247578693508592508960400151915061224088858486898f6080015161308b565b90506124ad565b600689600881111561225b5761225b61505e565b03612286578960200151935086915085905061227f88858484898f608001516131bf565b92506124ad565b600089600881111561229a5761229a61505e565b036122bc575060009250829150859050846122b7888287856132e5565b6124ad565b60018960088111156122d0576122d061505e565b036122ed575085925084915060009050806122b788848787613432565b60028960088111156123015761230161505e565b036123615785600114612340576040517f63e95dfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009350600092508691508590506122b7888b6080015160001c87856135a8565b60038960088111156123755761237561505e565b036123d557856001146123b4576040517f63e95dfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b86935085925060009150600090506122b7888b6080015160001c87876136a3565b60048960088111156123e9576123e961505e565b036124105760009350600092508691508590506122b7888b6080015160001c838886613791565b60058960088111156124245761242461505e565b0361244b5786935085925060009150600090506122b7888b6080015160001c8588886138e2565b600889600881111561245f5761245f61505e565b14801561248b57507f000000000000000000000000000000000000000000000000000000000000000087145b6124975761249761508d565b5085925084915060009050806124ad8386613a55565b9650965096509692505050565b73ffffffffffffffffffffffffffffffffffffffff83166124dd576124dd61508d565b600082815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902054339082811015612579576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f6275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016106bb565b600084815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff898116808652918452828520888703905582518981529384018890529092908616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6291015b60405180910390a45050505050565b73ffffffffffffffffffffffffffffffffffffffff83166126175761261761508d565b6000612624848484613b2a565b905061264481600086868660405180602001604052806000815250612f04565b50505050565b73ffffffffffffffffffffffffffffffffffffffff84163b15611897576040517fbc197c8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063bc197c81906126c190899089908890889088906004016150bc565b6020604051808303816000875af192505050801561271a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261271791810190615127565b60015b6127dd57612726615144565b806308c379a003612779575061273a615160565b80612745575061277b565b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106bb91906145af565b505b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f6e6f6e2d4552433131353552656365697665720000000000000000000000000060448201526064016106bb565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c810000000000000000000000000000000000000000000000000000000014611fe2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433131353552656365697665722072656a6563746564000000000000000060448201526064016106bb565b80807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff116128e2576040517f42b51b6000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006128ee8585613bd2565b90508285828151811061290357612903614f62565b602002602001015160200181815161291b9190615208565b9052505050505050565b6000600183600881111561293b5761293b61505e565b1480612958575060038360088111156129565761295661505e565b145b80612974575060058360088111156129725761297261505e565b145b806129905750600883600881111561298e5761298e61505e565b145b806129ac575060078360088111156129aa576129aa61505e565b145b156129bb5761209d8483613c45565b61209d8483613cb9565b80807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff11612a1f576040517f42b51b6000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612a2b8585613bd2565b905082858281518110612a4057612a40614f62565b602002602001015160200181815161291b9190615230565b606080606080600080612a6a87613d2e565b915091508167ffffffffffffffff811115612a8757612a87614736565b604051908082528060200260200182016040528015612ab0578160200160208202803683370190505b5095508167ffffffffffffffff811115612acc57612acc614736565b604051908082528060200260200182016040528015612af5578160200160208202803683370190505b5094508067ffffffffffffffff811115612b1157612b11614736565b604051908082528060200260200182016040528015612b3a578160200160208202803683370190505b5093508067ffffffffffffffff811115612b5657612b56614736565b604051908082528060200260200182016040528015612b7f578160200160208202803683370190505b509250612b8f8787878787613dda565b50509193509193565b73ffffffffffffffffffffffffffffffffffffffff8316612bbb57612bbb61508d565b8051825114612bcc57612bcc61508d565b3360005b8351811015612c8157828181518110612beb57612beb614f62565b602002602001015160056000868481518110612c0957612c09614f62565b6020026020010151815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612c6b9190614f4f565b90915550612c7a905081614f91565b9050612bd0565b508373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612cf9929190614fc9565b60405180910390a46126448160008686866040518060200160405280600081525061264a565b73ffffffffffffffffffffffffffffffffffffffff8316612d4257612d4261508d565b8051825114612d5357612d5361508d565b3360005b8351811015612e7e576000848281518110612d7457612d74614f62565b602002602001015190506000848381518110612d9257612d92614f62565b602090810291909101810151600084815260058352604080822073ffffffffffffffffffffffffffffffffffffffff8c168352909352919091205490915081811015612e3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f6275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016106bb565b600092835260056020908152604080852073ffffffffffffffffffffffffffffffffffffffff8b16865290915290922091039055612e7781614f91565b9050612d57565b50600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612ef6929190614fc9565b60405180910390a450505050565b73ffffffffffffffffffffffffffffffffffffffff84163b15611897576040517ff23a6e6100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063f23a6e6190612f7b9089908990889088908890600401615257565b6020604051808303816000875af1925050508015612fd4575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612fd191810190615127565b60015b612fe057612726615144565b7fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e610000000000000000000000000000000000000000000000000000000014611fe2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433131353552656365697665722072656a6563746564000000000000000060448201526064016106bb565b6000613098878786613f26565b6040517f3fc20d4f00000000000000000000000000000000000000000000000000000000815260048101879052602481018690526044810185905273ffffffffffffffffffffffffffffffffffffffff848116606483015260848201849052881690633fc20d4f9060a4016020604051808303816000875af1158015613122573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613146919061529c565b9050613153878683613f72565b6040805173ffffffffffffffffffffffffffffffffffffffff808a168252602082018490528516918101919091528490869088907fc6baad430667a9b3f12a9f115e0af95c8538e5e2595e248f2d068f6c93c6101e906060015b60405180910390a49695505050505050565b60006131cc878686613f72565b6040517fe92ebd3a00000000000000000000000000000000000000000000000000000000815260048101879052602481018690526044810185905273ffffffffffffffffffffffffffffffffffffffff84811660648301526084820184905288169063e92ebd3a9060a4016020604051808303816000875af1158015613256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327a919061529c565b9050613287878783613f26565b6040805173ffffffffffffffffffffffffffffffffffffffff808a168252602082018790528516918101919091528190869088907fff21d0dd1bae0672a5771fb6668afecf9485c8e6e82a7d2f1ee58a96277c630e906060016131ad565b8373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561336a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252613367918101906152b5565b60015b6133a0576040517f93bee3e100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806133ad8684613fb9565b90925090506133bc8482614034565b6133c887863085614063565b6040805183815260208101889052908101829052849073ffffffffffffffffffffffffffffffffffffffff80881691908a16907fd86e46c0b98ab82d234497fd7d7e31711dfa27764034b1763f3575c521f6ff94906060015b60405180910390a450505050505050565b8373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156134b7575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526134b4918101906152b5565b60015b6134ed576040517f93bee3e100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006134f88561413f565b9050600061350682876152d2565b90506000806135176012868561414f565b90925090506135268185614f4f565b93506135328685614034565b61353d8988846141e8565b60408051838152602081018a9052908101859052869073ffffffffffffffffffffffffffffffffffffffff808a1691908c16907f62a282d05dd7f7ec454ec1e3ebe4c23b911f1fedecfa6f241f4b663896e592cf9060600160405180910390a4505050505050505050565b6002600a556040517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152306024830152604482018590528516906342842e0e90606401600060405180830381600087803b15801561362357600080fd5b505af1158015613637573d6000803e3d6000fd5b505050506001600a81905550808273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f7672c4a63cc0b66a7449c3e1051810a6f128034121aa8314de5b008254b2389f86604051612ef691815260200190565b6040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152604482018590528516906342842e0e90606401600060405180830381600087803b15801561371957600080fd5b505af115801561372d573d6000803e3d6000fd5b50505050808273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fe67983c06675e145002b5c4392d05e59790fd0cc13fb15ed1a6201f9d78e17ef86604051612ef691815260200190565b3073ffffffffffffffffffffffffffffffffffffffff8616036137e0576040517f73a7f55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60026009556040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152306024830152604482018690526064820185905260a06084830152600060a483015286169063f242432a9060c401600060405180830381600087803b15801561387057600080fd5b505af1158015613884573d6000803e3d6000fd5b5050600160095550506040805185815260208101859052829173ffffffffffffffffffffffffffffffffffffffff80861692908916917f9e8d41f891cc91b6fbf90fec18d6464e22e7d95db0113fefec8c8e6815c9608491016125e5565b3073ffffffffffffffffffffffffffffffffffffffff861603613931576040517fe69dd17800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061393c8461413f565b9050600061394a82866152d2565b90506139568383614034565b6040517ff242432a00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8581166024830152604482018890526064820183905260a06084830152600060a483015288169063f242432a9060c401600060405180830381600087803b1580156139e157600080fd5b505af11580156139f5573d6000803e3d6000fd5b5050604080518981526020810189905290810185905285925073ffffffffffffffffffffffffffffffffffffffff80881692508a16907f285f7151736e0529314aabab94f541d8837226ed08c744dbe86bb81c76b13b3d90606001613421565b6000613a608361413f565b9050613a8c7f000000000000000000000000000000000000000000000000000000000000000082614034565b6000613a9882856152d2565b60405190915073ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083906000818181858888f19350505050158015613ade573d6000803e3d6000fd5b508273ffffffffffffffffffffffffffffffffffffffff1682827fa99566a5bc143aef6dfe90cacd94612c00db3ce770f4687cccc7146a841aeb4260405160405180910390a450505050565b600082815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281208054339184918490613b6c908490614f4f565b9091555050604080518581526020810185905273ffffffffffffffffffffffffffffffffffffffff80881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4949350505050565b60005b8251811015613c135781838281518110613bf157613bf1614f62565b60200260200101516000015103156106f657613c0c81614f91565b9050613bd5565b6040517fe6e53d7f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080613c528484613bd2565b90506000848281518110613c6857613c68614f62565b60200260200101516020015190506000811215613cb1576040517fb11f012b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b600080613cc68484613bd2565b90506000848281518110613cdc57613cdc614f62565b60200260200101516020015190506000811315613d25576040517fa91f3c8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61081d816152e5565b6000806000805b8451811015613daf576000858281518110613d5257613d52614f62565b60200260200101516020015190506000811315613d7957613d7285614f91565b9450613d9e565b6000811215613d9257613d8b84614f91565b9350613d9e565b613d9b83614f91565b92505b50613da881614f91565b9050613d35565b50835181613dbd8486614f4f565b613dc79190614f4f565b14613dd457613dd461508d565b50915091565b60008060005b8751811015613f09576000888281518110613dfd57613dfd614f62565b60200260200101516020015190506000811315613e8057888281518110613e2657613e26614f62565b602002602001015160000151888581518110613e4457613e44614f62565b60200260200101818152505080878581518110613e6357613e63614f62565b6020908102919091010152613e79600185614f4f565b9350613ef8565b6000811215613ef857888281518110613e9b57613e9b614f62565b602002602001015160000151868481518110613eb957613eb9614f62565b6020908102919091010152613ecd816152e5565b858481518110613edf57613edf614f62565b6020908102919091010152613ef5600184614f4f565b92505b50613f0281614f91565b9050613de0565b50855182148015613f1a5750835181145b611fe257611fe261508d565b60008281526003602052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614158015613f5d5750600081115b15613f6d57612644838383613b2a565b505050565b60008281526003602052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614158015613fa95750600081115b15613f6d57613f6d8383836124ba565b6000806000613fca6012858761414f565b9093509050801561402757613fe0600184614f4f565b9250600080613ff18660128761414f565b91509150806000146140055761400561508d565b8682116140145761401461508d565b61401e87836152d2565b9350505061402c565b600091505b509250929050565b801561103757613f6d61405c60015473ffffffffffffffffffffffffffffffffffffffff1690565b8383613b2a565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526126449085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261423e565b6000600854826106f6919061534c565b6000808360ff168560ff160361416a575081905060006141e0565b8360ff168560ff1610156141aa5760006141848686615360565b6141929060ff16600a615491565b905061419e818561549d565b925060009150506141e0565b60006141b68587615360565b6141c49060ff16600a615491565b90506141d0818561534c565b92506141dc81856154b4565b9150505b935093915050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052613f6d9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016140bd565b60006142a0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661434d9092919063ffffffff16565b90508051600014806142c15750808060200190518101906142c191906154c8565b613f6d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106bb565b6060613cb18484600085856000808673ffffffffffffffffffffffffffffffffffffffff16858760405161438191906154e5565b60006040518083038185875af1925050503d80600081146143be576040519150601f19603f3d011682016040523d82523d6000602084013e6143c3565b606091505b50915091506143d4878383876143df565b979650505050505050565b6060831561447557825160000361446e5773ffffffffffffffffffffffffffffffffffffffff85163b61446e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106bb565b5081613cb1565b613cb183838151156127455781518083602001fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146144ae57600080fd5b919050565b600080604083850312156144c657600080fd5b6144cf8361448a565b946020939093013593505050565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461136157600080fd5b60006020828403121561451d57600080fd5b81356121fc816144dd565b60006020828403121561453a57600080fd5b5035919050565b60005b8381101561455c578181015183820152602001614544565b50506000910152565b6000815180845261457d816020860160208601614541565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006121fc6020830184614565565b60008083601f8401126145d457600080fd5b50813567ffffffffffffffff8111156145ec57600080fd5b60208301915083602082850101111561460457600080fd5b9250929050565b60008060008060006080868803121561462357600080fd5b61462c8661448a565b945061463a6020870161448a565b935060408601359250606086013567ffffffffffffffff81111561465d57600080fd5b614669888289016145c2565b969995985093965092949392505050565b6000806040838503121561468d57600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b838110156146cc578151875295820195908201906001016146b0565b509495945050505050565b6020815260006121fc602083018461469c565b600060a082840312156146fc57600080fd5b50919050565b60008060c0838503121561471557600080fd5b61471f84846146ea565b915061472d60a0840161448a565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116810181811067ffffffffffffffff821117156147a9576147a9614736565b6040525050565b600067ffffffffffffffff8211156147ca576147ca614736565b5060051b60200190565b600082601f8301126147e557600080fd5b813560206147f2826147b0565b6040516147ff8282614765565b83815260059390931b850182019282810191508684111561481f57600080fd5b8286015b8481101561483a5780358352918301918301614823565b509695505050505050565b600082601f83011261485657600080fd5b813567ffffffffffffffff81111561487057614870614736565b6040516148a560207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160182614765565b8181528460208386010111156148ba57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a086880312156148ef57600080fd5b6148f88661448a565b94506149066020870161448a565b9350604086013567ffffffffffffffff8082111561492357600080fd5b61492f89838a016147d4565b9450606088013591508082111561494557600080fd5b61495189838a016147d4565b9350608088013591508082111561496757600080fd5b5061497488828901614845565b9150509295509295909350565b801515811461136157600080fd5b60ff8116811461136157600080fd5b600080600080600080600060e0888a0312156149b957600080fd5b6149c28861448a565b96506149d06020890161448a565b955060408801356149e081614981565b94506060880135935060808801356149f78161498f565b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215614a2757600080fd5b823567ffffffffffffffff80821115614a3f57600080fd5b818501915085601f830112614a5357600080fd5b81356020614a60826147b0565b604051614a6d8282614765565b83815260059390931b8501820192828101915089841115614a8d57600080fd5b948201945b83861015614ab257614aa38661448a565b82529482019490820190614a92565b96505086013592505080821115614ac857600080fd5b50614ad5858286016147d4565b9150509250929050565b600060a08284031215614af157600080fd5b6121fc83836146ea565b60008060408385031215614b0e57600080fd5b614b178361448a565b91506020830135614b2781614981565b809150509250929050565b60008083601f840112614b4457600080fd5b50813567ffffffffffffffff811115614b5c57600080fd5b60208301915083602060a08302850101111561460457600080fd5b60008083601f840112614b8957600080fd5b50813567ffffffffffffffff811115614ba157600080fd5b6020830191508360208260051b850101111561460457600080fd5b600080600080600060608688031215614bd457600080fd5b853567ffffffffffffffff80821115614bec57600080fd5b614bf889838a01614b32565b90975095506020880135915080821115614c1157600080fd5b50614c1e88828901614b77565b9094509250614c3190506040870161448a565b90509295509295909350565b608081526000614c50608083018761469c565b8281036020840152614c62818761469c565b90508281036040840152614c76818661469c565b905082810360608401526143d4818561469c565b60008060008060008060008060a0898b031215614ca657600080fd5b614caf8961448a565b9750614cbd60208a0161448a565b9650604089013567ffffffffffffffff80821115614cda57600080fd5b614ce68c838d01614b77565b909850965060608b0135915080821115614cff57600080fd5b614d0b8c838d01614b77565b909650945060808b0135915080821115614d2457600080fd5b50614d318b828c016145c2565b999c989b5096995094979396929594505050565b60008060008060408587031215614d5b57600080fd5b843567ffffffffffffffff80821115614d7357600080fd5b614d7f88838901614b32565b90965094506020870135915080821115614d9857600080fd5b50614da587828801614b77565b95989497509550505050565b600060208284031215614dc357600080fd5b6121fc8261448a565b60008060408385031215614ddf57600080fd5b614de88361448a565b915061472d6020840161448a565b60008060008060008060a08789031215614e0f57600080fd5b614e188761448a565b9550614e266020880161448a565b94506040870135935060608701359250608087013567ffffffffffffffff811115614e5057600080fd5b614e5c89828a016145c2565b979a9699509497509295939492505050565b600080600080600060a08688031215614e8657600080fd5b614e8f8661448a565b9450614e9d6020870161448a565b93506040860135925060608601359150608086013567ffffffffffffffff811115614ec757600080fd5b61497488828901614845565b600181811c90821680614ee757607f821691505b6020821081036146fc577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156106f6576106f6614f20565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614fc257614fc2614f20565b5060010190565b604081526000614fdc604083018561469c565b828103602084015261081d818561469c565b600060a0828403121561500057600080fd5b60405160a0810181811067ffffffffffffffff8211171561502357615023614736565b806040525082358152602083013560208201526040830135604082015260608301356060820152608083013560808201528091505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525060a060408301526150f560a083018661469c565b8281036060840152615107818661469c565b9050828103608084015261511b8185614565565b98975050505050505050565b60006020828403121561513957600080fd5b81516121fc816144dd565b600060033d111561515d5760046000803e5060005160e01c5b90565b600060443d101561516e5790565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc803d016004833e81513d67ffffffffffffffff81602484011181841117156151bc57505050505090565b82850191508151818111156151d45750505050505090565b843d87010160208285010111156151ee5750505050505090565b6151fd60208286010187614765565b509095945050505050565b808201828112600083128015821682158216171561522857615228614f20565b505092915050565b818103600083128015838313168383128216171561525057615250614f20565b5092915050565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015283606083015260a060808301526143d460a0830184614565565b6000602082840312156152ae57600080fd5b5051919050565b6000602082840312156152c757600080fd5b81516121fc8161498f565b818103818111156106f6576106f6614f20565b60007f8000000000000000000000000000000000000000000000000000000000000000820361531657615316614f20565b5060000390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261535b5761535b61531d565b500490565b60ff82811682821603908111156106f6576106f6614f20565b600181815b8085111561402c57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156153b8576153b8614f20565b808516156153c557918102915b93841c939080029061537e565b6000826153e1575060016106f6565b816153ee575060006106f6565b8160018114615404576002811461540e5761542a565b60019150506106f6565b60ff84111561541f5761541f614f20565b50506001821b6106f6565b5060208310610133831016604e8410600b841016171561544d575081810a6106f6565b6154578383615379565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561548957615489614f20565b029392505050565b60006121fc83836153d2565b80820281158282048414176106f6576106f6614f20565b6000826154c3576154c361531d565b500690565b6000602082840312156154da57600080fd5b81516121fc81614981565b600082516154f7818460208701614541565b919091019291505056fea26469706673582212208ee057b7cc4c41ee2a644fde9e42bd16120bcb004dab8cfed77d427b4e4223f564736f6c63430008130033454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e74726163742900000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106101b65760003560e01c8063739653ba116100ec578063d44f70b41161008a578063e985e9c511610064578063e985e9c51461058a578063f23a6e61146105e0578063f242432a14610600578063f2fde38b1461062057600080fd5b8063d44f70b41461052a578063e36383991461053d578063e4288c071461055d57600080fd5b8063a22cb465116100c6578063a22cb4651461047b578063b369799e1461049b578063bc197c81146104be578063c7d15f84146104e757600080fd5b8063739653ba146104065780638da5cb5b146104195780638fec80091461046557600080fd5b80632eb2c2d6116101595780634b7ac8d4116101335780634b7ac8d41461039b5780634e1273f4146103bb5780636f6e25c7146103db578063715018a6146103f157600080fd5b80632eb2c2d6146103305780633644e5151461035257806343d8e5061461038657600080fd5b80630e89341c116101955780630e89341c14610252578063150b7a021461027f578063215835b3146102d0578063286450f1146102fd57600080fd5b8062fdd58e146101bb57806301ffc9a7146101ee57806306bea5451461021e575b600080fd5b3480156101c757600080fd5b506101db6101d63660046144b3565b610640565b6040519081526020015b60405180910390f35b3480156101fa57600080fd5b5061020e61020936600461450b565b6106fc565b60405190151581526020016101e5565b34801561022a57600080fd5b506101db7f7aea62eb64c80d70d6f7fceb0f80c4901e6585fbeca774ca10ae898d1af3af6781565b34801561025e57600080fd5b5061027261026d366004614528565b610752565b6040516101e591906145af565b34801561028b57600080fd5b5061029f61029a36600461460b565b6107e6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016101e5565b3480156102dc57600080fd5b506102f06102eb36600461467a565b610826565b6040516101e591906146d7565b61031061030b366004614702565b6109ff565b6040805194855260208501939093529183015260608201526080016101e5565b34801561033c57600080fd5b5061035061034b3660046148d7565b610ada565b005b34801561035e57600080fd5b506101db7f50be42a09d7a61df5930eab434d46c185ceb8580ca9c8c2d7960786f1bbe83fc81565b34801561039257600080fd5b50610350610b8f565b3480156103a757600080fd5b506103506103b636600461499e565b610bc8565b3480156103c757600080fd5b506102f06103d6366004614a14565b610e82565b3480156103e757600080fd5b506101db60045481565b3480156103fd57600080fd5b50610350610fb4565b610310610414366004614adf565b610fc8565b34801561042557600080fd5b5060015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e5565b34801561047157600080fd5b506101db60085481565b34801561048757600080fd5b50610350610496366004614afb565b61102c565b6104ae6104a9366004614bbc565b61103b565b6040516101e59493929190614c3d565b3480156104ca57600080fd5b5061029f6104d9366004614c8a565b600098975050505050505050565b3480156104f357600080fd5b50610440610502366004614528565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6104ae610538366004614d45565b61111e565b34801561054957600080fd5b50610350610558366004614528565b611173565b34801561056957600080fd5b506101db610578366004614db1565b60006020819052908152604090205481565b34801561059657600080fd5b5061020e6105a5366004614dcc565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260066020908152604080832093909416825291909152205460ff1690565b3480156105ec57600080fd5b5061029f6105fb366004614df6565b6111c8565b34801561060c57600080fd5b5061035061061b366004614e6e565b611209565b34801561062c57600080fd5b5061035061063b366004614db1565b6112ad565b600073ffffffffffffffffffffffffffffffffffffffff83166106c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f62616c616e63654f66286164647265737328302929000000000000000000000060448201526064015b60405180910390fd5b50600081815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020545b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806106f657506106f682611364565b60606007805461076190614ed3565b80601f016020809104026020016040519081016040528092919081815260200182805461078d90614ed3565b80156107da5780601f106107af576101008083540402835291602001916107da565b820191906000526020600020905b8154815290600101906020018083116107bd57829003601f168201915b50505050509050919050565b60006002600a540361081957507f150b7a020000000000000000000000000000000000000000000000000000000061081d565b5060005b95945050505050565b60608167ffffffffffffffff81111561084157610841614736565b60405190808252806020026020018201604052801561086a578160200160208202803683370190505b50905060008267ffffffffffffffff81111561088857610888614736565b6040519080825280602002602001820160405280156108b1578160200160208202803683370190505b50905060005b838110156109a75760006108cb8287614f4f565b604080513360601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602080830191909152603480830185905283518084039091018152605490920190925280519101209091508184848151811061093357610933614f62565b6020026020010181815250508085848151811061095257610952614f62565b6020908102919091018101919091526000918252600390526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055506109a081614f91565b90506108b7565b503373ffffffffffffffffffffffffffffffffffffffff167f69f4cd026fceaa224d78e03ab43e6c20f9d54eae52f88e23573a5ac5bc9c4cd783836040516109f0929190614fc9565b60405180910390a25092915050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600660209081526040808320338452909152812054819081908190859060ff16610a71576040517fb8e05a7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040516001815273ffffffffffffffffffffffffffffffffffffffff87169033907f6eb0debd3c0f189ccf977863c81ba259fe0eb500503c3f78777771a68bf8e4899060200160405180910390a3610ac98787611447565b929a91995097509095509350505050565b610ae2611563565b73ffffffffffffffffffffffffffffffffffffffff8516331480610b0b5750610b0b85336105a5565b610b71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6e6f74206f776e6572206e6f7220617070726f7665640000000000000000000060448201526064016106bb565b610b7e85858585856115d4565b610b886001600255565b5050505050565b610b9761189f565b6000600481905560405133917f6a48aa731704180ea30bb9c36eb6e31f04c276642647d76c25f20caaa50f884791a2565b600454600114610c34576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5065726d6974205369676e61747572652044697361626c65640000000000000060448201526064016106bb565b42841015610c4157600080fd5b73ffffffffffffffffffffffffffffffffffffffff8716600090815260208190526040812080547f50be42a09d7a61df5930eab434d46c185ceb8580ca9c8c2d7960786f1bbe83fc917f7aea62eb64c80d70d6f7fceb0f80c4901e6585fbeca774ca10ae898d1af3af67918b918b918b9187610cbc83614f91565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff948516908601529290911660608401521515608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001610d5f9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610de8573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610e6357508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610e6c57600080fd5b610e77898989611920565b505050505050505050565b60608151835114610eef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f6163636f756e74732e6c656e67746820213d206964732e6c656e67746800000060448201526064016106bb565b6000835167ffffffffffffffff811115610f0b57610f0b614736565b604051908082528060200260200182016040528015610f34578160200160208202803683370190505b50905060005b8451811015610fac57610f7f858281518110610f5857610f58614f62565b6020026020010151858381518110610f7257610f72614f62565b6020026020010151610640565b828281518110610f9157610f91614f62565b6020908102919091010152610fa581614f91565b9050610f3a565b509392505050565b610fbc61189f565b610fc66000611a4d565b565b60008060008060013373ffffffffffffffffffffffffffffffffffffffff167f1ae805a3773324a90592b8a87b99151f93a76c32229b924c6a8199c2acda49f960405160405180910390a361101d8533611447565b93509350935093509193509193565b611037338383611920565b5050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600660209081526040808320338452909152902054606090819081908190859060ff166110b0576040517fb8e05a7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405189815273ffffffffffffffffffffffffffffffffffffffff87169033907f6eb0debd3c0f189ccf977863c81ba259fe0eb500503c3f78777771a68bf8e4899060200160405180910390a361110a8a8a8a8a8a611ac4565b929d919c509a509098509650505050505050565b604051606090819081908190879033907f1ae805a3773324a90592b8a87b99151f93a76c32229b924c6a8199c2acda49f990600090a36111618888888833611ac4565b929b919a509850909650945050505050565b61117b61189f565b806107d0111561118a57600080fd5b6008546040513381528291907f418da9cf3f702319d14530681ec7bf242aeb71f4959c849ad3de431599b43cc49060200160405180910390a3600855565b60006002600954036111fb57507ff23a6e61000000000000000000000000000000000000000000000000000000006111ff565b5060005b9695505050505050565b611211611563565b73ffffffffffffffffffffffffffffffffffffffff851633148061123a575061123a85336105a5565b6112a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6e6f74206f776e6572206e6f7220617070726f7665640000000000000000000060448201526064016106bb565b610b7e8585858585611e10565b6112b561189f565b73ffffffffffffffffffffffffffffffffffffffff8116611358576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106bb565b61136181611a4d565b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fd9b67a260000000000000000000000000000000000000000000000000000000014806113f757507fffffffff0000000000000000000000000000000000000000000000000000000082167f0e89341c00000000000000000000000000000000000000000000000000000000145b806106f657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146106f6565b600080808034156114ce57505060405134808252600093508392507f97a93559a75ccc959fc63520f07017eed6d512f74e4214a7680ec0eefb5db5b49173ffffffffffffffffffffffffffffffffffffffff8616907f55f83f01c0664bd25aad3d627119249b43acc06873e584be1db2ddd46ca3bdeb9060200160405180910390a2611538565b6000806114e86114e3368a90038a018a614fee565b611feb565b909250905060006115088383611503368d90038d018d614fee565b61200f565b905061152a61151c368b90038b018b614fee565b8484848d606001358d612203565b929950909750955093505050505b8215611549576115498585856124ba565b801561155a5761155a8583836125f4565b92959194509250565b60028054036115ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106bb565b60028055565b815183511461163f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f6964732e6c656e67746820213d20616d6f756e74732e6c656e6774680000000060448201526064016106bb565b73ffffffffffffffffffffffffffffffffffffffff84166116bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016106bb565b3360005b845181101561180a5760008582815181106116dd576116dd614f62565b6020026020010151905060008583815181106116fb576116fb614f62565b602090810291909101810151600084815260058352604080822073ffffffffffffffffffffffffffffffffffffffff8e1683529093529190912054909150818110156117a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f696e73756666696369656e742062616c616e636500000000000000000000000060448201526064016106bb565b600083815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff8e8116855292528083208585039055908b168252812080548492906117ef908490614f4f565b925050819055505050508061180390614f91565b90506116c0565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611881929190614fc9565b60405180910390a461189781878787878761264a565b505050505050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610fc6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106bb565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036119b5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f53657420617070726f76616c20666f722073656c66000000000000000000000060448201526064016106bb565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526006602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b606080808060008667ffffffffffffffff811115611ae457611ae4614736565b604051908082528060200260200182016040528015611b2957816020015b6040805180820190915260008082526020820152815260200190600190039081611b025790505b5090508660005b81811015611b8b5760405180604001604052808b8b84818110611b5557611b55614f62565b9050602002013581526020016000815250838281518110611b7857611b78614f62565b6020908102919091010152600101611b30565b503415611c0e57611bbd827f97a93559a75ccc959fc63520f07017eed6d512f74e4214a7680ec0eefb5db5b434612888565b8673ffffffffffffffffffffffffffffffffffffffff167f55f83f01c0664bd25aad3d627119249b43acc06873e584be1db2ddd46ca3bdeb34604051611c0591815260200190565b60405180910390a25b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091528760005b8c811015611d28578d8d82818110611c5757611c57614f62565b905060a00201803603810190611c6d9190614fee565b9250600080611c7b85611feb565b915091506000611c8c83838861200f565b905060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff876060015103611ccd57611cc6898584612925565b9050611cd4565b5060608601515b600080600080611ce88b898989898f612203565b93509350935093506000831115611d0457611d048d85856129c5565b8015611d1557611d158d8383612888565b8860010198505050505050505050611c3d565b505050611d3482612a58565b835191995097509195509350600103611d8b57611d868785600081518110611d5e57611d5e614f62565b602002602001015185600081518110611d7957611d79614f62565b60200260200101516125f4565b611da0565b600184511115611da057611da0878585612b98565b8551600103611ded57611de88787600081518110611dc057611dc0614f62565b602002602001015187600081518110611ddb57611ddb614f62565b60200260200101516124ba565b611e02565b600186511115611e0257611e02878787612d1f565b505095509550955095915050565b73ffffffffffffffffffffffffffffffffffffffff8416611e8d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016106bb565b600083815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff89168452909152902054339083811015611f29576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f696e73756666696369656e742062616c616e636500000000000000000000000060448201526064016106bb565b600085815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff8b8116855292528083208785039055908816825281208054869290611f75908490614f4f565b9091555050604080518681526020810186905273ffffffffffffffffffffffffffffffffffffffff808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611fe2828888888888612f04565b50505050505050565b8051600090819080821a60088111156120065761200661505e565b94909350915050565b6000808460088111156120245761202461505e565b14806120415750600184600881111561203f5761203f61505e565b145b156120a45760408051606085901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602080830191909152600060348084019190915283518084039091018152605490920190925280519101205b90506121fc565b60028460088111156120b8576120b861505e565b14806120d5575060048460088111156120d3576120d361505e565b145b806120f1575060038460088111156120ef576120ef61505e565b145b8061210d5750600584600881111561210b5761210b61505e565b145b1561217057608082015160408051606086901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602080830191909152603480830194909452825180830390940184526054909101909152815191012061209d565b60068460088111156121845761218461505e565b03612194575060408101516121fc565b60078460088111156121a8576121a861505e565b036121b8575060208101516121fc565b60088460088111156121cc576121cc61505e565b146121d9576121d961508d565b507f97a93559a75ccc959fc63520f07017eed6d512f74e4214a7680ec0eefb5db5b45b9392505050565b6000808080600789600881111561221c5761221c61505e565b03612247578693508592508960400151915061224088858486898f6080015161308b565b90506124ad565b600689600881111561225b5761225b61505e565b03612286578960200151935086915085905061227f88858484898f608001516131bf565b92506124ad565b600089600881111561229a5761229a61505e565b036122bc575060009250829150859050846122b7888287856132e5565b6124ad565b60018960088111156122d0576122d061505e565b036122ed575085925084915060009050806122b788848787613432565b60028960088111156123015761230161505e565b036123615785600114612340576040517f63e95dfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009350600092508691508590506122b7888b6080015160001c87856135a8565b60038960088111156123755761237561505e565b036123d557856001146123b4576040517f63e95dfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b86935085925060009150600090506122b7888b6080015160001c87876136a3565b60048960088111156123e9576123e961505e565b036124105760009350600092508691508590506122b7888b6080015160001c838886613791565b60058960088111156124245761242461505e565b0361244b5786935085925060009150600090506122b7888b6080015160001c8588886138e2565b600889600881111561245f5761245f61505e565b14801561248b57507f97a93559a75ccc959fc63520f07017eed6d512f74e4214a7680ec0eefb5db5b487145b6124975761249761508d565b5085925084915060009050806124ad8386613a55565b9650965096509692505050565b73ffffffffffffffffffffffffffffffffffffffff83166124dd576124dd61508d565b600082815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902054339082811015612579576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f6275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016106bb565b600084815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff898116808652918452828520888703905582518981529384018890529092908616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6291015b60405180910390a45050505050565b73ffffffffffffffffffffffffffffffffffffffff83166126175761261761508d565b6000612624848484613b2a565b905061264481600086868660405180602001604052806000815250612f04565b50505050565b73ffffffffffffffffffffffffffffffffffffffff84163b15611897576040517fbc197c8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063bc197c81906126c190899089908890889088906004016150bc565b6020604051808303816000875af192505050801561271a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261271791810190615127565b60015b6127dd57612726615144565b806308c379a003612779575061273a615160565b80612745575061277b565b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106bb91906145af565b505b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f6e6f6e2d4552433131353552656365697665720000000000000000000000000060448201526064016106bb565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c810000000000000000000000000000000000000000000000000000000014611fe2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433131353552656365697665722072656a6563746564000000000000000060448201526064016106bb565b80807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff116128e2576040517f42b51b6000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006128ee8585613bd2565b90508285828151811061290357612903614f62565b602002602001015160200181815161291b9190615208565b9052505050505050565b6000600183600881111561293b5761293b61505e565b1480612958575060038360088111156129565761295661505e565b145b80612974575060058360088111156129725761297261505e565b145b806129905750600883600881111561298e5761298e61505e565b145b806129ac575060078360088111156129aa576129aa61505e565b145b156129bb5761209d8483613c45565b61209d8483613cb9565b80807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff11612a1f576040517f42b51b6000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612a2b8585613bd2565b905082858281518110612a4057612a40614f62565b602002602001015160200181815161291b9190615230565b606080606080600080612a6a87613d2e565b915091508167ffffffffffffffff811115612a8757612a87614736565b604051908082528060200260200182016040528015612ab0578160200160208202803683370190505b5095508167ffffffffffffffff811115612acc57612acc614736565b604051908082528060200260200182016040528015612af5578160200160208202803683370190505b5094508067ffffffffffffffff811115612b1157612b11614736565b604051908082528060200260200182016040528015612b3a578160200160208202803683370190505b5093508067ffffffffffffffff811115612b5657612b56614736565b604051908082528060200260200182016040528015612b7f578160200160208202803683370190505b509250612b8f8787878787613dda565b50509193509193565b73ffffffffffffffffffffffffffffffffffffffff8316612bbb57612bbb61508d565b8051825114612bcc57612bcc61508d565b3360005b8351811015612c8157828181518110612beb57612beb614f62565b602002602001015160056000868481518110612c0957612c09614f62565b6020026020010151815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612c6b9190614f4f565b90915550612c7a905081614f91565b9050612bd0565b508373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612cf9929190614fc9565b60405180910390a46126448160008686866040518060200160405280600081525061264a565b73ffffffffffffffffffffffffffffffffffffffff8316612d4257612d4261508d565b8051825114612d5357612d5361508d565b3360005b8351811015612e7e576000848281518110612d7457612d74614f62565b602002602001015190506000848381518110612d9257612d92614f62565b602090810291909101810151600084815260058352604080822073ffffffffffffffffffffffffffffffffffffffff8c168352909352919091205490915081811015612e3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f6275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016106bb565b600092835260056020908152604080852073ffffffffffffffffffffffffffffffffffffffff8b16865290915290922091039055612e7781614f91565b9050612d57565b50600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612ef6929190614fc9565b60405180910390a450505050565b73ffffffffffffffffffffffffffffffffffffffff84163b15611897576040517ff23a6e6100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063f23a6e6190612f7b9089908990889088908890600401615257565b6020604051808303816000875af1925050508015612fd4575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612fd191810190615127565b60015b612fe057612726615144565b7fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e610000000000000000000000000000000000000000000000000000000014611fe2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433131353552656365697665722072656a6563746564000000000000000060448201526064016106bb565b6000613098878786613f26565b6040517f3fc20d4f00000000000000000000000000000000000000000000000000000000815260048101879052602481018690526044810185905273ffffffffffffffffffffffffffffffffffffffff848116606483015260848201849052881690633fc20d4f9060a4016020604051808303816000875af1158015613122573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613146919061529c565b9050613153878683613f72565b6040805173ffffffffffffffffffffffffffffffffffffffff808a168252602082018490528516918101919091528490869088907fc6baad430667a9b3f12a9f115e0af95c8538e5e2595e248f2d068f6c93c6101e906060015b60405180910390a49695505050505050565b60006131cc878686613f72565b6040517fe92ebd3a00000000000000000000000000000000000000000000000000000000815260048101879052602481018690526044810185905273ffffffffffffffffffffffffffffffffffffffff84811660648301526084820184905288169063e92ebd3a9060a4016020604051808303816000875af1158015613256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327a919061529c565b9050613287878783613f26565b6040805173ffffffffffffffffffffffffffffffffffffffff808a168252602082018790528516918101919091528190869088907fff21d0dd1bae0672a5771fb6668afecf9485c8e6e82a7d2f1ee58a96277c630e906060016131ad565b8373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561336a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252613367918101906152b5565b60015b6133a0576040517f93bee3e100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806133ad8684613fb9565b90925090506133bc8482614034565b6133c887863085614063565b6040805183815260208101889052908101829052849073ffffffffffffffffffffffffffffffffffffffff80881691908a16907fd86e46c0b98ab82d234497fd7d7e31711dfa27764034b1763f3575c521f6ff94906060015b60405180910390a450505050505050565b8373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156134b7575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526134b4918101906152b5565b60015b6134ed576040517f93bee3e100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006134f88561413f565b9050600061350682876152d2565b90506000806135176012868561414f565b90925090506135268185614f4f565b93506135328685614034565b61353d8988846141e8565b60408051838152602081018a9052908101859052869073ffffffffffffffffffffffffffffffffffffffff808a1691908c16907f62a282d05dd7f7ec454ec1e3ebe4c23b911f1fedecfa6f241f4b663896e592cf9060600160405180910390a4505050505050505050565b6002600a556040517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152306024830152604482018590528516906342842e0e90606401600060405180830381600087803b15801561362357600080fd5b505af1158015613637573d6000803e3d6000fd5b505050506001600a81905550808273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f7672c4a63cc0b66a7449c3e1051810a6f128034121aa8314de5b008254b2389f86604051612ef691815260200190565b6040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152604482018590528516906342842e0e90606401600060405180830381600087803b15801561371957600080fd5b505af115801561372d573d6000803e3d6000fd5b50505050808273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fe67983c06675e145002b5c4392d05e59790fd0cc13fb15ed1a6201f9d78e17ef86604051612ef691815260200190565b3073ffffffffffffffffffffffffffffffffffffffff8616036137e0576040517f73a7f55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60026009556040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152306024830152604482018690526064820185905260a06084830152600060a483015286169063f242432a9060c401600060405180830381600087803b15801561387057600080fd5b505af1158015613884573d6000803e3d6000fd5b5050600160095550506040805185815260208101859052829173ffffffffffffffffffffffffffffffffffffffff80861692908916917f9e8d41f891cc91b6fbf90fec18d6464e22e7d95db0113fefec8c8e6815c9608491016125e5565b3073ffffffffffffffffffffffffffffffffffffffff861603613931576040517fe69dd17800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061393c8461413f565b9050600061394a82866152d2565b90506139568383614034565b6040517ff242432a00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8581166024830152604482018890526064820183905260a06084830152600060a483015288169063f242432a9060c401600060405180830381600087803b1580156139e157600080fd5b505af11580156139f5573d6000803e3d6000fd5b5050604080518981526020810189905290810185905285925073ffffffffffffffffffffffffffffffffffffffff80881692508a16907f285f7151736e0529314aabab94f541d8837226ed08c744dbe86bb81c76b13b3d90606001613421565b6000613a608361413f565b9050613a8c7f97a93559a75ccc959fc63520f07017eed6d512f74e4214a7680ec0eefb5db5b482614034565b6000613a9882856152d2565b60405190915073ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083906000818181858888f19350505050158015613ade573d6000803e3d6000fd5b508273ffffffffffffffffffffffffffffffffffffffff1682827fa99566a5bc143aef6dfe90cacd94612c00db3ce770f4687cccc7146a841aeb4260405160405180910390a450505050565b600082815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281208054339184918490613b6c908490614f4f565b9091555050604080518581526020810185905273ffffffffffffffffffffffffffffffffffffffff80881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4949350505050565b60005b8251811015613c135781838281518110613bf157613bf1614f62565b60200260200101516000015103156106f657613c0c81614f91565b9050613bd5565b6040517fe6e53d7f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080613c528484613bd2565b90506000848281518110613c6857613c68614f62565b60200260200101516020015190506000811215613cb1576040517fb11f012b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b600080613cc68484613bd2565b90506000848281518110613cdc57613cdc614f62565b60200260200101516020015190506000811315613d25576040517fa91f3c8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61081d816152e5565b6000806000805b8451811015613daf576000858281518110613d5257613d52614f62565b60200260200101516020015190506000811315613d7957613d7285614f91565b9450613d9e565b6000811215613d9257613d8b84614f91565b9350613d9e565b613d9b83614f91565b92505b50613da881614f91565b9050613d35565b50835181613dbd8486614f4f565b613dc79190614f4f565b14613dd457613dd461508d565b50915091565b60008060005b8751811015613f09576000888281518110613dfd57613dfd614f62565b60200260200101516020015190506000811315613e8057888281518110613e2657613e26614f62565b602002602001015160000151888581518110613e4457613e44614f62565b60200260200101818152505080878581518110613e6357613e63614f62565b6020908102919091010152613e79600185614f4f565b9350613ef8565b6000811215613ef857888281518110613e9b57613e9b614f62565b602002602001015160000151868481518110613eb957613eb9614f62565b6020908102919091010152613ecd816152e5565b858481518110613edf57613edf614f62565b6020908102919091010152613ef5600184614f4f565b92505b50613f0281614f91565b9050613de0565b50855182148015613f1a5750835181145b611fe257611fe261508d565b60008281526003602052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614158015613f5d5750600081115b15613f6d57612644838383613b2a565b505050565b60008281526003602052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614158015613fa95750600081115b15613f6d57613f6d8383836124ba565b6000806000613fca6012858761414f565b9093509050801561402757613fe0600184614f4f565b9250600080613ff18660128761414f565b91509150806000146140055761400561508d565b8682116140145761401461508d565b61401e87836152d2565b9350505061402c565b600091505b509250929050565b801561103757613f6d61405c60015473ffffffffffffffffffffffffffffffffffffffff1690565b8383613b2a565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526126449085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261423e565b6000600854826106f6919061534c565b6000808360ff168560ff160361416a575081905060006141e0565b8360ff168560ff1610156141aa5760006141848686615360565b6141929060ff16600a615491565b905061419e818561549d565b925060009150506141e0565b60006141b68587615360565b6141c49060ff16600a615491565b90506141d0818561534c565b92506141dc81856154b4565b9150505b935093915050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052613f6d9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016140bd565b60006142a0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661434d9092919063ffffffff16565b90508051600014806142c15750808060200190518101906142c191906154c8565b613f6d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106bb565b6060613cb18484600085856000808673ffffffffffffffffffffffffffffffffffffffff16858760405161438191906154e5565b60006040518083038185875af1925050503d80600081146143be576040519150601f19603f3d011682016040523d82523d6000602084013e6143c3565b606091505b50915091506143d4878383876143df565b979650505050505050565b6060831561447557825160000361446e5773ffffffffffffffffffffffffffffffffffffffff85163b61446e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106bb565b5081613cb1565b613cb183838151156127455781518083602001fd5b803573ffffffffffffffffffffffffffffffffffffffff811681146144ae57600080fd5b919050565b600080604083850312156144c657600080fd5b6144cf8361448a565b946020939093013593505050565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461136157600080fd5b60006020828403121561451d57600080fd5b81356121fc816144dd565b60006020828403121561453a57600080fd5b5035919050565b60005b8381101561455c578181015183820152602001614544565b50506000910152565b6000815180845261457d816020860160208601614541565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006121fc6020830184614565565b60008083601f8401126145d457600080fd5b50813567ffffffffffffffff8111156145ec57600080fd5b60208301915083602082850101111561460457600080fd5b9250929050565b60008060008060006080868803121561462357600080fd5b61462c8661448a565b945061463a6020870161448a565b935060408601359250606086013567ffffffffffffffff81111561465d57600080fd5b614669888289016145c2565b969995985093965092949392505050565b6000806040838503121561468d57600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b838110156146cc578151875295820195908201906001016146b0565b509495945050505050565b6020815260006121fc602083018461469c565b600060a082840312156146fc57600080fd5b50919050565b60008060c0838503121561471557600080fd5b61471f84846146ea565b915061472d60a0840161448a565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116810181811067ffffffffffffffff821117156147a9576147a9614736565b6040525050565b600067ffffffffffffffff8211156147ca576147ca614736565b5060051b60200190565b600082601f8301126147e557600080fd5b813560206147f2826147b0565b6040516147ff8282614765565b83815260059390931b850182019282810191508684111561481f57600080fd5b8286015b8481101561483a5780358352918301918301614823565b509695505050505050565b600082601f83011261485657600080fd5b813567ffffffffffffffff81111561487057614870614736565b6040516148a560207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160182614765565b8181528460208386010111156148ba57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a086880312156148ef57600080fd5b6148f88661448a565b94506149066020870161448a565b9350604086013567ffffffffffffffff8082111561492357600080fd5b61492f89838a016147d4565b9450606088013591508082111561494557600080fd5b61495189838a016147d4565b9350608088013591508082111561496757600080fd5b5061497488828901614845565b9150509295509295909350565b801515811461136157600080fd5b60ff8116811461136157600080fd5b600080600080600080600060e0888a0312156149b957600080fd5b6149c28861448a565b96506149d06020890161448a565b955060408801356149e081614981565b94506060880135935060808801356149f78161498f565b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215614a2757600080fd5b823567ffffffffffffffff80821115614a3f57600080fd5b818501915085601f830112614a5357600080fd5b81356020614a60826147b0565b604051614a6d8282614765565b83815260059390931b8501820192828101915089841115614a8d57600080fd5b948201945b83861015614ab257614aa38661448a565b82529482019490820190614a92565b96505086013592505080821115614ac857600080fd5b50614ad5858286016147d4565b9150509250929050565b600060a08284031215614af157600080fd5b6121fc83836146ea565b60008060408385031215614b0e57600080fd5b614b178361448a565b91506020830135614b2781614981565b809150509250929050565b60008083601f840112614b4457600080fd5b50813567ffffffffffffffff811115614b5c57600080fd5b60208301915083602060a08302850101111561460457600080fd5b60008083601f840112614b8957600080fd5b50813567ffffffffffffffff811115614ba157600080fd5b6020830191508360208260051b850101111561460457600080fd5b600080600080600060608688031215614bd457600080fd5b853567ffffffffffffffff80821115614bec57600080fd5b614bf889838a01614b32565b90975095506020880135915080821115614c1157600080fd5b50614c1e88828901614b77565b9094509250614c3190506040870161448a565b90509295509295909350565b608081526000614c50608083018761469c565b8281036020840152614c62818761469c565b90508281036040840152614c76818661469c565b905082810360608401526143d4818561469c565b60008060008060008060008060a0898b031215614ca657600080fd5b614caf8961448a565b9750614cbd60208a0161448a565b9650604089013567ffffffffffffffff80821115614cda57600080fd5b614ce68c838d01614b77565b909850965060608b0135915080821115614cff57600080fd5b614d0b8c838d01614b77565b909650945060808b0135915080821115614d2457600080fd5b50614d318b828c016145c2565b999c989b5096995094979396929594505050565b60008060008060408587031215614d5b57600080fd5b843567ffffffffffffffff80821115614d7357600080fd5b614d7f88838901614b32565b90965094506020870135915080821115614d9857600080fd5b50614da587828801614b77565b95989497509550505050565b600060208284031215614dc357600080fd5b6121fc8261448a565b60008060408385031215614ddf57600080fd5b614de88361448a565b915061472d6020840161448a565b60008060008060008060a08789031215614e0f57600080fd5b614e188761448a565b9550614e266020880161448a565b94506040870135935060608701359250608087013567ffffffffffffffff811115614e5057600080fd5b614e5c89828a016145c2565b979a9699509497509295939492505050565b600080600080600060a08688031215614e8657600080fd5b614e8f8661448a565b9450614e9d6020870161448a565b93506040860135925060608601359150608086013567ffffffffffffffff811115614ec757600080fd5b61497488828901614845565b600181811c90821680614ee757607f821691505b6020821081036146fc577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156106f6576106f6614f20565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614fc257614fc2614f20565b5060010190565b604081526000614fdc604083018561469c565b828103602084015261081d818561469c565b600060a0828403121561500057600080fd5b60405160a0810181811067ffffffffffffffff8211171561502357615023614736565b806040525082358152602083013560208201526040830135604082015260608301356060820152608083013560808201528091505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525060a060408301526150f560a083018661469c565b8281036060840152615107818661469c565b9050828103608084015261511b8185614565565b98975050505050505050565b60006020828403121561513957600080fd5b81516121fc816144dd565b600060033d111561515d5760046000803e5060005160e01c5b90565b600060443d101561516e5790565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc803d016004833e81513d67ffffffffffffffff81602484011181841117156151bc57505050505090565b82850191508151818111156151d45750505050505090565b843d87010160208285010111156151ee5750505050505090565b6151fd60208286010187614765565b509095945050505050565b808201828112600083128015821682158216171561522857615228614f20565b505092915050565b818103600083128015838313168383128216171561525057615250614f20565b5092915050565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015283606083015260a060808301526143d460a0830184614565565b6000602082840312156152ae57600080fd5b5051919050565b6000602082840312156152c757600080fd5b81516121fc8161498f565b818103818111156106f6576106f6614f20565b60007f8000000000000000000000000000000000000000000000000000000000000000820361531657615316614f20565b5060000390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261535b5761535b61531d565b500490565b60ff82811682821603908111156106f6576106f6614f20565b600181815b8085111561402c57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156153b8576153b8614f20565b808516156153c557918102915b93841c939080029061537e565b6000826153e1575060016106f6565b816153ee575060006106f6565b8160018114615404576002811461540e5761542a565b60019150506106f6565b60ff84111561541f5761541f614f20565b50506001821b6106f6565b5060208310610133831016604e8410600b841016171561544d575081810a6106f6565b6154578383615379565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561548957615489614f20565b029392505050565b60006121fc83836153d2565b80820281158282048414176106f6576106f6614f20565b6000826154c3576154c361531d565b500690565b6000602082840312156154da57600080fd5b81516121fc81614981565b600082516154f7818460208701614541565b919091019291505056fea26469706673582212208ee057b7cc4c41ee2a644fde9e42bd16120bcb004dab8cfed77d427b4e4223f564736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : uri_ (string):
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.