mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
e11b298c28
* add overview and basic structure * add state and params * add basic messages * add state transitions * add begin block state transitions * add missing titles * add concepts * add events * update state and concepts * update for liquidator changes * update events * mention module accounts * update begin block * update params * update page numbering * add fee descriptions * add broken link linter * add broken link linter to CI * move link check to end of CI * update typo Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com> * address review comments * Update x/cdp/spec/06_params.md Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com> * Update x/cdp/spec/README.md Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com> * Update x/cdp/spec/README.md Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com> Co-authored-by: Kevin Davis <karzak@users.noreply.github.com>
1.4 KiB
1.4 KiB
Begin Blocker
At the start of every block the BeginBlocker of the cdp module:
- updates total CDP fees
- liquidates CDPs under the collateral ratio
- nets out system debt and, if necessary, starts auctions to re-balance it
- records the last block time
Update Fees
- The total fees accumulated since the last block across all CDPs are calculated.
- An equal amount of debt coins are minted and sent to the system's CDP module account.
- An equal amount of stable asset coins are minted and sent to the system's liquidator module account
Liquidate CDP
- Get every cdp that is under the liquidation ratio for its collateral type.
- For each cdp:
- Calculate and update fees since last update.
- Remove all collateral and internal debt coins from cdp and deposits and delete it. Send the coins to the liquidator module account.
- Start auctions of a fixed size from this collateral (with any remainder in a smaller sized auction), sending collateral and debt coins to the auction module account.
- Decrement total principal.
Net Out System Debt, Re-Balance
- Burn the maximum possible equal amount of debt and stable asset from the liquidator module account.
- If there is enough debt remaining for an auction, start one.
- If there is enough surplus stable asset remaining for an auction, start one.
- Otherwise do nothing, leave debt/surplus to accumulate over subsequent blocks.
Update Previous Block Time
The current block time is recorded.