-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0559b45
commit 938abd1
Showing
13 changed files
with
524 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
import { DefaultStore } from "../src"; | ||
import { PriceFeed, PriceServiceConnection } from "@pythnetwork/price-service-client"; | ||
import { ethers } from "ethers"; | ||
import { PrivateKey, toPrivateKey } from "../lib"; | ||
import {sleep} from "pyth_relay/lib/helpers"; | ||
|
||
const parser = yargs(hideBin(process.argv)) | ||
.scriptName("update_pricefeed.ts") | ||
.usage( | ||
"Usage: $0" | ||
) | ||
.options({}); | ||
|
||
async function main() { | ||
const mainnetFeedIds = [ | ||
"e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", | ||
"ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace", | ||
"63f341689d98a12ef60a5cff1d7f85c70a9e17bf1575f0e7c0b2512d48b1c8b3", | ||
"7677dd124dee46cfcd46ff03cf405fb0ed94b1f49efbea3444aadbda939a7ad3", | ||
"14eb6f846b84f37c841ce7a52a38706e54966df84b3a09cc40499b164af05672", | ||
"fa2d39b681f3cef5fa87432a8dbd05113917fffb1b6829a37395c88396522a4e", | ||
"7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592", | ||
"abe4f2b264560a397f38eec024369356e5c1ea4f7aab94729369f144b3d97779", | ||
"5fcf71143bb70d41af4fa9aa1287e2efd3c5911cee59f909f915c9f61baacb1e", | ||
"b82449fd728133488d2d41131cffe763f9c1693b73c544d9ef6aaa371060dd25", | ||
]; | ||
|
||
let feedIds: string[] = []; | ||
feedIds = [mainnetFeedIds[0]]; | ||
const defaultEndpoint = "https://xc-mainnet.pyth.network"; | ||
const hermesEndpoint = "http://127.0.0.1:7575"; | ||
|
||
const priceService = new PriceServiceConnection(defaultEndpoint, {verbose: true}); | ||
const hermes = new PriceServiceConnection(hermesEndpoint, {verbose: true}); | ||
|
||
const origUpdates: PriceFeed[] = []; | ||
const hermesUpdates: PriceFeed[] = []; | ||
|
||
let priceServiceSum = 0; | ||
let priceServiceCount = 0; | ||
|
||
priceService.subscribePriceFeedUpdates(feedIds, (feed) => { | ||
const publishTime = feed.getPriceUnchecked().publishTime; | ||
// const now = (new Date()).getTime(); | ||
// const diff = now / 1000 - publishTime; | ||
const receivedTime = feed.getMetadata()?.priceServiceReceiveTime!; | ||
const diff = receivedTime - publishTime; | ||
|
||
priceServiceSum += diff; | ||
priceServiceCount += 1; | ||
|
||
console.log(`p: ${priceServiceSum/priceServiceCount} ${diff} ${feed.getPriceUnchecked().price} ${JSON.stringify(feed.getMetadata())}`) | ||
origUpdates.push(feed); | ||
}) | ||
|
||
let hermesSum = 0; | ||
let hermesCount = 0; | ||
|
||
hermes.subscribePriceFeedUpdates(feedIds, (feed) => { | ||
const publishTime = feed.getPriceUnchecked().publishTime; | ||
// const now = (new Date()).getTime(); | ||
// const diff = now / 1000 - publishTime; | ||
const receivedTime = feed.getMetadata()?.priceServiceReceiveTime!; | ||
const diff = receivedTime - publishTime; | ||
|
||
hermesSum += diff; | ||
hermesCount += 1; | ||
console.log(`h: ${hermesSum/hermesCount} ${diff} ${feed.getPriceUnchecked().price} ${JSON.stringify(feed.getMetadata())}`) | ||
hermesUpdates.push(feed); | ||
}) | ||
} | ||
|
||
main(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Oops, something went wrong.