Functions
Structs
Account
Field | Type |
---|---|
| int256 |
| mapping(address => uint256) |
| mapping(address => uint256) |
| struct Sets.AddressSet |
| mapping(address => uint256) |
| mapping(address => mapping(address => uint256)) |
Functions
getYieldTokensPerShare
Gets the conversion rate of yield tokens per share.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to get the conversion rate for. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The rate of yield tokens per share. |
getUnderlyingTokensPerShare
Gets the conversion rate of underlying tokens per share.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to get the conversion rate for. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token to check. |
Return Values:
Name | Type | Description |
---|---|---|
| bool | If the underlying token is supported. |
isSupportedYieldToken
Gets if a yield token is supported.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to check. |
Return Values:
Name | Type | Description |
---|---|---|
| bool | If the yield token is supported. |
accounts
Gets information about the account owned by owner
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address that owns the account. |
Return Values:
Name | Type | Description |
---|---|---|
| int256 | The unrealized amount of debt that the account had incurred. |
| address[] | The yield tokens that the owner has deposited. |
positions
Gets information about a yield token position for the account owned by owner
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address that owns the account. |
| address | The address of the yield token to get the position of. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The amount of shares of that |
| 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:
Name | Type | Description |
---|---|---|
| address | The owner of the account. |
| address | The address which is allowed to mint on behalf of |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The amount of debt tokens that |
withdrawAllowance
Gets the amount of shares of yieldToken
that spender
is allowed to withdraw on behalf of owner
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The owner of the account. |
| address | The address which is allowed to withdraw on behalf of |
| address | The address of the yield token. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The amount of shares that |
getUnderlyingTokenParameters
Gets the parameters of an underlying token.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token. |
Return Values:
Name | Type | Description |
---|---|---|
| struct IAlchemistV2State.UnderlyingTokenParams | The underlying token parameters. |
getYieldTokenParameters
Get the parameters and state of a yield-token.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The current amount of underlying tokens that can be repaid. |
| uint256 | The rate at which the the current limit increases back to its maximum in tokens per block. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The current amount of underlying tokens that can be liquidated. |
| uint256 | The rate at which the function increases back to its maximum limit (tokens / block). |
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address to set or unset as a sentinel. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address to set or unset as a keeper. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token to add. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to add. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token to enable or disable. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to enable or disable. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token to configure the repay limit of. |
| uint256 | The maximum repay limit. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token to configure the liquidation limit of. |
| uint256 | The maximum liquidation limit. |
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| uint256 | The maximum minting limit. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to set the credit unlock rate for. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to set the adapter for. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to set the maximum expected value for. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield bearing token to set the maximum loss for. |
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the reward token to snap. |
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The owner of the account whos debt to increase. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address that will be approved to mint. |
| uint256 | The amount of tokens that |
approveWithdraw
Approve spender
to withdraw amount
shares of yieldToken
.
NOTE: This function is WHITELISTED.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address that will be approved to withdraw. |
| address | The address of the yield token that |
| uint256 | The amount of shares that |
poke
Synchronizes the state of the account owned by owner
.
Parameters:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The yield-token to deposit. |
| uint256 | The amount of yield tokens to deposit. |
| address | The owner of the account that will receive the resulting shares. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The number of shares issued to |
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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to wrap the underlying tokens into. |
| uint256 | The amount of the underlying token to deposit. |
| address | The address of the recipient. |
| uint256 | The minimum amount of yield tokens that are expected to be deposited to |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The number of shares issued to |
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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to withdraw. |
| uint256 | The number of shares to burn. |
| address | The address of the recipient. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The number of yield tokens that were withdrawn to |
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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner to withdraw from. |
| address | The address of the yield token to withdraw. |
| uint256 | The number of shares to burn. |
| address | The address of the recipient. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The number of yield tokens that were withdrawn to |
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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to withdraw. |
| uint256 | The number of shares to burn. |
| address | The address of the recipient. |
| uint256 | The minimum amount of underlying tokens that are expected to be withdrawn to |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The number of underlying tokens that were withdrawn to |
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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner to withdraw from. |
| address | The address of the yield token to withdraw. |
| uint256 | The number of shares to burn. |
| address | The address of the recipient. |
| uint256 | The minimum amount of underlying tokens that are expected to be withdrawn to |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | The number of underlying tokens that were withdrawn to |
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:
Name | Type | Description |
---|---|---|
| uint256 | The amount of tokens to mint. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the owner of the account to mint from. |
| uint256 | The amount of tokens to mint. |
| 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:
Name | Type | Description |
---|---|---|
| uint256 | The amount of tokens to burn. |
| address | The address of the recipient. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token to repay. |
| uint256 | The amount of the underlying token to repay. |
| address | The address of the recipient which will receive credit. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to liquidate. |
| uint256 | The number of shares to burn for credit. |
| uint256 | The minimum amount of underlying tokens that are expected to be liquidated. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to credit accounts for. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to harvest. |
| uint256 | The minimum amount of underlying tokens that are expected to be withdrawn to |
_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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to preemptively harvest. |
_checkYieldTokenEnabled
Checks if a yield token is enabled.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
_checkUnderlyingTokenEnabled
Checks if an underlying token is enabled.
Parameters:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
_deposit
Deposits amount
yield tokens into the account of recipient
.
Emits a {Deposit} event.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to deposit. |
| uint256 | The amount of yield tokens to deposit. |
| address | The recipient of the yield tokens. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | number of shares minted to |
_withdraw
Withdraw yieldToken
from the account owned by owner
by burning shares and receiving yield tokens of equivalent value.
Emits a {Withdraw} event.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to withdraw. |
| address | The address of the account owner to withdraw from. |
| uint256 | The number of shares to burn. |
| address | The recipient of the withdrawn shares. This parameter is only used for logging. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The owner of the account to mint from. |
| uint256 | The amount to mint. |
| address | The recipient of the minted debt tokens. |
_sync
Synchronizes the active balance and expected value of yieldToken
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
| uint256 | The amount to add or subtract from the debt. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | loss in basis points. |
_distributeCredit
Distributes amount
credit to all depositors of yieldToken
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to distribute credit for. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
_distributeUnlockedCredit
Distributes unlocked credit of yieldToken
to all depositors.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to distribute unlocked credit for. |
_wrap
Wraps amount
of an underlying token into its yieldToken
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to wrap the underlying tokens into. |
| uint256 | The amount of the underlying token to wrap. |
| uint256 | The minimum amount of yield tokens that are expected to be received from the operation. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | amount of yield tokens that resulted from the operation. |
_unwrap
Unwraps amount
of yieldToken
into its underlying token.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to unwrap. |
| uint256 | The amount of the underlying token to wrap. |
| address | The recipient of the tokens after they are unwrapped. |
| uint256 | The minimum amount of underlying tokens that are expected to be received from the operation. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
_poke
Synchronizes the state of yieldToken
for the account owned by owner
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
| int256 | The amount to increase the debt by. |
_approveMint
Set the mint allowance for spender
to amount
for the account owned by owner
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
| address | The address of the spender. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
| address | The address of the spender. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
| address | The address of the spender. |
| address | The address of the yield token to set the withdraw allowance for. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
| address | The address of the spender. |
| address | The address of the yield token to decrease the withdraw allowance for. |
| 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:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | total value. |
_issueSharesForAmount
Issues shares of yieldToken
for amount
of its underlying token to recipient
.
IMPORTANT: amount
must never be 0.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the recipient. |
| address | The address of the yield token. |
| uint256 | The amount of the underlying token. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | amount of shares issued to |
_burnShares
Burns share
shares of yieldToken
from the account owned by owner
.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the owner. |
| address | The address of the yield token. |
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the account owner. |
Return Values:
Name | Type | Description |
---|---|---|
| int256 | amount of debt that the account owned by |
_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:
Name | Type | Description |
---|---|---|
| address | The address of the yield token to get the virtual active balance of. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | virtual active balance. |
_calculateUnlockedCredit
Calculates the amount of unlocked credit for yieldToken
that is available for distribution.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | amount of unlocked credit available. |
convertYieldTokensToShares
Gets the amount of shares that amount
of yieldToken
is exchangeable for.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
| uint256 | The amount of yield tokens. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | number of shares. |
convertSharesToYieldTokens
Gets the amount of yield tokens that shares
shares of yieldToken
is exchangeable for.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
| uint256 | The amount of shares. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | amount of yield tokens. |
convertSharesToUnderlyingTokens
Gets the amount of underlying tokens that shares
shares of yieldToken
is exchangeable for.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
| uint256 | The amount of shares. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | amount of underlying tokens. |
convertYieldTokensToUnderlying
Gets the amount of an underlying token that amount
of yieldToken
is exchangeable for.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
| uint256 | The amount of yield tokens. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | amount of underlying tokens. |
convertUnderlyingTokensToYield
Gets the amount of yieldToken
that amount
of its underlying token is exchangeable for.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
| uint256 | The amount of underlying tokens. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | amount of yield tokens. |
convertUnderlyingTokensToShares
Gets the amount of shares of yieldToken
that amount
of its underlying token is exchangeable for.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the yield token. |
| uint256 | The amount of underlying tokens. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | amount of shares. |
normalizeUnderlyingTokensToDebt
Normalize amount
of underlyingToken
to a value which is comparable to units of the debt token.
Parameters:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token. |
| uint256 | The amount of the debt token. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| address | The address of the underlying token. |
| uint256 | The amount of the debt token. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| bool | The expression to check. |
_checkState
Checks an expression and reverts with an {IllegalState} error if the expression is {false}.
Parameters:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| uint256 | The first operand. |
| uint256 | The second operand. |
Return Values:
Name | Type | Description |
---|---|---|
| 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:
Name | Type | Description |
---|---|---|
| uint256 | The first operand. |
| uint256 | The second operand. |
Return Values:
Name | Type | Description |
---|---|---|
| uint256 | the result. |
Last updated