Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 38 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Enter Next Cycle | 20109900 | 258 days ago | IN | 0 ETH | 0.00054058 | ||||
Set Fund Locking... | 20109888 | 258 days ago | IN | 0 ETH | 0.00010576 | ||||
Enter Next Cycle | 20009818 | 272 days ago | IN | 0 ETH | 0.00179348 | ||||
Enter Next Cycle | 19559038 | 335 days ago | IN | 0 ETH | 0.00634394 | ||||
Enter Next Cycle | 19537870 | 338 days ago | IN | 0 ETH | 0.00350579 | ||||
Enter Next Cycle | 19469721 | 348 days ago | IN | 0 ETH | 0.00692731 | ||||
Enter Next Cycle | 19388612 | 359 days ago | IN | 0 ETH | 0.00672742 | ||||
Set Fund Locking... | 19388593 | 359 days ago | IN | 0 ETH | 0.00125367 | ||||
Enter Next Cycle | 18919041 | 425 days ago | IN | 0 ETH | 0.00313643 | ||||
Set Fund Locking... | 18919032 | 425 days ago | IN | 0 ETH | 0.00053431 | ||||
Enter Next Cycle | 18768481 | 446 days ago | IN | 0 ETH | 0.00464769 | ||||
Set Fund Locking... | 18768444 | 446 days ago | IN | 0 ETH | 0.00092826 | ||||
Enter Next Cycle | 18640084 | 464 days ago | IN | 0 ETH | 0.00428046 | ||||
Enter Next Cycle | 18426165 | 494 days ago | IN | 0 ETH | 0.00223568 | ||||
Enter Next Cycle | 18368226 | 502 days ago | IN | 0 ETH | 0.00088708 | ||||
Set Fund Locking... | 18368219 | 502 days ago | IN | 0 ETH | 0.00017484 | ||||
Revoke Role | 18182699 | 528 days ago | IN | 0 ETH | 0.00023787 | ||||
Grant Role | 18182697 | 528 days ago | IN | 0 ETH | 0.0004277 | ||||
Enter Next Cycle | 17969419 | 558 days ago | IN | 0 ETH | 0.00383777 | ||||
Enter Next Cycle | 17833649 | 577 days ago | IN | 0 ETH | 0.00201139 | ||||
Enter Next Cycle | 17370963 | 642 days ago | IN | 0 ETH | 0.00750451 | ||||
Enter Next Cycle | 17370952 | 642 days ago | IN | 0 ETH | 0.00664061 | ||||
Enter Next Cycle | 17170316 | 670 days ago | IN | 0 ETH | 0.01288836 | ||||
Set Fund Locking... | 17170288 | 670 days ago | IN | 0 ETH | 0.00213079 | ||||
Enter Next Cycle | 17078296 | 683 days ago | IN | 0 ETH | 0.0068976 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x634FaBad...773B836fB The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
HighTableVault
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 1 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// contracts/HighTableVault.sol // SPDX-License-Identifier: BUSL // Teahouse Finance pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "./IHighTableVault.sol"; /// @title An investment vault for working with TeaVaultV2 /// @author Teahouse Finance contract HighTableVault is IHighTableVault, AccessControl, ERC20 { using SafeERC20 for IERC20; uint256 public constant SECONDS_IN_A_YEAR = 365 * 86400; // for calculating management fee bytes32 public constant AUDITOR_ROLE = keccak256("AUDITOR_ROLE"); IERC20 internal immutable assetToken; FeeConfig public feeConfig; FundConfig public fundConfig; address[] public nftEnabled; GlobalState public globalState; mapping(uint32 => CycleState) public cycleState; mapping(address => UserState) public userState; Price public initialPrice; // initial price Price public closePrice; // price after fund is closed /// @param _name name of the vault token /// @param _symbol symbol of the vault token /// @param _asset address of the asset token /// @param _priceNumerator initial price for each vault token in asset token /// @param _priceDenominator price denominator (actual price = _initialPrice / _priceDenominator) /// @param _startTimestamp starting timestamp of the first cycle /// @param _initialAdmin address of the initial admin /// @notice To setup a HighTableVault, the procedure should be /// @notice 1. Deploy HighTableVault /// @notice 2. Set FeeConfig /// @notice 3. (optionally) Deploy TeaVaultV2 /// @notice 4. Set TeaVaultV2's investor to HighTableVault /// @notice 5. Set TeaVaultV2 address (setTeaVaultV2) /// @notice 6. Grant auditor role to an address (grantRole) /// @notice 7. Set fund locking timestamp for initial cycle (setFundLockingTimestamp) /// @notice 8. Set deposit limit for initial cycle (setDepositLimit) /// @notice 9. Set enabled NFT list, or disable NFT check (setEnabledNFTs or setDisableNFTChecks) /// @notice 10. Users will be able to request deposits /// @notice On initial price: the vault token has 18 decimals, so if the asset token is not 18 decimals, /// @notice should take extra care in setting the initial price. /// @notice For example, if using USDC (has 6 decimals), and want to have 1:1 inital price, /// @notice the initial price should be numerator = 1_000_000 and denominator = 1_000_000_000_000_000_000. constructor( string memory _name, string memory _symbol, address _asset, uint128 _priceNumerator, uint128 _priceDenominator, uint64 _startTimestamp, address _initialAdmin) ERC20(_name, _symbol) { if (_priceNumerator == 0 || _priceDenominator == 0) revert InvalidInitialPrice(); _grantRole(DEFAULT_ADMIN_ROLE, _initialAdmin); assetToken = IERC20(_asset); initialPrice = Price(_priceNumerator, _priceDenominator); globalState.cycleStartTimestamp = _startTimestamp; emit FundInitialized(msg.sender, _priceNumerator, _priceDenominator, _startTimestamp, _initialAdmin); } /// @inheritdoc IHighTableVault function setEnabledNFTs(address[] calldata _nfts) external override { if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert OnlyAvailableToAdmins(); nftEnabled = _nfts; emit NFTEnabled(msg.sender, globalState.cycleIndex, _nfts); } /// @inheritdoc IHighTableVault function setDisableNFTChecks(bool _checks) external override { if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert OnlyAvailableToAdmins(); fundConfig.disableNFTChecks = _checks; emit DisableNFTChecks(msg.sender, globalState.cycleIndex, _checks); } /// @inheritdoc IHighTableVault function setFeeConfig(FeeConfig calldata _feeConfig) external override { if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert OnlyAvailableToAdmins(); if (_feeConfig.managerEntryFee + _feeConfig.platformEntryFee + _feeConfig.managerExitFee + _feeConfig.platformExitFee > 1000000) revert InvalidFeePercentage(); if (_feeConfig.managerPerformanceFee + _feeConfig.platformPerformanceFee > 1000000) revert InvalidFeePercentage(); if (_feeConfig.managerManagementFee + _feeConfig.platformManagementFee > 1000000) revert InvalidFeePercentage(); feeConfig = _feeConfig; emit FeeConfigChanged(msg.sender, globalState.cycleIndex, _feeConfig); } /// @inheritdoc IHighTableVault function setTeaVaultV2(address _teaVaultV2) external override { if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert OnlyAvailableToAdmins(); fundConfig.teaVaultV2 = ITeaVaultV2(_teaVaultV2); emit UpdateTeaVaultV2(msg.sender, globalState.cycleIndex, _teaVaultV2); } /// @inheritdoc IHighTableVault /// @dev Does not use nonReentrant because it can only be called from auditors function enterNextCycle( uint32 _cycleIndex, uint128 _fundValue, uint128 _depositLimit, uint128 _withdrawAmount, uint64 _cycleStartTimestamp, uint64 _fundingLockTimestamp, bool _closeFund) external override returns (uint256 platformFee, uint256 managerFee) { // withdraw from vault if (_withdrawAmount > 0) { fundConfig.teaVaultV2.withdraw(address(this), address(assetToken), _withdrawAmount); } // permission checks are done in the internal function (platformFee, managerFee) = _internalEnterNextCycle(_cycleIndex, _fundValue, _depositLimit, _cycleStartTimestamp, _fundingLockTimestamp, _closeFund); // distribute fees if (platformFee > 0) { assetToken.safeTransfer(feeConfig.platformVault, platformFee); } if (managerFee > 0) { assetToken.safeTransfer(feeConfig.managerVault, managerFee); } // check if the remaining balance is enough for locked assets // and deposit extra balance back to the vault uint256 deposits = _internalCheckDeposits(); if (deposits > 0) { assetToken.safeApprove(address(fundConfig.teaVaultV2), deposits); fundConfig.teaVaultV2.deposit(address(assetToken), deposits); } } /// @inheritdoc IHighTableVault function previewNextCycle(uint128 _fundValue, uint64 _timestamp) external override view returns (uint256 withdrawAmount) { if (globalState.cycleIndex > 0) { // calculate performance and management fees (uint256 pFee, uint256 mFee) = _calculatePMFees(_fundValue, _timestamp); withdrawAmount += pFee + mFee; } uint32 cycleIndex = globalState.cycleIndex; // convert total withdrawals to assets if (cycleState[cycleIndex].requestedWithdrawals > 0) { // if requestedWithdrawals > 0, there must be some remaining shares so totalSupply() won't be zero uint256 fundValueAfterPMFee = _fundValue - withdrawAmount; withdrawAmount += uint256(cycleState[cycleIndex].requestedWithdrawals) * fundValueAfterPMFee / totalSupply(); } if (cycleState[cycleIndex].requestedDeposits > 0) { uint256 requestedDeposits = cycleState[cycleIndex].requestedDeposits; uint256 platformFee = requestedDeposits * feeConfig.platformEntryFee / 1000000; uint256 managerFee = requestedDeposits * feeConfig.managerEntryFee / 1000000; withdrawAmount += platformFee + managerFee; if (withdrawAmount > requestedDeposits) { withdrawAmount -= requestedDeposits; } else { withdrawAmount = 0; } } } /// @inheritdoc IHighTableVault function setFundLockingTimestamp(uint64 _fundLockingTimestamp) external override { if (!hasRole(AUDITOR_ROLE, msg.sender)) revert OnlyAvailableToAuditors(); globalState.fundingLockTimestamp = _fundLockingTimestamp; emit FundLockingTimestampUpdated(msg.sender, globalState.cycleIndex, _fundLockingTimestamp); } /// @inheritdoc IHighTableVault function setDepositLimit(uint128 _depositLimit) external override { if (!hasRole(AUDITOR_ROLE, msg.sender)) revert OnlyAvailableToAuditors(); globalState.depositLimit = _depositLimit; emit DepositLimitUpdated(msg.sender, globalState.cycleIndex, _depositLimit); } /// @inheritdoc IHighTableVault function setDisableFunding(bool _disableDepositing, bool _disableWithdrawing, bool _disableCancelDepositing, bool _disableCancelWithdrawing) external override { if (!hasRole(AUDITOR_ROLE, msg.sender)) revert OnlyAvailableToAuditors(); fundConfig.disableDepositing = _disableDepositing; fundConfig.disableWithdrawing = _disableWithdrawing; fundConfig.disableCancelDepositing = _disableCancelDepositing; fundConfig.disableCancelWithdrawing = _disableCancelWithdrawing; emit FundingChanged(msg.sender, globalState.cycleIndex, _disableDepositing, _disableWithdrawing, _disableCancelDepositing, _disableCancelWithdrawing); } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because there is no danger of reentrance attack /// @dev since there is no checking nor recording of amount of assets function depositToVault(uint256 _value) external override { if (!hasRole(AUDITOR_ROLE, msg.sender)) revert OnlyAvailableToAuditors(); uint256 balance = assetToken.balanceOf(address(this)); if (balance - globalState.lockedAssets < _value) revert NotEnoughAssets(); assetToken.safeApprove(address(fundConfig.teaVaultV2), _value); fundConfig.teaVaultV2.deposit(address(assetToken), _value); emit DepositToVault(msg.sender, globalState.cycleIndex, address(fundConfig.teaVaultV2), _value); } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because there is no danger of reentrance attack /// @dev since there is no checking nor recording of amount of assets function withdrawFromVault(uint256 _value) external override { if (!hasRole(AUDITOR_ROLE, msg.sender)) revert OnlyAvailableToAuditors(); fundConfig.teaVaultV2.withdraw(address(this), address(assetToken), _value); emit WithdrawFromVault(msg.sender, globalState.cycleIndex, address(fundConfig.teaVaultV2), _value); } /// @inheritdoc IHighTableVault function asset() external override view returns (address assetTokenAddress) { return address(assetToken); } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because there is no danger of reentrance attack /// @dev since recording of deposited assets happens after receiving assets /// @dev and assetToken has to be attacked in some way to perform reentrance function requestDeposit(uint256 _assets, address _receiver) public override { assetToken.safeTransferFrom(msg.sender, address(this), _assets); _internalRequestDeposit(_assets, _receiver); } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because there is no danger of reentrance attack /// @dev since recording of deposited assets happens after receiving assets /// @dev and assetToken has to be attacked in some way to perform reentrance function claimAndRequestDeposit(uint256 _assets, address _receiver) external override returns (uint256 assets) { assets = claimOwedAssets(msg.sender); requestDeposit(_assets, _receiver); } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because there is no danger of reentrance attack /// @dev since removing of deposited assets happens before receiving assets /// @dev and assetToken has to be attacked in some way to perform reentrance function cancelDeposit(uint256 _assets, address _receiver) external override { _internalCancelDeposit(_assets, _receiver); assetToken.safeTransfer(_receiver, _assets); } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because this function does not call other contracts function requestWithdraw(uint256 _shares, address _owner) public override { if (fundConfig.disableWithdrawing) revert WithdrawDisabled(); if (globalState.fundClosed) revert FundIsClosed(); if (block.timestamp > globalState.fundingLockTimestamp) revert FundingLocked(); if (_owner != msg.sender) { _spendAllowance(_owner, msg.sender, _shares); } _transfer(_owner, address(this), _shares); uint32 cycleIndex = globalState.cycleIndex; uint128 shares = SafeCast.toUint128(_shares); cycleState[cycleIndex].requestedWithdrawals += shares; // if user has previously requested deposits or withdrawals, convert them _convertPreviousRequests(_owner); userState[_owner].requestedWithdrawals += shares; userState[_owner].requestCycleIndex = cycleIndex; emit WithdrawalRequested(msg.sender, cycleIndex, _owner, _shares); } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because this function does not call other contracts function claimAndRequestWithdraw(uint256 _shares, address _owner) external override returns (uint256 shares) { shares = claimOwedShares(msg.sender); requestWithdraw(_shares, _owner); } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because this function does not call other contracts function cancelWithdraw(uint256 _shares, address _receiver) external override { if (block.timestamp > globalState.fundingLockTimestamp) revert FundingLocked(); if (fundConfig.disableCancelWithdrawing) revert CancelWithdrawDisabled(); uint32 cycleIndex = globalState.cycleIndex; if (userState[msg.sender].requestCycleIndex != cycleIndex) revert NotEnoughWithdrawals(); if (userState[msg.sender].requestedWithdrawals < _shares) revert NotEnoughWithdrawals(); uint128 shares = SafeCast.toUint128(_shares); cycleState[cycleIndex].requestedWithdrawals -= shares; userState[msg.sender].requestedWithdrawals -= shares; _transfer(address(this), _receiver, _shares); emit WithdrawalCanceled(msg.sender, cycleIndex, _receiver, _shares); } /// @inheritdoc IHighTableVault function requestedFunds(address _owner) external override view returns (uint256 assets, uint256 shares) { if (userState[_owner].requestCycleIndex != globalState.cycleIndex) { return (0, 0); } assets = userState[_owner].requestedDeposits; shares = userState[_owner].requestedWithdrawals; } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because there is no danger of reentrance attack /// @dev since owed assets are cleared before sending out /// @dev and assetToken has to be attacked in some way to perform reentrance function claimOwedAssets(address _receiver) public override returns (uint256 assets) { assets = _internalClaimOwedAssets(_receiver); if (assets > 0) { assetToken.safeTransfer(_receiver, assets); } } /// @inheritdoc IHighTableVault /// @dev No need for nonReentrant because this function does not call other contracts function claimOwedShares(address _receiver) public override returns (uint256 shares) { _convertPreviousRequests(msg.sender); if (userState[msg.sender].owedShares > 0) { shares = userState[msg.sender].owedShares; userState[msg.sender].owedShares = 0; _transfer(address(this), _receiver, shares); emit ClaimOwedShares(msg.sender, _receiver, shares); } } /// @inheritdoc IHighTableVault function claimOwedFunds(address _receiver) external override returns (uint256 assets, uint256 shares) { assets = claimOwedAssets(_receiver); shares = claimOwedShares(_receiver); } /// @inheritdoc IHighTableVault function closePosition(uint256 _shares, address _owner) public override returns (uint256 assets) { if (!globalState.fundClosed) revert FundIsNotClosed(); if (_owner != msg.sender) { _spendAllowance(_owner, msg.sender, _shares); } _burn(_owner, _shares); // closePrice.denominator is the remaining amount of shares when the fund is closed // so if it's zero, no one would have any remaining shares to call closePosition assets = _shares * closePrice.numerator / closePrice.denominator; userState[_owner].owedAssets += SafeCast.toUint128(assets); } /// @inheritdoc IHighTableVault function closePositionAndClaim(address _receiver) external override returns (uint256 assets) { claimOwedShares(msg.sender); uint256 shares = balanceOf(msg.sender); closePosition(shares, msg.sender); assets = claimOwedAssets(_receiver); } /// @notice Internal function for entering next cycle function _internalEnterNextCycle( uint32 _cycleIndex, uint128 _fundValue, uint128 _depositLimit, uint64 _cycleStartTimestamp, uint64 _fundingLockTimestamp, bool _closeFund) internal returns (uint256 platformFee, uint256 managerFee) { if (!hasRole(AUDITOR_ROLE, msg.sender)) revert OnlyAvailableToAuditors(); if (address(fundConfig.teaVaultV2) == address(0)) revert IncorrectVaultAddress(); if (feeConfig.platformVault == address(0)) revert IncorrectVaultAddress(); if (feeConfig.managerVault == address(0)) revert IncorrectVaultAddress(); if (globalState.fundClosed) revert FundIsClosed(); if (_cycleIndex != globalState.cycleIndex) revert IncorrectCycleIndex(); if (_cycleStartTimestamp <= globalState.cycleStartTimestamp || _cycleStartTimestamp > block.timestamp) revert IncorrectCycleStartTimestamp(); // record current cycle state cycleState[_cycleIndex].totalFundValue = _fundValue; uint256 pFee; uint256 mFee; if (_cycleIndex > 0) { // distribute performance and management fees (pFee, mFee) = _calculatePMFees(_fundValue, _cycleStartTimestamp); platformFee += pFee; managerFee += mFee; } uint256 fundValueAfterPMFees = _fundValue - platformFee - managerFee; uint256 currentTotalSupply = totalSupply(); if (currentTotalSupply > 0 && fundValueAfterPMFees == 0) revert InvalidFundValue(); if (currentTotalSupply == 0 && cycleState[_cycleIndex].requestedDeposits == 0) revert NoDeposits(); (pFee, mFee) = _processRequests(fundValueAfterPMFees); platformFee += pFee; managerFee += mFee; if (_closeFund) { // calculate exit fees for all remaining funds (pFee, mFee) = _calculateCloseFundFees(); platformFee += pFee; managerFee += mFee; // set price for closing position uint128 finalFundValue = SafeCast.toUint128(cycleState[globalState.cycleIndex].fundValueAfterRequests - pFee - mFee); closePrice = Price(finalFundValue, SafeCast.toUint128(totalSupply())); globalState.lockedAssets += finalFundValue; globalState.fundClosed = true; } if (currentTotalSupply == 0) { emit EnterNextCycle( msg.sender, _cycleIndex, _fundValue, initialPrice.numerator, initialPrice.denominator, _depositLimit, _cycleStartTimestamp, _fundingLockTimestamp, _closeFund, platformFee, managerFee); } else { emit EnterNextCycle( msg.sender, _cycleIndex, _fundValue, fundValueAfterPMFees, currentTotalSupply, _depositLimit, _cycleStartTimestamp, _fundingLockTimestamp, _closeFund, platformFee, managerFee); } // enter next cycle globalState.cycleIndex ++; globalState.cycleStartTimestamp = _cycleStartTimestamp; globalState.depositLimit = _depositLimit; globalState.fundingLockTimestamp = _fundingLockTimestamp; } /// @notice Interal function for checking if the remaining balance is enough for locked assets function _internalCheckDeposits() internal view returns (uint256 deposits) { deposits = assetToken.balanceOf(address(this)); if (deposits < globalState.lockedAssets) revert NotEnoughAssets(); unchecked { deposits = deposits - globalState.lockedAssets; } } /// @notice Calculate performance and management fees function _calculatePMFees(uint128 _fundValue, uint64 _timestamp) internal view returns (uint256 platformFee, uint256 managerFee) { // calculate management fees uint256 fundValue = _fundValue; uint64 timeDiff = _timestamp - globalState.cycleStartTimestamp; unchecked { platformFee = fundValue * feeConfig.platformManagementFee * timeDiff / (SECONDS_IN_A_YEAR * 1000000); managerFee = fundValue * feeConfig.managerManagementFee * timeDiff / (SECONDS_IN_A_YEAR * 1000000); } // calculate and distribute performance fees if (fundValue > cycleState[globalState.cycleIndex - 1].fundValueAfterRequests) { unchecked { uint256 profits = fundValue - cycleState[globalState.cycleIndex - 1].fundValueAfterRequests; platformFee += profits * feeConfig.platformPerformanceFee / 1000000; managerFee += profits * feeConfig.managerPerformanceFee / 1000000; } } } /// @notice Calculate exit fees when closing fund function _calculateCloseFundFees() internal view returns (uint256 platformFee, uint256 managerFee) { // calculate exit fees for remaining funds uint256 fundValue = cycleState[globalState.cycleIndex].fundValueAfterRequests; unchecked { platformFee = fundValue * feeConfig.platformExitFee / 1000000; managerFee = fundValue * feeConfig.managerExitFee / 1000000; } } /// @notice Process requested withdrawals and deposits function _processRequests(uint256 _fundValueAfterPMFees) internal returns (uint256 platformFee, uint256 managerFee) { uint32 cycleIndex = globalState.cycleIndex; uint256 currentTotalSupply = totalSupply(); uint256 fundValueAfterRequests = _fundValueAfterPMFees; // convert total withdrawals to assets and calculate exit fees if (cycleState[cycleIndex].requestedWithdrawals > 0) { // if requestedWithdrawals > 0, there must be some remaining shares so totalSupply() won't be zero uint256 withdrawnAssets = _fundValueAfterPMFees * cycleState[cycleIndex].requestedWithdrawals / currentTotalSupply; uint256 pFee; uint256 mFee; unchecked { pFee = withdrawnAssets * feeConfig.platformExitFee / 1000000; mFee = withdrawnAssets * feeConfig.managerExitFee / 1000000; } // record remaining assets available for withdrawals cycleState[cycleIndex].convertedWithdrawals = SafeCast.toUint128(withdrawnAssets - pFee - mFee); globalState.lockedAssets += cycleState[cycleIndex].convertedWithdrawals; fundValueAfterRequests -= SafeCast.toUint128(withdrawnAssets); platformFee += pFee; managerFee += mFee; // burn converted share tokens _burn(address(this), cycleState[cycleIndex].requestedWithdrawals); } // convert total deposits to shares and calculate entry fees if (cycleState[cycleIndex].requestedDeposits > 0) { uint256 requestedDeposits = cycleState[cycleIndex].requestedDeposits; uint256 pFee; uint256 mFee; unchecked { pFee = requestedDeposits * feeConfig.platformEntryFee / 1000000; mFee = requestedDeposits * feeConfig.managerEntryFee / 1000000; } globalState.lockedAssets -= cycleState[cycleIndex].requestedDeposits; requestedDeposits = requestedDeposits - pFee - mFee; fundValueAfterRequests += SafeCast.toUint128(requestedDeposits); if (currentTotalSupply == 0) { // use initial price if there's no share tokens cycleState[cycleIndex].convertedDeposits = SafeCast.toUint128(requestedDeposits * initialPrice.denominator / initialPrice.numerator); } else { // _fundValueAfterPMFees is checked to be non-zero when total supply is non-zero cycleState[cycleIndex].convertedDeposits = SafeCast.toUint128(requestedDeposits * currentTotalSupply / _fundValueAfterPMFees); } platformFee += pFee; managerFee += mFee; // mint new share tokens _mint(address(this), cycleState[cycleIndex].convertedDeposits); } cycleState[cycleIndex].fundValueAfterRequests = SafeCast.toUint128(fundValueAfterRequests); } /// @notice Convert previous requested deposits and withdrawls function _convertPreviousRequests(address _receiver) internal { uint32 cycleIndex = userState[_receiver].requestCycleIndex; if (cycleIndex >= globalState.cycleIndex) { return; } if (userState[_receiver].requestedDeposits > 0) { // if requestedDeposits of a user > 0 then requestedDeposits of the cycle must be > 0 uint256 owedShares = uint256(userState[_receiver].requestedDeposits) * cycleState[cycleIndex].convertedDeposits / cycleState[cycleIndex].requestedDeposits; userState[_receiver].owedShares += SafeCast.toUint128(owedShares); emit ConvertToShares(_receiver, cycleIndex, userState[_receiver].requestedDeposits, owedShares); userState[_receiver].requestedDeposits = 0; } if (userState[_receiver].requestedWithdrawals > 0) { // if requestedWithdrawals of a user > 0 then requestedWithdrawals of the cycle must be > 0 uint256 owedAssets = uint256(userState[_receiver].requestedWithdrawals) * cycleState[cycleIndex].convertedWithdrawals / cycleState[cycleIndex].requestedWithdrawals; userState[_receiver].owedAssets += SafeCast.toUint128(owedAssets); emit ConvertToAssets(_receiver, cycleIndex, userState[_receiver].requestedWithdrawals, owedAssets); userState[_receiver].requestedWithdrawals = 0; } } /// @notice Internal function for processing deposit requests function _internalRequestDeposit(uint256 _assets, address _receiver) internal { if (fundConfig.disableDepositing) revert DepositDisabled(); if (globalState.fundClosed) revert FundIsClosed(); if (block.timestamp > globalState.fundingLockTimestamp) revert FundingLocked(); if (_assets + cycleState[globalState.cycleIndex].requestedDeposits > globalState.depositLimit) revert ExceedDepositLimit(); if (!_hasNFT(_receiver)) revert ReceiverDoNotHasNFT(); uint32 cycleIndex = globalState.cycleIndex; uint128 assets = SafeCast.toUint128(_assets); cycleState[cycleIndex].requestedDeposits += assets; globalState.lockedAssets += assets; // if user has previously requested deposits or withdrawals, convert them _convertPreviousRequests(_receiver); userState[_receiver].requestedDeposits += assets; userState[_receiver].requestCycleIndex = cycleIndex; emit DepositRequested(msg.sender, cycleIndex, _receiver, _assets); } /// @notice Internal function for canceling deposit requests function _internalCancelDeposit(uint256 _assets, address _receiver) internal { if (block.timestamp > globalState.fundingLockTimestamp) revert FundingLocked(); if (fundConfig.disableCancelDepositing) revert CancelDepositDisabled(); uint32 cycleIndex = globalState.cycleIndex; if (userState[msg.sender].requestCycleIndex != cycleIndex) revert NotEnoughDeposits(); if (userState[msg.sender].requestedDeposits < _assets) revert NotEnoughDeposits(); uint128 assets = SafeCast.toUint128(_assets); cycleState[cycleIndex].requestedDeposits -= assets; globalState.lockedAssets -= assets; userState[msg.sender].requestedDeposits -= assets; emit DepositCanceled(msg.sender, cycleIndex, _receiver, _assets); } /// @notice Internal function for claiming owed assets function _internalClaimOwedAssets(address _receiver) internal returns (uint256 assets) { _convertPreviousRequests(msg.sender); if (userState[msg.sender].owedAssets > 0) { assets = userState[msg.sender].owedAssets; globalState.lockedAssets -= userState[msg.sender].owedAssets; userState[msg.sender].owedAssets = 0; emit ClaimOwedAssets(msg.sender, _receiver, assets); } } /// @notice Internal NFT checker /// @param _receiver address of the receiver /// @return hasNFT true if the receiver has at least one of the NFT, false if not /// @dev always returns true if disableNFTChecks is enabled function _hasNFT(address _receiver) internal view returns (bool hasNFT) { if (fundConfig.disableNFTChecks) { return true; } uint256 i; uint256 length = nftEnabled.length; for (i = 0; i < length; ) { if (IERC721(nftEnabled[i]).balanceOf(_receiver) > 0) { return true; } unchecked { ++i; } } return false; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol) pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248) { require(value >= type(int248).min && value <= type(int248).max, "SafeCast: value doesn't fit in 248 bits"); return int248(value); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240) { require(value >= type(int240).min && value <= type(int240).max, "SafeCast: value doesn't fit in 240 bits"); return int240(value); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232) { require(value >= type(int232).min && value <= type(int232).max, "SafeCast: value doesn't fit in 232 bits"); return int232(value); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224) { require(value >= type(int224).min && value <= type(int224).max, "SafeCast: value doesn't fit in 224 bits"); return int224(value); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216) { require(value >= type(int216).min && value <= type(int216).max, "SafeCast: value doesn't fit in 216 bits"); return int216(value); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208) { require(value >= type(int208).min && value <= type(int208).max, "SafeCast: value doesn't fit in 208 bits"); return int208(value); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200) { require(value >= type(int200).min && value <= type(int200).max, "SafeCast: value doesn't fit in 200 bits"); return int200(value); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192) { require(value >= type(int192).min && value <= type(int192).max, "SafeCast: value doesn't fit in 192 bits"); return int192(value); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184) { require(value >= type(int184).min && value <= type(int184).max, "SafeCast: value doesn't fit in 184 bits"); return int184(value); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176) { require(value >= type(int176).min && value <= type(int176).max, "SafeCast: value doesn't fit in 176 bits"); return int176(value); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168) { require(value >= type(int168).min && value <= type(int168).max, "SafeCast: value doesn't fit in 168 bits"); return int168(value); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160) { require(value >= type(int160).min && value <= type(int160).max, "SafeCast: value doesn't fit in 160 bits"); return int160(value); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152) { require(value >= type(int152).min && value <= type(int152).max, "SafeCast: value doesn't fit in 152 bits"); return int152(value); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144) { require(value >= type(int144).min && value <= type(int144).max, "SafeCast: value doesn't fit in 144 bits"); return int144(value); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136) { require(value >= type(int136).min && value <= type(int136).max, "SafeCast: value doesn't fit in 136 bits"); return int136(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120) { require(value >= type(int120).min && value <= type(int120).max, "SafeCast: value doesn't fit in 120 bits"); return int120(value); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112) { require(value >= type(int112).min && value <= type(int112).max, "SafeCast: value doesn't fit in 112 bits"); return int112(value); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104) { require(value >= type(int104).min && value <= type(int104).max, "SafeCast: value doesn't fit in 104 bits"); return int104(value); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96) { require(value >= type(int96).min && value <= type(int96).max, "SafeCast: value doesn't fit in 96 bits"); return int96(value); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88) { require(value >= type(int88).min && value <= type(int88).max, "SafeCast: value doesn't fit in 88 bits"); return int88(value); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80) { require(value >= type(int80).min && value <= type(int80).max, "SafeCast: value doesn't fit in 80 bits"); return int80(value); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72) { require(value >= type(int72).min && value <= type(int72).max, "SafeCast: value doesn't fit in 72 bits"); return int72(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56) { require(value >= type(int56).min && value <= type(int56).max, "SafeCast: value doesn't fit in 56 bits"); return int56(value); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48) { require(value >= type(int48).min && value <= type(int48).max, "SafeCast: value doesn't fit in 48 bits"); return int48(value); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40) { require(value >= type(int40).min && value <= type(int40).max, "SafeCast: value doesn't fit in 40 bits"); return int40(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24) { require(value >= type(int24).min && value <= type(int24).max, "SafeCast: value doesn't fit in 24 bits"); return int24(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// contracts/IHighTableVault.sol // SPDX-License-Identifier: BUSL // Teahouse Finance pragma solidity ^0.8.0; import "./ITeaVaultV2.sol"; error OnlyAvailableToAdmins(); // operation is available only to admins error OnlyAvailableToAuditors(); // operation is available only to auditors error ReceiverDoNotHasNFT(); // receiver does not have required NFT to deposit error IncorrectVaultAddress(); // TeaVaultV2, managerVault, or platformVault is 0 error IncorrectReceiverAddress(); // receiver address is 0 error NotEnoughAssets(); // does not have enough asset tokens error FundingLocked(); // deposit and withdraw are not allowed in locked period error ExceedDepositLimit(); // requested deposit exceeds current deposit limit error DepositDisabled(); // deposit request is disabled error WithdrawDisabled(); // withdraw request is disabled error NotEnoughDeposits(); // user does not have enough deposit requested to cancel error NotEnoughWithdrawals(); // user does not have enough withdrawals requested to cancel error InvalidInitialPrice(); // invalid initial price error FundIsClosed(); // fund is closed, requests are not allowed error FundIsNotClosed(); // fund is not closed, can't close position error InvalidFeePercentage(); // incorrect fee percentage error IncorrectCycleIndex(); // incorrect cycle index error IncorrectCycleStartTimestamp(); // incorrect cycle start timestamp (before previous cycle start timestamp or later than current time) error InvalidFundValue(); // incorrect fund value (zero or very close to zero) error NoDeposits(); // can not enter next cycle if there's no share and no requested deposits error CancelDepositDisabled(); // canceling deposit is disabled error CancelWithdrawDisabled(); // canceling withdraw is disabled interface IHighTableVault { struct Price { uint128 numerator; // numerator of the price uint128 denominator; // denominator of the price } struct FeeConfig { address platformVault; // platform fee goes here address managerVault; // manager fee goes here uint24 platformEntryFee; // platform entry fee in 0.0001% (collected when depositing) uint24 managerEntryFee; // manager entry fee in 0.0001% (colleceted when depositing) uint24 platformExitFee; // platform exit fee (collected when withdrawing) uint24 managerExitFee; // manager exit fee (collected when withdrawing) uint24 platformPerformanceFee; // platform performance fee (collected for each cycle, from profits) uint24 managerPerformanceFee; // manager performance fee (collected for each cycle, from profits) uint24 platformManagementFee; // platform yearly management fee (collected for each cycle, from total value) uint24 managerManagementFee; // manager yearly management fee (collected for each cycle, from total value) } struct FundConfig { ITeaVaultV2 teaVaultV2; // TeaVaultV2 address bool disableNFTChecks; // allow everyone to access the vault bool disableDepositing; // disable requesting depositing bool disableWithdrawing; // disable requesting withdrawing bool disableCancelDepositing; // disable canceling depositing bool disableCancelWithdrawing; // disable canceling withdrawing } struct GlobalState { uint128 depositLimit; // deposit limit (in asset) uint128 lockedAssets; // locked assets (assets waiting to be withdrawn, or deposited by users but not converted to shares yet) uint32 cycleIndex; // current cycle index uint64 cycleStartTimestamp; // start timestamp of current cycle uint64 fundingLockTimestamp; // timestamp for locking depositing/withdrawing bool fundClosed; // fund is closed } struct CycleState { uint128 totalFundValue; // total fund value in asset tokens, at the end of the cycle uint128 fundValueAfterRequests; // fund value after requests are processed in asset tokens, at the end of the cycle uint128 requestedDeposits; // total requested deposits during this cycle (in assets) uint128 convertedDeposits; // converted deposits at the end of the cycle (in shares) uint128 requestedWithdrawals; // total requested withdrawals during this cycle (in shares) uint128 convertedWithdrawals; // converted withdrawals at the end of the cycle (in assets) } struct UserState { uint128 requestedDeposits; // deposits requested but not converted (in assets) uint128 owedShares; // shares available to be withdrawn uint128 requestedWithdrawals; // withdrawals requested but not converted (in shares) uint128 owedAssets; // assets available to be withdrawn uint32 requestCycleIndex; // cycle index for requests (for both deposits and withdrawals) } // ------ // events // ------ event FundInitialized(address indexed caller, uint256 priceNumerator, uint256 priceDenominator, uint64 startTimestamp, address admin); event NFTEnabled(address indexed caller, uint32 indexed cycleIndex, address[] nfts); event DisableNFTChecks(address indexed caller, uint32 indexed cycleIndex, bool disableChecks); event FeeConfigChanged(address indexed caller, uint32 indexed cycleIndex, FeeConfig feeConfig); event EnterNextCycle(address indexed caller, uint32 indexed cycleIndex, uint256 fundValue, uint256 priceNumerator, uint256 priceDenominator, uint256 depositLimit, uint64 startTimestamp, uint64 lockTimestamp, bool fundClosed, uint256 platformFee, uint256 managerFee); event FundLockingTimestampUpdated(address indexed caller, uint32 indexed cycleIndex, uint64 lockTimestamp); event DepositLimitUpdated(address indexed caller, uint32 indexed cycleIndex, uint256 depositLimit); event UpdateTeaVaultV2(address indexed caller, uint32 indexed cycleIndex, address teaVaultV2); event DepositToVault(address indexed caller, uint32 indexed cycleIndex, address teaVaultV2, uint256 value); event WithdrawFromVault(address indexed caller, uint32 indexed cycleIndex, address teaVaultV2, uint256 value); event FundingChanged(address indexed caller, uint32 indexed cycleIndex, bool disableDepositing, bool disableWithdrawing, bool disableCancelDepositing, bool disableCancelWithdrawing); event DepositRequested(address indexed caller, uint32 indexed cycleIndex, address indexed receiver, uint256 assets); event DepositCanceled(address indexed caller, uint32 indexed cycleIndex, address indexed receiver, uint256 assets); event WithdrawalRequested(address indexed caller, uint32 indexed cycleIndex, address indexed owner, uint256 shares); event WithdrawalCanceled(address indexed caller, uint32 indexed cycleIndex, address indexed receiver, uint256 shares); event ClaimOwedAssets(address indexed caller, address indexed receiver, uint256 assets); event ClaimOwedShares(address indexed caller, address indexed receiver, uint256 shares); event ConvertToShares(address indexed owner, uint32 indexed cycleIndex, uint256 assets, uint256 shares); event ConvertToAssets(address indexed owner, uint32 indexed cycleIndex, uint256 shares, uint256 assets); // --------------- // admin functions // --------------- /// @notice Set the list of NFTs for allowing depositing /// @param _nfts addresses of the NFTs /// @notice Only available to admins function setEnabledNFTs(address[] memory _nfts) external; /// @notice Disable/enable NFT checks /// @param _checks true to disable NFT checks, false to enable /// @notice Only available to admins function setDisableNFTChecks(bool _checks) external; /// @notice Set fee structure and platform/manager vault addresses /// @param _feeConfig fee structure settings /// @notice Only available to admins function setFeeConfig(FeeConfig calldata _feeConfig) external; /// @notice Set TeaVaultV2 address /// @param _teaVaultV2 address to TeaVaultV2 /// @notice Only available to admins function setTeaVaultV2(address _teaVaultV2) external; // ----------------- // auditor functions // ----------------- /// @notice Enter next cycle /// @param _cycleIndex current cycle index (to prevent accidental replay) /// @param _fundValue total fund value for this cycle /// @param _withdrawAmount amount to withdraw from TeaVaultV2 /// @param _cycleStartTimestamp starting timestamp of the next cycle /// @param _fundingLockTimestamp funding lock timestamp for next cycle /// @param _closeFund true to close fund, irreversible /// @return platformFee total fee paid to the platform /// @return managerFee total fee paid to the manager /// @notice Only available to auditors /// @notice Use previewNextCycle function to get an estimation of required _withdrawAmount /// @notice _cycleStartTimestamp must be later than start timestamp of current cycle /// @notice and before the block timestamp when the transaction is confirmed /// @notice _fundValue can't be zero or close to zero except for the first first cycle function enterNextCycle( uint32 _cycleIndex, uint128 _fundValue, uint128 _depositLimit, uint128 _withdrawAmount, uint64 _cycleStartTimestamp, uint64 _fundingLockTimestamp, bool _closeFund) external returns (uint256 platformFee, uint256 managerFee); /// @notice Update fund locking timestamp /// @param _fundLockingTimestamp new timestamp for locking withdraw/deposits /// @notice Only available to auditors function setFundLockingTimestamp(uint64 _fundLockingTimestamp) external; /// @notice Update deposit limit /// @param _depositLimit new deposit limit /// @notice Only available to auditors function setDepositLimit(uint128 _depositLimit) external; /// @notice Allowing/disabling depositing/withdrawing /// @param _disableDepositing true to allow depositing, false to disallow /// @param _disableWithdrawing true to allow withdrawing, false to disallow /// @param _disableCancelDepositing true to allow withdrawing, false to disallow /// @param _disableCancelWithdrawing true to allow withdrawing, false to disallow /// @notice Only available to auditors function setDisableFunding(bool _disableDepositing, bool _disableWithdrawing, bool _disableCancelDepositing, bool _disableCancelWithdrawing) external; /// @notice Deposit fund to TeaVaultV2 /// @notice Can not deposit locked assets /// @param _value value to deposit /// @notice Only available to auditors function depositToVault(uint256 _value) external; /// @notice Withdraw fund from TeaVaultV2 /// @param _value value to withdraw /// @notice Only available to auditors function withdrawFromVault(uint256 _value) external; // -------------------------- // functions available to all // -------------------------- /// @notice Returns address of the asset token /// @return assetTokenAddress address of the asset token function asset() external view returns (address assetTokenAddress); /// @notice Request deposits /// @notice Actual deposits will be executed when entering the next cycle /// @param _assets amount of asset tokens to deposit /// @param _receiver address where the deposit is credited /// @notice _receiver need to have the required NFT /// @notice Request is disabled when time is later than fundingLockTimestamp function requestDeposit(uint256 _assets, address _receiver) external; /// @notice Claim owed assets and request deposits /// @notice Actual deposits will be executed when entering the next cycle /// @param _assets amount of asset tokens to deposit /// @param _receiver address where the deposit is credited /// @return assets amount of owed asset tokens claimed /// @notice _receiver need to have the required NFT /// @notice Request is disabled when time is later than fundingLockTimestamp function claimAndRequestDeposit(uint256 _assets, address _receiver) external returns (uint256 assets); /// @notice Cancel deposit requests /// @param _assets amount of asset tokens to cancel deposit /// @param _receiver address to receive the asset tokens /// @notice Request is disabled when time is later than fundingLockTimestamp function cancelDeposit(uint256 _assets, address _receiver) external; /// @notice Request withdrawals /// @notice Actual withdrawals will be executed when entering the next cycle /// @param _shares amount of share tokens to withdraw /// @param _owner owner address of share tokens /// @notice If _owner is different from msg.sender, _owner must approve msg.sender to spend share tokens /// @notice Request is disabled when time is later than fundingLockTimestamp function requestWithdraw(uint256 _shares, address _owner) external; /// @notice Claim owed shares and request withdrawals /// @notice Actual withdrawals will be executed when entering the next cycle /// @param _shares amount of share tokens to withdraw /// @param _owner owner address of share tokens /// @return shares amount of owed share tokens claimed /// @notice If _owner is different from msg.sender, _owner must approve msg.sender to spend share tokens /// @notice Request is disabled when time is later than fundingLockTimestamp function claimAndRequestWithdraw(uint256 _shares, address _owner) external returns (uint256 shares); /// @notice Cancel withdrawal requests /// @param _shares amount of share tokens to cancel withdrawal /// @param _receiver address to receive the share tokens /// @notice Request is disabled when time is later than fundingLockTimestamp function cancelWithdraw(uint256 _shares, address _receiver) external; /// @notice Returns currently requested deposits and withdrawals /// @param _owner address of the owner /// @return assets amount of asset tokens requested to be deposited /// @return shares amount of asset tokens requested to be withdrawn function requestedFunds(address _owner) external view returns (uint256 assets, uint256 shares); /// @notice Claim owed assets /// @param _receiver address to receive the tokens /// @return assets amount of owed asset tokens claimed function claimOwedAssets(address _receiver) external returns (uint256 assets); /// @notice Claim owed shares /// @param _receiver address to receive the tokens /// @return shares amount of owed share tokens claimed function claimOwedShares(address _receiver) external returns (uint256 shares); /// @notice Claim owed assets and shares /// @param _receiver address to receive the tokens /// @return assets amount of owed asset tokens claimed /// @return shares amount of owed share tokens claimed function claimOwedFunds(address _receiver) external returns (uint256 assets, uint256 shares); /// @notice Close positions /// @notice Converted assets are added to owed assets /// @notice Only available when fund is closed /// @param _shares amount of share tokens to close /// @param _owner owner address of share tokens /// @return assets amount of assets converted /// @notice If _owner is different from msg.sender, _owner must approve msg.sender to spend share tokens function closePosition(uint256 _shares, address _owner) external returns (uint256 assets); /// @notice Close positions and claim all assets /// @notice Only available when fund is closed /// @param _receiver address to receive asset tokens /// @return assets amount of asset tokens withdrawn function closePositionAndClaim(address _receiver) external returns (uint256 assets); /// @notice Preview how much assets is required for entering next cycle /// @param _fundValue total fund value for this cycle /// @param _timestamp predicted timestamp for start of next cycle /// @return withdrawAmount amount of assets required function previewNextCycle(uint128 _fundValue, uint64 _timestamp) external view returns (uint256 withdrawAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// 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 (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// contracts/ITeaVaultV2.sol // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; interface ITeaVaultV2 { function deposit(address _token, uint256 _amount) external; function withdraw(address _recipient, address _token, uint256 _amount) external; function deposit721(address _token, uint256 _tokenId) external; function withdraw721(address _recipient, address _token, uint256 _tokenId) external; function deposit1155(address _token, uint256 _tokenId, uint256 _amount) external; function withdraw1155(address _recipient, address _token, uint256 _tokenId, uint256 _amount) external; function depositETH(uint256 _amount) external payable; function withdrawETH(address payable _recipient, uint256 _amount) external; }
{ "optimizer": { "enabled": true, "runs": 1 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint128","name":"_priceNumerator","type":"uint128"},{"internalType":"uint128","name":"_priceDenominator","type":"uint128"},{"internalType":"uint64","name":"_startTimestamp","type":"uint64"},{"internalType":"address","name":"_initialAdmin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CancelDepositDisabled","type":"error"},{"inputs":[],"name":"CancelWithdrawDisabled","type":"error"},{"inputs":[],"name":"DepositDisabled","type":"error"},{"inputs":[],"name":"ExceedDepositLimit","type":"error"},{"inputs":[],"name":"FundIsClosed","type":"error"},{"inputs":[],"name":"FundIsNotClosed","type":"error"},{"inputs":[],"name":"FundingLocked","type":"error"},{"inputs":[],"name":"IncorrectCycleIndex","type":"error"},{"inputs":[],"name":"IncorrectCycleStartTimestamp","type":"error"},{"inputs":[],"name":"IncorrectVaultAddress","type":"error"},{"inputs":[],"name":"InvalidFeePercentage","type":"error"},{"inputs":[],"name":"InvalidFundValue","type":"error"},{"inputs":[],"name":"InvalidInitialPrice","type":"error"},{"inputs":[],"name":"NoDeposits","type":"error"},{"inputs":[],"name":"NotEnoughAssets","type":"error"},{"inputs":[],"name":"NotEnoughDeposits","type":"error"},{"inputs":[],"name":"NotEnoughWithdrawals","type":"error"},{"inputs":[],"name":"OnlyAvailableToAdmins","type":"error"},{"inputs":[],"name":"OnlyAvailableToAuditors","type":"error"},{"inputs":[],"name":"ReceiverDoNotHasNFT","type":"error"},{"inputs":[],"name":"WithdrawDisabled","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"ClaimOwedAssets","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"ClaimOwedShares","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"ConvertToAssets","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"ConvertToShares","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"DepositCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"depositLimit","type":"uint256"}],"name":"DepositLimitUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"DepositRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"address","name":"teaVaultV2","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"DepositToVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"bool","name":"disableChecks","type":"bool"}],"name":"DisableNFTChecks","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"fundValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceDenominator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"depositLimit","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"lockTimestamp","type":"uint64"},{"indexed":false,"internalType":"bool","name":"fundClosed","type":"bool"},{"indexed":false,"internalType":"uint256","name":"platformFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"managerFee","type":"uint256"}],"name":"EnterNextCycle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"components":[{"internalType":"address","name":"platformVault","type":"address"},{"internalType":"address","name":"managerVault","type":"address"},{"internalType":"uint24","name":"platformEntryFee","type":"uint24"},{"internalType":"uint24","name":"managerEntryFee","type":"uint24"},{"internalType":"uint24","name":"platformExitFee","type":"uint24"},{"internalType":"uint24","name":"managerExitFee","type":"uint24"},{"internalType":"uint24","name":"platformPerformanceFee","type":"uint24"},{"internalType":"uint24","name":"managerPerformanceFee","type":"uint24"},{"internalType":"uint24","name":"platformManagementFee","type":"uint24"},{"internalType":"uint24","name":"managerManagementFee","type":"uint24"}],"indexed":false,"internalType":"struct IHighTableVault.FeeConfig","name":"feeConfig","type":"tuple"}],"name":"FeeConfigChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"priceNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceDenominator","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"indexed":false,"internalType":"address","name":"admin","type":"address"}],"name":"FundInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"uint64","name":"lockTimestamp","type":"uint64"}],"name":"FundLockingTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"bool","name":"disableDepositing","type":"bool"},{"indexed":false,"internalType":"bool","name":"disableWithdrawing","type":"bool"},{"indexed":false,"internalType":"bool","name":"disableCancelDepositing","type":"bool"},{"indexed":false,"internalType":"bool","name":"disableCancelWithdrawing","type":"bool"}],"name":"FundingChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"address[]","name":"nfts","type":"address[]"}],"name":"NFTEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"address","name":"teaVaultV2","type":"address"}],"name":"UpdateTeaVaultV2","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":false,"internalType":"address","name":"teaVaultV2","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"WithdrawFromVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"WithdrawalCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"WithdrawalRequested","type":"event"},{"inputs":[],"name":"AUDITOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SECONDS_IN_A_YEAR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"assetTokenAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_assets","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"cancelDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"cancelWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_assets","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"claimAndRequestDeposit","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"}],"name":"claimAndRequestWithdraw","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"claimOwedAssets","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"claimOwedFunds","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"claimOwedShares","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"}],"name":"closePosition","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"closePositionAndClaim","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"closePrice","outputs":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"cycleState","outputs":[{"internalType":"uint128","name":"totalFundValue","type":"uint128"},{"internalType":"uint128","name":"fundValueAfterRequests","type":"uint128"},{"internalType":"uint128","name":"requestedDeposits","type":"uint128"},{"internalType":"uint128","name":"convertedDeposits","type":"uint128"},{"internalType":"uint128","name":"requestedWithdrawals","type":"uint128"},{"internalType":"uint128","name":"convertedWithdrawals","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"depositToVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_cycleIndex","type":"uint32"},{"internalType":"uint128","name":"_fundValue","type":"uint128"},{"internalType":"uint128","name":"_depositLimit","type":"uint128"},{"internalType":"uint128","name":"_withdrawAmount","type":"uint128"},{"internalType":"uint64","name":"_cycleStartTimestamp","type":"uint64"},{"internalType":"uint64","name":"_fundingLockTimestamp","type":"uint64"},{"internalType":"bool","name":"_closeFund","type":"bool"}],"name":"enterNextCycle","outputs":[{"internalType":"uint256","name":"platformFee","type":"uint256"},{"internalType":"uint256","name":"managerFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeConfig","outputs":[{"internalType":"address","name":"platformVault","type":"address"},{"internalType":"address","name":"managerVault","type":"address"},{"internalType":"uint24","name":"platformEntryFee","type":"uint24"},{"internalType":"uint24","name":"managerEntryFee","type":"uint24"},{"internalType":"uint24","name":"platformExitFee","type":"uint24"},{"internalType":"uint24","name":"managerExitFee","type":"uint24"},{"internalType":"uint24","name":"platformPerformanceFee","type":"uint24"},{"internalType":"uint24","name":"managerPerformanceFee","type":"uint24"},{"internalType":"uint24","name":"platformManagementFee","type":"uint24"},{"internalType":"uint24","name":"managerManagementFee","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fundConfig","outputs":[{"internalType":"contract ITeaVaultV2","name":"teaVaultV2","type":"address"},{"internalType":"bool","name":"disableNFTChecks","type":"bool"},{"internalType":"bool","name":"disableDepositing","type":"bool"},{"internalType":"bool","name":"disableWithdrawing","type":"bool"},{"internalType":"bool","name":"disableCancelDepositing","type":"bool"},{"internalType":"bool","name":"disableCancelWithdrawing","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalState","outputs":[{"internalType":"uint128","name":"depositLimit","type":"uint128"},{"internalType":"uint128","name":"lockedAssets","type":"uint128"},{"internalType":"uint32","name":"cycleIndex","type":"uint32"},{"internalType":"uint64","name":"cycleStartTimestamp","type":"uint64"},{"internalType":"uint64","name":"fundingLockTimestamp","type":"uint64"},{"internalType":"bool","name":"fundClosed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialPrice","outputs":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nftEnabled","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_fundValue","type":"uint128"},{"internalType":"uint64","name":"_timestamp","type":"uint64"}],"name":"previewNextCycle","outputs":[{"internalType":"uint256","name":"withdrawAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_assets","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"requestDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"}],"name":"requestWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"requestedFunds","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_depositLimit","type":"uint128"}],"name":"setDepositLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_disableDepositing","type":"bool"},{"internalType":"bool","name":"_disableWithdrawing","type":"bool"},{"internalType":"bool","name":"_disableCancelDepositing","type":"bool"},{"internalType":"bool","name":"_disableCancelWithdrawing","type":"bool"}],"name":"setDisableFunding","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_checks","type":"bool"}],"name":"setDisableNFTChecks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_nfts","type":"address[]"}],"name":"setEnabledNFTs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"platformVault","type":"address"},{"internalType":"address","name":"managerVault","type":"address"},{"internalType":"uint24","name":"platformEntryFee","type":"uint24"},{"internalType":"uint24","name":"managerEntryFee","type":"uint24"},{"internalType":"uint24","name":"platformExitFee","type":"uint24"},{"internalType":"uint24","name":"managerExitFee","type":"uint24"},{"internalType":"uint24","name":"platformPerformanceFee","type":"uint24"},{"internalType":"uint24","name":"managerPerformanceFee","type":"uint24"},{"internalType":"uint24","name":"platformManagementFee","type":"uint24"},{"internalType":"uint24","name":"managerManagementFee","type":"uint24"}],"internalType":"struct IHighTableVault.FeeConfig","name":"_feeConfig","type":"tuple"}],"name":"setFeeConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_fundLockingTimestamp","type":"uint64"}],"name":"setFundLockingTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_teaVaultV2","type":"address"}],"name":"setTeaVaultV2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userState","outputs":[{"internalType":"uint128","name":"requestedDeposits","type":"uint128"},{"internalType":"uint128","name":"owedShares","type":"uint128"},{"internalType":"uint128","name":"requestedWithdrawals","type":"uint128"},{"internalType":"uint128","name":"owedAssets","type":"uint128"},{"internalType":"uint32","name":"requestCycleIndex","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"withdrawFromVault","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061025c5760003560e01c806301ffc9a71461026157806306297eab1461028957806306fdde03146102a9578063076d0815146102be578063095ea7b3146102d35780630c8f81b5146102e65780631696adc81461037a57806318160ddd1461039b5780631987b045146103a35780631d0806ae146103cb5780631e5eb1d0146104095780631fd46898146104dc57806323b872dd146104ef578063248a9ca31461050257806326c113fb1461051557806329344f08146105285780632f2ff15d1461053b578063313ce5671461054e57806335cb739e1461055d57806336568abe1461057057806338d52e0f1461058357806339509351146105a957806341295a5d146105bc5780634643d424146105cf5780634923d29e146105e2578063578f2bcc1461067c5780636297817f1461068f5780636e1d616e146106a257806370a08231146106b757806373601719146106ca5780638fffd8b2146106dd57806391d14854146106f057806395d89b411461070357806398000ff71461070b578063a217fddf1461071e578063a457c2d714610726578063a9059cbb14610739578063b04622961461074c578063b5e0ecac1461075f578063c4fa17a414610772578063ccc143b81461077d578063ccdf429914610790578063d547741f146107ae578063dd62ed3e146107c1578063e02ff7fe146107d4578063e22857ce146107e7578063e28d1d2e146107fa578063e76c01e414610883578063e982701714610926578063ec8ad8e814610939578063f3ad74011461094c578063f807f6d61461095f575b600080fd5b61027461026f3660046141ac565b610972565b60405190151581526020015b60405180910390f35b61029c6102973660046141d6565b6109a9565b60405161028091906141fc565b6102b16109d3565b6040516102809190614234565b6102d16102cc3660046141d6565b610a65565b005b6102746102e1366004614287565b610b76565b61033a6102f43660046142b3565b600e602052600090815260409020805460018201546002909201546001600160801b0380831693600160801b938490048216938183169391049091169063ffffffff1685565b604080516001600160801b039687168152948616602086015292851692840192909252909216606082015263ffffffff909116608082015260a001610280565b61038d6103883660046142b3565b610b8e565b604051908152602001610280565b60035461038d565b6103b66103b1366004614320565b610c38565b60408051928352602083019190915201610280565b600f546103e9906001600160801b0380821691600160801b90041682565b604080516001600160801b03938416815292909116602083015201610280565b600654600754600854610476926001600160a01b03908116929081169162ffffff600160a01b8304811692600160b81b8104821692600160d01b8204831692600160e81b9092048216918181169163010000008104821691600160301b8204811691600160481b9004168a565b604080516001600160a01b039b8c1681529a90991660208b015262ffffff978816988a01989098529486166060890152928516608088015290841660a0870152831660c0860152821660e085015281166101008401521661012082015261014001610280565b6102d16104ea3660046143aa565b610e50565b6102746104fd3660046143c5565b610eed565b61038d6105103660046141d6565b610f13565b61038d610523366004614406565b610f28565b6102d1610536366004614406565b610f3f565b6102d1610549366004614406565b610f82565b60405160128152602001610280565b6102d161056b366004614406565b610fa3565b6102d161057e366004614406565b61118b565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4861029c565b6102746105b7366004614287565b61120a565b6102d16105ca366004614436565b61122c565b6102d16105dd36600461444f565b6113d0565b61063a6105f03660046144c3565b600d602052600090815260409020805460018201546002909201546001600160801b0380831693600160801b93849004821693818316939181900483169282811692919091041686565b604080516001600160801b03978816815295871660208701529386169385019390935290841660608401528316608083015290911660a082015260c001610280565b6103b661068a3660046142b3565b611451565b6103b661069d3660046142b3565b61146f565b61038d600080516020614bdd83398151915281565b61038d6106c53660046142b3565b6114de565b6102d16106d83660046144de565b6114f9565b6102d16106eb366004614406565b6115ec565b6102746106fe366004614406565b61162a565b6102b1611653565b61038d6107193660046142b3565b611662565b61038d600081565b610274610734366004614287565b6116a9565b610274610747366004614287565b61172f565b6102d161075a3660046141d6565b61173d565b61038d61076d366004614406565b61194c565b61038d6301e1338081565b6102d161078b366004614406565b611a38565b6010546103e9906001600160801b0380821691600160801b90041682565b6102d16107bc366004614406565b611c1a565b61038d6107cf36600461453a565b611c36565b6102d16107e2366004614568565b611c61565b6102d16107f53660046142b3565b611cf0565b600954610842906001600160a01b0381169060ff600160a01b8204811691600160a81b8104821691600160b01b8204811691600160b81b8104821691600160c01b9091041686565b604080516001600160a01b039097168752941515602087015292151593850193909352151560608401529015156080830152151560a082015260c001610280565b600b54600c546108d6916001600160801b0380821692600160801b909204169063ffffffff8116906001600160401b03600160201b8204811691600160601b81049091169060ff600160a01b9091041686565b604080516001600160801b03978816815296909516602087015263ffffffff909316938501939093526001600160401b0390811660608501529091166080830152151560a082015260c001610280565b61038d6109343660046142b3565b611d71565b6102d1610947366004614583565b611d9e565b61038d61095a3660046145a0565b611e1f565b61038d61096d366004614406565b611fcd565b60006001600160e01b03198216637965db0b60e01b14806109a357506301ffc9a760e01b6001600160e01b03198316145b92915050565b600a81815481106109b957600080fd5b6000918252602090912001546001600160a01b0316905081565b6060600480546109e2906145d3565b80601f0160208091040260200160405190810160405280929190818152602001828054610a0e906145d3565b8015610a5b5780601f10610a3057610100808354040283529160200191610a5b565b820191906000526020600020905b815481529060010190602001808311610a3e57829003601f168201915b5050505050905090565b610a7d600080516020614bdd8339815191523361162a565b610a9a576040516312dd957560e31b815260040160405180910390fd5b600954604051636ce5768960e11b81526001600160a01b039091169063d9caed1290610aee9030907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48908690600401614607565b600060405180830381600087803b158015610b0857600080fd5b505af1158015610b1c573d6000803e3d6000fd5b5050600c5460095460405163ffffffff90921693503392507f07673397b18958e624a46b92034a2a5d69ee7ef570059d4d2dc692349216395291610b6b916001600160a01b031690869061462b565b60405180910390a350565b600033610b84818585611fe4565b5060019392505050565b6000610b9933612108565b336000908152600e6020526040902054600160801b90046001600160801b031615610c335750336000908152600e6020526040902080546001600160801b03808216909255600160801b900416610bf1308383612427565b6040518181526001600160a01b0383169033907f438df5737634ab0704853a9f34ac7b2b5878a6e872a2cd85e097221d151b9e74906020015b60405180910390a35b919050565b6000806001600160801b03861615610cdf57600954604051636ce5768960e11b81523060048201526001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811660248301526001600160801b03891660448301529091169063d9caed1290606401600060405180830381600087803b158015610cc657600080fd5b505af1158015610cda573d6000803e3d6000fd5b505050505b610ced8989898888886125dc565b90925090508115610d3257600654610d32906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488116911684612b6a565b8015610d7257600754610d72906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488116911683612b6a565b6000610d7c612bc0565b90508015610e4357600954610dbe906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488116911683612c9e565b6009546040516311f9fbc960e21b81526001600160a01b03909116906347e7ef2490610e10907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4890859060040161462b565b600060405180830381600087803b158015610e2a57600080fd5b505af1158015610e3e573d6000803e3d6000fd5b505050505b5097509795505050505050565b610e68600080516020614bdd8339815191523361162a565b610e85576040516312dd957560e31b815260040160405180910390fd5b600c8054600160601b600160a01b03198116600160601b6001600160401b03851690810291821790935560405192835263ffffffff9182169116179033907f1cced4c455e5e9eb599e2636157518cf49e3253f25025d686fceed9b09db415390602001610b6b565b600033610efb858285612da2565b610f06858585612427565b60019150505b9392505050565b60009081526020819052604090206001015490565b6000610f3333610b8e565b90506109a38383611a38565b610f746001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816333085612e16565b610f7e8282612e37565b5050565b610f8b82610f13565b610f94816130b5565b610f9e83836130c2565b505050565b600c54600160601b90046001600160401b0316421115610fd657604051631154791f60e31b815260040160405180910390fd5b600954600160c01b900460ff1615611001576040516370d38fdb60e11b815260040160405180910390fd5b600c54336000908152600e602052604090206002015463ffffffff91821691168114611040576040516308018a9d60e11b815260040160405180910390fd5b336000908152600e60205260409020600101546001600160801b031683111561107c576040516308018a9d60e11b815260040160405180910390fd5b600061108784613146565b63ffffffff83166000908152600d60205260408120600201805492935083929091906110bd9084906001600160801b031661465a565b82546101009290920a6001600160801b03818102199093169183160217909155336000908152600e60205260408120600101805485945090926111029185911661465a565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550611131308486612427565b826001600160a01b03168263ffffffff16336001600160a01b03167f26691efbd563db4f0ef52c831c675b90138ae4905406c87c2b0f4563e1dd83a98760405161117d91815260200190565b60405180910390a450505050565b6001600160a01b03811633146112005760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610f7e82826131b3565b600033610b8481858561121d8383611c36565b611227919061467a565b611fe4565b61123760003361162a565b6112545760405163026a32f560e01b815260040160405180910390fd5b620f424061126860a08301608084016146a9565b61127860c0840160a085016146a9565b61128860608501604086016146a9565b61129860808601606087016146a9565b6112a291906146c6565b6112ac91906146c6565b6112b691906146c6565b62ffffff1611156112da5760405163390edff560e11b815260040160405180910390fd5b620f42406112ee60e0830160c084016146a9565b6112ff610100840160e085016146a9565b61130991906146c6565b62ffffff16111561132d5760405163390edff560e11b815260040160405180910390fd5b620f4240611343610120830161010084016146a9565b611355610140840161012085016146a9565b61135f91906146c6565b62ffffff1611156113835760405163390edff560e11b815260040160405180910390fd5b806006611390828261470f565b5050600c5460405163ffffffff9091169033907f20d90a0fb35da673e55fe1e68cfbd15031f646dfdb88fca5da5d5b5aa1737c9190610b6b9085906148bb565b6113db60003361162a565b6113f85760405163026a32f560e01b815260040160405180910390fd5b611404600a838361413d565b50600c5460405163ffffffff9091169033907fdbacfed7331c1f7d5ea718f12281a7cddbe34f9191280d075171555ae205556f9061144590869086906149a5565b60405180910390a35050565b60008061145d83611662565b915061146883610b8e565b9050915091565b600c546001600160a01b0382166000908152600e60205260408120600201549091829163ffffffff9081169116146114ac57506000928392509050565b50506001600160a01b03166000908152600e6020526040902080546001909101546001600160801b0391821692911690565b6001600160a01b031660009081526001602052604090205490565b611511600080516020614bdd8339815191523361162a565b61152e576040516312dd957560e31b815260040160405180910390fd5b6009805461ffff60a81b1916600160a81b86151590810260ff60b01b191691909117600160b01b8615159081029190911761ffff60b81b1916600160b81b86151590810260ff60c01b191691909117600160c01b86151590810291909117909455600c5460408051948552602085019390935291830152606082019290925263ffffffff9091169033907f756dd9c69469d2afa95e813c93b1b5e013030da6125e8deba169cac0b05be95b906080015b60405180910390a350505050565b6115f68282613218565b610f7e6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168284612b6a565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600580546109e2906145d3565b600061166d8261342c565b90508015610c3357610c336001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168383612b6a565b600033816116b78286611c36565b9050838110156117175760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016111f7565b6117248286868403611fe4565b506001949350505050565b600033610b84818585612427565b611755600080516020614bdd8339815191523361162a565b611772576040516312dd957560e31b815260040160405180910390fd5b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906370a08231906117c19030906004016141fc565b602060405180830381865afa1580156117de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061180291906149f3565b600b54909150829061182490600160801b90046001600160801b031683614a0c565b101561184357604051630de1bf7560e21b815260040160405180910390fd5b60095461187d906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488116911684612c9e565b6009546040516311f9fbc960e21b81526001600160a01b03909116906347e7ef24906118cf907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4890869060040161462b565b600060405180830381600087803b1580156118e957600080fd5b505af11580156118fd573d6000803e3d6000fd5b5050600c5460095460405163ffffffff90921693503392507f5d1dfc1839b0efecd070cb1dffe5619e5eee01414217e375af83ab539f86746991611445916001600160a01b031690879061462b565b600c54600090600160a01b900460ff16611979576040516362fa8aa560e01b815260040160405180910390fd5b6001600160a01b038216331461199457611994823385612da2565b61199e8284613516565b6010546001600160801b03600160801b82048116916119be911685614a1f565b6119c89190614a36565b90506119d381613146565b6001600160a01b0383166000908152600e602052604090206001018054601090611a0e908490600160801b90046001600160801b0316614a58565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555092915050565b600954600160b01b900460ff1615611a63576040516337ae717b60e01b815260040160405180910390fd5b600c54600160a01b900460ff1615611a8e576040516333cd40f760e21b815260040160405180910390fd5b600c54600160601b90046001600160401b0316421115611ac157604051631154791f60e31b815260040160405180910390fd5b6001600160a01b0381163314611adc57611adc813384612da2565b611ae7813084612427565b600c5463ffffffff166000611afb84613146565b63ffffffff83166000908152600d6020526040812060020180549293508392909190611b319084906001600160801b0316614a58565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550611b5e83612108565b6001600160a01b0383166000908152600e602052604081206001018054839290611b929084906001600160801b0316614a58565b82546101009290920a6001600160801b03818102199093169190921691909102179055506001600160a01b0383166000818152600e6020908152604091829020600201805463ffffffff191663ffffffff8716908117909155915187815233917f3810ab7906acf68459e21d2bda4204d1ea974be908fbafd94960af3e65f57406910161117d565b611c2382610f13565b611c2c816130b5565b610f9e83836131b3565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b611c79600080516020614bdd8339815191523361162a565b611c96576040516312dd957560e31b815260040160405180910390fd5b600b80546001600160801b0319166001600160801b038316908117909155600c5460405191825263ffffffff169033907fa16b5549c22000d0e01e72b956bb87da3bfe261ae97db12a513c1c8389415c4090602001610b6b565b611cfb60003361162a565b611d185760405163026a32f560e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b038316179055600c5460405163ffffffff9091169033907f176fab7d1785c2fd0f77b65b7bd24a50e28206d75f8f9cc841a6f73c339d6f8790610b6b9085906141fc565b6000611d7c33610b8e565b506000611d88336114de565b9050611d94813361194c565b50610f0c83611662565b611da960003361162a565b611dc65760405163026a32f560e01b815260040160405180910390fd5b6009805460ff60a01b1916600160a01b83151590810291909117909155600c5460405191825263ffffffff169033907f3b93f6236a5ca20626fa185941c647a5f2eb017a57d5e06f61a46026e0913a7490602001610b6b565b600c5460009063ffffffff1615611e5b57600080611e3d8585613652565b9092509050611e4c818361467a565b611e56908461467a565b925050505b600c5463ffffffff166000818152600d60205260409020600201546001600160801b031615611ee9576000611e99836001600160801b038716614a0c565b9050611ea460035490565b63ffffffff83166000908152600d6020526040902060020154611ed19083906001600160801b0316614a1f565b611edb9190614a36565b611ee5908461467a565b9250505b63ffffffff81166000908152600d60205260409020600101546001600160801b031615611fc65763ffffffff81166000908152600d60205260408120600101546007546001600160801b039091169190620f424090611f5490600160a01b900462ffffff1684614a1f565b611f5e9190614a36565b600754909150600090620f424090611f8290600160b81b900462ffffff1685614a1f565b611f8c9190614a36565b9050611f98818361467a565b611fa2908661467a565b945082851115611fbd57611fb68386614a0c565b9450611fc2565b600094505b5050505b5092915050565b6000611fd833611662565b90506109a38383610f3f565b6001600160a01b0383166120465760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016111f7565b6001600160a01b0382166120a75760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016111f7565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0381166000908152600e6020526040902060020154600c5463ffffffff9182169116811061213b575050565b6001600160a01b0382166000908152600e60205260409020546001600160801b0316156122a95763ffffffff81166000908152600d60209081526040808320600101546001600160a01b0386168452600e9092528220546001600160801b03808316926121b392600160801b90910482169116614a1f565b6121bd9190614a36565b90506121c881613146565b6001600160a01b0384166000908152600e602052604090208054601090612200908490600160801b90046001600160801b0316614a58565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b0385166000818152600e60205260409081902054905163ffffffff8716945091927fd9afe7596a53cbdd5895a926034be7e90058aeffbd6d142b7e4669c4cdeb59db9261227992909116908690614a78565b60405180910390a3506001600160a01b0382166000908152600e6020526040902080546001600160801b03191690555b6001600160a01b0382166000908152600e60205260409020600101546001600160801b031615610f7e5763ffffffff81166000908152600d60209081526040808320600201546001600160a01b0386168452600e9092528220600101546001600160801b038083169261232792600160801b90910482169116614a1f565b6123319190614a36565b905061233c81613146565b6001600160a01b0384166000908152600e602052604090206001018054601090612377908490600160801b90046001600160801b0316614a58565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b0385166000818152600e60205260409081902060010154905163ffffffff8716945091927f03d70ca23b379999d618a0b320f816f1bb4011e3d167124ee74ba6b67025ccc0926123f392909116908690614a78565b60405180910390a350506001600160a01b03166000908152600e6020526040902060010180546001600160801b0319169055565b6001600160a01b03831661248b5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016111f7565b6001600160a01b0382166124ed5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016111f7565b6001600160a01b038316600090815260016020526040902054818110156125655760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016111f7565b6001600160a01b0380851660009081526001602052604080822085850390559185168152908120805484929061259c90849061467a565b92505081905550826001600160a01b0316846001600160a01b0316600080516020614c1d833981519152846040516115de91815260200190565b50505050565b6000806125f7600080516020614bdd8339815191523361162a565b612614576040516312dd957560e31b815260040160405180910390fd5b6009546001600160a01b031661263d57604051633240c75d60e11b815260040160405180910390fd5b6006546001600160a01b031661266657604051633240c75d60e11b815260040160405180910390fd5b6007546001600160a01b031661268f57604051633240c75d60e11b815260040160405180910390fd5b600c54600160a01b900460ff16156126ba576040516333cd40f760e21b815260040160405180910390fd5b600c5463ffffffff8981169116146126e5576040516359d9c8e760e11b815260040160405180910390fd5b600c546001600160401b03600160201b9091048116908616111580612712575042856001600160401b0316115b15612730576040516306f0300360e01b815260040160405180910390fd5b63ffffffff88166000818152600d6020526040812080546001600160801b0319166001600160801b038b161790559081901561278e576127708988613652565b909250905061277f828561467a565b935061278b818461467a565b92505b6000836127a4866001600160801b038d16614a0c565b6127ae9190614a0c565b905060006127bb60035490565b90506000811180156127cb575081155b156127e957604051631a43347b60e01b815260040160405180910390fd5b80158015612816575063ffffffff8c166000908152600d60205260409020600101546001600160801b0316155b1561283457604051630558800760e21b815260040160405180910390fd5b61283d8261377c565b909450925061284c848761467a565b9550612858838661467a565b945086156129b457600c5463ffffffff166000908152600d6020526040902054600754620f4240600160801b9092046001600160801b0316600160d01b820462ffffff908116820284900493600160e81b90930416020490945092506128be848761467a565b95506128ca838661467a565b600c5463ffffffff166000908152600d602052604081205491965090612916908590612907908890600160801b90046001600160801b0316614a0c565b6129119190614a0c565b613146565b90506040518060400160405280826001600160801b0316815260200161293e61291160035490565b6001600160801b039081169091528151602090920151918116600160801b9282168302176010908155600b80548594919361297c9286920416614a58565b82546001600160801b039182166101009390930a92830291909202199091161790555050600c805460ff60a01b1916600160a01b1790555b80600003612a4557600f54604080516001600160801b038e811682528084166020830152600160801b909304831681830152918c1660608301526001600160401b038b811660808401528a1660a083015288151560c083015260e0820188905261010082018790525163ffffffff8e16913391600080516020614bfd833981519152918190036101200190a3612abe565b604080516001600160801b038d81168252602082018590528183018490528c1660608201526001600160401b038b811660808301528a1660a082015288151560c082015260e081018890526101008101879052905163ffffffff8e16913391600080516020614bfd833981519152918190036101200190a35b600c805463ffffffff16906000612ad483614a91565b82546101009290920a63ffffffff8181021990931691909216919091021790555050600c8054600b80546001600160801b0319166001600160801b039c909c169b909b17909a55600160201b600160a01b0319909916600160201b6001600160401b03998a1602600160601b600160a01b03191617600160601b9790981696909602969096179096559097909650945050505050565b610f9e8363a9059cbb60e01b8484604051602401612b8992919061462b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613b3e565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906370a0823190612c0f9030906004016141fc565b602060405180830381865afa158015612c2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c5091906149f3565b600b54909150600160801b90046001600160801b0316811015612c8657604051630de1bf7560e21b815260040160405180910390fd5b600b54600160801b90046001600160801b0316900390565b801580612d185750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612cf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1691906149f3565b155b612d835760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016111f7565b610f9e8363095ea7b360e01b8484604051602401612b8992919061462b565b6000612dae8484611c36565b905060001981146125d65781811015612e095760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016111f7565b6125d68484848403611fe4565b6125d6846323b872dd60e01b858585604051602401612b8993929190614607565b600954600160a81b900460ff1615612e6257604051633eca454160e21b815260040160405180910390fd5b600c54600160a01b900460ff1615612e8d576040516333cd40f760e21b815260040160405180910390fd5b600c54600160601b90046001600160401b0316421115612ec057604051631154791f60e31b815260040160405180910390fd5b600b54600c5463ffffffff166000908152600d60205260409020600101546001600160801b0391821691612ef591168461467a565b1115612f14576040516325d16c5160e01b815260040160405180910390fd5b612f1d81613c10565b612f3a57604051631e84063d60e21b815260040160405180910390fd5b600c5463ffffffff166000612f4e84613146565b63ffffffff83166000908152600d6020526040812060010180549293508392909190612f849084906001600160801b0316614a58565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555080600b60000160108282829054906101000a90046001600160801b0316612fcf9190614a58565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550612ffc83612108565b6001600160a01b0383166000908152600e60205260408120805483929061302d9084906001600160801b0316614a58565b82546101009290920a6001600160801b03818102199093169190921691909102179055506001600160a01b0383166000818152600e6020908152604091829020600201805463ffffffff191663ffffffff8716908117909155915187815233917fbfe5941e15cff302c0267251043bf2848ebc12b8259e8c065ba97644923497b5910161117d565b6130bf8133613cf0565b50565b6130cc828261162a565b610f7e576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556131023390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006001600160801b038211156131af5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b60648201526084016111f7565b5090565b6131bd828261162a565b15610f7e576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600c54600160601b90046001600160401b031642111561324b57604051631154791f60e31b815260040160405180910390fd5b600954600160b81b900460ff161561327657604051638da7160560e01b815260040160405180910390fd5b600c54336000908152600e602052604090206002015463ffffffff918216911681146132b557604051631648a98f60e31b815260040160405180910390fd5b336000908152600e60205260409020546001600160801b03168311156132ee57604051631648a98f60e31b815260040160405180910390fd5b60006132f984613146565b63ffffffff83166000908152600d602052604081206001018054929350839290919061332f9084906001600160801b031661465a565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555080600b60000160108282829054906101000a90046001600160801b031661337a919061465a565b82546101009290920a6001600160801b03818102199093169183160217909155336000908152600e60205260408120805485945090926133bc9185911661465a565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550826001600160a01b03168263ffffffff16336001600160a01b03167f52bcf77e4201d50a5a56cbac4a5eadb29047a1f2866e4896b737d2ab7ec06b498760405161117d91815260200190565b600061343733612108565b336000908152600e6020526040902060010154600160801b90046001600160801b031615610c335750336000908152600e6020526040902060010154600b80546001600160801b03600160801b9384900481169384939260109261349e928692041661465a565b82546101009290920a6001600160801b03818102199093169183160217909155336000818152600e60209081526040918290206001018054909416909355518481526001600160a01b038616935090917f1e82b8552efdf1dbc6131cc7346db181a113c1cf3885db8b7d9db0e60311a1079101610c2a565b6001600160a01b0382166135765760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016111f7565b6001600160a01b038216600090815260016020526040902054818110156135ea5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016111f7565b6001600160a01b0383166000908152600160205260408120838303905560038054849290613619908490614a0c565b90915550506040518281526000906001600160a01b03851690600080516020614c1d8339815191529060200160405180910390a3505050565b600c5460009081906001600160801b03851690829061368190600160201b90046001600160401b031686614ab4565b600854600c54651cae8c13e00062ffffff600160301b8404811687026001600160401b0386169081028390049950600160481b909404168602909202919091049450909150600d906000906136de9060019063ffffffff16614ad4565b63ffffffff168152602081019190915260400160002054600160801b90046001600160801b031682111561377357600c5463ffffffff90811660001901166000908152600d6020526040902054600854600160801b9091046001600160801b0316830390620f42409062ffffff1682026008549190049590950194620f4240906301000000900462ffffff1682020484019350505b50509250929050565b600c54600090819063ffffffff168161379460035490565b63ffffffff83166000908152600d602052604090206002015490915085906001600160801b03161561390b5763ffffffff83166000908152600d602052604081206002015483906137ee906001600160801b031689614a1f565b6137f89190614a36565b600754909150620f424062ffffff600160d01b83048116840282900492600160e81b90041683020461382e816129078486614a0c565b63ffffffff87166000908152600d6020526040902060020180546001600160801b03908116600160801b93821684021791829055600b805492849004821693909260109261387f9286920416614a58565b92506101000a8154816001600160801b0302191690836001600160801b031602179055506138ac83613146565b6138bf906001600160801b031685614a0c565b93506138cb828961467a565b97506138d7818861467a565b63ffffffff87166000908152600d60205260409020600201549097506139079030906001600160801b0316613516565b5050505b63ffffffff83166000908152600d60205260409020600101546001600160801b031615613af95763ffffffff83166000908152600d6020526040902060010154600754600b80546001600160801b0393841693620f424062ffffff600160a01b86048116870282900495600160b81b900416860204928592909160109161399b918591600160801b90041661465a565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508082846139cc9190614a0c565b6139d69190614a0c565b92506139e183613146565b6139f4906001600160801b03168561467a565b935084600003613a6657600f54613a2e906001600160801b0380821691613a2491600160801b9091041686614a1f565b6129119190614a36565b63ffffffff87166000908152600d6020526040902060010180546001600160801b03928316600160801b029216919091179055613aa8565b613a7489613a248786614a1f565b63ffffffff87166000908152600d6020526040902060010180546001600160801b03928316600160801b0292169190911790555b613ab2828961467a565b9750613abe818861467a565b63ffffffff87166000908152600d6020526040902060010154909750613af5903090600160801b90046001600160801b0316613d54565b5050505b613b0281613146565b63ffffffff9093166000908152600d6020526040902080546001600160801b03948516600160801b029416939093179092555091939092509050565b6000613b93826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613e219092919063ffffffff16565b805190915015610f9e5780806020019051810190613bb19190614af1565b610f9e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016111f7565b600954600090600160a01b900460ff1615613c2d57506001919050565b600a546000905b80821015613ce6576000600a8381548110613c5157613c51614b0e565b6000918252602090912001546040516370a0823160e01b81526001600160a01b03909116906370a0823190613c8a9088906004016141fc565b602060405180830381865afa158015613ca7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ccb91906149f3565b1115613cdb575060019392505050565b816001019150613c34565b5060009392505050565b613cfa828261162a565b610f7e57613d12816001600160a01b03166014613e38565b613d1d836020613e38565b604051602001613d2e929190614b24565b60408051601f198184030181529082905262461bcd60e51b82526111f791600401614234565b6001600160a01b038216613daa5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016111f7565b8060036000828254613dbc919061467a565b90915550506001600160a01b03821660009081526001602052604081208054839290613de990849061467a565b90915550506040518181526001600160a01b03831690600090600080516020614c1d8339815191529060200160405180910390a35050565b6060613e308484600085613fd3565b949350505050565b60606000613e47836002614a1f565b613e5290600261467a565b6001600160401b03811115613e6957613e69614b93565b6040519080825280601f01601f191660200182016040528015613e93576020820181803683370190505b509050600360fc1b81600081518110613eae57613eae614b0e565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613edd57613edd614b0e565b60200101906001600160f81b031916908160001a9053506000613f01846002614a1f565b613f0c90600161467a565b90505b6001811115613f84576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613f4057613f40614b0e565b1a60f81b828281518110613f5657613f56614b0e565b60200101906001600160f81b031916908160001a90535060049490941c93613f7d81614ba9565b9050613f0f565b508315610f0c5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016111f7565b6060824710156140345760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016111f7565b6001600160a01b0385163b61408b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016111f7565b600080866001600160a01b031685876040516140a79190614bc0565b60006040518083038185875af1925050503d80600081146140e4576040519150601f19603f3d011682016040523d82523d6000602084013e6140e9565b606091505b50915091506140f9828286614104565b979650505050505050565b60608315614113575081610f0c565b8251156141235782518084602001fd5b8160405162461bcd60e51b81526004016111f79190614234565b828054828255906000526020600020908101928215614190579160200282015b828111156141905781546001600160a01b0319166001600160a01b0384351617825560209092019160019091019061415d565b506131af9291505b808211156131af5760008155600101614198565b6000602082840312156141be57600080fd5b81356001600160e01b031981168114610f0c57600080fd5b6000602082840312156141e857600080fd5b5035919050565b6001600160a01b03169052565b6001600160a01b0391909116815260200190565b60005b8381101561422b578181015183820152602001614213565b50506000910152565b6020815260008251806020840152614253816040850160208701614210565b601f01601f19169190910160400192915050565b6001600160a01b03811681146130bf57600080fd5b8035610c3381614267565b6000806040838503121561429a57600080fd5b82356142a581614267565b946020939093013593505050565b6000602082840312156142c557600080fd5b8135610f0c81614267565b803563ffffffff81168114610c3357600080fd5b80356001600160801b0381168114610c3357600080fd5b80356001600160401b0381168114610c3357600080fd5b80151581146130bf57600080fd5b600080600080600080600060e0888a03121561433b57600080fd5b614344886142d0565b9650614352602089016142e4565b9550614360604089016142e4565b945061436e606089016142e4565b935061437c608089016142fb565b925061438a60a089016142fb565b915060c088013561439a81614312565b8091505092959891949750929550565b6000602082840312156143bc57600080fd5b610f0c826142fb565b6000806000606084860312156143da57600080fd5b83356143e581614267565b925060208401356143f581614267565b929592945050506040919091013590565b6000806040838503121561441957600080fd5b82359150602083013561442b81614267565b809150509250929050565b6000610140828403121561444957600080fd5b50919050565b6000806020838503121561446257600080fd5b82356001600160401b038082111561447957600080fd5b818501915085601f83011261448d57600080fd5b81358181111561449c57600080fd5b8660208260051b85010111156144b157600080fd5b60209290920196919550909350505050565b6000602082840312156144d557600080fd5b610f0c826142d0565b600080600080608085870312156144f457600080fd5b84356144ff81614312565b9350602085013561450f81614312565b9250604085013561451f81614312565b9150606085013561452f81614312565b939692955090935050565b6000806040838503121561454d57600080fd5b823561455881614267565b9150602083013561442b81614267565b60006020828403121561457a57600080fd5b610f0c826142e4565b60006020828403121561459557600080fd5b8135610f0c81614312565b600080604083850312156145b357600080fd5b6145bc836142e4565b91506145ca602084016142fb565b90509250929050565b600181811c908216806145e757607f821691505b60208210810361444957634e487b7160e01b600052602260045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052601160045260246000fd5b6001600160801b03828116828216039080821115611fc657611fc6614644565b808201808211156109a3576109a3614644565b62ffffff811681146130bf57600080fd5b8035610c338161468d565b6000602082840312156146bb57600080fd5b8135610f0c8161468d565b62ffffff818116838216019080821115611fc657611fc6614644565b80546001600160a01b0319166001600160a01b0392909216919091179055565b600081356109a38161468d565b813561471a81614267565b61472481836146e2565b5060018101602083013561473781614267565b61474181836146e2565b5060408301356147508161468d565b815462ffffff60a01b191660a09190911b62ffffff60a01b1617815561479d61477b60608501614702565b82805462ffffff60b81b191660b89290921b62ffffff60b81b16919091179055565b6147ce6147ac60808501614702565b82805462ffffff60d01b191660d09290921b62ffffff60d01b16919091179055565b6148016147dd60a08501614702565b8280546001600160e81b031660e89290921b6001600160e81b031916919091179055565b506002810161482a61481560c08501614702565b825462ffffff191662ffffff91909116178255565b61485761483960e08501614702565b825465ffffff000000191660189190911b65ffffff00000016178255565b6148896148676101008501614702565b82805462ffffff60301b191660309290921b62ffffff60301b16919091179055565b610f9e6148996101208501614702565b82805462ffffff60481b191660489290921b62ffffff60481b16919091179055565b61014081016148d2826148cd8561427c565b6141ef565b6148de6020840161427c565b6148eb60208401826141ef565b506148f86040840161469e565b62ffffff16604083015261490e6060840161469e565b62ffffff1660608301526149246080840161469e565b62ffffff16608083015261493a60a0840161469e565b62ffffff1660a083015261495060c0840161469e565b62ffffff1660c083015261496660e0840161469e565b62ffffff1660e083015261010061497e84820161469e565b62ffffff169083015261012061499584820161469e565b62ffffff16920191909152919050565b60208082528181018390526000908460408401835b868110156149e85782356149cd81614267565b6001600160a01b0316825291830191908301906001016149ba565b509695505050505050565b600060208284031215614a0557600080fd5b5051919050565b818103818111156109a3576109a3614644565b80820281158282048414176109a3576109a3614644565b600082614a5357634e487b7160e01b600052601260045260246000fd5b500490565b6001600160801b03818116838216019080821115611fc657611fc6614644565b6001600160801b03929092168252602082015260400190565b600063ffffffff808316818103614aaa57614aaa614644565b6001019392505050565b6001600160401b03828116828216039080821115611fc657611fc6614644565b63ffffffff828116828216039080821115611fc657611fc6614644565b600060208284031215614b0357600080fd5b8151610f0c81614312565b634e487b7160e01b600052603260045260246000fd5b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351614b56816017850160208801614210565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351614b87816028840160208801614210565b01602801949350505050565b634e487b7160e01b600052604160045260246000fd5b600081614bb857614bb8614644565b506000190190565b60008251614bd2818460208701614210565b919091019291505056fe59a1c48e5837ad7a7f3dcedcbe129bf3249ec4fbf651fd4f5e2600ead39fe2f59218348c215ae6efb0182d0a67ae857e1c1efadb71ca49e42fbebb0cefa34cedddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220a6a3cad834959ab805e2e963f45079911cb1671671694621fbc1b3c3edd114cb64736f6c63430008120033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.