From 7f05ff611cbe4e2486b3c6c056ed17eba8213fcf Mon Sep 17 00:00:00 2001 From: Aditya Arora Date: Tue, 4 Mar 2025 00:24:47 -0500 Subject: [PATCH 1/3] chore(pricefeed) Add morpho guide --- pages/price-feeds/_meta.json | 1 + pages/price-feeds/use-pyth-for-morpho.mdx | 54 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 pages/price-feeds/use-pyth-for-morpho.mdx diff --git a/pages/price-feeds/_meta.json b/pages/price-feeds/_meta.json index c860a060..2b1c74c9 100644 --- a/pages/price-feeds/_meta.json +++ b/pages/price-feeds/_meta.json @@ -24,6 +24,7 @@ }, "use-real-time-data": "Use Real-Time Price Data", + "use-pyth-for-morpho": "Use Pyth for Morpho Markets", "fetch-price-updates": "Fetch Price Updates", "schedule-price-updates": "Schedule Price Updates", "migrate-an-app-to-pyth": "Migrate an App to Pyth", diff --git a/pages/price-feeds/use-pyth-for-morpho.mdx b/pages/price-feeds/use-pyth-for-morpho.mdx new file mode 100644 index 00000000..60b1065f --- /dev/null +++ b/pages/price-feeds/use-pyth-for-morpho.mdx @@ -0,0 +1,54 @@ +import { Steps } from "nextra/components"; + +# How to use Pyth for Morpho Markets + +At the time of writing, Morpho supports an [oracle interface](https://github.com/morpho-org/morpho-blue-oracles/tree/main/src) similar to ChainlinkAggregatorV3Interface. + +This guide will show how you can leverage Pyth real time price data to power Morpho markets. + +There are three main steps to use Pyth price feeds for Morpho markets: + +1. Deploy the [`PythAggregatorV3`](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/sdk/solidity/PythAggregatorV3.sol) contract to provide a Chainlink-compatible feed interface. +2. Run the price pusher or scheduler +3. Deploy the Morpho oracle contract + + + +### Deploy the `PythAggregatorV3` contract + +Pyth provides a wrapper called `PythAggregatorV3` that implements the ChainlinkAggregatorV3Interface. +This wrapper allows you to use Pyth price feeds with Morpho markets. +[Migrate from Chainlink to Pyth](./migrate-an-app-to-pyth/chainlink.md) explains how to deploy the `PythAggregatorV3` contract. + +You can use the forge [script](https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/script/PythAggregatorV3Deployment.s.sol) from the [pyth-examples](https://github.com/pyth-network/pyth-examples/tree/main/price_feeds/evm/chainlink_migration) directory to deploy the `PythAggregatorV3` contract. + +```bash +forge script script/PythAggregatorV3Deployment.s.sol --rpc-url $RPC_URL --broadcast --verify +``` + +This script will deploy the `PythAggregatorV3` contract and verify it on the target chain. +You have to run the script for both `BASE` and `QUOTE` price feeds. + +### Run the price pusher or scheduler + +As a pull oracle, Pyth's users are typically responsible for updating the state of on-chain feeds. +Please see [What is a Pull Oracle?](/price-feeds/pull-updates) to learn more about pull updates. + +If you are using the `PythAggregatorV3` contract, you must push price updates to the contract at regular intervals. +The Pyth Data Association sponsors regular on-chain updates for some price feeds. +See [Sponsored Feeds](./sponsored-feeds.mdx) for the current list of feeds and their update parameters. + +If you don't find relevant price feeds in the [Sponsored Feeds](./sponsored-feeds.mdx) list, you can run the scheduler/price pusher for the price feed you need. + +Please see [Schedule Price Updates](./schedule-price-updates.mdx) for more information on how to schedule price updates. + +### Deploy the Morpho oracle contract + +After deploying the `PythAggregatorV3` contract and scheduling price updates, you can deploy the Morpho oracle contract with the address of the `PythAggregatorV3` contract. + +Please refer to the [Morpho documentation](https://docs.morpho.org/morpho/tutorials/deploy-an-oracle/) for more information on how to deploy the Morpho oracle contract. + + + + + From 9daaec0ff2e122ea2c53c492ca84d64fa2a94d21 Mon Sep 17 00:00:00 2001 From: Aditya Arora Date: Tue, 4 Mar 2025 10:42:52 -0500 Subject: [PATCH 2/3] update --- pages/price-feeds/use-pyth-for-morpho.mdx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/pages/price-feeds/use-pyth-for-morpho.mdx b/pages/price-feeds/use-pyth-for-morpho.mdx index 60b1065f..7448abbe 100644 --- a/pages/price-feeds/use-pyth-for-morpho.mdx +++ b/pages/price-feeds/use-pyth-for-morpho.mdx @@ -2,15 +2,16 @@ import { Steps } from "nextra/components"; # How to use Pyth for Morpho Markets -At the time of writing, Morpho supports an [oracle interface](https://github.com/morpho-org/morpho-blue-oracles/tree/main/src) similar to ChainlinkAggregatorV3Interface. - This guide will show how you can leverage Pyth real time price data to power Morpho markets. -There are three main steps to use Pyth price feeds for Morpho markets: +At the time of writing, Morpho supports an [oracle interface](https://github.com/morpho-org/morpho-blue-oracles/tree/main/src) similar to [ChainlinkAggregatorV3Interface](https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol). +We need to wrap the Pyth oracle with this interface to use it with Morpho. + +There are three steps to use Pyth price feeds for Morpho markets: 1. Deploy the [`PythAggregatorV3`](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/sdk/solidity/PythAggregatorV3.sol) contract to provide a Chainlink-compatible feed interface. -2. Run the price pusher or scheduler -3. Deploy the Morpho oracle contract +2. Run the price pusher or scheduler. +3. Deploy the Morpho oracle contract. @@ -22,7 +23,7 @@ This wrapper allows you to use Pyth price feeds with Morpho markets. You can use the forge [script](https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/script/PythAggregatorV3Deployment.s.sol) from the [pyth-examples](https://github.com/pyth-network/pyth-examples/tree/main/price_feeds/evm/chainlink_migration) directory to deploy the `PythAggregatorV3` contract. -```bash +```bash copy forge script script/PythAggregatorV3Deployment.s.sol --rpc-url $RPC_URL --broadcast --verify ``` @@ -38,17 +39,14 @@ If you are using the `PythAggregatorV3` contract, you must push price updates to The Pyth Data Association sponsors regular on-chain updates for some price feeds. See [Sponsored Feeds](./sponsored-feeds.mdx) for the current list of feeds and their update parameters. -If you don't find relevant price feeds in the [Sponsored Feeds](./sponsored-feeds.mdx) list, you can run the scheduler/price pusher for the price feed you need. +If you don't find relevant price IDs in the [Sponsored Feeds](./sponsored-feeds.mdx) list, you can run the scheduler/price pusher for the price feed you need. Please see [Schedule Price Updates](./schedule-price-updates.mdx) for more information on how to schedule price updates. ### Deploy the Morpho oracle contract -After deploying the `PythAggregatorV3` contract and scheduling price updates, you can deploy the Morpho oracle contract with the address of the `PythAggregatorV3` contract. +After deploying the `PythAggregatorV3` contract and scheduling price updates, you can deploy the Morpho oracle contract with the address of the `PythAggregatorV3` contract deployed in the first step. Please refer to the [Morpho documentation](https://docs.morpho.org/morpho/tutorials/deploy-an-oracle/) for more information on how to deploy the Morpho oracle contract. - - - From 895c099a448a73a55a6c93a0ea4655ed712484cd Mon Sep 17 00:00:00 2001 From: Aditya Arora Date: Tue, 4 Mar 2025 10:43:49 -0500 Subject: [PATCH 3/3] update --- pages/price-feeds/_meta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/price-feeds/_meta.json b/pages/price-feeds/_meta.json index 2b1c74c9..8c2d4ea1 100644 --- a/pages/price-feeds/_meta.json +++ b/pages/price-feeds/_meta.json @@ -24,10 +24,10 @@ }, "use-real-time-data": "Use Real-Time Price Data", - "use-pyth-for-morpho": "Use Pyth for Morpho Markets", "fetch-price-updates": "Fetch Price Updates", "schedule-price-updates": "Schedule Price Updates", "migrate-an-app-to-pyth": "Migrate an App to Pyth", + "use-pyth-for-morpho": "Use Pyth for Morpho Markets", "publish-data": "Publish Data", "troubleshoot": "Troubleshoot Errors",