For the complete documentation index, see llms.txt. This page is also available as Markdown.

가격 읽기

PriceFeed 컨트랙트 주소를 찾고, Chainlink 인터페이스로 연결하여 적절한 검증과 함께 현재 가격을 조회합니다.

1단계: 오라클 주소 찾기

주어진 쌍의 PriceFeed 컨트랙트 주소를 찾는 세 가지 방법:

  • Price Oracle Tracker (개발 중 가장 간편): price-oracle-tracker.vercel.app — 배포된 모든 쌍, 실시간 가격, decimals, heartbeat, 주소를 표시합니다.

  • OracleFactory를 통한 온체인 조회: pairToOracle(string pair) 호출. 쌍 심볼은 대문자로 전달해야 합니다(예: "PSG/USDT") — 팩토리는 읽기 시 입력값을 정규화하지 않습니다.

  • OracleFactoryReader를 통한 대량 온체인 조회: getActiveOracles()를 호출하여 모든 활성 쌍과 해당 주소를 한 번에 조회합니다.

interface IOracleFactory {
    function pairToOracle(string memory pair) external view returns (address);
    function getOracleCount() external view returns (uint256);
}

function resolveFeed(address factory, string memory pair)
    external view returns (address)
{
    // Pair symbol must be passed in uppercase (e.g. "PSG/USDT").
    return IOracleFactory(factory).pairToOracle(pair);
}

2단계: 인터페이스로 연결하기

PriceFeed 컨트랙트는 표준 Chainlink IAggregatorV3Interface와 함께 상태 및 일시 정지 상태를 위한 Chiliz 전용 확장을 구현합니다.

3단계: 가격 읽기

기본 함수는 latestRoundData()로, 현재 가격을 round 및 타임스탬프 메타데이터와 함께 반환합니다.

프로토콜이 18 decimals로 정규화하지 않고 피드의 기본 decimals를 사용하는 경우:

과거 데이터

오라클은 모든 과거 round 데이터를 온체인에 저장합니다. 각 가격 업데이트는 증가하는 roundId와 함께 새로운 round를 생성합니다.

Chiliz 피드가 제공하는 추가 헬퍼 뷰:

함수
반환값

latestAnswer()

최신 가격, 없으면 0

latestTimestamp()

최신 updatedAt, 없으면 0

latestRound()

현재 round ID

getAnswer(uint80 roundId)

특정 round의 가격, 없으면 0

getTimestamp(uint80 roundId)

특정 round의 타임스탬프, 없으면 0

getRoundsData(uint80[] roundIds)

대량 RoundData 배열

roundExists(uint80 roundId)

updatedAt > 0이면 true

이벤트

PriceFeed 컨트랙트는 다음을 emit합니다:

  • AnswerUpdated(int256 indexed current, uint80 indexed roundId, uint256 updatedAt): 모든 가격 업데이트 시 emit됩니다. 가격 또는 round로 필터링할 수 있습니다.

  • NewRound(uint80 indexed roundId, address indexed startedBy, uint256 startedAt): 새 round 시작 시 emit됩니다. round 또는 시작한 주소로 필터링할 수 있습니다.

검색 함수 (OracleFactoryReader)

함수
설명

getActiveOracles()

모든 활성 쌍과 오라클 주소를 반환합니다

getAllOracles()

비활성 오라클을 포함한 모든 오라클을 반환합니다

getOraclesByPairs(string[] pairs)

여러 쌍 이름을 한 번의 호출로 오라클 주소로 변환합니다

getOracleHealthStatus(address oracle)

단일 오라클의 상태를 반환합니다

getAllOracleHealthStatus()

시스템의 모든 오라클 상태를 반환합니다

마지막 업데이트

도움이 되었나요?