-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pricefeed) Deploy morph mainnet (#2061)
* chore(pricefeed) Deploy morph mainnet * pre-commit * pnpm-lock update
- Loading branch information
Showing
9 changed files
with
438 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
import { HermesClient, PriceFeedMetadata } from "@pythnetwork/hermes-client"; | ||
import { DefaultStore, toPrivateKey } from "../src"; | ||
|
||
const parser = yargs(hideBin(process.argv)) | ||
.usage("Update the set of price feeds in a network. Usage: $0") | ||
.options({ | ||
"private-key": { | ||
type: "string", | ||
demandOption: true, | ||
desc: "Private key to sign the transactions with", | ||
}, | ||
contract: { | ||
type: "string", | ||
demandOption: true, | ||
desc: "Contract to update price feeds for (e.g mumbai_0xff1a0f4744e8582DF1aE09D5611b887B6a12925C)", | ||
}, | ||
endpoint: { | ||
type: "string", | ||
desc: "Hermes endpoint to use, defaults to https://hermes.pyth.network", | ||
}, | ||
}); | ||
|
||
// This script is intended to update all pricefeeds after we deploy pyth pricefeeds contract. | ||
// It will fetch all pricefeeds from hermes and update the pricefeeds contract with the new pricefeeds. | ||
async function main() { | ||
const argv = await parser.argv; | ||
let priceFeedsMetadata: PriceFeedMetadata[] = []; | ||
const client = new HermesClient( | ||
argv.endpoint || "https://hermes.pyth.network" | ||
); | ||
const contract = DefaultStore.contracts[argv.contract]; | ||
const privateKey = toPrivateKey(argv["private-key"]); | ||
|
||
priceFeedsMetadata = await client.getPriceFeeds(); | ||
|
||
const priceFeedIds = priceFeedsMetadata.map((feed) => feed.id); | ||
console.log(`Fetched ${priceFeedIds.length} price feed IDs`); | ||
|
||
// We can adjust the chunk size based on the chain. Don't exceed 150 for now. | ||
// TODO: Add a check for the chain's block gas limit and adjust the chunk size accordingly. | ||
const chunkSize = 150; | ||
for (let i = 0; i < priceFeedIds.length; i += chunkSize) { | ||
const chunk = priceFeedIds.slice(i, i + chunkSize); | ||
console.log(`length: ${chunk.length}`); | ||
const updates = await client.getLatestPriceUpdates(chunk, { | ||
parsed: false, | ||
}); | ||
console.log( | ||
await contract.executeUpdatePriceFeed( | ||
privateKey, | ||
updates.binary.data.map((update) => Buffer.from(update, "hex")) | ||
) | ||
); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters