Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

TrancheVault

Git Source

Inherits: ERC4626

Title: TrancheVault

ERC4626 share token for a HousePool tranche (senior or junior). Routes all deposits/withdrawals through HousePool.

Note: security-contact: contact@plether.com

Constants

POOL

IHousePool public immutable POOL;

IS_SENIOR

bool public immutable IS_SENIOR;

DEPOSIT_COOLDOWN

uint256 public constant DEPOSIT_COOLDOWN = 1 hours;

State Variables

lastDepositTime

mapping(address => uint256) public lastDepositTime;

seedReceiver

address public seedReceiver;

seedShareFloor

uint256 public seedShareFloor;

Functions

constructor

constructor(
    IERC20 _usdc,
    address _pool,
    bool _isSenior,
    string memory _name,
    string memory _symbol
) ERC4626(_usdc) ERC20(_name, _symbol);

Parameters

NameTypeDescription
_usdcIERC20Underlying USDC token used as the vault asset
_pooladdressHousePool that holds USDC and manages the tranche waterfall
_isSeniorboolTrue for the senior tranche, false for junior
_namestringERC20 share token name
_symbolstringERC20 share token symbol

_decimalsOffset

Virtual share offset mitigates ERC4626 first-depositor inflation attack

function _decimalsOffset() internal pure override returns (uint8);

_update

Enforces a deposit cooldown on share transfers. Prevents flash-deposit-then-transfer to bypass the withdrawal cooldown. Propagates the sender’s cooldown to the receiver if it is more recent.

function _update(
    address from,
    address to,
    uint256 amount
) internal override;

totalAssets

Returns the tranche assets from the pending post-reconcile HousePool state.

function totalAssets() public view override returns (uint256);

deposit

Deposits assets into the tranche after reconciling pool accounting and lifecycle gates.

function deposit(
    uint256 assets,
    address receiver
) public override returns (uint256);

mint

Mints tranche shares after reconciling pool accounting and lifecycle gates.

function mint(
    uint256 shares,
    address receiver
) public override returns (uint256);

previewDeposit

function previewDeposit(
    uint256 assets
) public view override returns (uint256);

previewMint

function previewMint(
    uint256 shares
) public view override returns (uint256);

maxDeposit

Returns the current max deposit if lifecycle, freshness, and impairment gates allow deposits.

function maxDeposit(
    address receiver
) public view override returns (uint256);

maxMint

Returns the current max mint if lifecycle, freshness, and impairment gates allow deposits.

function maxMint(
    address receiver
) public view override returns (uint256);

withdraw

Withdraws tranche assets after reconciling pool accounting.

function withdraw(
    uint256 assets,
    address receiver,
    address _owner
) public override returns (uint256);

redeem

Redeems tranche shares after reconciling pool accounting.

function redeem(
    uint256 shares,
    address receiver,
    address _owner
) public override returns (uint256);

previewWithdraw

function previewWithdraw(
    uint256 assets
) public view override returns (uint256);

previewRedeem

function previewRedeem(
    uint256 shares
) public view override returns (uint256);

maxWithdraw

Returns the withdrawable asset amount after cooldown and pool-level withdrawal gates.

function maxWithdraw(
    address _owner
) public view override returns (uint256);

maxRedeem

Returns the redeemable share amount after cooldown and pool-level withdrawal gates.

function maxRedeem(
    address _owner
) public view override returns (uint256);

_deposit

function _deposit(
    address caller,
    address receiver,
    uint256 assets,
    uint256 shares
) internal override;

_withdraw

function _withdraw(
    address caller,
    address receiver,
    address _owner,
    uint256 assets,
    uint256 shares
) internal override;

bootstrapMint

Mints shares to explicitly bootstrap previously quarantined pool assets into this tranche.

Only the pool may call this. The pool must have already assigned matching assets to the tranche principal.

function bootstrapMint(
    uint256 shares,
    address receiver
) external;

configureSeedPosition

Registers or increases the permanent seed-share floor for this tranche.

The pool must mint the corresponding shares before or within the same flow.

function configureSeedPosition(
    address receiver,
    uint256 floorShares
) external;

_unlockedOwnerShares

function _unlockedOwnerShares(
    address _owner
) internal view returns (uint256 ownerShares);

_isTerminallyWiped

function _isTerminallyWiped() internal view returns (bool);

_requireActiveTranche

function _requireActiveTranche() internal view;

_requireLifecycleActiveForOrdinaryDeposit

function _requireLifecycleActiveForOrdinaryDeposit() internal view;

_ordinaryDepositsAllowed

function _ordinaryDepositsAllowed() internal view returns (bool);

_canDepositNow

function _canDepositNow() internal view returns (bool);

_frozenLpFeeBps

function _frozenLpFeeBps() internal view returns (uint256);

_applyFee

function _applyFee(
    uint256 grossAssets,
    uint256 feeBps
) internal pure returns (uint256);

_grossUpForFee

function _grossUpForFee(
    uint256 netAssets,
    uint256 feeBps
) internal pure returns (uint256);

_applyFeeToShares

function _applyFeeToShares(
    uint256 grossShares,
    uint256 feeBps
) internal pure returns (uint256);

_grossUpSharesForFee

function _grossUpSharesForFee(
    uint256 netShares,
    uint256 feeBps
) internal pure returns (uint256);

_previewFrozenDepositShares

function _previewFrozenDepositShares(
    uint256 assets,
    uint256 feeBps
) internal view returns (uint256);

_previewFrozenMintAssets

function _previewFrozenMintAssets(
    uint256 shares,
    uint256 feeBps
) internal view returns (uint256);

_maxFrozenMintShares

function _maxFrozenMintShares(
    uint256 feeBps
) internal view returns (uint256);

Errors

TrancheVault__DepositCooldown

error TrancheVault__DepositCooldown();

TrancheVault__TransferDuringCooldown

error TrancheVault__TransferDuringCooldown();

TrancheVault__TrancheImpaired

error TrancheVault__TrancheImpaired();

TrancheVault__ThirdPartyDepositForExistingHolder

error TrancheVault__ThirdPartyDepositForExistingHolder();

TrancheVault__NotPool

error TrancheVault__NotPool();

TrancheVault__SeedFloorBreached

error TrancheVault__SeedFloorBreached();

TrancheVault__InvalidSeedPosition

error TrancheVault__InvalidSeedPosition();

TrancheVault__TerminallyWiped

error TrancheVault__TerminallyWiped();

TrancheVault__TradingNotActive

error TrancheVault__TradingNotActive();