Feature Tip: Add private address tag to any address under My Name Tag !
ERC-721
Overview
Max Total Supply
0 AKOL
Holders
153
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Balance
1 AKOLLoading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
Akolytes
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import {ERC20} from "solmate/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol"; import {Owned} from "solmate/auth/Owned.sol"; import {ERC721} from "solmate/tokens/ERC721.sol"; import {ERC2981} from "openzeppelin-contracts/contracts/token/common/ERC2981.sol"; import {IERC2981} from "openzeppelin-contracts/contracts/interfaces/IERC2981.sol"; import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; import {IERC721} from "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol"; import {ICurve} from "lssvm2/bonding-curves/ICurve.sol"; import {LSSVMPair} from "lssvm2/LSSVMPair.sol"; import {ERC20} from "solmate/tokens/ERC20.sol"; import {PairFactoryLike} from "./PairFactoryLike.sol"; import {RoyaltyHandler} from "./RoyaltyHandler.sol"; import {ERC721Minimal} from "./ERC721Minimal.sol"; import {StringLib} from "./libs/StringLib.sol"; import {Base64} from "./libs/Base64.sol"; interface IMarkov { function speak(uint256 magic, uint256 duration) external view returns (string memory s); } contract Akolytes is ERC721Minimal, ERC2981, Owned { /*////////////////////////////////////////////////////////////// Struct //////////////////////////////////////////////////////////////*/ struct OwnerOfWithData { address owner; uint96 lastTransferTimestamp; } /*////////////////////////////////////////////////////////////// Libraries //////////////////////////////////////////////////////////////*/ using SafeTransferLib for address payable; using SafeTransferLib for ERC20; using StringLib for string; using StringLib for StringLib.slice; /*////////////////////////////////////////////////////////////// Error //////////////////////////////////////////////////////////////*/ error Cooldown(); error Monless(); error Akoless(); error Scarce(); error TooHigh(); error NoYeet(); error NoZero(); error WrongFrom(); error Unauth(); /*////////////////////////////////////////////////////////////// Events //////////////////////////////////////////////////////////////*/ event NewRoyalty(uint256 newRoyalty); event RoyaltiesClaimed(address token, uint256 amount); /*////////////////////////////////////////////////////////////// Constants //////////////////////////////////////////////////////////////*/ uint256 constant TOTAL_AKOLS = 512; string private constant ARWEAVE_HASH = "XxDgZs6LRWDmzQIfR0Lssic8a4k3eQbyaosttObj7Ec"; // Name generation process: 1 random from s1, 1 random from s2, and then 0-2 from s3 string private constant s1 = "Cth,Az,Ap,Ch,Bl,Gh,Gl,Kr,M,Nl,Ny,D,Xy,Rh,U,Bl,Cz,En,Fz,H,Il,J,Jh,Y,YvK,Z,Zh,Sl,T,O,U,Ub,Os,Eh,Sh"; uint256 private constant s1Length = 35; string private constant s2 = "ak,al,es,et,id,il,id,oo,or,ux,un,ap,ek,ex,in,ol,up,-af,-aw,'et,'ed,-in,-is,'od,-at,-of"; uint256 private constant s2Length = 26; string private constant s3 = "ag,al,on,ak,ash,a,ber,bal,buk,cla,ced,ck,dar,dru,est,end,fli,fa,-fur,gen,ga,his,ha,ilk,in,-in,ju,ja,-ki,ll,lo,mo,-mu,ma,no,r,ss,sh,sto,ta,tha,un,vy,va,wy,wu,y,yy,z,zs,ton,gon,-man,lu,get,har,uz,ek,ec,-s"; uint256 private constant s3Length = 60; // Max number of times we grab a syllable from s3 uint256 private constant maxS3Iters = 2; // Max 10% royalty uint256 private constant MAX_ROYALTY = 1000; // Get ur akolytes before i yeet them uint256 private constant MIN_YEET_DELAY = 7 days; // For metadata uint256 constant DURATION = 42; /*////////////////////////////////////////////////////////////// Immutables //////////////////////////////////////////////////////////////*/ // Immutable contract reference vars address private immutable MONS; address private immutable SUDO_FACTORY; address private immutable GDA_ADDRESS; address private immutable LINEAR_ADDRESS; address private immutable XMON_ADDRESS; address payable public immutable ROYALTY_HANDER; uint256 private immutable START_TIME; // Babble babble IMarkov public immutable MARKOV; /*////////////////////////////////////////////////////////////// Storage //////////////////////////////////////////////////////////////*/ // Mapping of (id, 256 bits) => (owner address, 160 bits | unlockDate timestamp, 96 bits) mapping(uint256 => OwnerOfWithData) public ownerOfWithData; // Mapping of (token address, 160 bits | akolyte id, 96 bits) => amount already claimed for that id mapping(uint256 => uint256) public royaltyClaimedPerId; // Mapping of royalty amounts accumulated in total per royalty token mapping(address => uint256) public royaltyAccumulatedPerTokenType; // Seed overrides for speaking mapping(uint256 => uint256) public markovSeed; /*////////////////////////////////////////////////////////////// Constructor //////////////////////////////////////////////////////////////*/ constructor(address _mons, address _factory, address _markov, address _gda, address _xmon, address _linear) ERC721Minimal("Akolytes", "AKOL") Owned(msg.sender) { MONS = _mons; SUDO_FACTORY = _factory; ROYALTY_HANDER = payable(address(new RoyaltyHandler())); START_TIME = block.timestamp; MARKOV = IMarkov(_markov); GDA_ADDRESS = _gda; XMON_ADDRESS = _xmon; LINEAR_ADDRESS = _linear; // 5% royalty, set to this address _setDefaultRoyalty(address(this), 500); } /*////////////////////////////////////////////////////////////// User Facing //////////////////////////////////////////////////////////////*/ // Claim for mons function tap_to_summon_akolytes(uint256[] calldata ids) public { for (uint256 i; i < ids.length; ++i) { if (ERC721(MONS).ownerOf(ids[i]) != msg.sender) { revert Monless(); } } _mint(msg.sender, ids); } // Claims royalties accrued for owned IDs function claimRoyalties(address royaltyToken, uint256[] calldata ids) public returns (uint256 royaltiesReceived) { uint256 idLength = ids.length; accumulateRoyalty(royaltyToken); uint256 amountPerId = royaltyAccumulatedPerTokenType[royaltyToken] / TOTAL_AKOLS; for (uint256 i; i < idLength; ++i) { if (ownerOf(ids[i]) == msg.sender) { uint256 idAndTokenKey = uint256(uint160(royaltyToken)) << 96 | ids[i]; // This should undeflow if already claimed to the maximum amount uint256 royaltyToAdd = amountPerId - royaltyClaimedPerId[idAndTokenKey]; // If we are sending a royalty amount, then keep track of the amount if (royaltyToAdd > 0) { royaltiesReceived += royaltyToAdd; royaltyClaimedPerId[idAndTokenKey] = amountPerId; } } else { revert Akoless(); } } // If native token if (royaltyToken == address(0)) { RoyaltyHandler(ROYALTY_HANDER).sendETH(payable(msg.sender), royaltiesReceived); } // Otherwise, do ERC20 transfer else { RoyaltyHandler(ROYALTY_HANDER).sendERC20(msg.sender, royaltyToken, royaltiesReceived); } return royaltiesReceived; } // Accumulates royalties accrued function accumulateRoyalty(address royaltyToken) public { // Handle native token royalties if (royaltyToken == address(0)) { // Send balance and accumulate uint256 ethBalance = address(this).balance; royaltyAccumulatedPerTokenType[address(0)] += ethBalance; ROYALTY_HANDER.safeTransferETH(ethBalance); emit RoyaltiesClaimed(royaltyToken, ethBalance); } else { uint256 tokenBalance = ERC20(royaltyToken).balanceOf(address(this)); royaltyAccumulatedPerTokenType[royaltyToken] += tokenBalance; ERC20(royaltyToken).safeTransfer(ROYALTY_HANDER, tokenBalance); emit RoyaltiesClaimed(royaltyToken, tokenBalance); } } function recast(uint256 id, uint256 seed) external payable { require(msg.value == 0.01 ether); require(ownerOf(id) == msg.sender); markovSeed[id] = seed; } /*////////////////////////////////////////////////////////////// IERC721 Compliance //////////////////////////////////////////////////////////////*/ // Overrides both ERC721 and ERC2981 function supportsInterface(bytes4 interfaceId) public pure override(ERC2981, ERC721Minimal) returns (bool) { return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165 || interfaceId == 0x80ac58cd // ERC165 Interface ID for ERC721 || interfaceId == type(IERC2981).interfaceId // ERC165 interface for IERC2981 || interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata } function ownerOf(uint256 id) public view override returns (address owner) { owner = ownerOfWithData[id].owner; } // Transfers and sets time delay if to/from a non-sudo pool function transferFrom(address from, address to, uint256 id) public override { if (from != ownerOf(id)) { revert WrongFrom(); } if (to == address(0)) { revert NoZero(); } if (msg.sender != from && !isApprovedForAll[from][msg.sender] && msg.sender != getApproved[id]) { revert Unauth(); } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { _balanceOf[from]--; _balanceOf[to]++; } delete getApproved[id]; uint256 timestamp = block.timestamp; // Always allow transfer if one of the recipients is a sudo pool bool isPair; try PairFactoryLike(SUDO_FACTORY).isValidPair(from) returns (bool result) { isPair = result; } catch {} if (!isPair) { try PairFactoryLike(SUDO_FACTORY).isValidPair(to) returns (bool result) { isPair = result; } catch {} } // If either to or from a pool, always allow it if (isPair) { ownerOfWithData[id].owner = to; } // If one of the two recipients is not a sudo pool else { // Check if earlier than allowed, if so, then revert if (timestamp < ownerOfWithData[id].lastTransferTimestamp) { revert Cooldown(); } // If it is past the cooldown, then we set a new cooldown, and let the transfer go through ownerOfWithData[id] = OwnerOfWithData({owner: to, lastTransferTimestamp: uint96(timestamp + 7 days)}); } emit Transfer(from, to, id); } /*////////////////////////////////////////////////////////////// Generative Metadata //////////////////////////////////////////////////////////////*/ function getName(uint256 seed) public pure returns (string memory) { uint256 rng = seed; // Get uniform from s1 string memory nameS1 = _getItemFromCSV(s1, rng % s1Length); // Update seed rng = uint256(keccak256(abi.encode(rng))); // Get uniform from s2 string memory nameS2 = _getItemFromCSV(s2, rng % s2Length); // Concatenate the two string memory name = string(abi.encodePacked(nameS1, nameS2)); // Update seed rng = uint256(keccak256(abi.encode(rng))); // Add any s3 syllables (if possible) for (uint256 i = 0; i < rng % (maxS3Iters + 1); i++) { string memory nameS3 = _getItemFromCSV(s3, rng % s3Length); rng = uint256(keccak256(abi.encode(rng))); name = string(abi.encodePacked(name, nameS3)); } return name; } // @dev Don't worry about anything from here until the tokenURI function _getItemFromCSV(string memory str, uint256 index) internal pure returns (string memory) { StringLib.slice memory strSlice = str.toSlice(); string memory separatorStr = ","; StringLib.slice memory separator = separatorStr.toSlice(); StringLib.slice memory item; for (uint256 i = 0; i <= index; i++) { item = strSlice.split(separator); } return item.toString(); } function d1(uint256 seed) internal pure returns (uint256 result) { uint256 start = 0; uint256 end = 512; uint256 diff = end + 1 - start; result = (seed % diff) + start; } function d2(uint256 seed) internal pure returns (uint256 result) { uint256 start = 0; uint256 end = 512; uint256 subresult1 = d1(seed); uint256 seed2 = uint256(keccak256(abi.encode(seed, start, end))); uint256 subresult2 = d1(seed2); result = (subresult1 + subresult2) / 2; } function d3(uint256 seed) internal pure returns (uint256 result) { uint256 start = 0; uint256 end = 512; uint256 midpoint = (start + end) / 2; uint256 d2Value = d2(seed); if (d2Value >= midpoint) { result = end - (d2Value - midpoint); } else { result = start + (midpoint - d2Value); } } function d4(uint256 seed) internal pure returns (uint256 result) { uint256 start = 0; uint256 end = 512; result = d1(seed); if (result % 2 == 1) { result = d1(uint256(keccak256(abi.encode(seed, start, end)))); } } function d5(uint256 seed) internal pure returns (uint256 result) { uint256 selector = seed % 4; uint256 newSeed = uint256(keccak256(abi.encode(seed / d1(seed)))); if (selector == 0) { result = d3(newSeed); } else if (selector == 1) { result = d1(newSeed); } else if (selector == 2) { result = d2(newSeed); } else if (selector == 3) {} result = d4(newSeed); } function d6(uint256 id) internal pure returns (uint256) { if (id == 0) { return 0; } for (uint256 i = 2; i <= id / 2; i++) { uint256 result = id - ((id / i) * i); if (result == 0) { return 1; } } return 2; } function secondD(uint256 seed, uint256 id) internal pure returns (string memory) { return string( abi.encodePacked( '"trait_type": "4tiart",' '"value": "', Strings.toString(d4(seed)), '"},{', '"trait_type": "V",' '"value": "', Strings.toString(d5(seed)), '"},{', '"trait_type": "-- . . . .",' '"value": "', Strings.toString(d6(id)), '"}' ) ); } function getD(uint256 seed, uint256 id) internal pure returns (string memory) { return string( abi.encodePacked( "{", '"trait_type": "TRAIT ONE",' '"value": "', Strings.toString(d1(seed)), '"},{', '"trait_type": "7R417_2",' '"value": "', Strings.toString(d2(seed)), '"},{', '"trait_type": "trait3",' '"value": "', Strings.toString(d3(seed)), '"},{', secondD(seed, id) ) ); } function getMagic(uint256 id) public view returns (uint256) { if (markovSeed[id] == 0) { return uint256(keccak256(abi.encode(id))); } else { return uint256(keccak256(abi.encode(id, markovSeed[id]))); } } // Handles metadata from arweave hash, constructs name and metadata function tokenURI(uint256 id) public view override returns (string memory) { uint256 seed = uint256(keccak256(abi.encode(id, uint160(SUDO_FACTORY)))); return string( abi.encodePacked( "data:application/json;base64,", Base64.encode( bytes( abi.encodePacked( '{"name":"', getName(id), '", "description":"', MARKOV.speak(getMagic(id), DURATION), '", "image": "', "ar://", ARWEAVE_HASH, "/m", Strings.toString(id), ".gif", '", "attributes": [', getD(seed, id), "]", "}" ) ) ) ) ); } /*////////////////////////////////////////////////////////////// Mint x Pool //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256[] memory ids) internal virtual { require(to != address(0), "INVALID_RECIPIENT"); uint256 numIds = ids.length; unchecked { _balanceOf[to] += numIds; } for (uint256 i; i < numIds;) { uint256 id = ids[i]; if (id >= TOTAL_AKOLS) { revert Scarce(); } require(ownerOf(id) == address(0), "ALREADY_MINTED"); ownerOfWithData[id].owner = to; emit Transfer(address(0), to, id); unchecked { ++i; } } } function initPools() public onlyOwner returns (address gdaPool, address tradePool){ uint256[] memory empty = new uint256[](0); gdaPool = address( PairFactoryLike(SUDO_FACTORY).createPairERC721ERC20( PairFactoryLike.CreateERC721ERC20PairParams({ token: ERC20(XMON_ADDRESS), nft: IERC721(address(this)), bondingCurve: ICurve(GDA_ADDRESS), assetRecipient: payable(address(0)), poolType: LSSVMPair.PoolType.NFT, delta: ((uint128(1500000000) << 88)) | ((uint128(11574) << 48)) | uint128(block.timestamp), fee: 0, spotPrice: 5 ether, propertyChecker: address(0), initialNFTIDs: empty, initialTokenBalance: 0 }) ) ); tradePool = address( PairFactoryLike(SUDO_FACTORY).createPairERC721ETH( IERC721(address(this)), ICurve(LINEAR_ADDRESS), payable(address(this)), LSSVMPair.PoolType.TRADE, 0.0128 ether, 0, 0.0128 ether, address(0), empty ) ); uint256[] memory akolytesToDeposit = new uint256[](69); for (uint256 i; i < 69;) { akolytesToDeposit[i] = 341 + i; unchecked { ++i; } } _mint(gdaPool, akolytesToDeposit); akolytesToDeposit = new uint256[](102); for (uint256 i; i < 102;) { akolytesToDeposit[i] = 410 + i; unchecked { ++i; } } _mint(tradePool, akolytesToDeposit); } /*////////////////////////////////////////////////////////////// Conveniences //////////////////////////////////////////////////////////////*/ function idsForAddress(address a) external view returns (uint256[] memory) { uint256 balance = balanceOf(a); uint256[] memory ids = new uint256[](balance); if (balance > 0) { uint256 counter = 0; for (uint256 i; i < TOTAL_AKOLS;) { address owner = ownerOfWithData[i].owner; if (owner == a) { ids[counter] = i; unchecked { ++counter; } if (counter == balance) { return ids; } } unchecked { ++i; } } } return ids; } function royaltiesAccrued(uint256[] memory ids, address royaltyToken) external view returns (uint256[] memory royaltyPerId) { uint256 idLength = ids.length; royaltyPerId = new uint256[](idLength); uint256 amountPerId = royaltyAccumulatedPerTokenType[royaltyToken] / TOTAL_AKOLS; for (uint256 i; i < idLength; ++i) { uint256 idAndTokenKey = uint256(uint160(royaltyToken)) << 96 | ids[i]; royaltyPerId[i] = amountPerId - royaltyClaimedPerId[idAndTokenKey]; } } /*////////////////////////////////////////////////////////////// Tweaks //////////////////////////////////////////////////////////////*/ function adjustRoyalty(uint96 newRoyalty) public onlyOwner { if (newRoyalty <= MAX_ROYALTY) { _setDefaultRoyalty(address(this), newRoyalty); emit NewRoyalty(newRoyalty); } else { revert TooHigh(); } } function yeet(uint256[] calldata ids) public onlyOwner { // Can only yeet after min yeet delay if (block.timestamp < START_TIME + MIN_YEET_DELAY) { revert NoYeet(); } // Can only yeet below 341 (ensures no supply rug) uint256 numIds = ids.length; for (uint256 i; i < numIds; ++i) { if (ids[i] >= 341) { revert Scarce(); } } _mint(msg.sender, ids); } // Receive ETH receive() external payable {} }
// 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: 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), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument. mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. 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), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. 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), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. 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: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Simple single owner authorization mixin. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Owned.sol) abstract contract Owned { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event OwnershipTransferred(address indexed user, address indexed newOwner); /*////////////////////////////////////////////////////////////// OWNERSHIP STORAGE //////////////////////////////////////////////////////////////*/ address public owner; modifier onlyOwner() virtual { require(msg.sender == owner, "UNAUTHORIZED"); _; } /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor(address _owner) { owner = _owner; emit OwnershipTransferred(address(0), _owner); } /*////////////////////////////////////////////////////////////// OWNERSHIP LOGIC //////////////////////////////////////////////////////////////*/ function transferOwnership(address newOwner) public virtual onlyOwner { owner = newOwner; emit OwnershipTransferred(msg.sender, newOwner); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern, minimalist, and gas efficient ERC-721 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) abstract contract ERC721 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 indexed id); event Approval(address indexed owner, address indexed spender, uint256 indexed id); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /*////////////////////////////////////////////////////////////// METADATA STORAGE/LOGIC //////////////////////////////////////////////////////////////*/ string public name; string public symbol; function tokenURI(uint256 id) public view virtual returns (string memory); /*////////////////////////////////////////////////////////////// ERC721 BALANCE/OWNER STORAGE //////////////////////////////////////////////////////////////*/ mapping(uint256 => address) internal _ownerOf; mapping(address => uint256) internal _balanceOf; function ownerOf(uint256 id) public view virtual returns (address owner) { require((owner = _ownerOf[id]) != address(0), "NOT_MINTED"); } function balanceOf(address owner) public view virtual returns (uint256) { require(owner != address(0), "ZERO_ADDRESS"); return _balanceOf[owner]; } /*////////////////////////////////////////////////////////////// ERC721 APPROVAL STORAGE //////////////////////////////////////////////////////////////*/ mapping(uint256 => address) public getApproved; mapping(address => mapping(address => bool)) public isApprovedForAll; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor(string memory _name, string memory _symbol) { name = _name; symbol = _symbol; } /*////////////////////////////////////////////////////////////// ERC721 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 id) public virtual { address owner = _ownerOf[id]; require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED"); getApproved[id] = spender; emit Approval(owner, spender, id); } function setApprovalForAll(address operator, bool approved) public virtual { isApprovedForAll[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function transferFrom( address from, address to, uint256 id ) public virtual { require(from == _ownerOf[id], "WRONG_FROM"); require(to != address(0), "INVALID_RECIPIENT"); require( msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id], "NOT_AUTHORIZED" ); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { _balanceOf[from]--; _balanceOf[to]++; } _ownerOf[id] = to; delete getApproved[id]; emit Transfer(from, to, id); } function safeTransferFrom( address from, address to, uint256 id ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function safeTransferFrom( address from, address to, uint256 id, bytes calldata data ) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } /*////////////////////////////////////////////////////////////// ERC165 LOGIC //////////////////////////////////////////////////////////////*/ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165 interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721 interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 id) internal virtual { require(to != address(0), "INVALID_RECIPIENT"); require(_ownerOf[id] == address(0), "ALREADY_MINTED"); // Counter overflow is incredibly unrealistic. unchecked { _balanceOf[to]++; } _ownerOf[id] = to; emit Transfer(address(0), to, id); } function _burn(uint256 id) internal virtual { address owner = _ownerOf[id]; require(owner != address(0), "NOT_MINTED"); // Ownership check above ensures no underflow. unchecked { _balanceOf[owner]--; } delete _ownerOf[id]; delete getApproved[id]; emit Transfer(owner, address(0), id); } /*////////////////////////////////////////////////////////////// INTERNAL SAFE MINT LOGIC //////////////////////////////////////////////////////////////*/ function _safeMint(address to, uint256 id) internal virtual { _mint(to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function _safeMint( address to, uint256 id, bytes memory data ) internal virtual { _mint(to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } } /// @notice A generic interface for a contract which properly accepts ERC721 tokens. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) abstract contract ERC721TokenReceiver { function onERC721Received( address, address, uint256, bytes calldata ) external virtual returns (bytes4) { return ERC721TokenReceiver.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/common/ERC2981.sol) pragma solidity ^0.8.0; import "../../interfaces/IERC2981.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. * * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the * fee is specified in basis points by default. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. * * _Available since v4.5._ */ abstract contract ERC2981 is IERC2981, ERC165 { struct RoyaltyInfo { address receiver; uint96 royaltyFraction; } RoyaltyInfo private _defaultRoyaltyInfo; mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } /** * @inheritdoc IERC2981 */ function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual override returns (address, uint256) { RoyaltyInfo memory royalty = _tokenRoyaltyInfo[tokenId]; if (royalty.receiver == address(0)) { royalty = _defaultRoyaltyInfo; } uint256 royaltyAmount = (salePrice * royalty.royaltyFraction) / _feeDenominator(); return (royalty.receiver, royaltyAmount); } /** * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an * override. */ function _feeDenominator() internal pure virtual returns (uint96) { return 10000; } /** * @dev Sets the royalty information that all ids in this contract will default to. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: invalid receiver"); _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Removes default royalty information. */ function _deleteDefaultRoyalty() internal virtual { delete _defaultRoyaltyInfo; } /** * @dev Sets the royalty information for a specific token id, overriding the global default. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Resets royalty information for the token id back to the global default. */ function _resetTokenRoyalty(uint256 tokenId) internal virtual { delete _tokenRoyaltyInfo[tokenId]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: 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; 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: MIT pragma solidity ^0.8.0; import {IERC721} from "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol"; import {ICurve} from "lssvm2/bonding-curves/ICurve.sol"; import {LSSVMPair} from "lssvm2/LSSVMPair.sol"; import {ERC20} from "solmate/tokens/ERC20.sol"; interface PairFactoryLike { function isValidPair(address pairAddress) external view returns (bool); function createPairERC721ETH( IERC721 _nft, ICurve _bondingCurve, address payable _assetRecipient, LSSVMPair.PoolType _poolType, uint128 _delta, uint96 _fee, uint128 _spotPrice, address _propertyChecker, uint256[] calldata _initialNFTIDs ) external payable returns (LSSVMPair pair); struct CreateERC721ERC20PairParams { ERC20 token; IERC721 nft; ICurve bondingCurve; address payable assetRecipient; LSSVMPair.PoolType poolType; uint128 delta; uint96 fee; uint128 spotPrice; address propertyChecker; uint256[] initialNFTIDs; uint256 initialTokenBalance; } function createPairERC721ERC20(CreateERC721ERC20PairParams calldata params) external returns (LSSVMPair pair); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import {ERC20} from "solmate/tokens/ERC20.sol"; import {Owned} from "solmate/auth/Owned.sol"; import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol"; contract RoyaltyHandler is Owned { using SafeTransferLib for address payable; using SafeTransferLib for ERC20; constructor() Owned(msg.sender) {} function sendETH(address payable to, uint256 amount) external onlyOwner { to.safeTransferETH(amount); } function sendERC20(address to, address erc20Address, uint256 amount) external onlyOwner { ERC20(erc20Address).safeTransfer(to, amount); } receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; /// @notice Modern, minimalist, and gas efficient ERC-721 implementation. /// @author Forked from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) abstract contract ERC721Minimal { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 indexed id); event Approval(address indexed owner, address indexed spender, uint256 indexed id); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /*////////////////////////////////////////////////////////////// METADATA STORAGE/LOGIC //////////////////////////////////////////////////////////////*/ string public name; string public symbol; function tokenURI(uint256 id) public view virtual returns (string memory); /*////////////////////////////////////////////////////////////// ERC721 BALANCE/OWNER STORAGE //////////////////////////////////////////////////////////////*/ mapping(address => uint256) internal _balanceOf; function ownerOf(uint256 id) public view virtual returns (address owner); function balanceOf(address owner) public view virtual returns (uint256) { require(owner != address(0), "ZERO_ADDRESS"); return _balanceOf[owner]; } /*////////////////////////////////////////////////////////////// ERC721 APPROVAL STORAGE //////////////////////////////////////////////////////////////*/ mapping(uint256 => address) public getApproved; mapping(address => mapping(address => bool)) public isApprovedForAll; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor(string memory _name, string memory _symbol) { name = _name; symbol = _symbol; } /*////////////////////////////////////////////////////////////// ERC721 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 id) public virtual { address owner = ownerOf(id); require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED"); getApproved[id] = spender; emit Approval(owner, spender, id); } function setApprovalForAll(address operator, bool approved) public virtual { isApprovedForAll[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function transferFrom(address from, address to, uint256 id) public virtual; function safeTransferFrom(address from, address to, uint256 id) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } function safeTransferFrom(address from, address to, uint256 id, bytes calldata data) public virtual { transferFrom(from, to, id); require( to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT" ); } /*////////////////////////////////////////////////////////////// ERC165 LOGIC //////////////////////////////////////////////////////////////*/ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165 || interfaceId == 0x80ac58cd // ERC165 Interface ID for ERC721 || interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata } } /// @notice A generic interface for a contract which properly accepts ERC721 tokens. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) abstract contract ERC721TokenReceiver { function onERC721Received(address, address, uint256, bytes calldata) external virtual returns (bytes4) { return ERC721TokenReceiver.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; library StringLib { struct slice { uint256 _len; uint256 _ptr; } function memcpy(uint256 dest, uint256 src, uint256 len) private pure { // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint256 mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /* * @dev Returns a slice containing the entire string. * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ function toSlice(string memory self) internal pure returns (slice memory) { uint256 ptr; assembly { ptr := add(self, 0x20) } return slice(bytes(self).length, ptr); } /* * @dev Copies a slice to a new string. * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ function toString(slice memory self) internal pure returns (string memory) { string memory ret = new string(self._len); uint256 retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; } // Returns the memory address of the first byte of the first occurrence of // `needle` in `self`, or the first byte after `self` if not found. function findPtr(uint256 selflen, uint256 selfptr, uint256 needlelen, uint256 needleptr) private pure returns (uint256) { uint256 ptr = selfptr; uint256 idx; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); bytes32 needledata; assembly { needledata := and(mload(needleptr), mask) } uint256 end = selfptr + selflen - needlelen; bytes32 ptrdata; assembly { ptrdata := and(mload(ptr), mask) } while (ptrdata != needledata) { if (ptr >= end) { return selfptr + selflen; } ptr++; assembly { ptrdata := and(mload(ptr), mask) } } return ptr; } else { // For long needles, use hashing bytes32 hash; assembly { hash := keccak256(needleptr, needlelen) } for (idx = 0; idx <= selflen - needlelen; idx++) { bytes32 testHash; assembly { testHash := keccak256(ptr, needlelen) } if (hash == testHash) { return ptr; } ptr += 1; } } } return selfptr + selflen; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and `token` to everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; if (ptr == self._ptr + self._len) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; self._ptr = ptr + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and returning everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { split(self, needle, token); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <[email protected]> library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /// @notice Encodes some bytes to the base64 representation function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) {} { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// 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 AUCTION_ENDED // The auction has ended } }
// 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: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// 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 {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: 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: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/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.0) (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}. * 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/lssvm2/lib/", "@openzeppelin/contracts-upgradeable/=lib/lssvm2/lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/lssvm2/lib/openzeppelin-contracts/contracts/", "@prb/math/=lib/lssvm2/lib/prb-math/src/", "clones-with-immutable-args/=lib/lssvm2/lib/clones-with-immutable-args/src/", "create2-helpers/=lib/lssvm2/lib/royalty-registry-solidity/lib/create2-helpers/", "create3-factory/=lib/lssvm2/lib/create3-factory/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "foundry-huff/=lib/lssvm2/lib/foundry-huff/src/", "huffmate/=lib/lssvm2/lib/huffmate/src/", "libraries-solidity/=lib/lssvm2/lib/libraries-solidity/contracts/", "lssvm2/=lib/lssvm2/src/", "manifoldxyz/=lib/lssvm2/lib/royalty-registry-solidity/contracts/", "openzeppelin-contracts-upgradeable/=lib/lssvm2/lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/openzeppelin-contracts/contracts/", "prb-math/=lib/lssvm2/lib/prb-math/src/", "prb-test/=lib/lssvm2/lib/prb-math/lib/prb-test/src/", "royalty-registry-solidity/=lib/lssvm2/lib/royalty-registry-solidity/", "solady/=lib/solady/", "solidity-stringutils/=lib/lssvm2/lib/foundry-huff/lib/solidity-stringutils/", "solmate/=lib/solmate/src/", "stringutils/=lib/lssvm2/lib/foundry-huff/lib/solidity-stringutils/", "zipped-contracts/=lib/zipped-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "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":"address","name":"_mons","type":"address"},{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_markov","type":"address"},{"internalType":"address","name":"_gda","type":"address"},{"internalType":"address","name":"_xmon","type":"address"},{"internalType":"address","name":"_linear","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Akoless","type":"error"},{"inputs":[],"name":"Cooldown","type":"error"},{"inputs":[],"name":"Monless","type":"error"},{"inputs":[],"name":"NoYeet","type":"error"},{"inputs":[],"name":"NoZero","type":"error"},{"inputs":[],"name":"Scarce","type":"error"},{"inputs":[],"name":"TooHigh","type":"error"},{"inputs":[],"name":"Unauth","type":"error"},{"inputs":[],"name":"WrongFrom","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newRoyalty","type":"uint256"}],"name":"NewRoyalty","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RoyaltiesClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"MARKOV","outputs":[{"internalType":"contract IMarkov","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROYALTY_HANDER","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"royaltyToken","type":"address"}],"name":"accumulateRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint96","name":"newRoyalty","type":"uint96"}],"name":"adjustRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"royaltyToken","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"claimRoyalties","outputs":[{"internalType":"uint256","name":"royaltiesReceived","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getMagic","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"seed","type":"uint256"}],"name":"getName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"a","type":"address"}],"name":"idsForAddress","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initPools","outputs":[{"internalType":"address","name":"gdaPool","type":"address"},{"internalType":"address","name":"tradePool","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"markovSeed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"ownerOfWithData","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint96","name":"lastTransferTimestamp","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"seed","type":"uint256"}],"name":"recast","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address","name":"royaltyToken","type":"address"}],"name":"royaltiesAccrued","outputs":[{"internalType":"uint256[]","name":"royaltyPerId","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"royaltyAccumulatedPerTokenType","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"royaltyClaimedPerId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"tap_to_summon_akolytes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"yeet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6101806040523480156200001257600080fd5b506040516200460338038062004603833981016040819052620000359162000299565b3360405180604001604052806008815260200167416b6f6c7974657360c01b815250604051806040016040528060048152602001631052d3d360e21b8152508160009081620000859190620003bf565b506001620000948282620003bf565b5050600780546001600160a01b0319166001600160a01b0384169081179091556040519091506000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600160a01b03808716608052851660a05260405162000104906200026e565b604051809103906000f08015801562000121573d6000803e3d6000fd5b506001600160a01b039081166101205242610140528481166101605283811660c05282811661010052811660e0526200015d306101f462000169565b5050505050506200048b565b6127106001600160601b0382161115620001dd5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b60648201526084015b60405180910390fd5b6001600160a01b038216620002355760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401620001d4565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600555565b61042d80620041d683390190565b80516001600160a01b03811681146200029457600080fd5b919050565b60008060008060008060c08789031215620002b357600080fd5b620002be876200027c565b9550620002ce602088016200027c565b9450620002de604088016200027c565b9350620002ee606088016200027c565b9250620002fe608088016200027c565b91506200030e60a088016200027c565b90509295509295509295565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200034557607f821691505b6020821081036200036657634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620003ba57600081815260208120601f850160051c81016020861015620003955750805b601f850160051c820191505b81811015620003b657828155600101620003a1565b5050505b505050565b81516001600160401b03811115620003db57620003db6200031a565b620003f381620003ec845462000330565b846200036c565b602080601f8311600181146200042b5760008415620004125750858301515b600019600386901b1c1916600185901b178555620003b6565b600085815260208120601f198616915b828110156200045c578886015182559484019460019091019084016200043b565b50858210156200047b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e05161010051610120516101405161016051613ca662000530600039600081816106210152611cfe015260006118750152600081816102d701528181610fdd0152818161107201528181611eee01526120070152600061135c015260006114dd0152600061138b015260008181610bbd01528181610c4e0152818161141e015281816114ae0152611c930152600061095b0152613ca66000f3fe6080604052600436106101f25760003560e01c80636b8ff5741161010d578063bafa874b116100a0578063c8d16a2f1161006f578063c8d16a2f14610696578063e1e562c7146106c3578063e985e9c5146106f0578063f2fde38b1461072b578063f64f0a9d1461074b57600080fd5b8063bafa874b1461060f578063bd075be814610643578063c45493a914610663578063c87b56dd1461067657600080fd5b80639d328086116100dc5780639d3280861461058f578063a22cb465146105af578063a5afa55e146105cf578063b88d4fde146105ef57600080fd5b80636b8ff5741461051a57806370a082311461053a5780638da5cb5b1461055a57806395d89b411461057a57600080fd5b806335978c4a116101855780635bc0a623116101545780635bc0a623146104625780635f5b87c0146104825780636352211e146104b7578063637f52b3146104ed57600080fd5b806335978c4a146103785780633d9b11fb146103a65780633fef10611461041557806342842e0e1461044257600080fd5b8063169f1ced116101c1578063169f1ced146102c55780631ee0f279146102f957806323b872dd146103195780632a55205a1461033957600080fd5b806301ffc9a7146101fe57806306fdde0314610233578063081812fc14610255578063095ea7b3146102a357600080fd5b366101f957005b600080fd5b34801561020a57600080fd5b5061021e610219366004612cfd565b61076b565b60405190151581526020015b60405180910390f35b34801561023f57600080fd5b506102486107d8565b60405161022a9190612d3e565b34801561026157600080fd5b5061028b610270366004612d71565b6003602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161022a565b3480156102af57600080fd5b506102c36102be366004612daa565b610866565b005b3480156102d157600080fd5b5061028b7f000000000000000000000000000000000000000000000000000000000000000081565b34801561030557600080fd5b506102c3610314366004612e1b565b61094d565b34801561032557600080fd5b506102c3610334366004612e5d565b610a79565b34801561034557600080fd5b50610359610354366004612e9e565b610ddc565b604080516001600160a01b03909316835260208301919091520161022a565b34801561038457600080fd5b50610398610393366004612ec0565b610e8a565b60405190815260200161022a565b3480156103b257600080fd5b506103ee6103c1366004612d71565b6008602052600090815260409020546001600160a01b03811690600160a01b90046001600160601b031682565b604080516001600160a01b0390931683526001600160601b0390911660208301520161022a565b34801561042157600080fd5b50610435610430366004612f15565b6110d8565b60405161022a9190612f6d565b34801561044e57600080fd5b506102c361045d366004612e5d565b6111ac565b34801561046e57600080fd5b5061039861047d366004612d71565b6112a4565b34801561048e57600080fd5b50610497611313565b604080516001600160a01b0393841681529290911660208301520161022a565b3480156104c357600080fd5b5061028b6104d2366004612d71565b6000908152600860205260409020546001600160a01b031690565b3480156104f957600080fd5b50610398610508366004612f15565b600a6020526000908152604090205481565b34801561052657600080fd5b50610248610535366004612d71565b611641565b34801561054657600080fd5b50610398610555366004612f15565b6117d2565b34801561056657600080fd5b5060075461028b906001600160a01b031681565b34801561058657600080fd5b50610248611835565b34801561059b57600080fd5b506102c36105aa366004612e1b565b611842565b3480156105bb57600080fd5b506102c36105ca366004612f8e565b61194d565b3480156105db57600080fd5b506104356105ea36600461300e565b6119b9565b3480156105fb57600080fd5b506102c361060a3660046130c6565b611abb565b34801561061b57600080fd5b5061028b7f000000000000000000000000000000000000000000000000000000000000000081565b34801561064f57600080fd5b506102c361065e366004613165565b611ba3565b6102c3610671366004612e9e565b611c44565b34801561068257600080fd5b50610248610691366004612d71565b611c8c565b3480156106a257600080fd5b506103986106b1366004612d71565b600b6020526000908152604090205481565b3480156106cf57600080fd5b506103986106de366004612d71565b60096020526000908152604090205481565b3480156106fc57600080fd5b5061021e61070b36600461318e565b600460209081526000928352604080842090915290825290205460ff1681565b34801561073757600080fd5b506102c3610746366004612f15565b611e1a565b34801561075757600080fd5b506102c3610766366004612f15565b611e90565b60006301ffc9a760e01b6001600160e01b03198316148061079c57506380ac58cd60e01b6001600160e01b03198316145b806107b757506001600160e01b0319821663152a902d60e11b145b806107d25750635b5e139f60e01b6001600160e01b03198316145b92915050565b600080546107e5906131bc565b80601f0160208091040260200160405190810160405280929190818152602001828054610811906131bc565b801561085e5780601f106108335761010080835404028352916020019161085e565b820191906000526020600020905b81548152906001019060200180831161084157829003601f168201915b505050505081565b6000818152600860205260409020546001600160a01b0316338114806108af57506001600160a01b038116600090815260046020908152604080832033845290915290205460ff165b6108f15760405162461bcd60e51b815260206004820152600e60248201526d1393d517d055551213d49256915160921b60448201526064015b60405180910390fd5b60008281526003602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60005b81811015610a3757337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e85858581811061099a5761099a6131f6565b905060200201356040518263ffffffff1660e01b81526004016109bf91815260200190565b602060405180830381865afa1580156109dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a00919061320c565b6001600160a01b031614610a27576040516352cfcc0760e11b815260040160405180910390fd5b610a308161323f565b9050610950565b50610a753383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061202c92505050565b5050565b6000818152600860205260409020546001600160a01b03848116911614610ab35760405163c6de3f2560e01b815260040160405180910390fd5b6001600160a01b038216610ada5760405163c3b65ced60e01b815260040160405180910390fd5b336001600160a01b03841614801590610b1757506001600160a01b038316600090815260046020908152604080832033845290915290205460ff16155b8015610b3a57506000818152600360205260409020546001600160a01b03163314155b15610b585760405163b4c9b31760e01b815260040160405180910390fd5b6001600160a01b0383811660008181526002602090815260408083208054600019019055868516835280832080546001019055858352600390915280822080546001600160a01b0319169055516324a5046360e21b81526004810192909252429290917f000000000000000000000000000000000000000000000000000000000000000090911690639294118c90602401602060405180830381865afa925050508015610c22575060408051601f3d908101601f19168201909252610c1f91810190613258565b60015b15610c2a5790505b80610cb9576040516324a5046360e21b81526001600160a01b0385811660048301527f00000000000000000000000000000000000000000000000000000000000000001690639294118c90602401602060405180830381865afa925050508015610cb1575060408051601f3d908101601f19168201909252610cae91810190613258565b60015b15610cb95790505b8015610ceb57600083815260086020526040902080546001600160a01b0319166001600160a01b038616179055610d94565b600083815260086020526040902054600160a01b90046001600160601b0316821015610d2a5760405163b0782df760e01b815260040160405180910390fd5b6040518060400160405280856001600160a01b031681526020018362093a80610d539190613275565b6001600160601b03908116909152600085815260086020908152604090912083519390910151909116600160a01b026001600160a01b039092169190911790555b82846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050505050565b60008281526006602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291610e515750604080518082019091526005546001600160a01b0381168252600160a01b90046001600160601b031660208201525b602081015160009061271090610e70906001600160601b031687613288565b610e7a91906132b5565b91519350909150505b9250929050565b600081610e9685611e90565b6001600160a01b0385166000908152600a6020526040812054610ebc90610200906132b5565b905060005b82811015610fb25733610f01878784818110610edf57610edf6131f6565b905060200201356000908152600860205260409020546001600160a01b031690565b6001600160a01b031603610f89576000868683818110610f2357610f236131f6565b905060200201356060896001600160a01b0316901b1790506000600960008381526020019081526020016000205484610f5c91906132c9565b90508015610f8257610f6e8187613275565b600083815260096020526040902085905595505b5050610fa2565b604051631d4b433560e01b815260040160405180910390fd5b610fab8161323f565b9050610ec1565b506001600160a01b038616611046576040516364a197f360e01b8152336004820152602481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906364a197f390604401600060405180830381600087803b15801561102957600080fd5b505af115801561103d573d6000803e3d6000fd5b505050506110cf565b6040516323e5d69960e21b81523360048201526001600160a01b038781166024830152604482018590527f00000000000000000000000000000000000000000000000000000000000000001690638f975a6490606401600060405180830381600087803b1580156110b657600080fd5b505af11580156110ca573d6000803e3d6000fd5b505050505b50509392505050565b606060006110e5836117d2565b905060008167ffffffffffffffff81111561110257611102612fc7565b60405190808252806020026020018201604052801561112b578160200160208202803683370190505b50905081156111a5576000805b6102008110156110cf576000818152600860205260409020546001600160a01b03908116908716810361119c5781848481518110611178576111786131f6565b60200260200101818152505082600101925084830361119c57509195945050505050565b50600101611138565b9392505050565b6111b7838383610a79565b6001600160a01b0382163b15806112605750604051630a85bd0160e11b8082523360048301526001600160a01b03858116602484015260448301849052608060648401526000608484015290919084169063150b7a029060a4016020604051808303816000875af1158015611230573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125491906132dc565b6001600160e01b031916145b61129f5760405162461bcd60e51b815260206004820152601060248201526f155394d0519157d49150d2541251539560821b60448201526064016108e8565b505050565b6000818152600b602052604081205481036112e4576040805160208101849052015b60408051601f19818403018152919052805160209091012092915050565b6000828152600b6020908152604091829020548251918201859052918101919091526060016112c6565b919050565b60075460009081906001600160a01b031633146113425760405162461bcd60e51b81526004016108e8906132f9565b604080516000808252610180820183526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166020840190815230848601527f00000000000000000000000000000000000000000000000000000000000000008216606085015260808401839052600160a08501526e59682f000000002d3600000000000042176001600160801b031660c085015260e08401839052674563918244f40000610100850152610120840183905261014084018490526101608401929092529251634b58c15f60e11b815291927f000000000000000000000000000000000000000000000000000000000000000016916396b182be9161145191600401613341565b6020604051808303816000875af1158015611470573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611494919061320c565b6040516382c1b8ff60e01b81529093506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906382c1b8ff9061151c9030907f0000000000000000000000000000000000000000000000000000000000000000908290600290662d79883d20000090600090829082908c90600401613447565b6020604051808303816000875af115801561153b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155f919061320c565b6040805160458082526108c0820190925291935060009190602082016108a08036833701905050905060005b60458110156115c5576115a081610155613275565b8282815181106115b2576115b26131f6565b602090810291909101015260010161158b565b506115d0848261202c565b604080516066808252610ce082019092529060208201610cc08036833701905050905060005b60668110156116305761160b8161019a613275565b82828151811061161d5761161d6131f6565b60209081029190910101526001016115f6565b5061163b838261202c565b50509091565b606060008290506000611676604051806080016040528060608152602001613a86606091396116716023856134c9565b612199565b90508160405160200161168b91815260200190565b6040516020818303038152906040528051906020012060001c915060006116cf604051806080016040528060568152602001613b2660569139611671601a866134c9565b9050600082826040516020016116e69291906134f9565b60408051601f19818403018152828252602083018790529250016040516020818303038152906040528051906020012060001c935060005b61172a60026001613275565b61173490866134c9565b8110156117c857600061176560405180610100016040528060ca8152602001613b7c60ca9139611671603c896134c9565b90508560405160200161177a91815260200190565b60408051601f1981840301815290829052805160209182012097506117a39185918491016134f9565b60405160208183030381529060405292505080806117c09061323f565b91505061171e565b5095945050505050565b60006001600160a01b0382166118195760405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b60448201526064016108e8565b506001600160a01b031660009081526002602052604090205490565b600180546107e5906131bc565b6007546001600160a01b0316331461186c5760405162461bcd60e51b81526004016108e8906132f9565b61189962093a807f0000000000000000000000000000000000000000000000000000000000000000613275565b4210156118b957604051630e8ff4f360e11b815260040160405180910390fd5b8060005b8181101561190f576101558484838181106118da576118da6131f6565b90506020020135106118ff5760405163016c400b60e41b815260040160405180910390fd5b6119088161323f565b90506118bd565b5061129f3384848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061202c92505050565b3360008181526004602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b81516060908067ffffffffffffffff8111156119d7576119d7612fc7565b604051908082528060200260200182016040528015611a00578160200160208202803683370190505b506001600160a01b0384166000908152600a602052604081205491935090611a2b90610200906132b5565b905060005b82811015611ab2576000868281518110611a4c57611a4c6131f6565b60200260200101516060876001600160a01b0316901b179050600960008281526020019081526020016000205483611a8491906132c9565b858381518110611a9657611a966131f6565b602090810291909101015250611aab8161323f565b9050611a30565b50505092915050565b611ac6858585610a79565b6001600160a01b0384163b1580611b5d5750604051630a85bd0160e11b808252906001600160a01b0386169063150b7a0290611b0e9033908a90899089908990600401613528565b6020604051808303816000875af1158015611b2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5191906132dc565b6001600160e01b031916145b611b9c5760405162461bcd60e51b815260206004820152601060248201526f155394d0519157d49150d2541251539560821b60448201526064016108e8565b5050505050565b6007546001600160a01b03163314611bcd5760405162461bcd60e51b81526004016108e8906132f9565b6103e8816001600160601b031611611c2857611be9308261225d565b6040516001600160601b03821681527ff56c18f7a70485e938b87e3d7e58858e493a28163eb0efb8f9b607f50d0a91279060200160405180910390a150565b604051637901a5a760e11b815260040160405180910390fd5b50565b34662386f26fc1000014611c5757600080fd5b6000828152600860205260409020546001600160a01b03163314611c7a57600080fd5b6000918252600b602052604090912055565b60606000827f0000000000000000000000000000000000000000000000000000000000000000604051602001611cd59291909182526001600160a01b0316602082015260400190565b6040516020818303038152906040528051906020012060001c9050611df3611cfc84611641565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663cde1309c611d34876112a4565b6040516001600160e01b031960e084901b1681526004810191909152602a6024820152604401600060405180830381865afa158015611d77573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d9f919081019061357c565b6040518060600160405280602b8152602001613c46602b9139611dc18761235a565b611dcb86896123ed565b604051602001611ddf959493929190613610565b60405160208183030381529060405261244c565b604051602001611e039190613736565b604051602081830303815290604052915050919050565b6007546001600160a01b03163314611e445760405162461bcd60e51b81526004016108e8906132f9565b600780546001600160a01b0319166001600160a01b03831690811790915560405133907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a350565b6001600160a01b038116611f5a576000808052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e380544792839291611edb908490613275565b90915550611f1490506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016826125b6565b604080516001600160a01b0384168152602081018390527f8fbbda19f4a70036f6f585dc4160142a8fa2a20ffb9393d23274f78de4e39888910160405180910390a15050565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc5919061377b565b6001600160a01b0383166000908152600a6020526040812080549293508392909190611ff2908490613275565b90915550611f1490506001600160a01b0383167f000000000000000000000000000000000000000000000000000000000000000083612607565b6001600160a01b0382166120765760405162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b60448201526064016108e8565b80516001600160a01b03831660009081526002602052604081208054830190555b818110156121935760008382815181106120b3576120b36131f6565b6020026020010151905061020081106120df5760405163016c400b60e41b815260040160405180910390fd5b6000818152600860205260409020546001600160a01b0316156121355760405162461bcd60e51b815260206004820152600e60248201526d1053149150511657d3525395115160921b60448201526064016108e8565b60008181526008602052604080822080546001600160a01b0319166001600160a01b03891690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a450600101612097565b50505050565b606060006121ce8460408051808201825260008082526020918201528151808301909252825182529182019181019190915290565b60408051808201825260018152600b60fa1b6020808301918252835180850185526000808252908201819052845180860186528451815280830193909352845180860190955280855290840152929350919060005b868111612248576122348584612688565b9150806122408161323f565b915050612223565b50612252816126ae565b979650505050505050565b6127106001600160601b03821611156122cb5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b60648201526084016108e8565b6001600160a01b0382166123215760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c69642072656365697665720000000000000060448201526064016108e8565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600555565b6060600061236783612717565b600101905060008167ffffffffffffffff81111561238757612387612fc7565b6040519080825280601f01601f1916602001820160405280156123b1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846123bb57509392505050565b60606124006123fb846127ef565b61235a565b61240c6123fb8561282c565b6124186123fb86612893565b6124228686612901565b6040516020016124359493929190613794565b604051602081830303815290604052905092915050565b80516060906000819003612470575050604080516020810190915260008152919050565b6000600361247f836002613275565b61248991906132b5565b612494906004613288565b905060006124a3826020613275565b67ffffffffffffffff8111156124bb576124bb612fc7565b6040519080825280601f01601f1916602001820160405280156124e5576020820181803683370190505b5090506000604051806060016040528060408152602001613ae6604091399050600181016020830160005b86811015612571576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101612510565b50600386066001811461258b576002811461259c576125a8565b613d3d60f01b6001198301526125a8565b603d60f81b6000198301525b505050918152949350505050565b600080600080600085875af190508061129f5760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b60448201526064016108e8565b600060405163a9059cbb60e01b81526001600160a01b0384166004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806121935760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016108e8565b60408051808201909152600080825260208201526126a7838383612939565b5092915050565b60606000826000015167ffffffffffffffff8111156126cf576126cf612fc7565b6040519080825280601f01601f1916602001820160405280156126f9576020820181803683370190505b50905060006020820190506126a781856020015186600001516129e4565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106127565772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310612782576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106127a057662386f26fc10000830492506010015b6305f5e10083106127b8576305f5e100830492506008015b61271083106127cc57612710830492506004015b606483106127de576064830492506002015b600a83106107d25760010192915050565b6000806102008180612802836001613275565b61280c91906132c9565b90508261281982876134c9565b6128239190613275565b95945050505050565b6000806102008161283c856127ef565b60408051602080820189905281830187905260608083018790528351808403909101815260809092019092528051910120909150600061287b826127ef565b905060026128898285613275565b61225291906132b5565b6000806102008160026128a68383613275565b6128b091906132b5565b905060006128bd8661282c565b90508181106128e1576128d082826132c9565b6128da90846132c9565b94506128f8565b6128eb81836132c9565b6128f59085613275565b94505b50505050919050565b606061290f6123fb84612a55565b61291b6123fb85612abf565b6129276123fb85612b54565b6040516020016124359392919061389c565b6040805180820190915260008082526020820152600061296b8560000151866020015186600001518760200151612bcb565b60208087018051918601919091525190915061298790826132c9565b83528451602086015161299a9190613275565b81036129a957600085526129db565b835183516129b79190613275565b855186906129c69083906132c9565b90525083516129d59082613275565b60208601525b50909392505050565b60208110612a1c57815183526129fb602084613275565b9250612a08602083613275565b9150612a156020826132c9565b90506129e4565b60006001612a2b8360206132c9565b612a3790610100613a79565b612a4191906132c9565b925184518416931916929092179092525050565b600080610200612a64846127ef565b9250612a716002846134c9565b600103612ab857604080516020810186905290810183905260608101829052612ab5906080016040516020818303038152906040528051906020012060001c6127ef565b92505b5050919050565b600080612acd6004846134c9565b90506000612ada846127ef565b612ae490856132b5565b604051602001612af691815260200190565b6040516020818303038152906040528051906020012060001c905081600003612b2957612b2281612893565b9250612b4b565b81600103612b3a57612b22816127ef565b81600203612b4b57612b228161282c565b612ab581612a55565b600081600003612b6657506000919050565b60025b612b746002846132b5565b8111612bc257600081612b8781866132b5565b612b919190613288565b612b9b90856132c9565b905080600003612baf575060019392505050565b5080612bba8161323f565b915050612b69565b50600292915050565b60008381868511612cd05760208511612c7f5760006001612bed8760206132c9565b612bf8906008613288565b612c03906002613a79565b612c0d91906132c9565b8551901991508116600087612c228b8b613275565b612c2c91906132c9565b855190915083165b828114612c7157818610612c5957612c4c8b8b613275565b9650505050505050612cdf565b85612c638161323f565b965050838651169050612c34565b859650505050505050612cdf565b508383206000905b612c9186896132c9565b8211612cce57858320808203612cad5783945050505050612cdf565b612cb8600185613275565b9350508180612cc69061323f565b925050612c87565b505b612cda8787613275565b925050505b949350505050565b6001600160e01b031981168114611c4157600080fd5b600060208284031215612d0f57600080fd5b81356111a581612ce7565b60005b83811015612d35578181015183820152602001612d1d565b50506000910152565b6020815260008251806020840152612d5d816040850160208701612d1a565b601f01601f19169190910160400192915050565b600060208284031215612d8357600080fd5b5035919050565b6001600160a01b0381168114611c4157600080fd5b803561130e81612d8a565b60008060408385031215612dbd57600080fd5b8235612dc881612d8a565b946020939093013593505050565b60008083601f840112612de857600080fd5b50813567ffffffffffffffff811115612e0057600080fd5b6020830191508360208260051b8501011115610e8357600080fd5b60008060208385031215612e2e57600080fd5b823567ffffffffffffffff811115612e4557600080fd5b612e5185828601612dd6565b90969095509350505050565b600080600060608486031215612e7257600080fd5b8335612e7d81612d8a565b92506020840135612e8d81612d8a565b929592945050506040919091013590565b60008060408385031215612eb157600080fd5b50508035926020909101359150565b600080600060408486031215612ed557600080fd5b8335612ee081612d8a565b9250602084013567ffffffffffffffff811115612efc57600080fd5b612f0886828701612dd6565b9497909650939450505050565b600060208284031215612f2757600080fd5b81356111a581612d8a565b600081518084526020808501945080840160005b83811015612f6257815187529582019590820190600101612f46565b509495945050505050565b6020815260006111a56020830184612f32565b8015158114611c4157600080fd5b60008060408385031215612fa157600080fd5b8235612fac81612d8a565b91506020830135612fbc81612f80565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561300657613006612fc7565b604052919050565b6000806040838503121561302157600080fd5b823567ffffffffffffffff8082111561303957600080fd5b818501915085601f83011261304d57600080fd5b813560208282111561306157613061612fc7565b8160051b9250613072818401612fdd565b828152928401810192818101908985111561308c57600080fd5b948201945b848610156130aa57853582529482019490820190613091565b96506130b99050878201612d9f565b9450505050509250929050565b6000806000806000608086880312156130de57600080fd5b85356130e981612d8a565b945060208601356130f981612d8a565b935060408601359250606086013567ffffffffffffffff8082111561311d57600080fd5b818801915088601f83011261313157600080fd5b81358181111561314057600080fd5b89602082850101111561315257600080fd5b9699959850939650602001949392505050565b60006020828403121561317757600080fd5b81356001600160601b03811681146111a557600080fd5b600080604083850312156131a157600080fd5b82356131ac81612d8a565b91506020830135612fbc81612d8a565b600181811c908216806131d057607f821691505b6020821081036131f057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561321e57600080fd5b81516111a581612d8a565b634e487b7160e01b600052601160045260246000fd5b60006001820161325157613251613229565b5060010190565b60006020828403121561326a57600080fd5b81516111a581612f80565b808201808211156107d2576107d2613229565b80820281158282048414176107d2576107d2613229565b634e487b7160e01b600052601260045260246000fd5b6000826132c4576132c461329f565b500490565b818103818111156107d2576107d2613229565b6000602082840312156132ee57600080fd5b81516111a581612ce7565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b6003811061333d57634e487b7160e01b600052602160045260246000fd5b9052565b6020815261335b6020820183516001600160a01b03169052565b6000602083015161337760408401826001600160a01b03169052565b5060408301516001600160a01b03811660608401525060608301516001600160a01b03811660808401525060808301516133b460a084018261331f565b5060a08301516001600160801b03811660c08401525060c08301516001600160601b03811660e08401525060e08301516101006133fb818501836001600160801b03169052565b8401519050610120613417848201836001600160a01b03169052565b808501519150506101606101408181860152613437610180860184612f32565b9501519301929092525090919050565b6001600160a01b038a811682528981166020830152888116604083015260009061012090613478606085018b61331f565b6001600160801b0389811660808601526001600160601b03891660a0860152871660c0850152851660e084015261010083018190526134b981840185612f32565b9c9b505050505050505050505050565b6000826134d8576134d861329f565b500690565b600081516134ef818560208601612d1a565b9290920192915050565b6000835161350b818460208801612d1a565b83519083019061351f818360208801612d1a565b01949350505050565b6001600160a01b038681168252851660208201526040810184905260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b60006020828403121561358e57600080fd5b815167ffffffffffffffff808211156135a657600080fd5b818401915084601f8301126135ba57600080fd5b8151818111156135cc576135cc612fc7565b6135df601f8201601f1916602001612fdd565b91508082528560208285010111156135f657600080fd5b613607816020840160208601612d1a565b50949350505050565b683d913730b6b2911d1160b91b81528551600090613635816009850160208b01612d1a565b71111610113232b9b1b934b83a34b7b7111d1160711b600991840191820152865161366781601b840160208b01612d1a565b6c1116101134b6b0b3b2911d101160991b601b92909101918201526461723a2f2f60d81b602882015285516136a381602d840160208a01612d1a565b612f6d60f01b602d929091019182015284516136c681602f840160208901612d1a565b61372961371c61370f6137096136eb602f86880101631733b4b360e11b815260040190565b71222c202261747472696275746573223a205b60701b815260120190565b886134dd565b605d60f81b815260010190565b607d60f81b815260010190565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161376e81601d850160208701612d1a565b91909101601d0192915050565b60006020828403121561378d57600080fd5b5051919050565b607b60f81b81527f2274726169745f74797065223a20225452414954204f4e45222c2276616c7565600182015263111d101160e11b602182015284516000906137e4816025850160208a01612d1a565b63227d2c7b60e01b60259184019182018190527f2274726169745f74797065223a202237523431375f32222c2276616c7565223a602983015261101160f11b6049830152865161383b81604b850160208b01612d1a565b604b9201918201527f2274726169745f74797065223a2022747261697433222c2276616c7565223a20604f820152601160f91b606f82015261225261389661388660708401886134dd565b63227d2c7b60e01b815260040190565b856134dd565b7f2274726169745f74797065223a2022347469617274222c2276616c7565223a208152601160f91b6020820152600084516138de816021850160208901612d1a565b63227d2c7b60e01b60219184019182018190527f2274726169745f74797065223a202256222c2276616c7565223a2022000000006025830152855161392a816041850160208a01612d1a565b60419201918201527f2274726169745f74797065223a20222d2d202e202e202e202e222c2276616c7560458201526432911d101160d91b6065820152835161397981606a840160208801612d1a565b61227d60f01b606a9290910191820152606c0195945050505050565b600181815b808511156139d05781600019048211156139b6576139b6613229565b808516156139c357918102915b93841c939080029061399a565b509250929050565b6000826139e7575060016107d2565b816139f4575060006107d2565b8160018114613a0a5760028114613a1457613a30565b60019150506107d2565b60ff841115613a2557613a25613229565b50506001821b6107d2565b5060208310610133831016604e8410600b8410161715613a53575081810a6107d2565b613a5d8383613995565b8060001904821115613a7157613a71613229565b029392505050565b60006111a583836139d856fe4374682c417a2c41702c43682c426c2c47682c476c2c4b722c4d2c4e6c2c4e792c442c58792c52682c552c426c2c437a2c456e2c467a2c482c496c2c4a2c4a682c592c59764b2c5a2c5a682c536c2c542c4f2c552c55622c4f732c45682c53684142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f616b2c616c2c65732c65742c69642c696c2c69642c6f6f2c6f722c75782c756e2c61702c656b2c65782c696e2c6f6c2c75702c2d61662c2d61772c2765742c2765642c2d696e2c2d69732c276f642c2d61742c2d6f6661672c616c2c6f6e2c616b2c6173682c612c6265722c62616c2c62756b2c636c612c6365642c636b2c6461722c6472752c6573742c656e642c666c692c66612c2d6675722c67656e2c67612c6869732c68612c696c6b2c696e2c2d696e2c6a752c6a612c2d6b692c6c6c2c6c6f2c6d6f2c2d6d752c6d612c6e6f2c722c73732c73682c73746f2c74612c7468612c756e2c76792c76612c77792c77752c792c79792c7a2c7a732c746f6e2c676f6e2c2d6d616e2c6c752c6765742c6861722c757a2c656b2c65632c2d73587844675a73364c5257446d7a51496652304c737369633861346b3365516279616f7374744f626a374563a2646970667358221220db7b652469e7381a76650f39bb9f22d88ca4a0c58450bfabbdd8fd05caa6eb9b64736f6c63430008140033608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506103cc806100616000396000f3fe6080604052600436106100435760003560e01c806364a197f31461004f5780638da5cb5b146100715780638f975a64146100ad578063f2fde38b146100cd57600080fd5b3661004a57005b600080fd5b34801561005b57600080fd5b5061006f61006a3660046102df565b6100ed565b005b34801561007d57600080fd5b50600054610091906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b3480156100b957600080fd5b5061006f6100c836600461030b565b610137565b3480156100d957600080fd5b5061006f6100e836600461034c565b61017a565b6000546001600160a01b031633146101205760405162461bcd60e51b815260040161011790610370565b60405180910390fd5b6101336001600160a01b038316826101ef565b5050565b6000546001600160a01b031633146101615760405162461bcd60e51b815260040161011790610370565b6101756001600160a01b0383168483610240565b505050565b6000546001600160a01b031633146101a45760405162461bcd60e51b815260040161011790610370565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b600080600080600085875af19050806101755760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b6044820152606401610117565b600060405163a9059cbb60e01b81526001600160a01b0384166004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806102c15760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606401610117565b50505050565b6001600160a01b03811681146102dc57600080fd5b50565b600080604083850312156102f257600080fd5b82356102fd816102c7565b946020939093013593505050565b60008060006060848603121561032057600080fd5b833561032b816102c7565b9250602084013561033b816102c7565b929592945050506040919091013590565b60006020828403121561035e57600080fd5b8135610369816102c7565b9392505050565b6020808252600c908201526b15539055551213d49256915160a21b60408201526060019056fea2646970667358221220f69a0c7c1200f108e1172c5c9c1b986a21d96b2fd0ae3aeeb690bf3227d0fd0564736f6c634300081400330000000000000000000000000427743df720801825a5c82e0582b1e915e0f750000000000000000000000000a020d57ab0448ef74115c112d18a9c231cc860000000000000000000000000002a7021d9a7cd3a13b00fb01a5b5dead63705676d0000000000000000000000001fd5876d4a3860eb0159055a3b7cb79fdfff6b670000000000000000000000003aada3e213abf8529606924d8d1c55cbdc70bf74000000000000000000000000e5d78fec1a7f42d2f3620238c498f088a866fdc5
Deployed Bytecode
0x6080604052600436106101f25760003560e01c80636b8ff5741161010d578063bafa874b116100a0578063c8d16a2f1161006f578063c8d16a2f14610696578063e1e562c7146106c3578063e985e9c5146106f0578063f2fde38b1461072b578063f64f0a9d1461074b57600080fd5b8063bafa874b1461060f578063bd075be814610643578063c45493a914610663578063c87b56dd1461067657600080fd5b80639d328086116100dc5780639d3280861461058f578063a22cb465146105af578063a5afa55e146105cf578063b88d4fde146105ef57600080fd5b80636b8ff5741461051a57806370a082311461053a5780638da5cb5b1461055a57806395d89b411461057a57600080fd5b806335978c4a116101855780635bc0a623116101545780635bc0a623146104625780635f5b87c0146104825780636352211e146104b7578063637f52b3146104ed57600080fd5b806335978c4a146103785780633d9b11fb146103a65780633fef10611461041557806342842e0e1461044257600080fd5b8063169f1ced116101c1578063169f1ced146102c55780631ee0f279146102f957806323b872dd146103195780632a55205a1461033957600080fd5b806301ffc9a7146101fe57806306fdde0314610233578063081812fc14610255578063095ea7b3146102a357600080fd5b366101f957005b600080fd5b34801561020a57600080fd5b5061021e610219366004612cfd565b61076b565b60405190151581526020015b60405180910390f35b34801561023f57600080fd5b506102486107d8565b60405161022a9190612d3e565b34801561026157600080fd5b5061028b610270366004612d71565b6003602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161022a565b3480156102af57600080fd5b506102c36102be366004612daa565b610866565b005b3480156102d157600080fd5b5061028b7f000000000000000000000000fd74138815ced52e05b0988d3aba3235545c2ff981565b34801561030557600080fd5b506102c3610314366004612e1b565b61094d565b34801561032557600080fd5b506102c3610334366004612e5d565b610a79565b34801561034557600080fd5b50610359610354366004612e9e565b610ddc565b604080516001600160a01b03909316835260208301919091520161022a565b34801561038457600080fd5b50610398610393366004612ec0565b610e8a565b60405190815260200161022a565b3480156103b257600080fd5b506103ee6103c1366004612d71565b6008602052600090815260409020546001600160a01b03811690600160a01b90046001600160601b031682565b604080516001600160a01b0390931683526001600160601b0390911660208301520161022a565b34801561042157600080fd5b50610435610430366004612f15565b6110d8565b60405161022a9190612f6d565b34801561044e57600080fd5b506102c361045d366004612e5d565b6111ac565b34801561046e57600080fd5b5061039861047d366004612d71565b6112a4565b34801561048e57600080fd5b50610497611313565b604080516001600160a01b0393841681529290911660208301520161022a565b3480156104c357600080fd5b5061028b6104d2366004612d71565b6000908152600860205260409020546001600160a01b031690565b3480156104f957600080fd5b50610398610508366004612f15565b600a6020526000908152604090205481565b34801561052657600080fd5b50610248610535366004612d71565b611641565b34801561054657600080fd5b50610398610555366004612f15565b6117d2565b34801561056657600080fd5b5060075461028b906001600160a01b031681565b34801561058657600080fd5b50610248611835565b34801561059b57600080fd5b506102c36105aa366004612e1b565b611842565b3480156105bb57600080fd5b506102c36105ca366004612f8e565b61194d565b3480156105db57600080fd5b506104356105ea36600461300e565b6119b9565b3480156105fb57600080fd5b506102c361060a3660046130c6565b611abb565b34801561061b57600080fd5b5061028b7f0000000000000000000000002a7021d9a7cd3a13b00fb01a5b5dead63705676d81565b34801561064f57600080fd5b506102c361065e366004613165565b611ba3565b6102c3610671366004612e9e565b611c44565b34801561068257600080fd5b50610248610691366004612d71565b611c8c565b3480156106a257600080fd5b506103986106b1366004612d71565b600b6020526000908152604090205481565b3480156106cf57600080fd5b506103986106de366004612d71565b60096020526000908152604090205481565b3480156106fc57600080fd5b5061021e61070b36600461318e565b600460209081526000928352604080842090915290825290205460ff1681565b34801561073757600080fd5b506102c3610746366004612f15565b611e1a565b34801561075757600080fd5b506102c3610766366004612f15565b611e90565b60006301ffc9a760e01b6001600160e01b03198316148061079c57506380ac58cd60e01b6001600160e01b03198316145b806107b757506001600160e01b0319821663152a902d60e11b145b806107d25750635b5e139f60e01b6001600160e01b03198316145b92915050565b600080546107e5906131bc565b80601f0160208091040260200160405190810160405280929190818152602001828054610811906131bc565b801561085e5780601f106108335761010080835404028352916020019161085e565b820191906000526020600020905b81548152906001019060200180831161084157829003601f168201915b505050505081565b6000818152600860205260409020546001600160a01b0316338114806108af57506001600160a01b038116600090815260046020908152604080832033845290915290205460ff165b6108f15760405162461bcd60e51b815260206004820152600e60248201526d1393d517d055551213d49256915160921b60448201526064015b60405180910390fd5b60008281526003602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60005b81811015610a3757337f0000000000000000000000000427743df720801825a5c82e0582b1e915e0f7506001600160a01b0316636352211e85858581811061099a5761099a6131f6565b905060200201356040518263ffffffff1660e01b81526004016109bf91815260200190565b602060405180830381865afa1580156109dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a00919061320c565b6001600160a01b031614610a27576040516352cfcc0760e11b815260040160405180910390fd5b610a308161323f565b9050610950565b50610a753383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061202c92505050565b5050565b6000818152600860205260409020546001600160a01b03848116911614610ab35760405163c6de3f2560e01b815260040160405180910390fd5b6001600160a01b038216610ada5760405163c3b65ced60e01b815260040160405180910390fd5b336001600160a01b03841614801590610b1757506001600160a01b038316600090815260046020908152604080832033845290915290205460ff16155b8015610b3a57506000818152600360205260409020546001600160a01b03163314155b15610b585760405163b4c9b31760e01b815260040160405180910390fd5b6001600160a01b0383811660008181526002602090815260408083208054600019019055868516835280832080546001019055858352600390915280822080546001600160a01b0319169055516324a5046360e21b81526004810192909252429290917f000000000000000000000000a020d57ab0448ef74115c112d18a9c231cc8600090911690639294118c90602401602060405180830381865afa925050508015610c22575060408051601f3d908101601f19168201909252610c1f91810190613258565b60015b15610c2a5790505b80610cb9576040516324a5046360e21b81526001600160a01b0385811660048301527f000000000000000000000000a020d57ab0448ef74115c112d18a9c231cc860001690639294118c90602401602060405180830381865afa925050508015610cb1575060408051601f3d908101601f19168201909252610cae91810190613258565b60015b15610cb95790505b8015610ceb57600083815260086020526040902080546001600160a01b0319166001600160a01b038616179055610d94565b600083815260086020526040902054600160a01b90046001600160601b0316821015610d2a5760405163b0782df760e01b815260040160405180910390fd5b6040518060400160405280856001600160a01b031681526020018362093a80610d539190613275565b6001600160601b03908116909152600085815260086020908152604090912083519390910151909116600160a01b026001600160a01b039092169190911790555b82846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050505050565b60008281526006602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291610e515750604080518082019091526005546001600160a01b0381168252600160a01b90046001600160601b031660208201525b602081015160009061271090610e70906001600160601b031687613288565b610e7a91906132b5565b91519350909150505b9250929050565b600081610e9685611e90565b6001600160a01b0385166000908152600a6020526040812054610ebc90610200906132b5565b905060005b82811015610fb25733610f01878784818110610edf57610edf6131f6565b905060200201356000908152600860205260409020546001600160a01b031690565b6001600160a01b031603610f89576000868683818110610f2357610f236131f6565b905060200201356060896001600160a01b0316901b1790506000600960008381526020019081526020016000205484610f5c91906132c9565b90508015610f8257610f6e8187613275565b600083815260096020526040902085905595505b5050610fa2565b604051631d4b433560e01b815260040160405180910390fd5b610fab8161323f565b9050610ec1565b506001600160a01b038616611046576040516364a197f360e01b8152336004820152602481018490527f000000000000000000000000fd74138815ced52e05b0988d3aba3235545c2ff96001600160a01b0316906364a197f390604401600060405180830381600087803b15801561102957600080fd5b505af115801561103d573d6000803e3d6000fd5b505050506110cf565b6040516323e5d69960e21b81523360048201526001600160a01b038781166024830152604482018590527f000000000000000000000000fd74138815ced52e05b0988d3aba3235545c2ff91690638f975a6490606401600060405180830381600087803b1580156110b657600080fd5b505af11580156110ca573d6000803e3d6000fd5b505050505b50509392505050565b606060006110e5836117d2565b905060008167ffffffffffffffff81111561110257611102612fc7565b60405190808252806020026020018201604052801561112b578160200160208202803683370190505b50905081156111a5576000805b6102008110156110cf576000818152600860205260409020546001600160a01b03908116908716810361119c5781848481518110611178576111786131f6565b60200260200101818152505082600101925084830361119c57509195945050505050565b50600101611138565b9392505050565b6111b7838383610a79565b6001600160a01b0382163b15806112605750604051630a85bd0160e11b8082523360048301526001600160a01b03858116602484015260448301849052608060648401526000608484015290919084169063150b7a029060a4016020604051808303816000875af1158015611230573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125491906132dc565b6001600160e01b031916145b61129f5760405162461bcd60e51b815260206004820152601060248201526f155394d0519157d49150d2541251539560821b60448201526064016108e8565b505050565b6000818152600b602052604081205481036112e4576040805160208101849052015b60408051601f19818403018152919052805160209091012092915050565b6000828152600b6020908152604091829020548251918201859052918101919091526060016112c6565b919050565b60075460009081906001600160a01b031633146113425760405162461bcd60e51b81526004016108e8906132f9565b604080516000808252610180820183526001600160a01b037f0000000000000000000000003aada3e213abf8529606924d8d1c55cbdc70bf7481166020840190815230848601527f0000000000000000000000001fd5876d4a3860eb0159055a3b7cb79fdfff6b678216606085015260808401839052600160a08501526e59682f000000002d3600000000000042176001600160801b031660c085015260e08401839052674563918244f40000610100850152610120840183905261014084018490526101608401929092529251634b58c15f60e11b815291927f000000000000000000000000a020d57ab0448ef74115c112d18a9c231cc8600016916396b182be9161145191600401613341565b6020604051808303816000875af1158015611470573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611494919061320c565b6040516382c1b8ff60e01b81529093506001600160a01b037f000000000000000000000000a020d57ab0448ef74115c112d18a9c231cc8600016906382c1b8ff9061151c9030907f000000000000000000000000e5d78fec1a7f42d2f3620238c498f088a866fdc5908290600290662d79883d20000090600090829082908c90600401613447565b6020604051808303816000875af115801561153b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155f919061320c565b6040805160458082526108c0820190925291935060009190602082016108a08036833701905050905060005b60458110156115c5576115a081610155613275565b8282815181106115b2576115b26131f6565b602090810291909101015260010161158b565b506115d0848261202c565b604080516066808252610ce082019092529060208201610cc08036833701905050905060005b60668110156116305761160b8161019a613275565b82828151811061161d5761161d6131f6565b60209081029190910101526001016115f6565b5061163b838261202c565b50509091565b606060008290506000611676604051806080016040528060608152602001613a86606091396116716023856134c9565b612199565b90508160405160200161168b91815260200190565b6040516020818303038152906040528051906020012060001c915060006116cf604051806080016040528060568152602001613b2660569139611671601a866134c9565b9050600082826040516020016116e69291906134f9565b60408051601f19818403018152828252602083018790529250016040516020818303038152906040528051906020012060001c935060005b61172a60026001613275565b61173490866134c9565b8110156117c857600061176560405180610100016040528060ca8152602001613b7c60ca9139611671603c896134c9565b90508560405160200161177a91815260200190565b60408051601f1981840301815290829052805160209182012097506117a39185918491016134f9565b60405160208183030381529060405292505080806117c09061323f565b91505061171e565b5095945050505050565b60006001600160a01b0382166118195760405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b60448201526064016108e8565b506001600160a01b031660009081526002602052604090205490565b600180546107e5906131bc565b6007546001600160a01b0316331461186c5760405162461bcd60e51b81526004016108e8906132f9565b61189962093a807f0000000000000000000000000000000000000000000000000000000065449ddb613275565b4210156118b957604051630e8ff4f360e11b815260040160405180910390fd5b8060005b8181101561190f576101558484838181106118da576118da6131f6565b90506020020135106118ff5760405163016c400b60e41b815260040160405180910390fd5b6119088161323f565b90506118bd565b5061129f3384848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061202c92505050565b3360008181526004602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b81516060908067ffffffffffffffff8111156119d7576119d7612fc7565b604051908082528060200260200182016040528015611a00578160200160208202803683370190505b506001600160a01b0384166000908152600a602052604081205491935090611a2b90610200906132b5565b905060005b82811015611ab2576000868281518110611a4c57611a4c6131f6565b60200260200101516060876001600160a01b0316901b179050600960008281526020019081526020016000205483611a8491906132c9565b858381518110611a9657611a966131f6565b602090810291909101015250611aab8161323f565b9050611a30565b50505092915050565b611ac6858585610a79565b6001600160a01b0384163b1580611b5d5750604051630a85bd0160e11b808252906001600160a01b0386169063150b7a0290611b0e9033908a90899089908990600401613528565b6020604051808303816000875af1158015611b2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5191906132dc565b6001600160e01b031916145b611b9c5760405162461bcd60e51b815260206004820152601060248201526f155394d0519157d49150d2541251539560821b60448201526064016108e8565b5050505050565b6007546001600160a01b03163314611bcd5760405162461bcd60e51b81526004016108e8906132f9565b6103e8816001600160601b031611611c2857611be9308261225d565b6040516001600160601b03821681527ff56c18f7a70485e938b87e3d7e58858e493a28163eb0efb8f9b607f50d0a91279060200160405180910390a150565b604051637901a5a760e11b815260040160405180910390fd5b50565b34662386f26fc1000014611c5757600080fd5b6000828152600860205260409020546001600160a01b03163314611c7a57600080fd5b6000918252600b602052604090912055565b60606000827f000000000000000000000000a020d57ab0448ef74115c112d18a9c231cc86000604051602001611cd59291909182526001600160a01b0316602082015260400190565b6040516020818303038152906040528051906020012060001c9050611df3611cfc84611641565b7f0000000000000000000000002a7021d9a7cd3a13b00fb01a5b5dead63705676d6001600160a01b031663cde1309c611d34876112a4565b6040516001600160e01b031960e084901b1681526004810191909152602a6024820152604401600060405180830381865afa158015611d77573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d9f919081019061357c565b6040518060600160405280602b8152602001613c46602b9139611dc18761235a565b611dcb86896123ed565b604051602001611ddf959493929190613610565b60405160208183030381529060405261244c565b604051602001611e039190613736565b604051602081830303815290604052915050919050565b6007546001600160a01b03163314611e445760405162461bcd60e51b81526004016108e8906132f9565b600780546001600160a01b0319166001600160a01b03831690811790915560405133907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a350565b6001600160a01b038116611f5a576000808052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e380544792839291611edb908490613275565b90915550611f1490506001600160a01b037f000000000000000000000000fd74138815ced52e05b0988d3aba3235545c2ff916826125b6565b604080516001600160a01b0384168152602081018390527f8fbbda19f4a70036f6f585dc4160142a8fa2a20ffb9393d23274f78de4e39888910160405180910390a15050565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc5919061377b565b6001600160a01b0383166000908152600a6020526040812080549293508392909190611ff2908490613275565b90915550611f1490506001600160a01b0383167f000000000000000000000000fd74138815ced52e05b0988d3aba3235545c2ff983612607565b6001600160a01b0382166120765760405162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b60448201526064016108e8565b80516001600160a01b03831660009081526002602052604081208054830190555b818110156121935760008382815181106120b3576120b36131f6565b6020026020010151905061020081106120df5760405163016c400b60e41b815260040160405180910390fd5b6000818152600860205260409020546001600160a01b0316156121355760405162461bcd60e51b815260206004820152600e60248201526d1053149150511657d3525395115160921b60448201526064016108e8565b60008181526008602052604080822080546001600160a01b0319166001600160a01b03891690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a450600101612097565b50505050565b606060006121ce8460408051808201825260008082526020918201528151808301909252825182529182019181019190915290565b60408051808201825260018152600b60fa1b6020808301918252835180850185526000808252908201819052845180860186528451815280830193909352845180860190955280855290840152929350919060005b868111612248576122348584612688565b9150806122408161323f565b915050612223565b50612252816126ae565b979650505050505050565b6127106001600160601b03821611156122cb5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b60648201526084016108e8565b6001600160a01b0382166123215760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c69642072656365697665720000000000000060448201526064016108e8565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600555565b6060600061236783612717565b600101905060008167ffffffffffffffff81111561238757612387612fc7565b6040519080825280601f01601f1916602001820160405280156123b1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846123bb57509392505050565b60606124006123fb846127ef565b61235a565b61240c6123fb8561282c565b6124186123fb86612893565b6124228686612901565b6040516020016124359493929190613794565b604051602081830303815290604052905092915050565b80516060906000819003612470575050604080516020810190915260008152919050565b6000600361247f836002613275565b61248991906132b5565b612494906004613288565b905060006124a3826020613275565b67ffffffffffffffff8111156124bb576124bb612fc7565b6040519080825280601f01601f1916602001820160405280156124e5576020820181803683370190505b5090506000604051806060016040528060408152602001613ae6604091399050600181016020830160005b86811015612571576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101612510565b50600386066001811461258b576002811461259c576125a8565b613d3d60f01b6001198301526125a8565b603d60f81b6000198301525b505050918152949350505050565b600080600080600085875af190508061129f5760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b60448201526064016108e8565b600060405163a9059cbb60e01b81526001600160a01b0384166004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806121935760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016108e8565b60408051808201909152600080825260208201526126a7838383612939565b5092915050565b60606000826000015167ffffffffffffffff8111156126cf576126cf612fc7565b6040519080825280601f01601f1916602001820160405280156126f9576020820181803683370190505b50905060006020820190506126a781856020015186600001516129e4565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106127565772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310612782576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106127a057662386f26fc10000830492506010015b6305f5e10083106127b8576305f5e100830492506008015b61271083106127cc57612710830492506004015b606483106127de576064830492506002015b600a83106107d25760010192915050565b6000806102008180612802836001613275565b61280c91906132c9565b90508261281982876134c9565b6128239190613275565b95945050505050565b6000806102008161283c856127ef565b60408051602080820189905281830187905260608083018790528351808403909101815260809092019092528051910120909150600061287b826127ef565b905060026128898285613275565b61225291906132b5565b6000806102008160026128a68383613275565b6128b091906132b5565b905060006128bd8661282c565b90508181106128e1576128d082826132c9565b6128da90846132c9565b94506128f8565b6128eb81836132c9565b6128f59085613275565b94505b50505050919050565b606061290f6123fb84612a55565b61291b6123fb85612abf565b6129276123fb85612b54565b6040516020016124359392919061389c565b6040805180820190915260008082526020820152600061296b8560000151866020015186600001518760200151612bcb565b60208087018051918601919091525190915061298790826132c9565b83528451602086015161299a9190613275565b81036129a957600085526129db565b835183516129b79190613275565b855186906129c69083906132c9565b90525083516129d59082613275565b60208601525b50909392505050565b60208110612a1c57815183526129fb602084613275565b9250612a08602083613275565b9150612a156020826132c9565b90506129e4565b60006001612a2b8360206132c9565b612a3790610100613a79565b612a4191906132c9565b925184518416931916929092179092525050565b600080610200612a64846127ef565b9250612a716002846134c9565b600103612ab857604080516020810186905290810183905260608101829052612ab5906080016040516020818303038152906040528051906020012060001c6127ef565b92505b5050919050565b600080612acd6004846134c9565b90506000612ada846127ef565b612ae490856132b5565b604051602001612af691815260200190565b6040516020818303038152906040528051906020012060001c905081600003612b2957612b2281612893565b9250612b4b565b81600103612b3a57612b22816127ef565b81600203612b4b57612b228161282c565b612ab581612a55565b600081600003612b6657506000919050565b60025b612b746002846132b5565b8111612bc257600081612b8781866132b5565b612b919190613288565b612b9b90856132c9565b905080600003612baf575060019392505050565b5080612bba8161323f565b915050612b69565b50600292915050565b60008381868511612cd05760208511612c7f5760006001612bed8760206132c9565b612bf8906008613288565b612c03906002613a79565b612c0d91906132c9565b8551901991508116600087612c228b8b613275565b612c2c91906132c9565b855190915083165b828114612c7157818610612c5957612c4c8b8b613275565b9650505050505050612cdf565b85612c638161323f565b965050838651169050612c34565b859650505050505050612cdf565b508383206000905b612c9186896132c9565b8211612cce57858320808203612cad5783945050505050612cdf565b612cb8600185613275565b9350508180612cc69061323f565b925050612c87565b505b612cda8787613275565b925050505b949350505050565b6001600160e01b031981168114611c4157600080fd5b600060208284031215612d0f57600080fd5b81356111a581612ce7565b60005b83811015612d35578181015183820152602001612d1d565b50506000910152565b6020815260008251806020840152612d5d816040850160208701612d1a565b601f01601f19169190910160400192915050565b600060208284031215612d8357600080fd5b5035919050565b6001600160a01b0381168114611c4157600080fd5b803561130e81612d8a565b60008060408385031215612dbd57600080fd5b8235612dc881612d8a565b946020939093013593505050565b60008083601f840112612de857600080fd5b50813567ffffffffffffffff811115612e0057600080fd5b6020830191508360208260051b8501011115610e8357600080fd5b60008060208385031215612e2e57600080fd5b823567ffffffffffffffff811115612e4557600080fd5b612e5185828601612dd6565b90969095509350505050565b600080600060608486031215612e7257600080fd5b8335612e7d81612d8a565b92506020840135612e8d81612d8a565b929592945050506040919091013590565b60008060408385031215612eb157600080fd5b50508035926020909101359150565b600080600060408486031215612ed557600080fd5b8335612ee081612d8a565b9250602084013567ffffffffffffffff811115612efc57600080fd5b612f0886828701612dd6565b9497909650939450505050565b600060208284031215612f2757600080fd5b81356111a581612d8a565b600081518084526020808501945080840160005b83811015612f6257815187529582019590820190600101612f46565b509495945050505050565b6020815260006111a56020830184612f32565b8015158114611c4157600080fd5b60008060408385031215612fa157600080fd5b8235612fac81612d8a565b91506020830135612fbc81612f80565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561300657613006612fc7565b604052919050565b6000806040838503121561302157600080fd5b823567ffffffffffffffff8082111561303957600080fd5b818501915085601f83011261304d57600080fd5b813560208282111561306157613061612fc7565b8160051b9250613072818401612fdd565b828152928401810192818101908985111561308c57600080fd5b948201945b848610156130aa57853582529482019490820190613091565b96506130b99050878201612d9f565b9450505050509250929050565b6000806000806000608086880312156130de57600080fd5b85356130e981612d8a565b945060208601356130f981612d8a565b935060408601359250606086013567ffffffffffffffff8082111561311d57600080fd5b818801915088601f83011261313157600080fd5b81358181111561314057600080fd5b89602082850101111561315257600080fd5b9699959850939650602001949392505050565b60006020828403121561317757600080fd5b81356001600160601b03811681146111a557600080fd5b600080604083850312156131a157600080fd5b82356131ac81612d8a565b91506020830135612fbc81612d8a565b600181811c908216806131d057607f821691505b6020821081036131f057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561321e57600080fd5b81516111a581612d8a565b634e487b7160e01b600052601160045260246000fd5b60006001820161325157613251613229565b5060010190565b60006020828403121561326a57600080fd5b81516111a581612f80565b808201808211156107d2576107d2613229565b80820281158282048414176107d2576107d2613229565b634e487b7160e01b600052601260045260246000fd5b6000826132c4576132c461329f565b500490565b818103818111156107d2576107d2613229565b6000602082840312156132ee57600080fd5b81516111a581612ce7565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b6003811061333d57634e487b7160e01b600052602160045260246000fd5b9052565b6020815261335b6020820183516001600160a01b03169052565b6000602083015161337760408401826001600160a01b03169052565b5060408301516001600160a01b03811660608401525060608301516001600160a01b03811660808401525060808301516133b460a084018261331f565b5060a08301516001600160801b03811660c08401525060c08301516001600160601b03811660e08401525060e08301516101006133fb818501836001600160801b03169052565b8401519050610120613417848201836001600160a01b03169052565b808501519150506101606101408181860152613437610180860184612f32565b9501519301929092525090919050565b6001600160a01b038a811682528981166020830152888116604083015260009061012090613478606085018b61331f565b6001600160801b0389811660808601526001600160601b03891660a0860152871660c0850152851660e084015261010083018190526134b981840185612f32565b9c9b505050505050505050505050565b6000826134d8576134d861329f565b500690565b600081516134ef818560208601612d1a565b9290920192915050565b6000835161350b818460208801612d1a565b83519083019061351f818360208801612d1a565b01949350505050565b6001600160a01b038681168252851660208201526040810184905260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b60006020828403121561358e57600080fd5b815167ffffffffffffffff808211156135a657600080fd5b818401915084601f8301126135ba57600080fd5b8151818111156135cc576135cc612fc7565b6135df601f8201601f1916602001612fdd565b91508082528560208285010111156135f657600080fd5b613607816020840160208601612d1a565b50949350505050565b683d913730b6b2911d1160b91b81528551600090613635816009850160208b01612d1a565b71111610113232b9b1b934b83a34b7b7111d1160711b600991840191820152865161366781601b840160208b01612d1a565b6c1116101134b6b0b3b2911d101160991b601b92909101918201526461723a2f2f60d81b602882015285516136a381602d840160208a01612d1a565b612f6d60f01b602d929091019182015284516136c681602f840160208901612d1a565b61372961371c61370f6137096136eb602f86880101631733b4b360e11b815260040190565b71222c202261747472696275746573223a205b60701b815260120190565b886134dd565b605d60f81b815260010190565b607d60f81b815260010190565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161376e81601d850160208701612d1a565b91909101601d0192915050565b60006020828403121561378d57600080fd5b5051919050565b607b60f81b81527f2274726169745f74797065223a20225452414954204f4e45222c2276616c7565600182015263111d101160e11b602182015284516000906137e4816025850160208a01612d1a565b63227d2c7b60e01b60259184019182018190527f2274726169745f74797065223a202237523431375f32222c2276616c7565223a602983015261101160f11b6049830152865161383b81604b850160208b01612d1a565b604b9201918201527f2274726169745f74797065223a2022747261697433222c2276616c7565223a20604f820152601160f91b606f82015261225261389661388660708401886134dd565b63227d2c7b60e01b815260040190565b856134dd565b7f2274726169745f74797065223a2022347469617274222c2276616c7565223a208152601160f91b6020820152600084516138de816021850160208901612d1a565b63227d2c7b60e01b60219184019182018190527f2274726169745f74797065223a202256222c2276616c7565223a2022000000006025830152855161392a816041850160208a01612d1a565b60419201918201527f2274726169745f74797065223a20222d2d202e202e202e202e222c2276616c7560458201526432911d101160d91b6065820152835161397981606a840160208801612d1a565b61227d60f01b606a9290910191820152606c0195945050505050565b600181815b808511156139d05781600019048211156139b6576139b6613229565b808516156139c357918102915b93841c939080029061399a565b509250929050565b6000826139e7575060016107d2565b816139f4575060006107d2565b8160018114613a0a5760028114613a1457613a30565b60019150506107d2565b60ff841115613a2557613a25613229565b50506001821b6107d2565b5060208310610133831016604e8410600b8410161715613a53575081810a6107d2565b613a5d8383613995565b8060001904821115613a7157613a71613229565b029392505050565b60006111a583836139d856fe4374682c417a2c41702c43682c426c2c47682c476c2c4b722c4d2c4e6c2c4e792c442c58792c52682c552c426c2c437a2c456e2c467a2c482c496c2c4a2c4a682c592c59764b2c5a2c5a682c536c2c542c4f2c552c55622c4f732c45682c53684142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f616b2c616c2c65732c65742c69642c696c2c69642c6f6f2c6f722c75782c756e2c61702c656b2c65782c696e2c6f6c2c75702c2d61662c2d61772c2765742c2765642c2d696e2c2d69732c276f642c2d61742c2d6f6661672c616c2c6f6e2c616b2c6173682c612c6265722c62616c2c62756b2c636c612c6365642c636b2c6461722c6472752c6573742c656e642c666c692c66612c2d6675722c67656e2c67612c6869732c68612c696c6b2c696e2c2d696e2c6a752c6a612c2d6b692c6c6c2c6c6f2c6d6f2c2d6d752c6d612c6e6f2c722c73732c73682c73746f2c74612c7468612c756e2c76792c76612c77792c77752c792c79792c7a2c7a732c746f6e2c676f6e2c2d6d616e2c6c752c6765742c6861722c757a2c656b2c65632c2d73587844675a73364c5257446d7a51496652304c737369633861346b3365516279616f7374744f626a374563a2646970667358221220db7b652469e7381a76650f39bb9f22d88ca4a0c58450bfabbdd8fd05caa6eb9b64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000427743df720801825a5c82e0582b1e915e0f750000000000000000000000000a020d57ab0448ef74115c112d18a9c231cc860000000000000000000000000002a7021d9a7cd3a13b00fb01a5b5dead63705676d0000000000000000000000001fd5876d4a3860eb0159055a3b7cb79fdfff6b670000000000000000000000003aada3e213abf8529606924d8d1c55cbdc70bf74000000000000000000000000e5d78fec1a7f42d2f3620238c498f088a866fdc5
-----Decoded View---------------
Arg [0] : _mons (address): 0x0427743DF720801825a5c82e0582B1E915E0F750
Arg [1] : _factory (address): 0xA020d57aB0448Ef74115c112D18a9C231CC86000
Arg [2] : _markov (address): 0x2a7021D9a7CD3a13b00fB01A5B5dEad63705676D
Arg [3] : _gda (address): 0x1fD5876d4A3860Eb0159055a3b7Cb79fdFFf6B67
Arg [4] : _xmon (address): 0x3aaDA3e213aBf8529606924d8D1c55CbDc70Bf74
Arg [5] : _linear (address): 0xe5d78fec1a7f42d2F3620238C498F088A866FdC5
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000000427743df720801825a5c82e0582b1e915e0f750
Arg [1] : 000000000000000000000000a020d57ab0448ef74115c112d18a9c231cc86000
Arg [2] : 0000000000000000000000002a7021d9a7cd3a13b00fb01a5b5dead63705676d
Arg [3] : 0000000000000000000000001fd5876d4a3860eb0159055a3b7cb79fdfff6b67
Arg [4] : 0000000000000000000000003aada3e213abf8529606924d8d1c55cbdc70bf74
Arg [5] : 000000000000000000000000e5d78fec1a7f42d2f3620238c498f088a866fdc5
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.