Rho Protocol Documentation
BlogApply for BetaETH Sepolia faucet
  • ๐ŸŒŸ Getting started
    • ๐Ÿ“„ Overview
    • ๐Ÿ’ก Why go with Rho?
    • ๐ŸŽฏ Key use cases
    • ๐Ÿ›ก๏ธ Safety and dependability
    • ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Who does Rho Protocol benefit?
  • ๐Ÿ“‹ PRODUCT GUIDE
    • ๐Ÿ”ง Product basics
      • ๐Ÿ“ˆ PnL mechanics: How to profit with Rho
      • ๐Ÿ“‰ DV01: Fixed income's delta
    • ๐Ÿ’น Margin and leverage on Rho
      • ๐Ÿง  Is 50x leverage high for a rates trade?
    • ๐Ÿ“… Maturity selection in interest rate futures
    • ๐Ÿค– Automated market maker (AMM) model
    • ๐Ÿ’ผ Leveraging interest rate futures at Rho Protocol
    • ๐Ÿฆ Rho Liquidity Vault
    • โ—Risks
  • ๐Ÿš€ How to trade on Rho
    • ๐Ÿ“– New user guide: Start here
    • ๐Ÿ’ฐ Depositing collateral
      • ๐Ÿ”— Cross-chain deposits
      • ๐Ÿงช Requesting testnet assets
    • ๐Ÿ“Š Dashboard overview
    • โšก Executing your first trade
    • ๐Ÿ”€ Switching environments
    • ๐Ÿ”™ Review and adjust
  • ๐Ÿ—‚๏ธ Trading products: Technical specifications
    • ๐Ÿ‘‰ Rho rate futures
    • ๐Ÿ”จ Trading mechanisms and models
    • ๐Ÿงฎ P&L Calculation
    • ๐Ÿงพ Fees Structure Overview
      • Liquidity Provider (LP) Fees
      • Protocol fees
      • Time to Maturity
      • Price Impact and Variable LP Fee
      • Summary: Total Fee Calculation
      • Example 1: 31 Days to Maturity
      • Example 2: 1 Day to Maturity
    • ๐Ÿ›ก๏ธ Risk management and margin details
  • ๐Ÿ—๏ธ Practical applications and use cases
    • ๐ŸŒณ Hedging against interest rate fluctuations
    • ๐Ÿ’ต Opportunities to capitalize
    • ๐ŸŽฏ Arbitrage strategies
    • ๐Ÿ’ธ Income generation through enhanced yield strategies
    • ๐ŸŒฑ Portfolio diversification
  • โ‰๏ธ Frequently Asked Questions
    • ๐Ÿ“ฅ For Vaults depositors
    • ๐Ÿง How and why should I begin trading IRDs on Rho Protocol?
    • ๐Ÿ’ผ What digital wallets does Rho Protocol support?
    • ๐Ÿ”ง How can I effectively manage my collateral at Rho Protocol?
    • ๐Ÿšจ What can I do to prevent being liquidated?
  • ๐Ÿ› ๏ธ Troubleshooting
    • ๐Ÿ”— Connecting wallets
    • โŒ Failed transactions / trades
    • ๐Ÿ”Ž Viewing transactions
    • ๐Ÿ“ž Contact support
  • ๐Ÿ‘จโ€๐Ÿ’ป Developer docs
    • ๐Ÿ“„ Contracts overview
      • ๐Ÿ—ƒ๏ธ Types, structs and enums
      • ๐Ÿ“ก Router contract
      • ๐Ÿ’ฌ Quoter contract
      • ๐Ÿ‘“ ViewDataProvider
    • ๐Ÿ’ป Rho SDK
      • ๐Ÿ“š Technical Reference
  • ๐Ÿ”ง Deployed contracts
    • ๐Ÿงช Testnet addresses
    • ๐Ÿ”‘ Mainnet addresses
Powered by GitBook
On this page
  • Types
  • MarketId
  • FutureId
  • Structs
  • OraclePackage
  • Margin.Value
  • ProfitAndLoss.Value
  • FixedAndFloatTokensPair.Value
  • TradeInfo
  • ProvisionDistribution
  • Enums
  • RiskDirection.Value
  1. ๐Ÿ‘จโ€๐Ÿ’ป Developer docs
  2. ๐Ÿ“„ Contracts overview

๐Ÿ—ƒ๏ธ Types, structs and enums

Documentation on types, structs and enums used across different contracts.

Types

MarketId

Alias for bytes32. It's a hash of the properties of MarketKey struct.

