@pythnetwork/price-pusher 10.3.0 → 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/index.cjs +0 -0
- 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 +122 -133
package/README.md
CHANGED
|
@@ -182,7 +182,9 @@ pnpm run start solana \
|
|
|
182
182
|
|
|
183
183
|
|
|
184
184
|
|
|
185
|
-
# Or, run the price pusher docker image instead of building from the source
|
|
185
|
+
# Or, run the price pusher docker image instead of building from the source.
|
|
186
|
+
# Note: There is no :latest tag. Find available version tags at:
|
|
187
|
+
# https://gallery.ecr.aws/pyth-network/xc-price-pusher
|
|
186
188
|
docker run public.ecr.aws/pyth-network/xc-price-pusher:v<version> -- npm run start -- <above-arguments>
|
|
187
189
|
```
|
|
188
190
|
|
package/dist/aptos/aptos.cjs
CHANGED
|
@@ -36,18 +36,18 @@ class AptosPriceListener extends _interface.ChainPriceListener {
|
|
|
36
36
|
// If undefined, there has been some change and we would need to update accordingly.
|
|
37
37
|
const handle = res.data.info.handle;
|
|
38
38
|
const priceItemRes = await client.getTableItem(handle, {
|
|
39
|
-
key_type: `${this.pythModule}::price_identifier::PriceIdentifier`,
|
|
40
|
-
value_type: `${this.pythModule}::price_info::PriceInfo`,
|
|
41
39
|
key: {
|
|
42
40
|
bytes: priceId
|
|
43
|
-
}
|
|
41
|
+
},
|
|
42
|
+
key_type: `${this.pythModule}::price_identifier::PriceIdentifier`,
|
|
43
|
+
value_type: `${this.pythModule}::price_info::PriceInfo`
|
|
44
44
|
});
|
|
45
45
|
const multiplier = priceItemRes.price_feed.price.price.negative === true ? -1 : 1;
|
|
46
46
|
const price = multiplier * Number(priceItemRes.price_feed.price.price.magnitude);
|
|
47
47
|
this.logger.debug(`Polled an Aptos on-chain price for feed ${this.priceIdToAlias.get(priceId) ?? ""} (${priceId}).`);
|
|
48
48
|
return {
|
|
49
|
-
price: price.toString(),
|
|
50
49
|
conf: priceItemRes.price_feed.price.conf,
|
|
50
|
+
price: price.toString(),
|
|
51
51
|
publishTime: Number(priceItemRes.price_feed.price.timestamp)
|
|
52
52
|
};
|
|
53
53
|
} catch (error) {
|
|
@@ -110,11 +110,11 @@ class AptosPricePusher {
|
|
|
110
110
|
const client = new _aptos.AptosClient(this.endpoint);
|
|
111
111
|
const sequenceNumber = await this.tryGetNextSequenceNumber(client, account);
|
|
112
112
|
const rawTx = await client.generateTransaction(account.address(), {
|
|
113
|
-
function: `${this.pythContractAddress}::pyth::update_price_feeds_with_funder`,
|
|
114
|
-
type_arguments: [],
|
|
115
113
|
arguments: [
|
|
116
114
|
priceFeedUpdateData
|
|
117
|
-
]
|
|
115
|
+
],
|
|
116
|
+
function: `${this.pythContractAddress}::pyth::update_price_feeds_with_funder`,
|
|
117
|
+
type_arguments: []
|
|
118
118
|
}, {
|
|
119
119
|
sequence_number: sequenceNumber.toFixed(0)
|
|
120
120
|
});
|
package/dist/aptos/aptos.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HermesClient } from "@pythnetwork/hermes-client";
|
|
1
|
+
import type { HermesClient } from "@pythnetwork/hermes-client";
|
|
2
2
|
import type { Logger } from "pino";
|
|
3
3
|
import type { IPricePusher, PriceInfo, PriceItem } from "../interface.js";
|
|
4
4
|
import { ChainPriceListener } from "../interface.js";
|
|
@@ -30,8 +30,8 @@ class AptosBalanceTracker extends _interface.BaseBalanceTracker {
|
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
32
|
this.client = new _tssdk.Aptos(new _tssdk.AptosConfig({
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
fullnode: config.endpoint,
|
|
34
|
+
network: _tssdk.Network.CUSTOM
|
|
35
35
|
}));
|
|
36
36
|
this.aptosAddress = config.address;
|
|
37
37
|
// APT has 8 decimal places by default
|
|
@@ -62,12 +62,12 @@ class AptosBalanceTracker extends _interface.BaseBalanceTracker {
|
|
|
62
62
|
}
|
|
63
63
|
function createAptosBalanceTracker(params) {
|
|
64
64
|
return new AptosBalanceTracker({
|
|
65
|
-
endpoint: params.endpoint,
|
|
66
65
|
address: params.address,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
metrics: params.metrics,
|
|
66
|
+
decimals: params.decimals,
|
|
67
|
+
endpoint: params.endpoint,
|
|
70
68
|
logger: params.logger,
|
|
71
|
-
|
|
69
|
+
metrics: params.metrics,
|
|
70
|
+
network: params.network,
|
|
71
|
+
updateInterval: params.updateInterval
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
2
|
import type { BaseBalanceTrackerConfig, IBalanceTracker } from "../interface.js";
|
|
3
3
|
import { BaseBalanceTracker } from "../interface.js";
|
|
4
|
-
import { PricePusherMetrics } from "../metrics.js";
|
|
4
|
+
import type { PricePusherMetrics } from "../metrics.js";
|
|
5
5
|
import type { DurationInSeconds } from "../utils.js";
|
|
6
6
|
/**
|
|
7
7
|
* Aptos-specific configuration for balance tracker
|
package/dist/aptos/command.cjs
CHANGED
|
@@ -17,8 +17,8 @@ const _metrics = require("../metrics.cjs");
|
|
|
17
17
|
const _options = /*#__PURE__*/ _interop_require_wildcard(require("../options.cjs"));
|
|
18
18
|
const _priceconfig = require("../price-config.cjs");
|
|
19
19
|
const _pythpricelistener = require("../pyth-price-listener.cjs");
|
|
20
|
-
const _aptos1 = require("./aptos.cjs");
|
|
21
20
|
const _utils = require("../utils.cjs");
|
|
21
|
+
const _aptos1 = require("./aptos.cjs");
|
|
22
22
|
const _balancetracker = require("./balance-tracker.cjs");
|
|
23
23
|
function _interop_require_default(obj) {
|
|
24
24
|
return obj && obj.__esModule ? obj : {
|
|
@@ -67,22 +67,21 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
67
67
|
return newObj;
|
|
68
68
|
}
|
|
69
69
|
const _default = {
|
|
70
|
-
command: "aptos",
|
|
71
|
-
describe: "run price pusher for aptos",
|
|
72
70
|
builder: {
|
|
73
71
|
endpoint: {
|
|
74
72
|
description: "RPC endpoint endpoint URL for aptos. The pusher will periodically" + "poll for updates. The polling interval is configurable via the " + "`polling-frequency` command-line argument.",
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
required: true,
|
|
74
|
+
type: "string"
|
|
77
75
|
},
|
|
78
76
|
"override-gas-price-multiplier": {
|
|
77
|
+
default: 2,
|
|
79
78
|
description: "Multiply the gas price by this number if the transaction is not landing to override it. Default 2",
|
|
80
|
-
type: "number",
|
|
81
79
|
required: false,
|
|
82
|
-
|
|
80
|
+
type: "number"
|
|
83
81
|
},
|
|
84
82
|
..._options.priceConfigFile,
|
|
85
83
|
..._options.priceServiceEndpoint,
|
|
84
|
+
..._options.hermesAccessToken,
|
|
86
85
|
..._options.mnemonicFile,
|
|
87
86
|
..._options.pythContractAddress,
|
|
88
87
|
..._options.pollingFrequency,
|
|
@@ -92,14 +91,18 @@ const _default = {
|
|
|
92
91
|
..._options.enableMetrics,
|
|
93
92
|
..._options.metricsPort
|
|
94
93
|
},
|
|
94
|
+
command: "aptos",
|
|
95
|
+
describe: "run price pusher for aptos",
|
|
95
96
|
handler: async function(argv) {
|
|
96
97
|
// FIXME: type checks for this
|
|
97
|
-
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, overrideGasPriceMultiplier, logLevel, controllerLogLevel, enableMetrics, metricsPort } = argv;
|
|
98
|
+
const { endpoint, priceConfigFile, priceServiceEndpoint, hermesAccessToken, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, overrideGasPriceMultiplier, logLevel, controllerLogLevel, enableMetrics, metricsPort } = argv;
|
|
98
99
|
const logger = (0, _pino.default)({
|
|
99
100
|
level: logLevel
|
|
100
101
|
});
|
|
101
102
|
const priceConfigs = (0, _priceconfig.readPriceConfigFile)(priceConfigFile);
|
|
102
|
-
const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint
|
|
103
|
+
const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint, {
|
|
104
|
+
accessToken: hermesAccessToken
|
|
105
|
+
});
|
|
103
106
|
// Initialize metrics if enabled
|
|
104
107
|
let metrics;
|
|
105
108
|
if (enableMetrics) {
|
|
@@ -113,8 +116,8 @@ const _default = {
|
|
|
113
116
|
const account = _aptos.AptosAccount.fromDerivePath(_aptos1.APTOS_ACCOUNT_HD_PATH, mnemonic);
|
|
114
117
|
logger.info(`Pushing from account address: ${account.address()}`);
|
|
115
118
|
let priceItems = priceConfigs.map(({ id, alias })=>({
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
alias,
|
|
120
|
+
id
|
|
118
121
|
}));
|
|
119
122
|
// Better to filter out invalid price items before creating the pyth listener
|
|
120
123
|
const { existingPriceItems, invalidPriceItems } = await (0, _utils.filterInvalidPriceItems)(hermesClient, priceItems);
|
|
@@ -138,20 +141,20 @@ const _default = {
|
|
|
138
141
|
}, {
|
|
139
142
|
level: controllerLogLevel
|
|
140
143
|
}), {
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
metrics: metrics,
|
|
145
|
+
pushingFrequency
|
|
143
146
|
});
|
|
144
147
|
// Create and start the balance tracker if metrics are enabled
|
|
145
148
|
if (metrics) {
|
|
146
149
|
const balanceTracker = (0, _balancetracker.createAptosBalanceTracker)({
|
|
147
150
|
address: account.address().toString(),
|
|
148
151
|
endpoint,
|
|
149
|
-
network: "aptos",
|
|
150
|
-
updateInterval: pushingFrequency,
|
|
151
|
-
metrics,
|
|
152
152
|
logger: logger.child({
|
|
153
153
|
module: "AptosBalanceTracker"
|
|
154
|
-
})
|
|
154
|
+
}),
|
|
155
|
+
metrics,
|
|
156
|
+
network: "aptos",
|
|
157
|
+
updateInterval: pushingFrequency
|
|
155
158
|
});
|
|
156
159
|
// Start the balance tracker
|
|
157
160
|
await balanceTracker.start();
|
package/dist/aptos/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;
|
|
@@ -11,11 +9,14 @@ declare const _default: {
|
|
|
11
9
|
"polling-frequency": Options;
|
|
12
10
|
"pyth-contract-address": Options;
|
|
13
11
|
"mnemonic-file": Options;
|
|
12
|
+
"hermes-access-token": Options;
|
|
14
13
|
"price-service-endpoint": Options;
|
|
15
14
|
"price-config-file": Options;
|
|
16
15
|
endpoint: Options;
|
|
17
16
|
"override-gas-price-multiplier": Options;
|
|
18
17
|
};
|
|
18
|
+
command: string;
|
|
19
|
+
describe: string;
|
|
19
20
|
handler: (argv: any) => Promise<void>;
|
|
20
21
|
};
|
|
21
22
|
export default _default;
|
package/dist/controller.cjs
CHANGED
|
@@ -68,8 +68,8 @@ class Controller {
|
|
|
68
68
|
if (pushThresholdMet) {
|
|
69
69
|
this.logger.info({
|
|
70
70
|
priceIds: pricesToPush.map((priceConfig)=>({
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
alias: priceConfig.alias,
|
|
72
|
+
id: priceConfig.id
|
|
73
73
|
}))
|
|
74
74
|
}, "Some of the checks triggered pushing update. Will push the updates for some feeds.");
|
|
75
75
|
// note that the priceIds are without leading "0x"
|
package/dist/controller.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
2
|
import type { IPriceListener, IPricePusher } from "./interface.js";
|
|
3
|
-
import { PricePusherMetrics } from "./metrics.js";
|
|
3
|
+
import type { PricePusherMetrics } from "./metrics.js";
|
|
4
4
|
import type { PriceConfig } from "./price-config.js";
|
|
5
5
|
import type { DurationInSeconds } from "./utils.js";
|
|
6
6
|
export declare class Controller {
|
|
@@ -48,11 +48,11 @@ class EvmBalanceTracker extends _interface.BaseBalanceTracker {
|
|
|
48
48
|
}
|
|
49
49
|
function createEvmBalanceTracker(params) {
|
|
50
50
|
return new EvmBalanceTracker({
|
|
51
|
-
client: params.client,
|
|
52
51
|
address: params.address,
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
client: params.client,
|
|
53
|
+
logger: params.logger,
|
|
55
54
|
metrics: params.metrics,
|
|
56
|
-
|
|
55
|
+
network: params.network,
|
|
56
|
+
updateInterval: params.updateInterval
|
|
57
57
|
});
|
|
58
58
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
|
-
import type { SuperWalletClient } from "./super-wallet.js";
|
|
3
2
|
import type { BaseBalanceTrackerConfig, IBalanceTracker } from "../interface.js";
|
|
4
3
|
import { BaseBalanceTracker } from "../interface.js";
|
|
5
|
-
import { PricePusherMetrics } from "../metrics.js";
|
|
4
|
+
import type { PricePusherMetrics } from "../metrics.js";
|
|
6
5
|
import type { DurationInSeconds } from "../utils.js";
|
|
6
|
+
import type { SuperWalletClient } from "./super-wallet.js";
|
|
7
7
|
/**
|
|
8
8
|
* EVM-specific configuration for balance tracker
|
|
9
9
|
*/
|
package/dist/evm/command.cjs
CHANGED
|
@@ -12,16 +12,16 @@ const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
|
|
|
12
12
|
const _hermesclient = require("@pythnetwork/hermes-client");
|
|
13
13
|
const _pino = /*#__PURE__*/ _interop_require_default(require("pino"));
|
|
14
14
|
const _controller = require("../controller.cjs");
|
|
15
|
+
const _metrics = require("../metrics.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");
|
|
19
|
+
const _utils = require("../utils.cjs");
|
|
20
|
+
const _balancetracker = require("./balance-tracker.cjs");
|
|
18
21
|
const _customgasstation = require("./custom-gas-station.cjs");
|
|
19
22
|
const _evm = require("./evm.cjs");
|
|
20
23
|
const _pythcontract = require("./pyth-contract.cjs");
|
|
21
24
|
const _superwallet = require("./super-wallet.cjs");
|
|
22
|
-
const _metrics = require("../metrics.cjs");
|
|
23
|
-
const _utils = require("../utils.cjs");
|
|
24
|
-
const _balancetracker = require("./balance-tracker.cjs");
|
|
25
25
|
function _interop_require_default(obj) {
|
|
26
26
|
return obj && obj.__esModule ? obj : {
|
|
27
27
|
default: obj
|
|
@@ -69,58 +69,57 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
69
69
|
return newObj;
|
|
70
70
|
}
|
|
71
71
|
const _default = {
|
|
72
|
-
command: "evm",
|
|
73
|
-
describe: "run price pusher for evm",
|
|
74
72
|
builder: {
|
|
73
|
+
"custom-gas-station": {
|
|
74
|
+
description: "If using a custom gas station, chainId of custom gas station to use",
|
|
75
|
+
required: false,
|
|
76
|
+
type: "number"
|
|
77
|
+
},
|
|
75
78
|
endpoint: {
|
|
76
79
|
description: "RPC endpoint URL for evm network. If you provide a normal HTTP endpoint, the pusher " + "will periodically poll for updates. The polling interval is configurable via the " + "`polling-frequency` command-line argument. If you provide a websocket RPC " + "endpoint (`ws[s]://...`), the price pusher will use event subscriptions to read " + "the current EVM price in addition to polling. ",
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
required: true,
|
|
81
|
+
type: "string"
|
|
79
82
|
},
|
|
80
|
-
"
|
|
81
|
-
description: "
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
"gas-limit": {
|
|
84
|
+
description: "Gas limit for the transaction",
|
|
85
|
+
required: false,
|
|
86
|
+
type: "number"
|
|
84
87
|
},
|
|
85
|
-
"
|
|
86
|
-
description: "
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"standard",
|
|
90
|
-
"fast"
|
|
91
|
-
],
|
|
92
|
-
required: false
|
|
88
|
+
"gas-price": {
|
|
89
|
+
description: "Override the gas price that would be received from the RPC",
|
|
90
|
+
required: false,
|
|
91
|
+
type: "number"
|
|
93
92
|
},
|
|
94
93
|
"override-gas-price-multiplier": {
|
|
94
|
+
default: 1.1,
|
|
95
95
|
description: "Multiply the previous gas price by this number if the transaction is not landing to override. " + "Please note that the gas price can grow exponentially on consecutive failures; " + "to set a cap on the multiplier, use the `override-gas-price-multiplier-cap` option." + "Default to 1.1",
|
|
96
|
-
type: "number",
|
|
97
96
|
required: false,
|
|
98
|
-
|
|
97
|
+
type: "number"
|
|
99
98
|
},
|
|
100
99
|
"override-gas-price-multiplier-cap": {
|
|
100
|
+
default: 5,
|
|
101
101
|
description: "Maximum gas price multiplier to use in override compared to the RPC returned " + "gas price. Default to 5",
|
|
102
|
-
type: "number",
|
|
103
102
|
required: false,
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
"gas-limit": {
|
|
107
|
-
description: "Gas limit for the transaction",
|
|
108
|
-
type: "number",
|
|
109
|
-
required: false
|
|
103
|
+
type: "number"
|
|
110
104
|
},
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
"tx-speed": {
|
|
106
|
+
choices: [
|
|
107
|
+
"slow",
|
|
108
|
+
"standard",
|
|
109
|
+
"fast"
|
|
110
|
+
],
|
|
111
|
+
description: "txSpeed for custom gas station. choose between 'slow'|'standard'|'fast'",
|
|
114
112
|
required: false
|
|
115
113
|
},
|
|
116
114
|
"update-fee-multiplier": {
|
|
115
|
+
default: 1,
|
|
117
116
|
description: "Multiplier for the fee to update the price. It is useful in networks " + "such as Hedera where setting on-chain getUpdateFee as the transaction value " + "won't work. Default to 1",
|
|
118
|
-
type: "number",
|
|
119
117
|
required: false,
|
|
120
|
-
|
|
118
|
+
type: "number"
|
|
121
119
|
},
|
|
122
120
|
..._options.priceConfigFile,
|
|
123
121
|
..._options.priceServiceEndpoint,
|
|
122
|
+
..._options.hermesAccessToken,
|
|
124
123
|
..._options.mnemonicFile,
|
|
125
124
|
..._options.pythContractAddress,
|
|
126
125
|
..._options.pollingFrequency,
|
|
@@ -130,18 +129,22 @@ const _default = {
|
|
|
130
129
|
..._options.enableMetrics,
|
|
131
130
|
..._options.metricsPort
|
|
132
131
|
},
|
|
132
|
+
command: "evm",
|
|
133
|
+
describe: "run price pusher for evm",
|
|
133
134
|
handler: async function(argv) {
|
|
134
135
|
// FIXME: type checks for this
|
|
135
|
-
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, customGasStation, txSpeed, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, gasLimit, gasPrice, updateFeeMultiplier, logLevel, controllerLogLevel, enableMetrics, metricsPort } = argv;
|
|
136
|
+
const { endpoint, priceConfigFile, priceServiceEndpoint, hermesAccessToken, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, customGasStation, txSpeed, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, gasLimit, gasPrice, updateFeeMultiplier, logLevel, controllerLogLevel, enableMetrics, metricsPort } = argv;
|
|
136
137
|
const logger = (0, _pino.default)({
|
|
137
138
|
level: logLevel
|
|
138
139
|
});
|
|
139
140
|
const priceConfigs = (0, _priceconfig.readPriceConfigFile)(priceConfigFile);
|
|
140
|
-
const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint
|
|
141
|
+
const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint, {
|
|
142
|
+
accessToken: hermesAccessToken
|
|
143
|
+
});
|
|
141
144
|
const mnemonic = _nodefs.default.readFileSync(mnemonicFile, "utf8").trim();
|
|
142
145
|
let priceItems = priceConfigs.map(({ id, alias })=>({
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
alias,
|
|
147
|
+
id
|
|
145
148
|
}));
|
|
146
149
|
// Better to filter out invalid price items before creating the pyth listener
|
|
147
150
|
const { existingPriceItems, invalidPriceItems } = await (0, _utils.filterInvalidPriceItems)(hermesClient, priceItems);
|
|
@@ -184,18 +187,18 @@ const _default = {
|
|
|
184
187
|
}, {
|
|
185
188
|
level: controllerLogLevel
|
|
186
189
|
}), {
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
metrics: metrics,
|
|
191
|
+
pushingFrequency
|
|
189
192
|
});
|
|
190
193
|
// Create and start the balance tracker if metrics are enabled
|
|
191
194
|
if (metrics) {
|
|
192
195
|
const balanceTracker = (0, _balancetracker.createEvmBalanceTracker)({
|
|
193
|
-
client,
|
|
194
196
|
address: client.account.address,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
client,
|
|
198
|
+
logger,
|
|
197
199
|
metrics,
|
|
198
|
-
|
|
200
|
+
network: await client.getChainId().then((id)=>id.toString()),
|
|
201
|
+
updateInterval: pushingFrequency
|
|
199
202
|
});
|
|
200
203
|
// Start the balance tracker
|
|
201
204
|
await balanceTracker.start();
|
package/dist/evm/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;
|
|
@@ -11,17 +9,20 @@ declare const _default: {
|
|
|
11
9
|
"polling-frequency": Options;
|
|
12
10
|
"pyth-contract-address": Options;
|
|
13
11
|
"mnemonic-file": Options;
|
|
12
|
+
"hermes-access-token": Options;
|
|
14
13
|
"price-service-endpoint": Options;
|
|
15
14
|
"price-config-file": Options;
|
|
16
|
-
endpoint: Options;
|
|
17
15
|
"custom-gas-station": Options;
|
|
18
|
-
|
|
19
|
-
"override-gas-price-multiplier": Options;
|
|
20
|
-
"override-gas-price-multiplier-cap": Options;
|
|
16
|
+
endpoint: Options;
|
|
21
17
|
"gas-limit": Options;
|
|
22
18
|
"gas-price": Options;
|
|
19
|
+
"override-gas-price-multiplier": Options;
|
|
20
|
+
"override-gas-price-multiplier-cap": Options;
|
|
21
|
+
"tx-speed": Options;
|
|
23
22
|
"update-fee-multiplier": Options;
|
|
24
23
|
};
|
|
24
|
+
command: string;
|
|
25
|
+
describe: string;
|
|
25
26
|
handler: (argv: any) => Promise<void>;
|
|
26
27
|
};
|
|
27
28
|
export default _default;
|
package/dist/evm/evm.cjs
CHANGED
|
@@ -17,8 +17,8 @@ _export(exports, {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _viem = require("viem");
|
|
20
|
-
const _utils = require("../utils.cjs");
|
|
21
20
|
const _interface = require("../interface.cjs");
|
|
21
|
+
const _utils = require("../utils.cjs");
|
|
22
22
|
class EvmPriceListener extends _interface.ChainPriceListener {
|
|
23
23
|
pythContract;
|
|
24
24
|
watchEvents;
|
|
@@ -44,8 +44,8 @@ class EvmPriceListener extends _interface.ChainPriceListener {
|
|
|
44
44
|
this.pythContract.watchEvent.PriceFeedUpdate({
|
|
45
45
|
id: this.priceItems.map((item)=>(0, _utils.addLeading0x)(item.id))
|
|
46
46
|
}, {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
onLogs: this.onPriceFeedUpdate.bind(this),
|
|
48
|
+
strict: true
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
onPriceFeedUpdate(logs) {
|
|
@@ -156,8 +156,8 @@ class EvmPricePusher {
|
|
|
156
156
|
const priceIdsWith0x = priceIds.map((priceId)=>(0, _utils.addLeading0x)(priceId));
|
|
157
157
|
// Update lastAttempt
|
|
158
158
|
this.lastPushAttempt = {
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
gasPrice: gasPrice,
|
|
160
|
+
nonce: txNonce
|
|
161
161
|
};
|
|
162
162
|
try {
|
|
163
163
|
const { request } = await this.pythContract.simulate.updatePriceFeedsIfNecessary([
|
|
@@ -165,10 +165,10 @@ class EvmPricePusher {
|
|
|
165
165
|
priceIdsWith0x,
|
|
166
166
|
pubTimesToPushParam
|
|
167
167
|
], {
|
|
168
|
-
|
|
168
|
+
gas: this.gasLimit === undefined ? undefined : BigInt(Math.ceil(this.gasLimit)),
|
|
169
169
|
gasPrice: BigInt(Math.ceil(gasPrice)),
|
|
170
170
|
nonce: txNonce,
|
|
171
|
-
|
|
171
|
+
value: updateFee
|
|
172
172
|
});
|
|
173
173
|
this.logger.debug({
|
|
174
174
|
request
|
package/dist/evm/evm.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type { HexString, UnixTimestamp } from "@pythnetwork/hermes-client";
|
|
2
|
-
import { HermesClient } from "@pythnetwork/hermes-client";
|
|
1
|
+
import type { HermesClient, HexString, UnixTimestamp } from "@pythnetwork/hermes-client";
|
|
3
2
|
import type { Logger } from "pino";
|
|
4
3
|
import type { IPricePusher, PriceInfo, PriceItem } from "../interface.js";
|
|
4
|
+
import { ChainPriceListener } from "../interface.js";
|
|
5
5
|
import type { DurationInSeconds } from "../utils.js";
|
|
6
|
-
import { CustomGasStation } from "./custom-gas-station";
|
|
6
|
+
import type { CustomGasStation } from "./custom-gas-station";
|
|
7
7
|
import type { PythContract } from "./pyth-contract.js";
|
|
8
8
|
import type { SuperWalletClient } from "./super-wallet.js";
|
|
9
|
-
import { ChainPriceListener } from "../interface.js";
|
|
10
9
|
export declare class EvmPriceListener extends ChainPriceListener {
|
|
11
10
|
private pythContract;
|
|
12
11
|
private watchEvents;
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "createPythContract", {
|
|
|
11
11
|
const _viem = require("viem");
|
|
12
12
|
const _pythabi = require("./pyth-abi.cjs");
|
|
13
13
|
const createPythContract = (client, address)=>(0, _viem.getContract)({
|
|
14
|
-
client,
|
|
15
14
|
abi: _pythabi.PythAbi,
|
|
16
|
-
address
|
|
15
|
+
address,
|
|
16
|
+
client
|
|
17
17
|
});
|
|
@@ -56,9 +56,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
56
56
|
const UNKNOWN_CHAIN_CONFIG = {
|
|
57
57
|
name: "Unknown",
|
|
58
58
|
nativeCurrency: {
|
|
59
|
+
decimals: 18,
|
|
59
60
|
name: "Unknown",
|
|
60
|
-
symbol: "Unknown"
|
|
61
|
-
decimals: 18
|
|
61
|
+
symbol: "Unknown"
|
|
62
62
|
},
|
|
63
63
|
rpcUrls: {
|
|
64
64
|
default: {
|
|
@@ -83,8 +83,8 @@ const createClient = async (endpoint, mnemonic)=>{
|
|
|
83
83
|
transport
|
|
84
84
|
}).getChainId();
|
|
85
85
|
return (0, _viem.createWalletClient)({
|
|
86
|
-
transport,
|
|
87
86
|
account: (0, _accounts.mnemonicToAccount)(mnemonic),
|
|
88
|
-
chain: getChainById(chainId)
|
|
87
|
+
chain: getChainById(chainId),
|
|
88
|
+
transport
|
|
89
89
|
}).extend(_viem.publicActions);
|
|
90
90
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Account, Chain, Client,
|
|
1
|
+
import type { Account, Chain, Client, PublicActions, RpcSchema, Transport, WalletActions } from "viem";
|
|
2
2
|
export type SuperWalletClient = Client<Transport, Chain, Account, RpcSchema, PublicActions<Transport, Chain, Account> & WalletActions<Chain, Account>>;
|
|
3
3
|
export declare const createClient: (endpoint: string, mnemonic: string) => Promise<SuperWalletClient>;
|
package/dist/fuel/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 _fuels = require("fuels");
|
|
14
14
|
const _pino = /*#__PURE__*/ _interop_require_default(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 _fuel = require("./fuel.cjs");
|
|
19
|
-
const _controller = require("../controller.cjs");
|
|
20
19
|
const _utils = require("../utils.cjs");
|
|
20
|
+
const _fuel = require("./fuel.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: "fuel",
|
|
69
|
-
describe: "run price pusher for Fuel",
|
|
70
68
|
builder: {
|
|
71
69
|
endpoint: {
|
|
72
70
|
description: "Fuel 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 Fuel",
|
|
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: "fuel",
|
|
93
|
+
describe: "run price pusher for Fuel",
|
|
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.default)({
|
|
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);
|