Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/price_pusher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/price-pusher",
"version": "6.7.1",
"version": "6.7.2",
"description": "Pyth Price Pusher",
"homepage": "https://pyth.network",
"main": "lib/index.js",
Expand Down
3 changes: 3 additions & 0 deletions apps/price_pusher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import near from "./near/command";
import solana from "./solana/command";

yargs(hideBin(process.argv))
.parserConfiguration({
"parse-numbers": false,
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you don't do this, hexadecimal strings are parsed as numbers automatically by yargs

the javascript ecosystem continues to be a dumpster fire lol

.config("config")
.global("config")
.command(evm)
Expand Down
11 changes: 10 additions & 1 deletion apps/price_pusher/src/sui/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export default {
required: true,
default: 30,
} as Options,
"ignore-gas-objects": {
description:
"Gas objects to ignore when merging gas objects on startup -- use this for locked objects.",
type: "array",
required: false,
default: [],
} as Options,
"gas-budget": {
description: "Gas budget for each price update",
type: "number",
Expand Down Expand Up @@ -73,6 +80,7 @@ export default {
pythStateId,
wormholeStateId,
numGasObjects,
ignoreGasObjects,
gasBudget,
accountIndex,
} = argv;
Expand Down Expand Up @@ -126,7 +134,8 @@ export default {
endpoint,
keypair,
gasBudget,
numGasObjects
numGasObjects,
ignoreGasObjects
);

const controller = new Controller(
Expand Down
25 changes: 18 additions & 7 deletions apps/price_pusher/src/sui/sui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export class SuiPricePusher implements IPricePusher {
endpoint: string,
keypair: Ed25519Keypair,
gasBudget: number,
numGasObjects: number
numGasObjects: number,
ignoreGasObjects: string[]
): Promise<SuiPricePusher> {
if (numGasObjects > MAX_NUM_OBJECTS_IN_ARGUMENT) {
throw new Error(
Expand All @@ -183,7 +184,8 @@ export class SuiPricePusher implements IPricePusher {
const gasPool = await SuiPricePusher.initializeGasPool(
keypair,
provider,
numGasObjects
numGasObjects,
ignoreGasObjects
);

const pythClient = new SuiPythClient(
Expand Down Expand Up @@ -318,17 +320,26 @@ export class SuiPricePusher implements IPricePusher {

// This function will smash all coins owned by the signer into one, and then
// split them equally into numGasObjects.
// ignoreGasObjects is a list of gas objects that will be ignored during the
// merging -- use this to store any locked objects on initialization.
private static async initializeGasPool(
signer: Ed25519Keypair,
provider: SuiClient,
numGasObjects: number
numGasObjects: number,
ignoreGasObjects: string[]
): Promise<SuiObjectRef[]> {
const signerAddress = await signer.toSuiAddress();

if (ignoreGasObjects.length > 0) {
console.log("Ignoring some gas objects for coin merging:");
console.log(ignoreGasObjects);
}

const consolidatedCoin = await SuiPricePusher.mergeGasCoinsIntoOne(
signer,
provider,
signerAddress
signerAddress,
ignoreGasObjects
);
const coinResult = await provider.getObject({
id: consolidatedCoin.objectId,
Expand Down Expand Up @@ -458,7 +469,8 @@ export class SuiPricePusher implements IPricePusher {
private static async mergeGasCoinsIntoOne(
signer: Ed25519Keypair,
provider: SuiClient,
owner: SuiAddress
owner: SuiAddress,
initialLockedAddresses: string[]
): Promise<SuiObjectRef> {
const gasCoins = await SuiPricePusher.getAllGasCoins(provider, owner);
// skip merging if there is only one coin
Expand All @@ -472,6 +484,7 @@ export class SuiPricePusher implements IPricePusher {
);
let finalCoin;
const lockedAddresses: Set<string> = new Set();
initialLockedAddresses.forEach((value) => lockedAddresses.add(value));
for (let i = 0; i < gasCoinsChunks.length; i++) {
const mergeTx = new TransactionBlock();
let coins = gasCoinsChunks[i];
Expand All @@ -497,15 +510,13 @@ export class SuiPricePusher implements IPricePusher {
"quorum of validators because of locked objects. Retried a conflicting transaction"
)
) {
/*
Object.values((e as any).data).forEach((lockedObjects: any) => {
lockedObjects.forEach((lockedObject: [string, number, string]) => {
lockedAddresses.add(lockedObject[0]);
});
});
// retry merging without the locked coins
i--;
*/
continue;
}
throw e;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.