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

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

deposit

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

mint

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

maxDeposit

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

maxMint

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

withdraw

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

redeem

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

maxWithdraw

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

maxRedeem

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);

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();