Mirroring https://github.com/pyth-network/pyth-crosschain

Devin AI bdc0aacfae docs: add detailed regeneration steps to README 5 сар өмнө
.github d10e5e976e ci: add workflow for Hermes Rust client 5 сар өмнө
apps bdc0aacfae docs: add detailed regeneration steps to README 5 сар өмнө
contract_manager 795e914f3a feat: Add iota mainnet (#2653) 6 сар өмнө
governance 6ebed9c240 feat: add amount to stake (#2671) 6 сар өмнө
lazer 82d8685d58 fix(lazer/solana): add mut annotation on treasury account (#2625) 6 сар өмнө
licenses ee455f1196 [solidity sdk] Add zerolend AggregatorV3 adapter to SDK (#1437) 1 жил өмнө
packages e78549ab80 feat(entropy-explorer): implement some feedback items 6 сар өмнө
patches 9f054411b8 fix: fix broken wallet adapter in proposals app 8 сар өмнө
price_service 1b5195aa0a fix: run turbo fix 8 сар өмнө
pythnet 9bb7a5a92e refactor(pythnet/pythnet_sdk): add test for update data with fixture (#2551) 7 сар өмнө
target_chains f01d4bd4bc feat(target_chains/ethereum/pyth): strict minimal updateData parsing (#2637) 6 сар өмнө
.dockerignore d5b2fd7ee8 feat(hermes): configurable cache size (#2547) 7 сар өмнө
.envrc 7e293cf125 chore: upgrade nix flake dependencies 8 сар өмнө
.gitignore f80ae5c65b fix: fix vercel's use of corepack during the ignoreCommand 8 сар өмнө
.gitmodules 5602f4b874 chore: remove erroneous git modules (#2347) 9 сар өмнө
.nvmrc 81655125f9 chore: upgrade javascript dependencies 7 сар өмнө
.pre-commit-config.yaml 74d1fc89b0 chore(js): update fix:fmt config (#2514) 8 сар өмнө
.prettierignore 74d1fc89b0 chore(js): update fix:fmt config (#2514) 8 сар өмнө
.tool-versions 81655125f9 chore: upgrade javascript dependencies 7 сар өмнө
Dockerfile.node 81655125f9 chore: upgrade javascript dependencies 7 сар өмнө
LICENSE c7c8c2d2fc Update copyright messages 10 сар өмнө
README.md e04dd22873 chore: update readme to say turbo should be run with `pnpm turbo` 8 сар өмнө
SECURITY.md 4a90dcb3c4 chore(lazer): add evm audit (#2527) 7 сар өмнө
flake.lock 81655125f9 chore: upgrade javascript dependencies 7 сар өмнө
flake.nix 8a05757929 chore: update turbo config 8 сар өмнө
funding.json f5f5b8b3bc chore: add funding.json for op grant (#1608) 1 жил өмнө
package.json 67e1021b53 fix: use pnpm to publish instead of lerna 7 сар өмнө
pnpm-lock.yaml e78549ab80 feat(entropy-explorer): implement some feedback items 6 сар өмнө
pnpm-workspace.yaml e78549ab80 feat(entropy-explorer): implement some feedback items 6 сар өмнө
prettier.config.mjs b1dc4c27f5 chore: move prettier to individual packages & upgrade prettier 8 сар өмнө
tsconfig.base.json 183081cc20 Expose pythnet message buffer idls (#865) 2 жил өмнө
turbo.json b0d68f775a fix(staking-sdk): fix staking-sdk build 7 сар өмнө
vercel-ignore.sh f80ae5c65b fix: fix vercel's use of corepack during the ignoreCommand 8 сар өмнө

README.md

Pyth Crosschain

This repository acts as a monorepo for the various components that make up Pyth protocols.

Within this monorepo you will find the following subprojects:

Target Chains

target_chains

This directory contains on-chain contracts and SDKs for all of the various blockchain runtimes that Pyth supports. Each subdirectory corresponds to a blockchain runtime. Inside each subdirectory, there are subfolders for contracts and SDKs.

Hermes

hermes

Hermes is an off-chain service which constantly observes Pythnet and the Wormhole network watching for price updates emitted from the Pyth contract. It exposes all observed attestations via a public API over HTTPS/WSS which can be consumed by client-side applications that wish to use Pyth pricing data.

The price_service/client directory provides an SDK for interacting with Hermes. However, most users will interact with the price service via a chain-specific SDK

For a guide on utilising this service in your project, see the chain-specific SDK and examples for your blockchain runtime in the target_chains directory.

Fortuna

fortuna

Fortuna is an off-chain service which can be used by Entropy providers.

Local Development

Setup

Please install the following tools in order to work in this repository:

  • NVM to manage your node version, then run nvm use 20 to ensure you are using node version 20.
  • Foundry in order to use forge for Ethereum contract development
  • Solana CLI for working with Solana programs.
    • After installing, please run solana keygen new to generate a local private key.
  • Anchor for developing Solana programs.
  • Pre-commit is used to automatically format and lint the repository.
    • After installing, please run pre-commit install in the root of the repo to configure the checks to run on each git commit.
  • Rust

Pull requests

Use the Conventional Commits format for your commit messages and PR titles. In the PR description, please include a summary of the changes and any relevant context. Also, please make sure to update the package versions following the Semantic Versioning rules.

Releases

The repository has several CI workflows that automatically release new versions of the various components when a new Github release is published. Each component's workflow uses a specific tag format including the component name and version number (e.g., Fortuna uses the tag fortuna-vX.Y.Z). The general process for creating a new release is:

  1. Update the version number of the component in the repo, e.g., in package.json or Cargo.toml or wherever. Please follow Semantic Versioning for package versions.
  2. Submit a PR with the changes and merge them in to main.
  3. Create a new release on github. Configure the release to create a new tag when published. Set the tag name and version for the component you wish to release -- see the Releases page to identify the relevant tag.
  4. Publish the release. This step will automatically trigger a Github Action to build the package and release it. This step will e.g., publish packages to NPM, or build and push docker images.

Note that all javascript packages are released together using a tag of the form pyth-js-v<number>. (The number is arbitrary.) If you have a javascript package that shouldn't be published, simply add "private": "true" to the package.json file and it will be excluded from the publishing workflow. If you are creating a new public javascript package, you should add the following config option to package.json:

  "publishConfig": {
    "access": "public"
  },

Typescript Monorepo

All of the typescript / javascript packages in this repository are part of a turborepo monorepo.

Setting up

If you use nix and direnv, just cd to the project directory and direnv allow.

If you use nix but not direnv, just cd to the project directory and enter a nix development shell with nix develop.

If you don't use nix at all, then install the required system packages:

  • Node.js -- match the version to .nvmrc; you can use nvm to manage your Node.js version.
  • pnpm -- match the version to the version specified in package.json; you can experiment with corepack to manage your pnpm version for you.

Common tasks

The following tasks are the most common ways to interact with the monorepo. Thanks to turborepo, these tasks will coordinate building any needed dependencies, and task execution will be cached and will only re-run as necessary. For any of the following tasks, you can pass any valid turbo run option after --, for instance you could run pnpm test -- --concurrency 2.

  • pnpm turbo test: Run all unit tests, integration tests, linting, and format checks, as well as whatever other code checks any packages support.
  • pnpm turbo fix: Run auto fixes, including reformatting code and auto-fixing lint rules where possible.
  • pnpm turbo start:dev: Start all development servers in parallel.
  • pnpm turbo start:prod: Run production builds and start production mode servers in parallel.

Building a new package

New packages should be configured with a few requirements in mind:

  1. You need to make sure package.json scripts are named such that that turborepo will hook into them at the expected times.

    • See turbo.json to see the base configuration and ensure you use script names that match the tasks that turborepo is configured to run.
    • You don't need to define scripts for all the tasks that are in the root turbo.json config, just define the ones that make sense for your project.
    • You shouldn't define scripts for tasks that just trigger other tasks; instead configure turborepo dependencies to trigger the tasks. This will allow turborepo to cache and parallelize things more effectively.
    • In general, build, fix, and test are the main turborepo task graph entry points, and any sub-tasks that apply to your package should be configured as dependencies somewhere in the graph rooted at one of those.
    • If you need sub-tasks or a task configuration that only apply to your or a small few packages, add a package-scoped turbo.json, see the one in the insights app as an example.
  2. Make sure to configure the tools you need and hook up the relevant checks to turborepo via the test root task so they run on CI. The most common tools (eslint, prettier, jest, and typescript) are trivial to configure correctly using shared configs, see the relevant config files in the insights app as a starting point.

  3. If you are writing a package that will be published:

    • Make sure you are dual-exporting cjs and esm correctly, see how the lazer sdk package builds (in particular look at the build:cjs and build:esm tasks) for an example for how to do this

    • Ensure you have properly configured subpath exports to reference the esm and cjs outputs so that your package can be consumed correctly in both environments. Again, see the lazer sdk as an example for doing this correctly.

    • Ensure you have set a main and types property on your package.json pointing to your cjs entrypoint for use in older javascript environments.

    • Ensure you configure the files property on your package.json to include all output files and to exclude source files & tooling configuration. This will result in smaller package sizes.

Audit / Feature Status

This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Or plainly spoken - this is a very complex piece of software which targets a bleeding-edge, experimental smart contract runtime. Mistakes happen, and no matter how hard you try and whether you pay someone to audit it, it may eat your tokens, set your printer on fire or startle your cat. Cryptocurrencies are a high-risk investment, no matter how fancy.