@pythnetwork/price-pusher 10.3.1 → 10.4.0
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 -1
- package/dist/aptos/aptos.cjs +7 -7
- package/dist/aptos/aptos.d.ts +1 -1
- package/dist/aptos/balance-tracker.cjs +7 -7
- package/dist/aptos/balance-tracker.d.ts +1 -1
- package/dist/aptos/command.cjs +20 -17
- package/dist/aptos/command.d.ts +3 -2
- package/dist/controller.cjs +2 -2
- package/dist/controller.d.ts +1 -1
- package/dist/evm/balance-tracker.cjs +4 -4
- package/dist/evm/balance-tracker.d.ts +2 -2
- package/dist/evm/command.cjs +46 -43
- package/dist/evm/command.d.ts +7 -6
- package/dist/evm/evm.cjs +7 -7
- package/dist/evm/evm.d.ts +3 -4
- package/dist/evm/pyth-contract.cjs +2 -2
- package/dist/evm/super-wallet.cjs +4 -4
- package/dist/evm/super-wallet.d.ts +1 -1
- package/dist/fuel/command.cjs +17 -14
- package/dist/fuel/command.d.ts +3 -2
- package/dist/fuel/fuel.d.ts +2 -2
- package/dist/injective/command.cjs +26 -23
- package/dist/injective/command.d.ts +5 -4
- package/dist/injective/injective.cjs +11 -11
- package/dist/injective/injective.d.ts +2 -3
- package/dist/interface.d.ts +1 -1
- package/dist/metrics.cjs +29 -29
- package/dist/near/command.cjs +22 -19
- package/dist/near/command.d.ts +5 -4
- package/dist/near/near.cjs +17 -16
- package/dist/near/near.d.ts +1 -1
- package/dist/options.cjs +36 -26
- package/dist/options.d.ts +3 -0
- package/dist/price-config.cjs +13 -13
- package/dist/pyth-price-listener.cjs +2 -2
- package/dist/pyth-price-listener.d.ts +2 -3
- package/dist/solana/balance-tracker.cjs +5 -5
- package/dist/solana/balance-tracker.d.ts +2 -2
- package/dist/solana/command.cjs +75 -60
- package/dist/solana/command.d.ts +13 -10
- package/dist/solana/solana.d.ts +4 -4
- package/dist/sui/balance-tracker.cjs +4 -4
- package/dist/sui/balance-tracker.d.ts +2 -2
- package/dist/sui/command.cjs +42 -39
- package/dist/sui/command.d.ts +7 -6
- package/dist/sui/sui.cjs +14 -14
- package/dist/sui/sui.d.ts +2 -2
- package/dist/ton/command.cjs +17 -14
- package/dist/ton/command.d.ts +3 -2
- package/dist/ton/ton.d.ts +2 -3
- package/dist/utils.d.ts +1 -2
- package/package.json +119 -130
package/dist/sui/command.cjs
CHANGED
|
@@ -18,9 +18,9 @@ const _metrics = require("../metrics.cjs");
|
|
|
18
18
|
const _options = /*#__PURE__*/ _interop_require_wildcard(require("../options.cjs"));
|
|
19
19
|
const _priceconfig = require("../price-config.cjs");
|
|
20
20
|
const _pythpricelistener = require("../pyth-price-listener.cjs");
|
|
21
|
+
const _utils = require("../utils.cjs");
|
|
21
22
|
const _balancetracker = require("./balance-tracker.cjs");
|
|
22
23
|
const _sui = require("./sui.cjs");
|
|
23
|
-
const _utils = require("../utils.cjs");
|
|
24
24
|
function _interop_require_default(obj) {
|
|
25
25
|
return obj && obj.__esModule ? obj : {
|
|
26
26
|
default: obj
|
|
@@ -68,50 +68,49 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
68
68
|
return newObj;
|
|
69
69
|
}
|
|
70
70
|
const _default = {
|
|
71
|
-
command: "sui",
|
|
72
|
-
describe: "Run price pusher for sui. Most of the arguments below are" + "network specific, so there's one set of values for mainnet and" + " another for testnet. See config.sui.mainnet.sample.json for the " + "appropriate values for your network. ",
|
|
73
71
|
builder: {
|
|
72
|
+
"account-index": {
|
|
73
|
+
default: 0,
|
|
74
|
+
description: "Index of the account to use derived by the mnemonic",
|
|
75
|
+
required: true,
|
|
76
|
+
type: "number"
|
|
77
|
+
},
|
|
74
78
|
endpoint: {
|
|
75
79
|
description: "RPC endpoint URL for sui. The pusher will periodically" + "poll for updates. The polling interval is configurable via the " + "`polling-frequency` command-line argument.",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
"pyth-state-id": {
|
|
80
|
-
description: "Pyth State Id. Can be found here" + "https://docs.pyth.network/documentation/pythnet-price-feeds/sui",
|
|
81
|
-
type: "string",
|
|
82
|
-
required: true
|
|
83
|
-
},
|
|
84
|
-
"wormhole-state-id": {
|
|
85
|
-
description: "Wormhole State Id. Can be found here" + "https://docs.pyth.network/documentation/pythnet-price-feeds/sui",
|
|
86
|
-
type: "string",
|
|
87
|
-
required: true
|
|
80
|
+
required: true,
|
|
81
|
+
type: "string"
|
|
88
82
|
},
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
"gas-budget": {
|
|
84
|
+
default: 500_000_000,
|
|
85
|
+
description: "Gas budget for each price update",
|
|
92
86
|
required: true,
|
|
93
|
-
|
|
87
|
+
type: "number"
|
|
94
88
|
},
|
|
95
89
|
"ignore-gas-objects": {
|
|
90
|
+
default: [],
|
|
96
91
|
description: "Gas objects to ignore when merging gas objects on startup -- use this for locked objects.",
|
|
97
|
-
type: "array",
|
|
98
92
|
required: false,
|
|
99
|
-
|
|
93
|
+
type: "array"
|
|
100
94
|
},
|
|
101
|
-
"gas-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
"num-gas-objects": {
|
|
96
|
+
default: 30,
|
|
97
|
+
description: "Number of gas objects in the pool.",
|
|
104
98
|
required: true,
|
|
105
|
-
|
|
99
|
+
type: "number"
|
|
106
100
|
},
|
|
107
|
-
"
|
|
108
|
-
description: "
|
|
109
|
-
type: "number",
|
|
101
|
+
"pyth-state-id": {
|
|
102
|
+
description: "Pyth State Id. Can be found here" + "https://docs.pyth.network/documentation/pythnet-price-feeds/sui",
|
|
110
103
|
required: true,
|
|
111
|
-
|
|
104
|
+
type: "string"
|
|
105
|
+
},
|
|
106
|
+
"wormhole-state-id": {
|
|
107
|
+
description: "Wormhole State Id. Can be found here" + "https://docs.pyth.network/documentation/pythnet-price-feeds/sui",
|
|
108
|
+
required: true,
|
|
109
|
+
type: "string"
|
|
112
110
|
},
|
|
113
111
|
..._options.priceConfigFile,
|
|
114
112
|
..._options.priceServiceEndpoint,
|
|
113
|
+
..._options.hermesAccessToken,
|
|
115
114
|
..._options.mnemonicFile,
|
|
116
115
|
..._options.pollingFrequency,
|
|
117
116
|
..._options.pushingFrequency,
|
|
@@ -120,20 +119,24 @@ const _default = {
|
|
|
120
119
|
..._options.enableMetrics,
|
|
121
120
|
..._options.metricsPort
|
|
122
121
|
},
|
|
122
|
+
command: "sui",
|
|
123
|
+
describe: "Run price pusher for sui. Most of the arguments below are" + "network specific, so there's one set of values for mainnet and" + " another for testnet. See config.sui.mainnet.sample.json for the " + "appropriate values for your network. ",
|
|
123
124
|
handler: async function(argv) {
|
|
124
|
-
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, ignoreGasObjects, gasBudget, accountIndex, logLevel, controllerLogLevel, enableMetrics, metricsPort } = argv;
|
|
125
|
+
const { endpoint, priceConfigFile, priceServiceEndpoint, hermesAccessToken, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, ignoreGasObjects, gasBudget, accountIndex, logLevel, controllerLogLevel, enableMetrics, metricsPort } = argv;
|
|
125
126
|
const logger = (0, _pino.default)({
|
|
126
127
|
level: logLevel
|
|
127
128
|
});
|
|
128
129
|
const priceConfigs = (0, _priceconfig.readPriceConfigFile)(priceConfigFile);
|
|
129
|
-
const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint
|
|
130
|
+
const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint, {
|
|
131
|
+
accessToken: hermesAccessToken
|
|
132
|
+
});
|
|
130
133
|
const mnemonic = _nodefs.default.readFileSync(mnemonicFile, "utf8").trim();
|
|
131
134
|
const keypair = _ed25519.Ed25519Keypair.deriveKeypair(mnemonic, `m/44'/784'/${accountIndex}'/0'/0'`);
|
|
132
135
|
const suiAddress = keypair.getPublicKey().toSuiAddress();
|
|
133
136
|
logger.info(`Pushing updates from wallet address: ${suiAddress}`);
|
|
134
137
|
let priceItems = priceConfigs.map(({ id, alias })=>({
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
alias,
|
|
139
|
+
id
|
|
137
140
|
}));
|
|
138
141
|
// Better to filter out invalid price items before creating the pyth listener
|
|
139
142
|
const { existingPriceItems, invalidPriceItems } = await (0, _utils.filterInvalidPriceItems)(hermesClient, priceItems);
|
|
@@ -169,18 +172,18 @@ const _default = {
|
|
|
169
172
|
}, {
|
|
170
173
|
level: controllerLogLevel
|
|
171
174
|
}), {
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
metrics: metrics,
|
|
176
|
+
pushingFrequency
|
|
174
177
|
});
|
|
175
178
|
// Create and start the balance tracker if metrics are enabled
|
|
176
179
|
if (metrics) {
|
|
177
180
|
const balanceTracker = (0, _balancetracker.createSuiBalanceTracker)({
|
|
178
|
-
client: suiClient,
|
|
179
181
|
address: suiAddress,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
client: suiClient,
|
|
183
|
+
logger,
|
|
182
184
|
metrics,
|
|
183
|
-
|
|
185
|
+
network: "sui",
|
|
186
|
+
updateInterval: pushingFrequency
|
|
184
187
|
});
|
|
185
188
|
// Start the balance tracker
|
|
186
189
|
await balanceTracker.start();
|
package/dist/sui/command.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Options } from "yargs";
|
|
2
2
|
declare const _default: {
|
|
3
|
-
command: string;
|
|
4
|
-
describe: string;
|
|
5
3
|
builder: {
|
|
6
4
|
"metrics-port": Options;
|
|
7
5
|
"enable-metrics": Options;
|
|
@@ -10,16 +8,19 @@ declare const _default: {
|
|
|
10
8
|
"pushing-frequency": Options;
|
|
11
9
|
"polling-frequency": Options;
|
|
12
10
|
"mnemonic-file": Options;
|
|
11
|
+
"hermes-access-token": Options;
|
|
13
12
|
"price-service-endpoint": Options;
|
|
14
13
|
"price-config-file": Options;
|
|
14
|
+
"account-index": Options;
|
|
15
15
|
endpoint: Options;
|
|
16
|
+
"gas-budget": Options;
|
|
17
|
+
"ignore-gas-objects": Options;
|
|
18
|
+
"num-gas-objects": Options;
|
|
16
19
|
"pyth-state-id": Options;
|
|
17
20
|
"wormhole-state-id": Options;
|
|
18
|
-
"num-gas-objects": Options;
|
|
19
|
-
"ignore-gas-objects": Options;
|
|
20
|
-
"gas-budget": Options;
|
|
21
|
-
"account-index": Options;
|
|
22
21
|
};
|
|
22
|
+
command: string;
|
|
23
|
+
describe: string;
|
|
23
24
|
handler: (argv: any) => Promise<void>;
|
|
24
25
|
};
|
|
25
26
|
export default _default;
|
package/dist/sui/sui.cjs
CHANGED
|
@@ -58,8 +58,8 @@ class SuiPriceListener extends _interface.ChainPriceListener {
|
|
|
58
58
|
const conf = priceInfo.conf;
|
|
59
59
|
const timestamp = priceInfo.timestamp;
|
|
60
60
|
return {
|
|
61
|
-
price: negative ? `-${magnitude}` : magnitude,
|
|
62
61
|
conf,
|
|
62
|
+
price: negative ? `-${magnitude}` : magnitude,
|
|
63
63
|
publishTime: Number(timestamp)
|
|
64
64
|
};
|
|
65
65
|
} catch (error) {
|
|
@@ -167,11 +167,11 @@ class SuiPricePusher {
|
|
|
167
167
|
]);
|
|
168
168
|
tx.setGasBudget(this.gasBudget);
|
|
169
169
|
const result = await this.provider.signAndExecuteTransaction({
|
|
170
|
-
signer: this.signer,
|
|
171
|
-
transaction: tx,
|
|
172
170
|
options: {
|
|
173
171
|
showEffects: true
|
|
174
|
-
}
|
|
172
|
+
},
|
|
173
|
+
signer: this.signer,
|
|
174
|
+
transaction: tx
|
|
175
175
|
});
|
|
176
176
|
nextGasObject = result.effects?.mutated?.map((obj)=>obj.reference).find((ref)=>ref.objectId === gasObject.objectId);
|
|
177
177
|
this.logger.info({
|
|
@@ -246,14 +246,14 @@ class SuiPricePusher {
|
|
|
246
246
|
let numCoins = 0;
|
|
247
247
|
while(hasNextPage){
|
|
248
248
|
const paginatedCoins = await provider.getCoins({
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
cursor,
|
|
250
|
+
owner
|
|
251
251
|
});
|
|
252
252
|
numCoins += paginatedCoins.data.length;
|
|
253
253
|
for (const c of paginatedCoins.data)coins.add(JSON.stringify({
|
|
254
|
+
digest: c.digest,
|
|
254
255
|
objectId: c.coinObjectId,
|
|
255
|
-
version: c.version
|
|
256
|
-
digest: c.digest
|
|
256
|
+
version: c.version
|
|
257
257
|
}));
|
|
258
258
|
hasNextPage = paginatedCoins.hasNextPage;
|
|
259
259
|
cursor = paginatedCoins.nextCursor;
|
|
@@ -278,11 +278,11 @@ class SuiPricePusher {
|
|
|
278
278
|
gasCoin
|
|
279
279
|
]);
|
|
280
280
|
const result = await provider.signAndExecuteTransaction({
|
|
281
|
-
signer,
|
|
282
|
-
transaction: tx,
|
|
283
281
|
options: {
|
|
284
282
|
showEffects: true
|
|
285
|
-
}
|
|
283
|
+
},
|
|
284
|
+
signer,
|
|
285
|
+
transaction: tx
|
|
286
286
|
});
|
|
287
287
|
const error = result.effects?.status.error;
|
|
288
288
|
if (error) {
|
|
@@ -318,11 +318,11 @@ class SuiPricePusher {
|
|
|
318
318
|
let mergeResult;
|
|
319
319
|
try {
|
|
320
320
|
mergeResult = await provider.signAndExecuteTransaction({
|
|
321
|
-
signer,
|
|
322
|
-
transaction: mergeTx,
|
|
323
321
|
options: {
|
|
324
322
|
showEffects: true
|
|
325
|
-
}
|
|
323
|
+
},
|
|
324
|
+
signer,
|
|
325
|
+
transaction: mergeTx
|
|
326
326
|
});
|
|
327
327
|
} catch (error_) {
|
|
328
328
|
logger.error(error_, "Merge transaction failed with error");
|
package/dist/sui/sui.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SuiObjectRef } from "@mysten/sui/client";
|
|
2
2
|
import { SuiClient } from "@mysten/sui/client";
|
|
3
|
-
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
4
|
-
import { HermesClient } from "@pythnetwork/hermes-client";
|
|
3
|
+
import type { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
4
|
+
import type { HermesClient } from "@pythnetwork/hermes-client";
|
|
5
5
|
import { SuiPythClient } from "@pythnetwork/pyth-sui-js";
|
|
6
6
|
import type { Logger } from "pino";
|
|
7
7
|
import type { IPricePusher, PriceInfo, PriceItem } from "../interface.js";
|
package/dist/ton/command.cjs
CHANGED
|
@@ -12,12 +12,12 @@ const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
|
|
|
12
12
|
const _hermesclient = require("@pythnetwork/hermes-client");
|
|
13
13
|
const _ton = require("@ton/ton");
|
|
14
14
|
const _pino = require("pino");
|
|
15
|
+
const _controller = require("../controller.cjs");
|
|
15
16
|
const _options = /*#__PURE__*/ _interop_require_wildcard(require("../options.cjs"));
|
|
16
17
|
const _priceconfig = require("../price-config.cjs");
|
|
17
18
|
const _pythpricelistener = require("../pyth-price-listener.cjs");
|
|
18
|
-
const _ton1 = require("./ton.cjs");
|
|
19
|
-
const _controller = require("../controller.cjs");
|
|
20
19
|
const _utils = require("../utils.cjs");
|
|
20
|
+
const _ton1 = require("./ton.cjs");
|
|
21
21
|
function _interop_require_default(obj) {
|
|
22
22
|
return obj && obj.__esModule ? obj : {
|
|
23
23
|
default: obj
|
|
@@ -65,41 +65,44 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
65
65
|
return newObj;
|
|
66
66
|
}
|
|
67
67
|
const _default = {
|
|
68
|
-
command: "ton",
|
|
69
|
-
describe: "run price pusher for TON",
|
|
70
68
|
builder: {
|
|
71
69
|
endpoint: {
|
|
72
70
|
description: "TON RPC API endpoint",
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
required: true,
|
|
72
|
+
type: "string"
|
|
75
73
|
},
|
|
76
74
|
"private-key-file": {
|
|
77
75
|
description: "Path to the private key file",
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
required: true,
|
|
77
|
+
type: "string"
|
|
80
78
|
},
|
|
81
79
|
"pyth-contract-address": {
|
|
82
80
|
description: "Pyth contract address on TON",
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
required: true,
|
|
82
|
+
type: "string"
|
|
85
83
|
},
|
|
86
84
|
..._options.priceConfigFile,
|
|
87
85
|
..._options.priceServiceEndpoint,
|
|
86
|
+
..._options.hermesAccessToken,
|
|
88
87
|
..._options.pushingFrequency,
|
|
89
88
|
..._options.pollingFrequency,
|
|
90
89
|
..._options.logLevel,
|
|
91
90
|
..._options.controllerLogLevel
|
|
92
91
|
},
|
|
92
|
+
command: "ton",
|
|
93
|
+
describe: "run price pusher for TON",
|
|
93
94
|
handler: async function(argv) {
|
|
94
|
-
const { endpoint, privateKeyFile, pythContractAddress, priceConfigFile, priceServiceEndpoint, pushingFrequency, pollingFrequency, logLevel, controllerLogLevel } = argv;
|
|
95
|
+
const { endpoint, privateKeyFile, pythContractAddress, priceConfigFile, priceServiceEndpoint, hermesAccessToken, pushingFrequency, pollingFrequency, logLevel, controllerLogLevel } = argv;
|
|
95
96
|
const logger = (0, _pino.pino)({
|
|
96
97
|
level: logLevel
|
|
97
98
|
});
|
|
98
99
|
const priceConfigs = (0, _priceconfig.readPriceConfigFile)(priceConfigFile);
|
|
99
|
-
const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint
|
|
100
|
+
const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint, {
|
|
101
|
+
accessToken: hermesAccessToken
|
|
102
|
+
});
|
|
100
103
|
let priceItems = priceConfigs.map(({ id, alias })=>({
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
alias,
|
|
105
|
+
id
|
|
103
106
|
}));
|
|
104
107
|
// Better to filter out invalid price items before creating the pyth listener
|
|
105
108
|
const { existingPriceItems, invalidPriceItems } = await (0, _utils.filterInvalidPriceItems)(hermesClient, priceItems);
|
package/dist/ton/command.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { Options } from "yargs";
|
|
2
2
|
declare const _default: {
|
|
3
|
-
command: string;
|
|
4
|
-
describe: string;
|
|
5
3
|
builder: {
|
|
6
4
|
"controller-log-level": Options;
|
|
7
5
|
"log-level": Options;
|
|
8
6
|
"polling-frequency": Options;
|
|
9
7
|
"pushing-frequency": Options;
|
|
8
|
+
"hermes-access-token": Options;
|
|
10
9
|
"price-service-endpoint": Options;
|
|
11
10
|
"price-config-file": Options;
|
|
12
11
|
endpoint: Options;
|
|
13
12
|
"private-key-file": Options;
|
|
14
13
|
"pyth-contract-address": Options;
|
|
15
14
|
};
|
|
15
|
+
command: string;
|
|
16
|
+
describe: string;
|
|
16
17
|
handler: (argv: any) => Promise<void>;
|
|
17
18
|
};
|
|
18
19
|
export default _default;
|
package/dist/ton/ton.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { HermesClient } from "@pythnetwork/hermes-client";
|
|
2
|
-
import type { ContractProvider } from "@ton/ton";
|
|
3
|
-
import { Address, TonClient } from "@ton/ton";
|
|
1
|
+
import type { HermesClient } from "@pythnetwork/hermes-client";
|
|
2
|
+
import type { Address, ContractProvider, TonClient } from "@ton/ton";
|
|
4
3
|
import type { Logger } from "pino";
|
|
5
4
|
import type { IPricePusher, PriceInfo, PriceItem } from "../interface.js";
|
|
6
5
|
import { ChainPriceListener } from "../interface.js";
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { HexString } from "@pythnetwork/hermes-client";
|
|
2
|
-
import { HermesClient } from "@pythnetwork/hermes-client";
|
|
1
|
+
import type { HermesClient, HexString } from "@pythnetwork/hermes-client";
|
|
3
2
|
import type { PriceItem } from "./interface.js";
|
|
4
3
|
export type PctNumber = number;
|
|
5
4
|
export type DurationInSeconds = number;
|