Skip to main content

PrizeVault

Git Source

Inherits: TwabERC20, Claimable, IERC4626, ILiquidationSource, Ownable

Author: G9 Software Inc.

The prize vault takes deposits of an asset and earns yield with the deposits through an underlying yield vault. The yield is then expected to be liquidated and contributed to the prize pool as prize tokens. The depositors of the prize vault will then be eligible to win prizes from the pool. If a prize is won, The permitted claimer contract for the prize vault will claim the prize on behalf of the winner. Depositors can also set custom hooks that are called directly before and after their prize is claimed.

Share balances are stored in the TwabController contract.

Depositors should always expect to be able to withdraw their full deposit amount and no more as long as global withdrawal limits meet or exceed their balance. However, if the underlying yield source loses assets, depositors will only be able to withdraw a proportional amount of remaining assets based on their share balance and the total debt balance.

*The prize vault is designed to embody the "no loss" spirit of PoolTogether, down to the last wei. Most ERC4626 yield vaults incur small, necessary rounding errors on deposit and withdrawal to ensure the internal accounting cannot be taken advantage of. The prize vault employs two strategies in an attempt to cover these rounding errors with yield to ensure that depositors can withdraw every last wei of their initial deposit:

  1. The "dust collection strategy": Rounding errors are directly related to the exchange rate of the underlying yield vault; the more assets a single yield vault share is worth, the more severe the rounding errors can become. For example, if the exchange rate is 100 assets for 1 yield vault share and we assume 0 decimal precision; if alice deposits 199 assets, the yield vault will round down on the conversion and mint alice 1 share, essentially donating the remaining 99 assets to the yield vault. This behavior can open pathways for exploits in the prize vault since a bad actor could repeatedly make deposits and withdrawals that result in large rounding errors and since the prize vault covers rounding errors with yield, the attacker could withdraw without loss while essentially donating the yield back to the yield vault. To mitigate this issue, the prize vault calculates the amount of yield vault shares that would be minted during a deposit, but mints those shares directly instead, ensuring that only the exact amount of assets needed are sent to the yield vault while keeping the remainder as a latent balance in the prize vault until it can be used in the next deposit or withdraw. An inverse strategy is also used when withdrawing assets from the yield vault. This reduces the possible rounding errors to just 1 wei per deposit or withdraw.
  2. The "yield buffer": Since the prize vault can still incur minimal rounding errors from the yield vault, a yield buffer is required to ensure that there is always enough yield reserved to cover the rounding errors on deposits and withdrawals. This buffer should never run dry during normal operating conditions and expected yield rates. If the yield buffer is ever depleted, new deposits will be prevented and the prize vault will enter a lossy withdrawal state where depositors will incur the rounding errors on withdraw.*

The prize vault does not support underlying yield vaults that take a fee on deposit or withdraw.

TWAB_SUPPLY_LIMIT

The TWAB supply limit is the max number of shares that can be minted in the TWAB controller.

uint256 constant TWAB_SUPPLY_LIMIT = type(uint96).max;

State Variables

FEE_PRECISION

The yield fee decimal precision.

uint32 public constant FEE_PRECISION = 1e9;

MAX_YIELD_FEE

The max yield fee that can be set.

Decimal precision is defined by FEE_PRECISION.

If the yield fee is set too high, liquidations won't occur on a regular basis. If a use case requires a yield fee higher than this max, a custom liquidation pair can be set to manipulate the yield as required.

uint32 public constant MAX_YIELD_FEE = 9e8;

yieldBuffer

The yield buffer that is reserved for covering rounding errors on withdrawals and deposits.

