RFQ Calculations Guide

This guide covers the rfqCalculations module, which provides functions for calculating position sizes, collateral requirements, and reserve prices for RFQ orders.

Table of Contents

Overview

The RFQ calculations module helps you:

  1. Calculate number of contracts from a trade amount

  2. Calculate collateral required for a given position

  3. Calculate reserve price (total premium) for an order

  4. Determine collateral type (base vs quote) for each product

Importing

import {
  calculateNumContracts,
  calculateCollateralRequired,
  calculateReservePrice,
  calculateDeliveryAmount,
  premiumPerContract,
  isBaseCollateral,
  isPhysicalProduct,
  type ProductName,
  type DeliveryResult,
} from '@thetanuts-finance/thetanuts-client';

Core Functions

isBaseCollateral

Determines whether a product uses base collateral (WETH/cbBTC) or quote collateral (USDC).

Returns:

  • true for: INVERSE_CALL, INVERSE_CALL_SPREAD, PHYSICAL_CALL, PHYSICAL_CALL_SPREAD, PHYSICAL_CALL_FLY, PHYSICAL_CALL_CONDOR

  • false for all other products (they use USDC)

calculateNumContracts

Calculates the number of option contracts from a trade amount.

For SELL orders:

  • tradeAmount = collateral you're putting up

  • Formula: tradeAmount / maxLossPerContract

For BUY orders:

  • tradeAmount = premium you're willing to pay

  • Formula: tradeAmount / premiumPerContract

calculateCollateralRequired

Calculates the collateral required to open a position.

Returns: Collateral in the appropriate unit (WETH/cbBTC for base, USDC for quote)

premiumPerContract

Converts MM price (in underlying units) to premium per contract in collateral units.

For base collateral products: Returns mmPrice as-is (already in underlying) For quote collateral products: Returns mmPrice × spot (converts to USDC)

calculateReservePrice

Calculates the total premium (reserve price) for an order.

Returns: Total premium in collateral units

Buy vs Sell Orders

SELL Orders

When selling options, you provide collateral and receive premium.

Input: tradeAmount = collateral you're putting up Output: numContracts based on max loss per contract

BUY Orders

When buying options, you pay premium to acquire contracts.

Input: tradeAmount = premium budget (in collateral units) Required: mmPrice and spot to calculate premium per contract Output: numContracts based on premium cost

Examples by Product Type

Vanilla Options

Spreads

Multi-Leg Structures

Physical Options

Physical options involve actual delivery of the underlying asset at expiry, unlike cash-settled options.

isPhysicalProduct

Check if a product is physically settled.

calculateDeliveryAmount

Calculate what the buyer must deliver at exercise for physical options.

Physical Option Formulas:

Product
Collateral (Seller)
Delivery (Buyer)

PHYSICAL_CALL

numContracts (WETH)

strike × numContracts (USDC)

PHYSICAL_PUT

strike × numContracts (USDC)

numContracts (WETH)

Physical Option Examples

Max Contracts Calculation (OptionBook)

When filling orders from the OptionBook, the maxContracts calculation determines how many contracts can be filled based on the maker's available collateral. The formula varies by option type.

Max Contracts by Option Type

Option Type
Collateral Type
Formula
Example (10,000 collateral, $2,500 strike)

PUT

USDC (6 dec)

(maxCollateral × 1e8) / strike

(10000 × 1e8) / 250000000000 = 4 contracts

INVERSE_CALL

WETH (18 dec)

maxCollateral / 1e12

10e18 / 1e12 = 10,000,000 (raw), 10 contracts

LINEAR_CALL

USDC (6 dec)

(maxCollateral × 1e8) / strike

(10000 × 1e8) / 250000000000 = 4 contracts

SPREAD

USDC (6 dec)

(maxCollateral × 1e8) / spreadWidth

(1000 × 1e8) / 10000000000 = 10 contracts

INVERSE_CALL vs LINEAR_CALL

The key difference is collateral type:

  • INVERSE_CALL: Uses base token (WETH/cbBTC) as collateral. 1 contract = 1 underlying token.

  • LINEAR_CALL: Uses quote token (USDC) as collateral. Same formula as PUT.

The SDK's getCollateralDecimals() helper distinguishes between them:

Example: Filling Orders

Last updated