Oracle for Stablecoins

Building
Stablecoin Protocols

This high-level guide explores stablecoins, their most common designs, and how they typically use oracle prices to power their operations.

What are Stablecoins?

Stablecoins (or “stables”) are cryptocurrencies designed to maintain a stable value, typically pegged to a fiat currency (like USD) or a basket of assets. Unlike other cryptocurrencies like Bitcoin or Ethereum, which can experience significant price volatility, stablecoins offer stability and reduced price volatility, making them valuable for decentralized finance (DeFi) applications.

Stablecoins in Practice

Stablecoins are typically backed by reserves of the underlying asset, held in banks or other trusted institutions. This backing helps maintain the stability of the stablecoin's value. There are different types of stablecoins:

Fiat-Collateralized Stablecoinsare backed by a reserve of fiat currency held in a bank. For example, a USD-backed stablecoin would be pegged to the value of the US Dollar.

Crypto-Collateralized Stablecoinsare backed by a reserve of other cryptocurrencies, often using over-collateralization to maintain stability.

Algorithmic Stablecoinsuse algorithms to regulate their supply and demand to maintain a stable value. The stability is achieved through mechanisms like adjusting the coin's supply or encouraging users to buy or sell.

Blockchain oracles play a crucial role in the functioning of stablecoins by providing external price information to the smart contract that governs the stablecoin's pegging mechanism. Stablecoins have gained popularity as a medium of exchange, a store of value, and a way to move funds quickly within the decentralized finance ecosystem without being subjected to the price volatility associated with other cryptocurrencies. Consider the popularity of market pairs with USD or a stablecoin (typically USDC or USDT) as the quote currency over BTC or ETH denominated pairs. Stablecoins will most likely play a crucial role for DeFi, as they provide a stable base currency for trading, lending, and other financial activities.

You can start building your stablecoin protocol and request low-latency price updates through Pyth Price Feeds.

Explore our docs to get started.

Stablecoins:
How Do They Work?

This section explains the critical role that price oracles play in stablecoin protocols, including over-collateralized and algorithmic approaches.

Over-Collateralized Stablecoins

In the over-collateralized model, stablecoins are backed by a surplus of collateral assets that exceed the outstanding stablecoin supply. Users deposit more assets than the value of stablecoins they wish to mint. The surplus collateral provides security and mitigates risks, ensuring the stablecoin's stability.

To create over-collateralized stablecoins, users lock a certain amount of collateral, often cryptocurrencies like Ether (ETH), into a smart contract. The contract calculates the value of the collateral and allows the issuance of stablecoins, ensuring a sufficient collateralization ratio. If the value of the collateral falls below a specified threshold, liquidation mechanisms may be triggered to maintain the stability of the stablecoin.

For example, Dai, a popular over-collateralized stablecoin on the Ethereum blockchain, uses a smart contract system called the Maker Protocol. Users lock ETH into a collateralized debt position (CDP) to generate Dai.

Fiat-Collateralized Stablecoins

These stablecoins are directly backed by traditional fiat currencies or assets held in reserve. Each stablecoin represents a fixed amount of the fiat currency, allowing for direct redemption.

To create fiat-collateralized stablecoins, users deposit fiat currencies into a custodial account or reserve. The stablecoin issuer mints an equivalent amount of stablecoins. These reserves are audited regularly to ensure transparency and maintain the stablecoin's peg to the fiat currency.

For example, Tether (USDT) is a popular fiat-collateralized stablecoin where each USDT token is backed by one US dollar held in reserve.

Crypto-Collateralized Stablecoins

Crypto-collateralized stablecoins use other cryptocurrencies as collateral to issue new stablecoins. The value of the collateralized cryptocurrency determines the stability of the stablecoin.

Users lock a specific amount of cryptocurrency into a smart contract to create stablecoins. The smart contract calculates the collateralization ratio and allows the issuance of stablecoins accordingly. The stablecoin's value is maintained by ensuring sufficient collateralization and liquidation mechanisms if the value of the collateral drops significantly.

Synthetix (sUSD) is an example of a crypto-collateralized stablecoin protocol where users lock cryptocurrencies as collateral to mint synthetic stablecoins.

Algorithmic Stablecoins

Algorithmic stablecoins, also known as non-collateralized stablecoins, operate without relying on any physical collateral to stabilize their value. Instead, they employ sophisticated algorithms and economic mechanisms to dynamically adjust the stablecoin's supply based on market demand and price movements.

Non-collateralized stablecoins achieve stability through the principles of seigniorage, which refers to the difference between the value of assets in the system and the value of outstanding stablecoins. When the stablecoin's price exceeds the peg, the protocol aims to expand the money supply to reduce the value of each stablecoin. Conversely, when the stablecoin's price falls below the peg, the protocol contracts the money supply, increasing the value of each stablecoin.