The buffer prevents the entire yield balance from being liquidated, which would leave the vault in a state where a single rounding error could reduce the totalAssets to less than the totalSupply. The yield buffer is expected to be of insignificant value and is used to cover rounding errors on deposits and withdrawals. Yield is expected to accrue faster than the yield buffer can be reasonably depleted. IT IS RECOMMENDED TO DONATE ASSETS DIRECTLY TO THE PRIZE VAULT AFTER DEPLOYMENT TO FILL THE YIELD BUFFER AND COVER ROUNDING ERRORS UNTIL THE DEPOSITS CAN GENERATE ENOUGH YIELD TO KEEP THE BUFFER FULL WITHOUT ASSISTANCE. The yield buffer should be set as high as possible while still being considered insignificant for the underlying asset. For example, a reasonable yield buffer for USDC with 6 decimals might be 1e5 (0.10),whichwillcoverupto100kroundingerrorswhilestillbeinganinsignificantvalue.Someassetsmaybeconsideredincompatiblewiththeprizevaultiftheyieldvaultincursroundingerrorsandtheunderlyingassethasalowprecisionperdollarratio.Precisionperdollar(PPD)canbecalculatedby:(10DECIMALS)/(0.10), which will cover up to 100k rounding errors while still being an insignificant value. Some assets may be considered incompatible with the prize vault if the yield vault incurs rounding errors and the underlying asset has a low precision per dollar ratio. Precision per dollar (PPD) can be calculated by: (10 ^ DECIMALS) / ( value of 1 asset). For example, USDC has a PPD of (10 ^ 6) / (1)=10e6p/1) = 10e6 p/. As a rule of thumb, assets with lower PPD than USDC should not be assumed to be compatible since the potential loss of a single unit rounding error is likely too high to be made up by yield at a reasonable rate. Actual results may vary based on expected gas costs, asset fluctuation, and yield accrual rates. If the underlying yield vault does not incur any rounding errors, then the yield buffer can be set to zero. If the yield buffer is depleted on the prize vault, new deposits will be prevented if it would result in a rounding error and any rounding errors incurred by withdrawals will not be covered by yield. The yield buffer will be replenished automatically as yield accrues.

uint256 public immutable yieldBuffer;

yieldVault

Address of the underlying ERC4626 vault generating yield.

IERC4626 public immutable yieldVault;

yieldFeePercentage

Yield fee percentage represented in integer format with decimal precision defined by FEE_PRECISION.

For example, if FEE_PRECISION were 1e9 a value of 1e7 = 0.01 = 1%.

uint32 public yieldFeePercentage;

yieldFeeRecipient

Address of the yield fee recipient.

address public yieldFeeRecipient;

yieldFeeBalance

The accrued yield fee balance that the fee recipient can claim as vault shares.

uint256 public yieldFeeBalance;

liquidationPair

Address of the liquidation pair used to liquidate yield for prize token.

address public liquidationPair;

_asset

Address of the underlying asset used by the Vault.

IERC20 private immutable _asset;

_underlyingDecimals

Underlying asset decimals.

uint8 private immutable _underlyingDecimals;

Functions

onlyLiquidationPair

Requires the caller to be the liquidation pair.

modifier onlyLiquidationPair();

onlyYieldFeeRecipient

Requires the caller to be the yield fee recipient.

modifier onlyYieldFeeRecipient();

constructor

Vault constructor

constructor(
string memory name_,
string memory symbol_,
IERC4626 yieldVault_,
PrizePool prizePool_,
address claimer_,
address yieldFeeRecipient_,
uint32 yieldFeePercentage_,
uint256 yieldBuffer_,
address owner_
) TwabERC20(name_, symbol_, prizePool_.twabController()) Claimable(prizePool_, claimer_) Ownable(owner_);

Parameters

NameTypeDescription
name_stringName of the ERC20 share minted by the vault
symbol_stringSymbol of the ERC20 share minted by the vault
yieldVault_IERC4626Address of the underlying ERC4626 vault in which assets are deposited to generate yield
prizePool_PrizePoolAddress of the PrizePool that computes prizes
claimer_addressAddress of the claimer
yieldFeeRecipient_addressAddress of the yield fee recipient
yieldFeePercentage_uint32Yield fee percentage
yieldBuffer_uint256Amount of yield to keep as a buffer
owner_addressAddress that will gain ownership of this contract

decimals

Returns the decimals places of the token.

function decimals() public view override(ERC20, IERC20Metadata) returns (uint8);

asset

function asset() external view returns (address);

totalAssets

The latent asset balance is included in the total asset count to account for the "dust collection strategy".

This function uses convertToAssets to ensure it does not revert, but may result in some approximation depending on the yield vault implementation.

