# 工作原理

## 前期工作

请参见Chainlink Oracle 接口文档

<https://docs.chain.link/data-feeds/api-reference#aggregatorv3interface> &#x20;

## 支持的Frax资产

目前支持 frxETH/ETH 和 sfrxETH/ETH。

## Frax双 oracle 价格逻辑

### frxEth

frxEth价格是从两个链上价格来源确定的。第一个价格来源是frxEth / ETH Curve池的EMA预言机 - [0xa1f8a6807c402e4a15ef4eba36528a3fed24e577](https://etherscan.io/address/0xa1f8a6807c402e4a15ef4eba36528a3fed24e577)。该价格的最低限制为0.7（0.7 frxEth = 1 ETH），最高限制为1（1 frxEth = 1 ETH）。

第二个价格来源来自Uniswap的frxEth / FRAX池的TWAP预言机 - [0x36C060Cc4b088c830a561E959A679A58205D3F56](https://etherscan.io/address/0x36C060Cc4b088c830a561E959A679A58205D3F56)。然后，我们从这个Chainlink预言机（[0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419](https://etherscan.io/address/0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419)）获取ETH的美元价格，并从这个Chainlink预言机（[0xB9E1E3A9feFf48998E45Fa90847ed4D467E8BcfD](https://etherscan.io/address/0xB9E1E3A9feFf48998E45Fa90847ed4D467E8BcfD)）获取FRAX的美元价格。

这些Chainlink价格用于将frxEth / FRAX池价格转换为frxEth / ETH价格，使用以下公式：

```
ethPerFrxEth = (fraxPerFrxEthUniswapTwap * usdPerFraxChainlink) / usdPerEthChainlink;
```

来自Uniswap的价格同样被限制在0.7和1之间，反映了Curve的价格。

这两个价格中较低的价格被返回为priceLow，较高的价格被返回为priceHigh。这些价格随后被写入frxEth / ETH的Frax预言机中。

### sfrxEth

简单地从sfrxEth合约中检索pricePerShare()，以与上述frxEth双预言机相同的方式检索priceHigh和priceLow，并返回以下方程：

<pre><code><strong>priceLow =  (SFRXETH_ERC4626.pricePerShare() * frxEthEthPriceLow) / 1e18;
</strong>priceHigh = (SFRXETH_ERC4626.pricePerShare() * frxEthEthPriceHigh) / 1e18;
</code></pre>

这是因为`pricePerShare()`返回一个`sfrxEth`值多少个`frxEth`。`pricePerShare()`会随着时间的推移而上涨。

这些价格随后被写入`sfrxEth / ETH`的Frax Oracle。

## 如何使用Chainlink接口 - AggregatorV3Interface

只需在Frax Oracle合约上调用 <https://docs.chain.link/data-feeds/api-reference#getrounddata> 或 <https://docs.chain.link/data-feeds/api-reference#latestrounddata>，以获取您想要价格的资产。

## 二层网络的Frax 预言机

即将到来......


---

# 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.frax.finance/zh/frax-yu-yan-ji/gong-zuo-yuan-li.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.
