Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
EverlongManagedLeveragedVaultGettersV1
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 {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IAsset} from "src/interfaces/utils/tokens/IAsset.sol";
import {IBaseManagedLeveragedVault} from "src/interfaces/core/mlv/base/IBaseManagedLeveragedVault.sol";
import {PropManagedLeveragedVaultGetters, ManagedLeveragedVaultStorageLib} from "src/core/mlv/helpers/protocol/v1/prop/PropManagedLeveragedVaultGetters.sol";
/// @dev Handles the asset of the MLV not being the same as the asset of the collateral
contract EverlongManagedLeveragedVaultGettersV1 is PropManagedLeveragedVaultGetters {
using SafeCast for int256;
constructor(IBaseManagedLeveragedVault _vault) PropManagedLeveragedVaultGetters(_vault) {}
function computeNetColl(
uint256 debtTokenSurplusInAssets,
uint256 collToReceive,
uint256 prevTotalAssets
) external view override returns (uint256 netColl) {
uint256 currTotalAssets = vault.totalAssets();
uint256 totalAssetsDelta = prevTotalAssets - currTotalAssets - debtTokenSurplusInAssets;
uint256 totalAssetsDeltaInCollVaultAsset = _assetToCollVaultAsset(totalAssetsDelta);
int256 operationProfit = int256(collToReceive) - int256(IERC4626(collateral()).convertToShares(totalAssetsDeltaInCollVaultAsset));
netColl = (int256(collToReceive) + operationProfit).toUint256();
}
function _assetToCollVaultAsset(uint256 assets) internal view returns (uint256 collVaultAssetAmount) {
address collVaultAsset = IERC4626(collateral()).asset();
uint256 collVaultAssetPrice = getPrice(collVaultAsset);
uint256 assetPrice = getPrice(_asset());
uint256 collVaultAssetScaling = 10 ** uint256(IAsset(collVaultAsset).decimals());
uint256 assetDecimalsScaling = 10 ** uint256(IAsset(_asset()).decimals());
// An overflow would require a very high decimal coll vault asset, or really high price
collVaultAssetAmount = assets * assetPrice * collVaultAssetScaling / (collVaultAssetPrice * assetDecimalsScaling);
}
function _asset() internal view returns (address) {
bytes32[] memory slots = new bytes32[](1);
slots[0] = ManagedLeveragedVaultStorageLib.assetSlot();
bytes32[] memory r = vault.extSloads(slots);
return address(uint160(uint256(r[0])));
}
}// 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 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
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 {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IBaseManagedLeveragedVault {
// --- Enums ------------------------------------------------
enum Tolerance { ABOVE, BOTH }
enum Operation { LEVERAGE, DELEVERAGE}
struct BaseInitParams {
IERC20 asset;
string name;
string symbol;
address everlongCore;
address debtToken;
address collateral;
uint16 maxDeviationICRinBP;
uint16 maxDeviationTotalAssetsInBP;
uint16 maxSlippageSwapInBP;
address keeper;
address targetICRHook;
address feeHook;
address getters;
}
// --- Errors ------------------------------------------------
error ZeroAmount();
error ZeroAddress();
error SurpassedPrecision(uint256 precision);
error AlreadyOpened();
error NotOwner(address caller);
error NotSupportedMethod();
error VaultSlippage(uint256 expected, uint256 actual);
// --- Events -----------------------------------------------
event NewTargetICRHook(address targetICRHook);
event NewKeeper(address keeper);
event NewMaxDeviationICRInBP(uint16 maxDeviationICRInBP);
event NewMaxDeviationTotalAssetsInBP(uint16 maxDeviationTotalAssetsInBP);
event NewMaxSlippageSwapInBP(uint16 maxSlippageSwapInBP);
event NewFeeHook(address feeHook);
event NewGetters(address getters);
// --- Functions ---------------------------------------------
function totalAssets() external view returns (uint256);
function setMaxDeviationICRinBP(uint16 _maxDeviationICRinBP) external;
function setMaxDeviationTotalAssetsInBP(uint16 _maxDeviationTotalAssetsInBP) external;
function setMaxSlippageSwapInBP(uint16 _maxSlippageSwapInBP) external;
function setKeeper(address _keeper) external;
function setTargetICRHook(address _targetICRHook) external;
function setFeeHook(address _feeHook) external;
function setGetters(address _getters) external;
function getPrice(address token) external view returns (uint256 scaledPriceInUsdWad);
function extSloads(bytes32[] memory slots) external view returns (bytes32[] memory values);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {BaseManagedLeveragedVaultGetters, IBaseManagedLeveragedVaultGetters} from "src/core/mlv/helpers/base/BaseManagedLeveragedVaultGetters.sol";
import {ManagedLeveragedVaultGettersV1, IBaseManagedLeveragedVault, ManagedLeveragedVaultStorageLib} from "src/core/mlv/helpers/base/v1/ManagedLeveragedVaultGettersV1.sol";
import {IPropManagedLeveragedVaultGetters} from "src/interfaces/core/mlv/helpers/protocol/v1/prop/IPropManagedLeveragedVaultGetters.sol";
import {PropGettersLib} from "src/core/mlv/helpers/base/lib/PropGettersLib.sol";
import {IPositionManager} from "src/interfaces/utils/IPositionManager.sol";
import {IBorrowerOperations} from "src/interfaces/utils/IBorrowerOperations.sol";
import {IEverlongCore} from "src/interfaces/core/IEverlongCore.sol";
import {ITargetICRHook} from "src/interfaces/utils/ITargetICRHook.sol";
import {IFeeHook} from "src/interfaces/utils/IFeeHook.sol";
contract PropManagedLeveragedVaultGetters is ManagedLeveragedVaultGettersV1, IPropManagedLeveragedVaultGetters {
using PropGettersLib for PropGettersLib.Context;
uint256 internal constant _BORROWER_OPERATIONS_SLOT = 7;
uint256 internal constant _POSITION_MANAGER_SLOT = 8;
uint256 internal constant _LEVERAGE_ROUTER_SLOT = 9;
uint256 internal constant _DELEVERAGE_ROUTER_SLOT = 10;
function borrowerOperationsSlot() internal pure returns (bytes32) {
return bytes32(uint256(ManagedLeveragedVaultStorageLib.MLV_VAULT_LOC) + _BORROWER_OPERATIONS_SLOT);
}
function positionManagerSlot() internal pure returns (bytes32) {
return bytes32(uint256(ManagedLeveragedVaultStorageLib.MLV_VAULT_LOC) + _POSITION_MANAGER_SLOT);
}
function leverageRouterSlot() internal pure returns (bytes32) {
return bytes32(uint256(ManagedLeveragedVaultStorageLib.MLV_VAULT_LOC) + _LEVERAGE_ROUTER_SLOT);
}
function deleverageRouterSlot() internal pure returns (bytes32) {
return bytes32(uint256(ManagedLeveragedVaultStorageLib.MLV_VAULT_LOC) + _DELEVERAGE_ROUTER_SLOT);
}
constructor(IBaseManagedLeveragedVault _vault) ManagedLeveragedVaultGettersV1(_vault) {}
function borrowerOperations() public view returns (address) {
bytes32[] memory slot = _array(borrowerOperationsSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function positionManager() public view returns (address) {
bytes32[] memory slot = _array(positionManagerSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function leverageRouter() public view returns (address) {
bytes32[] memory slot = _array(leverageRouterSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function deleverageRouter() public view returns (address) {
bytes32[] memory slot = _array(deleverageRouterSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function getCollateralBalance() public view override returns (uint256) {
return _getPropGettersContext().getCollateralBalance();
}
function getDebtBalance() public view override returns (uint256) {
return _getPropGettersContext().getDebtBalance();
}
function checkMaxOperationCost(address inputToken, uint256 amountToSwap, uint256 prevTotalAssets) external view override {
_getPropGettersContext().checkMaxOperationCost(inputToken, amountToSwap, prevTotalAssets);
}
function getPrice(address token) public view override returns (uint256) {
return _getPropGettersContext().getPrice(token);
}
function getCurrentPositionICR() public view override returns (uint256) {
return _getPropGettersContext().getCurrentPositionICR();
}
function _getPropGettersContext()
private
view
returns (PropGettersLib.Context memory ctx)
{
// Use _array() as a base, then resize in assembly to avoid a second allocation.
// We only need 6 sloads because maxDeviationTotalAssetsInBP & maxSlippageSwapInBP share the same slot (#2).
bytes32[] memory slots = new bytes32[](8);
slots[0] = ManagedLeveragedVaultStorageLib.assetSlot();
slots[1] = ManagedLeveragedVaultStorageLib.everlongCoreSlot();
slots[2] = ManagedLeveragedVaultStorageLib.debtTokenSlot();
slots[3] = ManagedLeveragedVaultStorageLib.targetICRHookSlot();
slots[4] = ManagedLeveragedVaultStorageLib.feeHookSlot();
// packed: ICR bp, totalAssets bp, slippage bp, collateral
slots[5] = ManagedLeveragedVaultStorageLib.maxDeviationICRInBPSlot();
slots[6] = positionManagerSlot();
slots[7] = borrowerOperationsSlot();
bytes32[] memory r = vault.extSloads(slots);
address asset_ = address(uint160(uint256(r[0])));
address core_ = address(uint160(uint256(r[1])));
address debt_ = address(uint160(uint256(r[2])));
address target_= address(uint160(uint256(r[3])));
address fee_ = address(uint160(uint256(r[4])));
uint256 packed = uint256(r[5]);
address positionManager_ = address(uint160(uint256(r[6])));
address bo_ = address(uint160(uint256(r[7])));
uint16 maxDevTotalAssetsBp = uint16(packed >> ManagedLeveragedVaultStorageLib.MAX_DEVIATION_TOTAL_ASSETS_IN_BP_BITS);
uint16 maxSlippageSwapBp = uint16(packed >> ManagedLeveragedVaultStorageLib.MAX_SLIPPAGE_SWAP_IN_BP_BITS);
ctx = PropGettersLib.Context({
asset: asset_,
vault: address(vault),
everlongCore: IEverlongCore(core_),
positionManager: IPositionManager(positionManager_),
borrowerOperations: IBorrowerOperations(bo_),
debtToken: debt_,
targetICRHook: ITargetICRHook(target_),
feeHook: IFeeHook(fee_),
maxDeviationTotalAssetsInBP: maxDevTotalAssetsBp,
maxSlippageSwapInBP: maxSlippageSwapBp
});
}
}// 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 v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IDenManager} from "src/interfaces/periphery/beraborrow/IDenManager.sol";
import {IAsset} from "src/interfaces/utils/tokens/IAsset.sol";
import {PropMath} from "src/libraries/PropMath.sol";
import {FeeLib} from "src/libraries/FeeLib.sol";
import {PriceLib} from "src/libraries/PriceLib.sol";
import {IFeeHook} from "src/interfaces/utils/IFeeHook.sol";
import {ITargetICRHook} from "src/interfaces/utils/ITargetICRHook.sol";
import {IBaseManagedLeveragedVault} from "src/interfaces/core/mlv/base/IBaseManagedLeveragedVault.sol";
import {IBaseManagedLeveragedVaultGetters} from "src/interfaces/core/mlv/helpers/base/IBaseManagedLeveragedVaultGetters.sol";
import {IEverlongCore} from "src/interfaces/core/IEverlongCore.sol";
import {IPriceFeed} from "src/interfaces/core/oracles/IPriceFeed.sol";
import {IBorrowerOperations} from "src/interfaces/periphery/beraborrow/IBorrowerOperations.sol";
library ManagedLeveragedVaultStorageLib {
// storage-location constant
bytes32 private constant ERC4626_LOC = 0x0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00;
bytes32 internal constant MLV_VAULT_LOC = 0x12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c100;
// ERC4626 storage slots
uint256 internal constant _ASSET_SLOT = 0;
// MLV storage slots
uint256 internal constant _BEACON_OWNER_SLOT = 0;
uint256 internal constant _DEBT_TOKEN_SLOT = 1;
uint256 internal constant _COLLATERAL_SLOT = 2;
uint256 internal constant _MAX_DEVIATION_ICR_IN_BP_SLOT = 2;
uint256 internal constant _MAX_DEVIATION_TOTAL_ASSETS_IN_BP_SLOT = 2;
uint256 internal constant _MAX_SLIPPAGE_SWAP_IN_BP_SLOT = 2;
uint256 internal constant _KEEPER_SLOT = 3;
uint256 internal constant _TARGET_ICR_HOOK_SLOT = 4;
uint256 internal constant _FEE_HOOK_SLOT = 5;
uint256 internal constant _GETTERS_SLOT = 6;
// bit offsets within slot 2
uint256 internal constant MAX_DEVIATION_ICR_IN_BP_BITS = 160;
uint256 internal constant MAX_DEVIATION_TOTAL_ASSETS_IN_BP_BITS = 176;
uint256 internal constant MAX_SLIPPAGE_SWAP_IN_BP_BITS = 192;
// ERC4626 simple-slot getters
function assetSlot() internal pure returns (bytes32) {
return bytes32(uint256(ERC4626_LOC) + _ASSET_SLOT);
}
// MLV simple-slot getters
function everlongCoreSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _BEACON_OWNER_SLOT);
}
function debtTokenSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _DEBT_TOKEN_SLOT);
}
function collateralSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _COLLATERAL_SLOT);
}
function maxDeviationICRInBPSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _MAX_DEVIATION_ICR_IN_BP_SLOT);
}
function maxDeviationTotalAssetsInBPSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _MAX_DEVIATION_TOTAL_ASSETS_IN_BP_SLOT);
}
function maxSlippageSwapInBPSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _MAX_SLIPPAGE_SWAP_IN_BP_SLOT);
}
function keeperSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _KEEPER_SLOT);
}
function targetICRHookSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _TARGET_ICR_HOOK_SLOT);
}
function feeHookSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _FEE_HOOK_SLOT);
}
function gettersSlot() internal pure returns (bytes32) {
return bytes32(uint256(MLV_VAULT_LOC) + _GETTERS_SLOT);
}
}
abstract contract BaseManagedLeveragedVaultGetters is IBaseManagedLeveragedVaultGetters {
using Math for uint256;
using FeeLib for uint256;
using PriceLib for uint256;
using SafeCast for int256;
IBaseManagedLeveragedVault public immutable vault;
uint256 constant WAD = 1e18;
uint256 constant BP = 1e4;
constructor(IBaseManagedLeveragedVault _vault) {
vault = _vault;
}
// ─── ERC4626 getters ──────────────────────────────────────────────
function asset() public view returns (address) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.assetSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
// ─── ManagedLeveragedVault getters ──────────────────────────────
function everlongCore() public view returns (address) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.everlongCoreSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function debtToken() public view returns (address) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.debtTokenSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function collateral() public view returns (address) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.collateralSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function maxDeviationICRbp() public view returns (uint16) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.maxDeviationICRInBPSlot());
return uint16(uint256(vault.extSloads(slot)[0]) >> ManagedLeveragedVaultStorageLib.MAX_DEVIATION_ICR_IN_BP_BITS);
}
function maxDeviationTotalAssetsInBP() public view returns (uint16) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.maxDeviationTotalAssetsInBPSlot());
return uint16(uint256(vault.extSloads(slot)[0]) >> ManagedLeveragedVaultStorageLib.MAX_DEVIATION_TOTAL_ASSETS_IN_BP_BITS);
}
function maxSlippageSwapInBP() public view returns (uint16) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.maxSlippageSwapInBPSlot());
return uint16(uint256(vault.extSloads(slot)[0]) >> ManagedLeveragedVaultStorageLib.MAX_SLIPPAGE_SWAP_IN_BP_BITS);
}
function keeper() public view returns (address) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.keeperSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function feeHook() public view returns (address) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.feeHookSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function targetICRHook() public view returns (address) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.targetICRHookSlot());
return address(uint160(uint256(vault.extSloads(slot)[0])));
}
function getters() public view returns (IBaseManagedLeveragedVaultGetters) {
bytes32[] memory slot = _array(ManagedLeveragedVaultStorageLib.gettersSlot());
return IBaseManagedLeveragedVaultGetters(address(uint160(uint256(vault.extSloads(slot)[0]))));
}
// ─── internal helper ────────────────────────────────────────────
function _array(bytes32 x) internal pure returns (bytes32[] memory) {
bytes32[] memory res = new bytes32[](1);
res[0] = x;
return res;
}
function getCollateralBalance() public view virtual returns (uint256) {}
function getDebtBalance() public view virtual returns (uint256) {}
function checkMaxOperationCost(address inputToken, uint256 amountToSwap, uint256 prevTotalAssets) external view virtual {}
function getPrice(address token) public view virtual returns (uint256) {}
function getCurrentPositionICR() public view virtual returns (uint256) {}
function getCollateralValue() public view returns (uint256) {
uint256 amount = getCollateralBalance();
return getCollateralValue(amount);
}
function getCollateralValue(uint256 amount) public view returns (uint256) {
address _collateral = collateral();
uint256 price = getPrice(_collateral);
return amount.convertToValue(price, IAsset(_collateral).decimals());
}
function getDebtValue() public view returns (uint256) {
uint256 debtBalance = getDebtBalance();
return getDebtValue(debtBalance);
}
function getDebtValue(uint256 amount) public view returns (uint256) {
address _debtToken = debtToken();
uint256 price = getPrice(_debtToken);
return amount.convertToValue(price, IAsset(_debtToken).decimals());
}
function getTargetICR() public view returns (uint256) {
ITargetICRHook _targetICRHook = ITargetICRHook(targetICRHook());
return _targetICRHook.calcTargetICR();
}
function entryFeeInBP(uint256 amount, address caller) external view returns (uint256) {
IFeeHook _feeHook = IFeeHook(feeHook());
return _feeHook.calcFee(caller, asset(), amount, IFeeHook.Action.DEPOSIT);
}
function exitFeeInBP(uint256 amount, address caller) external view returns (uint256) {
IFeeHook _feeHook = IFeeHook(feeHook());
return _feeHook.calcFee(caller, asset(), amount, IFeeHook.Action.WITHDRAW);
}
function checkInvariantICR(uint256 currentICR, uint256 targetICR, IBaseManagedLeveragedVault.Tolerance tolerance) external view {
uint256 maxDelta = Math.min(currentICR, targetICR).mulDiv(maxDeviationICRbp(), BP);
if (IBaseManagedLeveragedVault.Tolerance.ABOVE == tolerance) {
if (!PropMath._isWithinToleranceAbove(currentICR, targetICR, maxDelta)) revert PositionOutOfTargetCR(currentICR, targetICR, maxDelta);
} else {
if (!PropMath._isApproxEqAbs(currentICR, targetICR, maxDelta)) revert PositionOutOfTargetCR(currentICR, targetICR, maxDelta);
}
}
function computeNetColl(
uint256 nectSurplusInAssets,
uint256 collToReceive,
uint256 prevTotalAssets
) external view virtual returns (uint256 netColl) {
uint256 currTotalAssets = vault.totalAssets();
uint256 totalAssetsDelta = prevTotalAssets - currTotalAssets - nectSurplusInAssets;
int256 operationProfit = int256(collToReceive) - int256(IERC4626(collateral()).convertToShares(totalAssetsDelta));
netColl = (int256(collToReceive) + operationProfit).toUint256();
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {IBaseManagedLeveragedVault} from "src/interfaces/core/mlv/base/IBaseManagedLeveragedVault.sol";
import {ManagedLeveragedVaultStorageLib, BaseManagedLeveragedVaultGetters} from "src/core/mlv/helpers/base/BaseManagedLeveragedVaultGetters.sol";
abstract contract ManagedLeveragedVaultGettersV1 is BaseManagedLeveragedVaultGetters {
constructor(IBaseManagedLeveragedVault _vault) BaseManagedLeveragedVaultGetters(_vault) {}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
interface IPropManagedLeveragedVaultGetters {
function borrowerOperations() external view returns (address);
function positionManager() external view returns (address);
function leverageRouter() external view returns (address);
function deleverageRouter() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {IPositionManager} from "src/interfaces/utils/IPositionManager.sol";
import {IBorrowerOperations} from "src/interfaces/utils/IBorrowerOperations.sol";
import {IEverlongCore} from "src/interfaces/core/IEverlongCore.sol";
import {IBaseManagedLeveragedVault} from "src/interfaces/core/mlv/base/IBaseManagedLeveragedVault.sol";
import {IAsset} from "src/interfaces/utils/tokens/IAsset.sol";
import {ITargetICRHook} from "src/interfaces/utils/ITargetICRHook.sol";
import {IFeeHook} from "src/interfaces/utils/IFeeHook.sol";
import {IPriceFeed} from "src/interfaces/core/oracles/IPriceFeed.sol";
import {PriceLib} from "src/libraries/PriceLib.sol";
library PropGettersLib {
using Math for uint256;
using PriceLib for uint256;
uint256 constant BP = 1e4;
error TotalAssetsDeviation(uint256 prevTotalAssets, uint256 newTotalAssets, uint256 maxDelta);
error VaultSlippage(uint256 expected, uint256 actual);
struct Context {
address asset;
address vault;
IEverlongCore everlongCore;
IPositionManager positionManager;
IBorrowerOperations borrowerOperations;
address debtToken;
ITargetICRHook targetICRHook;
IFeeHook feeHook;
uint16 maxDeviationTotalAssetsInBP;
uint16 maxSlippageSwapInBP;
}
function getCollateralBalance(Context memory $) internal view returns (uint256) {
IPositionManager _positionManager = IPositionManager($.positionManager);
(uint256 collVaultShares,) = _positionManager.getPositionCollAndDebt(address($.vault));
collVaultShares += _positionManager.surplusBalances(address($.vault));
return collVaultShares;
}
function getDebtBalance(Context memory $) internal view returns (uint256) {
(, uint256 debt) = IPositionManager($.positionManager).getPositionCollAndDebt(address($.vault));
return debt;
}
function getCurrentPositionICR(Context memory $) internal view returns (uint256) {
IPositionManager _positionManager = IPositionManager($.positionManager);
uint256 collPrice = _positionManager.fetchPrice();
return _positionManager.getCurrentICR(address($.vault), collPrice);
}
function getPrice(Context memory $, address token) internal view returns (uint256 scaledPriceInUsdWad) {
return IPriceFeed(IEverlongCore($.everlongCore).priceFeed()).fetchPrice(token);
}
function checkMaxOperationCost(Context memory $, address inputToken, uint256 amountToSwap, uint256 prevTotalAssets) internal view {
uint256 currTotalAssets = IBaseManagedLeveragedVault($.vault).totalAssets();
uint256 maxDelta = Math.min(prevTotalAssets, currTotalAssets).mulDiv($.maxDeviationTotalAssetsInBP, BP);
if (currTotalAssets < prevTotalAssets - maxDelta) revert TotalAssetsDeviation(prevTotalAssets, currTotalAssets, maxDelta);
int256 totalAssetsDelta = int256(prevTotalAssets) - int256(currTotalAssets);
uint256 assetPrice = getPrice($, $.asset);
uint256 debtFeeInAssets;
if (inputToken == $.debtToken) {
// Convert from NECT to assets
IBorrowerOperations borrowerOps = IBorrowerOperations($.borrowerOperations);
bool isRecoveryMode = borrowerOps.checkRecoveryMode(borrowerOps.getTCR());
uint256 debtFee = isRecoveryMode ? 0 : IPositionManager($.positionManager).getBorrowingFeeWithDecay(amountToSwap);
uint256 nectPrice = getPrice($, $.debtToken);
debtFeeInAssets = debtFee.mulDiv(nectPrice, assetPrice);
amountToSwap = amountToSwap.mulDiv(nectPrice, assetPrice);
} else {
uint256 exposurePrice = getPrice($, inputToken);
// Convert from exposure to assets
amountToSwap = amountToSwap.mulDiv(exposurePrice, assetPrice);
}
int256 totalAssetsDeltaFromSwap = totalAssetsDelta - int256(debtFeeInAssets);
// Early return if positive swap slippage
if (totalAssetsDeltaFromSwap <= 0) return;
uint256 swapDelta = uint256(totalAssetsDeltaFromSwap);
uint256 maxSwapDelta = amountToSwap.mulDiv($.maxSlippageSwapInBP, BP);
if (swapDelta > maxSwapDelta) revert VaultSlippage(swapDelta, maxSwapDelta);
}
}// 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 "src/interfaces/utils/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
pragma solidity 0.8.26;
import {ICore} from "./ICore.sol";
interface IBorrowerOperations {
struct Balances {
uint256[] collaterals;
uint256[] debts;
uint256[] prices;
}
event BorrowingFeePaid(address indexed borrower, uint256 amount);
event CollateralConfigured(address positionManager, address collateralToken);
event PositionCreated(address indexed _borrower, uint256 arrayIndex);
event PositionManagerRemoved(address positionManager);
event PositionUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, uint8 operation);
function addColl(
address positionManager,
address account,
uint256 _collateralAmount,
address _upperHint,
address _lowerHint
) external;
function adjustPosition(
address positionManager,
address account,
uint256 _maxFeePercentage,
uint256 _collDeposit,
uint256 _collWithdrawal,
uint256 _debtChange,
bool _isDebtIncrease,
address _upperHint,
address _lowerHint
) external;
function closePosition(address positionManager, address account) external;
function configureCollateral(address positionManager, address collateralToken) external;
function fetchBalances() external view returns (Balances memory balances);
function getGlobalSystemBalances() external view returns (uint256 totalPricedCollateral, uint256 totalDebt);
function getTCR() external view returns (uint256 globalTotalCollateralRatio);
function openPosition(
address positionManager,
address account,
uint256 _maxFeePercentage,
uint256 _collateralAmount,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external;
function removePositionManager(address positionManager) external;
function repayDebt(
address positionManager,
address account,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external;
function setDelegateApproval(address _delegate, bool _isApproved) external;
function setMinNetDebt(uint256 _minNetDebt) external;
function withdrawColl(
address positionManager,
address account,
uint256 _collWithdrawal,
address _upperHint,
address _lowerHint
) external;
function withdrawDebt(
address positionManager,
address account,
uint256 _maxFeePercentage,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external;
function positionManagers(uint256) external view returns (address);
function checkRecoveryMode(uint256 TCR) external view returns (bool);
function DEBT_GAS_COMPENSATION() external view returns (uint256);
function DECIMAL_PRECISION() external view returns (uint256);
function PERCENT_DIVISOR() external view returns (uint256);
function CORE() external view returns (ICore);
function debtToken() external view returns (address);
function factory() external view returns (address);
function getCompositeDebt(uint256 _debt) external view returns (uint256);
function guardian() external view returns (address);
function isApprovedDelegate(address owner, address caller) external view returns (bool isApproved);
function minNetDebt() external view returns (uint256);
function owner() external view returns (address);
function positionManagersData(address) external view returns (address collateralToken, uint16 index);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/**
* @title EverlongCore
* @author Everlong Labs
* @notice Single source of truth across all Everlong contracts for key administrative data
*/
interface IEverlongCore {
function owner() external view returns (address);
function feeReceiver() external view returns (address);
function priceFeed() external view returns (address);
function setFeeReceiver(address _feeReceiver) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
interface ITargetICRHook {
function calcTargetICR()
external
view
returns (uint256 targetICR);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
interface IFeeHook {
enum Action {
DEPOSIT,
MINT,
WITHDRAW,
REDEEM
}
function calcFee(address caller, address token, uint amount, Action action) external view returns (uint feeInBP);
}// 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
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 "src/interfaces/utils/IFactory.sol";
interface IDenManager {
event BaseRateUpdated(uint256 _baseRate);
event CollateralSent(address _to, uint256 _amount);
event LTermsUpdated(uint256 _L_collateral, uint256 _L_debt);
event LastFeeOpTimeUpdated(uint256 _lastFeeOpTime);
event Redemption(
address indexed _redeemer,
uint256 _attemptedDebtAmount,
uint256 _actualDebtAmount,
uint256 _collateralSent,
uint256 _collateralFee
);
event SystemSnapshotsUpdated(uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot);
event TotalStakesUpdated(uint256 _newTotalStakes);
event DenIndexUpdated(address _borrower, uint256 _newIndex);
event DenSnapshotsUpdated(uint256 _L_collateral, uint256 _L_debt);
event DenUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, uint8 _operation);
function addCollateralSurplus(address borrower, uint256 collSurplus) external;
function applyPendingRewards(address _borrower) external returns (uint256 coll, uint256 debt);
function claimCollateral(address borrower, address _receiver) external;
function closeDen(address _borrower, address _receiver, uint256 collAmount, uint256 debtAmount) external;
function closeDenByLiquidation(address _borrower) external;
function setCollVaultRouter(address _collVaultRouter) external;
function collectInterests() external;
function decayBaseRateAndGetBorrowingFee(uint256 _debt) external returns (uint256);
function decreaseDebtAndSendCollateral(address account, uint256 debt, uint256 coll) external;
function fetchPrice() external view returns (uint256);
function finalizeLiquidation(
address _liquidator,
uint256 _debt,
uint256 _coll,
uint256 _collSurplus,
uint256 _debtGasComp,
uint256 _collGasComp
) external;
function getEntireSystemBalances() external view returns (uint256, uint256, uint256);
function movePendingDenRewardsToActiveBalances(uint256 _debt, uint256 _collateral) external;
function openDen(
address _borrower,
uint256 _collateralAmount,
uint256 _compositeDebt,
uint256 NICR,
address _upperHint,
address _lowerHint
) external returns (uint256 stake, uint256 arrayIndex);
function redeemCollateral(
uint256 _debtAmount,
address _firstRedemptionHint,
address _upperPartialRedemptionHint,
address _lowerPartialRedemptionHint,
uint256 _partialRedemptionHintNICR,
uint256 _maxIterations,
uint256 _maxFeePercentage
) external;
function setAddresses(address _priceFeedAddress, address _sortedDensAddress, address _collateralToken) external;
function setParameters(
IFactory.DeploymentParams calldata _params
) external;
function setPaused(bool _paused) external;
function setPriceFeed(address _priceFeedAddress) external;
function startSunset() external;
function updateBalances() external;
function updateDenFromAdjustment(
bool _isDebtIncrease,
uint256 _debtChange,
uint256 _netDebtChange,
bool _isCollIncrease,
uint256 _collChange,
address _upperHint,
address _lowerHint,
address _borrower,
address _receiver
) external returns (uint256, uint256, uint256);
function DEBT_GAS_COMPENSATION() external view returns (uint256);
function DECIMAL_PRECISION() external view returns (uint256);
function L_collateral() external view returns (uint256);
function L_debt() external view returns (uint256);
function MCR() external view returns (uint256);
function PERCENT_DIVISOR() external view returns (uint256);
function BERABORROW_CORE() external view returns (address);
function SUNSETTING_INTEREST_RATE() external view returns (uint256);
function Dens(
address
)
external
view
returns (
uint256 debt,
uint256 coll,
uint256 stake,
uint8 status,
uint128 arrayIndex,
uint256 activeInterestIndex
);
function activeInterestIndex() external view returns (uint256);
function baseRate() external view returns (uint256);
function borrowerOperations() external view returns (address);
function borrowingFeeFloor() external view returns (uint256);
function collateralToken() external view returns (address);
function debtToken() external view returns (address);
function 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 getDenCollAndDebt(address _borrower) external view returns (uint256 coll, uint256 debt);
function getDenFromDenOwnersArray(uint256 _index) external view returns (address);
function getDenOwnersCount() external view returns (uint256);
function getDenStake(address _borrower) external view returns (uint256);
function getDenStatus(address _borrower) external view returns (uint256);
function guardian() external view returns (address);
function hasPendingRewards(address _borrower) external view returns (bool);
function interestPayable() external view returns (uint256);
function interestRate() external view returns (uint256);
function lastActiveIndexUpdate() external view returns (uint256);
function lastCollateralError_Redistribution() external view returns (uint256);
function lastDebtError_Redistribution() external view returns (uint256);
function lastFeeOperationTime() external view returns (uint256);
function liquidationManager() external view returns (address);
function maxBorrowingFee() external view returns (uint256);
function maxRedemptionFee() external view returns (uint256);
function maxSystemDebt() external view returns (uint256);
function minuteDecayFactor() external view returns (uint256);
function owner() external view returns (address);
function paused() external view returns (bool);
function priceFeed() external view returns (address);
function redemptionFeeFloor() external view returns (uint256);
function rewardSnapshots(address) external view returns (uint256 collateral, uint256 debt);
function sortedDens() external view returns (address);
function sunsetting() external view returns (bool);
function surplusBalances(address) external view returns (uint256);
function systemDeploymentTime() external view returns (uint256);
function totalCollateralSnapshot() external view returns (uint256);
function totalStakes() external view returns (uint256);
function totalStakesSnapshot() external view returns (uint256);
function brimeDen() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
library PropMath {
uint256 internal constant DECIMAL_PRECISION = 1e18;
/* Precision for Nominal ICR (independent of price). Rationale for the value:
*
* - Making it “too high” could lead to overflows.
* - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division.
*
* This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39,
* and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.
*
*/
uint256 internal constant NICR_PRECISION = 1e20;
function _getAbsoluteDifference(uint256 _a, uint256 _b) internal pure returns (uint256) {
return (_a >= _b) ? _a - _b : _b - _a;
}
function _computeNominalCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {
if (_debt > 0) {
return (_coll * NICR_PRECISION) / _debt;
}
// Return the maximal value for uint256 if the Position has a debt of 0. Represents "infinite" CR.
else {
// if (_debt == 0)
return 2 ** 256 - 1;
}
}
function _computeCR(uint256 _coll, uint256 _debt, uint256 _price) internal pure returns (uint256) {
if (_debt > 0) {
uint256 newCollRatio = (_coll * _price) / _debt;
return newCollRatio;
}
// Return the maximal value for uint256 if the Position has a debt of 0. Represents "infinite" CR.
else {
// if (_debt == 0)
return 2 ** 256 - 1;
}
}
function _computeCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {
if (_debt > 0) {
uint256 newCollRatio = (_coll) / _debt;
return newCollRatio;
}
// Return the maximal value for uint256 if the Position has a debt of 0. Represents "infinite" CR.
else {
// if (_debt == 0)
return 2 ** 256 - 1;
}
}
function _isApproxEqAbs(uint256 a, uint256 b, uint256 tolerance) internal pure returns (bool) {
return a > b ? (a - b) <= tolerance : (b - a) <= tolerance;
}
function _isWithinToleranceAbove(
uint256 a,
uint256 b,
uint256 tolerance
) internal pure returns (bool) {
if (a < b) return false;
return (a - b) <= tolerance;
}
function _isWithinToleranceBelow(
uint256 a,
uint256 b,
uint256 tolerance
) internal pure returns (bool) {
if (a > b) return false;
return (b - a) <= tolerance;
}
}// 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 {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
library PriceLib {
using Math for uint;
// WAD adjusted result
function convertToValue(uint amount, uint price, uint8 decimals) internal pure returns (uint) {
return amount * price / 10 ** decimals;
}
function convertToAmount(uint amountInUsd, uint collPrice, uint8 collDecimals, Math.Rounding rounding) internal pure returns (uint) {
if (collPrice == 0 || amountInUsd == 0) {
return 0;
}
return amountInUsd.mulDiv(10 ** collDecimals, collPrice, rounding);
}
// Coll decimal adjust amount result
function convertAssetsToCollAmount(uint assets, uint collPrice, uint debtTokenPrice, uint8 vaultDecimals, uint8 collDecimals, Math.Rounding rounding) internal pure returns (uint) {
uint assetsUsdValue = assets.mulDiv(debtTokenPrice, 10 ** vaultDecimals, rounding);
if (collPrice != 0) {
return convertToAmount(assetsUsdValue, collPrice, collDecimals, rounding);
} else {
return 0;
}
}
function convertCollAmountToAssets(uint collAmount, uint collPrice, uint debtTokenPrice, uint8 vaultDecimals, uint8 collDecimals) internal pure returns (uint) {
uint collUsdValue = collAmount * collPrice / 10 ** collDecimals;
if (debtTokenPrice != 0) {
return collUsdValue * 10 ** vaultDecimals / debtTokenPrice;
} else {
return 0;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {IBaseManagedLeveragedVault} from "src/interfaces/core/mlv/base/IBaseManagedLeveragedVault.sol";
interface IBaseManagedLeveragedVaultGetters {
error PositionOutOfTargetCR(uint256 currentICR, uint256 targetICR, uint256 maxDelta);
error TotalAssetsDeviation(uint256 prevTotalAssets, uint256 newTotalAssets, uint256 maxDelta);
error VaultSlippage(uint256 expected, uint256 actual);
function getPrice(address token) external view returns (uint256);
function vault() external view returns (IBaseManagedLeveragedVault);
function getCollateralBalance() external view returns (uint256);
function getCollateralValue() external view returns (uint256);
function getCollateralValue(uint256 amount) external view returns (uint256);
function getDebtBalance() external view returns (uint256);
function getDebtValue() external view returns (uint256);
function getDebtValue(uint256 amount) external view returns (uint256);
function getCurrentPositionICR() external view returns (uint256);
function getTargetICR() external view returns (uint256);
function entryFeeInBP(uint256 amount, address caller) external view returns (uint256);
function exitFeeInBP(uint256 amount, address caller) external view returns (uint256);
function checkInvariantICR(uint256 currentICR, uint256 targetICR, IBaseManagedLeveragedVault.Tolerance tolerance) external view;
function checkMaxOperationCost(address inputToken, uint256 amountToSwap, uint256 prevTotalAssets) external view;
function computeNetColl(uint256 nectSurplusInAssets, uint256 collToReceive, uint256 prevTotalAssets) external view returns (uint256 netColl);
}// 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 {ICore} from "src/interfaces/utils/ICore.sol";
interface IBorrowerOperations {
struct Balances {
uint256[] collaterals;
uint256[] debts;
uint256[] prices;
}
event BorrowingFeePaid(address indexed borrower, uint256 amount);
event CollateralConfigured(address denManager, address collateralToken);
event DenCreated(address indexed _borrower, uint256 arrayIndex);
event DenManagerRemoved(address denManager);
event DenUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, uint8 operation);
function addColl(
address denManager,
address account,
uint256 _collateralAmount,
address _upperHint,
address _lowerHint
) external;
function adjustDen(
address denManager,
address account,
uint256 _maxFeePercentage,
uint256 _collDeposit,
uint256 _collWithdrawal,
uint256 _debtChange,
bool _isDebtIncrease,
address _upperHint,
address _lowerHint
) external;
function brimeDen() external view returns (address);
function closeDen(address denManager, address account) external;
function configureCollateral(address denManager, address collateralToken) external;
function fetchBalances() external view returns (Balances memory balances);
function getGlobalSystemBalances() external view returns (uint256 totalPricedCollateral, uint256 totalDebt);
function getTCR() external view returns (uint256 globalTotalCollateralRatio);
function openDen(
address denManager,
address account,
uint256 _maxFeePercentage,
uint256 _collateralAmount,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external;
function removeDenManager(address denManager) external;
function repayDebt(
address denManager,
address account,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external;
function setDelegateApproval(address _delegate, bool _isApproved) external;
function setMinNetDebt(uint256 _minNetDebt) external;
function withdrawColl(
address denManager,
address account,
uint256 _collWithdrawal,
address _upperHint,
address _lowerHint
) external;
function withdrawDebt(
address denManager,
address account,
uint256 _maxFeePercentage,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external;
function denManagers(uint256) external view returns (address);
function checkRecoveryMode(uint256 TCR) external view returns (bool);
function DEBT_GAS_COMPENSATION() external view returns (uint256);
function DECIMAL_PRECISION() external view returns (uint256);
function PERCENT_DIVISOR() external view returns (uint256);
function BERABORROW_CORE() external view returns (ICore);
function debtToken() external view returns (address);
function factory() external view returns (address);
function getCompositeDebt(uint256 _debt) external view returns (uint256);
function guardian() external view returns (address);
function isApprovedDelegate(address owner, address caller) external view returns (bool isApproved);
function minNetDebt() external view returns (uint256);
function owner() external view returns (address);
function denManagersData(address) external view returns (address collateralToken, uint16 index);
function brimeMCR() external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC3156 FlashBorrower, as defined in
* https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
*
* _Available since v4.1._
*/
interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
interface IFactory {
// commented values are suggested default parameters
struct DeploymentParams {
uint256 minuteDecayFactor; // 999037758833783000 (half life of 12 hours)
uint256 redemptionFeeFloor; // 1e18 / 1000 * 5 (0.5%)
uint256 maxRedemptionFee; // 1e18 (100%)
uint256 borrowingFeeFloor; // 1e18 / 1000 * 5 (0.5%)
uint256 maxBorrowingFee; // 1e18 / 100 * 5 (5%)
uint256 interestRateInBps; // 100 (1%)
uint256 maxDebt;
uint256 MCR; // 12 * 1e17 (120%)
address collVaultRouter; // set to address(0) if DenManager coll is not CollateralVault
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
interface ICore {
// --- Public variables ---
function metaCore() external view returns (address);
function startTime() external view returns (uint256);
function CCR() external view returns (uint256);
function dmBootstrapPeriod() external view returns (uint64);
function isPeriphery(address peripheryContract) external view returns (bool);
// --- External functions ---
function setPeripheryEnabled(address _periphery, bool _enabled) external;
function setPMBootstrapPeriod(address dm, uint64 _bootstrapPeriod) external;
function setNewCCR(uint256 _CCR) external;
function priceFeed() external view returns (address);
function owner() external view returns (address);
function pendingOwner() external view returns (address);
function guardian() external view returns (address);
function feeReceiver() external view returns (address);
function paused() external view returns (bool);
function lspBootstrapPeriod() external view returns (uint64);
function getLspEntryFee(address rebalancer) external view returns (uint16);
function getLspExitFee(address rebalancer) external view returns (uint16);
function interestProtocolShare() external view returns (uint16);
function defaultInterestReceiver() external view returns (address);
// --- Events ---
event CCRSet(uint256 initialCCR);
event PMBootstrapPeriodSet(address dm, uint64 bootstrapPeriod);
event PeripheryEnabled(address indexed periphery, bool enabled);
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin-upgradeable/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/",
"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/",
"ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"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":"contract IBaseManagedLeveragedVault","name":"_vault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"currentICR","type":"uint256"},{"internalType":"uint256","name":"targetICR","type":"uint256"},{"internalType":"uint256","name":"maxDelta","type":"uint256"}],"name":"PositionOutOfTargetCR","type":"error"},{"inputs":[{"internalType":"uint256","name":"prevTotalAssets","type":"uint256"},{"internalType":"uint256","name":"newTotalAssets","type":"uint256"},{"internalType":"uint256","name":"maxDelta","type":"uint256"}],"name":"TotalAssetsDeviation","type":"error"},{"inputs":[{"internalType":"uint256","name":"prevTotalAssets","type":"uint256"},{"internalType":"uint256","name":"newTotalAssets","type":"uint256"},{"internalType":"uint256","name":"maxDelta","type":"uint256"}],"name":"TotalAssetsDeviation","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"VaultSlippage","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"VaultSlippage","type":"error"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowerOperations","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"currentICR","type":"uint256"},{"internalType":"uint256","name":"targetICR","type":"uint256"},{"internalType":"enum IBaseManagedLeveragedVault.Tolerance","name":"tolerance","type":"uint8"}],"name":"checkInvariantICR","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"amountToSwap","type":"uint256"},{"internalType":"uint256","name":"prevTotalAssets","type":"uint256"}],"name":"checkMaxOperationCost","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateral","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"debtTokenSurplusInAssets","type":"uint256"},{"internalType":"uint256","name":"collToReceive","type":"uint256"},{"internalType":"uint256","name":"prevTotalAssets","type":"uint256"}],"name":"computeNetColl","outputs":[{"internalType":"uint256","name":"netColl","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"debtToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deleverageRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"caller","type":"address"}],"name":"entryFeeInBP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"everlongCore","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"caller","type":"address"}],"name":"exitFeeInBP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeHook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCollateralBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getCollateralValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCollateralValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentPositionICR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDebtBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDebtValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getDebtValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"getTargetICR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getters","outputs":[{"internalType":"contract IBaseManagedLeveragedVaultGetters","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keeper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"leverageRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDeviationICRbp","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDeviationTotalAssetsInBP","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSlippageSwapInBP","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"targetICRHook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IBaseManagedLeveragedVault","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a060405234801561000f575f80fd5b50604051613ca4380380613ca4833981810160405281019061003191906100e0565b8080808073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250505050505061010b565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61009e82610075565b9050919050565b5f6100af82610094565b9050919050565b6100bf816100a5565b81146100c9575f80fd5b50565b5f815190506100da816100b6565b92915050565b5f602082840312156100f5576100f4610071565b5b5f610102848285016100cc565b91505092915050565b608051613afc6101a85f395f818161068f01528181610771015281816108e8015281816109b901528181610ac701528181610bae01528181610c8101528181610d5401528181610e2501528181610ef80152818161118801528181611318015281816113eb015281816115d5015281816116a6015281816117630152818161179b015281816119ed01528181611bc90152612c150152613afc5ff3fe608060405234801561000f575f80fd5b50600436106101d8575f3560e01c80638152e26011610102578063d3af80d7116100a0578063f11f44611161006f578063f11f446114610550578063f8d898981461056e578063fbfa77cf1461058c578063fcfa3e94146105aa576101d8565b8063d3af80d7146104c6578063d8dfeb45146104e4578063ebe6e53d14610502578063ec9d255214610532576101d8565b806391b58ae8116100dc57806391b58ae81461043c578063aced16611461045a578063c0177bd514610478578063c047e563146104a8576101d8565b80638152e260146103d257806382fee08f146103f05780638f3fadf614610420576101d8565b806341976e091161017a5780636317732e116101495780636317732e1461035a578063685159f81461037857806377553ad414610396578063791b98bc146103b4576101d8565b806341976e09146102d05780634ad45c84146103005780634bb701ad1461031e5780635ccbbdf11461033c576101d8565b806321a348a1116101b657806321a348a114610248578063293772e51461026457806338d52e0f146102945780633d6105d9146102b2576101d8565b80630fc0958e146101dc5780631529a6391461020c57806321216ba31461022a575b5f80fd5b6101f660048036038101906101f19190612e73565b6105c8565b6040516102039190612ec0565b60405180910390f35b610214610663565b6040516102219190612ec0565b60405180910390f35b610232610679565b60405161023f9190612ee8565b60405180910390f35b610262600480360381019061025d9190612f01565b61074a565b005b61027e60048036038101906102799190612f51565b61076d565b60405161028b9190612ec0565b60405180910390f35b61029c6108d2565b6040516102a99190612ee8565b60405180910390f35b6102ba6109a3565b6040516102c79190612ee8565b60405180910390f35b6102ea60048036038101906102e59190612fa1565b610a74565b6040516102f79190612ec0565b60405180910390f35b610308610a96565b6040516103159190612ec0565b60405180910390f35b610326610ab1565b6040516103339190612ee8565b60405180910390f35b610344610b82565b6040516103519190612ec0565b60405180910390f35b610362610b98565b60405161036f9190613027565b60405180910390f35b610380610c69565b60405161038d919061305c565b60405180910390f35b61039e610d3e565b6040516103ab9190612ee8565b60405180910390f35b6103bc610e0f565b6040516103c99190612ee8565b60405180910390f35b6103da610ee0565b6040516103e7919061305c565b60405180910390f35b61040a60048036038101906104059190613075565b610fb5565b6040516104179190612ec0565b60405180910390f35b61043a600480360381019061043591906130c3565b611057565b005b61044461115c565b6040516104519190612ec0565b60405180910390f35b610462611172565b60405161046f9190612ee8565b60405180910390f35b610492600480360381019061048d9190613075565b611243565b60405161049f9190612ec0565b60405180910390f35b6104b06112e5565b6040516104bd9190612ec0565b60405180910390f35b6104ce611300565b6040516104db919061305c565b60405180910390f35b6104ec6113d5565b6040516104f99190612ee8565b60405180910390f35b61051c60048036038101906105179190612e73565b6114a6565b6040516105299190612ec0565b60405180910390f35b61053a611540565b6040516105479190612ec0565b60405180910390f35b6105586115bf565b6040516105659190612ee8565b60405180910390f35b610576611690565b6040516105839190612ee8565b60405180910390f35b610594611761565b6040516105a19190613133565b60405180910390f35b6105b2611785565b6040516105bf9190612ee8565b60405180910390f35b5f806105d26115bf565b90508073ffffffffffffffffffffffffffffffffffffffff1663385d2ae2846105f96108d2565b8760026040518563ffffffff1660e01b815260040161061b94939291906131bf565b602060405180830381865afa158015610636573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061065a9190613216565b91505092915050565b5f61067461066f611856565b611cce565b905090565b5f8061068b610686611de9565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016106e69190613301565b5f60405180830381865afa158015610700573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610728919061349b565b5f8151811061073a576107396134e2565b5b60200260200101515f1c91505090565b610768838383610758611856565b611e99909392919063ffffffff16565b505050565b5f807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107fc9190613216565b90505f85828561080c919061353c565b610816919061353c565b90505f6108228261226a565b90505f61082d6113d5565b73ffffffffffffffffffffffffffffffffffffffff1663c6e6f592836040518263ffffffff1660e01b81526004016108659190612ec0565b602060405180830381865afa158015610880573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108a49190613216565b876108af9190613578565b90506108c581886108c091906135b8565b61243f565b9450505050509392505050565b5f806108e46108df61248b565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b815260040161093f9190613301565b5f60405180830381865afa158015610959573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610981919061349b565b5f81518110610993576109926134e2565b5b60200260200101515f1c91505090565b5f806109b56109b06124c3565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610a109190613301565b5f60405180830381865afa158015610a2a573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610a52919061349b565b5f81518110610a6457610a636134e2565b5b60200260200101515f1c91505090565b5f610a8f82610a81611856565b6124fc90919063ffffffff16565b9050919050565b5f80610aa0610b82565b9050610aab81611243565b91505090565b5f80610ac3610abe6125ed565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610b1e9190613301565b5f60405180830381865afa158015610b38573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610b60919061349b565b5f81518110610b7257610b716134e2565b5b60200260200101515f1c91505090565b5f610b93610b8e611856565b612626565b905090565b5f80610baa610ba56126b3565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610c059190613301565b5f60405180830381865afa158015610c1f573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610c47919061349b565b5f81518110610c5957610c586134e2565b5b60200260200101515f1c91505090565b5f80610c7b610c766126ec565b611e21565b905060b07f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b8152600401610cd89190613301565b5f60405180830381865afa158015610cf2573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610d1a919061349b565b5f81518110610d2c57610d2b6134e2565b5b60200260200101515f1c901c91505090565b5f80610d50610d4b612725565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610dab9190613301565b5f60405180830381865afa158015610dc5573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610ded919061349b565b5f81518110610dff57610dfe6134e2565b5b60200260200101515f1c91505090565b5f80610e21610e1c61275e565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610e7c9190613301565b5f60405180830381865afa158015610e96573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610ebe919061349b565b5f81518110610ed057610ecf6134e2565b5b60200260200101515f1c91505090565b5f80610ef2610eed612797565b611e21565b905060c07f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b8152600401610f4f9190613301565b5f60405180830381865afa158015610f69573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610f91919061349b565b5f81518110610fa357610fa26134e2565b5b60200260200101515f1c901c91505090565b5f80610fbf6113d5565b90505f610fcb82610a74565b905061104e818373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561101a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061103e919061362f565b866127d09092919063ffffffff16565b92505050919050565b5f611083611063611300565b61ffff1661271061107487876127fd565b6128159092919063ffffffff16565b90508160018111156110985761109761314c565b5b5f60018111156110ab576110aa61314c565b5b03611105576110bb8484836128e8565b611100578383826040517fed9118ed0000000000000000000000000000000000000000000000000000000081526004016110f79392919061365a565b60405180910390fd5b611156565b611110848483612912565b611155578383826040517fed9118ed00000000000000000000000000000000000000000000000000000000815260040161114c9392919061365a565b60405180910390fd5b5b50505050565b5f61116d611168611856565b612947565b905090565b5f8061118461117f612a47565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016111df9190613301565b5f60405180830381865afa1580156111f9573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611221919061349b565b5f81518110611233576112326134e2565b5b60200260200101515f1c91505090565b5f8061124d611690565b90505f61125982610a74565b90506112dc818373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112cc919061362f565b866127d09092919063ffffffff16565b92505050919050565b5f806112ef610663565b90506112fa81610fb5565b91505090565b5f8061131261130d612a80565b611e21565b905060a07f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b815260040161136f9190613301565b5f60405180830381865afa158015611389573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906113b1919061349b565b5f815181106113c3576113c26134e2565b5b60200260200101515f1c901c91505090565b5f806113e76113e2612ab9565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016114429190613301565b5f60405180830381865afa15801561145c573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611484919061349b565b5f81518110611496576114956134e2565b5b60200260200101515f1c91505090565b5f806114b06115bf565b90508073ffffffffffffffffffffffffffffffffffffffff1663385d2ae2846114d76108d2565b875f6040518563ffffffff1660e01b81526004016114f894939291906131bf565b602060405180830381865afa158015611513573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115379190613216565b91505092915050565b5f8061154a610ab1565b90508073ffffffffffffffffffffffffffffffffffffffff1663404adb316040518163ffffffff1660e01b8152600401602060405180830381865afa158015611595573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115b99190613216565b91505090565b5f806115d16115cc612af2565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b815260040161162c9190613301565b5f60405180830381865afa158015611646573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061166e919061349b565b5f815181106116805761167f6134e2565b5b60200260200101515f1c91505090565b5f806116a261169d612b2b565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016116fd9190613301565b5f60405180830381865afa158015611717573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061173f919061349b565b5f81518110611751576117506134e2565b5b60200260200101515f1c91505090565b7f000000000000000000000000000000000000000000000000000000000000000081565b5f80611797611792612b64565b611e21565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016117f29190613301565b5f60405180830381865afa15801561180c573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611834919061349b565b5f81518110611846576118456134e2565b5b60200260200101515f1c91505090565b61185e612cd4565b5f600867ffffffffffffffff81111561187a57611879613335565b5b6040519080825280602002602001820160405280156118a85781602001602082028036833780820191505090505b5090506118b361248b565b815f815181106118c6576118c56134e2565b5b6020026020010181815250506118da611de9565b816001815181106118ee576118ed6134e2565b5b602002602001018181525050611902612b2b565b81600281518110611916576119156134e2565b5b60200260200101818152505061192a6125ed565b8160038151811061193e5761193d6134e2565b5b602002602001018181525050611952612af2565b81600481518110611966576119656134e2565b5b60200260200101818152505061197a612a80565b8160058151811061198e5761198d6134e2565b5b6020026020010181815250506119a261275e565b816006815181106119b6576119b56134e2565b5b6020026020010181815250506119ca612725565b816007815181106119de576119dd6134e2565b5b6020026020010181815250505f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b8152600401611a449190613301565b5f60405180830381865afa158015611a5e573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611a86919061349b565b90505f815f81518110611a9c57611a9b6134e2565b5b60200260200101515f1c90505f82600181518110611abd57611abc6134e2565b5b60200260200101515f1c90505f83600281518110611ade57611add6134e2565b5b60200260200101515f1c90505f84600381518110611aff57611afe6134e2565b5b60200260200101515f1c90505f85600481518110611b2057611b1f6134e2565b5b60200260200101515f1c90505f86600581518110611b4157611b406134e2565b5b60200260200101515f1c90505f87600681518110611b6257611b616134e2565b5b60200260200101515f1c90505f88600781518110611b8357611b826134e2565b5b60200260200101515f1c90505f60b084901c90505f60c085901c90506040518061014001604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020017f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1681526020018a73ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018973ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1681526020018361ffff1681526020018261ffff168152509c5050505050505050505050505090565b5f80826060015190505f8173ffffffffffffffffffffffffffffffffffffffff1663eb7a7f7e85602001516040518263ffffffff1660e01b8152600401611d159190612ee8565b6040805180830381865afa158015611d2f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d53919061368f565b5090508173ffffffffffffffffffffffffffffffffffffffff1663ec38a05d85602001516040518263ffffffff1660e01b8152600401611d939190612ee8565b602060405180830381865afa158015611dae573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611dd29190613216565b81611ddd91906136cd565b90508092505050919050565b5f807f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c611e1a91906136cd565b5f1b905090565b60605f600167ffffffffffffffff811115611e3f57611e3e613335565b5b604051908082528060200260200182016040528015611e6d5781602001602082028036833780820191505090505b50905082815f81518110611e8457611e836134e2565b5b60200260200101818152505080915050919050565b5f846020015173ffffffffffffffffffffffffffffffffffffffff166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ee7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f0b9190613216565b90505f611f3786610100015161ffff16612710611f2886866127fd565b6128159092919063ffffffff16565b90508083611f45919061353c565b821015611f8d578282826040517f1ca8c50a000000000000000000000000000000000000000000000000000000008152600401611f849392919061365a565b60405180910390fd5b5f8284611f9a9190613578565b90505f611faa88895f01516124fc565b90505f8860a0015173ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16036121a6575f896080015190505f8173ffffffffffffffffffffffffffffffffffffffff16634e443d9e8373ffffffffffffffffffffffffffffffffffffffff1663b620115d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612052573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120769190613216565b6040518263ffffffff1660e01b81526004016120929190612ec0565b602060405180830381865afa1580156120ad573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120d19190613735565b90505f8161215a578b6060015173ffffffffffffffffffffffffffffffffffffffff1663477d66cf8b6040518263ffffffff1660e01b81526004016121169190612ec0565b602060405180830381865afa158015612131573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121559190613216565b61215c565b5f5b90505f61216d8d8e60a001516124fc565b90506121848187846128159092919063ffffffff16565b945061219b81878d6128159092919063ffffffff16565b9a50505050506121cc565b5f6121b18a8a6124fc565b90506121c881848a6128159092919063ffffffff16565b9750505b5f81846121d99190613578565b90505f81136121ed57505050505050612264565b5f8190505f6122128c610120015161ffff166127108c6128159092919063ffffffff16565b90508082111561225b5781816040517f4e0298da000000000000000000000000000000000000000000000000000000008152600401612252929190613760565b60405180910390fd5b50505050505050505b50505050565b5f806122746113d5565b73ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122bc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122e0919061379b565b90505f6122ec82610a74565b90505f6122ff6122fa612b9d565b610a74565b90505f8373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561234b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061236f919061362f565b60ff16600a61237e91906138f5565b90505f612389612b9d565b73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123d1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123f5919061362f565b60ff16600a61240491906138f5565b90508084612412919061393f565b82848961241f919061393f565b612429919061393f565b61243391906139ad565b95505050505050919050565b5f80821215612483576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161247a90613a37565b60405180910390fd5b819050919050565b5f807f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e005f1b5f1c6124bc91906136cd565b5f1b905090565b5f600a7f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c6124f591906136cd565b5f1b905090565b5f826040015173ffffffffffffffffffffffffffffffffffffffff1663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561254a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061256e919061379b565b73ffffffffffffffffffffffffffffffffffffffff1663ace1798e836040518263ffffffff1660e01b81526004016125a69190612ee8565b602060405180830381865afa1580156125c1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125e59190613216565b905092915050565b5f60047f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c61261f91906136cd565b5f1b905090565b5f80826060015173ffffffffffffffffffffffffffffffffffffffff1663eb7a7f7e84602001516040518263ffffffff1660e01b81526004016126699190612ee8565b6040805180830381865afa158015612683573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126a7919061368f565b91505080915050919050565b5f60067f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c6126e591906136cd565b5f1b905090565b5f60027f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c61271e91906136cd565b5f1b905090565b5f60077f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c61275791906136cd565b5f1b905090565b5f60087f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c61279091906136cd565b5f1b905090565b5f60027f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c6127c991906136cd565b5f1b905090565b5f81600a6127de9190613a55565b83856127ea919061393f565b6127f491906139ad565b90509392505050565b5f81831061280b578161280d565b825b905092915050565b5f805f80198587098587029250828110838203039150505f810361284d5783828161284357612842613980565b5b04925050506128e1565b808411612858575f80fd5b5f8486880990508281118203915080830392505f60018619018616905080860495508084049350600181825f0304019050808302841793505f600287600302189050808702600203810290508087026002038102905080870260020381029050808702600203810290508087026002038102905080870260020381029050808502955050505050505b9392505050565b5f828410156128f9575f905061290b565b818385612906919061353c565b111590505b9392505050565b5f82841161292e57818484612927919061353c565b111561293e565b81838561293b919061353c565b11155b90509392505050565b5f80826060015190505f8173ffffffffffffffffffffffffffffffffffffffff16630fdb11cf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561299a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129be9190613216565b90508173ffffffffffffffffffffffffffffffffffffffff1663d293c7108560200151836040518363ffffffff1660e01b81526004016129ff929190613a9f565b602060405180830381865afa158015612a1a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a3e9190613216565b92505050919050565b5f60037f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612a7991906136cd565b5f1b905090565b5f60027f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612ab291906136cd565b5f1b905090565b5f60027f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612aeb91906136cd565b5f1b905090565b5f60057f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612b2491906136cd565b5f1b905090565b5f60017f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612b5d91906136cd565b5f1b905090565b5f60097f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612b9691906136cd565b5f1b905090565b5f80600167ffffffffffffffff811115612bba57612bb9613335565b5b604051908082528060200260200182016040528015612be85781602001602082028036833780820191505090505b509050612bf361248b565b815f81518110612c0657612c056134e2565b5b6020026020010181815250505f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b8152600401612c6c9190613301565b5f60405180830381865afa158015612c86573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190612cae919061349b565b9050805f81518110612cc357612cc26134e2565b5b60200260200101515f1c9250505090565b6040518061014001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f61ffff1681526020015f61ffff1681525090565b5f604051905090565b5f80fd5b5f80fd5b5f819050919050565b612df881612de6565b8114612e02575f80fd5b50565b5f81359050612e1381612def565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f612e4282612e19565b9050919050565b612e5281612e38565b8114612e5c575f80fd5b50565b5f81359050612e6d81612e49565b92915050565b5f8060408385031215612e8957612e88612dde565b5b5f612e9685828601612e05565b9250506020612ea785828601612e5f565b9150509250929050565b612eba81612de6565b82525050565b5f602082019050612ed35f830184612eb1565b92915050565b612ee281612e38565b82525050565b5f602082019050612efb5f830184612ed9565b92915050565b5f805f60608486031215612f1857612f17612dde565b5b5f612f2586828701612e5f565b9350506020612f3686828701612e05565b9250506040612f4786828701612e05565b9150509250925092565b5f805f60608486031215612f6857612f67612dde565b5b5f612f7586828701612e05565b9350506020612f8686828701612e05565b9250506040612f9786828701612e05565b9150509250925092565b5f60208284031215612fb657612fb5612dde565b5b5f612fc384828501612e5f565b91505092915050565b5f819050919050565b5f612fef612fea612fe584612e19565b612fcc565b612e19565b9050919050565b5f61300082612fd5565b9050919050565b5f61301182612ff6565b9050919050565b61302181613007565b82525050565b5f60208201905061303a5f830184613018565b92915050565b5f61ffff82169050919050565b61305681613040565b82525050565b5f60208201905061306f5f83018461304d565b92915050565b5f6020828403121561308a57613089612dde565b5b5f61309784828501612e05565b91505092915050565b600281106130ac575f80fd5b50565b5f813590506130bd816130a0565b92915050565b5f805f606084860312156130da576130d9612dde565b5b5f6130e786828701612e05565b93505060206130f886828701612e05565b9250506040613109868287016130af565b9150509250925092565b5f61311d82612ff6565b9050919050565b61312d81613113565b82525050565b5f6020820190506131465f830184613124565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6004811061318a5761318961314c565b5b50565b5f81905061319a82613179565b919050565b5f6131a98261318d565b9050919050565b6131b98161319f565b82525050565b5f6080820190506131d25f830187612ed9565b6131df6020830186612ed9565b6131ec6040830185612eb1565b6131f960608301846131b0565b95945050505050565b5f8151905061321081612def565b92915050565b5f6020828403121561322b5761322a612dde565b5b5f61323884828501613202565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f819050919050565b61327c8161326a565b82525050565b5f61328d8383613273565b60208301905092915050565b5f602082019050919050565b5f6132af82613241565b6132b9818561324b565b93506132c48361325b565b805f5b838110156132f45781516132db8882613282565b97506132e683613299565b9250506001810190506132c7565b5085935050505092915050565b5f6020820190508181035f83015261331981846132a5565b905092915050565b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61336b82613325565b810181811067ffffffffffffffff8211171561338a57613389613335565b5b80604052505050565b5f61339c612dd5565b90506133a88282613362565b919050565b5f67ffffffffffffffff8211156133c7576133c6613335565b5b602082029050602081019050919050565b5f80fd5b6133e58161326a565b81146133ef575f80fd5b50565b5f81519050613400816133dc565b92915050565b5f613418613413846133ad565b613393565b9050808382526020820190506020840283018581111561343b5761343a6133d8565b5b835b81811015613464578061345088826133f2565b84526020840193505060208101905061343d565b5050509392505050565b5f82601f83011261348257613481613321565b5b8151613492848260208601613406565b91505092915050565b5f602082840312156134b0576134af612dde565b5b5f82015167ffffffffffffffff8111156134cd576134cc612de2565b5b6134d98482850161346e565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61354682612de6565b915061355183612de6565b92508282039050818111156135695761356861350f565b5b92915050565b5f819050919050565b5f6135828261356f565b915061358d8361356f565b925082820390508181125f8412168282135f8512151617156135b2576135b161350f565b5b92915050565b5f6135c28261356f565b91506135cd8361356f565b92508282019050828112155f8312168382125f8412151617156135f3576135f261350f565b5b92915050565b5f60ff82169050919050565b61360e816135f9565b8114613618575f80fd5b50565b5f8151905061362981613605565b92915050565b5f6020828403121561364457613643612dde565b5b5f6136518482850161361b565b91505092915050565b5f60608201905061366d5f830186612eb1565b61367a6020830185612eb1565b6136876040830184612eb1565b949350505050565b5f80604083850312156136a5576136a4612dde565b5b5f6136b285828601613202565b92505060206136c385828601613202565b9150509250929050565b5f6136d782612de6565b91506136e283612de6565b92508282019050808211156136fa576136f961350f565b5b92915050565b5f8115159050919050565b61371481613700565b811461371e575f80fd5b50565b5f8151905061372f8161370b565b92915050565b5f6020828403121561374a57613749612dde565b5b5f61375784828501613721565b91505092915050565b5f6040820190506137735f830185612eb1565b6137806020830184612eb1565b9392505050565b5f8151905061379581612e49565b92915050565b5f602082840312156137b0576137af612dde565b5b5f6137bd84828501613787565b91505092915050565b5f8160011c9050919050565b5f808291508390505b600185111561381b578086048111156137f7576137f661350f565b5b60018516156138065780820291505b8081029050613814856137c6565b94506137db565b94509492505050565b5f8261383357600190506138ee565b81613840575f90506138ee565b816001811461385657600281146138605761388f565b60019150506138ee565b60ff8411156138725761387161350f565b5b8360020a9150848211156138895761388861350f565b5b506138ee565b5060208310610133831016604e8410600b84101617156138c45782820a9050838111156138bf576138be61350f565b5b6138ee565b6138d184848460016137d2565b925090508184048111156138e8576138e761350f565b5b81810290505b9392505050565b5f6138ff82612de6565b915061390a83612de6565b92506139377fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484613824565b905092915050565b5f61394982612de6565b915061395483612de6565b925082820261396281612de6565b915082820484148315176139795761397861350f565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6139b782612de6565b91506139c283612de6565b9250826139d2576139d1613980565b5b828204905092915050565b5f82825260208201905092915050565b7f53616665436173743a2076616c7565206d75737420626520706f7369746976655f82015250565b5f613a216020836139dd565b9150613a2c826139ed565b602082019050919050565b5f6020820190508181035f830152613a4e81613a15565b9050919050565b5f613a5f82612de6565b9150613a6a836135f9565b9250613a977fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484613824565b905092915050565b5f604082019050613ab25f830185612ed9565b613abf6020830184612eb1565b939250505056fea2646970667358221220e12b972e2f11af5e3ee18e6e78f1daeb6b8c0662c234696ae1309efb609283f664736f6c634300081a0033000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe9263
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106101d8575f3560e01c80638152e26011610102578063d3af80d7116100a0578063f11f44611161006f578063f11f446114610550578063f8d898981461056e578063fbfa77cf1461058c578063fcfa3e94146105aa576101d8565b8063d3af80d7146104c6578063d8dfeb45146104e4578063ebe6e53d14610502578063ec9d255214610532576101d8565b806391b58ae8116100dc57806391b58ae81461043c578063aced16611461045a578063c0177bd514610478578063c047e563146104a8576101d8565b80638152e260146103d257806382fee08f146103f05780638f3fadf614610420576101d8565b806341976e091161017a5780636317732e116101495780636317732e1461035a578063685159f81461037857806377553ad414610396578063791b98bc146103b4576101d8565b806341976e09146102d05780634ad45c84146103005780634bb701ad1461031e5780635ccbbdf11461033c576101d8565b806321a348a1116101b657806321a348a114610248578063293772e51461026457806338d52e0f146102945780633d6105d9146102b2576101d8565b80630fc0958e146101dc5780631529a6391461020c57806321216ba31461022a575b5f80fd5b6101f660048036038101906101f19190612e73565b6105c8565b6040516102039190612ec0565b60405180910390f35b610214610663565b6040516102219190612ec0565b60405180910390f35b610232610679565b60405161023f9190612ee8565b60405180910390f35b610262600480360381019061025d9190612f01565b61074a565b005b61027e60048036038101906102799190612f51565b61076d565b60405161028b9190612ec0565b60405180910390f35b61029c6108d2565b6040516102a99190612ee8565b60405180910390f35b6102ba6109a3565b6040516102c79190612ee8565b60405180910390f35b6102ea60048036038101906102e59190612fa1565b610a74565b6040516102f79190612ec0565b60405180910390f35b610308610a96565b6040516103159190612ec0565b60405180910390f35b610326610ab1565b6040516103339190612ee8565b60405180910390f35b610344610b82565b6040516103519190612ec0565b60405180910390f35b610362610b98565b60405161036f9190613027565b60405180910390f35b610380610c69565b60405161038d919061305c565b60405180910390f35b61039e610d3e565b6040516103ab9190612ee8565b60405180910390f35b6103bc610e0f565b6040516103c99190612ee8565b60405180910390f35b6103da610ee0565b6040516103e7919061305c565b60405180910390f35b61040a60048036038101906104059190613075565b610fb5565b6040516104179190612ec0565b60405180910390f35b61043a600480360381019061043591906130c3565b611057565b005b61044461115c565b6040516104519190612ec0565b60405180910390f35b610462611172565b60405161046f9190612ee8565b60405180910390f35b610492600480360381019061048d9190613075565b611243565b60405161049f9190612ec0565b60405180910390f35b6104b06112e5565b6040516104bd9190612ec0565b60405180910390f35b6104ce611300565b6040516104db919061305c565b60405180910390f35b6104ec6113d5565b6040516104f99190612ee8565b60405180910390f35b61051c60048036038101906105179190612e73565b6114a6565b6040516105299190612ec0565b60405180910390f35b61053a611540565b6040516105479190612ec0565b60405180910390f35b6105586115bf565b6040516105659190612ee8565b60405180910390f35b610576611690565b6040516105839190612ee8565b60405180910390f35b610594611761565b6040516105a19190613133565b60405180910390f35b6105b2611785565b6040516105bf9190612ee8565b60405180910390f35b5f806105d26115bf565b90508073ffffffffffffffffffffffffffffffffffffffff1663385d2ae2846105f96108d2565b8760026040518563ffffffff1660e01b815260040161061b94939291906131bf565b602060405180830381865afa158015610636573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061065a9190613216565b91505092915050565b5f61067461066f611856565b611cce565b905090565b5f8061068b610686611de9565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016106e69190613301565b5f60405180830381865afa158015610700573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610728919061349b565b5f8151811061073a576107396134e2565b5b60200260200101515f1c91505090565b610768838383610758611856565b611e99909392919063ffffffff16565b505050565b5f807f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107fc9190613216565b90505f85828561080c919061353c565b610816919061353c565b90505f6108228261226a565b90505f61082d6113d5565b73ffffffffffffffffffffffffffffffffffffffff1663c6e6f592836040518263ffffffff1660e01b81526004016108659190612ec0565b602060405180830381865afa158015610880573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108a49190613216565b876108af9190613578565b90506108c581886108c091906135b8565b61243f565b9450505050509392505050565b5f806108e46108df61248b565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b815260040161093f9190613301565b5f60405180830381865afa158015610959573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610981919061349b565b5f81518110610993576109926134e2565b5b60200260200101515f1c91505090565b5f806109b56109b06124c3565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610a109190613301565b5f60405180830381865afa158015610a2a573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610a52919061349b565b5f81518110610a6457610a636134e2565b5b60200260200101515f1c91505090565b5f610a8f82610a81611856565b6124fc90919063ffffffff16565b9050919050565b5f80610aa0610b82565b9050610aab81611243565b91505090565b5f80610ac3610abe6125ed565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610b1e9190613301565b5f60405180830381865afa158015610b38573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610b60919061349b565b5f81518110610b7257610b716134e2565b5b60200260200101515f1c91505090565b5f610b93610b8e611856565b612626565b905090565b5f80610baa610ba56126b3565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610c059190613301565b5f60405180830381865afa158015610c1f573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610c47919061349b565b5f81518110610c5957610c586134e2565b5b60200260200101515f1c91505090565b5f80610c7b610c766126ec565b611e21565b905060b07f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b8152600401610cd89190613301565b5f60405180830381865afa158015610cf2573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610d1a919061349b565b5f81518110610d2c57610d2b6134e2565b5b60200260200101515f1c901c91505090565b5f80610d50610d4b612725565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610dab9190613301565b5f60405180830381865afa158015610dc5573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610ded919061349b565b5f81518110610dff57610dfe6134e2565b5b60200260200101515f1c91505090565b5f80610e21610e1c61275e565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b8152600401610e7c9190613301565b5f60405180830381865afa158015610e96573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610ebe919061349b565b5f81518110610ed057610ecf6134e2565b5b60200260200101515f1c91505090565b5f80610ef2610eed612797565b611e21565b905060c07f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b8152600401610f4f9190613301565b5f60405180830381865afa158015610f69573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610f91919061349b565b5f81518110610fa357610fa26134e2565b5b60200260200101515f1c901c91505090565b5f80610fbf6113d5565b90505f610fcb82610a74565b905061104e818373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561101a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061103e919061362f565b866127d09092919063ffffffff16565b92505050919050565b5f611083611063611300565b61ffff1661271061107487876127fd565b6128159092919063ffffffff16565b90508160018111156110985761109761314c565b5b5f60018111156110ab576110aa61314c565b5b03611105576110bb8484836128e8565b611100578383826040517fed9118ed0000000000000000000000000000000000000000000000000000000081526004016110f79392919061365a565b60405180910390fd5b611156565b611110848483612912565b611155578383826040517fed9118ed00000000000000000000000000000000000000000000000000000000815260040161114c9392919061365a565b60405180910390fd5b5b50505050565b5f61116d611168611856565b612947565b905090565b5f8061118461117f612a47565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016111df9190613301565b5f60405180830381865afa1580156111f9573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611221919061349b565b5f81518110611233576112326134e2565b5b60200260200101515f1c91505090565b5f8061124d611690565b90505f61125982610a74565b90506112dc818373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112cc919061362f565b866127d09092919063ffffffff16565b92505050919050565b5f806112ef610663565b90506112fa81610fb5565b91505090565b5f8061131261130d612a80565b611e21565b905060a07f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b815260040161136f9190613301565b5f60405180830381865afa158015611389573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906113b1919061349b565b5f815181106113c3576113c26134e2565b5b60200260200101515f1c901c91505090565b5f806113e76113e2612ab9565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016114429190613301565b5f60405180830381865afa15801561145c573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611484919061349b565b5f81518110611496576114956134e2565b5b60200260200101515f1c91505090565b5f806114b06115bf565b90508073ffffffffffffffffffffffffffffffffffffffff1663385d2ae2846114d76108d2565b875f6040518563ffffffff1660e01b81526004016114f894939291906131bf565b602060405180830381865afa158015611513573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115379190613216565b91505092915050565b5f8061154a610ab1565b90508073ffffffffffffffffffffffffffffffffffffffff1663404adb316040518163ffffffff1660e01b8152600401602060405180830381865afa158015611595573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115b99190613216565b91505090565b5f806115d16115cc612af2565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b815260040161162c9190613301565b5f60405180830381865afa158015611646573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061166e919061349b565b5f815181106116805761167f6134e2565b5b60200260200101515f1c91505090565b5f806116a261169d612b2b565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016116fd9190613301565b5f60405180830381865afa158015611717573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061173f919061349b565b5f81518110611751576117506134e2565b5b60200260200101515f1c91505090565b7f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926381565b5f80611797611792612b64565b611e21565b90507f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685826040518263ffffffff1660e01b81526004016117f29190613301565b5f60405180830381865afa15801561180c573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611834919061349b565b5f81518110611846576118456134e2565b5b60200260200101515f1c91505090565b61185e612cd4565b5f600867ffffffffffffffff81111561187a57611879613335565b5b6040519080825280602002602001820160405280156118a85781602001602082028036833780820191505090505b5090506118b361248b565b815f815181106118c6576118c56134e2565b5b6020026020010181815250506118da611de9565b816001815181106118ee576118ed6134e2565b5b602002602001018181525050611902612b2b565b81600281518110611916576119156134e2565b5b60200260200101818152505061192a6125ed565b8160038151811061193e5761193d6134e2565b5b602002602001018181525050611952612af2565b81600481518110611966576119656134e2565b5b60200260200101818152505061197a612a80565b8160058151811061198e5761198d6134e2565b5b6020026020010181815250506119a261275e565b816006815181106119b6576119b56134e2565b5b6020026020010181815250506119ca612725565b816007815181106119de576119dd6134e2565b5b6020026020010181815250505f7f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b8152600401611a449190613301565b5f60405180830381865afa158015611a5e573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190611a86919061349b565b90505f815f81518110611a9c57611a9b6134e2565b5b60200260200101515f1c90505f82600181518110611abd57611abc6134e2565b5b60200260200101515f1c90505f83600281518110611ade57611add6134e2565b5b60200260200101515f1c90505f84600381518110611aff57611afe6134e2565b5b60200260200101515f1c90505f85600481518110611b2057611b1f6134e2565b5b60200260200101515f1c90505f86600581518110611b4157611b406134e2565b5b60200260200101515f1c90505f87600681518110611b6257611b616134e2565b5b60200260200101515f1c90505f88600781518110611b8357611b826134e2565b5b60200260200101515f1c90505f60b084901c90505f60c085901c90506040518061014001604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020017f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff1681526020018a73ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018973ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1681526020018361ffff1681526020018261ffff168152509c5050505050505050505050505090565b5f80826060015190505f8173ffffffffffffffffffffffffffffffffffffffff1663eb7a7f7e85602001516040518263ffffffff1660e01b8152600401611d159190612ee8565b6040805180830381865afa158015611d2f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d53919061368f565b5090508173ffffffffffffffffffffffffffffffffffffffff1663ec38a05d85602001516040518263ffffffff1660e01b8152600401611d939190612ee8565b602060405180830381865afa158015611dae573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611dd29190613216565b81611ddd91906136cd565b90508092505050919050565b5f807f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c611e1a91906136cd565b5f1b905090565b60605f600167ffffffffffffffff811115611e3f57611e3e613335565b5b604051908082528060200260200182016040528015611e6d5781602001602082028036833780820191505090505b50905082815f81518110611e8457611e836134e2565b5b60200260200101818152505080915050919050565b5f846020015173ffffffffffffffffffffffffffffffffffffffff166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ee7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f0b9190613216565b90505f611f3786610100015161ffff16612710611f2886866127fd565b6128159092919063ffffffff16565b90508083611f45919061353c565b821015611f8d578282826040517f1ca8c50a000000000000000000000000000000000000000000000000000000008152600401611f849392919061365a565b60405180910390fd5b5f8284611f9a9190613578565b90505f611faa88895f01516124fc565b90505f8860a0015173ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16036121a6575f896080015190505f8173ffffffffffffffffffffffffffffffffffffffff16634e443d9e8373ffffffffffffffffffffffffffffffffffffffff1663b620115d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612052573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120769190613216565b6040518263ffffffff1660e01b81526004016120929190612ec0565b602060405180830381865afa1580156120ad573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120d19190613735565b90505f8161215a578b6060015173ffffffffffffffffffffffffffffffffffffffff1663477d66cf8b6040518263ffffffff1660e01b81526004016121169190612ec0565b602060405180830381865afa158015612131573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121559190613216565b61215c565b5f5b90505f61216d8d8e60a001516124fc565b90506121848187846128159092919063ffffffff16565b945061219b81878d6128159092919063ffffffff16565b9a50505050506121cc565b5f6121b18a8a6124fc565b90506121c881848a6128159092919063ffffffff16565b9750505b5f81846121d99190613578565b90505f81136121ed57505050505050612264565b5f8190505f6122128c610120015161ffff166127108c6128159092919063ffffffff16565b90508082111561225b5781816040517f4e0298da000000000000000000000000000000000000000000000000000000008152600401612252929190613760565b60405180910390fd5b50505050505050505b50505050565b5f806122746113d5565b73ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122bc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122e0919061379b565b90505f6122ec82610a74565b90505f6122ff6122fa612b9d565b610a74565b90505f8373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561234b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061236f919061362f565b60ff16600a61237e91906138f5565b90505f612389612b9d565b73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123d1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123f5919061362f565b60ff16600a61240491906138f5565b90508084612412919061393f565b82848961241f919061393f565b612429919061393f565b61243391906139ad565b95505050505050919050565b5f80821215612483576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161247a90613a37565b60405180910390fd5b819050919050565b5f807f0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e005f1b5f1c6124bc91906136cd565b5f1b905090565b5f600a7f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c6124f591906136cd565b5f1b905090565b5f826040015173ffffffffffffffffffffffffffffffffffffffff1663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561254a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061256e919061379b565b73ffffffffffffffffffffffffffffffffffffffff1663ace1798e836040518263ffffffff1660e01b81526004016125a69190612ee8565b602060405180830381865afa1580156125c1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125e59190613216565b905092915050565b5f60047f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c61261f91906136cd565b5f1b905090565b5f80826060015173ffffffffffffffffffffffffffffffffffffffff1663eb7a7f7e84602001516040518263ffffffff1660e01b81526004016126699190612ee8565b6040805180830381865afa158015612683573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126a7919061368f565b91505080915050919050565b5f60067f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c6126e591906136cd565b5f1b905090565b5f60027f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c61271e91906136cd565b5f1b905090565b5f60077f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c61275791906136cd565b5f1b905090565b5f60087f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c61279091906136cd565b5f1b905090565b5f60027f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c6127c991906136cd565b5f1b905090565b5f81600a6127de9190613a55565b83856127ea919061393f565b6127f491906139ad565b90509392505050565b5f81831061280b578161280d565b825b905092915050565b5f805f80198587098587029250828110838203039150505f810361284d5783828161284357612842613980565b5b04925050506128e1565b808411612858575f80fd5b5f8486880990508281118203915080830392505f60018619018616905080860495508084049350600181825f0304019050808302841793505f600287600302189050808702600203810290508087026002038102905080870260020381029050808702600203810290508087026002038102905080870260020381029050808502955050505050505b9392505050565b5f828410156128f9575f905061290b565b818385612906919061353c565b111590505b9392505050565b5f82841161292e57818484612927919061353c565b111561293e565b81838561293b919061353c565b11155b90509392505050565b5f80826060015190505f8173ffffffffffffffffffffffffffffffffffffffff16630fdb11cf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561299a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129be9190613216565b90508173ffffffffffffffffffffffffffffffffffffffff1663d293c7108560200151836040518363ffffffff1660e01b81526004016129ff929190613a9f565b602060405180830381865afa158015612a1a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a3e9190613216565b92505050919050565b5f60037f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612a7991906136cd565b5f1b905090565b5f60027f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612ab291906136cd565b5f1b905090565b5f60027f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612aeb91906136cd565b5f1b905090565b5f60057f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612b2491906136cd565b5f1b905090565b5f60017f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612b5d91906136cd565b5f1b905090565b5f60097f12ca37b393c412d053690654fb6d504d2a16c55c2bd10941af581f2221d9c1005f1b5f1c612b9691906136cd565b5f1b905090565b5f80600167ffffffffffffffff811115612bba57612bb9613335565b5b604051908082528060200260200182016040528015612be85781602001602082028036833780820191505090505b509050612bf361248b565b815f81518110612c0657612c056134e2565b5b6020026020010181815250505f7f000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe926373ffffffffffffffffffffffffffffffffffffffff16637784c685836040518263ffffffff1660e01b8152600401612c6c9190613301565b5f60405180830381865afa158015612c86573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190612cae919061349b565b9050805f81518110612cc357612cc26134e2565b5b60200260200101515f1c9250505090565b6040518061014001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f61ffff1681526020015f61ffff1681525090565b5f604051905090565b5f80fd5b5f80fd5b5f819050919050565b612df881612de6565b8114612e02575f80fd5b50565b5f81359050612e1381612def565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f612e4282612e19565b9050919050565b612e5281612e38565b8114612e5c575f80fd5b50565b5f81359050612e6d81612e49565b92915050565b5f8060408385031215612e8957612e88612dde565b5b5f612e9685828601612e05565b9250506020612ea785828601612e5f565b9150509250929050565b612eba81612de6565b82525050565b5f602082019050612ed35f830184612eb1565b92915050565b612ee281612e38565b82525050565b5f602082019050612efb5f830184612ed9565b92915050565b5f805f60608486031215612f1857612f17612dde565b5b5f612f2586828701612e5f565b9350506020612f3686828701612e05565b9250506040612f4786828701612e05565b9150509250925092565b5f805f60608486031215612f6857612f67612dde565b5b5f612f7586828701612e05565b9350506020612f8686828701612e05565b9250506040612f9786828701612e05565b9150509250925092565b5f60208284031215612fb657612fb5612dde565b5b5f612fc384828501612e5f565b91505092915050565b5f819050919050565b5f612fef612fea612fe584612e19565b612fcc565b612e19565b9050919050565b5f61300082612fd5565b9050919050565b5f61301182612ff6565b9050919050565b61302181613007565b82525050565b5f60208201905061303a5f830184613018565b92915050565b5f61ffff82169050919050565b61305681613040565b82525050565b5f60208201905061306f5f83018461304d565b92915050565b5f6020828403121561308a57613089612dde565b5b5f61309784828501612e05565b91505092915050565b600281106130ac575f80fd5b50565b5f813590506130bd816130a0565b92915050565b5f805f606084860312156130da576130d9612dde565b5b5f6130e786828701612e05565b93505060206130f886828701612e05565b9250506040613109868287016130af565b9150509250925092565b5f61311d82612ff6565b9050919050565b61312d81613113565b82525050565b5f6020820190506131465f830184613124565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6004811061318a5761318961314c565b5b50565b5f81905061319a82613179565b919050565b5f6131a98261318d565b9050919050565b6131b98161319f565b82525050565b5f6080820190506131d25f830187612ed9565b6131df6020830186612ed9565b6131ec6040830185612eb1565b6131f960608301846131b0565b95945050505050565b5f8151905061321081612def565b92915050565b5f6020828403121561322b5761322a612dde565b5b5f61323884828501613202565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f819050919050565b61327c8161326a565b82525050565b5f61328d8383613273565b60208301905092915050565b5f602082019050919050565b5f6132af82613241565b6132b9818561324b565b93506132c48361325b565b805f5b838110156132f45781516132db8882613282565b97506132e683613299565b9250506001810190506132c7565b5085935050505092915050565b5f6020820190508181035f83015261331981846132a5565b905092915050565b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61336b82613325565b810181811067ffffffffffffffff8211171561338a57613389613335565b5b80604052505050565b5f61339c612dd5565b90506133a88282613362565b919050565b5f67ffffffffffffffff8211156133c7576133c6613335565b5b602082029050602081019050919050565b5f80fd5b6133e58161326a565b81146133ef575f80fd5b50565b5f81519050613400816133dc565b92915050565b5f613418613413846133ad565b613393565b9050808382526020820190506020840283018581111561343b5761343a6133d8565b5b835b81811015613464578061345088826133f2565b84526020840193505060208101905061343d565b5050509392505050565b5f82601f83011261348257613481613321565b5b8151613492848260208601613406565b91505092915050565b5f602082840312156134b0576134af612dde565b5b5f82015167ffffffffffffffff8111156134cd576134cc612de2565b5b6134d98482850161346e565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61354682612de6565b915061355183612de6565b92508282039050818111156135695761356861350f565b5b92915050565b5f819050919050565b5f6135828261356f565b915061358d8361356f565b925082820390508181125f8412168282135f8512151617156135b2576135b161350f565b5b92915050565b5f6135c28261356f565b91506135cd8361356f565b92508282019050828112155f8312168382125f8412151617156135f3576135f261350f565b5b92915050565b5f60ff82169050919050565b61360e816135f9565b8114613618575f80fd5b50565b5f8151905061362981613605565b92915050565b5f6020828403121561364457613643612dde565b5b5f6136518482850161361b565b91505092915050565b5f60608201905061366d5f830186612eb1565b61367a6020830185612eb1565b6136876040830184612eb1565b949350505050565b5f80604083850312156136a5576136a4612dde565b5b5f6136b285828601613202565b92505060206136c385828601613202565b9150509250929050565b5f6136d782612de6565b91506136e283612de6565b92508282019050808211156136fa576136f961350f565b5b92915050565b5f8115159050919050565b61371481613700565b811461371e575f80fd5b50565b5f8151905061372f8161370b565b92915050565b5f6020828403121561374a57613749612dde565b5b5f61375784828501613721565b91505092915050565b5f6040820190506137735f830185612eb1565b6137806020830184612eb1565b9392505050565b5f8151905061379581612e49565b92915050565b5f602082840312156137b0576137af612dde565b5b5f6137bd84828501613787565b91505092915050565b5f8160011c9050919050565b5f808291508390505b600185111561381b578086048111156137f7576137f661350f565b5b60018516156138065780820291505b8081029050613814856137c6565b94506137db565b94509492505050565b5f8261383357600190506138ee565b81613840575f90506138ee565b816001811461385657600281146138605761388f565b60019150506138ee565b60ff8411156138725761387161350f565b5b8360020a9150848211156138895761388861350f565b5b506138ee565b5060208310610133831016604e8410600b84101617156138c45782820a9050838111156138bf576138be61350f565b5b6138ee565b6138d184848460016137d2565b925090508184048111156138e8576138e761350f565b5b81810290505b9392505050565b5f6138ff82612de6565b915061390a83612de6565b92506139377fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484613824565b905092915050565b5f61394982612de6565b915061395483612de6565b925082820261396281612de6565b915082820484148315176139795761397861350f565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6139b782612de6565b91506139c283612de6565b9250826139d2576139d1613980565b5b828204905092915050565b5f82825260208201905092915050565b7f53616665436173743a2076616c7565206d75737420626520706f7369746976655f82015250565b5f613a216020836139dd565b9150613a2c826139ed565b602082019050919050565b5f6020820190508181035f830152613a4e81613a15565b9050919050565b5f613a5f82612de6565b9150613a6a836135f9565b9250613a977fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484613824565b905092915050565b5f604082019050613ab25f830185612ed9565b613abf6020830184612eb1565b939250505056fea2646970667358221220e12b972e2f11af5e3ee18e6e78f1daeb6b8c0662c234696ae1309efb609283f664736f6c634300081a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe9263
-----Decoded View---------------
Arg [0] : _vault (address): 0xF3Db5347D1B71F6792E0889b46deB1629cfe9263
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000f3db5347d1b71f6792e0889b46deb1629cfe9263
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 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.