function totalAssets() public view returns (uint256);

convertToShares

This function uses approximate total assets and should not be used for onchain conversions.

function convertToShares(uint256 _assets) external view returns (uint256);

convertToAssets

This function uses approximate total assets and should not be used for onchain conversions.

function convertToAssets(uint256 _shares) external view returns (uint256);

maxDeposit

Considers the TWAB mint limit

Returns zero if any deposit would result in a loss of assets

Returns zero if total assets cannot be determined

Returns zero if the yield buffer is less than half full. This is a safety precaution to ensure a deposit of the asset amount returned by this function cannot reasonably trigger a LossyDeposit revert in the deposit or mint functions if the yield buffer has been configured properly.

Any latent balance of assets in the prize vault will be swept in with the deposit as a part of the "dust collection strategy". This means that the max deposit must account for the latent balance by subtracting it from the max deposit available otherwise.

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

maxMint

Returns the same value as maxDeposit since shares and assets are 1:1 on mint

Returns zero if any deposit would result in a loss of assets

function maxMint(address _owner) external view returns (uint256);

maxWithdraw

The prize vault maintains a latent balance of assets as part of the "dust collection strategy". This latent balance are accounted for in the max withdraw limits.

Returns zero if total assets cannot be determined

function maxWithdraw(address _owner) external view returns (uint256);

maxRedeem

The prize vault maintains a latent balance of assets as part of the "dust collection strategy". This latent balance are accounted for in the max redeem limits.

Returns zero if total assets cannot be determined

function maxRedeem(address _owner) external view returns (uint256);

previewDeposit

function previewDeposit(uint256 _assets) public pure returns (uint256);

previewMint

function previewMint(uint256 _shares) public pure returns (uint256);

previewWithdraw

Reverts if totalAssets in the vault is zero

function previewWithdraw(uint256 _assets) public view returns (uint256);

previewRedeem

function previewRedeem(uint256 _shares) public view returns (uint256);

deposit

function deposit(uint256 _assets, address _receiver) external returns (uint256);

mint

function mint(uint256 _shares, address _receiver) external returns (uint256);

withdraw

function withdraw(uint256 _assets, address _receiver, address _owner) external returns (uint256);

redeem

function redeem(uint256 _shares, address _receiver, address _owner) external returns (uint256);

depositWithPermit

Approve underlying asset with permit, deposit into the Vault and mint Vault shares to _owner.

Can't be used to deposit on behalf of another user since permit does not accept a receiver parameter, meaning that anyone could reuse the signature and pass an arbitrary receiver to this function.

function depositWithPermit(uint256 _assets, address _owner, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s)
external
returns (uint256);

Parameters

NameTypeDescription
_assetsuint256Amount of assets to approve and deposit
_owneraddressAddress of the owner depositing _assets and signing the permit
_deadlineuint256Timestamp after which the approval is no longer valid
_vuint8V part of the secp256k1 signature
_rbytes32R part of the secp256k1 signature
_sbytes32S part of the secp256k1 signature

Returns

NameTypeDescription
<none>uint256Amount of Vault shares minted to _owner.

withdraw

Alternate flow for IERC4626.withdraw that reverts if the max share limit is exceeded.

function withdraw(uint256 _assets, address _receiver, address _owner, uint256 _maxShares) external returns (uint256);

Parameters

NameTypeDescription
_assetsuint256See IERC4626.withdraw
_receiveraddressSee IERC4626.withdraw
_owneraddressSee IERC4626.withdraw
_maxSharesuint256The max shares that can be burned for the withdrawal to succeed.

Returns

NameTypeDescription
<none>uint256The amount of shares burned for the withdrawal

redeem

Alternate flow for IERC4626.redeem that reverts if the assets returned does not reach the minimum asset threshold.

function redeem(uint256 _shares, address _receiver, address _owner, uint256 _minAssets) external returns (uint256);

Parameters

NameTypeDescription
_sharesuint256See IERC4626.redeem
_receiveraddressSee IERC4626.redeem
_owneraddressSee IERC4626.redeem
_minAssetsuint256The minimum assets that can be returned for the redemption to succeed

