Overview
BERA Balance
BERA Value
$0.00More Info
Private Name Tags
ContractCreator
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:
IBGTVault
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 100 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {InfraredCollateralVault, IERC20, PriceLib, SafeERC20} from "./InfraredCollateralVault.sol"; import {IInfraredCollateralVault} from "../../interfaces/core/vaults/IInfraredCollateralVault.sol"; import {IInfraredVault} from "../../interfaces/utils/integrations/IInfraredVault.sol"; import {IIBGTVault} from "../../interfaces/core/vaults/IIBGTVault.sol"; import {IAsset} from "../../interfaces/utils/tokens/IAsset.sol"; import {IRebalancer} from "../../interfaces/utils/integrations/IRebalancer.sol"; contract IBGTVault is InfraredCollateralVault { using SafeERC20 for IERC20; using PriceLib for uint; // keccak256(abi.encode(uint(keccak256("openzeppelin.storage.IBGTCollVault")) - 1)) & ~bytes32(uint(0xff)) bytes32 private constant IBGTCollVaultStorageLocation = 0x7c295a6235a8870762eedf177b0c47538f1234d5dd210c9bdc5ca11b722c7c00; function _getIBGTCollVaultStorage() internal pure returns (IIBGTVault.IBGTVaultStorage storage store) { assembly { store.slot := IBGTCollVaultStorageLocation } } modifier onlyKeeperOrOwner() { require( _getIBGTCollVaultStorage().keeper == msg.sender || getMetaBeraborrowCore().owner() == msg.sender, "Not owner nor keeper" ); _; } /// @dev Token out or received currency will always be the asset of the vault function rebalance(IInfraredCollateralVault.RebalanceParams calldata p) external override onlyKeeperOrOwner harvestRewards { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); uint sentPrice = getPrice(p.sentCurrency); uint receivedPrice = getPrice(asset()); uint8 sentDecimals = IAsset(p.sentCurrency).decimals(); uint sentCurrencyBalance = IAsset(p.sentCurrency).balanceOf(address(this)); uint receivedCurrencyBalance = IAsset(asset()).balanceOf(address(this)); // Perform the swap using the swapper contract IERC20(p.sentCurrency).safeTransfer(p.swapper, p.sentAmount); IRebalancer(p.swapper).swap( p.sentCurrency, p.sentAmount, asset(), p.payload ); uint received = IAsset(asset()).balanceOf(address(this)) - receivedCurrencyBalance; uint sent = sentCurrencyBalance - IAsset(p.sentCurrency).balanceOf(address(this)); // if we were to rebalance locked emissions, a possible revert on subsequent `$.balanceOf` calls would occur if (sent > getBalance(p.sentCurrency)) revert WithdrawingLockedEmissions(); // if threshold isn't set, it will be 0, not tolerating any slippage require(_getBalanceData().emissionSchedule[asset()]._unlockRatePerSecond != 0, "CollVault: asset needs a defined unlockRatePerSecond"); uint receivedValue = received.convertToValue(receivedPrice, assetDecimals()); uint sentValue = sent.convertToValue(sentPrice, sentDecimals); // if threshold isn't set, it will be 0, not tolerating any slippage require(receivedValue >= sentValue * (BP - $.threshold[p.sentCurrency]) / BP, "CollVault: received amount is below threshold"); _decreaseBalance(p.sentCurrency, sent); _increaseBalance(asset(), received); _afterVaultRebalance(received); emit Rebalance(p.sentCurrency, sent, received, sentValue, receivedValue); } /** * @return tokens Only includes tokens that are virtually accounted as rewardedTokens * @return amounts Array of amounts per token after performance fee */ function previewHarvestRewards() external view returns (address[] memory tokens, uint[] memory amounts) { IInfraredVault iVault = infraredVault(); tokens = iVault.getAllRewardTokens(); amounts = new uint[](tokens.length); uint _performanceFee = getPerformanceFee(); address _iRedToken = iRedToken(); address _ibgt = ibgt(); IIBGTVault _ibgtVault = IIBGTVault(ibgtVault()); for (uint i; i < tokens.length; i++) { address _token = tokens[i]; uint rewards = iVault.earned(address(this), tokens[i]); if (rewards == 0) continue; bool isIBGT = _token == _ibgt; if (isIBGT && _hasPriceFeed(_ibgt)) { rewards = _ibgtVault.previewDeposit(rewards); _token = isIBGT ? address(_ibgtVault) : _token; } if (_hasPriceFeed(_token) && _token != _iRedToken && !_isCollVault(_token)) { uint fee = rewards * _performanceFee / BP; uint netRewards = rewards - fee; amounts[i] = netRewards; } } } function setKeeper(address _keeper) external onlyOwner { _getIBGTCollVaultStorage().keeper = _keeper; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {BaseCollateralVault, ERC4626Upgradeable} from "./BaseCollateralVault.sol"; import {PriceLib} from "../../libraries/PriceLib.sol"; import {IDenManager} from "../../interfaces/core/IDenManager.sol"; import {IInfraredWrapper} from "../../interfaces/core/vaults/IInfraredWrapper.sol"; import {IPriceFeed} from "../../interfaces/core/IPriceFeed.sol"; import {IInfraredCollateralVault} from "../../interfaces/core/vaults/IInfraredCollateralVault.sol"; import {IRebalancer} from "../../interfaces/utils/integrations/IRebalancer.sol"; import {IAsset} from "../../interfaces/utils/tokens/IAsset.sol"; import {IIBGTVault} from "../../interfaces/core/vaults/IIBGTVault.sol"; import {IInfraredVault} from "../../interfaces/utils/integrations/IInfraredVault.sol"; import {FeeLib} from "../../libraries/FeeLib.sol"; import {EmissionsLib} from "src/libraries/EmissionsLib.sol"; /** * @title Beraborrow Infrared Collateral Vault * @notice Supercharges DenManager with PoL */ abstract contract InfraredCollateralVault is BaseCollateralVault { using Math for uint; using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; using EmissionsLib for EmissionsLib.BalanceData; using EmissionsLib for EmissionsLib.EmissionSchedule; using PriceLib for uint; using FeeLib for uint; uint internal constant WAD = 1e18; error WithdrawingLockedEmissions(); // keccak256(abi.encode(uint(keccak256("openzeppelin.storage.InfraredCollateralVault")) - 1)) & ~bytes32(uint(0xff)) bytes32 private constant InfraredCollateralVaultStorageLocation = 0xf6a35052099d23fafed8c58b549933969c057c5a9a13ac5133024adc8dd4f200; event Rebalance(address indexed sentCurrency, uint sent, uint received, uint sentValue, uint receivedValue); event PerformanceFee(address indexed token, uint amount); function _getInfraredCollVaultStorage() internal pure returns (IInfraredCollateralVault.InfraredCollVaultStorage storage store) { assembly { store.slot := InfraredCollateralVaultStorageLocation } } function __InfraredCollateralVault_init(IInfraredCollateralVault.InfraredInitParams calldata params) internal onlyInitializing { __InfraredCollateralVault_init_unchained(params); } function __InfraredCollateralVault_init_unchained(IInfraredCollateralVault.InfraredInitParams calldata params) internal onlyInitializing { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); if (params._iRedToken == address(0) || address(params._infraredVault) == address(0) || params._ibgtVault == address(0)) { revert("CollVault: 0 address"); } IERC20 _asset = params._baseParams._asset; require(params._minPerformanceFee <= params._maxPerformanceFee && params._maxPerformanceFee <= BP, "CollVault: Incorrect min/max performance fee"); require(params._performanceFee >= params._minPerformanceFee && params._performanceFee <= params._maxPerformanceFee, "CollVault: performance fee out of bounds"); bool infraredWrapped = params._infraredWrapper != address(0); address stakingToken = params._infraredVault.stakingToken(); require(infraredWrapped ? stakingToken == params._infraredWrapper : stakingToken == address(_asset), "CollVault: stakingToken mismatch"); require(!infraredWrapped || IInfraredWrapper(params._infraredWrapper).infraredCollVault() == address(this), "CollVault: InfraredWrapper mismatch"); $.minPerformanceFee = params._minPerformanceFee; $.maxPerformanceFee = params._maxPerformanceFee; $.performanceFee = params._performanceFee; $.iRedToken = params._iRedToken; // this set assumes that the iRedToken is a reward token in all InfraredVaults, which may not be the case $._infraredVault = params._infraredVault; $.ibgtVault = params._ibgtVault; $.infraredWrapper = IInfraredWrapper(params._infraredWrapper); __BaseCollateralVault_init(params._baseParams); $.ibgt = address(this) == params._ibgtVault ? address(_asset) : IIBGTVault(params._ibgtVault).asset(); } // Compound iBGT rewards /// @dev Since we are not accepting donations, we won't `stake` ibgt.balanceOf(this) function _harvestRewards() internal override { if (block.timestamp == _getInfraredCollVaultStorage().lastUpdate) return; IInfraredVault iVault = infraredVault(); address[] memory tokens = iVault.getAllRewardTokens(); uint[] memory prevBalances = new uint[](tokens.length); for (uint i; i < tokens.length; i++) { prevBalances[i] = IERC20(tokens[i]).balanceOf(address(this)); } // harvest rewards iVault.getReward(); uint _performanceFee = getPerformanceFee(); address _iRedToken = iRedToken(); address _ibgt = ibgt(); IIBGTVault _ibgtVault = IIBGTVault(ibgtVault()); // re-stake iBGT, take performance fee and update accounting for (uint i; i < tokens.length; i++) { address _token = tokens[i]; uint newBalance = IERC20(_token).balanceOf(address(this)); uint rewards = newBalance - prevBalances[i]; if (rewards == 0) continue; /// @dev Skip if no rewards, saves from iVault revert 'Cannot stake 0' (rewards, _token) = _autoCompoundHook(_token, _ibgt, _ibgtVault, rewards); // Meanwhile the token doesn't has an oracle mapped, it will be processed as a donation // This will avoid returns meanwhile a newly Infrared pushed reward token is not mapped if (_hasPriceFeed(_token) && _token != _iRedToken && !_isCollVault(_token)) { uint fee = rewards * _performanceFee / BP; uint netRewards = rewards - fee; if (_token == asset()) { _stake(netRewards); } _increaseBalance(_token, netRewards); // First time the oracle happens to be mapped, we add the token to the rewardedTokens // If token has no oracle map this won't be called, hence not DOS the vault at `totalAssets` _addRewardedToken(_token); // won't add duplicates if (fee != 0) { IERC20(_token).safeTransfer(getMetaBeraborrowCore().feeReceiver(), fee); emit PerformanceFee(_token, fee); } } } _getInfraredCollVaultStorage().lastUpdate = uint96(block.timestamp); } /** @dev See {IERC4626-totalAssets}. */ /// @notice Returns the total assets in the vault, denominated in the asset of the vault /// @dev Virtual accounting to avoid donations, asset valued denomination, returned in WAD /// @dev Not yet harvested rewards not yet added due to possible temporal overestimation due to rewards being donated through `getRewardForUser` function totalAssets() public view override virtual returns (uint amountInAsset) { // UsdValue is scaled to 1e18, since `getPrice` returns a WAD scaled price uint usdValue; address[] memory _rewardedTokens = rewardedTokens(); uint rewardedTokensLength = _rewardedTokens.length; uint assetPrice = getPrice(asset()); uint assetBalance = _isRewardedToken(asset()) ? 0 : getBalance(asset()); for (uint i; i < rewardedTokensLength; i++) { usdValue += _convertToValue(_rewardedTokens[i]); } amountInAsset = usdValue.mulDiv(10 ** assetDecimals(), assetPrice) + assetBalance; } function _previewRedeem(uint shares) internal view override returns (uint, uint) { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); bool isInternalRedemption = address(this) == $.ibgtVault && getPriceFeed().isCollVault(msg.sender); uint shareFee = isInternalRedemption ? 0 : shares.feeOnRaw(getWithdrawFee()); uint assets = ERC4626Upgradeable.previewRedeem(shares - shareFee); return (assets, shareFee); } /// @dev Token out or received currency will always be the asset of the vault function rebalance(IInfraredCollateralVault.RebalanceParams calldata p) external virtual onlyOwner { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); uint sentPrice = getPrice(p.sentCurrency); uint receivedPrice = getPrice(asset()); uint8 sentDecimals = IAsset(p.sentCurrency).decimals(); uint sentCurrencyBalance = IAsset(p.sentCurrency).balanceOf(address(this)); uint receivedCurrencyBalance = IAsset(asset()).balanceOf(address(this)); // Perform the swap using the swapper contract IERC20(p.sentCurrency).safeTransfer(p.swapper, p.sentAmount); IRebalancer(p.swapper).swap( p.sentCurrency, p.sentAmount, asset(), p.payload ); uint received = IAsset(asset()).balanceOf(address(this)) - receivedCurrencyBalance; uint sent = sentCurrencyBalance - IAsset(p.sentCurrency).balanceOf(address(this)); // if we were to rebalance locked emissions, a possible revert on subsequent `$.balanceOf` calls would occur if (sent > getBalance(p.sentCurrency)) revert WithdrawingLockedEmissions(); uint receivedValue = received.convertToValue(receivedPrice, assetDecimals()); uint sentValue = sent.convertToValue(sentPrice, sentDecimals); // if threshold isn't set, it will be 0, not tolerating any slippage require(receivedValue >= sentValue * (BP - $.threshold[p.sentCurrency]) / BP, "CollVault: received amount is below threshold"); _decreaseBalance(p.sentCurrency, sent); _increaseBalance(asset(), received); _afterVaultRebalance(received); emit Rebalance(p.sentCurrency, sent, received, sentValue, receivedValue); } function setUnlockRatePerSecond(address token, uint64 _unlockRatePerSecond) external onlyOwner { _getBalanceData().setUnlockRatePerSecond(token, _unlockRatePerSecond); } /// @notice Creates a linear vesting for certain tokens donated to this vault /// @dev Make sure to call `setUnlockRatePerSecond` before calling this function for each token, default one is too low for this purpose function internalizeDonations(address[] memory tokens, uint128[] memory amounts) external virtual onlyOwner { uint tokensLength = tokens.length; require(tokensLength == amounts.length, "CollVault: tokens and amounts length mismatch"); address _ibgt = ibgt(); IIBGTVault _ibgtVault = IIBGTVault(ibgtVault()); uint _performanceFee = getPerformanceFee(); for (uint i; i < tokensLength; i++) { address token = tokens[i]; uint amount = amounts[i]; if (amount == 0) continue; // asset is staked in infraredVault, not in address(this) uint donatedAmount = token != asset() ? IERC20(token).balanceOf(address(this)) - getBalanceOfWithFutureEmissions(token) : IAsset(asset()).balanceOf(address(this)); require(donatedAmount >= amount, "CollVault: insufficient balance"); (amount, token) = _autoCompoundHook(token, _ibgt, _ibgtVault, amount); require(_isRewardedToken(token), "CollVault: token not rewarded"); uint fee = amount * _performanceFee / BP; uint netAmounts = amount - fee; if (token == asset()) { _stake(netAmounts); } if (fee != 0) { IERC20(token).safeTransfer(getMetaBeraborrowCore().feeReceiver(), fee); } _getBalanceData().addEmissions(token, uint128(netAmounts)); } } /// @dev Harvests rewards to don't have previously accrued but still not harvested rewards processed with the new fee function setPerformanceFee(uint16 _performanceFee) external virtual onlyOwner harvestRewards { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); require(_performanceFee >= $.minPerformanceFee && _performanceFee <= $.maxPerformanceFee, "CollVault: performance fee out of bounds"); $.performanceFee = _performanceFee; } function setPairThreshold(address tokenIn, uint thresholdInBP) external virtual onlyOwner { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); require(thresholdInBP <= BP, "CollVault: threshold > BP"); $.threshold[tokenIn] = thresholdInBP; } function setIRED(address _iRedToken) external virtual onlyOwner { _getInfraredCollVaultStorage().iRedToken = _iRedToken; } function _increaseBalance(address token, uint amount) internal override { _getBalanceData().balance[token] += amount; } function _decreaseBalance(address token, uint amount) internal override { _getBalanceData().balance[token] -= amount; } /* Getters */ /// @dev Doesn't include vesting amount, same as `getTokenVirtualBalance` in LSPGetters function getBalance(address token) public view override returns (uint) { return _getBalanceData().balanceOf(token); } /// @dev Includes vesting amount function getBalanceOfWithFutureEmissions(address token) public view virtual returns (uint) { return _getBalanceData().balance[token]; } /// @dev Returns the locked emissions function getLockedEmissions(address token) public view returns (uint) { EmissionsLib.EmissionSchedule memory schedule = _getBalanceData().emissionSchedule[token]; uint fullUnlockTimestamp = schedule.unlockTimestamp(); return schedule.lockedEmissions(fullUnlockTimestamp); } function unlockRatePerSecond(address token) external view virtual returns (uint) { EmissionsLib.EmissionSchedule memory schedule = _getBalanceData().emissionSchedule[token]; return schedule.unlockRatePerSecond(); } function getFullProfitUnlockTimestamp(address token) external view returns (uint) { EmissionsLib.EmissionSchedule memory schedule = _getBalanceData().emissionSchedule[token]; return schedule.unlockTimestamp(); } function getPerformanceFee() public view virtual returns (uint16) { return _getInfraredCollVaultStorage().performanceFee; } /// @dev Returns tokens that has been rewarded at some point by the infrared vault function rewardedTokens() public view virtual returns (address[] memory) { return _getInfraredCollVaultStorage().rewardedTokens.values(); } function _isRewardedToken(address token) internal view virtual returns (bool) { return _getInfraredCollVaultStorage().rewardedTokens.contains(token); } function _addRewardedToken(address token) internal virtual { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); $.rewardedTokens.add(token); } function iRedToken() public view virtual returns (address) { return _getInfraredCollVaultStorage().iRedToken; } function infraredVault() public view virtual returns (IInfraredVault) { return _getInfraredCollVaultStorage()._infraredVault; } function ibgt() public view virtual returns (address) { return _getInfraredCollVaultStorage().ibgt; } function ibgtVault() public view virtual returns (address) { return _getInfraredCollVaultStorage().ibgtVault; } function _stake(uint amount) internal override { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); IInfraredVault iVault = $._infraredVault; IInfraredWrapper infraredWrapper = $.infraredWrapper; address stakingToken; if (address(infraredWrapper) != address(0)) { IERC20(asset()).safeApprove(address(infraredWrapper), amount); infraredWrapper.depositFor(address(this), amount); stakingToken = address(infraredWrapper); } else { stakingToken = asset(); } IERC20(stakingToken).safeIncreaseAllowance(address(iVault), amount); iVault.stake(amount); } function _unstake(uint amount) internal override { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); IInfraredWrapper infraredWrapper = $.infraredWrapper; $._infraredVault.withdraw(amount); if (address(infraredWrapper) != address(0)) { infraredWrapper.withdrawTo(address(this), amount); } } /// @dev Rewards the rest of the rewarded tokens (not the asset) to the receiver function _withdrawExtraRewardedTokens( address receiver, uint shares, uint _totalSupply ) internal override virtual { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); address[] memory tokens = rewardedTokens(); uint tokensLength = tokens.length; address _ibgtVault = $.ibgtVault; for (uint i; i < tokensLength; i++) { address token = tokens[i]; // if token is the asset, go next token since has already been transferred if (token == asset()) { continue; } uint amount = shares.mulDiv(getBalance(token), _totalSupply, Math.Rounding.Down); if (amount == 0) continue; _decreaseBalance(token, amount); if (token == _ibgtVault && _ibgtVault != address(this)) { IInfraredCollateralVault(token).redeem(amount, receiver, address(this)); } else { IERC20(token).safeTransfer(receiver, amount); } } } function _hasPriceFeed(address token) internal view virtual returns (bool) { IPriceFeed priceFeed = getPriceFeed(); (address oracle,,,,) = priceFeed.oracleRecords(token); IPriceFeed.FeedType memory feedInfo = priceFeed.feedType(token); return oracle != address(0) || feedInfo.isCollVault || feedInfo.spotOracle != address(0); } function _convertToValue(address token) public view virtual returns (uint) { uint currentBalance = getBalance(token); uint price = getPrice(token); uint8 _decimals = IAsset(token).decimals(); return currentBalance.convertToValue(price, _decimals); } /** * @dev Hook that is called to check if the token is a collateral vault * @dev Prevents recursion DOS attacks by preventing the vault from being a reward token * Only collateral vault permitted is iBGTVault */ function _isCollVault(address token) internal view virtual returns (bool) { IInfraredCollateralVault.InfraredCollVaultStorage storage $ = _getInfraredCollVaultStorage(); // iBGTVault is the only collateral vault permitted, unless it is the current vault if (token == $.ibgtVault && $.ibgtVault != address(this)) { return false; } return getPriceFeed().isCollVault(token); } function _autoCompoundHook(address _token, address /*_ibgt*/, IIBGTVault /*_ibgtVault*/, uint _rewards) internal virtual returns (uint, address) { return (_rewards, _token); } /** * @dev Hook that is called after the vault has been rebalanced * Meant to be used by the child contract to stake the `asset()` in the infrared vault */ function _afterVaultRebalance(uint amount) internal virtual { _stake(amount); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {IBaseCollateralVault} from "./IBaseCollateralVault.sol"; import {IInfraredWrapper} from "./IInfraredWrapper.sol"; import {IDenManager} from "../IDenManager.sol"; import {IBeraborrowCore} from "../IBeraborrowCore.sol"; import {IInfraredVault} from "../../utils/integrations/IInfraredVault.sol"; import {EmissionsLib} from "src/libraries/EmissionsLib.sol"; interface IInfraredCollateralVault is IBaseCollateralVault { struct InfraredCollVaultStorage { uint16 minPerformanceFee; uint16 maxPerformanceFee; uint16 performanceFee; // over yield, in basis points address iRedToken; /// @dev We currently don't know the infraredVault implementation, but if it were to be possible for them to remove tokens from the rewardTokens /// There would be no need to remove it from here since the amounts should continue being accounted for in the virtual balance EnumerableSet.AddressSet rewardedTokens; IInfraredVault _infraredVault; address ibgtVault; address ibgt; IInfraredWrapper infraredWrapper; uint96 lastUpdate; mapping(address tokenIn => uint) threshold; } struct InfraredInitParams { BaseInitParams _baseParams; uint16 _minPerformanceFee; uint16 _maxPerformanceFee; uint16 _performanceFee; // over yield, in basis points address _iRedToken; IInfraredVault _infraredVault; address _ibgtVault; address _infraredWrapper; } struct RebalanceParams { address sentCurrency; uint sentAmount; address swapper; bytes payload; } function rebalance(RebalanceParams calldata p) external; function setUnlockRatePerSecond(address token, uint64 _unlockRatePerSecond) external; function internalizeDonations(address[] memory tokens, uint128[] memory amounts) external; function setPairThreshold(address tokenIn, uint thresholdInBP) external; function setPerformanceFee(uint16 _performanceFee) external; function setWithdrawFee(uint16 _withdrawFee) external; function getBalance(address token) external view returns (uint); function getBalanceOfWithFutureEmissions(address token) external view returns (uint); function getFullProfitUnlockTimestamp(address token) external view returns (uint); function unlockRatePerSecond(address token) external view returns (uint); function getLockedEmissions(address token) external view returns (uint); function getPerformanceFee() external view returns (uint16); function rewardedTokens() external view returns (address[] memory); function iRedToken() external view returns (address); function infraredVault() external view returns (IInfraredVault); function ibgt() external view returns (address); function ibgtVault() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; interface IInfraredVault { function stakingToken() external view returns (address); function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function getRewardForUser(address account) external; function rewardTokens(uint) external view returns (address); function getAllRewardTokens() external view returns (address[] memory); function earned(address account, address _rewardsToken) external view returns (uint256); function registerVault(address stakingToken) external returns (address); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {IInfraredCollateralVault} from "./IInfraredCollateralVault.sol"; import {IInfraredVault} from "../../utils/integrations/IInfraredVault.sol"; interface IIBGTVault is IInfraredCollateralVault { struct IBGTVaultStorage { address keeper; } function initialize(IInfraredCollateralVault.InfraredInitParams calldata baseParams /*, InitParams calldata ibgtParams */) external; function setInfraredVault(address _infraredVault) external; function upgradeToAndCall(address newImplementation, bytes calldata data) external; function setKeeper(address _keeper) external; function previewHarvestRewards() external view returns (address[] memory tokens, uint[] memory amounts); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; interface IAsset is IERC20 { function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; interface IRebalancer { function swap( address sentCurrency, uint sentAmount, address receivedCurrency, bytes calldata payload ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * 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; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { 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 log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {ERC4626Upgradeable, ERC20Upgradeable, IERC20, Math, SafeERC20} from "@openzeppelin-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol"; import {IBaseCollateralVault, IERC4626} from "../../interfaces/core/vaults/IBaseCollateralVault.sol"; import {IMetaBeraborrowCore} from "../../interfaces/core/IMetaBeraborrowCore.sol"; import {IPriceFeed} from "../../interfaces/core/IPriceFeed.sol"; import {IAsset} from "../../interfaces/utils/tokens/IAsset.sol"; import {FeeLib} from "../../libraries/FeeLib.sol"; import {EmissionsLib} from "../../libraries/EmissionsLib.sol"; abstract contract BaseCollateralVault is ERC4626Upgradeable, UUPSUpgradeable, IBaseCollateralVault { using Math for uint; using SafeERC20 for IERC20; using FeeLib for uint; uint internal constant BP = 1e4; // keccak256(abi.encode(uint(keccak256("openzeppelin.storage.BaseCollateralVault")) - 1)) & ~bytes32(uint(0xff)) bytes32 private constant BaseCollateralVaultStorageLocation = 0x19001df2d131e9aa1479f4ce661ae121445caf0662dea1e41907028a6da6fe00; function _getBaseCollVaultStorage() internal pure returns (BaseCollVaultStorage storage store) { assembly { store.slot := BaseCollateralVaultStorageLocation } } constructor() { _disableInitializers(); } function __BaseCollateralVault_init(BaseInitParams calldata params) internal onlyInitializing { __BaseCollateralVault_init_unchained(params); } function __BaseCollateralVault_init_unchained(BaseInitParams calldata params) internal onlyInitializing { BaseCollVaultStorage storage $ = _getBaseCollVaultStorage(); if (address(params._metaBeraborrowCore) == address(0) || address(params._asset) == address(0)) { revert("CollVault: 0 address"); } _requireAssetFeed(params._metaBeraborrowCore, address(params._asset)); require(params._withdrawFee >= params._minWithdrawFee && params._withdrawFee <= params._maxWithdrawFee, "CollVault: withdraw fee out of bounds"); $.minWithdrawFee = params._minWithdrawFee; $.maxWithdrawFee = params._maxWithdrawFee; $.withdrawFee = params._withdrawFee; uint8 _assetDecimals = IAsset(address(params._asset)).decimals(); if (_assetDecimals > 18) { revert("CollVault: asset decimals > 18"); } $.assetDecimals = _assetDecimals; $._metaBeraborrowCore = params._metaBeraborrowCore; __ERC20_init(params._sharesName, params._sharesSymbol); __ERC4626_init(params._asset); } function _requireAssetFeed(IMetaBeraborrowCore _metaBeraborrowCore, address asset) internal virtual { IPriceFeed priceFeed = IPriceFeed(_metaBeraborrowCore.priceFeed()); require(priceFeed.fetchPrice(asset) != 0, "CollVault: asset price feed not set up"); } modifier onlyOwner { _onlyOwner(); _; } modifier harvestRewards() { _harvestRewards(); _; } function _onlyOwner() private view { // Owner is beacon variable MetaBeraborrowCore::owner() require(msg.sender == getMetaBeraborrowCore().owner(), "CollVault: caller is not the owner"); } function _authorizeUpgrade(address newImplementation) internal override virtual onlyOwner {} /** @dev See {IERC4626-totalAssets}. */ /// @notice Returns the total assets in the vault, denominated in the asset of the vault /// @dev Virtual accounting to avoid donations, asset valued denomination, returned in asset decimals function totalAssets() public view override(ERC4626Upgradeable, IBaseCollateralVault) virtual returns (uint) { return getBalance(asset()); } /// @dev Called by DenManager, returns the share usd value in WAD /// @dev Fees are not accounted to downprice the share value for redeemCollateral, /// for borrowing, MCR will account for this downprice function fetchPrice() public view virtual returns (uint) { uint _totalSupply = totalSupply(); if (_totalSupply == 0) return 0; return (totalAssets() * 10 ** _decimalsOffset()).mulDiv(getPrice(asset()), _totalSupply); } /// @dev Note, validate this implementation if inherited by multi asset vault (InfraredCollateralVault) function _decimalsOffset() internal view override virtual returns (uint8) { return 18 - assetDecimals(); } function deposit( uint assets, address receiver ) public override(ERC4626Upgradeable, IERC4626) harvestRewards returns (uint shares) { shares = super.deposit(assets, receiver); _stake(assets); _increaseBalance(asset(), assets); } function mint( uint shares, address receiver ) public override(ERC4626Upgradeable, IERC4626) harvestRewards returns (uint assets) { assets = super.mint(shares, receiver); _stake(assets); _increaseBalance(asset(), assets); } function withdraw( uint assets, address receiver, address _owner ) public override(ERC4626Upgradeable, IERC4626) harvestRewards returns (uint shares) { uint _totalSupply = totalSupply(); // cached to don't account for the burn { // scope to avoid stack too deep error uint256 maxAssets = maxWithdraw(_owner); if (assets > maxAssets) { revert ERC4626ExceededMaxWithdraw(_owner, assets, maxAssets); } } uint shareFee; (shares, shareFee) = _previewWithdraw(assets); (uint assetAmount, uint netShares) = _applyShareFee(shares, _totalSupply, shareFee); if (assetAmount != 0) { _unstake(assetAmount); _decreaseBalance(asset(), assetAmount); } _withdraw(msg.sender, receiver, _owner, assetAmount, shares); _withdrawExtraRewardedTokens(receiver, netShares, _totalSupply); } /// @dev Decompounded redeem() function to reuse `previewRedeem()` on `infrared.withdraw` function redeem( uint shares, address receiver, address _owner ) public override(ERC4626Upgradeable, IERC4626) harvestRewards returns (uint assets) { uint _totalSupply = totalSupply(); // cached to don't account for the burn { // scope to avoid stack too deep error uint256 maxShares = maxRedeem(_owner); if (shares > maxShares) { revert ERC4626ExceededMaxRedeem(_owner, shares, maxShares); } } uint shareFee; (assets, shareFee) = _previewRedeem(shares); (uint assetAmount, uint netShares) = _applyShareFee(shares, _totalSupply, shareFee); if (assetAmount != 0) { _unstake(assetAmount); _decreaseBalance(asset(), assetAmount); } _withdraw(msg.sender, receiver, _owner, assetAmount, shares); _withdrawExtraRewardedTokens(receiver, netShares, _totalSupply); } function _applyShareFee(uint shares, uint _totalSupply, uint fee) internal virtual returns (uint, uint) { BaseCollVaultStorage storage $ = _getBaseCollVaultStorage(); uint netShares = shares - fee; uint assetAmount = netShares.mulDiv(getBalance(asset()), _totalSupply, Math.Rounding.Down); address feeReceiver = $._metaBeraborrowCore.feeReceiver(); if (fee != 0) { _mint(feeReceiver, fee); } return (assetAmount, netShares); } /// @dev Preview adding an exit fee on withdraw. See {IERC4626-previewWithdraw}. function previewWithdraw( uint assets ) public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint) { (uint totalShares,) = _previewWithdraw(assets); return totalShares; } function _previewWithdraw(uint assets) internal view virtual returns (uint, uint) { BaseCollVaultStorage storage $ = _getBaseCollVaultStorage(); uint netShares = super.previewWithdraw(assets); uint totalShares = netShares.mulDiv(BP, BP - $.withdrawFee, Math.Rounding.Up); uint shareFee = totalShares - netShares; return (totalShares, shareFee); } /// @dev Preview taking an exit fee on redeem. See {IERC4626-previewRedeem}. function previewRedeem( uint shares ) public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint) { (uint assets,) = _previewRedeem(shares); return assets; } function _previewRedeem(uint shares) internal view virtual returns (uint, uint) { BaseCollVaultStorage storage $ = _getBaseCollVaultStorage(); uint shareFee = shares.feeOnRaw($.withdrawFee); uint assets = super.previewRedeem(shares - shareFee); return (assets, shareFee); } /** @dev See {IERC4626-maxWithdraw}. */ function maxWithdraw(address _owner) public view override(ERC4626Upgradeable, IERC4626) returns (uint) { return previewRedeem(balanceOf(_owner)); } /// @dev `receiver` automatically receives `asset()` donations, and `tokens` and `amounts` donations as desired by the owner `amounts` function receiveDonations(address[] memory tokens, uint[] memory amounts, address receiver) external virtual onlyOwner { BaseCollVaultStorage storage $ = _getBaseCollVaultStorage(); uint tokensLength = tokens.length; require(tokensLength == amounts.length, "CollVault: tokens and amounts length mismatch"); uint assetBalance = IERC20(asset()).balanceOf(address(this)); uint virtualBalance = $.balanceData.balance[asset()]; if (assetBalance > virtualBalance) { IERC20(asset()).safeTransfer(receiver, assetBalance - virtualBalance); } for (uint i; i < tokensLength; i++) { if (tokens[i] == asset()) { continue; } uint256 tokenBalance = IERC20(tokens[i]).balanceOf(address(this)); uint256 virtualTokenBalance = $.balanceData.balance[tokens[i]]; uint256 transferAmount = Math.min(amounts[i], tokenBalance - virtualTokenBalance); if (transferAmount > 0) { IERC20(tokens[i]).safeTransfer(receiver, transferAmount); } } } function setWithdrawFee(uint16 _withdrawFee) external virtual onlyOwner { BaseCollVaultStorage storage $ = _getBaseCollVaultStorage(); require(_withdrawFee >= $.minWithdrawFee && _withdrawFee <= $.maxWithdrawFee, "CollVault: Withdraw fee out of bounds"); $.withdrawFee = _withdrawFee; } function _increaseBalance(address token, uint amount) internal virtual { BaseCollVaultStorage storage $ = _getBaseCollVaultStorage(); $.balanceData.balance[token] += amount; } function _decreaseBalance(address token, uint amount) internal virtual { BaseCollVaultStorage storage $ = _getBaseCollVaultStorage(); $.balanceData.balance[token] -= amount; } function _getBalanceData() internal view virtual returns (EmissionsLib.BalanceData storage) { return _getBaseCollVaultStorage().balanceData; } function getPrice( address token ) public view virtual returns (uint) { return getPriceFeed().fetchPrice(token); } function getBalance(address token) public view virtual returns (uint) { return _getBaseCollVaultStorage().balanceData.balance[token]; } function getWithdrawFee() public view virtual returns (uint16) { return _getBaseCollVaultStorage().withdrawFee; } function getMetaBeraborrowCore() public view virtual returns (IMetaBeraborrowCore) { return _getBaseCollVaultStorage()._metaBeraborrowCore; } function getPriceFeed() public view virtual returns (IPriceFeed) { return IPriceFeed(_getBaseCollVaultStorage()._metaBeraborrowCore.priceFeed()); } function assetDecimals() public view virtual returns (uint8) { return _getBaseCollVaultStorage().assetDecimals; } function _harvestRewards() internal virtual {} function _stake(uint amount) internal virtual {} function _unstake(uint amount) internal virtual {} function _withdrawExtraRewardedTokens(address receiver, uint netShares, uint _totalSupply) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; library PriceLib { using Math for uint; // WAD adjusted result function convertToValue(uint amount, uint price, uint8 decimals) internal pure returns (uint) { return amount * price / 10 ** decimals; } // Coll decimal adjust amount result function convertAssetsToCollAmount(uint assets, uint collPrice, uint nectPrice, uint8 vaultDecimals, uint8 collDecimals, Math.Rounding rounding) internal pure returns (uint) { uint assetsUsdValue = assets.mulDiv(nectPrice, 10 ** vaultDecimals, rounding); if (collPrice != 0) { return assetsUsdValue.mulDiv(10 ** collDecimals, collPrice, rounding); } else { return 0; } } function convertCollAmountToAssets(uint collAmount, uint collPrice, uint nectPrice, uint8 vaultDecimals, uint8 collDecimals) internal pure returns (uint) { uint collUsdValue = collAmount * collPrice / 10 ** collDecimals; if (nectPrice != 0) { return collUsdValue * 10 ** vaultDecimals / nectPrice; } else { return 0; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IERC3156FlashBorrower} from "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IFactory} from "./IFactory.sol"; interface IDenManager { event BaseRateUpdated(uint256 _baseRate); event CollateralSent(address _to, uint256 _amount); event LTermsUpdated(uint256 _L_collateral, uint256 _L_debt); event LastFeeOpTimeUpdated(uint256 _lastFeeOpTime); event Redemption( address indexed _redeemer, uint256 _attemptedDebtAmount, uint256 _actualDebtAmount, uint256 _collateralSent, uint256 _collateralFee ); event SystemSnapshotsUpdated(uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot); event TotalStakesUpdated(uint256 _newTotalStakes); event DenIndexUpdated(address _borrower, uint256 _newIndex); event DenSnapshotsUpdated(uint256 _L_collateral, uint256 _L_debt); event DenUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, uint8 _operation); function addCollateralSurplus(address borrower, uint256 collSurplus) external; function applyPendingRewards(address _borrower) external returns (uint256 coll, uint256 debt); function claimCollateral(address borrower, address _receiver) external; function closeDen(address _borrower, address _receiver, uint256 collAmount, uint256 debtAmount) external; function closeDenByLiquidation(address _borrower) external; function setCollVaultRouter(address _collVaultRouter) external; function collectInterests() external; function decayBaseRateAndGetBorrowingFee(uint256 _debt) external returns (uint256); function decreaseDebtAndSendCollateral(address account, uint256 debt, uint256 coll) external; function fetchPrice() external view returns (uint256); function finalizeLiquidation( address _liquidator, uint256 _debt, uint256 _coll, uint256 _collSurplus, uint256 _debtGasComp, uint256 _collGasComp ) external; function getEntireSystemBalances() external view returns (uint256, uint256, uint256); function movePendingDenRewardsToActiveBalances(uint256 _debt, uint256 _collateral) external; function openDen( address _borrower, uint256 _collateralAmount, uint256 _compositeDebt, uint256 NICR, address _upperHint, address _lowerHint ) external returns (uint256 stake, uint256 arrayIndex); function redeemCollateral( uint256 _debtAmount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint256 _partialRedemptionHintNICR, uint256 _maxIterations, uint256 _maxFeePercentage ) external; function setAddresses(address _priceFeedAddress, address _sortedDensAddress, address _collateralToken) external; function setParameters( IFactory.DeploymentParams calldata _params ) external; function setPaused(bool _paused) external; function setPriceFeed(address _priceFeedAddress) external; function startSunset() external; function updateBalances() external; function updateDenFromAdjustment( bool _isDebtIncrease, uint256 _debtChange, uint256 _netDebtChange, bool _isCollIncrease, uint256 _collChange, address _upperHint, address _lowerHint, address _borrower, address _receiver ) external returns (uint256, uint256, uint256); function DEBT_GAS_COMPENSATION() external view returns (uint256); function DECIMAL_PRECISION() external view returns (uint256); function L_collateral() external view returns (uint256); function L_debt() external view returns (uint256); function MCR() external view returns (uint256); function PERCENT_DIVISOR() external view returns (uint256); function BERABORROW_CORE() external view returns (address); function SUNSETTING_INTEREST_RATE() external view returns (uint256); function Dens( address ) external view returns ( uint256 debt, uint256 coll, uint256 stake, uint8 status, uint128 arrayIndex, uint256 activeInterestIndex ); function activeInterestIndex() external view returns (uint256); function baseRate() external view returns (uint256); function borrowerOperations() external view returns (address); function borrowingFeeFloor() external view returns (uint256); function collateralToken() external view returns (address); function debtToken() external view returns (address); function defaultedCollateral() external view returns (uint256); function defaultedDebt() external view returns (uint256); function getBorrowingFee(uint256 _debt) external view returns (uint256); function getBorrowingFeeWithDecay(uint256 _debt) external view returns (uint256); function getBorrowingRate() external view returns (uint256); function getBorrowingRateWithDecay() external view returns (uint256); function getCurrentICR(address _borrower, uint256 _price) external view returns (uint256); function getEntireDebtAndColl( address _borrower ) external view returns (uint256 debt, uint256 coll, uint256 pendingDebtReward, uint256 pendingCollateralReward); function getEntireSystemColl() external view returns (uint256); function getEntireSystemDebt() external view returns (uint256); function getNominalICR(address _borrower) external view returns (uint256); function getPendingCollAndDebtRewards(address _borrower) external view returns (uint256, uint256); function getRedemptionFeeWithDecay(uint256 _collateralDrawn) external view returns (uint256); function getRedemptionRate() external view returns (uint256); function getRedemptionRateWithDecay() external view returns (uint256); function getTotalActiveCollateral() external view returns (uint256); function getTotalActiveDebt() external view returns (uint256); function getDenCollAndDebt(address _borrower) external view returns (uint256 coll, uint256 debt); function getDenFromDenOwnersArray(uint256 _index) external view returns (address); function getDenOwnersCount() external view returns (uint256); function getDenStake(address _borrower) external view returns (uint256); function getDenStatus(address _borrower) external view returns (uint256); function guardian() external view returns (address); function hasPendingRewards(address _borrower) external view returns (bool); function interestPayable() external view returns (uint256); function interestRate() external view returns (uint256); function lastActiveIndexUpdate() external view returns (uint256); function lastCollateralError_Redistribution() external view returns (uint256); function lastDebtError_Redistribution() external view returns (uint256); function lastFeeOperationTime() external view returns (uint256); function liquidationManager() external view returns (address); function maxBorrowingFee() external view returns (uint256); function maxRedemptionFee() external view returns (uint256); function maxSystemDebt() external view returns (uint256); function minuteDecayFactor() external view returns (uint256); function owner() external view returns (address); function paused() external view returns (bool); function priceFeed() external view returns (address); function redemptionFeeFloor() external view returns (uint256); function rewardSnapshots(address) external view returns (uint256 collateral, uint256 debt); function sortedDens() external view returns (address); function sunsetting() external view returns (bool); function surplusBalances(address) external view returns (uint256); function systemDeploymentTime() external view returns (uint256); function totalCollateralSnapshot() external view returns (uint256); function totalStakes() external view returns (uint256); function totalStakesSnapshot() external view returns (uint256); function brimeDen() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; interface IInfraredWrapper is IERC20 { function metaBeraborrowCore() external view returns (address); function infraredCollVault() external view returns (address); function decimals() external view returns (uint8); function depositFor(address account, uint256 amount) external returns (bool); function withdrawTo(address account, uint256 amount) external returns (bool); function recover(address account) external returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IPriceFeed { struct FeedType { address spotOracle; bool isCollVault; } event NewOracleRegistered(address token, address chainlinkAggregator, address underlyingDerivative); event PriceFeedStatusUpdated(address token, address oracle, bool isWorking); event PriceRecordUpdated(address indexed token, uint256 _price); event NewCollVaultRegistered(address collVault, bool enable); event NewSpotOracleRegistered(address token, address spotOracle); function fetchPrice(address _token) external view returns (uint256); function getMultiplePrices(address[] memory _tokens) external view returns (uint256[] memory prices); function setOracle( address _token, address _chainlinkOracle, uint32 _heartbeat, uint16 _staleThreshold, address underlyingDerivative ) external; function whitelistCollateralVault(address _collateralVaultShareToken, bool enable) external; function setSpotOracle(address _token, address _spotOracle) external; function MAX_PRICE_DEVIATION_FROM_PREVIOUS_ROUND() external view returns (uint256); function BERABORROW_CORE() external view returns (address); function RESPONSE_TIMEOUT() external view returns (uint256); function TARGET_DIGITS() external view returns (uint256); function guardian() external view returns (address); function oracleRecords( address ) external view returns ( address chainLinkOracle, uint8 decimals, uint32 heartbeat, uint16 staleThreshold, address underlyingDerivative ); function isCollVault(address _collateralVaultShareToken) external view returns (bool); function isStableBPT(address _oracle) external view returns (bool); function isWeightedBPT(address _oracle) external view returns (bool); function getSpotOracle(address _token) external view returns (address); function feedType(address _token) external view returns (FeedType memory); function owner() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; library FeeLib { using Math for uint; uint private constant BP = 1e4; /// @dev Calculates the fees that should be added to an amount `shares` that does already include fees. /// Used in {IERC4626-deposit}, {IERC4626-mint}, {IERC4626-withdraw} and {IERC4626-previewRedeem} operations. function feeOnRaw( uint shares, uint feeBP ) internal pure returns (uint) { return shares.mulDiv(feeBP, BP, Math.Rounding.Up); } /// @dev Calculates the fee part of an amount `shares` that deoes not includes fees. /// Used in {IERC4626-previewDeposit} and {IERC4626-previewRedeem} operations. function feeOnTotal( uint shares, uint feeBP ) internal pure returns (uint) { return shares.mulDiv(feeBP, feeBP + BP, Math.Rounding.Up); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {ILiquidStabilityPool} from "../interfaces/core/ILiquidStabilityPool.sol"; library EmissionsLib { using SafeCast for uint256; uint64 constant internal DEFAULT_UNLOCK_RATE = 1e11; // 10% per second uint64 constant internal MAX_UNLOCK_RATE = 1e12; // 100% struct BalanceData { mapping(address token => uint) balance; mapping(address token => EmissionSchedule) emissionSchedule; } struct EmissionSchedule { uint128 emissions; uint64 lockTimestamp; uint64 _unlockRatePerSecond; // rate points } error AmountCannotBeZero(); error EmissionRateExceedsMax(); // error UnsupportedEmissionConfig(); event EmissionsAdded(address indexed token, uint128 amount); event EmissionsSub(address indexed token, uint128 amount); event NewUnlockRatePerSecond(address indexed token, uint64 unlockRatePerSecond); /// @dev zero _unlockRatePerSecond parameter resets rate back to DEFAULT_UNLOCK_RATE function setUnlockRatePerSecond(BalanceData storage $, address token, uint64 _unlockRatePerSecond) internal { if (_unlockRatePerSecond > MAX_UNLOCK_RATE) revert EmissionRateExceedsMax(); _addEmissions($, token, 0); // update lockTimestamp and emissions $.emissionSchedule[token]._unlockRatePerSecond = _unlockRatePerSecond; emit NewUnlockRatePerSecond(token, _unlockRatePerSecond); } function addEmissions(BalanceData storage $, address token, uint128 amount) internal { if (amount == 0) revert AmountCannotBeZero(); _addEmissions($, token, amount); emit EmissionsAdded(token, amount); } function _addEmissions(BalanceData storage $, address token, uint128 amount) private { EmissionSchedule memory schedule = $.emissionSchedule[token]; uint256 _unlockTimestamp = unlockTimestamp(schedule); uint128 nextEmissions = (lockedEmissions(schedule, _unlockTimestamp) + amount).toUint128(); schedule.emissions = nextEmissions; schedule.lockTimestamp = block.timestamp.toUint64(); $.balance[token] += amount; $.emissionSchedule[token] = schedule; } function subEmissions(BalanceData storage $, address token, uint128 amount) internal { if (amount == 0) revert AmountCannotBeZero(); _subEmissions($, token, amount); emit EmissionsSub(token, amount); } function _subEmissions(BalanceData storage $, address token, uint128 amount) private { EmissionSchedule memory schedule = $.emissionSchedule[token]; uint256 _unlockTimestamp = unlockTimestamp(schedule); uint128 nextEmissions = (lockedEmissions(schedule, _unlockTimestamp) - amount).toUint128(); schedule.emissions = nextEmissions; schedule.lockTimestamp = block.timestamp.toUint64(); $.balance[token] -= amount; $.emissionSchedule[token] = schedule; } /// @dev Doesn't include locked emissions function unlockedEmissions(EmissionSchedule memory schedule) internal view returns (uint256) { return schedule.emissions - lockedEmissions(schedule, unlockTimestamp(schedule)); } function balanceOfWithFutureEmissions(BalanceData storage $, address token) internal view returns (uint256) { return $.balance[token]; } /** * @notice Returns the unlocked token emissions */ function balanceOf(BalanceData storage $, address token) internal view returns (uint256) { EmissionSchedule memory schedule = $.emissionSchedule[token]; return $.balance[token] - lockedEmissions(schedule, unlockTimestamp(schedule)); } /** * @notice Returns locked emissions */ function lockedEmissions(EmissionSchedule memory schedule, uint256 _unlockTimestamp) internal view returns (uint256) { if (block.timestamp >= _unlockTimestamp) { // all emissions were unlocked return 0; } else { // emissions are still unlocking, calculate the amount of already unlocked emissions uint256 secondsSinceLockup = block.timestamp - schedule.lockTimestamp; // design decision - use dimensionless 'unlock rate units' to unlock emissions over a fixed time window uint256 ratePointsUnlocked = unlockRatePerSecond(schedule) * secondsSinceLockup; // emissions remainder is designed to be added to balance in unlockTimestamp return schedule.emissions - ratePointsUnlocked * schedule.emissions / MAX_UNLOCK_RATE; } } // timestamp at which all emissions are fully unlocked function unlockTimestamp(EmissionSchedule memory schedule) internal pure returns (uint256) { // ceil to account for remainder seconds left after integer division return divRoundUp(MAX_UNLOCK_RATE, unlockRatePerSecond(schedule)) + schedule.lockTimestamp; } function unlockRatePerSecond(EmissionSchedule memory schedule) internal pure returns (uint256) { return schedule._unlockRatePerSecond == 0 ? DEFAULT_UNLOCK_RATE : schedule._unlockRatePerSecond; } function divRoundUp(uint256 dividend, uint256 divisor) internal pure returns (uint256) { return (dividend + divisor - 1) / divisor; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {IERC4626, IERC20} from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {IDenManager} from "../IDenManager.sol"; import {IMetaBeraborrowCore} from "../IMetaBeraborrowCore.sol"; import {IPriceFeed} from "../IPriceFeed.sol"; import {EmissionsLib} from "src/libraries/EmissionsLib.sol"; interface IBaseCollateralVault is IERC4626, IERC1822Proxiable { struct BaseInitParams { uint16 _minWithdrawFee; uint16 _maxWithdrawFee; uint16 _withdrawFee; IMetaBeraborrowCore _metaBeraborrowCore; // ERC4626 IERC20 _asset; // ERC20 string _sharesName; string _sharesSymbol; } struct BaseCollVaultStorage { uint16 minWithdrawFee; uint16 maxWithdrawFee; uint16 withdrawFee; // over rewarded tokens, in basis points uint8 assetDecimals; IMetaBeraborrowCore _metaBeraborrowCore; // Second mapping of this struct is usless, but it's for retrocompatibility with InfraredCollateralVault EmissionsLib.BalanceData balanceData; } function totalAssets() external view returns (uint); function fetchPrice() external view returns (uint); function getPrice(address token) external view returns (uint); function receiveDonations(address[] memory tokens, uint[] memory amounts, address receiver) external; function setWithdrawFee(uint16 _withdrawFee) external; function getBalance(address token) external view returns (uint); function getWithdrawFee() external view returns (uint16); function getMetaBeraborrowCore() external view returns (IMetaBeraborrowCore); function getPriceFeed() external view returns (IPriceFeed); function assetDecimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {IMetaBeraborrowCore} from "src/interfaces/core/IMetaBeraborrowCore.sol"; interface IBeraborrowCore { // --- Public variables --- function metaBeraborrowCore() external view returns (IMetaBeraborrowCore); function startTime() external view returns (uint256); function CCR() external view returns (uint256); function dmBootstrapPeriod() external view returns (uint64); function isPeriphery(address peripheryContract) external view returns (bool); // --- External functions --- function setPeripheryEnabled(address _periphery, bool _enabled) external; function setDMBootstrapPeriod(address dm, uint64 _bootstrapPeriod) external; function setNewCCR(uint256 _CCR) external; function priceFeed() external view returns (address); function owner() external view returns (address); function pendingOwner() external view returns (address); function guardian() external view returns (address); function manager() external view returns (address); function feeReceiver() external view returns (address); function paused() external view returns (bool); function lspBootstrapPeriod() external view returns (uint64); function getLspEntryFee(address rebalancer) external view returns (uint16); function getLspExitFee(address rebalancer) external view returns (uint16); function getPeripheryFlashLoanFee(address peripheryContract) external view returns (uint16); // --- Events --- event CCRSet(uint256 initialCCR); event DMBootstrapPeriodSet(address dm, uint64 bootstrapPeriod); event PeripheryEnabled(address indexed periphery, bool enabled); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.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 {ERC20Upgradeable} from "../ERC20Upgradeable.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {Initializable} from "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for * underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends * the ERC-20 standard. Any additional extensions included along it would affect the "shares" token represented by this * contract and not the "assets" token which is an independent contract. * * [CAUTION] * ==== * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning * with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by * verifying the amount received is as expected, using a wrapper that performs these checks such as * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router]. * * Since v4.9, this implementation introduces configurable virtual assets and shares to help developers mitigate that risk. * The `_decimalsOffset()` corresponds to an offset in the decimal representation between the underlying asset's decimals * and the vault decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which * itself determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default * offset (0) makes it non-profitable even if an attacker is able to capture value from multiple user deposits, as a result * of the value being captured by the virtual shares (out of the attacker's donation) matching the attacker's expected gains. * With a larger offset, the attack becomes orders of magnitude more expensive than it is profitable. More details about the * underlying math can be found xref:erc4626.adoc#inflation-attack[here]. * * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the * `_convertToShares` and `_convertToAssets` functions. * * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide]. * ==== */ abstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626 { using Math for uint256; /// @custom:storage-location erc7201:openzeppelin.storage.ERC4626 struct ERC4626Storage { IERC20 _asset; uint8 _underlyingDecimals; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC4626")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC4626StorageLocation = 0x0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00; function _getERC4626Storage() private pure returns (ERC4626Storage storage $) { assembly { $.slot := ERC4626StorageLocation } } /** * @dev Attempted to deposit more assets than the max amount for `receiver`. */ error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max); /** * @dev Attempted to mint more shares than the max amount for `receiver`. */ error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max); /** * @dev Attempted to withdraw more assets than the max amount for `receiver`. */ error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max); /** * @dev Attempted to redeem more shares than the max amount for `receiver`. */ error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max); /** * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777). */ function __ERC4626_init(IERC20 asset_) internal onlyInitializing { __ERC4626_init_unchained(asset_); } function __ERC4626_init_unchained(IERC20 asset_) internal onlyInitializing { ERC4626Storage storage $ = _getERC4626Storage(); (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_); $._underlyingDecimals = success ? assetDecimals : 18; $._asset = asset_; } /** * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way. */ function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) { (bool success, bytes memory encodedDecimals) = address(asset_).staticcall( abi.encodeCall(IERC20Metadata.decimals, ()) ); if (success && encodedDecimals.length >= 32) { uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256)); if (returnedDecimals <= type(uint8).max) { return (true, uint8(returnedDecimals)); } } return (false, 0); } /** * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This * "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals. * * See {IERC20Metadata-decimals}. */ function decimals() public view virtual override(IERC20Metadata, ERC20Upgradeable) returns (uint8) { ERC4626Storage storage $ = _getERC4626Storage(); return $._underlyingDecimals + _decimalsOffset(); } /** @dev See {IERC4626-asset}. */ function asset() public view virtual returns (address) { ERC4626Storage storage $ = _getERC4626Storage(); return address($._asset); } /** @dev See {IERC4626-totalAssets}. */ function totalAssets() public view virtual returns (uint256) { ERC4626Storage storage $ = _getERC4626Storage(); return $._asset.balanceOf(address(this)); } /** @dev See {IERC4626-convertToShares}. */ function convertToShares(uint256 assets) public view virtual returns (uint256) { return _convertToShares(assets, Math.Rounding.Down); } /** @dev See {IERC4626-convertToAssets}. */ function convertToAssets(uint256 shares) public view virtual returns (uint256) { return _convertToAssets(shares, Math.Rounding.Down); } /** @dev See {IERC4626-maxDeposit}. */ function maxDeposit(address) public view virtual returns (uint256) { return type(uint256).max; } /** @dev See {IERC4626-maxMint}. */ function maxMint(address) public view virtual returns (uint256) { return type(uint256).max; } /** @dev See {IERC4626-maxWithdraw}. */ function maxWithdraw(address owner) public view virtual returns (uint256) { return _convertToAssets(balanceOf(owner), Math.Rounding.Down); } /** @dev See {IERC4626-maxRedeem}. */ function maxRedeem(address owner) public view virtual returns (uint256) { return balanceOf(owner); } /** @dev See {IERC4626-previewDeposit}. */ function previewDeposit(uint256 assets) public view virtual returns (uint256) { return _convertToShares(assets, Math.Rounding.Down); } /** @dev See {IERC4626-previewMint}. */ function previewMint(uint256 shares) public view virtual returns (uint256) { return _convertToAssets(shares, Math.Rounding.Up); } /** @dev See {IERC4626-previewWithdraw}. */ function previewWithdraw(uint256 assets) public view virtual returns (uint256) { return _convertToShares(assets, Math.Rounding.Up); } /** @dev See {IERC4626-previewRedeem}. */ function previewRedeem(uint256 shares) public view virtual returns (uint256) { return _convertToAssets(shares, Math.Rounding.Down); } /** @dev See {IERC4626-deposit}. */ function deposit(uint256 assets, address receiver) public virtual returns (uint256) { uint256 maxAssets = maxDeposit(receiver); if (assets > maxAssets) { revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets); } uint256 shares = previewDeposit(assets); _deposit(_msgSender(), receiver, assets, shares); return shares; } /** @dev See {IERC4626-mint}. */ function mint(uint256 shares, address receiver) public virtual returns (uint256) { uint256 maxShares = maxMint(receiver); if (shares > maxShares) { revert ERC4626ExceededMaxMint(receiver, shares, maxShares); } uint256 assets = previewMint(shares); _deposit(_msgSender(), receiver, assets, shares); return assets; } /** @dev See {IERC4626-withdraw}. */ function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) { uint256 maxAssets = maxWithdraw(owner); if (assets > maxAssets) { revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets); } uint256 shares = previewWithdraw(assets); _withdraw(_msgSender(), receiver, owner, assets, shares); return shares; } /** @dev See {IERC4626-redeem}. */ function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) { uint256 maxShares = maxRedeem(owner); if (shares > maxShares) { revert ERC4626ExceededMaxRedeem(owner, shares, maxShares); } uint256 assets = previewRedeem(shares); _withdraw(_msgSender(), receiver, owner, assets, shares); return assets; } /** * @dev Internal conversion function (from assets to shares) with support for rounding direction. */ // Deposit 1 USDC // 1e6 * 1e12 / 1 -> 1e18 shares minted // Deposit 1 USDC after first mint // 1e6 * 1e18 / 1e18 -> 1e6 shares minted // After first mint, BaseCollVault correctly does: // 1e6 * 1e18 / 1e6 -> 1e18 shares minted // Problem is usdValue in `totalAssets will have to be multiplied in 10 ** decimal precision, instead of WAD: // Currently: `amountInAsset = usdValue.mulDiv(WAD, assetPrice) + assetBalanceWad;` // Fix: `amountInAsset = usdValue.mulDiv(assetDecimals(), assetPrice) + assetBalance;` // Which reduces precision in totalAsset. // We could fix it by overriding deposit/mint/withdraw/redeem to scale internally assets to WAD, but leads to higher complexity // 8 decimals // 1e8 * 1e10 / 1 = 1e18 minted shares // 1e8 * 1e18 / 1e8 = 1e18 minted shares function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) { return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding); } /** * @dev Internal conversion function (from shares to assets) with support for rounding direction. */ function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) { return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding); } /** * @dev Deposit/mint common workflow. */ function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual { ERC4626Storage storage $ = _getERC4626Storage(); // If _asset is ERC-777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the // assets are transferred and before the shares are minted, which is a valid state. // slither-disable-next-line reentrancy-no-eth SafeERC20.safeTransferFrom($._asset, caller, address(this), assets); _mint(receiver, shares); emit Deposit(caller, receiver, assets, shares); } /** * @dev Withdraw/redeem common workflow. */ function _withdraw( address caller, address receiver, address owner, uint256 assets, uint256 shares ) internal virtual { ERC4626Storage storage $ = _getERC4626Storage(); if (caller != owner) { _spendAllowance(owner, caller, shares); } // If _asset is ERC-777, `transfer` can trigger a reentrancy AFTER the transfer happens through the // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the // shares are burned and after the assets are transferred, which is a valid state. _burn(owner, shares); SafeERC20.safeTransfer($._asset, receiver, assets); emit Withdraw(caller, receiver, owner, assets, shares); } function _decimalsOffset() internal view virtual returns (uint8) { return 0; } }
// 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.26; interface IMetaBeraborrowCore { // --------------------------------- // Structures // --------------------------------- struct FeeInfo { bool existsForNect; uint16 nectFee; } struct RebalancerFeeInfo { bool exists; uint16 entryFee; uint16 exitFee; } // --------------------------------- // Public constants // --------------------------------- function OWNERSHIP_TRANSFER_DELAY() external view returns (uint256); function DEFAULT_FLASH_LOAN_FEE() external view returns (uint16); // --------------------------------- // Public state variables // --------------------------------- function nect() external view returns (address); function lspEntryFee() external view returns (uint16); function lspExitFee() external view returns (uint16); function feeReceiver() external view returns (address); function priceFeed() external view returns (address); function owner() external view returns (address); function pendingOwner() external view returns (address); function ownershipTransferDeadline() external view returns (uint256); function manager() external view returns (address); function guardian() external view returns (address); function paused() external view returns (bool); function lspBootstrapPeriod() external view returns (uint64); // --------------------------------- // External functions // --------------------------------- function setFeeReceiver(address _feeReceiver) external; function setPriceFeed(address _priceFeed) external; function setGuardian(address _guardian) external; function setManager(address _manager) external; /** * @notice Global pause/unpause * Pausing halts new deposits/borrowing across the protocol */ function setPaused(bool _paused) external; /** * @notice Extend or change the LSP bootstrap period, * after which certain protocol mechanics change */ function setLspBootstrapPeriod(uint64 _bootstrapPeriod) external; /** * @notice Set a custom flash-loan fee for a given periphery contract * @param _periphery Target contract that will get this custom fee * @param _nectFee Fee in basis points (bp) * @param _existsForNect Whether this custom fee is used when the caller = `nect` */ function setPeripheryFlashLoanFee(address _periphery, uint16 _nectFee, bool _existsForNect) external; /** * @notice Begin the ownership transfer process * @param newOwner The address proposed to be the new owner */ function commitTransferOwnership(address newOwner) external; /** * @notice Finish the ownership transfer, after the mandatory delay */ function acceptTransferOwnership() external; /** * @notice Revoke a pending ownership transfer */ function revokeTransferOwnership() external; /** * @notice Look up a custom flash-loan fee for a specific periphery contract * @param peripheryContract The contract that might have a custom fee * @return The flash-loan fee in basis points */ function getPeripheryFlashLoanFee(address peripheryContract) external view returns (uint16); /** * @notice Set / override entry & exit fees for a special rebalancer contract */ function setRebalancerFee(address _rebalancer, uint16 _entryFee, uint16 _exitFee) external; /** * @notice Set the LSP entry fee globally * @param _fee Fee in basis points */ function setEntryFee(uint16 _fee) external; /** * @notice Set the LSP exit fee globally * @param _fee Fee in basis points */ function setExitFee(uint16 _fee) external; /** * @notice Look up the LSP entry fee for a rebalancer * @param rebalancer Possibly has a special fee * @return The entry fee in basis points */ function getLspEntryFee(address rebalancer) external view returns (uint16); /** * @notice Look up the LSP exit fee for a rebalancer * @param rebalancer Possibly has a special fee * @return The exit fee in basis points */ function getLspExitFee(address rebalancer) external view returns (uint16); // --------------------------------- // Events // --------------------------------- event NewOwnerCommitted(address indexed owner, address indexed pendingOwner, uint256 deadline); event NewOwnerAccepted(address indexed oldOwner, address indexed newOwner); event NewOwnerRevoked(address indexed owner, address indexed revokedOwner); event FeeReceiverSet(address indexed feeReceiver); event PriceFeedSet(address indexed priceFeed); event GuardianSet(address indexed guardian); event ManagerSet(address indexed manager); event PeripheryFlashLoanFee(address indexed periphery, uint16 nectFee); event LSPBootstrapPeriodSet(uint64 bootstrapPeriod); event RebalancerFees(address indexed rebalancer, uint16 entryFee, uint16 exitFee); event EntryFeeSet(uint16 fee); event ExitFeeSet(uint16 fee); event Paused(); event Unpaused(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC3156 FlashBorrower, as defined in * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156]. * * _Available since v4.1._ */ interface IERC3156FlashBorrower { /** * @dev Receive a flash loan. * @param initiator The initiator of the loan. * @param token The loan currency. * @param amount The amount of tokens lent. * @param fee The additional amount of tokens to repay. * @param data Arbitrary data structure, intended to contain user-defined parameters. * @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan" */ function onFlashLoan( address initiator, address token, uint256 amount, uint256 fee, bytes calldata data ) external returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; interface IFactory { // commented values are suggested default parameters struct DeploymentParams { uint256 minuteDecayFactor; // 999037758833783000 (half life of 12 hours) uint256 redemptionFeeFloor; // 1e18 / 1000 * 5 (0.5%) uint256 maxRedemptionFee; // 1e18 (100%) uint256 borrowingFeeFloor; // 1e18 / 1000 * 5 (0.5%) uint256 maxBorrowingFee; // 1e18 / 100 * 5 (5%) uint256 interestRateInBps; // 100 (1%) uint256 maxDebt; uint256 MCR; // 12 * 1e17 (120%) address collVaultRouter; // set to address(0) if DenManager coll is not CollateralVault } event NewDeployment(address collateral, address priceFeed, address denManager, address sortedDens); function deployNewInstance( address collateral, address priceFeed, address customDenManagerImpl, address customSortedDensImpl, DeploymentParams calldata params, uint64 unlockRatePerSecond, bool forceThroughLspBalanceCheck ) external; function setImplementations(address _denManagerImpl, address _sortedDensImpl) external; function BERABORROW_CORE() external view returns (address); function borrowerOperations() external view returns (address); function debtToken() external view returns (address); function guardian() external view returns (address); function liquidationManager() external view returns (address); function owner() external view returns (address); function sortedDensImpl() external view returns (address); function liquidStabilityPool() external view returns (address); function denManagerCount() external view returns (uint256); function denManagerImpl() external view returns (address); function denManagers(uint256) external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {IMetaBeraborrowCore} from "./IMetaBeraborrowCore.sol"; import {IDebtToken} from "./IDebtToken.sol"; import {IDebtToken} from "./IDebtToken.sol"; import {EmissionsLib} from "src/libraries/EmissionsLib.sol"; interface ILiquidStabilityPool is IERC4626, IERC1822Proxiable { struct LSPStorage { IMetaBeraborrowCore metaBeraborrowCore; address feeReceiver; /// @notice Array of tokens that have been emitted to the LiquidStabilityPool /// @notice Used to track which tokens can be withdrawn to LSP share holders /// @dev Doesn't include tokens that are already BeraBorrow's collaterals EnumerableSet.AddressSet extraAssets; Queue queue; address[] collateralTokens; mapping(uint16 => SunsetIndex) _sunsetIndexes; mapping(address collateral => uint256 index) indexByCollateral; mapping(bytes32 => uint) threshold; EmissionsLib.BalanceData balanceData; mapping(address => bool) factoryProtocol; mapping(address => bool) liquidationManagerProtocol; // Allowed to withdraw their positions during bootstrap period mapping(address => bool) boycoVault; } struct InitParams { IERC20 _asset; string _sharesName; string _sharesSymbol; IMetaBeraborrowCore _metaBeraborrowCore; address _liquidationManager; address _factory; address _feeReceiver; } struct RebalanceParams { address sentCurrency; uint sentAmount; address receivedCurrency; address swapper; bytes payload; } struct SunsetIndex { uint128 idx; uint128 expiry; } struct Queue { uint16 firstSunsetIndexKey; uint16 nextSunsetIndexKey; } event CollAndEmissionsWithdraw( address indexed receiver, uint shares, uint[] amounts ); struct Arrays { uint length; address[] collaterals; uint collateralsLength; uint[] amounts; } event EmissionTokenAdded(address token); event EmissionTokenRemoved(address token); event StabilityPoolDebtBalanceUpdated(uint256 newBalance); event UserDepositChanged(address indexed depositor, uint256 newDeposit); event CollateralOverwritten(address oldCollateral, address newCollateral); // PROXY function upgradeToAndCall(address newImplementation, bytes calldata data) external; function getCurrentImplementation() external view returns (address); function SUNSET_DURATION() external view returns (uint128); function totalDebtTokenDeposits() external view returns (uint256); function enableCollateral(address _collateral, uint64 _unlockRatePerSecond, bool forceThroughBalanceCheck) external; function startCollateralSunset(address collateral) external; function getTotalDebtTokenDeposits() external view returns (uint256); function getCollateralTokens() external view returns (address[] memory); function offset(address collateral, uint256 _debtToOffset, uint256 _collToAdd) external; function initialize(InitParams calldata params) external; function rebalance(RebalanceParams calldata p) external; function linearVestingExtraAssets(address token, int amount, address recipient) external; function withdraw( uint assets, address[] calldata preferredUnderlyingTokens, address receiver, address _owner ) external returns (uint shares); function redeem( uint shares, address[] calldata preferredUnderlyingTokens, address receiver, address _owner ) external returns (uint assets); function updateProtocol( address _liquidationManager, address _factory, bool _register ) external; function addNewExtraAsset(address token, uint64 _unlockRatePerSecond) external; function removeEmitedTokens(address token) external; function setPairThreshold(address tokenIn, address tokenOut, uint thresholdInBP) external; function setUnlockRatePerSecond(address token, uint64 _unlockRatePerSecond) external; function getPrice(address token) external view returns (uint); function getLockedEmissions(address token) external view returns (uint); function extSloads(bytes32[] calldata slots) external view returns (bytes32[] memory res); function unlockRatePerSecond(address token) external view returns (uint); function removeExtraAsset(address token) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol"; import "../token/ERC20/extensions/IERC20Metadata.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * _Available since v4.7._ */ interface IERC4626 is IERC20, IERC20Metadata { event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /** * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. * * - MUST be an ERC-20 token contract. * - MUST NOT revert. */ function asset() external view returns (address assetTokenAddress); /** * @dev Returns the total amount of the underlying asset that is “managed” by Vault. * * - SHOULD include any compounding that occurs from yield. * - MUST be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT revert. */ function totalAssets() external view returns (uint256 totalManagedAssets); /** * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToShares(uint256 assets) external view returns (uint256 shares); /** * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, * through a deposit call. * * - MUST return a limited value if receiver is subject to some deposit limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. * - MUST NOT revert. */ function maxDeposit(address receiver) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given * current on-chain conditions. * * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called * in the same transaction. * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the * deposit would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewDeposit(uint256 assets) external view returns (uint256 shares); /** * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * deposit execution, and are accounted for during deposit. * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares); /** * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. * - MUST return a limited value if receiver is subject to some mint limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. * - MUST NOT revert. */ function maxMint(address receiver) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given * current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the * same transaction. * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint * would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by minting. */ function previewMint(uint256 shares) external view returns (uint256 assets); /** * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint * execution, and are accounted for during mint. * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function mint(uint256 shares, address receiver) external returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the * Vault, through a withdraw call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST NOT revert. */ function maxWithdraw(address owner) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, * given current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if * called * in the same transaction. * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though * the withdrawal would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewWithdraw(uint256 assets) external view returns (uint256 shares); /** * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * withdraw execution, and are accounted for during withdraw. * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function withdraw( uint256 assets, address receiver, address owner ) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, * through a redeem call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. * - MUST NOT revert. */ function maxRedeem(address owner) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, * given current on-chain conditions. * * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the * same transaction. * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the * redemption would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by redeeming. */ function previewRedeem(uint256 shares) external view returns (uint256 assets); /** * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * redeem execution, and are accounted for during redeem. * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function redeem( uint256 shares, address receiver, address owner ) external returns (uint256 assets); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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) (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) (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 abstract contract 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 pragma solidity 0.8.26; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IERC3156FlashBorrower } from "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol"; import "./IBeraborrowCore.sol"; interface IDebtToken is IERC20 { // --- Events --- event FlashLoanFeeUpdated(uint256 newFee); // --- Public constants --- function version() external view returns (string memory); function permitTypeHash() external view returns (bytes32); // --- Public immutables --- function gasPool() external view returns (address); function DEBT_GAS_COMPENSATION() external view returns (uint256); function PSMBond() external view returns (address); // --- Public mappings --- function liquidStabilityPools(address) external view returns (bool); function borrowerOperations(address) external view returns (bool); function factories(address) external view returns (bool); function peripheries(address) external view returns (bool); function denManagers(address) external view returns (bool); // --- External functions --- function enableDenManager(address _denManager) external; function mintWithGasCompensation(address _account, uint256 _amount) external returns (bool); function burnWithGasCompensation(address _account, uint256 _amount) external returns (bool); function mint(address _account, uint256 _amount) external; function burn(address _account, uint256 _amount) external; function decimals() external view returns (uint8); function sendToPeriphery(address _sender, uint256 _amount) external; function sendToSP(address _sender, uint256 _amount) external; function returnFromPool(address _poolAddress, address _receiver, uint256 _amount) external; function transfer(address recipient, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function maxFlashLoan(address token) external view returns (uint256); function flashFee(address token, uint256 amount) external view returns (uint256); function flashLoan( IERC3156FlashBorrower receiver, address token, uint256 amount, bytes calldata data ) external returns (bool); function whitelistLiquidStabilityPoolAddress(address _liquidStabilityPool, bool active) external; function whitelistBorrowerOperationsAddress(address _borrowerOperations, bool active) external; function whitelistFactoryAddress(address _factory, bool active) external; function whitelistPeripheryAddress(address _periphery, bool active) external; function whitelistPSMBond(address, bool) external; function setDebtGasCompensation(uint256 _gasCompensation, bool _isFinalValue) external; function setFlashLoanFee(uint256 _fee) external; function DOMAIN_SEPARATOR() external view returns (bytes32); function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; function nonces(address owner) external view returns (uint256); }
// 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/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 v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated 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 v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin-upgradeable/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/", "solady/=lib/solady/src/", "@chimera/=lib/chimera/src/", "forge-std/=lib/forge-std/src/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "chimera/=lib/chimera/src/", "ds-test/=lib/chimera/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "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": 100 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"AmountCannotBeZero","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":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxDeposit","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxMint","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxRedeem","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxWithdraw","type":"error"},{"inputs":[],"name":"EmissionRateExceedsMax","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"WithdrawingLockedEmissions","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":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"EmissionsAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint64","name":"unlockRatePerSecond","type":"uint64"}],"name":"NewUnlockRatePerSecond","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PerformanceFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sentCurrency","type":"address"},{"indexed":false,"internalType":"uint256","name":"sent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"received","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sentValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedValue","type":"uint256"}],"name":"Rebalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"_convertToValue","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":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","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":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fetchPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getBalanceOfWithFutureEmissions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getFullProfitUnlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getLockedEmissions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMetaBeraborrowCore","outputs":[{"internalType":"contract IMetaBeraborrowCore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPerformanceFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPriceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWithdrawFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"iRedToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ibgt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ibgtVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"infraredVault","outputs":[{"internalType":"contract IInfraredVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint128[]","name":"amounts","type":"uint128[]"}],"name":"internalizeDonations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previewHarvestRewards","outputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"sentCurrency","type":"address"},{"internalType":"uint256","name":"sentAmount","type":"uint256"},{"internalType":"address","name":"swapper","type":"address"},{"internalType":"bytes","name":"payload","type":"bytes"}],"internalType":"struct IInfraredCollateralVault.RebalanceParams","name":"p","type":"tuple"}],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"receiver","type":"address"}],"name":"receiveDonations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardedTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_iRedToken","type":"address"}],"name":"setIRED","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_keeper","type":"address"}],"name":"setKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"thresholdInBP","type":"uint256"}],"name":"setPairThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_performanceFee","type":"uint16"}],"name":"setPerformanceFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint64","name":"_unlockRatePerSecond","type":"uint64"}],"name":"setUnlockRatePerSecond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_withdrawFee","type":"uint16"}],"name":"setWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"amountInAsset","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":"token","type":"address"}],"name":"unlockRatePerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a060405230608052348015610013575f80fd5b5061001c610021565b6100d3565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100715760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d05780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516151966100f95f395f8181612c3e01528181612c670152612da001526151965ff3fe6080604052600436106102e3575f3560e01c806370a0823111610181578063ba087652116100d4578063d9c0019711610083578063d9c0019714610880578063dd62ed3e1461089f578063e993e7ed146108be578063ec05c341146108d2578063ef8b30f714610804578063f8b2cb4f146108f1578063fd64c37714610910575f80fd5b8063ba087652146107d1578063c2d41601146107f0578063c63d75b61461052a578063c6e6f59214610804578063ce96cb7714610823578063d5c16d7914610842578063d905777e14610861575f80fd5b8063aa290e6d11610130578063aa290e6d146106e2578063aaffe07614610701578063ad3cb1cc14610722578063b009c92c14610752578063b2c06ba014610774578063b3d7f6b914610793578063b460af94146107b2575f80fd5b806370a082311461061f578063748747e61461063e57806394bf804d1461065d57806395d89b411461067c5780639a400b0f146106905780639e87a5cd146106af578063a9059cbb146106c3575f80fd5b8063322ce8f01161023957806341519a65116101e857806341519a651461056857806341976e09146105875780634cdad506146105a65780634f1ef286146105c557806352d1902d146105d85780636ab3b0e5146105ec5780636e553f6514610600575f80fd5b8063322ce8f0146104a557806332e1fef2146104c457806338d52e0f146104e35780633dafa4f3146104f75780633e92f95b1461050b578063402d267d1461052a578063403dd3bc14610549575f80fd5b80631540aa89116102955780631540aa89146103d157806318160ddd146103f8578063221085d71461040c578063235c36031461042d57806323b872dd1461044157806329d78c8814610460578063313ce5671461047f575f80fd5b806301e1d114146102e757806306fdde031461030e57806307a2d13a1461032f578063095ea7b31461034e5780630a28a4771461037d5780630b983a741461039c5780630fdb11cf146103bd575b5f80fd5b3480156102f2575f80fd5b506102fb610924565b6040519081526020015b60405180910390f35b348015610319575f80fd5b506103226109df565b60405161030591906145eb565b34801561033a575f80fd5b506102fb610349366004614620565b610a7d565b348015610359575f80fd5b5061036d61036836600461465b565b610a8e565b6040519015158152602001610305565b348015610388575f80fd5b506102fb610397366004614620565b610aa5565b3480156103a7575f80fd5b506103bb6103b6366004614685565b610ab8565b005b3480156103c8575f80fd5b506102fb610ad8565b3480156103dc575f80fd5b506103e5610b33565b60405161ffff9091168152602001610305565b348015610403575f80fd5b506102fb610b4e565b348015610417575f80fd5b50610420610b62565b60405161030591906146c7565b348015610438575f80fd5b506103e5610b81565b34801561044c575f80fd5b5061036d61045b3660046146db565b610b8a565b34801561046b575f80fd5b506102fb61047a366004614719565b610baf565b34801561048a575f80fd5b50610493610bd6565b60405160ff9091168152602001610305565b3480156104b0575f80fd5b506103bb6104bf366004614743565b610c00565b3480156104cf575f80fd5b506103bb6104de366004614837565b610cbd565b3480156104ee575f80fd5b50610420610f5a565b348015610502575f80fd5b50610420610f74565b348015610516575f80fd5b506103bb610525366004614901565b610f8f565b348015610535575f80fd5b506102fb610544366004614719565b6112f2565b348015610554575f80fd5b506102fb610563366004614719565b6112f8565b348015610573575f80fd5b506103bb610582366004614719565b61137b565b348015610592575f80fd5b506102fb6105a1366004614719565b6113bb565b3480156105b1575f80fd5b506102fb6105c0366004614620565b61142e565b6103bb6105d33660046149d1565b611439565b3480156105e3575f80fd5b506102fb611454565b3480156105f7575f80fd5b5061042061146f565b34801561060b575f80fd5b506102fb61061a366004614a76565b61148a565b34801561062a575f80fd5b506102fb610639366004614719565b6114b9565b348015610649575f80fd5b506103bb610658366004614719565b6114e2565b348015610668575f80fd5b506102fb610677366004614a76565b61152e565b348015610687575f80fd5b5061032261155d565b34801561069b575f80fd5b506103bb6106aa36600461465b565b611579565b3480156106ba575f80fd5b506104206115f9565b3480156106ce575f80fd5b5061036d6106dd36600461465b565b61167c565b3480156106ed575f80fd5b506103bb6106fc366004614743565b611689565b34801561070c575f80fd5b5061071561172a565b6040516103059190614adc565b34801561072d575f80fd5b50610322604051806040016040528060058152602001640352e302e360dc1b81525081565b34801561075d575f80fd5b5061076661173f565b604051610305929190614aee565b34801561077f575f80fd5b506103bb61078e366004614b46565b611a20565b34801561079e575f80fd5b506102fb6107ad366004614620565b6120a6565b3480156107bd575f80fd5b506102fb6107cc366004614b7c565b6120b2565b3480156107dc575f80fd5b506102fb6107eb366004614b7c565b61215e565b3480156107fb575f80fd5b506104936121ee565b34801561080f575f80fd5b506102fb61081e366004614620565b612207565b34801561082e575f80fd5b506102fb61083d366004614719565b612212565b34801561084d575f80fd5b506102fb61085c366004614719565b61221f565b34801561086c575f80fd5b506102fb61087b366004614719565b612292565b34801561088b575f80fd5b506102fb61089a366004614719565b61229c565b3480156108aa575f80fd5b506102fb6108b9366004614bbb565b61230f565b3480156108c9575f80fd5b50610420612349565b3480156108dd575f80fd5b506102fb6108ec366004614719565b612368565b3480156108fc575f80fd5b506102fb61090b366004614719565b6123f8565b34801561091b575f80fd5b5061042061240b565b5f805f61092f61172a565b80519091505f6109406105a1610f5a565b90505f61095361094e610f5a565b612426565b6109675761096261090b610f5a565b610969565b5f5b90505f5b838110156109ab5761099785828151811061098a5761098a614be7565b6020026020010151612368565b6109a19087614c0f565b955060010161096d565b50806109cb6109b86121ee565b6109c390600a614cfd565b87908561243c565b6109d59190614c0f565b9550505050505090565b60605f6109ea6124e5565b90508060030180546109fb90614d0b565b80601f0160208091040260200160405190810160405280929190818152602001828054610a2790614d0b565b8015610a725780601f10610a4957610100808354040283529160200191610a72565b820191905f5260205f20905b815481529060010190602001808311610a5557829003601f168201915b505050505091505090565b5f610a88825f612509565b92915050565b5f33610a9b81858561254e565b5060019392505050565b5f80610ab083612560565b509392505050565b610ac06125c1565b610ad48282610acd612695565b91906126a6565b5050565b5f80610ae2610b4e565b9050805f03610af2575f91505090565b610b2d610b006105a1610f5a565b82610b09612757565b610b1490600a614cfd565b610b1c610924565b610b269190614d43565b919061243c565b91505090565b5f610b3c61276b565b54640100000000900461ffff16919050565b5f80610b586124e5565b6002015492915050565b5f610b6b61276b565b54600160381b90046001600160a01b0316919050565b5f610b3c61278f565b5f33610b978582856127b3565b610ba2858585612803565b60019150505b9392505050565b5f610bb8612695565b6001600160a01b039092165f90815260209290925250604090205490565b5f80610be0612860565b9050610bea612757565b8154610b2d9190600160a01b900460ff16614d5a565b610c086125c1565b5f610c1161276b565b805490915061ffff90811690831610801590610c3c5750805461ffff62010000909104811690831611155b610c9b5760405162461bcd60e51b815260206004820152602560248201527f436f6c6c5661756c743a20576974686472617720666565206f7574206f6620626044820152646f756e647360d81b60648201526084015b60405180910390fd5b805461ffff9092166401000000000265ffff0000000019909216919091179055565b610cc56125c1565b5f610cce61276b565b84518451919250908114610cf45760405162461bcd60e51b8152600401610c9290614d73565b5f610cfd610f5a565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610d2891906146c7565b602060405180830381865afa158015610d43573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d679190614dc0565b90505f6001840181610d77610f5a565b6001600160a01b03166001600160a01b031681526020019081526020015f2054905080821115610dc757610dc785610daf8385614dd7565b610db7610f5a565b6001600160a01b03169190612884565b5f5b83811015610f5057610dd9610f5a565b6001600160a01b0316888281518110610df457610df4614be7565b60200260200101516001600160a01b03160315610f48575f888281518110610e1e57610e1e614be7565b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610e5191906146c7565b602060405180830381865afa158015610e6c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e909190614dc0565b90505f866001015f015f8b8581518110610eac57610eac614be7565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f205490505f610f058a8581518110610eec57610eec614be7565b60200260200101518385610f009190614dd7565b6128da565b90508015610f4457610f4489828d8781518110610f2457610f24614be7565b60200260200101516001600160a01b03166128849092919063ffffffff16565b5050505b600101610dc9565b5050505050505050565b5f80610f64612860565b546001600160a01b031692915050565b5f610f7d61278f565b600501546001600160a01b0316919050565b610f976125c1565b815181518114610fb95760405162461bcd60e51b8152600401610c9290614d73565b5f610fc2610f74565b90505f610fcd61240b565b90505f610fd8610b81565b61ffff1690505f5b848110156112e9575f878281518110610ffb57610ffb614be7565b602002602001015190505f87838151811061101857611018614be7565b60200260200101516001600160801b03169050805f036110395750506112e1565b5f611042610f5a565b6001600160a01b0316836001600160a01b0316036110d157611062610f5a565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161108d91906146c7565b602060405180830381865afa1580156110a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110cc9190614dc0565b61114f565b6110da83610baf565b6040516370a0823160e01b81526001600160a01b038516906370a08231906111069030906004016146c7565b602060405180830381865afa158015611121573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111459190614dc0565b61114f9190614dd7565b9050818110156111a15760405162461bcd60e51b815260206004820152601f60248201527f436f6c6c5661756c743a20696e73756666696369656e742062616c616e6365006044820152606401610c92565b6111aa83612426565b6111f65760405162461bcd60e51b815260206004820152601d60248201527f436f6c6c5661756c743a20746f6b656e206e6f742072657761726465640000006044820152606401610c92565b5f6127106112048785614d43565b61120e9190614dfe565b90505f61121b8285614dd7565b9050611225610f5a565b6001600160a01b0316856001600160a01b03160361124657611246816128ef565b81156112c7576112c7611257610b62565b6001600160a01b031663b3f006746040518163ffffffff1660e01b8152600401602060405180830381865afa158015611292573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112b69190614e1d565b6001600160a01b0387169084612884565b6112db85826112d4612695565b9190612a28565b50505050505b600101610fe0565b50505050505050565b505f1990565b5f80611302612695565b6001600160a01b0384165f90815260019190910160209081526040808320815160608101835290546001600160801b03811682526001600160401b03600160801b8204811694830194909452600160c01b900490921690820152915061136782612aa0565b90506113738282612ad1565b949350505050565b6113836125c1565b8061138c61278f565b80546001600160a01b0392909216600160301b026601000000000000600160d01b031990921691909117905550565b5f6113c46115f9565b6001600160a01b031663ace1798e836040518263ffffffff1660e01b81526004016113ef91906146c7565b602060405180830381865afa15801561140a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a889190614dc0565b5f80610ab083612b58565b611441612c33565b61144a82612cd7565b610ad48282612ce2565b5f61145d612d95565b505f8051602061511a83398151915290565b5f61147861278f565b600301546001600160a01b0316919050565b5f611493612dde565b61149d83836131f7565b90506114a8836128ef565b610a886114b3610f5a565b84613243565b5f806114c36124e5565b6001600160a01b039093165f9081526020939093525050604090205490565b6114ea6125c1565b807f7c295a6235a8870762eedf177b0c47538f1234d5dd210c9bdc5ca11b722c7c005b80546001600160a01b0319166001600160a01b039290921691909117905550565b5f611537612dde565b611541838361327d565b905061154c816128ef565b610a88611557610f5a565b82613243565b60605f6115686124e5565b90508060040180546109fb90614d0b565b6115816125c1565b5f61158a61278f565b90506127108211156115da5760405162461bcd60e51b81526020600482015260196024820152780436f6c6c5661756c743a207468726573686f6c64203e20425603c1b6044820152606401610c92565b6001600160a01b039092165f9081526007909201602052604090912055565b5f61160261276b565b5f0160079054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611653573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116779190614e1d565b905090565b5f33610a9b818585612803565b6116916125c1565b611699612dde565b5f6116a261278f565b805490915061ffff908116908316108015906116cd5750805461ffff62010000909104811690831611155b610c9b5760405162461bcd60e51b815260206004820152602860248201527f436f6c6c5661756c743a20706572666f726d616e636520666565206f7574206f6044820152676620626f756e647360c01b6064820152608401610c92565b606061167761173761278f565b6001016132c9565b6060805f61174b61146f565b9050806001600160a01b03166312edb24c6040518163ffffffff1660e01b81526004015f60405180830381865afa158015611788573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526117af9190810190614e38565b925082516001600160401b038111156117ca576117ca61475e565b6040519080825280602002602001820160405280156117f3578160200160208202803683370190505b5091505f6117ff610b81565b61ffff1690505f61180e612349565b90505f611819610f74565b90505f61182461240b565b90505f5b8751811015611a16575f88828151811061184457611844614be7565b602002602001015190505f876001600160a01b031663211dc32d308c868151811061187157611871614be7565b60200260200101516040518363ffffffff1660e01b8152600401611896929190614ec7565b602060405180830381865afa1580156118b1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118d59190614dc0565b9050805f036118e5575050611a0e565b6001600160a01b03828116908616148080156119055750611905866132d5565b156119835760405163ef8b30f760e01b8152600481018390526001600160a01b0386169063ef8b30f790602401602060405180830381865afa15801561194d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119719190614dc0565b91508061197e5782611980565b845b92505b61198c836132d5565b80156119aa5750866001600160a01b0316836001600160a01b031614155b80156119bc57506119ba836133f2565b155b15611a0a575f6127106119cf8a85614d43565b6119d99190614dfe565b90505f6119e68285614dd7565b9050808c87815181106119fb576119fb614be7565b60200260200101818152505050505b5050505b600101611828565b5050505050509091565b337f7c295a6235a8870762eedf177b0c47538f1234d5dd210c9bdc5ca11b722c7c00546001600160a01b03161480611ac6575033611a5c610b62565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a97573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611abb9190614e1d565b6001600160a01b0316145b611b095760405162461bcd60e51b81526020600482015260146024820152732737ba1037bbb732b9103737b91035b2b2b832b960611b6044820152606401610c92565b611b11612dde565b5f611b1a61278f565b90505f611b2d6105a16020850185614719565b90505f611b3b6105a1610f5a565b90505f611b4b6020860186614719565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b86573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611baa9190614ef1565b90505f611bba6020870187614719565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611be591906146c7565b602060405180830381865afa158015611c00573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c249190614dc0565b90505f611c2f610f5a565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611c5a91906146c7565b602060405180830381865afa158015611c75573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c999190614dc0565b9050611cbf611cae6060890160408a01614719565b60208901803590610db7908b614719565b611ccf6060880160408901614719565b6001600160a01b0316637f0f41d7611cea60208a018a614719565b8960200135611cf7610f5a565b611d0460608d018d614f0a565b6040518663ffffffff1660e01b8152600401611d24959493929190614f53565b5f604051808303815f87803b158015611d3b575f80fd5b505af1158015611d4d573d5f803e3d5ffd5b505050505f81611d5b610f5a565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611d8691906146c7565b602060405180830381865afa158015611da1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611dc59190614dc0565b611dcf9190614dd7565b90505f611ddf60208a018a614719565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611e0a91906146c7565b602060405180830381865afa158015611e25573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e499190614dc0565b611e539085614dd7565b9050611e6561090b60208b018b614719565b811115611e8557604051630301465d60e11b815260040160405180910390fd5b611e8d612695565b6001015f611e99610f5a565b6001600160a01b0316815260208101919091526040015f90812054600160c01b90046001600160401b03169003611f2f5760405162461bcd60e51b815260206004820152603460248201527f436f6c6c5661756c743a206173736574206e65656473206120646566696e6564604482015273081d5b9b1bd8dad4985d1954195c94d958dbdb9960621b6064820152608401610c92565b5f611f4487611f3c6121ee565b8591906134aa565b90505f611f52838a896134aa565b905061271060078b015f611f6960208f018f614719565b6001600160a01b0316815260208101919091526040015f2054611f8e90612710614dd7565b611f989083614d43565b611fa29190614dfe565b8210156120075760405162461bcd60e51b815260206004820152602d60248201527f436f6c6c5661756c743a20726563656976656420616d6f756e7420697320626560448201526c1b1bddc81d1a1c995cda1bdb19609a1b6064820152608401610c92565b61201d61201760208d018d614719565b846134ca565b61202e612028610f5a565b85613243565b612037846134fb565b61204460208c018c614719565b6040805185815260208101879052908101839052606081018490526001600160a01b0391909116907f90fea00fe6e24ccfd7c40b40e07486e8b69ada2a3ad693dd908b6479cac36b6b9060800160405180910390a25050505050505050505050565b5f610a88826001612509565b5f6120bb612dde565b5f6120c4610b4e565b90505f6120d084612212565b9050808611156120f957838682604051633fa733bb60e21b8152600401610c9293929190614fa3565b505f61210486612560565b90935090505f80612116858585613504565b91509150815f1461213b5761212a826135d0565b61213b612135610f5a565b836134ca565b61214833888885896136bc565b612153878286613773565b505050509392505050565b5f612167612dde565b5f612170610b4e565b90505f61217c84612292565b9050808611156121a557838682604051632e52afbb60e21b8152600401610c9293929190614fa3565b505f6121b086612b58565b90935090505f806121c2888585613504565b91509150815f146121e1576121d6826135d0565b6121e1612135610f5a565b612148338888858c6136bc565b5f6121f761276b565b54600160301b900460ff16919050565b5f610a88825f6138e2565b5f610a886105c0836114b9565b5f80612229612695565b6001600160a01b0384165f9081526001919091016020908152604091829020825160608101845290546001600160801b03811682526001600160401b03600160801b8204811693830193909352600160c01b9004909116918101919091529050610ba881612aa0565b5f610a88826114b9565b5f806122a6612695565b6001600160a01b0384165f9081526001919091016020908152604091829020825160608101845290546001600160801b03811682526001600160401b03600160801b8204811693830193909352600160c01b9004909116918101919091529050610ba88161391e565b5f806123196124e5565b6001600160a01b039485165f90815260019190910160209081526040808320959096168252939093525050205490565b5f61235261278f565b54600160301b90046001600160a01b0316919050565b5f80612373836123f8565b90505f61237f846113bb565b90505f846001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123be573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123e29190614ef1565b90506123ef8383836134aa565b95945050505050565b5f610a8882612405612695565b90613953565b5f61241461278f565b600401546001600160a01b0316919050565b5f610a888261243361278f565b600101906139df565b5f80805f19858709858702925082811083820303915050805f036124735783828161246957612469614dea565b0492505050610ba8565b80841161247e575f80fd5b5f8486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091025f889003889004909101858311909403939093029303949094049190911702949350505050565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0090565b5f610ba8612515610924565b612520906001614c0f565b612528612757565b61253390600a614cfd565b61253b610b4e565b6125459190614c0f565b85919085613a00565b61255b8383836001613a59565b505050565b5f805f61256b61276b565b90505f61257785613b3a565b82549091505f906125a6906127109061259c90640100000000900461ffff1682614dd7565b8491906001613a00565b90505f6125b38383614dd7565b919791965090945050505050565b6125c9610b62565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612604573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126289190614e1d565b6001600160a01b0316336001600160a01b0316146126935760405162461bcd60e51b815260206004820152602260248201527f436f6c6c5661756c743a2063616c6c6572206973206e6f7420746865206f776e60448201526132b960f11b6064820152608401610c92565b565b5f61269e61276b565b600101905090565b64e8d4a510006001600160401b03821611156126d5576040516304bba2fb60e51b815260040160405180910390fd5b6126e083835f613b46565b6001600160a01b0382165f81815260018501602090815260409182902080546001600160c01b0316600160c01b6001600160401b0387169081029190911790915591519182527f5577d4c8f6e5397effa5c71df8fe221e1162e18aaa0aabe87026cfb0c676215091015b60405180910390a2505050565b5f6127606121ee565b611677906012614fc4565b7f19001df2d131e9aa1479f4ce661ae121445caf0662dea1e41907028a6da6fe0090565b7ff6a35052099d23fafed8c58b549933969c057c5a9a13ac5133024adc8dd4f20090565b5f6127be848461230f565b90505f1981146127fd57818110156127ef57828183604051637dc7a0d960e11b8152600401610c9293929190614fa3565b6127fd84848484035f613a59565b50505050565b6001600160a01b03831661282c575f604051634b637e8f60e11b8152600401610c9291906146c7565b6001600160a01b038216612855575f60405163ec442f0560e01b8152600401610c9291906146c7565b61255b838383613caa565b7f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e0090565b61255b8363a9059cbb60e01b84846040516024016128a3929190614fdd565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613dcd565b5f8183106128e85781610ba8565b5090919050565b5f6128f861278f565b600381015460068201549192506001600160a01b0390811691165f81156129ad576129368286612926610f5a565b6001600160a01b03169190613e9e565b6040516317a790f160e11b81526001600160a01b03831690632f4f21e2906129649030908990600401614fdd565b6020604051808303815f875af1158015612980573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129a49190615005565b508190506129b8565b6129b5610f5a565b90505b6129cc6001600160a01b0382168487613f9f565b60405163534a7e1d60e11b8152600481018690526001600160a01b0384169063a694fc3a906024015f604051808303815f87803b158015612a0b575f80fd5b505af1158015612a1d573d5f803e3d5ffd5b505050505050505050565b806001600160801b03165f03612a515760405163d11b25af60e01b815260040160405180910390fd5b612a5c838383613b46565b6040516001600160801b03821681526001600160a01b038316907f693ffe037fd29f4846b006bd3ada57d4fd4c3622277227342f0e4fed9011dc209060200161274a565b60208101515f906001600160401b0316612ac764e8d4a51000612ac28561391e565b614039565b610a889190614c0f565b5f814210612ae057505f610a88565b5f83602001516001600160401b031642612afa9190614dd7565b90505f81612b078661391e565b612b119190614d43565b855190915064e8d4a5100090612b30906001600160801b031683614d43565b612b3a9190614dfe565b8551612b4f91906001600160801b0316614dd7565b92505050610a88565b5f805f612b6361278f565b60048101549091505f906001600160a01b031630148015612bf15750612b876115f9565b6001600160a01b031663e1bdd0a6336040518263ffffffff1660e01b8152600401612bb291906146c7565b602060405180830381865afa158015612bcd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612bf19190615005565b90505f81612c1457612c0f612c04610b33565b879061ffff1661405b565b612c16565b5f5b90505f612c266103498389614dd7565b9791965090945050505050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480612cb957507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612cad5f8051602061511a833981519152546001600160a01b031690565b6001600160a01b031614155b156126935760405163703e46dd60e11b815260040160405180910390fd5b612cdf6125c1565b50565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612d3c575060408051601f3d908101601f19168201909252612d3991810190614dc0565b60015b612d5b5781604051634c9c8ce360e01b8152600401610c9291906146c7565b5f8051602061511a8339815191528114612d8b57604051632a87526960e21b815260048101829052602401610c92565b61255b838361406b565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146126935760405163703e46dd60e11b815260040160405180910390fd5b612de661278f565b60060154600160a01b90046001600160601b03164203612e0257565b5f612e0b61146f565b90505f816001600160a01b03166312edb24c6040518163ffffffff1660e01b81526004015f60405180830381865afa158015612e49573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052612e709190810190614e38565b90505f81516001600160401b03811115612e8c57612e8c61475e565b604051908082528060200260200182016040528015612eb5578160200160208202803683370190505b5090505f5b8251811015612f6c57828181518110612ed557612ed5614be7565b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401612f0891906146c7565b602060405180830381865afa158015612f23573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f479190614dc0565b828281518110612f5957612f59614be7565b6020908102919091010152600101612eba565b50826001600160a01b0316633d18b9126040518163ffffffff1660e01b81526004015f604051808303815f87803b158015612fa5575f80fd5b505af1158015612fb7573d5f803e3d5ffd5b505050505f612fc4610b81565b61ffff1690505f612fd3612349565b90505f612fde610f74565b90505f612fe961240b565b90505f5b86518110156131bd575f87828151811061300957613009614be7565b602002602001015190505f816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161304091906146c7565b602060405180830381865afa15801561305b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061307f9190614dc0565b90505f88848151811061309457613094614be7565b6020026020010151826130a79190614dd7565b9050805f036130b8575050506131b5565b6130c1836132d5565b80156130df5750866001600160a01b0316836001600160a01b031614155b80156130f157506130ef836133f2565b155b156131b1575f6127106131048a84614d43565b61310e9190614dfe565b90505f61311b8284614dd7565b9050613125610f5a565b6001600160a01b0316856001600160a01b03160361314657613146816128ef565b6131508582613243565b613159856140c0565b81156131ae5761316a611257610b62565b846001600160a01b03167f620154c7367c3805aa5a57be3421bcd8ae0de705b07bb7880c7ebdd1eff84237836040516131a591815260200190565b60405180910390a25b50505b5050505b600101612fed565b50426131c761278f565b60060160146101000a8154816001600160601b0302191690836001600160601b0316021790555050505050505050565b5f80613202836112f2565b90508084111561322b57828482604051633c8097d960e11b8152600401610c9293929190614fa3565b5f61323585612207565b9050611373338587846140d8565b8061324c612695565b6001600160a01b0384165f908152602091909152604081208054909190613274908490614c0f565b90915550505050565b5f80613288836112f2565b9050808411156132b15782848260405163284ff66760e01b8152600401610c9293929190614fa3565b5f6132bb856120a6565b9050611373338583886140d8565b60605f610ba883614153565b5f806132df6115f9565b90505f816001600160a01b0316637cdde506856040518263ffffffff1660e01b815260040161330e91906146c7565b60a060405180830381865afa158015613329573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061334d919061501e565b5050505090505f826001600160a01b031663771bc577866040518263ffffffff1660e01b815260040161338091906146c7565b6040805180830381865afa15801561339a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906133be9190615093565b90506001600160a01b0382161515806133d8575080602001515b806123ef5750516001600160a01b03161515949350505050565b5f806133fc61278f565b60048101549091506001600160a01b03848116911614801561342b575060048101546001600160a01b03163014155b1561343857505f92915050565b6134406115f9565b6001600160a01b031663e1bdd0a6846040518263ffffffff1660e01b815260040161346b91906146c7565b602060405180830381865afa158015613486573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ba89190615005565b5f6134b682600a614cfd565b6134c08486614d43565b6113739190614dfe565b806134d3612695565b6001600160a01b0384165f908152602091909152604081208054909190613274908490614dd7565b612cdf816128ef565b5f805f61350f61276b565b90505f61351c8588614dd7565b90505f61353661352d61090b610f5a565b8390895f613a00565b90505f835f0160079054906101000a90046001600160a01b03166001600160a01b031663b3f006746040518163ffffffff1660e01b8152600401602060405180830381865afa15801561358b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906135af9190614e1d565b905086156135c1576135c181886141ac565b5093509150505b935093915050565b5f6135d961278f565b60068101546003820154604051632e1a7d4d60e01b8152600481018690529293506001600160a01b0391821692911690632e1a7d4d906024015f604051808303815f87803b158015613629575f80fd5b505af115801561363b573d5f803e3d5ffd5b505050506001600160a01b0381161561255b5760405163040b850f60e31b81526001600160a01b0382169063205c28789061367c9030908790600401614fdd565b6020604051808303815f875af1158015613698573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127fd9190615005565b5f6136c5612860565b9050836001600160a01b0316866001600160a01b0316146136eb576136eb8487846127b3565b6136f584836141e0565b805461370b906001600160a01b03168685612884565b836001600160a01b0316856001600160a01b0316876001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8686604051613763929190918252602082015260400190565b60405180910390a4505050505050565b5f61377c61278f565b90505f61378761172a565b80516004840154919250906001600160a01b03165f5b82811015610f50575f8482815181106137b8576137b8614be7565b602002602001015190506137ca610f5a565b6001600160a01b0316816001600160a01b0316036137e857506138da565b5f6137fe6137f5836123f8565b8a908a5f613a00565b9050805f0361380e5750506138da565b61381882826134ca565b836001600160a01b0316826001600160a01b031614801561384257506001600160a01b0384163014155b156138c357604051635d043b2960e11b8152600481018290526001600160a01b038b8116602483015230604483015283169063ba087652906064016020604051808303815f875af1158015613899573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906138bd9190614dc0565b506138d7565b6138d76001600160a01b0383168b83612884565b50505b60010161379d565b5f610ba86138ee612757565b6138f990600a614cfd565b613901610b4e565b61390b9190614c0f565b613913610924565b612545906001614c0f565b5f81604001516001600160401b03165f1461393d578160400151613944565b64174876e8005b6001600160401b031692915050565b6001600160a01b0381165f9081526001830160209081526040808320815160608101835290546001600160801b03811682526001600160401b03600160801b8204811694830194909452600160c01b9004909216908201526139bd816139b881612aa0565b612ad1565b6001600160a01b0384165f908152602086905260409020546113739190614dd7565b6001600160a01b0381165f9081526001830160205260408120541515610ba8565b5f80613a0d86868661243c565b90506001836002811115613a2357613a236150ef565b148015613a3f57505f8480613a3a57613a3a614dea565b868809115b156123ef57613a4f600182614c0f565b9695505050505050565b5f613a626124e5565b90506001600160a01b038516613a8d575f60405163e602df0560e01b8152600401610c9291906146c7565b6001600160a01b038416613ab6575f604051634a1406b160e11b8152600401610c9291906146c7565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115613b3357836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051613b2a91815260200190565b60405180910390a35b5050505050565b5f610a888260016138e2565b6001600160a01b0382165f9081526001840160209081526040808320815160608101835290546001600160801b03811682526001600160401b03600160801b8204811694830194909452600160c01b90049092169082015290613ba882612aa0565b90505f613bd1846001600160801b0316613bc28585612ad1565b613bcc9190614c0f565b614214565b6001600160801b03811684529050613be842614280565b6001600160401b03166020808501919091526001600160a01b0386165f908152908790526040812080546001600160801b0387169290613c29908490614c0f565b909155505050506001600160a01b03929092165f9081526001939093016020908152604093849020835181549285015194909501516001600160801b039095166001600160c01b031990921691909117600160801b6001600160401b0394851602176001600160c01b0316600160c01b939094169290920292909217905550565b5f613cb36124e5565b90506001600160a01b038416613ce15781816002015f828254613cd69190614c0f565b90915550613d3e9050565b6001600160a01b0384165f9081526020829052604090205482811015613d205784818460405163391434e360e21b8152600401610c9293929190614fa3565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b038316613d5c576002810180548390039055613d7a565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051613dbf91815260200190565b60405180910390a350505050565b5f613e21826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166142e79092919063ffffffff16565b80519091501561255b5780806020019051810190613e3f9190615005565b61255b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610c92565b801580613f155750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90613ed49030908690600401614ec7565b602060405180830381865afa158015613eef573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613f139190614dc0565b155b613f805760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610c92565b61255b8363095ea7b360e01b84846040516024016128a3929190614fdd565b5f81846001600160a01b031663dd62ed3e30866040518363ffffffff1660e01b8152600401613fcf929190614ec7565b602060405180830381865afa158015613fea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061400e9190614dc0565b6140189190614c0f565b90506127fd8463095ea7b360e01b85846040516024016128a3929190614fdd565b5f8160016140478286614c0f565b6140519190614dd7565b610ba89190614dfe565b5f610ba883836127106001613a00565b614074826142f5565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156140b85761255b8282614335565b610ad461435a565b5f6140c961278f565b905061255b6001820183614379565b5f6140e1612860565b80549091506140fb906001600160a01b031686308661438d565b61410584836141ac565b836001600160a01b0316856001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051613b2a929190918252602082015260400190565b6060815f018054806020026020016040519081016040528092919081815260200182805480156141a057602002820191905f5260205f20905b81548152602001906001019080831161418c575b50505050509050919050565b6001600160a01b0382166141d5575f60405163ec442f0560e01b8152600401610c9291906146c7565b610ad45f8383613caa565b6001600160a01b038216614209575f604051634b637e8f60e11b8152600401610c9291906146c7565b610ad4825f83613caa565b5f6001600160801b0382111561427c5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b6064820152608401610c92565b5090565b5f6001600160401b0382111561427c5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b6064820152608401610c92565b606061137384845f856143c5565b806001600160a01b03163b5f036143215780604051634c9c8ce360e01b8152600401610c9291906146c7565b805f8051602061511a83398151915261150d565b6060610ba8838360405180606001604052806027815260200161513a6027913961449c565b34156126935760405163b398979f60e01b815260040160405180910390fd5b5f610ba8836001600160a01b038416614506565b6040516001600160a01b03808516602483015283166044820152606481018290526127fd9085906323b872dd60e01b906084016128a3565b6060824710156144265760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610c92565b5f80866001600160a01b031685876040516144419190615103565b5f6040518083038185875af1925050503d805f811461447b576040519150601f19603f3d011682016040523d82523d5f602084013e614480565b606091505b509150915061449187838387614552565b979650505050505050565b60605f80856001600160a01b0316856040516144b89190615103565b5f60405180830381855af49150503d805f81146144f0576040519150601f19603f3d011682016040523d82523d5f602084013e6144f5565b606091505b5091509150613a4f86838387614552565b5f81815260018301602052604081205461454b57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610a88565b505f610a88565b606083156145c05782515f036145b9576001600160a01b0385163b6145b95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c92565b5081611373565b61137383838151156145d55781518083602001fd5b8060405162461bcd60e51b8152600401610c9291905b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b5f60208284031215614630575f80fd5b5035919050565b6001600160a01b0381168114612cdf575f80fd5b803561465681614637565b919050565b5f806040838503121561466c575f80fd5b823561467781614637565b946020939093013593505050565b5f8060408385031215614696575f80fd5b82356146a181614637565b915060208301356001600160401b03811681146146bc575f80fd5b809150509250929050565b6001600160a01b0391909116815260200190565b5f805f606084860312156146ed575f80fd5b83356146f881614637565b9250602084013561470881614637565b929592945050506040919091013590565b5f60208284031215614729575f80fd5b8135610ba881614637565b61ffff81168114612cdf575f80fd5b5f60208284031215614753575f80fd5b8135610ba881614734565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b038111828210171561479a5761479a61475e565b604052919050565b5f6001600160401b038211156147ba576147ba61475e565b5060051b60200190565b5f82601f8301126147d3575f80fd5b81356147e66147e1826147a2565b614772565b8082825260208201915060208360051b860101925085831115614807575f80fd5b602085015b8381101561482d57803561481f81614637565b83526020928301920161480c565b5095945050505050565b5f805f60608486031215614849575f80fd5b83356001600160401b0381111561485e575f80fd5b61486a868287016147c4565b93505060208401356001600160401b03811115614885575f80fd5b8401601f81018613614895575f80fd5b80356148a36147e1826147a2565b8082825260208201915060208360051b8501019250888311156148c4575f80fd5b6020840193505b828410156148e65783358252602093840193909101906148cb565b94506148f8925050506040850161464b565b90509250925092565b5f8060408385031215614912575f80fd5b82356001600160401b03811115614927575f80fd5b614933858286016147c4565b92505060208301356001600160401b0381111561494e575f80fd5b8301601f8101851361495e575f80fd5b803561496c6147e1826147a2565b8082825260208201915060208360051b85010192508783111561498d575f80fd5b6020840193505b828410156149c35783356001600160801b03811681146149b2575f80fd5b825260209384019390910190614994565b809450505050509250929050565b5f80604083850312156149e2575f80fd5b82356149ed81614637565b915060208301356001600160401b03811115614a07575f80fd5b8301601f81018513614a17575f80fd5b80356001600160401b03811115614a3057614a3061475e565b614a43601f8201601f1916602001614772565b818152866020838501011115614a57575f80fd5b816020840160208301375f602083830101528093505050509250929050565b5f8060408385031215614a87575f80fd5b8235915060208301356146bc81614637565b5f8151808452602084019350602083015f5b82811015614ad25781516001600160a01b0316865260209586019590910190600101614aab565b5093949350505050565b602081525f610ba86020830184614a99565b604081525f614b006040830185614a99565b82810360208401528084518083526020830191506020860192505f5b81811015614b3a578351835260209384019390920191600101614b1c565b50909695505050505050565b5f60208284031215614b56575f80fd5b81356001600160401b03811115614b6b575f80fd5b820160808185031215610ba8575f80fd5b5f805f60608486031215614b8e575f80fd5b833592506020840135614ba081614637565b91506040840135614bb081614637565b809150509250925092565b5f8060408385031215614bcc575f80fd5b8235614bd781614637565b915060208301356146bc81614637565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b80820180821115610a8857610a88614bfb565b6001815b60018411156135c857808504811115614c4157614c41614bfb565b6001841615614c4f57908102905b60019390931c928002614c26565b5f82614c6b57506001610a88565b81614c7757505f610a88565b8160018114614c8d5760028114614c9757614cb3565b6001915050610a88565b60ff841115614ca857614ca8614bfb565b50506001821b610a88565b5060208310610133831016604e8410600b8410161715614cd6575081810a610a88565b614ce25f198484614c22565b805f1904821115614cf557614cf5614bfb565b029392505050565b5f610ba860ff841683614c5d565b600181811c90821680614d1f57607f821691505b602082108103614d3d57634e487b7160e01b5f52602260045260245ffd5b50919050565b8082028115828204841417610a8857610a88614bfb565b60ff8181168382160190811115610a8857610a88614bfb565b6020808252602d908201527f436f6c6c5661756c743a20746f6b656e7320616e6420616d6f756e7473206c6560408201526c0dccee8d040dad2e6dac2e8c6d609b1b606082015260800190565b5f60208284031215614dd0575f80fd5b5051919050565b81810381811115610a8857610a88614bfb565b634e487b7160e01b5f52601260045260245ffd5b5f82614e1857634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215614e2d575f80fd5b8151610ba881614637565b5f60208284031215614e48575f80fd5b81516001600160401b03811115614e5d575f80fd5b8201601f81018413614e6d575f80fd5b8051614e7b6147e1826147a2565b8082825260208201915060208360051b850101925086831115614e9c575f80fd5b6020840193505b82841015613a4f578351614eb681614637565b825260209384019390910190614ea3565b6001600160a01b0392831681529116602082015260400190565b805160ff81168114614656575f80fd5b5f60208284031215614f01575f80fd5b610ba882614ee1565b5f808335601e19843603018112614f1f575f80fd5b8301803591506001600160401b03821115614f38575f80fd5b602001915036819003821315614f4c575f80fd5b9250929050565b6001600160a01b03868116825260208201869052841660408201526080606082018190528101829052818360a08301375f81830160a090810191909152601f909201601f19160101949350505050565b6001600160a01b039390931683526020830191909152604082015260600190565b60ff8281168282160390811115610a8857610a88614bfb565b6001600160a01b03929092168252602082015260400190565b80518015158114614656575f80fd5b5f60208284031215615015575f80fd5b610ba882614ff6565b5f805f805f60a08688031215615032575f80fd5b855161503d81614637565b945061504b60208701614ee1565b9350604086015163ffffffff81168114615063575f80fd5b606087015190935061507481614734565b608087015190925061508581614637565b809150509295509295909350565b5f60408284031280156150a4575f80fd5b50604080519081016001600160401b03811182821017156150c7576150c761475e565b60405282516150d581614637565b81526150e360208401614ff6565b60208201529392505050565b634e487b7160e01b5f52602160045260245ffd5b5f82518060208501845e5f92019182525091905056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212205b958f8f3ccf25cdbcfee6fd3aa05630cad99e2e8ade941f83dc468e4b64f0d764736f6c634300081a0033
Deployed Bytecode
0x6080604052600436106102e3575f3560e01c806370a0823111610181578063ba087652116100d4578063d9c0019711610083578063d9c0019714610880578063dd62ed3e1461089f578063e993e7ed146108be578063ec05c341146108d2578063ef8b30f714610804578063f8b2cb4f146108f1578063fd64c37714610910575f80fd5b8063ba087652146107d1578063c2d41601146107f0578063c63d75b61461052a578063c6e6f59214610804578063ce96cb7714610823578063d5c16d7914610842578063d905777e14610861575f80fd5b8063aa290e6d11610130578063aa290e6d146106e2578063aaffe07614610701578063ad3cb1cc14610722578063b009c92c14610752578063b2c06ba014610774578063b3d7f6b914610793578063b460af94146107b2575f80fd5b806370a082311461061f578063748747e61461063e57806394bf804d1461065d57806395d89b411461067c5780639a400b0f146106905780639e87a5cd146106af578063a9059cbb146106c3575f80fd5b8063322ce8f01161023957806341519a65116101e857806341519a651461056857806341976e09146105875780634cdad506146105a65780634f1ef286146105c557806352d1902d146105d85780636ab3b0e5146105ec5780636e553f6514610600575f80fd5b8063322ce8f0146104a557806332e1fef2146104c457806338d52e0f146104e35780633dafa4f3146104f75780633e92f95b1461050b578063402d267d1461052a578063403dd3bc14610549575f80fd5b80631540aa89116102955780631540aa89146103d157806318160ddd146103f8578063221085d71461040c578063235c36031461042d57806323b872dd1461044157806329d78c8814610460578063313ce5671461047f575f80fd5b806301e1d114146102e757806306fdde031461030e57806307a2d13a1461032f578063095ea7b31461034e5780630a28a4771461037d5780630b983a741461039c5780630fdb11cf146103bd575b5f80fd5b3480156102f2575f80fd5b506102fb610924565b6040519081526020015b60405180910390f35b348015610319575f80fd5b506103226109df565b60405161030591906145eb565b34801561033a575f80fd5b506102fb610349366004614620565b610a7d565b348015610359575f80fd5b5061036d61036836600461465b565b610a8e565b6040519015158152602001610305565b348015610388575f80fd5b506102fb610397366004614620565b610aa5565b3480156103a7575f80fd5b506103bb6103b6366004614685565b610ab8565b005b3480156103c8575f80fd5b506102fb610ad8565b3480156103dc575f80fd5b506103e5610b33565b60405161ffff9091168152602001610305565b348015610403575f80fd5b506102fb610b4e565b348015610417575f80fd5b50610420610b62565b60405161030591906146c7565b348015610438575f80fd5b506103e5610b81565b34801561044c575f80fd5b5061036d61045b3660046146db565b610b8a565b34801561046b575f80fd5b506102fb61047a366004614719565b610baf565b34801561048a575f80fd5b50610493610bd6565b60405160ff9091168152602001610305565b3480156104b0575f80fd5b506103bb6104bf366004614743565b610c00565b3480156104cf575f80fd5b506103bb6104de366004614837565b610cbd565b3480156104ee575f80fd5b50610420610f5a565b348015610502575f80fd5b50610420610f74565b348015610516575f80fd5b506103bb610525366004614901565b610f8f565b348015610535575f80fd5b506102fb610544366004614719565b6112f2565b348015610554575f80fd5b506102fb610563366004614719565b6112f8565b348015610573575f80fd5b506103bb610582366004614719565b61137b565b348015610592575f80fd5b506102fb6105a1366004614719565b6113bb565b3480156105b1575f80fd5b506102fb6105c0366004614620565b61142e565b6103bb6105d33660046149d1565b611439565b3480156105e3575f80fd5b506102fb611454565b3480156105f7575f80fd5b5061042061146f565b34801561060b575f80fd5b506102fb61061a366004614a76565b61148a565b34801561062a575f80fd5b506102fb610639366004614719565b6114b9565b348015610649575f80fd5b506103bb610658366004614719565b6114e2565b348015610668575f80fd5b506102fb610677366004614a76565b61152e565b348015610687575f80fd5b5061032261155d565b34801561069b575f80fd5b506103bb6106aa36600461465b565b611579565b3480156106ba575f80fd5b506104206115f9565b3480156106ce575f80fd5b5061036d6106dd36600461465b565b61167c565b3480156106ed575f80fd5b506103bb6106fc366004614743565b611689565b34801561070c575f80fd5b5061071561172a565b6040516103059190614adc565b34801561072d575f80fd5b50610322604051806040016040528060058152602001640352e302e360dc1b81525081565b34801561075d575f80fd5b5061076661173f565b604051610305929190614aee565b34801561077f575f80fd5b506103bb61078e366004614b46565b611a20565b34801561079e575f80fd5b506102fb6107ad366004614620565b6120a6565b3480156107bd575f80fd5b506102fb6107cc366004614b7c565b6120b2565b3480156107dc575f80fd5b506102fb6107eb366004614b7c565b61215e565b3480156107fb575f80fd5b506104936121ee565b34801561080f575f80fd5b506102fb61081e366004614620565b612207565b34801561082e575f80fd5b506102fb61083d366004614719565b612212565b34801561084d575f80fd5b506102fb61085c366004614719565b61221f565b34801561086c575f80fd5b506102fb61087b366004614719565b612292565b34801561088b575f80fd5b506102fb61089a366004614719565b61229c565b3480156108aa575f80fd5b506102fb6108b9366004614bbb565b61230f565b3480156108c9575f80fd5b50610420612349565b3480156108dd575f80fd5b506102fb6108ec366004614719565b612368565b3480156108fc575f80fd5b506102fb61090b366004614719565b6123f8565b34801561091b575f80fd5b5061042061240b565b5f805f61092f61172a565b80519091505f6109406105a1610f5a565b90505f61095361094e610f5a565b612426565b6109675761096261090b610f5a565b610969565b5f5b90505f5b838110156109ab5761099785828151811061098a5761098a614be7565b6020026020010151612368565b6109a19087614c0f565b955060010161096d565b50806109cb6109b86121ee565b6109c390600a614cfd565b87908561243c565b6109d59190614c0f565b9550505050505090565b60605f6109ea6124e5565b90508060030180546109fb90614d0b565b80601f0160208091040260200160405190810160405280929190818152602001828054610a2790614d0b565b8015610a725780601f10610a4957610100808354040283529160200191610a72565b820191905f5260205f20905b815481529060010190602001808311610a5557829003601f168201915b505050505091505090565b5f610a88825f612509565b92915050565b5f33610a9b81858561254e565b5060019392505050565b5f80610ab083612560565b509392505050565b610ac06125c1565b610ad48282610acd612695565b91906126a6565b5050565b5f80610ae2610b4e565b9050805f03610af2575f91505090565b610b2d610b006105a1610f5a565b82610b09612757565b610b1490600a614cfd565b610b1c610924565b610b269190614d43565b919061243c565b91505090565b5f610b3c61276b565b54640100000000900461ffff16919050565b5f80610b586124e5565b6002015492915050565b5f610b6b61276b565b54600160381b90046001600160a01b0316919050565b5f610b3c61278f565b5f33610b978582856127b3565b610ba2858585612803565b60019150505b9392505050565b5f610bb8612695565b6001600160a01b039092165f90815260209290925250604090205490565b5f80610be0612860565b9050610bea612757565b8154610b2d9190600160a01b900460ff16614d5a565b610c086125c1565b5f610c1161276b565b805490915061ffff90811690831610801590610c3c5750805461ffff62010000909104811690831611155b610c9b5760405162461bcd60e51b815260206004820152602560248201527f436f6c6c5661756c743a20576974686472617720666565206f7574206f6620626044820152646f756e647360d81b60648201526084015b60405180910390fd5b805461ffff9092166401000000000265ffff0000000019909216919091179055565b610cc56125c1565b5f610cce61276b565b84518451919250908114610cf45760405162461bcd60e51b8152600401610c9290614d73565b5f610cfd610f5a565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610d2891906146c7565b602060405180830381865afa158015610d43573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d679190614dc0565b90505f6001840181610d77610f5a565b6001600160a01b03166001600160a01b031681526020019081526020015f2054905080821115610dc757610dc785610daf8385614dd7565b610db7610f5a565b6001600160a01b03169190612884565b5f5b83811015610f5057610dd9610f5a565b6001600160a01b0316888281518110610df457610df4614be7565b60200260200101516001600160a01b03160315610f48575f888281518110610e1e57610e1e614be7565b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610e5191906146c7565b602060405180830381865afa158015610e6c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e909190614dc0565b90505f866001015f015f8b8581518110610eac57610eac614be7565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f205490505f610f058a8581518110610eec57610eec614be7565b60200260200101518385610f009190614dd7565b6128da565b90508015610f4457610f4489828d8781518110610f2457610f24614be7565b60200260200101516001600160a01b03166128849092919063ffffffff16565b5050505b600101610dc9565b5050505050505050565b5f80610f64612860565b546001600160a01b031692915050565b5f610f7d61278f565b600501546001600160a01b0316919050565b610f976125c1565b815181518114610fb95760405162461bcd60e51b8152600401610c9290614d73565b5f610fc2610f74565b90505f610fcd61240b565b90505f610fd8610b81565b61ffff1690505f5b848110156112e9575f878281518110610ffb57610ffb614be7565b602002602001015190505f87838151811061101857611018614be7565b60200260200101516001600160801b03169050805f036110395750506112e1565b5f611042610f5a565b6001600160a01b0316836001600160a01b0316036110d157611062610f5a565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161108d91906146c7565b602060405180830381865afa1580156110a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110cc9190614dc0565b61114f565b6110da83610baf565b6040516370a0823160e01b81526001600160a01b038516906370a08231906111069030906004016146c7565b602060405180830381865afa158015611121573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111459190614dc0565b61114f9190614dd7565b9050818110156111a15760405162461bcd60e51b815260206004820152601f60248201527f436f6c6c5661756c743a20696e73756666696369656e742062616c616e6365006044820152606401610c92565b6111aa83612426565b6111f65760405162461bcd60e51b815260206004820152601d60248201527f436f6c6c5661756c743a20746f6b656e206e6f742072657761726465640000006044820152606401610c92565b5f6127106112048785614d43565b61120e9190614dfe565b90505f61121b8285614dd7565b9050611225610f5a565b6001600160a01b0316856001600160a01b03160361124657611246816128ef565b81156112c7576112c7611257610b62565b6001600160a01b031663b3f006746040518163ffffffff1660e01b8152600401602060405180830381865afa158015611292573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112b69190614e1d565b6001600160a01b0387169084612884565b6112db85826112d4612695565b9190612a28565b50505050505b600101610fe0565b50505050505050565b505f1990565b5f80611302612695565b6001600160a01b0384165f90815260019190910160209081526040808320815160608101835290546001600160801b03811682526001600160401b03600160801b8204811694830194909452600160c01b900490921690820152915061136782612aa0565b90506113738282612ad1565b949350505050565b6113836125c1565b8061138c61278f565b80546001600160a01b0392909216600160301b026601000000000000600160d01b031990921691909117905550565b5f6113c46115f9565b6001600160a01b031663ace1798e836040518263ffffffff1660e01b81526004016113ef91906146c7565b602060405180830381865afa15801561140a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a889190614dc0565b5f80610ab083612b58565b611441612c33565b61144a82612cd7565b610ad48282612ce2565b5f61145d612d95565b505f8051602061511a83398151915290565b5f61147861278f565b600301546001600160a01b0316919050565b5f611493612dde565b61149d83836131f7565b90506114a8836128ef565b610a886114b3610f5a565b84613243565b5f806114c36124e5565b6001600160a01b039093165f9081526020939093525050604090205490565b6114ea6125c1565b807f7c295a6235a8870762eedf177b0c47538f1234d5dd210c9bdc5ca11b722c7c005b80546001600160a01b0319166001600160a01b039290921691909117905550565b5f611537612dde565b611541838361327d565b905061154c816128ef565b610a88611557610f5a565b82613243565b60605f6115686124e5565b90508060040180546109fb90614d0b565b6115816125c1565b5f61158a61278f565b90506127108211156115da5760405162461bcd60e51b81526020600482015260196024820152780436f6c6c5661756c743a207468726573686f6c64203e20425603c1b6044820152606401610c92565b6001600160a01b039092165f9081526007909201602052604090912055565b5f61160261276b565b5f0160079054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611653573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116779190614e1d565b905090565b5f33610a9b818585612803565b6116916125c1565b611699612dde565b5f6116a261278f565b805490915061ffff908116908316108015906116cd5750805461ffff62010000909104811690831611155b610c9b5760405162461bcd60e51b815260206004820152602860248201527f436f6c6c5661756c743a20706572666f726d616e636520666565206f7574206f6044820152676620626f756e647360c01b6064820152608401610c92565b606061167761173761278f565b6001016132c9565b6060805f61174b61146f565b9050806001600160a01b03166312edb24c6040518163ffffffff1660e01b81526004015f60405180830381865afa158015611788573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526117af9190810190614e38565b925082516001600160401b038111156117ca576117ca61475e565b6040519080825280602002602001820160405280156117f3578160200160208202803683370190505b5091505f6117ff610b81565b61ffff1690505f61180e612349565b90505f611819610f74565b90505f61182461240b565b90505f5b8751811015611a16575f88828151811061184457611844614be7565b602002602001015190505f876001600160a01b031663211dc32d308c868151811061187157611871614be7565b60200260200101516040518363ffffffff1660e01b8152600401611896929190614ec7565b602060405180830381865afa1580156118b1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118d59190614dc0565b9050805f036118e5575050611a0e565b6001600160a01b03828116908616148080156119055750611905866132d5565b156119835760405163ef8b30f760e01b8152600481018390526001600160a01b0386169063ef8b30f790602401602060405180830381865afa15801561194d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119719190614dc0565b91508061197e5782611980565b845b92505b61198c836132d5565b80156119aa5750866001600160a01b0316836001600160a01b031614155b80156119bc57506119ba836133f2565b155b15611a0a575f6127106119cf8a85614d43565b6119d99190614dfe565b90505f6119e68285614dd7565b9050808c87815181106119fb576119fb614be7565b60200260200101818152505050505b5050505b600101611828565b5050505050509091565b337f7c295a6235a8870762eedf177b0c47538f1234d5dd210c9bdc5ca11b722c7c00546001600160a01b03161480611ac6575033611a5c610b62565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a97573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611abb9190614e1d565b6001600160a01b0316145b611b095760405162461bcd60e51b81526020600482015260146024820152732737ba1037bbb732b9103737b91035b2b2b832b960611b6044820152606401610c92565b611b11612dde565b5f611b1a61278f565b90505f611b2d6105a16020850185614719565b90505f611b3b6105a1610f5a565b90505f611b4b6020860186614719565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b86573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611baa9190614ef1565b90505f611bba6020870187614719565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611be591906146c7565b602060405180830381865afa158015611c00573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c249190614dc0565b90505f611c2f610f5a565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611c5a91906146c7565b602060405180830381865afa158015611c75573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c999190614dc0565b9050611cbf611cae6060890160408a01614719565b60208901803590610db7908b614719565b611ccf6060880160408901614719565b6001600160a01b0316637f0f41d7611cea60208a018a614719565b8960200135611cf7610f5a565b611d0460608d018d614f0a565b6040518663ffffffff1660e01b8152600401611d24959493929190614f53565b5f604051808303815f87803b158015611d3b575f80fd5b505af1158015611d4d573d5f803e3d5ffd5b505050505f81611d5b610f5a565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611d8691906146c7565b602060405180830381865afa158015611da1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611dc59190614dc0565b611dcf9190614dd7565b90505f611ddf60208a018a614719565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611e0a91906146c7565b602060405180830381865afa158015611e25573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e499190614dc0565b611e539085614dd7565b9050611e6561090b60208b018b614719565b811115611e8557604051630301465d60e11b815260040160405180910390fd5b611e8d612695565b6001015f611e99610f5a565b6001600160a01b0316815260208101919091526040015f90812054600160c01b90046001600160401b03169003611f2f5760405162461bcd60e51b815260206004820152603460248201527f436f6c6c5661756c743a206173736574206e65656473206120646566696e6564604482015273081d5b9b1bd8dad4985d1954195c94d958dbdb9960621b6064820152608401610c92565b5f611f4487611f3c6121ee565b8591906134aa565b90505f611f52838a896134aa565b905061271060078b015f611f6960208f018f614719565b6001600160a01b0316815260208101919091526040015f2054611f8e90612710614dd7565b611f989083614d43565b611fa29190614dfe565b8210156120075760405162461bcd60e51b815260206004820152602d60248201527f436f6c6c5661756c743a20726563656976656420616d6f756e7420697320626560448201526c1b1bddc81d1a1c995cda1bdb19609a1b6064820152608401610c92565b61201d61201760208d018d614719565b846134ca565b61202e612028610f5a565b85613243565b612037846134fb565b61204460208c018c614719565b6040805185815260208101879052908101839052606081018490526001600160a01b0391909116907f90fea00fe6e24ccfd7c40b40e07486e8b69ada2a3ad693dd908b6479cac36b6b9060800160405180910390a25050505050505050505050565b5f610a88826001612509565b5f6120bb612dde565b5f6120c4610b4e565b90505f6120d084612212565b9050808611156120f957838682604051633fa733bb60e21b8152600401610c9293929190614fa3565b505f61210486612560565b90935090505f80612116858585613504565b91509150815f1461213b5761212a826135d0565b61213b612135610f5a565b836134ca565b61214833888885896136bc565b612153878286613773565b505050509392505050565b5f612167612dde565b5f612170610b4e565b90505f61217c84612292565b9050808611156121a557838682604051632e52afbb60e21b8152600401610c9293929190614fa3565b505f6121b086612b58565b90935090505f806121c2888585613504565b91509150815f146121e1576121d6826135d0565b6121e1612135610f5a565b612148338888858c6136bc565b5f6121f761276b565b54600160301b900460ff16919050565b5f610a88825f6138e2565b5f610a886105c0836114b9565b5f80612229612695565b6001600160a01b0384165f9081526001919091016020908152604091829020825160608101845290546001600160801b03811682526001600160401b03600160801b8204811693830193909352600160c01b9004909116918101919091529050610ba881612aa0565b5f610a88826114b9565b5f806122a6612695565b6001600160a01b0384165f9081526001919091016020908152604091829020825160608101845290546001600160801b03811682526001600160401b03600160801b8204811693830193909352600160c01b9004909116918101919091529050610ba88161391e565b5f806123196124e5565b6001600160a01b039485165f90815260019190910160209081526040808320959096168252939093525050205490565b5f61235261278f565b54600160301b90046001600160a01b0316919050565b5f80612373836123f8565b90505f61237f846113bb565b90505f846001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123be573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123e29190614ef1565b90506123ef8383836134aa565b95945050505050565b5f610a8882612405612695565b90613953565b5f61241461278f565b600401546001600160a01b0316919050565b5f610a888261243361278f565b600101906139df565b5f80805f19858709858702925082811083820303915050805f036124735783828161246957612469614dea565b0492505050610ba8565b80841161247e575f80fd5b5f8486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091025f889003889004909101858311909403939093029303949094049190911702949350505050565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0090565b5f610ba8612515610924565b612520906001614c0f565b612528612757565b61253390600a614cfd565b61253b610b4e565b6125459190614c0f565b85919085613a00565b61255b8383836001613a59565b505050565b5f805f61256b61276b565b90505f61257785613b3a565b82549091505f906125a6906127109061259c90640100000000900461ffff1682614dd7565b8491906001613a00565b90505f6125b38383614dd7565b919791965090945050505050565b6125c9610b62565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612604573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126289190614e1d565b6001600160a01b0316336001600160a01b0316146126935760405162461bcd60e51b815260206004820152602260248201527f436f6c6c5661756c743a2063616c6c6572206973206e6f7420746865206f776e60448201526132b960f11b6064820152608401610c92565b565b5f61269e61276b565b600101905090565b64e8d4a510006001600160401b03821611156126d5576040516304bba2fb60e51b815260040160405180910390fd5b6126e083835f613b46565b6001600160a01b0382165f81815260018501602090815260409182902080546001600160c01b0316600160c01b6001600160401b0387169081029190911790915591519182527f5577d4c8f6e5397effa5c71df8fe221e1162e18aaa0aabe87026cfb0c676215091015b60405180910390a2505050565b5f6127606121ee565b611677906012614fc4565b7f19001df2d131e9aa1479f4ce661ae121445caf0662dea1e41907028a6da6fe0090565b7ff6a35052099d23fafed8c58b549933969c057c5a9a13ac5133024adc8dd4f20090565b5f6127be848461230f565b90505f1981146127fd57818110156127ef57828183604051637dc7a0d960e11b8152600401610c9293929190614fa3565b6127fd84848484035f613a59565b50505050565b6001600160a01b03831661282c575f604051634b637e8f60e11b8152600401610c9291906146c7565b6001600160a01b038216612855575f60405163ec442f0560e01b8152600401610c9291906146c7565b61255b838383613caa565b7f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e0090565b61255b8363a9059cbb60e01b84846040516024016128a3929190614fdd565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613dcd565b5f8183106128e85781610ba8565b5090919050565b5f6128f861278f565b600381015460068201549192506001600160a01b0390811691165f81156129ad576129368286612926610f5a565b6001600160a01b03169190613e9e565b6040516317a790f160e11b81526001600160a01b03831690632f4f21e2906129649030908990600401614fdd565b6020604051808303815f875af1158015612980573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129a49190615005565b508190506129b8565b6129b5610f5a565b90505b6129cc6001600160a01b0382168487613f9f565b60405163534a7e1d60e11b8152600481018690526001600160a01b0384169063a694fc3a906024015f604051808303815f87803b158015612a0b575f80fd5b505af1158015612a1d573d5f803e3d5ffd5b505050505050505050565b806001600160801b03165f03612a515760405163d11b25af60e01b815260040160405180910390fd5b612a5c838383613b46565b6040516001600160801b03821681526001600160a01b038316907f693ffe037fd29f4846b006bd3ada57d4fd4c3622277227342f0e4fed9011dc209060200161274a565b60208101515f906001600160401b0316612ac764e8d4a51000612ac28561391e565b614039565b610a889190614c0f565b5f814210612ae057505f610a88565b5f83602001516001600160401b031642612afa9190614dd7565b90505f81612b078661391e565b612b119190614d43565b855190915064e8d4a5100090612b30906001600160801b031683614d43565b612b3a9190614dfe565b8551612b4f91906001600160801b0316614dd7565b92505050610a88565b5f805f612b6361278f565b60048101549091505f906001600160a01b031630148015612bf15750612b876115f9565b6001600160a01b031663e1bdd0a6336040518263ffffffff1660e01b8152600401612bb291906146c7565b602060405180830381865afa158015612bcd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612bf19190615005565b90505f81612c1457612c0f612c04610b33565b879061ffff1661405b565b612c16565b5f5b90505f612c266103498389614dd7565b9791965090945050505050565b306001600160a01b037f000000000000000000000000cf2787690cd7d00f2ab90022339492bf21e1dbd3161480612cb957507f000000000000000000000000cf2787690cd7d00f2ab90022339492bf21e1dbd36001600160a01b0316612cad5f8051602061511a833981519152546001600160a01b031690565b6001600160a01b031614155b156126935760405163703e46dd60e11b815260040160405180910390fd5b612cdf6125c1565b50565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612d3c575060408051601f3d908101601f19168201909252612d3991810190614dc0565b60015b612d5b5781604051634c9c8ce360e01b8152600401610c9291906146c7565b5f8051602061511a8339815191528114612d8b57604051632a87526960e21b815260048101829052602401610c92565b61255b838361406b565b306001600160a01b037f000000000000000000000000cf2787690cd7d00f2ab90022339492bf21e1dbd316146126935760405163703e46dd60e11b815260040160405180910390fd5b612de661278f565b60060154600160a01b90046001600160601b03164203612e0257565b5f612e0b61146f565b90505f816001600160a01b03166312edb24c6040518163ffffffff1660e01b81526004015f60405180830381865afa158015612e49573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052612e709190810190614e38565b90505f81516001600160401b03811115612e8c57612e8c61475e565b604051908082528060200260200182016040528015612eb5578160200160208202803683370190505b5090505f5b8251811015612f6c57828181518110612ed557612ed5614be7565b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401612f0891906146c7565b602060405180830381865afa158015612f23573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f479190614dc0565b828281518110612f5957612f59614be7565b6020908102919091010152600101612eba565b50826001600160a01b0316633d18b9126040518163ffffffff1660e01b81526004015f604051808303815f87803b158015612fa5575f80fd5b505af1158015612fb7573d5f803e3d5ffd5b505050505f612fc4610b81565b61ffff1690505f612fd3612349565b90505f612fde610f74565b90505f612fe961240b565b90505f5b86518110156131bd575f87828151811061300957613009614be7565b602002602001015190505f816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161304091906146c7565b602060405180830381865afa15801561305b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061307f9190614dc0565b90505f88848151811061309457613094614be7565b6020026020010151826130a79190614dd7565b9050805f036130b8575050506131b5565b6130c1836132d5565b80156130df5750866001600160a01b0316836001600160a01b031614155b80156130f157506130ef836133f2565b155b156131b1575f6127106131048a84614d43565b61310e9190614dfe565b90505f61311b8284614dd7565b9050613125610f5a565b6001600160a01b0316856001600160a01b03160361314657613146816128ef565b6131508582613243565b613159856140c0565b81156131ae5761316a611257610b62565b846001600160a01b03167f620154c7367c3805aa5a57be3421bcd8ae0de705b07bb7880c7ebdd1eff84237836040516131a591815260200190565b60405180910390a25b50505b5050505b600101612fed565b50426131c761278f565b60060160146101000a8154816001600160601b0302191690836001600160601b0316021790555050505050505050565b5f80613202836112f2565b90508084111561322b57828482604051633c8097d960e11b8152600401610c9293929190614fa3565b5f61323585612207565b9050611373338587846140d8565b8061324c612695565b6001600160a01b0384165f908152602091909152604081208054909190613274908490614c0f565b90915550505050565b5f80613288836112f2565b9050808411156132b15782848260405163284ff66760e01b8152600401610c9293929190614fa3565b5f6132bb856120a6565b9050611373338583886140d8565b60605f610ba883614153565b5f806132df6115f9565b90505f816001600160a01b0316637cdde506856040518263ffffffff1660e01b815260040161330e91906146c7565b60a060405180830381865afa158015613329573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061334d919061501e565b5050505090505f826001600160a01b031663771bc577866040518263ffffffff1660e01b815260040161338091906146c7565b6040805180830381865afa15801561339a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906133be9190615093565b90506001600160a01b0382161515806133d8575080602001515b806123ef5750516001600160a01b03161515949350505050565b5f806133fc61278f565b60048101549091506001600160a01b03848116911614801561342b575060048101546001600160a01b03163014155b1561343857505f92915050565b6134406115f9565b6001600160a01b031663e1bdd0a6846040518263ffffffff1660e01b815260040161346b91906146c7565b602060405180830381865afa158015613486573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ba89190615005565b5f6134b682600a614cfd565b6134c08486614d43565b6113739190614dfe565b806134d3612695565b6001600160a01b0384165f908152602091909152604081208054909190613274908490614dd7565b612cdf816128ef565b5f805f61350f61276b565b90505f61351c8588614dd7565b90505f61353661352d61090b610f5a565b8390895f613a00565b90505f835f0160079054906101000a90046001600160a01b03166001600160a01b031663b3f006746040518163ffffffff1660e01b8152600401602060405180830381865afa15801561358b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906135af9190614e1d565b905086156135c1576135c181886141ac565b5093509150505b935093915050565b5f6135d961278f565b60068101546003820154604051632e1a7d4d60e01b8152600481018690529293506001600160a01b0391821692911690632e1a7d4d906024015f604051808303815f87803b158015613629575f80fd5b505af115801561363b573d5f803e3d5ffd5b505050506001600160a01b0381161561255b5760405163040b850f60e31b81526001600160a01b0382169063205c28789061367c9030908790600401614fdd565b6020604051808303815f875af1158015613698573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127fd9190615005565b5f6136c5612860565b9050836001600160a01b0316866001600160a01b0316146136eb576136eb8487846127b3565b6136f584836141e0565b805461370b906001600160a01b03168685612884565b836001600160a01b0316856001600160a01b0316876001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8686604051613763929190918252602082015260400190565b60405180910390a4505050505050565b5f61377c61278f565b90505f61378761172a565b80516004840154919250906001600160a01b03165f5b82811015610f50575f8482815181106137b8576137b8614be7565b602002602001015190506137ca610f5a565b6001600160a01b0316816001600160a01b0316036137e857506138da565b5f6137fe6137f5836123f8565b8a908a5f613a00565b9050805f0361380e5750506138da565b61381882826134ca565b836001600160a01b0316826001600160a01b031614801561384257506001600160a01b0384163014155b156138c357604051635d043b2960e11b8152600481018290526001600160a01b038b8116602483015230604483015283169063ba087652906064016020604051808303815f875af1158015613899573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906138bd9190614dc0565b506138d7565b6138d76001600160a01b0383168b83612884565b50505b60010161379d565b5f610ba86138ee612757565b6138f990600a614cfd565b613901610b4e565b61390b9190614c0f565b613913610924565b612545906001614c0f565b5f81604001516001600160401b03165f1461393d578160400151613944565b64174876e8005b6001600160401b031692915050565b6001600160a01b0381165f9081526001830160209081526040808320815160608101835290546001600160801b03811682526001600160401b03600160801b8204811694830194909452600160c01b9004909216908201526139bd816139b881612aa0565b612ad1565b6001600160a01b0384165f908152602086905260409020546113739190614dd7565b6001600160a01b0381165f9081526001830160205260408120541515610ba8565b5f80613a0d86868661243c565b90506001836002811115613a2357613a236150ef565b148015613a3f57505f8480613a3a57613a3a614dea565b868809115b156123ef57613a4f600182614c0f565b9695505050505050565b5f613a626124e5565b90506001600160a01b038516613a8d575f60405163e602df0560e01b8152600401610c9291906146c7565b6001600160a01b038416613ab6575f604051634a1406b160e11b8152600401610c9291906146c7565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115613b3357836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051613b2a91815260200190565b60405180910390a35b5050505050565b5f610a888260016138e2565b6001600160a01b0382165f9081526001840160209081526040808320815160608101835290546001600160801b03811682526001600160401b03600160801b8204811694830194909452600160c01b90049092169082015290613ba882612aa0565b90505f613bd1846001600160801b0316613bc28585612ad1565b613bcc9190614c0f565b614214565b6001600160801b03811684529050613be842614280565b6001600160401b03166020808501919091526001600160a01b0386165f908152908790526040812080546001600160801b0387169290613c29908490614c0f565b909155505050506001600160a01b03929092165f9081526001939093016020908152604093849020835181549285015194909501516001600160801b039095166001600160c01b031990921691909117600160801b6001600160401b0394851602176001600160c01b0316600160c01b939094169290920292909217905550565b5f613cb36124e5565b90506001600160a01b038416613ce15781816002015f828254613cd69190614c0f565b90915550613d3e9050565b6001600160a01b0384165f9081526020829052604090205482811015613d205784818460405163391434e360e21b8152600401610c9293929190614fa3565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b038316613d5c576002810180548390039055613d7a565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051613dbf91815260200190565b60405180910390a350505050565b5f613e21826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166142e79092919063ffffffff16565b80519091501561255b5780806020019051810190613e3f9190615005565b61255b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610c92565b801580613f155750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90613ed49030908690600401614ec7565b602060405180830381865afa158015613eef573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613f139190614dc0565b155b613f805760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610c92565b61255b8363095ea7b360e01b84846040516024016128a3929190614fdd565b5f81846001600160a01b031663dd62ed3e30866040518363ffffffff1660e01b8152600401613fcf929190614ec7565b602060405180830381865afa158015613fea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061400e9190614dc0565b6140189190614c0f565b90506127fd8463095ea7b360e01b85846040516024016128a3929190614fdd565b5f8160016140478286614c0f565b6140519190614dd7565b610ba89190614dfe565b5f610ba883836127106001613a00565b614074826142f5565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156140b85761255b8282614335565b610ad461435a565b5f6140c961278f565b905061255b6001820183614379565b5f6140e1612860565b80549091506140fb906001600160a01b031686308661438d565b61410584836141ac565b836001600160a01b0316856001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051613b2a929190918252602082015260400190565b6060815f018054806020026020016040519081016040528092919081815260200182805480156141a057602002820191905f5260205f20905b81548152602001906001019080831161418c575b50505050509050919050565b6001600160a01b0382166141d5575f60405163ec442f0560e01b8152600401610c9291906146c7565b610ad45f8383613caa565b6001600160a01b038216614209575f604051634b637e8f60e11b8152600401610c9291906146c7565b610ad4825f83613caa565b5f6001600160801b0382111561427c5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b6064820152608401610c92565b5090565b5f6001600160401b0382111561427c5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b6064820152608401610c92565b606061137384845f856143c5565b806001600160a01b03163b5f036143215780604051634c9c8ce360e01b8152600401610c9291906146c7565b805f8051602061511a83398151915261150d565b6060610ba8838360405180606001604052806027815260200161513a6027913961449c565b34156126935760405163b398979f60e01b815260040160405180910390fd5b5f610ba8836001600160a01b038416614506565b6040516001600160a01b03808516602483015283166044820152606481018290526127fd9085906323b872dd60e01b906084016128a3565b6060824710156144265760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610c92565b5f80866001600160a01b031685876040516144419190615103565b5f6040518083038185875af1925050503d805f811461447b576040519150601f19603f3d011682016040523d82523d5f602084013e614480565b606091505b509150915061449187838387614552565b979650505050505050565b60605f80856001600160a01b0316856040516144b89190615103565b5f60405180830381855af49150503d805f81146144f0576040519150601f19603f3d011682016040523d82523d5f602084013e6144f5565b606091505b5091509150613a4f86838387614552565b5f81815260018301602052604081205461454b57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610a88565b505f610a88565b606083156145c05782515f036145b9576001600160a01b0385163b6145b95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c92565b5081611373565b61137383838151156145d55781518083602001fd5b8060405162461bcd60e51b8152600401610c9291905b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b5f60208284031215614630575f80fd5b5035919050565b6001600160a01b0381168114612cdf575f80fd5b803561465681614637565b919050565b5f806040838503121561466c575f80fd5b823561467781614637565b946020939093013593505050565b5f8060408385031215614696575f80fd5b82356146a181614637565b915060208301356001600160401b03811681146146bc575f80fd5b809150509250929050565b6001600160a01b0391909116815260200190565b5f805f606084860312156146ed575f80fd5b83356146f881614637565b9250602084013561470881614637565b929592945050506040919091013590565b5f60208284031215614729575f80fd5b8135610ba881614637565b61ffff81168114612cdf575f80fd5b5f60208284031215614753575f80fd5b8135610ba881614734565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b038111828210171561479a5761479a61475e565b604052919050565b5f6001600160401b038211156147ba576147ba61475e565b5060051b60200190565b5f82601f8301126147d3575f80fd5b81356147e66147e1826147a2565b614772565b8082825260208201915060208360051b860101925085831115614807575f80fd5b602085015b8381101561482d57803561481f81614637565b83526020928301920161480c565b5095945050505050565b5f805f60608486031215614849575f80fd5b83356001600160401b0381111561485e575f80fd5b61486a868287016147c4565b93505060208401356001600160401b03811115614885575f80fd5b8401601f81018613614895575f80fd5b80356148a36147e1826147a2565b8082825260208201915060208360051b8501019250888311156148c4575f80fd5b6020840193505b828410156148e65783358252602093840193909101906148cb565b94506148f8925050506040850161464b565b90509250925092565b5f8060408385031215614912575f80fd5b82356001600160401b03811115614927575f80fd5b614933858286016147c4565b92505060208301356001600160401b0381111561494e575f80fd5b8301601f8101851361495e575f80fd5b803561496c6147e1826147a2565b8082825260208201915060208360051b85010192508783111561498d575f80fd5b6020840193505b828410156149c35783356001600160801b03811681146149b2575f80fd5b825260209384019390910190614994565b809450505050509250929050565b5f80604083850312156149e2575f80fd5b82356149ed81614637565b915060208301356001600160401b03811115614a07575f80fd5b8301601f81018513614a17575f80fd5b80356001600160401b03811115614a3057614a3061475e565b614a43601f8201601f1916602001614772565b818152866020838501011115614a57575f80fd5b816020840160208301375f602083830101528093505050509250929050565b5f8060408385031215614a87575f80fd5b8235915060208301356146bc81614637565b5f8151808452602084019350602083015f5b82811015614ad25781516001600160a01b0316865260209586019590910190600101614aab565b5093949350505050565b602081525f610ba86020830184614a99565b604081525f614b006040830185614a99565b82810360208401528084518083526020830191506020860192505f5b81811015614b3a578351835260209384019390920191600101614b1c565b50909695505050505050565b5f60208284031215614b56575f80fd5b81356001600160401b03811115614b6b575f80fd5b820160808185031215610ba8575f80fd5b5f805f60608486031215614b8e575f80fd5b833592506020840135614ba081614637565b91506040840135614bb081614637565b809150509250925092565b5f8060408385031215614bcc575f80fd5b8235614bd781614637565b915060208301356146bc81614637565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b80820180821115610a8857610a88614bfb565b6001815b60018411156135c857808504811115614c4157614c41614bfb565b6001841615614c4f57908102905b60019390931c928002614c26565b5f82614c6b57506001610a88565b81614c7757505f610a88565b8160018114614c8d5760028114614c9757614cb3565b6001915050610a88565b60ff841115614ca857614ca8614bfb565b50506001821b610a88565b5060208310610133831016604e8410600b8410161715614cd6575081810a610a88565b614ce25f198484614c22565b805f1904821115614cf557614cf5614bfb565b029392505050565b5f610ba860ff841683614c5d565b600181811c90821680614d1f57607f821691505b602082108103614d3d57634e487b7160e01b5f52602260045260245ffd5b50919050565b8082028115828204841417610a8857610a88614bfb565b60ff8181168382160190811115610a8857610a88614bfb565b6020808252602d908201527f436f6c6c5661756c743a20746f6b656e7320616e6420616d6f756e7473206c6560408201526c0dccee8d040dad2e6dac2e8c6d609b1b606082015260800190565b5f60208284031215614dd0575f80fd5b5051919050565b81810381811115610a8857610a88614bfb565b634e487b7160e01b5f52601260045260245ffd5b5f82614e1857634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215614e2d575f80fd5b8151610ba881614637565b5f60208284031215614e48575f80fd5b81516001600160401b03811115614e5d575f80fd5b8201601f81018413614e6d575f80fd5b8051614e7b6147e1826147a2565b8082825260208201915060208360051b850101925086831115614e9c575f80fd5b6020840193505b82841015613a4f578351614eb681614637565b825260209384019390910190614ea3565b6001600160a01b0392831681529116602082015260400190565b805160ff81168114614656575f80fd5b5f60208284031215614f01575f80fd5b610ba882614ee1565b5f808335601e19843603018112614f1f575f80fd5b8301803591506001600160401b03821115614f38575f80fd5b602001915036819003821315614f4c575f80fd5b9250929050565b6001600160a01b03868116825260208201869052841660408201526080606082018190528101829052818360a08301375f81830160a090810191909152601f909201601f19160101949350505050565b6001600160a01b039390931683526020830191909152604082015260600190565b60ff8281168282160390811115610a8857610a88614bfb565b6001600160a01b03929092168252602082015260400190565b80518015158114614656575f80fd5b5f60208284031215615015575f80fd5b610ba882614ff6565b5f805f805f60a08688031215615032575f80fd5b855161503d81614637565b945061504b60208701614ee1565b9350604086015163ffffffff81168114615063575f80fd5b606087015190935061507481614734565b608087015190925061508581614637565b809150509295509295909350565b5f60408284031280156150a4575f80fd5b50604080519081016001600160401b03811182821017156150c7576150c761475e565b60405282516150d581614637565b81526150e360208401614ff6565b60208201529392505050565b634e487b7160e01b5f52602160045260245ffd5b5f82518060208501845e5f92019182525091905056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212205b958f8f3ccf25cdbcfee6fd3aa05630cad99e2e8ade941f83dc468e4b64f0d764736f6c634300081a0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
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.