# Orally Price Feed Integration Guide

### Overview

The Orally Price Feed system provides real-time price data from 9 centralized exchanges, secured through ICP canister's trusted execution environment and verified on-chain through ECDSA signatures. This guide explains the integration process and operation flow.

### Initial Setup

1. Generate API Key
   * Visit <https://app.orally.network/sybil>
   * Follow the API key generation process
   * Store the key securely for subsequent requests

### Integration Process

#### Regular Price Monitoring

Your liquidation bot should monitor prices using the following flow:

1. Regular Price Checks
   * Endpoint: `get_xrc_data` or `get_xrc_data_batch`
   * Cost: $0.001 per request
   * Include:
     * API key
     * Cache TTL (default 600 seconds)
     * Target token pair ID
   * Response: Current price feed without proof

#### Price Update Verification

When price changes require on-chain updates:

1. Request Signed Data
   * Endpoint: `get_xrc_data_with_proof`
   * Cost: $0.04 per request
   * Returns: Price data with ECDSA signature from ICP canister
2. On-Chain Verification
   * Submit signed data to Partisia chain
   * Smart contract verifies:
     * ECDSA signature authenticity
     * Signer authorization
     * Data integrity
   * After verification, data is decoded and available for use

### Technical Details

#### Proof Generation

1. ICP canister aggregates price data from exchanges
2. Data is encoded into a standardized format
3. Canister generates ECDSA signature using its DKG key
4. Returns packed data: {price\_data, metadata, signature}

#### Verification Process

1. Smart contract unpacks the provided data
2. Verifies ECDSA signature against authorized signer list
3. Decodes price data for use in smart contract operations

### Cost Structure

* Regular price checks: $0.001 per request
  * Recommended for continuous monitoring
  * Use cache\_ttl to optimize costs
* Signed data requests: $0.04 per request
  * Only needed when updating on-chain values
  * Includes proof generation and ICP canister operations

### Best Practices

#### Optimize Batch Requests

1. Use `get_xrc_data_batch` instead of multiple single requests:
   * Group related price feed queries into a single batch request
   * Example: Query all tokens in a lending pool in one call
   * Reduces total API calls and associated costs
   * Improves overall response time

#### Cache TTL Optimization

1. Regular Price Monitoring:
   * Use longer cache\_ttl (e.g., 600-1800 seconds) for stable pairs
   * Shorter cache\_ttl (60-300 seconds) for volatile pairs
2. Proof Generation:
   * Use the same cache\_ttl as for monitoring requests when requesting proofs&#x20;
   * Ensures fresh data for on-chain updates
   * Balance between data freshness and cost efficiency

**Regular monitoring flow**

```
Copyget_xrc_data_batch (longer cache_ttl)
→ detect significant price change
→ get_xrc_data_with_proof (shorter cache_ttl)
→ submit to chain
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.orally.network/orally-price-feed-integration-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
