AlchemistV2
is the core contract in any Alchemix debt-system that holds Account data and issues that system's debt tokens. The AlchemistV2
is flexible enough to accept deposits in the form of either yield-bearing-assets or underlying collateral assets (and wrapping said underlying tokens into their yield-bearing form).Account
in the Alchemist
has multiple components. The first 2 data-points to understand are balances and ** debt**.mapping
of yieldTokens to the Account
's respective balance of Alchemist-shares. ** Shares** represent a user's deposit of yieldTokens in the AlchemistV2
, and provide an accounting abstraction that helps the AlchemistV2
avoid bank-run scenarios.int256
type that represents both the account's debt (positive values) and credit (negative values).Account
manages its debt by tracking the lastAccruedWeights of the various depositedTokens that it is holding.Account
also has the ability to track mintAllowances and withdrawAllowances that allow 3rd-party accounts to mint and withdraw its assets.msg.sender
is another contract, that contract must be whitelisted by governance in order for the call to succeed.maximumLoss
(denominated in basis-points), the following functions are automatically disabled:deposit()
depositUnderlying()
withdrawUnderlying()
withdrawUnderlyingFrom()
liquidate()
harvest()
withdraw()
withdrawFrom()
repay()
mint()
burn()
maximumLoss
is configured as an amount of basis-points of the total expected value of the vault. Because there are situations where a vault might experience a small, transient loss, it will likely be wise to keep maximumLoss
around 1-10 bps.snap()
function can be called to reset the expected value of the yield tokens held by the Alchemist, thereby accepting the loss and resuming normal operation.repay()
liquidate()
, and mint()
all have time-based limits to how much they can be used.repay
and liquidate
limit that keeps track of the total amount of funds repaid or liquidated globally. Each synthetic token has its own mint
limit that keeps track of the total amount of funds minted globally. These limits each track their given metric and linearly cool down over a specified amount of time.liquidate()
cap for DAI to 20 million with a 10 minute cooldown, then the maximum amount of DAI that can be liquidated from all of the strategies used by the alUSD Alchemist over the span of 10 minutes is 20 million. The cooldown period is linear, so if the 20 million cap gets hit, no more DAI can be liquidated in that block, but after 5 minutes users can liquidate up to 10 million DAI.deposit()
depositUnderlying()
liquidate()
repay()
harvest()
function also still functions so debts can continue to be repaid by yield.