Token y2kBUSD_998*RISK
Overview ERC-1155
Total Supply:
0 rY2K
Holders:
20 addresses
Transfers:
-
Contract:
[ Download CSV Export ]
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Similar Match Source Code
Note: This contract matches the deployed ByteCode of the Source Code for Contract 0x7a25ae2a97e366cd7aad8e2751cf9ef94c8386e0
Contract Name:
Vault
Compiler Version
v0.8.15+commit.e14f2714
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.15; import {SemiFungibleVault} from "./SemiFungibleVault.sol"; import {ERC20} from "@solmate/tokens/ERC20.sol"; import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol"; import {IWETH} from "./interfaces/IWETH.sol"; import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol"; /// @author MiguelBits contract Vault is SemiFungibleVault, ReentrancyGuard { using FixedPointMathLib for uint256; /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error AddressZero(); error AddressNotFactory(address _contract); error AddressNotController(address _contract); error MarketEpochDoesNotExist(); error EpochAlreadyStarted(); error EpochNotFinished(); error FeeMoreThan150(uint256 _fee); error ZeroValue(); error OwnerDidNotAuthorize(address _sender, address _owner); error EpochEndMustBeAfterBegin(); error MarketEpochExists(); error FeeCannotBe0(); /*/////////////////////////////////////////////////////////////// IMMUTABLES AND STORAGE //////////////////////////////////////////////////////////////*/ address public immutable tokenInsured; address public treasury; int256 public immutable strikePrice; address public immutable factory; address public controller; uint256[] public epochs; /*////////////////////////////////////////////////////////////// MAPPINGS //////////////////////////////////////////////////////////////*/ mapping(uint256 => uint256) public idFinalTVL; mapping(uint256 => uint256) public idClaimTVL; // @audit uint32 for timestamp is enough for the next 80 years mapping(uint256 => uint256) public idEpochBegin; // @audit id can be uint32 mapping(uint256 => bool) public idEpochEnded; // @audit id can be uint32 mapping(uint256 => bool) public idExists; mapping(uint256 => uint256) public epochFee; mapping(uint256 => bool) public epochNull; /*////////////////////////////////////////////////////////////// MODIFIERS //////////////////////////////////////////////////////////////*/ /** @notice Only factory addresses can call functions that use this modifier */ modifier onlyFactory() { if(msg.sender != factory) revert AddressNotFactory(msg.sender); _; } /** @notice Only controller addresses can call functions that use this modifier */ modifier onlyController() { if(msg.sender != controller) revert AddressNotController(msg.sender); _; } /** @notice Only market addresses can call functions that use this modifier */ modifier marketExists(uint256 id) { if(idExists[id] != true) revert MarketEpochDoesNotExist(); _; } /** @notice You can only call functions that use this modifier before the current epoch has started */ modifier epochHasNotStarted(uint256 id) { if(block.timestamp > idEpochBegin[id]) revert EpochAlreadyStarted(); _; } /** @notice You can only call functions that use this modifier after the current epoch has started */ modifier epochHasEnded(uint256 id) { if(idEpochEnded[id] == false) revert EpochNotFinished(); _; } /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /** @notice constructor @param _assetAddress token address representing your asset to be deposited; @param _name token name for the ERC1155 mints. Insert the name of your token; Example: Y2K_USDC_1.2$ @param _symbol token symbol for the ERC1155 mints. insert here if risk or hedge + Symbol. Example: HedgeY2K or riskY2K; @param _token address of the oracle to lookup the price in chainlink oracles; @param _strikePrice uint256 representing the price to trigger the depeg event; @param _controller address of the controller contract, this contract can trigger the depeg events; */ constructor( address _assetAddress, string memory _name, string memory _symbol, address _treasury, address _token, int256 _strikePrice, address _controller ) SemiFungibleVault(ERC20(_assetAddress), _name, _symbol) { if(_treasury == address(0)) revert AddressZero(); if(_controller == address(0)) revert AddressZero(); if(_token == address(0)) revert AddressZero(); tokenInsured = _token; treasury = _treasury; strikePrice = _strikePrice; factory = msg.sender; controller = _controller; } /*/////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LOGIC //////////////////////////////////////////////////////////////*/ /** @notice Deposit function from ERC4626, with payment of a fee to a treasury implemented; @param id uint256 in UNIX timestamp, representing the end date of the epoch. Example: Epoch ends in 30th June 2022 at 00h 00min 00sec: 1654038000; @param assets uint256 representing how many assets the user wants to deposit, a fee will be taken from this value; @param receiver address of the receiver of the assets provided by this function, that represent the ownership of the deposited asset; */ function deposit( uint256 id, uint256 assets, address receiver ) public override marketExists(id) epochHasNotStarted(id) nonReentrant { if(receiver == address(0)) revert AddressZero(); assert(asset.transferFrom(msg.sender, address(this), assets)); _mint(receiver, id, assets, EMPTY); emit Deposit(msg.sender, receiver, id, assets); } /** @notice Deposit ETH function @param id uint256 in UNIX timestamp, representing the end date of the epoch. Example: Epoch ends in 30th June 2022 at 00h 00min 00sec: 1654038000; @param receiver address of the receiver of the shares provided by this function, that represent the ownership of the deposited asset; */ function depositETH(uint256 id, address receiver) external payable marketExists(id) epochHasNotStarted(id) nonReentrant { require(msg.value > 0, "ZeroValue"); if(receiver == address(0)) revert AddressZero(); IWETH(address(asset)).deposit{value: msg.value}(); _mint(receiver, id, msg.value, EMPTY); emit Deposit(msg.sender, receiver, id, msg.value); } /** @notice Withdraw entitled deposited assets, checking if a depeg event @param id uint256 in UNIX timestamp, representing the end date of the epoch. Example: Epoch ends in 30th June 2022 at 00h 00min 00sec: 1654038000; @param assets uint256 of how many assets you want to withdraw, this value will be used to calculate how many assets you are entitle to according to the events; @param receiver Address of the receiver of the assets provided by this function, that represent the ownership of the transfered asset; @param owner Address of the owner of these said assets; @return shares How many shares the owner is entitled to, according to the conditions; */ function withdraw( uint256 id, uint256 assets, address receiver, address owner ) external override epochHasEnded(id) marketExists(id) returns (uint256 shares) { if(receiver == address(0)) revert AddressZero(); if( msg.sender != owner && isApprovedForAll(owner, msg.sender) == false) revert OwnerDidNotAuthorize(msg.sender, owner); uint256 entitledShares; _burn(owner, id, assets); if(epochNull[id] == false) { entitledShares = previewWithdraw(id, assets); //Taking fee from the premium if(entitledShares > assets) { uint256 premium = entitledShares - assets; uint256 feeValue = calculateWithdrawalFeeValue(premium, id); entitledShares = entitledShares - feeValue; assert(asset.transfer(treasury, feeValue)); } } else{ entitledShares = assets; } if (entitledShares > 0) { assert(asset.transfer(receiver, entitledShares)); } emit Withdraw(msg.sender, receiver, owner, id, assets, entitledShares); return entitledShares; } /*/////////////////////////////////////////////////////////////// ACCOUNTING LOGIC //////////////////////////////////////////////////////////////*/ /** @notice returns total assets for the id of given epoch @param _id uint256 in UNIX timestamp, representing the end date of the epoch. Example: Epoch ends in 30th June 2022 at 00h 00min 00sec: 1654038000; */ function totalAssets(uint256 _id) public view override marketExists(_id) returns (uint256) { return totalSupply(_id); } /** @notice Calculates how much ether the %fee is taking from @param amount @param amount Amount to withdraw from vault @param _epoch Target epoch @return feeValue Current fee value */ function calculateWithdrawalFeeValue(uint256 amount, uint256 _epoch) public view returns (uint256 feeValue) { // 0.5% = multiply by 1000 then divide by 5 return amount.mulDivUp(epochFee[_epoch],1000); } /*/////////////////////////////////////////////////////////////// Factory FUNCTIONS //////////////////////////////////////////////////////////////*/ /** @notice Factory function, changes treasury address @param _treasury New treasury address */ function changeTreasury(address _treasury) public onlyFactory { if(_treasury == address(0)) revert AddressZero(); treasury = _treasury; } /** @notice Factory function, changes controller address @param _controller New controller address */ function changeController(address _controller) public onlyFactory{ if(_controller == address(0)) revert AddressZero(); controller = _controller; } /** @notice Function to deploy hedge assets for given epochs, after the creation of this vault @param epochBegin uint256 in UNIX timestamp, representing the begin date of the epoch. Example: Epoch begins in 31/May/2022 at 00h 00min 00sec: 1654038000 @param epochEnd uint256 in UNIX timestamp, representing the end date of the epoch and also the ID for the minting functions. Example: Epoch ends in 30th June 2022 at 00h 00min 00sec: 1656630000 @param _withdrawalFee uint256 of the fee value, multiply your % value by 10, Example: if you want fee of 0.5% , insert 5 */ function createAssets(uint256 epochBegin, uint256 epochEnd, uint256 _withdrawalFee) public onlyFactory { if(_withdrawalFee > 150) revert FeeMoreThan150(_withdrawalFee); if(_withdrawalFee == 0) revert FeeCannotBe0(); if(idExists[epochEnd] == true) revert MarketEpochExists(); if(epochBegin >= epochEnd) revert EpochEndMustBeAfterBegin(); idExists[epochEnd] = true; idEpochBegin[epochEnd] = epochBegin; epochs.push(epochEnd); epochFee[epochEnd] = _withdrawalFee; } /*/////////////////////////////////////////////////////////////// CONTROLLER LOGIC //////////////////////////////////////////////////////////////*/ /** @notice Controller can call this function to trigger the end of the epoch, storing the TVL of that epoch and if a depeg event occurred @param id uint256 in UNIX timestamp, representing the end date of the epoch. Example: Epoch ends in 30th June 2022 at 00h 00min 00sec: 1654038000 */ function endEpoch(uint256 id) public onlyController marketExists(id) { idEpochEnded[id] = true; idFinalTVL[id] = totalAssets(id); } /** @notice Function to be called after endEpoch, by the Controller only, this function stores the TVL of the counterparty vault in a mapping to be used for later calculations of the entitled withdraw @param id uint256 in UNIX timestamp, representing the end date of the epoch. Example: Epoch ends in 30th June 2022 at 00h 00min 00sec: 1654038000 @param claimTVL uint256 representing the TVL the counterparty vault has, storing this value in a mapping */ function setClaimTVL(uint256 id, uint256 claimTVL) public onlyController marketExists(id) { idClaimTVL[id] = claimTVL; } /** solhint-disable-next-line max-line-length @notice Function to be called after endEpoch and setClaimTVL functions, respecting the calls in order, after storing the TVL of the end of epoch and the TVL amount to claim, this function will allow the transfer of tokens to the counterparty vault @param id uint256 in UNIX timestamp, representing the end date of the epoch. Example: Epoch ends in 30th June 2022 at 00h 00min 00sec: 1654038000 @param _counterparty Address of the other vault, meaning address of the risk vault, if this is an hedge vault, and vice-versa */ function sendTokens(uint256 id, address _counterparty) public onlyController marketExists(id) { assert(asset.transfer(_counterparty, idFinalTVL[id])); } function setEpochNull(uint256 id) public onlyController marketExists(id) { epochNull[id] = true; } /*/////////////////////////////////////////////////////////////// INTERNAL HOOKS LOGIC //////////////////////////////////////////////////////////////*/ /** @notice Shows assets conversion output from withdrawing assets @param id uint256 token id of token @param assets Total number of assets */ function previewWithdraw(uint256 id, uint256 assets) public view override returns (uint256 entitledAmount) { // in case the risk wins aka no depeg event // risk users can withdraw the hedge (that is paid by the hedge buyers) and risk; withdraw = (risk + hedge) // hedge pay for each hedge seller = ( risk / tvl before the hedge payouts ) * tvl in hedge pool // in case there is a depeg event, the risk users can only withdraw the hedge entitledAmount = assets.mulDivUp(idClaimTVL[id],idFinalTVL[id]); // in case the hedge wins aka depegging // hedge users pay the hedge to risk users anyway, // hedge guy can withdraw risk (that is transfered from the risk pool), // withdraw = % tvl that hedge buyer owns // otherwise hedge users cannot withdraw any Eth } /** @notice Lookup total epochs length */ function epochsLength() public view returns (uint256) { return epochs.length; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.15; import {ERC20} from "@solmate/tokens/ERC20.sol"; import {SafeTransferLib} from "@solmate/utils/SafeTransferLib.sol"; import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol"; import { ERC1155Supply } from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; /// @author MiguelBits /// @author SlumDog abstract contract SemiFungibleVault is ERC1155Supply { using SafeTransferLib for ERC20; using FixedPointMathLib for uint256; /*/////////////////////////////////////////////////////////////// IMMUTABLES AND STORAGE //////////////////////////////////////////////////////////////*/ ERC20 public immutable asset; string public name; string public symbol; bytes internal constant EMPTY = ""; /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ /** @notice Deposit into vault when event is emitted * @param caller Address of deposit caller * @param owner receiver who will own of the tokens representing this deposit * @param id Vault id * @param assets Amount of owner assets to deposit into vault */ event Deposit( address caller, address indexed owner, uint256 indexed id, uint256 assets ); /** @notice Withdraw from vault when event is emitted * @param caller Address of withdraw caller * @param receiver Address of receiver of assets * @param owner Owner of shares * @param id Vault id * @param assets Amount of owner assets to withdraw from vault * @param shares Amount of owner shares to burn */ event Withdraw( address caller, address receiver, address indexed owner, uint256 indexed id, uint256 assets, uint256 shares ); /** @notice Contract constructor * @param _asset ERC20 token * @param _name Token name * @param _symbol Token symbol */ constructor( ERC20 _asset, string memory _name, string memory _symbol ) ERC1155("") { asset = _asset; name = _name; symbol = _symbol; } /*/////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LOGIC //////////////////////////////////////////////////////////////*/ /** @notice Triggers deposit into vault and mints shares for receiver * @param id Vault id * @param assets Amount of tokens to deposit * @param receiver Receiver of shares */ function deposit( uint256 id, uint256 assets, address receiver ) public virtual { // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, id, assets, EMPTY); emit Deposit(msg.sender, receiver, id, assets); } /** @notice Triggers withdraw from vault and burns receivers' shares * @param id Vault id * @param assets Amount of tokens to withdraw * @param receiver Receiver of assets * @param owner Owner of shares * @return shares Amount of shares burned */ function withdraw( uint256 id, uint256 assets, address receiver, address owner ) external virtual returns (uint256 shares) { require( msg.sender == owner || isApprovedForAll(owner, msg.sender), "Only owner can withdraw, or owner has approved receiver for all" ); shares = previewWithdraw(id, assets); _burn(owner, id, shares); emit Withdraw(msg.sender, receiver, owner, id, assets, shares); asset.safeTransfer(receiver, assets); } /*/////////////////////////////////////////////////////////////// ACCOUNTING LOGIC //////////////////////////////////////////////////////////////*/ /**@notice Returns total assets for token * @param _id uint256 token id of token */ function totalAssets(uint256 _id) public view virtual returns (uint256){ return totalSupply(_id); } /** @notice Shows assets conversion output from withdrawing assets @param id uint256 token id of token @param assets Total number of assets */ function previewWithdraw(uint256 id, uint256 assets) public view virtual returns (uint256) { } }
// 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/Rari-Capital/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; /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol) /// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol) library FixedPointMathLib { /*////////////////////////////////////////////////////////////// SIMPLIFIED FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s. function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down. } function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up. } function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down. } function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up. } /*////////////////////////////////////////////////////////////// LOW LEVEL FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ function mulDivDown( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // Divide z by the denominator. z := div(z, denominator) } } function mulDivUp( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // First, divide z - 1 by the denominator and add 1. // We allow z - 1 to underflow if z is 0, because we multiply the // end result by 0 if z is zero, ensuring we return 0 if z is zero. z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1)) } } function rpow( uint256 x, uint256 n, uint256 scalar ) internal pure returns (uint256 z) { assembly { switch x case 0 { switch n case 0 { // 0 ** 0 = 1 z := scalar } default { // 0 ** n = 0 z := 0 } } default { switch mod(n, 2) case 0 { // If n is even, store scalar in z for now. z := scalar } default { // If n is odd, store x in z for now. z := x } // Shifting right by 1 is like dividing by 2. let half := shr(1, scalar) for { // Shift n right by 1 before looping to halve it. n := shr(1, n) } n { // Shift n right by 1 each iteration to halve it. n := shr(1, n) } { // Revert immediately if x ** 2 would overflow. // Equivalent to iszero(eq(div(xx, x), x)) here. if shr(128, x) { revert(0, 0) } // Store x squared. let xx := mul(x, x) // Round to the nearest number. let xxRound := add(xx, half) // Revert if xx + half overflowed. if lt(xxRound, xx) { revert(0, 0) } // Set x to scaled xxRound. x := div(xxRound, scalar) // If n is even: if mod(n, 2) { // Compute z * x. let zx := mul(z, x) // If z * x overflowed: if iszero(eq(div(zx, x), z)) { // Revert if x is non-zero. if iszero(iszero(x)) { revert(0, 0) } } // Round to the nearest number. let zxRound := add(zx, half) // Revert if zx + half overflowed. if lt(zxRound, zx) { revert(0, 0) } // Return properly scaled zxRound. z := div(zxRound, scalar) } } } } } /*////////////////////////////////////////////////////////////// GENERAL NUMBER UTILITIES //////////////////////////////////////////////////////////////*/ function sqrt(uint256 x) internal pure returns (uint256 z) { assembly { // Start off with z at 1. z := 1 // Used below to help find a nearby power of 2. let y := x // Find the lowest power of 2 that is at least sqrt(x). if iszero(lt(y, 0x100000000000000000000000000000000)) { y := shr(128, y) // Like dividing by 2 ** 128. z := shl(64, z) // Like multiplying by 2 ** 64. } if iszero(lt(y, 0x10000000000000000)) { y := shr(64, y) // Like dividing by 2 ** 64. z := shl(32, z) // Like multiplying by 2 ** 32. } if iszero(lt(y, 0x100000000)) { y := shr(32, y) // Like dividing by 2 ** 32. z := shl(16, z) // Like multiplying by 2 ** 16. } if iszero(lt(y, 0x10000)) { y := shr(16, y) // Like dividing by 2 ** 16. z := shl(8, z) // Like multiplying by 2 ** 8. } if iszero(lt(y, 0x100)) { y := shr(8, y) // Like dividing by 2 ** 8. z := shl(4, z) // Like multiplying by 2 ** 4. } if iszero(lt(y, 0x10)) { y := shr(4, y) // Like dividing by 2 ** 4. z := shl(2, z) // Like multiplying by 2 ** 2. } if iszero(lt(y, 0x8)) { // Equivalent to 2 ** z. z := shl(1, z) } // Shifting right by 1 is like dividing by 2. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // Compute a rounded down version of z. let zRoundDown := div(x, z) // If zRoundDown is smaller, use it. if lt(zRoundDown, z) { z := zRoundDown } } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.15; interface IWETH { function deposit() external payable; function transfer(address to, uint256 value) external returns (bool); function withdraw(uint256) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: 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/Rari-Capital/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 { event Debug(bool one, bool two, uint256 retsize); /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; 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; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol) pragma solidity ^0.8.0; import "../ERC1155.sol"; /** * @dev Extension of ERC1155 that adds tracking of total supply per id. * * Useful for scenarios where Fungible and Non-fungible tokens have to be * clearly identified. Note: While a totalSupply of 1 might mean the * corresponding is an NFT, there is no guarantees that no other token with the * same id are not going to be minted. */ abstract contract ERC1155Supply is ERC1155 { mapping(uint256 => uint256) private _totalSupply; /** * @dev Total amount of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return ERC1155Supply.totalSupply(id) > 0; } /** * @dev See {ERC1155-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); if (from == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] += amounts[i]; } } if (to == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 supply = _totalSupply[id]; require(supply >= amount, "ERC1155: burn amount exceeds totalSupply"); unchecked { _totalSupply[id] = supply - amount; } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * 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 _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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); }
{ "remappings": [ "@chainlink/=lib/chainlink/contracts/src/v0.8/", "@openzeppelin/=lib/openzeppelin-contracts/", "@solmate/=lib/solmate/src/", "chainlink/=lib/chainlink/", "ds-test/=lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "solmate/=lib/solmate/src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_assetAddress","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"int256","name":"_strikePrice","type":"int256"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"AddressNotController","type":"error"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"AddressNotFactory","type":"error"},{"inputs":[],"name":"AddressZero","type":"error"},{"inputs":[],"name":"EpochAlreadyStarted","type":"error"},{"inputs":[],"name":"EpochEndMustBeAfterBegin","type":"error"},{"inputs":[],"name":"EpochNotFinished","type":"error"},{"inputs":[],"name":"FeeCannotBe0","type":"error"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"FeeMoreThan150","type":"error"},{"inputs":[],"name":"MarketEpochDoesNotExist","type":"error"},{"inputs":[],"name":"MarketEpochExists","type":"error"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"OwnerDidNotAuthorize","type":"error"},{"inputs":[],"name":"ZeroValue","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"asset","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"_epoch","type":"uint256"}],"name":"calculateWithdrawalFeeValue","outputs":[{"internalType":"uint256","name":"feeValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"changeController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"changeTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epochBegin","type":"uint256"},{"internalType":"uint256","name":"epochEnd","type":"uint256"},{"internalType":"uint256","name":"_withdrawalFee","type":"uint256"}],"name":"createAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"endEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochNull","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"idClaimTVL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"idEpochBegin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"idEpochEnded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"idExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"idFinalTVL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"entitledAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"_counterparty","type":"address"}],"name":"sendTokens","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":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"claimTVL","type":"uint256"}],"name":"setClaimTVL","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"setEpochNull","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"strikePrice","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenInsured","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6101006040523480156200001257600080fd5b50604051620032a1380380620032a1833981016040819052620000359162000248565b8686866040518060200160405280600081525062000059816200014c60201b60201c565b506001600160a01b038316608052600462000075838262000396565b50600562000084828262000396565b5050600160065550506001600160a01b038416620000b557604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b038116620000dd57604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0383166200010557604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0392831660a052600780546001600160a01b031990811695851695909517905560c0919091523360e0526008805490931691161790555062000462915050565b60026200015a828262000396565b5050565b80516001600160a01b03811681146200017657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001a357600080fd5b81516001600160401b0380821115620001c057620001c06200017b565b604051601f8301601f19908116603f01168101908282118183101715620001eb57620001eb6200017b565b816040528381526020925086838588010111156200020857600080fd5b600091505b838210156200022c57858201830151818301840152908201906200020d565b838211156200023e5760008385830101525b9695505050505050565b600080600080600080600060e0888a0312156200026457600080fd5b6200026f886200015e565b60208901519097506001600160401b03808211156200028d57600080fd5b6200029b8b838c0162000191565b975060408a0151915080821115620002b257600080fd5b50620002c18a828b0162000191565b955050620002d2606089016200015e565b9350620002e2608089016200015e565b925060a08801519150620002f960c089016200015e565b905092959891949750929550565b600181811c908216806200031c57607f821691505b6020821081036200033d57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039157600081815260208120601f850160051c810160208610156200036c5750805b601f850160051c820191505b818110156200038d5782815560010162000378565b5050505b505050565b81516001600160401b03811115620003b257620003b26200017b565b620003ca81620003c3845462000307565b8462000343565b602080601f831160018114620004025760008415620003e95750858301515b600019600386901b1c1916600185901b1785556200038d565b600085815260208120601f198616915b82811015620004335788860151825594840194600190910190840162000412565b5085821015620004525787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e051612dcd620004d4600039600081816106f301528181610c2701528181611434015261187a01526000610727015260006102b401526000818161041401528181610b0501528181610f9c0152818161129f0152818161134f015261167b0152612dcd6000f3fe60806040526004361061023a5760003560e01c806371b3177a1161012e578063bd85b039116100ab578063e985e9c51161006f578063e985e9c51461077e578063ea859a27146107c7578063f242432a146107f4578063f77c479114610814578063f9db24271461083457600080fd5b8063bd85b039146106b4578063c45a0155146106e1578063c52987cf14610715578063c6b61e4c14610749578063d662b92d1461076957600080fd5b8063a22cb465116100f2578063a22cb46514610607578063a5054b5b14610627578063ad5be0c414610647578063aff223b914610667578063b14f2a391461069457600080fd5b806371b3177a1461057257806374715614146105925780638dbdbe6d146105b257806394605857146105d257806395d89b41146105f257600080fd5b806338d52e0f116101bc5780634e1273f4116101805780634e1273f4146104c35780634f558e79146104f057806356150edf1461051f5780636164e45d1461053257806361d027b31461055257600080fd5b806338d52e0f146104025780633cebb823146104365780633e04836514610456578063488bd7b0146104765780634d288ba71461049657600080fd5b80630b8a295a116102035780630b8a295a146103405780630e89341c14610370578063243219d11461039057806329322e05146103c05780632eb2c2d6146103e257600080fd5b8062fdd58e1461023f57806301ffc9a71461027257806304da1a46146102a257806306fdde03146102ee5780630b6e8f8914610310575b600080fd5b34801561024b57600080fd5b5061025f61025a366004612485565b610861565b6040519081526020015b60405180910390f35b34801561027e57600080fd5b5061029261028d3660046124c8565b6108f7565b6040519015158152602001610269565b3480156102ae57600080fd5b506102d67f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610269565b3480156102fa57600080fd5b50610303610949565b6040516102699190612532565b34801561031c57600080fd5b5061029261032b366004612545565b600d6020526000908152604090205460ff1681565b34801561034c57600080fd5b5061029261035b366004612545565b600e6020526000908152604090205460ff1681565b34801561037c57600080fd5b5061030361038b366004612545565b6109d7565b34801561039c57600080fd5b506102926103ab366004612545565b60106020526000908152604090205460ff1681565b3480156103cc57600080fd5b506103e06103db36600461255e565b610a6b565b005b3480156103ee57600080fd5b506103e06103fd3660046126d6565b610b85565b34801561040e57600080fd5b506102d67f000000000000000000000000000000000000000000000000000000000000000081565b34801561044257600080fd5b506103e0610451366004612780565b610c1c565b34801561046257600080fd5b506103e061047136600461279b565b610cb0565b34801561048257600080fd5b5061025f61049136600461279b565b610d26565b3480156104a257600080fd5b5061025f6104b1366004612545565b600b6020526000908152604090205481565b3480156104cf57600080fd5b506104e36104de3660046127bd565b610d52565b60405161026991906128c3565b3480156104fc57600080fd5b5061029261050b366004612545565b600090815260036020526040902054151590565b6103e061052d36600461255e565b610e7c565b34801561053e57600080fd5b506103e061054d366004612545565b611079565b34801561055e57600080fd5b506007546102d6906001600160a01b031681565b34801561057e57600080fd5b5061025f61058d3660046128d6565b611114565b34801561059e57600080fd5b506103e06105ad36600461291c565b611429565b3480156105be57600080fd5b506103e06105cd366004612948565b611574565b3480156105de57600080fd5b5061025f6105ed366004612545565b611769565b3480156105fe57600080fd5b506103036117b7565b34801561061357600080fd5b506103e061062236600461298b565b6117c4565b34801561063357600080fd5b5061025f61064236600461279b565b6117d3565b34801561065357600080fd5b506103e0610662366004612545565b6117f0565b34801561067357600080fd5b5061025f610682366004612545565b600f6020526000908152604090205481565b3480156106a057600080fd5b506103e06106af366004612780565b61186f565b3480156106c057600080fd5b5061025f6106cf366004612545565b60009081526003602052604090205490565b3480156106ed57600080fd5b506102d67f000000000000000000000000000000000000000000000000000000000000000081565b34801561072157600080fd5b5061025f7f000000000000000000000000000000000000000000000000000000000000000081565b34801561075557600080fd5b5061025f610764366004612545565b611903565b34801561077557600080fd5b5060095461025f565b34801561078a57600080fd5b506102926107993660046129c2565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b3480156107d357600080fd5b5061025f6107e2366004612545565b600c6020526000908152604090205481565b34801561080057600080fd5b506103e061080f3660046129ec565b611924565b34801561082057600080fd5b506008546102d6906001600160a01b031681565b34801561084057600080fd5b5061025f61084f366004612545565b600a6020526000908152604090205481565b60006001600160a01b0383166108d15760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000908152602081815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b03198216636cdb3d1360e11b148061092857506001600160e01b031982166303a24d0760e21b145b8061094357506301ffc9a760e01b6001600160e01b03198316145b92915050565b6004805461095690612a51565b80601f016020809104026020016040519081016040528092919081815260200182805461098290612a51565b80156109cf5780601f106109a4576101008083540402835291602001916109cf565b820191906000526020600020905b8154815290600101906020018083116109b257829003601f168201915b505050505081565b6060600280546109e690612a51565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1290612a51565b8015610a5f5780601f10610a3457610100808354040283529160200191610a5f565b820191906000526020600020905b815481529060010190602001808311610a4257829003601f168201915b50505050509050919050565b6008546001600160a01b03163314610a9857604051632e91ff8760e21b81523360048201526024016108c8565b6000828152600e6020526040902054829060ff161515600114610ace576040516305cc46e760e31b815260040160405180910390fd5b6000838152600a60205260409081902054905163a9059cbb60e01b81526001600160a01b03848116600483015260248201929092527f00000000000000000000000000000000000000000000000000000000000000009091169063a9059cbb906044016020604051808303816000875af1158015610b50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b749190612a85565b610b8057610b80612aa2565b505050565b6001600160a01b038516331480610ba15750610ba18533610799565b610c085760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b60648201526084016108c8565b610c1585858585856119ab565b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610c675760405163017bb92160e41b81523360048201526024016108c8565b6001600160a01b038116610c8e57604051639fabe1c160e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b0392909216919091179055565b6008546001600160a01b03163314610cdd57604051632e91ff8760e21b81523360048201526024016108c8565b6000828152600e6020526040902054829060ff161515600114610d13576040516305cc46e760e31b815260040160405180910390fd5b506000918252600b602052604090912055565b6000828152600b6020908152604080832054600a909252822054610d4b918491611b96565b9392505050565b60608151835114610db75760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016108c8565b6000835167ffffffffffffffff811115610dd357610dd361258a565b604051908082528060200260200182016040528015610dfc578160200160208202803683370190505b50905060005b8451811015610e7457610e47858281518110610e2057610e20612ab8565b6020026020010151858381518110610e3a57610e3a612ab8565b6020026020010151610861565b828281518110610e5957610e59612ab8565b6020908102919091010152610e6d81612ae4565b9050610e02565b509392505050565b6000828152600e6020526040902054829060ff161515600114610eb2576040516305cc46e760e31b815260040160405180910390fd5b6000838152600c60205260409020548390421115610ee3576040516326ddce9160e01b815260040160405180910390fd5b600260065403610f355760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108c8565b600260065534610f735760405162461bcd60e51b81526020600482015260096024820152685a65726f56616c756560b81b60448201526064016108c8565b6001600160a01b038316610f9a57604051639fabe1c160e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610ff557600080fd5b505af1158015611009573d6000803e3d6000fd5b505050505061102983853460405180602001604052806000815250611bc4565b6040805133815234602082015285916001600160a01b038616917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a3505060016006555050565b6008546001600160a01b031633146110a657604051632e91ff8760e21b81523360048201526024016108c8565b6000818152600e6020526040902054819060ff1615156001146110dc576040516305cc46e760e31b815260040160405180910390fd5b6000828152600d60205260409020805460ff191660011790556110fe82611769565b6000928352600a60205260409092209190915550565b6000848152600d6020526040812054859060ff16151582036111495760405163ec76655760e01b815260040160405180910390fd5b6000868152600e6020526040902054869060ff16151560011461117f576040516305cc46e760e31b815260040160405180910390fd5b6001600160a01b0385166111a657604051639fabe1c160e01b815260040160405180910390fd5b336001600160a01b038516148015906111e357506001600160a01b038416600090815260016020908152604080832033845290915290205460ff16155b156112125760405163425da22160e11b81523360048201526001600160a01b03851660248201526044016108c8565b600061121f858989611ce7565b60008881526010602052604081205460ff1615159003611320576112438888610d26565b90508681111561131b5760006112598883612afd565b90506000611267828b6117d3565b90506112738184612afd565b60075460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018490529194507f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af11580156112e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130c9190612a85565b61131857611318612aa2565b50505b611323565b50855b80156113c85760405163a9059cbb60e01b81526001600160a01b038781166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015611398573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bc9190612a85565b6113c8576113c8612aa2565b604080513381526001600160a01b0388811660208301529181018990526060810183905289918716907fbbbdee62287b5bf3bee13cab60a29ad729cf38109bccbd2a986a11c99b8ca7049060800160405180910390a3979650505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146114745760405163017bb92160e41b81523360048201526024016108c8565b609681111561149957604051631206ee7f60e01b8152600481018290526024016108c8565b806000036114ba57604051636883b21160e01b815260040160405180910390fd5b6000828152600e602052604090205460ff1615156001036114ee57604051631870d25960e31b815260040160405180910390fd5b81831061150e57604051631d02ec5360e11b815260040160405180910390fd5b6000828152600e60209081526040808320805460ff19166001908117909155600c8352818420969096556009805496870190557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af90950193909355600f90925291902055565b6000838152600e6020526040902054839060ff1615156001146115aa576040516305cc46e760e31b815260040160405180910390fd5b6000848152600c602052604090205484904211156115db576040516326ddce9160e01b815260040160405180910390fd5b60026006540361162d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108c8565b60026006556001600160a01b03831661165957604051639fabe1c160e01b815260040160405180910390fd5b6040516323b872dd60e01b8152336004820152306024820152604481018590527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906323b872dd906064016020604051808303816000875af11580156116cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f09190612a85565b6116fc576116fc612aa2565b61171783868660405180602001604052806000815250611bc4565b604080513381526020810186905286916001600160a01b038616917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a350506001600655505050565b6000818152600e6020526040812054829060ff16151560011461179f576040516305cc46e760e31b815260040160405180910390fd5b60008381526003602052604090205491505b50919050565b6005805461095690612a51565b6117cf338383611e77565b5050565b6000818152600f6020526040812054610d4b9084906103e8611b96565b6008546001600160a01b0316331461181d57604051632e91ff8760e21b81523360048201526024016108c8565b6000818152600e6020526040902054819060ff161515600114611853576040516305cc46e760e31b815260040160405180910390fd5b506000908152601060205260409020805460ff19166001179055565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146118ba5760405163017bb92160e41b81523360048201526024016108c8565b6001600160a01b0381166118e157604051639fabe1c160e01b815260040160405180910390fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6009818154811061191357600080fd5b600091825260209091200154905081565b6001600160a01b03851633148061194057506119408533610799565b61199e5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201526808185c1c1c9bdd995960ba1b60648201526084016108c8565b610c158585858585611f57565b8151835114611a0d5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b60648201526084016108c8565b6001600160a01b038416611a335760405162461bcd60e51b81526004016108c890612b14565b33611a4281878787878761208f565b60005b8451811015611b28576000858281518110611a6257611a62612ab8565b602002602001015190506000858381518110611a8057611a80612ab8565b602090810291909101810151600084815280835260408082206001600160a01b038e168352909352919091205490915081811015611ad05760405162461bcd60e51b81526004016108c890612b59565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290611b0d908490612ba3565b9250508190555050505080611b2190612ae4565b9050611a45565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611b78929190612bbb565b60405180910390a4611b8e818787878787612208565b505050505050565b828202811515841585830485141716611bae57600080fd5b6001826001830304018115150290509392505050565b6001600160a01b038416611c245760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016108c8565b336000611c3085612363565b90506000611c3d85612363565b9050611c4e8360008985858961208f565b6000868152602081815260408083206001600160a01b038b16845290915281208054879290611c7e908490612ba3565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611cde836000898989896123ae565b50505050505050565b6001600160a01b038316611d495760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b60648201526084016108c8565b336000611d5584612363565b90506000611d6284612363565b9050611d828387600085856040518060200160405280600081525061208f565b6000858152602081815260408083206001600160a01b038a16845290915290205484811015611dff5760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b60648201526084016108c8565b6000868152602081815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4604080516020810190915260009052611cde565b816001600160a01b0316836001600160a01b031603611eea5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016108c8565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b038416611f7d5760405162461bcd60e51b81526004016108c890612b14565b336000611f8985612363565b90506000611f9685612363565b9050611fa683898985858961208f565b6000868152602081815260408083206001600160a01b038c16845290915290205485811015611fe75760405162461bcd60e51b81526004016108c890612b59565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a16825281208054889290612024908490612ba3565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4612084848a8a8a8a8a6123ae565b505050505050505050565b6001600160a01b0385166121165760005b8351811015612114578281815181106120bb576120bb612ab8565b6020026020010151600360008684815181106120d9576120d9612ab8565b6020026020010151815260200190815260200160002060008282546120fe9190612ba3565b9091555061210d905081612ae4565b90506120a0565b505b6001600160a01b038416611b8e5760005b8351811015611cde57600084828151811061214457612144612ab8565b60200260200101519050600084838151811061216257612162612ab8565b60200260200101519050600060036000848152602001908152602001600020549050818110156121e55760405162461bcd60e51b815260206004820152602860248201527f455243313135353a206275726e20616d6f756e74206578636565647320746f74604482015267616c537570706c7960c01b60648201526084016108c8565b6000928352600360205260409092209103905561220181612ae4565b9050612127565b6001600160a01b0384163b15611b8e5760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061224c9089908990889088908890600401612be9565b6020604051808303816000875af1925050508015612287575060408051601f3d908101601f1916820190925261228491810190612c47565b60015b61233357612293612c64565b806308c379a0036122cc57506122a7612c80565b806122b257506122ce565b8060405162461bcd60e51b81526004016108c89190612532565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016108c8565b6001600160e01b0319811663bc197c8160e01b14611cde5760405162461bcd60e51b81526004016108c890612d0a565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061239d5761239d612ab8565b602090810291909101015292915050565b6001600160a01b0384163b15611b8e5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906123f29089908990889088908890600401612d52565b6020604051808303816000875af192505050801561242d575060408051601f3d908101601f1916820190925261242a91810190612c47565b60015b61243957612293612c64565b6001600160e01b0319811663f23a6e6160e01b14611cde5760405162461bcd60e51b81526004016108c890612d0a565b80356001600160a01b038116811461248057600080fd5b919050565b6000806040838503121561249857600080fd5b6124a183612469565b946020939093013593505050565b6001600160e01b0319811681146124c557600080fd5b50565b6000602082840312156124da57600080fd5b8135610d4b816124af565b6000815180845260005b8181101561250b576020818501810151868301820152016124ef565b8181111561251d576000602083870101525b50601f01601f19169290920160200192915050565b602081526000610d4b60208301846124e5565b60006020828403121561255757600080fd5b5035919050565b6000806040838503121561257157600080fd5b8235915061258160208401612469565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff811182821017156125c6576125c661258a565b6040525050565b600067ffffffffffffffff8211156125e7576125e761258a565b5060051b60200190565b600082601f83011261260257600080fd5b8135602061260f826125cd565b60405161261c82826125a0565b83815260059390931b850182019282810191508684111561263c57600080fd5b8286015b848110156126575780358352918301918301612640565b509695505050505050565b600082601f83011261267357600080fd5b813567ffffffffffffffff81111561268d5761268d61258a565b6040516126a4601f8301601f1916602001826125a0565b8181528460208386010111156126b957600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a086880312156126ee57600080fd5b6126f786612469565b945061270560208701612469565b9350604086013567ffffffffffffffff8082111561272257600080fd5b61272e89838a016125f1565b9450606088013591508082111561274457600080fd5b61275089838a016125f1565b9350608088013591508082111561276657600080fd5b5061277388828901612662565b9150509295509295909350565b60006020828403121561279257600080fd5b610d4b82612469565b600080604083850312156127ae57600080fd5b50508035926020909101359150565b600080604083850312156127d057600080fd5b823567ffffffffffffffff808211156127e857600080fd5b818501915085601f8301126127fc57600080fd5b81356020612809826125cd565b60405161281682826125a0565b83815260059390931b850182019282810191508984111561283657600080fd5b948201945b8386101561285b5761284c86612469565b8252948201949082019061283b565b9650508601359250508082111561287157600080fd5b5061287e858286016125f1565b9150509250929050565b600081518084526020808501945080840160005b838110156128b85781518752958201959082019060010161289c565b509495945050505050565b602081526000610d4b6020830184612888565b600080600080608085870312156128ec57600080fd5b843593506020850135925061290360408601612469565b915061291160608601612469565b905092959194509250565b60008060006060848603121561293157600080fd5b505081359360208301359350604090920135919050565b60008060006060848603121561295d57600080fd5b833592506020840135915061297460408501612469565b90509250925092565b80151581146124c557600080fd5b6000806040838503121561299e57600080fd5b6129a783612469565b915060208301356129b78161297d565b809150509250929050565b600080604083850312156129d557600080fd5b6129de83612469565b915061258160208401612469565b600080600080600060a08688031215612a0457600080fd5b612a0d86612469565b9450612a1b60208701612469565b93506040860135925060608601359150608086013567ffffffffffffffff811115612a4557600080fd5b61277388828901612662565b600181811c90821680612a6557607f821691505b6020821081036117b157634e487b7160e01b600052602260045260246000fd5b600060208284031215612a9757600080fd5b8151610d4b8161297d565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201612af657612af6612ace565b5060010190565b600082821015612b0f57612b0f612ace565b500390565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60008219821115612bb657612bb6612ace565b500190565b604081526000612bce6040830185612888565b8281036020840152612be08185612888565b95945050505050565b6001600160a01b0386811682528516602082015260a060408201819052600090612c1590830186612888565b8281036060840152612c278186612888565b90508281036080840152612c3b81856124e5565b98975050505050505050565b600060208284031215612c5957600080fd5b8151610d4b816124af565b600060033d1115612c7d5760046000803e5060005160e01c5b90565b600060443d1015612c8e5790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715612cbe57505050505090565b8285019150815181811115612cd65750505050505090565b843d8701016020828501011115612cf05750505050505090565b612cff602082860101876125a0565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612d8c908301846124e5565b97965050505050505056fea26469706673582212200e6e420753209a62039f38bf60ce197e1c087a5a875a295330fba6c2a8fc0fa564736f6c634300080f003300000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000005c84cf4d91dc0acde638363ec804792bb2108258000000000000000000000000fea7a6a0b346362bf88a9e4a88416b77a57d6c2a0000000000000000000000000000000000000000000000000d8b72d434c7ffff000000000000000000000000225acf1d32f0928a96e49e6110aba1fdf777c85f000000000000000000000000000000000000000000000000000000000000001079326b4d494d5f3937352a48454447450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046859324b00000000000000000000000000000000000000000000000000000000