Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
LRTSquared
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 500 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {ERC20PermitUpgradeable} from "@openzeppelin-upgradeable/contracts/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; import {UUPSUpgradeable, Initializable} from "@openzeppelin-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol"; import {IPriceProvider} from "src/interfaces/IPriceProvider.sol"; import {Governable} from "./governance/Governable.sol"; import {PausableUpgradeable} from "@openzeppelin-upgradeable/contracts/utils/PausableUpgradeable.sol"; import {BucketLimiter} from "./libraries/BucketLimiter.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {ISwapper} from "./interfaces/ISwapper.sol"; /* AVSs pay out rewards to stakers in their ERC20 tokens. The LrtSquare contract consolidates AVS rewards into a single ERC20 token It is designed to address the inefficiencies of collecting small, scattered rewards, which can be costly and cumbersome for users. LrtSquare enables LRT protocols to deposit AVS rewards, issue share tokens to stakers, and allows users to redeem the underlying assets proportionate to their shares. This setup reduces transaction costs and simplifies the reward collection process, benefiting users with smaller stakes who might prefer managing/trading their share tokens directly, while larger holders have the option to redeem and potentially arbitrage. */ contract LRTSquared is Initializable, Governable, ERC20PermitUpgradeable, PausableUpgradeable, UUPSUpgradeable { using BucketLimiter for BucketLimiter.Limit; using SafeERC20 for IERC20; using Math for uint256; struct TokenInfo { bool registered; bool whitelisted; uint64 positionWeightLimit; } struct RateLimit { BucketLimiter.Limit limit; uint64 timePeriod; uint64 renewTimestamp; uint128 percentageLimit; } struct Fee { address treasury; uint48 depositFeeInBps; uint48 redeemFeeInBps; } uint64 public constant HUNDRED_PERCENT_LIMIT = 1_000_000_000; uint64 public constant HUNDRED_PERCENT_IN_BPS = 10000; mapping(address => TokenInfo) public tokenInfos; // only whitelisted depositors can deposit tokens into the vault mapping(address => bool) public depositor; // address of accepted tokens address[] public tokens; // address of the price provider address public priceProvider; // rate limit on deposit amount RateLimit private rateLimit; // address of the rebalancer address public rebalancer; // tokens that are whitelisted as swap output tokens can only be the output of rebalancing mapping(address swapOutputTokens => bool isWhitelisted) public isWhitelistedRebalanceOutputToken; // max slippage acceptable when we rebalance (in 18 decimals) uint256 public maxSlippageForRebalancing; // Swapper is a helper contract that helps us swap funds in the vault and rebalance address public swapper; // Swapper is a helper contract that helps us swap funds in the vault and rebalance mapping(address => bool) public pauser; // deposit amount for community pause in Eth uint256 public depositForCommunityPause; // deposited amount after community pause uint256 public communityPauseDepositedAmt; // fee struct Fee public fee; event TokenRegistered(address token); event TokenWhitelisted(address token, bool whitelisted); event PriceProviderSet(address oldPriceProvider, address newPriceProvider); event DepositorsSet(address[] accounts, bool[] isDepositor); event Deposit(address indexed sender, address indexed recipient, uint256 sharesMinted, uint256 fee, address[] tokens, uint256[] amounts); event Redeem(address indexed account, uint256 sharesRedeemed, uint256 fee, address[] tokens, uint256[] amounts); event CommunityPauseDepositSet(uint256 oldAmount, uint256 newAmount); event CommunityPause(address indexed pauser); event CommunityPauseAmountWithdrawal(address indexed recipient, uint256 amount); event RefillRateUpdated(uint128 oldRate, uint128 newRate); event PercentageRateLimitUpdated(uint128 oldPercentage, uint128 newPercentage); event RateLimitTimePeriodUpdated(uint64 oldTimePeriod, uint64 newTimePeriod); event TokenMaxPositionWeightLimitUpdated(uint64 oldLimit, uint64 newLimit); event RebalancerSet(address oldRebalancer, address newRebalancer); event PauserSet(address pauser, bool isPauser); event MaxSlippageForRebalanceSet(uint256 oldMaxSlippage, uint256 newMaxSlippage); event WhitelistRebalanceOutputToken(address token, bool whitelisted); event SwapperSet(address oldSwapper, address newSwapper); event Rebalance(address fromAsset, address toAsset, uint256 fromAssetAmount,uint256 toAssetAmount); event FeeSet(Fee oldFee, Fee newFee); event TreasurySet(address oldTreasury, address newTreasury); error TokenAlreadyRegistered(); error TokenNotWhitelisted(); error TokenNotRegistered(); error ArrayLengthMismatch(); error InvalidValue(); error InvalidRecipient(); error VaultTokenValueChanged(); error InsufficientShares(); error TotalSupplyZero(); error OnlyDepositors(); error PriceProviderNotConfigured(); error PriceProviderFailed(); error CommunityPauseDepositNotSet(); error IncorrectAmountOfEtherSent(); error EtherTransferFailed(); error NoCommunityPauseDepositAvailable(); error RateLimitExceeded(); error RateLimitRefillRateCannotBeGreaterThanCapacity(); error WeightLimitCannotBeGreaterThanHundred(); error TokenWeightLimitBreached(); error OnlyRebalancer(); error OnlyPauser(); error NotAValidRebalanceOutputToken(); error InsufficientTokensReceivedFromSwapper(); error ApplicableSlippageGreaterThanMaxLimit(); error AlreadyInSameState(); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize( string memory __name, string memory __symbol, address __governor, address __pauser, address __rebalancer, address __swapper, address __priceProvider, uint128 __percentageLimit, uint256 __depositForCommunityPause, Fee memory __fee ) public initializer { __ERC20_init(__name, __symbol); __ERC20Permit_init(__name); __UUPSUpgradeable_init(); _setGovernor(__governor); rebalancer = __rebalancer; swapper = __swapper; pauser[__pauser] = true; priceProvider = __priceProvider; // Initially allows 1000 ether in an hour with refill rate of 0.01 ether per seconds -> Max 1 hour -> 1036 shares // Updates every 1 hour -> new limit becomes percentageLimit * totalSupply rateLimit = RateLimit({ limit: BucketLimiter.create(1000 ether, 0.01 ether), timePeriod: 3600, renewTimestamp: uint64(block.timestamp + 3600), percentageLimit: __percentageLimit }); depositForCommunityPause = __depositForCommunityPause; _setFee(__fee); emit PauserSet(__pauser, true); emit RebalancerSet(address(0), __rebalancer); emit SwapperSet(address(0), __swapper); emit PriceProviderSet(address(0), __priceProvider); emit PercentageRateLimitUpdated(0, __percentageLimit); emit RefillRateUpdated(0, 0.01 ether); emit CommunityPauseDepositSet(0, __depositForCommunityPause); // 0.5% maxSlippageForRebalancing = 0.995 ether; } function getRateLimit() external view returns (RateLimit memory) { RateLimit memory _rateLimit = rateLimit; _rateLimit.limit.getCurrent(); return _rateLimit; } function whitelistRebalacingOutputToken(address _token, bool _shouldWhitelist) external onlyGovernor { if (_token == address(0)) revert InvalidValue(); if (_shouldWhitelist) { if(!isTokenRegistered(_token)) revert TokenNotRegistered(); if (IPriceProvider(priceProvider).getPriceInEth(_token) == 0) revert PriceProviderNotConfigured(); } isWhitelistedRebalanceOutputToken[_token] = _shouldWhitelist; emit WhitelistRebalanceOutputToken(_token, _shouldWhitelist); } function setFee(Fee memory _fee) external onlyGovernor { _setFee(_fee); } function setTreasuryAddress(address treasury) external onlyGovernor { if (treasury == address(0)) revert InvalidValue(); emit TreasurySet(fee.treasury, treasury); fee.treasury = treasury; } function setSwapper(address _swapper) external onlyGovernor { if (_swapper == address(0)) revert InvalidValue(); emit SwapperSet(swapper, _swapper); swapper = _swapper; } function rebalance( address _fromAsset, address _toAsset, uint256 _fromAssetAmount, uint256 _minToAssetAmount, bytes calldata _data ) external onlyRebalancer { if (!isTokenRegistered(_fromAsset) || !isTokenRegistered(_toAsset)) revert TokenNotRegistered(); // Input token may have been removed from whitelist to pause deposits for that token if (!isTokenWhitelisted(_toAsset)) revert TokenNotWhitelisted(); if (!isWhitelistedRebalanceOutputToken[_toAsset]) revert NotAValidRebalanceOutputToken(); uint256 vaultTotalValueBefore = _getVaultTokenValuesInEth(totalSupply()); uint256 toAssetAmountBefore = IERC20(_toAsset).balanceOf(address(this)); IERC20(_fromAsset).safeTransfer(swapper, _fromAssetAmount); uint256 outAmount = ISwapper(swapper).swap(_fromAsset, _toAsset, _fromAssetAmount, _minToAssetAmount, _data); uint256 vaultTotalValueAfter = _getVaultTokenValuesInEth(totalSupply()); uint256 toAssetAmountAfter = IERC20(_toAsset).balanceOf(address(this)); if (toAssetAmountAfter - toAssetAmountBefore < _minToAssetAmount) revert InsufficientTokensReceivedFromSwapper(); if (vaultTotalValueAfter < vaultTotalValueBefore) { uint256 minVaultTotalValueAfter = (vaultTotalValueBefore * maxSlippageForRebalancing) / 1 ether; if (vaultTotalValueAfter < minVaultTotalValueAfter) revert ApplicableSlippageGreaterThanMaxLimit(); } _verifyPositionLimits(); emit Rebalance(_fromAsset, _toAsset, _fromAssetAmount, outAmount); } function registerToken(address _token, uint64 _positionWeightLimit) external onlyGovernor { if (_token == address(0)) revert InvalidValue(); if (isTokenRegistered(_token)) revert TokenAlreadyRegistered(); if (IPriceProvider(priceProvider).getPriceInEth(_token) == 0) revert PriceProviderNotConfigured(); if (_positionWeightLimit > HUNDRED_PERCENT_LIMIT) revert WeightLimitCannotBeGreaterThanHundred(); tokenInfos[_token] = TokenInfo({registered: true, whitelisted: true, positionWeightLimit: _positionWeightLimit}); tokens.push(_token); emit TokenRegistered(_token); emit TokenWhitelisted(_token, true); } function setRebalancer(address account) external onlyGovernor { if (account == address(0)) revert InvalidValue(); emit RebalancerSet(rebalancer, account); rebalancer = account; } function setPauser(address account, bool isPauser) external onlyGovernor { if (account == address(0)) revert InvalidValue(); if (pauser[account] == isPauser) revert AlreadyInSameState(); pauser[account] = isPauser; emit PauserSet(account, isPauser); } function setMaxSlippageForRebalancing(uint256 maxSlippage) external onlyRebalancer { if (maxSlippage == 0) revert InvalidValue(); emit MaxSlippageForRebalanceSet(maxSlippageForRebalancing, maxSlippage); maxSlippageForRebalancing = maxSlippage; } function updateWhitelist(address _token, bool _whitelist) external onlyGovernor { if (_token == address(0)) revert InvalidValue(); if (!isTokenRegistered(_token)) revert TokenNotRegistered(); tokenInfos[_token].whitelisted = _whitelist; emit TokenWhitelisted(_token, _whitelist); } function updateTokenPositionWeightLimit(address _token, uint64 _TokenPositionWeightLimit) external onlyGovernor { if (_token == address(0)) revert InvalidValue(); if (!isTokenRegistered(_token)) revert TokenNotRegistered(); if (_TokenPositionWeightLimit > HUNDRED_PERCENT_LIMIT) revert WeightLimitCannotBeGreaterThanHundred(); emit TokenMaxPositionWeightLimitUpdated(tokenInfos[_token].positionWeightLimit, _TokenPositionWeightLimit); tokenInfos[_token].positionWeightLimit = _TokenPositionWeightLimit; } function setDepositors(address[] memory depositors, bool[] memory isDepositor) external onlyGovernor { uint256 len = depositors.length; if (len != isDepositor.length) revert ArrayLengthMismatch(); for (uint256 i = 0; i < len; ) { if (depositors[i] == address(0)) revert InvalidValue(); depositor[depositors[i]] = isDepositor[i]; unchecked { ++i; } } emit DepositorsSet(depositors, isDepositor); } function updatePriceProvider(address _priceProvider) external onlyGovernor { if (_priceProvider == address(0)) revert InvalidValue(); emit PriceProviderSet(priceProvider, _priceProvider); priceProvider = _priceProvider; } function setRateLimitConfig(uint128 __percentageLimit, uint64 __timePeriod, uint128 __refillRate) external onlyGovernor { uint256 _totalSupply = totalSupply(); uint128 capactity = uint128(_totalSupply.mulDiv(__percentageLimit, HUNDRED_PERCENT_LIMIT)); rateLimit = RateLimit({ limit: BucketLimiter.create(capactity, __refillRate), timePeriod: __timePeriod, renewTimestamp: uint64(block.timestamp + __timePeriod), percentageLimit: __percentageLimit }); } function setRateLimitTimePeriod(uint64 __timePeriod) external onlyGovernor { if (__timePeriod == 0) revert InvalidValue(); emit RateLimitTimePeriodUpdated(rateLimit.timePeriod, __timePeriod); rateLimit.timePeriod = __timePeriod; } function setRefillRatePerSecond(uint64 __refillRate) external onlyGovernor { emit RefillRateUpdated(rateLimit.limit.refillRate, __refillRate); rateLimit.limit.setRefillRate(__refillRate); } function setPercentageRateLimit(uint128 __percentageLimit) external onlyGovernor { emit PercentageRateLimitUpdated(rateLimit.percentageLimit, __percentageLimit); rateLimit.percentageLimit = __percentageLimit; } /// @notice Deposit rewards to the contract and mint share tokens to the recipient. /// @param _tokens addresses of ERC20 tokens to deposit /// @param _amounts amounts of tokens to deposit /// @param _receiver recipient of the minted share token function deposit( address[] memory _tokens, uint256[] memory _amounts, address _receiver ) external whenNotPaused onlyDepositors updateRateLimit { if (_tokens.length != _amounts.length) revert ArrayLengthMismatch(); if (_receiver == address(0)) revert InvalidRecipient(); bool initialDeposit = (totalSupply() == 0); uint256 vaultTokenValueBefore = _getVaultTokenValuesInEth( 1 * 10 ** decimals() ); (uint256 shareToMint, uint256 depositFee) = previewDeposit(_tokens, _amounts); // if initial deposit, set renew timestamp to new timestamp if (initialDeposit) rateLimit.renewTimestamp = uint64(block.timestamp + rateLimit.timePeriod); // check rate limit if(!rateLimit.limit.consume(uint128(shareToMint + depositFee))) revert RateLimitExceeded(); _deposit(_tokens, _amounts, shareToMint, depositFee, _receiver); _verifyPositionLimits(); uint256 vaultTokenValueAfter = _getVaultTokenValuesInEth( 1 * 10 ** decimals() ); if (!initialDeposit && vaultTokenValueBefore > vaultTokenValueAfter) revert VaultTokenValueChanged(); emit Deposit(msg.sender, _receiver, shareToMint, depositFee, _tokens, _amounts); } /// @notice Redeem the underlying assets proportionate to the share of the caller. /// @param vaultShares amount of vault share token to redeem the underlying assets function redeem(uint256 vaultShares) external { if (balanceOf(msg.sender) < vaultShares) revert InsufficientShares(); (address[] memory assets, uint256[] memory assetAmounts, uint256 feeForRedemption) = previewRedeem(vaultShares); if (feeForRedemption != 0) _transfer(msg.sender, fee.treasury, feeForRedemption); _burn(msg.sender, vaultShares - feeForRedemption); for (uint256 i = 0; i < assets.length; i++) if (assetAmounts[i] > 0) IERC20(assets[i]).safeTransfer(msg.sender, assetAmounts[i]); emit Redeem(msg.sender, vaultShares, feeForRedemption, assets, assetAmounts); } function previewDeposit(address[] memory _tokens, uint256[] memory _amounts) public view returns (uint256, uint256) { uint256 rewardsValueInEth = getTokenValuesInEth(_tokens, _amounts); uint256 shareToMint = _convertToShares(rewardsValueInEth, Math.Rounding.Floor); uint256 feeForDeposit = shareToMint.mulDiv(fee.depositFeeInBps, HUNDRED_PERCENT_IN_BPS); return (shareToMint - feeForDeposit, feeForDeposit); } function previewRedeem(uint256 vaultShares) public view returns (address[] memory, uint256[] memory, uint256) { uint256 feeForRedemption = vaultShares.mulDiv(fee.redeemFeeInBps, HUNDRED_PERCENT_IN_BPS); (address[] memory assets, uint256[] memory assetAmounts) = assetsForVaultShares(vaultShares - feeForRedemption); return (assets, assetAmounts, feeForRedemption); } function assetOf( address user, address token ) external view returns (uint256) { return assetForVaultShares(balanceOf(user), token); } function assetsOf( address user ) external view returns (address[] memory, uint256[] memory) { return assetsForVaultShares(balanceOf(user)); } function assetForVaultShares( uint256 vaultShares, address token ) public view returns (uint256) { if (!isTokenRegistered(token)) revert TokenNotRegistered(); if (totalSupply() == 0) revert TotalSupplyZero(); return _convertToAssetAmount(token, vaultShares, Math.Rounding.Floor); } function assetsForVaultShares( uint256 vaultShare ) public view returns (address[] memory, uint256[] memory) { if (totalSupply() == 0) revert TotalSupplyZero(); address[] memory assets = tokens; uint256 len = assets.length; uint256[] memory assetAmounts = new uint256[](len); for (uint256 i = 0; i < len; ) { assetAmounts[i] = assetForVaultShares(vaultShare, assets[i]); unchecked { ++i; } } return (assets, assetAmounts); } function totalAssets() public view returns (address[] memory, uint256[] memory) { address[] memory assets = tokens; uint256 len = assets.length; uint256[] memory assetAmounts = new uint256[](len); for (uint256 i = 0; i < len; ) { assetAmounts[i] = IERC20(assets[i]).balanceOf(address(this)); unchecked { ++i; } } return (assets, assetAmounts); } function tvl() external view returns (uint256, uint256) { ( address[] memory assets, uint256[] memory assetAmounts ) = totalAssets(); uint256 totalValue = 0; for (uint256 i = 0; i < assets.length; i++) { totalValue += (assetAmounts[i] * IPriceProvider(priceProvider).getPriceInEth(assets[i])) / 10 ** _getDecimals(assets[i]); } (uint256 ethUsdPrice, uint8 ethUsdDecimals) = IPriceProvider(priceProvider).getEthUsdPrice(); uint256 totalValueInUsd = totalValue * ethUsdPrice / 10 ** ethUsdDecimals; return (totalValue, totalValueInUsd); } function isTokenRegistered(address token) public view returns (bool) { return tokenInfos[token].registered; } function isTokenWhitelisted(address token) public view returns (bool) { return tokenInfos[token].whitelisted; } function getTokenValuesInEth( address[] memory _tokens, uint256[] memory _amounts ) public view returns (uint256) { uint256 total_eth = 0; uint256 len = _tokens.length; if (len != _amounts.length) revert ArrayLengthMismatch(); for (uint256 i = 0; i < _tokens.length; ) { if (!isTokenRegistered(_tokens[i])) revert TokenNotRegistered(); uint256 price = IPriceProvider(priceProvider).getPriceInEth( _tokens[i] ); if (price == 0) revert PriceProviderFailed(); total_eth += (_amounts[i] * price) / 10 ** _getDecimals(_tokens[i]); unchecked { ++i; } } return total_eth; } function getTokenTotalValuesInEth( address token ) public view returns (uint256) { uint256 price = IPriceProvider(priceProvider).getPriceInEth( token ); if (price == 0) revert PriceProviderFailed(); return (IERC20(token).balanceOf(address(this)) * IPriceProvider(priceProvider).getPriceInEth(token)) / 10 ** _getDecimals(token); } function fairValueOf(uint256 vaultTokenShares) external view returns (uint256, uint256) { uint256 valueInEth = _getVaultTokenValuesInEth(vaultTokenShares); (uint256 ethUsdPrice, uint8 ethUsdPriceDecimals) = IPriceProvider(priceProvider).getEthUsdPrice(); if (ethUsdPrice == 0) revert PriceProviderFailed(); uint256 valueInUsd = valueInEth * ethUsdPrice / 10 ** ethUsdPriceDecimals; return (valueInEth, valueInUsd); } function communityPause() external payable whenNotPaused { if (depositForCommunityPause == 0) revert CommunityPauseDepositNotSet(); if (msg.value != depositForCommunityPause) revert IncorrectAmountOfEtherSent(); _pause(); communityPauseDepositedAmt = msg.value; emit CommunityPause(msg.sender); } function pause() external onlyPauser whenNotPaused { _pause(); } function unpause() external onlyPauser whenPaused { uint256 amount = communityPauseDepositedAmt; if (amount != 0) { communityPauseDepositedAmt = 0; _withdrawEth(governor(), amount); emit CommunityPauseAmountWithdrawal(governor(), amount); } _unpause(); } function withdrawCommunityDepositedPauseAmount() external { uint256 amount = communityPauseDepositedAmt; if (amount == 0) revert NoCommunityPauseDepositAvailable(); communityPauseDepositedAmt = 0; _withdrawEth(governor(), amount); emit CommunityPauseAmountWithdrawal(governor(), amount); } function setCommunityPauseDepositAmount(uint256 amount) external onlyGovernor { emit CommunityPauseDepositSet(depositForCommunityPause, amount); depositForCommunityPause = amount; } function positionWeightLimit() public view returns (address[] memory, uint64[] memory) { uint256 len = tokens.length; uint64[] memory positionWeightLimits = new uint64[](len); uint256 vaultTotalValue = _getVaultTokenValuesInEth(totalSupply()); for (uint256 i = 0; i < len; ) { positionWeightLimits[i] = _getPositionWeight(tokens[i], vaultTotalValue); unchecked { ++i; } } return (tokens, positionWeightLimits); } function getPositionWeight(address token) public view returns (uint64) { if (!isTokenRegistered(token)) revert TokenNotRegistered(); uint256 vaultTotalValue = _getVaultTokenValuesInEth(totalSupply()); return _getPositionWeight(token, vaultTotalValue); } function _getPositionWeight(address token, uint256 vaultTotalValue) internal view returns (uint64) { uint256 valueOfTokenInVault = getTokenTotalValuesInEth(token); return SafeCast.toUint64((valueOfTokenInVault * HUNDRED_PERCENT_LIMIT) / vaultTotalValue); } /// @notice Deposit rewards to the contract and mint share tokens to the recipient. /// @param _tokens addresses of ERC20 tokens to deposit /// @param amounts amounts of tokens to deposit /// @param shareToMint amount of share token (= LRT^2 token) to mint /// @param depositFee fee to mint to the treasury /// @param recipientForMintedShare recipient of the minted share token function _deposit( address[] memory _tokens, uint256[] memory amounts, uint256 shareToMint, uint256 depositFee, address recipientForMintedShare ) internal { for (uint256 i = 0; i < _tokens.length; ) { if (!isTokenWhitelisted(_tokens[i])) revert TokenNotWhitelisted(); IERC20(_tokens[i]).safeTransferFrom(msg.sender, address(this), amounts[i]); unchecked { ++i; } } if (depositFee != 0) _mint(fee.treasury, depositFee); _mint(recipientForMintedShare, shareToMint); } function _convertToShares( uint256 valueInEth, Math.Rounding rounding ) public view virtual returns (uint256) { uint256 _totalSupply = totalSupply(); if (_totalSupply == 0) return valueInEth; return valueInEth.mulDiv(_totalSupply, _getVaultTokenValuesInEth(_totalSupply), rounding); } function _convertToAssetAmount( address assetToken, uint256 vaultShares, Math.Rounding rounding ) internal view virtual returns (uint256) { uint256 bal = IERC20(assetToken).balanceOf(address(this)); uint256 _totalSupply = totalSupply(); if (_totalSupply == 0) _totalSupply = 1; if (bal == 0) bal = 1; return vaultShares.mulDiv(bal, _totalSupply, rounding); } function _getDecimals(address erc20) internal view returns (uint8) { return IERC20Metadata(erc20).decimals(); } function _setFee(Fee memory _fee) internal { if ( _fee.treasury == address(0) || _fee.depositFeeInBps > HUNDRED_PERCENT_IN_BPS || _fee.redeemFeeInBps > HUNDRED_PERCENT_IN_BPS ) revert InvalidValue(); emit FeeSet(fee, _fee); fee = _fee; } function _verifyPositionLimits() internal view { uint256 len = tokens.length; uint256 vaultTotalValue = _getVaultTokenValuesInEth(totalSupply()); if(vaultTotalValue == 0) return; for (uint256 i = 0; i < len; ) { if (_getPositionWeight(tokens[i], vaultTotalValue) > tokenInfos[tokens[i]].positionWeightLimit) revert TokenWeightLimitBreached(); unchecked { ++i; } } } function _getVaultTokenValuesInEth( uint256 vaultTokenShares ) internal view returns (uint256) { uint256 totalSupply = totalSupply(); if (totalSupply == 0) return 0; ( address[] memory assets, uint256[] memory assetAmounts ) = totalAssets(); uint256 totalValue = getTokenValuesInEth(assets, assetAmounts); return (totalValue * vaultTokenShares) / totalSupply; } function _withdrawEth(address recipient, uint256 amount) internal { (bool success, ) = payable(recipient).call{value: amount}(""); if (!success) revert EtherTransferFailed(); } function _authorizeUpgrade(address newImplementation) internal override onlyGovernor {} modifier onlyDepositors() { _onlyDepositors(); _; } function _onlyDepositors() internal view { if (!depositor[msg.sender]) revert OnlyDepositors(); } modifier onlyRebalancer() { _onlyRebalancer(); _; } function _onlyRebalancer() internal view { if (rebalancer != msg.sender) revert OnlyRebalancer(); } modifier onlyPauser() { _onlyPauser(); _; } function _onlyPauser() internal view { if (!pauser[msg.sender]) revert OnlyPauser(); } modifier updateRateLimit { _updateRateLimit(); _; } function _updateRateLimit() internal { uint256 _totalSupply = totalSupply(); if(_totalSupply == 0) return; // If total supply = 0, can't mint anything since new rate limit which is a percentage of total supply would be 0 if (block.timestamp > rateLimit.renewTimestamp) { uint128 capactity = uint128(_totalSupply.mulDiv(rateLimit.percentageLimit, HUNDRED_PERCENT_LIMIT)); rateLimit.limit = BucketLimiter.create(capactity, rateLimit.limit.refillRate); rateLimit.renewTimestamp = uint64(block.timestamp + rateLimit.timePeriod); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC-20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { /** * @dev An operation with an ERC-20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { safeTransfer(token, to, value); } else if (!token.transferAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferFromAndCallRelaxed( IERC1363 token, address from, address to, uint256 value, bytes memory data ) internal { if (to.code.length == 0) { safeTransferFrom(token, from, to, value); } else if (!token.transferFromAndCall(from, to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}. * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall} * once without retrying, and relies on the returned value to be true. * * Reverts if the returned value is other than `true`. */ function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { forceApprove(token, to, value); } else if (!token.approveAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @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). * * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements. */ function _callOptionalReturn(IERC20 token, bytes memory data) private { uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) // bubble errors if iszero(success) { let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize()) revert(ptr, returndatasize()) } returnSize := returndatasize() returnValue := mload(0) } if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) { revert SafeERC20FailedOperation(address(token)); } } /** * @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). * * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { bool success; uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) returnSize := returndatasize() returnValue := mload(0) } return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC-20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; import {Panic} from "../Panic.sol"; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero). */ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * SafeCast.toUint(condition)); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(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 towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. Panic.panic(Panic.DIVISION_BY_ZERO); } // The following calculation ensures accurate ceiling division without overflow. // Since a is non-zero, (a - 1) / b will not overflow. // The largest possible result occurs when (a - 1) / b is type(uint256).max, // but the largest value we can obtain is type(uint256).max - 1, which happens // when a = type(uint256).max and b = 1. unchecked { return SafeCast.toUint(a > 0) * ((a - 1) / b + 1); } } /** * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * * 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²⁵⁶ and mod 2²⁵⁶ - 1, then use // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2²⁵⁶ + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW)); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); 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²⁵⁶ / 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²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv ≡ 1 mod 2⁴. 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⁸ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶ inverse *= 2 - denominator * inverse; // inverse mod 2³² inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶ // 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²⁵⁶. Since the preconditions guarantee that the outcome is // less than 2²⁵⁶, 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; } } /** * @dev 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) { return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0); } /** * @dev Calculate the modular multiplicative inverse of a number in Z/nZ. * * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0. * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible. * * If the input value is not inversible, 0 is returned. * * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}. */ function invMod(uint256 a, uint256 n) internal pure returns (uint256) { unchecked { if (n == 0) return 0; // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version) // Used to compute integers x and y such that: ax + ny = gcd(a, n). // When the gcd is 1, then the inverse of a modulo n exists and it's x. // ax + ny = 1 // ax = 1 + (-y)n // ax ≡ 1 (mod n) # x is the inverse of a modulo n // If the remainder is 0 the gcd is n right away. uint256 remainder = a % n; uint256 gcd = n; // Therefore the initial coefficients are: // ax + ny = gcd(a, n) = n // 0a + 1n = n int256 x = 0; int256 y = 1; while (remainder != 0) { uint256 quotient = gcd / remainder; (gcd, remainder) = ( // The old remainder is the next gcd to try. remainder, // Compute the next remainder. // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd // where gcd is at most n (capped to type(uint256).max) gcd - remainder * quotient ); (x, y) = ( // Increment the coefficient of a. y, // Decrement the coefficient of n. // Can overflow, but the result is casted to uint256 so that the // next value of y is "wrapped around" to a value between 0 and n - 1. x - y * int256(quotient) ); } if (gcd != 1) return 0; // No inverse exists. return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative. } } /** * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`. * * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that * `a**(p-2)` is the modular multiplicative inverse of a in Fp. * * NOTE: this function does NOT check that `p` is a prime greater than `2`. */ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) { unchecked { return Math.modExp(a, p - 2, p); } } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) * * Requirements: * - modulus can't be zero * - underlying staticcall to precompile must succeed * * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make * sure the chain you're using it on supports the precompiled contract for modular exponentiation * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, * the underlying function will succeed given the lack of a revert, but the result may be incorrectly * interpreted as 0. */ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) { (bool success, uint256 result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying * to operate modulo 0 or if the underlying precompile reverted. * * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack * of a revert, but the result may be incorrectly interpreted as 0. */ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) { if (m == 0) return (false, 0); assembly ("memory-safe") { let ptr := mload(0x40) // | Offset | Content | Content (Hex) | // |-----------|------------|--------------------------------------------------------------------| // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x60:0x7f | value of b | 0x<.............................................................b> | // | 0x80:0x9f | value of e | 0x<.............................................................e> | // | 0xa0:0xbf | value of m | 0x<.............................................................m> | mstore(ptr, 0x20) mstore(add(ptr, 0x20), 0x20) mstore(add(ptr, 0x40), 0x20) mstore(add(ptr, 0x60), b) mstore(add(ptr, 0x80), e) mstore(add(ptr, 0xa0), m) // Given the result < m, it's guaranteed to fit in 32 bytes, // so we can use the memory scratch space located at offset 0. success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20) result := mload(0x00) } } /** * @dev Variant of {modExp} that supports inputs of arbitrary length. */ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) { (bool success, bytes memory result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Variant of {tryModExp} that supports inputs of arbitrary length. */ function tryModExp( bytes memory b, bytes memory e, bytes memory m ) internal view returns (bool success, bytes memory result) { if (_zeroBytes(m)) return (false, new bytes(0)); uint256 mLen = m.length; // Encode call args in result and move the free memory pointer result = abi.encodePacked(b.length, e.length, mLen, b, e, m); assembly ("memory-safe") { let dataPtr := add(result, 0x20) // Write result on top of args to avoid allocating extra memory. success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen) // Overwrite the length. // result.length > returndatasize() is guaranteed because returndatasize() == m.length mstore(result, mLen) // Set the memory pointer after the returned data. mstore(0x40, add(dataPtr, mLen)) } } /** * @dev Returns whether the provided byte array is zero. */ function _zeroBytes(bytes memory byteArray) private pure returns (bool) { for (uint256 i = 0; i < byteArray.length; ++i) { if (byteArray[i] != 0) { return false; } } return true; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * This method is based on Newton's method for computing square roots; the algorithm is restricted to only * using integer operations. */ function sqrt(uint256 a) internal pure returns (uint256) { unchecked { // Take care of easy edge cases when a == 0 or a == 1 if (a <= 1) { return a; } // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between // the current value as `ε_n = | x_n - sqrt(a) |`. // // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is // bigger than any uint256. // // By noticing that // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)` // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar // to the msb function. uint256 aa = a; uint256 xn = 1; if (aa >= (1 << 128)) { aa >>= 128; xn <<= 64; } if (aa >= (1 << 64)) { aa >>= 64; xn <<= 32; } if (aa >= (1 << 32)) { aa >>= 32; xn <<= 16; } if (aa >= (1 << 16)) { aa >>= 16; xn <<= 8; } if (aa >= (1 << 8)) { aa >>= 8; xn <<= 4; } if (aa >= (1 << 4)) { aa >>= 4; xn <<= 2; } if (aa >= (1 << 2)) { xn <<= 1; } // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1). // // We can refine our estimation by noticing that the middle of that interval minimizes the error. // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2). // This is going to be our x_0 (and ε_0) xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2) // From here, Newton's method give us: // x_{n+1} = (x_n + a / x_n) / 2 // // One should note that: // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a // = ((x_n² + a) / (2 * x_n))² - a // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²) // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²) // = (x_n² - a)² / (2 * x_n)² // = ((x_n² - a) / (2 * x_n))² // ≥ 0 // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n // // This gives us the proof of quadratic convergence of the sequence: // ε_{n+1} = | x_{n+1} - sqrt(a) | // = | (x_n + a / x_n) / 2 - sqrt(a) | // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) | // = | (x_n - sqrt(a))² / (2 * x_n) | // = | ε_n² / (2 * x_n) | // = ε_n² / | (2 * x_n) | // // For the first iteration, we have a special case where x_0 is known: // ε_1 = ε_0² / | (2 * x_0) | // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2))) // ≤ 2**(2*e-4) / (3 * 2**(e-1)) // ≤ 2**(e-3) / 3 // ≤ 2**(e-3-log2(3)) // ≤ 2**(e-4.5) // // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n: // ε_{n+1} = ε_n² / | (2 * x_n) | // ≤ (2**(e-k))² / (2 * 2**(e-1)) // ≤ 2**(2*e-2*k) / 2**e // ≤ 2**(e-2*k) xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5 xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9 xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18 xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36 xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72 // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either // sqrt(a) or sqrt(a) + 1. return xn - SafeCast.toUint(xn > a / xn); } } /** * @dev Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 exp; unchecked { exp = 128 * SafeCast.toUint(value > (1 << 128) - 1); value >>= exp; result += exp; exp = 64 * SafeCast.toUint(value > (1 << 64) - 1); value >>= exp; result += exp; exp = 32 * SafeCast.toUint(value > (1 << 32) - 1); value >>= exp; result += exp; exp = 16 * SafeCast.toUint(value > (1 << 16) - 1); value >>= exp; result += exp; exp = 8 * SafeCast.toUint(value > (1 << 8) - 1); value >>= exp; result += exp; exp = 4 * SafeCast.toUint(value > (1 << 4) - 1); value >>= exp; result += exp; exp = 2 * SafeCast.toUint(value > (1 << 2) - 1); value >>= exp; result += exp; result += SafeCast.toUint(value > 1); } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 isGt; unchecked { isGt = SafeCast.toUint(value > (1 << 128) - 1); value >>= isGt * 128; result += isGt * 16; isGt = SafeCast.toUint(value > (1 << 64) - 1); value >>= isGt * 64; result += isGt * 8; isGt = SafeCast.toUint(value > (1 << 32) - 1); value >>= isGt * 32; result += isGt * 4; isGt = SafeCast.toUint(value > (1 << 16) - 1); value >>= isGt * 16; result += isGt * 2; result += SafeCast.toUint(value > (1 << 8) - 1); } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.20; import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; import {ERC20Upgradeable} from "../ERC20Upgradeable.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {EIP712Upgradeable} from "../../../utils/cryptography/EIP712Upgradeable.sol"; import {NoncesUpgradeable} from "../../../utils/NoncesUpgradeable.sol"; import {Initializable} from "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612]. * * Adds the {permit} method, which can be used to change an account's ERC-20 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. */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20Permit, EIP712Upgradeable, NoncesUpgradeable { bytes32 private constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Permit deadline has expired. */ error ERC2612ExpiredSignature(uint256 deadline); /** * @dev Mismatched signature. */ error ERC2612InvalidSigner(address signer, address owner); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC-20 token name. */ function __ERC20Permit_init(string memory name) internal onlyInitializing { __EIP712_init_unchained(name, "1"); } function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {} /** * @inheritdoc IERC20Permit */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { if (block.timestamp > deadline) { revert ERC2612ExpiredSignature(deadline); } bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); if (signer != owner) { revert ERC2612InvalidSigner(signer, owner); } _approve(owner, spender, value); } /** * @inheritdoc IERC20Permit */ function nonces(address owner) public view virtual override(IERC20Permit, NoncesUpgradeable) returns (uint256) { return super.nonces(owner); } /** * @inheritdoc IERC20Permit */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view virtual returns (bytes32) { return _domainSeparatorV4(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./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. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @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 ERC-1967) 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 ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @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() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing 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 notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC-1967 compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC-1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; interface IPriceProvider { /// @notice Get the price of the token in ETH (18 decimals) for the token amount = 1 * 10 ** token.decimals() function getPriceInEth(address token) external view returns (uint256); /// @notice Get the decimals of the price provider (6 decimals) function decimals() external pure returns (uint8); /// @notice Get the price of ETH in USD function getEthUsdPrice() external view returns (uint256, uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; contract Governable { // keccak256("LRTSquare.governor"); bytes32 private constant governorPosition = 0x7d8b90e89a676f7a8a3cf40a0c23c3d2ea61cec6ae800738fbd79bc111b5ea87; // keccak256("LRTSquare.pending.governor"); bytes32 private constant pendingGovernorPosition = 0x0fe544e960ecab9b6f1eee0df869972d09c3c135c0d116422cce176351b52237; event PendingGovernorshipTransfer( address indexed previousGovernor, address indexed newGovernor ); event GovernorshipTransferred( address indexed previousGovernor, address indexed newGovernor ); error OnlyGovernor(); error OnlyPendingGovernor(); error GovernorCannotBeAddressZero(); /** * @notice Returns the address of the current Governor. */ function governor() public view returns (address) { return _governor(); } /** * @dev Returns the address of the current Governor. */ function _governor() internal view returns (address governorOut) { bytes32 position = governorPosition; // solhint-disable-next-line no-inline-assembly assembly { governorOut := sload(position) } } /** * @dev Returns the address of the pending Governor. */ function _pendingGovernor() internal view returns (address pendingGovernor) { bytes32 position = pendingGovernorPosition; // solhint-disable-next-line no-inline-assembly assembly { pendingGovernor := sload(position) } } /** * @dev Throws if called by any account other than the Governor. */ modifier onlyGovernor() { if (!isGovernor()) revert OnlyGovernor(); _; } /** * @notice Returns true if the caller is the current Governor. */ function isGovernor() public view returns (bool) { return msg.sender == _governor(); } function _setGovernor(address newGovernor) internal { bytes32 position = governorPosition; // solhint-disable-next-line no-inline-assembly assembly { sstore(position, newGovernor) } } function _setPendingGovernor(address newGovernor) internal { bytes32 position = pendingGovernorPosition; // solhint-disable-next-line no-inline-assembly assembly { sstore(position, newGovernor) } } /** * @notice Transfers Governance of the contract to a new account (`newGovernor`). * Can only be called by the current Governor. Must be claimed for this to complete * @param _newGovernor Address of the new Governor */ function transferGovernance(address _newGovernor) external onlyGovernor { _setPendingGovernor(_newGovernor); emit PendingGovernorshipTransfer(_governor(), _newGovernor); } /** * @notice Claim Governance of the contract to a new account (`newGovernor`). * Can only be called by the new Governor. */ function claimGovernance() external { if (msg.sender != _pendingGovernor()) revert OnlyPendingGovernor(); _changeGovernor(msg.sender); } /** * @dev Change Governance of the contract to a new account (`newGovernor`). * @param _newGovernor Address of the new Governor */ function _changeGovernor(address _newGovernor) internal { if (_newGovernor == address(0)) revert GovernorCannotBeAddressZero(); emit GovernorshipTransferred(_governor(), _newGovernor); _setGovernor(_newGovernor); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../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 { /// @custom:storage-location erc7201:openzeppelin.storage.Pausable struct PausableStorage { bool _paused; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300; function _getPausableStorage() private pure returns (PausableStorage storage $) { assembly { $.slot := PausableStorageLocation } } /** * @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); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { PausableStorage storage $ = _getPausableStorage(); $._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) { PausableStorage storage $ = _getPausableStorage(); return $._paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; /** * The BucketLimiter contract is used to limit the rate of some action. * * Buckets refill at a constant rate, and have a maximum capacity. Each time * the consume function is called, the bucket gets depleted by the provided * amount. If the bucket is empty, the consume function will return false * and the bucket will not be depleted. Rates are measured in units per * second. * * To limit storage usage to a single slot, the Bucket struct is packed into * a single word, meaning all fields are uint128. * * Examples: * * ```sol * BucketLimiter.Limit storage limit = BucketLimiter.create(100, 1); * limit.consume(10); // returns true, remaining = 90 * limit.consume(80); // returns true, remaining = 10 * limit.consume(20); // returns false, remaining = 10 * // Wait 10 seconds (10 tokens get refilled) * limit.consume(20); // returns true, remaining = 0) * // Increase capacity * limit.setCapacity(200); // remaining = 0, capacity = 200 * // Increase refill rate * limit.setRefillRate(2); // remaining = 0, capacity = 200, refillRate = 2 * // Wait 10 seconds (20 tokens get refilled) * limit.consume(20); // returns true, remaining = 0 * ``` * * Developers should notice that rate-limits are vulnerable to two attacks: * 1. Sybil-attacks: Rate limits should typically be global across all user * accounts, otherwise an attacker can simply create many accounts to * bypass the rate limit. * 2. DoS attacks: Rate limits should typically apply to actions with a * friction such as a fee or a minimum stake time. Otherwise, an * attacker can simply spam the action to deplete the rate limit. */ library BucketLimiter { struct Limit { // The maximum capacity of the bucket, in consumable units (eg. tokens) uint128 capacity; // The remaining capacity in the bucket, that can be consumed uint128 remaining; // The timestamp of the last time the bucket was refilled uint128 lastRefill; // The rate at which the bucket refills, in units per second uint128 refillRate; } /* * Creates a new bucket with the given capacity and refill rate. * * @param capacity The maximum capacity of the bucket, in consumable units (eg. tokens) * @param refillRate The rate at which the bucket refills, in units per second * @return The created bucket */ function create(uint128 capacity, uint128 refillRate) internal view returns (Limit memory) { return Limit({ capacity: capacity, remaining: capacity, lastRefill: uint128(block.timestamp), refillRate: refillRate }); } function getCurrent(Limit memory limit) internal view returns (Limit memory) { _refill(limit); return limit; } function canConsume(Limit memory limit, uint128 amount) external view returns (bool) { _refill(limit); return limit.remaining >= amount; } /* * Consumes the given amount from the bucket, if there is sufficient capacity, and returns * whether the bucket had enough remaining capacity to consume the amount. * * @param limit The bucket to consume from * @param amount The amount to consume * @return True if the bucket had enough remaining capacity to consume the amount, false otherwise */ function consume(Limit storage limit, uint128 amount) internal returns (bool) { Limit memory _limit = limit; _refill(_limit); if (_limit.remaining < amount) { return false; } limit.remaining = _limit.remaining - amount; limit.lastRefill = _limit.lastRefill; return true; } /* * Refills the bucket based on the time elapsed since the last refill. This effectively simulates * the idea of the bucket continuously refilling at a constant rate. * * @param limit The bucket to refill */ function refill(Limit storage limit) internal { Limit memory _limit = limit; _refill(_limit); limit.remaining = _limit.remaining; limit.lastRefill = _limit.lastRefill; } function _refill(Limit memory limit) internal view { // We allow for overflow here, as the delta is resilient against it. uint128 now_ = uint128(block.timestamp); uint128 delta; unchecked { delta = now_ - limit.lastRefill; } uint128 tokens = delta * limit.refillRate; uint128 newRemaining = limit.remaining + tokens; if (newRemaining > limit.capacity) { limit.remaining = limit.capacity; } else { limit.remaining = newRemaining; } limit.lastRefill = now_; } /* * Sets the capacity of the bucket. If the new capacity is less than the remaining capacity, * the remaining capacity is set to the new capacity. * * @param limit The bucket to set the capacity of * @param capacity The new capacity */ function setCapacity(Limit storage limit, uint128 capacity) internal { refill(limit); limit.capacity = capacity; if (limit.remaining > capacity) { limit.remaining = capacity; } } /* * Sets the refill rate of the bucket, in units per second. * * @param limit The bucket to set the refill rate of * @param refillRate The new refill rate */ function setRefillRate(Limit storage limit, uint128 refillRate) internal { refill(limit); limit.refillRate = refillRate; } /* * Sets the remaining capacity of the bucket. If the new remaining capacity is greater than * the capacity, the remaining capacity is set to the capacity. * * @param limit The bucket to set the remaining capacity of * @param remaining The new remaining capacity */ function setRemaining(Limit storage limit, uint128 remaining) internal { refill(limit); limit.remaining = remaining; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.25; interface ISwapper { /** * @notice Strategist swaps assets sitting in the contract of the `assetHolder` * @param _fromAsset The token address of the asset being sold by the vault * @param _toAsset The token address of the asset being purchased by the vault * @param _fromAssetAmount The amount of assets being sold by the vault * @param _minToAssetAmount The minimum amount of assets to be purchased * @param _data Swap data */ function swap( address _fromAsset, address _toAsset, uint256 _fromAssetAmount, uint256 _minToAssetAmount, bytes calldata _data ) external returns (uint256 toAssetAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ 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 value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` 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 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1363.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC165} from "./IERC165.sol"; /** * @title IERC1363 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363]. * * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction. */ interface IERC1363 is IERC20, IERC165 { /* * Note: the ERC-165 identifier for this interface is 0xb0202a11. * 0xb0202a11 === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^ * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @param data Additional data with no specified format, sent in call to `spender`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * @dev Helper library for emitting standardized panic codes. * * ```solidity * contract Example { * using Panic for uint256; * * // Use any of the declared internal constants * function foo() { Panic.GENERIC.panic(); } * * // Alternatively * function foo() { Panic.panic(Panic.GENERIC); } * } * ``` * * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. * * _Available since v5.1._ */ // slither-disable-next-line unused-state library Panic { /// @dev generic / unspecified error uint256 internal constant GENERIC = 0x00; /// @dev used by the assert() builtin uint256 internal constant ASSERT = 0x01; /// @dev arithmetic underflow or overflow uint256 internal constant UNDER_OVERFLOW = 0x11; /// @dev division or modulo by zero uint256 internal constant DIVISION_BY_ZERO = 0x12; /// @dev enum conversion error uint256 internal constant ENUM_CONVERSION_ERROR = 0x21; /// @dev invalid encoding in storage uint256 internal constant STORAGE_ENCODING_ERROR = 0x22; /// @dev empty array pop uint256 internal constant EMPTY_ARRAY_POP = 0x31; /// @dev array out of bounds access uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; /// @dev resource error (too large allocation or too large array) uint256 internal constant RESOURCE_ERROR = 0x41; /// @dev calling invalid internal function uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51; /// @dev Reverts with a panic code. Recommended to use with /// the internal constants with predefined codes. function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) mstore(0x20, code) revert(0x1c, 0x24) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612]. * * Adds the {permit} method, which can be used to change an account's ERC-20 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. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ 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 v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; import {Initializable} from "../../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}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * 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 ERC-20 * applications. */ abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors { /// @custom:storage-location erc7201:openzeppelin.storage.ERC20 struct ERC20Storage { mapping(address account => uint256) _balances; mapping(address account => mapping(address spender => uint256)) _allowances; uint256 _totalSupply; string _name; string _symbol; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; function _getERC20Storage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20StorageLocation } } /** * @dev Sets the values for {name} and {symbol}. * * 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 { ERC20Storage storage $ = _getERC20Storage(); $._name = name_; $._symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); 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 default value returned by this function, unless * it's 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 returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` 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 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Skips emitting an {Approval} event indicating an allowance update. This is not * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve]. * * 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 `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` 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. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows $._totalSupply += value; } else { uint256 fromBalance = $._balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. $._balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. $._totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. $._balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` 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. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * * ```solidity * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } $._allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover( bytes32 hash, bytes memory signature ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly ("memory-safe") { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures] */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. */ abstract contract EIP712Upgradeable is Initializable, IERC5267 { bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /// @custom:storage-location erc7201:openzeppelin.storage.EIP712 struct EIP712Storage { /// @custom:oz-renamed-from _HASHED_NAME bytes32 _hashedName; /// @custom:oz-renamed-from _HASHED_VERSION bytes32 _hashedVersion; string _name; string _version; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.EIP712")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100; function _getEIP712Storage() private pure returns (EIP712Storage storage $) { assembly { $.slot := EIP712StorageLocation } } /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { EIP712Storage storage $ = _getEIP712Storage(); $._name = name; $._version = version; // Reset prior values in storage if upgrading $._hashedName = 0; $._hashedVersion = 0; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(); } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { EIP712Storage storage $ = _getEIP712Storage(); // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized // and the EIP712 domain is not reliable, as it will be missing name and version. require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized"); return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Name() internal view virtual returns (string memory) { EIP712Storage storage $ = _getEIP712Storage(); return $._name; } /** * @dev The version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Version() internal view virtual returns (string memory) { EIP712Storage storage $ = _getEIP712Storage(); return $._version; } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead. */ function _EIP712NameHash() internal view returns (bytes32) { EIP712Storage storage $ = _getEIP712Storage(); string memory name = _EIP712Name(); if (bytes(name).length > 0) { return keccak256(bytes(name)); } else { // If the name is empty, the contract may have been upgraded without initializing the new storage. // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design. bytes32 hashedName = $._hashedName; if (hashedName != 0) { return hashedName; } else { return keccak256(""); } } } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead. */ function _EIP712VersionHash() internal view returns (bytes32) { EIP712Storage storage $ = _getEIP712Storage(); string memory version = _EIP712Version(); if (bytes(version).length > 0) { return keccak256(bytes(version)); } else { // If the version is empty, the contract may have been upgraded without initializing the new storage. // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design. bytes32 hashedVersion = $._hashedVersion; if (hashedVersion != 0) { return hashedVersion; } else { return keccak256(""); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract NoncesUpgradeable is Initializable { /** * @dev The nonce used for an `account` is not the expected current nonce. */ error InvalidAccountNonce(address account, uint256 currentNonce); /// @custom:storage-location erc7201:openzeppelin.storage.Nonces struct NoncesStorage { mapping(address account => uint256) _nonces; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Nonces")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant NoncesStorageLocation = 0x5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb00; function _getNoncesStorage() private pure returns (NoncesStorage storage $) { assembly { $.slot := NoncesStorageLocation } } function __Nonces_init() internal onlyInitializing { } function __Nonces_init_unchained() internal onlyInitializing { } /** * @dev Returns the next unused nonce for an address. */ function nonces(address owner) public view virtual returns (uint256) { NoncesStorage storage $ = _getNoncesStorage(); return $._nonces[owner]; } /** * @dev Consumes a nonce. * * Returns the current value and increments nonce. */ function _useNonce(address owner) internal virtual returns (uint256) { NoncesStorage storage $ = _getNoncesStorage(); // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be // decremented or reset. This guarantees that the nonce never overflows. unchecked { // It is important to do x++ and not ++x here. return $._nonces[owner]++; } } /** * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`. */ function _useCheckedNonce(address owner, uint256 nonce) internal virtual { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @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] * ```solidity * 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 Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 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. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._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. * * 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. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * 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. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._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() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @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. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC-1822: 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 v5.0.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.21; import {IBeacon} from "../beacon/IBeacon.sol"; import {IERC1967} from "../../interfaces/IERC1967.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This library provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots. */ library ERC1967Utils { /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @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 ERC-1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit IERC1967.Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit IERC1967.AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the ERC-1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit IERC1967.BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an ERC-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { assembly ("memory-safe") { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an ERC-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an ERC-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { assembly ("memory-safe") { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @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. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.20; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. */ interface IERC1967 { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @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 ERC-1967 implementation slot: * ```solidity * contract ERC1967 { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct Int256Slot { int256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Int256Slot` with member `value` located at `slot`. */ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } /** * @dev Returns a `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; assembly ("memory-safe") { ptr := add(buffer, add(32, length)) } while (true) { ptr--; assembly ("memory-safe") { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; 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_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal * representation, according to EIP-55. */ function toChecksumHexString(address addr) internal pure returns (string memory) { bytes memory buffer = bytes(toHexString(addr)); // hash the hex part of buffer (skip length + 2 bytes, length 40) uint256 hashValue; assembly ("memory-safe") { hashValue := shr(96, keccak256(add(buffer, 0x22), 40)) } for (uint256 i = 41; i > 1; --i) { // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f) if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) { // case shift by xoring with 0x20 buffer[i] ^= 0x20; } hashValue >>= 4; } return string(buffer); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * int256(SafeCast.toUint(condition))); } } /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return ternary(a < b, a, b); } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson. // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift, // taking advantage of the most significant (or "sign" bit) in two's complement representation. // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result, // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative). int256 mask = n >> 255; // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it. return uint256((n + mask) ^ mask); } } }
{ "remappings": [ "@openzeppelin/=lib/openzeppelin-contracts/", "@openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 500 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"AlreadyInSameState","type":"error"},{"inputs":[],"name":"ApplicableSlippageGreaterThanMaxLimit","type":"error"},{"inputs":[],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[],"name":"CommunityPauseDepositNotSet","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"ERC2612ExpiredSignature","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC2612InvalidSigner","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"EtherTransferFailed","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"GovernorCannotBeAddressZero","type":"error"},{"inputs":[],"name":"IncorrectAmountOfEtherSent","type":"error"},{"inputs":[],"name":"InsufficientShares","type":"error"},{"inputs":[],"name":"InsufficientTokensReceivedFromSwapper","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidValue","type":"error"},{"inputs":[],"name":"NoCommunityPauseDepositAvailable","type":"error"},{"inputs":[],"name":"NotAValidRebalanceOutputToken","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OnlyDepositors","type":"error"},{"inputs":[],"name":"OnlyGovernor","type":"error"},{"inputs":[],"name":"OnlyPauser","type":"error"},{"inputs":[],"name":"OnlyPendingGovernor","type":"error"},{"inputs":[],"name":"OnlyRebalancer","type":"error"},{"inputs":[],"name":"PriceProviderFailed","type":"error"},{"inputs":[],"name":"PriceProviderNotConfigured","type":"error"},{"inputs":[],"name":"RateLimitExceeded","type":"error"},{"inputs":[],"name":"RateLimitRefillRateCannotBeGreaterThanCapacity","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"TokenAlreadyRegistered","type":"error"},{"inputs":[],"name":"TokenNotRegistered","type":"error"},{"inputs":[],"name":"TokenNotWhitelisted","type":"error"},{"inputs":[],"name":"TokenWeightLimitBreached","type":"error"},{"inputs":[],"name":"TotalSupplyZero","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"VaultTokenValueChanged","type":"error"},{"inputs":[],"name":"WeightLimitCannotBeGreaterThanHundred","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pauser","type":"address"}],"name":"CommunityPause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CommunityPauseAmountWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"CommunityPauseDepositSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"sharesMinted","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"accounts","type":"address[]"},{"indexed":false,"internalType":"bool[]","name":"isDepositor","type":"bool[]"}],"name":"DepositorsSet","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"treasury","type":"address"},{"internalType":"uint48","name":"depositFeeInBps","type":"uint48"},{"internalType":"uint48","name":"redeemFeeInBps","type":"uint48"}],"indexed":false,"internalType":"struct LRTSquared.Fee","name":"oldFee","type":"tuple"},{"components":[{"internalType":"address","name":"treasury","type":"address"},{"internalType":"uint48","name":"depositFeeInBps","type":"uint48"},{"internalType":"uint48","name":"redeemFeeInBps","type":"uint48"}],"indexed":false,"internalType":"struct LRTSquared.Fee","name":"newFee","type":"tuple"}],"name":"FeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernor","type":"address"}],"name":"GovernorshipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxSlippage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxSlippage","type":"uint256"}],"name":"MaxSlippageForRebalanceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pauser","type":"address"},{"indexed":false,"internalType":"bool","name":"isPauser","type":"bool"}],"name":"PauserSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernor","type":"address"}],"name":"PendingGovernorshipTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"oldPercentage","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"newPercentage","type":"uint128"}],"name":"PercentageRateLimitUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPriceProvider","type":"address"},{"indexed":false,"internalType":"address","name":"newPriceProvider","type":"address"}],"name":"PriceProviderSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"oldTimePeriod","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"newTimePeriod","type":"uint64"}],"name":"RateLimitTimePeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"fromAsset","type":"address"},{"indexed":false,"internalType":"address","name":"toAsset","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromAssetAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toAssetAmount","type":"uint256"}],"name":"Rebalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldRebalancer","type":"address"},{"indexed":false,"internalType":"address","name":"newRebalancer","type":"address"}],"name":"RebalancerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"sharesRedeemed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"oldRate","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"newRate","type":"uint128"}],"name":"RefillRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldSwapper","type":"address"},{"indexed":false,"internalType":"address","name":"newSwapper","type":"address"}],"name":"SwapperSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"oldLimit","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"newLimit","type":"uint64"}],"name":"TokenMaxPositionWeightLimitUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"TokenRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"whitelisted","type":"bool"}],"name":"TokenWhitelisted","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":"oldTreasury","type":"address"},{"indexed":false,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasurySet","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":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"whitelisted","type":"bool"}],"name":"WhitelistRebalanceOutputToken","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HUNDRED_PERCENT_IN_BPS","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HUNDRED_PERCENT_LIMIT","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"valueInEth","type":"uint256"},{"internalType":"enum Math.Rounding","name":"rounding","type":"uint8"}],"name":"_convertToShares","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":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultShares","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"name":"assetForVaultShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"assetOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultShare","type":"uint256"}],"name":"assetsForVaultShares","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"assetsOf","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"communityPause","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"communityPauseDepositedAmt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositForCommunityPause","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"depositor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultTokenShares","type":"uint256"}],"name":"fairValueOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"address","name":"treasury","type":"address"},{"internalType":"uint48","name":"depositFeeInBps","type":"uint48"},{"internalType":"uint48","name":"redeemFeeInBps","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getPositionWeight","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRateLimit","outputs":[{"components":[{"components":[{"internalType":"uint128","name":"capacity","type":"uint128"},{"internalType":"uint128","name":"remaining","type":"uint128"},{"internalType":"uint128","name":"lastRefill","type":"uint128"},{"internalType":"uint128","name":"refillRate","type":"uint128"}],"internalType":"struct BucketLimiter.Limit","name":"limit","type":"tuple"},{"internalType":"uint64","name":"timePeriod","type":"uint64"},{"internalType":"uint64","name":"renewTimestamp","type":"uint64"},{"internalType":"uint128","name":"percentageLimit","type":"uint128"}],"internalType":"struct LRTSquared.RateLimit","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenTotalValuesInEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"getTokenValuesInEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"__name","type":"string"},{"internalType":"string","name":"__symbol","type":"string"},{"internalType":"address","name":"__governor","type":"address"},{"internalType":"address","name":"__pauser","type":"address"},{"internalType":"address","name":"__rebalancer","type":"address"},{"internalType":"address","name":"__swapper","type":"address"},{"internalType":"address","name":"__priceProvider","type":"address"},{"internalType":"uint128","name":"__percentageLimit","type":"uint128"},{"internalType":"uint256","name":"__depositForCommunityPause","type":"uint256"},{"components":[{"internalType":"address","name":"treasury","type":"address"},{"internalType":"uint48","name":"depositFeeInBps","type":"uint48"},{"internalType":"uint48","name":"redeemFeeInBps","type":"uint48"}],"internalType":"struct LRTSquared.Fee","name":"__fee","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isGovernor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isTokenRegistered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isTokenWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"swapOutputTokens","type":"address"}],"name":"isWhitelistedRebalanceOutputToken","outputs":[{"internalType":"bool","name":"isWhitelisted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSlippageForRebalancing","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pauser","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"positionWeightLimit","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultShares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceProvider","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_fromAsset","type":"address"},{"internalType":"address","name":"_toAsset","type":"address"},{"internalType":"uint256","name":"_fromAssetAmount","type":"uint256"},{"internalType":"uint256","name":"_minToAssetAmount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rebalancer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultShares","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint64","name":"_positionWeightLimit","type":"uint64"}],"name":"registerToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setCommunityPauseDepositAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"depositors","type":"address[]"},{"internalType":"bool[]","name":"isDepositor","type":"bool[]"}],"name":"setDepositors","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"treasury","type":"address"},{"internalType":"uint48","name":"depositFeeInBps","type":"uint48"},{"internalType":"uint48","name":"redeemFeeInBps","type":"uint48"}],"internalType":"struct LRTSquared.Fee","name":"_fee","type":"tuple"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxSlippage","type":"uint256"}],"name":"setMaxSlippageForRebalancing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"isPauser","type":"bool"}],"name":"setPauser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"__percentageLimit","type":"uint128"}],"name":"setPercentageRateLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"__percentageLimit","type":"uint128"},{"internalType":"uint64","name":"__timePeriod","type":"uint64"},{"internalType":"uint128","name":"__refillRate","type":"uint128"}],"name":"setRateLimitConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"__timePeriod","type":"uint64"}],"name":"setRateLimitTimePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"setRebalancer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"__refillRate","type":"uint64"}],"name":"setRefillRatePerSecond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_swapper","type":"address"}],"name":"setSwapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"treasury","type":"address"}],"name":"setTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenInfos","outputs":[{"internalType":"bool","name":"registered","type":"bool"},{"internalType":"bool","name":"whitelisted","type":"bool"},{"internalType":"uint64","name":"positionWeightLimit","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"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":"value","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":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newGovernor","type":"address"}],"name":"transferGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tvl","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceProvider","type":"address"}],"name":"updatePriceProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint64","name":"_TokenPositionWeightLimit","type":"uint64"}],"name":"updateTokenPositionWeightLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"bool","name":"_whitelist","type":"bool"}],"name":"updateWhitelist","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":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"bool","name":"_shouldWhitelist","type":"bool"}],"name":"whitelistRebalacingOutputToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawCommunityDepositedPauseAmount","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a0806040523460c857306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a009081549060ff8260401c1660b957506001600160401b036002600160401b0319828216016075575b604051615bd690816100cd823960805181818161309401526131870152f35b6001600160401b031990911681179091556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a15f80806056565b63f92ee8a960e01b8152600490fd5b5f80fdfe6080806040526004361015610012575f80fd5b60e05f35811c91826301d22ccd146141f65750816301e1d114146141de57816306fdde0314614115578163095ea7b3146140ef5781630a1289ad146140b25781630a154161146140955781630c340a24146140635781630d392cd914613fbe5781630d52a7b914613dbf57816317d949fe14613da357816318160ddd14613d7a5781632015ef0114613cff57816323b872dd14613bbf57816326aa101f14613b8757816329272ff614613a765781632b3297f914613a505781632c62fa10146139eb578163313ce567146139d05781633644e515146139b65781633775bdc71461388e578163387e971c146138515781633995c06f1461382e5781633d8ae7c6146137165781633f4ba83a1461363857816343998bdd1461361f57816345e674c71461358a57816346063a521461353157816347b818ba146133af5781634cdad5061461334a5781634f1ef286146131375781634f64b2be146130f657816352d1902d1461307a57816352ed3ed814612fdd57816357d5d52014612fc45781635c975abb14612f835781635d36b19014612eda578163608baa9a14612eaf57816361ec384614612e495781636605bfda14612db45781636696821b14612ce55781636cfd155314612c5057816370a0823114612bfb5781637180c8ca14612b265781637ecebe0014612acf5781637f12dc6014612ab357816381692c0e14611b7b5781638456cb5914611afb57816384b0196e146119cb578163863a7fc11461199d5781639295d4781461196057816395d89b411461186057816398c601aa146115855781639a14f478146113d75781639c79d8dc146113ba5781639c82f2a414611325578163a9059cbb146112f4578163ad3cb1cc146112ab578163b5af090f14611266578163b860f0a11461116d578163b888879e14611147578163b8a723bd1461112a578163ba46ae72146110ce578163bd69bfbb14611033578163c7af335214610fff578163ce1f16c914610f50578163d38bfff414610ecb578163d505accf14610d38578163d6bcfca314610d1a578163db006a7514610b35578163dd62ed3e14610abc578163ddca3f4314610a7c578163df83ffe814610a01578163e5328e0614610887578163e8c67216146107ac57508063e9c459ba1461046c578063f293f14e146103ed5763fa6d102b1461036d575f80fd5b346103e95760203660031901126103e9576103866142d4565b6001600160a01b0381165f525f60205260ff60405f205416156103d7576103c66020916103c05f80516020615b61833981519152546150a3565b906150da565b6001600160401b0360405191168152f35b60405163259ba1ad60e01b8152600490fd5b5f80fd5b346103e9575f3660031901126103e957600d54801561045a575f600d557fd6060418062d03ef3ef2e9cca5d7e94502c0224f1ea338059fa40ecfb8bd121a60206001600160a01b035f80516020615b8183398151915261044e858254615232565b541692604051908152a2005b604051630758561360e51b8152600490fd5b346103e95760a03660031901126103e9576104856142d4565b61048d6142ea565b608435906001600160401b03908183116103e957366023840112156103e95782600401359182116103e95736602483850101116103e9576104cc6153e3565b6001600160a01b0380941692835f526020915f835260ff60405f205416158015610798575b6103d757851694855f525f835260ff60405f205460081c161561078657855f526008835260ff60405f20541615610774575f80516020615b618339815191529061053b82546150a3565b91604051936370a0823160e01b9283865230600487015286866024818d5afa958615610701578a918a915f9861073d575b50915f60c460249b938b969561058960443582600a541684615667565b600a541694806040519e8f98899788956304a0d80360e31b87526004870152828601526044356044860152606435606486015260a060848601528260a486015201848401378181018301849052601f01601f191681010301925af1958615610701575f9661070c575b506105fd90546150a3565b9260405191825230600483015284826024818b5afa918215610701575f926106d0575b5061062e9060643592614b22565b106106be57808210610683575b7ffea7a9a6e25cd0bbbfa80ce0c7646e61ee5e0551b3fdaaff0642e6f6adcc72e260808686898761066a6155c5565b60405193845283015260443560408301526060820152a1005b61069d670de0b6b3a7640000916009969594965490614985565b04116106ac579091848061063b565b604051631393c01360e31b8152600490fd5b60405163712681bd60e01b8152600490fd5b9091508481813d83116106fa575b6106e881836143a2565b810103126103e957519061062e610620565b503d6106de565b6040513d5f823e3d90fd5b9095508481813d8311610736575b61072481836143a2565b810103126103e95751946105fd6105f2565b503d61071a565b9392509650508682813d831161076d575b61075881836143a2565b810103126103e957905194899089905f61056c565b503d61074e565b6040516375d7f9d560e01b8152600490fd5b6040516307c241ad60e51b8152600490fd5b508581165f5260ff60405f205416156104f1565b346103e9575f3660031901126103e9575f60606040516107cb8161436c565b6107d3614e2c565b815282602082015282604082015201526040516107ef8161436c565b60606107f9614e50565b808352600654906001600160401b03908160208601818516815261083a6040880193838760401c1685528789019660801c8752610834614e2c565b50615802565b60405196516001600160801b03968188809351168a528260208201511660208b01528260408201511660408b0152015116606088015251166080860152511660a0840152511660c0820152f35b346103e9575f3660031901126103e95761089f614675565b5f915f906001600160a01b038060035416945b825184101561097a576108c58486614661565b5190826108d28686614661565b516040516334ff2eeb60e01b81529116600482015260209081816024818c5afa918215610701575f92610946575b50509061093861091561093e93600195614985565b61093261092d876109268b8b614661565b5116615136565b614998565b906149a9565b90614b60565b9301926108b2565b9080939250813d8311610973575b61095e81836143a2565b810103126103e9579051610938610915610900565b503d610954565b60408051635054022f60e11b81529190826004818a5afa918215610701576040926109bc915f905f926109c8575b506109b66109329185614985565b91614998565b82519182526020820152f35b6109b6925061093291506109f190863d88116109fa575b6109e981836143a2565b810190614b7b565b929091506109a8565b503d6109df565b346103e95760203660031901126103e9576004356001600160a01b035f80516020615b8183398151915254163303610a6a577f73624d727a5e51dee93a729f945f3dbf8bd3d81e122272d7f4bc9f6381021e4c6040600c548151908152836020820152a1600c55005b60405163070545c960e51b8152600490fd5b346103e9575f3660031901126103e9576060600e54604051906001600160a01b038116825265ffffffffffff8160a01c16602083015260d01c6040820152f35b346103e95760403660031901126103e957610ad56142d4565b6001600160a01b03610b1f610ae86142ea565b926001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160205260405f2090565b91165f52602052602060405f2054604051908152f35b346103e95760203660031901126103e957600435335f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00806020528160405f205410610d0857600e54610b8c8160d01c846152e3565b92610b9f610b9a8583614b22565b614909565b9390928580610cee575b610bb4915083614b22565b903315610cd657335f528060205260405f205490828210610cad579180915f933385526020520360408320555f80516020615b618339815191528181540390556040519081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203392a35f5b8251811015610c735780610c3860019286614661565b51610c44575b01610c22565b610c6e6001600160a01b03610c598387614661565b5116610c658388614661565b51903390615667565b610c3e565b5092610ca87f5db1997bc8fc1e1e4bcea6438a652310893f2756d6138bece7142ac25e9187dd93604051938493339785614dfc565b0390a2005b5060405163391434e360e21b815233600482015260248101919091526044810191909152606490fd5b604051634b637e8f60e11b81525f6004820152602490fd5b6001600160a01b03610d01921633614f76565b8585610ba9565b604051633999656760e01b8152600490fd5b346103e9575f3660031901126103e9576020604051633b9aca008152f35b346103e957806003193601126103e957610d506142d4565b90610d596142ea565b60443591606435906084359060ff821682036103e957824211610eb2576001600160a01b039081871692835f527f5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb0060205260405f20918254926001840190556040519560208701937f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98552866040890152858916606089015289608089015260a088015260c087015260c086528501918583106001600160401b03841117610e9e57610e6195610e5893604052519020610e3161572e565b906040519161190160f01b83526002830152602282015260c43591604260a43592206158e7565b90949194615969565b821603610e745750610e72926156a1565b005b6040516325c0072360e11b81526001600160a01b0391821660048201529084166024820152604490fd5b634e487b7160e01b5f52604160045260245ffd5b60405163313c898160e11b815260048101849052602490fd5b346103e95760203660031901126103e957610ee46142d4565b6001600160a01b03805f80516020615b81833981519152541691823303610a6a57807f0fe544e960ecab9b6f1eee0df869972d09c3c135c0d116422cce176351b522375516907fa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d5f80a3005b346103e95760203660031901126103e957610f6961433b565b6001600160a01b035f80516020615b8183398151915254163303610a6a576001600160401b03808216918215610fed57600654604080516001600160401b0394831685168152929093166020830152917f33e09603bebc108145e6185df188fd486e72ff9fc5e89cd7bf57a5fc1129cd4a91a167ffffffffffffffff191617600655005b604051632a9ffab760e21b8152600490fd5b346103e9575f3660031901126103e95760206001600160a01b035f80516020615b8183398151915254163314604051908152f35b346103e95760203660031901126103e95761104c6144ed565b6001600160a01b035f80516020615b8183398151915254163303610a6a5760065490604051908260801c82527f8b76cd989240b6e717d1437b39a1691ee1629b9c62dea6c5e50024736816847960406001600160801b03938484166020820152a1911660809190911b6fffffffffffffffffffffffffffffffff191617600655005b346103e95760203660031901126103e9576001600160a01b036110ef6142d4565b165f525f602052606060405f20546001600160401b036040519160ff81161515835260ff8160081c161515602084015260101c166040820152f35b346103e9575f3660031901126103e9576020600954604051908152f35b346103e9575f3660031901126103e95760206001600160a01b0360035416604051908152f35b346103e95760203660031901126103e95761118661433b565b6001600160a01b035f80516020615b8183398151915254163303610a6a57610e72907f38016aed2f1b157c3acb51fd6f9f9b07a1f97e2416d4e5bfb90382ef0e1f7a9260406001600160401b0360055460801c9382519485521692836020820152a161124b6111f3614e50565b6111fc81615802565b60406001600160801b039161122c836020830151166001600160801b036004549181199060801b16911617600455565b0151166001600160801b03166001600160801b03196005541617600555565b6001600160801b036005549181199060801b16911617600555565b346103e95760203660031901126103e95760206112a16112846142d4565b6001600160a01b03165f525f60205260ff60405f205460081c1690565b6040519015158152f35b346103e9575f3660031901126103e9576112f06040516112ca81614387565b60058152640352e302e360dc1b60208201526040519182916020835260208301906142b0565b0390f35b346103e95760403660031901126103e95761131a6113106142d4565b6024359033614f76565b602060405160018152f35b346103e95760203660031901126103e95761133e6142d4565b6001600160a01b03805f80516020615b8183398151915254163303610a6a57808216918215610fed57600a54604080516001600160a01b0394831685168152929093166020830152917f8020349d0bc5072c61ea63992108fed8a34a6009921e84089e8a7c89ad03d73f91a16001600160a01b03191617600a55005b346103e9575f3660031901126103e9576020600c54604051908152f35b346103e95760403660031901126103e9576001600160401b036004358181116103e9576114089036906004016143da565b6024359182116103e957366023830112156103e95781600401359161142c836143c3565b9061143a60405192836143a2565b8382526020908183016024819660051b830101913683116103e957602401905b82821061156d575050506001600160a01b03805f80516020615b8183398151915254163303610a6a578351908351820361155b575f5b8281106115085750505090816114b160405194604086526040860190614219565b918483038286015251918281520193915f5b8281106114f2577f5fcdd83f4c41c27a689eeb9536ad69f8d26d47cab9dc5cc76793b7e23a5b261e85870386a1005b83511515865294810194928101926001016114c3565b816115138288614661565b511615610fed576115248186614661565b51151590826115338289614661565b51165f5261155560019283875260405f209060ff801983541691151516179055565b01611490565b60405163512509d360e11b8152600490fd5b813580151581036103e957815290830190830161145a565b346103e95760603660031901126103e9576001600160401b036004358181116103e9576115b69036906004016143da565b6024906024358381116103e9576115d190369060040161444a565b906115da614300565b936115e3615444565b335f52600190602090600160205260ff60405f2054161561184e57611606615481565b835185510361155b576001600160a01b039687811697881561183c57611665975f80516020615b61833981519152541595869461164161505a565b9661166b6001600160801b036116578d8d614b2f565b819f91819d61180557614b60565b1661553a565b156117f357918b9492819694925f975b61171d575b5050505061169793508680611709575b505061585e565b61169f6155c5565b6116a761505a565b901591826116ff575b50506116ee576116e97f6fa8234a2db30e7490b3e314f2d1783c1de3ec2bf7be5f873d2a9d4f7b8bdf3d93604051938493339785614dfc565b0390a3005b6040516216dc7760e31b8152600490fd5b11905086806116b0565b61171691600e541661585e565b8a86611690565b9193958b90819892949698518310156117e857508661173f8361175e93614661565b51166001600160a01b03165f525f60205260ff60405f205460081c1690565b15610786578b61177c82886117748f8390614661565b511692614661565b5190604051916323b872dd60e01b86840152338884015230604484015260649081840152825260a08201828110858211176117d55786959493919286936117c5926040526159f4565b019291908d96949795939761167b565b87634e487b7160e01b5f5260416004525ffd5b969450879550611680565b60405163a74c1c5f60e01b8152600490fd5b60065467ffffffffffffffff60401b61182089831642614b60565b60401b169067ffffffffffffffff60401b191617600655614b60565b604051634e46966960e11b8152600490fd5b60405163015f483560e31b8152600490fd5b346103e9575f3660031901126103e9576040517f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace048054825f6118a18361472c565b92838352602094600191866001821691825f1461193e5750506001146118e4575b50506118d0925003836143a2565b6112f06040519282849384528301906142b0565b8592505f527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa905f915b8583106119265750506118d0935082010185806118c2565b8054838901850152879450869390920191810161190e565b92509350506118d094915060ff191682840152151560051b82010185806118c2565b346103e95760203660031901126103e9576001600160a01b036119816142d4565b165f526008602052602060ff60405f2054166040519015158152f35b346103e95760403660031901126103e95760206119c36119bb6142ea565b600435614d52565b604051908152f35b346103e9575f3660031901126103e9577fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100541580611ad2575b15611a8d57611a11614764565b90611a1a61484a565b604051602081018181106001600160401b03821117610e9e576112f092611a6d916040525f8352611a5f604051968796600f60f81b88528060208901528701906142b0565b9085820360408701526142b0565b904660608501523060808501525f60a085015283820360c0850152614255565b60405162461bcd60e51b815260206004820152601560248201527f4549503731323a20556e696e697469616c697a656400000000000000000000006044820152606490fd5b507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1015415611a04565b346103e9575f3660031901126103e957611b1361519c565b611b1b615444565b611b23615444565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300600160ff198254161790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346103e9576101803660031901126103e9576004356001600160401b0381116103e957611bac90369060040161459d565b6024356001600160401b0381116103e957611bcb90369060040161459d565b611bd3614300565b606435906001600160a01b039081831683036103e9578160843516608435036103e9578160a4351660a435036103e9578160c4351660c435036103e95760e435906001600160801b03821682036103e9576060366101231901126103e95760405195611c3e87614351565b6101243584811681036103e957875265ffffffffffff610144351661014435036103e95761014435602088015265ffffffffffff610164351661016435036103e9576101643560408801527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054956001600160401b0387161580612aa5575b60016001600160401b038916149081612a9b575b159081612a92575b50612a805760016001600160401b03198816177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005560ff8760401c1615612a41575b611d236157c1565b611d2b6157c1565b81516001600160401b038111610e9e57611d657f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace035461472c565b601f8111612985575b50806020601f82116001146128c5575f916128ba575b508160011b915f199060031b1c1916177f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03555b8051906001600160401b038211610e9e578190611df47f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace045461472c565b601f81116127f3575b50602090601f831160011461272e575f92612723575b50508160011b915f199060031b1c1916177f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace04555b611e4f6157c1565b60405190611e5c82614387565b60018252603160f81b6020830152611e726157c1565b8051906001600160401b038211610e9e578190611eaf7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1025461472c565b601f811161265c575b50602090601f8311600114612597575f9261258c575b50508160011b915f199060031b1c1916177fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d102555b8051906001600160401b038211610e9e578190611f3f7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1035461472c565b601f81116124c5575b50602090601f8311600114612400575f926123f5575b50508160011b915f199060031b1c1916177fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d103555b5f7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100555f7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10155611fe06157c1565b5f80516020615b81833981519152556001600160a01b031982608435168160075416176007558260a4351681600a541617600a558284165f52600b60205260405f20600160ff198254161790558260c43516906003541617600355612043614e2c565b506040516120508161436c565b683635c9adc5dea0000080825260208201526001600160801b0342166040820152662386f26fc100006060820152610e10420142116123e15760407f8b76cd989240b6e717d1437b39a1691ee1629b9c62dea6c5e50024736816847994819461220e60ff996121da7fa11b5803b8a35081b8f993e0dee5bc30301a3d83f644e5ab2ff39f972f0a807f966121a46001600160801b0360606001600160401b03610e10420116938c82848d51926121058461436c565b848452610e106020850152888f8501521691015261213c838251166001600160801b03166001600160801b03196004541617600455565b612161836020830151166001600160801b036004549181199060801b16911617600455565b612186838c830151166001600160801b03166001600160801b03196005541617600555565b0151166001600160801b036005549181199060801b16911617600555565b600680546fffffffffffffffffffffffffffffffff191660409290921b67ffffffffffffffff60401b1691909117610e10179055565b600680546001600160801b0316608089901b6fffffffffffffffffffffffffffffffff191617905561010435600c55614e8c565b82519116815260016020820152a181515f81526084356001600160a01b031660208201527f64187bd7b97e66658c91904f3021d7c28de967281d18b1a20742348afdd6a6b390604090a181515f815260a4356001600160a01b031660208201527f8020349d0bc5072c61ea63992108fed8a34a6009921e84089e8a7c89ad03d73f90604090a181515f815260c4356001600160a01b031660208201527f98c01d227e3cc9d2c6f54140e668728d1cb767472f07d012d156af971734459d90604090a16001600160801b038251915f8352166020820152a17f38016aed2f1b157c3acb51fd6f9f9b07a1f97e2416d4e5bfb90382ef0e1f7a92604080515f8152662386f26fc100006020820152a17f73624d727a5e51dee93a729f945f3dbf8bd3d81e122272d7f4bc9f6381021e4c604080515f8152610104356020820152a1670dcef33a6f83800060095560401c161561236457005b68ff0000000000000000197ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b634e487b7160e01b5f52601160045260245ffd5b015190508880611f5e565b92507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1035f527f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b75905f935b601f19841685106124aa576001945083601f19811610612492575b505050811b017fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10355611f92565b01515f1960f88460031b161c19169055888080612465565b8181015183556020948501946001909301929091019061244a565b9091507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1035f52601f830160051c7f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b750160208410612565575b908392915b601f820160051c7f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b750181106125575750611f48565b5f8155849350600101612522565b507f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b7561251d565b015190508980611ece565b92507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1025f527f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d905f935b601f1984168510612641576001945083601f19811610612629575b505050811b017fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10255611f02565b01515f1960f88460031b161c191690558980806125fc565b818101518355602094850194600190930192909101906125e1565b9091507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1025f52601f830160051c7f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d01602084106126fc575b908392915b601f820160051c7f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d0181106126ee5750611eb8565b5f81558493506001016126b9565b507f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d6126b4565b015190508980611e13565b92507f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace045f527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa905f935b601f19841685106127d8576001945083601f198116106127c0575b505050811b017f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0455611e47565b01515f1960f88460031b161c19169055898080612793565b81810151835560209485019460019093019290910190612778565b9091507f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace045f52601f830160051c7f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa0160208410612893575b908392915b601f820160051c7f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa0181106128855750611dfd565b5f8155849350600101612850565b507f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa61284b565b90508301518a611d84565b91507f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace035f527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab05f925b601f198316841061296d576001935082601f19811610612955575b5050811b017f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0355611db7565b8501515f1960f88460031b161c191690558a80612929565b8581015182556020938401936001909201910161290e565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace035f52601f820160051c7f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab00160208310612a1a575b601f820160051c7f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0018110612a0f5750611d6e565b5f81556001016129da565b507f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab06129da565b68ffffffffffffffffff19871668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0055611d1b565b60405163f92ee8a960e01b8152600490fd5b90501589611cd9565b303b159150611cd1565b5060ff8760401c1615611cbd565b346103e9575f3660031901126103e95760206040516127108152f35b346103e95760203660031901126103e9576001600160a01b03612af06142d4565b165f527f5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb00602052602060405f2054604051908152f35b346103e95760403660031901126103e957612b3f6142d4565b612b47614316565b6001600160a01b03805f80516020615b8183398151915254163303610a6a578216918215610fed57825f52600b60205260ff60405f20541682151590151514612be9577fa11b5803b8a35081b8f993e0dee5bc30301a3d83f644e5ab2ff39f972f0a807f925f52600b602052612bcc8260405f209060ff801983541691151516179055565b604080516001600160a01b039290921682529115156020820152a1005b604051633fbc93f360e01b8152600490fd5b346103e95760203660031901126103e95760206119c3612c196142d4565b6001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0060205260405f205490565b346103e95760203660031901126103e957612c696142d4565b6001600160a01b03805f80516020615b8183398151915254163303610a6a57808216918215610fed57600754604080516001600160a01b0394831685168152929093166020830152917f64187bd7b97e66658c91904f3021d7c28de967281d18b1a20742348afdd6a6b391a16001600160a01b03191617600755005b5f3660031901126103e957612cf8615444565b600c548015612da2573403612d9057612d0f615444565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300600160ff198254161790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a134600d55337ffd7ee573b5f0025377dc7fc832e85c1f9a1bf8c0ab7f9ba6fdc741d117b444ed5f80a2005b60405163256c3f0760e21b8152600490fd5b60405163400f6a8760e01b8152600490fd5b346103e95760203660031901126103e957612dcd6142d4565b6001600160a01b03805f80516020615b8183398151915254163303610a6a57808216918215610fed57600e54604080516001600160a01b0394831685168152929093166020830152917f21eb548722a564f6e09f039f7aa858ae94c911910f3823b37af2250eeca4f40391a16001600160a01b03191617600e55005b346103e95760403660031901126103e95760206119c3612e676142d4565b612eaa612e726142ea565b916001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0060205260405f205490565b614d52565b346103e95760403660031901126103e95760243560048110156103e9576119c3602091600435614ce7565b346103e9575f3660031901126103e9576001600160a01b03807f0fe544e960ecab9b6f1eee0df869972d09c3c135c0d116422cce176351b5223754163303612f71573315612f5f575f80516020615b818339815191529033908254167fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a5f80a3339055005b604051638843aaaf60e01b8152600490fd5b604051639ba0305d60e01b8152600490fd5b346103e9575f3660031901126103e957602060ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330054166040519015158152f35b346103e95760206119c3612fd7366144aa565b90614b95565b346103e95760203660031901126103e9576004612ffa81356150a3565b60406001600160a01b0360035416815193848092635054022f60e11b82525afa918215610701575f905f93613056575b508015613044576040926109326109b66109bc9385614985565b60405163068a761760e41b8152600490fd5b905061307291925060403d6040116109fa576109e981836143a2565b91908361302a565b346103e9575f3660031901126103e9576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036130e45760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b60405163703e46dd60e11b8152600490fd5b346103e95760203660031901126103e9576004356002548110156103e9576001600160a01b03613127602092614554565b9190546040519260031b1c168152f35b60403660031901126103e95761314b6142d4565b6024356001600160401b0381116103e957366023820112156103e95761317b90369060248160040135910161451e565b906001600160a01b03807f00000000000000000000000000000000000000000000000000000000000000001680301490811561331c575b506130e457805f80516020615b8183398151915254163303610a6a578116906040516352d1902d60e01b8152602081600481865afa5f91816132e8575b5061320d57604051634c9c8ce360e01b815260048101849052602490fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc929192908181036132d05750823b156132b75780546001600160a01b03191682179055604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561329e57505f80836020610e7295519101845af4613298615203565b91615afd565b915050346132a857005b63b398979f60e01b8152600490fd5b604051634c9c8ce360e01b815260048101839052602490fd5b60249060405190632a87526960e21b82526004820152fd5b9091506020813d602011613314575b81613304602093836143a2565b810103126103e9575190856131ef565b3d91506132f7565b9050817f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54161415846131b2565b346103e95760203660031901126103e9576133976133a5600435613380610b9a613379600e5460d01c846152e3565b8093614b22565b604093919351948594606086526060860190614219565b908482036020860152614255565b9060408301520390f35b346103e95760603660031901126103e9576133c86144ed565b6133d0614325565b906044356001600160801b0380821682036103e9576001600160a01b035f80516020615b8183398151915254163303610a6a57610e72936134dc613434613516948461342e815f80516020615b618339815191525499168099615265565b16615409565b9260606001600160401b038094169361344d8542614b60565b1694878260405161345d8161436c565b8381528760208201528860408201520152613491838251166001600160801b03166001600160801b03196004541617600455565b6134b6836020830151166001600160801b036004549181199060801b16911617600455565b612186836040830151166001600160801b03166001600160801b03196005541617600555565b6001600160401b0319600654161760065567ffffffffffffffff60401b6006549160401b169067ffffffffffffffff60401b191617600655565b6001600160801b036006549181199060801b16911617600655565b346103e95760203660031901126103e95760043561354d6153e3565b8015610fed577fa8fcfe631e055407319ebee96860e5a911fdd6af8156501f4c82b4c8bf33b1ed60406009548151908152836020820152a1600955005b346103e95760203660031901126103e9576135a36142d4565b6001600160a01b03805f80516020615b8183398151915254163303610a6a57808216918215610fed57600354604080516001600160a01b0394831685168152929093166020830152917f98c01d227e3cc9d2c6f54140e668728d1cb767472f07d012d156af971734459d91a16001600160a01b03191617600355005b346103e95760406109bc613632366144aa565b90614b2f565b346103e9575f3660031901126103e95761365061519c565b6136586151c5565b600d54806136be575b6136696151c5565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330060ff1981541690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b5f600d557fd6060418062d03ef3ef2e9cca5d7e94502c0224f1ea338059fa40ecfb8bd121a60206001600160a01b035f80516020615b81833981519152613706858254615232565b541692604051908152a280613661565b346103e95760403660031901126103e95761372f6142d4565b613737614325565b906001600160a01b0390815f80516020615b8183398151915254163303610a6a5716908115610fed57815f525f60205260ff60405f205416156103d7576001600160401b0391633b9aca008383161161381c577f67cba15f5a6551b1966bc3ebb577b6d72a3850d34e1d22f95fd8d027e06e746c82610e7294835f525f60205260405f205460101c166137e9604051928392839060209093929360408301946001600160401b03809216845216910152565b0390a15f525f60205260405f209069ffffffffffffffff000082549160101b169069ffffffffffffffff00001916179055565b6040516329fcf74560e11b8152600490fd5b346103e95760203660031901126103e95760206119c361384c6142d4565b6149c7565b346103e95760203660031901126103e9576001600160a01b036138726142d4565b165f526001602052602060ff60405f2054166040519015158152f35b346103e95760403660031901126103e9576138a76142d4565b6138af614316565b6001600160a01b0391825f80516020615b8183398151915254163303610a6a57828116928315610fed5782613922575b507fb8b9e5a88e9294b8e8db65259eca50004f01999ff58204e3ff1473f585d0b7d3925f526008602052612bcc8260405f209060ff801983541691151516179055565b835f525f60205260ff60405f205416156103d757602060249160035416604051928380926334ff2eeb60e01b82528860048301525afa908115610701575f91613984575b501561397257836138df565b6040516382cf5b8f60e01b8152600490fd5b90506020813d6020116139ae575b8161399f602093836143a2565b810103126103e9575184613966565b3d9150613992565b346103e9575f3660031901126103e95760206119c361572e565b346103e9575f3660031901126103e957602060405160128152f35b346103e95760203660031901126103e9576001600160a01b03613a0c6142d4565b165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052613a4060405f2054614909565b906112f060405192839283614288565b346103e9575f3660031901126103e95760206001600160a01b03600a5416604051908152f35b346103e9575f3660031901126103e957600254613a92816143c3565b613a9f60405191826143a2565b818152613aab826143c3565b60209282840191601f1901368337613ad05f80516020615b61833981519152546150a3565b5f5b828110613b4057505050613aff92613ae86145b8565b926020604051958695604087526040870190614219565b918583038287015251918281520192915f5b828110613b2057505050500390f35b83516001600160401b031685528695509381019392810192600101613b11565b80613b68836001600160a01b03613b5b600195999899614554565b90549060031b1c166150da565b6001600160401b03613b7a8388614661565b9116905201939293613ad2565b346103e95760203660031901126103e95760206112a1613ba56142d4565b6001600160a01b03165f525f60205260ff60405f20541690565b346103e95760603660031901126103e957613bd86142d4565b613be06142ea565b60443590613c1e836001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160205260405f2090565b335f5260205260405f2054925f198403613c3d575b61131a9350614f76565b828410613cd9576001600160a01b03811615613cc1573315613ca9578261131a94613c98836001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160205260405f2090565b335f526020520360405f2055613c33565b604051634a1406b160e11b81525f6004820152602490fd5b60405163e602df0560e01b81525f6004820152602490fd5b604051637dc7a0d960e11b81523360048201526024810185905260448101849052606490fd5b346103e95760603660031901126103e957604051613d1c81614351565b6001600160a01b0360043581811681036103e957825265ffffffffffff60243581811681036103e957602084015260443590811681036103e95760408301525f80516020615b8183398151915254163303610a6a57610e7290614e8c565b346103e9575f3660031901126103e95760205f80516020615b6183398151915254604051908152f35b346103e95760203660031901126103e957613a40600435614909565b346103e95760403660031901126103e957613dd86142d4565b613de0614325565b906001600160a01b0390815f80516020615b8183398151915254163303610a6a5781168015610fed57805f526020925f845260ff60405f205416613fac576024848460035416604051928380926334ff2eeb60e01b82528760048301525afa908115610701575f91613f7f575b5015613972576001600160401b03809116633b9aca00811161381c57613eef9160405191613e7a83614351565b60018352613ec98784016001815260408501928352865f525f8952613eb260405f2095511515869060ff801983541691151516179055565b51845461ff00191690151560081b61ff0016178455565b51825469ffffffffffffffff00001916911660101b69ffffffffffffffff000016179055565b60025468010000000000000000811015610e9e577fef81a9943b96c8df4ef243401c9bf5159146166211356898b52d382086168d9293604093613f39836001809501600255614554565b819291549060031b9186831b921b19161790557f158412daecdc1456d01568828bcdb18464cc7f1ce0215ddbc3f3cfede9d1e63d818551858152a18351928352820152a1005b90508481813d8311613fa5575b613f9681836143a2565b810103126103e9575185613e4d565b503d613f8c565b604051633ea7ffd960e11b8152600490fd5b346103e95760403660031901126103e957613fd76142d4565b613fdf614316565b6001600160a01b03805f80516020615b8183398151915254163303610a6a578216918215610fed57825f525f60205260ff60405f205416156103d7577fef81a9943b96c8df4ef243401c9bf5159146166211356898b52d382086168d92925f525f602052612bcc8260405f209061ff00825491151560081b169061ff001916179055565b346103e9575f3660031901126103e95760205f80516020615b81833981519152546001600160a01b0360405191168152f35b346103e9575f3660031901126103e9576020600d54604051908152f35b346103e95760203660031901126103e9576001600160a01b036140d36142d4565b165f52600b602052602060ff60405f2054166040519015158152f35b346103e95760403660031901126103e95761131a61410b6142d4565b60243590336156a1565b346103e9575f3660031901126103e9576040517f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace038054825f6141568361472c565b92838352602094600191866001821691825f1461193e5750506001146141845750506118d0925003836143a2565b8592505f527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0905f915b8583106141c65750506118d0935082010185806118c2565b805483890185015287945086939092019181016141ae565b346103e9575f3660031901126103e957613a40614675565b346103e9575f3660031901126103e9576020906001600160a01b03600754168152f35b9081518082526020808093019301915f5b828110614238575050505090565b83516001600160a01b03168552938101939281019260010161422a565b9081518082526020808093019301915f5b828110614274575050505090565b835185529381019392810192600101614266565b909161429f6142ad93604084526040840190614219565b916020818403910152614255565b90565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b03821682036103e957565b602435906001600160a01b03821682036103e957565b604435906001600160a01b03821682036103e957565b6024359081151582036103e957565b602435906001600160401b03821682036103e957565b600435906001600160401b03821682036103e957565b606081019081106001600160401b03821117610e9e57604052565b608081019081106001600160401b03821117610e9e57604052565b604081019081106001600160401b03821117610e9e57604052565b90601f801991011681019081106001600160401b03821117610e9e57604052565b6001600160401b038111610e9e5760051b60200190565b9080601f830112156103e95760209082356143f4816143c3565b9361440260405195866143a2565b81855260208086019260051b8201019283116103e957602001905b82821061442b575050505090565b81356001600160a01b03811681036103e957815290830190830161441d565b9080601f830112156103e9576020908235614464816143c3565b9361447260405195866143a2565b81855260208086019260051b8201019283116103e957602001905b82821061449b575050505090565b8135815290830190830161448d565b9060406003198301126103e9576001600160401b036004358181116103e957836144d6916004016143da565b926024359182116103e9576142ad9160040161444a565b600435906001600160801b03821682036103e957565b6001600160401b038111610e9e57601f01601f191660200190565b92919261452a82614503565b9161453860405193846143a2565b8294818452818301116103e9578281602093845f960137010152565b6002548110156145895760025f527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace01905f90565b634e487b7160e01b5f52603260045260245ffd5b9080601f830112156103e9578160206142ad9335910161451e565b6040519060025480835282602091602082019060025f527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace935f905b82821061460c5750505061460a925003836143a2565b565b85546001600160a01b0316845260019586019588955093810193909101906145f4565b90614639826143c3565b61464660405191826143a2565b8281528092614657601f19916143c3565b0190602036910137565b80518210156145895760209160051b010190565b61467d6145b8565b9081519161468a8361462f565b925f5b81811061469a5750509190565b6001600160a01b036146ac8285614661565b5116906040805180936370a0823160e01b825230600483015281602460209384935afa91821561472357505f916146f4575b50600192506146ed8288614661565b520161468d565b905082813d831161471c575b61470a81836143a2565b810103126103e957600191515f6146de565b503d614700565b513d5f823e3d90fd5b90600182811c9216801561475a575b602083101461474657565b634e487b7160e01b5f52602260045260245ffd5b91607f169161473b565b604051905f827fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d102918254926147988461472c565b8084529360209160019182811690811561482457506001146147c4575b50505061460a925003836143a2565b5f9081527f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d9590935091905b82841061480c575061460a9450505081016020015f80806147b5565b855488850183015294850194879450928101926147f0565b925050506020925061460a94915060ff191682840152151560051b8201015f80806147b5565b604051905f827fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1039182549261487e8461472c565b8084529360209160019182811690811561482457506001146148a95750505061460a925003836143a2565b5f9081527f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b759590935091905b8284106148f1575061460a9450505081016020015f80806147b5565b855488850183015294850194879450928101926148d5565b905f80516020615b618339815191525415614973576149266145b8565b80516149318161462f565b935f5b828110614942575050509190565b806149626001600160a01b0361495a60019488614661565b511684614d52565b61496c8289614661565b5201614934565b60405163ed0f386160e01b8152600490fd5b818102929181159184041417156123e157565b60ff16604d81116123e157600a0a90565b81156149b3570490565b634e487b7160e01b5f52601260045260245ffd5b6001600160a01b0390816003541660409081516334ff2eeb60e01b9485825284168060048301526020918281602481875afa908115614ada575f91614af5575b5015614ae45783516370a0823160e01b8152306004820152958287602481855afa968715614ada575f97614aa8575b50906024839286519586938492835260048301525afa92831561472357505f92614a76575b505061092d614a70610932926142ad95614985565b92615136565b90809250813d8311614aa1575b614a8d81836143a2565b810103126103e9575161092d614a70614a5b565b503d614a83565b919096508282813d8311614ad3575b614ac181836143a2565b810103126103e9579051956024614a36565b503d614ab7565b85513d5f823e3d90fd5b835163068a761760e41b8152600490fd5b90508281813d8311614b1b575b614b0c81836143a2565b810103126103e957515f614a07565b503d614b02565b919082039182116123e157565b614b4191614b3c91614b95565b614cba565b90614b5c61337965ffffffffffff600e5460a01c16846152e3565b9190565b919082018092116123e157565b519060ff821682036103e957565b91908260409103126103e9576142ad602083519301614b6d565b9190915f92815181510361155b575f936001600160a01b03918260035416915b8451871015614cb257614be884614bcc8988614661565b51166001600160a01b03165f525f60205260ff60405f20541690565b156103d75783614bf88887614661565b51166040908151916334ff2eeb60e01b83526004918284015260209283816024818a5afa938415614ca8575f94614c78575b50508215614c6b5750506001916109388961093261092d89610926614c5c614c6398614c56878d614661565b51614985565b948d614661565b960195614bb5565b5163068a761760e41b8152fd5b9080929450813d8311614ca1575b614c9081836143a2565b810103126103e95751915f80614c2a565b503d614c86565b82513d5f823e3d90fd5b955050505050565b5f80516020615b61833981519152548015614ce3579081614cdd6142ad936150a3565b9161534b565b5090565b905f80516020615b61833981519152548015614d4d57614d06816150a3565b600180614d1483858861534b565b94614d1e816157a3565b16149182614d36575b50506142ad9250151590614b60565b90809250156149b3576142ad930915155f80614d27565b505090565b906001600160a01b031690815f525f60205260ff60405f205416156103d7575f80516020615b6183398151915254908115614973576020602493604051948580926370a0823160e01b82523060048301525afa908115610701575f91614dc6575b6142ad93508161534b576001915061534b565b90506020833d602011614df4575b81614de1602093836143a2565b810103126103e9576142ad925190614db3565b3d9150614dd4565b926142ad9492614e1e9285526020850152608060408501526080840190614219565b916060818403910152614255565b60405190614e398261436c565b5f6060838281528260208201528260408201520152565b60405190614e5d8261436c565b8160606004546001600160801b0390818116845260801c6020840152600554908116604084015260801c910152565b6001600160a01b039081815116158015614f5f575b8015614f48575b610fed5760405191600e5491818316845265ffffffffffff92838160a01c16602086015260d01c60408501528181511660608501527f053a31509a16e67257fc3e50d5f8f50748f23268d2ff285f6b5893964ea93c4160c06020830195858751166080820152604084019586511660a0820152a151169165ffffffffffff60a01b905160a01b169065ffffffffffff60d01b905160d01b16911717600e55565b5061271065ffffffffffff60408301511611614ea8565b5061271065ffffffffffff60208301511611614ea1565b916001600160a01b03808416928315610cd6571692831561504257825f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace008060205260405f20549183831061500f575091806020927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef94865f5284520360405f2055845f5260405f20818154019055604051908152a3565b60405163391434e360e21b81526001600160a01b0391909116600482015260248101929092525060448101829052606490fd5b60405163ec442f0560e01b81525f6004820152602490fd5b5f80516020615b6183398151915254801561509e5761507a612fd7614675565b90670de0b6b3a7640000918281029281840414901517156123e1576142ad916149a9565b505f90565b5f80516020615b618339815191525480156150d4576150cf6142ad926150ca612fd7614675565b614985565b6149a9565b50505f90565b6150e3906149c7565b90633b9aca00918281029281840414901517156123e157615103916149a9565b6001600160401b0390818111615117571690565b604490604051906306dfcc6560e41b8252604060048301526024820152fd5b60206001600160a01b039160046040518094819363313ce56760e01b8352165afa908115610701575f91615168575090565b90506020813d602011615194575b81615183602093836143a2565b810103126103e9576142ad90614b6d565b3d9150615176565b335f52600b60205260ff60405f205416156151b357565b604051631d77d47760e21b8152600490fd5b60ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005416156151f157565b604051638dfc202b60e01b8152600490fd5b3d1561522d573d9061521482614503565b9161522260405193846143a2565b82523d5f602084013e565b606090565b5f8080936001600160a01b038294165af161524b615203565b501561525357565b604051630ce8f45160e31b8152600490fd5b90808202905f19818409908280831092039180830392146152d657633b9aca0090828211156152c4577f88f2cfb83100cb4e69e7c79c58b316e597157d372fb9787e8e47ce423a2e9c6d940990828211900360f71b910360091c170290565b634e487b715f5260116020526024601cfd5b5050633b9aca0091500490565b90808202905f19818409908280831092039180830392146153405761271090828211156152c4577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e91940990828211900360fc1b910360041c170290565b505061271091500490565b91818302915f19818509938380861095039480860395146153d657848311156153be5790829109815f038216809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b82634e487b715f52156003026011186020526024601cfd5b5050906142ad92506149a9565b6001600160a01b036007541633036153f757565b6040516309478a2f60e31b8152600490fd5b90615412614e2c565b506001600160801b0390816040519361542a8561436c565b168084526020840152814216604084015216606082015290565b60ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300541661546f57565b60405163d93c066560e01b8152600490fd5b5f80516020615b61833981519152548015615537576006546001600160401b0391828260401c1642116154b357505050565b60606154e0615503936154d36001600160801b0394859260801c90615265565b1660055460801c90615409565b613491838251166001600160801b03166001600160801b03196004541617600455565b67ffffffffffffffff60401b61551e60065492831642614b60565b60401b169067ffffffffffffffff60401b191617600655565b50565b604051906155478261436c565b600454916001600160801b039081841692838252602082019460801c85528280600554966155866040860195838a1687528960801c6060820152615802565b51169116908181106155bb5703928284116123e1576001600160801b0319809460801b16176004555116911617600555600190565b5050505050505f90565b6002546155df5f80516020615b61833981519152546150a3565b8015615663575f5b8281106155f357505050565b6155fc81614554565b90615618846001600160a01b03809354600395861b1c166150da565b9161562284614554565b9054911b1c165f525f6020526001600160401b039060409180835f205460101c1691161161565357506001016155e7565b51635253913f60e11b8152600490fd5b5050565b61460a926001600160a01b036040519363a9059cbb60e01b602086015216602484015260448301526044825261569c8261436c565b6159f4565b916001600160a01b03808416928315613cc15716928315613ca9577f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259161571a6020926001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160205260405f2090565b855f5282528060405f2055604051908152a3565b615736615a4e565b61573e615ab8565b6040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a0815260c081018181106001600160401b03821117610e9e5760405251902090565b600411156157ad57565b634e487b7160e01b5f52602160045260245ffd5b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c16156157f057565b604051631afcd79f60e31b8152600490fd5b6001600160801b0380421691604081019180808451168503168160608401511602918183169283036123e157602081019282845116018281116123e157815190831690831681111561585657505116905252565b929150505252565b6001600160a01b0316908115615042577fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205f925f80516020615b618339815191526158ac828254614b60565b90558484527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00825260408420818154019055604051908152a3565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161595e579160209360809260ff5f9560405194855216868401526040830152606082015282805260015afa15610701575f516001600160a01b0381161561595457905f905f90565b505f906001905f90565b5050505f9160039190565b615972816157a3565b8061597b575050565b615984816157a3565b6001810361599e5760405163f645eedf60e01b8152600490fd5b6159a7816157a3565b600281036159c85760405163fce698f760e01b815260048101839052602490fd5b806159d46003926157a3565b146159dc5750565b602490604051906335e2f38360e21b82526004820152fd5b905f602091828151910182855af115610701575f513d615a4557506001600160a01b0381163b155b615a235750565b604051635274afe760e01b81526001600160a01b039091166004820152602490fd5b60011415615a1c565b615a56614764565b8051908115615a66576020012090565b50507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100548015615a935790565b507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47090565b615ac061484a565b8051908115615ad0576020012090565b50507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d101548015615a935790565b90615b245750805115615b1257805190602001fd5b60405163d6bda27560e01b8152600490fd5b81511580615b57575b615b35575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b15615b2d56fe52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace027d8b90e89a676f7a8a3cf40a0c23c3d2ea61cec6ae800738fbd79bc111b5ea87a2646970667358221220f4c8e311aa69653d1dd124a35e4b8cebbf24ba768da773a65dcf567d9353491e64736f6c63430008190033
Deployed Bytecode
0x6080806040526004361015610012575f80fd5b60e05f35811c91826301d22ccd146141f65750816301e1d114146141de57816306fdde0314614115578163095ea7b3146140ef5781630a1289ad146140b25781630a154161146140955781630c340a24146140635781630d392cd914613fbe5781630d52a7b914613dbf57816317d949fe14613da357816318160ddd14613d7a5781632015ef0114613cff57816323b872dd14613bbf57816326aa101f14613b8757816329272ff614613a765781632b3297f914613a505781632c62fa10146139eb578163313ce567146139d05781633644e515146139b65781633775bdc71461388e578163387e971c146138515781633995c06f1461382e5781633d8ae7c6146137165781633f4ba83a1461363857816343998bdd1461361f57816345e674c71461358a57816346063a521461353157816347b818ba146133af5781634cdad5061461334a5781634f1ef286146131375781634f64b2be146130f657816352d1902d1461307a57816352ed3ed814612fdd57816357d5d52014612fc45781635c975abb14612f835781635d36b19014612eda578163608baa9a14612eaf57816361ec384614612e495781636605bfda14612db45781636696821b14612ce55781636cfd155314612c5057816370a0823114612bfb5781637180c8ca14612b265781637ecebe0014612acf5781637f12dc6014612ab357816381692c0e14611b7b5781638456cb5914611afb57816384b0196e146119cb578163863a7fc11461199d5781639295d4781461196057816395d89b411461186057816398c601aa146115855781639a14f478146113d75781639c79d8dc146113ba5781639c82f2a414611325578163a9059cbb146112f4578163ad3cb1cc146112ab578163b5af090f14611266578163b860f0a11461116d578163b888879e14611147578163b8a723bd1461112a578163ba46ae72146110ce578163bd69bfbb14611033578163c7af335214610fff578163ce1f16c914610f50578163d38bfff414610ecb578163d505accf14610d38578163d6bcfca314610d1a578163db006a7514610b35578163dd62ed3e14610abc578163ddca3f4314610a7c578163df83ffe814610a01578163e5328e0614610887578163e8c67216146107ac57508063e9c459ba1461046c578063f293f14e146103ed5763fa6d102b1461036d575f80fd5b346103e95760203660031901126103e9576103866142d4565b6001600160a01b0381165f525f60205260ff60405f205416156103d7576103c66020916103c05f80516020615b61833981519152546150a3565b906150da565b6001600160401b0360405191168152f35b60405163259ba1ad60e01b8152600490fd5b5f80fd5b346103e9575f3660031901126103e957600d54801561045a575f600d557fd6060418062d03ef3ef2e9cca5d7e94502c0224f1ea338059fa40ecfb8bd121a60206001600160a01b035f80516020615b8183398151915261044e858254615232565b541692604051908152a2005b604051630758561360e51b8152600490fd5b346103e95760a03660031901126103e9576104856142d4565b61048d6142ea565b608435906001600160401b03908183116103e957366023840112156103e95782600401359182116103e95736602483850101116103e9576104cc6153e3565b6001600160a01b0380941692835f526020915f835260ff60405f205416158015610798575b6103d757851694855f525f835260ff60405f205460081c161561078657855f526008835260ff60405f20541615610774575f80516020615b618339815191529061053b82546150a3565b91604051936370a0823160e01b9283865230600487015286866024818d5afa958615610701578a918a915f9861073d575b50915f60c460249b938b969561058960443582600a541684615667565b600a541694806040519e8f98899788956304a0d80360e31b87526004870152828601526044356044860152606435606486015260a060848601528260a486015201848401378181018301849052601f01601f191681010301925af1958615610701575f9661070c575b506105fd90546150a3565b9260405191825230600483015284826024818b5afa918215610701575f926106d0575b5061062e9060643592614b22565b106106be57808210610683575b7ffea7a9a6e25cd0bbbfa80ce0c7646e61ee5e0551b3fdaaff0642e6f6adcc72e260808686898761066a6155c5565b60405193845283015260443560408301526060820152a1005b61069d670de0b6b3a7640000916009969594965490614985565b04116106ac579091848061063b565b604051631393c01360e31b8152600490fd5b60405163712681bd60e01b8152600490fd5b9091508481813d83116106fa575b6106e881836143a2565b810103126103e957519061062e610620565b503d6106de565b6040513d5f823e3d90fd5b9095508481813d8311610736575b61072481836143a2565b810103126103e95751946105fd6105f2565b503d61071a565b9392509650508682813d831161076d575b61075881836143a2565b810103126103e957905194899089905f61056c565b503d61074e565b6040516375d7f9d560e01b8152600490fd5b6040516307c241ad60e51b8152600490fd5b508581165f5260ff60405f205416156104f1565b346103e9575f3660031901126103e9575f60606040516107cb8161436c565b6107d3614e2c565b815282602082015282604082015201526040516107ef8161436c565b60606107f9614e50565b808352600654906001600160401b03908160208601818516815261083a6040880193838760401c1685528789019660801c8752610834614e2c565b50615802565b60405196516001600160801b03968188809351168a528260208201511660208b01528260408201511660408b0152015116606088015251166080860152511660a0840152511660c0820152f35b346103e9575f3660031901126103e95761089f614675565b5f915f906001600160a01b038060035416945b825184101561097a576108c58486614661565b5190826108d28686614661565b516040516334ff2eeb60e01b81529116600482015260209081816024818c5afa918215610701575f92610946575b50509061093861091561093e93600195614985565b61093261092d876109268b8b614661565b5116615136565b614998565b906149a9565b90614b60565b9301926108b2565b9080939250813d8311610973575b61095e81836143a2565b810103126103e9579051610938610915610900565b503d610954565b60408051635054022f60e11b81529190826004818a5afa918215610701576040926109bc915f905f926109c8575b506109b66109329185614985565b91614998565b82519182526020820152f35b6109b6925061093291506109f190863d88116109fa575b6109e981836143a2565b810190614b7b565b929091506109a8565b503d6109df565b346103e95760203660031901126103e9576004356001600160a01b035f80516020615b8183398151915254163303610a6a577f73624d727a5e51dee93a729f945f3dbf8bd3d81e122272d7f4bc9f6381021e4c6040600c548151908152836020820152a1600c55005b60405163070545c960e51b8152600490fd5b346103e9575f3660031901126103e9576060600e54604051906001600160a01b038116825265ffffffffffff8160a01c16602083015260d01c6040820152f35b346103e95760403660031901126103e957610ad56142d4565b6001600160a01b03610b1f610ae86142ea565b926001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160205260405f2090565b91165f52602052602060405f2054604051908152f35b346103e95760203660031901126103e957600435335f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00806020528160405f205410610d0857600e54610b8c8160d01c846152e3565b92610b9f610b9a8583614b22565b614909565b9390928580610cee575b610bb4915083614b22565b903315610cd657335f528060205260405f205490828210610cad579180915f933385526020520360408320555f80516020615b618339815191528181540390556040519081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203392a35f5b8251811015610c735780610c3860019286614661565b51610c44575b01610c22565b610c6e6001600160a01b03610c598387614661565b5116610c658388614661565b51903390615667565b610c3e565b5092610ca87f5db1997bc8fc1e1e4bcea6438a652310893f2756d6138bece7142ac25e9187dd93604051938493339785614dfc565b0390a2005b5060405163391434e360e21b815233600482015260248101919091526044810191909152606490fd5b604051634b637e8f60e11b81525f6004820152602490fd5b6001600160a01b03610d01921633614f76565b8585610ba9565b604051633999656760e01b8152600490fd5b346103e9575f3660031901126103e9576020604051633b9aca008152f35b346103e957806003193601126103e957610d506142d4565b90610d596142ea565b60443591606435906084359060ff821682036103e957824211610eb2576001600160a01b039081871692835f527f5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb0060205260405f20918254926001840190556040519560208701937f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98552866040890152858916606089015289608089015260a088015260c087015260c086528501918583106001600160401b03841117610e9e57610e6195610e5893604052519020610e3161572e565b906040519161190160f01b83526002830152602282015260c43591604260a43592206158e7565b90949194615969565b821603610e745750610e72926156a1565b005b6040516325c0072360e11b81526001600160a01b0391821660048201529084166024820152604490fd5b634e487b7160e01b5f52604160045260245ffd5b60405163313c898160e11b815260048101849052602490fd5b346103e95760203660031901126103e957610ee46142d4565b6001600160a01b03805f80516020615b81833981519152541691823303610a6a57807f0fe544e960ecab9b6f1eee0df869972d09c3c135c0d116422cce176351b522375516907fa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d5f80a3005b346103e95760203660031901126103e957610f6961433b565b6001600160a01b035f80516020615b8183398151915254163303610a6a576001600160401b03808216918215610fed57600654604080516001600160401b0394831685168152929093166020830152917f33e09603bebc108145e6185df188fd486e72ff9fc5e89cd7bf57a5fc1129cd4a91a167ffffffffffffffff191617600655005b604051632a9ffab760e21b8152600490fd5b346103e9575f3660031901126103e95760206001600160a01b035f80516020615b8183398151915254163314604051908152f35b346103e95760203660031901126103e95761104c6144ed565b6001600160a01b035f80516020615b8183398151915254163303610a6a5760065490604051908260801c82527f8b76cd989240b6e717d1437b39a1691ee1629b9c62dea6c5e50024736816847960406001600160801b03938484166020820152a1911660809190911b6fffffffffffffffffffffffffffffffff191617600655005b346103e95760203660031901126103e9576001600160a01b036110ef6142d4565b165f525f602052606060405f20546001600160401b036040519160ff81161515835260ff8160081c161515602084015260101c166040820152f35b346103e9575f3660031901126103e9576020600954604051908152f35b346103e9575f3660031901126103e95760206001600160a01b0360035416604051908152f35b346103e95760203660031901126103e95761118661433b565b6001600160a01b035f80516020615b8183398151915254163303610a6a57610e72907f38016aed2f1b157c3acb51fd6f9f9b07a1f97e2416d4e5bfb90382ef0e1f7a9260406001600160401b0360055460801c9382519485521692836020820152a161124b6111f3614e50565b6111fc81615802565b60406001600160801b039161122c836020830151166001600160801b036004549181199060801b16911617600455565b0151166001600160801b03166001600160801b03196005541617600555565b6001600160801b036005549181199060801b16911617600555565b346103e95760203660031901126103e95760206112a16112846142d4565b6001600160a01b03165f525f60205260ff60405f205460081c1690565b6040519015158152f35b346103e9575f3660031901126103e9576112f06040516112ca81614387565b60058152640352e302e360dc1b60208201526040519182916020835260208301906142b0565b0390f35b346103e95760403660031901126103e95761131a6113106142d4565b6024359033614f76565b602060405160018152f35b346103e95760203660031901126103e95761133e6142d4565b6001600160a01b03805f80516020615b8183398151915254163303610a6a57808216918215610fed57600a54604080516001600160a01b0394831685168152929093166020830152917f8020349d0bc5072c61ea63992108fed8a34a6009921e84089e8a7c89ad03d73f91a16001600160a01b03191617600a55005b346103e9575f3660031901126103e9576020600c54604051908152f35b346103e95760403660031901126103e9576001600160401b036004358181116103e9576114089036906004016143da565b6024359182116103e957366023830112156103e95781600401359161142c836143c3565b9061143a60405192836143a2565b8382526020908183016024819660051b830101913683116103e957602401905b82821061156d575050506001600160a01b03805f80516020615b8183398151915254163303610a6a578351908351820361155b575f5b8281106115085750505090816114b160405194604086526040860190614219565b918483038286015251918281520193915f5b8281106114f2577f5fcdd83f4c41c27a689eeb9536ad69f8d26d47cab9dc5cc76793b7e23a5b261e85870386a1005b83511515865294810194928101926001016114c3565b816115138288614661565b511615610fed576115248186614661565b51151590826115338289614661565b51165f5261155560019283875260405f209060ff801983541691151516179055565b01611490565b60405163512509d360e11b8152600490fd5b813580151581036103e957815290830190830161145a565b346103e95760603660031901126103e9576001600160401b036004358181116103e9576115b69036906004016143da565b6024906024358381116103e9576115d190369060040161444a565b906115da614300565b936115e3615444565b335f52600190602090600160205260ff60405f2054161561184e57611606615481565b835185510361155b576001600160a01b039687811697881561183c57611665975f80516020615b61833981519152541595869461164161505a565b9661166b6001600160801b036116578d8d614b2f565b819f91819d61180557614b60565b1661553a565b156117f357918b9492819694925f975b61171d575b5050505061169793508680611709575b505061585e565b61169f6155c5565b6116a761505a565b901591826116ff575b50506116ee576116e97f6fa8234a2db30e7490b3e314f2d1783c1de3ec2bf7be5f873d2a9d4f7b8bdf3d93604051938493339785614dfc565b0390a3005b6040516216dc7760e31b8152600490fd5b11905086806116b0565b61171691600e541661585e565b8a86611690565b9193958b90819892949698518310156117e857508661173f8361175e93614661565b51166001600160a01b03165f525f60205260ff60405f205460081c1690565b15610786578b61177c82886117748f8390614661565b511692614661565b5190604051916323b872dd60e01b86840152338884015230604484015260649081840152825260a08201828110858211176117d55786959493919286936117c5926040526159f4565b019291908d96949795939761167b565b87634e487b7160e01b5f5260416004525ffd5b969450879550611680565b60405163a74c1c5f60e01b8152600490fd5b60065467ffffffffffffffff60401b61182089831642614b60565b60401b169067ffffffffffffffff60401b191617600655614b60565b604051634e46966960e11b8152600490fd5b60405163015f483560e31b8152600490fd5b346103e9575f3660031901126103e9576040517f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace048054825f6118a18361472c565b92838352602094600191866001821691825f1461193e5750506001146118e4575b50506118d0925003836143a2565b6112f06040519282849384528301906142b0565b8592505f527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa905f915b8583106119265750506118d0935082010185806118c2565b8054838901850152879450869390920191810161190e565b92509350506118d094915060ff191682840152151560051b82010185806118c2565b346103e95760203660031901126103e9576001600160a01b036119816142d4565b165f526008602052602060ff60405f2054166040519015158152f35b346103e95760403660031901126103e95760206119c36119bb6142ea565b600435614d52565b604051908152f35b346103e9575f3660031901126103e9577fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100541580611ad2575b15611a8d57611a11614764565b90611a1a61484a565b604051602081018181106001600160401b03821117610e9e576112f092611a6d916040525f8352611a5f604051968796600f60f81b88528060208901528701906142b0565b9085820360408701526142b0565b904660608501523060808501525f60a085015283820360c0850152614255565b60405162461bcd60e51b815260206004820152601560248201527f4549503731323a20556e696e697469616c697a656400000000000000000000006044820152606490fd5b507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1015415611a04565b346103e9575f3660031901126103e957611b1361519c565b611b1b615444565b611b23615444565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300600160ff198254161790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346103e9576101803660031901126103e9576004356001600160401b0381116103e957611bac90369060040161459d565b6024356001600160401b0381116103e957611bcb90369060040161459d565b611bd3614300565b606435906001600160a01b039081831683036103e9578160843516608435036103e9578160a4351660a435036103e9578160c4351660c435036103e95760e435906001600160801b03821682036103e9576060366101231901126103e95760405195611c3e87614351565b6101243584811681036103e957875265ffffffffffff610144351661014435036103e95761014435602088015265ffffffffffff610164351661016435036103e9576101643560408801527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054956001600160401b0387161580612aa5575b60016001600160401b038916149081612a9b575b159081612a92575b50612a805760016001600160401b03198816177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005560ff8760401c1615612a41575b611d236157c1565b611d2b6157c1565b81516001600160401b038111610e9e57611d657f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace035461472c565b601f8111612985575b50806020601f82116001146128c5575f916128ba575b508160011b915f199060031b1c1916177f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03555b8051906001600160401b038211610e9e578190611df47f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace045461472c565b601f81116127f3575b50602090601f831160011461272e575f92612723575b50508160011b915f199060031b1c1916177f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace04555b611e4f6157c1565b60405190611e5c82614387565b60018252603160f81b6020830152611e726157c1565b8051906001600160401b038211610e9e578190611eaf7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1025461472c565b601f811161265c575b50602090601f8311600114612597575f9261258c575b50508160011b915f199060031b1c1916177fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d102555b8051906001600160401b038211610e9e578190611f3f7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1035461472c565b601f81116124c5575b50602090601f8311600114612400575f926123f5575b50508160011b915f199060031b1c1916177fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d103555b5f7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100555f7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10155611fe06157c1565b5f80516020615b81833981519152556001600160a01b031982608435168160075416176007558260a4351681600a541617600a558284165f52600b60205260405f20600160ff198254161790558260c43516906003541617600355612043614e2c565b506040516120508161436c565b683635c9adc5dea0000080825260208201526001600160801b0342166040820152662386f26fc100006060820152610e10420142116123e15760407f8b76cd989240b6e717d1437b39a1691ee1629b9c62dea6c5e50024736816847994819461220e60ff996121da7fa11b5803b8a35081b8f993e0dee5bc30301a3d83f644e5ab2ff39f972f0a807f966121a46001600160801b0360606001600160401b03610e10420116938c82848d51926121058461436c565b848452610e106020850152888f8501521691015261213c838251166001600160801b03166001600160801b03196004541617600455565b612161836020830151166001600160801b036004549181199060801b16911617600455565b612186838c830151166001600160801b03166001600160801b03196005541617600555565b0151166001600160801b036005549181199060801b16911617600555565b600680546fffffffffffffffffffffffffffffffff191660409290921b67ffffffffffffffff60401b1691909117610e10179055565b600680546001600160801b0316608089901b6fffffffffffffffffffffffffffffffff191617905561010435600c55614e8c565b82519116815260016020820152a181515f81526084356001600160a01b031660208201527f64187bd7b97e66658c91904f3021d7c28de967281d18b1a20742348afdd6a6b390604090a181515f815260a4356001600160a01b031660208201527f8020349d0bc5072c61ea63992108fed8a34a6009921e84089e8a7c89ad03d73f90604090a181515f815260c4356001600160a01b031660208201527f98c01d227e3cc9d2c6f54140e668728d1cb767472f07d012d156af971734459d90604090a16001600160801b038251915f8352166020820152a17f38016aed2f1b157c3acb51fd6f9f9b07a1f97e2416d4e5bfb90382ef0e1f7a92604080515f8152662386f26fc100006020820152a17f73624d727a5e51dee93a729f945f3dbf8bd3d81e122272d7f4bc9f6381021e4c604080515f8152610104356020820152a1670dcef33a6f83800060095560401c161561236457005b68ff0000000000000000197ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b634e487b7160e01b5f52601160045260245ffd5b015190508880611f5e565b92507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1035f527f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b75905f935b601f19841685106124aa576001945083601f19811610612492575b505050811b017fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10355611f92565b01515f1960f88460031b161c19169055888080612465565b8181015183556020948501946001909301929091019061244a565b9091507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1035f52601f830160051c7f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b750160208410612565575b908392915b601f820160051c7f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b750181106125575750611f48565b5f8155849350600101612522565b507f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b7561251d565b015190508980611ece565b92507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1025f527f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d905f935b601f1984168510612641576001945083601f19811610612629575b505050811b017fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10255611f02565b01515f1960f88460031b161c191690558980806125fc565b818101518355602094850194600190930192909101906125e1565b9091507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1025f52601f830160051c7f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d01602084106126fc575b908392915b601f820160051c7f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d0181106126ee5750611eb8565b5f81558493506001016126b9565b507f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d6126b4565b015190508980611e13565b92507f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace045f527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa905f935b601f19841685106127d8576001945083601f198116106127c0575b505050811b017f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0455611e47565b01515f1960f88460031b161c19169055898080612793565b81810151835560209485019460019093019290910190612778565b9091507f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace045f52601f830160051c7f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa0160208410612893575b908392915b601f820160051c7f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa0181106128855750611dfd565b5f8155849350600101612850565b507f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa61284b565b90508301518a611d84565b91507f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace035f527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab05f925b601f198316841061296d576001935082601f19811610612955575b5050811b017f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0355611db7565b8501515f1960f88460031b161c191690558a80612929565b8581015182556020938401936001909201910161290e565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace035f52601f820160051c7f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab00160208310612a1a575b601f820160051c7f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0018110612a0f5750611d6e565b5f81556001016129da565b507f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab06129da565b68ffffffffffffffffff19871668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0055611d1b565b60405163f92ee8a960e01b8152600490fd5b90501589611cd9565b303b159150611cd1565b5060ff8760401c1615611cbd565b346103e9575f3660031901126103e95760206040516127108152f35b346103e95760203660031901126103e9576001600160a01b03612af06142d4565b165f527f5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb00602052602060405f2054604051908152f35b346103e95760403660031901126103e957612b3f6142d4565b612b47614316565b6001600160a01b03805f80516020615b8183398151915254163303610a6a578216918215610fed57825f52600b60205260ff60405f20541682151590151514612be9577fa11b5803b8a35081b8f993e0dee5bc30301a3d83f644e5ab2ff39f972f0a807f925f52600b602052612bcc8260405f209060ff801983541691151516179055565b604080516001600160a01b039290921682529115156020820152a1005b604051633fbc93f360e01b8152600490fd5b346103e95760203660031901126103e95760206119c3612c196142d4565b6001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0060205260405f205490565b346103e95760203660031901126103e957612c696142d4565b6001600160a01b03805f80516020615b8183398151915254163303610a6a57808216918215610fed57600754604080516001600160a01b0394831685168152929093166020830152917f64187bd7b97e66658c91904f3021d7c28de967281d18b1a20742348afdd6a6b391a16001600160a01b03191617600755005b5f3660031901126103e957612cf8615444565b600c548015612da2573403612d9057612d0f615444565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300600160ff198254161790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a134600d55337ffd7ee573b5f0025377dc7fc832e85c1f9a1bf8c0ab7f9ba6fdc741d117b444ed5f80a2005b60405163256c3f0760e21b8152600490fd5b60405163400f6a8760e01b8152600490fd5b346103e95760203660031901126103e957612dcd6142d4565b6001600160a01b03805f80516020615b8183398151915254163303610a6a57808216918215610fed57600e54604080516001600160a01b0394831685168152929093166020830152917f21eb548722a564f6e09f039f7aa858ae94c911910f3823b37af2250eeca4f40391a16001600160a01b03191617600e55005b346103e95760403660031901126103e95760206119c3612e676142d4565b612eaa612e726142ea565b916001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0060205260405f205490565b614d52565b346103e95760403660031901126103e95760243560048110156103e9576119c3602091600435614ce7565b346103e9575f3660031901126103e9576001600160a01b03807f0fe544e960ecab9b6f1eee0df869972d09c3c135c0d116422cce176351b5223754163303612f71573315612f5f575f80516020615b818339815191529033908254167fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a5f80a3339055005b604051638843aaaf60e01b8152600490fd5b604051639ba0305d60e01b8152600490fd5b346103e9575f3660031901126103e957602060ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330054166040519015158152f35b346103e95760206119c3612fd7366144aa565b90614b95565b346103e95760203660031901126103e9576004612ffa81356150a3565b60406001600160a01b0360035416815193848092635054022f60e11b82525afa918215610701575f905f93613056575b508015613044576040926109326109b66109bc9385614985565b60405163068a761760e41b8152600490fd5b905061307291925060403d6040116109fa576109e981836143a2565b91908361302a565b346103e9575f3660031901126103e9576001600160a01b037f000000000000000000000000ee179d2fa78c0c3c57f51888fdb098e83c575b541630036130e45760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b60405163703e46dd60e11b8152600490fd5b346103e95760203660031901126103e9576004356002548110156103e9576001600160a01b03613127602092614554565b9190546040519260031b1c168152f35b60403660031901126103e95761314b6142d4565b6024356001600160401b0381116103e957366023820112156103e95761317b90369060248160040135910161451e565b906001600160a01b03807f000000000000000000000000ee179d2fa78c0c3c57f51888fdb098e83c575b541680301490811561331c575b506130e457805f80516020615b8183398151915254163303610a6a578116906040516352d1902d60e01b8152602081600481865afa5f91816132e8575b5061320d57604051634c9c8ce360e01b815260048101849052602490fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc929192908181036132d05750823b156132b75780546001600160a01b03191682179055604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561329e57505f80836020610e7295519101845af4613298615203565b91615afd565b915050346132a857005b63b398979f60e01b8152600490fd5b604051634c9c8ce360e01b815260048101839052602490fd5b60249060405190632a87526960e21b82526004820152fd5b9091506020813d602011613314575b81613304602093836143a2565b810103126103e9575190856131ef565b3d91506132f7565b9050817f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54161415846131b2565b346103e95760203660031901126103e9576133976133a5600435613380610b9a613379600e5460d01c846152e3565b8093614b22565b604093919351948594606086526060860190614219565b908482036020860152614255565b9060408301520390f35b346103e95760603660031901126103e9576133c86144ed565b6133d0614325565b906044356001600160801b0380821682036103e9576001600160a01b035f80516020615b8183398151915254163303610a6a57610e72936134dc613434613516948461342e815f80516020615b618339815191525499168099615265565b16615409565b9260606001600160401b038094169361344d8542614b60565b1694878260405161345d8161436c565b8381528760208201528860408201520152613491838251166001600160801b03166001600160801b03196004541617600455565b6134b6836020830151166001600160801b036004549181199060801b16911617600455565b612186836040830151166001600160801b03166001600160801b03196005541617600555565b6001600160401b0319600654161760065567ffffffffffffffff60401b6006549160401b169067ffffffffffffffff60401b191617600655565b6001600160801b036006549181199060801b16911617600655565b346103e95760203660031901126103e95760043561354d6153e3565b8015610fed577fa8fcfe631e055407319ebee96860e5a911fdd6af8156501f4c82b4c8bf33b1ed60406009548151908152836020820152a1600955005b346103e95760203660031901126103e9576135a36142d4565b6001600160a01b03805f80516020615b8183398151915254163303610a6a57808216918215610fed57600354604080516001600160a01b0394831685168152929093166020830152917f98c01d227e3cc9d2c6f54140e668728d1cb767472f07d012d156af971734459d91a16001600160a01b03191617600355005b346103e95760406109bc613632366144aa565b90614b2f565b346103e9575f3660031901126103e95761365061519c565b6136586151c5565b600d54806136be575b6136696151c5565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330060ff1981541690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b5f600d557fd6060418062d03ef3ef2e9cca5d7e94502c0224f1ea338059fa40ecfb8bd121a60206001600160a01b035f80516020615b81833981519152613706858254615232565b541692604051908152a280613661565b346103e95760403660031901126103e95761372f6142d4565b613737614325565b906001600160a01b0390815f80516020615b8183398151915254163303610a6a5716908115610fed57815f525f60205260ff60405f205416156103d7576001600160401b0391633b9aca008383161161381c577f67cba15f5a6551b1966bc3ebb577b6d72a3850d34e1d22f95fd8d027e06e746c82610e7294835f525f60205260405f205460101c166137e9604051928392839060209093929360408301946001600160401b03809216845216910152565b0390a15f525f60205260405f209069ffffffffffffffff000082549160101b169069ffffffffffffffff00001916179055565b6040516329fcf74560e11b8152600490fd5b346103e95760203660031901126103e95760206119c361384c6142d4565b6149c7565b346103e95760203660031901126103e9576001600160a01b036138726142d4565b165f526001602052602060ff60405f2054166040519015158152f35b346103e95760403660031901126103e9576138a76142d4565b6138af614316565b6001600160a01b0391825f80516020615b8183398151915254163303610a6a57828116928315610fed5782613922575b507fb8b9e5a88e9294b8e8db65259eca50004f01999ff58204e3ff1473f585d0b7d3925f526008602052612bcc8260405f209060ff801983541691151516179055565b835f525f60205260ff60405f205416156103d757602060249160035416604051928380926334ff2eeb60e01b82528860048301525afa908115610701575f91613984575b501561397257836138df565b6040516382cf5b8f60e01b8152600490fd5b90506020813d6020116139ae575b8161399f602093836143a2565b810103126103e9575184613966565b3d9150613992565b346103e9575f3660031901126103e95760206119c361572e565b346103e9575f3660031901126103e957602060405160128152f35b346103e95760203660031901126103e9576001600160a01b03613a0c6142d4565b165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052613a4060405f2054614909565b906112f060405192839283614288565b346103e9575f3660031901126103e95760206001600160a01b03600a5416604051908152f35b346103e9575f3660031901126103e957600254613a92816143c3565b613a9f60405191826143a2565b818152613aab826143c3565b60209282840191601f1901368337613ad05f80516020615b61833981519152546150a3565b5f5b828110613b4057505050613aff92613ae86145b8565b926020604051958695604087526040870190614219565b918583038287015251918281520192915f5b828110613b2057505050500390f35b83516001600160401b031685528695509381019392810192600101613b11565b80613b68836001600160a01b03613b5b600195999899614554565b90549060031b1c166150da565b6001600160401b03613b7a8388614661565b9116905201939293613ad2565b346103e95760203660031901126103e95760206112a1613ba56142d4565b6001600160a01b03165f525f60205260ff60405f20541690565b346103e95760603660031901126103e957613bd86142d4565b613be06142ea565b60443590613c1e836001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160205260405f2090565b335f5260205260405f2054925f198403613c3d575b61131a9350614f76565b828410613cd9576001600160a01b03811615613cc1573315613ca9578261131a94613c98836001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160205260405f2090565b335f526020520360405f2055613c33565b604051634a1406b160e11b81525f6004820152602490fd5b60405163e602df0560e01b81525f6004820152602490fd5b604051637dc7a0d960e11b81523360048201526024810185905260448101849052606490fd5b346103e95760603660031901126103e957604051613d1c81614351565b6001600160a01b0360043581811681036103e957825265ffffffffffff60243581811681036103e957602084015260443590811681036103e95760408301525f80516020615b8183398151915254163303610a6a57610e7290614e8c565b346103e9575f3660031901126103e95760205f80516020615b6183398151915254604051908152f35b346103e95760203660031901126103e957613a40600435614909565b346103e95760403660031901126103e957613dd86142d4565b613de0614325565b906001600160a01b0390815f80516020615b8183398151915254163303610a6a5781168015610fed57805f526020925f845260ff60405f205416613fac576024848460035416604051928380926334ff2eeb60e01b82528760048301525afa908115610701575f91613f7f575b5015613972576001600160401b03809116633b9aca00811161381c57613eef9160405191613e7a83614351565b60018352613ec98784016001815260408501928352865f525f8952613eb260405f2095511515869060ff801983541691151516179055565b51845461ff00191690151560081b61ff0016178455565b51825469ffffffffffffffff00001916911660101b69ffffffffffffffff000016179055565b60025468010000000000000000811015610e9e577fef81a9943b96c8df4ef243401c9bf5159146166211356898b52d382086168d9293604093613f39836001809501600255614554565b819291549060031b9186831b921b19161790557f158412daecdc1456d01568828bcdb18464cc7f1ce0215ddbc3f3cfede9d1e63d818551858152a18351928352820152a1005b90508481813d8311613fa5575b613f9681836143a2565b810103126103e9575185613e4d565b503d613f8c565b604051633ea7ffd960e11b8152600490fd5b346103e95760403660031901126103e957613fd76142d4565b613fdf614316565b6001600160a01b03805f80516020615b8183398151915254163303610a6a578216918215610fed57825f525f60205260ff60405f205416156103d7577fef81a9943b96c8df4ef243401c9bf5159146166211356898b52d382086168d92925f525f602052612bcc8260405f209061ff00825491151560081b169061ff001916179055565b346103e9575f3660031901126103e95760205f80516020615b81833981519152546001600160a01b0360405191168152f35b346103e9575f3660031901126103e9576020600d54604051908152f35b346103e95760203660031901126103e9576001600160a01b036140d36142d4565b165f52600b602052602060ff60405f2054166040519015158152f35b346103e95760403660031901126103e95761131a61410b6142d4565b60243590336156a1565b346103e9575f3660031901126103e9576040517f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace038054825f6141568361472c565b92838352602094600191866001821691825f1461193e5750506001146141845750506118d0925003836143a2565b8592505f527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0905f915b8583106141c65750506118d0935082010185806118c2565b805483890185015287945086939092019181016141ae565b346103e9575f3660031901126103e957613a40614675565b346103e9575f3660031901126103e9576020906001600160a01b03600754168152f35b9081518082526020808093019301915f5b828110614238575050505090565b83516001600160a01b03168552938101939281019260010161422a565b9081518082526020808093019301915f5b828110614274575050505090565b835185529381019392810192600101614266565b909161429f6142ad93604084526040840190614219565b916020818403910152614255565b90565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b03821682036103e957565b602435906001600160a01b03821682036103e957565b604435906001600160a01b03821682036103e957565b6024359081151582036103e957565b602435906001600160401b03821682036103e957565b600435906001600160401b03821682036103e957565b606081019081106001600160401b03821117610e9e57604052565b608081019081106001600160401b03821117610e9e57604052565b604081019081106001600160401b03821117610e9e57604052565b90601f801991011681019081106001600160401b03821117610e9e57604052565b6001600160401b038111610e9e5760051b60200190565b9080601f830112156103e95760209082356143f4816143c3565b9361440260405195866143a2565b81855260208086019260051b8201019283116103e957602001905b82821061442b575050505090565b81356001600160a01b03811681036103e957815290830190830161441d565b9080601f830112156103e9576020908235614464816143c3565b9361447260405195866143a2565b81855260208086019260051b8201019283116103e957602001905b82821061449b575050505090565b8135815290830190830161448d565b9060406003198301126103e9576001600160401b036004358181116103e957836144d6916004016143da565b926024359182116103e9576142ad9160040161444a565b600435906001600160801b03821682036103e957565b6001600160401b038111610e9e57601f01601f191660200190565b92919261452a82614503565b9161453860405193846143a2565b8294818452818301116103e9578281602093845f960137010152565b6002548110156145895760025f527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace01905f90565b634e487b7160e01b5f52603260045260245ffd5b9080601f830112156103e9578160206142ad9335910161451e565b6040519060025480835282602091602082019060025f527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace935f905b82821061460c5750505061460a925003836143a2565b565b85546001600160a01b0316845260019586019588955093810193909101906145f4565b90614639826143c3565b61464660405191826143a2565b8281528092614657601f19916143c3565b0190602036910137565b80518210156145895760209160051b010190565b61467d6145b8565b9081519161468a8361462f565b925f5b81811061469a5750509190565b6001600160a01b036146ac8285614661565b5116906040805180936370a0823160e01b825230600483015281602460209384935afa91821561472357505f916146f4575b50600192506146ed8288614661565b520161468d565b905082813d831161471c575b61470a81836143a2565b810103126103e957600191515f6146de565b503d614700565b513d5f823e3d90fd5b90600182811c9216801561475a575b602083101461474657565b634e487b7160e01b5f52602260045260245ffd5b91607f169161473b565b604051905f827fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d102918254926147988461472c565b8084529360209160019182811690811561482457506001146147c4575b50505061460a925003836143a2565b5f9081527f42ad5d3e1f2e6e70edcf6d991b8a3023d3fca8047a131592f9edb9fd9b89d57d9590935091905b82841061480c575061460a9450505081016020015f80806147b5565b855488850183015294850194879450928101926147f0565b925050506020925061460a94915060ff191682840152151560051b8201015f80806147b5565b604051905f827fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1039182549261487e8461472c565b8084529360209160019182811690811561482457506001146148a95750505061460a925003836143a2565b5f9081527f5f9ce34815f8e11431c7bb75a8e6886a91478f7ffc1dbb0a98dc240fddd76b759590935091905b8284106148f1575061460a9450505081016020015f80806147b5565b855488850183015294850194879450928101926148d5565b905f80516020615b618339815191525415614973576149266145b8565b80516149318161462f565b935f5b828110614942575050509190565b806149626001600160a01b0361495a60019488614661565b511684614d52565b61496c8289614661565b5201614934565b60405163ed0f386160e01b8152600490fd5b818102929181159184041417156123e157565b60ff16604d81116123e157600a0a90565b81156149b3570490565b634e487b7160e01b5f52601260045260245ffd5b6001600160a01b0390816003541660409081516334ff2eeb60e01b9485825284168060048301526020918281602481875afa908115614ada575f91614af5575b5015614ae45783516370a0823160e01b8152306004820152958287602481855afa968715614ada575f97614aa8575b50906024839286519586938492835260048301525afa92831561472357505f92614a76575b505061092d614a70610932926142ad95614985565b92615136565b90809250813d8311614aa1575b614a8d81836143a2565b810103126103e9575161092d614a70614a5b565b503d614a83565b919096508282813d8311614ad3575b614ac181836143a2565b810103126103e9579051956024614a36565b503d614ab7565b85513d5f823e3d90fd5b835163068a761760e41b8152600490fd5b90508281813d8311614b1b575b614b0c81836143a2565b810103126103e957515f614a07565b503d614b02565b919082039182116123e157565b614b4191614b3c91614b95565b614cba565b90614b5c61337965ffffffffffff600e5460a01c16846152e3565b9190565b919082018092116123e157565b519060ff821682036103e957565b91908260409103126103e9576142ad602083519301614b6d565b9190915f92815181510361155b575f936001600160a01b03918260035416915b8451871015614cb257614be884614bcc8988614661565b51166001600160a01b03165f525f60205260ff60405f20541690565b156103d75783614bf88887614661565b51166040908151916334ff2eeb60e01b83526004918284015260209283816024818a5afa938415614ca8575f94614c78575b50508215614c6b5750506001916109388961093261092d89610926614c5c614c6398614c56878d614661565b51614985565b948d614661565b960195614bb5565b5163068a761760e41b8152fd5b9080929450813d8311614ca1575b614c9081836143a2565b810103126103e95751915f80614c2a565b503d614c86565b82513d5f823e3d90fd5b955050505050565b5f80516020615b61833981519152548015614ce3579081614cdd6142ad936150a3565b9161534b565b5090565b905f80516020615b61833981519152548015614d4d57614d06816150a3565b600180614d1483858861534b565b94614d1e816157a3565b16149182614d36575b50506142ad9250151590614b60565b90809250156149b3576142ad930915155f80614d27565b505090565b906001600160a01b031690815f525f60205260ff60405f205416156103d7575f80516020615b6183398151915254908115614973576020602493604051948580926370a0823160e01b82523060048301525afa908115610701575f91614dc6575b6142ad93508161534b576001915061534b565b90506020833d602011614df4575b81614de1602093836143a2565b810103126103e9576142ad925190614db3565b3d9150614dd4565b926142ad9492614e1e9285526020850152608060408501526080840190614219565b916060818403910152614255565b60405190614e398261436c565b5f6060838281528260208201528260408201520152565b60405190614e5d8261436c565b8160606004546001600160801b0390818116845260801c6020840152600554908116604084015260801c910152565b6001600160a01b039081815116158015614f5f575b8015614f48575b610fed5760405191600e5491818316845265ffffffffffff92838160a01c16602086015260d01c60408501528181511660608501527f053a31509a16e67257fc3e50d5f8f50748f23268d2ff285f6b5893964ea93c4160c06020830195858751166080820152604084019586511660a0820152a151169165ffffffffffff60a01b905160a01b169065ffffffffffff60d01b905160d01b16911717600e55565b5061271065ffffffffffff60408301511611614ea8565b5061271065ffffffffffff60208301511611614ea1565b916001600160a01b03808416928315610cd6571692831561504257825f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace008060205260405f20549183831061500f575091806020927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef94865f5284520360405f2055845f5260405f20818154019055604051908152a3565b60405163391434e360e21b81526001600160a01b0391909116600482015260248101929092525060448101829052606490fd5b60405163ec442f0560e01b81525f6004820152602490fd5b5f80516020615b6183398151915254801561509e5761507a612fd7614675565b90670de0b6b3a7640000918281029281840414901517156123e1576142ad916149a9565b505f90565b5f80516020615b618339815191525480156150d4576150cf6142ad926150ca612fd7614675565b614985565b6149a9565b50505f90565b6150e3906149c7565b90633b9aca00918281029281840414901517156123e157615103916149a9565b6001600160401b0390818111615117571690565b604490604051906306dfcc6560e41b8252604060048301526024820152fd5b60206001600160a01b039160046040518094819363313ce56760e01b8352165afa908115610701575f91615168575090565b90506020813d602011615194575b81615183602093836143a2565b810103126103e9576142ad90614b6d565b3d9150615176565b335f52600b60205260ff60405f205416156151b357565b604051631d77d47760e21b8152600490fd5b60ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005416156151f157565b604051638dfc202b60e01b8152600490fd5b3d1561522d573d9061521482614503565b9161522260405193846143a2565b82523d5f602084013e565b606090565b5f8080936001600160a01b038294165af161524b615203565b501561525357565b604051630ce8f45160e31b8152600490fd5b90808202905f19818409908280831092039180830392146152d657633b9aca0090828211156152c4577f88f2cfb83100cb4e69e7c79c58b316e597157d372fb9787e8e47ce423a2e9c6d940990828211900360f71b910360091c170290565b634e487b715f5260116020526024601cfd5b5050633b9aca0091500490565b90808202905f19818409908280831092039180830392146153405761271090828211156152c4577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e91940990828211900360fc1b910360041c170290565b505061271091500490565b91818302915f19818509938380861095039480860395146153d657848311156153be5790829109815f038216809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b82634e487b715f52156003026011186020526024601cfd5b5050906142ad92506149a9565b6001600160a01b036007541633036153f757565b6040516309478a2f60e31b8152600490fd5b90615412614e2c565b506001600160801b0390816040519361542a8561436c565b168084526020840152814216604084015216606082015290565b60ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300541661546f57565b60405163d93c066560e01b8152600490fd5b5f80516020615b61833981519152548015615537576006546001600160401b0391828260401c1642116154b357505050565b60606154e0615503936154d36001600160801b0394859260801c90615265565b1660055460801c90615409565b613491838251166001600160801b03166001600160801b03196004541617600455565b67ffffffffffffffff60401b61551e60065492831642614b60565b60401b169067ffffffffffffffff60401b191617600655565b50565b604051906155478261436c565b600454916001600160801b039081841692838252602082019460801c85528280600554966155866040860195838a1687528960801c6060820152615802565b51169116908181106155bb5703928284116123e1576001600160801b0319809460801b16176004555116911617600555600190565b5050505050505f90565b6002546155df5f80516020615b61833981519152546150a3565b8015615663575f5b8281106155f357505050565b6155fc81614554565b90615618846001600160a01b03809354600395861b1c166150da565b9161562284614554565b9054911b1c165f525f6020526001600160401b039060409180835f205460101c1691161161565357506001016155e7565b51635253913f60e11b8152600490fd5b5050565b61460a926001600160a01b036040519363a9059cbb60e01b602086015216602484015260448301526044825261569c8261436c565b6159f4565b916001600160a01b03808416928315613cc15716928315613ca9577f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259161571a6020926001600160a01b03165f527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0160205260405f2090565b855f5282528060405f2055604051908152a3565b615736615a4e565b61573e615ab8565b6040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a0815260c081018181106001600160401b03821117610e9e5760405251902090565b600411156157ad57565b634e487b7160e01b5f52602160045260245ffd5b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c16156157f057565b604051631afcd79f60e31b8152600490fd5b6001600160801b0380421691604081019180808451168503168160608401511602918183169283036123e157602081019282845116018281116123e157815190831690831681111561585657505116905252565b929150505252565b6001600160a01b0316908115615042577fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205f925f80516020615b618339815191526158ac828254614b60565b90558484527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00825260408420818154019055604051908152a3565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161595e579160209360809260ff5f9560405194855216868401526040830152606082015282805260015afa15610701575f516001600160a01b0381161561595457905f905f90565b505f906001905f90565b5050505f9160039190565b615972816157a3565b8061597b575050565b615984816157a3565b6001810361599e5760405163f645eedf60e01b8152600490fd5b6159a7816157a3565b600281036159c85760405163fce698f760e01b815260048101839052602490fd5b806159d46003926157a3565b146159dc5750565b602490604051906335e2f38360e21b82526004820152fd5b905f602091828151910182855af115610701575f513d615a4557506001600160a01b0381163b155b615a235750565b604051635274afe760e01b81526001600160a01b039091166004820152602490fd5b60011415615a1c565b615a56614764565b8051908115615a66576020012090565b50507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100548015615a935790565b507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47090565b615ac061484a565b8051908115615ad0576020012090565b50507fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d101548015615a935790565b90615b245750805115615b1257805190602001fd5b60405163d6bda27560e01b8152600490fd5b81511580615b57575b615b35575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b15615b2d56fe52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace027d8b90e89a676f7a8a3cf40a0c23c3d2ea61cec6ae800738fbd79bc111b5ea87a2646970667358221220f4c8e311aa69653d1dd124a35e4b8cebbf24ba768da773a65dcf567d9353491e64736f6c63430008190033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.