Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Commit cb6af36

Browse files
authored
Merge pull request #52 from pyth-network/abehjati/sdk-update-cascade-xc-pkgs
Use the new sdk on client pkgs
2 parents 9973aa4 + 8b7734d commit cb6af36

File tree

14 files changed

+75
-72
lines changed

14 files changed

+75
-72
lines changed

pyth-aptos-js/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ const priceIds = [
3838
// `getPythLatestPriceFeeds` returns a `PriceFeed` for each price id. It contains all information about a price and has
3939
// utility functions to get the current and exponentially-weighted moving average price, and other functionality.
4040
const priceFeeds = connection.getPythLatestPriceFeeds(priceIds);
41-
console.log(priceFeeds[0].getCurrentPrice()); // Price { conf: '1234', expo: -8, price: '12345678' }
42-
console.log(priceFeeds[1].getEmaPrice()); // Exponentially-weighted moving average price
41+
// Get the price if it is not older than 60 seconds from the current time.
42+
console.log(priceFeeds[0].getPriceNoOlderThan(60)); // Price { conf: '1234', expo: -8, price: '12345678' }
43+
// Get the exponentially-weighted moving average price if it is not older than 60 seconds from the current time.
44+
console.log(priceFeeds[1].getEmaPriceNoOlderThan(60));
4345

4446
// In order to use Pyth prices in your protocol you need to submit the price update data to Pyth contract in your target
4547
// chain. `getPriceUpdateData` creates the update data which can be submitted to your contract. Then your contract should

pyth-aptos-js/package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyth-aptos-js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-aptos-js",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Pyth Network Aptos Utilities",
55
"homepage": "https://pyth.network",
66
"author": {
@@ -47,7 +47,7 @@
4747
"yargs": "^17.4.1"
4848
},
4949
"dependencies": {
50-
"@pythnetwork/pyth-common-js": "^0.5.0",
50+
"@pythnetwork/pyth-common-js": "^1.0.0",
5151
"aptos": "^1.3.14",
5252
"buffer": "^6.0.3"
5353
}

pyth-aptos-js/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ export {
66
Price,
77
PriceFeed,
88
PriceServiceConnectionConfig,
9-
PriceStatus,
109
UnixTimestamp,
1110
} from "@pythnetwork/pyth-common-js";

pyth-evm-js/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ const priceIds = [
3838
// `getPythLatestPriceFeeds` returns a `PriceFeed` for each price id. It contains all information about a price and has
3939
// utility functions to get the current and exponentially-weighted moving average price, and other functionality.
4040
const priceFeeds = connection.getPythLatestPriceFeeds(priceIds);
41-
console.log(priceFeeds[0].getCurrentPrice()); // Price { conf: '1234', expo: -8, price: '12345678' }
42-
console.log(priceFeeds[1].getEmaPrice()); // Exponentially-weighted moving average price
41+
// Get the price if it is not older than 60 seconds from the current time.
42+
console.log(priceFeeds[0].getPriceNoOlderThan(60)); // Price { conf: '1234', expo: -8, price: '12345678' }
43+
// Get the exponentially-weighted moving average price if it is not older than 60 seconds from the current time.
44+
console.log(priceFeeds[1].getEmaPriceNoOlderThan(60));
4345

4446
// By subscribing to the price feeds you can get their updates in real-time.
4547
connection.subscribePriceFeedUpdates(priceIds, (priceFeed) => {
4648
console.log("Received a new price feed update!");
47-
console.log(priceFeed.getCurrentPrice());
49+
console.log(priceFeed.getPriceNoOlderThan(60));
4850
});
4951

5052
// When using subscription, make sure to close the websocket upon termination to finish the process gracefully.

pyth-evm-js/package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyth-evm-js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-evm-js",
3-
"version": "0.6.0",
3+
"version": "1.0.0",
44
"description": "Pyth Network EVM Utils in JS",
55
"homepage": "https://pyth.network",
66
"author": {
@@ -49,7 +49,7 @@
4949
"yargs": "^17.4.1"
5050
},
5151
"dependencies": {
52-
"@pythnetwork/pyth-common-js": "^0.5.0",
52+
"@pythnetwork/pyth-common-js": "^1.0.0",
5353
"buffer": "^6.0.3"
5454
}
5555
}

pyth-evm-js/src/examples/EvmPriceServiceClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function run() {
3737
console.log(priceIds);
3838
const priceFeeds = await connection.getLatestPriceFeeds(priceIds);
3939
console.log(priceFeeds);
40-
console.log(priceFeeds?.at(0)?.getCurrentPrice());
40+
console.log(priceFeeds?.at(0)?.getPriceNoOlderThan(60));
4141

4242
const updateData = await connection.getPriceFeedsUpdateData(priceIds);
4343
console.log(updateData);
@@ -47,7 +47,7 @@ async function run() {
4747
await connection.subscribePriceFeedUpdates(priceIds, (priceFeed) => {
4848
console.log(
4949
`Current price for ${priceFeed.id}: ${JSON.stringify(
50-
priceFeed.getCurrentPrice()
50+
priceFeed.getPriceNoOlderThan(60)
5151
)}.`
5252
);
5353
});

pyth-evm-js/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export {
66
Price,
77
PriceFeed,
88
PriceServiceConnectionConfig,
9-
PriceStatus,
109
UnixTimestamp,
1110
} from "@pythnetwork/pyth-common-js";
1211

pyth-terra-js/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ const priceIds = [
3838
// `getLatestPriceFeeds` returns a `PriceFeed` for each price id. It contains all information about a price and has
3939
// utility functions to get the current and exponentially-weighted moving average price, and other functionality.
4040
const priceFeeds = connection.getLatestPriceFeeds(priceIds);
41-
console.log(priceFeeds[0].getCurrentPrice()); // Price { conf: '1234', expo: -8, price: '12345678' }
42-
console.log(priceFeeds[1].getEmaPrice()); // Exponentially-weighted moving average price
41+
// Get the price if it is not older than 60 seconds from the current time.
42+
console.log(priceFeeds[0].getPriceNoOlderThan(60)); // Price { conf: '1234', expo: -8, price: '12345678' }
43+
// Get the exponentially-weighted moving average price if it is not older than 60 seconds from the current time.
44+
console.log(priceFeeds[1].getEmaPriceNoOlderThan(60));
4345

4446
// By subscribing to the price feeds you can get their updates realtime.
4547
connection.subscribePriceFeedUpdates(priceIds, (priceFeed) => {
4648
console.log("Received a new price feed update!");
47-
console.log(priceFeed.getCurrentPrice());
49+
console.log(priceFeed.getPriceNoOlderThan(60));
4850
});
4951

5052
// When using subscription, make sure to close the websocket upon termination to finish the process gracefully.

0 commit comments

Comments
 (0)