Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
SingleAssetVaultV2
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 10 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; pragma abicoder v2; import "./SingleAssetVault.sol"; import "../interfaces/IStaking.sol"; /// @dev This version adds support for using "boosted" user balances. /// Boosted user balances will take user's staking balance into account. contract SingleAssetVaultV2 is SingleAssetVault { event StakingContractUpdated(address _staking); /// @dev Track the boosted balances for all users mapping(address => uint256) internal boostedUserBalances; /// @dev Track the total boosted balance uint256 internal totalBoostedBalance; /// @dev Struct to store the formula weights that is used to calculate the boosted balance. struct BoostFormulaWeights { uint128 vaultBalanceWeight; uint128 stakingBalanceWeight; } BoostFormulaWeights public boostFormulaWeights; /// @dev Address of the staking contract address public stakingContract; /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} function initializeV2( string memory _name, string memory _symbol, address _governance, address _gatekeeper, address _feeCollection, address _strategyDataStoreAddress, address _token, address _accessManager, address _vaultRewards, address _stakingContract ) external virtual initializer { __SingleAssetVaultV2_init( _name, _symbol, _governance, _gatekeeper, _feeCollection, _strategyDataStoreAddress, _token, _accessManager, _vaultRewards, _stakingContract ); } // solhint-disable-next-line func-name-mixedcase function __SingleAssetVaultV2_init( string memory _name, string memory _symbol, address _governance, address _gatekeeper, address _feeCollection, address _strategyDataStoreAddress, address _token, address _accessManager, address _vaultRewards, address _stakingContract ) internal { __SingleAssetVault_init( _name, _symbol, _governance, _gatekeeper, _feeCollection, _strategyDataStoreAddress, _token, _accessManager, _vaultRewards ); __SingleAssetVaultV2_init_unchained(_stakingContract); } function __SingleAssetVaultV2_init_unchained(address _stakingContract) internal { require(_stakingContract != address(0), "!staking"); stakingContract = _stakingContract; boostFormulaWeights.vaultBalanceWeight = 1; boostFormulaWeights.stakingBalanceWeight = 9; } function version() external pure virtual override returns (string memory) { return "0.2.0"; } /// @notice Query the boosted vault balance of the user. /// @dev If no boosted vault balance but there is a normal balance for the user, it means the boosted balance hasn't been inited yet. /// Return the normal balance to keep it backward compatible. /// @param _user the address of the user to query /// @return the boosted balance of the user function boostedBalanceOf(address _user) external view returns (uint256) { require(_user != address(0), "!user"); if (boostedUserBalances[_user] == 0 && balanceOf(_user) > 0) { return balanceOf(_user); } return boostedUserBalances[_user]; } /// @notice Return the total of boosted balances /// @dev If no total boosted balance but there is totalSupply, it means the boosted balance hasn't been inited yet. /// Return the normal totalSupply in this case. function totalBoostedSupply() external view returns (uint256) { if (totalBoostedBalance == 0 && totalSupply() > 0) { return totalSupply(); } return totalBoostedBalance; } /// @notice Set the address of the staking contract. Can only be called by governance. /// @dev This needs to be called after upgrading from v1 to v2 version to ensure the staking contract address is set. /// @param _stakingContract The address of the staking contract. function setStakingContract(address _stakingContract) external { _onlyGovernance(); require(_stakingContract != address(0), "!staking"); if (_stakingContract != stakingContract) { stakingContract = _stakingContract; emit StakingContractUpdated(_stakingContract); } } /// @notice Set the weight used to calculate the boosted balance. Can only be called by governance. /// @dev This needs to be called after upgrading from v1 to v2 version. /// Also once this is called, the `updateBoostedBalancesForUsers` should be called as well with all the vault user addresses to recalculate the boosted balances. function setBoostedFormulaWeights(uint128 _vaultWeight, uint128 _stakingWeight) external { _onlyGovernance(); boostFormulaWeights.vaultBalanceWeight = _vaultWeight; boostFormulaWeights.stakingBalanceWeight = _stakingWeight; } /// @notice Recalculate the boosted balances for the given array of users. /// @dev Before the boosted balance is updated for a user, it will also ensure the rewards up to this point is calculated for the user. /// This function must be called whenever `setBoostedFormulaWeights` is called to recalcuate the boosted balances for users. /// It can also be called at anytime afterwards to reset the boosted balances for a user (or users). function updateBoostedBalancesForUsers(address[] calldata _users) external { uint256 totalBalanceToReduce; uint256 totalBalanceToAdd; for (uint256 i = 0; i < _users.length; i++) { if (vaultRewards != address(0)) { IYOPRewards(vaultRewards).calculateVaultRewards(_users[i]); } uint256 oldBoostedBalance = boostedUserBalances[_users[i]]; uint256 newBoostedBalance = _calculateBoostedBalanceForUser(_users[i]); boostedUserBalances[_users[i]] = newBoostedBalance; totalBalanceToReduce += oldBoostedBalance; totalBalanceToAdd += newBoostedBalance; } // only update the storage value once at the end to save gas totalBoostedBalance = totalBoostedBalance - totalBalanceToReduce + totalBalanceToAdd; } /// @notice Returns the latest boosted balance of the user based on their latest staking and vault positions /// Use this function and boostedBalanceOf to check if a user's boosted balance should be updated /// @param _user the address of the user to query /// @return the latest boosted balance for the user function latestBoostedBalanceOf(address _user) external view returns (uint256) { return _calculateBoostedBalanceForUser(_user); } function _calculateBoostedBalanceForUser(address _user) internal view returns (uint256) { return VaultUtils.calculateBoostedVaultBalance( _user, stakingContract, address(this), boostFormulaWeights.vaultBalanceWeight, boostFormulaWeights.stakingBalanceWeight ); } /// @dev This hook is called by the OZ ERC20 contract after the user balance is updated. /// At this point we can update the boosted balance as well. function _afterTokenTransfer( address _from, address _to, uint256 ) internal virtual override { uint256 totalReduce; uint256 totalAdd; if (_from != address(0)) { uint256 newBoostedBalance = _calculateBoostedBalanceForUser(_from); uint256 oldBoostedBalance = boostedUserBalances[_from]; boostedUserBalances[_from] = newBoostedBalance; totalReduce += oldBoostedBalance; totalAdd += newBoostedBalance; } if (_to != address(0)) { uint256 newBoostedBalance = _calculateBoostedBalanceForUser(_to); uint256 oldBoostedBalance = boostedUserBalances[_to]; boostedUserBalances[_to] = newBoostedBalance; totalReduce += oldBoostedBalance; totalAdd += newBoostedBalance; } totalBoostedBalance = totalBoostedBalance - totalReduce + totalAdd; } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; pragma abicoder v2; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "../interfaces/IHealthCheck.sol"; import "../interfaces/IStrategy.sol"; import "../interfaces/IAccessControlManager.sol"; import "../interfaces/IFeeCollection.sol"; import "./SingleAssetVaultBase.sol"; /// @dev NOTE: do not add any new state variables to this contract. If needed, see {VaultDataStorage.sol} instead. contract SingleAssetVault is SingleAssetVaultBase, PausableUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; event StrategyReported( address indexed _strategyAddress, uint256 _gain, uint256 _loss, uint256 _debtPaid, uint256 _totalGain, uint256 _totalLoss, uint256 _totalDebt, uint256 _debtAdded, uint256 _debtRatio ); uint256 internal constant SECONDS_PER_YEAR = 31_556_952; // 365.2425 days string internal constant API_VERSION = "0.1.0"; // solhint-disable-next-line no-empty-blocks constructor() {} function initialize( string memory _name, string memory _symbol, address _governance, address _gatekeeper, address _feeCollection, address _strategyDataStoreAddress, address _token, address _accessManager, address _vaultRewards ) external initializer { __SingleAssetVault_init( _name, _symbol, _governance, _gatekeeper, _feeCollection, _strategyDataStoreAddress, _token, _accessManager, _vaultRewards ); } // solhint-disable-next-line func-name-mixedcase function __SingleAssetVault_init( string memory _name, string memory _symbol, address _governance, address _gatekeeper, address _feeCollection, address _strategyDataStoreAddress, address _token, address _accessManager, address _vaultRewards ) internal { __SingleAssetVaultBase_init( _name, _symbol, _governance, _gatekeeper, _feeCollection, _strategyDataStoreAddress, _token, _accessManager, _vaultRewards ); _pause(); } function version() external pure virtual returns (string memory) { return API_VERSION; } function pause() external { _onlyGovernanceOrGatekeeper(governance); _pause(); } function unpause() external { _onlyGovernance(); _unpause(); } /// @notice Deposits `_amount` `token`, issuing shares to `recipient`. If the /// Vault is in Emergency Shutdown, deposits will not be accepted and this /// call will fail. /// @dev Measuring quantity of shares to issues is based on the total /// outstanding debt that this contract has ("expected value") instead /// of the total balance sheet it has ("estimated value") has important /// security considerations, and is done intentionally. If this value were /// measured against external systems, it could be purposely manipulated by /// an attacker to withdraw more assets than they otherwise should be able /// to claim by redeeming their shares. /// On deposit, this means that shares are issued against the total amount /// that the deposited capital can be given in service of the debt that /// Strategies assume. If that number were to be lower than the "expected /// value" at some future point, depositing shares via this method could /// entitle the depositor to *less* than the deposited value once the /// "realized value" is updated from further reports by the Strategies /// to the Vaults. /// Care should be taken by integrators to account for this discrepancy, /// by using the view-only methods of this contract (both off-chain and /// on-chain) to determine if depositing into the Vault is a "good idea". /// @param _amount The quantity of tokens to deposit, defaults to all. /// caller's address. /// @param _recipient the address that will receive the vault shares /// @return The issued Vault shares. function deposit(uint256 _amount, address _recipient) external whenNotPaused nonReentrant returns (uint256) { _onlyNotEmergencyShutdown(); return _deposit(_amount, _recipient); } /// @notice Withdraws the calling account's tokens from this Vault, redeeming /// amount `_shares` for an appropriate amount of tokens. /// See note on `setWithdrawalQueue` for further details of withdrawal /// ordering and behavior. /// @dev Measuring the value of shares is based on the total outstanding debt /// that this contract has ("expected value") instead of the total balance /// sheet it has ("estimated value") has important security considerations, /// and is done intentionally. If this value were measured against external /// systems, it could be purposely manipulated by an attacker to withdraw /// more assets than they otherwise should be able to claim by redeeming /// their shares. /// On withdrawal, this means that shares are redeemed against the total /// amount that the deposited capital had "realized" since the point it /// was deposited, up until the point it was withdrawn. If that number /// were to be higher than the "expected value" at some future point, /// withdrawing shares via this method could entitle the depositor to /// *more* than the expected value once the "realized value" is updated /// from further reports by the Strategies to the Vaults. /// Under exceptional scenarios, this could cause earlier withdrawals to /// earn "more" of the underlying assets than Users might otherwise be /// entitled to, if the Vault's estimated value were otherwise measured /// through external means, accounting for whatever exceptional scenarios /// exist for the Vault (that aren't covered by the Vault's own design.) /// In the situation where a large withdrawal happens, it can empty the /// vault balance and the strategies in the withdrawal queue. /// Strategies not in the withdrawal queue will have to be harvested to /// rebalance the funds and make the funds available again to withdraw. /// @param _maxShares How many shares to try and redeem for tokens, defaults to all. /// @param _recipient The address to issue the shares in this Vault to. /// @param _maxLoss The maximum acceptable loss to sustain on withdrawal in basis points. /// @return The quantity of tokens redeemed for `_shares`. function withdraw( uint256 _maxShares, address _recipient, uint256 _maxLoss ) external whenNotPaused nonReentrant returns (uint256) { _onlyNotEmergencyShutdown(); return _withdraw(_maxShares, _recipient, _maxLoss); } /// @notice Reports the amount of assets the calling Strategy has free (usually in terms of ROI). /// The performance fee is determined here, off of the strategy's profits /// (if any), and sent to governance. /// The strategist's fee is also determined here (off of profits), to be /// handled according to the strategist on the next harvest. /// This may only be called by a Strategy managed by this Vault. /// @dev For approved strategies, this is the most efficient behavior. /// The Strategy reports back what it has free, then Vault "decides" /// whether to take some back or give it more. Note that the most it can /// take is `gain + _debtPayment`, and the most it can give is all of the /// remaining reserves. Anything outside of those bounds is abnormal behavior. /// All approved strategies must have increased diligence around /// calling this function, as abnormal behavior could become catastrophic. /// @param _gain Amount Strategy has realized as a gain on it's investment since its last report, and is free to be given back to Vault as earnings /// @param _loss Amount Strategy has realized as a loss on it's investment since its last report, and should be accounted for on the Vault's balance sheet. /// The loss will reduce the debtRatio. The next time the strategy will harvest, it will pay back the debt in an attempt to adjust to the new debt limit. /// @param _debtPayment Amount Strategy has made available to cover outstanding debt /// @return Amount of debt outstanding (if totalDebt > debtLimit or emergency shutdown). function report( uint256 _gain, uint256 _loss, uint256 _debtPayment ) external returns (uint256) { address strat = _msgSender(); _validateStrategy(strat); require(token.balanceOf(strat) >= (_gain + _debtPayment), "!balance"); VaultUtils.checkStrategyHealth( healthCheck, strat, _gain, _loss, _debtPayment, _debtOutstanding(strat), strategies[strat].totalDebt ); totalDebt = VaultUtils.reportLoss(strategies, strat, totalDebt, _strategyDataStore(), _loss); // Returns are always "realized gains" strategies[strat].totalGain = strategies[strat].totalGain + _gain; // Assess both management fee and performance fee, and issue both as shares of the vault uint256 totalFees = VaultUtils.assessFees( token, feeCollection, strategies, strat, _gain, managementFee, _strategyDataStore().strategyPerformanceFee(address(this), strat) ); // Compute the line of credit the Vault is able to offer the Strategy (if any) uint256 credit = _creditAvailable(strat); // Outstanding debt the Strategy wants to take back from the Vault (if any) // NOTE: debtOutstanding <= StrategyInfo.totalDebt uint256 debt = _debtOutstanding(strat); uint256 debtPayment = Math.min(debt, _debtPayment); if (debtPayment > 0) { _decreaseDebt(strat, debtPayment); debt = debt - debtPayment; } // Update the actual debt based on the full credit we are extending to the Strategy // or the returns if we are taking funds back // NOTE: credit + self.strategies[msg.sender].totalDebt is always < self.debtLimit // NOTE: At least one of `credit` or `debt` is always 0 (both can be 0) if (credit > 0) { _increaseDebt(strat, credit); } // Give/take balance to Strategy, based on the difference between the reported gains // (if any), the debt payment (if any), the credit increase we are offering (if any), // and the debt needed to be paid off (if any) // NOTE: This is just used to adjust the balance of tokens between the Strategy and // the Vault based on the Strategy's debt limit (as well as the Vault's). uint256 totalAvailable = _gain + debtPayment; if (totalAvailable < credit) { // credit surplus, give to Strategy token.safeTransfer(strat, credit - totalAvailable); } else if (totalAvailable > credit) { // credit deficit, take from Strategy token.safeTransferFrom(strat, address(this), totalAvailable - credit); } // else, don't do anything because it is balanced _updateLockedProfit(_gain, totalFees, _loss); // solhint-disable-next-line not-rely-on-time strategies[strat].lastReport = block.timestamp; // solhint-disable-next-line not-rely-on-time lastReport = block.timestamp; StrategyInfo memory info = strategies[strat]; uint256 ratio = _strategyDataStore().strategyDebtRatio(address(this), strat); emit StrategyReported( strat, _gain, _loss, debtPayment, info.totalGain, info.totalLoss, info.totalDebt, credit, ratio ); if (ratio == 0 || emergencyShutdown) { // Take every last penny the Strategy has (Emergency Exit/revokeStrategy) // NOTE: This is different than `debt` in order to extract *all* of the returns return IStrategy(strat).estimatedTotalAssets(); } else { // Otherwise, just return what we have as debt outstanding return debt; } } function _deposit(uint256 _amount, address _recipient) internal returns (uint256) { require(_recipient != address(0), "!recipient"); if (accessManager != address(0)) { require(IAccessControlManager(accessManager).hasAccess(_msgSender(), address(this)), "!access"); } //TODO: do we also want to cap the `_amount` too? uint256 amount = _ensureValidDepositAmount(_msgSender(), _amount); uint256 shares = _issueSharesForAmount(_recipient, amount); token.safeTransferFrom(_msgSender(), address(this), amount); return shares; } function _issueSharesForAmount(address _recipient, uint256 _amount) internal returns (uint256) { uint256 supply = totalSupply(); uint256 shares = supply > 0 ? (_amount * supply) / _freeFunds() : _amount; require(shares > 0, "!amount"); // _mint will call '_beforeTokenTransfer' which will call "calculateRewards" on the YOPVaultRewards contract _mint(_recipient, shares); return shares; } function _withdraw( uint256 _maxShares, address _recipient, uint256 _maxLoss ) internal returns (uint256) { require(_recipient != address(0), "!recipient"); require(_maxLoss <= MAX_BASIS_POINTS, "!loss"); uint256 shares = _ensureValidShares(_msgSender(), _maxShares); uint256 value = _shareValue(shares); uint256 vaultBalance = token.balanceOf(address(this)); uint256 totalLoss = 0; if (value > vaultBalance) { // We need to go get some from our strategies in the withdrawal queue // NOTE: This performs forced withdrawals from each Strategy. During // forced withdrawal, a Strategy may realize a loss. That loss // is reported back to the Vault, and the will affect the amount // of tokens that the withdrawer receives for their shares. They // can optionally specify the maximum acceptable loss (in BPS) // to prevent excessive losses on their withdrawals (which may // happen in certain edge cases where Strategies realize a loss) totalLoss = _withdrawFromStrategies(value); if (totalLoss > 0) { value = value - totalLoss; } vaultBalance = token.balanceOf(address(this)); } // NOTE: We have withdrawn everything possible out of the withdrawal queue, // but we still don't have enough to fully pay them back, so adjust // to the total amount we've freed up through forced withdrawals if (value > vaultBalance) { value = vaultBalance; // NOTE: Burn # of shares that corresponds to what Vault has on-hand, // including the losses that were incurred above during withdrawals shares = _sharesForAmount(value + totalLoss); } // NOTE: This loss protection is put in place to revert if losses from // withdrawing are more than what is considered acceptable. require(totalLoss <= (_maxLoss * (value + totalLoss)) / MAX_BASIS_POINTS, "loss limit"); // burn shares // _burn will call '_beforeTokenTransfer' which will call "calculateRewards" on the YOPVaultRewards contract _burn(_msgSender(), shares); // Withdraw remaining balance to _recipient (may be different to msg.sender) (minus fee) token.safeTransfer(_recipient, value); return value; } function _withdrawFromStrategies(uint256 _withdrawValue) internal returns (uint256) { uint256 totalLoss = 0; uint256 value = _withdrawValue; address[] memory withdrawQueue = _strategyDataStore().withdrawQueue(address(this)); for (uint256 i = 0; i < withdrawQueue.length; i++) { address strategyAddress = withdrawQueue[i]; IStrategy strategyToWithdraw = IStrategy(strategyAddress); uint256 vaultBalance = token.balanceOf(address(this)); if (value <= vaultBalance) { // there are enough tokens in the vault now, no need to continue break; } // NOTE: Don't withdraw more than the debt so that Strategy can still // continue to work based on the profits it has // NOTE: This means that user will lose out on any profits that each // Strategy in the queue would return on next harvest, benefiting others uint256 amountNeeded = Math.min(value - vaultBalance, strategies[strategyAddress].totalDebt); if (amountNeeded == 0) { // nothing to withdraw from the strategy, try the next one continue; } uint256 loss = strategyToWithdraw.withdraw(amountNeeded); uint256 withdrawAmount = token.balanceOf(address(this)) - vaultBalance; if (loss > 0) { value = value - loss; totalLoss = totalLoss + loss; totalDebt = VaultUtils.reportLoss(strategies, strategyAddress, totalDebt, _strategyDataStore(), loss); } // Reduce the Strategy's debt by the amount withdrawn ("realized returns") // NOTE: This doesn't add to returns as it's not earned by "normal means" _decreaseDebt(strategyAddress, withdrawAmount); } return totalLoss; } function _ensureValidShares(address _account, uint256 _shares) internal view returns (uint256) { uint256 shares = Math.min(_shares, balanceOf(_account)); require(shares > 0, "!shares"); return shares; } function _increaseDebt(address _strategy, uint256 _amount) internal { strategies[_strategy].totalDebt = strategies[_strategy].totalDebt + _amount; totalDebt = totalDebt + _amount; } function _decreaseDebt(address _strategy, uint256 _amount) internal { strategies[_strategy].totalDebt = strategies[_strategy].totalDebt - _amount; totalDebt = totalDebt - _amount; } function _ensureValidDepositAmount(address _account, uint256 _amount) internal view returns (uint256) { uint256 amount = Math.min(_amount, token.balanceOf(_account)); amount = Math.min(amount, _availableDepositLimit()); require(amount > 0, "!amount"); return amount; } function _updateLockedProfit( uint256 _gain, uint256 _totalFees, uint256 _loss ) internal { // Profit is locked and gradually released per block // NOTE: compute current locked profit and replace with sum of current and new uint256 locakedProfileBeforeLoss = _calculateLockedProfit() + _gain - _totalFees; if (locakedProfileBeforeLoss > _loss) { lockedProfit = locakedProfileBeforeLoss - _loss; } else { lockedProfit = 0; } } // solhint-disable-next-line no-unused-vars function _authorizeUpgrade(address) internal view override { _onlyGovernance(); } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; interface IStaking { function totalWorkingSupply() external view returns (uint256); function workingBalanceOf(address _user) external view returns (uint256); } interface IStakingV2 { function stakeForUser( uint248 _amount, uint8 _lockPeriod, address _to ) external returns (uint256); function stakeAndBoostForUser( uint248 _amount, uint8 _lockPeriod, address _to, address[] calldata _vaultsToBoost ) external returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable 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( IERC20Upgradeable 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( IERC20Upgradeable 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( IERC20Upgradeable 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)); } } /** * @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(IERC20Upgradeable 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 v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { __ERC1967Upgrade_init_unchained(); __UUPSUpgradeable_init_unchained(); } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; interface IHealthCheck { function check( address callerStrategy, uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding, uint256 totalDebt ) external view returns (bool); function doHealthCheck(address _strategy) external view returns (bool); function enableCheck(address _strategy) external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IStrategy { // *** Events *** // event Harvested(uint256 _profit, uint256 _loss, uint256 _debtPayment, uint256 _debtOutstanding); event StrategistUpdated(address _newStrategist); event KeeperUpdated(address _newKeeper); event MinReportDelayUpdated(uint256 _delay); event MaxReportDelayUpdated(uint256 _delay); event ProfitFactorUpdated(uint256 _profitFactor); event DebtThresholdUpdated(uint256 _debtThreshold); event EmergencyExitEnabled(); // *** The following functions are used by the Vault *** // /// @notice returns the address of the token that the strategy wants function want() external view returns (IERC20); /// @notice the address of the Vault that the strategy belongs to function vault() external view returns (address); /// @notice if the strategy is active function isActive() external view returns (bool); /// @notice migrate the strategy to the new one function migrate(address _newStrategy) external; /// @notice withdraw the amount from the strategy function withdraw(uint256 _amount) external returns (uint256); /// @notice the amount of total assets managed by this strategy that should not account towards the TVL of the strategy function delegatedAssets() external view returns (uint256); /// @notice the total assets that the strategy is managing function estimatedTotalAssets() external view returns (uint256); // *** public read functions that can be called by anyone *** // function name() external view returns (string memory); function harvester() external view returns (address); function strategyProposer() external view returns (address); function strategyDeveloper() external view returns (address); function tendTrigger(uint256 _callCost) external view returns (bool); function harvestTrigger(uint256 _callCost) external view returns (bool); // *** write functions that can be called by the governance, the strategist or the keeper *** // function tend() external; function harvest() external; // *** write functions that can be called by the governance or the strategist ***// function setHarvester(address _havester) external; function setVault(address _vault) external; /// @notice `minReportDelay` is the minimum number of blocks that should pass for `harvest()` to be called. function setMinReportDelay(uint256 _delay) external; function setMaxReportDelay(uint256 _delay) external; /// @notice `profitFactor` is used to determine if it's worthwhile to harvest, given gas costs. function setProfitFactor(uint256 _profitFactor) external; /// @notice Sets how far the Strategy can go into loss without a harvest and report being required. function setDebtThreshold(uint256 _debtThreshold) external; // *** write functions that can be called by the governance, or the strategist, or the guardian, or the management *** // function setEmergencyExit() external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; interface IAccessControlManager { function hasAccess(address _user, address _vault) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; interface IFeeCollection { function collectManageFee(uint256 _amount) external; function collectPerformanceFee(address _strategy, uint256 _amount) external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; pragma abicoder v2; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "./BaseVault.sol"; import "../libraries/VaultUtils.sol"; /// @dev NOTE: do not add any new state variables to this contract. If needed, see {VaultDataStorage.sol} instead. abstract contract SingleAssetVaultBase is BaseVault { using SafeERC20Upgradeable for IERC20Upgradeable; // solhint-disable-next-line no-empty-blocks constructor() {} // solhint-disable-next-line func-name-mixedcase function __SingleAssetVaultBase_init_unchained(address _token) internal { require(_token != address(0), "!token"); token = IERC20Upgradeable(_token); // the vault decimals need to match the tokens to avoid any conversion vaultDecimals = ERC20Upgradeable(address(token)).decimals(); } // solhint-disable-next-line func-name-mixedcase function __SingleAssetVaultBase_init( string memory _name, string memory _symbol, address _governance, address _gatekeeper, address _feeCollection, address _strategyDataStoreAddress, address _token, address _accessManager, address _vaultRewards ) internal { __BaseVault__init( _name, _symbol, _governance, _gatekeeper, _feeCollection, _strategyDataStoreAddress, _accessManager, _vaultRewards ); __SingleAssetVaultBase_init_unchained(_token); } /// @notice Returns the total quantity of all assets under control of this /// Vault, whether they're loaned out to a Strategy, or currently held in /// the Vault. /// @return The total assets under control of this Vault. function totalAsset() external view returns (uint256) { return _totalAsset(); } /// @notice the remaining amount of underlying tokens that still can be deposited into the vault before reaching the limit function availableDepositLimit() external view returns (uint256) { return _availableDepositLimit(); } /// @notice Determines the maximum quantity of shares this Vault can facilitate a /// withdrawal for, factoring in assets currently residing in the Vault, /// as well as those deployed to strategies on the Vault's balance sheet. /// @dev Regarding how shares are calculated, see dev note on `deposit`. /// If you want to calculated the maximum a user could withdraw up to, /// you want to use this function. /// Note that the amount provided by this function is the theoretical /// maximum possible from withdrawing, the real amount depends on the /// realized losses incurred during withdrawal. /// @return The total quantity of shares this Vault can provide. function maxAvailableShares() external view returns (uint256) { return _maxAvailableShares(); } /// @notice Gives the price for a single Vault share. /// @dev See dev note on `withdraw`. /// @return The value of a single share. function pricePerShare() external view returns (uint256) { return _shareValue(10**vaultDecimals); } /// @notice Determines if `_strategy` is past its debt limit and if any tokens /// should be withdrawn to the Vault. /// @param _strategy The Strategy to check. /// @return The quantity of tokens to withdraw. function debtOutstanding(address _strategy) external view returns (uint256) { return _debtOutstanding(_strategy); } /// @notice Amount of tokens in Vault a Strategy has access to as a credit line. /// This will check the Strategy's debt limit, as well as the tokens /// available in the Vault, and determine the maximum amount of tokens /// (if any) the Strategy may draw on. /// In the rare case the Vault is in emergency shutdown this will return 0. /// @param _strategy The Strategy to check. /// @return The quantity of tokens available for the Strategy to draw on. function creditAvailable(address _strategy) external view returns (uint256) { return _creditAvailable(_strategy); } /// @notice Provide an accurate expected value for the return this `strategy` /// would provide to the Vault the next time `report()` is called /// (since the last time it was called). /// @param _strategy The Strategy to determine the expected return for. /// @return The anticipated amount `strategy` should make on its investment since its last report. function expectedReturn(address _strategy) external view returns (uint256) { return _expectedReturn(_strategy); } /// @notice send the tokens that are not managed by the vault to the governance /// @param _token the token to send /// @param _amount the amount of tokens to send function sweep(address _token, uint256 _amount) external { _onlyGovernance(); require(address(token) != _token, "!token"); _sweep(_token, _amount, governance); } function _totalAsset() internal view returns (uint256) { return token.balanceOf(address(this)) + totalDebt; } function _availableDepositLimit() internal view returns (uint256) { return depositLimit > _totalAsset() ? depositLimit - _totalAsset() : 0; } function _shareValue(uint256 _sharesAmount) internal view returns (uint256) { uint256 supply = totalSupply(); // if the value is empty then the price is 1:1 return supply == 0 ? _sharesAmount : (_sharesAmount * _freeFunds()) / supply; } function _calculateLockedProfit() internal view returns (uint256) { // solhint-disable-next-line not-rely-on-time uint256 lockedFundRatio = (block.timestamp - lastReport) * lockedProfitDegradation; return lockedFundRatio < DEGRADATION_COEFFICIENT ? lockedProfit - (lockedFundRatio * lockedProfit) / DEGRADATION_COEFFICIENT : 0; } function _freeFunds() internal view returns (uint256) { return _totalAsset() - _calculateLockedProfit(); } function _sharesForAmount(uint256 _amount) internal view returns (uint256) { uint256 freeFunds_ = _freeFunds(); return freeFunds_ > 0 ? (_amount * totalSupply()) / freeFunds_ : 0; } function _maxAvailableShares() internal view returns (uint256) { uint256 shares_ = _sharesForAmount(token.balanceOf(address(this))); address[] memory withdrawQueue = _strategyDataStore().withdrawQueue(address(this)); for (uint256 i = 0; i < withdrawQueue.length; i++) { shares_ = shares_ + _sharesForAmount(strategies[withdrawQueue[i]].totalDebt); } return shares_; } function _debtOutstanding(address _strategy) internal view returns (uint256) { _validateStrategy(_strategy); return VaultUtils.debtOutstanding(emergencyShutdown, _totalAsset(), _strategyDataStore(), strategies, _strategy); } function _creditAvailable(address _strategy) internal view returns (uint256) { if (emergencyShutdown) { return 0; } _validateStrategy(_strategy); return VaultUtils.creditAvailable(token, _totalAsset(), totalDebt, _strategyDataStore(), strategies, _strategy); } function _expectedReturn(address _strategy) internal view returns (uint256) { _validateStrategy(_strategy); return VaultUtils.expectedReturn(strategies, _strategy); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 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 Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal onlyInitializing { __ERC1967Upgrade_init_unchained(); } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; _functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @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) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { 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. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _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: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, 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}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), 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}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][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) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * 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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, 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 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 {} uint256[45] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; pragma abicoder v2; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "../interfaces/IStrategy.sol"; import "../interfaces/IVaultStrategyDataStore.sol"; import "../interfaces/IYOPRewards.sol"; import "./VaultMetaDataStore.sol"; import "../interfaces/IVault.sol"; /// @dev This contract is marked abstract to avoid being used directly. /// NOTE: do not add any new state variables to this contract. If needed, see {VaultDataStorage.sol} instead. abstract contract BaseVault is ERC20PermitUpgradeable, VaultMetaDataStore { using SafeERC20Upgradeable for IERC20Upgradeable; event StrategyAdded(address indexed _strategy); event StrategyMigrated(address indexed _oldVersion, address indexed _newVersion); event StrategyRevoked(address indexed _strategy); // solhint-disable-next-line no-empty-blocks constructor() {} // solhint-disable-next-line function __BaseVault__init_unchained() internal {} // solhint-disable-next-line func-name-mixedcase function __BaseVault__init( string memory _name, string memory _symbol, address _governance, address _gatekeeper, address _feeCollection, address _strategyDataStoreAddress, address _accessManager, address _vaultRewards ) internal { __ERC20_init(_name, _symbol); __ERC20Permit_init(_name); __VaultMetaDataStore_init( _governance, _gatekeeper, _feeCollection, _strategyDataStoreAddress, _accessManager, _vaultRewards ); __BaseVault__init_unchained(); } /// @notice returns decimals value of the vault function decimals() public view override returns (uint8) { return vaultDecimals; } /// @notice Init a new strategy. This should only be called by the {VaultStrategyDataStore} and should not be invoked manually. /// Use {VaultStrategyDataStore.addStrategy} to manually add a strategy to a Vault. /// @dev This will be called by the {VaultStrategyDataStore} when a strategy is added to a given Vault. function addStrategy(address _strategy) external virtual returns (bool) { _onlyNotEmergencyShutdown(); _onlyStrategyDataStore(); return _addStrategy(_strategy); } /// @notice Migrate a new strategy. This should only be called by the {VaultStrategyDataStore} and should not be invoked manually. /// Use {VaultStrategyDataStore.migrateStrategy} to manually migrate a strategy for a Vault. /// @dev This will called be the {VaultStrategyDataStore} when a strategy is migrated. /// This will then call the strategy to migrate (as the strategy only allows the vault to call the migrate function). function migrateStrategy(address _oldVersion, address _newVersion) external virtual returns (bool) { _onlyStrategyDataStore(); return _migrateStrategy(_oldVersion, _newVersion); } /// @notice called by the strategy to revoke itself. Should not be called by any other means. /// Use {VaultStrategyDataStore.revokeStrategy} to revoke a strategy manually. /// @dev The strategy could talk to the {VaultStrategyDataStore} directly when revoking itself. /// However, that means we will need to change the interfaces to Strategies and make them incompatible with Yearn's strategies. /// To avoid that, the strategies will continue talking to the Vault and the Vault will then let the {VaultStrategyDataStore} know. function revokeStrategy() external { _validateStrategy(_msgSender()); _strategyDataStore().revokeStrategyByStrategy(_msgSender()); emit StrategyRevoked(_msgSender()); } function strategy(address _strategy) external view returns (StrategyInfo memory) { return strategies[_strategy]; } function strategyDebtRatio(address _strategy) external view returns (uint256) { return _strategyDataStore().strategyDebtRatio(address(this), _strategy); } /// @dev It doesn't inherit openzepplin's ERC165 implementation to save on contract size /// but it is compatible with ERC165 function supportsInterface(bytes4 _interfaceId) external view virtual returns (bool) { // 0x01ffc9a7 is the interfaceId of IERC165 itself return _interfaceId == type(IVault).interfaceId || _interfaceId == 0x01ffc9a7; } /// @dev This is called when tokens are minted, transferred or burned by the ERC20 implementation from openzeppelin // solhint-disable-next-line no-unused-vars function _beforeTokenTransfer( address _from, address _to, uint256 ) internal override { if (_from == address(0)) { // this is a mint event, track block time for the account dt[_to] = block.number; } else { // this is a transfer or burn event, make sure it is at least 1 block later from deposit to prevent flash loan // this will cause a small issue that if a user minted some tokens before, and then mint some more and withdraw (burn) or transfer previously minted tokens in the same block, this will fail. // But it should not be a issue for majority of users and it does prevent flash loan require(block.number > dt[_from], "!block"); } if (vaultRewards != address(0)) { if (_from != address(0)) { IYOPRewards(vaultRewards).calculateVaultRewards(_from); } if (_to != address(0)) { IYOPRewards(vaultRewards).calculateVaultRewards(_to); } } } function _strategyDataStore() internal view returns (IVaultStrategyDataStore) { return IVaultStrategyDataStore(strategyDataStore); } function _onlyStrategyDataStore() internal view { require(_msgSender() == strategyDataStore, "!strategyStore"); } /// @dev ensure the vault is not in emergency shutdown mode function _onlyNotEmergencyShutdown() internal view { require(emergencyShutdown == false, "emergency shutdown"); } function _validateStrategy(address _strategy) internal view { require(strategies[_strategy].activation > 0, "!strategy"); } function _addStrategy(address _strategy) internal returns (bool) { /* solhint-disable not-rely-on-time */ strategies[_strategy] = StrategyInfo({ activation: block.timestamp, lastReport: block.timestamp, totalDebt: 0, totalGain: 0, totalLoss: 0 }); emit StrategyAdded(_strategy); return true; /* solhint-enable */ } function _migrateStrategy(address _oldVersion, address _newVersion) internal returns (bool) { StrategyInfo memory info = strategies[_oldVersion]; strategies[_oldVersion].totalDebt = 0; strategies[_newVersion] = StrategyInfo({ activation: info.activation, lastReport: info.lastReport, totalDebt: info.totalDebt, totalGain: 0, totalLoss: 0 }); IStrategy(_oldVersion).migrate(_newVersion); emit StrategyMigrated(_oldVersion, _newVersion); return true; } function _sweep( address _token, uint256 _amount, address _to ) internal { IERC20Upgradeable token_ = IERC20Upgradeable(_token); _amount = Math.min(_amount, token_.balanceOf(address(this))); token_.safeTransfer(_to, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; import "@openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "../interfaces/IStaking.sol"; import "../interfaces/IVault.sol"; import "../interfaces/IHealthCheck.sol"; import "../interfaces/IStrategy.sol"; import "../interfaces/IFeeCollection.sol"; import "../interfaces/IVaultStrategyDataStore.sol"; ///@dev This library will include some of the stateless functions used by the SingleAssetVault /// The main reason to put these function in the library is to reduce the size of the main contract library VaultUtils { uint256 internal constant SECONDS_PER_YEAR = 31_556_952; // 365.2425 days uint256 internal constant MAX_BASIS_POINTS = 10_000; function calculateBoostedVaultBalance( address _user, address _stakingContract, address _vaultContract, uint128 _vaultBalanceWeight, uint128 _stakingBalanceWeight ) external view returns (uint256) { uint256 stakingPoolSize = IStaking(_stakingContract).workingBalanceOf(_user); uint256 totalStakingSize = IStaking(_stakingContract).totalWorkingSupply(); uint256 userVaultBalance = IVault(_vaultContract).balanceOf(_user); uint256 totalVaultSize = IVault(_vaultContract).totalSupply(); uint128 totalWeight = _vaultBalanceWeight + _stakingBalanceWeight; // boostedBalance = min(1 * userVaultBalance + 9 * stakingPoolSize/totalStakingSize*totalVaultSize, 10 * userVaultBalance); return Math.min( _vaultBalanceWeight * userVaultBalance + (totalStakingSize == 0 ? 0 : ((_stakingBalanceWeight * stakingPoolSize * totalVaultSize) / totalStakingSize)), totalWeight * userVaultBalance ); } function checkStrategyHealth( address _healthCheck, address _strategy, uint256 _gain, uint256 _loss, uint256 _debtPayment, uint256 _debtOutstanding, uint256 _totalDebt ) external { if (_healthCheck != address(0)) { IHealthCheck check = IHealthCheck(_healthCheck); if (check.doHealthCheck(_strategy)) { require(check.check(_strategy, _gain, _loss, _debtPayment, _debtOutstanding, _totalDebt), "!healthy"); } else { check.enableCheck(_strategy); } } } function assessManagementFee( uint256 _lastReport, uint256 _totalDebt, uint256 _delegateAssets, uint256 _managementFee ) public view returns (uint256) { // solhint-disable-next-line not-rely-on-time uint256 duration = block.timestamp - _lastReport; require(duration > 0, "!block"); // should not be called twice within the same block // the managementFee is per year, so only charge the management fee for the period since last time it is charged. if (_managementFee > 0) { uint256 strategyTVL = _totalDebt - _delegateAssets; return (strategyTVL * _managementFee * duration) / SECONDS_PER_YEAR / MAX_BASIS_POINTS; } return 0; } function assessStrategyPerformanceFee(uint256 _performanceFee, uint256 _gain) public pure returns (uint256) { return (_gain * _performanceFee) / MAX_BASIS_POINTS; } function calculateFees( mapping(address => StrategyInfo) storage _strategies, address _strategy, uint256 _gain, uint256 _managementFee, uint256 _performanceFee ) public view returns (uint256 totalFee, uint256 performanceFee) { // Issue new shares to cover fees // solhint-disable-next-line not-rely-on-time if (_strategies[_strategy].activation == block.timestamp) { return (0, 0); // NOTE: Just added, no fees to assess } if (_gain == 0) { // The fees are not charged if there hasn't been any gains reported return (0, 0); } uint256 managementFee_ = assessManagementFee( _strategies[_strategy].lastReport, _strategies[_strategy].totalDebt, IStrategy(_strategy).delegatedAssets(), _managementFee ); uint256 strategyPerformanceFee_ = assessStrategyPerformanceFee(_performanceFee, _gain); uint256 totalFee_ = Math.min(_gain, managementFee_ + strategyPerformanceFee_); return (totalFee_, strategyPerformanceFee_); } function assessFees( IERC20Upgradeable _token, address _feeCollection, mapping(address => StrategyInfo) storage _strategies, address _strategy, uint256 _gain, uint256 _managementFee, uint256 _performanceFee ) external returns (uint256) { uint256 totalFee_; uint256 performanceFee_; (totalFee_, performanceFee_) = calculateFees(_strategies, _strategy, _gain, _managementFee, _performanceFee); if (totalFee_ > 0) { _token.approve(_feeCollection, totalFee_); uint256 managementFee_ = totalFee_ - performanceFee_; if (managementFee_ > 0) { IFeeCollection(_feeCollection).collectManageFee(managementFee_); } if (performanceFee_ > 0) { IFeeCollection(_feeCollection).collectPerformanceFee(_strategy, performanceFee_); } } return totalFee_; } function reportLoss( mapping(address => StrategyInfo) storage _strategies, address _strategy, uint256 _totalDebt, IVaultStrategyDataStore _strategyDataStore, uint256 _loss ) public returns (uint256) { if (_loss > 0) { require(_strategies[_strategy].totalDebt >= _loss, "!loss"); uint256 tRatio_ = _strategyDataStore.vaultTotalDebtRatio(address(this)); uint256 straRatio_ = _strategyDataStore.strategyDebtRatio(address(this), _strategy); // make sure we reduce our trust with the strategy by the amount of loss if (tRatio_ != 0) { uint256 c = Math.min((_loss * tRatio_) / _totalDebt, straRatio_); _strategyDataStore.updateStrategyDebtRatio(address(this), _strategy, straRatio_ - c); } _strategies[_strategy].totalLoss = _strategies[_strategy].totalLoss + _loss; _strategies[_strategy].totalDebt = _strategies[_strategy].totalDebt - _loss; _totalDebt = _totalDebt - _loss; } return _totalDebt; } function creditAvailable( IERC20Upgradeable _token, uint256 _totalAsset, uint256 _totalDebt, IVaultStrategyDataStore _strategyDataStore, mapping(address => StrategyInfo) storage _strategies, address _strategy ) external view returns (uint256) { uint256 vaultTotalDebtLimit_ = (_totalAsset * _strategyDataStore.vaultTotalDebtRatio(address(this))) / MAX_BASIS_POINTS; uint256 strategyDebtLimit_ = (_totalAsset * _strategyDataStore.strategyDebtRatio(address(this), _strategy)) / MAX_BASIS_POINTS; uint256 strategyTotalDebt_ = _strategies[_strategy].totalDebt; uint256 strategyMinDebtPerHarvest_ = _strategyDataStore.strategyMinDebtPerHarvest(address(this), _strategy); uint256 strategyMaxDebtPerHarvest_ = _strategyDataStore.strategyMaxDebtPerHarvest(address(this), _strategy); if ((strategyDebtLimit_ <= strategyTotalDebt_) || (vaultTotalDebtLimit_ <= _totalDebt)) { return 0; } uint256 available_ = strategyDebtLimit_ - strategyTotalDebt_; available_ = Math.min(available_, vaultTotalDebtLimit_ - _totalDebt); available_ = Math.min(available_, _token.balanceOf(address(this))); return available_ < strategyMinDebtPerHarvest_ ? 0 : Math.min(available_, strategyMaxDebtPerHarvest_); } function debtOutstanding( bool _emergencyShutdown, uint256 _totalAsset, IVaultStrategyDataStore _strategyDataStore, mapping(address => StrategyInfo) storage _strategies, address _strategy ) external view returns (uint256) { if (_strategyDataStore.vaultTotalDebtRatio(address(this)) == 0) { return _strategies[_strategy].totalDebt; } uint256 strategyLimit_ = (_totalAsset * _strategyDataStore.strategyDebtRatio(address(this), _strategy)) / MAX_BASIS_POINTS; uint256 strategyTotalDebt_ = _strategies[_strategy].totalDebt; if (_emergencyShutdown) { return strategyTotalDebt_; } else if (strategyTotalDebt_ <= strategyLimit_) { return 0; } else { return strategyTotalDebt_ - strategyLimit_; } } function expectedReturn(mapping(address => StrategyInfo) storage _strategies, address _strategy) external view returns (uint256) { uint256 strategyLastReport_ = _strategies[_strategy].lastReport; // solhint-disable-next-line not-rely-on-time uint256 sinceLastHarvest_ = block.timestamp - strategyLastReport_; uint256 totalHarvestTime_ = strategyLastReport_ - _strategies[_strategy].activation; // NOTE: If either `sinceLastHarvest_` or `totalHarvestTime_` is 0, we can short-circuit to `0` if ((sinceLastHarvest_ > 0) && (totalHarvestTime_ > 0) && (IStrategy(_strategy).isActive())) { // # NOTE: Unlikely to throw unless strategy accumalates >1e68 returns // # NOTE: Calculate average over period of time where harvests have occured in the past return (_strategies[_strategy].totalGain * sinceLastHarvest_) / totalHarvestTime_; } else { return 0; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @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-ERC20Permit.sol) pragma solidity ^0.8.0; import "./draft-IERC20PermitUpgradeable.sol"; import "../ERC20Upgradeable.sol"; import "../../../utils/cryptography/draft-EIP712Upgradeable.sol"; import "../../../utils/cryptography/ECDSAUpgradeable.sol"; import "../../../utils/CountersUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation 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. * * _Available since v3.4._ */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; mapping(address => CountersUpgradeable.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ function __ERC20Permit_init(string memory name) internal onlyInitializing { __Context_init_unchained(); __EIP712_init_unchained(name, "1"); __ERC20Permit_init_unchained(name); } function __ERC20Permit_init_unchained(string memory name) internal onlyInitializing { _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSAUpgradeable.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { CountersUpgradeable.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; interface IVaultStrategyDataStore { function strategyPerformanceFee(address _vault, address _strategy) external view returns (uint256); function strategyActivation(address _vault, address _strategy) external view returns (uint256); function strategyDebtRatio(address _vault, address _strategy) external view returns (uint256); function strategyMinDebtPerHarvest(address _vault, address _strategy) external view returns (uint256); function strategyMaxDebtPerHarvest(address _vault, address _strategy) external view returns (uint256); function vaultStrategies(address _vault) external view returns (address[] memory); function vaultTotalDebtRatio(address _vault) external view returns (uint256); function withdrawQueue(address _vault) external view returns (address[] memory); function revokeStrategyByStrategy(address _strategy) external; function setVaultManager(address _vault, address _manager) external; function setMaxTotalDebtRatio(address _vault, uint256 _maxTotalDebtRatio) external; function addStrategy( address _vault, address _strategy, uint256 _debtRatio, uint256 _minDebtPerHarvest, uint256 _maxDebtPerHarvest, uint256 _performanceFee ) external; function updateStrategyPerformanceFee( address _vault, address _strategy, uint256 _performanceFee ) external; function updateStrategyDebtRatio( address _vault, address _strategy, uint256 _debtRatio ) external; function updateStrategyMinDebtHarvest( address _vault, address _strategy, uint256 _minDebtPerHarvest ) external; function updateStrategyMaxDebtHarvest( address _vault, address _strategy, uint256 _maxDebtPerHarvest ) external; function migrateStrategy( address _vault, address _oldStrategy, address _newStrategy ) external; function revokeStrategy(address _vault, address _strategy) external; function setWithdrawQueue(address _vault, address[] calldata _queue) external; function addStrategyToWithdrawQueue(address _vault, address _strategy) external; function removeStrategyFromWithdrawQueue(address _vault, address _strategy) external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; interface IYOPRewards { /// @notice Returns the current emission rate (per epoch) for vault rewards and the current number of epoch (start from 1). function rate() external view returns (uint256 _rate, uint256 _epoch); /// @notice Returns the current ratio of community emissions for vault users function vaultsRewardsWeight() external view returns (uint256); /// @notice Returns the current ratio of community emissions for staking users function stakingRewardsWeight() external view returns (uint256); /// @notice Set the ratios of community emission for vaults and staking respectively. Governance only. Should emit an event. function setRewardsAllocationWeights(uint256 _weightForVaults, uint256 _weightForStaking) external; /// @notice Get the weight of a Vault function perVaultRewardsWeight(address vault) external view returns (uint256); /// @notice Set the weights for vaults. Governance only. Should emit events. function setPerVaultRewardsWeight(address[] calldata vaults, uint256[] calldata weights) external; /// @notice Calculate the rewards for the given user in the given vault. Vaults Only. /// This should be called by every Vault every time a user deposits or withdraws. function calculateVaultRewards(address _user) external; /// @notice Calculate the rewards for the given stake id in the staking contract. function calculateStakingRewards(uint256 _stakeId) external; /// @notice Allow a user to claim the accrued rewards from both vaults and staking, and transfer the YOP tokens to the given account. function claimAll(address _to) external; /// @notice Calculate the unclaimed rewards for the calling user function allUnclaimedRewards(address _user) external view returns ( uint256 totalRewards, uint256 vaultsRewards, uint256 stakingRewards ); } interface IYOPRewardsV2 { function claimRewardsForStakes(uint256[] calldata _stakeIds) external returns (uint256, uint256[] memory); function claimVaultRewardsForUsers(address[] calldata _users) external returns (uint256, uint256[] memory); }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; pragma abicoder v2; import "./roles/Governable.sol"; import "./roles/Gatekeeperable.sol"; import "./VaultDataStorage.sol"; /// @dev NOTE: do not add any new state variables to this contract. If needed, see {VaultDataStorage.sol} instead. abstract contract VaultMetaDataStore is GovernableUpgradeable, Gatekeeperable, VaultDataStorage { event EmergencyShutdown(bool _active); event HealthCheckUpdated(address indexed _healthCheck); event FeeCollectionUpdated(address indexed _feeCollection); event ManagementFeeUpdated(uint256 _managementFee); event StrategyDataStoreUpdated(address indexed _strategyDataStore); event DepositLimitUpdated(uint256 _limit); event LockedProfitDegradationUpdated(uint256 _degradation); event AccessManagerUpdated(address indexed _accessManager); event VaultRewardsContractUpdated(address indexed _vaultRewards); /// @notice The maximum basis points. 1 basis point is 0.01% and 100% is 10000 basis points uint256 internal constant MAX_BASIS_POINTS = 10_000; // solhint-disable-next-line no-empty-blocks constructor() {} // solhint-disable-next-line func-name-mixedcase function __VaultMetaDataStore_init( address _governance, address _gatekeeper, address _feeCollection, address _strategyDataStore, address _accessManager, address _vaultRewards ) internal { __Governable_init(_governance); __Gatekeeperable_init(_gatekeeper); __VaultDataStorage_init(); __VaultMetaDataStore_init_unchained(_feeCollection, _strategyDataStore, _accessManager, _vaultRewards); } // solhint-disable-next-line func-name-mixedcase function __VaultMetaDataStore_init_unchained( address _feeCollection, address _strategyDataStore, address _accessManager, address _vaultRewards ) internal { _updateFeeCollection(_feeCollection); _updateStrategyDataStore(_strategyDataStore); _updateAccessManager(_accessManager); _updateVaultRewardsContract(_vaultRewards); } /// @notice set the address to send the collected fees to. Only can be called by the governance. /// @param _feeCollection the new address to send the fees to. function setFeeCollection(address _feeCollection) external { _onlyGovernance(); _updateFeeCollection(_feeCollection); } /// @notice set the management fee in basis points. 1 basis point is 0.01% and 100% is 10000 basis points. function setManagementFee(uint256 _managementFee) external { _onlyGovernance(); _updateManagementFee(_managementFee); } function setGatekeeper(address _gatekeeper) external { _onlyGovernance(); _updateGatekeeper(_gatekeeper); } function setHealthCheck(address _healthCheck) external { _onlyGovernanceOrGatekeeper(governance); _updateHealthCheck(_healthCheck); } /// @notice Activates or deactivates Vault mode where all Strategies go into full withdrawal. /// During Emergency Shutdown: /// 1. No Users may deposit into the Vault (but may withdraw as usual.) /// 2. Governance may not add new Strategies. /// 3. Each Strategy must pay back their debt as quickly as reasonable to minimally affect their position. /// 4. Only Governance may undo Emergency Shutdown. /// /// See contract level note for further details. /// /// This may only be called by governance or the guardian. /// @param _active If true, the Vault goes into Emergency Shutdown. If false, the Vault goes back into Normal Operation. function setVaultEmergencyShutdown(bool _active) external { if (_active) { _onlyGovernanceOrGatekeeper(governance); } else { _onlyGovernance(); } if (emergencyShutdown != _active) { emergencyShutdown = _active; emit EmergencyShutdown(_active); } } /// @notice Changes the locked profit degradation. /// @param _degradation The rate of degradation in percent per second scaled to 1e18. function setLockedProfileDegradation(uint256 _degradation) external { _onlyGovernance(); require(_degradation <= DEGRADATION_COEFFICIENT, "!value"); if (lockedProfitDegradation != _degradation) { lockedProfitDegradation = _degradation; emit LockedProfitDegradationUpdated(_degradation); } } function setVaultCreator(address _creator) external { _onlyGovernanceOrGatekeeper(governance); creator = _creator; } function setDepositLimit(uint256 _limit) external { _onlyGovernanceOrGatekeeper(governance); _updateDepositLimit(_limit); } function setAccessManager(address _accessManager) external { _onlyGovernanceOrGatekeeper(governance); _updateAccessManager(_accessManager); } function _updateFeeCollection(address _feeCollection) internal { require(_feeCollection != address(0), "!input"); if (feeCollection != _feeCollection) { feeCollection = _feeCollection; emit FeeCollectionUpdated(_feeCollection); } } function _updateManagementFee(uint256 _managementFee) internal { require(_managementFee < MAX_BASIS_POINTS, "!input"); if (managementFee != _managementFee) { managementFee = _managementFee; emit ManagementFeeUpdated(_managementFee); } } function _updateHealthCheck(address _healthCheck) internal { if (healthCheck != _healthCheck) { healthCheck = _healthCheck; emit HealthCheckUpdated(_healthCheck); } } function _updateStrategyDataStore(address _strategyDataStore) internal { require(_strategyDataStore != address(0), "!input"); if (strategyDataStore != _strategyDataStore) { strategyDataStore = _strategyDataStore; emit StrategyDataStoreUpdated(_strategyDataStore); } } function _updateDepositLimit(uint256 _depositLimit) internal { if (depositLimit != _depositLimit) { depositLimit = _depositLimit; emit DepositLimitUpdated(_depositLimit); } } function _updateAccessManager(address _accessManager) internal { if (accessManager != _accessManager) { accessManager = _accessManager; emit AccessManagerUpdated(_accessManager); } } function _updateVaultRewardsContract(address _vaultRewards) internal { if (vaultRewards != _vaultRewards) { vaultRewards = _vaultRewards; emit VaultRewardsContractUpdated(_vaultRewards); } } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol"; struct StrategyInfo { uint256 activation; uint256 lastReport; uint256 totalDebt; uint256 totalGain; uint256 totalLoss; } interface IVault is IERC20, IERC20Permit { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint256); function activation() external view returns (uint256); function rewards() external view returns (address); function managementFee() external view returns (uint256); function gatekeeper() external view returns (address); function governance() external view returns (address); function creator() external view returns (address); function strategyDataStore() external view returns (address); function healthCheck() external view returns (address); function emergencyShutdown() external view returns (bool); function lockedProfitDegradation() external view returns (uint256); function depositLimit() external view returns (uint256); function lastReport() external view returns (uint256); function lockedProfit() external view returns (uint256); function totalDebt() external view returns (uint256); function token() external view returns (address); function totalAsset() external view returns (uint256); function availableDepositLimit() external view returns (uint256); function maxAvailableShares() external view returns (uint256); function pricePerShare() external view returns (uint256); function debtOutstanding(address _strategy) external view returns (uint256); function creditAvailable(address _strategy) external view returns (uint256); function expectedReturn(address _strategy) external view returns (uint256); function strategy(address _strategy) external view returns (StrategyInfo memory); function strategyDebtRatio(address _strategy) external view returns (uint256); function setRewards(address _rewards) external; function setManagementFee(uint256 _managementFee) external; function setGatekeeper(address _gatekeeper) external; function setStrategyDataStore(address _strategyDataStoreContract) external; function setHealthCheck(address _healthCheck) external; function setVaultEmergencyShutdown(bool _active) external; function setLockedProfileDegradation(uint256 _degradation) external; function setDepositLimit(uint256 _limit) external; function sweep(address _token, uint256 _amount) external; function addStrategy(address _strategy) external returns (bool); function migrateStrategy(address _oldVersion, address _newVersion) external returns (bool); function revokeStrategy() external; /// @notice deposit the given amount into the vault, and return the number of shares function deposit(uint256 _amount, address _recipient) external returns (uint256); /// @notice burn the given amount of shares from the vault, and return the number of underlying tokens recovered function withdraw( uint256 _shares, address _recipient, uint256 _maxLoss ) external returns (uint256); function report( uint256 _gain, uint256 _loss, uint256 _debtPayment ) external returns (uint256); } interface IBoostedVault { function totalBoostedSupply() external view returns (uint256); function boostedBalanceOf(address _user) external view returns (uint256); function updateBoostedBalancesForUsers(address[] calldata _users) external; }
// 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 IERC20PermitUpgradeable { /** * @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 v4.4.1 (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; import "./ECDSAUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712Upgradeable is Initializable { /* solhint-disable var-name-mixedcase */ bytes32 private _HASHED_NAME; bytes32 private _HASHED_VERSION; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash()); } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712NameHash() internal virtual view returns (bytes32) { return _HASHED_NAME; } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712VersionHash() internal virtual view returns (bytes32) { return _HASHED_VERSION; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../StringsUpgradeable.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @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); } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; pragma abicoder v2; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; interface IGovernable { function proposeGovernance(address _pendingGovernance) external; function acceptGovernance() external; } abstract contract GovernableInternal { event GovenanceUpdated(address _govenance); event GovenanceProposed(address _pendingGovenance); /// @dev This contract is used as part of the Vault contract and it is upgradeable. /// which means any changes to the state variables could corrupt the data. Do not modify these at all. /// @notice the address of the current governance address public governance; /// @notice the address of the pending governance address public pendingGovernance; /// @dev ensure msg.send is the governanace modifier onlyGovernance() { require(_getMsgSender() == governance, "governance only"); _; } /// @dev ensure msg.send is the pendingGovernance modifier onlyPendingGovernance() { require(_getMsgSender() == pendingGovernance, "pending governance only"); _; } /// @dev the deployer of the contract will be set as the initial governance // solhint-disable-next-line func-name-mixedcase function __Governable_init_unchained(address _governance) internal { require(_getMsgSender() != _governance, "invalid address"); _updateGovernance(_governance); } ///@notice propose a new governance of the vault. Only can be called by the existing governance. ///@param _pendingGovernance the address of the pending governance function proposeGovernance(address _pendingGovernance) external onlyGovernance { require(_pendingGovernance != address(0), "invalid address"); require(_pendingGovernance != governance, "already the governance"); pendingGovernance = _pendingGovernance; emit GovenanceProposed(_pendingGovernance); } ///@notice accept the proposal to be the governance of the vault. Only can be called by the pending governance. function acceptGovernance() external onlyPendingGovernance { _updateGovernance(pendingGovernance); } function _updateGovernance(address _pendingGovernance) internal { governance = _pendingGovernance; emit GovenanceUpdated(governance); } /// @dev provides an internal function to allow reduce the contract size function _onlyGovernance() internal view { require(_getMsgSender() == governance, "governance only"); } function _getMsgSender() internal view virtual returns (address); } /// @dev Add a `governance` and a `pendingGovernance` role to the contract, and implements a 2-phased nominatiom process to change the governance. /// Also provides a modifier to allow controlling access to functions of the contract. contract Governable is Context, GovernableInternal { constructor(address _governance) GovernableInternal() { __Governable_init_unchained(_governance); } function _getMsgSender() internal view override returns (address) { return _msgSender(); } } /// @dev ungradeable version of the {Governable} contract. Can be used as part of an upgradeable contract. abstract contract GovernableUpgradeable is ContextUpgradeable, GovernableInternal { // solhint-disable-next-line no-empty-blocks constructor() {} // solhint-disable-next-line func-name-mixedcase function __Governable_init(address _governance) internal { __Context_init(); __Governable_init_unchained(_governance); } // solhint-disable-next-line func-name-mixedcase function _getMsgSender() internal view override returns (address) { return _msgSender(); } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; pragma abicoder v2; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "../../interfaces/roles/IGatekeeperable.sol"; /// @dev Add the `Gatekeeper` role. /// Gatekeepers will help ensure the security of the vaults. They can set vault limits, pause deposits or withdraws. /// For vaults that defined restricted access, they will be able to control the access to these vaults as well. /// This contract also provides a `onlyGatekeeper` modifier to allow controlling access to functions of the contract. abstract contract Gatekeeperable is IGatekeeperable, ContextUpgradeable { event GatekeeperUpdated(address _guardian); /// @notice the address of the guardian for the vault /// @dev This contract is used as part of the Vault contract and it is upgradeable. /// which means any changes to the state variables could corrupt the data. Do not modify this at all. address public gatekeeper; /// @dev make sure msg.sender is the guardian or the governance modifier onlyGovernanceOrGatekeeper(address _governance) { _onlyGovernanceOrGatekeeper(_governance); _; } // solhint-disable-next-line no-empty-blocks constructor() {} /// @dev set the initial value for the gatekeeper. The deployer can not be the gatekeeper. /// @param _gatekeeper the default address of the guardian // solhint-disable-next-line func-name-mixedcase function __Gatekeeperable_init_unchained(address _gatekeeper) internal { require(_msgSender() != _gatekeeper, "invalid address"); _updateGatekeeper(_gatekeeper); } // solhint-disable-next-line func-name-mixedcase function __Gatekeeperable_init(address _gatekeeper) internal { __Context_init(); __Gatekeeperable_init_unchained(_gatekeeper); } ///@dev this can be used internally to update the gatekeep. If you want to expose it, create an external function in the implementation contract and call this. function _updateGatekeeper(address _gatekeeper) internal { require(_gatekeeper != address(0), "address is not valid"); require(_gatekeeper != gatekeeper, "already the gatekeeper"); gatekeeper = _gatekeeper; emit GatekeeperUpdated(_gatekeeper); } function _onlyGovernanceOrGatekeeper(address _governance) internal view { require((_msgSender() == _governance) || (gatekeeper != address(0) && gatekeeper == _msgSender()), "!authorised"); } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; pragma abicoder v2; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {StrategyInfo} from "../interfaces/IVault.sol"; /// @dev this contract is used to declare all the state variables that will be used by a Vault. /// Because the vault itself is upgradeable, changes to state variables could cause data corruption. /// The only safe operation is to add new fields, or rename an existing one (still not recommended to rename a field). /// To avoid any issues, if a new field is needed, we should create a new version of the data store and extend the previous version, /// rather than modifying the state variables directly. // solhint-disable-next-line max-states-count contract VaultDataStorage { // ### Vault base properties uint8 internal vaultDecimals; bool public emergencyShutdown; /// @notice timestamp for when the vault is deployed uint256 public activation; uint256 public managementFee; /// @notice degradation for locked profit per second /// @dev the value is based on 6-hour degradation period (1/(60*60*6) = 0.000046) /// NOTE: This is being deprecated by Yearn. See https://github.com/yearn/yearn-vaults/pull/471 uint256 internal lockedProfitDegradation; uint256 public depositLimit; /// @notice the timestamp of the last report received from a strategy uint256 internal lastReport; /// @notice how much profit is locked and cant be withdrawn uint256 public lockedProfit; /// @notice total value borrowed by all the strategies uint256 public totalDebt; address public feeCollection; address public healthCheck; address public strategyDataStore; address public accessManager; address public creator; IERC20Upgradeable public token; mapping(address => StrategyInfo) internal strategies; uint256 internal constant DEGRADATION_COEFFICIENT = 10**18; address public vaultRewards; /// @dev This is used to track the last deposit time of a user. /// It will be checked before the vault receipt token is transferred and they can only happen at least 1 block later to prevent flash loan attacks mapping(address => uint256) internal dt; /// @dev set the default values for the state variables here // solhint-disable-next-line func-name-mixedcase function __VaultDataStorage_init() internal { vaultDecimals = 18; lockedProfitDegradation = (DEGRADATION_COEFFICIENT * 46) / 10**6; depositLimit = type(uint256).max; /* solhint-disable not-rely-on-time */ activation = block.timestamp; lastReport = block.timestamp; /* solhint-enable */ } }
// 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 pragma solidity =0.8.9; interface IGatekeeperable { function gatekeeper() external view returns (address); }
// 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 v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity ^0.8.0; import "./draft-IERC20Permit.sol"; import "../ERC20.sol"; import "../../../utils/cryptography/draft-EIP712.sol"; import "../../../utils/cryptography/ECDSA.sol"; import "../../../utils/Counters.sol"; /** * @dev Implementation 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. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, 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}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), 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}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][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) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * 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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, 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 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 v4.4.1 (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; address private immutable _CACHED_THIS; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _CACHED_THIS = address(this); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// 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 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20Upgradeable.sol";
{ "optimizer": { "enabled": true, "runs": 10 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": { "contracts/libraries/VaultUtils.sol": { "VaultUtils": "0x3252456634469ce6c2540c02cbfa98320e32f223" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_accessManager","type":"address"}],"name":"AccessManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"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":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_limit","type":"uint256"}],"name":"DepositLimitUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_active","type":"bool"}],"name":"EmergencyShutdown","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_feeCollection","type":"address"}],"name":"FeeCollectionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_guardian","type":"address"}],"name":"GatekeeperUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_pendingGovenance","type":"address"}],"name":"GovenanceProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_govenance","type":"address"}],"name":"GovenanceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_healthCheck","type":"address"}],"name":"HealthCheckUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_degradation","type":"uint256"}],"name":"LockedProfitDegradationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_managementFee","type":"uint256"}],"name":"ManagementFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_staking","type":"address"}],"name":"StakingContractUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_strategy","type":"address"}],"name":"StrategyAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_strategyDataStore","type":"address"}],"name":"StrategyDataStoreUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_oldVersion","type":"address"},{"indexed":true,"internalType":"address","name":"_newVersion","type":"address"}],"name":"StrategyMigrated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_strategyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_gain","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_loss","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_debtPaid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_totalGain","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_totalLoss","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_totalDebt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_debtAdded","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_debtRatio","type":"uint256"}],"name":"StrategyReported","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_strategy","type":"address"}],"name":"StrategyRevoked","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_vaultRewards","type":"address"}],"name":"VaultRewardsContractUpdated","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accessManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"addStrategy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":"availableDepositLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boostFormulaWeights","outputs":[{"internalType":"uint128","name":"vaultBalanceWeight","type":"uint128"},{"internalType":"uint128","name":"stakingBalanceWeight","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"boostedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"creditAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"debtOutstanding","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"_amount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyShutdown","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"expectedReturn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollection","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gatekeeper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"healthCheck","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"_gatekeeper","type":"address"},{"internalType":"address","name":"_feeCollection","type":"address"},{"internalType":"address","name":"_strategyDataStoreAddress","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_accessManager","type":"address"},{"internalType":"address","name":"_vaultRewards","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"_gatekeeper","type":"address"},{"internalType":"address","name":"_feeCollection","type":"address"},{"internalType":"address","name":"_strategyDataStoreAddress","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_accessManager","type":"address"},{"internalType":"address","name":"_vaultRewards","type":"address"},{"internalType":"address","name":"_stakingContract","type":"address"}],"name":"initializeV2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"latestBoostedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockedProfit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managementFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAvailableShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_oldVersion","type":"address"},{"internalType":"address","name":"_newVersion","type":"address"}],"name":"migrateStrategy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingGovernance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pricePerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pendingGovernance","type":"address"}],"name":"proposeGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_gain","type":"uint256"},{"internalType":"uint256","name":"_loss","type":"uint256"},{"internalType":"uint256","name":"_debtPayment","type":"uint256"}],"name":"report","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revokeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_accessManager","type":"address"}],"name":"setAccessManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_vaultWeight","type":"uint128"},{"internalType":"uint128","name":"_stakingWeight","type":"uint128"}],"name":"setBoostedFormulaWeights","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_limit","type":"uint256"}],"name":"setDepositLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeCollection","type":"address"}],"name":"setFeeCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gatekeeper","type":"address"}],"name":"setGatekeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_healthCheck","type":"address"}],"name":"setHealthCheck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_degradation","type":"uint256"}],"name":"setLockedProfileDegradation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_managementFee","type":"uint256"}],"name":"setManagementFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingContract","type":"address"}],"name":"setStakingContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"}],"name":"setVaultCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_active","type":"bool"}],"name":"setVaultEmergencyShutdown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"strategy","outputs":[{"components":[{"internalType":"uint256","name":"activation","type":"uint256"},{"internalType":"uint256","name":"lastReport","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"totalGain","type":"uint256"},{"internalType":"uint256","name":"totalLoss","type":"uint256"}],"internalType":"struct StrategyInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategyDataStore","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"strategyDebtRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBoostedSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_users","type":"address[]"}],"name":"updateBoostedBalancesForUsers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"vaultRewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxShares","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_maxLoss","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a0604052306080523480156200001557600080fd5b50600054610100900460ff16620000335760005460ff16156200003d565b6200003d620000e2565b620000a55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b600054610100900460ff16158015620000c8576000805461ffff19166101011790555b8015620000db576000805461ff00191690555b5062000106565b6000620000fa306200010060201b620024551760201c565b15905090565b3b151590565b608051615fb2620001376000396000818161110d0152818161114d0152818161123001526112700152615fb26000f3fe6080604052600436106103505760003560e01c806380f83adc116101b957806380f83adc1461083c578063831983341461085c5780638429d51f1461087c5780638456cb591461089c57806394abf3e5146108b157806395d89b41146108d157806399530b06146108e65780639dd373b9146108fb578063a0e4af9a1461091b578063a1d9bafc14610930578063a457c2d714610950578063a59c9c2714610970578063a6f7f5d614610990578063a9059cbb146109a6578063b252720b146109c6578063bdc8144b146109e6578063bdcf36bb14610a06578063c373a08e14610a26578063c733e16814610a46578063c958080414610a66578063ccdc2c2314610a86578063d505accf14610aa6578063d764801314610ac6578063dd62ed3e14610ae6578063deabb80014610b2c578063e63697c814610b4c578063ecf7085814610b6c578063edbcfdf214610b82578063ee99205c14610ba2578063f39c38a014610bc3578063f9170d8f14610be3578063f9557ccb14610c03578063fbb9795614610c18578063fc0c546a14610c38578063fc7b9c1814610c58578063fdcb606814610c6e578063fe56e23214610c8e57600080fd5b8062ae6e0f1461035557806301ffc9a71461038857806302d05d3f146103b857806306fdde03146103e5578063095ea7b3146104075780630dda72991461042757806311bc82451461043c578063153c27c41461045e57806318160ddd146104735780631beabcd214610488578063223e5479146104a8578063228bfd9f146104c8578063238efcbc1461052a57806323b872dd1461053f5780632d9e1a7d1461055f578063313ce5671461057f57806333586b67146105ab5780633403c2fc146105cb5780633629c8de146105ec5780633644e515146106025780633659cfe6146106175780633786df5e1461063757806339509351146106575780633f4ba83a1461067757806344b813961461068c5780634f1ef286146106a257806354fd4d50146106b55780635aa6e675146106e35780635c975abb146107035780635ee9ca141461071b5780636cb56d191461073b5780636e553f651461075b5780636ea056a91461077b57806370a082311461079b57806375de2902146107bb5780637ecebe00146107d05780637f0f10e6146107f0575b600080fd5b34801561036157600080fd5b506103756103703660046152f1565b610cae565b6040519081526020015b60405180910390f35b34801561039457600080fd5b506103a86103a336600461530e565b610cbf565b604051901515815260200161037f565b3480156103c457600080fd5b5060da546103d8906001600160a01b031681565b60405161037f9190615338565b3480156103f157600080fd5b506103fa610cf2565b60405161037f9190615378565b34801561041357600080fd5b506103a86104223660046153ab565b610d84565b34801561043357600080fd5b50610375610d9a565b34801561044857600080fd5b5061045c6104573660046152f1565b610dd0565b005b34801561046a57600080fd5b50610375610df1565b34801561047f57600080fd5b50603554610375565b34801561049457600080fd5b506103756104a33660046152f1565b610dfb565b3480156104b457600080fd5b506103a86104c33660046152f1565b610e9a565b3480156104d457600080fd5b506104e86104e33660046152f1565b610eb5565b60405161037f9190600060a082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b34801561053657600080fd5b5061045c610f3f565b34801561054b57600080fd5b506103a861055a3660046153d7565b610fb3565b34801561056b57600080fd5b5061045c61057a366004615418565b61105f565b34801561058b57600080fd5b5060ce54600160a01b900460ff1660405160ff909116815260200161037f565b3480156105b757600080fd5b506103756105c63660046152f1565b6110ed565b3480156105d757600080fd5b5060ce546103a890600160a81b900460ff1681565b3480156105f857600080fd5b5061037560cf5481565b34801561060e57600080fd5b506103756110f8565b34801561062357600080fd5b5061045c6106323660046152f1565b611102565b34801561064357600080fd5b5061045c6106523660046152f1565b6111c8565b34801561066357600080fd5b506103a86106723660046153ab565b6111d9565b34801561068357600080fd5b5061045c611215565b34801561069857600080fd5b5061037560d45481565b61045c6106b03660046154ce565b611225565b3480156106c157600080fd5b506040805180820190915260058152640302e322e360dc1b60208201526103fa565b3480156106ef57600080fd5b5060cc546103d8906001600160a01b031681565b34801561070f57600080fd5b5060df5460ff166103a8565b34801561072757600080fd5b5061045c61073636600461553f565b6112df565b34801561074757600080fd5b506103a861075636600461555c565b61136c565b34801561076757600080fd5b50610375610776366004615595565b611380565b34801561078757600080fd5b5061045c6107963660046153ab565b6113f4565b3480156107a757600080fd5b506103756107b63660046152f1565b611443565b3480156107c757600080fd5b5061037561145e565b3480156107dc57600080fd5b506103756107eb3660046152f1565b611468565b3480156107fc57600080fd5b506101a95461081c906001600160801b0380821691600160801b90041682565b604080516001600160801b0393841681529290911660208301520161037f565b34801561084857600080fd5b5060d8546103d8906001600160a01b031681565b34801561086857600080fd5b5061045c6108773660046155da565b611486565b34801561088857600080fd5b5060dd546103d8906001600160a01b031681565b3480156108a857600080fd5b5061045c611512565b3480156108bd57600080fd5b506103756108cc3660046152f1565b61152f565b3480156108dd57600080fd5b506103fa6115b6565b3480156108f257600080fd5b506103756115c5565b34801561090757600080fd5b5061045c6109163660046152f1565b6115e9565b34801561092757600080fd5b5061045c611679565b34801561093c57600080fd5b5061037561094b3660046156b6565b611725565b34801561095c57600080fd5b506103a861096b3660046153ab565b611ddc565b34801561097c57600080fd5b5060ce546103d8906001600160a01b031681565b34801561099c57600080fd5b5061037560d05481565b3480156109b257600080fd5b506103a86109c13660046153ab565b611e75565b3480156109d257600080fd5b5060d7546103d8906001600160a01b031681565b3480156109f257600080fd5b5061045c610a01366004615418565b611e82565b348015610a1257600080fd5b50610375610a213660046152f1565b611ea0565b348015610a3257600080fd5b5061045c610a413660046152f1565b611eab565b348015610a5257600080fd5b5061045c610a613660046156e2565b611fa6565b348015610a7257600080fd5b5061045c610a813660046152f1565b612034565b348015610a9257600080fd5b5061045c610aa13660046157e3565b612052565b348015610ab257600080fd5b5061045c610ac1366004615825565b612074565b348015610ad257600080fd5b50610375610ae13660046152f1565b6121ae565b348015610af257600080fd5b50610375610b0136600461555c565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b348015610b3857600080fd5b5061045c610b47366004615896565b6121b9565b348015610b5857600080fd5b50610375610b6736600461590a565b61237c565b348015610b7857600080fd5b5061037560d25481565b348015610b8e57600080fd5b5060d6546103d8906001600160a01b031681565b348015610bae57600080fd5b506101aa546103d8906001600160a01b031681565b348015610bcf57600080fd5b5060cd546103d8906001600160a01b031681565b348015610bef57600080fd5b5061045c610bfe3660046152f1565b6123f2565b348015610c0f57600080fd5b50610375612429565b348015610c2457600080fd5b5061045c610c333660046152f1565b612433565b348015610c4457600080fd5b5060db546103d8906001600160a01b031681565b348015610c6457600080fd5b5061037560d55481565b348015610c7a57600080fd5b5060d9546103d8906001600160a01b031681565b348015610c9a57600080fd5b5061045c610ca9366004615418565b612444565b6000610cb98261245b565b92915050565b60006001600160e01b0319821663bf8b4f0760e01b1480610cb95750506001600160e01b0319166301ffc9a760e01b1490565b606060368054610d0190615931565b80601f0160208091040260200160405190810160405280929190818152602001828054610d2d90615931565b8015610d7a5780601f10610d4f57610100808354040283529160200191610d7a565b820191906000526020600020905b815481529060010190602001808311610d5d57829003601f168201915b5050505050905090565b6000610d913384846124fb565b50600192915050565b60006101a8546000148015610db757506000610db560355490565b115b15610dc8575060355490565b905090565b506101a85490565b60cc54610de5906001600160a01b031661261f565b610dee8161268f565b50565b6000610dc36126ee565b60006001600160a01b038216610e405760405162461bcd60e51b815260206004820152600560248201526410bab9b2b960d91b60448201526064015b60405180910390fd5b6001600160a01b03821660009081526101a76020526040902054158015610e6f57506000610e6d83611443565b115b15610e7d57610cb982611443565b506001600160a01b031660009081526101a7602052604090205490565b6000610ea461271b565b610eac61276a565b610cb9826127be565b610ee76040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b506001600160a01b0316600090815260dc6020908152604091829020825160a0810184528154815260018201549281019290925260028101549282019290925260038201546060820152600490910154608082015290565b60cd546001600160a01b0316336001600160a01b031614610f9c5760405162461bcd60e51b815260206004820152601760248201527670656e64696e6720676f7665726e616e6365206f6e6c7960481b6044820152606401610e37565b60cd54610fb1906001600160a01b0316612851565b565b6000610fc084848461289d565b6001600160a01b0384166000908152603460209081526040808320338452909152902054828110156110455760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610e37565b61105285338584036124fb565b60019150505b9392505050565b611067612a70565b670de0b6b3a76400008111156110a85760405162461bcd60e51b81526020600482015260066024820152652176616c756560d01b6044820152606401610e37565b8060d15414610dee5760d18190556040518181527f056863905a721211fc4dda1d688efc8f120b4b689d2e41da8249cf6eff200691906020015b60405180910390a150565b6000610cb982612aa3565b6000610dc3612af5565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561114b5760405162461bcd60e51b8152600401610e3790615966565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661117d612b70565b6001600160a01b0316146111a35760405162461bcd60e51b8152600401610e37906159a0565b6111ac81612b8c565b60408051600080825260208201909252610dee91839190612b94565b6111d0612a70565b610dee81612cdb565b3360008181526034602090815260408083206001600160a01b03871684529091528120549091610d919185906112109086906159f0565b6124fb565b61121d612a70565b610fb1612d60565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561126e5760405162461bcd60e51b8152600401610e3790615966565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166112a0612b70565b6001600160a01b0316146112c65760405162461bcd60e51b8152600401610e37906159a0565b6112cf82612b8c565b6112db82826001612b94565b5050565b80156112ff5760cc546112fa906001600160a01b031661261f565b611307565b611307612a70565b60ce5460ff600160a81b90910416151581151514610dee5760ce8054821515600160a81b0260ff60a81b199091161790556040517fba40372a3a724dca3c57156128ef1e896724b65b37a17f190b1ad5de68f3a4f3906110e290831515815260200190565b600061137661276a565b6110588383612ded565b600061138e60df5460ff1690565b156113ab5760405162461bcd60e51b8152600401610e3790615a08565b60026101115414156113cf5760405162461bcd60e51b8152600401610e3790615a32565b6002610111556113dd61271b565b6113e78383612fb1565b6001610111559392505050565b6113fc612a70565b60db546001600160a01b038381169116141561142a5760405162461bcd60e51b8152600401610e3790615a69565b60cc546112db90839083906001600160a01b03166130dc565b6001600160a01b031660009081526033602052604090205490565b6000610dc361317b565b6001600160a01b038116600090815260996020526040812054610cb9565b600054610100900460ff166114a15760005460ff16156114a5565b303b155b6114c15760405162461bcd60e51b8152600401610e3790615a89565b600054610100900460ff161580156114e3576000805461ffff19166101011790555b6114f48a8a8a8a8a8a8a8a8a613310565b8015611506576000805461ff00191690555b50505050505050505050565b60cc54611527906001600160a01b031661261f565b610fb1613334565b600061153961338c565b6001600160a01b031663a5145b4630846040518363ffffffff1660e01b8152600401611566929190615ad7565b60206040518083038186803b15801561157e57600080fd5b505afa158015611592573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb99190615af1565b606060378054610d0190615931565b60ce54600090610dc3906115e490600160a01b900460ff16600a615bee565b61339b565b6115f1612a70565b6001600160a01b0381166116175760405162461bcd60e51b8152600401610e3790615bfd565b6101aa546001600160a01b03828116911614610dee576101aa80546001600160a01b0319166001600160a01b0383161790556040517f6397f5b135542bb3f477cb346cfab5abdec1251d08dc8f8d4efb4ffe122ea0bf906110e2908390615338565b611682336133d8565b61168a61338c565b6001600160a01b031663ba6db98d336040518263ffffffff1660e01b81526004016116b59190615338565b600060405180830381600087803b1580156116cf57600080fd5b505af11580156116e3573d6000803e3d6000fd5b505050506116ee3390565b6001600160a01b03167f4201c688d84c01154d321afa0c72f1bffe9eef53005c9de9d035074e71e9b32a60405160405180910390a2565b600033611731816133d8565b61173b83866159f0565b60db546040516370a0823160e01b81526001600160a01b03909116906370a082319061176b908590600401615338565b60206040518083038186803b15801561178357600080fd5b505afa158015611797573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117bb9190615af1565b10156117f45760405162461bcd60e51b81526020600482015260086024820152672162616c616e636560c01b6044820152606401610e37565b60d754733252456634469ce6c2540c02cbfa98320e32f2239063f4daf9f0906001600160a01b03168388888861182984613429565b6001600160a01b03898116600090815260dc60205260409081902060020154905160e08a901b6001600160e01b031916815297821660048901529516602487015260448601939093526064850191909152608484015260a483015260c482015260e40160006040518083038186803b1580156118a457600080fd5b505af41580156118b8573d6000803e3d6000fd5b50505050733252456634469ce6c2540c02cbfa98320e32f22363d16075dd60dc8360d5546118e461338c565b896040518663ffffffff1660e01b8152600401611905959493929190615c1f565b60206040518083038186803b15801561191d57600080fd5b505af4158015611931573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119559190615af1565b60d5556001600160a01b038116600090815260dc602052604090206003015461197f9086906159f0565b6001600160a01b03808316600090815260dc6020819052604082206003019390935560db5460d65460d0549294733252456634469ce6c2540c02cbfa98320e32f223946346c2111a949381169392169187908c906119db61338c565b6001600160a01b03166326d3ce3f308c6040518363ffffffff1660e01b8152600401611a08929190615ad7565b60206040518083038186803b158015611a2057600080fd5b505afa158015611a34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a589190615af1565b6040516001600160e01b031960e08a901b1681526001600160a01b03978816600482015295871660248701526044860194909452949091166064840152608483015260a482019290925260c481019190915260e40160206040518083038186803b158015611ac557600080fd5b505af4158015611ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611afd9190615af1565b90506000611b0a836134b7565b90506000611b1784613429565b90506000611b25828861356a565b90508015611b4457611b378582613579565b611b418183615c4d565b91505b8215611b5457611b5485846135d1565b6000611b60828b6159f0565b905083811015611b9057611b8b86611b788387615c4d565b60db546001600160a01b03169190613622565b611bbb565b83811115611bbb57611bbb8630611ba78785615c4d565b60db546001600160a01b031692919061368a565b611bc68a868b6136c2565b6001600160a01b038616600090815260dc60209081526040808320426001820181905560d3819055825160a08101845282548152938401526002810154918301919091526003810154606083015260040154608082015290611c2661338c565b6001600160a01b031663a5145b46308a6040518363ffffffff1660e01b8152600401611c53929190615ad7565b60206040518083038186803b158015611c6b57600080fd5b505afa158015611c7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca39190615af1565b9050876001600160a01b03167f67f96d2854a335a4cadb49f84fd3ca6f990744ddb3feceeb4b349d2d53d32ad38d8d878660600151876080015188604001518d89604051611d29989796959493929190978852602088019690965260408701949094526060860192909252608085015260a084015260c083015260e08201526101000190565b60405180910390a2801580611d47575060ce54600160a81b900460ff165b15611dcc57876001600160a01b031663efbb5cb06040518163ffffffff1660e01b815260040160206040518083038186803b158015611d8557600080fd5b505afa158015611d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dbd9190615af1565b98505050505050505050611058565b8498505050505050505050611058565b3360009081526034602090815260408083206001600160a01b038616845290915281205482811015611e5e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610e37565b611e6b33858584036124fb565b5060019392505050565b6000610d9133848461289d565b60cc54611e97906001600160a01b031661261f565b610dee81613709565b6000610cb982613429565b60cc546001600160a01b0316336001600160a01b031614611ede5760405162461bcd60e51b8152600401610e3790615c64565b6001600160a01b038116611f045760405162461bcd60e51b8152600401610e3790615c8d565b60cc546001600160a01b0382811691161415611f5b5760405162461bcd60e51b8152602060048201526016602482015275616c72656164792074686520676f7665726e616e636560501b6044820152606401610e37565b60cd80546001600160a01b0319166001600160a01b0383161790556040517f9a35a2aeba8eb8a43609155078e2fd5cbafd797e0a76ec701999554effda58e4906110e2908390615338565b600054610100900460ff16611fc15760005460ff1615611fc5565b303b155b611fe15760405162461bcd60e51b8152600401610e3790615a89565b600054610100900460ff16158015612003576000805461ffff19166101011790555b6120158b8b8b8b8b8b8b8b8b8b613747565b8015612027576000805461ff00191690555b5050505050505050505050565b60cc54612049906001600160a01b031661261f565b610dee81613761565b61205a612a70565b6001600160801b03908116600160801b029116176101a955565b834211156120c45760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610e37565b6000609a548888886120d58c6137c0565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000612130826137e8565b9050600061214082878787613836565b9050896001600160a01b0316816001600160a01b0316146121a35760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610e37565b6115068a8a8a6124fb565b6000610cb9826134b7565b60008060005b838110156123575760dd546001600160a01b03161561225f5760dd546001600160a01b031663cafecbdf8686848181106121fb576121fb615cb6565b905060200201602081019061221091906152f1565b6040518263ffffffff1660e01b815260040161222c9190615338565b600060405180830381600087803b15801561224657600080fd5b505af115801561225a573d6000803e3d6000fd5b505050505b60006101a7600087878581811061227857612278615cb6565b905060200201602081019061228d91906152f1565b6001600160a01b03166001600160a01b0316815260200190815260200160002054905060006122e18787858181106122c7576122c7615cb6565b90506020020160208101906122dc91906152f1565b61245b565b9050806101a760008989878181106122fb576122fb615cb6565b905060200201602081019061231091906152f1565b6001600160a01b0316815260208101919091526040016000205561233482866159f0565b945061234081856159f0565b93505050808061234f90615ccc565b9150506121bf565b5080826101a8546123689190615c4d565b61237291906159f0565b6101a85550505050565b600061238a60df5460ff1690565b156123a75760405162461bcd60e51b8152600401610e3790615a08565b60026101115414156123cb5760405162461bcd60e51b8152600401610e3790615a32565b6002610111556123d961271b565b6123e484848461385e565b600161011155949350505050565b60cc54612407906001600160a01b031661261f565b60da80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610dc3613ab3565b61243b612a70565b610dee81613b42565b61244c612a70565b610dee81613c31565b3b151590565b6101aa546101a954604051631a4d9d2960e11b81526001600160a01b03808516600483015290921660248301523060448301526001600160801b038082166064840152600160801b909104166084820152600090733252456634469ce6c2540c02cbfa98320e32f2239063349b3a529060a4015b60206040518083038186803b1580156124e757600080fd5b505af4158015611592573d6000803e3d6000fd5b6001600160a01b03831661255d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610e37565b6001600160a01b0382166125be5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610e37565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b336001600160a01b0382161480612655575060ce546001600160a01b031615801590612655575060ce546001600160a01b031633145b610dee5760405162461bcd60e51b815260206004820152600b60248201526a08585d5d1a1bdc9a5cd95960aa1b6044820152606401610e37565b60d7546001600160a01b03828116911614610dee5760d780546001600160a01b0319166001600160a01b0383169081179091556040517f561e696bb6dd103fb892cfd663eedc6af38a38f7c222e2c4deade4f4045f925c90600090a250565b60006126f8613ab3565b60d254116127065750600090565b61270e613ab3565b60d254610dc39190615c4d565b60ce54600160a81b900460ff1615610fb15760405162461bcd60e51b815260206004820152601260248201527132b6b2b933b2b731bc9039b43aba3237bbb760711b6044820152606401610e37565b60d8546001600160a01b0316336001600160a01b031614610fb15760405162461bcd60e51b815260206004820152600e60248201526d21737472617465677953746f726560901b6044820152606401610e37565b6040805160a081018252428082526020808301918252600083850181815260608501828152608086018381526001600160a01b03891680855260dc909552878420965187559451600187015590516002860155516003850155915160049093019290925591517f3f008fd510eae7a9e7bee13513d7b83bef8003d488b5a3d0b0da4de71d6846f1908390a2506001919050565b60cc80546001600160a01b0319166001600160a01b0383169081179091556040517f82d3cb1aac85eaba89545486a5bdf332a6649ee2e53bccf1e2aec0683afced0e916110e291615338565b6001600160a01b0383166129015760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610e37565b6001600160a01b0382166129635760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610e37565b61296e838383613c90565b6001600160a01b038316600090815260336020526040902054818110156129e65760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610e37565b6001600160a01b03808516600090815260336020526040808220858503905591851681529081208054849290612a1d9084906159f0565b92505081905550826001600160a01b0316846001600160a01b0316600080516020615f5d83398151915284604051612a5791815260200190565b60405180910390a3612a6a848484613e07565b50505050565b60cc546001600160a01b0316336001600160a01b031614610fb15760405162461bcd60e51b8152600401610e3790615c64565b6000612aae826133d8565b604051633d26fc9160e21b815260dc60048201526001600160a01b0383166024820152733252456634469ce6c2540c02cbfa98320e32f2239063f49bf244906044016124cf565b6000610dc37f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f612b2460655490565b6066546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b600080516020615f16833981519152546001600160a01b031690565b610dee612a70565b6000612b9e612b70565b9050612ba984613edd565b600083511180612bb65750815b15612bc757612bc58484613f70565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff16612cd457805460ff19166001178155604051612c42908690612c13908590602401615338565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052613f70565b50805460ff19168155612c53612b70565b6001600160a01b0316826001600160a01b031614612ccb5760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b6064820152608401610e37565b612cd48561405b565b5050505050565b6001600160a01b038116612d015760405162461bcd60e51b8152600401610e3790615ce7565b60d6546001600160a01b03828116911614610dee5760d680546001600160a01b0319166001600160a01b0383169081179091556040517f166c82f2c4cd6d3546d8aa18fe78e4b4e6a1baa30de276480b10d2a4faa95a2890600090a250565b60df5460ff16612da95760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610e37565b60df805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051612de39190615338565b60405180910390a1565b60008060dc6000856001600160a01b03166001600160a01b031681526020019081526020016000206040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820154815250509050600060dc6000866001600160a01b03166001600160a01b03168152602001908152602001600020600201819055506040518060a0016040528082600001518152602001826020015181526020018260400151815260200160008152602001600081525060dc6000856001600160a01b03166001600160a01b031681526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040155905050836001600160a01b031663ce5494bb846040518263ffffffff1660e01b8152600401612f3d9190615338565b600060405180830381600087803b158015612f5757600080fd5b505af1158015612f6b573d6000803e3d6000fd5b50506040516001600160a01b038087169350871691507f100b69bb6b504e1252e36b375233158edee64d071b399e2f81473a695fd1b02190600090a35060019392505050565b60006001600160a01b038216612fd95760405162461bcd60e51b8152600401610e3790615d07565b60d9546001600160a01b0316156130a05760d9546001600160a01b0316631709ef0733306040518363ffffffff1660e01b815260040161301a929190615ad7565b60206040518083038186803b15801561303257600080fd5b505afa158015613046573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061306a9190615d2b565b6130a05760405162461bcd60e51b81526020600482015260076024820152662161636365737360c81b6044820152606401610e37565b60006130ac338561409b565b905060006130ba8483614106565b90506130d43360db546001600160a01b031690308561368a565b949350505050565b6040516370a0823160e01b815283906131659084906001600160a01b038416906370a0823190613110903090600401615338565b60206040518083038186803b15801561312857600080fd5b505afa15801561313c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131609190615af1565b61356a565b9250612a6a6001600160a01b0382168385613622565b60db546040516370a0823160e01b81526000918291613207916001600160a01b0316906370a08231906131b2903090600401615338565b60206040518083038186803b1580156131ca57600080fd5b505afa1580156131de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132029190615af1565b61416b565b9050600061321361338c565b6001600160a01b03166390ab8d1f306040518263ffffffff1660e01b815260040161323e9190615338565b60006040518083038186803b15801561325657600080fd5b505afa15801561326a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526132929190810190615d48565b905060005b8151811015613308576132ea60dc60008484815181106132b9576132b9615cb6565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206002015461416b565b6132f490846159f0565b92508061330081615ccc565b915050613297565b509092915050565b6133218989898989898989896141a5565b613329613334565b505050505050505050565b60df5460ff16156133575760405162461bcd60e51b8152600401610e3790615a08565b60df805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612dd63390565b60d8546001600160a01b031690565b6000806133a760355490565b905080156133d157806133b86141be565b6133c29085615df9565b6133cc9190615e18565b611058565b5090919050565b6001600160a01b038116600090815260dc6020526040902054610dee5760405162461bcd60e51b815260206004820152600960248201526821737472617465677960b81b6044820152606401610e37565b6000613434826133d8565b60ce54733252456634469ce6c2540c02cbfa98320e32f2239063cff4e18790600160a81b900460ff16613465613ab3565b61346d61338c565b6040516001600160e01b031960e086901b168152921515600484015260248301919091526001600160a01b03908116604483015260dc60648301528516608482015260a4016124cf565b60ce54600090600160a81b900460ff16156134d457506000919050565b6134dd826133d8565b60db54733252456634469ce6c2540c02cbfa98320e32f223906339be6e51906001600160a01b031661350d613ab3565b60d55461351861338c565b6040516001600160e01b031960e087901b1681526001600160a01b039485166004820152602481019390935260448301919091528216606482015260dc608482015290851660a482015260c4016124cf565b60008183106133d15781611058565b6001600160a01b038216600090815260dc60205260409020600201546135a0908290615c4d565b6001600160a01b038316600090815260dc602052604090206002015560d5546135ca908290615c4d565b60d5555050565b6001600160a01b038216600090815260dc60205260409020600201546135f89082906159f0565b6001600160a01b038316600090815260dc602052604090206002015560d5546135ca9082906159f0565b6040516001600160a01b03831660248201526044810182905261368590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526141da565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052612a6a9085906323b872dd60e01b9060840161364e565b600082846136ce6142ac565b6136d891906159f0565b6136e29190615c4d565b9050818111156136fe576136f68282615c4d565b60d455612a6a565b600060d45550505050565b8060d25414610dee5760d28190556040518181527fc512617347fd848ec9d7347c99c10e4fa7059132c92d0445930a7fb0c8252ff5906020016110e2565b6137588a8a8a8a8a8a8a8a8a613310565b61150681614316565b60d9546001600160a01b03828116911614610dee5760d980546001600160a01b0319166001600160a01b0383169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a250565b6001600160a01b03811660009081526099602052604090208054600181018255905b50919050565b6000610cb96137f5612af5565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60008060006138478787878761436b565b915091506138548161444e565b5095945050505050565b60006001600160a01b0383166138865760405162461bcd60e51b8152600401610e3790615d07565b6127108211156138c05760405162461bcd60e51b8152602060048201526005602482015264216c6f737360d81b6044820152606401610e37565b60006138cc3386614604565b905060006138d98261339b565b60db546040516370a0823160e01b81529192506000916001600160a01b03909116906370a082319061390f903090600401615338565b60206040518083038186803b15801561392757600080fd5b505afa15801561393b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061395f9190615af1565b9050600081831115613a0c5761397483614650565b90508015613989576139868184615c4d565b92505b60db546040516370a0823160e01b81526001600160a01b03909116906370a08231906139b9903090600401615338565b60206040518083038186803b1580156139d157600080fd5b505afa1580156139e5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a099190615af1565b91505b81831115613a2957819250613a26818461320291906159f0565b93505b612710613a3682856159f0565b613a409088615df9565b613a4a9190615e18565b811115613a865760405162461bcd60e51b815260206004820152600a6024820152691b1bdcdcc81b1a5b5a5d60b21b6044820152606401610e37565b613a9033856149d7565b60db54613aa7906001600160a01b03168885613622565b50909695505050505050565b60d55460db546040516370a0823160e01b8152600092916001600160a01b0316906370a0823190613ae8903090600401615338565b60206040518083038186803b158015613b0057600080fd5b505afa158015613b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b389190615af1565b610dc391906159f0565b6001600160a01b038116613b8f5760405162461bcd60e51b81526020600482015260146024820152731859191c995cdcc81a5cc81b9bdd081d985b1a5960621b6044820152606401610e37565b60ce546001600160a01b0382811691161415613be65760405162461bcd60e51b815260206004820152601660248201527530b63932b0b23c903a34329033b0ba32b5b2b2b832b960511b6044820152606401610e37565b60ce80546001600160a01b0319166001600160a01b0383161790556040517f2ae33fe0c6f544449738f838b5b9f63f9487de59447d108fcaf7aa24c06048ef906110e2908390615338565b6127108110613c525760405162461bcd60e51b8152600401610e3790615ce7565b8060d05414610dee5760d08190556040518181527f2147e2bc8c39e67f74b1a9e08896ea1485442096765942206af1f4bc8bcde917906020016110e2565b6001600160a01b038316613cbe576001600160a01b038216600090815260de60205260409020439055613d0e565b6001600160a01b038316600090815260de60205260409020544311613d0e5760405162461bcd60e51b815260206004820152600660248201526521626c6f636b60d01b6044820152606401610e37565b60dd546001600160a01b031615613685576001600160a01b03831615613d915760dd5460405163cafecbdf60e01b81526001600160a01b039091169063cafecbdf90613d5e908690600401615338565b600060405180830381600087803b158015613d7857600080fd5b505af1158015613d8c573d6000803e3d6000fd5b505050505b6001600160a01b038216156136855760dd5460405163cafecbdf60e01b81526001600160a01b039091169063cafecbdf90613dd0908590600401615338565b600060405180830381600087803b158015613dea57600080fd5b505af1158015613dfe573d6000803e3d6000fd5b50505050505050565b6000806001600160a01b03851615613e61576000613e248661245b565b6001600160a01b03871660009081526101a760205260409020805490829055909150613e5081856159f0565b9350613e5c82846159f0565b925050505b6001600160a01b03841615613eb8576000613e7b8561245b565b6001600160a01b03861660009081526101a760205260409020805490829055909150613ea781856159f0565b9350613eb382846159f0565b925050505b80826101a854613ec89190615c4d565b613ed291906159f0565b6101a8555050505050565b803b613f415760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610e37565b600080516020615f1683398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b613fcf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610e37565b600080846001600160a01b031684604051613fea9190615e3a565b600060405180830381855af49150503d8060008114614025576040519150601f19603f3d011682016040523d82523d6000602084013e61402a565b606091505b50915091506140528282604051806060016040528060278152602001615f3660279139614b26565b95945050505050565b61406481613edd565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60db546040516370a0823160e01b815260009182916140d69185916001600160a01b03909116906370a0823190613110908990600401615338565b90506140e4816131606126ee565b9050600081116110585760405162461bcd60e51b8152600401610e3790615e56565b60008061411260355490565b90506000808211614123578361413f565b61412b6141be565b6141358386615df9565b61413f9190615e18565b9050600081116141615760405162461bcd60e51b8152600401610e3790615e56565b6130d48582614b5f565b6000806141766141be565b905060008111614187576000611058565b8061419160355490565b61419b9085615df9565b6110589190615e18565b6141b58989898989898888614c40565b61332983614c6b565b60006141c86142ac565b6141d0613ab3565b610dc39190615c4d565b600061422f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614d3a9092919063ffffffff16565b805190915015613685578080602001905181019061424d9190615d2b565b6136855760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610e37565b60008060d15460d354426142c09190615c4d565b6142ca9190615df9565b9050670de0b6b3a764000081106142e2576000614310565b670de0b6b3a764000060d454826142f99190615df9565b6143039190615e18565b60d4546143109190615c4d565b91505090565b6001600160a01b03811661433c5760405162461bcd60e51b8152600401610e3790615bfd565b6101aa80546001600160a01b0319166001600160a01b03929092169190911790556001600960801b016101a955565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156143985750600090506003614445565b8460ff16601b141580156143b057508460ff16601c14155b156143c15750600090506004614445565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015614415573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661443e57600060019250925050614445565b9150600090505b94509492505050565b600081600481111561446257614462615e77565b141561446b5750565b600181600481111561447f5761447f615e77565b14156144c85760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606401610e37565b60028160048111156144dc576144dc615e77565b141561452a5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610e37565b600381600481111561453e5761453e615e77565b14156145975760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610e37565b60048160048111156145ab576145ab615e77565b1415610dee5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610e37565b6000806146148361316086611443565b9050600081116110585760405162461bcd60e51b81526020600482015260076024820152662173686172657360c81b6044820152606401610e37565b600080828161465d61338c565b6001600160a01b03166390ab8d1f306040518263ffffffff1660e01b81526004016146889190615338565b60006040518083038186803b1580156146a057600080fd5b505afa1580156146b4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526146dc9190810190615d48565b905060005b81518110156149cd5760008282815181106146fe576146fe615cb6565b602090810291909101015160db546040516370a0823160e01b815291925082916000916001600160a01b0316906370a082319061473f903090600401615338565b60206040518083038186803b15801561475757600080fd5b505afa15801561476b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061478f9190615af1565b90508086116147a0575050506149cd565b60006147d06147af8389615c4d565b6001600160a01b038616600090815260dc602052604090206002015461356a565b9050806147e057505050506149bb565b604051632e1a7d4d60e01b8152600481018290526000906001600160a01b03851690632e1a7d4d90602401602060405180830381600087803b15801561482557600080fd5b505af1158015614839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061485d9190615af1565b60db546040516370a0823160e01b815291925060009185916001600160a01b0316906370a0823190614893903090600401615338565b60206040518083038186803b1580156148ab57600080fd5b505afa1580156148bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148e39190615af1565b6148ed9190615c4d565b905081156149aa576148ff828a615c4d565b985061490b828b6159f0565b9950733252456634469ce6c2540c02cbfa98320e32f22363d16075dd60dc8860d55461493561338c565b876040518663ffffffff1660e01b8152600401614956959493929190615c1f565b60206040518083038186803b15801561496e57600080fd5b505af4158015614982573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149a69190615af1565b60d5555b6149b48682613579565b5050505050505b806149c581615ccc565b9150506146e1565b5091949350505050565b6001600160a01b038216614a375760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610e37565b614a4382600083613c90565b6001600160a01b03821660009081526033602052604090205481811015614ab75760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610e37565b6001600160a01b0383166000908152603360205260408120838303905560358054849290614ae6908490615c4d565b90915550506040518281526000906001600160a01b03851690600080516020615f5d8339815191529060200160405180910390a361368583600084613e07565b60608315614b35575081611058565b825115614b455782518084602001fd5b8160405162461bcd60e51b8152600401610e379190615378565b6001600160a01b038216614bb55760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610e37565b614bc160008383613c90565b8060356000828254614bd391906159f0565b90915550506001600160a01b03821660009081526033602052604081208054839290614c009084906159f0565b90915550506040518181526001600160a01b03831690600090600080516020615f5d8339815191529060200160405180910390a36112db60008383613e07565b614c4a8888614d49565b614c5388614d82565b614c61868686868686614ddd565b5050505050505050565b6001600160a01b038116614c915760405162461bcd60e51b8152600401610e3790615a69565b60db80546001600160a01b0319166001600160a01b0383169081179091556040805163313ce56760e01b8152905163313ce56791600480820192602092909190829003018186803b158015614ce557600080fd5b505afa158015614cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d1d9190615e8d565b60ce60146101000a81548160ff021916908360ff16021790555050565b60606130d48484600085614e0b565b600054610100900460ff16614d705760405162461bcd60e51b8152600401610e3790615eaa565b614d78614f33565b6112db8282614f5a565b600054610100900460ff16614da95760405162461bcd60e51b8152600401610e3790615eaa565b614db1614f33565b614dd481604051806040016040528060018152602001603160f81b815250614fa8565b610dee81614fe9565b614de686615037565b614def85615048565b614df7615059565b614e03848484846150a1565b505050505050565b606082471015614e6c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610e37565b843b614eba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610e37565b600080866001600160a01b03168587604051614ed69190615e3a565b60006040518083038185875af1925050503d8060008114614f13576040519150601f19603f3d011682016040523d82523d6000602084013e614f18565b606091505b5091509150614f28828286614b26565b979650505050505050565b600054610100900460ff16610fb15760405162461bcd60e51b8152600401610e3790615eaa565b600054610100900460ff16614f815760405162461bcd60e51b8152600401610e3790615eaa565b8151614f94906036906020850190615233565b508051613685906037906020840190615233565b600054610100900460ff16614fcf5760405162461bcd60e51b8152600401610e3790615eaa565b815160209283012081519190920120606591909155606655565b600054610100900460ff166150105760405162461bcd60e51b8152600401610e3790615eaa565b507f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9609a55565b61503f6150c5565b610dee816150f4565b6150506150c5565b610dee81615126565b60ce805460ff60a01b1916600960a11b179055620f4240615083670de0b6b3a7640000602e615df9565b61508d9190615e18565b60d15560001960d2554260cf81905560d355565b6150aa84612cdb565b6150b38361514f565b6150bc82613761565b612a6a816151d4565b600054610100900460ff166150ec5760405162461bcd60e51b8152600401610e3790615eaa565b610fb1614f33565b336001600160a01b038216141561511d5760405162461bcd60e51b8152600401610e3790615c8d565b610dee81612851565b336001600160a01b038216141561243b5760405162461bcd60e51b8152600401610e3790615c8d565b6001600160a01b0381166151755760405162461bcd60e51b8152600401610e3790615ce7565b60d8546001600160a01b03828116911614610dee5760d880546001600160a01b0319166001600160a01b0383169081179091556040517f812bdb126c250b52603ba4414e31e40e34c756275a9233ab38bd75c3ed1977ca90600090a250565b60dd546001600160a01b03828116911614610dee5760dd80546001600160a01b0319166001600160a01b0383169081179091556040517ffc9e517c762f1b253f79aa322d32d22d521ecd0589fa41711000f02febf7d92990600090a250565b82805461523f90615931565b90600052602060002090601f01602090048101928261526157600085556152a7565b82601f1061527a57805160ff19168380011785556152a7565b828001600101855582156152a7579182015b828111156152a757825182559160200191906001019061528c565b506152b39291506152b7565b5090565b5b808211156152b357600081556001016152b8565b6001600160a01b0381168114610dee57600080fd5b80356152ec816152cc565b919050565b60006020828403121561530357600080fd5b8135611058816152cc565b60006020828403121561532057600080fd5b81356001600160e01b03198116811461105857600080fd5b6001600160a01b0391909116815260200190565b60005b8381101561536757818101518382015260200161534f565b83811115612a6a5750506000910152565b602081526000825180602084015261539781604085016020870161534c565b601f01601f19169190910160400192915050565b600080604083850312156153be57600080fd5b82356153c9816152cc565b946020939093013593505050565b6000806000606084860312156153ec57600080fd5b83356153f7816152cc565b92506020840135615407816152cc565b929592945050506040919091013590565b60006020828403121561542a57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561546f5761546f615431565b604052919050565b60006001600160401b0383111561549057615490615431565b6154a3601f8401601f1916602001615447565b90508281528383830111156154b757600080fd5b828260208301376000602084830101529392505050565b600080604083850312156154e157600080fd5b82356154ec816152cc565b915060208301356001600160401b0381111561550757600080fd5b8301601f8101851361551857600080fd5b61552785823560208401615477565b9150509250929050565b8015158114610dee57600080fd5b60006020828403121561555157600080fd5b813561105881615531565b6000806040838503121561556f57600080fd5b823561557a816152cc565b9150602083013561558a816152cc565b809150509250929050565b600080604083850312156155a857600080fd5b82359150602083013561558a816152cc565b600082601f8301126155cb57600080fd5b61105883833560208501615477565b60008060008060008060008060006101208a8c0312156155f957600080fd5b89356001600160401b038082111561561057600080fd5b61561c8d838e016155ba565b9a5060208c013591508082111561563257600080fd5b5061563f8c828d016155ba565b98505060408a0135615650816152cc565b965060608a0135615660816152cc565b955061566e60808b016152e1565b945061567c60a08b016152e1565b935061568a60c08b016152e1565b925061569860e08b016152e1565b91506156a76101008b016152e1565b90509295985092959850929598565b6000806000606084860312156156cb57600080fd5b505081359360208301359350604090920135919050565b6000806000806000806000806000806101408b8d03121561570257600080fd5b8a356001600160401b038082111561571957600080fd5b6157258e838f016155ba565b9b5060208d013591508082111561573b57600080fd5b506157488d828e016155ba565b99505061575760408c016152e1565b975061576560608c016152e1565b965061577360808c016152e1565b955061578160a08c016152e1565b945061578f60c08c016152e1565b935061579d60e08c016152e1565b92506157ac6101008c016152e1565b91506157bb6101208c016152e1565b90509295989b9194979a5092959850565b80356001600160801b03811681146152ec57600080fd5b600080604083850312156157f657600080fd5b6157ff836157cc565b915061580d602084016157cc565b90509250929050565b60ff81168114610dee57600080fd5b600080600080600080600060e0888a03121561584057600080fd5b873561584b816152cc565b9650602088013561585b816152cc565b95506040880135945060608801359350608088013561587981615816565b9699959850939692959460a0840135945060c09093013592915050565b600080602083850312156158a957600080fd5b82356001600160401b03808211156158c057600080fd5b818501915085601f8301126158d457600080fd5b8135818111156158e357600080fd5b8660208260051b85010111156158f857600080fd5b60209290920196919550909350505050565b60008060006060848603121561591f57600080fd5b833592506020840135615407816152cc565b600181811c9082168061594557607f821691505b602082108114156137e257634e487b7160e01b600052602260045260246000fd5b6020808252602c90820152600080516020615ef683398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020615ef683398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008219821115615a0357615a036159da565b500190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526006908201526510ba37b5b2b760d11b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6001600160a01b0392831681529116602082015260400190565b600060208284031215615b0357600080fd5b5051919050565b600181815b80851115615b45578160001904821115615b2b57615b2b6159da565b80851615615b3857918102915b93841c9390800290615b0f565b509250929050565b600082615b5c57506001610cb9565b81615b6957506000610cb9565b8160018114615b7f5760028114615b8957615ba5565b6001915050610cb9565b60ff841115615b9a57615b9a6159da565b50506001821b610cb9565b5060208310610133831016604e8410600b8410161715615bc8575081810a610cb9565b615bd28383615b0a565b8060001904821115615be657615be66159da565b029392505050565b600061105860ff841683615b4d565b602080825260089082015267217374616b696e6760c01b604082015260600190565b9485526001600160a01b03938416602086015260408501929092529091166060830152608082015260a00190565b600082821015615c5f57615c5f6159da565b500390565b6020808252600f908201526e676f7665726e616e6365206f6e6c7960881b604082015260600190565b6020808252600f908201526e696e76616c6964206164647265737360881b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415615ce057615ce06159da565b5060010190565b602080825260069082015265085a5b9c1d5d60d21b604082015260600190565b6020808252600a9082015269085c9958da5c1a595b9d60b21b604082015260600190565b600060208284031215615d3d57600080fd5b815161105881615531565b60006020808385031215615d5b57600080fd5b82516001600160401b0380821115615d7257600080fd5b818501915085601f830112615d8657600080fd5b815181811115615d9857615d98615431565b8060051b9150615da9848301615447565b8181529183018401918481019088841115615dc357600080fd5b938501935b83851015615ded5784519250615ddd836152cc565b8282529385019390850190615dc8565b98975050505050505050565b6000816000190483118215151615615e1357615e136159da565b500290565b600082615e3557634e487b7160e01b600052601260045260246000fd5b500490565b60008251615e4c81846020870161534c565b9190910192915050565b60208082526007908201526608585b5bdd5b9d60ca1b604082015260600190565b634e487b7160e01b600052602160045260246000fd5b600060208284031215615e9f57600080fd5b815161105881615816565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122072121bf554a834d7f12d7324bd84a33ea510366fa1be1c954e662afb02b4ffdf64736f6c63430008090033
Deployed Bytecode
0x6080604052600436106103505760003560e01c806380f83adc116101b957806380f83adc1461083c578063831983341461085c5780638429d51f1461087c5780638456cb591461089c57806394abf3e5146108b157806395d89b41146108d157806399530b06146108e65780639dd373b9146108fb578063a0e4af9a1461091b578063a1d9bafc14610930578063a457c2d714610950578063a59c9c2714610970578063a6f7f5d614610990578063a9059cbb146109a6578063b252720b146109c6578063bdc8144b146109e6578063bdcf36bb14610a06578063c373a08e14610a26578063c733e16814610a46578063c958080414610a66578063ccdc2c2314610a86578063d505accf14610aa6578063d764801314610ac6578063dd62ed3e14610ae6578063deabb80014610b2c578063e63697c814610b4c578063ecf7085814610b6c578063edbcfdf214610b82578063ee99205c14610ba2578063f39c38a014610bc3578063f9170d8f14610be3578063f9557ccb14610c03578063fbb9795614610c18578063fc0c546a14610c38578063fc7b9c1814610c58578063fdcb606814610c6e578063fe56e23214610c8e57600080fd5b8062ae6e0f1461035557806301ffc9a71461038857806302d05d3f146103b857806306fdde03146103e5578063095ea7b3146104075780630dda72991461042757806311bc82451461043c578063153c27c41461045e57806318160ddd146104735780631beabcd214610488578063223e5479146104a8578063228bfd9f146104c8578063238efcbc1461052a57806323b872dd1461053f5780632d9e1a7d1461055f578063313ce5671461057f57806333586b67146105ab5780633403c2fc146105cb5780633629c8de146105ec5780633644e515146106025780633659cfe6146106175780633786df5e1461063757806339509351146106575780633f4ba83a1461067757806344b813961461068c5780634f1ef286146106a257806354fd4d50146106b55780635aa6e675146106e35780635c975abb146107035780635ee9ca141461071b5780636cb56d191461073b5780636e553f651461075b5780636ea056a91461077b57806370a082311461079b57806375de2902146107bb5780637ecebe00146107d05780637f0f10e6146107f0575b600080fd5b34801561036157600080fd5b506103756103703660046152f1565b610cae565b6040519081526020015b60405180910390f35b34801561039457600080fd5b506103a86103a336600461530e565b610cbf565b604051901515815260200161037f565b3480156103c457600080fd5b5060da546103d8906001600160a01b031681565b60405161037f9190615338565b3480156103f157600080fd5b506103fa610cf2565b60405161037f9190615378565b34801561041357600080fd5b506103a86104223660046153ab565b610d84565b34801561043357600080fd5b50610375610d9a565b34801561044857600080fd5b5061045c6104573660046152f1565b610dd0565b005b34801561046a57600080fd5b50610375610df1565b34801561047f57600080fd5b50603554610375565b34801561049457600080fd5b506103756104a33660046152f1565b610dfb565b3480156104b457600080fd5b506103a86104c33660046152f1565b610e9a565b3480156104d457600080fd5b506104e86104e33660046152f1565b610eb5565b60405161037f9190600060a082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b34801561053657600080fd5b5061045c610f3f565b34801561054b57600080fd5b506103a861055a3660046153d7565b610fb3565b34801561056b57600080fd5b5061045c61057a366004615418565b61105f565b34801561058b57600080fd5b5060ce54600160a01b900460ff1660405160ff909116815260200161037f565b3480156105b757600080fd5b506103756105c63660046152f1565b6110ed565b3480156105d757600080fd5b5060ce546103a890600160a81b900460ff1681565b3480156105f857600080fd5b5061037560cf5481565b34801561060e57600080fd5b506103756110f8565b34801561062357600080fd5b5061045c6106323660046152f1565b611102565b34801561064357600080fd5b5061045c6106523660046152f1565b6111c8565b34801561066357600080fd5b506103a86106723660046153ab565b6111d9565b34801561068357600080fd5b5061045c611215565b34801561069857600080fd5b5061037560d45481565b61045c6106b03660046154ce565b611225565b3480156106c157600080fd5b506040805180820190915260058152640302e322e360dc1b60208201526103fa565b3480156106ef57600080fd5b5060cc546103d8906001600160a01b031681565b34801561070f57600080fd5b5060df5460ff166103a8565b34801561072757600080fd5b5061045c61073636600461553f565b6112df565b34801561074757600080fd5b506103a861075636600461555c565b61136c565b34801561076757600080fd5b50610375610776366004615595565b611380565b34801561078757600080fd5b5061045c6107963660046153ab565b6113f4565b3480156107a757600080fd5b506103756107b63660046152f1565b611443565b3480156107c757600080fd5b5061037561145e565b3480156107dc57600080fd5b506103756107eb3660046152f1565b611468565b3480156107fc57600080fd5b506101a95461081c906001600160801b0380821691600160801b90041682565b604080516001600160801b0393841681529290911660208301520161037f565b34801561084857600080fd5b5060d8546103d8906001600160a01b031681565b34801561086857600080fd5b5061045c6108773660046155da565b611486565b34801561088857600080fd5b5060dd546103d8906001600160a01b031681565b3480156108a857600080fd5b5061045c611512565b3480156108bd57600080fd5b506103756108cc3660046152f1565b61152f565b3480156108dd57600080fd5b506103fa6115b6565b3480156108f257600080fd5b506103756115c5565b34801561090757600080fd5b5061045c6109163660046152f1565b6115e9565b34801561092757600080fd5b5061045c611679565b34801561093c57600080fd5b5061037561094b3660046156b6565b611725565b34801561095c57600080fd5b506103a861096b3660046153ab565b611ddc565b34801561097c57600080fd5b5060ce546103d8906001600160a01b031681565b34801561099c57600080fd5b5061037560d05481565b3480156109b257600080fd5b506103a86109c13660046153ab565b611e75565b3480156109d257600080fd5b5060d7546103d8906001600160a01b031681565b3480156109f257600080fd5b5061045c610a01366004615418565b611e82565b348015610a1257600080fd5b50610375610a213660046152f1565b611ea0565b348015610a3257600080fd5b5061045c610a413660046152f1565b611eab565b348015610a5257600080fd5b5061045c610a613660046156e2565b611fa6565b348015610a7257600080fd5b5061045c610a813660046152f1565b612034565b348015610a9257600080fd5b5061045c610aa13660046157e3565b612052565b348015610ab257600080fd5b5061045c610ac1366004615825565b612074565b348015610ad257600080fd5b50610375610ae13660046152f1565b6121ae565b348015610af257600080fd5b50610375610b0136600461555c565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b348015610b3857600080fd5b5061045c610b47366004615896565b6121b9565b348015610b5857600080fd5b50610375610b6736600461590a565b61237c565b348015610b7857600080fd5b5061037560d25481565b348015610b8e57600080fd5b5060d6546103d8906001600160a01b031681565b348015610bae57600080fd5b506101aa546103d8906001600160a01b031681565b348015610bcf57600080fd5b5060cd546103d8906001600160a01b031681565b348015610bef57600080fd5b5061045c610bfe3660046152f1565b6123f2565b348015610c0f57600080fd5b50610375612429565b348015610c2457600080fd5b5061045c610c333660046152f1565b612433565b348015610c4457600080fd5b5060db546103d8906001600160a01b031681565b348015610c6457600080fd5b5061037560d55481565b348015610c7a57600080fd5b5060d9546103d8906001600160a01b031681565b348015610c9a57600080fd5b5061045c610ca9366004615418565b612444565b6000610cb98261245b565b92915050565b60006001600160e01b0319821663bf8b4f0760e01b1480610cb95750506001600160e01b0319166301ffc9a760e01b1490565b606060368054610d0190615931565b80601f0160208091040260200160405190810160405280929190818152602001828054610d2d90615931565b8015610d7a5780601f10610d4f57610100808354040283529160200191610d7a565b820191906000526020600020905b815481529060010190602001808311610d5d57829003601f168201915b5050505050905090565b6000610d913384846124fb565b50600192915050565b60006101a8546000148015610db757506000610db560355490565b115b15610dc8575060355490565b905090565b506101a85490565b60cc54610de5906001600160a01b031661261f565b610dee8161268f565b50565b6000610dc36126ee565b60006001600160a01b038216610e405760405162461bcd60e51b815260206004820152600560248201526410bab9b2b960d91b60448201526064015b60405180910390fd5b6001600160a01b03821660009081526101a76020526040902054158015610e6f57506000610e6d83611443565b115b15610e7d57610cb982611443565b506001600160a01b031660009081526101a7602052604090205490565b6000610ea461271b565b610eac61276a565b610cb9826127be565b610ee76040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b506001600160a01b0316600090815260dc6020908152604091829020825160a0810184528154815260018201549281019290925260028101549282019290925260038201546060820152600490910154608082015290565b60cd546001600160a01b0316336001600160a01b031614610f9c5760405162461bcd60e51b815260206004820152601760248201527670656e64696e6720676f7665726e616e6365206f6e6c7960481b6044820152606401610e37565b60cd54610fb1906001600160a01b0316612851565b565b6000610fc084848461289d565b6001600160a01b0384166000908152603460209081526040808320338452909152902054828110156110455760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610e37565b61105285338584036124fb565b60019150505b9392505050565b611067612a70565b670de0b6b3a76400008111156110a85760405162461bcd60e51b81526020600482015260066024820152652176616c756560d01b6044820152606401610e37565b8060d15414610dee5760d18190556040518181527f056863905a721211fc4dda1d688efc8f120b4b689d2e41da8249cf6eff200691906020015b60405180910390a150565b6000610cb982612aa3565b6000610dc3612af5565b306001600160a01b037f0000000000000000000000005766c392ecc8deef0a1fad6286591d67414a58e216141561114b5760405162461bcd60e51b8152600401610e3790615966565b7f0000000000000000000000005766c392ecc8deef0a1fad6286591d67414a58e26001600160a01b031661117d612b70565b6001600160a01b0316146111a35760405162461bcd60e51b8152600401610e37906159a0565b6111ac81612b8c565b60408051600080825260208201909252610dee91839190612b94565b6111d0612a70565b610dee81612cdb565b3360008181526034602090815260408083206001600160a01b03871684529091528120549091610d919185906112109086906159f0565b6124fb565b61121d612a70565b610fb1612d60565b306001600160a01b037f0000000000000000000000005766c392ecc8deef0a1fad6286591d67414a58e216141561126e5760405162461bcd60e51b8152600401610e3790615966565b7f0000000000000000000000005766c392ecc8deef0a1fad6286591d67414a58e26001600160a01b03166112a0612b70565b6001600160a01b0316146112c65760405162461bcd60e51b8152600401610e37906159a0565b6112cf82612b8c565b6112db82826001612b94565b5050565b80156112ff5760cc546112fa906001600160a01b031661261f565b611307565b611307612a70565b60ce5460ff600160a81b90910416151581151514610dee5760ce8054821515600160a81b0260ff60a81b199091161790556040517fba40372a3a724dca3c57156128ef1e896724b65b37a17f190b1ad5de68f3a4f3906110e290831515815260200190565b600061137661276a565b6110588383612ded565b600061138e60df5460ff1690565b156113ab5760405162461bcd60e51b8152600401610e3790615a08565b60026101115414156113cf5760405162461bcd60e51b8152600401610e3790615a32565b6002610111556113dd61271b565b6113e78383612fb1565b6001610111559392505050565b6113fc612a70565b60db546001600160a01b038381169116141561142a5760405162461bcd60e51b8152600401610e3790615a69565b60cc546112db90839083906001600160a01b03166130dc565b6001600160a01b031660009081526033602052604090205490565b6000610dc361317b565b6001600160a01b038116600090815260996020526040812054610cb9565b600054610100900460ff166114a15760005460ff16156114a5565b303b155b6114c15760405162461bcd60e51b8152600401610e3790615a89565b600054610100900460ff161580156114e3576000805461ffff19166101011790555b6114f48a8a8a8a8a8a8a8a8a613310565b8015611506576000805461ff00191690555b50505050505050505050565b60cc54611527906001600160a01b031661261f565b610fb1613334565b600061153961338c565b6001600160a01b031663a5145b4630846040518363ffffffff1660e01b8152600401611566929190615ad7565b60206040518083038186803b15801561157e57600080fd5b505afa158015611592573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb99190615af1565b606060378054610d0190615931565b60ce54600090610dc3906115e490600160a01b900460ff16600a615bee565b61339b565b6115f1612a70565b6001600160a01b0381166116175760405162461bcd60e51b8152600401610e3790615bfd565b6101aa546001600160a01b03828116911614610dee576101aa80546001600160a01b0319166001600160a01b0383161790556040517f6397f5b135542bb3f477cb346cfab5abdec1251d08dc8f8d4efb4ffe122ea0bf906110e2908390615338565b611682336133d8565b61168a61338c565b6001600160a01b031663ba6db98d336040518263ffffffff1660e01b81526004016116b59190615338565b600060405180830381600087803b1580156116cf57600080fd5b505af11580156116e3573d6000803e3d6000fd5b505050506116ee3390565b6001600160a01b03167f4201c688d84c01154d321afa0c72f1bffe9eef53005c9de9d035074e71e9b32a60405160405180910390a2565b600033611731816133d8565b61173b83866159f0565b60db546040516370a0823160e01b81526001600160a01b03909116906370a082319061176b908590600401615338565b60206040518083038186803b15801561178357600080fd5b505afa158015611797573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117bb9190615af1565b10156117f45760405162461bcd60e51b81526020600482015260086024820152672162616c616e636560c01b6044820152606401610e37565b60d754733252456634469ce6c2540c02cbfa98320e32f2239063f4daf9f0906001600160a01b03168388888861182984613429565b6001600160a01b03898116600090815260dc60205260409081902060020154905160e08a901b6001600160e01b031916815297821660048901529516602487015260448601939093526064850191909152608484015260a483015260c482015260e40160006040518083038186803b1580156118a457600080fd5b505af41580156118b8573d6000803e3d6000fd5b50505050733252456634469ce6c2540c02cbfa98320e32f22363d16075dd60dc8360d5546118e461338c565b896040518663ffffffff1660e01b8152600401611905959493929190615c1f565b60206040518083038186803b15801561191d57600080fd5b505af4158015611931573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119559190615af1565b60d5556001600160a01b038116600090815260dc602052604090206003015461197f9086906159f0565b6001600160a01b03808316600090815260dc6020819052604082206003019390935560db5460d65460d0549294733252456634469ce6c2540c02cbfa98320e32f223946346c2111a949381169392169187908c906119db61338c565b6001600160a01b03166326d3ce3f308c6040518363ffffffff1660e01b8152600401611a08929190615ad7565b60206040518083038186803b158015611a2057600080fd5b505afa158015611a34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a589190615af1565b6040516001600160e01b031960e08a901b1681526001600160a01b03978816600482015295871660248701526044860194909452949091166064840152608483015260a482019290925260c481019190915260e40160206040518083038186803b158015611ac557600080fd5b505af4158015611ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611afd9190615af1565b90506000611b0a836134b7565b90506000611b1784613429565b90506000611b25828861356a565b90508015611b4457611b378582613579565b611b418183615c4d565b91505b8215611b5457611b5485846135d1565b6000611b60828b6159f0565b905083811015611b9057611b8b86611b788387615c4d565b60db546001600160a01b03169190613622565b611bbb565b83811115611bbb57611bbb8630611ba78785615c4d565b60db546001600160a01b031692919061368a565b611bc68a868b6136c2565b6001600160a01b038616600090815260dc60209081526040808320426001820181905560d3819055825160a08101845282548152938401526002810154918301919091526003810154606083015260040154608082015290611c2661338c565b6001600160a01b031663a5145b46308a6040518363ffffffff1660e01b8152600401611c53929190615ad7565b60206040518083038186803b158015611c6b57600080fd5b505afa158015611c7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca39190615af1565b9050876001600160a01b03167f67f96d2854a335a4cadb49f84fd3ca6f990744ddb3feceeb4b349d2d53d32ad38d8d878660600151876080015188604001518d89604051611d29989796959493929190978852602088019690965260408701949094526060860192909252608085015260a084015260c083015260e08201526101000190565b60405180910390a2801580611d47575060ce54600160a81b900460ff165b15611dcc57876001600160a01b031663efbb5cb06040518163ffffffff1660e01b815260040160206040518083038186803b158015611d8557600080fd5b505afa158015611d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dbd9190615af1565b98505050505050505050611058565b8498505050505050505050611058565b3360009081526034602090815260408083206001600160a01b038616845290915281205482811015611e5e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610e37565b611e6b33858584036124fb565b5060019392505050565b6000610d9133848461289d565b60cc54611e97906001600160a01b031661261f565b610dee81613709565b6000610cb982613429565b60cc546001600160a01b0316336001600160a01b031614611ede5760405162461bcd60e51b8152600401610e3790615c64565b6001600160a01b038116611f045760405162461bcd60e51b8152600401610e3790615c8d565b60cc546001600160a01b0382811691161415611f5b5760405162461bcd60e51b8152602060048201526016602482015275616c72656164792074686520676f7665726e616e636560501b6044820152606401610e37565b60cd80546001600160a01b0319166001600160a01b0383161790556040517f9a35a2aeba8eb8a43609155078e2fd5cbafd797e0a76ec701999554effda58e4906110e2908390615338565b600054610100900460ff16611fc15760005460ff1615611fc5565b303b155b611fe15760405162461bcd60e51b8152600401610e3790615a89565b600054610100900460ff16158015612003576000805461ffff19166101011790555b6120158b8b8b8b8b8b8b8b8b8b613747565b8015612027576000805461ff00191690555b5050505050505050505050565b60cc54612049906001600160a01b031661261f565b610dee81613761565b61205a612a70565b6001600160801b03908116600160801b029116176101a955565b834211156120c45760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610e37565b6000609a548888886120d58c6137c0565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000612130826137e8565b9050600061214082878787613836565b9050896001600160a01b0316816001600160a01b0316146121a35760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610e37565b6115068a8a8a6124fb565b6000610cb9826134b7565b60008060005b838110156123575760dd546001600160a01b03161561225f5760dd546001600160a01b031663cafecbdf8686848181106121fb576121fb615cb6565b905060200201602081019061221091906152f1565b6040518263ffffffff1660e01b815260040161222c9190615338565b600060405180830381600087803b15801561224657600080fd5b505af115801561225a573d6000803e3d6000fd5b505050505b60006101a7600087878581811061227857612278615cb6565b905060200201602081019061228d91906152f1565b6001600160a01b03166001600160a01b0316815260200190815260200160002054905060006122e18787858181106122c7576122c7615cb6565b90506020020160208101906122dc91906152f1565b61245b565b9050806101a760008989878181106122fb576122fb615cb6565b905060200201602081019061231091906152f1565b6001600160a01b0316815260208101919091526040016000205561233482866159f0565b945061234081856159f0565b93505050808061234f90615ccc565b9150506121bf565b5080826101a8546123689190615c4d565b61237291906159f0565b6101a85550505050565b600061238a60df5460ff1690565b156123a75760405162461bcd60e51b8152600401610e3790615a08565b60026101115414156123cb5760405162461bcd60e51b8152600401610e3790615a32565b6002610111556123d961271b565b6123e484848461385e565b600161011155949350505050565b60cc54612407906001600160a01b031661261f565b60da80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610dc3613ab3565b61243b612a70565b610dee81613b42565b61244c612a70565b610dee81613c31565b3b151590565b6101aa546101a954604051631a4d9d2960e11b81526001600160a01b03808516600483015290921660248301523060448301526001600160801b038082166064840152600160801b909104166084820152600090733252456634469ce6c2540c02cbfa98320e32f2239063349b3a529060a4015b60206040518083038186803b1580156124e757600080fd5b505af4158015611592573d6000803e3d6000fd5b6001600160a01b03831661255d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610e37565b6001600160a01b0382166125be5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610e37565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b336001600160a01b0382161480612655575060ce546001600160a01b031615801590612655575060ce546001600160a01b031633145b610dee5760405162461bcd60e51b815260206004820152600b60248201526a08585d5d1a1bdc9a5cd95960aa1b6044820152606401610e37565b60d7546001600160a01b03828116911614610dee5760d780546001600160a01b0319166001600160a01b0383169081179091556040517f561e696bb6dd103fb892cfd663eedc6af38a38f7c222e2c4deade4f4045f925c90600090a250565b60006126f8613ab3565b60d254116127065750600090565b61270e613ab3565b60d254610dc39190615c4d565b60ce54600160a81b900460ff1615610fb15760405162461bcd60e51b815260206004820152601260248201527132b6b2b933b2b731bc9039b43aba3237bbb760711b6044820152606401610e37565b60d8546001600160a01b0316336001600160a01b031614610fb15760405162461bcd60e51b815260206004820152600e60248201526d21737472617465677953746f726560901b6044820152606401610e37565b6040805160a081018252428082526020808301918252600083850181815260608501828152608086018381526001600160a01b03891680855260dc909552878420965187559451600187015590516002860155516003850155915160049093019290925591517f3f008fd510eae7a9e7bee13513d7b83bef8003d488b5a3d0b0da4de71d6846f1908390a2506001919050565b60cc80546001600160a01b0319166001600160a01b0383169081179091556040517f82d3cb1aac85eaba89545486a5bdf332a6649ee2e53bccf1e2aec0683afced0e916110e291615338565b6001600160a01b0383166129015760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610e37565b6001600160a01b0382166129635760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610e37565b61296e838383613c90565b6001600160a01b038316600090815260336020526040902054818110156129e65760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610e37565b6001600160a01b03808516600090815260336020526040808220858503905591851681529081208054849290612a1d9084906159f0565b92505081905550826001600160a01b0316846001600160a01b0316600080516020615f5d83398151915284604051612a5791815260200190565b60405180910390a3612a6a848484613e07565b50505050565b60cc546001600160a01b0316336001600160a01b031614610fb15760405162461bcd60e51b8152600401610e3790615c64565b6000612aae826133d8565b604051633d26fc9160e21b815260dc60048201526001600160a01b0383166024820152733252456634469ce6c2540c02cbfa98320e32f2239063f49bf244906044016124cf565b6000610dc37f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f612b2460655490565b6066546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b600080516020615f16833981519152546001600160a01b031690565b610dee612a70565b6000612b9e612b70565b9050612ba984613edd565b600083511180612bb65750815b15612bc757612bc58484613f70565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff16612cd457805460ff19166001178155604051612c42908690612c13908590602401615338565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052613f70565b50805460ff19168155612c53612b70565b6001600160a01b0316826001600160a01b031614612ccb5760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b6064820152608401610e37565b612cd48561405b565b5050505050565b6001600160a01b038116612d015760405162461bcd60e51b8152600401610e3790615ce7565b60d6546001600160a01b03828116911614610dee5760d680546001600160a01b0319166001600160a01b0383169081179091556040517f166c82f2c4cd6d3546d8aa18fe78e4b4e6a1baa30de276480b10d2a4faa95a2890600090a250565b60df5460ff16612da95760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610e37565b60df805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051612de39190615338565b60405180910390a1565b60008060dc6000856001600160a01b03166001600160a01b031681526020019081526020016000206040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820154815250509050600060dc6000866001600160a01b03166001600160a01b03168152602001908152602001600020600201819055506040518060a0016040528082600001518152602001826020015181526020018260400151815260200160008152602001600081525060dc6000856001600160a01b03166001600160a01b031681526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040155905050836001600160a01b031663ce5494bb846040518263ffffffff1660e01b8152600401612f3d9190615338565b600060405180830381600087803b158015612f5757600080fd5b505af1158015612f6b573d6000803e3d6000fd5b50506040516001600160a01b038087169350871691507f100b69bb6b504e1252e36b375233158edee64d071b399e2f81473a695fd1b02190600090a35060019392505050565b60006001600160a01b038216612fd95760405162461bcd60e51b8152600401610e3790615d07565b60d9546001600160a01b0316156130a05760d9546001600160a01b0316631709ef0733306040518363ffffffff1660e01b815260040161301a929190615ad7565b60206040518083038186803b15801561303257600080fd5b505afa158015613046573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061306a9190615d2b565b6130a05760405162461bcd60e51b81526020600482015260076024820152662161636365737360c81b6044820152606401610e37565b60006130ac338561409b565b905060006130ba8483614106565b90506130d43360db546001600160a01b031690308561368a565b949350505050565b6040516370a0823160e01b815283906131659084906001600160a01b038416906370a0823190613110903090600401615338565b60206040518083038186803b15801561312857600080fd5b505afa15801561313c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131609190615af1565b61356a565b9250612a6a6001600160a01b0382168385613622565b60db546040516370a0823160e01b81526000918291613207916001600160a01b0316906370a08231906131b2903090600401615338565b60206040518083038186803b1580156131ca57600080fd5b505afa1580156131de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132029190615af1565b61416b565b9050600061321361338c565b6001600160a01b03166390ab8d1f306040518263ffffffff1660e01b815260040161323e9190615338565b60006040518083038186803b15801561325657600080fd5b505afa15801561326a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526132929190810190615d48565b905060005b8151811015613308576132ea60dc60008484815181106132b9576132b9615cb6565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206002015461416b565b6132f490846159f0565b92508061330081615ccc565b915050613297565b509092915050565b6133218989898989898989896141a5565b613329613334565b505050505050505050565b60df5460ff16156133575760405162461bcd60e51b8152600401610e3790615a08565b60df805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612dd63390565b60d8546001600160a01b031690565b6000806133a760355490565b905080156133d157806133b86141be565b6133c29085615df9565b6133cc9190615e18565b611058565b5090919050565b6001600160a01b038116600090815260dc6020526040902054610dee5760405162461bcd60e51b815260206004820152600960248201526821737472617465677960b81b6044820152606401610e37565b6000613434826133d8565b60ce54733252456634469ce6c2540c02cbfa98320e32f2239063cff4e18790600160a81b900460ff16613465613ab3565b61346d61338c565b6040516001600160e01b031960e086901b168152921515600484015260248301919091526001600160a01b03908116604483015260dc60648301528516608482015260a4016124cf565b60ce54600090600160a81b900460ff16156134d457506000919050565b6134dd826133d8565b60db54733252456634469ce6c2540c02cbfa98320e32f223906339be6e51906001600160a01b031661350d613ab3565b60d55461351861338c565b6040516001600160e01b031960e087901b1681526001600160a01b039485166004820152602481019390935260448301919091528216606482015260dc608482015290851660a482015260c4016124cf565b60008183106133d15781611058565b6001600160a01b038216600090815260dc60205260409020600201546135a0908290615c4d565b6001600160a01b038316600090815260dc602052604090206002015560d5546135ca908290615c4d565b60d5555050565b6001600160a01b038216600090815260dc60205260409020600201546135f89082906159f0565b6001600160a01b038316600090815260dc602052604090206002015560d5546135ca9082906159f0565b6040516001600160a01b03831660248201526044810182905261368590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526141da565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052612a6a9085906323b872dd60e01b9060840161364e565b600082846136ce6142ac565b6136d891906159f0565b6136e29190615c4d565b9050818111156136fe576136f68282615c4d565b60d455612a6a565b600060d45550505050565b8060d25414610dee5760d28190556040518181527fc512617347fd848ec9d7347c99c10e4fa7059132c92d0445930a7fb0c8252ff5906020016110e2565b6137588a8a8a8a8a8a8a8a8a613310565b61150681614316565b60d9546001600160a01b03828116911614610dee5760d980546001600160a01b0319166001600160a01b0383169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a250565b6001600160a01b03811660009081526099602052604090208054600181018255905b50919050565b6000610cb96137f5612af5565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60008060006138478787878761436b565b915091506138548161444e565b5095945050505050565b60006001600160a01b0383166138865760405162461bcd60e51b8152600401610e3790615d07565b6127108211156138c05760405162461bcd60e51b8152602060048201526005602482015264216c6f737360d81b6044820152606401610e37565b60006138cc3386614604565b905060006138d98261339b565b60db546040516370a0823160e01b81529192506000916001600160a01b03909116906370a082319061390f903090600401615338565b60206040518083038186803b15801561392757600080fd5b505afa15801561393b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061395f9190615af1565b9050600081831115613a0c5761397483614650565b90508015613989576139868184615c4d565b92505b60db546040516370a0823160e01b81526001600160a01b03909116906370a08231906139b9903090600401615338565b60206040518083038186803b1580156139d157600080fd5b505afa1580156139e5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a099190615af1565b91505b81831115613a2957819250613a26818461320291906159f0565b93505b612710613a3682856159f0565b613a409088615df9565b613a4a9190615e18565b811115613a865760405162461bcd60e51b815260206004820152600a6024820152691b1bdcdcc81b1a5b5a5d60b21b6044820152606401610e37565b613a9033856149d7565b60db54613aa7906001600160a01b03168885613622565b50909695505050505050565b60d55460db546040516370a0823160e01b8152600092916001600160a01b0316906370a0823190613ae8903090600401615338565b60206040518083038186803b158015613b0057600080fd5b505afa158015613b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b389190615af1565b610dc391906159f0565b6001600160a01b038116613b8f5760405162461bcd60e51b81526020600482015260146024820152731859191c995cdcc81a5cc81b9bdd081d985b1a5960621b6044820152606401610e37565b60ce546001600160a01b0382811691161415613be65760405162461bcd60e51b815260206004820152601660248201527530b63932b0b23c903a34329033b0ba32b5b2b2b832b960511b6044820152606401610e37565b60ce80546001600160a01b0319166001600160a01b0383161790556040517f2ae33fe0c6f544449738f838b5b9f63f9487de59447d108fcaf7aa24c06048ef906110e2908390615338565b6127108110613c525760405162461bcd60e51b8152600401610e3790615ce7565b8060d05414610dee5760d08190556040518181527f2147e2bc8c39e67f74b1a9e08896ea1485442096765942206af1f4bc8bcde917906020016110e2565b6001600160a01b038316613cbe576001600160a01b038216600090815260de60205260409020439055613d0e565b6001600160a01b038316600090815260de60205260409020544311613d0e5760405162461bcd60e51b815260206004820152600660248201526521626c6f636b60d01b6044820152606401610e37565b60dd546001600160a01b031615613685576001600160a01b03831615613d915760dd5460405163cafecbdf60e01b81526001600160a01b039091169063cafecbdf90613d5e908690600401615338565b600060405180830381600087803b158015613d7857600080fd5b505af1158015613d8c573d6000803e3d6000fd5b505050505b6001600160a01b038216156136855760dd5460405163cafecbdf60e01b81526001600160a01b039091169063cafecbdf90613dd0908590600401615338565b600060405180830381600087803b158015613dea57600080fd5b505af1158015613dfe573d6000803e3d6000fd5b50505050505050565b6000806001600160a01b03851615613e61576000613e248661245b565b6001600160a01b03871660009081526101a760205260409020805490829055909150613e5081856159f0565b9350613e5c82846159f0565b925050505b6001600160a01b03841615613eb8576000613e7b8561245b565b6001600160a01b03861660009081526101a760205260409020805490829055909150613ea781856159f0565b9350613eb382846159f0565b925050505b80826101a854613ec89190615c4d565b613ed291906159f0565b6101a8555050505050565b803b613f415760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610e37565b600080516020615f1683398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b613fcf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610e37565b600080846001600160a01b031684604051613fea9190615e3a565b600060405180830381855af49150503d8060008114614025576040519150601f19603f3d011682016040523d82523d6000602084013e61402a565b606091505b50915091506140528282604051806060016040528060278152602001615f3660279139614b26565b95945050505050565b61406481613edd565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60db546040516370a0823160e01b815260009182916140d69185916001600160a01b03909116906370a0823190613110908990600401615338565b90506140e4816131606126ee565b9050600081116110585760405162461bcd60e51b8152600401610e3790615e56565b60008061411260355490565b90506000808211614123578361413f565b61412b6141be565b6141358386615df9565b61413f9190615e18565b9050600081116141615760405162461bcd60e51b8152600401610e3790615e56565b6130d48582614b5f565b6000806141766141be565b905060008111614187576000611058565b8061419160355490565b61419b9085615df9565b6110589190615e18565b6141b58989898989898888614c40565b61332983614c6b565b60006141c86142ac565b6141d0613ab3565b610dc39190615c4d565b600061422f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614d3a9092919063ffffffff16565b805190915015613685578080602001905181019061424d9190615d2b565b6136855760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610e37565b60008060d15460d354426142c09190615c4d565b6142ca9190615df9565b9050670de0b6b3a764000081106142e2576000614310565b670de0b6b3a764000060d454826142f99190615df9565b6143039190615e18565b60d4546143109190615c4d565b91505090565b6001600160a01b03811661433c5760405162461bcd60e51b8152600401610e3790615bfd565b6101aa80546001600160a01b0319166001600160a01b03929092169190911790556001600960801b016101a955565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156143985750600090506003614445565b8460ff16601b141580156143b057508460ff16601c14155b156143c15750600090506004614445565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015614415573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661443e57600060019250925050614445565b9150600090505b94509492505050565b600081600481111561446257614462615e77565b141561446b5750565b600181600481111561447f5761447f615e77565b14156144c85760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606401610e37565b60028160048111156144dc576144dc615e77565b141561452a5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610e37565b600381600481111561453e5761453e615e77565b14156145975760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610e37565b60048160048111156145ab576145ab615e77565b1415610dee5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610e37565b6000806146148361316086611443565b9050600081116110585760405162461bcd60e51b81526020600482015260076024820152662173686172657360c81b6044820152606401610e37565b600080828161465d61338c565b6001600160a01b03166390ab8d1f306040518263ffffffff1660e01b81526004016146889190615338565b60006040518083038186803b1580156146a057600080fd5b505afa1580156146b4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526146dc9190810190615d48565b905060005b81518110156149cd5760008282815181106146fe576146fe615cb6565b602090810291909101015160db546040516370a0823160e01b815291925082916000916001600160a01b0316906370a082319061473f903090600401615338565b60206040518083038186803b15801561475757600080fd5b505afa15801561476b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061478f9190615af1565b90508086116147a0575050506149cd565b60006147d06147af8389615c4d565b6001600160a01b038616600090815260dc602052604090206002015461356a565b9050806147e057505050506149bb565b604051632e1a7d4d60e01b8152600481018290526000906001600160a01b03851690632e1a7d4d90602401602060405180830381600087803b15801561482557600080fd5b505af1158015614839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061485d9190615af1565b60db546040516370a0823160e01b815291925060009185916001600160a01b0316906370a0823190614893903090600401615338565b60206040518083038186803b1580156148ab57600080fd5b505afa1580156148bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148e39190615af1565b6148ed9190615c4d565b905081156149aa576148ff828a615c4d565b985061490b828b6159f0565b9950733252456634469ce6c2540c02cbfa98320e32f22363d16075dd60dc8860d55461493561338c565b876040518663ffffffff1660e01b8152600401614956959493929190615c1f565b60206040518083038186803b15801561496e57600080fd5b505af4158015614982573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149a69190615af1565b60d5555b6149b48682613579565b5050505050505b806149c581615ccc565b9150506146e1565b5091949350505050565b6001600160a01b038216614a375760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610e37565b614a4382600083613c90565b6001600160a01b03821660009081526033602052604090205481811015614ab75760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610e37565b6001600160a01b0383166000908152603360205260408120838303905560358054849290614ae6908490615c4d565b90915550506040518281526000906001600160a01b03851690600080516020615f5d8339815191529060200160405180910390a361368583600084613e07565b60608315614b35575081611058565b825115614b455782518084602001fd5b8160405162461bcd60e51b8152600401610e379190615378565b6001600160a01b038216614bb55760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610e37565b614bc160008383613c90565b8060356000828254614bd391906159f0565b90915550506001600160a01b03821660009081526033602052604081208054839290614c009084906159f0565b90915550506040518181526001600160a01b03831690600090600080516020615f5d8339815191529060200160405180910390a36112db60008383613e07565b614c4a8888614d49565b614c5388614d82565b614c61868686868686614ddd565b5050505050505050565b6001600160a01b038116614c915760405162461bcd60e51b8152600401610e3790615a69565b60db80546001600160a01b0319166001600160a01b0383169081179091556040805163313ce56760e01b8152905163313ce56791600480820192602092909190829003018186803b158015614ce557600080fd5b505afa158015614cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d1d9190615e8d565b60ce60146101000a81548160ff021916908360ff16021790555050565b60606130d48484600085614e0b565b600054610100900460ff16614d705760405162461bcd60e51b8152600401610e3790615eaa565b614d78614f33565b6112db8282614f5a565b600054610100900460ff16614da95760405162461bcd60e51b8152600401610e3790615eaa565b614db1614f33565b614dd481604051806040016040528060018152602001603160f81b815250614fa8565b610dee81614fe9565b614de686615037565b614def85615048565b614df7615059565b614e03848484846150a1565b505050505050565b606082471015614e6c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610e37565b843b614eba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610e37565b600080866001600160a01b03168587604051614ed69190615e3a565b60006040518083038185875af1925050503d8060008114614f13576040519150601f19603f3d011682016040523d82523d6000602084013e614f18565b606091505b5091509150614f28828286614b26565b979650505050505050565b600054610100900460ff16610fb15760405162461bcd60e51b8152600401610e3790615eaa565b600054610100900460ff16614f815760405162461bcd60e51b8152600401610e3790615eaa565b8151614f94906036906020850190615233565b508051613685906037906020840190615233565b600054610100900460ff16614fcf5760405162461bcd60e51b8152600401610e3790615eaa565b815160209283012081519190920120606591909155606655565b600054610100900460ff166150105760405162461bcd60e51b8152600401610e3790615eaa565b507f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9609a55565b61503f6150c5565b610dee816150f4565b6150506150c5565b610dee81615126565b60ce805460ff60a01b1916600960a11b179055620f4240615083670de0b6b3a7640000602e615df9565b61508d9190615e18565b60d15560001960d2554260cf81905560d355565b6150aa84612cdb565b6150b38361514f565b6150bc82613761565b612a6a816151d4565b600054610100900460ff166150ec5760405162461bcd60e51b8152600401610e3790615eaa565b610fb1614f33565b336001600160a01b038216141561511d5760405162461bcd60e51b8152600401610e3790615c8d565b610dee81612851565b336001600160a01b038216141561243b5760405162461bcd60e51b8152600401610e3790615c8d565b6001600160a01b0381166151755760405162461bcd60e51b8152600401610e3790615ce7565b60d8546001600160a01b03828116911614610dee5760d880546001600160a01b0319166001600160a01b0383169081179091556040517f812bdb126c250b52603ba4414e31e40e34c756275a9233ab38bd75c3ed1977ca90600090a250565b60dd546001600160a01b03828116911614610dee5760dd80546001600160a01b0319166001600160a01b0383169081179091556040517ffc9e517c762f1b253f79aa322d32d22d521ecd0589fa41711000f02febf7d92990600090a250565b82805461523f90615931565b90600052602060002090601f01602090048101928261526157600085556152a7565b82601f1061527a57805160ff19168380011785556152a7565b828001600101855582156152a7579182015b828111156152a757825182559160200191906001019061528c565b506152b39291506152b7565b5090565b5b808211156152b357600081556001016152b8565b6001600160a01b0381168114610dee57600080fd5b80356152ec816152cc565b919050565b60006020828403121561530357600080fd5b8135611058816152cc565b60006020828403121561532057600080fd5b81356001600160e01b03198116811461105857600080fd5b6001600160a01b0391909116815260200190565b60005b8381101561536757818101518382015260200161534f565b83811115612a6a5750506000910152565b602081526000825180602084015261539781604085016020870161534c565b601f01601f19169190910160400192915050565b600080604083850312156153be57600080fd5b82356153c9816152cc565b946020939093013593505050565b6000806000606084860312156153ec57600080fd5b83356153f7816152cc565b92506020840135615407816152cc565b929592945050506040919091013590565b60006020828403121561542a57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561546f5761546f615431565b604052919050565b60006001600160401b0383111561549057615490615431565b6154a3601f8401601f1916602001615447565b90508281528383830111156154b757600080fd5b828260208301376000602084830101529392505050565b600080604083850312156154e157600080fd5b82356154ec816152cc565b915060208301356001600160401b0381111561550757600080fd5b8301601f8101851361551857600080fd5b61552785823560208401615477565b9150509250929050565b8015158114610dee57600080fd5b60006020828403121561555157600080fd5b813561105881615531565b6000806040838503121561556f57600080fd5b823561557a816152cc565b9150602083013561558a816152cc565b809150509250929050565b600080604083850312156155a857600080fd5b82359150602083013561558a816152cc565b600082601f8301126155cb57600080fd5b61105883833560208501615477565b60008060008060008060008060006101208a8c0312156155f957600080fd5b89356001600160401b038082111561561057600080fd5b61561c8d838e016155ba565b9a5060208c013591508082111561563257600080fd5b5061563f8c828d016155ba565b98505060408a0135615650816152cc565b965060608a0135615660816152cc565b955061566e60808b016152e1565b945061567c60a08b016152e1565b935061568a60c08b016152e1565b925061569860e08b016152e1565b91506156a76101008b016152e1565b90509295985092959850929598565b6000806000606084860312156156cb57600080fd5b505081359360208301359350604090920135919050565b6000806000806000806000806000806101408b8d03121561570257600080fd5b8a356001600160401b038082111561571957600080fd5b6157258e838f016155ba565b9b5060208d013591508082111561573b57600080fd5b506157488d828e016155ba565b99505061575760408c016152e1565b975061576560608c016152e1565b965061577360808c016152e1565b955061578160a08c016152e1565b945061578f60c08c016152e1565b935061579d60e08c016152e1565b92506157ac6101008c016152e1565b91506157bb6101208c016152e1565b90509295989b9194979a5092959850565b80356001600160801b03811681146152ec57600080fd5b600080604083850312156157f657600080fd5b6157ff836157cc565b915061580d602084016157cc565b90509250929050565b60ff81168114610dee57600080fd5b600080600080600080600060e0888a03121561584057600080fd5b873561584b816152cc565b9650602088013561585b816152cc565b95506040880135945060608801359350608088013561587981615816565b9699959850939692959460a0840135945060c09093013592915050565b600080602083850312156158a957600080fd5b82356001600160401b03808211156158c057600080fd5b818501915085601f8301126158d457600080fd5b8135818111156158e357600080fd5b8660208260051b85010111156158f857600080fd5b60209290920196919550909350505050565b60008060006060848603121561591f57600080fd5b833592506020840135615407816152cc565b600181811c9082168061594557607f821691505b602082108114156137e257634e487b7160e01b600052602260045260246000fd5b6020808252602c90820152600080516020615ef683398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020615ef683398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008219821115615a0357615a036159da565b500190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526006908201526510ba37b5b2b760d11b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6001600160a01b0392831681529116602082015260400190565b600060208284031215615b0357600080fd5b5051919050565b600181815b80851115615b45578160001904821115615b2b57615b2b6159da565b80851615615b3857918102915b93841c9390800290615b0f565b509250929050565b600082615b5c57506001610cb9565b81615b6957506000610cb9565b8160018114615b7f5760028114615b8957615ba5565b6001915050610cb9565b60ff841115615b9a57615b9a6159da565b50506001821b610cb9565b5060208310610133831016604e8410600b8410161715615bc8575081810a610cb9565b615bd28383615b0a565b8060001904821115615be657615be66159da565b029392505050565b600061105860ff841683615b4d565b602080825260089082015267217374616b696e6760c01b604082015260600190565b9485526001600160a01b03938416602086015260408501929092529091166060830152608082015260a00190565b600082821015615c5f57615c5f6159da565b500390565b6020808252600f908201526e676f7665726e616e6365206f6e6c7960881b604082015260600190565b6020808252600f908201526e696e76616c6964206164647265737360881b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415615ce057615ce06159da565b5060010190565b602080825260069082015265085a5b9c1d5d60d21b604082015260600190565b6020808252600a9082015269085c9958da5c1a595b9d60b21b604082015260600190565b600060208284031215615d3d57600080fd5b815161105881615531565b60006020808385031215615d5b57600080fd5b82516001600160401b0380821115615d7257600080fd5b818501915085601f830112615d8657600080fd5b815181811115615d9857615d98615431565b8060051b9150615da9848301615447565b8181529183018401918481019088841115615dc357600080fd5b938501935b83851015615ded5784519250615ddd836152cc565b8282529385019390850190615dc8565b98975050505050505050565b6000816000190483118215151615615e1357615e136159da565b500290565b600082615e3557634e487b7160e01b600052601260045260246000fd5b500490565b60008251615e4c81846020870161534c565b9190910192915050565b60208082526007908201526608585b5bdd5b9d60ca1b604082015260600190565b634e487b7160e01b600052602160045260246000fd5b600060208284031215615e9f57600080fd5b815161105881615816565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122072121bf554a834d7f12d7324bd84a33ea510366fa1be1c954e662afb02b4ffdf64736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
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.