Treasury
The Treasury contract is the backbone of the Orbit Protocol, responsible for managing stablecoin minting, supply control, and flash loan operations. It interacts with stablecoins, Blend pools, and the Pegkeeper to maintain the stability of the protocol's stablecoins.
Core Functionality
Initialization
The Treasury contract is initialized with two key parameters:
admin
: Address with administrative privilegespegkeeper
: Address of the Pegkeeper contract
Stablecoin Management
Adding Stablecoins
The add_stablecoin
function enables the admin to register new stablecoins with their corresponding Blend pools:
Only callable by admin
Maps stablecoin token address to its Blend pool
Emits an event with token and pool addresses
Supply Control
The Treasury provides two functions for managing stablecoin supply:
Increase Supply
Mints new stablecoins to the Treasury
Deposits minted tokens into the corresponding Blend pool
Requires positive amount
Only callable by admin
Decrease Supply
Withdraws tokens from Blend pool
Burns the withdrawn tokens
Requires positive amount
Verifies sufficient supply before burning
Only callable by admin
Peg Maintenance
The keep_peg
function is the core mechanism for maintaining stablecoin pegs:
Operation Flow:
Validates token address and amount from arguments
Mints requested tokens to Pegkeeper
Executes specified operation (via
name
andargs
)Verifies flash loan repayment
Burns repaid tokens
Safety Mechanisms:
Requires amount > 0
Validates flash loan repayment
Automatically burns repaid tokens
Reverts on failed operations
Administration
The Treasury includes administrative functions for protocol management:
Updates Pegkeeper address
Only callable by admin
Emits event on change
Upgrades contract implementation
Only callable by admin
Uses Soroban contract upgrade mechanism
Events
The Treasury emits events for major operations:
initialize
: Contract initializationadd_stablecoin
: New stablecoin registrationincrease_supply
: Supply increasedecrease_supply
: Supply decreasekeep_peg
: Peg maintenance operationset_pegkeeper
: Pegkeeper address update
Error Handling
The contract includes several error conditions:
AlreadyInitializedError
: Duplicate initializationInvalidAmount
: Zero or negative amountNotEnoughSupplyError
: Insufficient supply for burningFlashloanFailedError
: Failed flash loan repayment
Last updated