Returns

NameTypeDescription
<none>uint256The amount of assets returned for the redemption

totalDebt

Returns the total assets that are owed to share holders and any other internal balances.

function totalDebt() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total asset debt of the vault

totalPreciseAssets

Calculates the amount of assets the vault controls based on current onchain conditions.

The latent asset balance is included in the total asset count to account for the "dust collection strategy".

This function should be favored over totalAssets for state-changing functions since it uses previewRedeem over convertToAssets.

May revert for reasons that would cause yieldVault.previewRedeem to revert.

function totalPreciseAssets() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total assets controlled by the vault based on current onchain conditions

totalYieldBalance

Total yield balance of the vault

Equal to total assets minus total debt

function totalYieldBalance() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total yield balance

availableYieldBalance

Total available yield on the vault

Equal to total assets minus total allocation (total debt + yield buffer)

function availableYieldBalance() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The available yield balance

currentYieldBuffer

Current amount of assets available in the yield buffer

function currentYieldBuffer() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The available assets in the yield buffer

claimYieldFeeShares

Transfers yield fee shares to the yield fee recipient

Emits a ClaimYieldFeeShares event

Will revert if the caller is not the yield fee recipient or if zero shares are withdrawn

function claimYieldFeeShares(uint256 _shares) external onlyYieldFeeRecipient;

Parameters

NameTypeDescription
_sharesuint256The shares to mint to the yield fee recipient

liquidatableBalanceOf

Get the available amount of tokens that can be swapped.

Returns the liquid amount of _tokenOut minus any yield fees.

Supports the liquidation of either assets or prize vault shares.

function liquidatableBalanceOf(address _tokenOut) external view returns (uint256);

Parameters

NameTypeDescription
_tokenOutaddress

Returns

NameTypeDescription
<none>uint256uint256 Available amount of token

transferTokensOut

Transfers tokens to the receiver

Emits a TransferYieldOut event

Supports the liquidation of either assets or prize vault shares.

function transferTokensOut(address, address _receiver, address _tokenOut, uint256 _amountOut)
external
virtual
onlyLiquidationPair
returns (bytes memory);

Parameters

NameTypeDescription
<none>address
_receiveraddress
_tokenOutaddress
_amountOutuint256

verifyTokensIn

Verifies that tokens have been transferred in.

function verifyTokensIn(address _tokenIn, uint256 _amountIn, bytes calldata) external onlyLiquidationPair;

Parameters

NameTypeDescription
_tokenInaddress
_amountInuint256
<none>bytes

targetOf

Get the address that will receive tokenIn.

function targetOf(address) external view returns (address);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>addressaddress Address of the target

isLiquidationPair

Checks if a liquidation pair can be used to liquidate the given tokenOut from this source.

function isLiquidationPair(address _tokenOut, address _liquidationPair) external view returns (bool);

Parameters

NameTypeDescription
_tokenOutaddress
_liquidationPairaddress

Returns

NameTypeDescription
<none>boolbool True if the liquidation pair can be used, false otherwise

setClaimer

Set claimer.

function setClaimer(address _claimer) external onlyOwner;

Parameters

NameTypeDescription
_claimeraddressAddress of the claimer

setLiquidationPair

Set liquidationPair.

Emits a LiquidationPairSet event

function setLiquidationPair(address _liquidationPair) external onlyOwner;

Parameters

NameTypeDescription
_liquidationPairaddressNew liquidationPair address

setYieldFeePercentage

Set yield fee percentage.

Yield fee is defined on a scale from 0 to FEE_PRECISION, inclusive.

function setYieldFeePercentage(uint32 _yieldFeePercentage) external onlyOwner;

Parameters

NameTypeDescription
_yieldFeePercentageuint32The new yield fee percentage to set

setYieldFeeRecipient

Set fee recipient.

function setYieldFeeRecipient(address _yieldFeeRecipient) external onlyOwner;

Parameters

NameTypeDescription
_yieldFeeRecipientaddressAddress of the fee recipient

_tryGetAssetDecimals

Fetch decimals of the underlying asset.

A return value of false indicates that the attempt failed in some way.

