Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Terra SDK
name: CW SDK

on:
push:
Expand All @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./pyth-sdk-terra
working-directory: ./pyth-sdk-cw
steps:
- uses: actions/checkout@v2
- name: Install dependencies
Expand All @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./pyth-sdk-terra
working-directory: ./pyth-sdk-cw
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pyth SDK Example Terra Contract
name: Pyth SDK Example CW Contract

on:
push:
Expand All @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./examples/terra-contract
working-directory: ./examples/cw-contract
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand All @@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./examples/terra-contract
working-directory: ./examples/cw-contract
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ members = [
"pyth-sdk",
"pyth-sdk-solana",
"pyth-sdk-solana/test-contract",
"pyth-sdk-terra",
"examples/terra-contract",
"pyth-sdk-cw",
"examples/cw-contract",
]
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ optimize = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
cosmwasm-std = { version = "0.16.2" }
cosmwasm-storage = { version = "0.16.0" }
cw-storage-plus = "0.8.0"
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
cw-storage-plus = "0.13.4"
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
pyth-sdk-terra = { version = "0.4.0", path = "../../pyth-sdk-terra" } # Remove path and use version only when you use this example on your own.
pyth-sdk-cw = { version = "0.1.0", path = "../../pyth-sdk-cw" } # Remove path and use version only when you use this example on your own.

[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-schema = { version = "1.0.0" }
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cosmwasm_std::{
StdResult,
};

use pyth_sdk_terra::query_price_feed;
use pyth_sdk_cw::query_price_feed;

use crate::msg::{
ExecuteMsg,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pyth_sdk_terra::{
use pyth_sdk_cw::{
Price,
PriceIdentifier,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{
};

use cw_storage_plus::Item;
use pyth_sdk_terra::PriceIdentifier;
use pyth_sdk_cw::PriceIdentifier;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct State {
Expand Down
10 changes: 5 additions & 5 deletions pyth-sdk-terra/Cargo.toml → pyth-sdk-cw/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-sdk-terra"
version = "0.4.0"
name = "pyth-sdk-cw"
version = "0.1.0"
authors = ["Pyth Data Foundation"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -11,14 +11,14 @@ keywords = [ "pyth", "terra", "oracle" ]
readme = "README.md"

[dependencies]
cosmwasm-std = { version = "0.16.0" }
cosmwasm-storage = { version = "0.16.0" }
cosmwasm-std = { version = "1.0.0" }
cosmwasm-storage = { version = "1.0.0" }
serde = { version = "1.0.136", features = ["derive"] }
pyth-sdk = { path = "../pyth-sdk", version = "0.4.1" }
schemars = "0.8.1"

[dev-dependencies]
cosmwasm-schema = { version = "0.16.0" }
cosmwasm-schema = { version = "1.0.0" }

[lib]
crate-type = ["cdylib", "lib"]
22 changes: 11 additions & 11 deletions pyth-sdk-terra/README.md → pyth-sdk-cw/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Pyth Network Terra SDK
# Pyth Network CosmWasm SDK

This crate provides utilities for reading price feeds from the [pyth.network](https://pyth.network/) oracle on the Terra network.
It also includes an [example contract](../examples/terra-contract/) demonstrating how to read price feeds from on-chain Terra applications.
This crate provides utilities for reading price feeds from the [pyth.network](https://pyth.network/) oracle on the CosmWasm ecosystem.
It also includes an [example contract](../examples/terra-contract/) demonstrating how to read price feeds from on-chain CosmWasm applications.

## Installation

Add this crate to the dependencies section of your Terra contract's `Cargo.toml` file:
Add this crate to the dependencies section of your CosmWasm contract's `Cargo.toml` file:

```
[dependencies]
pyth-sdk-terra = { version = "<current version>" }
pyth-sdk-cw = { version = "<current version>" }
```

See [pyth-sdk-terra on crates.io](https://crates.io/crates/pyth-sdk-terra) to get the most recent version.
See [pyth-sdk-cw on crates.io](https://crates.io/crates/pyth-sdk-cw) to get the most recent version.

## Usage

Simply call the `query_price_feed` function in your Terra contract with a price feed id:
Simply call the `query_price_feed` function in your CosmWasm contract with a price feed id:

```rust
// Pyth network testnet contract address
Expand All @@ -29,15 +29,15 @@ let current_price: Price = price_feed.get_current_price().ok_or_else(|| StdError
println!("current BTC/USD price: ({} +- {}) x 10^{}", current_price.price, current_price.conf, current_price.expo);
```

`query_price_feed` makes a query to the Pyth Network Terra contract
`query_price_feed` makes a query to the Pyth Network CosmWasm contract
This query requires a price feed id that indicates the product whose price should be returned.
Each product listed on Pyth Network (e.g., BTC/USD) has its own price feed id; see the [Contracts and Price Feeds](#contracts-and-price-feeds) section below for the possible products and their price feed ids.
The result of the query is a `PriceFeed` struct which contains the current price of the product along with additional metadata.
This struct also has some useful functions for manipulating and combining prices; see the [common SDK documentation](../pyth-sdk) for more details.

## Off-Chain Queries

You can use the provided schemas in the `schema` directory to directly query the terra contract from off-chain applications.
You can use the provided schemas in the `schema` directory to directly query the CosmWasm contract from off-chain applications.
A typical query requires to pass the price feed id as a hex string. it will look like:

```
Expand All @@ -52,9 +52,9 @@ By going to the contract address in [Terra Finder](https://finder.terra.money/)

## Contracts and Price Feeds

Pyth is currently only available in Terra testnet.
Pyth is currently only available in Terra Classic testnet.

### Testnet
### Terra Classic testnet

The contract address is [`terra1wzs3rgzgjdde3kg7k3aaz6qx7sc5dcwxqe9fuc`](https://finder.terra.money/testnet/address/terra1wzs3rgzgjdde3kg7k3aaz6qx7sc5dcwxqe9fuc).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cosmwasm_schema::{
use std::env::current_dir;
use std::fs::create_dir_all;

use pyth_sdk_terra::{
use pyth_sdk_cw::{
PriceFeedResponse,
QueryMsg,
};
Expand Down
File renamed without changes.
File renamed without changes.