struct MarketKey {
    string sourceName;
    string instrumentName;
    string tag;
    uint16 version;
    address underlying;
}

function id(MarketKey memory self) internal pure returns (MarketId) {
    return
      MarketId.wrap(
        keccak256(abi.encode(self.sourceName, self.instrumentName, self.tag, self.version, self.underlying))
      );
}

Property name
Property Type
Description

sourceName

string

Source of interest rate. E.g: Binance or Lido

instrumentName

string

Instrument name. E.g 'BTCUSDT Perpetual' or 'stEth'

tag

string

Identifier to group rates. E.g: 'funding rate' or 'staking'

version

uint16

Counter for differentiating multiple markets of the same source and instrument

underlying

address

Address of the underlying ERC20 token


FutureId

Alias for bytes32. It's a hash of the properties of FutureKey struct.

struct FutureKey {
    MarketId marketId;
    uint64 termStart;
    uint64 termLength;
}

function id(FutureKey memory self) internal pure returns (FutureId) {
    return FutureId.wrap(keccak256(abi.encode(self.marketId, self.termStart, self.termLength)));
}
Property name
Property Type
Description

marketId

Market Identifier

termStart

uint64

Timestamp in seconds of the start of the future

termLength

uint64

Number of seconds until maturity


Structs

OraclePackage

Defines the format for passing an updated index value from the oracle for a given market.

struct OraclePackage {
  MarketId marketId;
  uint64 timestamp;
  bytes signature;
  SD59x18 indexValue;
}
Property name
Property Type
Description

marketId

Market Identifier

timestamp

uint64

Timestamp in seconds

signature

bytes

Oracle signature validated on-chain

indexValue

int256

New index value for a market


Margin.Value

struct Value {
    ProfitAndLoss.Value profitAndLoss;
    SD59x18 collateral;
}
Property name
Property Type
Description

profitAndLoss

User's P&L

collateral

int256

Amount of collateral deposited by user


ProfitAndLoss.Value

struct Value {
    SD59x18 netFutureValue;
    UD60x18 accruedLPFee;
    UD60x18 incurredFee;
}
Property name
Property Type
Description

netFutureValue

int256

Amount of P&L gained or lost by an user across all futures

accruedLPFee

uint256

Amount of fees accrued by user by providing liquidity

incurredFee

uint256

Amount of fees incurred to a user by trading


FixedAndFloatTokensPair.Value

Struct for passing the amount of fixed and float tokes in a future's vAMM.

struct Value {
    SD59x18 fixedTokenAmount;
    SD59x18 floatTokenAmount;
}
Property name
Property Type
Description

fixedTokenAmount

int256

Amount of fixed tokens

floatTokenAmount

int256

Amount of floating tokens


TradeInfo

Provides detailed insights into the outcome of a trade

struct TradeInfo {
  RiskDirection.Value direction;
  FixedAndFloatTokensPair.Value tokensPair;
  SD59x18 marketRateBefore;
  SD59x18 marketRateAfter;
  SD59x18 tradeRate;
  UD60x18 lpFee;
  UD60x18 protocolFee;
  SD59x18 floatIndex;
  SD59x18 floatTradeValue;
}
Property name
Property Type
Description

direction

RiskDirection.Value

Direction of the trade

tokensPair

FixedAndFloatTokensPair.Value

Fixed and float token amounts corresponding to the trade

marketRateBefore

int256

Prevailing market rate right before the trade

marketRateAfter

int256

Prevailing market rate right after the trade

tradeRate

int256

Specific rate, at which the trade was executed

lpFee

uint256

Amount of fees incurred that will to to makers

protocolFee

uint256

Amount of fees incurred that will go to the protocol

floatIndex

int256

Index value used for calculations for the trade

floatTradeValue

int256

The value of the floating leg of a trade using its latest available index. Used for P&L calculations.


ProvisionDistribution

Struct to show how liquidity is distributed between payer and receiver sides

struct ProvisionDistribution {
  UD60x18 total;
  UD60x18 payer;
  UD60x18 receiver;
}
Property name
Property Type
Description

total

uint256

Total liquidity

payer

uint256

Liquidity on payer side

receiver

uint256

Liquidity on receiver side


Enums

RiskDirection.Value

Indicates the direction of a trader, whether the user is a receiver or payer of fixed rates.

enum Value {
    RECEIVER,
    PAYER
}

Previous๐Ÿ“„ Contracts overviewNext๐Ÿ“ก Router contract

Last updated 1 year ago

MarketId
MarketId
ProfitAndLoss.Value