@pythnetwork/price-pusher 10.2.0 → 10.3.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/{lib/aptos/aptos.js → dist/aptos/aptos.cjs} +80 -76
- package/{lib → dist}/aptos/aptos.d.ts +5 -5
- package/{lib/aptos/balance-tracker.js → dist/aptos/balance-tracker.cjs} +37 -25
- package/{lib → dist}/aptos/balance-tracker.d.ts +9 -9
- package/dist/aptos/command.cjs +161 -0
- package/{lib → dist}/aptos/command.d.ts +1 -2
- package/dist/common.cjs +4 -0
- package/{lib → dist}/common.d.ts +0 -1
- package/{lib/controller.js → dist/controller.cjs} +35 -33
- package/{lib → dist}/controller.d.ts +5 -6
- package/dist/evm/balance-tracker.cjs +58 -0
- package/{lib → dist}/evm/balance-tracker.d.ts +10 -10
- package/dist/evm/command.cjs +205 -0
- package/{lib → dist}/evm/command.d.ts +1 -2
- package/dist/evm/custom-gas-station.cjs +54 -0
- package/{lib → dist}/evm/custom-gas-station.d.ts +1 -2
- package/dist/evm/evm.cjs +287 -0
- package/{lib → dist}/evm/evm.d.ts +8 -7
- package/{lib/evm/pyth-abi.js → dist/evm/pyth-abi.cjs} +181 -160
- package/{lib → dist}/evm/pyth-abi.d.ts +0 -1
- package/dist/evm/pyth-contract.cjs +17 -0
- package/{lib → dist}/evm/pyth-contract.d.ts +3 -4
- package/dist/evm/super-wallet.cjs +90 -0
- package/{lib → dist}/evm/super-wallet.d.ts +1 -2
- package/dist/fuel/command.cjs +135 -0
- package/{lib → dist}/fuel/command.d.ts +1 -2
- package/dist/fuel/fuel.cjs +108 -0
- package/{lib → dist}/fuel/fuel.d.ts +5 -5
- package/dist/index.cjs +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/injective/command.cjs +150 -0
- package/{lib → dist}/injective/command.d.ts +1 -2
- package/{lib/injective/injective.js → dist/injective/injective.cjs} +100 -98
- package/{lib → dist}/injective/injective.d.ts +7 -6
- package/dist/interface.cjs +142 -0
- package/{lib → dist}/interface.d.ts +12 -13
- package/dist/metrics.cjs +218 -0
- package/{lib → dist}/metrics.d.ts +10 -11
- package/dist/near/command.cjs +129 -0
- package/{lib → dist}/near/command.d.ts +1 -2
- package/dist/near/near.cjs +183 -0
- package/{lib → dist}/near/near.d.ts +5 -5
- package/dist/options.cjs +132 -0
- package/{lib → dist}/options.d.ts +1 -2
- package/dist/package.json +1 -0
- package/dist/price-config.cjs +104 -0
- package/{lib → dist}/price-config.d.ts +5 -6
- package/{lib/pyth-price-listener.js → dist/pyth-price-listener.cjs} +30 -24
- package/{lib → dist}/pyth-price-listener.d.ts +4 -4
- package/dist/solana/balance-tracker.cjs +60 -0
- package/{lib → dist}/solana/balance-tracker.d.ts +9 -9
- package/dist/solana/command.cjs +259 -0
- package/{lib → dist}/solana/command.d.ts +2 -3
- package/{lib/solana/solana.js → dist/solana/solana.cjs} +90 -78
- package/{lib → dist}/solana/solana.d.ts +6 -6
- package/dist/sui/balance-tracker.cjs +58 -0
- package/{lib → dist}/sui/balance-tracker.d.ts +9 -9
- package/dist/sui/command.cjs +190 -0
- package/{lib → dist}/sui/command.d.ts +1 -2
- package/{lib/sui/sui.js → dist/sui/sui.cjs} +145 -133
- package/{lib → dist}/sui/sui.d.ts +7 -8
- package/dist/ton/command.cjs +137 -0
- package/{lib → dist}/ton/command.d.ts +1 -2
- package/dist/ton/ton.cjs +103 -0
- package/{lib → dist}/ton/ton.d.ts +7 -6
- package/dist/utils.cjs +102 -0
- package/{lib → dist}/utils.d.ts +4 -4
- package/package.json +161 -20
- package/lib/aptos/aptos.d.ts.map +0 -1
- package/lib/aptos/balance-tracker.d.ts.map +0 -1
- package/lib/aptos/command.d.ts.map +0 -1
- package/lib/aptos/command.js +0 -126
- package/lib/common.d.ts.map +0 -1
- package/lib/common.js +0 -2
- package/lib/controller.d.ts.map +0 -1
- package/lib/evm/balance-tracker.d.ts.map +0 -1
- package/lib/evm/balance-tracker.js +0 -49
- package/lib/evm/command.d.ts.map +0 -1
- package/lib/evm/command.js +0 -178
- package/lib/evm/custom-gas-station.d.ts.map +0 -1
- package/lib/evm/custom-gas-station.js +0 -40
- package/lib/evm/evm.d.ts.map +0 -1
- package/lib/evm/evm.js +0 -270
- package/lib/evm/pyth-abi.d.ts.map +0 -1
- package/lib/evm/pyth-contract.d.ts.map +0 -1
- package/lib/evm/pyth-contract.js +0 -11
- package/lib/evm/super-wallet.d.ts.map +0 -1
- package/lib/evm/super-wallet.js +0 -73
- package/lib/fuel/command.d.ts.map +0 -1
- package/lib/fuel/command.js +0 -98
- package/lib/fuel/fuel.d.ts.map +0 -1
- package/lib/fuel/fuel.js +0 -101
- package/lib/index.d.ts +0 -3
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -34
- package/lib/injective/command.d.ts.map +0 -1
- package/lib/injective/command.js +0 -119
- package/lib/injective/injective.d.ts.map +0 -1
- package/lib/interface.d.ts.map +0 -1
- package/lib/interface.js +0 -122
- package/lib/metrics.d.ts.map +0 -1
- package/lib/metrics.js +0 -152
- package/lib/near/command.d.ts.map +0 -1
- package/lib/near/command.js +0 -103
- package/lib/near/near.d.ts.map +0 -1
- package/lib/near/near.js +0 -168
- package/lib/options.d.ts.map +0 -1
- package/lib/options.js +0 -84
- package/lib/price-config.d.ts.map +0 -1
- package/lib/price-config.js +0 -114
- package/lib/pyth-price-listener.d.ts.map +0 -1
- package/lib/solana/balance-tracker.d.ts.map +0 -1
- package/lib/solana/balance-tracker.js +0 -51
- package/lib/solana/command.d.ts.map +0 -1
- package/lib/solana/command.js +0 -223
- package/lib/solana/solana.d.ts.map +0 -1
- package/lib/sui/balance-tracker.d.ts.map +0 -1
- package/lib/sui/balance-tracker.js +0 -49
- package/lib/sui/command.d.ts.map +0 -1
- package/lib/sui/command.js +0 -160
- package/lib/sui/sui.d.ts.map +0 -1
- package/lib/ton/command.d.ts.map +0 -1
- package/lib/ton/command.js +0 -99
- package/lib/ton/ton.d.ts.map +0 -1
- package/lib/ton/ton.js +0 -97
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -61
package/lib/aptos/command.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const hermes_client_1 = require("@pythnetwork/hermes-client");
|
|
40
|
-
const options = __importStar(require("../options"));
|
|
41
|
-
const price_config_1 = require("../price-config");
|
|
42
|
-
const fs_1 = __importDefault(require("fs"));
|
|
43
|
-
const pyth_price_listener_1 = require("../pyth-price-listener");
|
|
44
|
-
const controller_1 = require("../controller");
|
|
45
|
-
const aptos_1 = require("./aptos");
|
|
46
|
-
const aptos_2 = require("aptos");
|
|
47
|
-
const pino_1 = __importDefault(require("pino"));
|
|
48
|
-
const utils_1 = require("../utils");
|
|
49
|
-
const metrics_1 = require("../metrics");
|
|
50
|
-
const balance_tracker_1 = require("./balance-tracker");
|
|
51
|
-
exports.default = {
|
|
52
|
-
command: "aptos",
|
|
53
|
-
describe: "run price pusher for aptos",
|
|
54
|
-
builder: {
|
|
55
|
-
endpoint: {
|
|
56
|
-
description: "RPC endpoint endpoint URL for aptos. The pusher will periodically" +
|
|
57
|
-
"poll for updates. The polling interval is configurable via the " +
|
|
58
|
-
"`polling-frequency` command-line argument.",
|
|
59
|
-
type: "string",
|
|
60
|
-
required: true,
|
|
61
|
-
},
|
|
62
|
-
"override-gas-price-multiplier": {
|
|
63
|
-
description: "Multiply the gas price by this number if the transaction is not landing to override it. Default 2",
|
|
64
|
-
type: "number",
|
|
65
|
-
required: false,
|
|
66
|
-
default: 2,
|
|
67
|
-
},
|
|
68
|
-
...options.priceConfigFile,
|
|
69
|
-
...options.priceServiceEndpoint,
|
|
70
|
-
...options.mnemonicFile,
|
|
71
|
-
...options.pythContractAddress,
|
|
72
|
-
...options.pollingFrequency,
|
|
73
|
-
...options.pushingFrequency,
|
|
74
|
-
...options.logLevel,
|
|
75
|
-
...options.controllerLogLevel,
|
|
76
|
-
...options.enableMetrics,
|
|
77
|
-
...options.metricsPort,
|
|
78
|
-
},
|
|
79
|
-
handler: async function (argv) {
|
|
80
|
-
// FIXME: type checks for this
|
|
81
|
-
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, overrideGasPriceMultiplier, logLevel, controllerLogLevel, enableMetrics, metricsPort, } = argv;
|
|
82
|
-
const logger = (0, pino_1.default)({ level: logLevel });
|
|
83
|
-
const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
|
|
84
|
-
const hermesClient = new hermes_client_1.HermesClient(priceServiceEndpoint);
|
|
85
|
-
// Initialize metrics if enabled
|
|
86
|
-
let metrics;
|
|
87
|
-
if (enableMetrics) {
|
|
88
|
-
metrics = new metrics_1.PricePusherMetrics(logger.child({ module: "Metrics" }));
|
|
89
|
-
metrics.start(metricsPort);
|
|
90
|
-
logger.info(`Metrics server started on port ${metricsPort}`);
|
|
91
|
-
}
|
|
92
|
-
const mnemonic = fs_1.default.readFileSync(mnemonicFile, "utf-8").trim();
|
|
93
|
-
const account = aptos_2.AptosAccount.fromDerivePath(aptos_1.APTOS_ACCOUNT_HD_PATH, mnemonic);
|
|
94
|
-
logger.info(`Pushing from account address: ${account.address()}`);
|
|
95
|
-
let priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
|
|
96
|
-
// Better to filter out invalid price items before creating the pyth listener
|
|
97
|
-
const { existingPriceItems, invalidPriceItems } = await (0, utils_1.filterInvalidPriceItems)(hermesClient, priceItems);
|
|
98
|
-
if (invalidPriceItems.length > 0) {
|
|
99
|
-
logger.error(`Invalid price id submitted for: ${invalidPriceItems
|
|
100
|
-
.map(({ alias }) => alias)
|
|
101
|
-
.join(", ")}`);
|
|
102
|
-
}
|
|
103
|
-
priceItems = existingPriceItems;
|
|
104
|
-
const pythListener = new pyth_price_listener_1.PythPriceListener(hermesClient, priceItems, logger.child({ module: "PythPriceListener" }));
|
|
105
|
-
const aptosListener = new aptos_1.AptosPriceListener(pythContractAddress, endpoint, priceItems, logger.child({ module: "AptosPriceListener" }), { pollingFrequency });
|
|
106
|
-
const aptosPusher = new aptos_1.AptosPricePusher(hermesClient, logger.child({ module: "AptosPricePusher" }), pythContractAddress, endpoint, mnemonic, overrideGasPriceMultiplier);
|
|
107
|
-
const controller = new controller_1.Controller(priceConfigs, pythListener, aptosListener, aptosPusher, logger.child({ module: "Controller" }, { level: controllerLogLevel }), {
|
|
108
|
-
pushingFrequency,
|
|
109
|
-
metrics,
|
|
110
|
-
});
|
|
111
|
-
// Create and start the balance tracker if metrics are enabled
|
|
112
|
-
if (metrics) {
|
|
113
|
-
const balanceTracker = (0, balance_tracker_1.createAptosBalanceTracker)({
|
|
114
|
-
address: account.address().toString(),
|
|
115
|
-
endpoint,
|
|
116
|
-
network: "aptos",
|
|
117
|
-
updateInterval: pushingFrequency,
|
|
118
|
-
metrics,
|
|
119
|
-
logger: logger.child({ module: "AptosBalanceTracker" }),
|
|
120
|
-
});
|
|
121
|
-
// Start the balance tracker
|
|
122
|
-
await balanceTracker.start();
|
|
123
|
-
}
|
|
124
|
-
controller.start();
|
|
125
|
-
},
|
|
126
|
-
};
|
package/lib/common.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/lib/common.js
DELETED
package/lib/controller.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAS,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAiC,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,MAA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BAAuB;IAU3C;;OAEG;cACa,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;CAiB/C;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,iBAAiB,CAAC;IAClC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,6BAA6B,GACpC,eAAe,CASjB"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EvmBalanceTracker = void 0;
|
|
4
|
-
exports.createEvmBalanceTracker = createEvmBalanceTracker;
|
|
5
|
-
const interface_1 = require("../interface");
|
|
6
|
-
/**
|
|
7
|
-
* EVM-specific implementation of the balance tracker
|
|
8
|
-
*/
|
|
9
|
-
class EvmBalanceTracker extends interface_1.BaseBalanceTracker {
|
|
10
|
-
client;
|
|
11
|
-
evmAddress;
|
|
12
|
-
constructor(config) {
|
|
13
|
-
super({
|
|
14
|
-
...config,
|
|
15
|
-
logger: config.logger.child({ module: "EvmBalanceTracker" }),
|
|
16
|
-
});
|
|
17
|
-
this.client = config.client;
|
|
18
|
-
this.evmAddress = config.address;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* EVM-specific implementation of balance update
|
|
22
|
-
*/
|
|
23
|
-
async updateBalance() {
|
|
24
|
-
try {
|
|
25
|
-
const balance = await this.client.getBalance({
|
|
26
|
-
address: this.evmAddress,
|
|
27
|
-
});
|
|
28
|
-
this.metrics.updateWalletBalance(this.address, this.network, balance);
|
|
29
|
-
this.logger.debug(`Updated EVM wallet balance: ${this.address} = ${balance.toString()}`);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
this.logger.error({ error }, "Error fetching EVM wallet balance for metrics");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.EvmBalanceTracker = EvmBalanceTracker;
|
|
37
|
-
/**
|
|
38
|
-
* Factory function to create a balance tracker for EVM chains
|
|
39
|
-
*/
|
|
40
|
-
function createEvmBalanceTracker(params) {
|
|
41
|
-
return new EvmBalanceTracker({
|
|
42
|
-
client: params.client,
|
|
43
|
-
address: params.address,
|
|
44
|
-
network: params.network,
|
|
45
|
-
updateInterval: params.updateInterval,
|
|
46
|
-
metrics: params.metrics,
|
|
47
|
-
logger: params.logger,
|
|
48
|
-
});
|
|
49
|
-
}
|
package/lib/evm/command.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/evm/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;kBA2BvB,OAAO;8BAMP,OAAO;oBAMP,OAAO;yCAUP,OAAO;6CAQP,OAAO;qBAKP,OAAO;qBAKP,OAAO;iCASP,OAAO;;oBAYiB,GAAG;;AA1EpC,wBA6ME"}
|
package/lib/evm/command.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const hermes_client_1 = require("@pythnetwork/hermes-client");
|
|
40
|
-
const fs_1 = __importDefault(require("fs"));
|
|
41
|
-
const options = __importStar(require("../options"));
|
|
42
|
-
const price_config_1 = require("../price-config");
|
|
43
|
-
const pyth_price_listener_1 = require("../pyth-price-listener");
|
|
44
|
-
const controller_1 = require("../controller");
|
|
45
|
-
const evm_1 = require("./evm");
|
|
46
|
-
const custom_gas_station_1 = require("./custom-gas-station");
|
|
47
|
-
const pino_1 = __importDefault(require("pino"));
|
|
48
|
-
const super_wallet_1 = require("./super-wallet");
|
|
49
|
-
const pyth_contract_1 = require("./pyth-contract");
|
|
50
|
-
const utils_1 = require("../utils");
|
|
51
|
-
const metrics_1 = require("../metrics");
|
|
52
|
-
const balance_tracker_1 = require("./balance-tracker");
|
|
53
|
-
exports.default = {
|
|
54
|
-
command: "evm",
|
|
55
|
-
describe: "run price pusher for evm",
|
|
56
|
-
builder: {
|
|
57
|
-
endpoint: {
|
|
58
|
-
description: "RPC endpoint URL for evm network. If you provide a normal HTTP endpoint, the pusher " +
|
|
59
|
-
"will periodically poll for updates. The polling interval is configurable via the " +
|
|
60
|
-
"`polling-frequency` command-line argument. If you provide a websocket RPC " +
|
|
61
|
-
"endpoint (`ws[s]://...`), the price pusher will use event subscriptions to read " +
|
|
62
|
-
"the current EVM price in addition to polling. ",
|
|
63
|
-
type: "string",
|
|
64
|
-
required: true,
|
|
65
|
-
},
|
|
66
|
-
"custom-gas-station": {
|
|
67
|
-
description: "If using a custom gas station, chainId of custom gas station to use",
|
|
68
|
-
type: "number",
|
|
69
|
-
required: false,
|
|
70
|
-
},
|
|
71
|
-
"tx-speed": {
|
|
72
|
-
description: "txSpeed for custom gas station. choose between 'slow'|'standard'|'fast'",
|
|
73
|
-
choices: ["slow", "standard", "fast"],
|
|
74
|
-
required: false,
|
|
75
|
-
},
|
|
76
|
-
"override-gas-price-multiplier": {
|
|
77
|
-
description: "Multiply the previous gas price by this number if the transaction is not landing to override. " +
|
|
78
|
-
"Please note that the gas price can grow exponentially on consecutive failures; " +
|
|
79
|
-
"to set a cap on the multiplier, use the `override-gas-price-multiplier-cap` option." +
|
|
80
|
-
"Default to 1.1",
|
|
81
|
-
type: "number",
|
|
82
|
-
required: false,
|
|
83
|
-
default: 1.1,
|
|
84
|
-
},
|
|
85
|
-
"override-gas-price-multiplier-cap": {
|
|
86
|
-
description: "Maximum gas price multiplier to use in override compared to the RPC returned " +
|
|
87
|
-
"gas price. Default to 5",
|
|
88
|
-
type: "number",
|
|
89
|
-
required: false,
|
|
90
|
-
default: 5,
|
|
91
|
-
},
|
|
92
|
-
"gas-limit": {
|
|
93
|
-
description: "Gas limit for the transaction",
|
|
94
|
-
type: "number",
|
|
95
|
-
required: false,
|
|
96
|
-
},
|
|
97
|
-
"gas-price": {
|
|
98
|
-
description: "Override the gas price that would be received from the RPC",
|
|
99
|
-
type: "number",
|
|
100
|
-
required: false,
|
|
101
|
-
},
|
|
102
|
-
"update-fee-multiplier": {
|
|
103
|
-
description: "Multiplier for the fee to update the price. It is useful in networks " +
|
|
104
|
-
"such as Hedera where setting on-chain getUpdateFee as the transaction value " +
|
|
105
|
-
"won't work. Default to 1",
|
|
106
|
-
type: "number",
|
|
107
|
-
required: false,
|
|
108
|
-
default: 1,
|
|
109
|
-
},
|
|
110
|
-
...options.priceConfigFile,
|
|
111
|
-
...options.priceServiceEndpoint,
|
|
112
|
-
...options.mnemonicFile,
|
|
113
|
-
...options.pythContractAddress,
|
|
114
|
-
...options.pollingFrequency,
|
|
115
|
-
...options.pushingFrequency,
|
|
116
|
-
...options.logLevel,
|
|
117
|
-
...options.controllerLogLevel,
|
|
118
|
-
...options.enableMetrics,
|
|
119
|
-
...options.metricsPort,
|
|
120
|
-
},
|
|
121
|
-
handler: async function (argv) {
|
|
122
|
-
// FIXME: type checks for this
|
|
123
|
-
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, customGasStation, txSpeed, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, gasLimit, gasPrice, updateFeeMultiplier, logLevel, controllerLogLevel, enableMetrics, metricsPort, } = argv;
|
|
124
|
-
const logger = (0, pino_1.default)({
|
|
125
|
-
level: logLevel,
|
|
126
|
-
});
|
|
127
|
-
const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
|
|
128
|
-
const hermesClient = new hermes_client_1.HermesClient(priceServiceEndpoint);
|
|
129
|
-
const mnemonic = fs_1.default.readFileSync(mnemonicFile, "utf-8").trim();
|
|
130
|
-
let priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
|
|
131
|
-
// Better to filter out invalid price items before creating the pyth listener
|
|
132
|
-
const { existingPriceItems, invalidPriceItems } = await (0, utils_1.filterInvalidPriceItems)(hermesClient, priceItems);
|
|
133
|
-
if (invalidPriceItems.length > 0) {
|
|
134
|
-
logger.error(`Invalid price id submitted for: ${invalidPriceItems
|
|
135
|
-
.map(({ alias }) => alias)
|
|
136
|
-
.join(", ")}`);
|
|
137
|
-
}
|
|
138
|
-
priceItems = existingPriceItems;
|
|
139
|
-
// Initialize metrics if enabled
|
|
140
|
-
let metrics;
|
|
141
|
-
if (enableMetrics) {
|
|
142
|
-
metrics = new metrics_1.PricePusherMetrics(logger.child({ module: "Metrics" }));
|
|
143
|
-
metrics.start(metricsPort);
|
|
144
|
-
logger.info(`Metrics server started on port ${metricsPort}`);
|
|
145
|
-
}
|
|
146
|
-
const pythListener = new pyth_price_listener_1.PythPriceListener(hermesClient, priceItems, logger.child({ module: "PythPriceListener" }));
|
|
147
|
-
const client = await (0, super_wallet_1.createClient)(endpoint, mnemonic);
|
|
148
|
-
const pythContract = (0, pyth_contract_1.createPythContract)(client, pythContractAddress);
|
|
149
|
-
logger.info(`Pushing updates from wallet address: ${client.account.address}`);
|
|
150
|
-
// It is possible to watch the events in the non-ws endpoints, either by getFilter
|
|
151
|
-
// or by getLogs, but it is very expensive and our polling mechanism does it
|
|
152
|
-
// in a more efficient way. So we only do it with ws endpoints.
|
|
153
|
-
const watchEvents = (0, utils_1.isWsEndpoint)(endpoint);
|
|
154
|
-
const evmListener = new evm_1.EvmPriceListener(pythContract, priceItems, watchEvents, logger.child({ module: "EvmPriceListener" }), {
|
|
155
|
-
pollingFrequency,
|
|
156
|
-
});
|
|
157
|
-
const gasStation = (0, custom_gas_station_1.getCustomGasStation)(logger.child({ module: "CustomGasStation" }), customGasStation, txSpeed);
|
|
158
|
-
const evmPusher = new evm_1.EvmPricePusher(hermesClient, client, pythContract, logger.child({ module: "EvmPricePusher" }), overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, updateFeeMultiplier, gasLimit, gasStation, gasPrice);
|
|
159
|
-
const controller = new controller_1.Controller(priceConfigs, pythListener, evmListener, evmPusher, logger.child({ module: "Controller" }, { level: controllerLogLevel }), {
|
|
160
|
-
pushingFrequency,
|
|
161
|
-
metrics,
|
|
162
|
-
});
|
|
163
|
-
// Create and start the balance tracker if metrics are enabled
|
|
164
|
-
if (metrics) {
|
|
165
|
-
const balanceTracker = (0, balance_tracker_1.createEvmBalanceTracker)({
|
|
166
|
-
client,
|
|
167
|
-
address: client.account.address,
|
|
168
|
-
network: await client.getChainId().then((id) => id.toString()),
|
|
169
|
-
updateInterval: pushingFrequency,
|
|
170
|
-
metrics,
|
|
171
|
-
logger,
|
|
172
|
-
});
|
|
173
|
-
// Start the balance tracker
|
|
174
|
-
await balanceTracker.start();
|
|
175
|
-
}
|
|
176
|
-
await controller.start();
|
|
177
|
-
},
|
|
178
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-gas-station.d.ts","sourceRoot":"","sources":["../../src/evm/custom-gas-station.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAK9B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,YAAY,CAElB;IACF,OAAO,CAAC,MAAM,CAAS;gBACX,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAMlD,iBAAiB;YAIT,yBAAyB;CAcxC;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,MAAM,gCAKjB"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomGasStation = void 0;
|
|
4
|
-
exports.getCustomGasStation = getCustomGasStation;
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
class CustomGasStation {
|
|
8
|
-
chain;
|
|
9
|
-
speed;
|
|
10
|
-
chainMethods = {
|
|
11
|
-
137: this.fetchMaticMainnetGasPrice.bind(this),
|
|
12
|
-
};
|
|
13
|
-
logger;
|
|
14
|
-
constructor(logger, chain, speed) {
|
|
15
|
-
this.logger = logger;
|
|
16
|
-
this.speed = (0, utils_1.verifyValidOption)(speed, utils_1.txSpeeds);
|
|
17
|
-
this.chain = (0, utils_1.verifyValidOption)(chain, utils_1.customGasChainIds);
|
|
18
|
-
}
|
|
19
|
-
async getCustomGasPrice() {
|
|
20
|
-
return this.chainMethods[this.chain]();
|
|
21
|
-
}
|
|
22
|
-
async fetchMaticMainnetGasPrice() {
|
|
23
|
-
try {
|
|
24
|
-
const res = await fetch("https://gasstation.polygon.technology/v2");
|
|
25
|
-
const jsonRes = await res.json();
|
|
26
|
-
const gasPrice = jsonRes[this.speed].maxFee;
|
|
27
|
-
return (0, viem_1.parseGwei)(gasPrice.toFixed(2));
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
this.logger.error(err, "Failed to fetch gas price from Matic mainnet. Returning undefined");
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.CustomGasStation = CustomGasStation;
|
|
36
|
-
function getCustomGasStation(logger, customGasStation, txSpeed) {
|
|
37
|
-
if (customGasStation && txSpeed) {
|
|
38
|
-
return new CustomGasStation(logger, customGasStation, txSpeed);
|
|
39
|
-
}
|
|
40
|
-
}
|
package/lib/evm/evm.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/evm/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,O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