@pythnetwork/price-pusher 5.6.3 → 5.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/lib/sui/command.d.ts +1 -0
- package/lib/sui/command.d.ts.map +1 -1
- package/lib/sui/command.js +10 -3
- package/lib/sui/sui.d.ts +4 -4
- package/lib/sui/sui.d.ts.map +1 -1
- package/lib/sui/sui.js +9 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ npm run start -- injective --grpc-endpoint https://grpc-endpoint.com \
|
|
|
85
85
|
|
|
86
86
|
# For Aptos
|
|
87
87
|
npm run start -- aptos --endpoint https://fullnode.testnet.aptoslabs.com/v1 \
|
|
88
|
-
--pyth-contract-address 0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387 --price-service-endpoint "https://
|
|
88
|
+
--pyth-contract-address 0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387 --price-service-endpoint "https://hermes-beta.pyth.network" \
|
|
89
89
|
--price-config-file "./price-config.testnet.sample.yaml" \
|
|
90
90
|
--mnemonic-file "path/to/mnemonic.txt" \
|
|
91
91
|
[--pushing-frequency 10] \
|
|
@@ -99,7 +99,7 @@ npm run start -- sui \
|
|
|
99
99
|
--wormhole-package-id 0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e \
|
|
100
100
|
--wormhole-state-id 0xebba4cc4d614f7a7cdbe883acc76d1cc767922bc96778e7b68be0d15fce27c02 \
|
|
101
101
|
--price-feed-to-price-info-object-table-id 0xf8929174008c662266a1adde78e1e8e33016eb7ad37d379481e860b911e40ed5 \
|
|
102
|
-
--price-service-endpoint https://
|
|
102
|
+
--price-service-endpoint https://hermes-beta.pyth.network \
|
|
103
103
|
--mnemonic-file ./mnemonic \
|
|
104
104
|
--price-config-file ./price-config.testnet.sample.yaml \
|
|
105
105
|
[--pushing-frequency 10] \
|
|
@@ -128,7 +128,7 @@ For example, to push `BTC/USD` and `BNB/USD` prices on Fantom testnet, run the f
|
|
|
128
128
|
|
|
129
129
|
```sh
|
|
130
130
|
npm run dev -- evm --endpoint https://endpoints.omniatech.io/v1/fantom/testnet/public \
|
|
131
|
-
--pyth-contract-address 0xff1a0f4744e8582DF1aE09D5611b887B6a12925C --price-service-endpoint https://
|
|
131
|
+
--pyth-contract-address 0xff1a0f4744e8582DF1aE09D5611b887B6a12925C --price-service-endpoint https://hermes-beta.pyth.network \
|
|
132
132
|
--mnemonic-file "./mnemonic" --price-config-file "./price-config.testnet.sample.yaml"
|
|
133
133
|
```
|
|
134
134
|
|
package/lib/sui/command.d.ts
CHANGED
package/lib/sui/command.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/sui/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/sui/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;oBA0DC,GAAG;;AAtDpC,wBAmIE"}
|
package/lib/sui/command.js
CHANGED
|
@@ -72,6 +72,12 @@ exports.default = {
|
|
|
72
72
|
required: true,
|
|
73
73
|
default: 500_000_000,
|
|
74
74
|
},
|
|
75
|
+
"account-index": {
|
|
76
|
+
description: "Index of the account to use derived by the mnemonic",
|
|
77
|
+
type: "number",
|
|
78
|
+
required: true,
|
|
79
|
+
default: 0,
|
|
80
|
+
},
|
|
75
81
|
...options.priceConfigFile,
|
|
76
82
|
...options.priceServiceEndpoint,
|
|
77
83
|
...options.mnemonicFile,
|
|
@@ -79,7 +85,7 @@ exports.default = {
|
|
|
79
85
|
...options.pushingFrequency,
|
|
80
86
|
},
|
|
81
87
|
handler: async function (argv) {
|
|
82
|
-
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, gasBudget, } = argv;
|
|
88
|
+
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, gasBudget, accountIndex, } = argv;
|
|
83
89
|
const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
|
|
84
90
|
const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
|
|
85
91
|
logger: {
|
|
@@ -95,13 +101,14 @@ exports.default = {
|
|
|
95
101
|
},
|
|
96
102
|
});
|
|
97
103
|
const mnemonic = fs_1.default.readFileSync(mnemonicFile, "utf-8").trim();
|
|
98
|
-
|
|
104
|
+
const keypair = sui_js_1.Ed25519Keypair.deriveKeypair(mnemonic, `m/44'/784'/${accountIndex}'/0'/0'`);
|
|
105
|
+
console.log(`Pushing updates from wallet address: ${keypair
|
|
99
106
|
.getPublicKey()
|
|
100
107
|
.toSuiAddress()}`);
|
|
101
108
|
const priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
|
|
102
109
|
const pythListener = new pyth_price_listener_1.PythPriceListener(priceServiceConnection, priceItems);
|
|
103
110
|
const suiListener = new sui_1.SuiPriceListener(pythStateId, wormholeStateId, endpoint, priceItems, { pollingFrequency });
|
|
104
|
-
const suiPusher = await sui_1.SuiPricePusher.createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint,
|
|
111
|
+
const suiPusher = await sui_1.SuiPricePusher.createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects);
|
|
105
112
|
const controller = new controller_1.Controller(priceConfigs, pythListener, suiListener, suiPusher, { pushingFrequency });
|
|
106
113
|
controller.start();
|
|
107
114
|
},
|
package/lib/sui/sui.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChainPriceListener, IPricePusher, PriceInfo, PriceItem } from "../interface";
|
|
2
2
|
import { DurationInSeconds } from "../utils";
|
|
3
3
|
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
|
|
4
|
-
import { JsonRpcProvider, RawSigner, SuiObjectRef, ObjectId } from "@mysten/sui.js";
|
|
4
|
+
import { JsonRpcProvider, Ed25519Keypair, RawSigner, SuiObjectRef, ObjectId } from "@mysten/sui.js";
|
|
5
5
|
import { SuiPythClient } from "@pythnetwork/pyth-sui-js";
|
|
6
6
|
export declare class SuiPriceListener extends ChainPriceListener {
|
|
7
7
|
private pythClient;
|
|
@@ -35,7 +35,7 @@ export declare class SuiPricePusher implements IPricePusher {
|
|
|
35
35
|
private gasBudget;
|
|
36
36
|
private gasPool;
|
|
37
37
|
private pythClient;
|
|
38
|
-
constructor(signer: RawSigner, priceServiceConnection: PriceServiceConnection, pythPackageId: string, pythStateId: string, wormholePackageId: string, wormholeStateId: string, endpoint: string,
|
|
38
|
+
constructor(signer: RawSigner, priceServiceConnection: PriceServiceConnection, pythPackageId: string, pythStateId: string, wormholePackageId: string, wormholeStateId: string, endpoint: string, keypair: Ed25519Keypair, gasBudget: number, gasPool: SuiObjectRef[], pythClient: SuiPythClient);
|
|
39
39
|
/**
|
|
40
40
|
* getPackageId returns the latest package id that the object belongs to. Use this to
|
|
41
41
|
* fetch the latest package id for a given object id and handle package upgrades automatically.
|
|
@@ -46,9 +46,9 @@ export declare class SuiPricePusher implements IPricePusher {
|
|
|
46
46
|
static getPackageId(provider: JsonRpcProvider, objectId: ObjectId): Promise<ObjectId>;
|
|
47
47
|
/**
|
|
48
48
|
* Create a price pusher with a pool of `numGasObjects` gas coins that will be used to send transactions.
|
|
49
|
-
* The gas coins of the wallet for the provided
|
|
49
|
+
* The gas coins of the wallet for the provided keypair will be merged and then evenly split into `numGasObjects`.
|
|
50
50
|
*/
|
|
51
|
-
static createWithAutomaticGasPool(priceServiceConnection: PriceServiceConnection, pythStateId: string, wormholeStateId: string, endpoint: string,
|
|
51
|
+
static createWithAutomaticGasPool(priceServiceConnection: PriceServiceConnection, pythStateId: string, wormholeStateId: string, endpoint: string, keypair: Ed25519Keypair, gasBudget: number, numGasObjects: number): Promise<SuiPricePusher>;
|
|
52
52
|
updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
|
|
53
53
|
/** Send every transaction in txs in parallel, returning when all transactions have completed. */
|
|
54
54
|
private sendTransactionBlocks;
|
package/lib/sui/sui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/sui/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EACL,eAAe,
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/sui/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EACL,eAAe,EAEf,cAAc,EACd,SAAS,EAGT,YAAY,EAKZ,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAOzD,qBAAa,gBAAiB,SAAQ,kBAAkB;IACtD,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,QAAQ,CAAkB;gBAGhC,WAAW,EAAE,QAAQ,EACrB,eAAe,EAAE,QAAQ,EACzB,QAAQ,EAAE,MAAM,EAChB,UAAU,EA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EAAsE;YACxD,oBAAoB;mBAwDb,iBAAiB;mBAuCjB,yBAAyB;mBAoBzB,cAAc;mBAiCd,mBAAmB;mBAsCnB,oBAAoB;CA+D1C"}
|
package/lib/sui/sui.js
CHANGED
|
@@ -76,7 +76,7 @@ class SuiPricePusher {
|
|
|
76
76
|
gasBudget;
|
|
77
77
|
gasPool;
|
|
78
78
|
pythClient;
|
|
79
|
-
constructor(signer, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint,
|
|
79
|
+
constructor(signer, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint, keypair, gasBudget, gasPool, pythClient) {
|
|
80
80
|
this.signer = signer;
|
|
81
81
|
this.priceServiceConnection = priceServiceConnection;
|
|
82
82
|
this.pythPackageId = pythPackageId;
|
|
@@ -115,19 +115,19 @@ class SuiPricePusher {
|
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Create a price pusher with a pool of `numGasObjects` gas coins that will be used to send transactions.
|
|
118
|
-
* The gas coins of the wallet for the provided
|
|
118
|
+
* The gas coins of the wallet for the provided keypair will be merged and then evenly split into `numGasObjects`.
|
|
119
119
|
*/
|
|
120
|
-
static async createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint,
|
|
120
|
+
static async createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects) {
|
|
121
121
|
if (numGasObjects > MAX_NUM_OBJECTS_IN_ARGUMENT) {
|
|
122
122
|
throw new Error(`numGasObjects cannot be greater than ${MAX_NUM_OBJECTS_IN_ARGUMENT} until we implement split chunking`);
|
|
123
123
|
}
|
|
124
124
|
const provider = new sui_js_1.JsonRpcProvider(new sui_js_1.Connection({ fullnode: endpoint }));
|
|
125
|
-
const signer = new sui_js_1.RawSigner(
|
|
125
|
+
const signer = new sui_js_1.RawSigner(keypair, provider);
|
|
126
126
|
const pythPackageId = await SuiPricePusher.getPackageId(provider, pythStateId);
|
|
127
127
|
const wormholePackageId = await SuiPricePusher.getPackageId(provider, wormholeStateId);
|
|
128
128
|
const gasPool = await SuiPricePusher.initializeGasPool(signer, numGasObjects);
|
|
129
129
|
const pythClient = new pyth_sui_js_1.SuiPythClient(provider, pythStateId, wormholeStateId);
|
|
130
|
-
return new SuiPricePusher(signer, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint,
|
|
130
|
+
return new SuiPricePusher(signer, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint, keypair, gasBudget, gasPool, pythClient);
|
|
131
131
|
}
|
|
132
132
|
async updatePriceFeed(priceIds, pubTimesToPush) {
|
|
133
133
|
if (priceIds.length === 0) {
|
|
@@ -182,8 +182,10 @@ class SuiPricePusher {
|
|
|
182
182
|
}
|
|
183
183
|
catch (e) {
|
|
184
184
|
console.log("Error when signAndExecuteTransactionBlock");
|
|
185
|
-
if (String(e).includes("
|
|
186
|
-
|
|
185
|
+
if (String(e).includes("Balance of gas object") ||
|
|
186
|
+
String(e).includes("GasBalanceTooLow")) {
|
|
187
|
+
// If the error is caused by insufficient gas, we should panic
|
|
188
|
+
throw e;
|
|
187
189
|
}
|
|
188
190
|
else {
|
|
189
191
|
// Refresh the coin object here in case the error is caused by an object version mismatch.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/price-pusher",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.1",
|
|
4
4
|
"description": "Pyth Price Pusher",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"yaml": "^2.1.1",
|
|
65
65
|
"yargs": "^17.5.1"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "44ebfbaf5512acd96a12b3cdf361b47e64802dbf"
|
|
68
68
|
}
|