function _tryGetAssetDecimals(IERC20 asset_) internal view returns (bool, uint8);

Parameters

NameTypeDescription
asset_IERC20Address of the underlying asset

Returns

NameTypeDescription
<none>boolTrue if the attempt was successful, false otherwise
<none>uint8Number of token decimals

_tryGetTotalPreciseAssets

Calculates the amount of assets the vault controls based on current onchain conditions.

Calls totalPreciseAssets externally so it can catch previewRedeem failures and return whether or not the call was successful.

function _tryGetTotalPreciseAssets() internal view returns (bool _success, uint256 _totalAssets);

Returns

NameTypeDescription
_successboolReturns true if totalAssets was successfully calculated and false otherwise
_totalAssetsuint256The total assets controlled by the vault based on current onchain conditions

_convertToShares

Converts assets to shares with the given vault state and rounding direction.

Returns zero if the vault is in a lossy state AND there are no more assets.

function _convertToShares(uint256 _assets, uint256 _totalAssets, uint256 _totalDebt, Math.Rounding _rounding)
internal
pure
returns (uint256);

Parameters

NameTypeDescription
_assetsuint256The assets to convert
_totalAssetsuint256The total assets that the vault controls
_totalDebtuint256The total debt the vault owes
_roundingMath.RoundingThe rounding direction for the conversion

Returns

NameTypeDescription
<none>uint256The resulting share balance

_convertToAssets

Converts shares to assets with the given vault state and rounding direction.

function _convertToAssets(uint256 _shares, uint256 _totalAssets, uint256 _totalDebt, Math.Rounding _rounding)
internal
pure
returns (uint256);

Parameters

NameTypeDescription
_sharesuint256The shares to convert
_totalAssetsuint256The total assets that the vault controls
_totalDebtuint256The total debt the vault owes
_roundingMath.RoundingThe rounding direction for the conversion

Returns

NameTypeDescription
<none>uint256The resulting asset balance

_mintLimit

Returns the shares that can be minted without exceeding the TwabController supply limit.

The TwabController limits the total supply for each vault.

function _mintLimit(uint256 _existingShares) internal pure returns (uint256);

Parameters

NameTypeDescription
_existingSharesuint256The current allocated prize vault shares (internal and external)

Returns

NameTypeDescription
<none>uint256The remaining shares that can be minted without exceeding TWAB limits

_enforceMintLimit

Verifies that the mint limit can support the new share balance.

Reverts if the mint limit is exceeded.

This MUST be called anytime there is a positive increase in the net total shares.

function _enforceMintLimit(uint256 _existingShares, uint256 _newShares) internal pure;

Parameters

NameTypeDescription
_existingSharesuint256The total existing prize vault shares (internal and external)
_newSharesuint256The new shares

_totalYieldBalance

Total yield balance of the vault (including the yield buffer).

function _totalYieldBalance(uint256 _totalAssets, uint256 totalDebt_) internal pure returns (uint256);

Parameters

NameTypeDescription
_totalAssetsuint256The total assets controlled by the vault
totalDebt_uint256The total asset debt owed

Returns

NameTypeDescription
<none>uint256The total yield balance

_availableYieldBalance

Available yield balance given the total assets and total share supply.

Subtracts the yield buffer from the total yield balance.

function _availableYieldBalance(uint256 _totalAssets, uint256 totalDebt_) internal view returns (uint256);

Parameters

NameTypeDescription
_totalAssetsuint256The total assets controlled by the vault
totalDebt_uint256The total asset debt owed

Returns

NameTypeDescription
<none>uint256The available yield balance

_depositAndMint

Deposits assets to the yield vault and mints shares

Emits a Deposit event.

Will revert if 0 shares are minted back to the receiver or if 0 assets are deposited.

Will revert if the deposit may result in the loss of funds.

function _depositAndMint(address _caller, address _receiver, uint256 _assets, uint256 _shares) internal;

Parameters

NameTypeDescription
_calleraddressThe caller of the deposit
_receiveraddressThe receiver of the deposit shares
_assetsuint256Amount of assets to deposit
_sharesuint256Amount of shares to mint

_burnAndWithdraw

