Skip to main content

Collateral

Overview

Used for minting and redeeming prePO Collateral tokens. A Collateral token is a share of a yield-bearing vault, its Base Token value varying based on the current value of the vault's assets.

Functions

deposit

  function deposit(
uint256 amount
) external returns (uint256)

Mints Collateral tokens for amount Base Token.

Assumes approval has been given by the user for the Collateral contract to spend their funds.

Parameters:

NameTypeDescription
amountuint256The amount of Base Token to deposit

initiateWithdrawal

  function initiateWithdrawal(
uint256 amount
) external

Creates a request to allow a withdrawal for amount Collateral in a later block.

The user's balance must be >= the amount requested to initiate a withdrawal. If this function is called when there is already an existing withdrawal request, the existing request is overwritten with the new amount and current block number.

Parameters:

NameTypeDescription
amountuint256The amount of Collateral to withdraw

uninitiateWithdrawal

  function uninitiateWithdrawal(
) external

Resets the existing withdrawal request on record for the caller.

This call will not revert if a user doesn't have an existing request and will simply reset the user's already empty request record.

withdraw

  function withdraw(
uint256 amount
) external returns (uint256)

Burns amount Collateral tokens in exchange for Base Token.

If delayedWithdrawalExpiry is non-zero, a withdrawal request must be initiated in a prior block no more than delayedWithdrawalExpiry blocks before. The amount specified in the request must match the amount being withdrawn.

Parameters:

NameTypeDescription
amountuint256The amount of Collateral to burn

setDepositsAllowed

  function setDepositsAllowed(
bool allowed
) external

Sets whether deposits to the Collateral vault are allowed.

Only callable by owner().

Parameters:

NameTypeDescription
allowedboolWhether deposits are allowed

setWithdrawalsAllowed

  function setWithdrawalsAllowed(
bool allowed
) external

Sets whether withdrawals from the Collateral vault are allowed.

Only callable by owner().

Parameters:

NameTypeDescription
allowedboolWhether withdrawals are allowed

setStrategyController

  function setStrategyController(
contract IStrategyController newController
) external

Sets the contract that controls which strategy funds are sent to.

Only callable by owner().

Parameters:

NameTypeDescription
newControllercontract IStrategyControllerAddress of a contract implementing IStrategyController

setDelayedWithdrawalExpiry

  function setDelayedWithdrawalExpiry(
uint256 expiry
) external

Sets the number of blocks to pass before expiring a withdrawal request.

If this is set to zero, withdrawal requests are ignored.

Only callable by owner().

Parameters:

NameTypeDescription
expiryuint256Blocks before expiring a withdrawal request

setMintingFee

  function setMintingFee(
uint256 newMintingFee
) external

Sets the fee for minting Collateral, must be a 4 decimal place percentage value e.g. 4.9999% = 49999.

Only callable by owner().

Parameters:

NameTypeDescription
newMintingFeeuint256The new fee for minting Collateral

setRedemptionFee

  function setRedemptionFee(
uint256 newRedemptionFee
) external

Sets the fee for redeeming Collateral, must be a 4 decimal place percentage value e.g. 4.9999% = 49999.

Only callable by owner().

Parameters:

NameTypeDescription
newRedemptionFeeuint256The new fee for redeeming Collateral

setDepositHook

  function setDepositHook(
contract IHook newDepositHook
) external

Sets the contract implementing IHook that will be called during the deposit() function.

Only callable by owner().

Parameters:

NameTypeDescription
newDepositHookcontract IHookAddress of a contract implementing IHook

setWithdrawHook

  function setWithdrawHook(
contract IHook newWithdrawHook
) external

Sets the contract implementing IHook that will be called during the withdraw() function.

Only callable by owner().

Parameters:

NameTypeDescription
newWithdrawHookcontract IHookAddress of a contract implementing IHook

getDepositsAllowed

  function getDepositsAllowed(
) external returns (bool)

getWithdrawalsAllowed

  function getWithdrawalsAllowed(
) external returns (bool)

