OstiumBuilder Service
Getting Started

Data Types & Formatting

Understanding data types, precision, and formatting requirements.

Alpha Version

The Ostium Builder Service is in Alpha. API endpoints, specifications, and builder URLs may change without notice. Use with caution in production environments.

Important Data Types

Prices and USD Amounts

  • Type: String
  • Purpose: Preserve precision
  • Example: "42500.25", "0.0001"
  • Note: Always use strings for monetary values to avoid floating-point precision issues

Leverage

  • Type: String
  • Example: "10" for 10x leverage
  • Valid range: Typically "1" to "100"

Sizes and Quantities

  • Type: String
  • Purpose: Preserve precision for fractional amounts
  • Example: "100.5", "0.001"

Indexes

  • Type: Integer
  • Used in: Asset index (a), position index (i), order type (t), order index (o)
  • Example: 0, 1, 2

Addresses

  • Type: String
  • Format: 0x-prefixed 40 hex characters
  • Example: "0x1234567890123456789012345678901234567890"
  • Case: Not case-sensitive

Timestamps

  • Type: Number (Unix timestamp in seconds)
  • Example: 1672531200

Transaction Data

  • Type: String
  • Format: 0x-prefixed hex string
  • Example: "0xabcdef..."

Request Format Examples

Open Position

{
  "open": {
    "a": 0,           // asset index (integer)
    "b": true,        // is long (boolean)
    "p": "42500",     // price (string)
    "s": "100",       // size (string)
    "l": "10",        // leverage (string)
    "t": "market"     // order type (string)
  }
}

Modify Position

{
  "modifies": [
    {
      "i": 0,           // position index (integer)
      "tp": "45000",    // take profit (string)
      "sl": "40000"     // stop loss (string)
    }
  ]
}

Common Validation Rules

  1. Strings for Precision: Always use strings for prices, sizes, and leverage
  2. Integer Indexes: Position, asset, and order indexes must be integers
  3. Valid Addresses: Must be properly formatted Ethereum addresses
  4. Non-negative Values: Sizes and leverage must be positive
  5. Reasonable Ranges: Values should be within reasonable trading ranges

Error Responses

If data types are incorrect, you'll receive validation errors:

{
  "error": "Validation failed",
  "errorCode": "VALIDATION_ERROR",
  "details": {
    "open.p": "Expected string, received number"
  }
}

On this page