Skip to main content

CollateralDepositRecord

Overview

Enforces Collateral deposit caps.

Functions

recordDeposit

  function recordDeposit(
address sender,
uint256 finalAmount
) external

This function will be called by a Collateral hook before the fee is subtracted from the initial amount passed in.

Only callable by allowed hooks.

Reverts if the incoming deposit brings either total over their respective caps.

finalAmount is added to both the global and account-specific deposit totals.

Parameters:

NameTypeDescription
senderaddressThe account making the Collateral deposit
finalAmountuint256The amount actually deposited by the user

recordWithdrawal

  function recordWithdrawal(
address sender,
uint256 finalAmount
) external

Called by a Collateral hook before the fee is subtracted from the amount withdrawn from the Strategy.

finalAmount is subtracted from both the global and account-specific deposit totals.

Only callable by allowed hooks.

Parameters:

NameTypeDescription
senderaddressThe account making the Collateral withdrawal
finalAmountuint256The amount actually withdrawn by the user

setGlobalDepositCap

  function setGlobalDepositCap(
uint256 newGlobalDepositCap
) external

Sets the global cap on assets backing Collateral in circulation.

Only callable by owner().

Parameters:

NameTypeDescription
newGlobalDepositCapuint256The new global deposit cap

setAccountDepositCap

  function setAccountDepositCap(
uint256 newAccountDepositCap
) external

Sets the cap on net Base Token deposits per user.

Only callable by owner().

Parameters:

NameTypeDescription
newAccountDepositCapuint256The new account deposit cap

setAllowedHook

  function setAllowedHook(
address hook,
bool allowed
) external

Sets if a contract is allowed to record deposits and withdrawals.

Only callable by owner().

Parameters:

NameTypeDescription
hookaddressThe contract address
allowedboolWhether or not the contract will be allowed

getGlobalDepositCap

  function getGlobalDepositCap(
) external returns (uint256)

Gets the maximum Base Token amount that is allowed to be deposited (net of withdrawals).

Deposits are not allowed if globalDepositAmount exceeds the globalDepositCap.

getGlobalDepositAmount

  function getGlobalDepositAmount(
) external returns (uint256)

getAccountDepositCap

  function getAccountDepositCap(
) external returns (uint256)

An account will not be allowed to deposit if their net deposits exceed accountDepositCap.

getNetDeposit

  function getNetDeposit(
address account
) external returns (uint256)

Parameters:

NameTypeDescription
accountaddressThe account to retrieve net deposits for

isHookAllowed

  function isHookAllowed(
address hook
) external returns (bool)

Returns whether the contract is allowed to record deposits and withdrawals.

Parameters:

NameTypeDescription
hookaddressThe contract to retrieve allowed status for

Events

GlobalDepositCapChanged

  event GlobalDepositCapChanged(
uint256 amount
)

Emitted via setGlobalDepositCap().

Parameters:

NameTypeDescription
amountuint256New global deposit cap

AccountDepositCapChanged

  event AccountDepositCapChanged(
uint256 amount
)

Emitted via setAccountDepositCap().

Parameters:

NameTypeDescription
amountuint256New account deposit cap

AllowedHooksChanged

  event AllowedHooksChanged(
address hook,
bool allowed
)

Emitted via setAllowedHook().

Parameters:

NameTypeDescription
hookaddressHook with changed permissions
allowedboolWhether the hook is allowed