CDS Markets

Learn how Credit Default Swap markets work in Siprifi and how to effectively trade credit risk.

Overview

A CDS (Credit Default Swap) market in Siprifi represents a bet on whether a specific credit event will occur before the maturity date. These markets enable decentralized trading of credit risk without traditional intermediaries.

Market Structure

Each market contains the following components:

ComponentDescription
Event NameDescription of the credit event being predicted
Maturity DateDeadline for the event to occur
CollateralETH locked in the market as backing
YES TokensERC-20 tokens representing bets that the event WILL occur
NO TokensERC-20 tokens representing bets that the event will NOT occur
StatusInProgress, MaturityReached, or Resolved

Market Lifecycle

1. Creation

Anyone can create a market by calling createMarket() with:

  • Event name (string describing the credit event)
  • Maturity timestamp (Unix timestamp)
  • ETH collateral (sent with the transaction)

The creator becomes the market issuer and receives NO tokens proportional to their collateral.

solidity
function createMarket(
    string memory eventName,
    uint256 maturity
) external payable returns (uint256 marketId)

2. Trading

While a market is active (before maturity), users can buy YES tokens:

  • Each YES token costs exactly 0.1 ETH
  • The ETH is added to the market collateral
  • An equal amount of NO tokens is minted to the issuer
solidity
function buyYes(uint256 id) external payable {
    require(msg.value == YES_PRICE, "Must send 0.1 ETH");
    // Mints 1 YES token to buyer
    // Mints 1 NO token to issuer
}

3. Maturity

Once the maturity date passes, the market enters the "MaturityReached" state. No more YES tokens can be purchased. The market awaits resolution by the issuer.

4. Resolution

The market issuer resolves the market by declaring the outcome:

  • Outcome 1 (YES wins): The credit event occurred
  • Outcome 0 (NO wins): The credit event did not occur
solidity
function resolve(uint256 id, uint8 outcome) external {
    require(msg.sender == market.issuer, "Only issuer");
    require(block.timestamp >= market.maturity, "Not mature");
    // outcome: 0 = NO wins, 1 = YES wins
}

5. Claiming

After resolution, winning token holders can claim their share of the collateral:

  • Winners receive: (their tokens / total winning tokens) * collateral
  • Tokens are burned when claiming
  • ETH is transferred directly to the claimer
solidity
function claim(uint256 id) external {
    // Burns winning tokens
    // Transfers proportional ETH to caller
}

Token Mechanics

YES and NO tokens are standard ERC-20 tokens. They can be transferred, traded on DEXs, or used as collateral in other DeFi protocols.

The token minting follows these rules:

ActionYES MintedNO MintedCollateral Change
Create Market (1 ETH)010 (to issuer)+1 ETH
Buy YES (0.1 ETH)1 (to buyer)1 (to issuer)+0.1 ETH
Claim (YES wins)-X (burned)0-proportional ETH
Claim (NO wins)0-X (burned)-proportional ETH

Risk Considerations

Important Risks:
  • Resolution Risk: The issuer has full control over resolution. Choose markets from trusted issuers.
  • Liquidity Risk: You may not be able to sell your tokens before maturity if there's no secondary market.
  • Smart Contract Risk: Bugs in the contract could result in loss of funds.