Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
17309196 | 502 days ago | Contract Creation | 0 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
LSSVMPairERC1155ETH
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {IRoyaltyEngineV1} from "manifoldxyz/IRoyaltyEngineV1.sol"; import {LSSVMPair} from "../LSSVMPair.sol"; import {LSSVMPairETH} from "../LSSVMPairETH.sol"; import {LSSVMPairERC1155} from "./LSSVMPairERC1155.sol"; import {ILSSVMPairFactoryLike} from "../ILSSVMPairFactoryLike.sol"; /** * @title An ERC1155 pair where the token is an ETH * @author boredGenius, 0xmons, 0xCygaar */ contract LSSVMPairERC1155ETH is LSSVMPairERC1155, LSSVMPairETH { uint256 internal constant IMMUTABLE_PARAMS_LENGTH = 93; constructor(IRoyaltyEngineV1 royaltyEngine) LSSVMPair(royaltyEngine) {} /** * Public functions */ /** * @inheritdoc LSSVMPair */ function pairVariant() public pure virtual override returns (ILSSVMPairFactoryLike.PairVariant) { return ILSSVMPairFactoryLike.PairVariant.ERC1155_ETH; } /** * Internal functions */ /** * @inheritdoc LSSVMPair * @dev see LSSVMPairCloner for params length calculation */ function _immutableParamsLength() internal pure override returns (uint256) { return IMMUTABLE_PARAMS_LENGTH; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * @dev Lookup engine interface */ interface IRoyaltyEngineV1 is IERC165 { /** * Get the royalty for a given token (address, id) and value amount. Does not cache the bps/amounts. Caches the spec for a given token address * * @param tokenAddress - The address of the token * @param tokenId - The id of the token * @param value - The value you wish to get the royalty of * * returns Two arrays of equal length, royalty recipients and the corresponding amount each recipient should get */ function getRoyalty(address tokenAddress, uint256 tokenId, uint256 value) external returns (address payable[] memory recipients, uint256[] memory amounts); /** * View only version of getRoyalty * * @param tokenAddress - The address of the token * @param tokenId - The id of the token * @param value - The value you wish to get the royalty of * * returns Two arrays of equal length, royalty recipients and the corresponding amount each recipient should get */ function getRoyaltyView(address tokenAddress, uint256 tokenId, uint256 value) external view returns (address payable[] memory recipients, uint256[] memory amounts); }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {IRoyaltyEngineV1} from "manifoldxyz/IRoyaltyEngineV1.sol"; import {ERC20} from "solmate/tokens/ERC20.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol"; import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol"; import {LSSVMRouter} from "./LSSVMRouter.sol"; import {ICurve} from "./bonding-curves/ICurve.sol"; import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol"; import {CurveErrorCodes} from "./bonding-curves/CurveErrorCodes.sol"; import {IOwnershipTransferReceiver} from "./lib/IOwnershipTransferReceiver.sol"; import {OwnableWithTransferCallback} from "./lib/OwnableWithTransferCallback.sol"; /** * @title The base contract for an NFT/TOKEN AMM pair * @author boredGenius, 0xmons, 0xCygaar * @notice This implements the core swap logic from NFT to TOKEN */ abstract contract LSSVMPair is OwnableWithTransferCallback, ERC721Holder, ERC1155Holder { /** * Library usage ** */ using Address for address; /** * Enums ** */ enum PoolType { TOKEN, NFT, TRADE } /** * Constants ** */ /** * @dev 50%, must <= 1 - MAX_PROTOCOL_FEE (set in LSSVMPairFactory) */ uint256 internal constant MAX_TRADE_FEE = 0.5e18; /** * Immutable params ** */ /** * @notice Sudoswap Royalty Engine */ IRoyaltyEngineV1 public immutable ROYALTY_ENGINE; /** * Storage variables ** */ /** * @dev This is generally used to mean the immediate sell price for the next marginal NFT. * However, this should NOT be assumed, as bonding curves may use spotPrice in different ways. * Use getBuyNFTQuote and getSellNFTQuote for accurate pricing info. */ uint128 public spotPrice; /** * @notice The parameter for the pair's bonding curve. * Units and meaning are bonding curve dependent. */ uint128 public delta; /** * @notice The spread between buy and sell prices, set to be a multiplier we apply to the buy price * Fee is only relevant for TRADE pools. Units are in base 1e18. */ uint96 public fee; /** * @notice The address that swapped assets are sent to. * For TRADE pools, assets are always sent to the pool, so this is used to track trade fee. * If set to address(0), will default to owner() for NFT and TOKEN pools. */ address payable internal assetRecipient; /** * Events */ event SwapNFTInPair(uint256 amountOut, uint256[] ids); event SwapNFTInPair(uint256 amountOut, uint256 numNFTs); event SwapNFTOutPair(uint256 amountIn, uint256[] ids); event SwapNFTOutPair(uint256 amountIn, uint256 numNFTs); event SpotPriceUpdate(uint128 newSpotPrice); event TokenDeposit(uint256 amount); event TokenWithdrawal(uint256 amount); event NFTWithdrawal(uint256[] ids); event NFTWithdrawal(uint256 numNFTs); event DeltaUpdate(uint128 newDelta); event FeeUpdate(uint96 newFee); event AssetRecipientChange(address indexed a); /** * Errors */ error LSSVMPair__NotRouter(); error LSSVMPair__CallFailed(); error LSSVMPair__InvalidDelta(); error LSSVMPair__WrongPoolType(); error LSSVMPair__OutputTooSmall(); error LSSVMPair__ZeroSwapAmount(); error LSSVMPair__RoyaltyTooLarge(); error LSSVMPair__TradeFeeTooLarge(); error LSSVMPair__InvalidSpotPrice(); error LSSVMPair__TargetNotAllowed(); error LSSVMPair__NftNotTransferred(); error LSSVMPair__AlreadyInitialized(); error LSSVMPair__FunctionNotAllowed(); error LSSVMPair__DemandedInputTooLarge(); error LSSVMPair__NonTradePoolWithTradeFee(); error LSSVMPair__BondingCurveError(CurveErrorCodes.Error error); constructor(IRoyaltyEngineV1 royaltyEngine) { ROYALTY_ENGINE = royaltyEngine; } /** * @notice Called during pair creation to set initial parameters * @dev Only called once by factory to initialize. * We verify this by making sure that the current owner is address(0). * The Ownable library we use disallows setting the owner to be address(0), so this condition * should only be valid before the first initialize call. * @param _owner The owner of the pair * @param _assetRecipient The address that will receive the TOKEN or NFT sent to this pair during swaps. NOTE: If set to address(0), they will go to the pair itself. * @param _delta The initial delta of the bonding curve * @param _fee The initial % fee taken, if this is a trade pair * @param _spotPrice The initial price to sell an asset into the pair */ function initialize( address _owner, address payable _assetRecipient, uint128 _delta, uint96 _fee, uint128 _spotPrice ) external { if (owner() != address(0)) revert LSSVMPair__AlreadyInitialized(); __Ownable_init(_owner); ICurve _bondingCurve = bondingCurve(); PoolType _poolType = poolType(); if (_poolType != PoolType.TRADE) { if (_fee != 0) revert LSSVMPair__NonTradePoolWithTradeFee(); } else { if (_fee > MAX_TRADE_FEE) revert LSSVMPair__TradeFeeTooLarge(); fee = _fee; } assetRecipient = _assetRecipient; if (!_bondingCurve.validateDelta(_delta)) revert LSSVMPair__InvalidDelta(); if (!_bondingCurve.validateSpotPrice(_spotPrice)) revert LSSVMPair__InvalidSpotPrice(); delta = _delta; spotPrice = _spotPrice; } /** * External state-changing functions */ /** * @notice Sends token to the pair in exchange for a specific set of NFTs * @dev To compute the amount of token to send, call bondingCurve.getBuyInfo * This swap is meant for users who want specific IDs. Also higher chance of * reverting if some of the specified IDs leave the pool before the swap goes through. * @param nftIds The list of IDs of the NFTs to purchase * @param maxExpectedTokenInput The maximum acceptable cost from the sender. If the actual * amount is greater than this value, the transaction will be reverted. * @param nftRecipient The recipient of the NFTs * @param isRouter True if calling from LSSVMRouter, false otherwise. Not used for ETH pairs. * @param routerCaller If isRouter is true, ERC20 tokens will be transferred from this address. Not used for ETH pairs. * @return - The amount of token used for purchase */ function swapTokenForSpecificNFTs( uint256[] calldata nftIds, uint256 maxExpectedTokenInput, address nftRecipient, bool isRouter, address routerCaller ) external payable virtual returns (uint256); /** * @notice Sends a set of NFTs to the pair in exchange for token * @dev To compute the amount of token to that will be received, call bondingCurve.getSellInfo. * @param nftIds The list of IDs of the NFTs to sell to the pair * @param minExpectedTokenOutput The minimum acceptable token received by the sender. If the actual * amount is less than this value, the transaction will be reverted. * @param tokenRecipient The recipient of the token output * @param isRouter True if calling from LSSVMRouter, false otherwise. Not used for * ETH pairs. * @param routerCaller If isRouter is true, ERC20 tokens will be transferred from this address. Not used for * ETH pairs. * @return outputAmount The amount of token received */ function swapNFTsForToken( uint256[] calldata nftIds, uint256 minExpectedTokenOutput, address payable tokenRecipient, bool isRouter, address routerCaller ) external virtual returns (uint256 outputAmount); /** * View functions */ /** * @dev Used as read function to query the bonding curve for buy pricing info * @param numNFTs The number of NFTs to buy from the pair */ function getBuyNFTQuote(uint256 assetId, uint256 numNFTs) external view returns ( CurveErrorCodes.Error error, uint256 newSpotPrice, uint256 newDelta, uint256 inputAmount, uint256 protocolFee, uint256 royaltyAmount ) { uint256 tradeFee; (error, newSpotPrice, newDelta, inputAmount, tradeFee, protocolFee) = bondingCurve().getBuyInfo(spotPrice, delta, numNFTs, fee, factory().protocolFeeMultiplier()); if (numNFTs != 0) { // Calculate the inputAmount minus tradeFee and protocolFee uint256 inputAmountMinusFees = inputAmount - tradeFee - protocolFee; // Compute royalties (,, royaltyAmount) = calculateRoyaltiesView(assetId, inputAmountMinusFees); inputAmount += royaltyAmount; } } /** * @dev Used as read function to query the bonding curve for sell pricing info including royalties * @param numNFTs The number of NFTs to sell to the pair */ function getSellNFTQuote(uint256 assetId, uint256 numNFTs) external view returns ( CurveErrorCodes.Error error, uint256 newSpotPrice, uint256 newDelta, uint256 outputAmount, uint256 protocolFee, uint256 royaltyAmount ) { (error, newSpotPrice, newDelta, outputAmount, /* tradeFee */, protocolFee) = bondingCurve().getSellInfo(spotPrice, delta, numNFTs, fee, factory().protocolFeeMultiplier()); if (numNFTs != 0) { // Compute royalties (,, royaltyAmount) = calculateRoyaltiesView(assetId, outputAmount); // Deduct royalties from outputAmount unchecked { // Safe because we already require outputAmount >= royaltyAmount in _calculateRoyalties() outputAmount -= royaltyAmount; } } } /** * @notice Returns the pair's variant (Pair uses ETH or ERC20) */ function pairVariant() public pure virtual returns (ILSSVMPairFactoryLike.PairVariant); function factory() public pure returns (ILSSVMPairFactoryLike _factory) { uint256 paramsLength = _immutableParamsLength(); assembly { _factory := shr(0x60, calldataload(sub(calldatasize(), paramsLength))) } } /** * @notice Returns the type of bonding curve that parameterizes the pair */ function bondingCurve() public pure returns (ICurve _bondingCurve) { uint256 paramsLength = _immutableParamsLength(); assembly { _bondingCurve := shr(0x60, calldataload(add(sub(calldatasize(), paramsLength), 20))) } } /** * @notice Returns the address of NFT collection that parameterizes the pair */ function nft() public pure returns (address _nft) { uint256 paramsLength = _immutableParamsLength(); assembly { _nft := shr(0x60, calldataload(add(sub(calldatasize(), paramsLength), 40))) } } /** * @notice Returns the pair's type (TOKEN/NFT/TRADE) */ function poolType() public pure returns (PoolType _poolType) { uint256 paramsLength = _immutableParamsLength(); assembly { _poolType := shr(0xf8, calldataload(add(sub(calldatasize(), paramsLength), 60))) } } /** * @notice Returns the address that receives assets when a swap is done with this pair * Can be set to another address by the owner, but has no effect on TRADE pools * If set to address(0), defaults to owner() for NFT/TOKEN pools */ function getAssetRecipient() public view returns (address payable) { // TRADE pools will always receive the asset themselves if (poolType() == PoolType.TRADE) { return payable(address(this)); } address payable _assetRecipient = assetRecipient; // Otherwise, we return the recipient if it's been set // Or, we replace it with owner() if it's address(0) if (_assetRecipient == address(0)) { return payable(owner()); } return _assetRecipient; } /** * @notice Returns the address that receives trade fees when a swap is done with this pair * Only relevant for TRADE pools * If set to address(0), defaults to the pair itself */ function getFeeRecipient() public view returns (address payable _feeRecipient) { _feeRecipient = assetRecipient; if (_feeRecipient == address(0)) { _feeRecipient = payable(address(this)); } } /** * Internal functions */ /** * @notice Calculates the amount needed to be sent into the pair for a buy and adjusts spot price or delta if necessary * @param numNFTs The amount of NFTs to purchase from the pair * @param _bondingCurve The bonding curve to use for price calculation * @param _factory The factory to use for protocol fee lookup * @return tradeFee The amount of tokens to send as trade fee * @return protocolFee The amount of tokens to send as protocol fee * @return inputAmount The amount of tokens total tokens receive */ function _calculateBuyInfoAndUpdatePoolParams(uint256 numNFTs, ICurve _bondingCurve, ILSSVMPairFactoryLike _factory) internal returns (uint256 tradeFee, uint256 protocolFee, uint256 inputAmount) { CurveErrorCodes.Error error; // Save on 2 SLOADs by caching uint128 currentSpotPrice = spotPrice; uint128 currentDelta = delta; uint128 newDelta; uint128 newSpotPrice; (error, newSpotPrice, newDelta, inputAmount, tradeFee, protocolFee) = _bondingCurve.getBuyInfo(currentSpotPrice, currentDelta, numNFTs, fee, _factory.protocolFeeMultiplier()); // Revert if bonding curve had an error if (error != CurveErrorCodes.Error.OK) { revert LSSVMPair__BondingCurveError(error); } // Consolidate writes to save gas if (currentSpotPrice != newSpotPrice || currentDelta != newDelta) { spotPrice = newSpotPrice; delta = newDelta; } // Emit spot price update if it has been updated if (currentSpotPrice != newSpotPrice) { emit SpotPriceUpdate(newSpotPrice); } // Emit delta update if it has been updated if (currentDelta != newDelta) { emit DeltaUpdate(newDelta); } } /** * @notice Calculates the amount needed to be sent by the pair for a sell and adjusts spot price or delta if necessary * @param numNFTs The amount of NFTs to send to the the pair * @param _bondingCurve The bonding curve to use for price calculation * @param _factory The factory to use for protocol fee lookup * @return protocolFee The amount of tokens to send as protocol fee * @return outputAmount The amount of tokens total tokens receive */ function _calculateSellInfoAndUpdatePoolParams( uint256 numNFTs, ICurve _bondingCurve, ILSSVMPairFactoryLike _factory ) internal returns (uint256 protocolFee, uint256 outputAmount) { CurveErrorCodes.Error error; // Save on 2 SLOADs by caching uint128 currentSpotPrice = spotPrice; uint128 currentDelta = delta; uint128 newSpotPrice; uint128 newDelta; (error, newSpotPrice, newDelta, outputAmount, /*tradeFee*/, protocolFee) = _bondingCurve.getSellInfo(currentSpotPrice, currentDelta, numNFTs, fee, _factory.protocolFeeMultiplier()); // Revert if bonding curve had an error if (error != CurveErrorCodes.Error.OK) { revert LSSVMPair__BondingCurveError(error); } // Consolidate writes to save gas if (currentSpotPrice != newSpotPrice || currentDelta != newDelta) { spotPrice = newSpotPrice; delta = newDelta; } // Emit spot price update if it has been updated if (currentSpotPrice != newSpotPrice) { emit SpotPriceUpdate(newSpotPrice); } // Emit delta update if it has been updated if (currentDelta != newDelta) { emit DeltaUpdate(newDelta); } } /** * @notice Pulls the token input of a trade from the trader (including all royalties and fees) * @param inputAmountExcludingRoyalty The amount of tokens to be sent, excluding the royalty (includes protocol fee) * @param royaltyAmounts The amounts of tokens to be sent as royalties * @param royaltyRecipients The recipients of the royalties * @param royaltyTotal The sum of all royaltyAmounts * @param tradeFeeAmount The amount of tokens to be sent as trade fee (if applicable) * @param isRouter Whether or not the caller is LSSVMRouter * @param routerCaller If called from LSSVMRouter, store the original caller * @param protocolFee The protocol fee to be paid */ function _pullTokenInputs( uint256 inputAmountExcludingRoyalty, uint256[] memory royaltyAmounts, address payable[] memory royaltyRecipients, uint256 royaltyTotal, uint256 tradeFeeAmount, bool isRouter, address routerCaller, uint256 protocolFee ) internal virtual; /** * @notice Sends excess tokens back to the caller (if applicable) * @dev Swap callers interacting with an ETH pair must be able to receive ETH (e.g. if the caller sends too much ETH) */ function _refundTokenToSender(uint256 inputAmount) internal virtual; /** * @notice Sends tokens to a recipient * @param tokenRecipient The address receiving the tokens * @param outputAmount The amount of tokens to send */ function _sendTokenOutput(address payable tokenRecipient, uint256 outputAmount) internal virtual; /** * @dev Used internally to grab pair parameters from calldata, see LSSVMPairCloner for technical details */ function _immutableParamsLength() internal pure virtual returns (uint256); /** * Royalty support functions */ function _calculateRoyalties(uint256 assetId, uint256 saleAmount) internal returns (address payable[] memory royaltyRecipients, uint256[] memory royaltyAmounts, uint256 royaltyTotal) { (address payable[] memory recipients, uint256[] memory amounts) = ROYALTY_ENGINE.getRoyalty(nft(), assetId, saleAmount); return _calculateRoyaltiesLogic(recipients, amounts, saleAmount); } /** * @dev Same as _calculateRoyalties, but uses getRoyaltyView to avoid state mutations and is public for external callers */ function calculateRoyaltiesView(uint256 assetId, uint256 saleAmount) public view returns (address payable[] memory royaltyRecipients, uint256[] memory royaltyAmounts, uint256 royaltyTotal) { (address payable[] memory recipients, uint256[] memory amounts) = ROYALTY_ENGINE.getRoyaltyView(nft(), assetId, saleAmount); return _calculateRoyaltiesLogic(recipients, amounts, saleAmount); } /** * @dev Common logic used by _calculateRoyalties() and calculateRoyaltiesView() */ function _calculateRoyaltiesLogic(address payable[] memory recipients, uint256[] memory amounts, uint256 saleAmount) internal view returns (address payable[] memory royaltyRecipients, uint256[] memory royaltyAmounts, uint256 royaltyTotal) { // Cache to save gas uint256 numRecipients = recipients.length; if (numRecipients != 0) { // If a pair has custom Settings, use the overridden royalty amount and only use the first receiver try factory().getSettingsForPair(address(this)) returns (bool settingsEnabled, uint96 bps) { if (settingsEnabled) { royaltyRecipients = new address payable[](1); royaltyRecipients[0] = recipients[0]; royaltyAmounts = new uint256[](1); royaltyAmounts[0] = (saleAmount * bps) / 10000; // Update numRecipients to match new recipients list numRecipients = 1; } else { royaltyRecipients = recipients; royaltyAmounts = amounts; } } catch { // Use the input values to calculate royalties if factory call fails royaltyRecipients = recipients; royaltyAmounts = amounts; } } for (uint256 i; i < numRecipients;) { royaltyTotal += royaltyAmounts[i]; unchecked { ++i; } } // Ensure royalty total is at most 25% of the sale amount // This defends against a rogue Manifold registry that charges extremely high royalties if (royaltyTotal > saleAmount >> 2) { revert LSSVMPair__RoyaltyTooLarge(); } } /** * Owner functions */ /** * @notice Rescues a specified set of NFTs owned by the pair to the owner address. (onlyOwnable modifier is in the implemented function) * @param a The NFT to transfer * @param nftIds The list of IDs of the NFTs to send to the owner */ function withdrawERC721(IERC721 a, uint256[] calldata nftIds) external virtual; /** * @notice Rescues ERC20 tokens from the pair to the owner. Only callable by the owner (onlyOwnable modifier is in the implemented function). * @param a The token to transfer * @param amount The amount of tokens to send to the owner */ function withdrawERC20(ERC20 a, uint256 amount) external virtual; /** * @notice Rescues ERC1155 tokens from the pair to the owner. Only callable by the owner. * @param a The NFT to transfer * @param ids The NFT ids to transfer * @param amounts The amounts of each id to transfer */ function withdrawERC1155(IERC1155 a, uint256[] calldata ids, uint256[] calldata amounts) external virtual; /** * @notice Updates the selling spot price. Only callable by the owner. * @param newSpotPrice The new selling spot price value, in Token */ function changeSpotPrice(uint128 newSpotPrice) external onlyOwner { ICurve _bondingCurve = bondingCurve(); if (!_bondingCurve.validateSpotPrice(newSpotPrice)) revert LSSVMPair__InvalidSpotPrice(); if (spotPrice != newSpotPrice) { spotPrice = newSpotPrice; emit SpotPriceUpdate(newSpotPrice); } } /** * @notice Updates the delta parameter. Only callable by the owner. * @param newDelta The new delta parameter */ function changeDelta(uint128 newDelta) external onlyOwner { ICurve _bondingCurve = bondingCurve(); if (!_bondingCurve.validateDelta(newDelta)) revert LSSVMPair__InvalidDelta(); if (delta != newDelta) { delta = newDelta; emit DeltaUpdate(newDelta); } } /** * @notice Updates the fee taken by the LP. Only callable by the owner. * Only callable if the pool is a Trade pool. Reverts if the fee is >= MAX_FEE. * @param newFee The new LP fee percentage, 18 decimals */ function changeFee(uint96 newFee) external onlyOwner { PoolType _poolType = poolType(); if (_poolType != PoolType.TRADE) revert LSSVMPair__NonTradePoolWithTradeFee(); if (newFee > MAX_TRADE_FEE) revert LSSVMPair__TradeFeeTooLarge(); if (fee != newFee) { fee = newFee; emit FeeUpdate(newFee); } } /** * @notice Changes the address that will receive assets received from * trades. Only callable by the owner. * @param newRecipient The new asset recipient */ function changeAssetRecipient(address payable newRecipient) external onlyOwner { if (assetRecipient != newRecipient) { assetRecipient = newRecipient; emit AssetRecipientChange(newRecipient); } } function _preCallCheck(address target) internal virtual; /** * @notice Allows the pair to make arbitrary external calls to contracts * whitelisted by the protocol. Only callable by the owner. * @param target The contract to call * @param data The calldata to pass to the contract */ function call(address payable target, bytes calldata data) external onlyOwner { ILSSVMPairFactoryLike _factory = factory(); if (!_factory.callAllowed(target)) revert LSSVMPair__TargetNotAllowed(); // Ensure the call isn't calling a banned function bytes4 sig = bytes4(data[:4]); if ( sig == IOwnershipTransferReceiver.onOwnershipTransferred.selector || sig == LSSVMRouter.pairTransferERC20From.selector || sig == LSSVMRouter.pairTransferNFTFrom.selector || sig == LSSVMRouter.pairTransferERC1155From.selector || sig == ILSSVMPairFactoryLike.openLock.selector || sig == ILSSVMPairFactoryLike.closeLock.selector ) { revert LSSVMPair__FunctionNotAllowed(); } // Prevent calling the pair's underlying nft // (We ban calling the underlying NFT/ERC20 to avoid maliciously transferring assets approved for the pair to spend) if (target == nft()) revert LSSVMPair__TargetNotAllowed(); _preCallCheck(target); (bool success,) = target.call{value: 0}(data); if (!success) revert LSSVMPair__CallFailed(); } /** * @notice Allows owner to batch multiple calls, forked from: https://github.com/boringcrypto/BoringSolidity/blob/master/contracts/BoringBatchable.sol * @notice The revert handling is forked from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/c239e1af8d1a1296577108dd6989a17b57434f8e/contracts/utils/Address.sol#L201 * @dev Intended for withdrawing/altering pool pricing in one tx, only callable by owner, cannot change owner * @param calls The calldata for each call to make * @param revertOnFail Whether or not to revert the entire tx if any of the calls fail. Calls to transferOwnership will revert regardless. */ function multicall(bytes[] calldata calls, bool revertOnFail) external onlyOwner { for (uint256 i; i < calls.length;) { bytes4 sig = bytes4(calls[i][:4]); // We ban calling transferOwnership when ownership if (sig == transferOwnership.selector) revert LSSVMPair__FunctionNotAllowed(); (bool success, bytes memory result) = address(this).delegatecall(calls[i]); if (!success && revertOnFail) { assembly { revert(add(0x20, result), mload(result)) } } unchecked { ++i; } } } }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {ERC20} from "solmate/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol"; import {LSSVMPair} from "./LSSVMPair.sol"; import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol"; /** * @title An NFT/Token pair where the token is ETH * @author boredGenius, 0xmons, 0xCygaar */ abstract contract LSSVMPairETH is LSSVMPair { using SafeTransferLib for address payable; using SafeTransferLib for ERC20; error LSSVMPairETH__InsufficientInput(); /** * @inheritdoc LSSVMPair */ function _pullTokenInputs( uint256 inputAmountExcludingRoyalty, uint256[] memory royaltyAmounts, address payable[] memory royaltyRecipients, uint256 royaltyTotal, uint256 tradeFeeAmount, bool, /*isRouter*/ address, /*routerCaller*/ uint256 protocolFee ) internal override { // Require that the input amount is sufficient to pay for the sale amount, royalties, and fees if (msg.value < (royaltyTotal + inputAmountExcludingRoyalty)) revert LSSVMPairETH__InsufficientInput(); // Transfer inputAmountExcludingRoyalty ETH to assetRecipient if it has been set address payable _assetRecipient = getAssetRecipient(); // Attempt to transfer trade fees only if TRADE pool and they exist if (poolType() == PoolType.TRADE && tradeFeeAmount != 0) { address payable _feeRecipient = getFeeRecipient(); // Only send and deduct tradeFeeAmount if the fee recipient is not the asset recipient (i.e. the pool) if (_feeRecipient != _assetRecipient) { inputAmountExcludingRoyalty -= tradeFeeAmount; _feeRecipient.safeTransferETH(tradeFeeAmount); } // In the else case, we would want to ensure that inputAmountExcludingRoyalty >= tradeFeeAmount / 2 // to avoid underpaying the trade fee, but it is always true because the max royalty // is 25%, the max protocol fee is 10%, and the max trade fee is 50%, meaning they can // never add up to more than 100%. } if (_assetRecipient != address(this)) { _assetRecipient.safeTransferETH(inputAmountExcludingRoyalty - protocolFee); } // Transfer royalties for (uint256 i; i < royaltyRecipients.length;) { royaltyRecipients[i].safeTransferETH(royaltyAmounts[i]); unchecked { ++i; } } // Take protocol fee if (protocolFee != 0) { payable(address(factory())).safeTransferETH(protocolFee); } } /** * @inheritdoc LSSVMPair */ function _refundTokenToSender(uint256 inputAmount) internal override { // Give excess ETH back to caller if (msg.value > inputAmount) { payable(msg.sender).safeTransferETH(msg.value - inputAmount); } } /** * @inheritdoc LSSVMPair */ function _sendTokenOutput(address payable tokenRecipient, uint256 outputAmount) internal override { // Send ETH to caller if (outputAmount != 0) { tokenRecipient.safeTransferETH(outputAmount); } } /** * @notice Withdraws all token owned by the pair to the owner address. * @dev Only callable by the owner. */ function withdrawAllETH() external onlyOwner { withdrawETH(address(this).balance); } /** * @notice Withdraws a specified amount of token owned by the pair to the owner address. * @dev Only callable by the owner. * @param amount The amount of token to send to the owner. If the pair's balance is less than * this value, the transaction will be reverted. */ function withdrawETH(uint256 amount) public onlyOwner { payable(msg.sender).safeTransferETH(amount); // emit event since ETH is the pair token emit TokenWithdrawal(amount); } /** * @inheritdoc LSSVMPair */ function withdrawERC20(ERC20 a, uint256 amount) external override onlyOwner { a.safeTransfer(msg.sender, amount); } /** * @dev All ETH transfers into the pair are accepted. This is the main method * for the owner to top up the pair's token reserves. */ receive() external payable { emit TokenDeposit(msg.value); } /** * @dev All ETH transfers into the pair are accepted. This is the main method * for the owner to top up the pair's token reserves. */ fallback() external payable { // Only allow calls without function selector require(msg.data.length == _immutableParamsLength()); emit TokenDeposit(msg.value); } function _preCallCheck(address) internal pure override {} }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {ERC20} from "solmate/tokens/ERC20.sol"; import {LSSVMPair} from "../LSSVMPair.sol"; import {LSSVMRouter} from "../LSSVMRouter.sol"; import {ICurve} from "../bonding-curves/ICurve.sol"; import {ILSSVMPairFactoryLike} from "../ILSSVMPairFactoryLike.sol"; /** * @title LSSVMPairERC1155 * @author boredGenius, 0xmons, 0xCygaar * @notice An NFT/Token pair for an ERC1155 NFT where NFTs with the same ID are considered fungible. */ abstract contract LSSVMPairERC1155 is LSSVMPair { /** * External state-changing functions */ /** * @notice Sends token to the pair in exchange for any `numNFTs` NFTs * @dev To compute the amount of token to send, call bondingCurve.getBuyInfo. * This swap function is meant for users who are ID agnostic * @param numNFTs The number of NFTs to purchase * @param maxExpectedTokenInput The maximum acceptable cost from the sender. If the actual * amount is greater than this value, the transaction will be reverted. * @param nftRecipient The recipient of the NFTs * @param isRouter True if calling from LSSVMRouter, false otherwise. Not used for ETH pairs. * @param routerCaller If isRouter is true, ERC20 tokens will be transferred from this address. Not used for ETH pairs. * @return inputAmount The amount of token used for purchase */ function swapTokenForSpecificNFTs( uint256[] calldata numNFTs, uint256 maxExpectedTokenInput, address nftRecipient, bool isRouter, address routerCaller ) external payable virtual override returns (uint256) { // Store locally to remove extra calls factory().openLock(); // Input validation { if (poolType() == PoolType.TOKEN) revert LSSVMPair__WrongPoolType(); if (numNFTs.length != 1 || numNFTs[0] == 0) revert LSSVMPair__ZeroSwapAmount(); } // Call bonding curve for pricing information uint256 tradeFee; uint256 protocolFee; uint256 inputAmountExcludingRoyalty; (tradeFee, protocolFee, inputAmountExcludingRoyalty) = _calculateBuyInfoAndUpdatePoolParams(numNFTs[0], bondingCurve(), factory()); (address payable[] memory royaltyRecipients, uint256[] memory royaltyAmounts, uint256 royaltyTotal) = _calculateRoyalties(nftId(), inputAmountExcludingRoyalty - protocolFee - tradeFee); // Revert if the input amount is too large if (royaltyTotal + inputAmountExcludingRoyalty > maxExpectedTokenInput) { revert LSSVMPair__DemandedInputTooLarge(); } _pullTokenInputs({ inputAmountExcludingRoyalty: inputAmountExcludingRoyalty, royaltyRecipients: royaltyRecipients, royaltyAmounts: royaltyAmounts, royaltyTotal: royaltyTotal, tradeFeeAmount: 2 * tradeFee, isRouter: isRouter, routerCaller: routerCaller, protocolFee: protocolFee }); _sendAnyNFTsToRecipient(IERC1155(nft()), nftRecipient, numNFTs[0]); _refundTokenToSender(royaltyTotal + inputAmountExcludingRoyalty); factory().closeLock(); emit SwapNFTOutPair(royaltyTotal + inputAmountExcludingRoyalty, numNFTs[0]); return (royaltyTotal + inputAmountExcludingRoyalty); } /** * @notice Sends a set of NFTs to the pair in exchange for token * @dev To compute the amount of token to that will be received, call bondingCurve.getSellInfo. * @param numNFTs The number of NFTs to swap * @param minExpectedTokenOutput The minimum acceptable token received by the sender. If the actual * amount is less than this value, the transaction will be reverted. * @param tokenRecipient The recipient of the token output * @param isRouter True if calling from LSSVMRouter, false otherwise. Not used for ETH pairs. * @param routerCaller If isRouter is true, ERC20 tokens will be transferred from this address. Not used for ETH pairs. * @return outputAmount The amount of token received */ function swapNFTsForToken( uint256[] calldata numNFTs, // @dev this is a bit hacky, to allow for better interop w/ other pair interfaces uint256 minExpectedTokenOutput, address payable tokenRecipient, bool isRouter, address routerCaller ) external virtual override returns (uint256 outputAmount) { // Store locally to remove extra calls ILSSVMPairFactoryLike _factory = factory(); _factory.openLock(); ICurve _bondingCurve = bondingCurve(); // Input validation { if (poolType() == PoolType.NFT) revert LSSVMPair__WrongPoolType(); if (numNFTs.length != 1 || numNFTs[0] == 0) revert LSSVMPair__ZeroSwapAmount(); } // Call bonding curve for pricing information uint256 protocolFee; (protocolFee, outputAmount) = _calculateSellInfoAndUpdatePoolParams(numNFTs[0], _bondingCurve, _factory); // Compute royalties (address payable[] memory royaltyRecipients, uint256[] memory royaltyAmounts, uint256 royaltyTotal) = _calculateRoyalties(nftId(), outputAmount); // Deduct royalties from outputAmount unchecked { // Safe because we already require outputAmount >= royaltyTotal in calculateRoyalties() outputAmount -= royaltyTotal; } if (outputAmount < minExpectedTokenOutput) revert LSSVMPair__OutputTooSmall(); _takeNFTsFromSender(IERC1155(nft()), numNFTs[0], _factory, isRouter, routerCaller); _sendTokenOutput(tokenRecipient, outputAmount); for (uint256 i; i < royaltyRecipients.length;) { _sendTokenOutput(royaltyRecipients[i], royaltyAmounts[i]); unchecked { ++i; } } _sendTokenOutput(payable(address(_factory)), protocolFee); _factory.closeLock(); emit SwapNFTInPair(outputAmount, numNFTs[0]); } /** * View functions */ /** * @notice Returns the ERC-1155 NFT ID this pool uses */ function nftId() public pure returns (uint256 id) { uint256 paramsLength = _immutableParamsLength(); assembly { id := calldataload(add(sub(calldatasize(), paramsLength), 61)) } } /** * Internal functions */ /** * @notice Sends some number of NFTs to a recipient address * @dev Even though we specify the NFT address here, this internal function is only * used to send NFTs associated with this specific pool. * @param _nft The address of the NFT to send * @param nftRecipient The receiving address for the NFTs * @param numNFTs The number of NFTs to send */ function _sendAnyNFTsToRecipient(IERC1155 _nft, address nftRecipient, uint256 numNFTs) internal virtual { _nft.safeTransferFrom(address(this), nftRecipient, nftId(), numNFTs, bytes("")); } /** * @notice Takes NFTs from the caller and sends them into the pair's asset recipient * @dev This is used by the LSSVMPair's swapNFTForToken function. * @param _nft The NFT collection to take from * @param numNFTs The number of NFTs to take * @param isRouter Whether or not to use the router pull flow * @param routerCaller If the caller is a router, passes in which address to pull from (i.e. the router's caller) */ function _takeNFTsFromSender( IERC1155 _nft, uint256 numNFTs, ILSSVMPairFactoryLike factory, bool isRouter, address routerCaller ) internal virtual { address _assetRecipient = getAssetRecipient(); if (isRouter) { // Verify if router is allowed LSSVMRouter router = LSSVMRouter(payable(msg.sender)); (bool routerAllowed,) = factory.routerStatus(router); if (!routerAllowed) revert LSSVMPair__NotRouter(); uint256 _nftId = nftId(); uint256 beforeBalance = _nft.balanceOf(_assetRecipient, _nftId); uint256[] memory ids = new uint256[](1); ids[0] = _nftId; uint256[] memory amounts = new uint256[](1); amounts[0] = numNFTs; router.pairTransferERC1155From(_nft, routerCaller, _assetRecipient, ids, amounts); if (_nft.balanceOf(_assetRecipient, _nftId) - beforeBalance != numNFTs) { revert LSSVMPair__NftNotTransferred(); } } else { // Pull NFTs directly from sender _nft.safeTransferFrom(msg.sender, _assetRecipient, nftId(), numNFTs, bytes("")); } } /** * Owner functions */ /** * @notice Rescues a specified set of NFTs owned by the pair to the owner address. Only callable by the owner. * @param a The NFT to transfer * @param nftIds The list of IDs of the NFTs to send to the owner */ function withdrawERC721(IERC721 a, uint256[] calldata nftIds) external virtual override onlyOwner { uint256 numNFTs = nftIds.length; for (uint256 i; i < numNFTs;) { a.safeTransferFrom(address(this), msg.sender, nftIds[i]); unchecked { ++i; } } } /** * @notice Transfers ERC1155 tokens from the pair to the owner. Only callable by the owner. * @param a The NFT to transfer * @param ids The NFT ids to transfer * @param amounts The amounts of each id to transfer */ function withdrawERC1155(IERC1155 a, uint256[] calldata ids, uint256[] calldata amounts) external virtual override onlyOwner { if (a == IERC1155(nft())) { // Check if we need to emit an event for withdrawing the NFT this pool is trading uint256 _nftId = nftId(); uint256 numNFTs = ids.length; uint256 numPairNFTsWithdrawn; for (uint256 i; i < numNFTs;) { if (ids[i] == _nftId) { numPairNFTsWithdrawn += amounts[i]; } unchecked { ++i; } } if (numPairNFTsWithdrawn != 0) { // Only emit for the pair's NFT emit NFTWithdrawal(numPairNFTsWithdrawn); } } a.safeBatchTransferFrom(address(this), msg.sender, ids, amounts, bytes("")); } }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {LSSVMRouter} from "./LSSVMRouter.sol"; interface ILSSVMPairFactoryLike { struct Settings { uint96 bps; address pairAddress; } enum PairNFTType { ERC721, ERC1155 } enum PairTokenType { ETH, ERC20 } enum PairVariant { ERC721_ETH, ERC721_ERC20, ERC1155_ETH, ERC1155_ERC20 } function protocolFeeMultiplier() external view returns (uint256); function protocolFeeRecipient() external view returns (address payable); function callAllowed(address target) external view returns (bool); function authAllowedForToken(address tokenAddress, address proposedAuthAddress) external view returns (bool); function getSettingsForPair(address pairAddress) external view returns (bool settingsEnabled, uint96 bps); function enableSettingsForPair(address settings, address pairAddress) external; function disableSettingsForPair(address settings, address pairAddress) external; function routerStatus(LSSVMRouter router) external view returns (bool allowed, bool wasEverTouched); function isValidPair(address pairAddress) external view returns (bool); function getPairNFTType(address pairAddress) external pure returns (PairNFTType); function getPairTokenType(address pairAddress) external pure returns (PairTokenType); function openLock() external; function closeLock() external; }
// 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: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * 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.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../IERC721Receiver.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721Holder is IERC721Receiver { /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { return this.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol) pragma solidity ^0.8.0; import "./ERC1155Receiver.sol"; /** * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens. * * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be * stuck. * * @dev _Available since v3.1._ */ contract ERC1155Holder is ERC1155Receiver { function onERC1155Received( address, address, uint256, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived( address, address, uint256[] memory, uint256[] memory, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155BatchReceived.selector; } }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {ERC20} from "solmate/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {LSSVMPair} from "./LSSVMPair.sol"; import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol"; import {CurveErrorCodes} from "./bonding-curves/CurveErrorCodes.sol"; contract LSSVMRouter { using SafeTransferLib for address payable; using SafeTransferLib for ERC20; struct PairSwapSpecific { LSSVMPair pair; uint256[] nftIds; } struct RobustPairSwapSpecific { PairSwapSpecific swapInfo; uint256 maxCost; } struct RobustPairSwapSpecificForToken { PairSwapSpecific swapInfo; uint256 minOutput; } struct NFTsForSpecificNFTsTrade { PairSwapSpecific[] nftToTokenTrades; PairSwapSpecific[] tokenToNFTTrades; } struct RobustPairNFTsFoTokenAndTokenforNFTsTrade { RobustPairSwapSpecific[] tokenToNFTTrades; RobustPairSwapSpecificForToken[] nftToTokenTrades; uint256 inputAmount; address payable tokenRecipient; address nftRecipient; } modifier checkDeadline(uint256 deadline) { _checkDeadline(deadline); _; } ILSSVMPairFactoryLike public immutable factory; constructor(ILSSVMPairFactoryLike _factory) { factory = _factory; } /** * ETH swaps */ /** * @notice Swaps ETH into specific NFTs using multiple pairs. * @param swapList The list of pairs to trade with and the IDs of the NFTs to buy from each. * @param ethRecipient The address that will receive the unspent ETH input * @param nftRecipient The address that will receive the NFT output * @param deadline The Unix timestamp (in seconds) at/after which the swap will revert * @return remainingValue The unspent ETH amount */ function swapETHForSpecificNFTs( PairSwapSpecific[] calldata swapList, address payable ethRecipient, address nftRecipient, uint256 deadline ) external payable checkDeadline(deadline) returns (uint256 remainingValue) { return _swapETHForSpecificNFTs(swapList, msg.value, ethRecipient, nftRecipient); } /** * @notice Swaps one set of NFTs into another set of specific NFTs using multiple pairs, using * ETH as the intermediary. * @param trade The struct containing all NFT-to-ETH swaps and ETH-to-NFT swaps. * @param minOutput The minimum acceptable total excess ETH received * @param ethRecipient The address that will receive the ETH output * @param nftRecipient The address that will receive the NFT output * @param deadline The Unix timestamp (in seconds) at/after which the swap will revert * @return outputAmount The total ETH received */ function swapNFTsForSpecificNFTsThroughETH( NFTsForSpecificNFTsTrade calldata trade, uint256 minOutput, address payable ethRecipient, address nftRecipient, uint256 deadline ) external payable checkDeadline(deadline) returns (uint256 outputAmount) { // Swap NFTs for ETH // minOutput of swap set to 0 since we're doing an aggregate slippage check outputAmount = _swapNFTsForToken(trade.nftToTokenTrades, 0, payable(address(this))); // Add extra value to buy NFTs outputAmount += msg.value; // Swap ETH for specific NFTs // cost <= inputValue = outputAmount - minOutput, so outputAmount' = (outputAmount - minOutput - cost) + minOutput >= minOutput outputAmount = _swapETHForSpecificNFTs( trade.tokenToNFTTrades, outputAmount - minOutput, ethRecipient, nftRecipient ) + minOutput; } /** * ERC20 swaps * * Note: All ERC20 swaps assume that a single ERC20 token is used for all the pairs involved. * Swapping using multiple tokens in the same transaction is possible, but the slippage checks * & the return values will be meaningless, and may lead to undefined behavior. * * Note: The sender should ideally grant infinite token approval to the router in order for NFT-to-NFT * swaps to work smoothly. */ /** * @notice Swaps ERC20 tokens into specific NFTs using multiple pairs. * @param swapList The list of pairs to trade with and the IDs of the NFTs to buy from each. * @param inputAmount The amount of ERC20 tokens to add to the ERC20-to-NFT swaps * @param nftRecipient The address that will receive the NFT output * @param deadline The Unix timestamp (in seconds) at/after which the swap will revert * @return remainingValue The unspent token amount */ function swapERC20ForSpecificNFTs( PairSwapSpecific[] calldata swapList, uint256 inputAmount, address nftRecipient, uint256 deadline ) external checkDeadline(deadline) returns (uint256 remainingValue) { return _swapERC20ForSpecificNFTs(swapList, inputAmount, nftRecipient); } /** * @notice Swaps NFTs into ETH/ERC20 using multiple pairs. * @param swapList The list of pairs to trade with and the IDs of the NFTs to sell to each. * @param minOutput The minimum acceptable total tokens received * @param tokenRecipient The address that will receive the token output * @param deadline The Unix timestamp (in seconds) at/after which the swap will revert * @return outputAmount The total tokens received */ function swapNFTsForToken( PairSwapSpecific[] calldata swapList, uint256 minOutput, address tokenRecipient, uint256 deadline ) external checkDeadline(deadline) returns (uint256 outputAmount) { return _swapNFTsForToken(swapList, minOutput, payable(tokenRecipient)); } /** * @notice Swaps one set of NFTs into another set of specific NFTs using multiple pairs, using * an ERC20 token as the intermediary. * @param trade The struct containing all NFT-to-ERC20 swaps and ERC20-to-NFT swaps. * @param inputAmount The amount of ERC20 tokens to add to the ERC20-to-NFT swaps * @param minOutput The minimum acceptable total excess tokens received * @param nftRecipient The address that will receive the NFT output * @param deadline The Unix timestamp (in seconds) at/after which the swap will revert * @return outputAmount The total ERC20 tokens received */ function swapNFTsForSpecificNFTsThroughERC20( NFTsForSpecificNFTsTrade calldata trade, uint256 inputAmount, uint256 minOutput, address nftRecipient, uint256 deadline ) external checkDeadline(deadline) returns (uint256 outputAmount) { // Swap NFTs for ERC20 // minOutput of swap set to 0 since we're doing an aggregate slippage check // output tokens are sent to msg.sender outputAmount = _swapNFTsForToken(trade.nftToTokenTrades, 0, payable(msg.sender)); // Add extra value to buy NFTs outputAmount += inputAmount; // Swap ERC20 for specific NFTs // cost <= maxCost = outputAmount - minOutput, so outputAmount' = outputAmount - cost >= minOutput // input tokens are taken directly from msg.sender outputAmount = _swapERC20ForSpecificNFTs(trade.tokenToNFTTrades, outputAmount - minOutput, nftRecipient) + minOutput; } /** * Robust Swaps * These are "robust" versions of the NFT<>Token swap functions which will never revert due to slippage * Instead, users specify a per-swap max cost. If the price changes more than the user specifies, no swap is attempted. This allows users to specify a batch of swaps, and execute as many of them as possible. */ /** * @dev Ensure msg.value >= sum of values in maxCostPerPair to make sure the transaction doesn't revert * @param swapList The list of pairs to trade with and the IDs of the NFTs to buy from each. * @param ethRecipient The address that will receive the unspent ETH input * @param nftRecipient The address that will receive the NFT output * @param deadline The Unix timestamp (in seconds) at/after which the swap will revert * @return remainingValue The unspent token amount */ function robustSwapETHForSpecificNFTs( RobustPairSwapSpecific[] calldata swapList, address payable ethRecipient, address nftRecipient, uint256 deadline ) public payable virtual checkDeadline(deadline) returns (uint256 remainingValue) { remainingValue = msg.value; uint256 pairCost; CurveErrorCodes.Error error; // Try doing each swap uint256 numSwaps = swapList.length; for (uint256 i; i < numSwaps;) { // Calculate actual cost per swap (error,,, pairCost,,) = swapList[i].swapInfo.pair.getBuyNFTQuote( swapList[i].swapInfo.nftIds[0], swapList[i].swapInfo.nftIds.length ); // If within our maxCost and no error, proceed if (pairCost <= swapList[i].maxCost && error == CurveErrorCodes.Error.OK) { // We know how much ETH to send because we already did the math above // So we just send that much remainingValue -= swapList[i].swapInfo.pair.swapTokenForSpecificNFTs{value: pairCost}( swapList[i].swapInfo.nftIds, pairCost, nftRecipient, true, msg.sender ); } unchecked { ++i; } } // Return remaining value to sender if (remainingValue > 0) { ethRecipient.safeTransferETH(remainingValue); } } /** * @notice Swaps as many ERC20 tokens for specific NFTs as possible, respecting the per-swap max cost. * @param swapList The list of pairs to trade with and the IDs of the NFTs to buy from each. * @param inputAmount The amount of ERC20 tokens to add to the ERC20-to-NFT swaps * @param nftRecipient The address that will receive the NFT output * @param deadline The Unix timestamp (in seconds) at/after which the swap will revert * @return remainingValue The unspent token amount */ function robustSwapERC20ForSpecificNFTs( RobustPairSwapSpecific[] calldata swapList, uint256 inputAmount, address nftRecipient, uint256 deadline ) public virtual checkDeadline(deadline) returns (uint256 remainingValue) { remainingValue = inputAmount; uint256 pairCost; CurveErrorCodes.Error error; // Try doing each swap uint256 numSwaps = swapList.length; for (uint256 i; i < numSwaps;) { // Calculate actual cost per swap (error,,, pairCost,,) = swapList[i].swapInfo.pair.getBuyNFTQuote( swapList[i].swapInfo.nftIds[0], swapList[i].swapInfo.nftIds.length ); // If within our maxCost and no error, proceed if (pairCost <= swapList[i].maxCost && error == CurveErrorCodes.Error.OK) { remainingValue -= swapList[i].swapInfo.pair.swapTokenForSpecificNFTs( swapList[i].swapInfo.nftIds, pairCost, nftRecipient, true, msg.sender ); } unchecked { ++i; } } } /** * @notice Swaps as many NFTs for tokens as possible, respecting the per-swap min output * @param swapList The list of pairs to trade with and the IDs of the NFTs to sell to each. * @param tokenRecipient The address that will receive the token output * @param deadline The Unix timestamp (in seconds) at/after which the swap will revert * @return outputAmount The total ETH/ERC20 received */ function robustSwapNFTsForToken( RobustPairSwapSpecificForToken[] calldata swapList, address payable tokenRecipient, uint256 deadline ) public virtual checkDeadline(deadline) returns (uint256 outputAmount) { // Try doing each swap uint256 numSwaps = swapList.length; for (uint256 i; i < numSwaps;) { uint256 pairOutput; // Locally scoped to avoid stack too deep error { CurveErrorCodes.Error error; uint256[] memory nftIds = swapList[i].swapInfo.nftIds; if (nftIds.length == 0) { unchecked { ++i; } continue; } (error,,, pairOutput,,) = swapList[i].swapInfo.pair.getSellNFTQuote(nftIds[0], nftIds.length); if (error != CurveErrorCodes.Error.OK) { unchecked { ++i; } continue; } } // If at least equal to our minOutput, proceed if (pairOutput >= swapList[i].minOutput) { // Do the swap and update outputAmount with how many tokens we got outputAmount += swapList[i].swapInfo.pair.swapNFTsForToken( swapList[i].swapInfo.nftIds, 0, tokenRecipient, true, msg.sender ); } unchecked { ++i; } } } /** * @notice Buys NFTs with ETH and sells them for tokens in one transaction * @param params All the parameters for the swap (packed in struct to avoid stack too deep), containing: * - ethToNFTSwapList The list of NFTs to buy * - nftToTokenSwapList The list of NFTs to sell * - inputAmount The max amount of tokens to send (if ERC20) * - tokenRecipient The address that receives tokens from the NFTs sold * - nftRecipient The address that receives NFTs * - deadline UNIX timestamp deadline for the swap */ function robustSwapETHForSpecificNFTsAndNFTsToToken(RobustPairNFTsFoTokenAndTokenforNFTsTrade calldata params) external payable virtual returns (uint256 remainingValue, uint256 outputAmount) { { remainingValue = msg.value; uint256 pairCost; CurveErrorCodes.Error error; // Try doing each swap uint256 numSwaps = params.tokenToNFTTrades.length; for (uint256 i; i < numSwaps;) { // Calculate actual cost per swap (error,,, pairCost,,) = params.tokenToNFTTrades[i].swapInfo.pair.getBuyNFTQuote( params.tokenToNFTTrades[i].swapInfo.nftIds[0], params.tokenToNFTTrades[i].swapInfo.nftIds.length ); // If within our maxCost and no error, proceed if (pairCost <= params.tokenToNFTTrades[i].maxCost && error == CurveErrorCodes.Error.OK) { // We know how much ETH to send because we already did the math above // So we just send that much remainingValue -= params.tokenToNFTTrades[i].swapInfo.pair.swapTokenForSpecificNFTs{value: pairCost}( params.tokenToNFTTrades[i].swapInfo.nftIds, pairCost, params.nftRecipient, true, msg.sender ); } unchecked { ++i; } } // Return remaining value to sender if (remainingValue > 0) { params.tokenRecipient.safeTransferETH(remainingValue); } } { // Try doing each swap uint256 numSwaps = params.nftToTokenTrades.length; for (uint256 i; i < numSwaps;) { uint256 pairOutput; // Locally scoped to avoid stack too deep error { CurveErrorCodes.Error error; uint256 assetId = params.nftToTokenTrades[i].swapInfo.nftIds[0]; (error,,, pairOutput,,) = params.nftToTokenTrades[i].swapInfo.pair.getSellNFTQuote( assetId, params.nftToTokenTrades[i].swapInfo.nftIds.length ); if (error != CurveErrorCodes.Error.OK) { unchecked { ++i; } continue; } } // If at least equal to our minOutput, proceed if (pairOutput >= params.nftToTokenTrades[i].minOutput) { // Do the swap and update outputAmount with how many tokens we got outputAmount += params.nftToTokenTrades[i].swapInfo.pair.swapNFTsForToken( params.nftToTokenTrades[i].swapInfo.nftIds, 0, params.tokenRecipient, true, msg.sender ); } unchecked { ++i; } } } } /** * @notice Buys NFTs with ERC20, and sells them for tokens in one transaction * @param params All the parameters for the swap (packed in struct to avoid stack too deep), containing: * - ethToNFTSwapList The list of NFTs to buy * - nftToTokenSwapList The list of NFTs to sell * - inputAmount The max amount of tokens to send (if ERC20) * - tokenRecipient The address that receives tokens from the NFTs sold * - nftRecipient The address that receives NFTs * - deadline UNIX timestamp deadline for the swap */ function robustSwapERC20ForSpecificNFTsAndNFTsToToken(RobustPairNFTsFoTokenAndTokenforNFTsTrade calldata params) external virtual returns (uint256 remainingValue, uint256 outputAmount) { { remainingValue = params.inputAmount; uint256 pairCost; CurveErrorCodes.Error error; // Try doing each swap uint256 numSwaps = params.tokenToNFTTrades.length; for (uint256 i; i < numSwaps;) { // Calculate actual cost per swap (error,,, pairCost,,) = params.tokenToNFTTrades[i].swapInfo.pair.getBuyNFTQuote( params.tokenToNFTTrades[i].swapInfo.nftIds[0], params.tokenToNFTTrades[i].swapInfo.nftIds.length ); // If within our maxCost and no error, proceed if (pairCost <= params.tokenToNFTTrades[i].maxCost && error == CurveErrorCodes.Error.OK) { remainingValue -= params.tokenToNFTTrades[i].swapInfo.pair.swapTokenForSpecificNFTs( params.tokenToNFTTrades[i].swapInfo.nftIds, pairCost, params.nftRecipient, true, msg.sender ); } unchecked { ++i; } } } { // Try doing each swap uint256 numSwaps = params.nftToTokenTrades.length; for (uint256 i; i < numSwaps;) { uint256 pairOutput; // Locally scoped to avoid stack too deep error { CurveErrorCodes.Error error; uint256 assetId = params.nftToTokenTrades[i].swapInfo.nftIds[0]; (error,,, pairOutput,,) = params.nftToTokenTrades[i].swapInfo.pair.getSellNFTQuote( assetId, params.nftToTokenTrades[i].swapInfo.nftIds.length ); if (error != CurveErrorCodes.Error.OK) { unchecked { ++i; } continue; } } // If at least equal to our minOutput, proceed if (pairOutput >= params.nftToTokenTrades[i].minOutput) { // Do the swap and update outputAmount with how many tokens we got outputAmount += params.nftToTokenTrades[i].swapInfo.pair.swapNFTsForToken( params.nftToTokenTrades[i].swapInfo.nftIds, 0, params.tokenRecipient, true, msg.sender ); } unchecked { ++i; } } } } receive() external payable {} /** * Restricted functions */ /** * @dev Allows an ERC20 pair contract to transfer ERC20 tokens directly from * the sender, in order to minimize the number of token transfers. Only callable by an ERC20 pair. * @param token The ERC20 token to transfer * @param from The address to transfer tokens from * @param to The address to transfer tokens to * @param amount The amount of tokens to transfer */ function pairTransferERC20From(ERC20 token, address from, address to, uint256 amount) external { // verify caller is a trusted pair contract require(factory.isValidPair(msg.sender), "Not pair"); // verify caller is an ERC20 pair require(factory.getPairTokenType(msg.sender) == ILSSVMPairFactoryLike.PairTokenType.ERC20, "Not ERC20 pair"); // transfer tokens to pair token.safeTransferFrom(from, to, amount); } /** * @dev Allows a pair contract to transfer ERC721 NFTs directly from * the sender, in order to minimize the number of token transfers. Only callable by a pair. * @param nft The ERC721 NFT to transfer * @param from The address to transfer tokens from * @param to The address to transfer tokens to * @param id The ID of the NFT to transfer */ function pairTransferNFTFrom(IERC721 nft, address from, address to, uint256 id) external { // verify caller is a trusted pair contract require(factory.isValidPair(msg.sender), "Not pair"); // transfer NFTs to pair nft.transferFrom(from, to, id); } function pairTransferERC1155From( IERC1155 nft, address from, address to, uint256[] calldata ids, uint256[] calldata amounts ) external { // verify caller is a trusted pair contract require(factory.isValidPair(msg.sender), "Not pair"); nft.safeBatchTransferFrom(from, to, ids, amounts, bytes("")); } /** * Internal functions */ /** * @param deadline The last valid time for a swap */ function _checkDeadline(uint256 deadline) internal view { require(block.timestamp <= deadline, "Deadline passed"); } /** * @notice Internal function used to swap ETH for a specific set of NFTs * @param swapList The list of pairs and swap calldata * @param inputAmount The total amount of ETH to send * @param ethRecipient The address receiving excess ETH * @param nftRecipient The address receiving the NFTs from the pairs * @return remainingValue The unspent token amount */ function _swapETHForSpecificNFTs( PairSwapSpecific[] calldata swapList, uint256 inputAmount, address payable ethRecipient, address nftRecipient ) internal virtual returns (uint256 remainingValue) { remainingValue = inputAmount; uint256 pairCost; CurveErrorCodes.Error error; // Do swaps uint256 numSwaps = swapList.length; for (uint256 i; i < numSwaps;) { // Calculate the cost per swap first to send exact amount of ETH over, saves gas by avoiding the need to send back excess ETH (error,,, pairCost,,) = swapList[i].pair.getBuyNFTQuote(swapList[i].nftIds[0], swapList[i].nftIds.length); // Require no errors require(error == CurveErrorCodes.Error.OK, "Bonding curve error"); // Total ETH taken from sender cannot exceed inputAmount // because otherwise the deduction from remainingValue will fail remainingValue -= swapList[i].pair.swapTokenForSpecificNFTs{value: pairCost}( swapList[i].nftIds, remainingValue, nftRecipient, true, msg.sender ); unchecked { ++i; } } // Return remaining value to sender if (remainingValue > 0) { ethRecipient.safeTransferETH(remainingValue); } } /** * @notice Internal function used to swap an ERC20 token for specific NFTs * @dev Note that we don't need to query the pair's bonding curve first for pricing data because * we just calculate and take the required amount from the caller during swap time. * However, we can't "pull" ETH, which is why for the ETH->NFT swaps, we need to calculate the pricing info * to figure out how much the router should send to the pool. * @param swapList The list of pairs and swap calldata * @param inputAmount The total amount of ERC20 tokens to send * @param nftRecipient The address receiving the NFTs from the pairs * @return remainingValue The unspent token amount */ function _swapERC20ForSpecificNFTs(PairSwapSpecific[] calldata swapList, uint256 inputAmount, address nftRecipient) internal virtual returns (uint256 remainingValue) { remainingValue = inputAmount; // Do swaps uint256 numSwaps = swapList.length; for (uint256 i; i < numSwaps;) { // Tokens are transferred in by the pair calling router.pairTransferERC20From // Total tokens taken from sender cannot exceed inputAmount // because otherwise the deduction from remainingValue will fail remainingValue -= swapList[i].pair.swapTokenForSpecificNFTs( swapList[i].nftIds, remainingValue, nftRecipient, true, msg.sender ); unchecked { ++i; } } } /** * @notice Swaps NFTs for tokens, designed to be used for 1 token at a time * @dev Calling with multiple tokens is permitted, BUT minOutput will be * far from enough of a safety check because different tokens almost certainly have different unit prices. * @param swapList The list of pairs and swap calldata * @param minOutput The minimum number of tokens to be receieved from the swaps * @param tokenRecipient The address that receives the tokens * @return outputAmount The number of tokens to be received */ function _swapNFTsForToken(PairSwapSpecific[] calldata swapList, uint256 minOutput, address payable tokenRecipient) internal virtual returns (uint256 outputAmount) { // Do swaps uint256 numSwaps = swapList.length; for (uint256 i; i < numSwaps;) { // Do the swap for token and then update outputAmount // Note: minExpectedTokenOutput is set to 0 since we're doing an aggregate slippage check below outputAmount += swapList[i].pair.swapNFTsForToken(swapList[i].nftIds, 0, tokenRecipient, true, msg.sender); unchecked { ++i; } } // Aggregate slippage check require(outputAmount >= minOutput, "outputAmount too low"); } }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {CurveErrorCodes} from "./CurveErrorCodes.sol"; interface ICurve { /** * @notice Validates if a delta value is valid for the curve. The criteria for * validity can be different for each type of curve, for instance ExponentialCurve * requires delta to be greater than 1. * @param delta The delta value to be validated * @return valid True if delta is valid, false otherwise */ function validateDelta(uint128 delta) external pure returns (bool valid); /** * @notice Validates if a new spot price is valid for the curve. Spot price is generally assumed to be the immediate sell price of 1 NFT to the pool, in units of the pool's paired token. * @param newSpotPrice The new spot price to be set * @return valid True if the new spot price is valid, false otherwise */ function validateSpotPrice(uint128 newSpotPrice) external view returns (bool valid); /** * @notice Given the current state of the pair and the trade, computes how much the user * should pay to purchase an NFT from the pair, the new spot price, and other values. * @param spotPrice The current selling spot price of the pair, in tokens * @param delta The delta parameter of the pair, what it means depends on the curve * @param numItems The number of NFTs the user is buying from the pair * @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals * @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals * @return error Any math calculation errors, only Error.OK means the returned values are valid * @return newSpotPrice The updated selling spot price, in tokens * @return newDelta The updated delta, used to parameterize the bonding curve * @return inputValue The amount that the user should pay, in tokens * @return tradeFee The amount that is sent to the trade fee recipient * @return protocolFee The amount of fee to send to the protocol, in tokens */ function getBuyInfo( uint128 spotPrice, uint128 delta, uint256 numItems, uint256 feeMultiplier, uint256 protocolFeeMultiplier ) external view returns ( CurveErrorCodes.Error error, uint128 newSpotPrice, uint128 newDelta, uint256 inputValue, uint256 tradeFee, uint256 protocolFee ); /** * @notice Given the current state of the pair and the trade, computes how much the user * should receive when selling NFTs to the pair, the new spot price, and other values. * @param spotPrice The current selling spot price of the pair, in tokens * @param delta The delta parameter of the pair, what it means depends on the curve * @param numItems The number of NFTs the user is selling to the pair * @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals * @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals * @return error Any math calculation errors, only Error.OK means the returned values are valid * @return newSpotPrice The updated selling spot price, in tokens * @return newDelta The updated delta, used to parameterize the bonding curve * @return outputValue The amount that the user should receive, in tokens * @return tradeFee The amount that is sent to the trade fee recipient * @return protocolFee The amount of fee to send to the protocol, in tokens */ function getSellInfo( uint128 spotPrice, uint128 delta, uint256 numItems, uint256 feeMultiplier, uint256 protocolFeeMultiplier ) external view returns ( CurveErrorCodes.Error error, uint128 newSpotPrice, uint128 newDelta, uint256 outputValue, uint256 tradeFee, uint256 protocolFee ); }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; contract CurveErrorCodes { enum Error { OK, // No error INVALID_NUMITEMS, // The numItem value is 0 SPOT_PRICE_OVERFLOW, // The updated spot price doesn't fit into 128 bits DELTA_OVERFLOW, // The updated delta doesn't fit into 128 bits SPOT_PRICE_UNDERFLOW // The updated spot price goes too low } }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.4; interface IOwnershipTransferReceiver { function onOwnershipTransferred(address oldOwner, bytes memory data) external payable; }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.4; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import {IOwnershipTransferReceiver} from "./IOwnershipTransferReceiver.sol"; abstract contract OwnableWithTransferCallback { using ERC165Checker for address; using Address for address; bytes4 constant TRANSFER_CALLBACK = type(IOwnershipTransferReceiver).interfaceId; error Ownable_NotOwner(); error Ownable_NewOwnerZeroAddress(); address private _owner; event OwnershipTransferred(address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal { _owner = initialOwner; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { if (owner() != msg.sender) revert Ownable_NotOwner(); _; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * @param newOwner The new address to become owner * @param data Any additional data to send to the ownership received callback. * Disallows setting to the zero address as a way to more gas-efficiently avoid reinitialization. * When ownership is transferred, if the new owner implements IOwnershipTransferCallback, we make a callback. * Can only be called by the current owner. */ function transferOwnership(address newOwner, bytes calldata data) public payable virtual onlyOwner { if (newOwner == address(0)) revert Ownable_NewOwnerZeroAddress(); _transferOwnership(newOwner); if (newOwner.isContract()) { try IOwnershipTransferReceiver(newOwner).onOwnershipTransferred{value: msg.value}(msg.sender, data) {} // If revert... catch (bytes memory reason) { // If we just transferred to a contract w/ no callback, this is fine if (reason.length == 0) { // i.e., no need to revert } // Otherwise, the callback had an error, and we should revert else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @notice Transfers ownership of the contract to a new account (`newOwner`). * @dev Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { _owner = newOwner; emit OwnershipTransferred(newOwner); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) pragma solidity ^0.8.0; import "../IERC1155Receiver.sol"; import "../../../utils/introspection/ERC165.sol"; /** * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.2) (utils/introspection/ERC165Checker.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface. */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) && !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces( address account, bytes4[] memory interfaceIds ) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * * Some precompiled contracts will falsely indicate support for a given interface, so caution * should be exercised when using this function. * * Interface identification is specified in ERC-165. */ function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) { // prepare call bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId); // perform static call bool success; uint256 returnSize; uint256 returnValue; assembly { success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20) returnSize := returndatasize() returnValue := mload(0x00) } return success && returnSize >= 0x20 && returnValue > 0; } }
// 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 (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; } }
{ "remappings": [ "@manifoldxyz/=lib/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@prb/math/=lib/prb-math/src/", "clones-with-immutable-args/=lib/clones-with-immutable-args/src/", "create3-factory/=lib/create3-factory/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "libraries-solidity/=lib/libraries-solidity/contracts/", "manifoldxyz/=lib/royalty-registry-solidity/contracts/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", "royalty-registry-solidity/=lib/royalty-registry-solidity/contracts/", "solmate/=lib/solmate/src/" ], "optimizer": { "enabled": true, "runs": 1000000 }, "metadata": { "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IRoyaltyEngineV1","name":"royaltyEngine","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"LSSVMPairETH__InsufficientInput","type":"error"},{"inputs":[],"name":"LSSVMPair__AlreadyInitialized","type":"error"},{"inputs":[{"internalType":"enum CurveErrorCodes.Error","name":"error","type":"uint8"}],"name":"LSSVMPair__BondingCurveError","type":"error"},{"inputs":[],"name":"LSSVMPair__CallFailed","type":"error"},{"inputs":[],"name":"LSSVMPair__DemandedInputTooLarge","type":"error"},{"inputs":[],"name":"LSSVMPair__FunctionNotAllowed","type":"error"},{"inputs":[],"name":"LSSVMPair__InvalidDelta","type":"error"},{"inputs":[],"name":"LSSVMPair__InvalidSpotPrice","type":"error"},{"inputs":[],"name":"LSSVMPair__NftNotTransferred","type":"error"},{"inputs":[],"name":"LSSVMPair__NonTradePoolWithTradeFee","type":"error"},{"inputs":[],"name":"LSSVMPair__NotRouter","type":"error"},{"inputs":[],"name":"LSSVMPair__OutputTooSmall","type":"error"},{"inputs":[],"name":"LSSVMPair__RoyaltyTooLarge","type":"error"},{"inputs":[],"name":"LSSVMPair__TargetNotAllowed","type":"error"},{"inputs":[],"name":"LSSVMPair__TradeFeeTooLarge","type":"error"},{"inputs":[],"name":"LSSVMPair__WrongPoolType","type":"error"},{"inputs":[],"name":"LSSVMPair__ZeroSwapAmount","type":"error"},{"inputs":[],"name":"Ownable_NewOwnerZeroAddress","type":"error"},{"inputs":[],"name":"Ownable_NotOwner","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"a","type":"address"}],"name":"AssetRecipientChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"newDelta","type":"uint128"}],"name":"DeltaUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint96","name":"newFee","type":"uint96"}],"name":"FeeUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"NFTWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"numNFTs","type":"uint256"}],"name":"NFTWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"newSpotPrice","type":"uint128"}],"name":"SpotPriceUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"SwapNFTInPair","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numNFTs","type":"uint256"}],"name":"SwapNFTInPair","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"SwapNFTOutPair","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numNFTs","type":"uint256"}],"name":"SwapNFTOutPair","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenWithdrawal","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"ROYALTY_ENGINE","outputs":[{"internalType":"contract IRoyaltyEngineV1","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bondingCurve","outputs":[{"internalType":"contract ICurve","name":"_bondingCurve","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint256","name":"saleAmount","type":"uint256"}],"name":"calculateRoyaltiesView","outputs":[{"internalType":"address payable[]","name":"royaltyRecipients","type":"address[]"},{"internalType":"uint256[]","name":"royaltyAmounts","type":"uint256[]"},{"internalType":"uint256","name":"royaltyTotal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"target","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"call","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newRecipient","type":"address"}],"name":"changeAssetRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"newDelta","type":"uint128"}],"name":"changeDelta","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint96","name":"newFee","type":"uint96"}],"name":"changeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"newSpotPrice","type":"uint128"}],"name":"changeSpotPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delta","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"contract ILSSVMPairFactoryLike","name":"_factory","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAssetRecipient","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint256","name":"numNFTs","type":"uint256"}],"name":"getBuyNFTQuote","outputs":[{"internalType":"enum CurveErrorCodes.Error","name":"error","type":"uint8"},{"internalType":"uint256","name":"newSpotPrice","type":"uint256"},{"internalType":"uint256","name":"newDelta","type":"uint256"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"protocolFee","type":"uint256"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeeRecipient","outputs":[{"internalType":"address payable","name":"_feeRecipient","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint256","name":"numNFTs","type":"uint256"}],"name":"getSellNFTQuote","outputs":[{"internalType":"enum CurveErrorCodes.Error","name":"error","type":"uint8"},{"internalType":"uint256","name":"newSpotPrice","type":"uint256"},{"internalType":"uint256","name":"newDelta","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"protocolFee","type":"uint256"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address payable","name":"_assetRecipient","type":"address"},{"internalType":"uint128","name":"_delta","type":"uint128"},{"internalType":"uint96","name":"_fee","type":"uint96"},{"internalType":"uint128","name":"_spotPrice","type":"uint128"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"calls","type":"bytes[]"},{"internalType":"bool","name":"revertOnFail","type":"bool"}],"name":"multicall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nft","outputs":[{"internalType":"address","name":"_nft","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"nftId","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"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":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","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":"nonpayable","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":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pairVariant","outputs":[{"internalType":"enum ILSSVMPairFactoryLike.PairVariant","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"poolType","outputs":[{"internalType":"enum LSSVMPair.PoolType","name":"_poolType","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"spotPrice","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","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":"numNFTs","type":"uint256[]"},{"internalType":"uint256","name":"minExpectedTokenOutput","type":"uint256"},{"internalType":"address payable","name":"tokenRecipient","type":"address"},{"internalType":"bool","name":"isRouter","type":"bool"},{"internalType":"address","name":"routerCaller","type":"address"}],"name":"swapNFTsForToken","outputs":[{"internalType":"uint256","name":"outputAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"numNFTs","type":"uint256[]"},{"internalType":"uint256","name":"maxExpectedTokenInput","type":"uint256"},{"internalType":"address","name":"nftRecipient","type":"address"},{"internalType":"bool","name":"isRouter","type":"bool"},{"internalType":"address","name":"routerCaller","type":"address"}],"name":"swapTokenForSpecificNFTs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"withdrawAllETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC1155","name":"a","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"withdrawERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"a","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"a","type":"address"},{"internalType":"uint256[]","name":"nftIds","type":"uint256[]"}],"name":"withdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60a06040523480156200001157600080fd5b506040516200529d3803806200529d833981016040819052620000349162000046565b6001600160a01b031660805262000078565b6000602082840312156200005957600080fd5b81516001600160a01b03811681146200007157600080fd5b9392505050565b6080516151fb620000a2600039600081816104c3015281816122fc015261333101526151fb6000f3fe6080604052600436106102385760003560e01c80638c90821f11610138578063c45a0155116100b0578063eff1d50e1161007f578063f23a6e6111610064578063f23a6e6114610860578063f4629549146108a5578063fd17aef9146108c557610273565b8063eff1d50e14610807578063f14210a61461084057610273565b8063c45a015514610736578063c6bc51821461076f578063d8a1890c146107a5578063ddca3f43146107c557610273565b8063a5ceac9911610107578063b1d3f1c1116100ec578063b1d3f1c114610690578063b1dd61b6146106b0578063bc197c81146106f157610273565b8063a5ceac9914610641578063a736946b1461066157610273565b80638c90821f146105ce5780638da5cb5b146105e157806390386bbf1461060c578063a1db97821461062157610273565b806333b24a3a116101cb5780634ccb20c01161019a5780636b7a22001161017f5780636b7a2200146105785780636d8b99f71461059857806379eac6c2146105b957610273565b80634ccb20c0146105435780636809f6641461055857610273565b806333b24a3a14610468578063398482d814610488578063424c1179146104b157806347ccca021461050a57610273565b80631afd78c5116102075780631afd78c5146103da5780631b8b921d1461040c5780631e9701d41461042c5780633053fc581461044c57610273565b806301ffc9a7146102b057806312b495a8146102e557806313edab8114610343578063150b7a021461036557610273565b36610273576040513481527ff1b3be8dace0fecfbdb6fb0fa1cc014c612bcb1b46db027c1ece5fc11fff09d6906020015b60405180910390a1005b605d361461028057600080fd5b6040513481527ff1b3be8dace0fecfbdb6fb0fa1cc014c612bcb1b46db027c1ece5fc11fff09d690602001610269565b3480156102bc57600080fd5b506102d06102cb3660046142b8565b6108e5565b60405190151581526020015b60405180910390f35b3480156102f157600080fd5b506001546103229070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff90911681526020016102dc565b34801561034f57600080fd5b5061036361035e36600461436f565b61097e565b005b34801561037157600080fd5b506103a96103803660046144d0565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016102dc565b3480156103e657600080fd5b506103fa6103f536600461453c565b610acd565b6040516102dc969594939291906145a1565b34801561041857600080fd5b50610363610427366004614619565b610d14565b34801561043857600080fd5b5061036361044736600461466f565b6111ab565b34801561045857600080fd5b5060026040516102dc91906146c6565b34801561047457600080fd5b506103fa61048336600461453c565b611385565b34801561049457600080fd5b50600154610322906fffffffffffffffffffffffffffffffff1681565b3480156104bd57600080fd5b506104e57f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016102dc565b34801561051657600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb013560601c6104e5565b34801561054f57600080fd5b506104e56115a2565b34801561056457600080fd5b506103636105733660046146fe565b6115d6565b34801561058457600080fd5b50610363610593366004614735565b6117e4565b6105ab6105a6366004614752565b611997565b6040519081526020016102dc565b3480156105c557600080fd5b506104e5611d85565b6103636105dc366004614619565b611e1c565b3480156105ed57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166104e5565b34801561061857600080fd5b50610363611fc7565b34801561062d57600080fd5b5061036361063c3660046147d7565b61203f565b34801561064d57600080fd5b5061036361065c366004614803565b6120cd565b34801561066d57600080fd5b5061068161067c36600461453c565b6122de565b6040516102dc939291906148c1565b34801561069c57600080fd5b506105ab6106ab366004614752565b612422565b3480156106bc57600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c6040516102dc9190614936565b3480156106fd57600080fd5b506103a961070c3660046149d9565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561074257600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c6104e5565b34801561077b57600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001356105ab565b3480156107b157600080fd5b506103636107c03660046146fe565b6127cc565b3480156107d157600080fd5b506002546107ea906bffffffffffffffffffffffff1681565b6040516bffffffffffffffffffffffff90911681526020016102dc565b34801561081357600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c6104e5565b34801561084c57600080fd5b5061036361085b366004614a87565b6129c8565b34801561086c57600080fd5b506103a961087b366004614aa0565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156108b157600080fd5b506103636108c0366004614b09565b612a75565b3480156108d157600080fd5b506103636108e0366004614b26565b612b82565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e000000000000000000000000000000000000000000000000000000000148061097857507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b3361099e60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16146109eb576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060005b81811015610ac6578473ffffffffffffffffffffffffffffffffffffffff166342842e0e3033878786818110610a2757610a27614b97565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b16815273ffffffffffffffffffffffffffffffffffffffff958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b158015610aa357600080fd5b505af1158015610ab7573d6000803e3d6000fd5b505050508060010190506109ef565b5050505050565b6000808080808080367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c60015460025473ffffffffffffffffffffffffffffffffffffffff9290921691637ca542ac916fffffffffffffffffffffffffffffffff8082169270010000000000000000000000000000000090920416908c906bffffffffffffffffffffffff16367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c73ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf39190614bc6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526fffffffffffffffffffffffffffffffff958616600482015294909316602485015260448401919091526bffffffffffffffffffffffff166064830152608482015260a40160c060405180830381865afa158015610c81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca59190614bdf565b949b506fffffffffffffffffffffffffffffffff9384169a5091909216975090955090935090508715610d0957600083610cdf8387614c7b565b610ce99190614c7b565b9050610cf58a826122de565b9450610d05915084905086614c8e565b9450505b509295509295509295565b33610d3460005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610d81576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c6040517f1fba95e800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015291925090821690631fba95e890602401602060405180830381865afa158015610e1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3e9190614ca1565b610e74576040517fc439313a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610e836004828587614cbe565b610e8c91614ce8565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f66e5774a000000000000000000000000000000000000000000000000000000001480610f1f57507fffffffff0000000000000000000000000000000000000000000000000000000081167f938e37da00000000000000000000000000000000000000000000000000000000145b80610f6b57507fffffffff0000000000000000000000000000000000000000000000000000000081167f7b872f9e00000000000000000000000000000000000000000000000000000000145b80610fb757507fffffffff0000000000000000000000000000000000000000000000000000000081167fac482d1d00000000000000000000000000000000000000000000000000000000145b8061100357507fffffffff0000000000000000000000000000000000000000000000000000000081167f0e4860df00000000000000000000000000000000000000000000000000000000145b8061104f57507fffffffff0000000000000000000000000000000000000000000000000000000081167fd83ff79c00000000000000000000000000000000000000000000000000000000145b15611086576040517f7adc5f7100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb36013560601c73ffffffffffffffffffffffffffffffffffffffff8616036110fb576040517fc439313a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008573ffffffffffffffffffffffffffffffffffffffff1660008686604051611126929190614d30565b60006040518083038185875af1925050503d8060008114611163576040519150601f19603f3d011682016040523d82523d6000602084013e611168565b606091505b50509050806111a3576040517f52574fde00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050565b336111cb60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611218576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8281101561137f57600084848381811061123757611237614b97565b90506020028101906112499190614d40565b61125891600491600091614cbe565b61126191614ce8565b90507f736f7de1000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008216016112de576040517f7adc5f7100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080308787868181106112f4576112f4614b97565b90506020028101906113069190614d40565b604051611314929190614d30565b600060405180830381855af49150503d806000811461134f576040519150601f19603f3d011682016040523d82523d6000602084013e611354565b606091505b5091509150811580156113645750845b1561137157805181602001fd5b83600101935050505061121b565b50505050565b60008080808080367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c60015460025473ffffffffffffffffffffffffffffffffffffffff929092169163097cc63d916fffffffffffffffffffffffffffffffff8082169270010000000000000000000000000000000090920416908b906bffffffffffffffffffffffff16367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c73ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114aa9190614bc6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526fffffffffffffffffffffffffffffffff958616600482015294909316602485015260448401919091526bffffffffffffffffffffffff166064830152608482015260a40160c060405180830381865afa158015611538573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155c9190614bdf565b949a50506fffffffffffffffffffffffffffffffff9283169850911695509350915086156115985761158e88846122de565b9485900394925050505b9295509295509295565b6002546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff16806115d35750305b90565b336115f660005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611643576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c6040517f0ae67ccc0000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff8416600482015290915073ffffffffffffffffffffffffffffffffffffffff821690630ae67ccc90602401602060405180830381865afa1580156116eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170f9190614ca1565b611745576040517ff863cd2500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001546fffffffffffffffffffffffffffffffff83811670010000000000000000000000000000000090920416146117e057600180546fffffffffffffffffffffffffffffffff908116700100000000000000000000000000000000918516918202179091556040519081527fc958ae052d28f8d17bc2c4ddbabb699a3cab5cccefd034d0fc971efdadc01da5906020015b60405180910390a15b5050565b3361180460005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611851576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf36013560f81c6002818181111561188b5761188b61455e565b146118c2576040517fecb8010500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6706f05b59d3b20000826bffffffffffffffffffffffff161115611912576040517f9cc0093b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002546bffffffffffffffffffffffff8381169116146117e057600280547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff84169081179091556040519081527f66c55c30868c51e7ad52e3d85d1403576a9967614e67c48e25b55a10baa650c0906020016117d7565b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c73ffffffffffffffffffffffffffffffffffffffff16630e4860df6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611a0757600080fd5b505af1158015611a1b573d6000803e3d6000fd5b5060009250611a28915050565b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c6002811115611a6057611a6061455e565b03611a97576040517fa284414700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600186141580611ac0575086866000818110611ab557611ab5614b97565b905060200201356000145b15611af7576040517f3b4935ad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000611b728a8a6000818110611b1257611b12614b97565b90506020020135611b467fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb736013560601c90565b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c612f89565b9194509250905060008080611bbe367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0013587611baf8888614c7b565b611bb99190614c7b565b613313565b919450925090508a611bd08583614c8e565b1115611c08576040517f15d61d4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611c2284838584611c1a8b6002614da5565b8e8e8c6133f5565b611c6c367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb013560601c8b8f8f6000818110611c6057611c60614b97565b905060200201356135e9565b611c7e611c798583614c8e565b6136a9565b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c73ffffffffffffffffffffffffffffffffffffffff1663d83ff79c6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611cec57600080fd5b505af1158015611d00573d6000803e3d6000fd5b505050507fd9c2402e1a067734ae78dab98f06d5b28e8a2d2c6370ec0e6ff8cc2749d050f18482611d319190614c8e565b8e8e6000818110611d4457611d44614b97565b90506020020135604051611d62929190918252602082015260400190565b60405180910390a1611d748482614c8e565b9d9c50505050505050505050505050565b60006002367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c6002811115611dc157611dc161455e565b03611dcb57503090565b6002546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1680611e1757505060005473ffffffffffffffffffffffffffffffffffffffff1690565b919050565b33611e3c60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611e89576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316611ed6576040517fedf1b1fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611edf836136c5565b73ffffffffffffffffffffffffffffffffffffffff83163b15611fc2576040517f66e5774a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416906366e5774a903490611f5490339087908790600401614dbc565b6000604051808303818588803b158015611f6d57600080fd5b505af193505050508015611f7f575060015b611fc2573d808015611fad576040519150601f19603f3d011682016040523d82523d6000602084013e611fb2565b606091505b5080511561137f57805181602001fd5b505050565b33611fe760005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614612034576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61203d476129c8565b565b3361205f60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16146120ac576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6117e073ffffffffffffffffffffffffffffffffffffffff83163383613732565b336120ed60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff161461213a576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb36013560601c73ffffffffffffffffffffffffffffffffffffffff86160361223b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0360135836000805b828110156121fc57838888838181106121c1576121c1614b97565b90506020020135036121f4578585828181106121df576121df614b97565b90506020020135826121f19190614c8e565b91505b6001016121a6565b508015612237576040518181527fd26d84b7e96b5b61cbb9f851a5a2953408c61abc7502e33a59d3e6146c0428b09060200160405180910390a15b5050505b604080516020810182526000815290517f2eb2c2d600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff871691632eb2c2d6916122a591309133918a918a918a918a9190600401614ed5565b600060405180830381600087803b1580156122bf57600080fd5b505af11580156122d3573d6000803e3d6000fd5b505050505050505050565b6060806000808073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016633e104014367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb0135861c6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018a905260448101899052606401600060405180830381865afa1580156123be573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526124049190810190614f9f565b915091506124138282886137eb565b94509450945050509250925092565b600080367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c90508073ffffffffffffffffffffffffffffffffffffffff16630e4860df6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561249657600080fd5b505af11580156124aa573d6000803e3d6000fd5b5050505060006124dd7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb736013560601c90565b90506001367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c60028111156125195761251961455e565b03612550576040517fa284414700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018814158061257957508888600081811061256e5761256e614b97565b905060200201356000145b156125b0576040517f3b4935ad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006125d68a8a60008181106125c8576125c8614b97565b905060200201358385613a47565b945090506000808061260b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0013588613313565b92509250925080870396508a871015612650576040517fa74ea4b100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61269c367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb013560601c8e8e600081811061268d5761268d614b97565b90506020020135888c8c613dc5565b6126a68a88614221565b60005b83518110156126f6576126ee8482815181106126c7576126c7614b97565b60200260200101518483815181106126e1576126e1614b97565b6020026020010151614221565b6001016126a9565b506127018685614221565b8573ffffffffffffffffffffffffffffffffffffffff1663d83ff79c6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561274957600080fd5b505af115801561275d573d6000803e3d6000fd5b505050507f58e7e2e8d4c949c019e4fe5f6e2a8f10e4e078a8747730386e9a230da8c969f0878e8e600081811061279657612796614b97565b905060200201356040516127b4929190918252602082015260400190565b60405180910390a15050505050509695505050505050565b336127ec60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614612839576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c6040517fa1bbb2e80000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff8416600482015290915073ffffffffffffffffffffffffffffffffffffffff82169063a1bbb2e890602401602060405180830381865afa1580156128e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129059190614ca1565b61293b576040517fff2848d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001546fffffffffffffffffffffffffffffffff8381169116146117e057600180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff84169081179091556040519081527ff06180fdbe95e5193df4dcd1352726b1f04cb58599ce58552cc952447af2ffbb906020016117d7565b336129e860005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614612a35576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612a3f3382614243565b6040518181527f0e266e8f38544aa1480d73762386eb10df55b1b8453d935762e891c44b69a1e69060200160405180910390a150565b33612a9560005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614612ae2576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025473ffffffffffffffffffffffffffffffffffffffff8281166c010000000000000000000000009092041614612b7f57600280546bffffffffffffffffffffffff166c0100000000000000000000000073ffffffffffffffffffffffffffffffffffffffff8416908102919091179091556040517f678f61dcdee86474eddea0407caf8f1f5130382a90dedabaef94906ed86a27b490600090a25b50565b60005473ffffffffffffffffffffffffffffffffffffffff1615612bd2576040517fe262b52400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff87161790556000612c417fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb736013560601c90565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf36013560f81c60028181811115612c7d57612c7d61455e565b14612ccd576bffffffffffffffffffffffff841615612cc8576040517fecb8010500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612d56565b6706f05b59d3b20000846bffffffffffffffffffffffff161115612d1d576040517f9cc0093b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff86161790555b6002805473ffffffffffffffffffffffffffffffffffffffff8881166c01000000000000000000000000026bffffffffffffffffffffffff909216919091179091556040517f0ae67ccc0000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff8716600482015290831690630ae67ccc90602401602060405180830381865afa158015612e00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e249190614ca1565b612e5a576040517ff863cd2500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa1bbb2e80000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83169063a1bbb2e890602401602060405180830381865afa158015612ed6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612efa9190614ca1565b612f30576040517fff2848d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50506fffffffffffffffffffffffffffffffff9081169216700100000000000000000000000000000000027fffffffffffffffffffffffffffffffff000000000000000000000000000000001691909117600155505050565b6000806000806000600160009054906101000a90046fffffffffffffffffffffffffffffffff1690506000600160109054906101000a90046fffffffffffffffffffffffffffffffff1690506000808973ffffffffffffffffffffffffffffffffffffffff16637ca542ac85858e600260009054906101000a90046bffffffffffffffffffffffff168e73ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561305d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130819190614bc6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526fffffffffffffffffffffffffffffffff958616600482015294909316602485015260448401919091526bffffffffffffffffffffffff166064830152608482015260a40160c060405180830381865afa15801561310f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131339190614bdf565b909c509a509850919650909250905060008560048111156131565761315661455e565b1461319857846040517f17ca377000000000000000000000000000000000000000000000000000000000815260040161318f9190615064565b60405180910390fd5b806fffffffffffffffffffffffffffffffff16846fffffffffffffffffffffffffffffffff161415806131ef5750816fffffffffffffffffffffffffffffffff16836fffffffffffffffffffffffffffffffff1614155b15613223576fffffffffffffffffffffffffffffffff82811670010000000000000000000000000000000002908216176001555b806fffffffffffffffffffffffffffffffff16846fffffffffffffffffffffffffffffffff1614613294576040516fffffffffffffffffffffffffffffffff821681527ff06180fdbe95e5193df4dcd1352726b1f04cb58599ce58552cc952447af2ffbb9060200160405180910390a15b816fffffffffffffffffffffffffffffffff16836fffffffffffffffffffffffffffffffff1614613305576040516fffffffffffffffffffffffffffffffff831681527fc958ae052d28f8d17bc2c4ddbabb699a3cab5cccefd034d0fc971efdadc01da59060200160405180910390a15b505050505093509350939050565b6060806000808073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001663f533b802367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb0135861c6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018a9052604481018990526064016000604051808303816000875af11580156123be573d6000803e3d6000fd5b6133ff8886614c8e565b341015613438576040517f9d981d3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000613442611d85565b90506002367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c600281111561347e5761347e61455e565b14801561348a57508415155b156134fc5760006134996115a2565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146134fa576134d8868b614c7b565b99506134fa73ffffffffffffffffffffffffffffffffffffffff821687614243565b505b73ffffffffffffffffffffffffffffffffffffffff8116301461354357613543613526838b614c7b565b73ffffffffffffffffffffffffffffffffffffffff831690614243565b60005b87518110156135b2576135aa89828151811061356457613564614b97565b602002602001015189838151811061357e5761357e614b97565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1661424390919063ffffffff16565b600101613546565b5081156122d3576122d37fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa336013560601c83614243565b604080516020810182526000815290517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169163f242432a9161367291309187917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe036013591889190600401615072565b600060405180830381600087803b15801561368c57600080fd5b505af11580156136a0573d6000803e3d6000fd5b50505050505050565b80341115612b7f57612b7f6136be8234614c7b565b3390614243565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc68616391a250565b60006040517fa9059cbb000000000000000000000000000000000000000000000000000000008152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061137f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5452414e534645525f4641494c45440000000000000000000000000000000000604482015260640161318f565b8251606090819060009080156139c457367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c6040517f0b89849300000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9190911690630b898493906024016040805180830381865afa9250505080156138c7575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526138c4918101906150c2565b60015b6138d6578693508592506139c4565b81156139ba5760408051600180825281830190925290602080830190803683370190505095508860008151811061390f5761390f614b97565b60200260200101518660008151811061392a5761392a614b97565b73ffffffffffffffffffffffffffffffffffffffff929092166020928302919091018201526040805160018082528183019092529182810190803683370190505094506127106139886bffffffffffffffffffffffff831689614da5565b61399291906150fc565b856000815181106139a5576139a5614b97565b602002602001018181525050600192506139c1565b8895508794505b50505b60005b818110156139fe578381815181106139e1576139e1614b97565b6020026020010151836139f49190614c8e565b92506001016139c7565b50600285901c821115613a3d576040517fb30f15ef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5093509350939050565b600080600080600160009054906101000a90046fffffffffffffffffffffffffffffffff1690506000600160109054906101000a90046fffffffffffffffffffffffffffffffff1690506000808873ffffffffffffffffffffffffffffffffffffffff1663097cc63d85858d600260009054906101000a90046bffffffffffffffffffffffff168d73ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613b19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b3d9190614bc6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526fffffffffffffffffffffffffffffffff958616600482015294909316602485015260448401919091526bffffffffffffffffffffffff166064830152608482015260a40160c060405180830381865afa158015613bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bef9190614bdf565b9b50909950929750909350915060009050856004811115613c1257613c1261455e565b14613c4b57846040517f17ca377000000000000000000000000000000000000000000000000000000000815260040161318f9190615064565b816fffffffffffffffffffffffffffffffff16846fffffffffffffffffffffffffffffffff16141580613ca25750806fffffffffffffffffffffffffffffffff16836fffffffffffffffffffffffffffffffff1614155b15613cd6576fffffffffffffffffffffffffffffffff81811670010000000000000000000000000000000002908316176001555b816fffffffffffffffffffffffffffffffff16846fffffffffffffffffffffffffffffffff1614613d47576040516fffffffffffffffffffffffffffffffff831681527ff06180fdbe95e5193df4dcd1352726b1f04cb58599ce58552cc952447af2ffbb9060200160405180910390a15b806fffffffffffffffffffffffffffffffff16836fffffffffffffffffffffffffffffffff1614613db8576040516fffffffffffffffffffffffffffffffff821681527fc958ae052d28f8d17bc2c4ddbabb699a3cab5cccefd034d0fc971efdadc01da59060200160405180910390a15b5050505050935093915050565b6000613dcf611d85565b9050821561415e576040517fa93ec68b00000000000000000000000000000000000000000000000000000000815233600482018190529060009073ffffffffffffffffffffffffffffffffffffffff87169063a93ec68b906024016040805180830381865afa158015613e46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e6a9190615137565b50905080613ea4576040517f3f80c4c000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001356040517efdd58e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018390529192506000918b169062fdd58e90604401602060405180830381865afa158015613f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f659190614bc6565b60408051600180825281830190925291925060009190602080830190803683370190505090508281600081518110613f9f57613f9f614b97565b60209081029190910101526040805160018082528183019092526000918160200160208202803683370190505090508a81600081518110613fe257613fe2614b97565b60209081029190910101526040517fac482d1d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87169063ac482d1d90614047908f908c908c9088908890600401615166565b600060405180830381600087803b15801561406157600080fd5b505af1158015614075573d6000803e3d6000fd5b50506040517efdd58e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a81166004830152602482018890528e93508692508f169062fdd58e90604401602060405180830381865afa1580156140ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141129190614bc6565b61411c9190614c7b565b14614153576040517fda276afb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050506111a3565b604080516020810182526000815290517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169163f242432a916141e791339186917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0360135918c9190600401615072565b600060405180830381600087803b15801561420157600080fd5b505af1158015614215573d6000803e3d6000fd5b50505050505050505050565b80156117e0576117e073ffffffffffffffffffffffffffffffffffffffff8316825b600080600080600085875af1905080611fc2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4554485f5452414e534645525f4641494c454400000000000000000000000000604482015260640161318f565b6000602082840312156142ca57600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146142fa57600080fd5b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81168114612b7f57600080fd5b60008083601f84011261433557600080fd5b50813567ffffffffffffffff81111561434d57600080fd5b6020830191508360208260051b850101111561436857600080fd5b9250929050565b60008060006040848603121561438457600080fd5b833561438f81614301565b9250602084013567ffffffffffffffff8111156143ab57600080fd5b6143b786828701614323565b9497909650939450505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561443a5761443a6143c4565b604052919050565b600082601f83011261445357600080fd5b813567ffffffffffffffff81111561446d5761446d6143c4565b61449e60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016143f3565b8181528460208386010111156144b357600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080608085870312156144e657600080fd5b84356144f181614301565b9350602085013561450181614301565b925060408501359150606085013567ffffffffffffffff81111561452457600080fd5b61453087828801614442565b91505092959194509250565b6000806040838503121561454f57600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6005811061459d5761459d61455e565b9052565b60c081016145af828961458d565b602082019690965260408101949094526060840192909252608083015260a090910152919050565b60008083601f8401126145e957600080fd5b50813567ffffffffffffffff81111561460157600080fd5b60208301915083602082850101111561436857600080fd5b60008060006040848603121561462e57600080fd5b833561463981614301565b9250602084013567ffffffffffffffff81111561465557600080fd5b6143b7868287016145d7565b8015158114612b7f57600080fd5b60008060006040848603121561468457600080fd5b833567ffffffffffffffff81111561469b57600080fd5b6146a786828701614323565b90945092505060208401356146bb81614661565b809150509250925092565b60208101600483106146da576146da61455e565b91905290565b6fffffffffffffffffffffffffffffffff81168114612b7f57600080fd5b60006020828403121561471057600080fd5b81356142fa816146e0565b6bffffffffffffffffffffffff81168114612b7f57600080fd5b60006020828403121561474757600080fd5b81356142fa8161471b565b60008060008060008060a0878903121561476b57600080fd5b863567ffffffffffffffff81111561478257600080fd5b61478e89828a01614323565b9097509550506020870135935060408701356147a981614301565b925060608701356147b981614661565b915060808701356147c981614301565b809150509295509295509295565b600080604083850312156147ea57600080fd5b82356147f581614301565b946020939093013593505050565b60008060008060006060868803121561481b57600080fd5b853561482681614301565b9450602086013567ffffffffffffffff8082111561484357600080fd5b61484f89838a01614323565b9096509450604088013591508082111561486857600080fd5b5061487588828901614323565b969995985093965092949392505050565b600081518084526020808501945080840160005b838110156148b65781518752958201959082019060010161489a565b509495945050505050565b606080825284519082018190526000906020906080840190828801845b8281101561491057815173ffffffffffffffffffffffffffffffffffffffff16845292840192908401906001016148de565b505050838103828501526149248187614886565b92505050826040830152949350505050565b60208101600383106146da576146da61455e565b600067ffffffffffffffff821115614964576149646143c4565b5060051b60200190565b600082601f83011261497f57600080fd5b8135602061499461498f8361494a565b6143f3565b82815260059290921b840181019181810190868411156149b357600080fd5b8286015b848110156149ce57803583529183019183016149b7565b509695505050505050565b600080600080600060a086880312156149f157600080fd5b85356149fc81614301565b94506020860135614a0c81614301565b9350604086013567ffffffffffffffff80821115614a2957600080fd5b614a3589838a0161496e565b94506060880135915080821115614a4b57600080fd5b614a5789838a0161496e565b93506080880135915080821115614a6d57600080fd5b50614a7a88828901614442565b9150509295509295909350565b600060208284031215614a9957600080fd5b5035919050565b600080600080600060a08688031215614ab857600080fd5b8535614ac381614301565b94506020860135614ad381614301565b93506040860135925060608601359150608086013567ffffffffffffffff811115614afd57600080fd5b614a7a88828901614442565b600060208284031215614b1b57600080fd5b81356142fa81614301565b600080600080600060a08688031215614b3e57600080fd5b8535614b4981614301565b94506020860135614b5981614301565b93506040860135614b69816146e0565b92506060860135614b798161471b565b91506080860135614b89816146e0565b809150509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215614bd857600080fd5b5051919050565b60008060008060008060c08789031215614bf857600080fd5b865160058110614c0757600080fd5b6020880151909650614c18816146e0565b6040880151909550614c29816146e0565b80945050606087015192506080870151915060a087015190509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561097857610978614c4c565b8082018082111561097857610978614c4c565b600060208284031215614cb357600080fd5b81516142fa81614661565b60008085851115614cce57600080fd5b83861115614cdb57600080fd5b5050820193919092039150565b7fffffffff000000000000000000000000000000000000000000000000000000008135818116916004851015614d285780818660040360031b1b83161692505b505092915050565b8183823760009101908152919050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112614d7557600080fd5b83018035915067ffffffffffffffff821115614d9057600080fd5b60200191503681900382131561436857600080fd5b808202811582820484141761097857610978614c4c565b73ffffffffffffffffffffffffffffffffffffffff8416815260406020820152816040820152818360608301376000818301606090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010192915050565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115614e5857600080fd5b8260051b80836020870137939093016020019392505050565b6000815180845260005b81811015614e9757602081850181015186830182015201614e7b565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600073ffffffffffffffffffffffffffffffffffffffff808a16835280891660208401525060a06040830152614f0f60a083018789614e26565b8281036060840152614f22818688614e26565b90508281036080840152614f368185614e71565b9a9950505050505050505050565b600082601f830112614f5557600080fd5b81516020614f6561498f8361494a565b82815260059290921b84018101918181019086841115614f8457600080fd5b8286015b848110156149ce5780518352918301918301614f88565b60008060408385031215614fb257600080fd5b825167ffffffffffffffff80821115614fca57600080fd5b818501915085601f830112614fde57600080fd5b81516020614fee61498f8361494a565b82815260059290921b8401810191818101908984111561500d57600080fd5b948201945b8386101561503457855161502581614301565b82529482019490820190615012565b9188015191965090935050508082111561504d57600080fd5b5061505a85828601614f44565b9150509250929050565b60208101610978828461458d565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015283606083015260a060808301526150b760a0830184614e71565b979650505050505050565b600080604083850312156150d557600080fd5b82516150e081614661565b60208401519092506150f18161471b565b809150509250929050565b600082615132577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000806040838503121561514a57600080fd5b825161515581614661565b60208401519092506150f181614661565b600073ffffffffffffffffffffffffffffffffffffffff8088168352808716602084015280861660408401525060a060608301526151a760a0830185614886565b82810360808401526151b98185614886565b9897505050505050505056fea2646970667358221220773129a088e95bdba990c30c7efee20cf49b850e33dc770f6fa192f88df376d764736f6c63430008140033000000000000000000000000bc40d21999b4bf120d330ee3a2de415287f626c9
Deployed Bytecode
0x6080604052600436106102385760003560e01c80638c90821f11610138578063c45a0155116100b0578063eff1d50e1161007f578063f23a6e6111610064578063f23a6e6114610860578063f4629549146108a5578063fd17aef9146108c557610273565b8063eff1d50e14610807578063f14210a61461084057610273565b8063c45a015514610736578063c6bc51821461076f578063d8a1890c146107a5578063ddca3f43146107c557610273565b8063a5ceac9911610107578063b1d3f1c1116100ec578063b1d3f1c114610690578063b1dd61b6146106b0578063bc197c81146106f157610273565b8063a5ceac9914610641578063a736946b1461066157610273565b80638c90821f146105ce5780638da5cb5b146105e157806390386bbf1461060c578063a1db97821461062157610273565b806333b24a3a116101cb5780634ccb20c01161019a5780636b7a22001161017f5780636b7a2200146105785780636d8b99f71461059857806379eac6c2146105b957610273565b80634ccb20c0146105435780636809f6641461055857610273565b806333b24a3a14610468578063398482d814610488578063424c1179146104b157806347ccca021461050a57610273565b80631afd78c5116102075780631afd78c5146103da5780631b8b921d1461040c5780631e9701d41461042c5780633053fc581461044c57610273565b806301ffc9a7146102b057806312b495a8146102e557806313edab8114610343578063150b7a021461036557610273565b36610273576040513481527ff1b3be8dace0fecfbdb6fb0fa1cc014c612bcb1b46db027c1ece5fc11fff09d6906020015b60405180910390a1005b605d361461028057600080fd5b6040513481527ff1b3be8dace0fecfbdb6fb0fa1cc014c612bcb1b46db027c1ece5fc11fff09d690602001610269565b3480156102bc57600080fd5b506102d06102cb3660046142b8565b6108e5565b60405190151581526020015b60405180910390f35b3480156102f157600080fd5b506001546103229070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff90911681526020016102dc565b34801561034f57600080fd5b5061036361035e36600461436f565b61097e565b005b34801561037157600080fd5b506103a96103803660046144d0565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016102dc565b3480156103e657600080fd5b506103fa6103f536600461453c565b610acd565b6040516102dc969594939291906145a1565b34801561041857600080fd5b50610363610427366004614619565b610d14565b34801561043857600080fd5b5061036361044736600461466f565b6111ab565b34801561045857600080fd5b5060026040516102dc91906146c6565b34801561047457600080fd5b506103fa61048336600461453c565b611385565b34801561049457600080fd5b50600154610322906fffffffffffffffffffffffffffffffff1681565b3480156104bd57600080fd5b506104e57f000000000000000000000000bc40d21999b4bf120d330ee3a2de415287f626c981565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016102dc565b34801561051657600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb013560601c6104e5565b34801561054f57600080fd5b506104e56115a2565b34801561056457600080fd5b506103636105733660046146fe565b6115d6565b34801561058457600080fd5b50610363610593366004614735565b6117e4565b6105ab6105a6366004614752565b611997565b6040519081526020016102dc565b3480156105c557600080fd5b506104e5611d85565b6103636105dc366004614619565b611e1c565b3480156105ed57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166104e5565b34801561061857600080fd5b50610363611fc7565b34801561062d57600080fd5b5061036361063c3660046147d7565b61203f565b34801561064d57600080fd5b5061036361065c366004614803565b6120cd565b34801561066d57600080fd5b5061068161067c36600461453c565b6122de565b6040516102dc939291906148c1565b34801561069c57600080fd5b506105ab6106ab366004614752565b612422565b3480156106bc57600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c6040516102dc9190614936565b3480156106fd57600080fd5b506103a961070c3660046149d9565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561074257600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c6104e5565b34801561077b57600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001356105ab565b3480156107b157600080fd5b506103636107c03660046146fe565b6127cc565b3480156107d157600080fd5b506002546107ea906bffffffffffffffffffffffff1681565b6040516bffffffffffffffffffffffff90911681526020016102dc565b34801561081357600080fd5b50367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c6104e5565b34801561084c57600080fd5b5061036361085b366004614a87565b6129c8565b34801561086c57600080fd5b506103a961087b366004614aa0565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156108b157600080fd5b506103636108c0366004614b09565b612a75565b3480156108d157600080fd5b506103636108e0366004614b26565b612b82565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e000000000000000000000000000000000000000000000000000000000148061097857507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b3361099e60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16146109eb576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060005b81811015610ac6578473ffffffffffffffffffffffffffffffffffffffff166342842e0e3033878786818110610a2757610a27614b97565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b16815273ffffffffffffffffffffffffffffffffffffffff958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b158015610aa357600080fd5b505af1158015610ab7573d6000803e3d6000fd5b505050508060010190506109ef565b5050505050565b6000808080808080367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c60015460025473ffffffffffffffffffffffffffffffffffffffff9290921691637ca542ac916fffffffffffffffffffffffffffffffff8082169270010000000000000000000000000000000090920416908c906bffffffffffffffffffffffff16367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c73ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf39190614bc6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526fffffffffffffffffffffffffffffffff958616600482015294909316602485015260448401919091526bffffffffffffffffffffffff166064830152608482015260a40160c060405180830381865afa158015610c81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca59190614bdf565b949b506fffffffffffffffffffffffffffffffff9384169a5091909216975090955090935090508715610d0957600083610cdf8387614c7b565b610ce99190614c7b565b9050610cf58a826122de565b9450610d05915084905086614c8e565b9450505b509295509295509295565b33610d3460005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610d81576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c6040517f1fba95e800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015291925090821690631fba95e890602401602060405180830381865afa158015610e1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3e9190614ca1565b610e74576040517fc439313a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610e836004828587614cbe565b610e8c91614ce8565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f66e5774a000000000000000000000000000000000000000000000000000000001480610f1f57507fffffffff0000000000000000000000000000000000000000000000000000000081167f938e37da00000000000000000000000000000000000000000000000000000000145b80610f6b57507fffffffff0000000000000000000000000000000000000000000000000000000081167f7b872f9e00000000000000000000000000000000000000000000000000000000145b80610fb757507fffffffff0000000000000000000000000000000000000000000000000000000081167fac482d1d00000000000000000000000000000000000000000000000000000000145b8061100357507fffffffff0000000000000000000000000000000000000000000000000000000081167f0e4860df00000000000000000000000000000000000000000000000000000000145b8061104f57507fffffffff0000000000000000000000000000000000000000000000000000000081167fd83ff79c00000000000000000000000000000000000000000000000000000000145b15611086576040517f7adc5f7100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb36013560601c73ffffffffffffffffffffffffffffffffffffffff8616036110fb576040517fc439313a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008573ffffffffffffffffffffffffffffffffffffffff1660008686604051611126929190614d30565b60006040518083038185875af1925050503d8060008114611163576040519150601f19603f3d011682016040523d82523d6000602084013e611168565b606091505b50509050806111a3576040517f52574fde00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050565b336111cb60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611218576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8281101561137f57600084848381811061123757611237614b97565b90506020028101906112499190614d40565b61125891600491600091614cbe565b61126191614ce8565b90507f736f7de1000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008216016112de576040517f7adc5f7100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080308787868181106112f4576112f4614b97565b90506020028101906113069190614d40565b604051611314929190614d30565b600060405180830381855af49150503d806000811461134f576040519150601f19603f3d011682016040523d82523d6000602084013e611354565b606091505b5091509150811580156113645750845b1561137157805181602001fd5b83600101935050505061121b565b50505050565b60008080808080367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c60015460025473ffffffffffffffffffffffffffffffffffffffff929092169163097cc63d916fffffffffffffffffffffffffffffffff8082169270010000000000000000000000000000000090920416908b906bffffffffffffffffffffffff16367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c73ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114aa9190614bc6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526fffffffffffffffffffffffffffffffff958616600482015294909316602485015260448401919091526bffffffffffffffffffffffff166064830152608482015260a40160c060405180830381865afa158015611538573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155c9190614bdf565b949a50506fffffffffffffffffffffffffffffffff9283169850911695509350915086156115985761158e88846122de565b9485900394925050505b9295509295509295565b6002546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff16806115d35750305b90565b336115f660005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611643576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c6040517f0ae67ccc0000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff8416600482015290915073ffffffffffffffffffffffffffffffffffffffff821690630ae67ccc90602401602060405180830381865afa1580156116eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170f9190614ca1565b611745576040517ff863cd2500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001546fffffffffffffffffffffffffffffffff83811670010000000000000000000000000000000090920416146117e057600180546fffffffffffffffffffffffffffffffff908116700100000000000000000000000000000000918516918202179091556040519081527fc958ae052d28f8d17bc2c4ddbabb699a3cab5cccefd034d0fc971efdadc01da5906020015b60405180910390a15b5050565b3361180460005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611851576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf36013560f81c6002818181111561188b5761188b61455e565b146118c2576040517fecb8010500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6706f05b59d3b20000826bffffffffffffffffffffffff161115611912576040517f9cc0093b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002546bffffffffffffffffffffffff8381169116146117e057600280547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff84169081179091556040519081527f66c55c30868c51e7ad52e3d85d1403576a9967614e67c48e25b55a10baa650c0906020016117d7565b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c73ffffffffffffffffffffffffffffffffffffffff16630e4860df6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611a0757600080fd5b505af1158015611a1b573d6000803e3d6000fd5b5060009250611a28915050565b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c6002811115611a6057611a6061455e565b03611a97576040517fa284414700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600186141580611ac0575086866000818110611ab557611ab5614b97565b905060200201356000145b15611af7576040517f3b4935ad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000611b728a8a6000818110611b1257611b12614b97565b90506020020135611b467fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb736013560601c90565b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c612f89565b9194509250905060008080611bbe367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0013587611baf8888614c7b565b611bb99190614c7b565b613313565b919450925090508a611bd08583614c8e565b1115611c08576040517f15d61d4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611c2284838584611c1a8b6002614da5565b8e8e8c6133f5565b611c6c367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb013560601c8b8f8f6000818110611c6057611c60614b97565b905060200201356135e9565b611c7e611c798583614c8e565b6136a9565b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c73ffffffffffffffffffffffffffffffffffffffff1663d83ff79c6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611cec57600080fd5b505af1158015611d00573d6000803e3d6000fd5b505050507fd9c2402e1a067734ae78dab98f06d5b28e8a2d2c6370ec0e6ff8cc2749d050f18482611d319190614c8e565b8e8e6000818110611d4457611d44614b97565b90506020020135604051611d62929190918252602082015260400190565b60405180910390a1611d748482614c8e565b9d9c50505050505050505050505050565b60006002367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c6002811115611dc157611dc161455e565b03611dcb57503090565b6002546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1680611e1757505060005473ffffffffffffffffffffffffffffffffffffffff1690565b919050565b33611e3c60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611e89576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316611ed6576040517fedf1b1fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611edf836136c5565b73ffffffffffffffffffffffffffffffffffffffff83163b15611fc2576040517f66e5774a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416906366e5774a903490611f5490339087908790600401614dbc565b6000604051808303818588803b158015611f6d57600080fd5b505af193505050508015611f7f575060015b611fc2573d808015611fad576040519150601f19603f3d011682016040523d82523d6000602084013e611fb2565b606091505b5080511561137f57805181602001fd5b505050565b33611fe760005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614612034576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61203d476129c8565b565b3361205f60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16146120ac576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6117e073ffffffffffffffffffffffffffffffffffffffff83163383613732565b336120ed60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff161461213a576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb36013560601c73ffffffffffffffffffffffffffffffffffffffff86160361223b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0360135836000805b828110156121fc57838888838181106121c1576121c1614b97565b90506020020135036121f4578585828181106121df576121df614b97565b90506020020135826121f19190614c8e565b91505b6001016121a6565b508015612237576040518181527fd26d84b7e96b5b61cbb9f851a5a2953408c61abc7502e33a59d3e6146c0428b09060200160405180910390a15b5050505b604080516020810182526000815290517f2eb2c2d600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff871691632eb2c2d6916122a591309133918a918a918a918a9190600401614ed5565b600060405180830381600087803b1580156122bf57600080fd5b505af11580156122d3573d6000803e3d6000fd5b505050505050505050565b6060806000808073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bc40d21999b4bf120d330ee3a2de415287f626c916633e104014367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb0135861c6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018a905260448101899052606401600060405180830381865afa1580156123be573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526124049190810190614f9f565b915091506124138282886137eb565b94509450945050509250925092565b600080367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c90508073ffffffffffffffffffffffffffffffffffffffff16630e4860df6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561249657600080fd5b505af11580156124aa573d6000803e3d6000fd5b5050505060006124dd7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb736013560601c90565b90506001367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c60028111156125195761251961455e565b03612550576040517fa284414700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018814158061257957508888600081811061256e5761256e614b97565b905060200201356000145b156125b0576040517f3b4935ad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006125d68a8a60008181106125c8576125c8614b97565b905060200201358385613a47565b945090506000808061260b367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0013588613313565b92509250925080870396508a871015612650576040517fa74ea4b100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61269c367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb013560601c8e8e600081811061268d5761268d614b97565b90506020020135888c8c613dc5565b6126a68a88614221565b60005b83518110156126f6576126ee8482815181106126c7576126c7614b97565b60200260200101518483815181106126e1576126e1614b97565b6020026020010151614221565b6001016126a9565b506127018685614221565b8573ffffffffffffffffffffffffffffffffffffffff1663d83ff79c6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561274957600080fd5b505af115801561275d573d6000803e3d6000fd5b505050507f58e7e2e8d4c949c019e4fe5f6e2a8f10e4e078a8747730386e9a230da8c969f0878e8e600081811061279657612796614b97565b905060200201356040516127b4929190918252602082015260400190565b60405180910390a15050505050509695505050505050565b336127ec60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614612839576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7013560601c6040517fa1bbb2e80000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff8416600482015290915073ffffffffffffffffffffffffffffffffffffffff82169063a1bbb2e890602401602060405180830381865afa1580156128e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129059190614ca1565b61293b576040517fff2848d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001546fffffffffffffffffffffffffffffffff8381169116146117e057600180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff84169081179091556040519081527ff06180fdbe95e5193df4dcd1352726b1f04cb58599ce58552cc952447af2ffbb906020016117d7565b336129e860005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614612a35576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612a3f3382614243565b6040518181527f0e266e8f38544aa1480d73762386eb10df55b1b8453d935762e891c44b69a1e69060200160405180910390a150565b33612a9560005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614612ae2576040517f5eee3ad100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025473ffffffffffffffffffffffffffffffffffffffff8281166c010000000000000000000000009092041614612b7f57600280546bffffffffffffffffffffffff166c0100000000000000000000000073ffffffffffffffffffffffffffffffffffffffff8416908102919091179091556040517f678f61dcdee86474eddea0407caf8f1f5130382a90dedabaef94906ed86a27b490600090a25b50565b60005473ffffffffffffffffffffffffffffffffffffffff1615612bd2576040517fe262b52400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff87161790556000612c417fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb736013560601c90565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf36013560f81c60028181811115612c7d57612c7d61455e565b14612ccd576bffffffffffffffffffffffff841615612cc8576040517fecb8010500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612d56565b6706f05b59d3b20000846bffffffffffffffffffffffff161115612d1d576040517f9cc0093b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff86161790555b6002805473ffffffffffffffffffffffffffffffffffffffff8881166c01000000000000000000000000026bffffffffffffffffffffffff909216919091179091556040517f0ae67ccc0000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff8716600482015290831690630ae67ccc90602401602060405180830381865afa158015612e00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e249190614ca1565b612e5a576040517ff863cd2500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa1bbb2e80000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83169063a1bbb2e890602401602060405180830381865afa158015612ed6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612efa9190614ca1565b612f30576040517fff2848d600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50506fffffffffffffffffffffffffffffffff9081169216700100000000000000000000000000000000027fffffffffffffffffffffffffffffffff000000000000000000000000000000001691909117600155505050565b6000806000806000600160009054906101000a90046fffffffffffffffffffffffffffffffff1690506000600160109054906101000a90046fffffffffffffffffffffffffffffffff1690506000808973ffffffffffffffffffffffffffffffffffffffff16637ca542ac85858e600260009054906101000a90046bffffffffffffffffffffffff168e73ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561305d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130819190614bc6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526fffffffffffffffffffffffffffffffff958616600482015294909316602485015260448401919091526bffffffffffffffffffffffff166064830152608482015260a40160c060405180830381865afa15801561310f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131339190614bdf565b909c509a509850919650909250905060008560048111156131565761315661455e565b1461319857846040517f17ca377000000000000000000000000000000000000000000000000000000000815260040161318f9190615064565b60405180910390fd5b806fffffffffffffffffffffffffffffffff16846fffffffffffffffffffffffffffffffff161415806131ef5750816fffffffffffffffffffffffffffffffff16836fffffffffffffffffffffffffffffffff1614155b15613223576fffffffffffffffffffffffffffffffff82811670010000000000000000000000000000000002908216176001555b806fffffffffffffffffffffffffffffffff16846fffffffffffffffffffffffffffffffff1614613294576040516fffffffffffffffffffffffffffffffff821681527ff06180fdbe95e5193df4dcd1352726b1f04cb58599ce58552cc952447af2ffbb9060200160405180910390a15b816fffffffffffffffffffffffffffffffff16836fffffffffffffffffffffffffffffffff1614613305576040516fffffffffffffffffffffffffffffffff831681527fc958ae052d28f8d17bc2c4ddbabb699a3cab5cccefd034d0fc971efdadc01da59060200160405180910390a15b505050505093509350939050565b6060806000808073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bc40d21999b4bf120d330ee3a2de415287f626c91663f533b802367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcb0135861c6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018a9052604481018990526064016000604051808303816000875af11580156123be573d6000803e3d6000fd5b6133ff8886614c8e565b341015613438576040517f9d981d3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000613442611d85565b90506002367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf013560f81c600281111561347e5761347e61455e565b14801561348a57508415155b156134fc5760006134996115a2565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146134fa576134d8868b614c7b565b99506134fa73ffffffffffffffffffffffffffffffffffffffff821687614243565b505b73ffffffffffffffffffffffffffffffffffffffff8116301461354357613543613526838b614c7b565b73ffffffffffffffffffffffffffffffffffffffff831690614243565b60005b87518110156135b2576135aa89828151811061356457613564614b97565b602002602001015189838151811061357e5761357e614b97565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1661424390919063ffffffff16565b600101613546565b5081156122d3576122d37fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa336013560601c83614243565b604080516020810182526000815290517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169163f242432a9161367291309187917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe036013591889190600401615072565b600060405180830381600087803b15801561368c57600080fd5b505af11580156136a0573d6000803e3d6000fd5b50505050505050565b80341115612b7f57612b7f6136be8234614c7b565b3390614243565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc68616391a250565b60006040517fa9059cbb000000000000000000000000000000000000000000000000000000008152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061137f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5452414e534645525f4641494c45440000000000000000000000000000000000604482015260640161318f565b8251606090819060009080156139c457367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa3013560601c6040517f0b89849300000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9190911690630b898493906024016040805180830381865afa9250505080156138c7575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526138c4918101906150c2565b60015b6138d6578693508592506139c4565b81156139ba5760408051600180825281830190925290602080830190803683370190505095508860008151811061390f5761390f614b97565b60200260200101518660008151811061392a5761392a614b97565b73ffffffffffffffffffffffffffffffffffffffff929092166020928302919091018201526040805160018082528183019092529182810190803683370190505094506127106139886bffffffffffffffffffffffff831689614da5565b61399291906150fc565b856000815181106139a5576139a5614b97565b602002602001018181525050600192506139c1565b8895508794505b50505b60005b818110156139fe578381815181106139e1576139e1614b97565b6020026020010151836139f49190614c8e565b92506001016139c7565b50600285901c821115613a3d576040517fb30f15ef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5093509350939050565b600080600080600160009054906101000a90046fffffffffffffffffffffffffffffffff1690506000600160109054906101000a90046fffffffffffffffffffffffffffffffff1690506000808873ffffffffffffffffffffffffffffffffffffffff1663097cc63d85858d600260009054906101000a90046bffffffffffffffffffffffff168d73ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613b19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b3d9190614bc6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526fffffffffffffffffffffffffffffffff958616600482015294909316602485015260448401919091526bffffffffffffffffffffffff166064830152608482015260a40160c060405180830381865afa158015613bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bef9190614bdf565b9b50909950929750909350915060009050856004811115613c1257613c1261455e565b14613c4b57846040517f17ca377000000000000000000000000000000000000000000000000000000000815260040161318f9190615064565b816fffffffffffffffffffffffffffffffff16846fffffffffffffffffffffffffffffffff16141580613ca25750806fffffffffffffffffffffffffffffffff16836fffffffffffffffffffffffffffffffff1614155b15613cd6576fffffffffffffffffffffffffffffffff81811670010000000000000000000000000000000002908316176001555b816fffffffffffffffffffffffffffffffff16846fffffffffffffffffffffffffffffffff1614613d47576040516fffffffffffffffffffffffffffffffff831681527ff06180fdbe95e5193df4dcd1352726b1f04cb58599ce58552cc952447af2ffbb9060200160405180910390a15b806fffffffffffffffffffffffffffffffff16836fffffffffffffffffffffffffffffffff1614613db8576040516fffffffffffffffffffffffffffffffff821681527fc958ae052d28f8d17bc2c4ddbabb699a3cab5cccefd034d0fc971efdadc01da59060200160405180910390a15b5050505050935093915050565b6000613dcf611d85565b9050821561415e576040517fa93ec68b00000000000000000000000000000000000000000000000000000000815233600482018190529060009073ffffffffffffffffffffffffffffffffffffffff87169063a93ec68b906024016040805180830381865afa158015613e46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e6a9190615137565b50905080613ea4576040517f3f80c4c000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001356040517efdd58e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018390529192506000918b169062fdd58e90604401602060405180830381865afa158015613f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f659190614bc6565b60408051600180825281830190925291925060009190602080830190803683370190505090508281600081518110613f9f57613f9f614b97565b60209081029190910101526040805160018082528183019092526000918160200160208202803683370190505090508a81600081518110613fe257613fe2614b97565b60209081029190910101526040517fac482d1d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87169063ac482d1d90614047908f908c908c9088908890600401615166565b600060405180830381600087803b15801561406157600080fd5b505af1158015614075573d6000803e3d6000fd5b50506040517efdd58e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a81166004830152602482018890528e93508692508f169062fdd58e90604401602060405180830381865afa1580156140ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141129190614bc6565b61411c9190614c7b565b14614153576040517fda276afb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050506111a3565b604080516020810182526000815290517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169163f242432a916141e791339186917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0360135918c9190600401615072565b600060405180830381600087803b15801561420157600080fd5b505af1158015614215573d6000803e3d6000fd5b50505050505050505050565b80156117e0576117e073ffffffffffffffffffffffffffffffffffffffff8316825b600080600080600085875af1905080611fc2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4554485f5452414e534645525f4641494c454400000000000000000000000000604482015260640161318f565b6000602082840312156142ca57600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146142fa57600080fd5b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81168114612b7f57600080fd5b60008083601f84011261433557600080fd5b50813567ffffffffffffffff81111561434d57600080fd5b6020830191508360208260051b850101111561436857600080fd5b9250929050565b60008060006040848603121561438457600080fd5b833561438f81614301565b9250602084013567ffffffffffffffff8111156143ab57600080fd5b6143b786828701614323565b9497909650939450505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561443a5761443a6143c4565b604052919050565b600082601f83011261445357600080fd5b813567ffffffffffffffff81111561446d5761446d6143c4565b61449e60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016143f3565b8181528460208386010111156144b357600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080608085870312156144e657600080fd5b84356144f181614301565b9350602085013561450181614301565b925060408501359150606085013567ffffffffffffffff81111561452457600080fd5b61453087828801614442565b91505092959194509250565b6000806040838503121561454f57600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6005811061459d5761459d61455e565b9052565b60c081016145af828961458d565b602082019690965260408101949094526060840192909252608083015260a090910152919050565b60008083601f8401126145e957600080fd5b50813567ffffffffffffffff81111561460157600080fd5b60208301915083602082850101111561436857600080fd5b60008060006040848603121561462e57600080fd5b833561463981614301565b9250602084013567ffffffffffffffff81111561465557600080fd5b6143b7868287016145d7565b8015158114612b7f57600080fd5b60008060006040848603121561468457600080fd5b833567ffffffffffffffff81111561469b57600080fd5b6146a786828701614323565b90945092505060208401356146bb81614661565b809150509250925092565b60208101600483106146da576146da61455e565b91905290565b6fffffffffffffffffffffffffffffffff81168114612b7f57600080fd5b60006020828403121561471057600080fd5b81356142fa816146e0565b6bffffffffffffffffffffffff81168114612b7f57600080fd5b60006020828403121561474757600080fd5b81356142fa8161471b565b60008060008060008060a0878903121561476b57600080fd5b863567ffffffffffffffff81111561478257600080fd5b61478e89828a01614323565b9097509550506020870135935060408701356147a981614301565b925060608701356147b981614661565b915060808701356147c981614301565b809150509295509295509295565b600080604083850312156147ea57600080fd5b82356147f581614301565b946020939093013593505050565b60008060008060006060868803121561481b57600080fd5b853561482681614301565b9450602086013567ffffffffffffffff8082111561484357600080fd5b61484f89838a01614323565b9096509450604088013591508082111561486857600080fd5b5061487588828901614323565b969995985093965092949392505050565b600081518084526020808501945080840160005b838110156148b65781518752958201959082019060010161489a565b509495945050505050565b606080825284519082018190526000906020906080840190828801845b8281101561491057815173ffffffffffffffffffffffffffffffffffffffff16845292840192908401906001016148de565b505050838103828501526149248187614886565b92505050826040830152949350505050565b60208101600383106146da576146da61455e565b600067ffffffffffffffff821115614964576149646143c4565b5060051b60200190565b600082601f83011261497f57600080fd5b8135602061499461498f8361494a565b6143f3565b82815260059290921b840181019181810190868411156149b357600080fd5b8286015b848110156149ce57803583529183019183016149b7565b509695505050505050565b600080600080600060a086880312156149f157600080fd5b85356149fc81614301565b94506020860135614a0c81614301565b9350604086013567ffffffffffffffff80821115614a2957600080fd5b614a3589838a0161496e565b94506060880135915080821115614a4b57600080fd5b614a5789838a0161496e565b93506080880135915080821115614a6d57600080fd5b50614a7a88828901614442565b9150509295509295909350565b600060208284031215614a9957600080fd5b5035919050565b600080600080600060a08688031215614ab857600080fd5b8535614ac381614301565b94506020860135614ad381614301565b93506040860135925060608601359150608086013567ffffffffffffffff811115614afd57600080fd5b614a7a88828901614442565b600060208284031215614b1b57600080fd5b81356142fa81614301565b600080600080600060a08688031215614b3e57600080fd5b8535614b4981614301565b94506020860135614b5981614301565b93506040860135614b69816146e0565b92506060860135614b798161471b565b91506080860135614b89816146e0565b809150509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215614bd857600080fd5b5051919050565b60008060008060008060c08789031215614bf857600080fd5b865160058110614c0757600080fd5b6020880151909650614c18816146e0565b6040880151909550614c29816146e0565b80945050606087015192506080870151915060a087015190509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561097857610978614c4c565b8082018082111561097857610978614c4c565b600060208284031215614cb357600080fd5b81516142fa81614661565b60008085851115614cce57600080fd5b83861115614cdb57600080fd5b5050820193919092039150565b7fffffffff000000000000000000000000000000000000000000000000000000008135818116916004851015614d285780818660040360031b1b83161692505b505092915050565b8183823760009101908152919050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112614d7557600080fd5b83018035915067ffffffffffffffff821115614d9057600080fd5b60200191503681900382131561436857600080fd5b808202811582820484141761097857610978614c4c565b73ffffffffffffffffffffffffffffffffffffffff8416815260406020820152816040820152818360608301376000818301606090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010192915050565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115614e5857600080fd5b8260051b80836020870137939093016020019392505050565b6000815180845260005b81811015614e9757602081850181015186830182015201614e7b565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600073ffffffffffffffffffffffffffffffffffffffff808a16835280891660208401525060a06040830152614f0f60a083018789614e26565b8281036060840152614f22818688614e26565b90508281036080840152614f368185614e71565b9a9950505050505050505050565b600082601f830112614f5557600080fd5b81516020614f6561498f8361494a565b82815260059290921b84018101918181019086841115614f8457600080fd5b8286015b848110156149ce5780518352918301918301614f88565b60008060408385031215614fb257600080fd5b825167ffffffffffffffff80821115614fca57600080fd5b818501915085601f830112614fde57600080fd5b81516020614fee61498f8361494a565b82815260059290921b8401810191818101908984111561500d57600080fd5b948201945b8386101561503457855161502581614301565b82529482019490820190615012565b9188015191965090935050508082111561504d57600080fd5b5061505a85828601614f44565b9150509250929050565b60208101610978828461458d565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015283606083015260a060808301526150b760a0830184614e71565b979650505050505050565b600080604083850312156150d557600080fd5b82516150e081614661565b60208401519092506150f18161471b565b809150509250929050565b600082615132577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000806040838503121561514a57600080fd5b825161515581614661565b60208401519092506150f181614661565b600073ffffffffffffffffffffffffffffffffffffffff8088168352808716602084015280861660408401525060a060608301526151a760a0830185614886565b82810360808401526151b98185614886565b9897505050505050505056fea2646970667358221220773129a088e95bdba990c30c7efee20cf49b850e33dc770f6fa192f88df376d764736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000bc40d21999b4bf120d330ee3a2de415287f626c9
-----Decoded View---------------
Arg [0] : royaltyEngine (address): 0xBc40d21999b4BF120d330Ee3a2DE415287f626C9
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000bc40d21999b4bf120d330ee3a2de415287f626c9
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 27 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.