Treasury
The Treasury contract serves as the central bank of the Orbit Protocol, responsible for controlling the issuance of stablecoins, managing their supply, and facilitating peg maintenance operations.
Stablecoin Management
The Treasury manages stablecoins throughout their lifecycle within the protocol, from initial creation to supply adjustments.
Adding Stablecoins
Stablecoins are added to the protocol through the Treasury by calling the add_stablecoin()
function.
This function:
Maps a stablecoin token to its corresponding Blend pool
Can only be called by the admin (the DAO contract)
Verifies the Blend pool exists through the factory
Checks if the stablecoin is already registered
Supply Control
The Treasury precisely controls the circulating supply of each stablecoin through two complementary functions:
When increasing supply:
The Treasury mints the specified amount of the stablecoin
The minted tokens are deposited into the corresponding Blend pool
The internal supply counter is updated
When decreasing supply:
The Treasury withdraws tokens from the Blend pool
Verifies the withdrawal succeeded
Burns the withdrawn tokens to reduce the total supply
Both operations require administrative privileges and emit appropriate events.
Claiming Interest
The Treasury can collect interest accrued from stablecoin deposits in Blend pools:
When interest is claimed:
The contract calculates interest by comparing the current B-rate value to the original deposit
The interest amount is withdrawn from the Blend pool
Withdrawn tokens are sent to the specified recipient
Keep Peg Mechanism
The Treasury provides a mechanism for maintaining stablecoin pegs through the keep_peg()
function:
This function:
Extracts token address, amount, and Blend pool from the args
Validates parameters and checks for registered Blend pool
Mints the requested amount to the Pegkeeper
Invokes the specified function on the Pegkeeper
Handles the return of tokens
Burns the returned tokens
Administration
The Treasury provides administrative functions to manage protocol configuration.
Setting the Pegkeeper
The Pegkeeper address can be updated by the admin:
This function updates the stored Pegkeeper address and emits an event recording the change.
Setting the Admin
The admin address can be updated by the current admin:
This function updates the admin address and emits an event recording the change.
Contract Upgrades
The Treasury supports upgradability through Soroban's native upgrade mechanism:
This function allows the admin to upgrade the contract to a new implementation while preserving all contract storage.
Contract Initialization
The Treasury is initialized with three key parameters:
During initialization:
The admin address is set (the DAO contract)
The factory address is stored for validating Blend pools
The Pegkeeper address is configured
An initialization event is emitted
All future administrative operations will require authorization from this admin address.
Errors
The Treasury contract may produce the following errors:
AlreadyAddedError
(1507): Attempting to add a stablecoin that's already registeredInvalidAmount
(1502): Providing zero or negative amount for supply changesBlendPoolNotFoundError
(1506): Operating on a token without a registered Blend poolInvalidBlendPoolError
(1508): Providing an invalid Blend pool addressNotEnoughSupplyError
(1504): Insufficient supply when attempting to decrease supplyFlashloanFailedError
(1503): Failed token return during peg maintenanceNoInterestToClaim
(1509): No interest available when attempting to claim
Events
The Treasury emits events for all major operations:
initialize
: Contract initialization with admin and pegkeeper addressesadd_stablecoin
: Registration of a new stablecoin with its Blend poolincrease_supply
: Supply increase with token and amountdecrease_supply
: Supply decrease with token and amountclaim
: Interest claim with reserve, recipient, and amountkeep_peg
: Peg maintenance operation with token and amountset_pegkeeper
: Pegkeeper address updateset_admin
: Admin address update
Last updated