Verified contractExactGPL-3.0-only
NavLens
Address0xefa6a7cd4f77a839b7395082d41a88cdaf9955f2
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.25
- Same code
1 more contract
Details
- Compiler
- solc 0.8.25+commit.b61c2a91
- Language
- solidity
- Optimization
- Yes, 1 runs
- EVM version
- cancun
- License
- GPL-3.0-only
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,332,599
- Creation transaction
- 0xbed0803c6f…5c73507c33
- Main copy (most transactions)
- 0x981b14d4…a474708c
7 files
- src/navvaults/accounting/NavLens.solmain18.75 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol12.18 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.78 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol683 B
- lib/openzeppelin-contracts/contracts/utils/math/Math.sol15.12 KB
- src/navvaults/math/NavFeeMath.sol4.58 KB
- src/navvaults/types/NavTypes.sol2.87 KB
src/navvaults/accounting/NavLens.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.25;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { NavTypes } from "../types/NavTypes.sol";
import { NavFeeMath } from "../math/NavFeeMath.sol";
interface INavReadSource is IERC4626 {
function underlyingVault() external view returns (IERC4626);
function previewNav() external view returns (NavTypes.Snapshot memory);
function shareMultiplier() external view returns (uint256);
function activated() external view returns (bool);
function paused() external view returns (bool);
function seedLock() external view returns (address);
function readProviderCapacity(NavTypes.Operation operation)
external
view
returns (NavTypes.Capacity memory);
}
/// @notice Immutable, stateless read/calculation module. Holds no funds, approvals or administrative
/// authority. Vaults pin a shared instance; calls use STATICCALL, never delegatecall.
contract NavLens {
error InvalidValuation();
error UnavailableValuation();
error PositionMismatch();
error AccountingLimit();
error InvalidConfiguration();
/// @notice Validate per-proxy configuration without storing state in the shared Lens.
function validateInitialization(NavTypes.Init calldata init)
external
view
returns (IERC20 assetToken, uint256 multiplier)
{
return _validateInitialization(init, NavTypes.MAX_PERFORMANCE_BPS);
}
function validateInitialization(NavTypes.Init calldata init, uint16 cap)
external
view
returns (IERC20 assetToken, uint256 multiplier)
{
return _validateInitialization(init, cap);
}
function _validateInitialization(NavTypes.Init calldata init, uint16 cap)
private
view
returns (IERC20 assetToken, uint256 multiplier)
{
if (cap == 0 || cap > NavTypes.ABSOLUTE_MAX_PERFORMANCE_BPS) {
revert InvalidConfiguration();
}
if (init.underlying.code.length == 0) revert InvalidConfiguration();
address assetAddress = IERC4626(init.underlying).asset();
if (
init.admin == address(0) || init.pauser == address(0) || assetAddress.code.length == 0
|| init.underlying == assetAddress || init.recoveryTreasury == address(0)
|| bytes(init.name).length == 0 || init.fees.recipient == address(0)
|| init.fees.managementBps > NavTypes.MAX_MANAGEMENT_BPS
|| init.fees.performanceBps > cap
) revert InvalidConfiguration();
uint8 assetDecimals = IERC20Metadata(assetAddress).decimals();
if (assetDecimals > 18 || IERC20Metadata(init.underlying).decimals() > 27) {
revert InvalidConfiguration();
}
return (IERC20(assetAddress), 10 ** (18 - assetDecimals));
}
/// @notice Value only the accounted backing shares and verify the provider still uses the asset.
function grossAssets(
IERC4626 underlying,
address expectedAsset,
address account,
uint256 managedShares
) external view returns (uint256 assets) {
if (underlying.asset() != expectedAsset) revert UnavailableValuation();
if (
managedShares > NavTypes.MAX_ACCOUNTING || underlying.balanceOf(account) < managedShares
) {
revert PositionMismatch();
}
assets = managedShares == 0 ? 0 : underlying.convertToAssets(managedShares);
if (assets > NavTypes.MAX_ACCOUNTING) revert AccountingLimit();
}
/// @notice Simulate fees and pricing. The vault adds timestamps and configuration metadata.
function calculateNav(NavFeeMath.Input calldata input)
external
pure
returns (NavTypes.Valuation memory value)
{
NavTypes.Accrual memory accrual = NavFeeMath.accrue(input);
if (
input.feeSharesR + accrual.managementSharesR + accrual.performanceSharesR
> input.underlyingShares * NavTypes.RAY
) {
revert UnavailableValuation();
}
value = NavTypes.Valuation({
grossAssets: input.grossAssets,
netAssets: accrual.netAssets,
netNavRay: input.supply == 0
? 0
: Math.mulDiv(accrual.netAssets, input.priceScale, input.supply),
highWaterMark: accrual.highWaterMark,
managementSharesR: accrual.managementSharesR,
performanceSharesR: accrual.performanceSharesR,
remainder: accrual.remainder
});
}
function managementFeeExhaustsBacking(NavFeeMath.Input calldata input)
external
pure
returns (bool)
{
return NavFeeMath.managementFeeExhaustsBacking(input);
}
/// @notice Reprice settled ownership without charging fees again on capital-flow rounding.
function afterOperation(
uint256 grossPositionAssets,
uint256 underlyingShares,
uint256 recordedFeeSharesR,
uint256 supply,
uint256 previousHighWaterMark,
uint256 priceScale
) external pure returns (uint256 netAssets, uint256 netNavRay, uint256 highWaterMark) {
uint256 underlyingSharesRay = underlyingShares * NavTypes.RAY;
if (recordedFeeSharesR > underlyingSharesRay) revert PositionMismatch();
if (supply == 0) return (0, 0, 0);
netAssets = underlyingSharesRay == 0
? 0
: Math.mulDiv(
grossPositionAssets, underlyingSharesRay - recordedFeeSharesR, underlyingSharesRay
);
netNavRay = Math.mulDiv(netAssets, priceScale, supply);
highWaterMark = Math.max(
previousHighWaterMark, Math.mulDiv(netAssets, priceScale, supply, Math.Rounding.Ceil)
);
}
function _liveSnapshot(INavReadSource vault)
private
view
returns (NavTypes.Snapshot memory snapshot)
{
snapshot = vault.previewNav();
if (snapshot.valuationStatus == NavTypes.ValuationStatus.Unavailable) {
revert InvalidValuation();
}
}
function _userUnderlyingSharesRay(NavTypes.Snapshot memory snapshot)
private
pure
returns (uint256)
{
return snapshot.underlyingSharesRaw * NavTypes.RAY - snapshot.feeUnderlyingSharesR;
}
function _toVaultShares(
NavTypes.Snapshot memory snapshot,
uint256 underlyingShares,
Math.Rounding rounding
) private pure returns (uint256) {
return Math.mulDiv(
underlyingShares * NavTypes.RAY,
snapshot.currentSupplyRaw,
_userUnderlyingSharesRay(snapshot),
rounding
);
}
function _toUnderlyingShares(
NavTypes.Snapshot memory snapshot,
uint256 vaultShares,
Math.Rounding rounding
) private pure returns (uint256) {
return Math.mulDiv(
vaultShares,
_userUnderlyingSharesRay(snapshot),
snapshot.currentSupplyRaw * NavTypes.RAY,
rounding
);
}
function preview(INavReadSource vault, NavTypes.Operation operation, uint256 amount)
external
view
returns (uint256)
{
if (vault.totalSupply() == 0) {
return _initialPreview(vault.shareMultiplier(), operation, amount);
}
return _preview(vault.underlyingVault(), _liveSnapshot(vault), operation, amount);
}
function _initialPreview(uint256 multiplier, NavTypes.Operation operation, uint256 amount)
private
pure
returns (uint256)
{
if (operation == NavTypes.Operation.Deposit || operation == NavTypes.Operation.Withdraw) {
return Math.mulDiv(amount, multiplier, 1);
}
return operation == NavTypes.Operation.Mint
? Math.ceilDiv(amount, multiplier)
: amount / multiplier;
}
function _preview(
IERC4626 underlying,
NavTypes.Snapshot memory snapshot,
NavTypes.Operation operation,
uint256 amount
) private view returns (uint256) {
if (operation == NavTypes.Operation.Deposit) {
return _toVaultShares(snapshot, underlying.previewDeposit(amount), Math.Rounding.Floor);
}
if (operation == NavTypes.Operation.Mint) {
return underlying.previewMint(_toUnderlyingShares(snapshot, amount, Math.Rounding.Ceil));
}
if (operation == NavTypes.Operation.Withdraw) {
return _toVaultShares(snapshot, underlying.previewWithdraw(amount), Math.Rounding.Ceil);
}
return underlying.previewRedeem(_toUnderlyingShares(snapshot, amount, Math.Rounding.Floor));
}
function _operationsDisabled(INavReadSource vault) private view returns (bool) {
return !vault.activated() || vault.paused();
}
function maximum(INavReadSource vault, NavTypes.Operation operation, address account)
external
view
returns (uint256)
{
bool isDeposit =
operation == NavTypes.Operation.Deposit || operation == NavTypes.Operation.Mint;
if (_operationsDisabled(vault)) {
return 0;
}
NavTypes.Snapshot memory snapshot = _liveSnapshot(vault);
if (isDeposit && snapshot.currentSupplyRaw != 0 && snapshot.activeGrossAssetsRaw == 0) {
return 0;
}
NavTypes.Capacity memory limit = vault.readProviderCapacity(operation);
if (limit.state == NavTypes.LimitState.Disabled) {
return 0;
}
IERC4626 underlying = vault.underlyingVault();
if (!isDeposit && snapshot.currentSupplyRaw == 0) return 0;
if (isDeposit) {
if (
account == address(0) || account == vault.seedLock() || account == address(vault)
|| account == address(underlying)
) {
return 0;
}
uint256 assets = _maxDepositAssets(vault, underlying, snapshot, limit.executableAssets);
if (operation == NavTypes.Operation.Deposit) return assets;
if (snapshot.currentSupplyRaw == 0) return assets * vault.shareMultiplier();
if (assets == 0) return 0;
// Asset quotes can map several adjacent share amounts to the same rounded cost.
// Keep the native share cap as well as the accounting and asset budgets.
uint256 mintBudget = Math.min(
underlying.maxMint(address(vault)),
Math.min(
NavTypes.MAX_ACCOUNTING - snapshot.underlyingSharesRaw,
underlying.previewDeposit(assets)
)
);
return Math.min(
NavTypes.MAX_ACCOUNTING - snapshot.currentSupplyRaw,
_toVaultShares(snapshot, mintBudget, Math.Rounding.Floor)
);
}
uint256 balance = vault.balanceOf(account);
if (operation == NavTypes.Operation.Withdraw) {
return _maxWithdrawAssets(underlying, snapshot, balance, limit.executableAssets);
}
// A conservative underlying budget; unrelated routes and reserved fee shares are excluded.
if (limit.executableAssets == type(uint256).max) return balance;
uint256 assetBudget = Math.min(limit.executableAssets, snapshot.activeGrossAssetsRaw);
uint256 underlyingBudget =
Math.min(underlying.convertToShares(assetBudget), snapshot.underlyingSharesRaw);
return Math.min(balance, _toVaultShares(snapshot, underlyingBudget, Math.Rounding.Floor));
}
/// @dev Redeem rounds down while withdraw rounds up. Provider previews need not be exact
/// inverses, so verify the candidate against the user's fee-adjusted backing share budget.
function _maxWithdrawAssets(
IERC4626 underlying,
NavTypes.Snapshot memory snapshot,
uint256 balance,
uint256 providerAssetLimit
) private view returns (uint256) {
uint256 shareBudget = _toUnderlyingShares(snapshot, balance, Math.Rounding.Floor);
if (shareBudget == 0 || providerAssetLimit == 0) return 0;
uint256 assets = Math.min(providerAssetLimit, underlying.previewRedeem(shareBudget));
if (assets == 0 || underlying.previewWithdraw(assets) <= shareBudget) return assets;
// Normal double-rounding boundaries need just one asset-unit adjustment.
--assets;
if (assets == 0 || underlying.previewWithdraw(assets) <= shareBudget) return assets;
// For providers with a larger preview gap, find an executable amount rather than
// assuming a fixed haircut. The upper bound is uint128-sized, so this terminates.
uint256 low;
uint256 high = assets - 1;
while (low < high) {
uint256 mid = low + (high - low + 1) / 2;
if (underlying.previewWithdraw(mid) <= shareBudget) low = mid;
else high = mid - 1;
}
return low;
}
/// @dev Restrict provider capacity by both accounting size limits.
function _maxDepositAssets(
INavReadSource vault,
IERC4626 underlying,
NavTypes.Snapshot memory snapshot,
uint256 providerAssetLimit
) private view returns (uint256) {
// Entry amounts must not depend on exit fees or withdrawable liquidity. The asset
// headroom also bounds gross valuation after entry (entry fees only reduce it).
uint256 assetLimit =
Math.min(providerAssetLimit, NavTypes.MAX_ACCOUNTING - snapshot.activeGrossAssetsRaw);
uint256 remainingUnderlyingShares = NavTypes.MAX_ACCOUNTING - snapshot.underlyingSharesRaw;
assetLimit = Math.min(assetLimit, underlying.convertToAssets(remainingUnderlyingShares));
if (snapshot.currentSupplyRaw == 0) {
return Math.min(assetLimit, NavTypes.MAX_ACCOUNTING / vault.shareMultiplier());
}
uint256 remainingVaultShares = NavTypes.MAX_ACCOUNTING - snapshot.currentSupplyRaw;
uint256 underlyingSharesForMint =
_toUnderlyingShares(snapshot, remainingVaultShares, Math.Rounding.Floor);
return Math.min(assetLimit, underlying.convertToAssets(underlyingSharesForMint));
}
function capacity(INavReadSource vault, NavTypes.Operation operation, address account)
public
view
returns (NavTypes.Capacity memory limit)
{
bool isDeposit =
operation == NavTypes.Operation.Deposit || operation == NavTypes.Operation.Mint;
if (_operationsDisabled(vault)) {
limit.state = NavTypes.LimitState.Disabled;
limit.reason = keccak256("LOCAL_PAUSE_OR_NOT_ACTIVE");
return limit;
}
if (vault.previewNav().valuationStatus == NavTypes.ValuationStatus.Unavailable) {
limit.state = NavTypes.LimitState.Unknown;
limit.reason = keccak256("VALUATION_UNAVAILABLE");
return limit;
}
try vault.readProviderCapacity(operation) returns (NavTypes.Capacity memory providerLimit) {
limit = providerLimit;
} catch {
limit.state = NavTypes.LimitState.Unknown;
limit.reason = keccak256("CAPACITY_UNAVAILABLE");
}
// Capacity uses assets even when the ERC4626 maximum is denominated in shares.
if (operation == NavTypes.Operation.Mint) {
uint256 maxShares = vault.maxMint(account);
// An unlimited share sentinel must not be converted through previewMint arithmetic.
limit.executableAssets =
maxShares == type(uint256).max ? type(uint256).max : vault.previewMint(maxShares);
} else if (operation == NavTypes.Operation.Redeem) {
limit.executableAssets = vault.previewRedeem(vault.maxRedeem(account));
} else if (isDeposit) {
limit.executableAssets = vault.maxDeposit(account);
} else {
limit.executableAssets = vault.maxWithdraw(account);
}
}
function quote(
INavReadSource vault,
NavTypes.Operation operation,
uint256 amount,
address account
) external view returns (NavTypes.Quote memory quoteResult) {
quoteResult.inputRaw = amount;
quoteResult.evaluatedAt = uint64(block.timestamp);
NavTypes.Snapshot memory snapshot = _liveSnapshot(vault);
quoteResult.netNavRay = snapshot.netNavRay;
quoteResult.capacity = capacity(vault, operation, account);
quoteResult.outputRaw = snapshot.currentSupplyRaw == 0
? _initialPreview(vault.shareMultiplier(), operation, amount)
: _preview(vault.underlyingVault(), snapshot, operation, amount);
uint256 assets = operation == NavTypes.Operation.Mint
|| operation == NavTypes.Operation.Redeem
? quoteResult.outputRaw
: amount;
if (quoteResult.capacity.state == NavTypes.LimitState.Disabled) {
quoteResult.assessment = NavTypes.Assessment.Reject;
} else if (assets <= quoteResult.capacity.executableAssets) {
quoteResult.assessment = NavTypes.Assessment.Pass;
} else if (quoteResult.capacity.state == NavTypes.LimitState.Unknown) {
quoteResult.assessment = NavTypes.Assessment.SimulationRequired;
} else {
quoteResult.assessment = NavTypes.Assessment.Reject;
}
// A provider limit does not replace the user's ownership or receiver validation.
if (
operation == NavTypes.Operation.Withdraw
&& quoteResult.outputRaw > vault.balanceOf(account)
|| operation == NavTypes.Operation.Redeem && amount > vault.balanceOf(account)
|| operation == NavTypes.Operation.Mint
&& quoteResult.capacity.state != NavTypes.LimitState.Unknown
&& amount > vault.maxMint(account)
) {
quoteResult.assessment = NavTypes.Assessment.Reject;
}
if (operation == NavTypes.Operation.Deposit || operation == NavTypes.Operation.Mint) {
if (
account == address(0) || account == address(vault)
|| account == address(vault.underlyingVault()) || account == vault.seedLock()
) {
quoteResult.assessment = NavTypes.Assessment.Reject;
}
}
}
}
lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
import {IERC20Metadata} from "../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].
*/
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);
}
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
lib/openzeppelin-contracts/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @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 towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (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 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^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 (unsignedRoundsUp(rounding) && 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
* towards zero.
*
* 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}
src/navvaults/math/NavFeeMath.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.25;
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { NavTypes } from "../types/NavTypes.sol";
/// @notice Share-denominated fee attribution, with a persistent management-accrual remainder.
library NavFeeMath {
uint256 internal constant BASIS_POINTS = 10_000;
uint256 internal constant MANAGEMENT_FEE_DENOMINATOR = BASIS_POINTS * 365 days;
error InvalidAccounting();
struct Input {
uint256 grossAssets;
uint256 underlyingShares;
uint256 supply;
uint256 feeSharesR;
uint256 previousNetAssets;
uint256 highWaterMark;
uint256 priceScale;
uint256 elapsed;
uint256 remainder;
uint16 managementBps;
uint16 performanceBps;
}
function accrue(Input memory input) internal pure returns (NavTypes.Accrual memory accrual) {
accrual.highWaterMark = input.highWaterMark;
accrual.remainder = input.remainder;
uint256 totalUnderlyingSharesRay = input.underlyingShares * NavTypes.RAY;
if (input.feeSharesR > totalUnderlyingSharesRay) {
revert InvalidAccounting();
}
if (input.supply == 0 || input.underlyingShares == 0 || input.grossAssets == 0) {
return accrual;
}
// 1. Charge elapsed management fees on the previous net asset checkpoint.
(accrual.managementSharesR, accrual.remainder) = _managementFee(input);
uint256 userUnderlyingSharesRay = totalUnderlyingSharesRay - input.feeSharesR;
if (accrual.managementSharesR >= userUnderlyingSharesRay && accrual.managementSharesR != 0)
{
revert InvalidAccounting();
}
userUnderlyingSharesRay -= accrual.managementSharesR;
uint256 assetsAfterManagementFee =
Math.mulDiv(input.grossAssets, userUnderlyingSharesRay, totalUnderlyingSharesRay);
// 2. Charge performance fees only on gains above the high-water mark, after management.
uint256 highWaterMarkAssets =
Math.mulDiv(input.highWaterMark, input.supply, input.priceScale, Math.Rounding.Ceil);
if (input.highWaterMark != 0 && assetsAfterManagementFee > highWaterMarkAssets) {
uint256 performanceAssetsRay = Math.mulDiv(
(assetsAfterManagementFee - highWaterMarkAssets) * NavTypes.RAY,
input.performanceBps,
BASIS_POINTS
);
accrual.performanceSharesR =
Math.mulDiv(performanceAssetsRay, input.underlyingShares, input.grossAssets);
}
// 3. Value the shares still owned by users and advance the high-water mark.
userUnderlyingSharesRay -= accrual.performanceSharesR;
accrual.netAssets =
Math.mulDiv(input.grossAssets, userUnderlyingSharesRay, totalUnderlyingSharesRay);
accrual.highWaterMark = Math.max(
input.highWaterMark,
Math.mulDiv(accrual.netAssets, input.priceScale, input.supply, Math.Rounding.Ceil)
);
}
function managementFeeExhaustsBacking(Input memory input) internal pure returns (bool) {
uint256 totalUnderlyingSharesRay = input.underlyingShares * NavTypes.RAY;
if (input.feeSharesR > totalUnderlyingSharesRay) revert InvalidAccounting();
if (input.supply == 0 || input.underlyingShares == 0 || input.grossAssets == 0) {
return false;
}
(uint256 managementSharesR,) = _managementFee(input);
return
managementSharesR != 0
&& managementSharesR >= totalUnderlyingSharesRay - input.feeSharesR;
}
function _managementFee(Input memory input)
private
pure
returns (uint256 managementSharesR, uint256 remainder)
{
uint256 managementRateSeconds = uint256(input.managementBps) * input.elapsed;
uint256 managementAssetsRay = Math.mulDiv(
input.previousNetAssets * NavTypes.RAY,
managementRateSeconds,
MANAGEMENT_FEE_DENOMINATOR
);
uint256 managementRemainder = mulmod(
input.previousNetAssets * NavTypes.RAY,
managementRateSeconds,
MANAGEMENT_FEE_DENOMINATOR
) + input.remainder;
managementAssetsRay += managementRemainder / MANAGEMENT_FEE_DENOMINATOR;
remainder = managementRemainder % MANAGEMENT_FEE_DENOMINATOR;
managementSharesR =
Math.mulDiv(managementAssetsRay, input.underlyingShares, input.grossAssets);
}
}
src/navvaults/types/NavTypes.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.25;
/// @notice Shared units: assets and shares are raw token units; the R suffix denotes raw shares scaled by RAY (1e27).
library NavTypes {
uint16 internal constant MAX_MANAGEMENT_BPS = 5000;
uint16 internal constant MAX_PERFORMANCE_BPS = 5000;
uint16 internal constant ABSOLUTE_MAX_PERFORMANCE_BPS = 10_000;
uint256 internal constant RAY = 1e27;
uint256 internal constant MAX_ACCOUNTING = type(uint128).max;
enum Operation {
Deposit,
Mint,
Withdraw,
Redeem
}
enum LimitState {
Bounded,
Unbounded,
Unknown,
Disabled
}
enum Assessment {
Pass,
Reject,
SimulationRequired
}
enum ValuationStatus {
Valid,
Empty,
Unavailable
}
struct FeeConfig {
uint16 managementBps;
uint16 performanceBps;
address recipient;
}
struct Init {
address underlying;
address lens;
address admin;
address pauser;
address recoveryTreasury;
string name;
string symbol;
FeeConfig fees;
}
struct Capacity {
LimitState state;
uint256 executableAssets;
bytes32 reason;
bytes32 configHash;
}
struct Quote {
uint256 inputRaw;
uint256 outputRaw;
Capacity capacity;
Assessment assessment;
uint256 netNavRay;
uint64 evaluatedAt;
}
/// @dev Exactly four persistent slots. All narrowing follows MAX_ACCOUNTING checks.
struct Accounting {
uint128 underlyingSharesRaw;
uint128 activeNetAssetsRaw;
uint256 feeUnderlyingSharesR;
uint256 highWaterMarkRay;
uint128 currentSupplyRaw;
uint64 checkpointAt;
uint40 managementRemainder;
}
/// @notice Live read DTO, never persisted. Unavailable values are not execution quotes.
struct Snapshot {
uint256 netNavRay;
uint256 activeNetAssetsRaw;
uint256 activeGrossAssetsRaw;
uint256 currentSupplyRaw;
uint256 underlyingSharesRaw;
uint256 feeUnderlyingSharesR;
uint256 highWaterMarkRay;
uint64 evaluatedAt;
uint64 checkpointAt;
ValuationStatus valuationStatus;
}
/// @dev Compact result of live valuation. Observation metadata stays in the vault.
struct Valuation {
uint256 grossAssets;
uint256 netAssets;
uint256 netNavRay;
uint256 highWaterMark;
uint256 managementSharesR;
uint256 performanceSharesR;
uint256 remainder;
}
struct Accrual {
uint256 managementSharesR;
uint256 performanceSharesR;
uint256 remainder;
uint256 netAssets;
uint256 highWaterMark;
}
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 1,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.