> For the complete documentation index, see [llms.txt](https://pangeaswap.gitbook.io/pangeaswap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pangeaswap.gitbook.io/pangeaswap/developers/contracts/price-oracle.md).

# Price Oracle

토큰의 가격과 유동성 포지션의 자산 가치에 대한 평가는 LP 의 포트폴리오 운영에 있어서 중요한 요소입니다. LP 는 유동성 포지션을 생성한 후에 지속적으로 해당 포지션의 가치 변화를 주시하며 추가예치/유지/인출 등의 의사결정을 내릴 수 있어야 합니다. 이를 위해 판게아 스왑에서는 Price Oracle 을 활용하여 토큰의 가격과 유동성 포지션의 가치에 대한 정보를 유저에게 제공합니다.

판게아 스왑에서는 토큰을 `Base Token` 과 `Derived Token` 으로 분류하고 서로 다른 방식으로 가격을 계산합니다.

외부 오라클인 [Witnet](https://witnet.io/) 을 이용하여 가격을 직접 받아올 수 있는 토큰을 `Base Token` 으로 분류하며, KLAY 와 USDT 가 이에 해당합니다. 그 외의 토큰들을 `Derived Token` 으로 분류하며, 클레이튼 생태계 내 유동성 풀들의 교환비를 통해 그 가격을 계산합니다. 보다 구체적으로는 Klayswap, Claimswap, Pala 등 8개 DEX 의 유동성 풀들의 Reserve 의 비율을 토대로 `Derived Token`의 가격을 계산합니다.

토큰의 가격은 스왑이 발생할 때마다 실시간으로 변화하기 때문에 매 스팟 시점 기준으로 가치를 평가했을 때에는 volatility 가 지나치게 커질 수 있습니다. 이 부분을 완화하기 위해 판게아 스왑에서 보여지는 토큰의 가격은 SMA(Simple Moving Average) 방식으로 계산한 10여분 간의 가격 평균을 이용합니다. 보다 구체적으로는 클레이튼 네트워크는 128 Block 단위로 과거 시점의 데이터를 조회할 수 있어 640(128\*5) Block 사이의 5개 관측값의 평균으로 가격을 계산합니다.

이러한 처리의 과정들은 아래의 repository 에 공개되어 있습니다. 향후 Chainlink 등 다양한 외부 오라클이 추가됨에 따라 보다 고도화될 예정입니다.

{% embed url="<https://github.com/pangea-protocol/pangea-onchain-price-oracle>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://pangeaswap.gitbook.io/pangeaswap/developers/contracts/price-oracle.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
