基于区块链的毕业设计Price feed for stETH/ETH pair – stETH/ETH对的价格馈送

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Price feed for stETH/ETH pair – stETH/ETH对的价格馈送 是一篇很好的国外资料

Price feed for stETH/ETH pair

The feed is used to fetch stETH/ETH pair price in a safe manner, which means that the price should be expensive to significantly manipulate in any direction.

The price is defined as the amount of ETH wei needed to buy 1 stETH. For example, a price equal to 10**18 would mean that stETH is pegged 1:1 to ETH.

  • Current price—current price of stETH on Curve pool. Flashloanable.
  • Historical price—the price of stETH on Curve pool that was at least 15 blocks ago. May be older than 15 blocks: in that case, the pool price that was 15 blocks ago differs from the “historical price” by no more than N%.
  • Safe price range—the range from historical price - N% to min(historical price + N%, 1).
  • Safe price—the price that’s within the safe price range.

The parameter N is configured by the price feed admin; we’re planning to initially set it to 5%. See the detailed specification in specification.md.

Price feed interface

  • safe_price() -> (price: uint256, timestamp: uint256) returns the cached safe price and its timestamp.

  • current_price() -> (price: uint256, is_safe: bool) returns the current pool price and whether the price is safe.

  • update_safe_price() -> uint256 sets the cached safe price to the max(current pool price, 1) given that the latter is safe.

  • fetch_safe_price(max_age: uint256) -> (price: uint256, timestamp: uint256) returns the cached safe price and its timestamp. Calls update_safe_price() prior to that if the cached safe price is older than max_age seconds.

Deploy variables

  • DEPLOYER required
  • STABLE_SWAP_ORACLE_ADDRESS required, address of stable swap oracle
  • CURVE_POOL_ADDRESS required, address of curve pool
  • MAX_SAFE_PRICE_DIFFERENCE optional, min:0, max:10000, default to 500
  • ADMIN optional, default to DEPLOYER

Price feed接口

feed用于以安全的方式获取stETH/ETH对价格,这意味着在任何方向上显著操纵价格都是昂贵的

价格的定义是购买1英镑所需的金额。例如,等于10**18的价格意味着stETH与ETH的比例为1:1

  • 曲线池上stETH的当前价格。Flashloanable的
  • 安全价格范围从历史价格-N%到最小值(历史价格+N%,1)的范围
  • 安全价格在安全价格范围内的价格
  • 安全价格()-&gt(price:uint256,timestamp:uint256)返回缓存的安全价格及其时间戳

参数N由price feed admin配置;我们计划一开始把它设为5%。具体规格见specification.md.

部署变量

  • 当前价格()-&gt(price:uint256,is u safe:bool)返回当前池价格以及该价格是否安全
  • 更新安全价格()->uint256将缓存的安全价格设置为最大值(当前池价格,1),前提是后者是安全的
  • 获取安全价格(最大年龄:uint256)—&gt(price:uint256,timestamp:uint256)返回缓存的安全价格及其时间戳。如果缓存的安全价格早于maxu age seconds,则在此之前调用updateu safeu price()
  • 需要部署者

Deploy variables

  • 需要稳定交换ORACLE地址,需要稳定交换ORACLE地址
  • 需要曲线池地址,需要曲线池地址
  • 最大安全价差可选,min:0, max:10000,默认为500,管理可选,默认为DEPLOYER
  • MAX_SAFE_PRICE_DIFFERENCE optional, min:0, max:10000, default to 500
  • ADMIN optional, default to DEPLOYER

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/21812.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计Price feed for stETH/ETH pair – stETH/ETH对的价格馈送

提供最优质的资源集合

立即查看 了解详情