Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
RebalancePool
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import { ERC4626Upgradeable, IERC4626Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import { IRebalancePool } from "./interfaces/IRebalancePool.sol"; import { IAToken } from "./interfaces/IAToken.sol"; import { IPriceOracle } from "./interfaces/IPriceOracle.sol"; import { FullMath } from "./libs/math/FullMath.sol"; import { CustomRevert } from "./libs/CustomRevert.sol"; /** * @title RebalancePool * @notice A vault that handles the rebalance of assets, managing deposits and redemptions while distributing yield * @dev Implements ERC4626 with additional features for yield distribution and rebalancing */ contract RebalancePool is ERC4626Upgradeable, AccessControlUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable, IRebalancePool { using SafeERC20Upgradeable for IERC20Upgradeable; using CustomRevert for bytes4; // Roles bytes32 public constant PROTOCOL_ROLE = keccak256("PROTOCOL_ROLE"); bytes32 public constant TREASURY_ROLE = keccak256("TREASURY_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); // Addresses address public protocolAddress; address public treasuryAddress; address public aTokenAddress; address public priceOracleAddress; // Tokens and providers IAToken public aToken; IPriceOracle public priceOracle; // Fee and precision constants uint256 public yieldFeePercentage; // In basis points (e.g., 2000 = 20%) uint256 private lastTotalAssets; uint256 public PRECISION = 1e18; uint256 public constant MAXIMUM_COOLING_PERIOD = 2 days; uint256 public constant BASE_POINTS = 10_000; uint256 public MINIMUM_DEPOSIT_AMOUNT; uint256 public COOLING_PERIOD; // Mappings for deposit times and NAV updates mapping(address => LastDeposit) public lastDeposits; mapping(address => uint256) public lastNavUpdate; // Structure to track deposits struct LastDeposit { uint256 timestamp; uint256 amount; address depositor; } address[] public additionalTokens; mapping(address => bool) public isAdditionalToken; // Decimals uint8 private _decimals; /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} /** * @notice Initializes the RebalancePool contract */ function initialize( address admin, string memory name, string memory symbol, address _aToken, address _protocol, address _treasury, address _priceOracle, uint256 _yieldFeePercentage, uint256 _minimumDepositAmount ) external initializer { if (_aToken == address(0) || _protocol == address(0) || _treasury == address(0) || admin == address(0)) { IRebalancePool.ZeroAddress.selector.revertWith(); } if (_minimumDepositAmount == 0) { IRebalancePool.ZeroDeposit.selector.revertWith(); } if (_yieldFeePercentage > BASE_POINTS) { // 10000 basis points = 100% IRebalancePool.InvalidYieldFee.selector.revertWith(); } __ERC4626_init(IERC20Upgradeable(_aToken)); __ERC20_init(name, symbol); __AccessControl_init(); __Pausable_init(); __ReentrancyGuard_init(); aToken = IAToken(_aToken); _decimals = 18; PRECISION = 10 ** uint256(_decimals); _grantRole(DEFAULT_ADMIN_ROLE, admin); _grantRole(PROTOCOL_ROLE, _protocol); _grantRole(TREASURY_ROLE, _treasury); _grantRole(PAUSER_ROLE, admin); protocolAddress = _protocol; treasuryAddress = _treasury; aTokenAddress = _aToken; priceOracleAddress = _priceOracle; priceOracle = IPriceOracle(_priceOracle); yieldFeePercentage = _yieldFeePercentage; MINIMUM_DEPOSIT_AMOUNT = _minimumDepositAmount; lastTotalAssets = 0; // Initialize to zero COOLING_PERIOD = 1; // Default cooling period } /** * @notice Prevents the contract from receiving Ether directly. */ receive() external payable { IRebalancePool.NotPermitted.selector.revertWith(); } /** * @notice Fallback function to prevent unintended Ether transfers. */ fallback() external payable { IRebalancePool.NotPermitted.selector.revertWith(); } /** * @notice Returns the number of decimals used to get its user representation. * @return The number of decimals. */ function decimals() public view virtual override(ERC4626Upgradeable, IRebalancePool) returns (uint8) { return 18; } /** * @notice Calculates the total assets managed by the vault. * @return The total assets. */ function totalAssets() public view virtual override(ERC4626Upgradeable, IERC4626Upgradeable) returns (uint256) { uint256 aTokenBalance = aToken.balanceOf(address(this)); return aTokenBalance; } /** * @notice Allows depositing assets into the vault. * @param assets The amount of assets to deposit. * @param receiver The address receiving the shares. * @return shares The amount of shares minted. */ function deposit( uint256 assets, address receiver ) public virtual override(ERC4626Upgradeable, IERC4626Upgradeable) nonReentrant whenNotPaused onlyRole(PROTOCOL_ROLE) returns (uint256) { if (assets == 0) { IRebalancePool.ZeroDeposit.selector.revertWith(); } // Require a minimum deposit amount if (assets < MINIMUM_DEPOSIT_AMOUNT) { IRebalancePool.InvalidDepositAmount.selector.revertWith(); } lastTotalAssets += assets; address depositor = _msgSender(); lastDeposits[receiver] = LastDeposit({ timestamp: block.timestamp, depositor: depositor, amount: assets }); uint256 shares = super.deposit(assets, receiver); emit DepositMade(depositor, receiver, assets); return shares; } /** * @notice Allows minting shares by depositing assets. * param shares The amount of shares to mint. * param receiver The address receiving the shares. * @return assets The amount of assets deposited. */ function mint( uint256, address ) public virtual override(ERC4626Upgradeable, IERC4626Upgradeable) nonReentrant whenNotPaused returns (uint256) { IRebalancePool.NotPermitted.selector.revertWith(); } /** * @notice Allows withdrawing assets from the vault. * param assets The amount of assets to withdraw. * param receiver The address receiving the assets. * param owner The owner of the shares. * @return shares The amount of shares burned. */ function withdraw( uint256, address, address ) public virtual override(ERC4626Upgradeable, IERC4626Upgradeable) nonReentrant whenNotPaused returns (uint256) { IRebalancePool.NotPermitted.selector.revertWith(); } /** * @notice Allows redeeming shares for assets. * @param shares The amount of shares to redeem. * @param receiver The address receiving the assets. * @param owner The owner of the shares. * @return assets The amount of assets redeemed. */ function redeem( uint256 shares, address receiver, address owner ) public virtual override(ERC4626Upgradeable, IERC4626Upgradeable) nonReentrant whenNotPaused onlyRole(PROTOCOL_ROLE) returns (uint256) { if (shares == 0) { IRebalancePool.ZeroRedeem.selector.revertWith(); } if (block.timestamp < lastDeposits[owner].timestamp + COOLING_PERIOD) { IRebalancePool.RedeemingNotAvailableYet.selector.revertWith(); } uint256 userSharesBefore = balanceOf(owner); uint256 totalSharesBefore = totalSupply(); uint256 assets = super.redeem(shares, receiver, owner); _withdrawOtherERC20(owner, userSharesBefore, totalSharesBefore); return assets; } /** * @notice Adds an ERC20 token to the list of additional tokens held by the vault. * @dev Only callable by the admin. * @param token The address of the ERC20 token to add. */ function addAdditionalToken(address token) external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) { if (token == address(0)) { IRebalancePool.ZeroAddress.selector.revertWith(); } if (isAdditionalToken[token]) { IRebalancePool.TokenAlreadyAdded.selector.revertWith(token); } isAdditionalToken[token] = true; additionalTokens.push(token); } /** * @dev Internal function to withdraw other ERC20 tokens to the user proportionally to their shares. * @param user The address of the user. * @param userShares The number of shares owned by the user. * @param totalShares The total number of shares in existence. */ function _withdrawOtherERC20(address user, uint256 userShares, uint256 totalShares) internal { if (userShares == 0 || totalShares == 0) { IRebalancePool.ZeroShares.selector.revertWith(); } for (uint256 i = 0; i < additionalTokens.length; ) { address token = additionalTokens[i]; uint256 vaultBalance = IERC20Upgradeable(token).balanceOf(address(this)); if (vaultBalance > 0) { uint256 userTokenAmount = FullMath.mulDiv(vaultBalance, userShares, totalShares); if (userTokenAmount > 0) { IERC20Upgradeable(token).safeTransfer(user, userTokenAmount); emit OtherERC20Withdrawn(user, token, userTokenAmount); } } unchecked { ++i; } } } /** * @notice Updates the Net Asset Value (NAV) of the tokens. * @dev This function can be called by anyone as ERC4626 handles NAV updates automatically. */ function updateNAV() public override nonReentrant { lastNavUpdate[_msgSender()] = block.number; emit NAVUpdated(_msgSender(), totalAssets(), totalSupply()); } /** * @notice Returns the Net Asset Value (NAV) per share. * @return The NAV per share. */ function getNavPerShare() public view override returns (uint256) { uint256 totalAssetsValue = totalAssets(); uint256 totalShares = totalSupply(); uint256 price = 0; bool isValid; if (totalShares == 0) { if (address(priceOracle) == address(0)) { price = aToken.nav(); return price; } else { (isValid, price) = priceOracle.getPrice(address(aToken)); if (!isValid) IRebalancePool.InvalidPriceFromOracle.selector.revertWith(); return price; } } return (totalAssetsValue * aToken.nav()) / totalShares; } /** * @notice Returns the cooling-off period for redeeming shares. * @return The cooling-off period. */ function coolingOffPeriod() external view override returns (uint256) { return COOLING_PERIOD; } /** * @notice Sets the price oracle for the pool. * @param _priceOracle The new price oracle. */ function setPriceOracle(address _priceOracle) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_priceOracle == address(0)) { IRebalancePool.ZeroAddress.selector.revertWith(); } emit PriceOracleUpdated(address(priceOracle), _priceOracle); priceOracle = IPriceOracle(_priceOracle); } /** * @notice Sets the yield fee percentage. * @param _yieldFeePercentage The new yield fee percentage. */ function setYieldFeePercentage(uint256 _yieldFeePercentage) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_yieldFeePercentage > BASE_POINTS) { IRebalancePool.InvalidYieldFee.selector.revertWith(); } yieldFeePercentage = _yieldFeePercentage; emit YieldFeeUpdated(_yieldFeePercentage); } /** * @notice Transfers specified token to the treasury address. * @param token The address of the token to transfer. * @param amount The amount of tokens to transfer. */ function transferTokenToTreasury(address token, uint256 amount) external override nonReentrant whenNotPaused onlyRole(TREASURY_ROLE) { if (token == address(0) || token == address(this) || token == address(asset()) || isAdditionalToken[token]) { IRebalancePool.CannotRecoverToken.selector.revertWith(); } IERC20Upgradeable(token).safeTransfer(treasuryAddress, amount); } /** * @notice Sets the cooling period for redeeming shares. * @param _coolingPeriod The new cooling period. */ function setCoolingPeriod(uint256 _coolingPeriod) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_coolingPeriod > MAXIMUM_COOLING_PERIOD) { IRebalancePool.InvalidCoolingPeriod.selector.revertWith(); } emit CoolingOffPeriodUpdated(COOLING_PERIOD, _coolingPeriod); COOLING_PERIOD = _coolingPeriod; } /** * @notice Pauses the contract, preventing certain actions. */ function pause() external onlyRole(PAUSER_ROLE) { _pause(); } /** * @notice Unpauses the contract, allowing actions to be performed. */ function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) { _unpause(); } /** * @notice Allows the admin to recover ERC20 tokens mistakenly sent to the contract. * @param tokenAddress The address of the ERC20 token. * @param tokenAmount The amount of tokens to recover. */ function recoverERC20(address tokenAddress, uint256 tokenAmount) external nonReentrant whenNotPaused onlyRole(DEFAULT_ADMIN_ROLE) { if (tokenAddress == address(this) || tokenAddress == asset() || isAdditionalToken[tokenAddress]) { IRebalancePool.CannotRecoverToken.selector.revertWith(); } IERC20Upgradeable(tokenAddress).safeTransfer(_msgSender(), tokenAmount); } /** * @notice Hook that is called before any token transfer. * @param from The address tokens are transferred from. * @param to The address tokens are transferred to. * @param amount The amount of tokens transferred. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override whenNotPaused { if (from != address(0)) { // Ensure the cooling-off period is respected for the sender if (block.timestamp < lastDeposits[from].timestamp + COOLING_PERIOD) { IRebalancePool.CoolingPeriodTriggered.selector.revertWith(); } } if (to != address(0)) { lastDeposits[to] = LastDeposit({ timestamp: block.timestamp, depositor: from, amount: amount }); } super._beforeTokenTransfer(from, to, amount); } /** * @notice Prevents renouncing roles for security * @dev Overrides the default renounceRole function to prevent accidental role removal */ function renounceRole(bytes32, address) public virtual override { revert("Roles can't be renounced"); } /** * @notice Checks if the contract supports a specific interface. * @param interfaceId The interface identifier. * @return True if the interface is supported, false otherwise. */ function supportsInterface(bytes4 interfaceId) public view override(AccessControlUpgradeable) returns (bool) { return interfaceId == type(IRebalancePool).interfaceId || super.supportsInterface(interfaceId); } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC4626.sol) pragma solidity ^0.8.0; import "../ERC20Upgradeable.sol"; import "../utils/SafeERC20Upgradeable.sol"; import "../../../interfaces/IERC4626Upgradeable.sol"; import "../../../utils/math/MathUpgradeable.sol"; import {Initializable} from "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the ERC4626 "Tokenized Vault Standard" as defined in * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626]. * * This extension allows the minting and burning of "shares" (represented using the ERC20 inheritance) in exchange for * underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends * the ERC20 standard. Any additional extensions included along it would affect the "shares" token represented by this * contract and not the "assets" token which is an independent contract. * * [CAUTION] * ==== * 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 uses virtual assets and shares to 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, 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]. * ==== * * _Available since v4.7._ */ abstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626Upgradeable { using MathUpgradeable for uint256; IERC20Upgradeable private _asset; uint8 private _underlyingDecimals; /** * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777). */ function __ERC4626_init(IERC20Upgradeable asset_) internal onlyInitializing { __ERC4626_init_unchained(asset_); } function __ERC4626_init_unchained(IERC20Upgradeable asset_) internal onlyInitializing { (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(IERC20Upgradeable asset_) private view returns (bool, uint8) { (bool success, bytes memory encodedDecimals) = address(asset_).staticcall( abi.encodeWithSelector(IERC20MetadataUpgradeable.decimals.selector) ); 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(IERC20MetadataUpgradeable, ERC20Upgradeable) returns (uint8) { return _underlyingDecimals + _decimalsOffset(); } /** @dev See {IERC4626-asset}. */ function asset() public view virtual override returns (address) { return address(_asset); } /** @dev See {IERC4626-totalAssets}. */ function totalAssets() public view virtual override returns (uint256) { return _asset.balanceOf(address(this)); } /** @dev See {IERC4626-convertToShares}. */ function convertToShares(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4626-convertToAssets}. */ function convertToAssets(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4626-maxDeposit}. */ function maxDeposit(address) public view virtual override returns (uint256) { return type(uint256).max; } /** @dev See {IERC4626-maxMint}. */ function maxMint(address) public view virtual override returns (uint256) { return type(uint256).max; } /** @dev See {IERC4626-maxWithdraw}. */ function maxWithdraw(address owner) public view virtual override returns (uint256) { return _convertToAssets(balanceOf(owner), MathUpgradeable.Rounding.Down); } /** @dev See {IERC4626-maxRedeem}. */ function maxRedeem(address owner) public view virtual override returns (uint256) { return balanceOf(owner); } /** @dev See {IERC4626-previewDeposit}. */ function previewDeposit(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4626-previewMint}. */ function previewMint(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, MathUpgradeable.Rounding.Up); } /** @dev See {IERC4626-previewWithdraw}. */ function previewWithdraw(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, MathUpgradeable.Rounding.Up); } /** @dev See {IERC4626-previewRedeem}. */ function previewRedeem(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4626-deposit}. */ function deposit(uint256 assets, address receiver) public virtual override returns (uint256) { require(assets <= maxDeposit(receiver), "ERC4626: deposit more than max"); uint256 shares = previewDeposit(assets); _deposit(_msgSender(), receiver, assets, shares); return shares; } /** @dev See {IERC4626-mint}. * * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero. * In this case, the shares will be minted without requiring any assets to be deposited. */ function mint(uint256 shares, address receiver) public virtual override returns (uint256) { require(shares <= maxMint(receiver), "ERC4626: mint more than max"); uint256 assets = previewMint(shares); _deposit(_msgSender(), receiver, assets, shares); return assets; } /** @dev See {IERC4626-withdraw}. */ function withdraw(uint256 assets, address receiver, address owner) public virtual override returns (uint256) { require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max"); uint256 shares = previewWithdraw(assets); _withdraw(_msgSender(), receiver, owner, assets, shares); return shares; } /** @dev See {IERC4626-redeem}. */ function redeem(uint256 shares, address receiver, address owner) public virtual override returns (uint256) { require(shares <= maxRedeem(owner), "ERC4626: redeem more than max"); uint256 assets = previewRedeem(shares); _withdraw(_msgSender(), receiver, owner, assets, shares); return assets; } /** * @dev Internal conversion function (from assets to shares) with support for rounding direction. */ function _convertToShares(uint256 assets, MathUpgradeable.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, MathUpgradeable.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 { // If _asset is ERC777, `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 SafeERC20Upgradeable.safeTransferFrom(_asset, caller, address(this), assets); _mint(receiver, shares); emit Deposit(caller, receiver, assets, shares); } /** * @dev Withdraw/redeem common workflow. */ function _withdraw( address caller, address receiver, address owner, uint256 assets, uint256 shares ) internal virtual { if (caller != owner) { _spendAllowance(owner, caller, shares); } // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the // shares are burned and after the assets are transferred, which is a valid state. _burn(owner, shares); SafeERC20Upgradeable.safeTransfer(_asset, receiver, assets); emit Withdraw(caller, receiver, owner, assets, shares); } function _decimalsOffset() internal view virtual returns (uint8) { return 0; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation 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). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import { IERC4626Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; /** * @title IRebalancePool * @notice Interface for the RebalancePool contract implementing ERC4626 */ interface IRebalancePool is IERC4626Upgradeable { /// @notice Errors error ZeroAddress(); error ZeroDeposit(); error InvalidDepositAmount(); error ZeroRedeem(); error TokenAlreadyAdded(address token); error ZeroShares(); error InvalidPriceFromOracle(); error NotPermitted(); error InvalidYieldFee(); error RedeemingNotAvailableYet(); error CannotRecoverToken(); error UpdatingNotAvailableYet(); error InvalidCoolingPeriod(); error CoolingPeriodTriggered(); /// @notice Events event YieldDistributed(uint256 indexed assets, uint256 indexed shares); event NAVUpdated(address indexed caller, uint256 indexed totalAssets, uint256 indexed totalSupply); event CoolingOffPeriodUpdated(uint256 indexed oldPeriod, uint256 indexed newPeriod); event FeeCollectorUpdated(address indexed oldCollector, address indexed newCollector); event PriceOracleUpdated(address indexed oldOracle, address indexed newOracle); event OtherERC20Withdrawn(address indexed receiver, address indexed token, uint256 indexed amount); event DepositMade(address indexed depositor, address indexed receiver, uint256 indexed amount); event YieldFeeUpdated(uint256 indexed newFee); /// @notice Function to update NAV externally function updateNAV() external; /// @notice Get NAV per share function getNavPerShare() external view returns (uint256); /// @notice Override decimals function decimals() external view override returns (uint8); /// @notice Get cooling off period function coolingOffPeriod() external view returns (uint256); /// @notice Transfer tokens to treasury function transferTokenToTreasury(address token, uint256 amount) external; /// @notice Get yieldFeePercentage function yieldFeePercentage() external view returns (uint256); /// @notice Get base points function BASE_POINTS() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import { GroupId } from "../types/GroupId.sol"; /** * @title IAToken * @notice Interface for AToken, an ERC20-compatible token with minting, burning, and * additional functionality for treasury and rebalance management. */ interface IAToken is IERC20Upgradeable { /** * @dev Emitted when the treasury address is updated. * @param oldTreasury The previous treasury address. * @param newTreasury The new treasury address. */ event UpdateTreasuryAddress(address indexed oldTreasury, address indexed newTreasury); /** * @dev Emitted when the rebalance pool address is updated. * @param oldRebalancePool The previous rebalance pool address. * @param newRebalancePool The new rebalance pool address. */ event UpdateRebalancePool(address indexed oldRebalancePool, address indexed newRebalancePool); /** * @dev Emitted when tokens are minted to an address. * @param to The address receiving the minted tokens. * @param amount The amount of tokens minted. */ event Minted(address indexed to, uint256 indexed amount); /** * @dev Emitted when tokens are burned from an address. * @param from The address from which tokens are burned. * @param amount The amount of tokens burned. */ event Burned(address indexed from, uint256 indexed amount); /** * @dev Emitted when a group is updated. * @param groupId The identifier of the updated group. */ event UpdateGroup(GroupId indexed groupId); /** * @dev Emitted when the max supply is updated. * @param oldMaxSupply The previous max supply. * @param newMaxSupply The new max supply. */ event UpdateMaxSupply(uint256 indexed oldMaxSupply, uint256 indexed newMaxSupply); // Custom Errors error InvalidDecimals(); error ErrorNotPermitted(); error ErrorZeroAddress(); error ErrorZeroAmount(); error ErrorExceedsMaxSupply(); error ErrorCannotRecoverToken(); error ErrorParameterUnchanged(); /** * @notice Returns the beta status of the token. */ function beta() external view returns (bool); /** * @notice Returns the Net Asset Value (NAV) of the token. * @return The current NAV as an unsigned integer. */ function nav() external view returns (uint256); /** * @notice Returns the number of decimals used by the token. * @return The number of decimals. */ function decimals() external view returns (uint8); /** * @notice Mints tokens to a specified address. * @dev Emits a {Minted} event. * @param _to The address to receive the minted tokens. * @param _amount The amount of tokens to mint. */ function mint(address _to, uint256 _amount) external; /** * @notice Burns tokens from a specified address. * @dev Emits a {Burned} event. * @param _from The address from which tokens are burned. * @param _amount The amount of tokens to burn. */ function burn(address _from, uint256 _amount) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; /** * @title IPriceOracle * @notice Interface for the PriceOracle contract, managing and updating token price feeds. */ interface IPriceOracle { /** * @dev Emitted when a price feed is added for a token. * @param token The address of the token. * @param feed The address of the Chainlink price feed. */ event FeedAdded(address indexed token, address indexed feed); /** * @dev Emitted when a price feed is removed for a token. * @param token The address of the token. */ event FeedRemoved(address indexed token); /** * @dev Emitted when a price feed is updated for a token. * @param token The address of the token. * @param oldFeed The address of the old price feed. * @param newFeed The address of the new price feed. */ event FeedUpdated(address indexed token, address indexed oldFeed, address indexed newFeed); // Custom Errors error ZeroAddress(); error InvalidAddress(); error InvalidOperation(); error InvalidAmount(); error StalePrice(); error InvalidInput(); error DuplicateEntry(); /** * @notice Gets the latest price data for a specified token. * @param token The address of the token. * @return isValid Whether the price is valid. * @return price The last updated price (18 decimals). */ function getPrice(address token) external view returns (bool isValid, uint256 price); /** * @notice gets the token decimals from the feed */ function getFeedDecimals(address token) external view returns (uint8 decimals); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // solhint-disable /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0 = a * b; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly ("memory-safe") { let mm := mulmod(a, b, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1, "FullMath: denominator too small"); // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { assembly ("memory-safe") { result := div(prod0, denominator) } return result; } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly ("memory-safe") { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly ("memory-safe") { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (0 - denominator) & denominator; // Divide denominator by power of two assembly ("memory-safe") { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly ("memory-safe") { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly ("memory-safe") { twos := add(div(sub(0, twos), twos), 1) } 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 // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use 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. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // 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 * inv; return result; } } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) { unchecked { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) != 0) { require(++result > 0, "FullMath: addition overflow"); } } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import { GroupId } from "../types/GroupId.sol"; // solhint-disable /// @title Library for reverting with custom errors efficiently /// @notice Contains functions for reverting with custom errors with different argument types efficiently /// @dev To use this library, declare `using CustomRevert for bytes4;` and replace `revert CustomError()` with /// `CustomError.selector.revertWith()` /// @dev The functions may tamper with the free memory pointer but it is fine since the call context is exited immediately library CustomRevert { /// @dev Reverts with the selector of a custom error in the scratch space function revertWith(bytes4 selector) internal pure { assembly("memory-safe") { mstore(0, selector) revert(0, 0x04) } } /// @dev Reverts with a custom error with an address argument in the scratch space function revertWith(bytes4 selector, address addr) internal pure { assembly("memory-safe") { mstore(0, selector) mstore(0x04, and(addr, 0xffffffffffffffffffffffffffffffffffffffff)) revert(0, 0x24) } } /// @dev Reverts with a custom error with an int24 argument in the scratch space function revertWith(bytes4 selector, int24 value) internal pure { assembly("memory-safe") { mstore(0, selector) mstore(0x04, signextend(2, value)) revert(0, 0x24) } } /// @dev Reverts with a custom error with a uint160 argument in the scratch space function revertWith(bytes4 selector, uint160 value) internal pure { assembly("memory-safe") { mstore(0, selector) mstore(0x04, and(value, 0xffffffffffffffffffffffffffffffffffffffff)) revert(0, 0x24) } } /// @dev Reverts with a custom error with two int24 arguments function revertWith(bytes4 selector, int24 value1, int24 value2) internal pure { assembly("memory-safe") { let fmp := mload(0x40) mstore(fmp, selector) mstore(add(fmp, 0x04), signextend(2, value1)) mstore(add(fmp, 0x24), signextend(2, value2)) revert(fmp, 0x44) } } /// @dev Reverts with a custom error with two uint160 arguments function revertWith(bytes4 selector, uint160 value1, uint160 value2) internal pure { assembly("memory-safe") { let fmp := mload(0x40) mstore(fmp, selector) mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff)) mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff)) revert(fmp, 0x44) } } /// @dev Reverts with a custom error with two address arguments function revertWith(bytes4 selector, address value1, address value2) internal pure { assembly("memory-safe") { mstore(0, selector) mstore(0x04, and(value1, 0xffffffffffffffffffffffffffffffffffffffff)) mstore(0x24, and(value2, 0xffffffffffffffffffffffffffffffffffffffff)) revert(0, 0x44) } } /// @dev Reverts with a custom error with a bytes32 argument in the scratch space function revertWith(bytes4 selector, bytes32 value) internal pure { assembly("memory-safe") { mstore(0, selector) mstore(0x04, value) revert(0, 0x24) } } /// @dev Reverts with a custom error with a bytes32 argument in the scratch space function revertWith(bytes4 selector, GroupId value) internal pure { bytes32 valueBytes = GroupId.unwrap(value); assembly("memory-safe") { mstore(0, selector) mstore(0x04, valueBytes) revert(0, 0x24) } } /// @dev Reverts with a custom error with a bytes32 and an address argument function revertWith(bytes4 selector, GroupId value, address addr) internal pure { bytes32 valueBytes = GroupId.unwrap(value); assembly("memory-safe") { mstore(0x00, selector) mstore(0x04, valueBytes) mstore(0x24, and(addr, 0xffffffffffffffffffffffffffffffffffffffff)) revert(0x00, 0x44) } } /// @dev Reverts with a custom error with a bytes32, address, and uint256 arguments function revertWith(bytes4 selector, GroupId value, address addr, uint256 amount) internal pure { bytes32 valueBytes = GroupId.unwrap(value); assembly("memory-safe") { mstore(0x00, selector) mstore(0x04, valueBytes) mstore(0x24, and(addr, 0xffffffffffffffffffffffffffffffffffffffff)) mstore(0x44, amount) revert(0x00, 0x64) } } /// @notice bubble up the revert message returned by a call and revert with the selector provided /// @dev this function should only be used with custom errors of the type `CustomError(address target, bytes revertReason)` function bubbleUpAndRevertWith(bytes4 selector, address addr) internal pure { assembly("memory-safe") { let size := returndatasize() let fmp := mload(0x40) // Encode selector, address, offset, size, data mstore(fmp, selector) mstore(add(fmp, 0x04), addr) mstore(add(fmp, 0x24), 0x40) mstore(add(fmp, 0x44), size) returndatacopy(add(fmp, 0x64), 0, size) // Ensure the size is a multiple of 32 bytes let encodedSize := add(0x64, mul(div(add(size, 31), 32), 32)) revert(fmp, encodedSize) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.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}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * 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 ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the 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 override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[45] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20Upgradeable.sol"; import "../token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * _Available since v4.7._ */ interface IERC4626Upgradeable is IERC20Upgradeable, IERC20MetadataUpgradeable { event Deposit(address indexed 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.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // 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 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```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 Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * 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 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; 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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; import "./math/SignedMathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/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. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/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 pragma solidity 0.8.28; import { GroupKey } from "./GroupKey.sol"; type GroupId is bytes32; // @notice library for computing the ID of a group library GroupIdLibrary { using GroupIdLibrary for GroupId; function toId(GroupKey memory groupKey) internal pure returns (GroupId groupId) { groupId = GroupId.wrap(keccak256(abi.encode(groupKey))); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMathUpgradeable { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import { DTokenRegistry } from "../declarations/DTokenRegistry.sol"; /** * @title GroupKey * @dev Struct representing the core group key information. */ struct GroupKey { /** * @dev The core group information from the DTokenRegistry. */ DTokenRegistry.GroupCore core; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import { Currency } from "../types/Currency.sol"; import { Address } from "../types/Address.sol"; import { DefaultFeeParams, FeeParams, FeePermissions, CollateralInfo } from "../types/CommonTypes.sol"; library DTokenRegistry { // Core tokens of the group (immutable) struct GroupCore { Currency aToken; // Yield-bearing token Currency xToken; // Leverage token Currency baseToken; // Base token for the group - wrapped Avax Currency yieldBearingToken; // Example: staked AVAX (immutable) Currency wethToken; // WETH token address for the router } // Decimals for each core token struct GroupDecimals { uint8 aTokenDecimals; uint8 xTokenDecimals; uint8 baseTokenDecimals; uint8 yieldBearingTokenDecimals; } // Extended group settings (mutable) struct GroupExtended { Address priceOracle; // Price Oracle address Address rateProvider; // Rate provider address Address swapRouter; // Swap Router Address treasury; // Treasury address Address feeCollector; // Fee collector address Address strategy; // Strategy contract address Currency rebalancePool; // Rebalance pool address } // Metadata for the group (partially mutable) struct GroupMeta { uint96 stabilityRatio; // Mutable stability ratio (this is 2^96-1 and we have max 5e18) uint96 stabilityConditionsTriggeringRate; // Mutable stability fee trigger (this is 2^96-1 and we have max 5e18) uint8 feeModel; // Immutable fee model used for this group bool isWrappingRequired; // Immutable wrapping requirement flag } // Struct representing full group setup during creation struct GroupSetup { GroupCore core; GroupDecimals decimals; GroupExtended extended; GroupMeta meta; FeeParams fees; DefaultFeeParams defaultFees; FeePermissions feePermissions; CollateralInfo[] acceptableCollaterals; } // Data used for updating mutable parts of the group struct GroupUpdate { GroupExtended extended; GroupMeta meta; CollateralInfo[] acceptableCollaterals; FeeParams feeParams; DefaultFeeParams defaultFees; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; /// @notice https://forum.openzeppelin.com/t/safeerc20-vs-safeerc20upgradeable/17326 import { SafeERC20Upgradeable, IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import { CustomRevert } from "../libs/CustomRevert.sol"; // Custom type `Currency` to represent either an ERC20 token or the native currency (e.g., ETH) type Currency is address; /** * @title CurrencyLibrary * @dev A library for handling operations related to currencies, supporting both ERC20 tokens and native currency. * Provides utility functions for balance checks, transfers, approvals, and comparisons. */ library CurrencyLibrary { // Use SafeERC20Upgradeable for IERC20Upgradeable token operations to ensure safety using SafeERC20Upgradeable for IERC20Upgradeable; // Use CustomRevert for standardized error handling via selectors using CustomRevert for bytes4; // Define a constant representing the native currency (address(0)) Currency public constant NATIVE = Currency.wrap(address(0)); // Custom error definitions for various invalid operations involving native currency error NativeCurrencyTransfersNotAllowed(); error NativeCurrencyTransferFromNotAllowed(); error NativeCurrencyApprovalNotAllowed(); error NativeCurrencyDoesNotHaveTotalSupply(); error NativeCurrencyIncreaseAllowanceNotAllowed(); error NativeCurrencyDecreaseAllowanceNotAllowed(); error ArbitraryTransfersNotAllowed(); /** * @notice Checks if two currencies are equal. * @param currency The first currency to compare. * @param other The second currency to compare. * @return True if both currencies are the same, false otherwise. */ function equals(Currency currency, Currency other) internal pure returns (bool) { return Currency.unwrap(currency) == Currency.unwrap(other); } /** * @notice Retrieves the balance of the specified owner for the given currency. * @param currency The currency to check (ERC20 token or native). * @param owner The address of the owner whose balance is queried. * @return The balance of the owner in the specified currency. */ function balanceOf(Currency currency, address owner) internal view returns (uint256) { if (isNative(currency)) { return owner.balance; // For native currency, return the ETH balance } else { return IERC20Upgradeable(Currency.unwrap(currency)).balanceOf(owner); // For ERC20 tokens, use balanceOf } } /** * @notice Safely transfers a specified amount of the currency to a recipient. * @param currency The currency to transfer (must be an ERC20 token). * @param to The recipient address. * @param amount The amount to transfer. * @dev Native currency transfers are not allowed and will revert. */ function safeTransfer(Currency currency, address to, uint256 amount) internal { if (isNative(currency)) { // Revert if attempting to transfer native currency using ERC20 methods NativeCurrencyTransfersNotAllowed.selector.revertWith(); } else { IERC20Upgradeable(Currency.unwrap(currency)).safeTransfer(to, amount); } } /** * @notice Safely transfers a specified amount of the currency from one address to another. * @param currency The currency to transfer (must be an ERC20 token). * @param safeFrom The address to transfer from. * @param to The recipient address. * @param amount The amount to transfer. * @dev Native currency transfers are not allowed and will revert. * @dev Arbitrary transfers (i.e., not initiated by the sender) are also not allowed and will revert. * @notice Slither false positive. The function is internal and only used within the library */ //slither-disable-next-line arbitrary-send-erc20 function safeTransferFrom(Currency currency, address safeFrom, address to, uint256 amount) internal { if (isNative(currency)) { // Revert if attempting to transfer ERC20 tokens from an address other than the sender // This is to prevent arbitrary transfers, which are not allowed in the context of this library // This logic has the priority, so overrides any other inhereted logic NativeCurrencyTransferFromNotAllowed.selector.revertWith(); } else { if (safeFrom != msg.sender) ArbitraryTransfersNotAllowed.selector.revertWith(); IERC20Upgradeable(Currency.unwrap(currency)).safeTransferFrom(safeFrom, to, amount); } } /** * @notice Retrieves the allowance of a spender for the given owner's currency. * @param currency The currency to check (must be an ERC20 token). * @param owner The address of the owner of the currency. * @param spender The address of the spender. * @return The allowance of the spender for the owner's currency. */ function allowance(Currency currency, address owner, address spender) internal view returns (uint256) { if (isNative(currency)) { return 0; // For native currency, return 0 as allowance is not applicable } else { return IERC20Upgradeable(Currency.unwrap(currency)).allowance(owner, spender); // For ERC20 tokens, use allowance } } /** * @notice Safely approves a spender to spend a specified amount of the currency. * @param currency The currency to approve (must be an ERC20 token). * @param spender The address authorized to spend the tokens. * @param amount The amount to approve. * @dev Approving native currency is not allowed and will revert. */ function safeApprove(Currency currency, address spender, uint256 amount) internal { if (!isNative(currency)) { IERC20Upgradeable(Currency.unwrap(currency)).safeApprove(spender, amount); } else { // Revert if attempting to approve native currency NativeCurrencyApprovalNotAllowed.selector.revertWith(); } } /** * @notice Safely increases the allowance of a spender for the currency. * @param currency The currency to modify allowance for (must be an ERC20 token). * @param spender The address authorized to spend the tokens. * @param addedValue The amount to increase the allowance by. * @dev Increasing allowance for native currency is not allowed and will revert. */ function safeIncreaseAllowance(Currency currency, address spender, uint256 addedValue) internal { if (!isNative(currency)) { IERC20Upgradeable(Currency.unwrap(currency)).safeIncreaseAllowance(spender, addedValue); } else { // Revert if attempting to increase allowance for native currency NativeCurrencyIncreaseAllowanceNotAllowed.selector.revertWith(); } } /** * @notice Checks if the given currency is the native currency. * @param currency The currency to check. * @return True if `currency` is the native currency, false otherwise. */ function isNative(Currency currency) internal pure returns (bool) { return Currency.unwrap(currency) == Currency.unwrap(NATIVE); } /** * @notice Checks if the given currency is the zero address. * @param currency The currency to check. * @return True if `currency` is the zero address, false otherwise. */ function isZero(Currency currency) internal pure returns (bool) { return Currency.unwrap(currency) == address(0); } /** * @notice Converts the currency address to a unique identifier. * @param currency The currency to convert. * @return The uint256 representation of the currency's address. */ function toId(Currency currency) internal pure returns (uint256) { return uint160(Currency.unwrap(currency)); } /** * @notice Unwraps the `Currency` type to retrieve the underlying address. * @param currency The currency to unwrap. * @return The underlying address of the currency. */ function toAddress(Currency currency) internal pure returns (address) { return Currency.unwrap(currency); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; // Import the CustomRevert library for standardized error handling import { CustomRevert } from "../libs/CustomRevert.sol"; /** * @title Address * @dev Defines a user-defined value type `Address` that wraps the built-in `address` type. */ type Address is address; /** * @title AddressLibrary * @dev A library for performing various operations on the `Address` type. */ library AddressLibrary { // Apply the library functions to the `Address` type using AddressLibrary for Address; // Use the CustomRevert library for standardized error handling via selectors using CustomRevert for bytes4; // Custom error definitions for more descriptive revert reasons error ZeroAddress(); error FailedCall(string reason); error NonContractAddress(); error UnableToSendValue(); /** * @notice Checks if the given `Address` is the zero address. * @param addr The `Address` to check. * @return True if `addr` is the zero address, false otherwise. */ function isZero(Address addr) internal pure returns (bool) { return Address.unwrap(addr) == address(0); } /** * @notice Determines if the given `Address` is a contract. * @param addr The `Address` to check. * @return True if `addr` is a contract, false otherwise. * * @dev This method relies on the fact that contracts have non-zero code size. * It returns false for contracts in construction, since the code is only stored at the end of the constructor execution. */ function isContract(Address addr) internal view returns (bool) { return Address.unwrap(addr).code.length > 0; } /** * @notice Compares two `Address` instances for equality. * @param a The first `Address`. * @param b The second `Address`. * @return True if both addresses are equal, false otherwise. */ function equals(Address a, Address b) internal pure returns (bool) { address addrA = Address.unwrap(a); address addrB = Address.unwrap(b); return addrA == addrB; } /** * @notice Converts an `Address` to a `uint160`. * @param addr The `Address` to convert. * @return The `uint160` representation of the address. */ function toUint160(Address addr) internal pure returns (uint160) { return uint160(Address.unwrap(addr)); } /** * @notice Creates an `Address` from a `uint160`. * @param addr The `uint160` value to convert. * @return A new `Address` instance. */ function fromUint160(uint160 addr) internal pure returns (Address) { return Address.wrap(address(addr)); } /** * @notice Unwraps the `Address` type to retrieve the underlying address. * @param addr The `Address` to unwrap. * @return The underlying `address`. */ function toAddress(Address addr) internal pure returns (address) { return Address.unwrap(addr); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import { Currency } from "./Currency.sol"; import { DTokenRegistry } from "../declarations/DTokenRegistry.sol"; import { Address } from "../types/Address.sol"; // Enums representing different fee models that can be applied. enum OperationTypes { OP_TYPE_MINT_VT, OP_TYPE_MINT_YT, OP_TYPE_REDEEM_VT, OP_TYPE_REDEEM_YT } enum FeeModel { NONE, // No fees. MANAGEMENT_FEE, // Management fee model. VARIABLE_FUNDING_FEE, // Fee that varies based on funding. FIXED_FUNDING_FEE, // Fixed fee for funding. CURATED_PAIRS_FEE, // Curated pairs fee model. BLANK_FEE // Blank fee model. } // Information about acceptable collaterals struct CollateralInfo { Currency token; // Token address for collateral uint8 decimals; // Decimals for the collateral token uint256 minAmount; // Minimum amount for both usage minting and redeeming (as desired token) uint256 maxAmount; // Maximum amount for both usage minting and redeeming (as desired token) } // DefaultFeeParams defines the basic fee structure with base, min, and max fees. struct DefaultFeeParams { uint24 baseFee; // The base fee applied when no flags are present. uint24 minFee; // The minimum fee allowed for dynamic fee models. uint24 maxFee; // The maximum fee allowed. } // FeeParams defines specific fees for different token types and operations. struct FeeParams { uint24 mintFeeVT; // Minting fee for volatile tokens (VT). uint24 redeemFeeVT; // Redemption fee for volatile tokens (VT). uint24 mintFeeYT; // Minting fee for yield tokens (YT). uint24 redeemFeeYT; // Redemption fee for yield tokens (YT). uint24 stabilityMintFeeVT; // Stability minting fee for volatile tokens (VT). uint24 stabilityMintFeeYT; // Stability minting fee for yield tokens (YT). uint24 stabilityRedeemFeeVT; // Stability redemption fee for volatile tokens (VT). uint24 stabilityRedeemFeeYT; // Stability redemption fee for yield tokens (YT). uint24 yieldFeeVT; // Yield fee for volatile tokens (VT). uint24 yieldFeeYT; // Yield fee for yield tokens (YT). uint24 protocolFee; // Protocol fee. } // FeePermissions define the flexibility of the fee model (dynamic fees, delegation). struct FeePermissions { bool isDynamic; // Whether the fee model is dynamic. bool allowDelegation; // Whether fee delegation is allowed. } struct GroupState { DTokenRegistry.GroupCore core; DTokenRegistry.GroupExtended extended; bytes32 feesPacked; CollateralInfo[] acceptableCollaterals; Address hookContract; bytes32 groupSettings; }
{ "remappings": [ "@aave/=node_modules/@aave/", "@account-abstraction/=node_modules/@account-abstraction/", "@chainlink/=node_modules/@chainlink/", "@eth-optimism/=node_modules/@chainlink/contracts/node_modules/@eth-optimism/", "@openzeppelin/=node_modules/@openzeppelin/", "@uniswap/=node_modules/@uniswap/", "base64-sol/=node_modules/base64-sol/", "ds-test/=lib/ds-test/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "forge-std/=lib/forge-std/src/", "hardhat/=node_modules/hardhat/", "solidity-bytes-utils/=node_modules/solidity-bytes-utils/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/", "solmate/=lib/solmate/src/", "abdk-libraries-solidity/=node_modules/abdk-libraries-solidity/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "shanghai", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CannotRecoverToken","type":"error"},{"inputs":[],"name":"CoolingPeriodTriggered","type":"error"},{"inputs":[],"name":"InvalidCoolingPeriod","type":"error"},{"inputs":[],"name":"InvalidDepositAmount","type":"error"},{"inputs":[],"name":"InvalidPriceFromOracle","type":"error"},{"inputs":[],"name":"InvalidYieldFee","type":"error"},{"inputs":[],"name":"NotPermitted","type":"error"},{"inputs":[],"name":"RedeemingNotAvailableYet","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"TokenAlreadyAdded","type":"error"},{"inputs":[],"name":"UpdatingNotAvailableYet","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroDeposit","type":"error"},{"inputs":[],"name":"ZeroRedeem","type":"error"},{"inputs":[],"name":"ZeroShares","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":"uint256","name":"oldPeriod","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newPeriod","type":"uint256"}],"name":"CoolingOffPeriodUpdated","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":"depositor","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositMade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldCollector","type":"address"},{"indexed":true,"internalType":"address","name":"newCollector","type":"address"}],"name":"FeeCollectorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint256","name":"totalAssets","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"totalSupply","type":"uint256"}],"name":"NAVUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"OtherERC20Withdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOracle","type":"address"},{"indexed":true,"internalType":"address","name":"newOracle","type":"address"}],"name":"PriceOracleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"YieldDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"YieldFeeUpdated","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"BASE_POINTS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"COOLING_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAXIMUM_COOLING_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_DEPOSIT_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TREASURY_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"contract IAToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"addAdditionalToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"additionalTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"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":"coolingOffPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getNavPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"_aToken","type":"address"},{"internalType":"address","name":"_protocol","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"address","name":"_priceOracle","type":"address"},{"internalType":"uint256","name":"_yieldFeePercentage","type":"uint256"},{"internalType":"uint256","name":"_minimumDepositAmount","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isAdditionalToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastDeposits","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"depositor","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastNavUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"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":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOracle","outputs":[{"internalType":"contract IPriceOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOracleAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverERC20","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":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_coolingPeriod","type":"uint256"}],"name":"setCoolingPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceOracle","type":"address"}],"name":"setPriceOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_yieldFeePercentage","type":"uint256"}],"name":"setYieldFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferTokenToTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateNAV","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldFeePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6080806040523461012457670de0b6b3a7640000610167555f5460ff8160081c161591828093610117575b8015610100575b156100a7575060ff1981166001175f5581610095575b5061005c575b6040516134b290816101298239f35b61ff00195f54165f557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a161004d565b61ffff1916610101175f908155610047565b62461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b1580156100315750600160ff831614610031565b50600160ff83161061002a565b5f80fdfe60806040526004361015610032575b3615610023576339218f3b60e01b5f5260045ffd5b6339218f3b60e01b5f5260045ffd5b5f5f3560e01c90816301e1d1141461237d57816301ffc9a71461230d57816302768de4146122d3578163055c2418146122955781630676c1b71461226c57816306fdde03146121b557816307a2d13a14611cd757816307c8743114612151578163095ea7b31461212b5781630a28a477146120e857816318160ddd146120cb5781631d42d3421461208857816323b872dd14612050578163248a9ca3146120255781632630c12f14611ffc5781632bc51c6d14611fd35781632f2ff15d14611f2d5781632febaa7414611f0f578163305c74a514611ebf578163313ce56714611ea457816336568abe14611e4557816338911aa814611de557816338d52e0f14611dbd5781633950935114611d6f5781633f4ba83a14611cdc578163402d267d146106fd5781634cdad50614611cd75781635034d9d21461143b578163530e784f146113c65781635c975abb146113a45781636c622b2d146113865781636e553f65146110f557816370a082311461059d5781638456cb591461104e578163874351a014610f6757816388565b6714610f2e5781638980f11f14610ea557816391d1485414610e5c5781639362a4d714610e3f57816394bf804d14610e1a57816395d89b4114610d4f578163a0c1f15e14610d26578163a217fddf14610d0b578163a457c2d714610c69578163a9059cbb14610c38578163aaf5eb6814610c1a578163abd894b014610c00578163b3d7f6b914610b92578163b460af9414610b62578163b5ab1c5d14610b46578163ba08765214610785578163c24d56911461072b578163c5f956af14610702578163c63d75b6146106fd578163c6e6f59214610310578163ce96cb77146106c4578163d11a57ec1461069d578163d547741f146105dd578163d905777e1461059d578163dcfc0ced14610574578163dd62ed3e14610522578163deb3eb4e1461037b578163df2889741461035d578163e16777c11461033f578163e63ab1e914610315575063ef8b30f70361000e575b61255b565b3461033c578060031936011261033c5760206040515f51602061341d5f395f51905f528152f35b80fd5b3461033c578060031936011261033c57602061016554604051908152f35b3461033c578060031936011261033c57602061016954604051908152f35b3461033c57604036600319011261033c57610394612397565b61039c612cf1565b6103a4612da9565b5f51602061343d5f395f51905f52825260c960209081526040808420335f908152925290205460ff161561045d576001600160a01b031680158015610454575b8015610440575b8015610429575b61041a576101605461041191602435916001600160a01b031690612ded565b600161012d5580f35b6380eb2a0160e01b8252600482fd5b5080825261016d60205260ff6040832054166103f2565b506065546001600160a01b031681146103eb565b503081146103e4565b61051e61046933613115565b61050660116104845f51602061343d5f395f51905f526131fb565b9260376040519485927f416363657373436f6e74726f6c3a206163636f756e742000000000000000000060208501526104c681518092602086880191016123c3565b83017001034b99036b4b9b9b4b733903937b6329607d1b838201526104f58251809360206048850191016123c3565b01010301601f19810183528261249d565b60405162461bcd60e51b8152918291600483016123e4565b0390fd5b3461033c57604036600319011261033c57604061053d612397565b916105466123ad565b9260018060a01b031681526034602052209060018060a01b03165f52602052602060405f2054604051908152f35b3461033c578060031936011261033c57610161546040516001600160a01b039091168152602090f35b3461033c57602036600319011261033c5760206105d56105bb612397565b6001600160a01b03165f9081526033602052604090205490565b604051908152f35b3461033c57604036600319011261033c576004356105f96123ad565b90610618610613825f5260c9602052600160405f20015490565b6128c7565b80835260c96020526040832060018060a01b0383165f5260205260ff60405f205416610642578280f35b80835260c9602090815260408085206001600160a01b03949094165f81815294909252909220805460ff191690553391907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b8480a481808280f35b3461033c578060031936011261033c5760206040515f51602061343d5f395f51905f528152f35b3461033c57602036600319011261033c576020906105d5906040906001600160a01b036106ef612397565b1681526033845220546127d6565b61245c565b3461033c578060031936011261033c57610160546040516001600160a01b039091168152602090f35b3461033c57602036600319011261033c576060906040906001600160a01b03610752612397565b16815261016a60205220805490600181015490600260018060a01b03910154169060405192835260208301526040820152f35b3461033c5761079336612521565b61079e939193612cf1565b6107a6612da9565b6107ae612855565b8215610b37576001600160a01b03811680835261016a6020526040832054610169546107d991612629565b4210610b2857808352603360205260408320549160355495828552603360205260408520548611610ae35761080d866127d6565b95833303610ad3575b831580610a8457610825612da9565b15610a53575b8386526033602052604086205491818310610a03578185938489526033602052036040882055816035540360355586837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020604051868152a360655461089e90899083906001600160a01b0316612ded565b60405191888352602083015260018060a01b0316907ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db60403392a4821580156109fb575b6109ec57835b61016c548110156109db576108fc8161242e565b90546040516370a0823160e01b8152306004820152929160031b1c6001600160a01b0316602083602481845afa80156109d057879061099a575b6001935089878261094c575b50505050016108e8565b61095592612f7c565b9081610963575b8987610942565b61096e828683612ded565b857f1552ffe9b36f921b6b707966693e4fbc2c2f37223d823c03cd5e517d18f6728c8980a4888061095c565b506020833d82116109c8575b816109b36020938361249d565b810103126109c45760019251610936565b5f80fd5b3d91506109a6565b6040513d89823e3d90fd5b602086600161012d55604051908152f35b639811e0c760e01b8452600484fd5b5085156108e2565b60405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608490fd5b83865261016a602052610a6e60408720546101695490612629565b42101561082b5763a0d31fa160e01b8652600486fd5b60405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608490fd5b610ade813385612a37565b610816565b60405162461bcd60e51b815260206004820152601d60248201527f455243343632363a2072656465656d206d6f7265207468616e206d61780000006044820152606490fd5b6315fb7a8d60e11b8352600483fd5b63ad26a26360e01b8252600482fd5b3461033c578060031936011261033c5760206040516127108152f35b3461033c57600490610b7336612521565b505050610b7e612cf1565b610b86612da9565b6339218f3b60e01b8152fd5b3461033c57602036600319011261033c57610bab612579565b9060018201809211610bec57603554905060018101809111610bd85760016105d591602093600435612e2a565b634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b81526011600452602490fd5b3461033c578060031936011261033c5760206105d5612661565b3461033c578060031936011261033c57602061016754604051908152f35b3461033c57604036600319011261033c57610c5e610c54612397565b6024359033612acf565b602060405160018152f35b3461033c57604036600319011261033c57610c82612397565b60406024359233815260346020522060018060a01b0382165f5260205260405f205491808310610cb857610c5e92039033612906565b60405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608490fd5b3461033c578060031936011261033c57602090604051908152f35b3461033c578060031936011261033c57610163546040516001600160a01b039091168152602090f35b3461033c578060031936011261033c57604051908060375490610d71826125f1565b8085529160018116908115610df35750600114610da9575b610da584610d998186038261249d565b604051918291826123e4565b0390f35b603781525f51602061345d5f395f51905f52939250905b808210610dd957509091508101602001610d9982610d89565b919260018160209254838588010152019101909291610dc0565b60ff191660208087019190915292151560051b85019092019250610d999150839050610d89565b3461033c57604036600319011261033c57600490610e366123ad565b50610b7e612cf1565b3461033c578060031936011261033c5760206040516202a3008152f35b3461033c57604036600319011261033c576040610e776123ad565b91600435815260c9602052209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b3461033c57604036600319011261033c57610ebe612397565b610ec6612cf1565b610ece612da9565b610ed6612803565b6001600160a01b03163081148015610f1a575b8015610f03575b61041a5761041190602435903390612ded565b5080825261016d60205260ff604083205416610ef0565b506065546001600160a01b03168114610ee9565b3461033c57602036600319011261033c576020906040906001600160a01b03610f55612397565b16815261016b83522054604051908152f35b3461033c57602036600319011261033c57610f80612397565b610f88612cf1565b610f90612803565b6001600160a01b0316801561103f5780825261016d60205260ff60408320541661102d5780825261016d60205260408220805460ff1916600117905561016c546801000000000000000081101561101957806001610ff2920161016c5561242e565b81546001600160a01b0360039290921b91821b191692901b919091179055600161012d5580f35b634e487b7160e01b83526041600452602483fd5b6313501a5160e01b8252600452602490fd5b63d92e233d60e01b8252600482fd5b3461033c578060031936011261033c575f51602061341d5f395f51905f52815260c960209081526040808320335f908152925290205460ff16156110ce57611094612da9565b600160ff1960fb54161760fb557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b61051e6110da33613115565b61050660116104845f51602061341d5f395f51905f526131fb565b3461033c57604036600319011261033c57600435906111126123ad565b9161111b612cf1565b611123612da9565b61112b612855565b801561137757610168548110611368576111488161016654612629565b6101665560405161115881612481565b42815260208082018381523360408085019182526001600160a01b0397881680885261016a909452862093518455905160018401555160029290920180546001600160a01b03191692909516919091179093556111b481612a0a565b6065546040516323b872dd60e01b6020820152336024820152306044820152606480820185905281529192916111fd916001600160a01b03166111f860848361249d565b612e8c565b8315938461132357602094611210612da9565b156112c6575b61122283603554612629565b603555808452603385526040842083815401905580847fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef87604051878152a38060405183815284878201527fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d760403392a3604051937f1de3ece35391f6bba650736f2d5d3f12e2cfc54538a340cc5d762d34ca449de7339180a4600161012d558152f35b6040516112d281612481565b428152858101848152604080830187815284885261016a895290872092518355905160018301555160029190910180546001600160a01b0319166001600160a01b0392909216919091179055611216565b60405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606490fd5b63fe9ba5cd60e01b8252600482fd5b6356316e8760e01b8252600482fd5b3461033c578060031936011261033c57602061016854604051908152f35b3461033c578060031936011261033c57602060ff60fb54166040519015158152f35b3461033c57602036600319011261033c576113df612397565b6113e7612803565b6001600160a01b0316801561103f5761016454816001600160a01b0382167f56b5f80d8cac1479698aa7d01605fd6111e90b15fc4d2b377417f46034876cbd8580a36001600160a01b031916176101645580f35b346109c4576101203660031901126109c457611455612397565b60243567ffffffffffffffff81116109c4576114759036906004016124db565b9060443567ffffffffffffffff81116109c4576114969036906004016124db565b906064356001600160a01b038116908190036109c4576084356001600160a01b03811691908290036109c45760a4356001600160a01b038116908190036109c45760c4356001600160a01b03811693908490036109c45760e4359461010435965f549860ff8a60081c1615998a809b611cca575b8015611cb3575b15611c575760ff1981166001175f558a611c46575b5085158015611c3e575b8015611c36575b8015611c25575b611c16578815611c07576127108811611bf8576115b160ff5f5460081c1661156581612d49565b61156e81612d49565b87611578816132cc565b9015611bf0575b6065549060ff60a01b9060a01b16906affffffffffffffffffffff60a81b1617176065556115ac81612d49565b612d49565b80519067ffffffffffffffff8211611aee5781906115d06036546125f1565b601f8111611b7e575b50602090601f8311600114611b0d575f92611b02575b50508160011b915f199060031b1c1916176036555b80519067ffffffffffffffff8211611aee5781906116236037546125f1565b601f8111611a7c575b50602090601f8311600114611a0b575f92611a00575b50508160011b915f199060031b1c1916176037555b61169060ff5f5460081c1661166b81612d49565b61167481612d49565b61167d81612d49565b60ff1960fb541660fb556115ac81612d49565b600161012d5561016380546001600160a01b0319168517905561016e805460ff19166012179055670de0b6b3a7640000610167556001600160a01b0381165f9081527f81fe90a866a48a634a12852c1be675b683a22307409932a7443b8029347be756602052604090205460ff16156119a6575b5f8281527fbc7c178fd410adcb1dbb6d474075107c7490aa7bcc9d458f1e59916663c2d830602052604090205460ff1615611933575b5f8381527f241320afe9ca3655819934c49d3f71e7dceb37dd0a74d0ba47d46dadf51f929f602052604090205460ff16156118d3575b6001600160a01b0381165f9081527f69740cd0ab091be8193e004660c49ef128fdf47ef95c5cc8c747e37ac0379df8602052604090205460ff161561186a575b506001600160601b0360a01b61015f54161761015f556001600160601b0360a01b610160541617610160556001600160601b0360a01b61016154161761016155806001600160601b0360a01b610162541617610162556001600160601b0360a01b6101645416176101645561016555610168555f6101665560016101695561183457005b61ff00195f54165f557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1005b6001600160a01b03165f8181527f69740cd0ab091be8193e004660c49ef128fdf47ef95c5cc8c747e37ac0379df860205260408120805460ff191660011790553391905f51602061341d5f395f51905f52905f5160206133dd5f395f51905f529080a4876117b0565b5f8381527f241320afe9ca3655819934c49d3f71e7dceb37dd0a74d0ba47d46dadf51f929f60205260408120805460ff19166001179055339084905f51602061343d5f395f51905f52905f5160206133dd5f395f51905f529080a4611770565b5f8281527fbc7c178fd410adcb1dbb6d474075107c7490aa7bcc9d458f1e59916663c2d83060205260408120805460ff19166001179055339083907fba279271fb7bbf76a6f3df3cc57bf80647fcafdea60ec3383d90f459de74e7c0905f5160206133dd5f395f51905f529080a461173a565b6001600160a01b0381165f8181527f81fe90a866a48a634a12852c1be675b683a22307409932a7443b8029347be75660205260408120805460ff191660011790553391905f5160206133dd5f395f51905f528180a4611704565b015190508a80611642565b60375f9081525f51602061345d5f395f51905f529350601f198516905b818110611a645750908460019594939210611a4c575b505050811b01603755611657565b01515f1960f88460031b161c191690558a8080611a3e565b92936020600181928786015181550195019301611a28565b90915060375f52601f830160051c5f51602061345d5f395f51905f52019060208410611ad9575b90601f8493920160051c5f51602061345d5f395f51905f5201905b818110611acb575061162c565b5f8155849350600101611abe565b5f51602061345d5f395f51905f529150611aa3565b634e487b7160e01b5f52604160045260245ffd5b015190508b806115ef565b60365f9081525f5160206133fd5f395f51905f529350601f198516905b818110611b665750908460019594939210611b4e575b505050811b01603655611604565b01515f1960f88460031b161c191690558b8080611b40565b92936020600181928786015181550195019301611b2a565b90915060365f52601f830160051c5f5160206133fd5f395f51905f52019060208410611bdb575b90601f8493920160051c5f5160206133fd5f395f51905f5201905b818110611bcd57506115d9565b5f8155849350600101611bc0565b5f5160206133fd5f395f51905f529150611ba5565b50601261157f565b6328b0b87d60e11b5f5260045ffd5b6356316e8760e01b5f5260045ffd5b63d92e233d60e01b5f5260045ffd5b506001600160a01b0383161561153e565b508415611537565b508315611530565b61ffff1916610101175f558a611526565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b1580156115115750600160ff821614611511565b50600160ff82161061150a565b612410565b346109c4575f3660031901126109c457611cf4612803565b60fb5460ff811615611d335760ff191660fb557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b346109c45760403660031901126109c457610c5e611d8b612397565b335f52603460205260405f2060018060a01b0382165f52602052611db660405f206024359054612629565b9033612906565b346109c4575f3660031901126109c4576065546040516001600160a01b039091168152602090f35b346109c4575f3660031901126109c457611dfd612cf1565b335f5261016b6020524360405f2055611e14612579565b60355490337f264bf8bd3fab760f4e029bea92c9b1d17b337ca38bd14b1fc19ae1281a45c0475f80a4600161012d55005b346109c45760403660031901126109c457611e5e6123ad565b5060405162461bcd60e51b815260206004820152601860248201527f526f6c65732063616e27742062652072656e6f756e63656400000000000000006044820152606490fd5b346109c4575f3660031901126109c457602060405160128152f35b346109c45760203660031901126109c457600435611edb612803565b6127108111611bf85780610165557f1d790bd9e0ba77e3018126af541b8939894355dca1446c9d1a43dc44d4938fa65f80a2005b346109c4575f3660031901126109c457602061016954604051908152f35b346109c45760403660031901126109c457600435611f496123ad565b90611f63610613825f5260c9602052600160405f20015490565b805f5260c960205260405f2060018060a01b0383165f5260205260ff60405f20541615611f8c57005b5f81815260c9602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291905f5160206133dd5f395f51905f529080a4005b346109c4575f3660031901126109c457610162546040516001600160a01b039091168152602090f35b346109c4575f3660031901126109c457610164546040516001600160a01b039091168152602090f35b346109c45760203660031901126109c45760206105d56004355f5260c9602052600160405f20015490565b346109c45760603660031901126109c457610c5e61206c612397565b6120746123ad565b60443591612083833383612a37565b612acf565b346109c45760203660031901126109c45760043561016c548110156109c4576120b260209161242e565b905460405160039290921b1c6001600160a01b03168152f35b346109c4575f3660031901126109c4576020603554604051908152f35b346109c45760203660031901126109c45760355460018101809111610bd85761210f612579565b60018101809111610bd85760016105d591602093600435612e2a565b346109c45760403660031901126109c457610c5e612147612397565b6024359033612906565b346109c45760203660031901126109c45760043561216d612803565b6202a30081116121a65780610169547f57ab8d659db717e1850739c715e809cbb3cfba8c0c0f1d36c1a5717d96d74bc45f80a361016955005b631ae05ebf60e11b5f5260045ffd5b346109c4575f3660031901126109c4576040515f6036546121d5816125f1565b808452906001811690811561224857506001146121fd575b610da583610d998185038261249d565b91905060365f525f5160206133fd5f395f51905f52915f905b80821061222e57509091508101602001610d996121ed565b919260018160209254838588010152019101909291612216565b60ff191660208086019190915291151560051b84019091019150610d9990506121ed565b346109c4575f3660031901126109c45761015f546040516001600160a01b039091168152602090f35b346109c45760203660031901126109c4576001600160a01b036122b6612397565b165f5261016d602052602060ff60405f2054166040519015158152f35b346109c4575f3660031901126109c45760206040517fba279271fb7bbf76a6f3df3cc57bf80647fcafdea60ec3383d90f459de74e7c08152f35b346109c45760203660031901126109c45760043563ffffffff60e01b81168091036109c4576020906307e141d960e01b8114908115612352575b506040519015158152f35b637965db0b60e01b81149150811561236c575b5082612347565b6301ffc9a760e01b14905082612365565b346109c4575f3660031901126109c45760206105d5612579565b600435906001600160a01b03821682036109c457565b602435906001600160a01b03821682036109c457565b5f5b8381106123d45750505f910152565b81810151838201526020016123c5565b6040916020825261240481518092816020860152602086860191016123c3565b601f01601f1916010190565b346109c45760203660031901126109c45760206105d56004356127d6565b61016c548110156124485761016c5f5260205f2001905f90565b634e487b7160e01b5f52603260045260245ffd5b346109c45760203660031901126109c457612475612397565b5060206040515f198152f35b6060810190811067ffffffffffffffff821117611aee57604052565b90601f8019910116810190811067ffffffffffffffff821117611aee57604052565b67ffffffffffffffff8111611aee57601f01601f191660200190565b81601f820112156109c4578035906124f2826124bf565b92612500604051948561249d565b828452602083830101116109c457815f926020809301838601378301015290565b60609060031901126109c457600435906024356001600160a01b03811681036109c457906044356001600160a01b03811681036109c45790565b346109c45760203660031901126109c45760206105d5600435612a0a565b610163546040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa9081156125e6575f916125b7575090565b90506020813d6020116125de575b816125d26020938361249d565b810103126109c4575190565b3d91506125c5565b6040513d5f823e3d90fd5b90600182811c9216801561261f575b602083101461260b57565b634e487b7160e01b5f52602260045260245ffd5b91607f1691612600565b91908201809211610bd857565b519081151582036109c457565b811561264d570490565b634e487b7160e01b5f52601260045260245ffd5b612669612579565b60355480156126f9576101635460405163c1590cd760e01b81529290602090849060049082906001600160a01b03165afa9283156125e6575f936126c5575b50828102928184041490151715610bd8576126c291612643565b90565b9092506020813d6020116126f1575b816126e16020938361249d565b810103126109c45751915f6126a8565b3d91506126d4565b5050610164546001600160a01b03168061274657506101635460405163c1590cd760e01b815290602090829060049082906001600160a01b03165afa9081156125e6575f916125b7575090565b604060018060a01b03610163541660248251809481936341976e0960e01b835260048301525afa9081156125e6575f905f92612795575b50156127865790565b636f4f5ab960e01b5f5260045ffd5b9150506040813d6040116127ce575b816127b16040938361249d565b810103126109c45760206127c482612636565b910151905f61277d565b3d91506127a4565b6127de612579565b9060018201809211610bd85760355460018101809111610bd8576126c2925f92612e2a565b335f9081527f81fe90a866a48a634a12852c1be675b683a22307409932a7443b8029347be756602052604090205460ff161561283b57565b61051e61284733613115565b61050660116104845f6131fb565b335f9081527fbc7c178fd410adcb1dbb6d474075107c7490aa7bcc9d458f1e59916663c2d830602052604090205460ff161561288d57565b61051e61289933613115565b61050660116104847fba279271fb7bbf76a6f3df3cc57bf80647fcafdea60ec3383d90f459de74e7c06131fb565b5f81815260c96020908152604080832033845290915290205460ff16156128eb5750565b61051e90610506601161048461290033613115565b936131fb565b6001600160a01b03169081156129b9576001600160a01b03169182156129695760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591835f526034825260405f20855f5282528060405f2055604051908152a3565b60405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608490fd5b60405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b6035549060018201809211610bd857612a21612579565b60018101809111610bd8576126c2925f92612e2a565b6001600160a01b038082165f908152603460209081526040808320938616835292905220549290919060018401612a6f575b50505050565b808410612a8a57612a81930391612906565b5f808080612a69565b60405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606490fd5b6001600160a01b0316801592909183612c9e576001600160a01b03169283159081612c4d57612afc612da9565b15612c1c575b15612bbd575b815f52603360205260405f2054818110612b6957817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f52603384520360405f2055845f526033825260405f20818154019055604051908152a3565b60405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608490fd5b604051612bc981612481565b428152602080820183815260408084018681525f88815261016a9094529220925183555160018301555160029190910180546001600160a01b0319166001600160a01b0392909216919091179055612b08565b825f5261016a602052612c3760405f20546101695490612629565b421015612b025763a0d31fa160e01b5f5260045ffd5b60405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608490fd5b60405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608490fd5b600261012d5414612d0457600261012d55565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b15612d5057565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b60ff60fb5416612db557565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604480830193909352918152612e28916111f860648361249d565b565b9190612e37828285613041565b936003811015612e78576001149283612e63575b505050612e555790565b60018101809111610bd85790565b90918093501561264d570915155f8080612e4b565b634e487b7160e01b5f52602160045260245ffd5b90612eec9160018060a01b03165f8060405193612eaa60408661249d565b602085527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564602086015260208151910182855af1612ee661329d565b9161334b565b8051908115918215612f5a575b505015612f0257565b60405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b81925090602091810103126109c4576020612f759101612636565b5f80612ef9565b91818302915f1981850993838086109503948086039586851115612ffc5714612ff4579082910981805f03168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b505091500490565b60405162461bcd60e51b815260206004820152601f60248201527f46756c6c4d6174683a2064656e6f6d696e61746f7220746f6f20736d616c6c006044820152606490fd5b915f1982840992828102928380861095039480860395146130f757848311156130ba57829109600182190182168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b60405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b6044820152606490fd5b5050906126c29250612643565b908151811015612448570160200190565b61311f602a6124bf565b9061312d604051928361249d565b602a825261313b602a6124bf565b6020830190601f19013682378251156124485760309053815160011015612448576078602183015360295b600181116131ba57506131765790565b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b90600f81166010811015612448576f181899199a1a9b1b9c1cb0b131b232b360811b901a6131e88385613104565b5360041c908015610bd8575f1901613166565b61320560426124bf565b90613213604051928361249d565b6042825261322160426124bf565b6020830190601f19013682378251156124485760309053815160011015612448576078602183015360415b6001811161325c57506131765790565b90600f81166010811015612448576f181899199a1a9b1b9c1cb0b131b232b360811b901a61328a8385613104565b5360041c908015610bd8575f190161324c565b3d156132c7573d906132ae826124bf565b916132bc604051938461249d565b82523d5f602084013e565b606090565b5f8091604051602081019063313ce56760e01b8252600481526132f060248261249d565b51916001600160a01b03165afa61330561329d565b908061333f575b613318575b505f905f90565b602081519181808201938492010103126109c4575160ff8111613311579060ff6001921690565b5060208151101561330c565b919290156133ad575081511561335f575090565b3b156133685790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156133c05750805190602001fd5b60405162461bcd60e51b815290819061051e90600483016123e456fe2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b865d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862ae1dcbdb91df27212a29bc27177c840cf2f819ecf2187432e1fac86c2dd5dfca942a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31aea2646970667358221220574da34d371a638adccc59c9e8b70b26d240e58b5a0f02e021ebc8884b59049c64736f6c634300081c0033
Deployed Bytecode
0x60806040526004361015610032575b3615610023576339218f3b60e01b5f5260045ffd5b6339218f3b60e01b5f5260045ffd5b5f5f3560e01c90816301e1d1141461237d57816301ffc9a71461230d57816302768de4146122d3578163055c2418146122955781630676c1b71461226c57816306fdde03146121b557816307a2d13a14611cd757816307c8743114612151578163095ea7b31461212b5781630a28a477146120e857816318160ddd146120cb5781631d42d3421461208857816323b872dd14612050578163248a9ca3146120255781632630c12f14611ffc5781632bc51c6d14611fd35781632f2ff15d14611f2d5781632febaa7414611f0f578163305c74a514611ebf578163313ce56714611ea457816336568abe14611e4557816338911aa814611de557816338d52e0f14611dbd5781633950935114611d6f5781633f4ba83a14611cdc578163402d267d146106fd5781634cdad50614611cd75781635034d9d21461143b578163530e784f146113c65781635c975abb146113a45781636c622b2d146113865781636e553f65146110f557816370a082311461059d5781638456cb591461104e578163874351a014610f6757816388565b6714610f2e5781638980f11f14610ea557816391d1485414610e5c5781639362a4d714610e3f57816394bf804d14610e1a57816395d89b4114610d4f578163a0c1f15e14610d26578163a217fddf14610d0b578163a457c2d714610c69578163a9059cbb14610c38578163aaf5eb6814610c1a578163abd894b014610c00578163b3d7f6b914610b92578163b460af9414610b62578163b5ab1c5d14610b46578163ba08765214610785578163c24d56911461072b578163c5f956af14610702578163c63d75b6146106fd578163c6e6f59214610310578163ce96cb77146106c4578163d11a57ec1461069d578163d547741f146105dd578163d905777e1461059d578163dcfc0ced14610574578163dd62ed3e14610522578163deb3eb4e1461037b578163df2889741461035d578163e16777c11461033f578163e63ab1e914610315575063ef8b30f70361000e575b61255b565b3461033c578060031936011261033c5760206040515f51602061341d5f395f51905f528152f35b80fd5b3461033c578060031936011261033c57602061016554604051908152f35b3461033c578060031936011261033c57602061016954604051908152f35b3461033c57604036600319011261033c57610394612397565b61039c612cf1565b6103a4612da9565b5f51602061343d5f395f51905f52825260c960209081526040808420335f908152925290205460ff161561045d576001600160a01b031680158015610454575b8015610440575b8015610429575b61041a576101605461041191602435916001600160a01b031690612ded565b600161012d5580f35b6380eb2a0160e01b8252600482fd5b5080825261016d60205260ff6040832054166103f2565b506065546001600160a01b031681146103eb565b503081146103e4565b61051e61046933613115565b61050660116104845f51602061343d5f395f51905f526131fb565b9260376040519485927f416363657373436f6e74726f6c3a206163636f756e742000000000000000000060208501526104c681518092602086880191016123c3565b83017001034b99036b4b9b9b4b733903937b6329607d1b838201526104f58251809360206048850191016123c3565b01010301601f19810183528261249d565b60405162461bcd60e51b8152918291600483016123e4565b0390fd5b3461033c57604036600319011261033c57604061053d612397565b916105466123ad565b9260018060a01b031681526034602052209060018060a01b03165f52602052602060405f2054604051908152f35b3461033c578060031936011261033c57610161546040516001600160a01b039091168152602090f35b3461033c57602036600319011261033c5760206105d56105bb612397565b6001600160a01b03165f9081526033602052604090205490565b604051908152f35b3461033c57604036600319011261033c576004356105f96123ad565b90610618610613825f5260c9602052600160405f20015490565b6128c7565b80835260c96020526040832060018060a01b0383165f5260205260ff60405f205416610642578280f35b80835260c9602090815260408085206001600160a01b03949094165f81815294909252909220805460ff191690553391907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b8480a481808280f35b3461033c578060031936011261033c5760206040515f51602061343d5f395f51905f528152f35b3461033c57602036600319011261033c576020906105d5906040906001600160a01b036106ef612397565b1681526033845220546127d6565b61245c565b3461033c578060031936011261033c57610160546040516001600160a01b039091168152602090f35b3461033c57602036600319011261033c576060906040906001600160a01b03610752612397565b16815261016a60205220805490600181015490600260018060a01b03910154169060405192835260208301526040820152f35b3461033c5761079336612521565b61079e939193612cf1565b6107a6612da9565b6107ae612855565b8215610b37576001600160a01b03811680835261016a6020526040832054610169546107d991612629565b4210610b2857808352603360205260408320549160355495828552603360205260408520548611610ae35761080d866127d6565b95833303610ad3575b831580610a8457610825612da9565b15610a53575b8386526033602052604086205491818310610a03578185938489526033602052036040882055816035540360355586837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020604051868152a360655461089e90899083906001600160a01b0316612ded565b60405191888352602083015260018060a01b0316907ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db60403392a4821580156109fb575b6109ec57835b61016c548110156109db576108fc8161242e565b90546040516370a0823160e01b8152306004820152929160031b1c6001600160a01b0316602083602481845afa80156109d057879061099a575b6001935089878261094c575b50505050016108e8565b61095592612f7c565b9081610963575b8987610942565b61096e828683612ded565b857f1552ffe9b36f921b6b707966693e4fbc2c2f37223d823c03cd5e517d18f6728c8980a4888061095c565b506020833d82116109c8575b816109b36020938361249d565b810103126109c45760019251610936565b5f80fd5b3d91506109a6565b6040513d89823e3d90fd5b602086600161012d55604051908152f35b639811e0c760e01b8452600484fd5b5085156108e2565b60405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608490fd5b83865261016a602052610a6e60408720546101695490612629565b42101561082b5763a0d31fa160e01b8652600486fd5b60405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608490fd5b610ade813385612a37565b610816565b60405162461bcd60e51b815260206004820152601d60248201527f455243343632363a2072656465656d206d6f7265207468616e206d61780000006044820152606490fd5b6315fb7a8d60e11b8352600483fd5b63ad26a26360e01b8252600482fd5b3461033c578060031936011261033c5760206040516127108152f35b3461033c57600490610b7336612521565b505050610b7e612cf1565b610b86612da9565b6339218f3b60e01b8152fd5b3461033c57602036600319011261033c57610bab612579565b9060018201809211610bec57603554905060018101809111610bd85760016105d591602093600435612e2a565b634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b81526011600452602490fd5b3461033c578060031936011261033c5760206105d5612661565b3461033c578060031936011261033c57602061016754604051908152f35b3461033c57604036600319011261033c57610c5e610c54612397565b6024359033612acf565b602060405160018152f35b3461033c57604036600319011261033c57610c82612397565b60406024359233815260346020522060018060a01b0382165f5260205260405f205491808310610cb857610c5e92039033612906565b60405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608490fd5b3461033c578060031936011261033c57602090604051908152f35b3461033c578060031936011261033c57610163546040516001600160a01b039091168152602090f35b3461033c578060031936011261033c57604051908060375490610d71826125f1565b8085529160018116908115610df35750600114610da9575b610da584610d998186038261249d565b604051918291826123e4565b0390f35b603781525f51602061345d5f395f51905f52939250905b808210610dd957509091508101602001610d9982610d89565b919260018160209254838588010152019101909291610dc0565b60ff191660208087019190915292151560051b85019092019250610d999150839050610d89565b3461033c57604036600319011261033c57600490610e366123ad565b50610b7e612cf1565b3461033c578060031936011261033c5760206040516202a3008152f35b3461033c57604036600319011261033c576040610e776123ad565b91600435815260c9602052209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b3461033c57604036600319011261033c57610ebe612397565b610ec6612cf1565b610ece612da9565b610ed6612803565b6001600160a01b03163081148015610f1a575b8015610f03575b61041a5761041190602435903390612ded565b5080825261016d60205260ff604083205416610ef0565b506065546001600160a01b03168114610ee9565b3461033c57602036600319011261033c576020906040906001600160a01b03610f55612397565b16815261016b83522054604051908152f35b3461033c57602036600319011261033c57610f80612397565b610f88612cf1565b610f90612803565b6001600160a01b0316801561103f5780825261016d60205260ff60408320541661102d5780825261016d60205260408220805460ff1916600117905561016c546801000000000000000081101561101957806001610ff2920161016c5561242e565b81546001600160a01b0360039290921b91821b191692901b919091179055600161012d5580f35b634e487b7160e01b83526041600452602483fd5b6313501a5160e01b8252600452602490fd5b63d92e233d60e01b8252600482fd5b3461033c578060031936011261033c575f51602061341d5f395f51905f52815260c960209081526040808320335f908152925290205460ff16156110ce57611094612da9565b600160ff1960fb54161760fb557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b61051e6110da33613115565b61050660116104845f51602061341d5f395f51905f526131fb565b3461033c57604036600319011261033c57600435906111126123ad565b9161111b612cf1565b611123612da9565b61112b612855565b801561137757610168548110611368576111488161016654612629565b6101665560405161115881612481565b42815260208082018381523360408085019182526001600160a01b0397881680885261016a909452862093518455905160018401555160029290920180546001600160a01b03191692909516919091179093556111b481612a0a565b6065546040516323b872dd60e01b6020820152336024820152306044820152606480820185905281529192916111fd916001600160a01b03166111f860848361249d565b612e8c565b8315938461132357602094611210612da9565b156112c6575b61122283603554612629565b603555808452603385526040842083815401905580847fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef87604051878152a38060405183815284878201527fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d760403392a3604051937f1de3ece35391f6bba650736f2d5d3f12e2cfc54538a340cc5d762d34ca449de7339180a4600161012d558152f35b6040516112d281612481565b428152858101848152604080830187815284885261016a895290872092518355905160018301555160029190910180546001600160a01b0319166001600160a01b0392909216919091179055611216565b60405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606490fd5b63fe9ba5cd60e01b8252600482fd5b6356316e8760e01b8252600482fd5b3461033c578060031936011261033c57602061016854604051908152f35b3461033c578060031936011261033c57602060ff60fb54166040519015158152f35b3461033c57602036600319011261033c576113df612397565b6113e7612803565b6001600160a01b0316801561103f5761016454816001600160a01b0382167f56b5f80d8cac1479698aa7d01605fd6111e90b15fc4d2b377417f46034876cbd8580a36001600160a01b031916176101645580f35b346109c4576101203660031901126109c457611455612397565b60243567ffffffffffffffff81116109c4576114759036906004016124db565b9060443567ffffffffffffffff81116109c4576114969036906004016124db565b906064356001600160a01b038116908190036109c4576084356001600160a01b03811691908290036109c45760a4356001600160a01b038116908190036109c45760c4356001600160a01b03811693908490036109c45760e4359461010435965f549860ff8a60081c1615998a809b611cca575b8015611cb3575b15611c575760ff1981166001175f558a611c46575b5085158015611c3e575b8015611c36575b8015611c25575b611c16578815611c07576127108811611bf8576115b160ff5f5460081c1661156581612d49565b61156e81612d49565b87611578816132cc565b9015611bf0575b6065549060ff60a01b9060a01b16906affffffffffffffffffffff60a81b1617176065556115ac81612d49565b612d49565b80519067ffffffffffffffff8211611aee5781906115d06036546125f1565b601f8111611b7e575b50602090601f8311600114611b0d575f92611b02575b50508160011b915f199060031b1c1916176036555b80519067ffffffffffffffff8211611aee5781906116236037546125f1565b601f8111611a7c575b50602090601f8311600114611a0b575f92611a00575b50508160011b915f199060031b1c1916176037555b61169060ff5f5460081c1661166b81612d49565b61167481612d49565b61167d81612d49565b60ff1960fb541660fb556115ac81612d49565b600161012d5561016380546001600160a01b0319168517905561016e805460ff19166012179055670de0b6b3a7640000610167556001600160a01b0381165f9081527f81fe90a866a48a634a12852c1be675b683a22307409932a7443b8029347be756602052604090205460ff16156119a6575b5f8281527fbc7c178fd410adcb1dbb6d474075107c7490aa7bcc9d458f1e59916663c2d830602052604090205460ff1615611933575b5f8381527f241320afe9ca3655819934c49d3f71e7dceb37dd0a74d0ba47d46dadf51f929f602052604090205460ff16156118d3575b6001600160a01b0381165f9081527f69740cd0ab091be8193e004660c49ef128fdf47ef95c5cc8c747e37ac0379df8602052604090205460ff161561186a575b506001600160601b0360a01b61015f54161761015f556001600160601b0360a01b610160541617610160556001600160601b0360a01b61016154161761016155806001600160601b0360a01b610162541617610162556001600160601b0360a01b6101645416176101645561016555610168555f6101665560016101695561183457005b61ff00195f54165f557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1005b6001600160a01b03165f8181527f69740cd0ab091be8193e004660c49ef128fdf47ef95c5cc8c747e37ac0379df860205260408120805460ff191660011790553391905f51602061341d5f395f51905f52905f5160206133dd5f395f51905f529080a4876117b0565b5f8381527f241320afe9ca3655819934c49d3f71e7dceb37dd0a74d0ba47d46dadf51f929f60205260408120805460ff19166001179055339084905f51602061343d5f395f51905f52905f5160206133dd5f395f51905f529080a4611770565b5f8281527fbc7c178fd410adcb1dbb6d474075107c7490aa7bcc9d458f1e59916663c2d83060205260408120805460ff19166001179055339083907fba279271fb7bbf76a6f3df3cc57bf80647fcafdea60ec3383d90f459de74e7c0905f5160206133dd5f395f51905f529080a461173a565b6001600160a01b0381165f8181527f81fe90a866a48a634a12852c1be675b683a22307409932a7443b8029347be75660205260408120805460ff191660011790553391905f5160206133dd5f395f51905f528180a4611704565b015190508a80611642565b60375f9081525f51602061345d5f395f51905f529350601f198516905b818110611a645750908460019594939210611a4c575b505050811b01603755611657565b01515f1960f88460031b161c191690558a8080611a3e565b92936020600181928786015181550195019301611a28565b90915060375f52601f830160051c5f51602061345d5f395f51905f52019060208410611ad9575b90601f8493920160051c5f51602061345d5f395f51905f5201905b818110611acb575061162c565b5f8155849350600101611abe565b5f51602061345d5f395f51905f529150611aa3565b634e487b7160e01b5f52604160045260245ffd5b015190508b806115ef565b60365f9081525f5160206133fd5f395f51905f529350601f198516905b818110611b665750908460019594939210611b4e575b505050811b01603655611604565b01515f1960f88460031b161c191690558b8080611b40565b92936020600181928786015181550195019301611b2a565b90915060365f52601f830160051c5f5160206133fd5f395f51905f52019060208410611bdb575b90601f8493920160051c5f5160206133fd5f395f51905f5201905b818110611bcd57506115d9565b5f8155849350600101611bc0565b5f5160206133fd5f395f51905f529150611ba5565b50601261157f565b6328b0b87d60e11b5f5260045ffd5b6356316e8760e01b5f5260045ffd5b63d92e233d60e01b5f5260045ffd5b506001600160a01b0383161561153e565b508415611537565b508315611530565b61ffff1916610101175f558a611526565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b1580156115115750600160ff821614611511565b50600160ff82161061150a565b612410565b346109c4575f3660031901126109c457611cf4612803565b60fb5460ff811615611d335760ff191660fb557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b346109c45760403660031901126109c457610c5e611d8b612397565b335f52603460205260405f2060018060a01b0382165f52602052611db660405f206024359054612629565b9033612906565b346109c4575f3660031901126109c4576065546040516001600160a01b039091168152602090f35b346109c4575f3660031901126109c457611dfd612cf1565b335f5261016b6020524360405f2055611e14612579565b60355490337f264bf8bd3fab760f4e029bea92c9b1d17b337ca38bd14b1fc19ae1281a45c0475f80a4600161012d55005b346109c45760403660031901126109c457611e5e6123ad565b5060405162461bcd60e51b815260206004820152601860248201527f526f6c65732063616e27742062652072656e6f756e63656400000000000000006044820152606490fd5b346109c4575f3660031901126109c457602060405160128152f35b346109c45760203660031901126109c457600435611edb612803565b6127108111611bf85780610165557f1d790bd9e0ba77e3018126af541b8939894355dca1446c9d1a43dc44d4938fa65f80a2005b346109c4575f3660031901126109c457602061016954604051908152f35b346109c45760403660031901126109c457600435611f496123ad565b90611f63610613825f5260c9602052600160405f20015490565b805f5260c960205260405f2060018060a01b0383165f5260205260ff60405f20541615611f8c57005b5f81815260c9602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291905f5160206133dd5f395f51905f529080a4005b346109c4575f3660031901126109c457610162546040516001600160a01b039091168152602090f35b346109c4575f3660031901126109c457610164546040516001600160a01b039091168152602090f35b346109c45760203660031901126109c45760206105d56004355f5260c9602052600160405f20015490565b346109c45760603660031901126109c457610c5e61206c612397565b6120746123ad565b60443591612083833383612a37565b612acf565b346109c45760203660031901126109c45760043561016c548110156109c4576120b260209161242e565b905460405160039290921b1c6001600160a01b03168152f35b346109c4575f3660031901126109c4576020603554604051908152f35b346109c45760203660031901126109c45760355460018101809111610bd85761210f612579565b60018101809111610bd85760016105d591602093600435612e2a565b346109c45760403660031901126109c457610c5e612147612397565b6024359033612906565b346109c45760203660031901126109c45760043561216d612803565b6202a30081116121a65780610169547f57ab8d659db717e1850739c715e809cbb3cfba8c0c0f1d36c1a5717d96d74bc45f80a361016955005b631ae05ebf60e11b5f5260045ffd5b346109c4575f3660031901126109c4576040515f6036546121d5816125f1565b808452906001811690811561224857506001146121fd575b610da583610d998185038261249d565b91905060365f525f5160206133fd5f395f51905f52915f905b80821061222e57509091508101602001610d996121ed565b919260018160209254838588010152019101909291612216565b60ff191660208086019190915291151560051b84019091019150610d9990506121ed565b346109c4575f3660031901126109c45761015f546040516001600160a01b039091168152602090f35b346109c45760203660031901126109c4576001600160a01b036122b6612397565b165f5261016d602052602060ff60405f2054166040519015158152f35b346109c4575f3660031901126109c45760206040517fba279271fb7bbf76a6f3df3cc57bf80647fcafdea60ec3383d90f459de74e7c08152f35b346109c45760203660031901126109c45760043563ffffffff60e01b81168091036109c4576020906307e141d960e01b8114908115612352575b506040519015158152f35b637965db0b60e01b81149150811561236c575b5082612347565b6301ffc9a760e01b14905082612365565b346109c4575f3660031901126109c45760206105d5612579565b600435906001600160a01b03821682036109c457565b602435906001600160a01b03821682036109c457565b5f5b8381106123d45750505f910152565b81810151838201526020016123c5565b6040916020825261240481518092816020860152602086860191016123c3565b601f01601f1916010190565b346109c45760203660031901126109c45760206105d56004356127d6565b61016c548110156124485761016c5f5260205f2001905f90565b634e487b7160e01b5f52603260045260245ffd5b346109c45760203660031901126109c457612475612397565b5060206040515f198152f35b6060810190811067ffffffffffffffff821117611aee57604052565b90601f8019910116810190811067ffffffffffffffff821117611aee57604052565b67ffffffffffffffff8111611aee57601f01601f191660200190565b81601f820112156109c4578035906124f2826124bf565b92612500604051948561249d565b828452602083830101116109c457815f926020809301838601378301015290565b60609060031901126109c457600435906024356001600160a01b03811681036109c457906044356001600160a01b03811681036109c45790565b346109c45760203660031901126109c45760206105d5600435612a0a565b610163546040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa9081156125e6575f916125b7575090565b90506020813d6020116125de575b816125d26020938361249d565b810103126109c4575190565b3d91506125c5565b6040513d5f823e3d90fd5b90600182811c9216801561261f575b602083101461260b57565b634e487b7160e01b5f52602260045260245ffd5b91607f1691612600565b91908201809211610bd857565b519081151582036109c457565b811561264d570490565b634e487b7160e01b5f52601260045260245ffd5b612669612579565b60355480156126f9576101635460405163c1590cd760e01b81529290602090849060049082906001600160a01b03165afa9283156125e6575f936126c5575b50828102928184041490151715610bd8576126c291612643565b90565b9092506020813d6020116126f1575b816126e16020938361249d565b810103126109c45751915f6126a8565b3d91506126d4565b5050610164546001600160a01b03168061274657506101635460405163c1590cd760e01b815290602090829060049082906001600160a01b03165afa9081156125e6575f916125b7575090565b604060018060a01b03610163541660248251809481936341976e0960e01b835260048301525afa9081156125e6575f905f92612795575b50156127865790565b636f4f5ab960e01b5f5260045ffd5b9150506040813d6040116127ce575b816127b16040938361249d565b810103126109c45760206127c482612636565b910151905f61277d565b3d91506127a4565b6127de612579565b9060018201809211610bd85760355460018101809111610bd8576126c2925f92612e2a565b335f9081527f81fe90a866a48a634a12852c1be675b683a22307409932a7443b8029347be756602052604090205460ff161561283b57565b61051e61284733613115565b61050660116104845f6131fb565b335f9081527fbc7c178fd410adcb1dbb6d474075107c7490aa7bcc9d458f1e59916663c2d830602052604090205460ff161561288d57565b61051e61289933613115565b61050660116104847fba279271fb7bbf76a6f3df3cc57bf80647fcafdea60ec3383d90f459de74e7c06131fb565b5f81815260c96020908152604080832033845290915290205460ff16156128eb5750565b61051e90610506601161048461290033613115565b936131fb565b6001600160a01b03169081156129b9576001600160a01b03169182156129695760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591835f526034825260405f20855f5282528060405f2055604051908152a3565b60405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608490fd5b60405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b6035549060018201809211610bd857612a21612579565b60018101809111610bd8576126c2925f92612e2a565b6001600160a01b038082165f908152603460209081526040808320938616835292905220549290919060018401612a6f575b50505050565b808410612a8a57612a81930391612906565b5f808080612a69565b60405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606490fd5b6001600160a01b0316801592909183612c9e576001600160a01b03169283159081612c4d57612afc612da9565b15612c1c575b15612bbd575b815f52603360205260405f2054818110612b6957817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f52603384520360405f2055845f526033825260405f20818154019055604051908152a3565b60405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608490fd5b604051612bc981612481565b428152602080820183815260408084018681525f88815261016a9094529220925183555160018301555160029190910180546001600160a01b0319166001600160a01b0392909216919091179055612b08565b825f5261016a602052612c3760405f20546101695490612629565b421015612b025763a0d31fa160e01b5f5260045ffd5b60405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608490fd5b60405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608490fd5b600261012d5414612d0457600261012d55565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b15612d5057565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b60ff60fb5416612db557565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604480830193909352918152612e28916111f860648361249d565b565b9190612e37828285613041565b936003811015612e78576001149283612e63575b505050612e555790565b60018101809111610bd85790565b90918093501561264d570915155f8080612e4b565b634e487b7160e01b5f52602160045260245ffd5b90612eec9160018060a01b03165f8060405193612eaa60408661249d565b602085527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564602086015260208151910182855af1612ee661329d565b9161334b565b8051908115918215612f5a575b505015612f0257565b60405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b81925090602091810103126109c4576020612f759101612636565b5f80612ef9565b91818302915f1981850993838086109503948086039586851115612ffc5714612ff4579082910981805f03168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b505091500490565b60405162461bcd60e51b815260206004820152601f60248201527f46756c6c4d6174683a2064656e6f6d696e61746f7220746f6f20736d616c6c006044820152606490fd5b915f1982840992828102928380861095039480860395146130f757848311156130ba57829109600182190182168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b60405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b6044820152606490fd5b5050906126c29250612643565b908151811015612448570160200190565b61311f602a6124bf565b9061312d604051928361249d565b602a825261313b602a6124bf565b6020830190601f19013682378251156124485760309053815160011015612448576078602183015360295b600181116131ba57506131765790565b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b90600f81166010811015612448576f181899199a1a9b1b9c1cb0b131b232b360811b901a6131e88385613104565b5360041c908015610bd8575f1901613166565b61320560426124bf565b90613213604051928361249d565b6042825261322160426124bf565b6020830190601f19013682378251156124485760309053815160011015612448576078602183015360415b6001811161325c57506131765790565b90600f81166010811015612448576f181899199a1a9b1b9c1cb0b131b232b360811b901a61328a8385613104565b5360041c908015610bd8575f190161324c565b3d156132c7573d906132ae826124bf565b916132bc604051938461249d565b82523d5f602084013e565b606090565b5f8091604051602081019063313ce56760e01b8252600481526132f060248261249d565b51916001600160a01b03165afa61330561329d565b908061333f575b613318575b505f905f90565b602081519181808201938492010103126109c4575160ff8111613311579060ff6001921690565b5060208151101561330c565b919290156133ad575081511561335f575090565b3b156133685790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156133c05750805190602001fd5b60405162461bcd60e51b815290819061051e90600483016123e456fe2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b865d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862ae1dcbdb91df27212a29bc27177c840cf2f819ecf2187432e1fac86c2dd5dfca942a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31aea2646970667358221220574da34d371a638adccc59c9e8b70b26d240e58b5a0f02e021ebc8884b59049c64736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.