Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60a06040 | 20178222 | 29 days ago | IN | 0 ETH | 0.0466728 |
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:
UltraLRT
Compiler Version
v0.8.16+commit.07a7930e
Optimization Enabled:
Yes with 0 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; // upgrading contracts import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import {ERC4626Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {IERC20MetadataUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; // safeTransfer import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; // storage contract import {UltraLRTStorage} from "src/vaults/restaking/UltraLRTStorage.sol"; import {WithdrawalEscrowV2} from "src/vaults/restaking/WithdrawalEscrowV2.sol"; // governance contract import {AffineGovernable} from "src/utils/audited/AffineGovernable.sol"; import {ReStakingErrors} from "src/libs/ReStakingErrors.sol"; import {IDelegator} from "src/vaults/restaking/IDelegator.sol"; import {IDelegatorFactory} from "src/vaults/restaking/DelegatorFactory.sol"; import {IDelegatorBeacon} from "src/vaults/restaking/DelegatorBeacon.sol"; /** * @title UltraLRT * @notice UltraLRT is a liquid staking vault that allows users to deposit staked assets and receive shares in return. * The shares can be redeemed for the underlying assets at any time. Vault will delegate the assets to the delegators and harvest the profit. * The vault will also distribute the profits to the holders. */ contract UltraLRT is ERC4626Upgradeable, UUPSUpgradeable, AccessControlUpgradeable, PausableUpgradeable, AffineGovernable, ReentrancyGuardUpgradeable, UltraLRTStorage { using SafeTransferLib for ERC20; /** * @notice Initialize the UltraLRT contract * @param _governance The address of the governance contract * @param _asset The address of the asset token * @param _delegatorBeacon The address of the delegator beacon * @param _name The name of the token * @param _symbol The symbol of the token */ function initialize( address _governance, address _asset, address _delegatorBeacon, string memory _name, string memory _symbol ) external initializer { governance = _governance; // init token __ERC4626_init(IERC20MetadataUpgradeable(_asset)); __ERC20_init(_name, _symbol); // init control __AccessControl_init(); __Pausable_init(); __ReentrancyGuard_init(); // All roles use the default admin role // Governance has the admin role and all roles _grantRole(DEFAULT_ADMIN_ROLE, governance); _grantRole(GUARDIAN_ROLE, governance); _grantRole(HARVESTER, governance); // beacon proxy /// @dev check for the owner of the beacon: Invalid beacon require(IDelegatorBeacon(_delegatorBeacon).owner() == governance, "ULRT: IB"); beacon = _delegatorBeacon; } /** * @notice Upgrade the UltraLRT contract * @param newImplementation The address of the new implementation contract */ function _authorizeUpgrade(address newImplementation) internal override onlyGovernance {} /** * @notice The maximum amount of assets that can be deposited into the vault * @return The maximum amount of assets that can be deposited * @dev See {IERC4262-maxDeposit}. */ function maxDeposit(address) public view virtual override returns (uint256) { bool isCollateralized = totalAssets() > 0 || totalSupply() == 0; return isCollateralized ? type(uint128).max : 0; } /** * @notice The maximum amount of shares that can be minted * @return The maximum amount of shares that can be minted * @dev See {IERC4262-maxMint}. */ function maxMint(address) public view virtual override returns (uint256) { return type(uint128).max; } /** * @notice set the delegator factory * @param _factory The address of the delegator factory * @dev factory must have the vault set to this vault */ function setDelegatorFactory(address _factory) external onlyGovernance { if (IDelegatorFactory(_factory).vault() != address(this)) revert ReStakingErrors.InvalidDelegatorFactory(); delegatorFactory = _factory; } /** * @notice set max unresolved epoch * @param _maxUnresolvedEpochs The maximum unresolved epoch * @dev delegation of assets will be stopped if the unresolved epoch is greater than the max unresolved epoch */ function setMaxUnresolvedEpochs(uint256 _maxUnresolvedEpochs) external onlyGovernance { maxUnresolvedEpochs = _maxUnresolvedEpochs; } /// @notice Pause the contract function pause() external onlyRole(GUARDIAN_ROLE) { _pause(); } /// @notice Unpause the contract function unpause() external onlyRole(GUARDIAN_ROLE) { _unpause(); } /*////////////////////////////////////////////////////////////// DECIMALS //////////////////////////////////////////////////////////////*/ /// @dev E.g. if the asset has 18 decimals, and initialSharesPerAsset is 1e8, then the vault has 26 decimals. And /// "one" `asset` will be worth "one" share (where "one" means 10 ** token.decimals()). function decimals() public view virtual override(ERC20Upgradeable, IERC20MetadataUpgradeable) returns (uint8) { return IERC20MetadataUpgradeable(asset()).decimals() + _initialShareDecimals(); } /// @notice The amount of shares to mint per wei of `asset` at genesis. function initialSharesPerAsset() public pure virtual returns (uint256) { return 10 ** _initialShareDecimals(); } /// @notice Each wei of `asset` at genesis is worth 10 ** (initialShareDecimals) shares. function _initialShareDecimals() internal pure virtual returns (uint8) { return 8; } /*////////////////////////////////////////////////////////////// DEPOSIT ETH //////////////////////////////////////////////////////////////*/ /** * @notice Pause the deposit */ function pauseDeposit() external onlyGovernance { depositPaused = 1; } /** * @notice Unpause the deposit */ function unpauseDeposit() external onlyGovernance { depositPaused = 0; } /** * @notice Deposit assets into the vault * @param receiver The address of the receiver * @return The amount of shares minted */ function deposit(uint256 assets, address receiver) public override whenNotPaused whenDepositNotPaused nonReentrant returns (uint256) { if (assets > maxDeposit(receiver)) revert ReStakingErrors.ExceedsDepositLimit(); uint256 shares = previewDeposit(assets); _deposit(_msgSender(), receiver, assets, shares); return shares; } /** * @notice mint specific amount of shares * @param shares The amount of shares to mint * @param receiver The address of the receiver * @return The amount of assets minted */ function mint(uint256 shares, address receiver) public override whenNotPaused whenDepositNotPaused nonReentrant returns (uint256) { if (shares > maxMint(receiver)) revert ReStakingErrors.ExceedsMintLimit(); uint256 assets = previewMint(shares); _deposit(_msgSender(), receiver, assets, shares); return assets; } /*////////////////////////////////////////////////////////////// WITHDRAWALS //////////////////////////////////////////////////////////////*/ /** * @notice Withdraw assets from the vault * @param assets The amount of assets to withdraw * @param receiver The address of the receiver * @param owner The address of the owner * @return The amount of shares burned * @dev See {IERC4262-withdraw}. */ function withdraw(uint256 assets, address receiver, address owner) public override whenNotPaused nonReentrant returns (uint256) { if (assets > maxWithdraw(owner)) revert ReStakingErrors.ExceedsWithdrawLimit(); uint256 shares = previewWithdraw(assets); _withdraw(_msgSender(), receiver, owner, assets, shares); return shares; } /** * @notice Redeem shares from the vault * @param shares The amount of shares to redeem * @param receiver The address of the receiver * @param owner The address of the owner * @return The amount of assets redeemed * @dev See {IERC4262-redeem}. */ function redeem(uint256 shares, address receiver, address owner) public override whenNotPaused nonReentrant returns (uint256) { if (shares > maxRedeem(owner)) revert ReStakingErrors.ExceedsRedeemLimit(); uint256 assets = previewRedeem(shares); _withdraw(_msgSender(), receiver, owner, assets, shares); return assets; } /** * @notice withdraw from the vault * @param caller The address of the caller * @param receiver The address of the receiver * @param owner The address of the owner * @param assets The amount of assets to withdraw * @param shares The amount of shares to burn */ function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares) internal override { if (caller != owner) { _spendAllowance(owner, caller, shares); } // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the // shares are burned and after the assets are transfered, which is a valid state. // TODO: calculate fees if (!canWithdraw(assets)) { // do withdrawal request _transfer(_msgSender(), address(escrow), shares); escrow.registerWithdrawalRequest(receiver, shares); // do immediate withdrawal request for user // _liquidationRequest(assets); emit Withdraw(caller, receiver, owner, assets, shares); return; } _burn(owner, shares); uint256 assetsToReceive = Math.min(vaultAssets(), assets); if (assetsToReceive + ST_ETH_TRANSFER_BUFFER < assets) revert ReStakingErrors.InsufficientLiquidAssets(); ERC20(asset()).safeTransfer(receiver, assetsToReceive); emit Withdraw(caller, receiver, owner, assetsToReceive, shares); } /** * @notice Check if the withdrawal can be done * @param assets The amount of assets to withdraw * @return True if the withdrawal can be done */ function canWithdraw(uint256 assets) public view returns (bool) { if (_msgSender() == address(escrow)) { return true; } uint256 escrowDebt = address(escrow) == address(0) ? 0 : escrow.totalDebt(); return escrowDebt == 0 && (vaultAssets() + ST_ETH_TRANSFER_BUFFER) >= assets; } /*////////////////////////////////////////////////////////////// ESCROW //////////////////////////////////////////////////////////////*/ /** * @notice Set the withdrawal escrow * @param _escrow The address of the withdrawal escrow * @dev The escrow must have the vault set to this vault * @dev existing escrow debt must be zero */ function setWithdrawalEscrow(WithdrawalEscrowV2 _escrow) external onlyGovernance { if (address(escrow) != address(0) && escrow.totalDebt() > 0) revert ReStakingErrors.ExistingEscrowDebt(); if (address(_escrow.vault()) != address(this)) revert ReStakingErrors.InvalidEscrowVault(); escrow = _escrow; } /*////////////////////////////////////////////////////////////// EPOCH //////////////////////////////////////////////////////////////*/ /** * @notice End the current epoch * @dev Only the harvester can end the epoch anytime * @dev for other The epoch can only be ended if the last epoch was ended at least `LOCK_INTERVAL` seconds ago */ function endEpoch() external { if (!hasRole(HARVESTER, msg.sender) && (block.timestamp - lastEpochTime) < LOCK_INTERVAL) { revert ReStakingErrors.RunningEpoch(); } /// @dev only harvester can end and epoch after uint256 closingEpoch = escrow.currentEpoch(); escrow.endEpoch(); lastEpochTime = block.timestamp; /// @request for liquidation in case called by non-harvester (uint256 shares,) = escrow.epochInfo(closingEpoch); uint256 assets = convertToAssets(shares); _liquidationRequest(assets); } /** * @notice Do liquidation request to delegators * @param assets The amount of assets to liquidate * @dev Only the harvester can do the liquidation request */ function liquidationRequest(uint256 assets) external onlyRole(HARVESTER) { _liquidationRequest(assets); } /** * @notice Do liquidation request to delegators * @param assets The amount of assets to liquidate */ function _liquidationRequest(uint256 assets) internal { for (uint256 i = 0; i < delegatorCount && assets > 0; i++) { IDelegator delegator = delegatorQueue[i]; if (delegator.withdrawableAssets() > 0) { uint256 assetsToRequest = Math.min(delegator.withdrawableAssets(), assets); delegator.requestWithdrawal(assetsToRequest); assets -= assetsToRequest; } } } /** * @notice Withdraw from speicific delegator * @param delegator The address of the delegator * @param assets The amount of assets to withdraw */ function delegatorWithdrawRequest(IDelegator delegator, uint256 assets) external onlyRole(HARVESTER) { if (assets > delegator.withdrawableAssets()) revert ReStakingErrors.ExceedsDelegatorWithdrawableAssets(); delegator.requestWithdrawal(assets); } /** * @notice Resolve the debt */ function resolveDebt() external { if (escrow.resolvingEpoch() == escrow.currentEpoch()) { revert ReStakingErrors.NoResolvingEpoch(); } uint256 assets = previewRedeem(escrow.getDebtToResolve()); // try liquidating assets if ((vaultAssets() + ST_ETH_TRANSFER_BUFFER) < assets) { _getDelegatorLiquidAssets(assets); } if ((vaultAssets() + ST_ETH_TRANSFER_BUFFER) < assets) { revert ReStakingErrors.InsufficientLiquidAssets(); } escrow.resolveDebtShares(); } /*////////////////////////////////////////////////////////////// DELEGATOR //////////////////////////////////////////////////////////////*/ // todo check a valid operator address /** * @notice Create a new delegator * @param _operator The address of the operator */ function createDelegator(address _operator) external onlyGovernance { if (delegatorCount >= MAX_DELEGATOR) revert ReStakingErrors.ExceedsMaxDelegatorLimit(); if (delegatorFactory == address(0)) revert ReStakingErrors.InvalidDelegatorFactory(); address newDelegator = IDelegatorFactory(delegatorFactory).createDelegator(_operator); delegatorQueue[delegatorCount] = IDelegator(newDelegator); DelegatorInfo memory info; info.balance = 0; info.isActive = true; delegatorMap[newDelegator] = info; delegatorCount = delegatorCount + 1; } /** * @notice Drop a delegator * @param _delegator The address of the delegator */ function dropDelegator(address _delegator) external onlyGovernance { if (IDelegator(_delegator).totalLockedValue() > 0) revert ReStakingErrors.NonZeroEmptyDelegatorTVL(); DelegatorInfo memory info = delegatorMap[_delegator]; if (!info.isActive) revert ReStakingErrors.InactiveDelegator(); if (info.balance > 0) revert ReStakingErrors.RequireHarvest(); info.isActive = false; for (uint8 i = 0; i < delegatorCount; i++) { if (address(delegatorQueue[i]) == _delegator) { delegatorQueue[i] = delegatorQueue[delegatorCount - 1]; delegatorQueue[delegatorCount - 1] = IDelegator(address(0)); delegatorCount = delegatorCount - 1; delegatorMap[_delegator] = info; break; } } } /** * @notice Harvest the profit */ function harvest() external onlyRole(HARVESTER) { if (block.timestamp <= lastHarvest + LOCK_INTERVAL) revert ReStakingErrors.ProfitUnlocking(); uint256 newDelegatorAssets; for (uint8 i = 0; i < delegatorCount; i++) { uint256 currentDelegatorTVL = delegatorQueue[i].totalLockedValue(); // TODO map utilization delegatorMap[address(delegatorQueue[i])].balance = uint248(currentDelegatorTVL); newDelegatorAssets += currentDelegatorTVL; } // TODO: incremental distribution of assets if (delegatorAssets < newDelegatorAssets) { maxLockedProfit = newDelegatorAssets - delegatorAssets; } else { maxLockedProfit = 0; } lastHarvest = block.timestamp; delegatorAssets = newDelegatorAssets; } /** * @notice Collect the delegator debt * @dev will withdraw the liquid assets from the delegators */ function collectDelegatorDebt() external onlyRole(HARVESTER) { _getDelegatorLiquidAssets(totalAssets()); } /** * @notice Collect liquid assets from the delegator * @dev make sure to update the delegator assets */ ///TODO check for price change on profit and loss function withdrawFromDelegator(address _delegator) external onlyRole(HARVESTER) { IDelegator delegator = IDelegator(_delegator); uint256 prevTVL = delegatorMap[_delegator].balance; delegator.withdraw(); uint256 newTVL = delegator.totalLockedValue(); uint256 TVLReduced = prevTVL > newTVL ? prevTVL - newTVL : 0; delegatorMap[_delegator].balance = uint248(newTVL); // update the delegator assets if (TVLReduced > 0) { delegatorAssets -= TVLReduced; } } /** * @notice Get the delegator liquid assets * @param requiredVaultAssets The amount of liquid assets required in vault * @dev Each time this will check the vault assets, if it meets required assets then it will stop */ function _getDelegatorLiquidAssets(uint256 requiredVaultAssets) internal { uint256 currentDelegatorAssets = delegatorAssets; for (uint8 i = 0; i < delegatorCount && requiredVaultAssets > 0; i++) { IDelegator delegator = delegatorQueue[i]; // check for zero assets if (IERC20MetadataUpgradeable(asset()).balanceOf(address(delegator)) < 2) { /// @dev taking into account transfer 1 steth has issue. continue; } uint256 prevTVL = delegatorMap[address(delegator)].balance; delegator.withdraw(); uint256 newTVL = delegator.totalLockedValue(); delegatorMap[address(delegator)].balance = uint248(newTVL); currentDelegatorAssets -= (prevTVL > newTVL ? prevTVL - newTVL : 0); if ((vaultAssets() + ST_ETH_TRANSFER_BUFFER) < requiredVaultAssets) { break; } } delegatorAssets = currentDelegatorAssets; } /** * @notice Delegate the assets to the delegator * @param _delegator The address of the delegator * @param amount The amount of assets to delegate */ function delegateToDelegator(address _delegator, uint256 amount) external onlyRole(HARVESTER) { if (address(escrow) == address(0)) { revert ReStakingErrors.InvalidEscrow(); } if (maxUnresolvedEpochs < (escrow.currentEpoch() - escrow.resolvingEpoch())) { revert ReStakingErrors.MaxUnresolvedEpochReached(); } IDelegator delegator = IDelegator(_delegator); DelegatorInfo memory info = delegatorMap[_delegator]; if (!info.isActive) revert ReStakingErrors.InactiveDelegator(); if (vaultAssets() < amount) revert ReStakingErrors.InsufficientLiquidAssets(); // delegate ERC20(asset()).safeApprove(_delegator, amount); delegator.delegate(amount); info.balance += uint248(amount); delegatorMap[_delegator] = info; delegatorAssets += amount; } /** * @notice Current locked profit amount. * @dev Profit unlocks uniformly over `LOCK_INTERVAL` seconds after the last harvest */ function lockedProfit() public view virtual returns (uint256) { if (block.timestamp >= lastHarvest + LOCK_INTERVAL) { return 0; } uint256 unlockedProfit = (maxLockedProfit * (block.timestamp - lastHarvest)) / LOCK_INTERVAL; return maxLockedProfit - unlockedProfit; } /*////////////////////////////////////////////////////////////// TVL //////////////////////////////////////////////////////////////*/ // TODO -- calculate tvl // get assets // get shares /** * @notice Get the total assets */ function totalAssets() public view override returns (uint256) { return vaultAssets() + delegatorAssets - lockedProfit(); } /** * @notice Get the vault liquid assets */ function vaultAssets() public view returns (uint256) { return IERC20MetadataUpgradeable(asset()).balanceOf(address(this)); } /*////////////////////////////////////////////////////////////// FEES //////////////////////////////////////////////////////////////*/ /** * @notice Set the management fee */ function setManagementFee(uint256 feeBps) external onlyGovernance { managementFee = feeBps; } /** * @notice Set the withdrawal fee */ function setWithdrawalFee(uint256 feeBps) external onlyGovernance { withdrawalFee = feeBps; } /*////////////////////////////////////////////////////////////// Balancer Interface for pice //////////////////////////////////////////////////////////////*/ /** * @notice returns the per share assets */ function getRate() external view returns (uint256) { return convertToAssets(10 ** decimals()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; 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, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } 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 Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate that the this implementation remains valid after an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(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); _upgradeToAndCallUUPS(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; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (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 { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { 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()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol) pragma solidity ^0.8.0; import "../ERC20Upgradeable.sol"; import "../utils/SafeERC20Upgradeable.sol"; import "../../../interfaces/IERC4626Upgradeable.sol"; import "../../../utils/math/MathUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the ERC4626 "Tokenized Vault Standard" as defined in * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626]. * * This extension allows the minting and burning of "shares" (represented using the ERC20 inheritance) in exchange for * underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends * the ERC20 standard. Any additional extensions included along it would affect the "shares" token represented by this * contract and not the "assets" token which is an independent contract. * * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router]. * * _Available since v4.7._ */ abstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626Upgradeable { using MathUpgradeable for uint256; IERC20MetadataUpgradeable private _asset; /** * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777). */ function __ERC4626_init(IERC20MetadataUpgradeable asset_) internal onlyInitializing { __ERC4626_init_unchained(asset_); } function __ERC4626_init_unchained(IERC20MetadataUpgradeable asset_) internal onlyInitializing { _asset = asset_; } /** @dev See {IERC4262-asset}. */ function asset() public view virtual override returns (address) { return address(_asset); } /** @dev See {IERC4262-totalAssets}. */ function totalAssets() public view virtual override returns (uint256) { return _asset.balanceOf(address(this)); } /** @dev See {IERC4262-convertToShares}. */ function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) { return _convertToShares(assets, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-convertToAssets}. */ function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) { return _convertToAssets(shares, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-maxDeposit}. */ function maxDeposit(address) public view virtual override returns (uint256) { return _isVaultCollateralized() ? type(uint256).max : 0; } /** @dev See {IERC4262-maxMint}. */ function maxMint(address) public view virtual override returns (uint256) { return type(uint256).max; } /** @dev See {IERC4262-maxWithdraw}. */ function maxWithdraw(address owner) public view virtual override returns (uint256) { return _convertToAssets(balanceOf(owner), MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-maxRedeem}. */ function maxRedeem(address owner) public view virtual override returns (uint256) { return balanceOf(owner); } /** @dev See {IERC4262-previewDeposit}. */ function previewDeposit(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-previewMint}. */ function previewMint(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, MathUpgradeable.Rounding.Up); } /** @dev See {IERC4262-previewWithdraw}. */ function previewWithdraw(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, MathUpgradeable.Rounding.Up); } /** @dev See {IERC4262-previewRedeem}. */ function previewRedeem(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-deposit}. */ function deposit(uint256 assets, address receiver) public virtual override returns (uint256) { require(assets <= maxDeposit(receiver), "ERC4626: deposit more than max"); uint256 shares = previewDeposit(assets); _deposit(_msgSender(), receiver, assets, shares); return shares; } /** @dev See {IERC4262-mint}. */ function mint(uint256 shares, address receiver) public virtual override returns (uint256) { require(shares <= maxMint(receiver), "ERC4626: mint more than max"); uint256 assets = previewMint(shares); _deposit(_msgSender(), receiver, assets, shares); return assets; } /** @dev See {IERC4262-withdraw}. */ function withdraw( uint256 assets, address receiver, address owner ) public virtual override returns (uint256) { require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max"); uint256 shares = previewWithdraw(assets); _withdraw(_msgSender(), receiver, owner, assets, shares); return shares; } /** @dev See {IERC4262-redeem}. */ function redeem( uint256 shares, address receiver, address owner ) public virtual override returns (uint256) { require(shares <= maxRedeem(owner), "ERC4626: redeem more than max"); uint256 assets = previewRedeem(shares); _withdraw(_msgSender(), receiver, owner, assets, shares); return assets; } /** * @dev Internal conversion function (from assets to shares) with support for rounding direction. * * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset * would represent an infinite amout of shares. */ function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 shares) { uint256 supply = totalSupply(); return (assets == 0 || supply == 0) ? assets.mulDiv(10**decimals(), 10**_asset.decimals(), rounding) : assets.mulDiv(supply, totalAssets(), rounding); } /** * @dev Internal conversion function (from shares to assets) with support for rounding direction. */ function _convertToAssets(uint256 shares, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 assets) { uint256 supply = totalSupply(); return (supply == 0) ? shares.mulDiv(10**_asset.decimals(), 10**decimals(), rounding) : shares.mulDiv(totalAssets(), supply, rounding); } /** * @dev Deposit/mint common workflow. */ function _deposit( address caller, address receiver, uint256 assets, uint256 shares ) internal virtual { // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the // assets are transfered and before the shares are minted, which is a valid state. // slither-disable-next-line reentrancy-no-eth SafeERC20Upgradeable.safeTransferFrom(_asset, caller, address(this), assets); _mint(receiver, shares); emit Deposit(caller, receiver, assets, shares); } /** * @dev Withdraw/redeem common workflow. */ function _withdraw( address caller, address receiver, address owner, uint256 assets, uint256 shares ) internal virtual { if (caller != owner) { _spendAllowance(owner, caller, shares); } // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the // shares are burned and after the assets are transfered, which is a valid state. _burn(owner, shares); SafeERC20Upgradeable.safeTransfer(_asset, receiver, assets); emit Withdraw(caller, receiver, owner, assets, shares); } function _isVaultCollateralized() private view returns (bool) { return totalAssets() > 0 || totalSupply() == 0; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// 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 (last updated v4.7.0) (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 { __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: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[45] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`. // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`. // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a // good first aproximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1; uint256 x = a; if (x >> 128 > 0) { x >>= 128; result <<= 64; } if (x >> 64 > 0) { x >>= 64; result <<= 32; } if (x >> 32 > 0) { x >>= 32; result <<= 16; } if (x >> 16 > 0) { x >>= 16; result <<= 8; } if (x >> 8 > 0) { x >>= 8; result <<= 4; } if (x >> 4 > 0) { x >>= 4; result <<= 2; } if (x >> 2 > 0) { result <<= 1; } // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { uint256 result = sqrt(a); if (rounding == Rounding.Up && result * result < a) { result += 1; } return result; } }
// 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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {IStEth} from "src/interfaces/lido/IStEth.sol"; import {WithdrawalEscrowV2} from "src/vaults/restaking/WithdrawalEscrowV2.sol"; import {IDelegator} from "src/vaults/restaking/IDelegator.sol"; import {ReStakingErrors} from "src/libs/ReStakingErrors.sol"; abstract contract UltraLRTStorage { struct DelegatorInfo { bool isActive; uint248 balance; } bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN"); bytes32 public constant HARVESTER = keccak256("HARVESTER"); uint256 public constant MAX_BPS = 10_000; uint256 public constant MAX_DELEGATOR = 50; // buffer we ignore while resolving shares due to transfer glitch in steth uint256 public constant ST_ETH_TRANSFER_BUFFER = 1000; // only pausing the deposits in case of limit reached uint256 public depositPaused; IStEth public constant STETH = IStEth(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84); WithdrawalEscrowV2 public escrow; address public beacon; address public delegatorFactory; uint256 public delegatorAssets; /// @notice Fee charged to vault over a year, number is in bps uint256 public managementFee; /// @notice Fee charged on redemption of shares, number is in bps uint256 public withdrawalFee; /** * @notice A timestamp representing when the most recent harvest occurred. * @dev Since the time since the last harvest is used to calculate management fees, this is set * to `block.timestamp` (instead of 0) during initialization. */ uint256 public lastHarvest; /// @notice The amount of profit *originally* locked after harvesting from a strategy uint256 public maxLockedProfit; /// @notice Amount of time in seconds that profit takes to fully unlock. See lockedProfit(). uint256 public constant LOCK_INTERVAL = 24 hours; // delegator array IDelegator[MAX_DELEGATOR] public delegatorQueue; mapping(address => DelegatorInfo) public delegatorMap; //active delegator count uint256 public delegatorCount; // last epoch time uint256 public lastEpochTime; // max unresolved epochs uint256 public maxUnresolvedEpochs; modifier whenDepositNotPaused() { if (depositPaused != 0) revert ReStakingErrors.DepositPaused(); _; } /** * @dev This empty reserved space is put in place to allow future versions to add new */ uint256[100] private __gap; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {ERC4626Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {UltraLRT} from "src/vaults/restaking/UltraLRT.sol"; /** * @title WithdrawalEscrowV2 * @dev Escrow contract for withdrawal requests */ contract WithdrawalEscrowV2 { using SafeTransferLib for ERC20; /// @notice The vault asset. ERC20 public immutable asset; /// @notice The vault this escrow attached to. UltraLRT public immutable vault; // per epoch per user debt shares mapping(uint256 => mapping(address => uint256)) public userDebtShare; struct EpochInfo { uint128 shares; uint128 assets; } uint256 public currentEpoch; uint256 public resolvingEpoch; uint256 public totalDebt; // map per epoch debt share mapping(uint256 => EpochInfo) public epochInfo; /** * @param _vault UltraLRT vault address */ constructor(UltraLRT _vault) { asset = ERC20(_vault.asset()); vault = _vault; } /** * @notice Modifier to allow function calls only from the vault */ modifier onlyVault() { require(msg.sender == address(vault), "WE: must be vault"); _; } /** * @notice Modifier to allow function calls only from the governance */ modifier onlyGovernance() { require(msg.sender == address(vault.governance()), "WE: Must be gov"); _; } /** * @notice Withdrawal Request event * @param user user address * @param epoch epoch of the request * @param shares withdrawal vault shares * @dev will makes things easy to search for each user withdrawal requests */ event WithdrawalRequest(address indexed user, uint256 epoch, uint256 shares); /** * @notice Register withdrawal request as debt * @param user user address * @param shares amount of vault shares user requested to withdraw */ function registerWithdrawalRequest(address user, uint256 shares) external onlyVault { // register shares of the user userDebtShare[currentEpoch][user] += shares; epochInfo[currentEpoch].shares += uint128(shares); totalDebt += shares; emit WithdrawalRequest(user, currentEpoch, shares); } /** * @notice End the epoch * @dev will be called by the vault after closing a position */ function endEpoch() external onlyVault { require(epochInfo[currentEpoch].shares > 0, "WEV2: No Debt."); currentEpoch = currentEpoch + 1; // TODO: epoch end event } /** * @notice Get the debt to resolve * @return amount of debt to resolve */ function getDebtToResolve() external view returns (uint256) { return resolvingEpoch < currentEpoch ? epochInfo[resolvingEpoch].shares : 0; } /** * @notice resolve the locked shares for current epoch * @dev This function will be triggered after closing a position * @dev will check for available shares to burn * @dev after resolving vault will send the assets to escrow and burn the share */ function resolveDebtShares() external onlyVault { require(resolvingEpoch < currentEpoch, "WEV2: No debt."); uint256 preAssets = asset.balanceOf(address(this)); vault.redeem({shares: epochInfo[resolvingEpoch].shares, receiver: address(this), owner: address(this)}); uint256 currentAssets = asset.balanceOf(address(this)); totalDebt -= epochInfo[resolvingEpoch].shares; epochInfo[resolvingEpoch].assets = uint128(currentAssets - preAssets); resolvingEpoch += 1; } /** * @notice Redeem multiple epochs * @param user user address * @param epochs withdrawal request epochs * @return totalAssets received */ function redeemMultiEpoch(address user, uint256[] calldata epochs) public returns (uint256 totalAssets) { for (uint8 i = 0; i < epochs.length; i++) { totalAssets += redeem(user, epochs[i]); } } /** * @notice Redeem withdrawal request * @param user address * @param epoch withdrawal request epoch * @return received assets */ function redeem(address user, uint256 epoch) public returns (uint256) { // Should be a resolved epoch require(canWithdraw(epoch), "WE: epoch not resolved."); // total assets for user uint256 assets = _epochSharesToAssets(user, epoch); require(assets > 0, "WE: no assets to redeem"); // reset the user debt share userDebtShare[epoch][user] = 0; // Transfer asset to user asset.safeTransfer(user, assets); return assets; } /** * @notice Convert epoch shares to assets * @param user User address * @param epoch withdrawal request epoch * @return converted assets */ function _epochSharesToAssets(address user, uint256 epoch) internal view returns (uint256) { uint256 userShares = userDebtShare[epoch][user]; EpochInfo memory data = epochInfo[epoch]; return (userShares * data.assets) / data.shares; } /** * @notice Check if an epoch is completed or not * @param epoch Epoch number * @return True if epoch is completed */ function canWithdraw(uint256 epoch) public view returns (bool) { return epoch < resolvingEpoch; } /** * @notice Get withdrawable assets of a user * @param user User address * @param epoch The vault epoch * @return Amount of assets user will receive */ function withdrawableAssets(address user, uint256 epoch) public view returns (uint256) { if (!canWithdraw(epoch)) { return 0; } return _epochSharesToAssets(user, epoch); } /** * @notice Get withdrawable shares of a user * @param user user address * @param epoch requests epoch * @return amount of shares to withdraw */ function withdrawableShares(address user, uint256 epoch) public view returns (uint256) { if (!canWithdraw(epoch)) { return 0; } return userDebtShare[epoch][user]; } /** * @notice Get total withdrawable assets of a user for multiple epochs * @param user User address * @param epochs withdrawal request epochs * @return assets total withdrawable assets */ function getAssets(address user, uint256[] calldata epochs) public view returns (uint256 assets) { for (uint256 i = 0; i < epochs.length; i++) { assets += withdrawableAssets(user, epochs[i]); } return assets; } /** * @notice sweep the assets to governance * @param _asset Asset address * @dev only use case in case of emergency */ function sweep(address _asset) external onlyGovernance { ERC20(_asset).safeTransfer(vault.governance(), ERC20(_asset).balanceOf(address(this))); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; /*////////////////////////////////////////////////////////////// AUDIT INFO //////////////////////////////////////////////////////////////*/ /** * Audits: * 1. Nov 8, 2022, size: 27 Line * Extended: No * Changes: None */ contract AffineGovernable { /// @notice The governance address address public governance; modifier onlyGovernance() { _onlyGovernance(); _; } function _onlyGovernance() internal view { require(msg.sender == governance, "Only Governance."); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; library ReStakingErrors { error AlreadyApprovedToken(); error NotApprovedToken(); error DepositAmountCannotBeZero(); error CannotDepositForZeroAddress(); error TokenNotAllowedForStaking(); error WithdrawAmountCannotBeZero(); error InvalidWithdrawalAmount(); error ExceedsDepositLimit(); error ExceedsMintLimit(); error ExceedsWithdrawLimit(); error ExceedsRedeemLimit(); error InsufficientLiquidAssets(); error ExistingEscrowDebt(); error InvalidEscrowVault(); error ExceedsDelegatorWithdrawableAssets(); error ExceedsMaxDelegatorLimit(); error NonZeroEmptyDelegatorTVL(); error InactiveDelegator(); error RequireHarvest(); error ProfitUnlocking(); error DepositPaused(); error InvalidDelegatorFactory(); error RunningEpoch(); error NoResolvingEpoch(); error MaxUnresolvedEpochReached(); error InvalidEscrow(); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; interface IDelegator { // vault request to withdraw assets function requestWithdrawal(uint256 assets) external; // vault will check the availability of liquid assets function checkAssetAvailability(uint256 assets) external view returns (bool); // vault withdraw liquid assets call by vault function delegate(uint256 amount) external; // vault delegate assets to delegator function withdraw() external; // get delegator tvl function totalLockedValue() external returns (uint256); function withdrawableAssets() external view returns (uint256); function queuedAssets() external view returns (uint256); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; import {UltraLRT} from "src/vaults/restaking/UltraLRT.sol"; import {EigenDelegator} from "src/vaults/restaking/EigenDelegator.sol"; interface IDelegatorFactory { function createDelegator(address _operator) external returns (address); function vault() external returns (address); } /** * @title DelegatorFactory * @dev Delegator Factory contract */ contract DelegatorFactory { address public vault; /** * @dev Modifier to allow function calls only from the vault */ modifier onlyVault() { require(msg.sender == vault, "DF: only vault"); _; } /** * @dev Constructor * @param _vault Vault address */ constructor(address _vault) { vault = _vault; } /** * @notice Create a new delegator * @param _operator Operator address * @return Delegator address */ function createDelegator(address _operator) external onlyVault returns (address) { BeaconProxy bProxy = new BeaconProxy( UltraLRT(vault).beacon(), abi.encodeWithSelector(EigenDelegator.initialize.selector, vault, _operator) ); return address(bProxy); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; interface IDelegatorBeacon { function owner() external returns (address); } /** * @title DelegatorBeacon * @dev Delegator Beacon contract */ contract DelegatorBeacon is Ownable { UpgradeableBeacon immutable beacon; address public blueprint; /** * @dev Constructor * @param _initBlueprint Initial blueprint address * @param governance Governance address */ constructor(address _initBlueprint, address governance) { beacon = new UpgradeableBeacon(_initBlueprint); blueprint = _initBlueprint; transferOwnership(governance); } /** * @notice Update the blueprint * @param _newBlueprint New blueprint address */ function update(address _newBlueprint) public onlyOwner { beacon.upgradeTo(_newBlueprint); blueprint = _newBlueprint; } /** * @notice Get the implementation address * @return Implementation address */ function implementation() public view returns (address) { return beacon.implementation(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.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 { } 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 _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @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"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; 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 proxied contracts do not make use of 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. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * 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 prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; 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 { } 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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.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)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(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 (last updated v4.7.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20Upgradeable.sol"; import "../token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * _Available since v4.7._ */ interface IERC4626Upgradeable is IERC20Upgradeable, IERC20MetadataUpgradeable { event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /** * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. * * - MUST be an ERC-20 token contract. * - MUST NOT revert. */ function asset() external view returns (address assetTokenAddress); /** * @dev Returns the total amount of the underlying asset that is “managed” by Vault. * * - SHOULD include any compounding that occurs from yield. * - MUST be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT revert. */ function totalAssets() external view returns (uint256 totalManagedAssets); /** * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToShares(uint256 assets) external view returns (uint256 shares); /** * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, * through a deposit call. * * - MUST return a limited value if receiver is subject to some deposit limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. * - MUST NOT revert. */ function maxDeposit(address receiver) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given * current on-chain conditions. * * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called * in the same transaction. * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the * deposit would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewDeposit(uint256 assets) external view returns (uint256 shares); /** * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * deposit execution, and are accounted for during deposit. * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares); /** * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. * - MUST return a limited value if receiver is subject to some mint limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. * - MUST NOT revert. */ function maxMint(address receiver) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given * current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the * same transaction. * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint * would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by minting. */ function previewMint(uint256 shares) external view returns (uint256 assets); /** * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint * execution, and are accounted for during mint. * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function mint(uint256 shares, address receiver) external returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the * Vault, through a withdraw call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST NOT revert. */ function maxWithdraw(address owner) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, * given current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if * called * in the same transaction. * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though * the withdrawal would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewWithdraw(uint256 assets) external view returns (uint256 shares); /** * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * withdraw execution, and are accounted for during withdraw. * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function withdraw( uint256 assets, address receiver, address owner ) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, * through a redeem call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. * - MUST NOT revert. */ function maxRedeem(address owner) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, * given current on-chain conditions. * * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the * same transaction. * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the * redemption would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by redeeming. */ function previewRedeem(uint256 shares) external view returns (uint256 assets); /** * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * redeem execution, and are accounted for during redeem. * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function redeem( uint256 shares, address receiver, address owner ) external returns (uint256 assets); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`. // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`. // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a // good first aproximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1; uint256 x = a; if (x >> 128 > 0) { x >>= 128; result <<= 64; } if (x >> 64 > 0) { x >>= 64; result <<= 32; } if (x >> 32 > 0) { x >>= 32; result <<= 16; } if (x >> 16 > 0) { x >>= 16; result <<= 8; } if (x >> 8 > 0) { x >>= 8; result <<= 4; } if (x >> 4 > 0) { x >>= 4; result <<= 2; } if (x >> 2 > 0) { result <<= 1; } // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { uint256 result = sqrt(a); if (rounding == Rounding.Up && result * result < a) { result += 1; } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IStEth is IERC20 { function submit(address _referral) external payable returns (uint256); function getTotalPooledEther() external view returns (uint256); function getTotalShares() external view returns (uint256); function sharesOf(address _account) external view returns (uint256); function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256); function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256); function transferShares(address _recipient, uint256 _sharesAmount) external returns (uint256); function transferSharesFrom(address _sender, address _recipient, uint256 _sharesAmount) external returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol) pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../Proxy.sol"; import "../ERC1967/ERC1967Upgrade.sol"; /** * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}. * * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't * conflict with the storage layout of the implementation behind the proxy. * * _Available since v3.4._ */ contract BeaconProxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the proxy with `beacon`. * * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity * constructor. * * Requirements: * * - `beacon` must be a contract with the interface {IBeacon}. */ constructor(address beacon, bytes memory data) payable { _upgradeBeaconToAndCall(beacon, data, false); } /** * @dev Returns the current beacon address. */ function _beacon() internal view virtual returns (address) { return _getBeacon(); } /** * @dev Returns the current implementation address of the associated beacon. */ function _implementation() internal view virtual override returns (address) { return IBeacon(_getBeacon()).implementation(); } /** * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}. * * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. * * Requirements: * * - `beacon` must be a contract. * - The implementation returned by `beacon` must be a contract. */ function _setBeacon(address beacon, bytes memory data) internal virtual { _upgradeBeaconToAndCall(beacon, data, false); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {UltraLRT} from "src/vaults/restaking/UltraLRT.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; import {AffineDelegator} from "src/vaults/restaking/AffineDelegator.sol"; import {AffineGovernable} from "src/utils/audited/AffineGovernable.sol"; import {IStEth} from "src/interfaces/lido/IStEth.sol"; import { WithdrawalInfo, QueuedWithdrawalParams, ApproverSignatureAndExpiryParams, IDelegationManager, IStrategyManager, IStrategy } from "src/interfaces/eigenlayer/eigen.sol"; /** * @title AffineDelegator * @dev Delegator contract for stETH on Eigenlayer */ contract EigenDelegator is Initializable, AffineDelegator, AffineGovernable { using SafeTransferLib for ERC20; /// @notice StrategyManager for Eigenlayer IStrategyManager public constant STRATEGY_MANAGER = IStrategyManager(0x858646372CC42E1A627fcE94aa7A7033e7CF075A); /// @notice DelegationManager for Eigenlayer IDelegationManager public constant DELEGATION_MANAGER = IDelegationManager(0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A); /// @notice stETH strategy on Eigenlayer IStrategy public constant STAKED_ETH_STRATEGY = IStrategy(0x93c4b944D05dfe6df7645A86cd2206016c51564D); // withdrawals record mapping(bytes32 => uint256) public withdrawals; /** * @dev Initialize the contract * @param _vault Vault address * @param _operator Operator address */ function initialize(address _vault, address _operator) external initializer { vault = _vault; asset = ERC20(UltraLRT(vault).asset()); governance = UltraLRT(vault).governance(); currentOperator = _operator; // P2P operator stETH = IStEth(address(asset)); stETH.approve(address(STRATEGY_MANAGER), type(uint256).max); } address public currentOperator; // UltraLRT public vault; IStEth public stETH; uint256 public queuedShares; /** * @notice Modifier to allow function calls only from the vault or harvester * @param amount Amount to delegate * @dev Delegate & restake stETH to operator on Eigenlayer */ function _delegate(uint256 amount) internal override { // deposit into strategy STRATEGY_MANAGER.depositIntoStrategy(address(STAKED_ETH_STRATEGY), address(asset), amount); // delegate to operator if not already if (DELEGATION_MANAGER.delegatedTo(address(this)) != currentOperator) { _delegateToOperator(); } } /** * @notice Request withdrawal from eigenlayer * @param assets Amount to withdraw */ function _requestWithdrawal(uint256 assets) internal override { // request withdrawal QueuedWithdrawalParams[] memory params = new QueuedWithdrawalParams[](1); uint256[] memory shares = new uint256[](1); shares[0] = Math.min(STAKED_ETH_STRATEGY.underlyingToShares(assets), STAKED_ETH_STRATEGY.shares(address(this))); // in any case if converted shares is zero will revert the ops. if (shares[0] > 0) { queuedShares += shares[0]; address[] memory strategies = new address[](1); strategies[0] = address(STAKED_ETH_STRATEGY); params[0] = QueuedWithdrawalParams(strategies, shares, address(this)); bytes32[] memory withdrawalRoots = DELEGATION_MANAGER.queueWithdrawals(params); withdrawals[withdrawalRoots[0]] = shares[0]; } } /** * @notice Complete withdrawal request * @param withdrawalInfo Withdrawal info */ function completeWithdrawalRequest(WithdrawalInfo[] calldata withdrawalInfo) external { require(withdrawalInfo.length == 1, "ED: Invalid info length"); bytes32 root = DELEGATION_MANAGER.calculateWithdrawalRoot(withdrawalInfo[0]); require(DELEGATION_MANAGER.pendingWithdrawals(root), "ED: Invalid withdrawal root"); require(withdrawals[root] > 0, "ED: Withdrawal not recorded"); address[][] memory stEthAddresses = new address[][](1); address[] memory subAddresses = new address[](1); subAddresses[0] = address(stETH); stEthAddresses[0] = subAddresses; uint256[] memory timeIndex = new uint256[](1); timeIndex[0] = 0; bool[] memory receiveAsTokens = new bool[](1); receiveAsTokens[0] = true; DELEGATION_MANAGER.completeQueuedWithdrawals(withdrawalInfo, stEthAddresses, timeIndex, receiveAsTokens); queuedShares -= withdrawalInfo[0].shares[0]; } /** * @notice Record withdrawal request from External requests * @param withdrawal Withdrawal info */ function recordWithdrawalsRequest(WithdrawalInfo calldata withdrawal) external onlyHarvester { require( withdrawal.staker == address(this) && withdrawal.delegatedTo == currentOperator, "ED: Invalid staker or operator" ); bytes32 root = DELEGATION_MANAGER.calculateWithdrawalRoot(withdrawal); require(DELEGATION_MANAGER.pendingWithdrawals(root), "ED: Invalid withdrawal root"); require(withdrawals[root] == 0, "ED: Withdrawal already recorded"); if (withdrawals[root] == 0) { withdrawals[root] = withdrawal.shares[0]; queuedShares += withdrawal.shares[0]; } } /** * @dev Withdraw stETH from delegator to vault */ function withdraw() external override onlyVault { stETH.transferShares(address(vault), stETH.sharesOf(address(this))); } /** * @notice Get withdrawable assets * @return withdrawable assets */ function withdrawableAssets() public view override returns (uint256) { return STAKED_ETH_STRATEGY.userUnderlyingView(address(this)); } /** * @notice Get queued assets * @return queued assets */ function queuedAssets() public view override returns (uint256) { return STAKED_ETH_STRATEGY.sharesToUnderlyingView(queuedShares) + stETH.balanceOf(address(this)); } /** * @dev Delegate to operator */ function _delegateToOperator() internal { // delegate to operator ApproverSignatureAndExpiryParams memory params = ApproverSignatureAndExpiryParams("", 0); DELEGATION_MANAGER.delegateTo( currentOperator, params, 0x0000000000000000000000000000000000000000000000000000000000000000 ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol) pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../../access/Ownable.sol"; import "../../utils/Address.sol"; /** * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their * implementation contract, which is where they will delegate all function calls. * * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon. */ contract UpgradeableBeacon is IBeacon, Ownable { address private _implementation; /** * @dev Emitted when the implementation returned by the beacon is changed. */ event Upgraded(address indexed implementation); /** * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the * beacon. */ constructor(address implementation_) { _setImplementation(implementation_); } /** * @dev Returns the current implementation address. */ function implementation() public view virtual override returns (address) { return _implementation; } /** * @dev Upgrades the beacon to a new implementation. * * Emits an {Upgraded} event. * * Requirements: * * - msg.sender must be the owner of the contract. * - `newImplementation` must be a contract. */ function upgradeTo(address newImplementation) public virtual onlyOwner { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation contract address for this beacon * * Requirements: * * - `newImplementation` must be a contract. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract"); _implementation = newImplementation; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// 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 (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (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) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/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 (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @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 (last updated v4.6.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overridden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../interfaces/draft-IERC1822.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.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 ERC1967Upgrade { // 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 StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.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) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @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 StorageSlot.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"); StorageSlot.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 StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.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) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; interface IUltraLRT { function hasRole(bytes32 role, address user) external view returns (bool); function HARVESTER() external view returns (bytes32); } /** * @title AffineDelegator * @dev Delegator contract for stETH on Eigenlayer */ abstract contract AffineDelegator { using SafeTransferLib for ERC20; address public vault; ERC20 public asset; /** * @notice Modifier to allow function calls only from the vault or harvester */ modifier onlyVaultOrHarvester() { require( IUltraLRT(vault).hasRole(IUltraLRT(vault).HARVESTER(), msg.sender) || msg.sender == vault, "AffineDelegator: Not a vault or harvester" ); _; } /** * @notice Modifier to allow function calls only from the vault */ modifier onlyVault() { require(msg.sender == vault, "AffineDelegator: Not a vault"); _; } /** * @notice Modifier to allow function calls only from the harvester */ modifier onlyHarvester() { require(IUltraLRT(vault).hasRole(IUltraLRT(vault).HARVESTER(), msg.sender), "AffineDelegator: Not a harvester"); _; } /** * @dev Delegate & restake stETH to operator */ function delegate(uint256 amount) external { // Transfer assets from vault to delegator asset.safeTransferFrom(msg.sender, address(this), amount); _delegate(amount); } /** * @dev Delegate stETH to operator */ function _delegate(uint256 amount) internal virtual {} /** * @notice Request withdrawal from eigenlayer * @param assets Amount to withdraw * @dev Request withdrawal from eigenlayer */ function requestWithdrawal(uint256 assets) external onlyVaultOrHarvester { _requestWithdrawal(assets); } /** * @dev Request withdrawal from eigenlayer */ function _requestWithdrawal(uint256 assets) internal virtual {} /** * @dev Withdraw stETH from delegator to vault */ function withdraw() external virtual onlyVault { asset.safeTransfer(vault, asset.balanceOf(address(this))); } /** * @notice Get total locked value * @return Total locked value */ function totalLockedValue() public view virtual returns (uint256) { return withdrawableAssets() + queuedAssets(); } /** * @notice Get withdrawable assets * @return Amount of withdrawable assets */ function withdrawableAssets() public view virtual returns (uint256) {} /** * @notice Get queued assets * @return Amount of queued assets */ function queuedAssets() public view virtual returns (uint256) {} /** * @dev This empty reserved space is put in place to allow future versions to add new */ uint256[50] private __gap; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; struct WithdrawalInfo { address staker; address delegatedTo; address withdrawer; uint256 nonce; uint32 startBlock; address[] strategies; uint256[] shares; } struct QueuedWithdrawalParams { address[] strategies; uint256[] shares; address recipient; } struct ApproverSignatureAndExpiryParams { bytes signature; uint256 expiry; } interface IDelegationManager { function delegateTo(address, ApproverSignatureAndExpiryParams calldata, bytes32) external; function queueWithdrawals(QueuedWithdrawalParams[] calldata) external returns (bytes32[] memory); function completeQueuedWithdrawals( WithdrawalInfo[] calldata, address[][] calldata, uint256[] calldata, bool[] calldata ) external; function calculateWithdrawalRoot(WithdrawalInfo memory withdrawal) external pure returns (bytes32); function pendingWithdrawals(bytes32) external view returns (bool); /** * @notice returns the address of the operator that `staker` is delegated to. * @notice Mapping: staker => operator whom the staker is currently delegated to. * @dev Note that returning address(0) indicates that the staker is not actively delegated to any operator. */ function delegatedTo(address staker) external view returns (address); } interface IStrategyManager { function depositIntoStrategy(address, address, uint256) external; } interface IStrategy { function underlyingToShares(uint256) external view returns (uint256); function sharesToUnderlying(uint256) external view returns (uint256); function userUnderlyingView(address) external view returns (uint256); function sharesToUnderlyingView(uint256) external view returns (uint256); function shares(address) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (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 StorageSlot { 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) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "src/=src/", "script/=script/", "@aave/=node_modules/@aave/", "@chainlink/=node_modules/@chainlink/", "@eth-optimism/=node_modules/@eth-optimism/", "@opengsn/=node_modules/@opengsn/", "@openzeppelin/=node_modules/@openzeppelin/", "@uniswap/=node_modules/@uniswap/", "base64-sol/=node_modules/base64-sol/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc721a/=node_modules/erc721a/", "hardhat/=node_modules/hardhat/", "solady/=node_modules/solady/", "solmate/=node_modules/solmate/" ], "optimizer": { "enabled": true, "runs": 0 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"name":"DepositPaused","type":"error"},{"inputs":[],"name":"ExceedsDelegatorWithdrawableAssets","type":"error"},{"inputs":[],"name":"ExceedsDepositLimit","type":"error"},{"inputs":[],"name":"ExceedsMaxDelegatorLimit","type":"error"},{"inputs":[],"name":"ExceedsMintLimit","type":"error"},{"inputs":[],"name":"ExceedsRedeemLimit","type":"error"},{"inputs":[],"name":"ExceedsWithdrawLimit","type":"error"},{"inputs":[],"name":"ExistingEscrowDebt","type":"error"},{"inputs":[],"name":"InactiveDelegator","type":"error"},{"inputs":[],"name":"InsufficientLiquidAssets","type":"error"},{"inputs":[],"name":"InvalidDelegatorFactory","type":"error"},{"inputs":[],"name":"InvalidEscrow","type":"error"},{"inputs":[],"name":"InvalidEscrowVault","type":"error"},{"inputs":[],"name":"MaxUnresolvedEpochReached","type":"error"},{"inputs":[],"name":"NoResolvingEpoch","type":"error"},{"inputs":[],"name":"NonZeroEmptyDelegatorTVL","type":"error"},{"inputs":[],"name":"ProfitUnlocking","type":"error"},{"inputs":[],"name":"RequireHarvest","type":"error"},{"inputs":[],"name":"RunningEpoch","type":"error"},{"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":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":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":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GUARDIAN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HARVESTER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LOCK_INTERVAL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_DELEGATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STETH","outputs":[{"internalType":"contract IStEth","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ST_ETH_TRANSFER_BUFFER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beacon","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"canWithdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectDelegatorDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"createDelegator","outputs":[],"stateMutability":"nonpayable","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":"address","name":"_delegator","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"delegateToDelegator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegatorAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"delegatorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"delegatorFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"delegatorMap","outputs":[{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint248","name":"balance","type":"uint248"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"delegatorQueue","outputs":[{"internalType":"contract IDelegator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IDelegator","name":"delegator","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"delegatorWithdrawRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositPaused","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"}],"name":"dropDelegator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"escrow","outputs":[{"internalType":"contract WithdrawalEscrowV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialSharesPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_delegatorBeacon","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastEpochTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastHarvest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"liquidationRequest","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLockedProfit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxUnresolvedEpochs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resolveDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_factory","type":"address"}],"name":"setDelegatorFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeBps","type":"uint256"}],"name":"setManagementFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxUnresolvedEpochs","type":"uint256"}],"name":"setMaxUnresolvedEpochs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract WithdrawalEscrowV2","name":"_escrow","type":"address"}],"name":"setWithdrawalEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeBps","type":"uint256"}],"name":"setWithdrawalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","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":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseDeposit","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":"vaultAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"}],"name":"withdrawFromDelegator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawalFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a06040523060805234801561001457600080fd5b506080516151df61004c6000396000818161148b015281816114cb01528181611bb101528181611bf10152611cef01526151df6000f3fe6080604052600436106103ba5760003560e01c806301e1d114146103bf57806301ffc9a7146103e757806302befd241461041757806306fdde031461042e578063079faad41461045057806307a2d13a1461047e57806307d979181461049e578063095ea7b3146104c05780630a28a477146104e05780630b9663db1461050057806317e310f51461051557806318160ddd14610535578063209c33b61461054a57806323b872dd1461056a578063248a9ca31461058a57806324ea54f4146105aa5780632f2ff15d146105cc578063313ce567146105ec57806336568abe146106135780633659cfe61461063357806336716d751461065357806338d52e0f1461067357806339509351146106885780633f4ba83a146106a8578063402d267d146106bd57806344b81396146106dd5780634641257d146106f25780634ae82ebd146107075780634cdad5061461047e5780634f1ef28614610727578063508aba571461073a5780635157ced51461075157806351e596e01461076657806352d1902d1461077b57806359068e391461079057806359659e90146107b05780635aa6e675146107d15780635c975abb146107f25780635e5b75941461080b578063666183ee1461086b578063679aefce1461088257806368bb9a971461089757806369026e88146108ae5780636a8305f7146108c35780636e553f65146108da57806370a08231146108fa57806383b435891461091a5780638456cb591461093a57806389c614b81461094f5780638bc7e8c41461096657806391d148541461097d57806392be0bbf1461099d57806394bf804d146109b257806395d89b41146109d25780639723c3dd146109e7578063a217fddf146109fd578063a26b915f14610a12578063a457c2d714610a32578063a6f7f5d614610a52578063a9059cbb14610a69578063ac1e502514610a89578063ac6b458714610aa9578063b3d7f6b914610ac9578063b460af9414610ae9578063ba08765214610b09578063bdd6e8b814610b29578063c63d75b614610b3e578063c6e6f59214610b5e578063cb9d9fa714610b7e578063ce96cb7714610ba0578063d00364be14610bc0578063d3396c1814610bd7578063d547741f14610bec578063d905777e14610c0c578063dd62ed3e14610c2c578063dfc58e9414610c4c578063e00bfe5014610c6c578063e2fdcc1714610c94578063ef8b30f714610b5e578063f1a392da14610cb5578063f6df5a7814610ccc578063fbe85f0614610ce1578063fd44e64f14610d01578063fd967f4714610d21578063fe56e23214610d37575b600080fd5b3480156103cb57600080fd5b506103d4610d57565b6040519081526020015b60405180910390f35b3480156103f357600080fd5b50610407610402366004614761565b610d86565b60405190151581526020016103de565b34801561042357600080fd5b506103d46101c45481565b34801561043a57600080fd5b50610443610dbd565b6040516103de91906147af565b34801561045c57600080fd5b506101c754610471906001600160a01b031681565b6040516103de91906147e2565b34801561048a57600080fd5b506103d46104993660046147f6565b610e4f565b3480156104aa57600080fd5b506104be6104b9366004614824565b610e5c565b005b3480156104cc57600080fd5b506104076104db366004614841565b610fb8565b3480156104ec57600080fd5b506103d46104fb3660046147f6565b610fd0565b34801561050c57600080fd5b506104be610fdd565b34801561052157600080fd5b506104be610530366004614824565b6111a4565b34801561054157600080fd5b506035546103d4565b34801561055657600080fd5b506104716105653660046147f6565b61130e565b34801561057657600080fd5b5061040761058536600461486d565b61132f565b34801561059657600080fd5b506103d46105a53660046147f6565b611355565b3480156105b657600080fd5b506103d46000805160206150c383398151915281565b3480156105d857600080fd5b506104be6105e73660046148ae565b61136b565b3480156105f857600080fd5b50610601611387565b60405160ff90911681526020016103de565b34801561061f57600080fd5b506104be61062e3660046148ae565b6113fe565b34801561063f57600080fd5b506104be61064e366004614824565b611481565b34801561065f57600080fd5b506104be61066e366004614841565b611549565b34801561067f57600080fd5b50610471611820565b34801561069457600080fd5b506104076106a3366004614841565b61182f565b3480156106b457600080fd5b506104be611851565b3480156106c957600080fd5b506103d46106d8366004614824565b611871565b3480156106e957600080fd5b506103d46118b1565b3480156106fe57600080fd5b506104be611915565b34801561071357600080fd5b506104be610722366004614841565b611aae565b6104be610735366004614969565b611ba7565b34801561074657600080fd5b506103d46102025481565b34801561075d57600080fd5b506104be611c5c565b34801561077257600080fd5b506103d4611c6c565b34801561078757600080fd5b506103d4611ce2565b34801561079c57600080fd5b506104be6107ab3660046147f6565b611d90565b3480156107bc57600080fd5b506101c654610471906001600160a01b031681565b3480156107dd57600080fd5b5061019154610471906001600160a01b031681565b3480156107fe57600080fd5b5061015f5460ff16610407565b34801561081757600080fd5b5061084c610826366004614824565b6101ff6020526000908152604090205460ff81169061010090046001600160f81b031682565b6040805192151583526001600160f81b039091166020830152016103de565b34801561087757600080fd5b506103d46102005481565b34801561088e57600080fd5b506103d4611d9e565b3480156108a357600080fd5b506103d46201518081565b3480156108ba57600080fd5b506104be611db6565b3480156108cf57600080fd5b506103d46101c85481565b3480156108e657600080fd5b506103d46108f53660046148ae565b611dc6565b34801561090657600080fd5b506103d4610915366004614824565b611e6a565b34801561092657600080fd5b506104be6109353660046149ec565b611e85565b34801561094657600080fd5b506104be612115565b34801561095b57600080fd5b506103d46102015481565b34801561097257600080fd5b506103d46101ca5481565b34801561098957600080fd5b506104076109983660046148ae565b612135565b3480156109a957600080fd5b506104be612161565b3480156109be57600080fd5b506103d46109cd3660046148ae565b612189565b3480156109de57600080fd5b50610443612220565b3480156109f357600080fd5b506103d46103e881565b348015610a0957600080fd5b506103d4600081565b348015610a1e57600080fd5b506104be610a2d366004614824565b61222f565b348015610a3e57600080fd5b50610407610a4d366004614841565b612392565b348015610a5e57600080fd5b506103d46101c95481565b348015610a7557600080fd5b50610407610a84366004614841565b612418565b348015610a9557600080fd5b506104be610aa43660046147f6565b612426565b348015610ab557600080fd5b506104be610ac4366004614824565b612434565b348015610ad557600080fd5b506103d4610ae43660046147f6565b6126a8565b348015610af557600080fd5b506103d4610b04366004614a87565b6126b5565b348015610b1557600080fd5b506103d4610b24366004614a87565b612739565b348015610b3557600080fd5b506103d4603281565b348015610b4a57600080fd5b506103d4610b59366004614824565b6127af565b348015610b6a57600080fd5b506103d4610b793660046147f6565b6127bb565b348015610b8a57600080fd5b506103d460008051602061518a83398151915281565b348015610bac57600080fd5b506103d4610bbb366004614824565b6127c8565b348015610bcc57600080fd5b506103d46101cc5481565b348015610be357600080fd5b506104be6127dd565b348015610bf857600080fd5b506104be610c073660046148ae565b612a30565b348015610c1857600080fd5b506103d4610c27366004614824565b612a4c565b348015610c3857600080fd5b506103d4610c47366004614ac9565b612a57565b348015610c5857600080fd5b506104be610c673660046147f6565b612a82565b348015610c7857600080fd5b5061047173ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b348015610ca057600080fd5b506101c554610471906001600160a01b031681565b348015610cc157600080fd5b506103d46101cb5481565b348015610cd857600080fd5b506103d4612aa3565b348015610ced57600080fd5b50610407610cfc3660046147f6565b612ab1565b348015610d0d57600080fd5b506104be610d1c366004614824565b612b8e565b348015610d2d57600080fd5b506103d461271081565b348015610d4357600080fd5b506104be610d523660046147f6565b612c4e565b6000610d616118b1565b6101c854610d6d611c6c565b610d779190614b0d565b610d819190614b20565b905090565b60006001600160e01b03198216637965db0b60e01b1480610db757506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060368054610dcc90614b33565b80601f0160208091040260200160405190810160405280929190818152602001828054610df890614b33565b8015610e455780601f10610e1a57610100808354040283529160200191610e45565b820191906000526020600020905b815481529060010190602001808311610e2857829003601f168201915b5050505050905090565b6000610db7826000612c5c565b610e64612d27565b60326102005410610e885760405163740dbc7160e11b815260040160405180910390fd5b6101c7546001600160a01b0316610eb257604051633a4a298160e11b815260040160405180910390fd5b6101c75460405162fb2f2360e31b81526000916001600160a01b0316906307d9791890610ee39085906004016147e2565b6020604051808303816000875af1158015610f02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f269190614b6d565b9050806101cd6102005460328110610f4057610f40614b8a565b0180546001600160a01b0319166001600160a01b0392831617905560408051808201825260006020808301828152600180855295871683526101ff909152929020815192516001600160f81b03166101000292151560ff1692909217909155610200549091610faf9190614b0d565b61020055505050565b600033610fc6818585612d77565b5060019392505050565b6000610db7826001612e9b565b610ff560008051602061518a83398151915233612135565b15801561101257506201518061020154426110109190614b20565b105b156110305760405163ba407ddd60e01b815260040160405180910390fd5b6101c55460408051630ecce30160e31b815290516000926001600160a01b03169163766718089160048083019260209291908290030181865afa15801561107b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061109f9190614ba0565b90506101c560009054906101000a90046001600160a01b03166001600160a01b0316630b9663db6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156110f257600080fd5b505af1158015611106573d6000803e3d6000fd5b5050426102015550506101c554604051631c4a114760e11b8152600481018390526000916001600160a01b031690633894228e906024016040805180830381865afa158015611159573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117d9190614bd5565b506001600160801b03169050600061119482610e4f565b905061119f81612f51565b505050565b60008051602061518a8339815191526111bc816130ef565b6001600160a01b03821660008181526101ff6020526040808220548151633ccfd60b60e01b8152915186946101009092046001600160f81b0316939192633ccfd60b92600480830193919282900301818387803b15801561121c57600080fd5b505af1158015611230573d6000803e3d6000fd5b505050506000826001600160a01b031663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611276573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129a9190614ba0565b905060008183116112ac5760006112b6565b6112b68284614b20565b6001600160a01b03871660009081526101ff60205260409020805460ff166101006001600160f81b038616021790559050801561130657806101c860008282546113009190614b20565b90915550505b505050505050565b6101cd816032811061131f57600080fd5b01546001600160a01b0316905081565b60003361133d8582856130f9565b611348858585613173565b60019150505b9392505050565b600090815261012d602052604090206001015490565b61137482611355565b61137d816130ef565b61119f838361332f565b60006008611393611820565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f49190614c08565b610d819190614c2b565b6001600160a01b03811633146114735760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61147d82826133b6565b5050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036114c95760405162461bcd60e51b815260040161146a90614c44565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166114fb61341e565b6001600160a01b0316146115215760405162461bcd60e51b815260040161146a90614c7e565b61152a8161343a565b6040805160008082526020820190925261154691839190613442565b50565b60008051602061518a833981519152611561816130ef565b6101c5546001600160a01b031661158b5760405163c4c3834b60e01b815260040160405180910390fd5b6101c560009054906101000a90046001600160a01b03166001600160a01b0316637daac6316040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116039190614ba0565b6101c560009054906101000a90046001600160a01b03166001600160a01b031663766718086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611657573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167b9190614ba0565b6116859190614b20565b6102025410156116a85760405163c2411dcb60e01b815260040160405180910390fd5b6001600160a01b03831660009081526101ff602090815260409182902082518084019093525460ff811615158084526101009091046001600160f81b03169183019190915284919061170d57604051631977e12160e31b815260040160405180910390fd5b83611716611c6c565b101561173557604051633b90d00960e01b815260040160405180910390fd5b6117528585611742611820565b6001600160a01b031691906135ad565b604051639fa6dd3560e01b8152600481018590526001600160a01b03831690639fa6dd3590602401600060405180830381600087803b15801561179457600080fd5b505af11580156117a8573d6000803e3d6000fd5b5050505083816020018181516117be9190614cb8565b6001600160f81b039081169091526001600160a01b03871660009081526101ff6020908152604082208551918601519093166101000290151560ff16179091556101c88054879350909190611814908490614b0d565b90915550505050505050565b6065546001600160a01b031690565b600033610fc68185856118428383612a57565b61184c9190614b0d565b612d77565b6000805160206150c3833981519152611869816130ef565b611546613624565b600080600061187e610d57565b118061188a5750603554155b9050806118985760006118a1565b6001600160801b035b6001600160801b03169392505050565b6000620151806101cb546118c59190614b0d565b42106118d15750600090565b6000620151806101cb54426118e69190614b20565b6101cc546118f49190614cdf565b6118fe9190614d14565b9050806101cc5461190f9190614b20565b91505090565b60008051602061518a83398151915261192d816130ef565b620151806101cb5461193f9190614b0d565b421161195e57604051632592339560e11b815260040160405180910390fd5b6000805b610200548160ff161015611a785760006101cd8260ff166032811061198957611989614b8a565b0160009054906101000a90046001600160a01b03166001600160a01b031663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af11580156119dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a019190614ba0565b9050806101ff60006101cd8560ff1660328110611a2057611a20614b8a565b01546001600160a01b03168152602081019190915260400160002080546001600160f81b03929092166101000260ff909216919091179055611a628184614b0d565b9250508080611a7090614d36565b915050611962565b50806101c8541015611a9b576101c854611a929082614b20565b6101cc55611aa2565b60006101cc555b426101cb556101c85550565b60008051602061518a833981519152611ac6816130ef565b826001600160a01b0316632cdf74016040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b289190614ba0565b821115611b485760405163096d79dd60e31b815260040160405180910390fd5b6040516313dccf3d60e31b8152600481018390526001600160a01b03841690639ee679e890602401600060405180830381600087803b158015611b8a57600080fd5b505af1158015611b9e573d6000803e3d6000fd5b50505050505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003611bef5760405162461bcd60e51b815260040161146a90614c44565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611c2161341e565b6001600160a01b031614611c475760405162461bcd60e51b815260040161146a90614c7e565b611c508261343a565b61147d82826001613442565b611c64612d27565b60006101c455565b6000611c76611820565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611ca191906147e2565b602060405180830381865afa158015611cbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d819190614ba0565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611d7d5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b606482015260840161146a565b5060008051602061512383398151915290565b611d98612d27565b61020255565b6000610d81611dab611387565b61049990600a614e39565b611dbe612d27565b60016101c455565b6000611dd0613671565b6101c45415611df25760405163035edea360e41b815260040160405180910390fd5b60026101925403611e155760405162461bcd60e51b815260040161146a90614e48565b600261019255611e2482611871565b831115611e4457604051630aad288560e21b815260040160405180910390fd5b6000611e4f846127bb565b9050611e5d338486846136b8565b6001610192559392505050565b6001600160a01b031660009081526033602052604090205490565b600054610100900460ff1615808015611ea55750600054600160ff909116105b80611ec65750611eb430613736565b158015611ec6575060005460ff166001145b611f295760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161146a565b6000805460ff191660011790558015611f4c576000805461ff0019166101001790555b61019180546001600160a01b0319166001600160a01b038816179055611f7185613745565b611f7b8383613775565b611f836137a6565b611f8b6137cd565b611f936137fc565b61019154611fac906000906001600160a01b031661332f565b61019154611fd2906000805160206150c3833981519152906001600160a01b031661332f565b61019154611ff89060008051602061518a833981519152906001600160a01b031661332f565b6101915460408051638da5cb5b60e01b815290516001600160a01b0392831692871691638da5cb5b91600480830192602092919082900301816000875af1158015612047573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206b9190614b6d565b6001600160a01b0316146120ac5760405162461bcd60e51b81526020600482015260086024820152672aa6292a1d1024a160c11b604482015260640161146a565b6101c680546001600160a01b0319166001600160a01b0386161790558015611306576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050565b6000805160206150c383398151915261212d816130ef565b61154661382b565b600091825261012d602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60008051602061518a833981519152612179816130ef565b611546612184610d57565b613869565b6000612193613671565b6101c454156121b55760405163035edea360e41b815260040160405180910390fd5b600261019254036121d85760405162461bcd60e51b815260040161146a90614e48565b6002610192556121e7826127af565b83111561220757604051636ae0191360e11b815260040160405180910390fd5b6000612212846126a8565b9050611e5d338483876136b8565b606060378054610dcc90614b33565b612237612d27565b6101c5546001600160a01b0316158015906122be57506101c55460408051631f8f738360e31b815290516000926001600160a01b03169163fc7b9c189160048083019260209291908290030181865afa158015612298573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122bc9190614ba0565b115b156122dc57604051631ddf6bfb60e21b815260040160405180910390fd5b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612324573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123489190614b6d565b6001600160a01b03161461236f57604051633dc8560760e01b815260040160405180910390fd5b6101c580546001600160a01b0319166001600160a01b0392909216919091179055565b600033816123a08286612a57565b9050838110156124005760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161146a565b61240d8286868403612d77565b506001949350505050565b600033610fc6818585613173565b61242e612d27565b6101ca55565b61243c612d27565b6000816001600160a01b031663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af115801561247e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a29190614ba0565b11156124c157604051631d3b20af60e21b815260040160405180910390fd5b6001600160a01b03811660009081526101ff602090815260409182902082518084019093525460ff811615158084526101009091046001600160f81b03169183019190915261252357604051631977e12160e31b815260040160405180910390fd5b60208101516001600160f81b03161561254f576040516322600afb60e01b815260040160405180910390fd5b60008082525b610200548160ff16101561119f57826001600160a01b03166101cd8260ff166032811061258457612584614b8a565b01546001600160a01b031603612696576101cd6001610200546125a79190614b20565b603281106125b7576125b7614b8a565b01546001600160a01b03166101cd60ff8316603281106125d9576125d9614b8a565b0160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060006101cd6001610200546126139190614b20565b6032811061262357612623614b8a565b0180546001600160a01b0319166001600160a01b03929092169190911790556102005461265290600190614b20565b610200556001600160a01b03831660009081526101ff602090815260409091208351918401516001600160f81b03166101000291151560ff16919091179055505050565b806126a081614d36565b915050612555565b6000610db7826001612c5c565b60006126bf613671565b600261019254036126e25760405162461bcd60e51b815260040161146a90614e48565b6002610192556126f1826127c8565b8411156127115760405163c02fc37d60e01b815260040160405180910390fd5b600061271c85610fd0565b905061272b3385858885613aa3565b600161019255949350505050565b6000612743613671565b600261019254036127665760405162461bcd60e51b815260040161146a90614e48565b60026101925561277582612a4c565b84111561279557604051632206bead60e21b815260040160405180910390fd5b60006127a085610e4f565b905061272b3385858489613aa3565b506001600160801b0390565b6000610db7826000612e9b565b6000610db76127d683611e6a565b6000612c5c565b6101c560009054906101000a90046001600160a01b03166001600160a01b031663766718086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612831573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128559190614ba0565b6101c560009054906101000a90046001600160a01b03166001600160a01b0316637daac6316040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128cd9190614ba0565b036128eb57604051631991f45f60e01b815260040160405180910390fd5b60006129686101c560009054906101000a90046001600160a01b03166001600160a01b0316631d174cf86040518163ffffffff1660e01b8152600401602060405180830381865afa158015612944573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104999190614ba0565b9050806103e8612976611c6c565b6129809190614b0d565b101561298f5761298f81613869565b806103e861299b611c6c565b6129a59190614b0d565b10156129c457604051633b90d00960e01b815260040160405180910390fd5b6101c560009054906101000a90046001600160a01b03166001600160a01b03166372cc5e956040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612a1557600080fd5b505af1158015612a29573d6000803e3d6000fd5b5050505050565b612a3982611355565b612a42816130ef565b61119f83836133b6565b6000610db782611e6a565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b60008051602061518a833981519152612a9a816130ef565b61147d82612f51565b6000610d816008600a614e39565b6101c5546000906001600160a01b03163303612acf57506001919050565b6101c5546000906001600160a01b031615612b61576101c560009054906101000a90046001600160a01b03166001600160a01b031663fc7b9c186040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b5c9190614ba0565b612b64565b60005b90508015801561134e5750826103e8612b7b611c6c565b612b859190614b0d565b10159392505050565b612b96612d27565b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612be0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c049190614b6d565b6001600160a01b031614612c2b57604051633a4a298160e11b815260040160405180910390fd5b6101c780546001600160a01b0319166001600160a01b0392909216919091179055565b612c56612d27565b6101c955565b600080612c6860355490565b90508015612c8957612c84612c7b610d57565b85908386613c63565b612d1f565b6065546040805163313ce56760e01b81529051612d1f926001600160a01b03169163313ce5679160048083019260209291908290030181865afa158015612cd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf89190614c08565b612d0390600a614e39565b612d0b611387565b612d1690600a614e39565b86919086613c63565b949350505050565b610191546001600160a01b03163314612d755760405162461bcd60e51b815260206004820152601060248201526f27b7363c9023b7bb32b93730b731b29760811b604482015260640161146a565b565b6001600160a01b038316612dd95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161146a565b6001600160a01b038216612e3a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161146a565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b600080612ea760355490565b9050831580612eb4575080155b612ec457612c8481612d16610d57565b612d1f612ecf611387565b612eda90600a614e39565b606560009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d0b9190614c08565b60005b6102005481108015612f665750600082115b1561147d5760006101cd8260328110612f8157612f81614b8a565b0160009054906101000a90046001600160a01b031690506000816001600160a01b0316632cdf74016040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ffc9190614ba0565b11156130dc57600061306f826001600160a01b0316632cdf74016040518163ffffffff1660e01b8152600401602060405180830381865afa158015613045573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130699190614ba0565b85613cc0565b6040516313dccf3d60e31b8152600481018290529091506001600160a01b03831690639ee679e890602401600060405180830381600087803b1580156130b457600080fd5b505af11580156130c8573d6000803e3d6000fd5b5050505080846130d89190614b20565b9350505b50806130e781614e7f565b915050612f54565b6115468133613cd6565b60006131058484612a57565b9050600019811461316d57818110156131605760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161146a565b61316d8484848403612d77565b50505050565b6001600160a01b0383166131d75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161146a565b6001600160a01b0382166132395760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161146a565b6001600160a01b038316600090815260336020526040902054818110156132b15760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161146a565b6001600160a01b038085166000908152603360205260408082208585039055918516815290812080548492906132e8908490614b0d565b92505081905550826001600160a01b0316846001600160a01b031660008051602061516a8339815191528460405161332291815260200190565b60405180910390a361316d565b6133398282612135565b61147d57600082815261012d602090815260408083206001600160a01b03851684529091529020805460ff191660011790556133723390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6133c08282612135565b1561147d57600082815261012d602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020615123833981519152546001600160a01b031690565b611546612d27565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156134755761119f83613d3a565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156134cf575060408051601f3d908101601f191682019092526134cc91810190614ba0565b60015b6135325760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161146a565b60008051602061512383398151915281146135a15760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161146a565b5061119f838383613dd4565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061316d5760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b604482015260640161146a565b61362c613df9565b61015f805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161366791906147e2565b60405180910390a1565b61015f5460ff1615612d755760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161146a565b6065546136d0906001600160a01b0316853085613e43565b6136da8382613e9d565b826001600160a01b0316846001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78484604051613728929190918252602082015260400190565b60405180910390a350505050565b6001600160a01b03163b151590565b600054610100900460ff1661376c5760405162461bcd60e51b815260040161146a90614e98565b61154681613f6a565b600054610100900460ff1661379c5760405162461bcd60e51b815260040161146a90614e98565b61147d8282613fb3565b600054610100900460ff16612d755760405162461bcd60e51b815260040161146a90614e98565b600054610100900460ff166137f45760405162461bcd60e51b815260040161146a90614e98565b612d75613ff3565b600054610100900460ff166138235760405162461bcd60e51b815260040161146a90614e98565b612d75614027565b613833613671565b61015f805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861365a3390565b6101c85460005b610200548160ff161080156138855750600083115b15613a9b5760006101cd8260ff16603281106138a3576138a3614b8a565b01546001600160a01b0316905060026138ba611820565b6001600160a01b03166370a08231836040518263ffffffff1660e01b81526004016138e591906147e2565b602060405180830381865afa158015613902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139269190614ba0565b10156139325750613a89565b6001600160a01b03811660008181526101ff6020526040808220548151633ccfd60b60e01b815291516101009091046001600160f81b03169392633ccfd60b926004808201939182900301818387803b15801561398e57600080fd5b505af11580156139a2573d6000803e3d6000fd5b505050506000826001600160a01b031663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af11580156139e8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a0c9190614ba0565b6001600160a01b03841660009081526101ff60205260409020805460ff166101006001600160f81b038416021790559050808211613a4b576000613a55565b613a558183614b20565b613a5f9086614b20565b9450856103e8613a6d611c6c565b613a779190614b0d565b1015613a8557505050613a9b565b5050505b80613a9381614d36565b915050613870565b506101c85550565b826001600160a01b0316856001600160a01b031614613ac757613ac78386836130f9565b613ad082612ab1565b613ba557613aeb336101c5546001600160a01b031683613173565b6101c554604051637397216f60e01b81526001600160a01b0386811660048301526024820184905290911690637397216f90604401600060405180830381600087803b158015613b3a57600080fd5b505af1158015613b4e573d6000803e3d6000fd5b50505050826001600160a01b0316846001600160a01b0316866001600160a01b03166000805160206151038339815191528585604051613b98929190918252602082015260400190565b60405180910390a4612a29565b613baf8382614056565b6000613bc2613bbc611c6c565b84613cc0565b905082613bd16103e883614b0d565b1015613bf057604051633b90d00960e01b815260040160405180910390fd5b613c0d8582613bfd611820565b6001600160a01b03169190614192565b836001600160a01b0316856001600160a01b0316876001600160a01b03166000805160206151038339815191528486604051613c53929190918252602082015260400190565b60405180910390a4505050505050565b600080613c7186868661420a565b90506001836002811115613c8757613c87614ee3565b148015613ca4575060008480613c9f57613c9f614cfe565b868809115b15613cb757613cb4600182614b0d565b90505b95945050505050565b6000818310613ccf578161134e565b5090919050565b613ce08282612135565b61147d57613cf8816001600160a01b031660146142b9565b613d038360206142b9565b604051602001613d14929190614ef9565b60408051601f198184030181529082905262461bcd60e51b825261146a916004016147af565b613d4381613736565b613da55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161146a565b60008051602061512383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b613ddd83614454565b600082511180613dea5750805b1561119f5761316d8383614494565b61015f5460ff16612d755760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161146a565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261316d90859061457d565b6001600160a01b038216613ef35760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161146a565b8060356000828254613f059190614b0d565b90915550506001600160a01b03821660009081526033602052604081208054839290613f32908490614b0d565b90915550506040518181526001600160a01b0383169060009060008051602061516a8339815191529060200160405180910390a35050565b600054610100900460ff16613f915760405162461bcd60e51b815260040161146a90614e98565b606580546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff16613fda5760405162461bcd60e51b815260040161146a90614e98565b6036613fe68382614fae565b50603761119f8282614fae565b600054610100900460ff1661401a5760405162461bcd60e51b815260040161146a90614e98565b61015f805460ff19169055565b600054610100900460ff1661404e5760405162461bcd60e51b815260040161146a90614e98565b600161019255565b6001600160a01b0382166140b65760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161146a565b6001600160a01b0382166000908152603360205260409020548181101561412a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161146a565b6001600160a01b0383166000908152603360205260408120838303905560358054849290614159908490614b20565b90915550506040518281526000906001600160a01b0385169060008051602061516a8339815191529060200160405180910390a3505050565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061316d5760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b604482015260640161146a565b60008080600019858709858702925082811083820303915050806000036142445783828161423a5761423a614cfe565b049250505061134e565b80841161425057600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b606060006142c8836002614cdf565b6142d3906002614b0d565b6001600160401b038111156142ea576142ea6148de565b6040519080825280601f01601f191660200182016040528015614314576020820181803683370190505b509050600360fc1b8160008151811061432f5761432f614b8a565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061435e5761435e614b8a565b60200101906001600160f81b031916908160001a9053506000614382846002614cdf565b61438d906001614b0d565b90505b6001811115614405576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106143c1576143c1614b8a565b1a60f81b8282815181106143d7576143d7614b8a565b60200101906001600160f81b031916908160001a90535060049490941c936143fe8161506d565b9050614390565b50831561134e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161146a565b61445d81613d3a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606061449f83613736565b6144fa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161146a565b600080846001600160a01b0316846040516145159190615084565b600060405180830381855af49150503d8060008114614550576040519150601f19603f3d011682016040523d82523d6000602084013e614555565b606091505b5091509150613cb782826040518060600160405280602781526020016151436027913961464f565b60006145d2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166146889092919063ffffffff16565b80519091501561119f57808060200190518101906145f091906150a0565b61119f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161146a565b6060831561465e57508161134e565b82511561466e5782518084602001fd5b8160405162461bcd60e51b815260040161146a91906147af565b6060612d1f84846000858561469c85613736565b6146e85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161146a565b600080866001600160a01b031685876040516147049190615084565b60006040518083038185875af1925050503d8060008114614741576040519150601f19603f3d011682016040523d82523d6000602084013e614746565b606091505b509150915061475682828661464f565b979650505050505050565b60006020828403121561477357600080fd5b81356001600160e01b03198116811461134e57600080fd5b60005b838110156147a657818101518382015260200161478e565b50506000910152565b60208152600082518060208401526147ce81604085016020870161478b565b601f01601f19169190910160400192915050565b6001600160a01b0391909116815260200190565b60006020828403121561480857600080fd5b5035919050565b6001600160a01b038116811461154657600080fd5b60006020828403121561483657600080fd5b813561134e8161480f565b6000806040838503121561485457600080fd5b823561485f8161480f565b946020939093013593505050565b60008060006060848603121561488257600080fd5b833561488d8161480f565b9250602084013561489d8161480f565b929592945050506040919091013590565b600080604083850312156148c157600080fd5b8235915060208301356148d38161480f565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b038084111561490e5761490e6148de565b604051601f8501601f19908116603f01168101908282118183101715614936576149366148de565b8160405280935085815286868601111561494f57600080fd5b858560208301376000602087830101525050509392505050565b6000806040838503121561497c57600080fd5b82356149878161480f565b915060208301356001600160401b038111156149a257600080fd5b8301601f810185136149b357600080fd5b6149c2858235602084016148f4565b9150509250929050565b600082601f8301126149dd57600080fd5b61134e838335602085016148f4565b600080600080600060a08688031215614a0457600080fd5b8535614a0f8161480f565b94506020860135614a1f8161480f565b93506040860135614a2f8161480f565b925060608601356001600160401b0380821115614a4b57600080fd5b614a5789838a016149cc565b93506080880135915080821115614a6d57600080fd5b50614a7a888289016149cc565b9150509295509295909350565b600080600060608486031215614a9c57600080fd5b833592506020840135614aae8161480f565b91506040840135614abe8161480f565b809150509250925092565b60008060408385031215614adc57600080fd5b8235614ae78161480f565b915060208301356148d38161480f565b634e487b7160e01b600052601160045260246000fd5b80820180821115610db757610db7614af7565b81810381811115610db757610db7614af7565b600181811c90821680614b4757607f821691505b602082108103614b6757634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215614b7f57600080fd5b815161134e8161480f565b634e487b7160e01b600052603260045260246000fd5b600060208284031215614bb257600080fd5b5051919050565b80516001600160801b0381168114614bd057600080fd5b919050565b60008060408385031215614be857600080fd5b614bf183614bb9565b9150614bff60208401614bb9565b90509250929050565b600060208284031215614c1a57600080fd5b815160ff8116811461134e57600080fd5b60ff8181168382160190811115610db757610db7614af7565b6020808252602c908201526000805160206150e383398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201526000805160206150e383398151915260408201526b6163746976652070726f787960a01b606082015260800190565b6001600160f81b03818116838216019080821115614cd857614cd8614af7565b5092915050565b6000816000190483118215151615614cf957614cf9614af7565b500290565b634e487b7160e01b600052601260045260246000fd5b600082614d3157634e487b7160e01b600052601260045260246000fd5b500490565b600060ff821660ff8103614d4c57614d4c614af7565b60010192915050565b600181815b80851115614d90578160001904821115614d7657614d76614af7565b80851615614d8357918102915b93841c9390800290614d5a565b509250929050565b600082614da757506001610db7565b81614db457506000610db7565b8160018114614dca5760028114614dd457614df0565b6001915050610db7565b60ff841115614de557614de5614af7565b50506001821b610db7565b5060208310610133831016604e8410600b8410161715614e13575081810a610db7565b614e1d8383614d55565b8060001904821115614e3157614e31614af7565b029392505050565b600061134e60ff841683614d98565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060018201614e9157614e91614af7565b5060010190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052602160045260246000fd5b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351614f2b81601785016020880161478b565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351614f5c81602884016020880161478b565b01602801949350505050565b601f82111561119f57600081815260208120601f850160051c81016020861015614f8f5750805b601f850160051c820191505b8181101561130657828155600101614f9b565b81516001600160401b03811115614fc757614fc76148de565b614fdb81614fd58454614b33565b84614f68565b602080601f8311600181146150105760008415614ff85750858301515b600019600386901b1c1916600185901b178555611306565b600085815260208120601f198616915b8281101561503f57888601518255948401946001909101908401615020565b508582101561505d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008161507c5761507c614af7565b506000190190565b6000825161509681846020870161478b565b9190910192915050565b6000602082840312156150b257600080fd5b8151801515811461134e57600080fdfe8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe846756e6374696f6e206d7573742062652063616c6c6564207468726f75676820fbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884ca26469706673582212205e53a072a20391d6499274e12d663e4b988317a5be738e18256bb48dfcf0eb2764736f6c63430008100033
Deployed Bytecode
0x6080604052600436106103ba5760003560e01c806301e1d114146103bf57806301ffc9a7146103e757806302befd241461041757806306fdde031461042e578063079faad41461045057806307a2d13a1461047e57806307d979181461049e578063095ea7b3146104c05780630a28a477146104e05780630b9663db1461050057806317e310f51461051557806318160ddd14610535578063209c33b61461054a57806323b872dd1461056a578063248a9ca31461058a57806324ea54f4146105aa5780632f2ff15d146105cc578063313ce567146105ec57806336568abe146106135780633659cfe61461063357806336716d751461065357806338d52e0f1461067357806339509351146106885780633f4ba83a146106a8578063402d267d146106bd57806344b81396146106dd5780634641257d146106f25780634ae82ebd146107075780634cdad5061461047e5780634f1ef28614610727578063508aba571461073a5780635157ced51461075157806351e596e01461076657806352d1902d1461077b57806359068e391461079057806359659e90146107b05780635aa6e675146107d15780635c975abb146107f25780635e5b75941461080b578063666183ee1461086b578063679aefce1461088257806368bb9a971461089757806369026e88146108ae5780636a8305f7146108c35780636e553f65146108da57806370a08231146108fa57806383b435891461091a5780638456cb591461093a57806389c614b81461094f5780638bc7e8c41461096657806391d148541461097d57806392be0bbf1461099d57806394bf804d146109b257806395d89b41146109d25780639723c3dd146109e7578063a217fddf146109fd578063a26b915f14610a12578063a457c2d714610a32578063a6f7f5d614610a52578063a9059cbb14610a69578063ac1e502514610a89578063ac6b458714610aa9578063b3d7f6b914610ac9578063b460af9414610ae9578063ba08765214610b09578063bdd6e8b814610b29578063c63d75b614610b3e578063c6e6f59214610b5e578063cb9d9fa714610b7e578063ce96cb7714610ba0578063d00364be14610bc0578063d3396c1814610bd7578063d547741f14610bec578063d905777e14610c0c578063dd62ed3e14610c2c578063dfc58e9414610c4c578063e00bfe5014610c6c578063e2fdcc1714610c94578063ef8b30f714610b5e578063f1a392da14610cb5578063f6df5a7814610ccc578063fbe85f0614610ce1578063fd44e64f14610d01578063fd967f4714610d21578063fe56e23214610d37575b600080fd5b3480156103cb57600080fd5b506103d4610d57565b6040519081526020015b60405180910390f35b3480156103f357600080fd5b50610407610402366004614761565b610d86565b60405190151581526020016103de565b34801561042357600080fd5b506103d46101c45481565b34801561043a57600080fd5b50610443610dbd565b6040516103de91906147af565b34801561045c57600080fd5b506101c754610471906001600160a01b031681565b6040516103de91906147e2565b34801561048a57600080fd5b506103d46104993660046147f6565b610e4f565b3480156104aa57600080fd5b506104be6104b9366004614824565b610e5c565b005b3480156104cc57600080fd5b506104076104db366004614841565b610fb8565b3480156104ec57600080fd5b506103d46104fb3660046147f6565b610fd0565b34801561050c57600080fd5b506104be610fdd565b34801561052157600080fd5b506104be610530366004614824565b6111a4565b34801561054157600080fd5b506035546103d4565b34801561055657600080fd5b506104716105653660046147f6565b61130e565b34801561057657600080fd5b5061040761058536600461486d565b61132f565b34801561059657600080fd5b506103d46105a53660046147f6565b611355565b3480156105b657600080fd5b506103d46000805160206150c383398151915281565b3480156105d857600080fd5b506104be6105e73660046148ae565b61136b565b3480156105f857600080fd5b50610601611387565b60405160ff90911681526020016103de565b34801561061f57600080fd5b506104be61062e3660046148ae565b6113fe565b34801561063f57600080fd5b506104be61064e366004614824565b611481565b34801561065f57600080fd5b506104be61066e366004614841565b611549565b34801561067f57600080fd5b50610471611820565b34801561069457600080fd5b506104076106a3366004614841565b61182f565b3480156106b457600080fd5b506104be611851565b3480156106c957600080fd5b506103d46106d8366004614824565b611871565b3480156106e957600080fd5b506103d46118b1565b3480156106fe57600080fd5b506104be611915565b34801561071357600080fd5b506104be610722366004614841565b611aae565b6104be610735366004614969565b611ba7565b34801561074657600080fd5b506103d46102025481565b34801561075d57600080fd5b506104be611c5c565b34801561077257600080fd5b506103d4611c6c565b34801561078757600080fd5b506103d4611ce2565b34801561079c57600080fd5b506104be6107ab3660046147f6565b611d90565b3480156107bc57600080fd5b506101c654610471906001600160a01b031681565b3480156107dd57600080fd5b5061019154610471906001600160a01b031681565b3480156107fe57600080fd5b5061015f5460ff16610407565b34801561081757600080fd5b5061084c610826366004614824565b6101ff6020526000908152604090205460ff81169061010090046001600160f81b031682565b6040805192151583526001600160f81b039091166020830152016103de565b34801561087757600080fd5b506103d46102005481565b34801561088e57600080fd5b506103d4611d9e565b3480156108a357600080fd5b506103d46201518081565b3480156108ba57600080fd5b506104be611db6565b3480156108cf57600080fd5b506103d46101c85481565b3480156108e657600080fd5b506103d46108f53660046148ae565b611dc6565b34801561090657600080fd5b506103d4610915366004614824565b611e6a565b34801561092657600080fd5b506104be6109353660046149ec565b611e85565b34801561094657600080fd5b506104be612115565b34801561095b57600080fd5b506103d46102015481565b34801561097257600080fd5b506103d46101ca5481565b34801561098957600080fd5b506104076109983660046148ae565b612135565b3480156109a957600080fd5b506104be612161565b3480156109be57600080fd5b506103d46109cd3660046148ae565b612189565b3480156109de57600080fd5b50610443612220565b3480156109f357600080fd5b506103d46103e881565b348015610a0957600080fd5b506103d4600081565b348015610a1e57600080fd5b506104be610a2d366004614824565b61222f565b348015610a3e57600080fd5b50610407610a4d366004614841565b612392565b348015610a5e57600080fd5b506103d46101c95481565b348015610a7557600080fd5b50610407610a84366004614841565b612418565b348015610a9557600080fd5b506104be610aa43660046147f6565b612426565b348015610ab557600080fd5b506104be610ac4366004614824565b612434565b348015610ad557600080fd5b506103d4610ae43660046147f6565b6126a8565b348015610af557600080fd5b506103d4610b04366004614a87565b6126b5565b348015610b1557600080fd5b506103d4610b24366004614a87565b612739565b348015610b3557600080fd5b506103d4603281565b348015610b4a57600080fd5b506103d4610b59366004614824565b6127af565b348015610b6a57600080fd5b506103d4610b793660046147f6565b6127bb565b348015610b8a57600080fd5b506103d460008051602061518a83398151915281565b348015610bac57600080fd5b506103d4610bbb366004614824565b6127c8565b348015610bcc57600080fd5b506103d46101cc5481565b348015610be357600080fd5b506104be6127dd565b348015610bf857600080fd5b506104be610c073660046148ae565b612a30565b348015610c1857600080fd5b506103d4610c27366004614824565b612a4c565b348015610c3857600080fd5b506103d4610c47366004614ac9565b612a57565b348015610c5857600080fd5b506104be610c673660046147f6565b612a82565b348015610c7857600080fd5b5061047173ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b348015610ca057600080fd5b506101c554610471906001600160a01b031681565b348015610cc157600080fd5b506103d46101cb5481565b348015610cd857600080fd5b506103d4612aa3565b348015610ced57600080fd5b50610407610cfc3660046147f6565b612ab1565b348015610d0d57600080fd5b506104be610d1c366004614824565b612b8e565b348015610d2d57600080fd5b506103d461271081565b348015610d4357600080fd5b506104be610d523660046147f6565b612c4e565b6000610d616118b1565b6101c854610d6d611c6c565b610d779190614b0d565b610d819190614b20565b905090565b60006001600160e01b03198216637965db0b60e01b1480610db757506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060368054610dcc90614b33565b80601f0160208091040260200160405190810160405280929190818152602001828054610df890614b33565b8015610e455780601f10610e1a57610100808354040283529160200191610e45565b820191906000526020600020905b815481529060010190602001808311610e2857829003601f168201915b5050505050905090565b6000610db7826000612c5c565b610e64612d27565b60326102005410610e885760405163740dbc7160e11b815260040160405180910390fd5b6101c7546001600160a01b0316610eb257604051633a4a298160e11b815260040160405180910390fd5b6101c75460405162fb2f2360e31b81526000916001600160a01b0316906307d9791890610ee39085906004016147e2565b6020604051808303816000875af1158015610f02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f269190614b6d565b9050806101cd6102005460328110610f4057610f40614b8a565b0180546001600160a01b0319166001600160a01b0392831617905560408051808201825260006020808301828152600180855295871683526101ff909152929020815192516001600160f81b03166101000292151560ff1692909217909155610200549091610faf9190614b0d565b61020055505050565b600033610fc6818585612d77565b5060019392505050565b6000610db7826001612e9b565b610ff560008051602061518a83398151915233612135565b15801561101257506201518061020154426110109190614b20565b105b156110305760405163ba407ddd60e01b815260040160405180910390fd5b6101c55460408051630ecce30160e31b815290516000926001600160a01b03169163766718089160048083019260209291908290030181865afa15801561107b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061109f9190614ba0565b90506101c560009054906101000a90046001600160a01b03166001600160a01b0316630b9663db6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156110f257600080fd5b505af1158015611106573d6000803e3d6000fd5b5050426102015550506101c554604051631c4a114760e11b8152600481018390526000916001600160a01b031690633894228e906024016040805180830381865afa158015611159573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117d9190614bd5565b506001600160801b03169050600061119482610e4f565b905061119f81612f51565b505050565b60008051602061518a8339815191526111bc816130ef565b6001600160a01b03821660008181526101ff6020526040808220548151633ccfd60b60e01b8152915186946101009092046001600160f81b0316939192633ccfd60b92600480830193919282900301818387803b15801561121c57600080fd5b505af1158015611230573d6000803e3d6000fd5b505050506000826001600160a01b031663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611276573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129a9190614ba0565b905060008183116112ac5760006112b6565b6112b68284614b20565b6001600160a01b03871660009081526101ff60205260409020805460ff166101006001600160f81b038616021790559050801561130657806101c860008282546113009190614b20565b90915550505b505050505050565b6101cd816032811061131f57600080fd5b01546001600160a01b0316905081565b60003361133d8582856130f9565b611348858585613173565b60019150505b9392505050565b600090815261012d602052604090206001015490565b61137482611355565b61137d816130ef565b61119f838361332f565b60006008611393611820565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f49190614c08565b610d819190614c2b565b6001600160a01b03811633146114735760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61147d82826133b6565b5050565b6001600160a01b037f0000000000000000000000000b75f2b048ca8517f6476316f872903920dcc8ef1630036114c95760405162461bcd60e51b815260040161146a90614c44565b7f0000000000000000000000000b75f2b048ca8517f6476316f872903920dcc8ef6001600160a01b03166114fb61341e565b6001600160a01b0316146115215760405162461bcd60e51b815260040161146a90614c7e565b61152a8161343a565b6040805160008082526020820190925261154691839190613442565b50565b60008051602061518a833981519152611561816130ef565b6101c5546001600160a01b031661158b5760405163c4c3834b60e01b815260040160405180910390fd5b6101c560009054906101000a90046001600160a01b03166001600160a01b0316637daac6316040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116039190614ba0565b6101c560009054906101000a90046001600160a01b03166001600160a01b031663766718086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611657573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167b9190614ba0565b6116859190614b20565b6102025410156116a85760405163c2411dcb60e01b815260040160405180910390fd5b6001600160a01b03831660009081526101ff602090815260409182902082518084019093525460ff811615158084526101009091046001600160f81b03169183019190915284919061170d57604051631977e12160e31b815260040160405180910390fd5b83611716611c6c565b101561173557604051633b90d00960e01b815260040160405180910390fd5b6117528585611742611820565b6001600160a01b031691906135ad565b604051639fa6dd3560e01b8152600481018590526001600160a01b03831690639fa6dd3590602401600060405180830381600087803b15801561179457600080fd5b505af11580156117a8573d6000803e3d6000fd5b5050505083816020018181516117be9190614cb8565b6001600160f81b039081169091526001600160a01b03871660009081526101ff6020908152604082208551918601519093166101000290151560ff16179091556101c88054879350909190611814908490614b0d565b90915550505050505050565b6065546001600160a01b031690565b600033610fc68185856118428383612a57565b61184c9190614b0d565b612d77565b6000805160206150c3833981519152611869816130ef565b611546613624565b600080600061187e610d57565b118061188a5750603554155b9050806118985760006118a1565b6001600160801b035b6001600160801b03169392505050565b6000620151806101cb546118c59190614b0d565b42106118d15750600090565b6000620151806101cb54426118e69190614b20565b6101cc546118f49190614cdf565b6118fe9190614d14565b9050806101cc5461190f9190614b20565b91505090565b60008051602061518a83398151915261192d816130ef565b620151806101cb5461193f9190614b0d565b421161195e57604051632592339560e11b815260040160405180910390fd5b6000805b610200548160ff161015611a785760006101cd8260ff166032811061198957611989614b8a565b0160009054906101000a90046001600160a01b03166001600160a01b031663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af11580156119dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a019190614ba0565b9050806101ff60006101cd8560ff1660328110611a2057611a20614b8a565b01546001600160a01b03168152602081019190915260400160002080546001600160f81b03929092166101000260ff909216919091179055611a628184614b0d565b9250508080611a7090614d36565b915050611962565b50806101c8541015611a9b576101c854611a929082614b20565b6101cc55611aa2565b60006101cc555b426101cb556101c85550565b60008051602061518a833981519152611ac6816130ef565b826001600160a01b0316632cdf74016040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b289190614ba0565b821115611b485760405163096d79dd60e31b815260040160405180910390fd5b6040516313dccf3d60e31b8152600481018390526001600160a01b03841690639ee679e890602401600060405180830381600087803b158015611b8a57600080fd5b505af1158015611b9e573d6000803e3d6000fd5b50505050505050565b6001600160a01b037f0000000000000000000000000b75f2b048ca8517f6476316f872903920dcc8ef163003611bef5760405162461bcd60e51b815260040161146a90614c44565b7f0000000000000000000000000b75f2b048ca8517f6476316f872903920dcc8ef6001600160a01b0316611c2161341e565b6001600160a01b031614611c475760405162461bcd60e51b815260040161146a90614c7e565b611c508261343a565b61147d82826001613442565b611c64612d27565b60006101c455565b6000611c76611820565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611ca191906147e2565b602060405180830381865afa158015611cbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d819190614ba0565b6000306001600160a01b037f0000000000000000000000000b75f2b048ca8517f6476316f872903920dcc8ef1614611d7d5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b606482015260840161146a565b5060008051602061512383398151915290565b611d98612d27565b61020255565b6000610d81611dab611387565b61049990600a614e39565b611dbe612d27565b60016101c455565b6000611dd0613671565b6101c45415611df25760405163035edea360e41b815260040160405180910390fd5b60026101925403611e155760405162461bcd60e51b815260040161146a90614e48565b600261019255611e2482611871565b831115611e4457604051630aad288560e21b815260040160405180910390fd5b6000611e4f846127bb565b9050611e5d338486846136b8565b6001610192559392505050565b6001600160a01b031660009081526033602052604090205490565b600054610100900460ff1615808015611ea55750600054600160ff909116105b80611ec65750611eb430613736565b158015611ec6575060005460ff166001145b611f295760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161146a565b6000805460ff191660011790558015611f4c576000805461ff0019166101001790555b61019180546001600160a01b0319166001600160a01b038816179055611f7185613745565b611f7b8383613775565b611f836137a6565b611f8b6137cd565b611f936137fc565b61019154611fac906000906001600160a01b031661332f565b61019154611fd2906000805160206150c3833981519152906001600160a01b031661332f565b61019154611ff89060008051602061518a833981519152906001600160a01b031661332f565b6101915460408051638da5cb5b60e01b815290516001600160a01b0392831692871691638da5cb5b91600480830192602092919082900301816000875af1158015612047573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206b9190614b6d565b6001600160a01b0316146120ac5760405162461bcd60e51b81526020600482015260086024820152672aa6292a1d1024a160c11b604482015260640161146a565b6101c680546001600160a01b0319166001600160a01b0386161790558015611306576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050565b6000805160206150c383398151915261212d816130ef565b61154661382b565b600091825261012d602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60008051602061518a833981519152612179816130ef565b611546612184610d57565b613869565b6000612193613671565b6101c454156121b55760405163035edea360e41b815260040160405180910390fd5b600261019254036121d85760405162461bcd60e51b815260040161146a90614e48565b6002610192556121e7826127af565b83111561220757604051636ae0191360e11b815260040160405180910390fd5b6000612212846126a8565b9050611e5d338483876136b8565b606060378054610dcc90614b33565b612237612d27565b6101c5546001600160a01b0316158015906122be57506101c55460408051631f8f738360e31b815290516000926001600160a01b03169163fc7b9c189160048083019260209291908290030181865afa158015612298573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122bc9190614ba0565b115b156122dc57604051631ddf6bfb60e21b815260040160405180910390fd5b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612324573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123489190614b6d565b6001600160a01b03161461236f57604051633dc8560760e01b815260040160405180910390fd5b6101c580546001600160a01b0319166001600160a01b0392909216919091179055565b600033816123a08286612a57565b9050838110156124005760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161146a565b61240d8286868403612d77565b506001949350505050565b600033610fc6818585613173565b61242e612d27565b6101ca55565b61243c612d27565b6000816001600160a01b031663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af115801561247e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a29190614ba0565b11156124c157604051631d3b20af60e21b815260040160405180910390fd5b6001600160a01b03811660009081526101ff602090815260409182902082518084019093525460ff811615158084526101009091046001600160f81b03169183019190915261252357604051631977e12160e31b815260040160405180910390fd5b60208101516001600160f81b03161561254f576040516322600afb60e01b815260040160405180910390fd5b60008082525b610200548160ff16101561119f57826001600160a01b03166101cd8260ff166032811061258457612584614b8a565b01546001600160a01b031603612696576101cd6001610200546125a79190614b20565b603281106125b7576125b7614b8a565b01546001600160a01b03166101cd60ff8316603281106125d9576125d9614b8a565b0160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060006101cd6001610200546126139190614b20565b6032811061262357612623614b8a565b0180546001600160a01b0319166001600160a01b03929092169190911790556102005461265290600190614b20565b610200556001600160a01b03831660009081526101ff602090815260409091208351918401516001600160f81b03166101000291151560ff16919091179055505050565b806126a081614d36565b915050612555565b6000610db7826001612c5c565b60006126bf613671565b600261019254036126e25760405162461bcd60e51b815260040161146a90614e48565b6002610192556126f1826127c8565b8411156127115760405163c02fc37d60e01b815260040160405180910390fd5b600061271c85610fd0565b905061272b3385858885613aa3565b600161019255949350505050565b6000612743613671565b600261019254036127665760405162461bcd60e51b815260040161146a90614e48565b60026101925561277582612a4c565b84111561279557604051632206bead60e21b815260040160405180910390fd5b60006127a085610e4f565b905061272b3385858489613aa3565b506001600160801b0390565b6000610db7826000612e9b565b6000610db76127d683611e6a565b6000612c5c565b6101c560009054906101000a90046001600160a01b03166001600160a01b031663766718086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612831573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128559190614ba0565b6101c560009054906101000a90046001600160a01b03166001600160a01b0316637daac6316040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128cd9190614ba0565b036128eb57604051631991f45f60e01b815260040160405180910390fd5b60006129686101c560009054906101000a90046001600160a01b03166001600160a01b0316631d174cf86040518163ffffffff1660e01b8152600401602060405180830381865afa158015612944573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104999190614ba0565b9050806103e8612976611c6c565b6129809190614b0d565b101561298f5761298f81613869565b806103e861299b611c6c565b6129a59190614b0d565b10156129c457604051633b90d00960e01b815260040160405180910390fd5b6101c560009054906101000a90046001600160a01b03166001600160a01b03166372cc5e956040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612a1557600080fd5b505af1158015612a29573d6000803e3d6000fd5b5050505050565b612a3982611355565b612a42816130ef565b61119f83836133b6565b6000610db782611e6a565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b60008051602061518a833981519152612a9a816130ef565b61147d82612f51565b6000610d816008600a614e39565b6101c5546000906001600160a01b03163303612acf57506001919050565b6101c5546000906001600160a01b031615612b61576101c560009054906101000a90046001600160a01b03166001600160a01b031663fc7b9c186040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b5c9190614ba0565b612b64565b60005b90508015801561134e5750826103e8612b7b611c6c565b612b859190614b0d565b10159392505050565b612b96612d27565b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612be0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c049190614b6d565b6001600160a01b031614612c2b57604051633a4a298160e11b815260040160405180910390fd5b6101c780546001600160a01b0319166001600160a01b0392909216919091179055565b612c56612d27565b6101c955565b600080612c6860355490565b90508015612c8957612c84612c7b610d57565b85908386613c63565b612d1f565b6065546040805163313ce56760e01b81529051612d1f926001600160a01b03169163313ce5679160048083019260209291908290030181865afa158015612cd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf89190614c08565b612d0390600a614e39565b612d0b611387565b612d1690600a614e39565b86919086613c63565b949350505050565b610191546001600160a01b03163314612d755760405162461bcd60e51b815260206004820152601060248201526f27b7363c9023b7bb32b93730b731b29760811b604482015260640161146a565b565b6001600160a01b038316612dd95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161146a565b6001600160a01b038216612e3a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161146a565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b600080612ea760355490565b9050831580612eb4575080155b612ec457612c8481612d16610d57565b612d1f612ecf611387565b612eda90600a614e39565b606560009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d0b9190614c08565b60005b6102005481108015612f665750600082115b1561147d5760006101cd8260328110612f8157612f81614b8a565b0160009054906101000a90046001600160a01b031690506000816001600160a01b0316632cdf74016040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ffc9190614ba0565b11156130dc57600061306f826001600160a01b0316632cdf74016040518163ffffffff1660e01b8152600401602060405180830381865afa158015613045573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130699190614ba0565b85613cc0565b6040516313dccf3d60e31b8152600481018290529091506001600160a01b03831690639ee679e890602401600060405180830381600087803b1580156130b457600080fd5b505af11580156130c8573d6000803e3d6000fd5b5050505080846130d89190614b20565b9350505b50806130e781614e7f565b915050612f54565b6115468133613cd6565b60006131058484612a57565b9050600019811461316d57818110156131605760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161146a565b61316d8484848403612d77565b50505050565b6001600160a01b0383166131d75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161146a565b6001600160a01b0382166132395760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161146a565b6001600160a01b038316600090815260336020526040902054818110156132b15760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161146a565b6001600160a01b038085166000908152603360205260408082208585039055918516815290812080548492906132e8908490614b0d565b92505081905550826001600160a01b0316846001600160a01b031660008051602061516a8339815191528460405161332291815260200190565b60405180910390a361316d565b6133398282612135565b61147d57600082815261012d602090815260408083206001600160a01b03851684529091529020805460ff191660011790556133723390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6133c08282612135565b1561147d57600082815261012d602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020615123833981519152546001600160a01b031690565b611546612d27565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156134755761119f83613d3a565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156134cf575060408051601f3d908101601f191682019092526134cc91810190614ba0565b60015b6135325760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161146a565b60008051602061512383398151915281146135a15760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161146a565b5061119f838383613dd4565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061316d5760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b604482015260640161146a565b61362c613df9565b61015f805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161366791906147e2565b60405180910390a1565b61015f5460ff1615612d755760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161146a565b6065546136d0906001600160a01b0316853085613e43565b6136da8382613e9d565b826001600160a01b0316846001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78484604051613728929190918252602082015260400190565b60405180910390a350505050565b6001600160a01b03163b151590565b600054610100900460ff1661376c5760405162461bcd60e51b815260040161146a90614e98565b61154681613f6a565b600054610100900460ff1661379c5760405162461bcd60e51b815260040161146a90614e98565b61147d8282613fb3565b600054610100900460ff16612d755760405162461bcd60e51b815260040161146a90614e98565b600054610100900460ff166137f45760405162461bcd60e51b815260040161146a90614e98565b612d75613ff3565b600054610100900460ff166138235760405162461bcd60e51b815260040161146a90614e98565b612d75614027565b613833613671565b61015f805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861365a3390565b6101c85460005b610200548160ff161080156138855750600083115b15613a9b5760006101cd8260ff16603281106138a3576138a3614b8a565b01546001600160a01b0316905060026138ba611820565b6001600160a01b03166370a08231836040518263ffffffff1660e01b81526004016138e591906147e2565b602060405180830381865afa158015613902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139269190614ba0565b10156139325750613a89565b6001600160a01b03811660008181526101ff6020526040808220548151633ccfd60b60e01b815291516101009091046001600160f81b03169392633ccfd60b926004808201939182900301818387803b15801561398e57600080fd5b505af11580156139a2573d6000803e3d6000fd5b505050506000826001600160a01b031663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af11580156139e8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a0c9190614ba0565b6001600160a01b03841660009081526101ff60205260409020805460ff166101006001600160f81b038416021790559050808211613a4b576000613a55565b613a558183614b20565b613a5f9086614b20565b9450856103e8613a6d611c6c565b613a779190614b0d565b1015613a8557505050613a9b565b5050505b80613a9381614d36565b915050613870565b506101c85550565b826001600160a01b0316856001600160a01b031614613ac757613ac78386836130f9565b613ad082612ab1565b613ba557613aeb336101c5546001600160a01b031683613173565b6101c554604051637397216f60e01b81526001600160a01b0386811660048301526024820184905290911690637397216f90604401600060405180830381600087803b158015613b3a57600080fd5b505af1158015613b4e573d6000803e3d6000fd5b50505050826001600160a01b0316846001600160a01b0316866001600160a01b03166000805160206151038339815191528585604051613b98929190918252602082015260400190565b60405180910390a4612a29565b613baf8382614056565b6000613bc2613bbc611c6c565b84613cc0565b905082613bd16103e883614b0d565b1015613bf057604051633b90d00960e01b815260040160405180910390fd5b613c0d8582613bfd611820565b6001600160a01b03169190614192565b836001600160a01b0316856001600160a01b0316876001600160a01b03166000805160206151038339815191528486604051613c53929190918252602082015260400190565b60405180910390a4505050505050565b600080613c7186868661420a565b90506001836002811115613c8757613c87614ee3565b148015613ca4575060008480613c9f57613c9f614cfe565b868809115b15613cb757613cb4600182614b0d565b90505b95945050505050565b6000818310613ccf578161134e565b5090919050565b613ce08282612135565b61147d57613cf8816001600160a01b031660146142b9565b613d038360206142b9565b604051602001613d14929190614ef9565b60408051601f198184030181529082905262461bcd60e51b825261146a916004016147af565b613d4381613736565b613da55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161146a565b60008051602061512383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b613ddd83614454565b600082511180613dea5750805b1561119f5761316d8383614494565b61015f5460ff16612d755760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161146a565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261316d90859061457d565b6001600160a01b038216613ef35760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161146a565b8060356000828254613f059190614b0d565b90915550506001600160a01b03821660009081526033602052604081208054839290613f32908490614b0d565b90915550506040518181526001600160a01b0383169060009060008051602061516a8339815191529060200160405180910390a35050565b600054610100900460ff16613f915760405162461bcd60e51b815260040161146a90614e98565b606580546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff16613fda5760405162461bcd60e51b815260040161146a90614e98565b6036613fe68382614fae565b50603761119f8282614fae565b600054610100900460ff1661401a5760405162461bcd60e51b815260040161146a90614e98565b61015f805460ff19169055565b600054610100900460ff1661404e5760405162461bcd60e51b815260040161146a90614e98565b600161019255565b6001600160a01b0382166140b65760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161146a565b6001600160a01b0382166000908152603360205260409020548181101561412a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161146a565b6001600160a01b0383166000908152603360205260408120838303905560358054849290614159908490614b20565b90915550506040518281526000906001600160a01b0385169060008051602061516a8339815191529060200160405180910390a3505050565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061316d5760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b604482015260640161146a565b60008080600019858709858702925082811083820303915050806000036142445783828161423a5761423a614cfe565b049250505061134e565b80841161425057600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b606060006142c8836002614cdf565b6142d3906002614b0d565b6001600160401b038111156142ea576142ea6148de565b6040519080825280601f01601f191660200182016040528015614314576020820181803683370190505b509050600360fc1b8160008151811061432f5761432f614b8a565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061435e5761435e614b8a565b60200101906001600160f81b031916908160001a9053506000614382846002614cdf565b61438d906001614b0d565b90505b6001811115614405576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106143c1576143c1614b8a565b1a60f81b8282815181106143d7576143d7614b8a565b60200101906001600160f81b031916908160001a90535060049490941c936143fe8161506d565b9050614390565b50831561134e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161146a565b61445d81613d3a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606061449f83613736565b6144fa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161146a565b600080846001600160a01b0316846040516145159190615084565b600060405180830381855af49150503d8060008114614550576040519150601f19603f3d011682016040523d82523d6000602084013e614555565b606091505b5091509150613cb782826040518060600160405280602781526020016151436027913961464f565b60006145d2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166146889092919063ffffffff16565b80519091501561119f57808060200190518101906145f091906150a0565b61119f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161146a565b6060831561465e57508161134e565b82511561466e5782518084602001fd5b8160405162461bcd60e51b815260040161146a91906147af565b6060612d1f84846000858561469c85613736565b6146e85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161146a565b600080866001600160a01b031685876040516147049190615084565b60006040518083038185875af1925050503d8060008114614741576040519150601f19603f3d011682016040523d82523d6000602084013e614746565b606091505b509150915061475682828661464f565b979650505050505050565b60006020828403121561477357600080fd5b81356001600160e01b03198116811461134e57600080fd5b60005b838110156147a657818101518382015260200161478e565b50506000910152565b60208152600082518060208401526147ce81604085016020870161478b565b601f01601f19169190910160400192915050565b6001600160a01b0391909116815260200190565b60006020828403121561480857600080fd5b5035919050565b6001600160a01b038116811461154657600080fd5b60006020828403121561483657600080fd5b813561134e8161480f565b6000806040838503121561485457600080fd5b823561485f8161480f565b946020939093013593505050565b60008060006060848603121561488257600080fd5b833561488d8161480f565b9250602084013561489d8161480f565b929592945050506040919091013590565b600080604083850312156148c157600080fd5b8235915060208301356148d38161480f565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b038084111561490e5761490e6148de565b604051601f8501601f19908116603f01168101908282118183101715614936576149366148de565b8160405280935085815286868601111561494f57600080fd5b858560208301376000602087830101525050509392505050565b6000806040838503121561497c57600080fd5b82356149878161480f565b915060208301356001600160401b038111156149a257600080fd5b8301601f810185136149b357600080fd5b6149c2858235602084016148f4565b9150509250929050565b600082601f8301126149dd57600080fd5b61134e838335602085016148f4565b600080600080600060a08688031215614a0457600080fd5b8535614a0f8161480f565b94506020860135614a1f8161480f565b93506040860135614a2f8161480f565b925060608601356001600160401b0380821115614a4b57600080fd5b614a5789838a016149cc565b93506080880135915080821115614a6d57600080fd5b50614a7a888289016149cc565b9150509295509295909350565b600080600060608486031215614a9c57600080fd5b833592506020840135614aae8161480f565b91506040840135614abe8161480f565b809150509250925092565b60008060408385031215614adc57600080fd5b8235614ae78161480f565b915060208301356148d38161480f565b634e487b7160e01b600052601160045260246000fd5b80820180821115610db757610db7614af7565b81810381811115610db757610db7614af7565b600181811c90821680614b4757607f821691505b602082108103614b6757634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215614b7f57600080fd5b815161134e8161480f565b634e487b7160e01b600052603260045260246000fd5b600060208284031215614bb257600080fd5b5051919050565b80516001600160801b0381168114614bd057600080fd5b919050565b60008060408385031215614be857600080fd5b614bf183614bb9565b9150614bff60208401614bb9565b90509250929050565b600060208284031215614c1a57600080fd5b815160ff8116811461134e57600080fd5b60ff8181168382160190811115610db757610db7614af7565b6020808252602c908201526000805160206150e383398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201526000805160206150e383398151915260408201526b6163746976652070726f787960a01b606082015260800190565b6001600160f81b03818116838216019080821115614cd857614cd8614af7565b5092915050565b6000816000190483118215151615614cf957614cf9614af7565b500290565b634e487b7160e01b600052601260045260246000fd5b600082614d3157634e487b7160e01b600052601260045260246000fd5b500490565b600060ff821660ff8103614d4c57614d4c614af7565b60010192915050565b600181815b80851115614d90578160001904821115614d7657614d76614af7565b80851615614d8357918102915b93841c9390800290614d5a565b509250929050565b600082614da757506001610db7565b81614db457506000610db7565b8160018114614dca5760028114614dd457614df0565b6001915050610db7565b60ff841115614de557614de5614af7565b50506001821b610db7565b5060208310610133831016604e8410600b8410161715614e13575081810a610db7565b614e1d8383614d55565b8060001904821115614e3157614e31614af7565b029392505050565b600061134e60ff841683614d98565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060018201614e9157614e91614af7565b5060010190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052602160045260246000fd5b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351614f2b81601785016020880161478b565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351614f5c81602884016020880161478b565b01602801949350505050565b601f82111561119f57600081815260208120601f850160051c81016020861015614f8f5750805b601f850160051c820191505b8181101561130657828155600101614f9b565b81516001600160401b03811115614fc757614fc76148de565b614fdb81614fd58454614b33565b84614f68565b602080601f8311600181146150105760008415614ff85750858301515b600019600386901b1c1916600185901b178555611306565b600085815260208120601f198616915b8281101561503f57888601518255948401946001909101908401615020565b508582101561505d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008161507c5761507c614af7565b506000190190565b6000825161509681846020870161478b565b9190910192915050565b6000602082840312156150b257600080fd5b8151801515811461134e57600080fdfe8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe846756e6374696f6e206d7573742062652063616c6c6564207468726f75676820fbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884ca26469706673582212205e53a072a20391d6499274e12d663e4b988317a5be738e18256bb48dfcf0eb2764736f6c63430008100033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.