Functions
Structs
Account
debt
int256
balances
mapping(address => uint256)
lastAccruedWeights
mapping(address => uint256)
depositedTokens
struct Sets.AddressSet
mintAllowances
mapping(address => uint256)
withdrawAllowances
mapping(address => mapping(address => uint256))
Functions
getYieldTokensPerShare
Gets the conversion rate of yield tokens per share.
Parameters:
yieldToken
address
The address of the yield token to get the conversion rate for.
Return Values:
rate
uint256
The rate of yield tokens per share.
getUnderlyingTokensPerShare
Gets the conversion rate of underlying tokens per share.
Parameters:
yieldToken
address
The address of the yield token to get the conversion rate for.
Return Values:
rate
uint256
The rate of underlying tokens per share.
getSupportedUnderlyingTokens
Gets the supported underlying tokens.
The order of the entries returned by this function is not guaranteed to be consistent between calls.
getSupportedYieldTokens
Gets the supported yield tokens.
The order of the entries returned by this function is not guaranteed to be consistent between calls.
isSupportedUnderlyingToken
Gets if an underlying token is supported.
Parameters:
underlyingToken
address
The address of the underlying token to check.
Return Values:
isSupported
bool
If the underlying token is supported.
isSupportedYieldToken
Gets if a yield token is supported.
Parameters:
yieldToken
address
The address of the yield token to check.
Return Values:
isSupported
bool
If the yield token is supported.
accounts
Gets information about the account owned by owner
.
Parameters:
owner
address
The address that owns the account.
Return Values:
debt
int256
The unrealized amount of debt that the account had incurred.
depositedTokens
address[]
The yield tokens that the owner has deposited.
positions
Gets information about a yield token position for the account owned by owner
.
Parameters:
owner
address
The address that owns the account.
yieldToken
address
The address of the yield token to get the position of.
Return Values:
shares
uint256
The amount of shares of that owner
owns of the yield token.
lastAccruedWeight
uint256
The last recorded accrued weight of the yield token.
mintAllowance
Gets the amount of debt tokens spender
is allowed to mint on behalf of owner
.
Parameters:
owner
address
The owner of the account.
spender
address
The address which is allowed to mint on behalf of owner
.
Return Values:
allowance
uint256
The amount of debt tokens that spender
can mint on behalf of owner
.
withdrawAllowance
Gets the amount of shares of yieldToken
that spender
is allowed to withdraw on behalf of owner
.
Parameters:
owner
address
The owner of the account.
spender
address
The address which is allowed to withdraw on behalf of owner
.
yieldToken
address
The address of the yield token.
Return Values:
allowance
uint256
The amount of shares that spender
can withdraw on behalf of owner
.
getUnderlyingTokenParameters
Gets the parameters of an underlying token.
Parameters:
underlyingToken
address
The address of the underlying token.
Return Values:
params
struct IAlchemistV2State.UnderlyingTokenParams
The underlying token parameters.
getYieldTokenParameters
Get the parameters and state of a yield-token.
Parameters:
yieldToken
address
The address of the yield token.
Return Values:
params
struct IAlchemistV2State.YieldTokenParams
The yield token parameters.
getMintLimitInfo
Gets current limit, maximum, and rate of the minting limiter.
getRepayLimitInfo
Gets current limit, maximum, and rate of a repay limiter for underlyingToken
.
Parameters:
underlyingToken
address
The address of the underlying token.
Return Values:
currentLimit
uint256
The current amount of underlying tokens that can be repaid.
rate
uint256
The rate at which the the current limit increases back to its maximum in tokens per block.
maximum
uint256
The maximum possible amount of tokens that can be repaid at a time.
getLiquidationLimitInfo
Gets current limit, maximum, and rate of the liquidation limiter for underlyingToken
.
Parameters:
underlyingToken
address
The address of the underlying token.
Return Values:
currentLimit
uint256
The current amount of underlying tokens that can be liquidated.
rate
uint256
The rate at which the function increases back to its maximum limit (tokens / block).
maximum
uint256
The highest possible maximum amount of debt tokens that can be liquidated at a time.
initialize
Initialize the contract.
params.protocolFee
must be in range or this call will with an {IllegalArgument} error. The minting growth limiter parameters must be valid or this will revert with an {IllegalArgument} error. For more information, see the {Limiters} library.
Emits an {AdminUpdated} event. Emits a {TransmuterUpdated} event. Emits a {MinimumCollateralizationUpdated} event. Emits a {ProtocolFeeUpdated} event. Emits a {ProtocolFeeReceiverUpdated} event. Emits a {MintingLimitUpdated} event.
Parameters:
params
struct IAlchemistV2AdminActions.InitializationParams
The contract initialization parameters.
setPendingAdmin
Sets the pending administrator.
msg.sender
must be the admin or this call will will revert with an {Unauthorized} error.
Emits a {PendingAdminUpdated} event.
This is the first step in the two-step process of setting a new administrator. After this function is called, the pending administrator will then need to call {acceptAdmin} to complete the process.
Parameters:
value
address
the address to set the pending admin to.
acceptAdmin
Allows for msg.sender
to accepts the role of administrator.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. The current pending administrator must be non-zero or this call will revert with an {IllegalState} error.
Emits a {AdminUpdated} event. Emits a {PendingAdminUpdated} event. This is the second step in the two-step process of setting a new administrator. After this function is successfully called, this pending administrator will be reset and the new administrator will be set.
setSentinel
Sets an address as a sentinel.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error.
Parameters:
sentinel
address
The address to set or unset as a sentinel.
flag
bool
A flag indicating of the address should be set or unset as a sentinel.
setKeeper
Sets an address as a keeper.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error.
Parameters:
keeper
address
The address to set or unset as a keeper.
flag
bool
A flag indicating of the address should be set or unset as a keeper.
addUnderlyingToken
Adds an underlying token to the system.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error.
Parameters:
underlyingToken
address
The address of the underlying token to add.
config
struct IAlchemistV2AdminActions.UnderlyingTokenConfig
The initial underlying token configuration.
addYieldToken
Adds a yield token to the system.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error.
Emits a {AddYieldToken} event. Emits a {TokenAdapterUpdated} event. Emits a {MaximumLossUpdated} event.
Parameters:
yieldToken
address
The address of the yield token to add.
config
struct IAlchemistV2AdminActions.YieldTokenConfig
The initial yield token configuration.
setUnderlyingTokenEnabled
Sets an underlying token as either enabled or disabled.
msg.sender
must be either the admin or a sentinel or this call will revert with an {Unauthorized} error. underlyingToken
must be registered or this call will revert with a {UnsupportedToken} error.
Emits an {UnderlyingTokenEnabled} event.
Parameters:
underlyingToken
address
The address of the underlying token to enable or disable.
enabled
bool
If the underlying token should be enabled or disabled.
setYieldTokenEnabled
Sets a yield token as either enabled or disabled.
msg.sender
must be either the admin or a sentinel or this call will revert with an {Unauthorized} error. yieldToken
must be registered or this call will revert with a {UnsupportedToken} error.
Emits a {YieldTokenEnabled} event.
Parameters:
yieldToken
address
The address of the yield token to enable or disable.
enabled
bool
If the underlying token should be enabled or disabled.
configureRepayLimit
Configures the the repay limit of underlyingToken
.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. underlyingToken
must be registered or this call will revert with a {UnsupportedToken} error.
Emits a {ReplayLimitUpdated} event.
Parameters:
underlyingToken
address
The address of the underlying token to configure the repay limit of.
maximum
uint256
The maximum repay limit.
blocks
uint256
The number of blocks it will take for the maximum repayment limit to be replenished when it is completely exhausted.
configureLiquidationLimit
Configure the liquidation limiter of underlyingToken
.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. underlyingToken
must be registered or this call will revert with a {UnsupportedToken} error.
Emits a {LiquidationLimitUpdated} event.
Parameters:
underlyingToken
address
The address of the underlying token to configure the liquidation limit of.
maximum
uint256
The maximum liquidation limit.
blocks
uint256
The number of blocks it will take for the maximum liquidation limit to be replenished when it is completely exhausted.
setTransmuter
Set the address of the transmuter.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. value
must be non-zero or this call will revert with an {IllegalArgument} error.
Emits a {TransmuterUpdated} event.
Parameters:
value
address
The address of the transmuter.
setMinimumCollateralization
Set the minimum collateralization ratio.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error.
Emits a {MinimumCollateralizationUpdated} event.
Parameters:
value
uint256
The new minimum collateralization ratio.
setProtocolFee
Sets the fee that the protocol will take from harvests.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. value
must be in range or this call will with an {IllegalArgument} error.
Emits a {ProtocolFeeUpdated} event.
Parameters:
value
uint256
The value to set the protocol fee to measured in basis points.
setProtocolFeeReceiver
Sets the address which will receive protocol fees.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. value
must be non-zero or this call will revert with an {IllegalArgument} error.
Emits a {ProtocolFeeReceiverUpdated} event.
Parameters:
value
address
The address to set the protocol fee receiver to.
configureMintingLimit
Configures the minting limiter.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error.
Emits a {MintingLimitUpdated} event.
Parameters:
maximum
uint256
The maximum minting limit.
blocks
uint256
The number of blocks it will take for the maximum minting limit to be replenished when it is completely exhausted.
configureCreditUnlockRate
Sets the rate at which credit will be completely available to depositors after it is harvested.
Emits a {CreditUnlockRateUpdated} event.
Parameters:
yieldToken
address
The address of the yield token to set the credit unlock rate for.
blocks
uint256
The number of blocks that it will take before the credit will be unlocked.
setTokenAdapter
Sets the token adapter of a yield token.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. The token that adapter
supports must be yieldToken
or this call will revert with a {IllegalState} error.
Emits a {TokenAdapterUpdated} event.
Parameters:
yieldToken
address
The address of the yield token to set the adapter for.
adapter
address
The address to set the token adapter to.
setMaximumExpectedValue
Sets the maximum expected value of a yield token that the system can hold.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. yieldToken
must be registered or this call will revert with a {UnsupportedToken} error.
Parameters:
yieldToken
address
The address of the yield token to set the maximum expected value for.
value
uint256
The maximum expected value of the yield token denoted measured in its underlying token.
setMaximumLoss
Sets the maximum loss that a yield bearing token will permit before restricting certain actions.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. yieldToken
must be registered or this call will revert with a {UnsupportedToken} error.
There are two types of loss of value for yield bearing assets: temporary or permanent. The system will automatically restrict actions which are sensitive to both forms of loss when detected. For example, deposits must be restricted when an excessive loss is encountered to prevent users from having their collateral harvested from them. While the user would receive credit, which then could be exchanged for value equal to the collateral that was harvested from them, it is seen as a negative user experience because the value of their collateral should have been higher than what was originally recorded when they made their deposit.
Parameters:
yieldToken
address
The address of the yield bearing token to set the maximum loss for.
value
uint256
The value to set the maximum loss to. This is in units of basis points.
snap
Snap the expected value yieldToken
to the current value.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. yieldToken
must be registered or this call will revert with a {UnsupportedToken} error.
This function should only be used in the event of a loss in the target yield-token. For example, say a third-party protocol experiences a fifty percent loss. The expected value (amount of underlying tokens) of the yield tokens being held by the system would be two times the real value that those yield tokens could be redeemed for. This function gives governance a way to realize those losses so that users can continue using the token as normal.
Parameters:
yieldToken
address
The address of the yield token to snap.
sweepTokens
Sweep all of 'rewardtoken' from the alchemist into the admin.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error. rewardToken
must not be a yield or underlying token or this call will revert with a {UnsupportedToken} error.
Parameters:
rewardToken
address
The address of the reward token to snap.
amount
uint256
The amount of 'rewardToken' to sweep to the admin.
setTransferAdapterAddress
Set the address of the V1 transfer adapter.
msg.sender
must be the admin or this call will revert with an {Unauthorized} error.
Parameters:
transferAdapterAddress
address
The address of the V1 transfer adapter to be set in the alchemist.
transferDebtV1
Accept debt from the V1 transfer vault adapter.
msg.sender
must be a sentinal or the admin or this call will revert with an {Unauthorized} error.
Parameters:
owner
address
The owner of the account whos debt to increase.
debt
int256
The amount of debt incoming from the V1 tranfer adapter.
approveMint
Approve spender
to mint amount
debt tokens.
NOTE: This function is WHITELISTED.
Parameters:
spender
address
The address that will be approved to mint.
amount
uint256
The amount of tokens that spender
will be allowed to mint.
approveWithdraw
Approve spender
to withdraw amount
shares of yieldToken
.
NOTE: This function is WHITELISTED.
Parameters:
spender
address
The address that will be approved to withdraw.
yieldToken
address
The address of the yield token that spender
will be allowed to withdraw.
shares
uint256
The amount of shares that spender
will be allowed to withdraw.
poke
Synchronizes the state of the account owned by owner
.
Parameters:
owner
address
The owner of the account to synchronize.
deposit
Deposit a yield token into a user's account.
An approval must be set for yieldToken
which is greater than amount
.
yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. yieldToken
must be enabled or this call will revert with a {TokenDisabled} error. yieldToken
underlying token must be enabled or this call will revert with a {TokenDisabled} error. recipient
must be non-zero or this call will revert with an {IllegalArgument} error. amount
must be greater than zero or the call will revert with an {IllegalArgument} error.
Emits a {Deposit} event.
NOTE: This function is WHITELISTED.
NOTE: When depositing, the AlchemistV2
contract must have allowance() to spend funds on behalf of msg.sender for at least amount of the yieldToken being deposited. This can be done via the standard ERC20.approve()
method.
Example:
Parameters:
yieldToken
address
The yield-token to deposit.
amount
uint256
The amount of yield tokens to deposit.
recipient
address
The owner of the account that will receive the resulting shares.
Return Values:
sharesIssued
uint256
The number of shares issued to recipient
.
depositUnderlying
Deposit an underlying token into the account of recipient
as yieldToken
.
An approval must be set for the underlying token of yieldToken
which is greater than amount
.
yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. recipient
must be non-zero or this call will revert with an {IllegalArgument} error. amount
must be greater than zero or the call will revert with an {IllegalArgument} error.
Emits a {Deposit} event.
NOTE: This function is WHITELISTED. NOTE: When depositing, the AlchemistV2
contract must have allowance() to spend funds on behalf of msg.sender for at least amount of the underlyingToken being deposited. This can be done via the standard ERC20.approve()
method.
Example:
Parameters:
yieldToken
address
The address of the yield token to wrap the underlying tokens into.
amount
uint256
The amount of the underlying token to deposit.
recipient
address
The address of the recipient.
minimumAmountOut
uint256
The minimum amount of yield tokens that are expected to be deposited to recipient
.
Return Values:
sharesIssued
uint256
The number of shares issued to recipient
.
withdraw
Withdraw yield tokens to recipient
by burning share
shares. The number of yield tokens withdrawn to recipient
will depend on the value of shares for that yield token at the time of the call.
yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. recipient
must be non-zero or this call will revert with an {IllegalArgument} error.
Emits a {Withdraw} event.
NOTE: This function is WHITELISTED.
Example:
Parameters:
yieldToken
address
The address of the yield token to withdraw.
shares
uint256
The number of shares to burn.
recipient
address
The address of the recipient.
Return Values:
amountWithdrawn
uint256
The number of yield tokens that were withdrawn to recipient
.
withdrawFrom
Withdraw yield tokens to recipient
by burning share
shares from the account of owner
owner
must have an withdrawal allowance which is greater than amount
for this call to succeed.
yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. recipient
must be non-zero or this call will revert with an {IllegalArgument} error.
Emits a {Withdraw} event.
NOTE: This function is WHITELISTED.
Example:
Parameters:
owner
address
The address of the account owner to withdraw from.
yieldToken
address
The address of the yield token to withdraw.
shares
uint256
The number of shares to burn.
recipient
address
The address of the recipient.
Return Values:
amountWithdrawn
uint256
The number of yield tokens that were withdrawn to recipient
.
withdrawUnderlying
Withdraw underlying tokens to recipient
by burning share
shares and unwrapping the yield tokens that the shares were redeemed for.
yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. recipient
must be non-zero or this call will revert with an {IllegalArgument} error. The loss in expected value of yieldToken
must be less than the maximum permitted by the system or this call will revert with a {LossExceeded} error.
Emits a {Withdraw} event.
NOTE: This function is WHITELISTED. NOTE: The caller of withdrawFrom()
must have withdrawAllowance() to withdraw funds on behalf of owner for at least the amount of yieldTokens
that shares will be converted to. This can be done via the approveWithdraw()
or permitWithdraw()
methods.
Example:
Parameters:
yieldToken
address
The address of the yield token to withdraw.
shares
uint256
The number of shares to burn.
recipient
address
The address of the recipient.
minimumAmountOut
uint256
The minimum amount of underlying tokens that are expected to be withdrawn to recipient
.
Return Values:
amountWithdrawn
uint256
The number of underlying tokens that were withdrawn to recipient
.
withdrawUnderlyingFrom
Withdraw underlying tokens to recipient
by burning share
shares from the account of owner
and unwrapping the yield tokens that the shares were redeemed for.
yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. recipient
must be non-zero or this call will revert with an {IllegalArgument} error. The loss in expected value of yieldToken
must be less than the maximum permitted by the system or this call will revert with a {LossExceeded} error.
Emits a {Withdraw} event.
NOTE: This function is WHITELISTED. NOTE: The caller of withdrawFrom()
must have withdrawAllowance() to withdraw funds on behalf of owner for at least the amount of yieldTokens
that shares will be converted to. This can be done via the approveWithdraw()
or permitWithdraw()
methods.
Example:
Parameters:
owner
address
The address of the account owner to withdraw from.
yieldToken
address
The address of the yield token to withdraw.
shares
uint256
The number of shares to burn.
recipient
address
The address of the recipient.
minimumAmountOut
uint256
The minimum amount of underlying tokens that are expected to be withdrawn to recipient
.
Return Values:
amountWithdrawn
uint256
The number of underlying tokens that were withdrawn to recipient
.
mint
Mint amount
debt tokens.
recipient
must be non-zero or this call will revert with an {IllegalArgument} error. amount
must be greater than zero or this call will revert with a {IllegalArgument} error.
Emits a {Mint} event.
NOTE: This function is WHITELISTED.
Example:
Parameters:
amount
uint256
The amount of tokens to mint.
recipient
address
The address of the recipient.
mintFrom
Mint amount
debt tokens from the account owned by owner
to recipient
.
recipient
must be non-zero or this call will revert with an {IllegalArgument} error. amount
must be greater than zero or this call will revert with a {IllegalArgument} error.
Emits a {Mint} event.
NOTE: This function is WHITELISTED. NOTE: The caller of mintFrom()
must have mintAllowance() to mint debt from the Account
controlled by owner for at least the amount of yieldTokens that shares will be converted to. This can be done via the approveMint()
or permitMint()
methods.
Example:
Parameters:
owner
address
The address of the owner of the account to mint from.
amount
uint256
The amount of tokens to mint.
recipient
address
The address of the recipient.
burn
Burn amount
debt tokens to credit the account owned by recipient
.
amount
will be limited up to the amount of debt that recipient
currently holds.
recipient
must be non-zero or this call will revert with an {IllegalArgument} error. amount
must be greater than zero or this call will revert with a {IllegalArgument} error. recipient
must have non-zero debt or this call will revert with an {IllegalState} error.
Emits a {Burn} event.
NOTE: This function is WHITELISTED.
Example:
Parameters:
amount
uint256
The amount of tokens to burn.
recipient
address
The address of the recipient.
Return Values:
amountBurned
uint256
The amount of tokens that were burned.
repay
Repay amount
debt using underlyingToken
to credit the account owned by recipient
.
amount
will be limited up to the amount of debt that recipient
currently holds.
amount
must be greater than zero or this call will revert with a {IllegalArgument} error. recipient
must be non-zero or this call will revert with an {IllegalArgument} error. underlyingToken
must be enabled or this call will revert with a {TokenDisabled} error. amount
must be less than or equal to the current available repay limit or this call will revert with a {ReplayLimitExceeded} error.
Emits a {Repay} event. NOTE: This function is WHITELISTED.
Example:
Parameters:
underlyingToken
address
The address of the underlying token to repay.
amount
uint256
The amount of the underlying token to repay.
recipient
address
The address of the recipient which will receive credit.
Return Values:
amountRepaid
uint256
The amount of tokens that were repaid.
liquidate
@notice
shares
will be limited up to an equal amount of debt that recipient
currently holds.
shares
must be greater than zero or this call will revert with a {IllegalArgument} error. yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. yieldToken
must be enabled or this call will revert with a {TokenDisabled} error. yieldToken
underlying token must be enabled or this call will revert with a {TokenDisabled} error. The loss in expected value of yieldToken
must be less than the maximum permitted by the system or this call will revert with a {LossExceeded} error. amount
must be less than or equal to the current available liquidation limit or this call will revert with a {LiquidationLimitExceeded} error.
Emits a {Liquidate} event.
NOTE: This function is WHITELISTED.
Example:
Parameters:
yieldToken
address
The address of the yield token to liquidate.
shares
uint256
The number of shares to burn for credit.
minimumAmountOut
uint256
The minimum amount of underlying tokens that are expected to be liquidated.
Return Values:
sharesLiquidated
uint256
The amount of shares that were liquidated.
donate
Burns amount
debt tokens to credit accounts which have deposited yieldToken
.
amount
must be greater than zero or this call will revert with a {IllegalArgument} error. yieldToken
must be registered or this call will revert with a {UnsupportedToken} error.
Emits a {Donate} event.
NOTE: This function is WHITELISTED.
Example:
Parameters:
yieldToken
address
The address of the yield token to credit accounts for.
amount
uint256
The amount of debt tokens to burn.
harvest
Harvests outstanding yield that a yield token has accumulated and distributes it as credit to holders.
msg.sender
must be a keeper or this call will revert with an {Unauthorized} error. yieldToken
must be registered or this call will revert with a {UnsupportedToken} error. The amount being harvested must be greater than zero or else this call will revert with an {IllegalState} error.
Emits a {Harvest} event.
Parameters:
yieldToken
address
The address of the yield token to harvest.
minimumAmountOut
uint256
The minimum amount of underlying tokens that are expected to be withdrawn to recipient
.
_onlyAdmin
Checks that the msg.sender
is the administrator.
msg.sender
must be the administrator or this call will revert with an {Unauthorized} error.
_onlySentinelOrAdmin
Checks that the msg.sender
is the administrator or a sentinel.
msg.sender
must be either the administrator or a sentinel or this call will revert with an {Unauthorized} error.
_onlyKeeper
Checks that the msg.sender
is a keeper.
msg.sender
must be a keeper or this call will revert with an {Unauthorized} error.
_onlyTransferAdapter
Checks that the msg.sender
is the V1 transfer adapter.
msg.sender
must be the administrator or this call will revert with an {Unauthorized} error.
_preemptivelyHarvestDeposited
Preemptively harvests all of the yield tokens that have been deposited into an account.
Parameters:
owner
address
The address which owns the account.
_preemptivelyHarvest
Preemptively harvests yieldToken
.
This will earmark yield tokens to be harvested at a future time when the current value of the token is greater than the expected value. The purpose of this function is to synchronize the balance of the yield token which is held by users versus tokens which will be seized by the protocol.
Parameters:
yieldToken
address
The address of the yield token to preemptively harvest.
_checkYieldTokenEnabled
Checks if a yield token is enabled.
Parameters:
yieldToken
address
The address of the yield token.
_checkUnderlyingTokenEnabled
Checks if an underlying token is enabled.
Parameters:
underlyingToken
address
The address of the underlying token.
_checkSupportedYieldToken
Checks if an address is a supported yield token.
If the address is not a supported yield token, this function will revert using a {UnsupportedToken} error.
Parameters:
yieldToken
address
The address to check.
_checkSupportedUnderlyingToken
Checks if an address is a supported underlying token.
If the address is not a supported yield token, this function will revert using a {UnsupportedToken} error.
Parameters:
underlyingToken
address
The address to check.
_checkMintingLimit
Checks if amount
of debt tokens can be minted.
amount
must be less than the current minting limit or this call will revert with a {MintingLimitExceeded} error.
Parameters:
amount
uint256
The amount to check.
_checkLoss
Checks if the current loss of yieldToken
has exceeded its maximum acceptable loss.
The loss that yieldToken
has incurred must be less than its maximum accepted value or this call will revert with a {LossExceeded} error.
Parameters:
yieldToken
address
The address of the yield token.
_deposit
Deposits amount
yield tokens into the account of recipient
.
Emits a {Deposit} event.
Parameters:
yieldToken
address
The address of the yield token to deposit.
amount
uint256
The amount of yield tokens to deposit.
recipient
address
The recipient of the yield tokens.
Return Values:
The
uint256
number of shares minted to recipient
.
_withdraw
Withdraw yieldToken
from the account owned by owner
by burning shares and receiving yield tokens of equivalent value.
Emits a {Withdraw} event.
Parameters:
yieldToken
address
The address of the yield token to withdraw.
owner
address
The address of the account owner to withdraw from.
shares
uint256
The number of shares to burn.
recipient
address
The recipient of the withdrawn shares. This parameter is only used for logging.
Return Values:
The
uint256
amount of yield tokens that the burned shares were exchanged for.
_mint
Mints debt tokens to recipient
using the account owned by owner
.
Emits a {Mint} event.
Parameters:
owner
address
The owner of the account to mint from.
amount
uint256
The amount to mint.
recipient
address
The recipient of the minted debt tokens.
_sync
Synchronizes the active balance and expected value of yieldToken
.
Parameters:
yieldToken
address
The address of the yield token.
amount
uint256
The amount to add or subtract from the debt.
operation
function (uint256,uint256) pure returns (uint256)
The mathematical operation to perform for the update. Either one of {_uadd} or {_usub}.
_loss
Gets the amount of loss that yieldToken
has incurred measured in basis points. When the expected underlying value is less than the actual value, this will return zero.
Parameters:
yieldToken
address
The address of the yield token.
Return Values:
The
uint256
loss in basis points.
_distributeCredit
Distributes amount
credit to all depositors of yieldToken
.
Parameters:
yieldToken
address
The address of the yield token to distribute credit for.
amount
uint256
The amount of credit to distribute in debt tokens.
_distributeUnlockedCreditDeposited
Distributes unlocked credit for all of the yield tokens that have been deposited into the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
_distributeUnlockedCredit
Distributes unlocked credit of yieldToken
to all depositors.
Parameters:
yieldToken
address
The address of the yield token to distribute unlocked credit for.
_wrap
Wraps amount
of an underlying token into its yieldToken
.
Parameters:
yieldToken
address
The address of the yield token to wrap the underlying tokens into.
amount
uint256
The amount of the underlying token to wrap.
minimumAmountOut
uint256
The minimum amount of yield tokens that are expected to be received from the operation.
Return Values:
The
uint256
amount of yield tokens that resulted from the operation.
_unwrap
Unwraps amount
of yieldToken
into its underlying token.
Parameters:
yieldToken
address
The address of the yield token to unwrap.
amount
uint256
The amount of the underlying token to wrap.
recipient
address
The recipient of the tokens after they are unwrapped.
minimumAmountOut
uint256
The minimum amount of underlying tokens that are expected to be received from the operation.
Return Values:
The
uint256
amount of underlying tokens that resulted from the operation.
_poke
Synchronizes the state for all of the tokens deposited in the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
_poke
Synchronizes the state of yieldToken
for the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
yieldToken
address
The address of the yield token to synchronize the state for.
_updateDebt
Increases the debt by amount
for the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
amount
int256
The amount to increase the debt by.
_approveMint
Set the mint allowance for spender
to amount
for the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
spender
address
The address of the spender.
amount
uint256
The amount of debt tokens to set the mint allowance to.
_decreaseMintAllowance
Decrease the mint allowance for spender
by amount
for the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
spender
address
The address of the spender.
amount
uint256
The amount of debt tokens to decrease the mint allowance by.
_approveWithdraw
Set the withdraw allowance of yieldToken
for spender
to shares
for the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
spender
address
The address of the spender.
yieldToken
address
The address of the yield token to set the withdraw allowance for.
shares
uint256
The amount of shares to set the withdraw allowance to.
_decreaseWithdrawAllowance
Decrease the withdraw allowance of yieldToken
for spender
by amount
for the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
spender
address
The address of the spender.
yieldToken
address
The address of the yield token to decrease the withdraw allowance for.
amount
uint256
The amount of shares to decrease the withdraw allowance by.
_validate
Checks that the account owned by owner
is properly collateralized.
If the account is undercollateralized then this will revert with an {Undercollateralized} error.
Parameters:
owner
address
The address of the account owner.
totalValue
Gets the total value of the deposit collateral measured in debt tokens of the account owned by owner
.
Parameters:
owner
address
The address of the account owner.
Return Values:
The
uint256
total value.
_issueSharesForAmount
Issues shares of yieldToken
for amount
of its underlying token to recipient
.
IMPORTANT: amount
must never be 0.
Parameters:
recipient
address
The address of the recipient.
yieldToken
address
The address of the yield token.
amount
uint256
The amount of the underlying token.
Return Values:
The
uint256
amount of shares issued to recipient
.
_burnShares
Burns share
shares of yieldToken
from the account owned by owner
.
Parameters:
owner
address
The address of the owner.
yieldToken
address
The address of the yield token.
shares
uint256
The amount of shares to burn.
_calculateUnrealizedDebt
Gets the amount of debt that the account owned by owner
will have after an update occurs.
Parameters:
owner
address
The address of the account owner.
Return Values:
The
int256
amount of debt that the account owned by owner
will have after an update.
_calculateUnrealizedActiveBalance
Gets the virtual active balance of yieldToken
.
The virtual active balance is the active balance minus any harvestable tokens which have yet to be realized.
Parameters:
yieldToken
address
The address of the yield token to get the virtual active balance of.
Return Values:
The
uint256
virtual active balance.
_calculateUnlockedCredit
Calculates the amount of unlocked credit for yieldToken
that is available for distribution.
Parameters:
yieldToken
address
The address of the yield token.
Return Values:
The
uint256
amount of unlocked credit available.
convertYieldTokensToShares
Gets the amount of shares that amount
of yieldToken
is exchangeable for.
Parameters:
yieldToken
address
The address of the yield token.
amount
uint256
The amount of yield tokens.
Return Values:
The
uint256
number of shares.
convertSharesToYieldTokens
Gets the amount of yield tokens that shares
shares of yieldToken
is exchangeable for.
Parameters:
yieldToken
address
The address of the yield token.
shares
uint256
The amount of shares.
Return Values:
The
uint256
amount of yield tokens.
convertSharesToUnderlyingTokens
Gets the amount of underlying tokens that shares
shares of yieldToken
is exchangeable for.
Parameters:
yieldToken
address
The address of the yield token.
shares
uint256
The amount of shares.
Return Values:
The
uint256
amount of underlying tokens.
convertYieldTokensToUnderlying
Gets the amount of an underlying token that amount
of yieldToken
is exchangeable for.
Parameters:
yieldToken
address
The address of the yield token.
amount
uint256
The amount of yield tokens.
Return Values:
The
uint256
amount of underlying tokens.
convertUnderlyingTokensToYield
Gets the amount of yieldToken
that amount
of its underlying token is exchangeable for.
Parameters:
yieldToken
address
The address of the yield token.
amount
uint256
The amount of underlying tokens.
Return Values:
The
uint256
amount of yield tokens.
convertUnderlyingTokensToShares
Gets the amount of shares of yieldToken
that amount
of its underlying token is exchangeable for.
Parameters:
yieldToken
address
The address of the yield token.
amount
uint256
The amount of underlying tokens.
Return Values:
The
uint256
amount of shares.
normalizeUnderlyingTokensToDebt
Normalize amount
of underlyingToken
to a value which is comparable to units of the debt token.
Parameters:
underlyingToken
address
The address of the underlying token.
amount
uint256
The amount of the debt token.
Return Values:
The
uint256
normalized amount.
normalizeDebtTokensToUnderlying
Normalize amount
of the debt token to a value which is comparable to units of underlyingToken
.
This operation will result in truncation of some of the least significant digits of amount
. This truncation amount will be the least significant N digits where N is the difference in decimals between the debt token and the underlying token.
Parameters:
underlyingToken
address
The address of the underlying token.
amount
uint256
The amount of the debt token.
Return Values:
The
uint256
normalized amount.
_onlyWhitelisted
Checks the whitelist for msg.sender.
Reverts if msg.sender is not in the whitelist.
_checkArgument
Checks an expression and reverts with an {IllegalArgument} error if the expression is {false}.
Parameters:
expression
bool
The expression to check.
_checkState
Checks an expression and reverts with an {IllegalState} error if the expression is {false}.
Parameters:
expression
bool
The expression to check.
_uadd
Adds two unsigned 256 bit integers together and returns the result.
This operation is checked and will fail if the result overflows.
Parameters:
x
uint256
The first operand.
y
uint256
The second operand.
Return Values:
z
uint256
The result.
_usub
Subtracts two unsigned 256 bit integers together and returns the result.
This operation is checked and will fail if the result overflows.
Parameters:
x
uint256
The first operand.
y
uint256
The second operand.
Return Values:
z
uint256
the result.
Last updated