Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@pythnetwork/client
Advanced tools
Pyth is building a way to deliver a decentralized, cross-chain market of verifiable data from high-quality nodes to any smart contract, anywhere.
This library reads on-chain Pyth data from @solana/web3.js and returns JavaScript-friendly objects.
See our examples repo for real-world usage examples.
$ npm install --save @pythnetwork/client
$ yarn add @pythnetwork/client
This library provides a subscription model for consuming price updates:
const pythConnection = new PythConnection(solanaWeb3Connection, getPythProgramKeyForCluster(solanaClusterName))
pythConnection.onPriceChange((product, price) => {
// sample output:
// SRM/USD: $8.68725 ±$0.0131
console.log(`${product.symbol}: $${price.price} \xB1$${price.confidence} Status: ${PriceStatus[price.status]}`)
})
// Start listening for price change events.
pythConnection.start()
The onPriceChange
callback will be invoked every time a Pyth price gets updated.
This callback gets two arguments:
price
contains the official Pyth price and confidence, along with the component prices that were combined to produce this result.product
contains metadata about the price feed, such as the symbol (e.g., "BTC/USD") and the number of decimal points.See src/example_usage.ts
for a runnable example of the above usage.
You can run this example with npm run example
.
You may also register to specific account updates using connection.onAccountChange
in the solana web3 API, then
use the methods in index.ts
to parse the on-chain data structures into Javascript-friendly objects.
In order to release a new version of this library and publish it to npm, follow these steps:
CHANGELOG.md
with a description of the changes in this version.npm version <new version number>
. This command will update the version of the package, tag the branch in git, and push your changes to github.main
, create a release, and a github action will automatically publish a new version of the package to npm.2.6.0
MAX_SLOT_DIFFERENCE
slots (currently 25).FAQs
Client for consuming Pyth price data
The npm package @pythnetwork/client receives a total of 32,971 weekly downloads. As such, @pythnetwork/client popularity was classified as popular.
We found that @pythnetwork/client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.