Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
CollateralVault
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
No with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {BaseCollateralVault, IBaseCollateralVault} from "./BaseCollateralVault.sol";
contract CollateralVault is BaseCollateralVault {
function initialize(IBaseCollateralVault.BaseInitParams calldata baseParams) public initializer {
__BaseCollateralVault_init(baseParams);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {ERC4626Upgradeable, ERC20Upgradeable, IERC20, Math, SafeERC20} from "@openzeppelin-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
import {IBaseCollateralVault, IERC4626} from "../../interfaces/core/vaults/IBaseCollateralVault.sol";
import {IMetaCore} from "../../interfaces/core/IMetaCore.sol";
import {IPriceFeed} from "../../interfaces/core/IPriceFeed.sol";
import {IAsset} from "../../interfaces/utils/tokens/IAsset.sol";
import {FeeLib} from "../../libraries/FeeLib.sol";
import {EmissionsLib} from "../../libraries/EmissionsLib.sol";
abstract contract BaseCollateralVault is ERC4626Upgradeable, UUPSUpgradeable, IBaseCollateralVault {
using Math for uint;
using SafeERC20 for IERC20;
using FeeLib for uint;
uint internal constant BP = 1e4;
// keccak256(abi.encode(uint(keccak256("openzeppelin.storage.BaseCollateralVault")) - 1)) & ~bytes32(uint(0xff))
bytes32 private constant BaseCollateralVaultStorageLocation = 0x19001df2d131e9aa1479f4ce661ae121445caf0662dea1e41907028a6da6fe00;
function _getBaseCollVaultStorage() internal pure returns (BaseCollVaultStorage storage store) {
assembly {
store.slot := BaseCollateralVaultStorageLocation
}
}
constructor() {
_disableInitializers();
}
function __BaseCollateralVault_init(BaseInitParams memory params) internal onlyInitializing {
__BaseCollateralVault_init_unchained(params);
}
function __BaseCollateralVault_init_unchained(BaseInitParams memory params) internal onlyInitializing {
BaseCollVaultStorage storage $ = _getBaseCollVaultStorage();
if (address(params._metaCore) == address(0) || address(params._asset) == address(0)) {
revert("CollVault: 0 address");
}
_requireAssetFeed(params._metaCore, address(params._asset));
require(params._withdrawFee >= params._minWithdrawFee && params._withdrawFee <= params._maxWithdrawFee, "CollVault: withdraw fee out of bounds");
$.minWithdrawFee = params._minWithdrawFee;
$.maxWithdrawFee = params._maxWithdrawFee;
$.withdrawFee = params._withdrawFee;
uint8 _assetDecimals = IAsset(address(params._asset)).decimals();
if (_assetDecimals > 18) {
revert("CollVault: asset decimals > 18");
}
$.assetDecimals = _assetDecimals;
$._metaCore = params._metaCore;
__ERC20_init(params._sharesName, params._sharesSymbol);
__ERC4626_init(params._asset);
}
function _requireAssetFeed(IMetaCore _metaCore, address asset) internal virtual {
IPriceFeed priceFeed = IPriceFeed(_metaCore.priceFeed());
require(priceFeed.fetchPrice(asset) != 0, "CollVault: asset price feed not set up");
}
modifier onlyOwner {
_onlyOwner();
_;
}
modifier harvestRewards() {
_harvestRewards();
_;
}
function _onlyOwner() private view {
// Owner is beacon variable MetaCore::owner()
require(msg.sender == getMetaCore().owner(), "CollVault: caller is not the owner");
}
function _authorizeUpgrade(address newImplementation) internal override virtual onlyOwner {}
/** @dev See {IERC4626-totalAssets}. */
/// @notice Returns the total assets in the vault, denominated in the asset of the vault
/// @dev Virtual accounting to avoid donations, asset valued denomination, returned in asset decimals
function totalAssets() public view override(ERC4626Upgradeable, IBaseCollateralVault) virtual returns (uint) {
return getBalance(asset());
}
/// @dev Called by PositionManager, returns the share usd value in WAD
/// @dev Fees are not accounted to downprice the share value for redeemCollateral,
/// for borrowing, MCR will account for this downprice
function fetchPrice() public view virtual returns (uint) {
uint _totalSupply = totalSupply();
if (_totalSupply == 0) return 0;
return (totalAssets() * 10 ** _decimalsOffset()).mulDiv(getPrice(asset()), _totalSupply);
}
/// @dev Note, validate this implementation if inherited by multi asset vault (LSTCollateralVault)
function _decimalsOffset() internal view override virtual returns (uint8) {
return 18 - assetDecimals();
}
function deposit(
uint assets,
address receiver
) public override(ERC4626Upgradeable, IERC4626) harvestRewards returns (uint shares) {
shares = super.deposit(assets, receiver);
_stake(assets);
_increaseBalance(asset(), assets);
}
function mint(
uint shares,
address receiver
) public override(ERC4626Upgradeable, IERC4626) harvestRewards returns (uint assets) {
assets = super.mint(shares, receiver);
_stake(assets);
_increaseBalance(asset(), assets);
}
function withdraw(
uint assets,
address receiver,
address _owner
) public override(ERC4626Upgradeable, IERC4626) harvestRewards returns (uint shares) {
uint _totalSupply = totalSupply(); // cached to don't account for the burn
{ // scope to avoid stack too deep error
uint256 maxAssets = maxWithdraw(_owner);
if (assets > maxAssets) {
revert ERC4626ExceededMaxWithdraw(_owner, assets, maxAssets);
}
}
uint shareFee;
(shares, shareFee) = _previewWithdraw(assets);
(uint assetAmount, uint netShares) = _applyShareFee(shares, _totalSupply, shareFee);
if (assetAmount != 0) {
_unstake(assetAmount);
_decreaseBalance(asset(), assetAmount);
}
_withdraw(msg.sender, receiver, _owner, assetAmount, shares);
_withdrawExtraRewardedTokens(receiver, netShares, _totalSupply);
}
/// @dev Decompounded redeem() function to reuse `previewRedeem()` on `lst.withdraw`
function redeem(
uint shares,
address receiver,
address _owner
) public override(ERC4626Upgradeable, IERC4626) harvestRewards returns (uint assets) {
uint _totalSupply = totalSupply(); // cached to don't account for the burn
{ // scope to avoid stack too deep error
uint256 maxShares = maxRedeem(_owner);
if (shares > maxShares) {
revert ERC4626ExceededMaxRedeem(_owner, shares, maxShares);
}
}
uint shareFee;
(assets, shareFee) = _previewRedeem(shares);
(uint assetAmount, uint netShares) = _applyShareFee(shares, _totalSupply, shareFee);
if (assetAmount != 0) {
_unstake(assetAmount);
_decreaseBalance(asset(), assetAmount);
}
_withdraw(msg.sender, receiver, _owner, assetAmount, shares);
_withdrawExtraRewardedTokens(receiver, netShares, _totalSupply);
}
function _applyShareFee(uint shares, uint _totalSupply, uint fee) internal virtual returns (uint, uint) {
BaseCollVaultStorage storage $ = _getBaseCollVaultStorage();
uint netShares = shares - fee;
uint assetAmount = netShares.mulDiv(getBalance(asset()), _totalSupply, Math.Rounding.Down);
address feeReceiver = $._metaCore.feeReceiver();
if (fee != 0) {
_mint(feeReceiver, fee);
}
return (assetAmount, netShares);
}
/// @dev Preview adding an exit fee on withdraw. See {IERC4626-previewWithdraw}.
function previewWithdraw(
uint assets
) public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint) {
(uint totalShares,) = _previewWithdraw(assets);
return totalShares;
}
function _previewWithdraw(uint assets) internal view virtual returns (uint, uint) {
BaseCollVaultStorage storage $ = _getBaseCollVaultStorage();
uint netShares = super.previewWithdraw(assets);
uint totalShares = netShares.mulDiv(BP, BP - $.withdrawFee, Math.Rounding.Up);
uint shareFee = totalShares - netShares;
return (totalShares, shareFee);
}
/// @dev Preview taking an exit fee on redeem. See {IERC4626-previewRedeem}.
function previewRedeem(
uint shares
) public view virtual override(ERC4626Upgradeable, IERC4626) returns (uint) {
(uint assets,) = _previewRedeem(shares);
return assets;
}
function _previewRedeem(uint shares) internal view virtual returns (uint, uint) {
BaseCollVaultStorage storage $ = _getBaseCollVaultStorage();
uint shareFee = shares.feeOnRaw($.withdrawFee);
uint assets = super.previewRedeem(shares - shareFee);
return (assets, shareFee);
}
/** @dev See {IERC4626-maxWithdraw}. */
function maxWithdraw(address _owner) public view override(ERC4626Upgradeable, IERC4626) returns (uint) {
return previewRedeem(balanceOf(_owner));
}
/// @dev `receiver` automatically receives `asset()` donations, and `tokens` and `amounts` donations as desired by the owner `amounts`
function receiveDonations(address[] memory tokens, uint[] memory amounts, address receiver) external virtual onlyOwner {
BaseCollVaultStorage storage $ = _getBaseCollVaultStorage();
uint tokensLength = tokens.length;
require(tokensLength == amounts.length, "CollVault: tokens and amounts length mismatch");
uint assetBalance = IERC20(asset()).balanceOf(address(this));
uint virtualBalance = $.balanceData.balance[asset()];
if (assetBalance > virtualBalance) {
IERC20(asset()).safeTransfer(receiver, assetBalance - virtualBalance);
}
for (uint i; i < tokensLength; i++) {
if (tokens[i] == asset()) {
continue;
}
uint256 tokenBalance = IERC20(tokens[i]).balanceOf(address(this));
uint256 virtualTokenBalance = $.balanceData.balance[tokens[i]];
uint256 transferAmount = Math.min(amounts[i], tokenBalance - virtualTokenBalance);
if (transferAmount > 0) {
IERC20(tokens[i]).safeTransfer(receiver, transferAmount);
}
}
}
function setWithdrawFee(uint16 _withdrawFee) external virtual onlyOwner {
BaseCollVaultStorage storage $ = _getBaseCollVaultStorage();
require(_withdrawFee >= $.minWithdrawFee && _withdrawFee <= $.maxWithdrawFee, "CollVault: Withdraw fee out of bounds");
$.withdrawFee = _withdrawFee;
}
function _increaseBalance(address token, uint amount) internal virtual {
BaseCollVaultStorage storage $ = _getBaseCollVaultStorage();
$.balanceData.balance[token] += amount;
}
function _decreaseBalance(address token, uint amount) internal virtual {
BaseCollVaultStorage storage $ = _getBaseCollVaultStorage();
$.balanceData.balance[token] -= amount;
}
function _getBalanceData() internal view virtual returns (EmissionsLib.BalanceData storage) {
return _getBaseCollVaultStorage().balanceData;
}
function getPrice(
address token
) public view virtual returns (uint) {
return getPriceFeed().fetchPrice(token);
}
function getBalance(address token) public view virtual returns (uint) {
return _getBaseCollVaultStorage().balanceData.balance[token];
}
function getWithdrawFee() public view virtual returns (uint16) {
return _getBaseCollVaultStorage().withdrawFee;
}
function getMetaCore() public view virtual returns (IMetaCore) {
return _getBaseCollVaultStorage()._metaCore;
}
function getPriceFeed() public view virtual returns (IPriceFeed) {
return IPriceFeed(_getBaseCollVaultStorage()._metaCore.priceFeed());
}
function assetDecimals() public view virtual returns (uint8) {
return _getBaseCollVaultStorage().assetDecimals;
}
function _harvestRewards() internal virtual {}
function _stake(uint amount) internal virtual {}
function _unstake(uint amount) internal virtual {}
function _withdrawExtraRewardedTokens(address receiver, uint netShares, uint _totalSupply) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {ERC20Upgradeable} from "../ERC20Upgradeable.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*
* This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for
* underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends
* the ERC-20 standard. Any additional extensions included along it would affect the "shares" token represented by this
* contract and not the "assets" token which is an independent contract.
*
* [CAUTION]
* ====
* In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning
* with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation
* attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial
* deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may
* similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by
* verifying the amount received is as expected, using a wrapper that performs these checks such as
* https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].
*
* Since v4.9, this implementation introduces configurable virtual assets and shares to help developers mitigate that risk.
* The `_decimalsOffset()` corresponds to an offset in the decimal representation between the underlying asset's decimals
* and the vault decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which
* itself determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default
* offset (0) makes it non-profitable even if an attacker is able to capture value from multiple user deposits, as a result
* of the value being captured by the virtual shares (out of the attacker's donation) matching the attacker's expected gains.
* With a larger offset, the attack becomes orders of magnitude more expensive than it is profitable. More details about the
* underlying math can be found xref:erc4626.adoc#inflation-attack[here].
*
* The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued
* to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets
* will cause the first user to exit to experience reduced losses in detriment to the last users that will experience
* bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the
* `_convertToShares` and `_convertToAssets` functions.
*
* To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].
* ====
*/
abstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626 {
using Math for uint256;
/// @custom:storage-location erc7201:openzeppelin.storage.ERC4626
struct ERC4626Storage {
IERC20 _asset;
uint8 _underlyingDecimals;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC4626")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC4626StorageLocation = 0x0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00;
function _getERC4626Storage() private pure returns (ERC4626Storage storage $) {
assembly {
$.slot := ERC4626StorageLocation
}
}
/**
* @dev Attempted to deposit more assets than the max amount for `receiver`.
*/
error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);
/**
* @dev Attempted to mint more shares than the max amount for `receiver`.
*/
error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);
/**
* @dev Attempted to withdraw more assets than the max amount for `receiver`.
*/
error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);
/**
* @dev Attempted to redeem more shares than the max amount for `receiver`.
*/
error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);
/**
* @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777).
*/
function __ERC4626_init(IERC20 asset_) internal onlyInitializing {
__ERC4626_init_unchained(asset_);
}
function __ERC4626_init_unchained(IERC20 asset_) internal onlyInitializing {
ERC4626Storage storage $ = _getERC4626Storage();
(bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);
$._underlyingDecimals = success ? assetDecimals : 18;
$._asset = asset_;
}
/**
* @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.
*/
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {
(bool success, bytes memory encodedDecimals) = address(asset_).staticcall(
abi.encodeCall(IERC20Metadata.decimals, ())
);
if (success && encodedDecimals.length >= 32) {
uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));
if (returnedDecimals <= type(uint8).max) {
return (true, uint8(returnedDecimals));
}
}
return (false, 0);
}
/**
* @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This
* "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the
* asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.
*
* See {IERC20Metadata-decimals}.
*/
function decimals() public view virtual override(IERC20Metadata, ERC20Upgradeable) returns (uint8) {
ERC4626Storage storage $ = _getERC4626Storage();
return $._underlyingDecimals + _decimalsOffset();
}
/** @dev See {IERC4626-asset}. */
function asset() public view virtual returns (address) {
ERC4626Storage storage $ = _getERC4626Storage();
return address($._asset);
}
/** @dev See {IERC4626-totalAssets}. */
function totalAssets() public view virtual returns (uint256) {
ERC4626Storage storage $ = _getERC4626Storage();
return $._asset.balanceOf(address(this));
}
/** @dev See {IERC4626-convertToShares}. */
function convertToShares(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Down);
}
/** @dev See {IERC4626-convertToAssets}. */
function convertToAssets(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Down);
}
/** @dev See {IERC4626-maxDeposit}. */
function maxDeposit(address) public view virtual returns (uint256) {
return type(uint256).max;
}
/** @dev See {IERC4626-maxMint}. */
function maxMint(address) public view virtual returns (uint256) {
return type(uint256).max;
}
/** @dev See {IERC4626-maxWithdraw}. */
function maxWithdraw(address owner) public view virtual returns (uint256) {
return _convertToAssets(balanceOf(owner), Math.Rounding.Down);
}
/** @dev See {IERC4626-maxRedeem}. */
function maxRedeem(address owner) public view virtual returns (uint256) {
return balanceOf(owner);
}
/** @dev See {IERC4626-previewDeposit}. */
function previewDeposit(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Down);
}
/** @dev See {IERC4626-previewMint}. */
function previewMint(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Up);
}
/** @dev See {IERC4626-previewWithdraw}. */
function previewWithdraw(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Up);
}
/** @dev See {IERC4626-previewRedeem}. */
function previewRedeem(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Down);
}
/** @dev See {IERC4626-deposit}. */
function deposit(uint256 assets, address receiver) public virtual returns (uint256) {
uint256 maxAssets = maxDeposit(receiver);
if (assets > maxAssets) {
revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);
}
uint256 shares = previewDeposit(assets);
_deposit(_msgSender(), receiver, assets, shares);
return shares;
}
/** @dev See {IERC4626-mint}. */
function mint(uint256 shares, address receiver) public virtual returns (uint256) {
uint256 maxShares = maxMint(receiver);
if (shares > maxShares) {
revert ERC4626ExceededMaxMint(receiver, shares, maxShares);
}
uint256 assets = previewMint(shares);
_deposit(_msgSender(), receiver, assets, shares);
return assets;
}
/** @dev See {IERC4626-withdraw}. */
function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {
uint256 maxAssets = maxWithdraw(owner);
if (assets > maxAssets) {
revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);
}
uint256 shares = previewWithdraw(assets);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return shares;
}
/** @dev See {IERC4626-redeem}. */
function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {
uint256 maxShares = maxRedeem(owner);
if (shares > maxShares) {
revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);
}
uint256 assets = previewRedeem(shares);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return assets;
}
/**
* @dev Internal conversion function (from assets to shares) with support for rounding direction.
*/
function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {
return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);
}
/**
* @dev Internal conversion function (from shares to assets) with support for rounding direction.
*/
function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {
return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);
}
/**
* @dev Deposit/mint common workflow.
*/
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {
ERC4626Storage storage $ = _getERC4626Storage();
// If _asset is ERC-777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the
// `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,
// calls the vault, which is assumed not malicious.
//
// Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the
// assets are transferred and before the shares are minted, which is a valid state.
// slither-disable-next-line reentrancy-no-eth
SafeERC20.safeTransferFrom($._asset, caller, address(this), assets);
_mint(receiver, shares);
emit Deposit(caller, receiver, assets, shares);
}
/**
* @dev Withdraw/redeem common workflow.
*/
function _withdraw(
address caller,
address receiver,
address owner,
uint256 assets,
uint256 shares
) internal virtual {
ERC4626Storage storage $ = _getERC4626Storage();
if (caller != owner) {
_spendAllowance(owner, caller, shares);
}
// If _asset is ERC-777, `transfer` can trigger a reentrancy AFTER the transfer happens through the
// `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,
// calls the vault, which is assumed not malicious.
//
// Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the
// shares are burned and after the assets are transferred, which is a valid state.
_burn(owner, shares);
SafeERC20.safeTransfer($._asset, receiver, assets);
emit Withdraw(caller, receiver, owner, assets, shares);
}
function _decimalsOffset() internal view virtual returns (uint8) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.20;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {IERC4626, IERC20} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {IPositionManager} from "../IPositionManager.sol";
import {IMetaCore} from "../IMetaCore.sol";
import {IPriceFeed} from "../IPriceFeed.sol";
import {EmissionsLib} from "src/libraries/EmissionsLib.sol";
interface IBaseCollateralVault is IERC4626, IERC1822Proxiable {
struct BaseInitParams {
uint16 _minWithdrawFee;
uint16 _maxWithdrawFee;
uint16 _withdrawFee;
IMetaCore _metaCore;
// ERC4626
IERC20 _asset;
// ERC20
string _sharesName;
string _sharesSymbol;
}
struct BaseCollVaultStorage {
uint16 minWithdrawFee;
uint16 maxWithdrawFee;
uint16 withdrawFee; // over rewarded tokens, in basis points
uint8 assetDecimals;
IMetaCore _metaCore;
// Second mapping of this struct is usless, but it's for retrocompatibility with LSTCollateralVault
EmissionsLib.BalanceData balanceData;
}
function totalAssets() external view returns (uint); // todo: maybe remove this
function fetchPrice() external view returns (uint);
function getPrice(address token) external view returns (uint);
function receiveDonations(address[] memory tokens, uint[] memory amounts, address receiver) external;
function setWithdrawFee(uint16 _withdrawFee) external;
function getBalance(address token) external view returns (uint);
function getWithdrawFee() external view returns (uint16);
function getMetaCore() external view returns (IMetaCore);
function getPriceFeed() external view returns (IPriceFeed);
function assetDecimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
interface IMetaCore {
// ---------------------------------
// Structures
// ---------------------------------
struct FeeInfo {
bool existsForDebtToken;
uint16 debtTokenFee;
}
struct RebalancerFeeInfo {
bool exists;
uint16 entryFee;
uint16 exitFee;
}
// ---------------------------------
// Public constants
// ---------------------------------
function OWNERSHIP_TRANSFER_DELAY() external view returns (uint256);
function DEFAULT_FLASH_LOAN_FEE() external view returns (uint16);
// ---------------------------------
// Public state variables
// ---------------------------------
function debtToken() external view returns (address);
function lspEntryFee() external view returns (uint16);
function lspExitFee() external view returns (uint16);
function interestProtocolShare() external view returns (uint16);
/// @dev Default interest receiver for all PositionManagers, unless overriden in the respective PM
function defaultInterestReceiver() external view returns (address);
function feeReceiver() external view returns (address);
function priceFeed() external view returns (address);
function owner() external view returns (address);
function pendingOwner() external view returns (address);
function ownershipTransferDeadline() external view returns (uint256);
function guardian() external view returns (address);
function paused() external view returns (bool);
function lspBootstrapPeriod() external view returns (uint64);
// ---------------------------------
// External functions
// ---------------------------------
function setFeeReceiver(address _feeReceiver) external;
function setPriceFeed(address _priceFeed) external;
function setGuardian(address _guardian) external;
/**
* @notice Global pause/unpause
* Pausing halts new deposits/borrowing across the protocol
*/
function setPaused(bool _paused) external;
/**
* @notice Extend or change the LSP bootstrap period,
* after which certain protocol mechanics change
*/
function setLspBootstrapPeriod(uint64 _bootstrapPeriod) external;
/**
* @notice Set a custom flash-loan fee for a given periphery contract
* @param _periphery Target contract that will get this custom fee
* @param _debtTokenFee Fee in basis points (bp)
* @param _existsForDebtToken Whether this custom fee is used when the caller = `debtToken`
*/
function setPeripheryFlashLoanFee(address _periphery, uint16 _debtTokenFee, bool _existsForDebtToken) external;
/**
* @notice Begin the ownership transfer process
* @param newOwner The address proposed to be the new owner
*/
function commitTransferOwnership(address newOwner) external;
/**
* @notice Finish the ownership transfer, after the mandatory delay
*/
function acceptTransferOwnership() external;
/**
* @notice Revoke a pending ownership transfer
*/
function revokeTransferOwnership() external;
/**
* @notice Look up a custom flash-loan fee for a specific periphery contract
* @param peripheryContract The contract that might have a custom fee
* @return The flash-loan fee in basis points
*/
function getPeripheryFlashLoanFee(address peripheryContract) external view returns (uint16);
/**
* @notice Set / override entry & exit fees for a special rebalancer contract
*/
function setRebalancerFee(address _rebalancer, uint16 _entryFee, uint16 _exitFee) external;
/**
* @notice Set the LSP entry fee globally
* @param _fee Fee in basis points
*/
function setEntryFee(uint16 _fee) external;
/**
* @notice Set the LSP exit fee globally
* @param _fee Fee in basis points
*/
function setExitFee(uint16 _fee) external;
/**
* @notice Set the interest protocol share globally to all PositionManagers
* @param _interestProtocolShare Share in basis points
*/
function setInterestProtocolShare(uint16 _interestProtocolShare) external;
/**
* @notice Look up the LSP entry fee for a rebalancer
* @param rebalancer Possibly has a special fee
* @return The entry fee in basis points
*/
function getLspEntryFee(address rebalancer) external view returns (uint16);
/**
* @notice Look up the LSP exit fee for a rebalancer
* @param rebalancer Possibly has a special fee
* @return The exit fee in basis points
*/
function getLspExitFee(address rebalancer) external view returns (uint16);
// ---------------------------------
// Events
// ---------------------------------
event NewOwnerCommitted(address indexed owner, address indexed pendingOwner, uint256 deadline);
event NewOwnerAccepted(address indexed oldOwner, address indexed newOwner);
event NewOwnerRevoked(address indexed owner, address indexed revokedOwner);
event FeeReceiverSet(address indexed feeReceiver);
event PriceFeedSet(address indexed priceFeed);
event GuardianSet(address indexed guardian);
event PeripheryFlashLoanFee(address indexed periphery, uint16 debtTokenFee);
event LSPBootstrapPeriodSet(uint64 bootstrapPeriod);
event RebalancerFees(address indexed rebalancer, uint16 entryFee, uint16 exitFee);
event EntryFeeSet(uint16 fee);
event ExitFeeSet(uint16 fee);
event InterestProtocolShareSet(uint16 interestProtocolShare);
event DefaultInterestReceiverSet(address indexed defaultInterestReceiver);
event Paused();
event Unpaused();
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IPriceFeed {
struct FeedType {
address spotOracle;
bool isCollVault;
}
event NewOracleRegistered(address token, address chainlinkAggregator, address underlyingDerivative);
event PriceFeedStatusUpdated(address token, address oracle, bool isWorking);
event PriceRecordUpdated(address indexed token, uint256 _price);
event NewCollVaultRegistered(address collVault, bool enable);
event NewSpotOracleRegistered(address token, address spotOracle);
function fetchPrice(address _token) external view returns (uint256);
function getMultiplePrices(address[] memory _tokens) external view returns (uint256[] memory prices);
function setOracle(
address _token,
address _chainlinkOracle,
uint32 _heartbeat,
uint16 _staleThreshold,
address underlyingDerivative
) external;
function whitelistCollateralVault(address _collateralVaultShareToken, bool enable) external;
function setSpotOracle(address _token, address _spotOracle) external;
function MAX_PRICE_DEVIATION_FROM_PREVIOUS_ROUND() external view returns (uint256);
function CORE() external view returns (address);
function RESPONSE_TIMEOUT() external view returns (uint256);
function TARGET_DIGITS() external view returns (uint256);
function guardian() external view returns (address);
function oracleRecords(
address
)
external
view
returns (
address chainLinkOracle,
uint8 decimals,
uint32 heartbeat,
uint16 staleThreshold,
address underlyingDerivative
);
function isCollVault(address _collateralVaultShareToken) external view returns (bool);
function isStableBPT(address _oracle) external view returns (bool);
function isWeightedBPT(address _oracle) external view returns (bool);
function getSpotOracle(address _token) external view returns (address);
function feedType(address _token) external view returns (FeedType memory);
function owner() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
interface IAsset is IERC20 {
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
library FeeLib {
using Math for uint;
uint private constant BP = 1e4;
/// @dev Calculates the fees that should be added to an amount `shares` that does already include fees.
/// Used in {IERC4626-deposit}, {IERC4626-mint}, {IERC4626-withdraw} and {IERC4626-previewRedeem} operations.
function feeOnRaw(
uint shares,
uint feeBP
) internal pure returns (uint) {
return shares.mulDiv(feeBP, BP, Math.Rounding.Up);
}
/// @dev Calculates the fee part of an amount `shares` that deoes not includes fees.
/// Used in {IERC4626-previewDeposit} and {IERC4626-previewRedeem} operations.
function feeOnTotal(
uint shares,
uint feeBP
) internal pure returns (uint) {
return shares.mulDiv(feeBP, feeBP + BP, Math.Rounding.Up);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
library EmissionsLib {
using SafeCast for uint256;
uint64 constant internal DEFAULT_UNLOCK_RATE = 1e11; // 10% per second
uint64 constant internal MAX_UNLOCK_RATE = 1e12; // 100%
struct BalanceData {
mapping(address token => uint) balance;
mapping(address token => EmissionSchedule) emissionSchedule;
}
struct EmissionSchedule {
uint128 emissions;
uint64 lockTimestamp;
uint64 _unlockRatePerSecond; // rate points
}
error AmountCannotBeZero();
error EmissionRateExceedsMax();
// error UnsupportedEmissionConfig();
event EmissionsAdded(address indexed token, uint128 amount);
event EmissionsSub(address indexed token, uint128 amount);
event NewUnlockRatePerSecond(address indexed token, uint64 unlockRatePerSecond);
/// @dev zero _unlockRatePerSecond parameter resets rate back to DEFAULT_UNLOCK_RATE
function setUnlockRatePerSecond(BalanceData storage $, address token, uint64 _unlockRatePerSecond) internal {
if (_unlockRatePerSecond > MAX_UNLOCK_RATE) revert EmissionRateExceedsMax();
_addEmissions($, token, 0); // update lockTimestamp and emissions
$.emissionSchedule[token]._unlockRatePerSecond = _unlockRatePerSecond;
emit NewUnlockRatePerSecond(token, _unlockRatePerSecond);
}
function addEmissions(BalanceData storage $, address token, uint128 amount) internal {
if (amount == 0) revert AmountCannotBeZero();
_addEmissions($, token, amount);
emit EmissionsAdded(token, amount);
}
function _addEmissions(BalanceData storage $, address token, uint128 amount) private {
EmissionSchedule memory schedule = $.emissionSchedule[token];
uint256 _unlockTimestamp = unlockTimestamp(schedule);
uint128 nextEmissions = (lockedEmissions(schedule, _unlockTimestamp) + amount).toUint128();
schedule.emissions = nextEmissions;
schedule.lockTimestamp = block.timestamp.toUint64();
$.balance[token] += amount;
$.emissionSchedule[token] = schedule;
}
function subEmissions(BalanceData storage $, address token, uint128 amount) internal {
if (amount == 0) revert AmountCannotBeZero();
_subEmissions($, token, amount);
emit EmissionsSub(token, amount);
}
function _subEmissions(BalanceData storage $, address token, uint128 amount) private {
EmissionSchedule memory schedule = $.emissionSchedule[token];
uint256 _unlockTimestamp = unlockTimestamp(schedule);
uint128 nextEmissions = (lockedEmissions(schedule, _unlockTimestamp) - amount).toUint128();
schedule.emissions = nextEmissions;
schedule.lockTimestamp = block.timestamp.toUint64();
$.balance[token] -= amount;
$.emissionSchedule[token] = schedule;
}
/// @dev Doesn't include locked emissions
function unlockedEmissions(EmissionSchedule memory schedule) internal view returns (uint256) {
return schedule.emissions - lockedEmissions(schedule, unlockTimestamp(schedule));
}
function balanceOfWithFutureEmissions(BalanceData storage $, address token) internal view returns (uint256) {
return $.balance[token];
}
/**
* @notice Returns the unlocked token emissions
*/
function balanceOf(BalanceData storage $, address token) internal view returns (uint256) {
EmissionSchedule memory schedule = $.emissionSchedule[token];
return $.balance[token] - lockedEmissions(schedule, unlockTimestamp(schedule));
}
/**
* @notice Returns locked emissions
*/
function lockedEmissions(EmissionSchedule memory schedule, uint256 _unlockTimestamp) internal view returns (uint256) {
if (block.timestamp >= _unlockTimestamp) {
// all emissions were unlocked
return 0;
} else {
// emissions are still unlocking, calculate the amount of already unlocked emissions
uint256 secondsSinceLockup = block.timestamp - schedule.lockTimestamp;
// design decision - use dimensionless 'unlock rate units' to unlock emissions over a fixed time window
uint256 ratePointsUnlocked = unlockRatePerSecond(schedule) * secondsSinceLockup;
// emissions remainder is designed to be added to balance in unlockTimestamp
return schedule.emissions - ratePointsUnlocked * schedule.emissions / MAX_UNLOCK_RATE;
}
}
// timestamp at which all emissions are fully unlocked
function unlockTimestamp(EmissionSchedule memory schedule) internal pure returns (uint256) {
// ceil to account for remainder seconds left after integer division
return divRoundUp(MAX_UNLOCK_RATE, unlockRatePerSecond(schedule)) + schedule.lockTimestamp;
}
function unlockRatePerSecond(EmissionSchedule memory schedule) internal pure returns (uint256) {
return schedule._unlockRatePerSecond == 0 ? DEFAULT_UNLOCK_RATE : schedule._unlockRatePerSecond;
}
function divRoundUp(uint256 dividend, uint256 divisor) internal pure returns (uint256) {
return (dividend + divisor - 1) / divisor;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors {
/// @custom:storage-location erc7201:openzeppelin.storage.ERC20
struct ERC20Storage {
mapping(address account => uint256) _balances;
mapping(address account => mapping(address spender => uint256)) _allowances;
uint256 _totalSupply;
string _name;
string _symbol;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
function _getERC20Storage() private pure returns (ERC20Storage storage $) {
assembly {
$.slot := ERC20StorageLocation
}
}
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
ERC20Storage storage $ = _getERC20Storage();
$._name = name_;
$._symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
$._totalSupply += value;
} else {
uint256 fromBalance = $._balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
$._balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
$._totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
$._balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
$._allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/IERC20.sol";
import "../token/ERC20/extensions/IERC20Metadata.sol";
/**
* @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*
* _Available since v4.7._
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(
uint256 assets,
address receiver,
address owner
) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(
uint256 shares,
address receiver,
address owner
) external returns (uint256 assets);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.21;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC3156FlashBorrower} from "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IFactory} from "./IFactory.sol";
interface IPositionManager {
event BaseRateUpdated(uint256 _baseRate);
event CollateralSent(address _to, uint256 _amount);
event LTermsUpdated(uint256 _L_collateral, uint256 _L_debt);
event LastFeeOpTimeUpdated(uint256 _lastFeeOpTime);
event Redemption(
address indexed _redeemer,
uint256 _attemptedDebtAmount,
uint256 _actualDebtAmount,
uint256 _collateralSent,
uint256 _collateralFee
);
event SystemSnapshotsUpdated(uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot);
event TotalStakesUpdated(uint256 _newTotalStakes);
event PositionIndexUpdated(address _borrower, uint256 _newIndex);
event PositionSnapshotsUpdated(uint256 _L_collateral, uint256 _L_debt);
event PositionUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, uint8 _operation);
function addCollateralSurplus(address borrower, uint256 collSurplus) external;
function applyPendingRewards(address _borrower) external returns (uint256 coll, uint256 debt);
function claimCollateral(address borrower, address _receiver) external;
function closePosition(address _borrower, address _receiver, uint256 collAmount, uint256 debtAmount) external;
function closePositionByLiquidation(address _borrower) external;
function setCollVaultRouter(address _collVaultRouter) external;
function collectInterests() external;
function decayBaseRateAndGetBorrowingFee(uint256 _debt) external returns (uint256);
function decreaseDebtAndSendCollateral(address account, uint256 debt, uint256 coll) external;
function fetchPrice() external view returns (uint256);
function finalizeLiquidation(
address _liquidator,
uint256 _debt,
uint256 _coll,
uint256 _collSurplus,
uint256 _debtGasComp,
uint256 _collGasComp
) external;
function getEntireSystemBalances() external view returns (uint256, uint256, uint256);
function movePendingPositionRewardsToActiveBalances(uint256 _debt, uint256 _collateral) external;
function openPosition(
address _borrower,
uint256 _collateralAmount,
uint256 _compositeDebt,
uint256 NICR,
address _upperHint,
address _lowerHint
) external returns (uint256 stake, uint256 arrayIndex);
function redeemCollateral(
uint256 _debtAmount,
address _firstRedemptionHint,
address _upperPartialRedemptionHint,
address _lowerPartialRedemptionHint,
uint256 _partialRedemptionHintNICR,
uint256 _maxIterations,
uint256 _maxFeePercentage
) external;
function setAddresses(address _priceFeedAddress, address _sortedPositionsAddress, address _collateralToken) external;
function setParameters(
IFactory.DeploymentParams calldata _params
) external;
function setPaused(bool _paused) external;
function setPriceFeed(address _priceFeedAddress) external;
function startSunset() external;
function updateBalances() external;
function updatePositionFromAdjustment(
bool _isDebtIncrease,
uint256 _debtChange,
uint256 _netDebtChange,
bool _isCollIncrease,
uint256 _collChange,
address _upperHint,
address _lowerHint,
address _borrower,
address _receiver
) external returns (uint256, uint256, uint256);
function DEBT_GAS_COMPENSATION() external view returns (uint256);
function DECIMAL_PRECISION() external view returns (uint256);
function L_collateral() external view returns (uint256);
function L_debt() external view returns (uint256);
function MCR() external view returns (uint256);
function PERCENT_DIVISOR() external view returns (uint256);
function CORE() external view returns (address);
function SUNSETTING_INTEREST_RATE() external view returns (uint256);
function Positions(
address
)
external
view
returns (
uint256 debt,
uint256 coll,
uint256 stake,
uint8 status,
uint128 arrayIndex,
uint256 activeInterestIndex
);
function activeInterestIndex() external view returns (uint256);
function baseRate() external view returns (uint256);
function borrowerOperations() external view returns (address);
function borrowingFeeFloor() external view returns (uint256);
function collateralToken() external view returns (address);
function debtToken() external view returns (address);
function collVaultRouter() external view returns (address);
function defaultedCollateral() external view returns (uint256);
function defaultedDebt() external view returns (uint256);
function getBorrowingFee(uint256 _debt) external view returns (uint256);
function getBorrowingFeeWithDecay(uint256 _debt) external view returns (uint256);
function getBorrowingRate() external view returns (uint256);
function getBorrowingRateWithDecay() external view returns (uint256);
function getCurrentICR(address _borrower, uint256 _price) external view returns (uint256);
function getEntireDebtAndColl(
address _borrower
) external view returns (uint256 debt, uint256 coll, uint256 pendingDebtReward, uint256 pendingCollateralReward);
function getEntireSystemColl() external view returns (uint256);
function getEntireSystemDebt() external view returns (uint256);
function getNominalICR(address _borrower) external view returns (uint256);
function getPendingCollAndDebtRewards(address _borrower) external view returns (uint256, uint256);
function getRedemptionFeeWithDecay(uint256 _collateralDrawn) external view returns (uint256);
function getRedemptionRate() external view returns (uint256);
function getRedemptionRateWithDecay() external view returns (uint256);
function getTotalActiveCollateral() external view returns (uint256);
function getTotalActiveDebt() external view returns (uint256);
function getPositionCollAndDebt(address _borrower) external view returns (uint256 coll, uint256 debt);
function getPositionFromPositionOwnersArray(uint256 _index) external view returns (address);
function getPositionOwnersCount() external view returns (uint256);
function getPositionStake(address _borrower) external view returns (uint256);
function getPositionStatus(address _borrower) external view returns (uint256);
function guardian() external view returns (address);
function hasPendingRewards(address _borrower) external view returns (bool);
function interestPayable() external view returns (uint256);
function interestRate() external view returns (uint256);
function lastActiveIndexUpdate() external view returns (uint256);
function lastCollateralError_Redistribution() external view returns (uint256);
function lastDebtError_Redistribution() external view returns (uint256);
function lastFeeOperationTime() external view returns (uint256);
function liquidationManager() external view returns (address);
function maxBorrowingFee() external view returns (uint256);
function maxRedemptionFee() external view returns (uint256);
function maxSystemDebt() external view returns (uint256);
function minuteDecayFactor() external view returns (uint256);
function owner() external view returns (address);
function paused() external view returns (bool);
function priceFeed() external view returns (address);
function redemptionFeeFloor() external view returns (uint256);
function rewardSnapshots(address) external view returns (uint256 collateral, uint256 debt);
function sortedPositions() external view returns (address);
function sunsetting() external view returns (bool);
function surplusBalances(address) external view returns (uint256);
function systemDeploymentTime() external view returns (uint256);
function totalCollateralSnapshot() external view returns (uint256);
function totalStakes() external view returns (uint256);
function totalStakesSnapshot() external view returns (uint256);
}// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC3156 FlashBorrower, as defined in
* https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
*
* _Available since v4.1._
*/
interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
interface IFactory {
// commented values are suggested default parameters
struct DeploymentParams {
uint256 minuteDecayFactor; // 999037758833783000 (half life of 12 hours)
uint256 redemptionFeeFloor; // 1e18 / 1000 * 5 (0.5%)
uint256 maxRedemptionFee; // 1e18 (100%)
uint256 borrowingFeeFloor; // 1e18 / 1000 * 5 (0.5%)
uint256 maxBorrowingFee; // 1e18 / 100 * 5 (5%)
uint256 interestRateInBps; // 100 (1%)
uint256 maxDebt;
uint256 MCR; // 12 * 1e17 (120%)
address collVaultRouter; // set to address(0) if PositionManager coll is not CollateralVault
}
event NewDeployment(address collateral, address priceFeed, address positionManager, address sortedPositions);
function deployNewInstance(
address collateral,
address priceFeed,
address customPositionManagerImpl,
address customSortedPositionsImpl,
DeploymentParams calldata params,
uint64 unlockRatePerSecond,
bool forceThroughLspBalanceCheck
) external;
function setImplementations(address _positionManagerImpl, address _sortedPositionsImpl) external;
function CORE() external view returns (address);
function borrowerOperations() external view returns (address);
function debtToken() external view returns (address);
function guardian() external view returns (address);
function liquidationManager() external view returns (address);
function owner() external view returns (address);
function sortedPositionsImpl() external view returns (address);
function liquidStabilityPool() external view returns (address);
function positionManagerCount() external view returns (uint256);
function positionManagerImpl() external view returns (address);
function positionManagers(uint256) external view returns (address);
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin-upgradeable/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/",
"solady/=lib/solady/src/",
"@solmate/=lib/solmate/src/",
"@chimera/=lib/chimera/src/",
"forge-std/=lib/forge-std/src/",
"@uniswap/v3-core/=lib/v3-core/",
"@uniswap/v3-periphery/=lib/v3-periphery/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"chimera/=lib/chimera/src/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"rewards/=lib/rewards/",
"solmate/=lib/solmate/src/",
"v3-core/=lib/v3-core/contracts/",
"v3-periphery/=lib/v3-periphery/contracts/"
],
"optimizer": {
"enabled": false,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxDeposit","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxMint","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxRedeem","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxWithdraw","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fetchPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMetaCore","outputs":[{"internalType":"contract IMetaCore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPriceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWithdrawFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"_minWithdrawFee","type":"uint16"},{"internalType":"uint16","name":"_maxWithdrawFee","type":"uint16"},{"internalType":"uint16","name":"_withdrawFee","type":"uint16"},{"internalType":"contract IMetaCore","name":"_metaCore","type":"address"},{"internalType":"contract IERC20","name":"_asset","type":"address"},{"internalType":"string","name":"_sharesName","type":"string"},{"internalType":"string","name":"_sharesSymbol","type":"string"}],"internalType":"struct IBaseCollateralVault.BaseInitParams","name":"baseParams","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"receiver","type":"address"}],"name":"receiveDonations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_withdrawFee","type":"uint16"}],"name":"setWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60a06040523073ffffffffffffffffffffffffffffffffffffffff1660809073ffffffffffffffffffffffffffffffffffffffff16815250348015610042575f80fd5b5061005161005660201b60201c565b6101b6565b5f61006561015460201b60201c565b9050805f0160089054906101000a900460ff16156100af576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff8016815f015f9054906101000a900467ffffffffffffffff1667ffffffffffffffff16146101515767ffffffffffffffff815f015f6101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055507fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d267ffffffffffffffff604051610148919061019d565b60405180910390a15b50565b5f7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00905090565b5f67ffffffffffffffff82169050919050565b6101978161017b565b82525050565b5f6020820190506101b05f83018461018e565b92915050565b60805161510b6101dc5f395f8181611e1201528181611e670152612021015261510b5ff3fe608060405260043610610224575f3560e01c80636e553f6511610122578063b460af94116100aa578063ce96cb771161006e578063ce96cb771461089e578063d905777e146108da578063dd62ed3e14610916578063ef8b30f714610952578063f8b2cb4f1461098e57610224565b8063b460af9414610784578063ba087652146107c0578063c2d41601146107fc578063c63d75b614610826578063c6e6f5921461086257610224565b806397640e98116100f157806397640e98146106905780639e87a5cd146106b8578063a9059cbb146106e2578063ad3cb1cc1461071e578063b3d7f6b91461074857610224565b80636e553f65146105b257806370a08231146105ee57806394bf804d1461062a57806395d89b411461066657610224565b806323b872dd116101b0578063402d267d11610174578063402d267d146104b857806341976e09146104f45780634cdad506146105305780634f1ef2861461056c57806352d1902d1461058857610224565b806323b872dd146103d8578063313ce56714610414578063322ce8f01461043e57806332e1fef21461046657806338d52e0f1461048e57610224565b80630a28a477116101f75780630a28a477146102f45780630fa7bbdd146103305780630fdb11cf1461035a5780631540aa891461038457806318160ddd146103ae57610224565b806301e1d1141461022857806306fdde031461025257806307a2d13a1461027c578063095ea7b3146102b8575b5f80fd5b348015610233575f80fd5b5061023c6109ca565b60405161024991906137ad565b60405180910390f35b34801561025d575f80fd5b506102666109e0565b6040516102739190613836565b60405180910390f35b348015610287575f80fd5b506102a2600480360381019061029d9190613891565b610a7e565b6040516102af91906137ad565b60405180910390f35b3480156102c3575f80fd5b506102de60048036038101906102d99190613916565b610a90565b6040516102eb919061396e565b60405180910390f35b3480156102ff575f80fd5b5061031a60048036038101906103159190613891565b610ab2565b60405161032791906137ad565b60405180910390f35b34801561033b575f80fd5b50610344610ac9565b60405161035191906139e2565b60405180910390f35b348015610365575f80fd5b5061036e610afa565b60405161037b91906137ad565b60405180910390f35b34801561038f575f80fd5b50610398610b66565b6040516103a59190613a17565b60405180910390f35b3480156103b9575f80fd5b506103c2610b85565b6040516103cf91906137ad565b60405180910390f35b3480156103e3575f80fd5b506103fe60048036038101906103f99190613a30565b610b9c565b60405161040b919061396e565b60405180910390f35b34801561041f575f80fd5b50610428610bca565b6040516104359190613a9b565b60405180910390f35b348015610449575f80fd5b50610464600480360381019061045f9190613ade565b610bff565b005b348015610471575f80fd5b5061048c60048036038101906104879190613d09565b610cb4565b005b348015610499575f80fd5b506104a2611011565b6040516104af9190613da0565b60405180910390f35b3480156104c3575f80fd5b506104de60048036038101906104d99190613db9565b611046565b6040516104eb91906137ad565b60405180910390f35b3480156104ff575f80fd5b5061051a60048036038101906105159190613db9565b61106f565b60405161052791906137ad565b60405180910390f35b34801561053b575f80fd5b5061055660048036038101906105519190613891565b6110f6565b60405161056391906137ad565b60405180910390f35b61058660048036038101906105819190613e94565b61110d565b005b348015610593575f80fd5b5061059c61112c565b6040516105a99190613f06565b60405180910390f35b3480156105bd575f80fd5b506105d860048036038101906105d39190613f1f565b61115d565b6040516105e591906137ad565b60405180910390f35b3480156105f9575f80fd5b50610614600480360381019061060f9190613db9565b611192565b60405161062191906137ad565b60405180910390f35b348015610635575f80fd5b50610650600480360381019061064b9190613f1f565b6111e5565b60405161065d91906137ad565b60405180910390f35b348015610671575f80fd5b5061067a61121a565b6040516106879190613836565b60405180910390f35b34801561069b575f80fd5b506106b660048036038101906106b19190613f7f565b6112b8565b005b3480156106c3575f80fd5b506106cc611442565b6040516106d99190613fe6565b60405180910390f35b3480156106ed575f80fd5b5061070860048036038101906107039190613916565b6114df565b604051610715919061396e565b60405180910390f35b348015610729575f80fd5b50610732611501565b60405161073f9190613836565b60405180910390f35b348015610753575f80fd5b5061076e60048036038101906107699190613891565b61153a565b60405161077b91906137ad565b60405180910390f35b34801561078f575f80fd5b506107aa60048036038101906107a59190613fff565b61154d565b6040516107b791906137ad565b60405180910390f35b3480156107cb575f80fd5b506107e660048036038101906107e19190613fff565b61161f565b6040516107f391906137ad565b60405180910390f35b348015610807575f80fd5b506108106116f1565b60405161081d9190613a9b565b60405180910390f35b348015610831575f80fd5b5061084c60048036038101906108479190613db9565b61170f565b60405161085991906137ad565b60405180910390f35b34801561086d575f80fd5b5061088860048036038101906108839190613891565b611738565b60405161089591906137ad565b60405180910390f35b3480156108a9575f80fd5b506108c460048036038101906108bf9190613db9565b61174a565b6040516108d191906137ad565b60405180910390f35b3480156108e5575f80fd5b5061090060048036038101906108fb9190613db9565b611763565b60405161090d91906137ad565b60405180910390f35b348015610921575f80fd5b5061093c6004803603810190610937919061404f565b611774565b60405161094991906137ad565b60405180910390f35b34801561095d575f80fd5b5061097860048036038101906109739190613891565b611804565b60405161098591906137ad565b60405180910390f35b348015610999575f80fd5b506109b460048036038101906109af9190613db9565b611816565b6040516109c191906137ad565b60405180910390f35b5f6109db6109d6611011565b611816565b905090565b60605f6109eb611867565b90508060030180546109fc906140ba565b80601f0160208091040260200160405190810160405280929190818152602001828054610a28906140ba565b8015610a735780601f10610a4a57610100808354040283529160200191610a73565b820191905f5260205f20905b815481529060010190602001808311610a5657829003601f168201915b505050505091505090565b5f610a89825f61188e565b9050919050565b5f80610a9a6118e6565b9050610aa78185856118ed565b600191505092915050565b5f80610abd836118ff565b50905080915050919050565b5f610ad2611975565b5f0160079054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f80610b04610b85565b90505f8103610b16575f915050610b63565b610b5f610b29610b24611011565b61106f565b82610b3261199c565b600a610b3e9190614246565b610b466109ca565b610b509190614290565b6119b69092919063ffffffff16565b9150505b90565b5f610b6f611975565b5f0160049054906101000a900461ffff16905090565b5f80610b8f611867565b9050806002015491505090565b5f80610ba66118e6565b9050610bb3858285611a89565b610bbe858585611b1b565b60019150509392505050565b5f80610bd4611c0b565b9050610bde61199c565b815f0160149054906101000a900460ff16610bf991906142d1565b91505090565b610c07611c32565b5f610c10611975565b9050805f015f9054906101000a900461ffff1661ffff168261ffff1610158015610c535750805f0160029054906101000a900461ffff1661ffff168261ffff1611155b610c92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8990614375565b60405180910390fd5b81815f0160046101000a81548161ffff021916908361ffff1602179055505050565b610cbc611c32565b5f610cc5611975565b90505f8451905083518114610d0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0690614403565b60405180910390fd5b5f610d18611011565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610d509190613da0565b602060405180830381865afa158015610d6b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d8f9190614435565b90505f836001015f015f610da1611011565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905080821115610e2357610e22858284610df59190614460565b610dfd611011565b73ffffffffffffffffffffffffffffffffffffffff16611d159092919063ffffffff16565b5b5f5b8381101561100757610e35611011565b73ffffffffffffffffffffffffffffffffffffffff16888281518110610e5e57610e5d614493565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff160315610ffa575f888281518110610e9657610e95614493565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610ed69190613da0565b602060405180830381865afa158015610ef1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f159190614435565b90505f866001015f015f8b8581518110610f3257610f31614493565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490505f610fa68a8581518110610f8d57610f8c614493565b5b60200260200101518385610fa19190614460565b611d9b565b90505f811115610ff657610ff589828d8781518110610fc857610fc7614493565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16611d159092919063ffffffff16565b5b5050505b8080600101915050610e25565b5050505050505050565b5f8061101b611c0b565b9050805f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505090565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9050919050565b5f611078611442565b73ffffffffffffffffffffffffffffffffffffffff1663ace1798e836040518263ffffffff1660e01b81526004016110b09190613da0565b602060405180830381865afa1580156110cb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110ef9190614435565b9050919050565b5f8061110183611db3565b50905080915050919050565b611115611e10565b61111e82611ef6565b6111288282611f01565b5050565b5f61113561201f565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5f1b905090565b5f6111666120a6565b61117083836120a8565b905061117b83612128565b61118c611186611011565b8461212b565b92915050565b5f8061119c611867565b9050805f015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054915050919050565b5f6111ee6120a6565b6111f88383612192565b905061120381612128565b61121461120e611011565b8261212b565b92915050565b60605f611225611867565b9050806004018054611236906140ba565b80601f0160208091040260200160405190810160405280929190818152602001828054611262906140ba565b80156112ad5780601f10611284576101008083540402835291602001916112ad565b820191905f5260205f20905b81548152906001019060200180831161129057829003601f168201915b505050505091505090565b5f6112c1612212565b90505f815f0160089054906101000a900460ff161590505f825f015f9054906101000a900467ffffffffffffffff1690505f808267ffffffffffffffff161480156113095750825b90505f60018367ffffffffffffffff1614801561133c57505f3073ffffffffffffffffffffffffffffffffffffffff163b145b90508115801561134a575080155b15611381576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001855f015f6101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555083156113ce576001855f0160086101000a81548160ff0219169083151502179055505b6113e0866113db906146c5565b612239565b831561143a575f855f0160086101000a81548160ff0219169083151502179055507fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d260016040516114319190614723565b60405180910390a15b505050505050565b5f61144b611975565b5f0160079054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114b6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114da9190614750565b905090565b5f806114e96118e6565b90506114f6818585611b1b565b600191505092915050565b6040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b5f61154682600161188e565b9050919050565b5f6115566120a6565b5f61155f610b85565b90505f61156b8461174a565b9050808611156115b6578386826040517ffe9cceec0000000000000000000000000000000000000000000000000000000081526004016115ad9392919061477b565b60405180910390fd5b505f6115c1866118ff565b80925081945050505f806115d685858561224d565b915091505f82146115fc576115ea82612349565b6115fb6115f5611011565b8361234c565b5b61160933888885896123b3565b6116148782866124ba565b505050509392505050565b5f6116286120a6565b5f611631610b85565b90505f61163d84611763565b905080861115611688578386826040517fb94abeec00000000000000000000000000000000000000000000000000000000815260040161167f9392919061477b565b60405180910390fd5b505f61169386611db3565b80925081945050505f806116a888858561224d565b915091505f82146116ce576116bc82612349565b6116cd6116c7611011565b8361234c565b5b6116db338888858c6123b3565b6116e68782866124ba565b505050509392505050565b5f6116fa611975565b5f0160069054906101000a900460ff16905090565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9050919050565b5f611743825f6124bf565b9050919050565b5f61175c61175783611192565b6110f6565b9050919050565b5f61176d82611192565b9050919050565b5f8061177e611867565b9050806001015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205491505092915050565b5f61180f825f6124bf565b9050919050565b5f61181f611975565b6001015f015f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b5f7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00905090565b5f6118de600161189c6109ca565b6118a691906147b0565b6118ae61199c565b600a6118ba9190614246565b6118c2610b85565b6118cc91906147b0565b8486612517909392919063ffffffff16565b905092915050565b5f33905090565b6118fa838383600161258b565b505050565b5f805f61190a611975565b90505f61191685612768565b90505f611955612710845f0160049054906101000a900461ffff1661ffff166127106119429190614460565b600185612517909392919063ffffffff16565b90505f82826119649190614460565b905081819550955050505050915091565b5f7f19001df2d131e9aa1479f4ce661ae121445caf0662dea1e41907028a6da6fe00905090565b5f6119a56116f1565b60126119b191906147e3565b905090565b5f805f80198587098587029250828110838203039150505f81036119ee578382816119e4576119e3614817565b5b0492505050611a82565b8084116119f9575f80fd5b5f8486880990508281118203915080830392505f60018619018616905080860495508084049350600181825f0304019050808302841793505f600287600302189050808702600203810290508087026002038102905080870260020381029050808702600203810290508087026002038102905080870260020381029050808502955050505050505b9392505050565b5f611a948484611774565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114611b155781811015611b06578281836040517ffb8f41b2000000000000000000000000000000000000000000000000000000008152600401611afd9392919061477b565b60405180910390fd5b611b1484848484035f61258b565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611b8b575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401611b829190613da0565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611bfb575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401611bf29190613da0565b60405180910390fd5b611c0683838361277b565b505050565b5f7f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00905090565b611c3a610ac9565b73ffffffffffffffffffffffffffffffffffffffff16638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c82573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ca69190614750565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611d13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d0a906148b4565b60405180910390fd5b565b611d968363a9059cbb60e01b8484604051602401611d349291906148d2565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506129aa565b505050565b5f818310611da95781611dab565b825b905092915050565b5f805f611dbe611975565b90505f611de9825f0160049054906101000a900461ffff1661ffff1686612a6f90919063ffffffff16565b90505f611e008287611dfb9190614460565b612a92565b9050808294509450505050915091565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161480611ebd57507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16611ea4612aa4565b73ffffffffffffffffffffffffffffffffffffffff1614155b15611ef4576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b611efe611c32565b50565b8173ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611f6957506040513d601f19601f82011682018060405250810190611f669190614923565b60015b611faa57816040517f4c9c8ce3000000000000000000000000000000000000000000000000000000008152600401611fa19190613da0565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5f1b811461201057806040517faa1d49a40000000000000000000000000000000000000000000000000000000081526004016120079190613f06565b60405180910390fd5b61201a8383612af7565b505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16146120a4576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b565b5f806120b383611046565b9050808411156120fe578284826040517f79012fb20000000000000000000000000000000000000000000000000000000081526004016120f59392919061477b565b60405180910390fd5b5f61210885611804565b905061211d6121156118e6565b858784612b69565b809250505092915050565b50565b5f612134611975565b905081816001015f015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461218691906147b0565b92505081905550505050565b5f8061219d8361170f565b9050808411156121e8578284826040517f284ff6670000000000000000000000000000000000000000000000000000000081526004016121df9392919061477b565b60405180910390fd5b5f6121f28561153a565b90506122076121ff6118e6565b858388612b69565b809250505092915050565b5f7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00905090565b612241612c1a565b61224a81612c5a565b50565b5f805f612258611975565b90505f84876122679190614460565b90505f61229061227d612278611011565b611816565b885f85612517909392919063ffffffff16565b90505f835f0160079054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b3f006746040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122ff573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123239190614750565b90505f8714612337576123368188612f3f565b5b81839550955050505050935093915050565b50565b5f612355611975565b905081816001015f015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546123a79190614460565b92505081905550505050565b5f6123bc611c0b565b90508373ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16146123fd576123fc848784611a89565b5b6124078483612fbe565b612434815f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff168685611d15565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db86866040516124aa92919061494e565b60405180910390a4505050505050565b505050565b5f61250f6124cb61199c565b600a6124d79190614246565b6124df610b85565b6124e991906147b0565b60016124f36109ca565b6124fd91906147b0565b8486612517909392919063ffffffff16565b905092915050565b5f806125248686866119b6565b90506001600281111561253a57612539614975565b5b83600281111561254d5761254c614975565b5b14801561256a57505f848061256557612564614817565b5b868809115b1561257f5760018161257c91906147b0565b90505b80915050949350505050565b5f612594611867565b90505f73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603612606575f6040517fe602df050000000000000000000000000000000000000000000000000000000081526004016125fd9190613da0565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603612676575f6040517f94280d6200000000000000000000000000000000000000000000000000000000815260040161266d9190613da0565b60405180910390fd5b82816001015f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508115612761578373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258560405161275891906137ad565b60405180910390a35b5050505050565b5f6127748260016124bf565b9050919050565b5f612784611867565b90505f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036127d85781816002015f8282546127cc91906147b0565b925050819055506128aa565b5f815f015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905082811015612863578481846040517fe450d38c00000000000000000000000000000000000000000000000000000000815260040161285a9392919061477b565b60405180910390fd5b828103825f015f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036128f35781816002015f828254039250508190555061293f565b81815f015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161299c91906137ad565b60405180910390a350505050565b5f612a0b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661303d9092919063ffffffff16565b90505f81511115612a6a5780806020019051810190612a2a91906149cc565b612a69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a6090614a67565b60405180910390fd5b5b505050565b5f612a8a82612710600186612517909392919063ffffffff16565b905092915050565b5f612a9d825f61188e565b9050919050565b5f612ad07f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5f1b613054565b5f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b612b008261305d565b8173ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a25f81511115612b5c57612b568282613126565b50612b65565b612b64613153565b5b5050565b5f612b72611c0b565b9050612ba2815f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1686308661318f565b612bac8483612f3f565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051612c0b92919061494e565b60405180910390a35050505050565b612c22613218565b612c58576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b612c62612c1a565b5f612c6b611975565b90505f73ffffffffffffffffffffffffffffffffffffffff16826060015173ffffffffffffffffffffffffffffffffffffffff161480612cda57505f73ffffffffffffffffffffffffffffffffffffffff16826080015173ffffffffffffffffffffffffffffffffffffffff16145b15612d1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d1190614acf565b60405180910390fd5b612d2c82606001518360800151613236565b815f015161ffff16826040015161ffff1610158015612d5b5750816020015161ffff16826040015161ffff1611155b612d9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d9190614b5d565b60405180910390fd5b815f0151815f015f6101000a81548161ffff021916908361ffff1602179055508160200151815f0160026101000a81548161ffff021916908361ffff1602179055508160400151815f0160046101000a81548161ffff021916908361ffff1602179055505f826080015173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e4c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e709190614ba5565b905060128160ff161115612eb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612eb090614c1a565b60405180910390fd5b80825f0160066101000a81548160ff021916908360ff1602179055508260600151825f0160076101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550612f2d8360a001518460c00151613364565b612f3a836080015161337a565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612faf575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401612fa69190613da0565b60405180910390fd5b612fba5f838361277b565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361302e575f6040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016130259190613da0565b60405180910390fd5b613039825f8361277b565b5050565b606061304b84845f8561338e565b90509392505050565b5f819050919050565b5f8173ffffffffffffffffffffffffffffffffffffffff163b036130b857806040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526004016130af9190613da0565b60405180910390fd5b806130e47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5f1b613054565b5f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606061314b83836040518060600160405280602781526020016150af60279139613457565b905092915050565b5f34111561318d576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b613212846323b872dd60e01b8585856040516024016131b093929190614c38565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506129aa565b50505050565b5f613221612212565b5f0160089054906101000a900460ff16905090565b5f8273ffffffffffffffffffffffffffffffffffffffff1663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613280573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132a49190614750565b90505f8173ffffffffffffffffffffffffffffffffffffffff1663ace1798e846040518263ffffffff1660e01b81526004016132e09190613da0565b602060405180830381865afa1580156132fb573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061331f9190614435565b0361335f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161335690614cdd565b60405180910390fd5b505050565b61336c612c1a565b61337682826134d9565b5050565b613382612c1a565b61338b81613515565b50565b6060824710156133d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133ca90614d6b565b60405180910390fd5b5f808673ffffffffffffffffffffffffffffffffffffffff1685876040516133fb9190614dcd565b5f6040518083038185875af1925050503d805f8114613435576040519150601f19603f3d011682016040523d82523d5f602084013e61343a565b606091505b509150915061344b878383876135a7565b92505050949350505050565b60605f808573ffffffffffffffffffffffffffffffffffffffff16856040516134809190614dcd565b5f60405180830381855af49150503d805f81146134b8576040519150601f19603f3d011682016040523d82523d5f602084013e6134bd565b606091505b50915091506134ce868383876135a7565b925050509392505050565b6134e1612c1a565b5f6134ea611867565b9050828160030190816134fd9190614f77565b508181600401908161350f9190614f77565b50505050565b61351d612c1a565b5f613526611c0b565b90505f806135338461361b565b9150915081613543576012613545565b805b835f0160146101000a81548160ff021916908360ff16021790555083835f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b60608315613608575f835103613600576135c085613724565b6135ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135f690615090565b60405180910390fd5b5b829050613613565b6136128383613746565b5b949350505050565b5f805f808473ffffffffffffffffffffffffffffffffffffffff1660405160240160405160208183030381529060405263313ce56760e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161368e9190614dcd565b5f60405180830381855afa9150503d805f81146136c6576040519150601f19603f3d011682016040523d82523d5f602084013e6136cb565b606091505b50915091508180156136df57506020815110155b15613716575f818060200190518101906136f99190614435565b905060ff80168111613714576001819450945050505061371f565b505b5f809350935050505b915091565b5f808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b5f825111156137585781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161378c9190613836565b60405180910390fd5b5f819050919050565b6137a781613795565b82525050565b5f6020820190506137c05f83018461379e565b92915050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f613808826137c6565b61381281856137d0565b93506138228185602086016137e0565b61382b816137ee565b840191505092915050565b5f6020820190508181035f83015261384e81846137fe565b905092915050565b5f604051905090565b5f80fd5b5f80fd5b61387081613795565b811461387a575f80fd5b50565b5f8135905061388b81613867565b92915050565b5f602082840312156138a6576138a561385f565b5b5f6138b38482850161387d565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6138e5826138bc565b9050919050565b6138f5816138db565b81146138ff575f80fd5b50565b5f81359050613910816138ec565b92915050565b5f806040838503121561392c5761392b61385f565b5b5f61393985828601613902565b925050602061394a8582860161387d565b9150509250929050565b5f8115159050919050565b61396881613954565b82525050565b5f6020820190506139815f83018461395f565b92915050565b5f819050919050565b5f6139aa6139a56139a0846138bc565b613987565b6138bc565b9050919050565b5f6139bb82613990565b9050919050565b5f6139cc826139b1565b9050919050565b6139dc816139c2565b82525050565b5f6020820190506139f55f8301846139d3565b92915050565b5f61ffff82169050919050565b613a11816139fb565b82525050565b5f602082019050613a2a5f830184613a08565b92915050565b5f805f60608486031215613a4757613a4661385f565b5b5f613a5486828701613902565b9350506020613a6586828701613902565b9250506040613a768682870161387d565b9150509250925092565b5f60ff82169050919050565b613a9581613a80565b82525050565b5f602082019050613aae5f830184613a8c565b92915050565b613abd816139fb565b8114613ac7575f80fd5b50565b5f81359050613ad881613ab4565b92915050565b5f60208284031215613af357613af261385f565b5b5f613b0084828501613aca565b91505092915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b613b43826137ee565b810181811067ffffffffffffffff82111715613b6257613b61613b0d565b5b80604052505050565b5f613b74613856565b9050613b808282613b3a565b919050565b5f67ffffffffffffffff821115613b9f57613b9e613b0d565b5b602082029050602081019050919050565b5f80fd5b5f613bc6613bc184613b85565b613b6b565b90508083825260208201905060208402830185811115613be957613be8613bb0565b5b835b81811015613c125780613bfe8882613902565b845260208401935050602081019050613beb565b5050509392505050565b5f82601f830112613c3057613c2f613b09565b5b8135613c40848260208601613bb4565b91505092915050565b5f67ffffffffffffffff821115613c6357613c62613b0d565b5b602082029050602081019050919050565b5f613c86613c8184613c49565b613b6b565b90508083825260208201905060208402830185811115613ca957613ca8613bb0565b5b835b81811015613cd25780613cbe888261387d565b845260208401935050602081019050613cab565b5050509392505050565b5f82601f830112613cf057613cef613b09565b5b8135613d00848260208601613c74565b91505092915050565b5f805f60608486031215613d2057613d1f61385f565b5b5f84013567ffffffffffffffff811115613d3d57613d3c613863565b5b613d4986828701613c1c565b935050602084013567ffffffffffffffff811115613d6a57613d69613863565b5b613d7686828701613cdc565b9250506040613d8786828701613902565b9150509250925092565b613d9a816138db565b82525050565b5f602082019050613db35f830184613d91565b92915050565b5f60208284031215613dce57613dcd61385f565b5b5f613ddb84828501613902565b91505092915050565b5f80fd5b5f67ffffffffffffffff821115613e0257613e01613b0d565b5b613e0b826137ee565b9050602081019050919050565b828183375f83830152505050565b5f613e38613e3384613de8565b613b6b565b905082815260208101848484011115613e5457613e53613de4565b5b613e5f848285613e18565b509392505050565b5f82601f830112613e7b57613e7a613b09565b5b8135613e8b848260208601613e26565b91505092915050565b5f8060408385031215613eaa57613ea961385f565b5b5f613eb785828601613902565b925050602083013567ffffffffffffffff811115613ed857613ed7613863565b5b613ee485828601613e67565b9150509250929050565b5f819050919050565b613f0081613eee565b82525050565b5f602082019050613f195f830184613ef7565b92915050565b5f8060408385031215613f3557613f3461385f565b5b5f613f428582860161387d565b9250506020613f5385828601613902565b9150509250929050565b5f80fd5b5f60e08284031215613f7657613f75613f5d565b5b81905092915050565b5f60208284031215613f9457613f9361385f565b5b5f82013567ffffffffffffffff811115613fb157613fb0613863565b5b613fbd84828501613f61565b91505092915050565b5f613fd0826139b1565b9050919050565b613fe081613fc6565b82525050565b5f602082019050613ff95f830184613fd7565b92915050565b5f805f606084860312156140165761401561385f565b5b5f6140238682870161387d565b935050602061403486828701613902565b925050604061404586828701613902565b9150509250925092565b5f80604083850312156140655761406461385f565b5b5f61407285828601613902565b925050602061408385828601613902565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806140d157607f821691505b6020821081036140e4576140e361408d565b5b50919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f8160011c9050919050565b5f808291508390505b600185111561416c57808604811115614148576141476140ea565b5b60018516156141575780820291505b808102905061416585614117565b945061412c565b94509492505050565b5f82614184576001905061423f565b81614191575f905061423f565b81600181146141a757600281146141b1576141e0565b600191505061423f565b60ff8411156141c3576141c26140ea565b5b8360020a9150848211156141da576141d96140ea565b5b5061423f565b5060208310610133831016604e8410600b84101617156142155782820a9050838111156142105761420f6140ea565b5b61423f565b6142228484846001614123565b92509050818404811115614239576142386140ea565b5b81810290505b9392505050565b5f61425082613795565b915061425b83613a80565b92506142887fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484614175565b905092915050565b5f61429a82613795565b91506142a583613795565b92508282026142b381613795565b915082820484148315176142ca576142c96140ea565b5b5092915050565b5f6142db82613a80565b91506142e683613a80565b9250828201905060ff8111156142ff576142fe6140ea565b5b92915050565b7f436f6c6c5661756c743a20576974686472617720666565206f7574206f6620625f8201527f6f756e6473000000000000000000000000000000000000000000000000000000602082015250565b5f61435f6025836137d0565b915061436a82614305565b604082019050919050565b5f6020820190508181035f83015261438c81614353565b9050919050565b7f436f6c6c5661756c743a20746f6b656e7320616e6420616d6f756e7473206c655f8201527f6e677468206d69736d6174636800000000000000000000000000000000000000602082015250565b5f6143ed602d836137d0565b91506143f882614393565b604082019050919050565b5f6020820190508181035f83015261441a816143e1565b9050919050565b5f8151905061442f81613867565b92915050565b5f6020828403121561444a5761444961385f565b5b5f61445784828501614421565b91505092915050565b5f61446a82613795565b915061447583613795565b925082820390508181111561448d5761448c6140ea565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f80fd5b5f80fd5b5f6144d2826138db565b9050919050565b6144e2816144c8565b81146144ec575f80fd5b50565b5f813590506144fd816144d9565b92915050565b5f61450d826138db565b9050919050565b61451d81614503565b8114614527575f80fd5b50565b5f8135905061453881614514565b92915050565b5f67ffffffffffffffff82111561455857614557613b0d565b5b614561826137ee565b9050602081019050919050565b5f61458061457b8461453e565b613b6b565b90508281526020810184848401111561459c5761459b613de4565b5b6145a7848285613e18565b509392505050565b5f82601f8301126145c3576145c2613b09565b5b81356145d384826020860161456e565b91505092915050565b5f60e082840312156145f1576145f06144c0565b5b6145fb60e0613b6b565b90505f61460a84828501613aca565b5f83015250602061461d84828501613aca565b602083015250604061463184828501613aca565b6040830152506060614645848285016144ef565b60608301525060806146598482850161452a565b60808301525060a082013567ffffffffffffffff81111561467d5761467c6144c4565b5b614689848285016145af565b60a08301525060c082013567ffffffffffffffff8111156146ad576146ac6144c4565b5b6146b9848285016145af565b60c08301525092915050565b5f6146d036836145dc565b9050919050565b5f819050919050565b5f67ffffffffffffffff82169050919050565b5f61470d614708614703846146d7565b613987565b6146e0565b9050919050565b61471d816146f3565b82525050565b5f6020820190506147365f830184614714565b92915050565b5f8151905061474a816138ec565b92915050565b5f602082840312156147655761476461385f565b5b5f6147728482850161473c565b91505092915050565b5f60608201905061478e5f830186613d91565b61479b602083018561379e565b6147a8604083018461379e565b949350505050565b5f6147ba82613795565b91506147c583613795565b92508282019050808211156147dd576147dc6140ea565b5b92915050565b5f6147ed82613a80565b91506147f883613a80565b9250828203905060ff811115614811576148106140ea565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7f436f6c6c5661756c743a2063616c6c6572206973206e6f7420746865206f776e5f8201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b5f61489e6022836137d0565b91506148a982614844565b604082019050919050565b5f6020820190508181035f8301526148cb81614892565b9050919050565b5f6040820190506148e55f830185613d91565b6148f2602083018461379e565b9392505050565b61490281613eee565b811461490c575f80fd5b50565b5f8151905061491d816148f9565b92915050565b5f602082840312156149385761493761385f565b5b5f6149458482850161490f565b91505092915050565b5f6040820190506149615f83018561379e565b61496e602083018461379e565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6149ab81613954565b81146149b5575f80fd5b50565b5f815190506149c6816149a2565b92915050565b5f602082840312156149e1576149e061385f565b5b5f6149ee848285016149b8565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e5f8201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b5f614a51602a836137d0565b9150614a5c826149f7565b604082019050919050565b5f6020820190508181035f830152614a7e81614a45565b9050919050565b7f436f6c6c5661756c743a203020616464726573730000000000000000000000005f82015250565b5f614ab96014836137d0565b9150614ac482614a85565b602082019050919050565b5f6020820190508181035f830152614ae681614aad565b9050919050565b7f436f6c6c5661756c743a20776974686472617720666565206f7574206f6620625f8201527f6f756e6473000000000000000000000000000000000000000000000000000000602082015250565b5f614b476025836137d0565b9150614b5282614aed565b604082019050919050565b5f6020820190508181035f830152614b7481614b3b565b9050919050565b614b8481613a80565b8114614b8e575f80fd5b50565b5f81519050614b9f81614b7b565b92915050565b5f60208284031215614bba57614bb961385f565b5b5f614bc784828501614b91565b91505092915050565b7f436f6c6c5661756c743a20617373657420646563696d616c73203e20313800005f82015250565b5f614c04601e836137d0565b9150614c0f82614bd0565b602082019050919050565b5f6020820190508181035f830152614c3181614bf8565b9050919050565b5f606082019050614c4b5f830186613d91565b614c586020830185613d91565b614c65604083018461379e565b949350505050565b7f436f6c6c5661756c743a2061737365742070726963652066656564206e6f74205f8201527f7365742075700000000000000000000000000000000000000000000000000000602082015250565b5f614cc76026836137d0565b9150614cd282614c6d565b604082019050919050565b5f6020820190508181035f830152614cf481614cbb565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f5f8201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b5f614d556026836137d0565b9150614d6082614cfb565b604082019050919050565b5f6020820190508181035f830152614d8281614d49565b9050919050565b5f81519050919050565b5f81905092915050565b5f614da782614d89565b614db18185614d93565b9350614dc18185602086016137e0565b80840191505092915050565b5f614dd88284614d9d565b915081905092915050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302614e3f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82614e04565b614e498683614e04565b95508019841693508086168417925050509392505050565b5f614e7b614e76614e7184613795565b613987565b613795565b9050919050565b5f819050919050565b614e9483614e61565b614ea8614ea082614e82565b848454614e10565b825550505050565b5f90565b614ebc614eb0565b614ec7818484614e8b565b505050565b5b81811015614eea57614edf5f82614eb4565b600181019050614ecd565b5050565b601f821115614f2f57614f0081614de3565b614f0984614df5565b81016020851015614f18578190505b614f2c614f2485614df5565b830182614ecc565b50505b505050565b5f82821c905092915050565b5f614f4f5f1984600802614f34565b1980831691505092915050565b5f614f678383614f40565b9150826002028217905092915050565b614f80826137c6565b67ffffffffffffffff811115614f9957614f98613b0d565b5b614fa382546140ba565b614fae828285614eee565b5f60209050601f831160018114614fdf575f8415614fcd578287015190505b614fd78582614f5c565b86555061503e565b601f198416614fed86614de3565b5f5b8281101561501457848901518255600182019150602085019450602081019050614fef565b86831015615031578489015161502d601f891682614f40565b8355505b6001600288020188555050505b505050505050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000005f82015250565b5f61507a601d836137d0565b915061508582615046565b602082019050919050565b5f6020820190508181035f8301526150a78161506e565b905091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a377d42104d7e0109b54c6571b881444073f2597b3ed3d7f1d733458e242941f64736f6c634300081a0033
Deployed Bytecode
0x608060405260043610610224575f3560e01c80636e553f6511610122578063b460af94116100aa578063ce96cb771161006e578063ce96cb771461089e578063d905777e146108da578063dd62ed3e14610916578063ef8b30f714610952578063f8b2cb4f1461098e57610224565b8063b460af9414610784578063ba087652146107c0578063c2d41601146107fc578063c63d75b614610826578063c6e6f5921461086257610224565b806397640e98116100f157806397640e98146106905780639e87a5cd146106b8578063a9059cbb146106e2578063ad3cb1cc1461071e578063b3d7f6b91461074857610224565b80636e553f65146105b257806370a08231146105ee57806394bf804d1461062a57806395d89b411461066657610224565b806323b872dd116101b0578063402d267d11610174578063402d267d146104b857806341976e09146104f45780634cdad506146105305780634f1ef2861461056c57806352d1902d1461058857610224565b806323b872dd146103d8578063313ce56714610414578063322ce8f01461043e57806332e1fef21461046657806338d52e0f1461048e57610224565b80630a28a477116101f75780630a28a477146102f45780630fa7bbdd146103305780630fdb11cf1461035a5780631540aa891461038457806318160ddd146103ae57610224565b806301e1d1141461022857806306fdde031461025257806307a2d13a1461027c578063095ea7b3146102b8575b5f80fd5b348015610233575f80fd5b5061023c6109ca565b60405161024991906137ad565b60405180910390f35b34801561025d575f80fd5b506102666109e0565b6040516102739190613836565b60405180910390f35b348015610287575f80fd5b506102a2600480360381019061029d9190613891565b610a7e565b6040516102af91906137ad565b60405180910390f35b3480156102c3575f80fd5b506102de60048036038101906102d99190613916565b610a90565b6040516102eb919061396e565b60405180910390f35b3480156102ff575f80fd5b5061031a60048036038101906103159190613891565b610ab2565b60405161032791906137ad565b60405180910390f35b34801561033b575f80fd5b50610344610ac9565b60405161035191906139e2565b60405180910390f35b348015610365575f80fd5b5061036e610afa565b60405161037b91906137ad565b60405180910390f35b34801561038f575f80fd5b50610398610b66565b6040516103a59190613a17565b60405180910390f35b3480156103b9575f80fd5b506103c2610b85565b6040516103cf91906137ad565b60405180910390f35b3480156103e3575f80fd5b506103fe60048036038101906103f99190613a30565b610b9c565b60405161040b919061396e565b60405180910390f35b34801561041f575f80fd5b50610428610bca565b6040516104359190613a9b565b60405180910390f35b348015610449575f80fd5b50610464600480360381019061045f9190613ade565b610bff565b005b348015610471575f80fd5b5061048c60048036038101906104879190613d09565b610cb4565b005b348015610499575f80fd5b506104a2611011565b6040516104af9190613da0565b60405180910390f35b3480156104c3575f80fd5b506104de60048036038101906104d99190613db9565b611046565b6040516104eb91906137ad565b60405180910390f35b3480156104ff575f80fd5b5061051a60048036038101906105159190613db9565b61106f565b60405161052791906137ad565b60405180910390f35b34801561053b575f80fd5b5061055660048036038101906105519190613891565b6110f6565b60405161056391906137ad565b60405180910390f35b61058660048036038101906105819190613e94565b61110d565b005b348015610593575f80fd5b5061059c61112c565b6040516105a99190613f06565b60405180910390f35b3480156105bd575f80fd5b506105d860048036038101906105d39190613f1f565b61115d565b6040516105e591906137ad565b60405180910390f35b3480156105f9575f80fd5b50610614600480360381019061060f9190613db9565b611192565b60405161062191906137ad565b60405180910390f35b348015610635575f80fd5b50610650600480360381019061064b9190613f1f565b6111e5565b60405161065d91906137ad565b60405180910390f35b348015610671575f80fd5b5061067a61121a565b6040516106879190613836565b60405180910390f35b34801561069b575f80fd5b506106b660048036038101906106b19190613f7f565b6112b8565b005b3480156106c3575f80fd5b506106cc611442565b6040516106d99190613fe6565b60405180910390f35b3480156106ed575f80fd5b5061070860048036038101906107039190613916565b6114df565b604051610715919061396e565b60405180910390f35b348015610729575f80fd5b50610732611501565b60405161073f9190613836565b60405180910390f35b348015610753575f80fd5b5061076e60048036038101906107699190613891565b61153a565b60405161077b91906137ad565b60405180910390f35b34801561078f575f80fd5b506107aa60048036038101906107a59190613fff565b61154d565b6040516107b791906137ad565b60405180910390f35b3480156107cb575f80fd5b506107e660048036038101906107e19190613fff565b61161f565b6040516107f391906137ad565b60405180910390f35b348015610807575f80fd5b506108106116f1565b60405161081d9190613a9b565b60405180910390f35b348015610831575f80fd5b5061084c60048036038101906108479190613db9565b61170f565b60405161085991906137ad565b60405180910390f35b34801561086d575f80fd5b5061088860048036038101906108839190613891565b611738565b60405161089591906137ad565b60405180910390f35b3480156108a9575f80fd5b506108c460048036038101906108bf9190613db9565b61174a565b6040516108d191906137ad565b60405180910390f35b3480156108e5575f80fd5b5061090060048036038101906108fb9190613db9565b611763565b60405161090d91906137ad565b60405180910390f35b348015610921575f80fd5b5061093c6004803603810190610937919061404f565b611774565b60405161094991906137ad565b60405180910390f35b34801561095d575f80fd5b5061097860048036038101906109739190613891565b611804565b60405161098591906137ad565b60405180910390f35b348015610999575f80fd5b506109b460048036038101906109af9190613db9565b611816565b6040516109c191906137ad565b60405180910390f35b5f6109db6109d6611011565b611816565b905090565b60605f6109eb611867565b90508060030180546109fc906140ba565b80601f0160208091040260200160405190810160405280929190818152602001828054610a28906140ba565b8015610a735780601f10610a4a57610100808354040283529160200191610a73565b820191905f5260205f20905b815481529060010190602001808311610a5657829003601f168201915b505050505091505090565b5f610a89825f61188e565b9050919050565b5f80610a9a6118e6565b9050610aa78185856118ed565b600191505092915050565b5f80610abd836118ff565b50905080915050919050565b5f610ad2611975565b5f0160079054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f80610b04610b85565b90505f8103610b16575f915050610b63565b610b5f610b29610b24611011565b61106f565b82610b3261199c565b600a610b3e9190614246565b610b466109ca565b610b509190614290565b6119b69092919063ffffffff16565b9150505b90565b5f610b6f611975565b5f0160049054906101000a900461ffff16905090565b5f80610b8f611867565b9050806002015491505090565b5f80610ba66118e6565b9050610bb3858285611a89565b610bbe858585611b1b565b60019150509392505050565b5f80610bd4611c0b565b9050610bde61199c565b815f0160149054906101000a900460ff16610bf991906142d1565b91505090565b610c07611c32565b5f610c10611975565b9050805f015f9054906101000a900461ffff1661ffff168261ffff1610158015610c535750805f0160029054906101000a900461ffff1661ffff168261ffff1611155b610c92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8990614375565b60405180910390fd5b81815f0160046101000a81548161ffff021916908361ffff1602179055505050565b610cbc611c32565b5f610cc5611975565b90505f8451905083518114610d0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0690614403565b60405180910390fd5b5f610d18611011565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610d509190613da0565b602060405180830381865afa158015610d6b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d8f9190614435565b90505f836001015f015f610da1611011565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905080821115610e2357610e22858284610df59190614460565b610dfd611011565b73ffffffffffffffffffffffffffffffffffffffff16611d159092919063ffffffff16565b5b5f5b8381101561100757610e35611011565b73ffffffffffffffffffffffffffffffffffffffff16888281518110610e5e57610e5d614493565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff160315610ffa575f888281518110610e9657610e95614493565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610ed69190613da0565b602060405180830381865afa158015610ef1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f159190614435565b90505f866001015f015f8b8581518110610f3257610f31614493565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490505f610fa68a8581518110610f8d57610f8c614493565b5b60200260200101518385610fa19190614460565b611d9b565b90505f811115610ff657610ff589828d8781518110610fc857610fc7614493565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16611d159092919063ffffffff16565b5b5050505b8080600101915050610e25565b5050505050505050565b5f8061101b611c0b565b9050805f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505090565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9050919050565b5f611078611442565b73ffffffffffffffffffffffffffffffffffffffff1663ace1798e836040518263ffffffff1660e01b81526004016110b09190613da0565b602060405180830381865afa1580156110cb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110ef9190614435565b9050919050565b5f8061110183611db3565b50905080915050919050565b611115611e10565b61111e82611ef6565b6111288282611f01565b5050565b5f61113561201f565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5f1b905090565b5f6111666120a6565b61117083836120a8565b905061117b83612128565b61118c611186611011565b8461212b565b92915050565b5f8061119c611867565b9050805f015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054915050919050565b5f6111ee6120a6565b6111f88383612192565b905061120381612128565b61121461120e611011565b8261212b565b92915050565b60605f611225611867565b9050806004018054611236906140ba565b80601f0160208091040260200160405190810160405280929190818152602001828054611262906140ba565b80156112ad5780601f10611284576101008083540402835291602001916112ad565b820191905f5260205f20905b81548152906001019060200180831161129057829003601f168201915b505050505091505090565b5f6112c1612212565b90505f815f0160089054906101000a900460ff161590505f825f015f9054906101000a900467ffffffffffffffff1690505f808267ffffffffffffffff161480156113095750825b90505f60018367ffffffffffffffff1614801561133c57505f3073ffffffffffffffffffffffffffffffffffffffff163b145b90508115801561134a575080155b15611381576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001855f015f6101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555083156113ce576001855f0160086101000a81548160ff0219169083151502179055505b6113e0866113db906146c5565b612239565b831561143a575f855f0160086101000a81548160ff0219169083151502179055507fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d260016040516114319190614723565b60405180910390a15b505050505050565b5f61144b611975565b5f0160079054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114b6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114da9190614750565b905090565b5f806114e96118e6565b90506114f6818585611b1b565b600191505092915050565b6040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b5f61154682600161188e565b9050919050565b5f6115566120a6565b5f61155f610b85565b90505f61156b8461174a565b9050808611156115b6578386826040517ffe9cceec0000000000000000000000000000000000000000000000000000000081526004016115ad9392919061477b565b60405180910390fd5b505f6115c1866118ff565b80925081945050505f806115d685858561224d565b915091505f82146115fc576115ea82612349565b6115fb6115f5611011565b8361234c565b5b61160933888885896123b3565b6116148782866124ba565b505050509392505050565b5f6116286120a6565b5f611631610b85565b90505f61163d84611763565b905080861115611688578386826040517fb94abeec00000000000000000000000000000000000000000000000000000000815260040161167f9392919061477b565b60405180910390fd5b505f61169386611db3565b80925081945050505f806116a888858561224d565b915091505f82146116ce576116bc82612349565b6116cd6116c7611011565b8361234c565b5b6116db338888858c6123b3565b6116e68782866124ba565b505050509392505050565b5f6116fa611975565b5f0160069054906101000a900460ff16905090565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9050919050565b5f611743825f6124bf565b9050919050565b5f61175c61175783611192565b6110f6565b9050919050565b5f61176d82611192565b9050919050565b5f8061177e611867565b9050806001015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205491505092915050565b5f61180f825f6124bf565b9050919050565b5f61181f611975565b6001015f015f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b5f7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00905090565b5f6118de600161189c6109ca565b6118a691906147b0565b6118ae61199c565b600a6118ba9190614246565b6118c2610b85565b6118cc91906147b0565b8486612517909392919063ffffffff16565b905092915050565b5f33905090565b6118fa838383600161258b565b505050565b5f805f61190a611975565b90505f61191685612768565b90505f611955612710845f0160049054906101000a900461ffff1661ffff166127106119429190614460565b600185612517909392919063ffffffff16565b90505f82826119649190614460565b905081819550955050505050915091565b5f7f19001df2d131e9aa1479f4ce661ae121445caf0662dea1e41907028a6da6fe00905090565b5f6119a56116f1565b60126119b191906147e3565b905090565b5f805f80198587098587029250828110838203039150505f81036119ee578382816119e4576119e3614817565b5b0492505050611a82565b8084116119f9575f80fd5b5f8486880990508281118203915080830392505f60018619018616905080860495508084049350600181825f0304019050808302841793505f600287600302189050808702600203810290508087026002038102905080870260020381029050808702600203810290508087026002038102905080870260020381029050808502955050505050505b9392505050565b5f611a948484611774565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114611b155781811015611b06578281836040517ffb8f41b2000000000000000000000000000000000000000000000000000000008152600401611afd9392919061477b565b60405180910390fd5b611b1484848484035f61258b565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611b8b575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401611b829190613da0565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611bfb575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401611bf29190613da0565b60405180910390fd5b611c0683838361277b565b505050565b5f7f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00905090565b611c3a610ac9565b73ffffffffffffffffffffffffffffffffffffffff16638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c82573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ca69190614750565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611d13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d0a906148b4565b60405180910390fd5b565b611d968363a9059cbb60e01b8484604051602401611d349291906148d2565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506129aa565b505050565b5f818310611da95781611dab565b825b905092915050565b5f805f611dbe611975565b90505f611de9825f0160049054906101000a900461ffff1661ffff1686612a6f90919063ffffffff16565b90505f611e008287611dfb9190614460565b612a92565b9050808294509450505050915091565b7f0000000000000000000000007df53dd25cf521efdf98dd3170fecebfc5c1b3ce73ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161480611ebd57507f0000000000000000000000007df53dd25cf521efdf98dd3170fecebfc5c1b3ce73ffffffffffffffffffffffffffffffffffffffff16611ea4612aa4565b73ffffffffffffffffffffffffffffffffffffffff1614155b15611ef4576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b611efe611c32565b50565b8173ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611f6957506040513d601f19601f82011682018060405250810190611f669190614923565b60015b611faa57816040517f4c9c8ce3000000000000000000000000000000000000000000000000000000008152600401611fa19190613da0565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5f1b811461201057806040517faa1d49a40000000000000000000000000000000000000000000000000000000081526004016120079190613f06565b60405180910390fd5b61201a8383612af7565b505050565b7f0000000000000000000000007df53dd25cf521efdf98dd3170fecebfc5c1b3ce73ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16146120a4576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b565b5f806120b383611046565b9050808411156120fe578284826040517f79012fb20000000000000000000000000000000000000000000000000000000081526004016120f59392919061477b565b60405180910390fd5b5f61210885611804565b905061211d6121156118e6565b858784612b69565b809250505092915050565b50565b5f612134611975565b905081816001015f015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461218691906147b0565b92505081905550505050565b5f8061219d8361170f565b9050808411156121e8578284826040517f284ff6670000000000000000000000000000000000000000000000000000000081526004016121df9392919061477b565b60405180910390fd5b5f6121f28561153a565b90506122076121ff6118e6565b858388612b69565b809250505092915050565b5f7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00905090565b612241612c1a565b61224a81612c5a565b50565b5f805f612258611975565b90505f84876122679190614460565b90505f61229061227d612278611011565b611816565b885f85612517909392919063ffffffff16565b90505f835f0160079054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b3f006746040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122ff573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123239190614750565b90505f8714612337576123368188612f3f565b5b81839550955050505050935093915050565b50565b5f612355611975565b905081816001015f015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546123a79190614460565b92505081905550505050565b5f6123bc611c0b565b90508373ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16146123fd576123fc848784611a89565b5b6124078483612fbe565b612434815f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff168685611d15565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db86866040516124aa92919061494e565b60405180910390a4505050505050565b505050565b5f61250f6124cb61199c565b600a6124d79190614246565b6124df610b85565b6124e991906147b0565b60016124f36109ca565b6124fd91906147b0565b8486612517909392919063ffffffff16565b905092915050565b5f806125248686866119b6565b90506001600281111561253a57612539614975565b5b83600281111561254d5761254c614975565b5b14801561256a57505f848061256557612564614817565b5b868809115b1561257f5760018161257c91906147b0565b90505b80915050949350505050565b5f612594611867565b90505f73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603612606575f6040517fe602df050000000000000000000000000000000000000000000000000000000081526004016125fd9190613da0565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603612676575f6040517f94280d6200000000000000000000000000000000000000000000000000000000815260040161266d9190613da0565b60405180910390fd5b82816001015f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508115612761578373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258560405161275891906137ad565b60405180910390a35b5050505050565b5f6127748260016124bf565b9050919050565b5f612784611867565b90505f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036127d85781816002015f8282546127cc91906147b0565b925050819055506128aa565b5f815f015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905082811015612863578481846040517fe450d38c00000000000000000000000000000000000000000000000000000000815260040161285a9392919061477b565b60405180910390fd5b828103825f015f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036128f35781816002015f828254039250508190555061293f565b81815f015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161299c91906137ad565b60405180910390a350505050565b5f612a0b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661303d9092919063ffffffff16565b90505f81511115612a6a5780806020019051810190612a2a91906149cc565b612a69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a6090614a67565b60405180910390fd5b5b505050565b5f612a8a82612710600186612517909392919063ffffffff16565b905092915050565b5f612a9d825f61188e565b9050919050565b5f612ad07f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5f1b613054565b5f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b612b008261305d565b8173ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a25f81511115612b5c57612b568282613126565b50612b65565b612b64613153565b5b5050565b5f612b72611c0b565b9050612ba2815f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1686308661318f565b612bac8483612f3f565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78585604051612c0b92919061494e565b60405180910390a35050505050565b612c22613218565b612c58576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b612c62612c1a565b5f612c6b611975565b90505f73ffffffffffffffffffffffffffffffffffffffff16826060015173ffffffffffffffffffffffffffffffffffffffff161480612cda57505f73ffffffffffffffffffffffffffffffffffffffff16826080015173ffffffffffffffffffffffffffffffffffffffff16145b15612d1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d1190614acf565b60405180910390fd5b612d2c82606001518360800151613236565b815f015161ffff16826040015161ffff1610158015612d5b5750816020015161ffff16826040015161ffff1611155b612d9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d9190614b5d565b60405180910390fd5b815f0151815f015f6101000a81548161ffff021916908361ffff1602179055508160200151815f0160026101000a81548161ffff021916908361ffff1602179055508160400151815f0160046101000a81548161ffff021916908361ffff1602179055505f826080015173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e4c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e709190614ba5565b905060128160ff161115612eb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612eb090614c1a565b60405180910390fd5b80825f0160066101000a81548160ff021916908360ff1602179055508260600151825f0160076101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550612f2d8360a001518460c00151613364565b612f3a836080015161337a565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612faf575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401612fa69190613da0565b60405180910390fd5b612fba5f838361277b565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361302e575f6040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016130259190613da0565b60405180910390fd5b613039825f8361277b565b5050565b606061304b84845f8561338e565b90509392505050565b5f819050919050565b5f8173ffffffffffffffffffffffffffffffffffffffff163b036130b857806040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526004016130af9190613da0565b60405180910390fd5b806130e47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5f1b613054565b5f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606061314b83836040518060600160405280602781526020016150af60279139613457565b905092915050565b5f34111561318d576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b613212846323b872dd60e01b8585856040516024016131b093929190614c38565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506129aa565b50505050565b5f613221612212565b5f0160089054906101000a900460ff16905090565b5f8273ffffffffffffffffffffffffffffffffffffffff1663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613280573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132a49190614750565b90505f8173ffffffffffffffffffffffffffffffffffffffff1663ace1798e846040518263ffffffff1660e01b81526004016132e09190613da0565b602060405180830381865afa1580156132fb573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061331f9190614435565b0361335f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161335690614cdd565b60405180910390fd5b505050565b61336c612c1a565b61337682826134d9565b5050565b613382612c1a565b61338b81613515565b50565b6060824710156133d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133ca90614d6b565b60405180910390fd5b5f808673ffffffffffffffffffffffffffffffffffffffff1685876040516133fb9190614dcd565b5f6040518083038185875af1925050503d805f8114613435576040519150601f19603f3d011682016040523d82523d5f602084013e61343a565b606091505b509150915061344b878383876135a7565b92505050949350505050565b60605f808573ffffffffffffffffffffffffffffffffffffffff16856040516134809190614dcd565b5f60405180830381855af49150503d805f81146134b8576040519150601f19603f3d011682016040523d82523d5f602084013e6134bd565b606091505b50915091506134ce868383876135a7565b925050509392505050565b6134e1612c1a565b5f6134ea611867565b9050828160030190816134fd9190614f77565b508181600401908161350f9190614f77565b50505050565b61351d612c1a565b5f613526611c0b565b90505f806135338461361b565b9150915081613543576012613545565b805b835f0160146101000a81548160ff021916908360ff16021790555083835f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b60608315613608575f835103613600576135c085613724565b6135ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135f690615090565b60405180910390fd5b5b829050613613565b6136128383613746565b5b949350505050565b5f805f808473ffffffffffffffffffffffffffffffffffffffff1660405160240160405160208183030381529060405263313ce56760e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161368e9190614dcd565b5f60405180830381855afa9150503d805f81146136c6576040519150601f19603f3d011682016040523d82523d5f602084013e6136cb565b606091505b50915091508180156136df57506020815110155b15613716575f818060200190518101906136f99190614435565b905060ff80168111613714576001819450945050505061371f565b505b5f809350935050505b915091565b5f808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b5f825111156137585781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161378c9190613836565b60405180910390fd5b5f819050919050565b6137a781613795565b82525050565b5f6020820190506137c05f83018461379e565b92915050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f613808826137c6565b61381281856137d0565b93506138228185602086016137e0565b61382b816137ee565b840191505092915050565b5f6020820190508181035f83015261384e81846137fe565b905092915050565b5f604051905090565b5f80fd5b5f80fd5b61387081613795565b811461387a575f80fd5b50565b5f8135905061388b81613867565b92915050565b5f602082840312156138a6576138a561385f565b5b5f6138b38482850161387d565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6138e5826138bc565b9050919050565b6138f5816138db565b81146138ff575f80fd5b50565b5f81359050613910816138ec565b92915050565b5f806040838503121561392c5761392b61385f565b5b5f61393985828601613902565b925050602061394a8582860161387d565b9150509250929050565b5f8115159050919050565b61396881613954565b82525050565b5f6020820190506139815f83018461395f565b92915050565b5f819050919050565b5f6139aa6139a56139a0846138bc565b613987565b6138bc565b9050919050565b5f6139bb82613990565b9050919050565b5f6139cc826139b1565b9050919050565b6139dc816139c2565b82525050565b5f6020820190506139f55f8301846139d3565b92915050565b5f61ffff82169050919050565b613a11816139fb565b82525050565b5f602082019050613a2a5f830184613a08565b92915050565b5f805f60608486031215613a4757613a4661385f565b5b5f613a5486828701613902565b9350506020613a6586828701613902565b9250506040613a768682870161387d565b9150509250925092565b5f60ff82169050919050565b613a9581613a80565b82525050565b5f602082019050613aae5f830184613a8c565b92915050565b613abd816139fb565b8114613ac7575f80fd5b50565b5f81359050613ad881613ab4565b92915050565b5f60208284031215613af357613af261385f565b5b5f613b0084828501613aca565b91505092915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b613b43826137ee565b810181811067ffffffffffffffff82111715613b6257613b61613b0d565b5b80604052505050565b5f613b74613856565b9050613b808282613b3a565b919050565b5f67ffffffffffffffff821115613b9f57613b9e613b0d565b5b602082029050602081019050919050565b5f80fd5b5f613bc6613bc184613b85565b613b6b565b90508083825260208201905060208402830185811115613be957613be8613bb0565b5b835b81811015613c125780613bfe8882613902565b845260208401935050602081019050613beb565b5050509392505050565b5f82601f830112613c3057613c2f613b09565b5b8135613c40848260208601613bb4565b91505092915050565b5f67ffffffffffffffff821115613c6357613c62613b0d565b5b602082029050602081019050919050565b5f613c86613c8184613c49565b613b6b565b90508083825260208201905060208402830185811115613ca957613ca8613bb0565b5b835b81811015613cd25780613cbe888261387d565b845260208401935050602081019050613cab565b5050509392505050565b5f82601f830112613cf057613cef613b09565b5b8135613d00848260208601613c74565b91505092915050565b5f805f60608486031215613d2057613d1f61385f565b5b5f84013567ffffffffffffffff811115613d3d57613d3c613863565b5b613d4986828701613c1c565b935050602084013567ffffffffffffffff811115613d6a57613d69613863565b5b613d7686828701613cdc565b9250506040613d8786828701613902565b9150509250925092565b613d9a816138db565b82525050565b5f602082019050613db35f830184613d91565b92915050565b5f60208284031215613dce57613dcd61385f565b5b5f613ddb84828501613902565b91505092915050565b5f80fd5b5f67ffffffffffffffff821115613e0257613e01613b0d565b5b613e0b826137ee565b9050602081019050919050565b828183375f83830152505050565b5f613e38613e3384613de8565b613b6b565b905082815260208101848484011115613e5457613e53613de4565b5b613e5f848285613e18565b509392505050565b5f82601f830112613e7b57613e7a613b09565b5b8135613e8b848260208601613e26565b91505092915050565b5f8060408385031215613eaa57613ea961385f565b5b5f613eb785828601613902565b925050602083013567ffffffffffffffff811115613ed857613ed7613863565b5b613ee485828601613e67565b9150509250929050565b5f819050919050565b613f0081613eee565b82525050565b5f602082019050613f195f830184613ef7565b92915050565b5f8060408385031215613f3557613f3461385f565b5b5f613f428582860161387d565b9250506020613f5385828601613902565b9150509250929050565b5f80fd5b5f60e08284031215613f7657613f75613f5d565b5b81905092915050565b5f60208284031215613f9457613f9361385f565b5b5f82013567ffffffffffffffff811115613fb157613fb0613863565b5b613fbd84828501613f61565b91505092915050565b5f613fd0826139b1565b9050919050565b613fe081613fc6565b82525050565b5f602082019050613ff95f830184613fd7565b92915050565b5f805f606084860312156140165761401561385f565b5b5f6140238682870161387d565b935050602061403486828701613902565b925050604061404586828701613902565b9150509250925092565b5f80604083850312156140655761406461385f565b5b5f61407285828601613902565b925050602061408385828601613902565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806140d157607f821691505b6020821081036140e4576140e361408d565b5b50919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f8160011c9050919050565b5f808291508390505b600185111561416c57808604811115614148576141476140ea565b5b60018516156141575780820291505b808102905061416585614117565b945061412c565b94509492505050565b5f82614184576001905061423f565b81614191575f905061423f565b81600181146141a757600281146141b1576141e0565b600191505061423f565b60ff8411156141c3576141c26140ea565b5b8360020a9150848211156141da576141d96140ea565b5b5061423f565b5060208310610133831016604e8410600b84101617156142155782820a9050838111156142105761420f6140ea565b5b61423f565b6142228484846001614123565b92509050818404811115614239576142386140ea565b5b81810290505b9392505050565b5f61425082613795565b915061425b83613a80565b92506142887fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484614175565b905092915050565b5f61429a82613795565b91506142a583613795565b92508282026142b381613795565b915082820484148315176142ca576142c96140ea565b5b5092915050565b5f6142db82613a80565b91506142e683613a80565b9250828201905060ff8111156142ff576142fe6140ea565b5b92915050565b7f436f6c6c5661756c743a20576974686472617720666565206f7574206f6620625f8201527f6f756e6473000000000000000000000000000000000000000000000000000000602082015250565b5f61435f6025836137d0565b915061436a82614305565b604082019050919050565b5f6020820190508181035f83015261438c81614353565b9050919050565b7f436f6c6c5661756c743a20746f6b656e7320616e6420616d6f756e7473206c655f8201527f6e677468206d69736d6174636800000000000000000000000000000000000000602082015250565b5f6143ed602d836137d0565b91506143f882614393565b604082019050919050565b5f6020820190508181035f83015261441a816143e1565b9050919050565b5f8151905061442f81613867565b92915050565b5f6020828403121561444a5761444961385f565b5b5f61445784828501614421565b91505092915050565b5f61446a82613795565b915061447583613795565b925082820390508181111561448d5761448c6140ea565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f80fd5b5f80fd5b5f6144d2826138db565b9050919050565b6144e2816144c8565b81146144ec575f80fd5b50565b5f813590506144fd816144d9565b92915050565b5f61450d826138db565b9050919050565b61451d81614503565b8114614527575f80fd5b50565b5f8135905061453881614514565b92915050565b5f67ffffffffffffffff82111561455857614557613b0d565b5b614561826137ee565b9050602081019050919050565b5f61458061457b8461453e565b613b6b565b90508281526020810184848401111561459c5761459b613de4565b5b6145a7848285613e18565b509392505050565b5f82601f8301126145c3576145c2613b09565b5b81356145d384826020860161456e565b91505092915050565b5f60e082840312156145f1576145f06144c0565b5b6145fb60e0613b6b565b90505f61460a84828501613aca565b5f83015250602061461d84828501613aca565b602083015250604061463184828501613aca565b6040830152506060614645848285016144ef565b60608301525060806146598482850161452a565b60808301525060a082013567ffffffffffffffff81111561467d5761467c6144c4565b5b614689848285016145af565b60a08301525060c082013567ffffffffffffffff8111156146ad576146ac6144c4565b5b6146b9848285016145af565b60c08301525092915050565b5f6146d036836145dc565b9050919050565b5f819050919050565b5f67ffffffffffffffff82169050919050565b5f61470d614708614703846146d7565b613987565b6146e0565b9050919050565b61471d816146f3565b82525050565b5f6020820190506147365f830184614714565b92915050565b5f8151905061474a816138ec565b92915050565b5f602082840312156147655761476461385f565b5b5f6147728482850161473c565b91505092915050565b5f60608201905061478e5f830186613d91565b61479b602083018561379e565b6147a8604083018461379e565b949350505050565b5f6147ba82613795565b91506147c583613795565b92508282019050808211156147dd576147dc6140ea565b5b92915050565b5f6147ed82613a80565b91506147f883613a80565b9250828203905060ff811115614811576148106140ea565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7f436f6c6c5661756c743a2063616c6c6572206973206e6f7420746865206f776e5f8201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b5f61489e6022836137d0565b91506148a982614844565b604082019050919050565b5f6020820190508181035f8301526148cb81614892565b9050919050565b5f6040820190506148e55f830185613d91565b6148f2602083018461379e565b9392505050565b61490281613eee565b811461490c575f80fd5b50565b5f8151905061491d816148f9565b92915050565b5f602082840312156149385761493761385f565b5b5f6149458482850161490f565b91505092915050565b5f6040820190506149615f83018561379e565b61496e602083018461379e565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6149ab81613954565b81146149b5575f80fd5b50565b5f815190506149c6816149a2565b92915050565b5f602082840312156149e1576149e061385f565b5b5f6149ee848285016149b8565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e5f8201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b5f614a51602a836137d0565b9150614a5c826149f7565b604082019050919050565b5f6020820190508181035f830152614a7e81614a45565b9050919050565b7f436f6c6c5661756c743a203020616464726573730000000000000000000000005f82015250565b5f614ab96014836137d0565b9150614ac482614a85565b602082019050919050565b5f6020820190508181035f830152614ae681614aad565b9050919050565b7f436f6c6c5661756c743a20776974686472617720666565206f7574206f6620625f8201527f6f756e6473000000000000000000000000000000000000000000000000000000602082015250565b5f614b476025836137d0565b9150614b5282614aed565b604082019050919050565b5f6020820190508181035f830152614b7481614b3b565b9050919050565b614b8481613a80565b8114614b8e575f80fd5b50565b5f81519050614b9f81614b7b565b92915050565b5f60208284031215614bba57614bb961385f565b5b5f614bc784828501614b91565b91505092915050565b7f436f6c6c5661756c743a20617373657420646563696d616c73203e20313800005f82015250565b5f614c04601e836137d0565b9150614c0f82614bd0565b602082019050919050565b5f6020820190508181035f830152614c3181614bf8565b9050919050565b5f606082019050614c4b5f830186613d91565b614c586020830185613d91565b614c65604083018461379e565b949350505050565b7f436f6c6c5661756c743a2061737365742070726963652066656564206e6f74205f8201527f7365742075700000000000000000000000000000000000000000000000000000602082015250565b5f614cc76026836137d0565b9150614cd282614c6d565b604082019050919050565b5f6020820190508181035f830152614cf481614cbb565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f5f8201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b5f614d556026836137d0565b9150614d6082614cfb565b604082019050919050565b5f6020820190508181035f830152614d8281614d49565b9050919050565b5f81519050919050565b5f81905092915050565b5f614da782614d89565b614db18185614d93565b9350614dc18185602086016137e0565b80840191505092915050565b5f614dd88284614d9d565b915081905092915050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302614e3f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82614e04565b614e498683614e04565b95508019841693508086168417925050509392505050565b5f614e7b614e76614e7184613795565b613987565b613795565b9050919050565b5f819050919050565b614e9483614e61565b614ea8614ea082614e82565b848454614e10565b825550505050565b5f90565b614ebc614eb0565b614ec7818484614e8b565b505050565b5b81811015614eea57614edf5f82614eb4565b600181019050614ecd565b5050565b601f821115614f2f57614f0081614de3565b614f0984614df5565b81016020851015614f18578190505b614f2c614f2485614df5565b830182614ecc565b50505b505050565b5f82821c905092915050565b5f614f4f5f1984600802614f34565b1980831691505092915050565b5f614f678383614f40565b9150826002028217905092915050565b614f80826137c6565b67ffffffffffffffff811115614f9957614f98613b0d565b5b614fa382546140ba565b614fae828285614eee565b5f60209050601f831160018114614fdf575f8415614fcd578287015190505b614fd78582614f5c565b86555061503e565b601f198416614fed86614de3565b5f5b8281101561501457848901518255600182019150602085019450602081019050614fef565b86831015615031578489015161502d601f891682614f40565b8355505b6001600288020188555050505b505050505050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000005f82015250565b5f61507a601d836137d0565b915061508582615046565b602082019050919050565b5f6020820190508181035f8301526150a78161506e565b905091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a377d42104d7e0109b54c6571b881444073f2597b3ed3d7f1d733458e242941f64736f6c634300081a0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.