Burns shares and withdraws assets from the underlying yield vault.

Emits a Withdraw event.

Will revert if 0 assets are withdrawn or if 0 shares are burned

function _burnAndWithdraw(address _caller, address _receiver, address _owner, uint256 _shares, uint256 _assets)
internal;

Parameters

NameTypeDescription
_calleraddressAddress of the caller
_receiveraddressAddress of the receiver of the assets
_owneraddressOwner of the shares
_sharesuint256Shares to burn
_assetsuint256Assets to withdraw

_maxYieldVaultWithdraw

Returns the max assets that can be withdrawn from the yield vault through this vault's _withdraw function.

This should be used over yieldVault.maxWithdraw when considering withdrawal limits since this function takes into account the yield vault redemption limits, which is necessary since the _withdraw function uses yieldVault.redeem instead of yieldVault.withdraw. Since we convert the max redeemable shares to assets rounding down, the yieldVault.previewWithdraw call in the _withdraw function is guaranteed to return less than or equal shares to the max yield vault redemption.

Returns zero if yieldVault.previewRedeem reverts.

function _maxYieldVaultWithdraw() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256The max assets that can be withdrawn from the yield vault.

_withdraw

Withdraws assets to the receiver while accounting for rounding errors.

function _withdraw(address _receiver, uint256 _assets) internal;

Parameters

NameTypeDescription
_receiveraddressThe receiver of the assets
_assetsuint256The assets to withdraw

_setYieldFeePercentage

Set yield fee percentage.

Yield fee is defined on a scale from 0 to MAX_YIELD_FEE, inclusive.

Emits a YieldFeePercentageSet event

function _setYieldFeePercentage(uint32 _yieldFeePercentage) internal;

Parameters

NameTypeDescription
_yieldFeePercentageuint32The new yield fee percentage to set

_setYieldFeeRecipient

Set yield fee recipient address.

Emits a YieldFeeRecipientSet event

function _setYieldFeeRecipient(address _yieldFeeRecipient) internal;

Parameters

NameTypeDescription
_yieldFeeRecipientaddressAddress of the fee recipient

Events

YieldFeeRecipientSet

Emitted when a new yield fee recipient has been set.

event YieldFeeRecipientSet(address indexed yieldFeeRecipient);

Parameters

NameTypeDescription
yieldFeeRecipientaddressAddress of the new yield fee recipient

YieldFeePercentageSet

Emitted when a new yield fee percentage has been set.

event YieldFeePercentageSet(uint256 yieldFeePercentage);

Parameters

NameTypeDescription
yieldFeePercentageuint256New yield fee percentage

TransferYieldOut

Emitted when yield is transferred out by the liquidation pair address.

event TransferYieldOut(
address indexed liquidationPair,
address indexed tokenOut,
address indexed recipient,
uint256 amountOut,
uint256 yieldFee
);

Parameters

NameTypeDescription
liquidationPairaddressThe liquidation pair address that initiated the transfer
tokenOutaddressThe token that was transferred out
recipientaddressThe recipient of the tokens
amountOutuint256The amount of tokens sent to the recipient
yieldFeeuint256The amount of shares accrued on the yield fee balance

ClaimYieldFeeShares

Emitted when yield fee shares are claimed by the yield fee recipient.

event ClaimYieldFeeShares(address indexed recipient, uint256 shares);

Parameters

NameTypeDescription
recipientaddressAddress receiving the fee shares
sharesuint256Amount of shares claimed

Errors

YieldVaultZeroAddress

Thrown when the Yield Vault is set to the zero address.

error YieldVaultZeroAddress();

OwnerZeroAddress

Thrown when the Owner is set to the zero address.

error OwnerZeroAddress();

WithdrawZeroAssets

Thrown when a withdrawal of zero assets on the yield vault is attempted

error WithdrawZeroAssets();

BurnZeroShares

Thrown when no shares are being burnt during a withdrawal of assets

error BurnZeroShares();

DepositZeroAssets

Thrown when zero assets are being deposited

error DepositZeroAssets();

MintZeroShares

Thrown when zero shares are being minted

error MintZeroShares();

ZeroTotalAssets

