chore(eth): update mentions to evm-testnet and hermes-beta (#1151)
We have deployed new Pyth contracts on testnets using the stable feeds and users no longer need to use hermes-beta in many networks. This change updates the mentions to them.
This commit is contained in:
parent
2b118c1f9c
commit
ff0d9fe65c
|
@ -25,7 +25,7 @@ const parser = yargs(hideBin(process.argv))
|
|||
},
|
||||
endpoint: {
|
||||
type: "string",
|
||||
desc: "Hermes endpoint to use, defaults to https://hermes.pyth.network for mainnet and https://hermes-beta.pyth.network for testnet",
|
||||
desc: "Hermes endpoint to use, defaults to https://hermes.pyth.network",
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -39,11 +39,8 @@ async function main() {
|
|||
)}`
|
||||
);
|
||||
}
|
||||
const defaultEndpoint = contract.getChain().isMainnet()
|
||||
? "https://hermes.pyth.network"
|
||||
: "https://hermes-beta.pyth.network";
|
||||
const priceService = new PriceServiceConnection(
|
||||
argv.endpoint || defaultEndpoint
|
||||
argv.endpoint || "https://hermes.pyth.network"
|
||||
);
|
||||
const vaas = await priceService.getLatestVaas(argv["feed-id"] as string[]);
|
||||
const privateKey = toPrivateKey(argv["private-key"]);
|
||||
|
|
|
@ -73,6 +73,12 @@ Two sample YAML configuration files are available in the root of this repo.
|
|||
You can get the list of available price feeds from
|
||||
[here](https://pyth.network/developers/price-feed-ids/).
|
||||
|
||||
Price pusher communicates with [Hermes][] price service to get the most recent price updates. Hermes listens to the
|
||||
Pythnet and Wormhole network to get latest price updates, and serves REST and websocket APIs for consumers to fetch the
|
||||
updates. Pyth hosts public endpoints for Hermes; however, it is recommended to get a private endpoint from one of the
|
||||
Hermes RPC providers for more reliability. Please refer to [this
|
||||
document](https://docs.pyth.network/documentation/pythnet-price-feeds/hermes) for more information.
|
||||
|
||||
To run the price pusher, please run the following commands, replacing the command line arguments as necessary:
|
||||
|
||||
```sh
|
||||
|
@ -86,7 +92,7 @@ cd price_pusher
|
|||
# For EVM
|
||||
npm run start -- evm --endpoint wss://example-rpc.com \
|
||||
--pyth-contract-address 0xff1a0f4744e8582DF...... \
|
||||
--price-service-endpoint https://example-pyth-price.com \
|
||||
--price-service-endpoint https://example-hermes-rpc.com \
|
||||
--price-config-file "path/to/price-config.testnet.sample.yaml" \
|
||||
--mnemonic-file "path/to/mnemonic.txt" \
|
||||
[--pushing-frequency 10] \
|
||||
|
@ -95,7 +101,7 @@ npm run start -- evm --endpoint wss://example-rpc.com \
|
|||
|
||||
# For Injective
|
||||
npm run start -- injective --grpc-endpoint https://grpc-endpoint.com \
|
||||
--pyth-contract-address inj1z60tg0... --price-service-endpoint "https://example-pyth-price.com" \
|
||||
--pyth-contract-address inj1z60tg0... --price-service-endpoint "https://example-hermes-rpc.com" \
|
||||
--price-config-file "path/to/price-config.testnet.sample.yaml" \
|
||||
--mnemonic-file "path/to/mnemonic.txt" \
|
||||
--network testnet \
|
||||
|
@ -104,7 +110,8 @@ npm run start -- injective --grpc-endpoint https://grpc-endpoint.com \
|
|||
|
||||
# For Aptos
|
||||
npm run start -- aptos --endpoint https://fullnode.testnet.aptoslabs.com/v1 \
|
||||
--pyth-contract-address 0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387 --price-service-endpoint "https://hermes-beta.pyth.network" \
|
||||
--pyth-contract-address 0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387 \
|
||||
--price-service-endpoint "https://example-hermes-rpc.com" \
|
||||
--price-config-file "./price-config.testnet.sample.yaml" \
|
||||
--mnemonic-file "path/to/mnemonic.txt" \
|
||||
[--pushing-frequency 10] \
|
||||
|
@ -118,7 +125,7 @@ npm run start -- sui \
|
|||
--wormhole-package-id 0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e \
|
||||
--wormhole-state-id 0xebba4cc4d614f7a7cdbe883acc76d1cc767922bc96778e7b68be0d15fce27c02 \
|
||||
--price-feed-to-price-info-object-table-id 0xf8929174008c662266a1adde78e1e8e33016eb7ad37d379481e860b911e40ed5 \
|
||||
--price-service-endpoint https://hermes-beta.pyth.network \
|
||||
--price-service-endpoint https://example-hermes-rpc.com \
|
||||
--mnemonic-file ./mnemonic \
|
||||
--price-config-file ./price-config.testnet.sample.yaml \
|
||||
[--pushing-frequency 10] \
|
||||
|
@ -130,6 +137,8 @@ npm run start -- sui \
|
|||
docker run public.ecr.aws/pyth-network/xc-price-pusher:v<version> -- <above-arguments>
|
||||
```
|
||||
|
||||
[hermes]: https://github.com/pyth-network/pyth-crosschain/tree/main/hermes
|
||||
|
||||
### Command Line Arguments
|
||||
|
||||
To know more about the arguments the price-pusher accepts. You can run:
|
||||
|
@ -146,14 +155,17 @@ npm run start -- {network} --help
|
|||
For example, to push `BTC/USD` and `BNB/USD` prices on Fantom testnet, run the following command:
|
||||
|
||||
```sh
|
||||
npm run dev -- evm --endpoint https://endpoints.omniatech.io/v1/fantom/testnet/public \
|
||||
--pyth-contract-address 0xff1a0f4744e8582DF1aE09D5611b887B6a12925C --price-service-endpoint https://hermes-beta.pyth.network \
|
||||
--mnemonic-file "./mnemonic" --price-config-file "./price-config.testnet.sample.yaml"
|
||||
npm run dev -- evm \
|
||||
--endpoint https://endpoints.omniatech.io/v1/fantom/testnet/public \
|
||||
--pyth-contract-address 0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb \
|
||||
--price-service-endpoint https://hermes.pyth.network \
|
||||
--mnemonic-file "./mnemonic" \
|
||||
--price-config-file "./price-config.stable.sample.yaml"
|
||||
```
|
||||
|
||||
[`price-config.testnet.sample.yaml`](./price-config.testnet.sample.yaml) contains configuration for `BTC/USD`
|
||||
and `BNB/USD` price feeds on Pyth testnet. [`price-config.mainnet.sample.yaml`](./price-config.mainnet.sample.yaml)
|
||||
contains the same configuration for `BTC/USD` and `BNB/USD` on Pyth mainnet.
|
||||
[`price-config.stable.sample.yaml`](./price-config.stable.sample.yaml) contains configuration for `BTC/USD`
|
||||
and `BNB/USD` price feeds on Pyth stable data sources. [`price-config.beta.sample.yaml`](./price-config.beta.sample.yaml)
|
||||
contains the same configuration for `BTC/USD` and `BNB/USD` on Pyth beta data sources.
|
||||
|
||||
You can also provide a config file instead of providing command line options, run the following command:
|
||||
|
||||
|
@ -163,30 +175,22 @@ npm run start -- injective --config "./config.injective.sample.json"
|
|||
|
||||
[`config.injective.sample.json`](./config.injective.sample.json) contains configuration to publish on Injective testnet.
|
||||
|
||||
## Running using a standalone price service (via docker-compose)
|
||||
## Running via docker-compose
|
||||
|
||||
Price pusher communicates with [Pyth price service][] to get the most recent price updates. Pyth price service listens to the
|
||||
Wormhole network to get latest price updates, and serves REST and websocket APIs for consumers to fetch the updates.
|
||||
Pyth hosts public endpoints for the price service; however, it is recommended to run it standalone to achieve more resiliency and
|
||||
scalability.
|
||||
This directory contains sample docker compose files ([stable](./docker-compose.stable.sample.yaml),
|
||||
[beta](./docker-compose.beta.sample.yaml)) a price pusher.
|
||||
|
||||
This directory contains sample docker compose files ([testnet](./docker-compose.testnet.sample.yaml),
|
||||
[mainnet](./docker-compose.mainnet.sample.yaml)) a price pusher and its dependencies, including a
|
||||
price service and a Wormhole spy. A price service depends on a Wormhole spy. A spy listens to the Wormhole
|
||||
network and reports all Pyth-related Wormhole messages to the price service.
|
||||
|
||||
To run the services via docker-compose, please modify the your target network (testnet, mainnet) sample docker-compose file to adjust the configurations.
|
||||
To run the services via docker-compose, please set the RPC endpoint and contract address of your target network in the
|
||||
sample docker-compose file.
|
||||
|
||||
Then, start the docker-compose like this:
|
||||
|
||||
```
|
||||
docker-compose -f docker-compose.testnet.sample.yaml up
|
||||
docker-compose -f docker-compose.stable.sample.yaml up
|
||||
```
|
||||
|
||||
It will take a few minutes until all the services are up and running.
|
||||
|
||||
[pyth price service]: https://github.com/pyth-network/pyth-crosschain/tree/main/price_service/server
|
||||
|
||||
## Reliability
|
||||
|
||||
You can run multiple instances of the price pusher to increase the reliability. It is better to use
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
"pyth-contract-address": "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387",
|
||||
"price-service-endpoint": "https://hermes-beta.pyth.network",
|
||||
"mnemonic-file": "./mnemonic",
|
||||
"price-config-file": "./price-config.testnet.sample.yaml"
|
||||
"price-config-file": "./price-config.beta.sample.yaml"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"endpoint": "https://eth-mainnet.public.blastapi.io",
|
||||
"pyth-contract-address": "0x4305FB66699C3B2702D4d05CF36551390A4c69C6",
|
||||
"price-service-endpoint": "https://hermes.pyth.network",
|
||||
"mnemonic-file": "./mnemonic",
|
||||
"price-config-file": "./price-config.stable.sample.yaml"
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"endpoint": "https://endpoints.omniatech.io/v1/fantom/testnet/public",
|
||||
"pyth-contract-address": "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C",
|
||||
"price-service-endpoint": "https://hermes-beta.pyth.network",
|
||||
"mnemonic-file": "./mnemonic",
|
||||
"price-config-file": "./price-config.testnet.sample.yaml"
|
||||
}
|
|
@ -3,6 +3,6 @@
|
|||
"pyth-contract-address": "inj1z60tg0tekdzcasenhuuwq3htjcd5slmgf7gpez",
|
||||
"price-service-endpoint": "https://hermes-beta.pyth.network",
|
||||
"mnemonic-file": "./mnemonic",
|
||||
"price-config-file": "./price-config.testnet.sample.yaml",
|
||||
"price-config-file": "./price-config.beta.sample.yaml",
|
||||
"network": "testnet"
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
"price-feed-to-price-info-object-table-id": "0x14b4697477d24c30c8eecc31dd1bd49a3115a9fe0db6bd4fd570cf14640b79a0",
|
||||
"price-service-endpoint": "https://hermes.pyth.network",
|
||||
"mnemonic-file": "./mnemonic",
|
||||
"price-config-file": "./price-config.mainnet.sample.yaml"
|
||||
"price-config-file": "./price-config.stable.sample.yaml"
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
"price-feed-to-price-info-object-table-id": "0xf8929174008c662266a1adde78e1e8e33016eb7ad37d379481e860b911e40ed5",
|
||||
"price-service-endpoint": "https://hermes-beta.pyth.network",
|
||||
"mnemonic-file": "./mnemonic",
|
||||
"price-config-file": "./price-config.testnet.sample.yaml"
|
||||
"price-config-file": "./price-config.beta.sample.yaml"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
services:
|
||||
price-pusher:
|
||||
# Use this to build the price pusher from source. A dependency of the pusher docker
|
||||
# image is the pyth-crosschain monorepo lerna docker image. Build lerna image
|
||||
# using the following command from the repo root:
|
||||
# `docker buildx build -f Dockerfile.lerna -t lerna .`
|
||||
#
|
||||
# Please note that the docker build from source only works in x86_64 platforms
|
||||
# and doesn't work on arm platforms (like Apple M1/M2).
|
||||
#
|
||||
# build:
|
||||
# context: .
|
||||
|
||||
# Replace <version> with the latest released image of the price pusher from here:
|
||||
# https://gallery.ecr.aws/pyth-network/xc-price-pusher
|
||||
image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
|
||||
restart: always
|
||||
command:
|
||||
- "--"
|
||||
- "evm"
|
||||
- "--endpoint"
|
||||
# Replace this with RPC endpoint URL for the EVM network.
|
||||
- "https://endpoints.omniatech.io/v1/fantom/testnet/public"
|
||||
- "--mnemonic-file"
|
||||
- "/mnemonic"
|
||||
- "--pyth-contract-address"
|
||||
# Replace this with the address of the Pyth contract on the EVM network.
|
||||
- "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C"
|
||||
- "--price-service-endpoint"
|
||||
- "https://hermes-beta.pyth.network" # Replace this with a private Hermes RPC for more reliability
|
||||
- "--price-config-file"
|
||||
- "/price_config"
|
||||
configs:
|
||||
- mnemonic
|
||||
- price_config
|
||||
configs:
|
||||
mnemonic:
|
||||
file: ./mnemonic # Replace this with the path to the mnemonic file
|
||||
price_config:
|
||||
file: ./price-config.beta.sample.yaml # Replace this with the path to the price configuration file
|
|
@ -1,92 +0,0 @@
|
|||
services:
|
||||
spy:
|
||||
# Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
|
||||
image: ghcr.io/wormhole-foundation/guardiand:v2.23.14
|
||||
command:
|
||||
- "spy"
|
||||
- "--nodeKey"
|
||||
- "/node.key"
|
||||
- "--spyRPC"
|
||||
- "[::]:7072"
|
||||
- "--bootstrap"
|
||||
- "/dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7"
|
||||
- "--network"
|
||||
- "/wormhole/mainnet/2"
|
||||
- "--logLevel"
|
||||
- "warn"
|
||||
price-service:
|
||||
# Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
|
||||
image: public.ecr.aws/pyth-network/xc-server:v3.0.8
|
||||
environment:
|
||||
SPY_SERVICE_HOST: "spy:7072"
|
||||
SPY_SERVICE_FILTERS: |
|
||||
[
|
||||
{
|
||||
"chain_id": 1,
|
||||
"emitter_address": "6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25"
|
||||
},
|
||||
{
|
||||
"chain_id": 26,
|
||||
"emitter_address": "f8cd23c2ab91237730770bbea08d61005cdda0984348f3f6eecb559638c0bba0"
|
||||
}
|
||||
]
|
||||
REST_PORT: "4200"
|
||||
PROM_PORT: "8081"
|
||||
READINESS_SPY_SYNC_TIME_SECONDS: "5"
|
||||
READINESS_NUM_LOADED_SYMBOLS: "280"
|
||||
LOG_LEVEL: warning
|
||||
WORMHOLE_CLUSTER: mainnet
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
"CMD",
|
||||
"wget",
|
||||
"--no-verbose",
|
||||
"--tries=1",
|
||||
"--spider",
|
||||
"http://localhost:4200/ready",
|
||||
]
|
||||
start_period: 20s
|
||||
depends_on:
|
||||
- spy
|
||||
price-pusher:
|
||||
# Use this to build the price pusher from source. A dependency of the pusher docker
|
||||
# image is the pyth-crosschain monorepo lerna docker image. Build lerna image
|
||||
# using the following command from the repo root:
|
||||
# `docker buildx build -f Dockerfile.lerna -t lerna .`
|
||||
#
|
||||
# Please note that the docker build from source only works in x86_64 platforms
|
||||
# and doesn't work on arm platforms (like Apple M1/M2).
|
||||
#
|
||||
# build:
|
||||
# context: .
|
||||
|
||||
# Replace <version> with the latest released image of the price pusher from here:
|
||||
# https://gallery.ecr.aws/pyth-network/xc-price-pusher
|
||||
image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
|
||||
restart: always
|
||||
command:
|
||||
- "--"
|
||||
- "evm"
|
||||
- "--endpoint"
|
||||
# Replace this with RPC endpoint URL for the EVM network.
|
||||
- "https://bsc-dataseed2.binance.org"
|
||||
- "--mnemonic-file"
|
||||
- "/mnemonic"
|
||||
- "--pyth-contract-address"
|
||||
- "0xd7308b14BF4008e7C7196eC35610B1427C5702EA"
|
||||
- "--price-service-endpoint"
|
||||
- "http://price-service:4200"
|
||||
- "--price-config-file"
|
||||
- "/price_config"
|
||||
configs:
|
||||
- mnemonic
|
||||
- price_config
|
||||
depends_on:
|
||||
price-service:
|
||||
condition: service_healthy
|
||||
configs:
|
||||
mnemonic:
|
||||
file: ./path/to/mnemonic.txt # Replace this with the path to the mnemonic file
|
||||
price_config:
|
||||
file: ./price-config.mainnet.sample.yaml # Replace this with the path to the price configuration file
|
|
@ -0,0 +1,40 @@
|
|||
services:
|
||||
price-pusher:
|
||||
# Use this to build the price pusher from source. A dependency of the pusher docker
|
||||
# image is the pyth-crosschain monorepo lerna docker image. Build lerna image
|
||||
# using the following command from the repo root:
|
||||
# `docker buildx build -f Dockerfile.lerna -t lerna .`
|
||||
#
|
||||
# Please note that the docker build from source only works in x86_64 platforms
|
||||
# and doesn't work on arm platforms (like Apple M1/M2).
|
||||
#
|
||||
# build:
|
||||
# context: .
|
||||
|
||||
# Replace <version> with the latest released image of the price pusher from here:
|
||||
# https://gallery.ecr.aws/pyth-network/xc-price-pusher
|
||||
image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
|
||||
restart: always
|
||||
command:
|
||||
- "--"
|
||||
- "evm"
|
||||
- "--endpoint"
|
||||
# Replace this with RPC endpoint URL for the EVM network.
|
||||
- "https://bsc-dataseed2.binance.org"
|
||||
- "--mnemonic-file"
|
||||
- "/mnemonic"
|
||||
# Replace this with the address of the Pyth contract on the EVM network.
|
||||
- "--pyth-contract-address"
|
||||
- "0xd7308b14BF4008e7C7196eC35610B1427C5702EA"
|
||||
- "--price-service-endpoint"
|
||||
- "https://hermes.pyth.network" # Replace this with a private Hermes RPC for more reliability
|
||||
- "--price-config-file"
|
||||
- "/price_config"
|
||||
configs:
|
||||
- mnemonic
|
||||
- price_config
|
||||
configs:
|
||||
mnemonic:
|
||||
file: ./path/to/mnemonic.txt # Replace this with the path to the mnemonic file
|
||||
price_config:
|
||||
file: ./price-config.stable.sample.yaml # Replace this with the path to the price configuration file
|
|
@ -1,92 +0,0 @@
|
|||
services:
|
||||
spy:
|
||||
# Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
|
||||
image: ghcr.io/wormhole-foundation/guardiand:v2.23.14
|
||||
command:
|
||||
- "spy"
|
||||
- "--nodeKey"
|
||||
- "/node.key"
|
||||
- "--spyRPC"
|
||||
- "[::]:7072"
|
||||
- "--bootstrap"
|
||||
- "/dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWAkB9ynDur1Jtoa97LBUp8RXdhzS5uHgAfdTquJbrbN7i"
|
||||
- "--network"
|
||||
- "/wormhole/testnet/2/1"
|
||||
- "--logLevel"
|
||||
- "warn"
|
||||
price-service:
|
||||
# Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
|
||||
image: public.ecr.aws/pyth-network/xc-server:v3.0.8
|
||||
environment:
|
||||
SPY_SERVICE_HOST: "spy:7072"
|
||||
SPY_SERVICE_FILTERS: |
|
||||
[
|
||||
{
|
||||
"chain_id": 1,
|
||||
"emitter_address": "f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0"
|
||||
},
|
||||
{
|
||||
"chain_id": 26,
|
||||
"emitter_address": "a27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b6"
|
||||
}
|
||||
]
|
||||
REST_PORT: "4200"
|
||||
PROM_PORT: "8081"
|
||||
READINESS_SPY_SYNC_TIME_SECONDS: "5"
|
||||
READINESS_NUM_LOADED_SYMBOLS: "280"
|
||||
LOG_LEVEL: warning
|
||||
WORMHOLE_CLUSTER: testnet
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
"CMD",
|
||||
"wget",
|
||||
"--no-verbose",
|
||||
"--tries=1",
|
||||
"--spider",
|
||||
"http://localhost:4200/ready",
|
||||
]
|
||||
start_period: 20s
|
||||
depends_on:
|
||||
- spy
|
||||
price-pusher:
|
||||
# Use this to build the price pusher from source. A dependency of the pusher docker
|
||||
# image is the pyth-crosschain monorepo lerna docker image. Build lerna image
|
||||
# using the following command from the repo root:
|
||||
# `docker buildx build -f Dockerfile.lerna -t lerna .`
|
||||
#
|
||||
# Please note that the docker build from source only works in x86_64 platforms
|
||||
# and doesn't work on arm platforms (like Apple M1/M2).
|
||||
#
|
||||
# build:
|
||||
# context: .
|
||||
|
||||
# Replace <version> with the latest released image of the price pusher from here:
|
||||
# https://gallery.ecr.aws/pyth-network/xc-price-pusher
|
||||
image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
|
||||
restart: always
|
||||
command:
|
||||
- "--"
|
||||
- "evm"
|
||||
- "--endpoint"
|
||||
# Replace this with RPC endpoint URL for the EVM network.
|
||||
- "https://endpoints.omniatech.io/v1/fantom/testnet/public"
|
||||
- "--mnemonic-file"
|
||||
- "/mnemonic"
|
||||
- "--pyth-contract-address"
|
||||
- "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C"
|
||||
- "--price-service-endpoint"
|
||||
- "http://price-service:4200"
|
||||
- "--price-config-file"
|
||||
- "/price_config"
|
||||
configs:
|
||||
- mnemonic
|
||||
- price_config
|
||||
depends_on:
|
||||
price-service:
|
||||
condition: service_healthy
|
||||
configs:
|
||||
mnemonic:
|
||||
file: ./mnemonic # Replace this with the path to the mnemonic file
|
||||
price_config:
|
||||
file: ./price-config.testnet.sample.yaml # Replace this with the path to the price configuration file
|
|
@ -23,21 +23,18 @@ $ yarn add @pythnetwork/price-service-client
|
|||
Typical usage of the connection is along the following lines:
|
||||
|
||||
```typescript
|
||||
const connection = new PriceServiceConnection(
|
||||
"https://hermes-beta.pyth.network",
|
||||
{
|
||||
priceFeedRequestConfig: {
|
||||
// Provide this option to retrieve signed price updates for on-chain contracts.
|
||||
// Ignore this option for off-chain use.
|
||||
binary: true,
|
||||
},
|
||||
}
|
||||
); // See Hermes endpoints section below for other endpoints
|
||||
const connection = new PriceServiceConnection("https://hermes.pyth.network", {
|
||||
priceFeedRequestConfig: {
|
||||
// Provide this option to retrieve signed price updates for on-chain contracts.
|
||||
// Ignore this option for off-chain use.
|
||||
binary: true,
|
||||
},
|
||||
}); // See Hermes endpoints section below for other endpoints
|
||||
|
||||
const priceIds = [
|
||||
// You can find the ids of prices at https://pyth.network/developers/price-feed-ids#pyth-evm-testnet
|
||||
"0xf9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b", // BTC/USD price id in testnet
|
||||
"0xca80ba6dc32e08d06f1aa886011eed1d77c77be9eb761cc10d72b7d0a2fd57a6", // ETH/USD price id in testnet
|
||||
// You can find the ids of prices at https://pyth.network/developers/price-feed-ids
|
||||
"0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", // BTC/USD price id
|
||||
"0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace", // ETH/USD price id
|
||||
];
|
||||
|
||||
// Get the latest values of the price feeds as json objects.
|
||||
|
@ -80,9 +77,16 @@ You can run it with `npm run example`.
|
|||
A full command that prints BTC and ETH price feeds, in the testnet network, looks like so:
|
||||
|
||||
```bash
|
||||
npm run example -- --endpoint https://hermes-beta.pyth.network --price-ids 0xf9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b 0xca80ba6dc32e08d06f1aa886011eed1d77c77be9eb761cc10d72b7d0a2fd57a6
|
||||
npm run example -- \
|
||||
--endpoint https://hermes.pyth.network \
|
||||
--price-ids \
|
||||
0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 \
|
||||
0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
|
||||
```
|
||||
|
||||
## Hermes endpoints
|
||||
|
||||
You can find the list of Hermes public endpoints [here](https://docs.pyth.network/documentation/pythnet-price-feeds/hermes#public-endpoints).
|
||||
Pyth offers a free public endpoint at [https://hermes.pyth.network](https://hermes.pyth.network). However, it is
|
||||
recommended to obtain a private endpoint from one of the Hermes RPC providers for more reliability. You can find more
|
||||
information about Hermes RPC providers
|
||||
[here](https://docs.pyth.network/documentation/pythnet-price-feeds/hermes#public-endpoint).
|
||||
|
|
|
@ -17,7 +17,10 @@ import { getBalance } from "./erc20";
|
|||
const CONFIG = {
|
||||
// Each token is configured with its ERC20 contract address and Pyth Price Feed ID.
|
||||
// You can find the list of price feed ids at https://pyth.network/developers/price-feed-ids
|
||||
// Note that feeds have different ids on testnet / mainnet.
|
||||
// Note that feeds have different ids on stable / beta.
|
||||
//
|
||||
// TODO: This example uses an old testnet contract that uses Beta feeds. We should update it
|
||||
// to use the new contract that serves stable feeds.
|
||||
baseToken: {
|
||||
name: "BRL",
|
||||
erc20Address: "0xB3a2EDFEFC35afE110F983E32Eb67E671501de1f",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Pyth EVM JS
|
||||
|
||||
[Pyth](https://pyth.network/) provides real-time pricing data in a variety of asset classes, including cryptocurrency, equities, FX and commodities. This library allows you to use these real-time prices on EVM-based networks.
|
||||
[Pyth](https://pyth.network/) provides real-time pricing data in a variety of asset classes, including cryptocurrency,
|
||||
equities, FX and commodities. This library allows you to use these real-time prices on EVM-based networks.
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -18,21 +19,20 @@ $ yarn add @pythnetwork/pyth-evm-js
|
|||
|
||||
## Quickstart
|
||||
|
||||
Pyth stores prices off-chain to minimize gas fees, which allows us to offer a wider selection of products and faster update times.
|
||||
See [On-Demand Updates](https://docs.pyth.network/documentation/pythnet-price-feeds/on-demand) for more information about this approach. In order to use Pyth prices on chain,
|
||||
they must be fetched from an off-chain Hermes instance. The `EvmPriceServiceConnection` class can be used to interact with these services,
|
||||
providing a way to fetch these prices directly in your code. The following example wraps an existing RPC provider and shows how to obtain
|
||||
Pyth prices and submit them to the network:
|
||||
Pyth stores prices off-chain to minimize gas fees, which allows us to offer a wider selection of products and faster
|
||||
update times. See [On-Demand Updates](https://docs.pyth.network/documentation/pythnet-price-feeds/on-demand) for more
|
||||
information about this approach. In order to use Pyth prices on chain, they must be fetched from an off-chain Hermes
|
||||
instance. The `EvmPriceServiceConnection` class can be used to interact with these services, providing a way to fetch
|
||||
these prices directly in your code. The following example wraps an existing RPC provider and shows how to obtain Pyth
|
||||
prices and submit them to the network:
|
||||
|
||||
```typescript
|
||||
const connection = new EvmPriceServiceConnection(
|
||||
"https://hermes-beta.pyth.network"
|
||||
); // See Hermes endpoints section below for other endpoints
|
||||
const connection = new EvmPriceServiceConnection("https://hermes.pyth.network"); // See Hermes endpoints section below for other endpoints
|
||||
|
||||
const priceIds = [
|
||||
// You can find the ids of prices at https://pyth.network/developers/price-feed-ids#pyth-evm-testnet
|
||||
"0xf9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b", // BTC/USD price id in testnet
|
||||
"0xca80ba6dc32e08d06f1aa886011eed1d77c77be9eb761cc10d72b7d0a2fd57a6", // ETH/USD price id in testnet
|
||||
// You can find the ids of prices at https://pyth.network/developers/price-feed-ids#pyth-evm-stable
|
||||
"0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", // BTC/USD price id
|
||||
"0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace", // ETH/USD price id
|
||||
];
|
||||
|
||||
// In order to use Pyth prices in your protocol you need to submit the price update data to Pyth contract in your target
|
||||
|
@ -133,7 +133,11 @@ There are two examples in [examples](./src/examples/).
|
|||
[This example](./src/examples/EvmPriceServiceClient.ts) fetches `PriceFeed` updates using both a HTTP-request API and a streaming websocket API. You can run it with `npm run example-client`. A full command that prints BTC and ETH price feeds, in the testnet network, looks like so:
|
||||
|
||||
```bash
|
||||
npm run example-client -- --endpoint https://hermes-beta.pyth.network --price-ids 0xf9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b 0xca80ba6dc32e08d06f1aa886011eed1d77c77be9eb761cc10d72b7d0a2fd57a6
|
||||
npm run example-client -- \
|
||||
--endpoint https://hermes.pyth.network \
|
||||
--price-ids \
|
||||
0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 \
|
||||
0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
|
||||
```
|
||||
|
||||
#### EvmRelay
|
||||
|
@ -144,19 +148,23 @@ npm run example-client -- --endpoint https://hermes-beta.pyth.network --price-id
|
|||
2. Calls the pyth contract with the update data.
|
||||
3. Submits it to the network and prints the txhash if successful.
|
||||
|
||||
You can run this example with `npm run example-relay`. A full command that updates BTC and ETH prices on the BNB Chain testnet network looks like so:
|
||||
You can run this example with `npm run example-relay`. A full command that updates BTC and ETH prices on the BNB Chain
|
||||
testnet network looks like so:
|
||||
|
||||
```bash
|
||||
npm run example-relay -- \
|
||||
--network "https://data-seed-prebsc-1-s1.binance.org:8545" \
|
||||
--pyth-contract "0xd7308b14BF4008e7C7196eC35610B1427C5702EA"\
|
||||
--pyth-contract "0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb"\
|
||||
--mnemonic "my good mnemonic" \
|
||||
--endpoint https://hermes-beta.pyth.network \
|
||||
--endpoint https://hermes.pyth.network \
|
||||
--price-ids \
|
||||
"0xf9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b" \
|
||||
"0xca80ba6dc32e08d06f1aa886011eed1d77c77be9eb761cc10d72b7d0a2fd57a6"
|
||||
"0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43" \
|
||||
"0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace"
|
||||
```
|
||||
|
||||
## Hermes endpoints
|
||||
|
||||
You can find the list of Hermes public endpoints [here](https://docs.pyth.network/documentation/pythnet-price-feeds/hermes#public-endpoints).
|
||||
Pyth offers a free public endpoint at [https://hermes.pyth.network](https://hermes.pyth.network). However, it is
|
||||
recommended to obtain a private endpoint from one of the Hermes RPC providers for more reliability. You can find more
|
||||
information about Hermes RPC providers
|
||||
[here](https://docs.pyth.network/documentation/pythnet-price-feeds/hermes#public-endpoint).
|
||||
|
|
Loading…
Reference in New Issue