Orbit Documentation
  • Github
  • Protocol Overview
    • What is Orbit Protocol
    • Ecosystem Participants
    • Smart Contracts
    • Whitepaper
    • Litepaper
  • Technical Documentation
    • Treasury
    • Bridge Oracle
    • PegKeeper
    • DAO
    • System Diagram
Powered by GitBook
On this page
  • Stablecoin Management
  • Adding Stablecoins
  • Supply Control
  • Claiming Interest
  • Keep Peg Mechanism
  • Administration
  • Setting the Pegkeeper
  • Setting the Admin
  • Contract Upgrades
  • Contract Initialization
  • Errors
  • Events
  1. Technical Documentation

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.

fn add_stablecoin(e: Env, token: Address, blend_pool: Address)

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:

fn increase_supply(e: Env, token: Address, amount: i128)
fn decrease_supply(e: Env, token: Address, amount: i128)

When increasing supply:

  1. The Treasury mints the specified amount of the stablecoin

  2. The minted tokens are deposited into the corresponding Blend pool

  3. The internal supply counter is updated

When decreasing supply:

  1. The Treasury withdraws tokens from the Blend pool

  2. Verifies the withdrawal succeeded

  3. 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:

fn claim(e: Env, reserve_address: Address, to: Address) -> i128

When interest is claimed:

  1. The contract calculates interest by comparing the current B-rate value to the original deposit

  2. The interest amount is withdrawn from the Blend pool

  3. 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:

fn keep_peg(e: Env, name: Symbol, args: Vec<Val>)

This function:

  1. Extracts token address, amount, and Blend pool from the args

  2. Validates parameters and checks for registered Blend pool

  3. Mints the requested amount to the Pegkeeper

  4. Invokes the specified function on the Pegkeeper

  5. Handles the return of tokens

  6. 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:

fn set_pegkeeper(e: Env, pegkeeper: Address)

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:

fn set_admin(e: Env, admin: Address)

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:

fn upgrade(e: Env, new_wasm_hash: BytesN<32>)

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:

fn __constructor(e: Env, admin: Address, factory: Address, pegkeeper: Address)

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 registered

  • InvalidAmount (1502): Providing zero or negative amount for supply changes

  • BlendPoolNotFoundError (1506): Operating on a token without a registered Blend pool

  • InvalidBlendPoolError (1508): Providing an invalid Blend pool address

  • NotEnoughSupplyError (1504): Insufficient supply when attempting to decrease supply

  • FlashloanFailedError (1503): Failed token return during peg maintenance

  • NoInterestToClaim (1509): No interest available when attempting to claim

Events

The Treasury emits events for all major operations:

  • initialize: Contract initialization with admin and pegkeeper addresses

  • add_stablecoin: Registration of a new stablecoin with its Blend pool

  • increase_supply: Supply increase with token and amount

  • decrease_supply: Supply decrease with token and amount

  • claim: Interest claim with reserve, recipient, and amount

  • keep_peg: Peg maintenance operation with token and amount

  • set_pegkeeper: Pegkeeper address update

  • set_admin: Admin address update

PreviousLitepaperNextBridge Oracle

Last updated 18 days ago