본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)7.0k · #13680

pyth

하는 일

이 스킬은 Solana 프로그램과 오프체인 앱에서 Pyth Network 가격 피드를 쓰는 방법을 안내합니다. 신뢰할 수 있는 실시간 가격이 필요한 DeFi나 트레이딩 기능을 만드는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓Solana 앱에 오라클에서 오는 실시간 자산 가격이 필요할 때.
  • ✓프로그램에서 신뢰 구간이나 EMA 가격을 쓰고 싶을 때.
  • ✓Hermes를 통해 오프체인에서 가격 업데이트를 가져와야 할 때.

스킬 링크

https://github.com/internet-court/internet-court-skill/blob/main/vendored/sendaifun/pyth/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/internet-court/internet-court-skill/blob/main/vendored/sendaifun/pyth/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Solana 프로그램에서 Pyth의 BTC/USD 가격을 읽고, 그 가격이 얼마나 신뢰할 만한지 확인해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 자산에 맞는 피드 ID를 쓰고, CPI 호출이나 오프체인 API로 신뢰 구간과 함께 가격을 읽은 뒤, 사용하기 전에 업데이트를 확인합니다. pull 모델을 쉬운 말로 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Pyth Network Development Guide

Pyth Network is a decentralized oracle providing real-time price feeds for cryptocurrencies, equities, forex, and commodities. This guide covers integrating Pyth price feeds into Solana applications.

Overview

Pyth Network provides:

  • Real-Time Price Feeds - 400ms update frequency with pull oracle model
  • Confidence Intervals - Statistical uncertainty bounds for each price
  • EMA Prices - Exponential moving average prices (~1 hour window)
  • Multi-Asset Support - Crypto, equities, FX, commodities, indices
  • On-Chain Integration - CPI for Solana programs
  • Off-Chain Integration - HTTP and WebSocket APIs via Hermes

Program IDs

Program Address Description
Solana Receiver rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ Posts price updates to Solana
Price Feed pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT Stores price feed data

Deployed on: Solana Mainnet, Devnet, Eclipse Mainnet/Testnet, Sonic networks

Popular Price Feed IDs

Asset Hex Feed ID
BTC/USD 0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43
ETH/USD 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
SOL/USD 0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d
USDC/USD 0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a
USDT/USD 0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b

Full list: https://pyth.network/developers/price-feed-ids

Quick Start

Installation

# TypeScript/JavaScript
npm install @pythnetwork/hermes-client @pythnetwork/pyth-solana-receiver

# Rust (add to Cargo.toml)
# pyth-solana-receiver-sdk = "0.3.0"

Fetch Price (Off-Chain)

import { HermesClient } from "@pythnetwork/hermes-client";

const client = new HermesClient("https://hermes.pyth.network");

const priceIds = [
  "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", // BTC/USD
];

const priceUpdates = await client.getLatestPriceUpdates(priceIds);

for (const update of priceUpdates.parsed) {
  const price = update.price;
  const displayPrice = Number(price.price) * Math.pow(10, price.expo);
  console.log(`Price: $${displayPrice.toFixed(2)}`);
  console.log(`Confidence: ±${Number(price.conf) * Math.pow(10, price.expo)}`);
}

Use Price On-Chain (Rust/Anchor)

use anchor_lang::prelude::*;
use pyth_solana_receiver_sdk::price_update::PriceUpdateV2;

#[derive(Accounts)]
pub struct UsePrice<'info> {
    pub price_update: Account<'info, PriceUpdateV2>,
}

pub fn use_price(ctx: Context<UsePrice>) -> Result<()> {
    let price_update = &ctx.accounts.price_update;
    let clock = Clock::get()?;

    // Get price no older than 60 seconds
    let price = price_update.get_price_no_older_than(
        &clock,
        60, // max age in seconds
    )?;

    msg!("Price: {} × 10^{}", price.price, price.exponent);
    msg!("Confidence: ±{}", price.conf);

    Ok(())
}

Core Concepts

Price Structure

Each Pyth price contains:

Field Type Description
price i64 Price value in fixed-point format
conf u64 Confidence interval (standard deviation)
expo i32 Exponent for scaling (e.g., -8 means divide by 10^8)
publish_time i64 Unix timestamp of price

Converting to display price:

const displayPrice = price * Math.pow(10, expo);
// Example: price=19405100, expo=-2 → $194,051.00

Confidence Intervals

Confidence intervals represent the uncertainty in the reported price:

// Price is $50,000 ± $50 means:
// - 68% chance true price is between $49,950 - $50,050
// - Use confidence for risk management

const price = 50000;
const confidence = 50;

// Safe lower bound (conservative)
const safeLowerBound = price - confidence;

// Safe upper bound (conservative)
const safeUpperBound = price + confidence;

Best Practice: Reject prices with confidence > 2% of price:

const maxConfidenceRatio = 0.02; // 2%
const confidenceRatio = confidence / Math.abs(price);

if (confidenceRatio > maxConfidenceRatio) {
  throw new Error("Price confidence too wide");
}

EMA Prices

Exponential Moving Average prices smooth out short-term volatility:

  • ~1 hour averaging window (5921 Solan
자주 묻는 질문

신뢰 구간은 무엇을 뜻하나요?

각 가격 주변의 불확실성을 나타내는 통계적 범위라고 스킬은 설명합니다.

Pyth는 어떤 네트워크에 있나요?

Solana 메인넷과 devnet, 그리고 일부 다른 네트워크에 배포되어 있다고 스킬은 말합니다.

가격은 얼마나 자주 업데이트되나요?

pull 오라클 모델에서 400밀리초 업데이트 주기를 언급합니다.

상세 정보

작성자의 원본 설명

Complete guide for Pyth Network - decentralized oracle providing real-time price feeds for DeFi. Covers price feed integration, confidence intervals, EMA prices, on-chain CPI, off-chain fetching, and streaming updates for Solana applications.

repo: internet-court/internet-court-skill

인기도

GitHub 스타
7.0k
순위
#13680
라이선스
—
업데이트
2026. 10. 26.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