@pythnetwork/price-pusher 6.6.3 → 6.8.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/evm/command.d.ts +2 -0
- package/lib/evm/command.d.ts.map +1 -1
- package/lib/evm/command.js +15 -2
- package/lib/evm/evm.d.ts +3 -1
- package/lib/evm/evm.d.ts.map +1 -1
- package/lib/evm/evm.js +12 -2
- package/lib/index.js +3 -0
- package/lib/solana/solana.d.ts.map +1 -1
- package/lib/solana/solana.js +15 -21
- package/lib/sui/command.d.ts +1 -0
- package/lib/sui/command.d.ts.map +1 -1
- package/lib/sui/command.js +8 -2
- package/lib/sui/sui.d.ts +1 -1
- package/lib/sui/sui.d.ts.map +1 -1
- package/lib/sui/sui.js +16 -5
- package/package.json +2 -2
package/lib/evm/command.d.ts
CHANGED
package/lib/evm/command.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/evm/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/evm/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;;;oBAqEL,GAAG;;AAjE9B,wBA8IE"}
|
package/lib/evm/command.js
CHANGED
|
@@ -73,6 +73,19 @@ exports.default = {
|
|
|
73
73
|
required: false,
|
|
74
74
|
default: 5,
|
|
75
75
|
},
|
|
76
|
+
"gas-limit": {
|
|
77
|
+
description: "Gas limit for the transaction",
|
|
78
|
+
type: "number",
|
|
79
|
+
required: false,
|
|
80
|
+
},
|
|
81
|
+
"update-fee-multiplier": {
|
|
82
|
+
description: "Multiplier for the fee to update the price. It is useful in networks " +
|
|
83
|
+
"such as Hedera where setting on-chain getUpdateFee as the transaction value " +
|
|
84
|
+
"won't work. Default to 1",
|
|
85
|
+
type: "number",
|
|
86
|
+
required: false,
|
|
87
|
+
default: 1,
|
|
88
|
+
},
|
|
76
89
|
...options.priceConfigFile,
|
|
77
90
|
...options.priceServiceEndpoint,
|
|
78
91
|
...options.mnemonicFile,
|
|
@@ -82,7 +95,7 @@ exports.default = {
|
|
|
82
95
|
},
|
|
83
96
|
handler: function (argv) {
|
|
84
97
|
// FIXME: type checks for this
|
|
85
|
-
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, customGasStation, txSpeed, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, } = argv;
|
|
98
|
+
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, customGasStation, txSpeed, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, gasLimit, updateFeeMultiplier, } = argv;
|
|
86
99
|
const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
|
|
87
100
|
const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
|
|
88
101
|
logger: {
|
|
@@ -105,7 +118,7 @@ exports.default = {
|
|
|
105
118
|
pollingFrequency,
|
|
106
119
|
});
|
|
107
120
|
const gasStation = (0, custom_gas_station_1.getCustomGasStation)(customGasStation, txSpeed);
|
|
108
|
-
const evmPusher = new evm_1.EvmPricePusher(priceServiceConnection, pythContractFactory, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, gasStation);
|
|
121
|
+
const evmPusher = new evm_1.EvmPricePusher(priceServiceConnection, pythContractFactory, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, updateFeeMultiplier, gasLimit, gasStation);
|
|
109
122
|
const controller = new controller_1.Controller(priceConfigs, pythListener, evmListener, evmPusher, { pushingFrequency });
|
|
110
123
|
controller.start();
|
|
111
124
|
},
|
package/lib/evm/evm.d.ts
CHANGED
|
@@ -19,12 +19,14 @@ export declare class EvmPricePusher implements IPricePusher {
|
|
|
19
19
|
private connection;
|
|
20
20
|
private overrideGasPriceMultiplier;
|
|
21
21
|
private overrideGasPriceMultiplierCap;
|
|
22
|
+
private updateFeeMultiplier;
|
|
23
|
+
private gasLimit?;
|
|
22
24
|
private customGasStation?;
|
|
23
25
|
private pythContract;
|
|
24
26
|
private web3;
|
|
25
27
|
private pusherAddress;
|
|
26
28
|
private lastPushAttempt;
|
|
27
|
-
constructor(connection: PriceServiceConnection, pythContractFactory: PythContractFactory, overrideGasPriceMultiplier: number, overrideGasPriceMultiplierCap: number, customGasStation?: CustomGasStation);
|
|
29
|
+
constructor(connection: PriceServiceConnection, pythContractFactory: PythContractFactory, overrideGasPriceMultiplier: number, overrideGasPriceMultiplierCap: number, updateFeeMultiplier: number, gasLimit?: number | undefined, customGasStation?: CustomGasStation);
|
|
28
30
|
updatePriceFeed(priceIds: string[], pubTimesToPush: UnixTimestamp[]): Promise<void>;
|
|
29
31
|
private getPriceFeedsUpdateData;
|
|
30
32
|
}
|
package/lib/evm/evm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/evm/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,SAAS,EACV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAgB,iBAAiB,EAAmB,MAAM,UAAU,CAAC;AAE5E,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,aAAa,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD,qBAAa,gBAAiB,SAAQ,kBAAkB;IACtD,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,YAAY,CAAW;gBAG7B,mBAAmB,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,CAAC,0BAA0B;IAClC,OAAO,CAAC,6BAA6B;IACrC,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,QAAQ,CAAC;IAZnB,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C,OAAO,CAAC,YAAY,CAAW;IAC/B,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,eAAe,CAA0B;gBAGvC,UAAU,EAAE,sBAAsB,EAC1C,mBAAmB,EAAE,mBAAmB,EAChC,0BAA0B,EAAE,MAAM,EAClC,6BAA6B,EAAE,MAAM,EACrC,mBAAmB,EAAE,MAAM,EAC3B,QAAQ,CAAC,oBAAQ,EACzB,gBAAgB,CAAC,EAAE,gBAAgB;IAa/B,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,aAAa,EAAE,GAC9B,OAAO,CAAC,IAAI,CAAC;YAuJF,uBAAuB;CAQtC;AAED,qBAAa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,mBAAmB;gBAFnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM;IAGrC;;;;;;OAMG;IACH,2BAA2B,IAAI,QAAQ;IAcvC;;;;;OAKG;IACH,kBAAkB,IAAI,QAAQ;IAS9B,oBAAoB,IAAI,OAAO;IAI/B,kBAAkB;IA0BlB,uBAAuB;CAQxB"}
|
package/lib/evm/evm.js
CHANGED
|
@@ -81,15 +81,19 @@ class EvmPricePusher {
|
|
|
81
81
|
connection;
|
|
82
82
|
overrideGasPriceMultiplier;
|
|
83
83
|
overrideGasPriceMultiplierCap;
|
|
84
|
+
updateFeeMultiplier;
|
|
85
|
+
gasLimit;
|
|
84
86
|
customGasStation;
|
|
85
87
|
pythContract;
|
|
86
88
|
web3;
|
|
87
89
|
pusherAddress;
|
|
88
90
|
lastPushAttempt;
|
|
89
|
-
constructor(connection, pythContractFactory, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, customGasStation) {
|
|
91
|
+
constructor(connection, pythContractFactory, overrideGasPriceMultiplier, overrideGasPriceMultiplierCap, updateFeeMultiplier, gasLimit, customGasStation) {
|
|
90
92
|
this.connection = connection;
|
|
91
93
|
this.overrideGasPriceMultiplier = overrideGasPriceMultiplier;
|
|
92
94
|
this.overrideGasPriceMultiplierCap = overrideGasPriceMultiplierCap;
|
|
95
|
+
this.updateFeeMultiplier = updateFeeMultiplier;
|
|
96
|
+
this.gasLimit = gasLimit;
|
|
93
97
|
this.customGasStation = customGasStation;
|
|
94
98
|
this.pythContract = pythContractFactory.createPythContractWithPayer();
|
|
95
99
|
this.web3 = new web3_1.default(pythContractFactory.createWeb3PayerProvider());
|
|
@@ -114,6 +118,7 @@ class EvmPricePusher {
|
|
|
114
118
|
updateFee = await this.pythContract.methods
|
|
115
119
|
.getUpdateFee(priceFeedUpdateData)
|
|
116
120
|
.call();
|
|
121
|
+
updateFee = Number(updateFee) * (this.updateFeeMultiplier || 1);
|
|
117
122
|
console.log(`Update fee: ${updateFee}`);
|
|
118
123
|
}
|
|
119
124
|
catch (e) {
|
|
@@ -143,7 +148,12 @@ class EvmPricePusher {
|
|
|
143
148
|
console.log(`Using gas price: ${gasPrice} and nonce: ${txNonce}`);
|
|
144
149
|
this.pythContract.methods
|
|
145
150
|
.updatePriceFeedsIfNecessary(priceFeedUpdateData, priceIdsWith0x, pubTimesToPush)
|
|
146
|
-
.send({
|
|
151
|
+
.send({
|
|
152
|
+
value: updateFee,
|
|
153
|
+
gasPrice,
|
|
154
|
+
nonce: txNonce,
|
|
155
|
+
gasLimit: this.gasLimit,
|
|
156
|
+
})
|
|
147
157
|
.on("transactionHash", (hash) => {
|
|
148
158
|
console.log(`Successful. Tx hash: ${hash}`);
|
|
149
159
|
})
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,9 @@ const command_4 = __importDefault(require("./sui/command"));
|
|
|
13
13
|
const command_5 = __importDefault(require("./near/command"));
|
|
14
14
|
const command_6 = __importDefault(require("./solana/command"));
|
|
15
15
|
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
16
|
+
.parserConfiguration({
|
|
17
|
+
"parse-numbers": false,
|
|
18
|
+
})
|
|
16
19
|
.config("config")
|
|
17
20
|
.global("config")
|
|
18
21
|
.command(command_2.default)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/solana/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,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;AAK3E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/solana/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,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;AAK3E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAGxE,qBAAa,mBAAoB,SAAQ,kBAAkB;IAEvD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,OAAO;gBADP,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,EAAE,MAAM,EACvB,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE;QACN,gBAAgB,EAAE,iBAAiB,CAAC;KACrC;IAKG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CA2B3E;AAED,qBAAa,iBAAkB,YAAW,YAAY;IAElD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,6BAA6B;gBAH7B,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,MAAM,EACf,6BAA6B,EAAE,MAAM;IAGzC,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC;CAwCjB;AAID,qBAAa,qBAAsB,YAAW,YAAY;IAEtD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;gBALd,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,MAAM;IAG1B,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC;CAuCjB"}
|
package/lib/solana/solana.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SolanaPricePusherJito = exports.SolanaPricePusher = exports.SolanaPriceListener = void 0;
|
|
4
4
|
const interface_1 = require("../interface");
|
|
5
5
|
const solana_utils_1 = require("@pythnetwork/solana-utils");
|
|
6
|
+
const price_service_sdk_1 = require("@pythnetwork/price-service-sdk");
|
|
6
7
|
class SolanaPriceListener extends interface_1.ChainPriceListener {
|
|
7
8
|
pythSolanaReceiver;
|
|
8
9
|
shardId;
|
|
@@ -76,6 +77,7 @@ class SolanaPricePusher {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
exports.SolanaPricePusher = SolanaPricePusher;
|
|
80
|
+
const UPDATES_PER_JITO_BUNDLE = 7;
|
|
79
81
|
class SolanaPricePusherJito {
|
|
80
82
|
pythSolanaReceiver;
|
|
81
83
|
priceServiceConnection;
|
|
@@ -100,27 +102,19 @@ class SolanaPricePusherJito {
|
|
|
100
102
|
console.error(new Date(), "getPriceFeedsUpdateData failed:", e);
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
await this.pythSolanaReceiver.connection.confirmTransaction({
|
|
118
|
-
signature: firstSignature,
|
|
119
|
-
blockhash: blockhashResult.value.blockhash,
|
|
120
|
-
lastValidBlockHeight: blockhashResult.value.lastValidBlockHeight,
|
|
121
|
-
}, "confirmed");
|
|
122
|
-
for (let i = this.jitoBundleSize; i < transactions.length; i += this.jitoBundleSize) {
|
|
123
|
-
await (0, solana_utils_1.sendTransactionsJito)(transactions.slice(i, i + this.jitoBundleSize), this.searcherClient, this.pythSolanaReceiver.wallet);
|
|
105
|
+
for (let i = 0; i < priceIds.length; i += UPDATES_PER_JITO_BUNDLE) {
|
|
106
|
+
const transactionBuilder = this.pythSolanaReceiver.newTransactionBuilder({
|
|
107
|
+
closeUpdateAccounts: true,
|
|
108
|
+
});
|
|
109
|
+
await transactionBuilder.addUpdatePriceFeed(priceFeedUpdateData.map((x) => {
|
|
110
|
+
return (0, price_service_sdk_1.sliceAccumulatorUpdateData)(Buffer.from(x, "base64"), i, i + UPDATES_PER_JITO_BUNDLE).toString("base64");
|
|
111
|
+
}), this.shardId);
|
|
112
|
+
const transactions = await transactionBuilder.buildVersionedTransactions({
|
|
113
|
+
jitoTipLamports: this.jitoTipLamports,
|
|
114
|
+
tightComputeBudget: true,
|
|
115
|
+
jitoBundleSize: this.jitoBundleSize,
|
|
116
|
+
});
|
|
117
|
+
await (0, solana_utils_1.sendTransactionsJito)(transactions, this.searcherClient, this.pythSolanaReceiver.wallet);
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
120
|
}
|
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;;;;;;;;;;;;;;;;;;oBAiEC,GAAG;;AA7DpC,wBA4IE"}
|
package/lib/sui/command.js
CHANGED
|
@@ -66,6 +66,12 @@ exports.default = {
|
|
|
66
66
|
required: true,
|
|
67
67
|
default: 30,
|
|
68
68
|
},
|
|
69
|
+
"ignore-gas-objects": {
|
|
70
|
+
description: "Gas objects to ignore when merging gas objects on startup -- use this for locked objects.",
|
|
71
|
+
type: "array",
|
|
72
|
+
required: false,
|
|
73
|
+
default: [],
|
|
74
|
+
},
|
|
69
75
|
"gas-budget": {
|
|
70
76
|
description: "Gas budget for each price update",
|
|
71
77
|
type: "number",
|
|
@@ -85,7 +91,7 @@ exports.default = {
|
|
|
85
91
|
...options.pushingFrequency,
|
|
86
92
|
},
|
|
87
93
|
handler: async function (argv) {
|
|
88
|
-
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, gasBudget, accountIndex, } = argv;
|
|
94
|
+
const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, ignoreGasObjects, gasBudget, accountIndex, } = argv;
|
|
89
95
|
const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
|
|
90
96
|
const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
|
|
91
97
|
logger: {
|
|
@@ -108,7 +114,7 @@ exports.default = {
|
|
|
108
114
|
const priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
|
|
109
115
|
const pythListener = new pyth_price_listener_1.PythPriceListener(priceServiceConnection, priceItems);
|
|
110
116
|
const suiListener = new sui_1.SuiPriceListener(pythStateId, wormholeStateId, endpoint, priceItems, { pollingFrequency });
|
|
111
|
-
const suiPusher = await sui_1.SuiPricePusher.createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects);
|
|
117
|
+
const suiPusher = await sui_1.SuiPricePusher.createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects, ignoreGasObjects);
|
|
112
118
|
const controller = new controller_1.Controller(priceConfigs, pythListener, suiListener, suiPusher, { pushingFrequency });
|
|
113
119
|
controller.start();
|
|
114
120
|
},
|
package/lib/sui/sui.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare class SuiPricePusher implements IPricePusher {
|
|
|
51
51
|
* Create a price pusher with a pool of `numGasObjects` gas coins that will be used to send transactions.
|
|
52
52
|
* The gas coins of the wallet for the provided keypair will be merged and then evenly split into `numGasObjects`.
|
|
53
53
|
*/
|
|
54
|
-
static createWithAutomaticGasPool(priceServiceConnection: PriceServiceConnection, pythStateId: string, wormholeStateId: string, endpoint: string, keypair: Ed25519Keypair, gasBudget: number, numGasObjects: number): Promise<SuiPricePusher>;
|
|
54
|
+
static createWithAutomaticGasPool(priceServiceConnection: PriceServiceConnection, pythStateId: string, wormholeStateId: string, endpoint: string, keypair: Ed25519Keypair, gasBudget: number, numGasObjects: number, ignoreGasObjects: string[]): Promise<SuiPricePusher>;
|
|
55
55
|
updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
|
|
56
56
|
/** Send every transaction in txs in parallel, returning when all transactions have completed. */
|
|
57
57
|
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,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAkB,MAAM,uBAAuB,CAAC;AAOhF,KAAK,QAAQ,GAAG,MAAM,CAAC;AAGvB,qBAAa,gBAAiB,SAAQ,kBAAkB;IACtD,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,QAAQ,CAAY;gBAG1B,WAAW,EAAE,QAAQ,EACrB,eAAe,EAAE,QAAQ,EACzB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE;QACN,gBAAgB,EAAE,iBAAiB,CAAC;KACrC;IAWG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CA2C3E;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAe,YAAW,YAAY;IAE/C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;I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,EAC9C,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,cAAc,CAAC;IA8CpB,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC;IA0ChB,iGAAiG;YACnF,qBAAqB;IAMnC,sEAAsE;YACxD,oBAAoB;mBA2Db,iBAAiB;mBAmDjB,yBAAyB;mBAoBzB,cAAc;mBAiCd,mBAAmB;mBAwCnB,oBAAoB;CAkE1C"}
|
package/lib/sui/sui.js
CHANGED
|
@@ -123,14 +123,14 @@ class SuiPricePusher {
|
|
|
123
123
|
* Create a price pusher with a pool of `numGasObjects` gas coins that will be used to send transactions.
|
|
124
124
|
* The gas coins of the wallet for the provided keypair will be merged and then evenly split into `numGasObjects`.
|
|
125
125
|
*/
|
|
126
|
-
static async createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects) {
|
|
126
|
+
static async createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects, ignoreGasObjects) {
|
|
127
127
|
if (numGasObjects > MAX_NUM_OBJECTS_IN_ARGUMENT) {
|
|
128
128
|
throw new Error(`numGasObjects cannot be greater than ${MAX_NUM_OBJECTS_IN_ARGUMENT} until we implement split chunking`);
|
|
129
129
|
}
|
|
130
130
|
const provider = new client_1.SuiClient({ url: endpoint });
|
|
131
131
|
const pythPackageId = await SuiPricePusher.getPackageId(provider, pythStateId);
|
|
132
132
|
const wormholePackageId = await SuiPricePusher.getPackageId(provider, wormholeStateId);
|
|
133
|
-
const gasPool = await SuiPricePusher.initializeGasPool(keypair, provider, numGasObjects);
|
|
133
|
+
const gasPool = await SuiPricePusher.initializeGasPool(keypair, provider, numGasObjects, ignoreGasObjects);
|
|
134
134
|
const pythClient = new pyth_sui_js_1.SuiPythClient(provider, pythStateId, wormholeStateId);
|
|
135
135
|
return new SuiPricePusher(keypair, provider, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint, keypair, gasBudget, gasPool, pythClient);
|
|
136
136
|
}
|
|
@@ -209,9 +209,15 @@ class SuiPricePusher {
|
|
|
209
209
|
}
|
|
210
210
|
// This function will smash all coins owned by the signer into one, and then
|
|
211
211
|
// split them equally into numGasObjects.
|
|
212
|
-
|
|
212
|
+
// ignoreGasObjects is a list of gas objects that will be ignored during the
|
|
213
|
+
// merging -- use this to store any locked objects on initialization.
|
|
214
|
+
static async initializeGasPool(signer, provider, numGasObjects, ignoreGasObjects) {
|
|
213
215
|
const signerAddress = await signer.toSuiAddress();
|
|
214
|
-
|
|
216
|
+
if (ignoreGasObjects.length > 0) {
|
|
217
|
+
console.log("Ignoring some gas objects for coin merging:");
|
|
218
|
+
console.log(ignoreGasObjects);
|
|
219
|
+
}
|
|
220
|
+
const consolidatedCoin = await SuiPricePusher.mergeGasCoinsIntoOne(signer, provider, signerAddress, ignoreGasObjects);
|
|
215
221
|
const coinResult = await provider.getObject({
|
|
216
222
|
id: consolidatedCoin.objectId,
|
|
217
223
|
options: { showContent: true },
|
|
@@ -297,7 +303,7 @@ class SuiPricePusher {
|
|
|
297
303
|
}
|
|
298
304
|
return newCoins;
|
|
299
305
|
}
|
|
300
|
-
static async mergeGasCoinsIntoOne(signer, provider, owner) {
|
|
306
|
+
static async mergeGasCoinsIntoOne(signer, provider, owner, initialLockedAddresses) {
|
|
301
307
|
const gasCoins = await SuiPricePusher.getAllGasCoins(provider, owner);
|
|
302
308
|
// skip merging if there is only one coin
|
|
303
309
|
if (gasCoins.length === 1) {
|
|
@@ -306,6 +312,7 @@ class SuiPricePusher {
|
|
|
306
312
|
const gasCoinsChunks = chunkArray(gasCoins, MAX_NUM_GAS_OBJECTS_IN_PTB - 2);
|
|
307
313
|
let finalCoin;
|
|
308
314
|
const lockedAddresses = new Set();
|
|
315
|
+
initialLockedAddresses.forEach((value) => lockedAddresses.add(value));
|
|
309
316
|
for (let i = 0; i < gasCoinsChunks.length; i++) {
|
|
310
317
|
const mergeTx = new transactions_1.TransactionBlock();
|
|
311
318
|
let coins = gasCoinsChunks[i];
|
|
@@ -323,6 +330,10 @@ class SuiPricePusher {
|
|
|
323
330
|
});
|
|
324
331
|
}
|
|
325
332
|
catch (e) {
|
|
333
|
+
console.log("Merge transaction failed with error:");
|
|
334
|
+
console.log(e);
|
|
335
|
+
console.log(e.data);
|
|
336
|
+
console.log(JSON.stringify(e));
|
|
326
337
|
if (String(e).includes("quorum of validators because of locked objects. Retried a conflicting transaction")) {
|
|
327
338
|
Object.values(e.data).forEach((lockedObjects) => {
|
|
328
339
|
lockedObjects.forEach((lockedObject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/price-pusher",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.0",
|
|
4
4
|
"description": "Pyth Price Pusher",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"yaml": "^2.1.1",
|
|
68
68
|
"yargs": "^17.5.1"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "641a4bdd6306ccb62ece63b800f9727f54f816df"
|
|
71
71
|
}
|