AlchemistV2is the core contract in any Alchemix debt-system that holds Account data and issues that system's debt tokens. The
AlchemistV2is 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).
Alchemisthas multiple components. The first 2 data-points to understand are balances and ** debt**.
mappingof 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
AlchemistV2avoid bank-run scenarios.
int256type that represents both the account's debt (positive values) and credit (negative values).
Accountmanages its debt by tracking the lastAccruedWeights of the various depositedTokens that it is holding.
Accountalso has the ability to track mintAllowances and withdrawAllowances that allow 3rd-party accounts to mint and withdraw its assets.
msg.senderis 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:
maximumLossis 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
maximumLossaround 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.
mint()all have time-based limits to how much they can be used.
liquidatelimit that keeps track of the total amount of funds repaid or liquidated globally. Each synthetic token has its own
mintlimit 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.
harvest()function also still functions so debts can continue to be repaid by yield.