Pegkeeper Usage and Operational Flow
The Pegkeeper contract maintains stablecoin pegs through a series of coordinated market operations. This guide explains how to interact with the Pegkeeper and understand its operational flow.
Core Concepts
Flash Loans
Uncollateralized loans that must be repaid in the same transaction
Used by Pegkeeper to obtain stablecoins for liquidations
Provided by the Treasury contract
Include built-in profitability checks
Liquidation Auctions
Triggered by a user when a positions become undercollateralized
Allow purchase of collateral at a discount
Execute through the Blend pool interface
Require specific parameter calculations
AMM Integration
Used for converting collateral to stablecoins
Facilitates profitable trading
Operational Flow
Liquidation Initiation done by user
Monitor Blend pool for liquidatable positions
Start liquidation
Calculate required parameters:
bid_amount
: Flash loan sizelot_amount
: Expected collateralliq_amount
: Liquidation percentage
Treasury Interaction
Call
keep_peg
on Treasury contractExample parameters:
Flash Loan Process
Treasury mints stablecoins
Tokens sent to Pegkeeper
Pegkeeper executes operations
Loan must be repaid with profit
Liquidation Execution
Pegkeeper participates in auction
Acquires collateral at discount
Verifies collateral receipt
Tracks balance changes
AMM Trading
Converts acquired collateral to stablecoins
Optimizes for minimal slippage
Ensures profitable conversion
Uses configured AMM router
Profit Management
Calculates operation profit
Transfers excess to fee_taker
Approves loan repayment
Reverts if unprofitable
Operation Completion
Treasury burns repaid tokens
Events emitted for tracking
State updates finalized
Last updated