Thrown if totalAssets is zero during a withdraw

error ZeroTotalAssets();

LPZeroAddress

Thrown when the Liquidation Pair being set is the zero address.

error LPZeroAddress();

LiquidationAmountOutZero

Thrown during the liquidation process when the liquidation amount out is zero.

error LiquidationAmountOutZero();

CallerNotLP

Thrown during the liquidation process when the caller is not the liquidation pair contract.

error CallerNotLP(address caller, address liquidationPair);

Parameters

NameTypeDescription
calleraddressThe caller address
liquidationPairaddressThe LP address

CallerNotYieldFeeRecipient

Thrown if the caller is not the yield fee recipient when withdrawing yield fee shares.

error CallerNotYieldFeeRecipient(address caller, address yieldFeeRecipient);

Parameters

NameTypeDescription
calleraddressThe caller address
yieldFeeRecipientaddressThe yield fee recipient address

PermitCallerNotOwner

Thrown when the caller of a permit function is not the owner of the assets being permitted.

error PermitCallerNotOwner(address caller, address owner);

Parameters

NameTypeDescription
calleraddressThe address of the caller
owneraddressThe address of the owner

YieldFeePercentageExceedsMax

Thrown when the yield fee percentage being set exceeds the max yield fee allowed.

error YieldFeePercentageExceedsMax(uint256 yieldFeePercentage, uint256 maxYieldFeePercentage);

Parameters

NameTypeDescription
yieldFeePercentageuint256The yield fee percentage in integer format
maxYieldFeePercentageuint256The max yield fee percentage in integer format

SharesExceedsYieldFeeBalance

Thrown when the yield fee shares being withdrawn exceeds the available yieldFee Balance.

error SharesExceedsYieldFeeBalance(uint256 shares, uint256 yieldFeeBalance);

Parameters

NameTypeDescription
sharesuint256The shares being withdrawn
yieldFeeBalanceuint256The available yield fee shares

LiquidationTokenInNotPrizeToken

Thrown during the liquidation process when the token in is not the prize token.

error LiquidationTokenInNotPrizeToken(address tokenIn, address prizeToken);

Parameters

NameTypeDescription
tokenInaddressThe provided tokenIn address
prizeTokenaddressThe prize token address

LiquidationTokenOutNotSupported

Thrown during the liquidation process when the token out is not supported.

error LiquidationTokenOutNotSupported(address tokenOut);

Parameters

NameTypeDescription
tokenOutaddressThe provided tokenOut address

LiquidationExceedsAvailable

Thrown during the liquidation process if the total to withdraw is greater than the available yield.

error LiquidationExceedsAvailable(uint256 totalToWithdraw, uint256 availableYield);

Parameters

NameTypeDescription
totalToWithdrawuint256The total yield to withdraw
availableYielduint256The available yield

LossyDeposit

Thrown when a deposit results in a state where the total assets are less than the total share supply.

error LossyDeposit(uint256 totalAssets, uint256 totalSupply);

Parameters

NameTypeDescription
totalAssetsuint256The total assets controlled by the vault
totalSupplyuint256The total shares minted and internally accounted for by the vault

MintLimitExceeded

Thrown when the mint limit is exceeded after increasing an external or internal share balance.

error MintLimitExceeded(uint256 excess);

Parameters

NameTypeDescription
excessuint256The amount in excess over the limit

MaxSharesExceeded

Thrown when a withdraw call burns more shares than the max share limit provided.

error MaxSharesExceeded(uint256 shares, uint256 maxShares);

Parameters

NameTypeDescription
sharesuint256The shares burned by the withdrawal
maxSharesuint256The max share limit provided

MinAssetsNotReached

Thrown when a redeem call returns less assets than the min threshold provided.

error MinAssetsNotReached(uint256 assets, uint256 minAssets);

Parameters

NameTypeDescription
assetsuint256The assets provided by the redemption
minAssetsuint256The min asset threshold requested

FailedToGetAssetDecimals

Thrown when the underlying asset does not specify it's number of decimals.

error FailedToGetAssetDecimals(address asset);

Parameters

NameTypeDescription
assetaddressThe underlying asset that was checked