Non-collateralized stablecoins face several challenges, primarily related to maintaining a stable peg over various market conditions. Extreme price volatility or sudden demand shifts can pose difficulties in algorithmically controlling the supply to stabilize the stablecoin.

An infamous example of an algorithmic mechanism is Terra's "Terraform" mechanism designed to regulate the supply of its stablecoin, Terra (UST) to achieve price stability.

Hybrid Stablecoins

The hybrid model leverages both collateralization and algorithmic mechanisms to strike a balance between stability and flexibility in maintaining the stablecoin's peg. More specifically, they use collateral assets to back the stablecoin initially, but also rely on algorithms to stabilize the token's value over time.

How Stablecoins Use Oracles

Price oracles act as decentralized data sources that fetch real-world asset prices from external markets and provide this information to smart contracts on the blockchain. Stablecoin protocols rely on secure price oracles to determine the stablecoin's current market value and ensure its peg to the target asset or fiat currency.

Price Monitoring

In the over-collateralized model, price oracles play a crucial role in determining the value of the collateral assets. These oracles fetch real-time market prices of the collateral assets and provide this data to the smart contract. The smart contract calculates the total value of the collateral and ensures that it exceeds the total outstanding stablecoin supply.

Stablecoin protocols using the over-collateralized model continuously monitor the value of the collateral to maintain the required collateralization ratio. If the value of the collateral decreases, price oracles trigger liquidation mechanisms to protect the stablecoin's stability.

An oracle specializing in low-latency price updates is critical for this operation. Pyth provides real-time price feeds to enable protocols to track the live prices of real-world assets including cryptocurrencies and traditional assets.

Dynamic Supply Adjustments

In the algorithmic stablecoin model, price oracles fetch the price of the stablecoin from external markets. Smart contracts use this data to algorithmically adjust the stablecoin's supply based on market demand and the target price.

Price oracles also play a role in determining whether the stablecoin's price deviates from the target value. If the stablecoin's price is above the target, the protocol expands the supply. Conversely, if the price falls below the target, the supply contracts, ensuring the stablecoin returns to its peg.

The Pyth protocol publishes secure and verified prices that are the result of on-chain aggregation from the real-time inputs of exchanges and liquidity pools.

Pyth is also the only oracle which provides confidence intervals—confidence bands around the reported price that reflect the level of volatility and price divergence between liquidity venues. A wider confidence band (e.g. ETH/USD at $2,000 ± $20 instead of ± $2) indicates greater “uncertainty” and divergence between liquidity venues. Developers can design their stablecoin protocols to respond to changes in confidence interval data for greater operational precision.

Stablecoin Glossary

This glossary provides the most common terms in the stablecoin and CDP space.

Algorithmic Stablecoin

A type of stablecoin that uses algorithms and smart contracts to control its supply and maintain price stability without physical collateral.

CDP (Collateralized Debt Position)

A smart contract mechanism used in some stablecoin protocols where users lock collateral to generate stablecoins.

Collateral

Assets held as security to back the value of a stablecoin, ensuring its stability and peg to a reference asset.

Fiat-Collateralized Stablecoin

A stablecoin directly backed by fiat currency or other traditional assets held in reserve.

Hybrid Stablecoin

A stablecoin model that combines elements of both collateralized and algorithmic approaches to achieve price stability.

Liquidity Pool

A pool of funds provided by users for trading and liquidity provision in decentralized exchanges.

Over-Collateralized Stablecoin

A stablecoin model where the value of collateral assets exceeds the value of the stablecoins in circulation.

Peg

The fixed exchange rate of a stablecoin to a reference asset or fiat currency.

Seigniorage

The difference between the value of assets held in a stablecoin protocol and the value of outstanding stablecoins. It helps maintain the peg through algorithmic supply adjustments.

Stablecoin

Cryptocurrencies designed to minimize price volatility and maintain a stable value, often pegged to fiat currency or a basket of assets.

Supply Adjustment

The mechanism used by stablecoins to regulate their token supply to maintain price stability.

Under-Collateralized Stablecoin

A stablecoin model where the value of collateral assets is slightly lower than the value of the stablecoins in circulation.

Volatility

The degree of price fluctuation of an asset over time. Stablecoins aim to reduce volatility and offer a more stable value.

Discover More Guides

Our guides cover popular DeFi solutions and how developers can leverage price oracles to create a unique, compelling product.

Lending

Borrowing and Lending

DEXs

Perpetual Futures

Derivatives

Options and Structured Product Vaults

Stablecoins

Stablecoins

integratingbg

Integrate Seamlessly

Pyth’s comprehensive suite of APIs solves all your financial data needs. Access to Pyth prices is permissionless and easy—no subscription necessary.

Developers can get started with our documentation, integration resources, and best practice guides. Watch along to learn how Pyth can super-charge your decentralized app.