getTreasury

  function getTreasury(
) external returns (address)

getMintingFee

  function getMintingFee(
) external returns (uint256)

Fee has four decimals places of percentage value precision e.g. 4.9999% = 49999.

getRedemptionFee

  function getRedemptionFee(
) external returns (uint256)

Fee has four decimals places of percentage value precision e.g. 4.9999% = 49999.

getBaseToken

  function getBaseToken(
) external returns (contract IERC20Upgradeable)

This asset will be required for minting Collateral, and returned when redeeming Collateral.

getStrategyController

  function getStrategyController(
) external returns (contract IStrategyController)

The Strategy Controller intermediates any interactions between this vault and a yield-earning strategy.

getDelayedWithdrawalExpiry

  function getDelayedWithdrawalExpiry(
) external returns (uint256)

getWithdrawalRequest

  function getWithdrawalRequest(
) external returns (struct ICollateral.WithdrawalRequest)

getDepositHook

  function getDepositHook(
) external returns (contract IHook)

getWithdrawHook

  function getWithdrawHook(
) external returns (contract IHook)

getAmountForShares

  function getAmountForShares(
uint256 shares
) external returns (uint256)

Gets the amount of Base Token received for redeeming shares Collateral.

Parameters:

NameTypeDescription
sharesuint256Amount of shares that would be redeemed

getSharesForAmount

  function getSharesForAmount(
uint256 amount
) external returns (uint256)

Parameters:

NameTypeDescription
amountuint256Amount of Base Token that would be deposited

totalAssets

  function totalAssets(
) external returns (uint256)

Returns the sum of the contract's latent Base Token balance and the estimated Base Token value of the strategy's assets.

This call relies on the totalValue() returned by the Strategy Controller. The Collateral vault trusts the Strategy Controller to relay an accurate value of the Strategy's assets.

getFeeDenominator

  function getFeeDenominator(
) external returns (uint256)

Returns the denominator for calculating fees from 4 decimal place percentage values e.g. 4.9999% = 49999.

getFeeLimit

  function getFeeLimit(
) external returns (uint256)

Returns the fee limit of 5% represented as 4 decimal place percentage value e.g. 4.9999% = 49999.

Events

DepositsAllowedChanged

  event DepositsAllowedChanged(
bool allowed
)

Emitted via setDepositsAllowed().

Parameters:

NameTypeDescription
allowedboolWhether deposits are allowed

WithdrawalsAllowedChanged

  event WithdrawalsAllowedChanged(
bool allowed
)

Emitted via setWithdrawalsAllowed().

Parameters:

NameTypeDescription
allowedboolWhether withdrawals are allowed

StrategyControllerChanged

  event StrategyControllerChanged(
address controller
)

Emitted via setStrategyController().

Parameters:

NameTypeDescription
controlleraddressThe address of the new Strategy Controller

MintingFeeChanged

  event MintingFeeChanged(
uint256 fee
)

Emitted via setMintingFee().

Parameters:

NameTypeDescription
feeuint256The new fee

RedemptionFeeChanged

  event RedemptionFeeChanged(
uint256 fee
)

Emitted via setRedemptionFee().

Parameters:

NameTypeDescription
feeuint256The new fee

DelayedWithdrawalChanged

  event DelayedWithdrawalChanged(
bool enabled
)

Emitted via setDelayedWithdrawal().

Parameters:

NameTypeDescription
enabledboolWhether or not delayed withdrawals are enabled

DelayedWithdrawalExpiryChanged

  event DelayedWithdrawalExpiryChanged(
uint256 expiry
)

Emitted via setDelayedWithdrawalExpiry().

Parameters:

NameTypeDescription
expiryuint256The new expiry

DepositHookChanged

  event DepositHookChanged(
address hook
)

Emitted via setDepositHook().

Parameters:

NameTypeDescription
hookaddressThe new deposit hook

WithdrawHookChanged

  event WithdrawHookChanged(
address hook
)

Emitted via setWithdrawalHook().

Parameters:

NameTypeDescription
hookaddressThe new withdraw hook