From cbb8584fc6340ca61bc627f44c10161b91ab31b3 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 24 Apr 2024 12:14:48 +0530 Subject: [PATCH 01/20] add dynamic tx-priority --- .../operations/fundCollateral.ts | 20 +++++- packages/js/src/utils/TransactionBuilder.ts | 16 ++++- packages/js/src/utils/helpers.ts | 65 +++++++++++++++++++ 3 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 packages/js/src/utils/helpers.ts diff --git a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts index 823fbc8ff..43e77e326 100644 --- a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts +++ b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts @@ -18,6 +18,7 @@ import { addDecimals } from '../../../utils/conversions'; import { Convergence } from '../../../Convergence'; import { protocolCache } from '../../protocolModule/cache'; import { collateralMintCache } from '../cache'; +import { getEstimatedPriorityFeeInMicorLamps } from '@/utils/helpers'; const Key = 'FundCollateralOperation' as const; /** @@ -158,9 +159,8 @@ export const fundCollateralBuilder = async ( const collateralMint = await collateralMintCache.get(convergence); const collateralDecimals = collateralMint.decimals; - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createFundCollateralInstruction( { @@ -178,4 +178,20 @@ export const fundCollateralBuilder = async ( signers: [user], key: 'fundCollateral', }); + + const estimatedTxFeeWithComputeUnits = + await getEstimatedPriorityFeeInMicorLamps( + txBuilder, + convergence.connection + ); + + if (estimatedTxFeeWithComputeUnits) { + txBuilder.addComputeBudgetIxs( + estimatedTxFeeWithComputeUnits.microLamports, + estimatedTxFeeWithComputeUnits.unitsConsumed + ); + } else { + txBuilder.addTxPriorityFeeIx(convergence); + } + return txBuilder; }; diff --git a/packages/js/src/utils/TransactionBuilder.ts b/packages/js/src/utils/TransactionBuilder.ts index a43f2446c..4c03ba036 100644 --- a/packages/js/src/utils/TransactionBuilder.ts +++ b/packages/js/src/utils/TransactionBuilder.ts @@ -304,11 +304,25 @@ export class TransactionBuilder { typeof convergence.transactionPriority === 'number' ? convergence.transactionPriority : TRANSACTION_PRIORITY_FEE_MAP[convergence.transactionPriority]; - return this.add({ + return this.prepend({ instruction: ComputeBudgetProgram.setComputeUnitPrice({ microLamports: txPriorityInLamports * Math.pow(10, 6), }), signers: [], }); } + + addComputeBudgetIxs(microLamports: number, computeUnits: number) { + return this.prepend({ + instruction: ComputeBudgetProgram.setComputeUnitLimit({ + units: computeUnits, + }), + signers: [], + }).add({ + instruction: ComputeBudgetProgram.setComputeUnitPrice({ + microLamports, + }), + signers: [], + }); + } } diff --git a/packages/js/src/utils/helpers.ts b/packages/js/src/utils/helpers.ts new file mode 100644 index 000000000..7fec8a357 --- /dev/null +++ b/packages/js/src/utils/helpers.ts @@ -0,0 +1,65 @@ +import { + Connection, + Transaction, + TransactionMessage, + VersionedTransaction, +} from '@solana/web3.js'; +import { TransactionBuilder } from './TransactionBuilder'; + +type EstimatedPriorityFee = { + unitsConsumed: number; + microLamports: number; +} | null; + +export const getEstimatedPriorityFeeInMicorLamps = async ( + tx: Transaction | TransactionBuilder, + connection: Connection +): Promise => { + try { + let txToProcess: Transaction; + const latestBlockhash = await connection.getLatestBlockhash(); + if (tx instanceof TransactionBuilder) { + txToProcess = tx.toTransaction(latestBlockhash); + } else { + txToProcess = tx; + } + if (!txToProcess.feePayer) { + throw new Error('Transaction must have a fee payer'); + } + const recentPriorityFeeData = + await connection.getRecentPrioritizationFees(); + + if (recentPriorityFeeData.length === 0) { + throw new Error('Failed to get recent prioritization fees'); + } + let avgPriorityFee = recentPriorityFeeData.reduce( + (acc, { prioritizationFee }) => acc + prioritizationFee, + 0 + ); + avgPriorityFee /= recentPriorityFeeData.length; + + const ixs = txToProcess.instructions.map((ix) => ix); + + const txMessage = new TransactionMessage({ + payerKey: txToProcess.feePayer, + recentBlockhash: latestBlockhash.blockhash, + instructions: ixs, + }).compileToV0Message(); + + const versionedTx = new VersionedTransaction(txMessage); + const simulateTxResult = await connection.simulateTransaction(versionedTx, { + sigVerify: false, + }); + const unitsConsumed = simulateTxResult.value?.unitsConsumed; + if (!unitsConsumed) { + throw new Error('Failed to get units consumed'); + } + return { + unitsConsumed, + microLamports: avgPriorityFee, + }; + } catch (error) { + console.error(error); + return null; + } +}; From ffbb4fc9c932396ab668b0b9c6e0f3bc90764753 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 24 Apr 2024 13:04:17 +0530 Subject: [PATCH 02/20] test implementation --- packages/js/src/constants.ts | 6 +-- .../operations/fundCollateral.ts | 35 ++++++++++++----- packages/js/src/utils/TransactionBuilder.ts | 26 ++++++++----- packages/js/src/utils/helpers.ts | 38 ++++++++++++++++++- packages/js/src/utils/types.ts | 8 +++- 5 files changed, 89 insertions(+), 24 deletions(-) diff --git a/packages/js/src/constants.ts b/packages/js/src/constants.ts index 3ba31d912..d10e05e65 100644 --- a/packages/js/src/constants.ts +++ b/packages/js/src/constants.ts @@ -1,8 +1,8 @@ export const TRANSACTION_PRIORITY_FEE_MAP = { none: 0, - normal: 5_000, - high: 15_000, - turbo: 25_000, + normal: 0.005, + high: 0.015, + turbo: 0.025, }; export const HXRO_COLLATERAL_LOG_INDEX = 7; diff --git a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts index 43e77e326..f0ed5c220 100644 --- a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts +++ b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts @@ -18,7 +18,10 @@ import { addDecimals } from '../../../utils/conversions'; import { Convergence } from '../../../Convergence'; import { protocolCache } from '../../protocolModule/cache'; import { collateralMintCache } from '../cache'; -import { getEstimatedPriorityFeeInMicorLamps } from '@/utils/helpers'; +import { + getComputeUnitsToBeConsumed, + getEstimatedPriorityFeeInMicorLamps, +} from '@/utils/helpers'; const Key = 'FundCollateralOperation' as const; /** @@ -178,20 +181,32 @@ export const fundCollateralBuilder = async ( signers: [user], key: 'fundCollateral', }); + const computeUnitsConsumed = await getComputeUnitsToBeConsumed( + txBuilder, + convergence.connection + ); + if (!computeUnitsConsumed) { + return txBuilder; + } + if (convergence.transactionPriority === 'dynamic') { + const estimatedTxFeeWithComputeUnits = + await getEstimatedPriorityFeeInMicorLamps( + txBuilder, + convergence.connection + ); - const estimatedTxFeeWithComputeUnits = - await getEstimatedPriorityFeeInMicorLamps( - txBuilder, - convergence.connection - ); - - if (estimatedTxFeeWithComputeUnits) { - txBuilder.addComputeBudgetIxs( + if (!estimatedTxFeeWithComputeUnits) { + return txBuilder; + } + txBuilder.addDynamicComputeBudgetIxs( estimatedTxFeeWithComputeUnits.microLamports, estimatedTxFeeWithComputeUnits.unitsConsumed ); } else { - txBuilder.addTxPriorityFeeIx(convergence); + txBuilder.addStaticComputeBudgetIxs( + convergence, + computeUnitsConsumed.unitsConsumed + ); } return txBuilder; }; diff --git a/packages/js/src/utils/TransactionBuilder.ts b/packages/js/src/utils/TransactionBuilder.ts index ca852762e..45610b7da 100644 --- a/packages/js/src/utils/TransactionBuilder.ts +++ b/packages/js/src/utils/TransactionBuilder.ts @@ -296,8 +296,11 @@ export class TransactionBuilder { }; } - addTxPriorityFeeIx(convergence: Convergence) { - if (!convergence.transactionPriority) { + addStaticComputeBudgetIxs(convergence: Convergence, computeUnits: number) { + if ( + !convergence.transactionPriority || + convergence.transactionPriority === 'dynamic' + ) { return this; } const txPriorityInLamports = @@ -306,23 +309,28 @@ export class TransactionBuilder { : TRANSACTION_PRIORITY_FEE_MAP[convergence.transactionPriority]; return this.prepend({ instruction: ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: txPriorityInLamports, + microLamports: txPriorityInLamports * Math.pow(10, 6), }), signers: [], - }); - } - - addComputeBudgetIxs(microLamports: number, computeUnits: number) { - return this.prepend({ + }).prepend({ instruction: ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnits, }), signers: [], - }).add({ + }); + } + + addDynamicComputeBudgetIxs(microLamports: number, computeUnits: number) { + return this.prepend({ instruction: ComputeBudgetProgram.setComputeUnitPrice({ microLamports, }), signers: [], + }).prepend({ + instruction: ComputeBudgetProgram.setComputeUnitLimit({ + units: computeUnits, + }), + signers: [], }); } } diff --git a/packages/js/src/utils/helpers.ts b/packages/js/src/utils/helpers.ts index 7fec8a357..ee997c3ae 100644 --- a/packages/js/src/utils/helpers.ts +++ b/packages/js/src/utils/helpers.ts @@ -38,8 +38,45 @@ export const getEstimatedPriorityFeeInMicorLamps = async ( ); avgPriorityFee /= recentPriorityFeeData.length; + const computeUnits = await getComputeUnitsToBeConsumed( + txToProcess, + connection + ); + if (!computeUnits) { + throw new Error('Failed to get compute units consumed'); + } + return { + unitsConsumed: computeUnits.unitsConsumed, + microLamports: avgPriorityFee, + }; + } catch (error) { + console.error(error); + return null; + } +}; + +type GetComputeUnitsToBeConsumed = { + unitsConsumed: number; +} | null; + +export const getComputeUnitsToBeConsumed = async ( + tx: Transaction | TransactionBuilder, + connection: Connection +): Promise => { + try { + let txToProcess: Transaction; + const latestBlockhash = await connection.getLatestBlockhash(); + if (tx instanceof TransactionBuilder) { + txToProcess = tx.toTransaction(latestBlockhash); + } else { + txToProcess = tx; + } const ixs = txToProcess.instructions.map((ix) => ix); + if (!txToProcess.feePayer) { + throw new Error('Transaction must have a fee payer'); + } + const txMessage = new TransactionMessage({ payerKey: txToProcess.feePayer, recentBlockhash: latestBlockhash.blockhash, @@ -56,7 +93,6 @@ export const getEstimatedPriorityFeeInMicorLamps = async ( } return { unitsConsumed, - microLamports: avgPriorityFee, }; } catch (error) { console.error(error); diff --git a/packages/js/src/utils/types.ts b/packages/js/src/utils/types.ts index 75084a54b..d9d05f48f 100644 --- a/packages/js/src/utils/types.ts +++ b/packages/js/src/utils/types.ts @@ -14,4 +14,10 @@ export type Option = T | null; export type Opaque = T & { __opaque__: K }; -export type TransactionPriority = 'none' | 'normal' | 'high' | 'turbo' | number; +export type TransactionPriority = + | 'dynamic' + | 'none' + | 'normal' + | 'high' + | 'turbo' + | number; From 58763bf5ba3fc39320e62e54a177b61a800e1130 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 24 Apr 2024 13:11:26 +0530 Subject: [PATCH 03/20] test implementation 2 --- .../operations/fundCollateral.ts | 29 ++-------------- packages/js/src/utils/helpers.ts | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts index f0ed5c220..e713c88cf 100644 --- a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts +++ b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts @@ -19,6 +19,7 @@ import { Convergence } from '../../../Convergence'; import { protocolCache } from '../../protocolModule/cache'; import { collateralMintCache } from '../cache'; import { + addComputeBudgetIxsIfNeeded, getComputeUnitsToBeConsumed, getEstimatedPriorityFeeInMicorLamps, } from '@/utils/helpers'; @@ -181,32 +182,6 @@ export const fundCollateralBuilder = async ( signers: [user], key: 'fundCollateral', }); - const computeUnitsConsumed = await getComputeUnitsToBeConsumed( - txBuilder, - convergence.connection - ); - if (!computeUnitsConsumed) { - return txBuilder; - } - if (convergence.transactionPriority === 'dynamic') { - const estimatedTxFeeWithComputeUnits = - await getEstimatedPriorityFeeInMicorLamps( - txBuilder, - convergence.connection - ); - - if (!estimatedTxFeeWithComputeUnits) { - return txBuilder; - } - txBuilder.addDynamicComputeBudgetIxs( - estimatedTxFeeWithComputeUnits.microLamports, - estimatedTxFeeWithComputeUnits.unitsConsumed - ); - } else { - txBuilder.addStaticComputeBudgetIxs( - convergence, - computeUnitsConsumed.unitsConsumed - ); - } + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); return txBuilder; }; diff --git a/packages/js/src/utils/helpers.ts b/packages/js/src/utils/helpers.ts index ee997c3ae..7d74c2c13 100644 --- a/packages/js/src/utils/helpers.ts +++ b/packages/js/src/utils/helpers.ts @@ -5,6 +5,7 @@ import { VersionedTransaction, } from '@solana/web3.js'; import { TransactionBuilder } from './TransactionBuilder'; +import { Convergence } from '@/Convergence'; type EstimatedPriorityFee = { unitsConsumed: number; @@ -99,3 +100,36 @@ export const getComputeUnitsToBeConsumed = async ( return null; } }; + +export const addComputeBudgetIxsIfNeeded = async ( + txBuilder: TransactionBuilder, + convergence: Convergence +) => { + const computeUnitsConsumed = await getComputeUnitsToBeConsumed( + txBuilder, + convergence.connection + ); + if (!computeUnitsConsumed) { + return txBuilder; + } + if (convergence.transactionPriority === 'dynamic') { + const estimatedTxFeeWithComputeUnits = + await getEstimatedPriorityFeeInMicorLamps( + txBuilder, + convergence.connection + ); + + if (!estimatedTxFeeWithComputeUnits) { + return txBuilder; + } + txBuilder.addDynamicComputeBudgetIxs( + estimatedTxFeeWithComputeUnits.microLamports, + estimatedTxFeeWithComputeUnits.unitsConsumed + ); + } else { + txBuilder.addStaticComputeBudgetIxs( + convergence, + computeUnitsConsumed.unitsConsumed + ); + } +}; From 8c5b14c845821df0244895844baecc72a7a9acf3 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 24 Apr 2024 16:13:50 +0530 Subject: [PATCH 04/20] resolve comments --- .../operations/fundCollateral.ts | 9 ++----- packages/js/src/utils/helpers.ts | 27 +++++++------------ 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts index e713c88cf..de7455733 100644 --- a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts +++ b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts @@ -18,11 +18,7 @@ import { addDecimals } from '../../../utils/conversions'; import { Convergence } from '../../../Convergence'; import { protocolCache } from '../../protocolModule/cache'; import { collateralMintCache } from '../cache'; -import { - addComputeBudgetIxsIfNeeded, - getComputeUnitsToBeConsumed, - getEstimatedPriorityFeeInMicorLamps, -} from '@/utils/helpers'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'FundCollateralOperation' as const; /** @@ -182,6 +178,5 @@ export const fundCollateralBuilder = async ( signers: [user], key: 'fundCollateral', }); - await addComputeBudgetIxsIfNeeded(txBuilder, convergence); - return txBuilder; + return await addComputeBudgetIxsIfNeeded(txBuilder, convergence); }; diff --git a/packages/js/src/utils/helpers.ts b/packages/js/src/utils/helpers.ts index 7d74c2c13..776caddbb 100644 --- a/packages/js/src/utils/helpers.ts +++ b/packages/js/src/utils/helpers.ts @@ -8,11 +8,10 @@ import { TransactionBuilder } from './TransactionBuilder'; import { Convergence } from '@/Convergence'; type EstimatedPriorityFee = { - unitsConsumed: number; microLamports: number; } | null; -export const getEstimatedPriorityFeeInMicorLamps = async ( +export const getEstimatedPriorityFee = async ( tx: Transaction | TransactionBuilder, connection: Connection ): Promise => { @@ -39,15 +38,7 @@ export const getEstimatedPriorityFeeInMicorLamps = async ( ); avgPriorityFee /= recentPriorityFeeData.length; - const computeUnits = await getComputeUnitsToBeConsumed( - txToProcess, - connection - ); - if (!computeUnits) { - throw new Error('Failed to get compute units consumed'); - } return { - unitsConsumed: computeUnits.unitsConsumed, microLamports: avgPriorityFee, }; } catch (error) { @@ -113,18 +104,17 @@ export const addComputeBudgetIxsIfNeeded = async ( return txBuilder; } if (convergence.transactionPriority === 'dynamic') { - const estimatedTxFeeWithComputeUnits = - await getEstimatedPriorityFeeInMicorLamps( - txBuilder, - convergence.connection - ); + const estimatedFee = await getEstimatedPriorityFee( + txBuilder, + convergence.connection + ); - if (!estimatedTxFeeWithComputeUnits) { + if (!estimatedFee) { return txBuilder; } txBuilder.addDynamicComputeBudgetIxs( - estimatedTxFeeWithComputeUnits.microLamports, - estimatedTxFeeWithComputeUnits.unitsConsumed + estimatedFee.microLamports, + computeUnitsConsumed.unitsConsumed ); } else { txBuilder.addStaticComputeBudgetIxs( @@ -132,4 +122,5 @@ export const addComputeBudgetIxsIfNeeded = async ( computeUnitsConsumed.unitsConsumed ); } + return txBuilder; }; From 4ba6fd66d4e166e5c2b8a662ec7711d541be3f8f Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 24 Apr 2024 16:22:35 +0530 Subject: [PATCH 05/20] optimise --- packages/js/src/utils/TransactionBuilder.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/js/src/utils/TransactionBuilder.ts b/packages/js/src/utils/TransactionBuilder.ts index 45610b7da..5f8a1bad9 100644 --- a/packages/js/src/utils/TransactionBuilder.ts +++ b/packages/js/src/utils/TransactionBuilder.ts @@ -297,10 +297,7 @@ export class TransactionBuilder { } addStaticComputeBudgetIxs(convergence: Convergence, computeUnits: number) { - if ( - !convergence.transactionPriority || - convergence.transactionPriority === 'dynamic' - ) { + if (convergence.transactionPriority === 'dynamic') { return this; } const txPriorityInLamports = From 60e1d4c7412a06164c9f7c7320764bc5b5853275 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 24 Apr 2024 17:08:30 +0530 Subject: [PATCH 06/20] add new tx priority changes to all operations --- .../operations/initializeCollateral.ts | 38 +++++----- .../operations/withdrawCollateral.ts | 7 +- .../protocolModule/operations/addBaseAsset.ts | 4 +- .../protocolModule/operations/addUserAsset.ts | 13 ++-- .../helpers.ts | 7 +- .../helpers.ts | 7 +- .../rfqModule/operations/addLegsToRfq.ts | 7 +- .../rfqModule/operations/cancelResponse.ts | 7 +- .../plugins/rfqModule/operations/cancelRfq.ts | 6 +- .../rfqModule/operations/cleanUpResponse.ts | 7 +- .../operations/cleanUpResponseLegs.ts | 7 +- .../rfqModule/operations/cleanUpRfq.ts | 7 +- .../plugins/rfqModule/operations/createRfq.ts | 5 +- .../operations/finalizeRfqConstruction.ts | 7 +- .../partlyRevertSettlementPreparation.ts | 7 +- .../operations/prepareMoreLegsSettlement.ts | 7 +- .../rfqModule/operations/prepareSettlement.ts | 3 +- .../rfqModule/operations/respondToRfq.ts | 7 +- .../operations/revertSettlementPreparation.ts | 6 +- .../plugins/rfqModule/operations/settle.ts | 4 +- .../systemModule/operations/createAccount.ts | 7 +- .../systemModule/operations/transferSol.ts | 17 +++-- .../approveTokenDelegateAuthority.ts | 16 +++-- .../operations/createTokenWithMint.ts | 3 +- .../tokenModule/operations/freezeTokens.ts | 16 +++-- .../tokenModule/operations/mintTokens.ts | 68 +++++++++--------- .../revokeTokenDelegateAuthority.ts | 16 +++-- .../tokenModule/operations/sendTokens.ts | 70 +++++++++---------- .../tokenModule/operations/thawTokens.ts | 16 +++-- .../operations/confirmAndPrepareVault.ts | 4 +- .../operations/createVault.ts | 3 +- .../operations/withdrawVaultTokens.ts | 9 +-- .../operations/cleanupWhitelist.ts | 8 ++- .../operations/createWhitelist.ts | 7 +- packages/js/src/utils/helpers.ts | 4 +- 35 files changed, 254 insertions(+), 173 deletions(-) diff --git a/packages/js/src/plugins/collateralModule/operations/initializeCollateral.ts b/packages/js/src/plugins/collateralModule/operations/initializeCollateral.ts index ae0bbff3e..13c550289 100644 --- a/packages/js/src/plugins/collateralModule/operations/initializeCollateral.ts +++ b/packages/js/src/plugins/collateralModule/operations/initializeCollateral.ts @@ -18,6 +18,7 @@ import { TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; import { protocolCache } from '../../protocolModule/cache'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'InitializeCollateralOperation' as const; @@ -196,21 +197,24 @@ export const initializeCollateralBuilder = async ( const rfqProgram = convergence.programs().getRfq(programs); - return TransactionBuilder.make() - .setFeePayer(user) - .addTxPriorityFeeIx(convergence) - .add({ - instruction: createInitializeCollateralInstruction( - { - user: user.publicKey, - protocol, - collateralMint, - collateralToken, - collateralInfo, - }, - rfqProgram.address - ), - signers: [user], - key: 'initializeCollateral', - }); + const txBuilder = + TransactionBuilder.make() + .setFeePayer(user) + .add({ + instruction: createInitializeCollateralInstruction( + { + user: user.publicKey, + protocol, + collateralMint, + collateralToken, + collateralInfo, + }, + rfqProgram.address + ), + signers: [user], + key: 'initializeCollateral', + }); + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + + return txBuilder; }; diff --git a/packages/js/src/plugins/collateralModule/operations/withdrawCollateral.ts b/packages/js/src/plugins/collateralModule/operations/withdrawCollateral.ts index 11e11d315..492a418ec 100644 --- a/packages/js/src/plugins/collateralModule/operations/withdrawCollateral.ts +++ b/packages/js/src/plugins/collateralModule/operations/withdrawCollateral.ts @@ -19,6 +19,7 @@ import { import { protocolCache } from '../../protocolModule/cache'; import { collateralMintCache } from '../cache'; import { addDecimals } from '../../..//utils/conversions'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'WithdrawCollateralOperation' as const; @@ -182,9 +183,8 @@ export const withdrawCollateralBuilder = async ( const collateralMint = await collateralMintCache.get(convergence); const collateralDecimals = collateralMint.decimals; - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(user) - .addTxPriorityFeeIx(convergence) .add({ instruction: createWithdrawCollateralInstruction( { @@ -202,4 +202,7 @@ export const withdrawCollateralBuilder = async ( signers: [user], key: 'withdrawCollateral', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/protocolModule/operations/addBaseAsset.ts b/packages/js/src/plugins/protocolModule/operations/addBaseAsset.ts index 7e95780cb..7f34b19e3 100644 --- a/packages/js/src/plugins/protocolModule/operations/addBaseAsset.ts +++ b/packages/js/src/plugins/protocolModule/operations/addBaseAsset.ts @@ -22,6 +22,7 @@ import { } from '../../../utils/TransactionBuilder'; import { baseAssetsCache } from '../cache'; import { findVacantBaseAssetIndex } from '../helpers'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'AddBaseAssetOperation' as const; @@ -169,7 +170,6 @@ export const addBaseAssetBuilder = async ( const builder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(cvg) .add({ instruction: createAddBaseAssetInstruction( { @@ -191,7 +191,7 @@ export const addBaseAssetBuilder = async ( signers: [authority], key: 'addBaseAsset', }); - + await addComputeBudgetIxsIfNeeded(builder, cvg); return { builder, baseAssetIndex: index, diff --git a/packages/js/src/plugins/protocolModule/operations/addUserAsset.ts b/packages/js/src/plugins/protocolModule/operations/addUserAsset.ts index 8a0e0f0ca..1db2e0091 100644 --- a/packages/js/src/plugins/protocolModule/operations/addUserAsset.ts +++ b/packages/js/src/plugins/protocolModule/operations/addUserAsset.ts @@ -15,6 +15,7 @@ import { } from '../../../utils/TransactionBuilder'; import { baseAssetsCache, registeredMintsCache } from '../cache'; import { findVacantBaseAssetIndex } from '../helpers'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'AddUserAssetOperation' as const; @@ -128,14 +129,15 @@ export const addUserAssetBuilder = async ( try { await cvg.protocol().findRegisteredMintByAddress({ address: mintInfo }); mintRegistered = true; - } catch (e) {} + } catch (e) { + // + } if (mintRegistered) { throw new Error(`Mint ${mint.toString()} had been already registered`); } const builder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(cvg) .add({ instruction: createAddUserAssetInstruction( { @@ -155,6 +157,9 @@ export const addUserAssetBuilder = async ( signers: [cvg.identity()], key: 'addUserAsset', }); - - return { builder, baseAssetIndex }; + await addComputeBudgetIxsIfNeeded(builder, cvg); + return { + builder, + baseAssetIndex, + }; }; diff --git a/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts b/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts index 4ee5c4400..a1ba76f8e 100644 --- a/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts +++ b/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts @@ -11,6 +11,7 @@ import { createAmericanProgram, } from './instrument'; import { TransactionBuilder } from '@/utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; export type PrepareAmericanOptionsResult = { ataTxBuilders: TransactionBuilder[]; @@ -109,10 +110,8 @@ export const prepareAmericanOptions = async ( const mintTxBuilder = TransactionBuilder.make().setFeePayer( convergence.rpc().getDefaultFeePayer() ); - mintTxBuilder.addTxPriorityFeeIx(convergence).add({ - instruction: ixWithSigners.ix, - signers: [convergence.identity()], - }); + await addComputeBudgetIxsIfNeeded(mintTxBuilder, convergence); + mintTxBuilderArray.push(mintTxBuilder); } return { diff --git a/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts b/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts index dae256ce2..9c5d095d5 100644 --- a/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts +++ b/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts @@ -9,6 +9,7 @@ import { PsyoptionsEuropeanInstrument, createEuropeanProgram, } from './instrument'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; export type PrepareEuropeanOptionsResult = { ataTxBuilders: TransactionBuilder[]; @@ -122,10 +123,8 @@ export const prepareEuropeanOptions = async ( const mintTxBuilder = TransactionBuilder.make().setFeePayer( convergence.rpc().getDefaultFeePayer() ); - mintTxBuilder.addTxPriorityFeeIx(convergence).add({ - instruction: ix, - signers: [convergence.identity()], - }); + + await addComputeBudgetIxsIfNeeded(mintTxBuilder, convergence); mintTxBuilderArray.push(mintTxBuilder); } diff --git a/packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts b/packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts index b5499f9dc..ad696789a 100644 --- a/packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts +++ b/packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts @@ -20,6 +20,7 @@ import { TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; import { LegInstrument } from '../../../plugins/instrumentModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'AddLegsToRfqOperation' as const; @@ -144,9 +145,8 @@ export const addLegsToRfqBuilder = async ( const rfqProgram = convergence.programs().getRfq(programs); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createAddLegsToRfqInstruction( { @@ -163,4 +163,7 @@ export const addLegsToRfqBuilder = async ( signers: [taker], key: 'addLegsToRfq', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/cancelResponse.ts b/packages/js/src/plugins/rfqModule/operations/cancelResponse.ts index fb5ee5f6b..785b5be1c 100644 --- a/packages/js/src/plugins/rfqModule/operations/cancelResponse.ts +++ b/packages/js/src/plugins/rfqModule/operations/cancelResponse.ts @@ -11,6 +11,7 @@ import { } from '../../../types'; import { TransactionBuilder, TransactionBuilderOptions } from '../../../utils'; import { SendAndConfirmTransactionResponse } from '@/plugins'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'cancelResponseOperation' as const; @@ -135,9 +136,8 @@ export const cancelResponseBuilder = async ( .rfqs() .findResponseByAddress({ address: response }); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCancelResponseInstruction( { @@ -151,4 +151,7 @@ export const cancelResponseBuilder = async ( signers: [maker], key: 'cancelResponse', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/cancelRfq.ts b/packages/js/src/plugins/rfqModule/operations/cancelRfq.ts index 86f618988..083bc1334 100644 --- a/packages/js/src/plugins/rfqModule/operations/cancelRfq.ts +++ b/packages/js/src/plugins/rfqModule/operations/cancelRfq.ts @@ -14,6 +14,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CancelRfqOperation' as const; @@ -124,9 +125,8 @@ export const cancelRfqBuilder = async ( taker = convergence.identity(), protocol = convergence.protocol().pdas().protocol(), } = params; - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCancelRfqInstruction( { @@ -139,4 +139,6 @@ export const cancelRfqBuilder = async ( signers: [taker], key: 'cancelRfq', }); + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/cleanUpResponse.ts b/packages/js/src/plugins/rfqModule/operations/cleanUpResponse.ts index c8d0ac84b..34e930570 100644 --- a/packages/js/src/plugins/rfqModule/operations/cleanUpResponse.ts +++ b/packages/js/src/plugins/rfqModule/operations/cleanUpResponse.ts @@ -20,6 +20,7 @@ import { import { legToBaseAssetMint } from '@/plugins/instrumentModule'; import { SendAndConfirmTransactionResponse } from '@/plugins/rpcModule'; import { prependWithProviderProgram } from '@/plugins/printTradeModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'cleanUpResponseOperation' as const; @@ -279,9 +280,8 @@ export const cleanUpEscrowResponseBuilder = async ( { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false } ); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCleanUpResponseInstruction( { @@ -296,6 +296,9 @@ export const cleanUpEscrowResponseBuilder = async ( signers: [], key: 'cleanUpResponses', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; export type CleanUpPrintTradeResponseBuilderParams = { diff --git a/packages/js/src/plugins/rfqModule/operations/cleanUpResponseLegs.ts b/packages/js/src/plugins/rfqModule/operations/cleanUpResponseLegs.ts index f4ce81798..a4ab83684 100644 --- a/packages/js/src/plugins/rfqModule/operations/cleanUpResponseLegs.ts +++ b/packages/js/src/plugins/rfqModule/operations/cleanUpResponseLegs.ts @@ -18,6 +18,7 @@ import { getOrCreateATA } from '../../../utils/ata'; import { InstrumentPdasClient } from '../../instrumentModule/InstrumentPdasClient'; import { protocolCache } from '../../protocolModule/cache'; import { legToBaseAssetMint } from '@/plugins/instrumentModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CleanUpResponseLegsOperation' as const; @@ -211,9 +212,8 @@ export const cleanUpResponseLegsBuilder = async ( anchorRemainingAccounts.push(instrumentProgramAccount, ...legAccounts); } - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCleanUpResponseEscrowLegsInstruction( { @@ -230,4 +230,7 @@ export const cleanUpResponseLegsBuilder = async ( signers: [], key: 'cleanUpResponseLegs', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/cleanUpRfq.ts b/packages/js/src/plugins/rfqModule/operations/cleanUpRfq.ts index 74903853c..392449465 100644 --- a/packages/js/src/plugins/rfqModule/operations/cleanUpRfq.ts +++ b/packages/js/src/plugins/rfqModule/operations/cleanUpRfq.ts @@ -14,6 +14,7 @@ import { TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; import { rfqProgram } from '../program'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CleanUpRfqOperation' as const; /** @@ -140,9 +141,8 @@ export const cleanUpRfqBuilder = async ( rfqModel.whitelist.toBase58() !== defaultPubkey.toBase58() ? rfqModel.whitelist : rfqProgram.address; - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCleanUpRfqInstruction( { @@ -156,4 +156,7 @@ export const cleanUpRfqBuilder = async ( signers: [], key: 'cleanUpRfq', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/createRfq.ts b/packages/js/src/plugins/rfqModule/operations/createRfq.ts index 82521f73b..942a2407a 100644 --- a/packages/js/src/plugins/rfqModule/operations/createRfq.ts +++ b/packages/js/src/plugins/rfqModule/operations/createRfq.ts @@ -35,6 +35,7 @@ import { import { OrderType, toSolitaOrderType } from '../models/OrderType'; import { InstructionUniquenessTracker } from '@/utils/classes'; import { createWhitelistBuilder } from '@/plugins/whitelistModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CreateRfqOperation' as const; @@ -399,7 +400,6 @@ export const createRfqBuilder = async ( .setContext({ rfq, }) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCreateRfqInstruction( { @@ -445,7 +445,6 @@ export const createRfqBuilder = async ( .setContext({ rfq, }) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCreateRfqInstruction( { @@ -481,6 +480,8 @@ export const createRfqBuilder = async ( const remainingLegsToAdd = instruments.slice(legsToAdd.length, legs.length); + await addComputeBudgetIxsIfNeeded(rfqBuilder, convergence); + return { createRfqTxBuilder: rfqBuilder, remainingLegsToAdd, diff --git a/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts b/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts index d287c82ad..2af86acd2 100644 --- a/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts +++ b/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts @@ -18,6 +18,7 @@ import { import { Convergence } from '../../../Convergence'; import { LegInstrument } from '@/plugins/instrumentModule'; import { PrintTradeLeg } from '@/plugins/printTradeModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'FinalizeRfqConstructionOperation' as const; @@ -199,7 +200,7 @@ export const finalizeRfqConstructionBuilder = async ( const protocol = convergence.protocol().pdas().protocol(); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) .setContext({ rfq, @@ -210,7 +211,6 @@ export const finalizeRfqConstructionBuilder = async ( }), signers: [], }) - .addTxPriorityFeeIx(convergence) .add({ instruction: createFinalizeRfqConstructionInstruction( { @@ -226,4 +226,7 @@ export const finalizeRfqConstructionBuilder = async ( signers: [taker], key: 'finalizeRfqConstruction', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/partlyRevertSettlementPreparation.ts b/packages/js/src/plugins/rfqModule/operations/partlyRevertSettlementPreparation.ts index e71a5ddc3..0a25afdd7 100644 --- a/packages/js/src/plugins/rfqModule/operations/partlyRevertSettlementPreparation.ts +++ b/packages/js/src/plugins/rfqModule/operations/partlyRevertSettlementPreparation.ts @@ -18,6 +18,7 @@ import { import { InstrumentPdasClient } from '../../instrumentModule'; import { AuthoritySide, toSolitaAuthoritySide } from '../models/AuthoritySide'; import { legToBaseAssetMint } from '@/plugins/instrumentModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'PartlyRevertSettlementPreparationOperation' as const; @@ -214,9 +215,8 @@ export const partlyRevertSettlementPreparationBuilder = async ( anchorRemainingAccounts.push(instrumentProgramAccount, ...legAccounts); } - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createPartlyRevertEscrowSettlementPreparationInstruction( { @@ -234,4 +234,7 @@ export const partlyRevertSettlementPreparationBuilder = async ( signers: [], key: 'partlyRevertSettlementPreparation', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/prepareMoreLegsSettlement.ts b/packages/js/src/plugins/rfqModule/operations/prepareMoreLegsSettlement.ts index 293b524bd..49c947185 100644 --- a/packages/js/src/plugins/rfqModule/operations/prepareMoreLegsSettlement.ts +++ b/packages/js/src/plugins/rfqModule/operations/prepareMoreLegsSettlement.ts @@ -27,6 +27,7 @@ import { import { getOrCreateATA } from '../../../utils/ata'; import { InstrumentPdasClient } from '../../instrumentModule'; import { legToBaseAssetMint } from '@/plugins/instrumentModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'PrepareMoreLegsSettlementOperation' as const; @@ -254,7 +255,7 @@ export const prepareMoreLegsSettlementBuilder = async ( anchorRemainingAccounts.push(instrumentProgramAccount, ...legAccounts); } - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) .add({ instruction: ComputeBudgetProgram.setComputeUnitLimit({ @@ -262,7 +263,6 @@ export const prepareMoreLegsSettlementBuilder = async ( }), signers: [], }) - .addTxPriorityFeeIx(convergence) .add({ instruction: createPrepareMoreEscrowLegsSettlementInstruction( { @@ -281,4 +281,7 @@ export const prepareMoreLegsSettlementBuilder = async ( signers: [caller], key: 'prepareMoreLegsSettlement', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/prepareSettlement.ts b/packages/js/src/plugins/rfqModule/operations/prepareSettlement.ts index 184a0fa22..7f133e977 100644 --- a/packages/js/src/plugins/rfqModule/operations/prepareSettlement.ts +++ b/packages/js/src/plugins/rfqModule/operations/prepareSettlement.ts @@ -40,6 +40,7 @@ import { psyoptionsEuropeanInstrumentProgram, } from '@/plugins/psyoptionsEuropeanInstrumentModule'; import { InstructionUniquenessTracker } from '@/utils/classes'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'PrepareSettlementOperation' as const; @@ -326,7 +327,6 @@ export const prepareSettlementBuilder = async ( }), signers: [], }) - .addTxPriorityFeeIx(convergence) .add({ instruction: createPrepareEscrowSettlementInstruction( { @@ -346,6 +346,7 @@ export const prepareSettlementBuilder = async ( key: 'prepareSettlement', }); + await addComputeBudgetIxsIfNeeded(prepareSettlementTxBuilder, convergence); return { ataTxBuilderArray, prepareSettlementTxBuilder, diff --git a/packages/js/src/plugins/rfqModule/operations/respondToRfq.ts b/packages/js/src/plugins/rfqModule/operations/respondToRfq.ts index 3dd4d8b30..e59f3ecb0 100644 --- a/packages/js/src/plugins/rfqModule/operations/respondToRfq.ts +++ b/packages/js/src/plugins/rfqModule/operations/respondToRfq.ts @@ -23,6 +23,7 @@ import { AdditionalResponseData, prependWithProviderProgram, } from '@/plugins/printTradeModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const getNextResponsePdaAndDistinguisher = async ( cvg: Convergence, @@ -293,7 +294,7 @@ export const respondToRfqBuilder = async ( } } - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(maker) .setContext({ response, @@ -304,7 +305,6 @@ export const respondToRfqBuilder = async ( }), signers: [], }) - .addTxPriorityFeeIx(convergence) .add({ instruction: createRespondToRfqInstruction( { @@ -329,4 +329,7 @@ export const respondToRfqBuilder = async ( signers: [maker], key: 'respondToRfq', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts b/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts index 1982a2769..cdbadd3cf 100644 --- a/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts +++ b/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts @@ -28,6 +28,7 @@ import { } from '../models'; import { legToBaseAssetMint } from '@/plugins/instrumentModule'; import { prependWithProviderProgram } from '@/plugins/printTradeModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'RevertSettlementPreparationOperation' as const; @@ -287,9 +288,8 @@ export const revertEscrowSettlementPreparationBuilder = async ( anchorRemainingAccounts.push(spotInstrumentProgramAccount, ...quoteAccounts); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(cvg) .add({ instruction: createRevertEscrowSettlementPreparationInstruction( { @@ -306,6 +306,8 @@ export const revertEscrowSettlementPreparationBuilder = async ( signers: [], key: 'revertSettlementPreparation', }); + await addComputeBudgetIxsIfNeeded(txBuilder, cvg); + return txBuilder; }; export type RevertPrintTradeSettlementPreparationBuilderParams = { diff --git a/packages/js/src/plugins/rfqModule/operations/settle.ts b/packages/js/src/plugins/rfqModule/operations/settle.ts index 295a724b2..6fedb3a05 100644 --- a/packages/js/src/plugins/rfqModule/operations/settle.ts +++ b/packages/js/src/plugins/rfqModule/operations/settle.ts @@ -32,6 +32,7 @@ import { prependWithProviderProgram } from '@/plugins/printTradeModule'; import { spotInstrumentProgram } from '@/plugins/spotInstrumentModule'; import { InstructionUniquenessTracker, getOrCreateATAtxBuilder } from '@/utils'; import { Protocol } from '@/plugins/protocolModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'SettleOperation' as const; @@ -280,7 +281,6 @@ export const settleEscrowBuilder = async ( }), signers: [], }) - .addTxPriorityFeeIx(cvg) .add({ instruction: createSettleEscrowInstruction( { @@ -294,7 +294,7 @@ export const settleEscrowBuilder = async ( signers: [], key: 'settle', }); - + await addComputeBudgetIxsIfNeeded(settleTxBuilder, cvg); return { ataTxBuilderArray, settleTxBuilder, diff --git a/packages/js/src/plugins/systemModule/operations/createAccount.ts b/packages/js/src/plugins/systemModule/operations/createAccount.ts index 8b9d6d859..e74e7d5a4 100644 --- a/packages/js/src/plugins/systemModule/operations/createAccount.ts +++ b/packages/js/src/plugins/systemModule/operations/createAccount.ts @@ -15,6 +15,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CreateAccountOperation' as const; @@ -161,13 +162,12 @@ export const createAccountBuilder = async ( const lamports = params.lamports ?? (await convergence.rpc().getRent(space)); assertSol(lamports); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) .setContext({ newAccount, lamports, }) - .addTxPriorityFeeIx(convergence) .add({ instruction: SystemProgram.createAccount({ fromPubkey: payer.publicKey, @@ -179,4 +179,7 @@ export const createAccountBuilder = async ( signers: [payer, newAccount], key: params.instructionKey ?? 'createAccount', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/systemModule/operations/transferSol.ts b/packages/js/src/plugins/systemModule/operations/transferSol.ts index 93f2ab684..1472e6e41 100644 --- a/packages/js/src/plugins/systemModule/operations/transferSol.ts +++ b/packages/js/src/plugins/systemModule/operations/transferSol.ts @@ -15,6 +15,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'TransferSolOperation' as const; @@ -98,7 +99,11 @@ export const transferSolOperationHandler: OperationHandler convergence: Convergence, scope: OperationScope ): Promise { - const builder = transferSolBuilder(convergence, operation.input, scope); + const builder = await transferSolBuilder( + convergence, + operation.input, + scope + ); return builder.sendAndConfirm(convergence, scope.confirmOptions); }, }; @@ -135,11 +140,11 @@ export type TransferSolBuilderParams = Omit< * @group Transaction Builders * @category Constructors */ -export const transferSolBuilder = ( +export const transferSolBuilder = async ( convergence: Convergence, params: TransferSolBuilderParams, options: TransactionBuilderOptions = {} -): TransactionBuilder => { +): Promise => { const { programs, payer = convergence.rpc().getDefaultFeePayer() } = options; const { from = convergence.identity(), @@ -151,9 +156,8 @@ export const transferSolBuilder = ( assertSol(amount); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: SystemProgram.transfer({ fromPubkey: from.publicKey, @@ -165,4 +169,7 @@ export const transferSolBuilder = ( signers: [from], key: params.instructionKey ?? 'transferSol', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/tokenModule/operations/approveTokenDelegateAuthority.ts b/packages/js/src/plugins/tokenModule/operations/approveTokenDelegateAuthority.ts index 96ce5e536..ef28c6ca8 100644 --- a/packages/js/src/plugins/tokenModule/operations/approveTokenDelegateAuthority.ts +++ b/packages/js/src/plugins/tokenModule/operations/approveTokenDelegateAuthority.ts @@ -18,6 +18,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'ApproveTokenDelegateAuthorityOperation' as const; @@ -114,11 +115,12 @@ export const approveTokenDelegateAuthorityOperationHandler: OperationHandler => { - return approveTokenDelegateAuthorityBuilder( + const builder = await approveTokenDelegateAuthorityBuilder( convergence, operation.input, scope - ).sendAndConfirm(convergence, scope.confirmOptions); + ); + return builder.sendAndConfirm(convergence, scope.confirmOptions); }, }; @@ -154,11 +156,11 @@ export type ApproveTokenDelegateAuthorityBuilderParams = Omit< * @group Transaction Builders * @category Constructors */ -export const approveTokenDelegateAuthorityBuilder = ( +export const approveTokenDelegateAuthorityBuilder = async ( convergence: Convergence, params: ApproveTokenDelegateAuthorityBuilderParams, options: TransactionBuilderOptions = {} -): TransactionBuilder => { +): Promise => { const { programs, payer = convergence.rpc().getDefaultFeePayer() } = options; const { mintAddress, @@ -182,9 +184,8 @@ export const approveTokenDelegateAuthorityBuilder = ( programs, }); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createApproveInstruction( tokenAddressOrAta, @@ -197,4 +198,7 @@ export const approveTokenDelegateAuthorityBuilder = ( signers, key: params.instructionKey ?? 'approveDelegateAuthority', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/tokenModule/operations/createTokenWithMint.ts b/packages/js/src/plugins/tokenModule/operations/createTokenWithMint.ts index e7d4da5e2..c2ef64891 100644 --- a/packages/js/src/plugins/tokenModule/operations/createTokenWithMint.ts +++ b/packages/js/src/plugins/tokenModule/operations/createTokenWithMint.ts @@ -20,6 +20,7 @@ import { useOperation, } from '../../../types'; import type { Convergence } from '../../../Convergence'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CreateTokenWithMintOperation' as const; @@ -276,7 +277,6 @@ export const createTokenWithMintBuilder = async ( const builder = TransactionBuilder.make() .setFeePayer(payer) .setContext({ mintSigner: mint, tokenAddress }) - .addTxPriorityFeeIx(convergence) // Create the Mint account. .add(createMintBuilder) @@ -284,6 +284,7 @@ export const createTokenWithMintBuilder = async ( // Create the Token account. .add(createTokenBuilder); + await addComputeBudgetIxsIfNeeded(builder, convergence); // Potentially mint the initial supply to the token account. if (!!initialSupply) { if (!isSigner(mintAuthority)) { diff --git a/packages/js/src/plugins/tokenModule/operations/freezeTokens.ts b/packages/js/src/plugins/tokenModule/operations/freezeTokens.ts index a54470d2c..ec6d060d5 100644 --- a/packages/js/src/plugins/tokenModule/operations/freezeTokens.ts +++ b/packages/js/src/plugins/tokenModule/operations/freezeTokens.ts @@ -16,6 +16,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'FreezeTokensOperation' as const; @@ -100,11 +101,12 @@ export const freezeTokensOperationHandler: OperationHandler { - return freezeTokensBuilder( + const builder = await freezeTokensBuilder( convergence, operation.input, scope - ).sendAndConfirm(convergence, scope.confirmOptions); + ); + return builder.sendAndConfirm(convergence, scope.confirmOptions); }, }; @@ -134,11 +136,11 @@ export type FreezeTokensBuilderParams = Omit< * @group Transaction Builders * @category Constructors */ -export const freezeTokensBuilder = ( +export const freezeTokensBuilder = async ( convergence: Convergence, params: FreezeTokensBuilderParams, options: TransactionBuilderOptions = {} -): TransactionBuilder => { +): Promise => { const { programs, payer = convergence.rpc().getDefaultFeePayer() } = options; const { mintAddress, @@ -161,9 +163,8 @@ export const freezeTokensBuilder = ( programs, }); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createFreezeAccountInstruction( tokenAddressOrAta, @@ -175,4 +176,7 @@ export const freezeTokensBuilder = ( signers, key: params.instructionKey ?? 'freezeTokens', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/tokenModule/operations/mintTokens.ts b/packages/js/src/plugins/tokenModule/operations/mintTokens.ts index 0479fc293..29aa2d696 100644 --- a/packages/js/src/plugins/tokenModule/operations/mintTokens.ts +++ b/packages/js/src/plugins/tokenModule/operations/mintTokens.ts @@ -18,6 +18,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; // ----------------- // Operation @@ -231,39 +232,38 @@ export const mintTokensBuilder = async ( programs, }); - return ( - TransactionBuilder.make() - .addTxPriorityFeeIx(convergence) - // Create token account if missing. - .add( - await convergence - .tokens() - .builders() - .createTokenIfMissing( - { - ...params, - mint: mintAddress, - owner: toOwner, - token: toToken, - tokenExists: toTokenExists, - tokenVariable: 'toToken', - }, - { payer, programs } - ) - ) + const txBuilder = TransactionBuilder.make() + // Create token account if missing. + .add( + await convergence + .tokens() + .builders() + .createTokenIfMissing( + { + ...params, + mint: mintAddress, + owner: toOwner, + token: toToken, + tokenExists: toTokenExists, + tokenVariable: 'toToken', + }, + { payer, programs } + ) + ) - // Mint tokens. - .add({ - instruction: createMintToInstruction( - mintAddress, - toPublicKey(destination), - mintAuthorityPublicKey, - amount.basisPoints.toNumber(), - multiSigners, - tokenProgram.address - ), - signers, - key: params.mintTokensInstructionKey ?? 'mintTokens', - }) - ); + // Mint tokens. + .add({ + instruction: createMintToInstruction( + mintAddress, + toPublicKey(destination), + mintAuthorityPublicKey, + amount.basisPoints.toNumber(), + multiSigners, + tokenProgram.address + ), + signers, + key: params.mintTokensInstructionKey ?? 'mintTokens', + }); + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/tokenModule/operations/revokeTokenDelegateAuthority.ts b/packages/js/src/plugins/tokenModule/operations/revokeTokenDelegateAuthority.ts index 3b48bfc7f..8c773a0b1 100644 --- a/packages/js/src/plugins/tokenModule/operations/revokeTokenDelegateAuthority.ts +++ b/packages/js/src/plugins/tokenModule/operations/revokeTokenDelegateAuthority.ts @@ -16,6 +16,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'RevokeTokenDelegateAuthorityOperation' as const; @@ -97,11 +98,12 @@ export const revokeTokenDelegateAuthorityOperationHandler: OperationHandler => { - return revokeTokenDelegateAuthorityBuilder( + const builder = await revokeTokenDelegateAuthorityBuilder( convergence, operation.input, scope - ).sendAndConfirm(convergence, scope.confirmOptions); + ); + return builder.sendAndConfirm(convergence, scope.confirmOptions); }, }; @@ -134,11 +136,11 @@ export type RevokeTokenDelegateAuthorityBuilderParams = Omit< * @group Transaction Builders * @category Constructors */ -export const revokeTokenDelegateAuthorityBuilder = ( +export const revokeTokenDelegateAuthorityBuilder = async ( convergence: Convergence, params: RevokeTokenDelegateAuthorityBuilderParams, options: TransactionBuilderOptions = {} -): TransactionBuilder => { +): Promise => { const { programs, payer = convergence.rpc().getDefaultFeePayer() } = options; const { mintAddress, @@ -160,9 +162,8 @@ export const revokeTokenDelegateAuthorityBuilder = ( programs, }); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createRevokeInstruction( tokenAccount, @@ -173,4 +174,7 @@ export const revokeTokenDelegateAuthorityBuilder = ( signers, key: params.instructionKey ?? 'revokeDelegateAuthority', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/tokenModule/operations/sendTokens.ts b/packages/js/src/plugins/tokenModule/operations/sendTokens.ts index 9a3c23663..a8d3cdd87 100644 --- a/packages/js/src/plugins/tokenModule/operations/sendTokens.ts +++ b/packages/js/src/plugins/tokenModule/operations/sendTokens.ts @@ -18,6 +18,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'SendTokensOperation' as const; @@ -257,40 +258,39 @@ export const sendTokensBuilder = async ( programs, }); - return ( - TransactionBuilder.make() - .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) - // Create token account if missing. - .add( - await convergence - .tokens() - .builders() - .createTokenIfMissing( - { - ...params, - mint: mintAddress, - owner: toOwner, - token: toToken, - tokenExists: toTokenExists, - tokenVariable: 'toToken', - }, - { programs, payer } - ) - ) + const txBuilder = TransactionBuilder.make() + .setFeePayer(payer) + // Create token account if missing. + .add( + await convergence + .tokens() + .builders() + .createTokenIfMissing( + { + ...params, + mint: mintAddress, + owner: toOwner, + token: toToken, + tokenExists: toTokenExists, + tokenVariable: 'toToken', + }, + { programs, payer } + ) + ) - // Transfer tokens. - .add({ - instruction: createTransferInstruction( - source, - toPublicKey(destination), - delegateAuthority ? delegateAuthority.publicKey : fromOwnerPublicKey, - amount.basisPoints.toNumber(), - fromMultiSigners, - tokenProgram.address - ), - signers, - key: params.transferTokensInstructionKey ?? 'transferTokens', - }) - ); + // Transfer tokens. + .add({ + instruction: createTransferInstruction( + source, + toPublicKey(destination), + delegateAuthority ? delegateAuthority.publicKey : fromOwnerPublicKey, + amount.basisPoints.toNumber(), + fromMultiSigners, + tokenProgram.address + ), + signers, + key: params.transferTokensInstructionKey ?? 'transferTokens', + }); + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/tokenModule/operations/thawTokens.ts b/packages/js/src/plugins/tokenModule/operations/thawTokens.ts index 8eebd8d22..bdff0bf3a 100644 --- a/packages/js/src/plugins/tokenModule/operations/thawTokens.ts +++ b/packages/js/src/plugins/tokenModule/operations/thawTokens.ts @@ -16,6 +16,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '../../../utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'ThawTokensOperation' as const; @@ -100,11 +101,12 @@ export const thawTokensOperationHandler: OperationHandler = convergence: Convergence, scope: OperationScope ): Promise { - return thawTokensBuilder( + const builder = await thawTokensBuilder( convergence, operation.input, scope - ).sendAndConfirm(convergence, scope.confirmOptions); + ); + return builder.sendAndConfirm(convergence, scope.confirmOptions); }, }; @@ -134,11 +136,11 @@ export type ThawTokensBuilderParams = Omit< * @group Transaction Builders * @category Constructors */ -export const thawTokensBuilder = ( +export const thawTokensBuilder = async ( convergence: Convergence, params: ThawTokensBuilderParams, options: TransactionBuilderOptions = {} -): TransactionBuilder => { +): Promise => { const { programs, payer = convergence.rpc().getDefaultFeePayer() } = options; const { mintAddress, @@ -161,9 +163,8 @@ export const thawTokensBuilder = ( programs, }); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createThawAccountInstruction( tokenAddressOrAta, @@ -175,4 +176,7 @@ export const thawTokensBuilder = ( signers, key: params.instructionKey ?? 'thawTokens', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/vaultOperatorModule/operations/confirmAndPrepareVault.ts b/packages/js/src/plugins/vaultOperatorModule/operations/confirmAndPrepareVault.ts index a7b2e15a5..6f21c5429 100644 --- a/packages/js/src/plugins/vaultOperatorModule/operations/confirmAndPrepareVault.ts +++ b/packages/js/src/plugins/vaultOperatorModule/operations/confirmAndPrepareVault.ts @@ -22,6 +22,7 @@ import { EscrowRfq, getEscrowPrepareSettlementRemainingAccounts, } from '@/plugins/rfqModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'ConfirmAndPrepareVaultOperation' as const; @@ -155,9 +156,10 @@ export const confirmAndPrepareVaultBuilder = async ( const builder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(cvg) .add(confirmIx, prepareIx); + await addComputeBudgetIxsIfNeeded(builder, cvg); + return { builder, vault: { diff --git a/packages/js/src/plugins/vaultOperatorModule/operations/createVault.ts b/packages/js/src/plugins/vaultOperatorModule/operations/createVault.ts index c9b1d0487..78d04ca5f 100644 --- a/packages/js/src/plugins/vaultOperatorModule/operations/createVault.ts +++ b/packages/js/src/plugins/vaultOperatorModule/operations/createVault.ts @@ -36,6 +36,7 @@ import { } from '@/plugins/rfqModule'; import { addDecimals, getOrCreateATAtxBuilder } from '@/utils'; import { Mint } from '@/plugins/tokenModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CreateVaultOperation' as const; @@ -226,7 +227,6 @@ export const createVaultBuilder = async ( const builder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(cvg) .add(transferLamportIx, { instruction: createCreateRfqInstruction( { @@ -273,6 +273,7 @@ export const createVaultBuilder = async ( if (receivedAtaBuilder !== undefined) { ataBuilder.add(receivedAtaBuilder); } + await addComputeBudgetIxsIfNeeded(builder, cvg); return { builder, diff --git a/packages/js/src/plugins/vaultOperatorModule/operations/withdrawVaultTokens.ts b/packages/js/src/plugins/vaultOperatorModule/operations/withdrawVaultTokens.ts index 8de3f4235..650176cbd 100644 --- a/packages/js/src/plugins/vaultOperatorModule/operations/withdrawVaultTokens.ts +++ b/packages/js/src/plugins/vaultOperatorModule/operations/withdrawVaultTokens.ts @@ -14,6 +14,7 @@ import { } from '../../../utils/TransactionBuilder'; import { VaultParameters } from '../models'; import { EscrowRfq } from '@/plugins/rfqModule'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'WithdrawVaultTokensOperation' as const; @@ -108,8 +109,8 @@ export const withdrawVaultTokensBuilder = async ( key: 'withdrawVaultTokens', }; - return TransactionBuilder.make() - .setFeePayer(payer) - .addTxPriorityFeeIx(cvg) - .add(ix); + const txBuilder = TransactionBuilder.make().setFeePayer(payer).add(ix); + + await addComputeBudgetIxsIfNeeded(txBuilder, cvg); + return txBuilder; }; diff --git a/packages/js/src/plugins/whitelistModule/operations/cleanupWhitelist.ts b/packages/js/src/plugins/whitelistModule/operations/cleanupWhitelist.ts index 36daf2dd0..4bd69e696 100644 --- a/packages/js/src/plugins/whitelistModule/operations/cleanupWhitelist.ts +++ b/packages/js/src/plugins/whitelistModule/operations/cleanupWhitelist.ts @@ -14,6 +14,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '@/utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CleanUpWhitelistOperation' as const; @@ -123,9 +124,8 @@ export const cleanUpWhitelistBuilder = async ( const systemProgram = convergence.programs().getSystem(programs); const rfqProgram = convergence.programs().getRfq(programs); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCleanUpWhitelistInstruction( { @@ -139,4 +139,8 @@ export const cleanUpWhitelistBuilder = async ( signers: [creator], key: 'CleanUpWhitelist', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + + return txBuilder; }; diff --git a/packages/js/src/plugins/whitelistModule/operations/createWhitelist.ts b/packages/js/src/plugins/whitelistModule/operations/createWhitelist.ts index dab4b138d..ebf568899 100644 --- a/packages/js/src/plugins/whitelistModule/operations/createWhitelist.ts +++ b/packages/js/src/plugins/whitelistModule/operations/createWhitelist.ts @@ -14,6 +14,7 @@ import { TransactionBuilder, TransactionBuilderOptions, } from '@/utils/TransactionBuilder'; +import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers'; const Key = 'CreateWhitelistOperation' as const; @@ -136,9 +137,8 @@ export const createWhitelistBuilder = async ( const systemProgram = convergence.programs().getSystem(programs); const rfqProgram = convergence.programs().getRfq(programs); - return TransactionBuilder.make() + const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .addTxPriorityFeeIx(convergence) .add({ instruction: createCreateWhitelistInstruction( { @@ -154,4 +154,7 @@ export const createWhitelistBuilder = async ( signers: [whitelistKeypair, payer], key: 'CreateWhitelist', }); + + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/utils/helpers.ts b/packages/js/src/utils/helpers.ts index 776caddbb..781a285c4 100644 --- a/packages/js/src/utils/helpers.ts +++ b/packages/js/src/utils/helpers.ts @@ -92,8 +92,8 @@ export const getComputeUnitsToBeConsumed = async ( } }; -export const addComputeBudgetIxsIfNeeded = async ( - txBuilder: TransactionBuilder, +export const addComputeBudgetIxsIfNeeded = async ( + txBuilder: TransactionBuilder, convergence: Convergence ) => { const computeUnitsConsumed = await getComputeUnitsToBeConsumed( From beb9abdec45d1184e18bb3c8fd4d4be146ba4041 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 24 Apr 2024 21:35:10 +0530 Subject: [PATCH 07/20] fix errors --- packages/js/src/Convergence.ts | 2 +- packages/js/src/constants.ts | 12 +++-- .../operations/fundCollateral.ts | 3 +- .../helpers.ts | 9 ++-- .../helpers.ts | 9 ++-- .../rfqModule/operations/confirmResponse.ts | 52 ++++++++----------- .../operations/finalizeRfqConstruction.ts | 8 +-- .../operations/prepareMoreLegsSettlement.ts | 13 +---- .../rfqModule/operations/prepareSettlement.ts | 8 ++- .../rfqModule/operations/respondToRfq.ts | 8 +-- .../plugins/rfqModule/operations/settle.ts | 8 +-- .../operations/createVault.ts | 2 +- packages/js/src/utils/TransactionBuilder.ts | 39 +++++++++++--- packages/js/src/utils/helpers.ts | 24 +++++---- packages/js/tests/helpers.ts | 2 +- packages/js/tests/integration/spot.spec.ts | 1 - 16 files changed, 108 insertions(+), 92 deletions(-) diff --git a/packages/js/src/Convergence.ts b/packages/js/src/Convergence.ts index 3108eff55..c478770ff 100644 --- a/packages/js/src/Convergence.ts +++ b/packages/js/src/Convergence.ts @@ -23,7 +23,7 @@ export class Convergence { this.connection = connection; this.cluster = options.cluster ?? resolveClusterFromConnection(connection); this.skipPreflight = options.skipPreflight ?? false; - this.transactionPriority = options.transactionPriority ?? 'none'; + this.transactionPriority = options.transactionPriority ?? 'normal'; this.use(corePlugins()); } diff --git a/packages/js/src/constants.ts b/packages/js/src/constants.ts index d10e05e65..b0cfca102 100644 --- a/packages/js/src/constants.ts +++ b/packages/js/src/constants.ts @@ -1,8 +1,12 @@ -export const TRANSACTION_PRIORITY_FEE_MAP = { +export const COMPUTE_UNIT_PRICE_IN_MICRO_LAMPORTS_MAP = { none: 0, - normal: 0.005, - high: 0.015, - turbo: 0.025, + normal: 5000, + high: 15000, + turbo: 25000, }; export const HXRO_COLLATERAL_LOG_INDEX = 7; + +export const DEFAULT_COMPUTE_UNITS = 200_000; + +export const DEFAULT_COMPUTE_UNIT_PRICE = 5000; diff --git a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts index de7455733..4ceca3369 100644 --- a/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts +++ b/packages/js/src/plugins/collateralModule/operations/fundCollateral.ts @@ -178,5 +178,6 @@ export const fundCollateralBuilder = async ( signers: [user], key: 'fundCollateral', }); - return await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + return txBuilder; }; diff --git a/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts b/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts index a1ba76f8e..f2beef100 100644 --- a/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts +++ b/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts @@ -107,9 +107,12 @@ export const prepareAmericanOptions = async ( isSigner: true, isWritable: false, }; - const mintTxBuilder = TransactionBuilder.make().setFeePayer( - convergence.rpc().getDefaultFeePayer() - ); + const mintTxBuilder = TransactionBuilder.make() + .setFeePayer(convergence.rpc().getDefaultFeePayer()) + .add({ + instruction: ixWithSigners.ix, + signers: [convergence.identity()], + }); await addComputeBudgetIxsIfNeeded(mintTxBuilder, convergence); mintTxBuilderArray.push(mintTxBuilder); diff --git a/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts b/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts index 9c5d095d5..8bee31121 100644 --- a/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts +++ b/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts @@ -120,9 +120,12 @@ export const prepareEuropeanOptions = async ( isWritable: false, }; - const mintTxBuilder = TransactionBuilder.make().setFeePayer( - convergence.rpc().getDefaultFeePayer() - ); + const mintTxBuilder = TransactionBuilder.make() + .setFeePayer(convergence.rpc().getDefaultFeePayer()) + .add({ + instruction: ix, + signers: [convergence.identity()], + }); await addComputeBudgetIxsIfNeeded(mintTxBuilder, convergence); mintTxBuilderArray.push(mintTxBuilder); diff --git a/packages/js/src/plugins/rfqModule/operations/confirmResponse.ts b/packages/js/src/plugins/rfqModule/operations/confirmResponse.ts index c5f8b2f28..59f15014f 100644 --- a/packages/js/src/plugins/rfqModule/operations/confirmResponse.ts +++ b/packages/js/src/plugins/rfqModule/operations/confirmResponse.ts @@ -1,5 +1,5 @@ import { createConfirmResponseInstruction } from '@convergence-rfq/rfq'; -import { PublicKey, ComputeBudgetProgram } from '@solana/web3.js'; +import { PublicKey } from '@solana/web3.js'; import { SendAndConfirmTransactionResponse } from '../../rpcModule'; import { Convergence } from '../../../Convergence'; @@ -202,35 +202,27 @@ export const confirmResponseBuilder = async ( return TransactionBuilder.make() .setFeePayer(payer) - .add( - { - instruction: ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, - }), - signers: [], - }, - { - instruction: createConfirmResponseInstruction( - { - rfq, - response, - collateralInfo, - makerCollateralInfo, - collateralToken, - taker: taker.publicKey, - protocol: convergence.protocol().pdas().protocol(), - riskEngine: convergence.programs().getRiskEngine(programs).address, - }, - { - side: toSolitaQuoteSide(side), - overrideLegMultiplierBps, - }, - convergence.programs().getRfq(programs).address - ), - signers: [taker], - key: 'confirmResponse', - } - ); + .add({ + instruction: createConfirmResponseInstruction( + { + rfq, + response, + collateralInfo, + makerCollateralInfo, + collateralToken, + taker: taker.publicKey, + protocol: convergence.protocol().pdas().protocol(), + riskEngine: convergence.programs().getRiskEngine(programs).address, + }, + { + side: toSolitaQuoteSide(side), + overrideLegMultiplierBps, + }, + convergence.programs().getRfq(programs).address + ), + signers: [taker], + key: 'confirmResponse', + }); }; const isResponseExpired = (response: Response): boolean => { diff --git a/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts b/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts index 2af86acd2..fb0585e47 100644 --- a/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts +++ b/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts @@ -1,5 +1,5 @@ import { createFinalizeRfqConstructionInstruction } from '@convergence-rfq/rfq'; -import { PublicKey, ComputeBudgetProgram } from '@solana/web3.js'; +import { PublicKey } from '@solana/web3.js'; import { SendAndConfirmTransactionResponse } from '../../rpcModule'; import { assertRfq, Rfq } from '../models'; @@ -205,12 +205,6 @@ export const finalizeRfqConstructionBuilder = async ( .setContext({ rfq, }) - .add({ - instruction: ComputeBudgetProgram.setComputeUnitLimit({ - units: 1400000, - }), - signers: [], - }) .add({ instruction: createFinalizeRfqConstructionInstruction( { diff --git a/packages/js/src/plugins/rfqModule/operations/prepareMoreLegsSettlement.ts b/packages/js/src/plugins/rfqModule/operations/prepareMoreLegsSettlement.ts index 49c947185..a06f6d593 100644 --- a/packages/js/src/plugins/rfqModule/operations/prepareMoreLegsSettlement.ts +++ b/packages/js/src/plugins/rfqModule/operations/prepareMoreLegsSettlement.ts @@ -1,9 +1,4 @@ -import { - PublicKey, - AccountMeta, - SYSVAR_RENT_PUBKEY, - ComputeBudgetProgram, -} from '@solana/web3.js'; +import { PublicKey, AccountMeta, SYSVAR_RENT_PUBKEY } from '@solana/web3.js'; import { createPrepareMoreEscrowLegsSettlementInstruction, AuthoritySide, @@ -257,12 +252,6 @@ export const prepareMoreLegsSettlementBuilder = async ( const txBuilder = TransactionBuilder.make() .setFeePayer(payer) - .add({ - instruction: ComputeBudgetProgram.setComputeUnitLimit({ - units: 1400000, - }), - signers: [], - }) .add({ instruction: createPrepareMoreEscrowLegsSettlementInstruction( { diff --git a/packages/js/src/plugins/rfqModule/operations/prepareSettlement.ts b/packages/js/src/plugins/rfqModule/operations/prepareSettlement.ts index 7f133e977..1379f1f12 100644 --- a/packages/js/src/plugins/rfqModule/operations/prepareSettlement.ts +++ b/packages/js/src/plugins/rfqModule/operations/prepareSettlement.ts @@ -323,7 +323,7 @@ export const prepareSettlementBuilder = async ( .setFeePayer(payer) .add({ instruction: ComputeBudgetProgram.setComputeUnitLimit({ - units: 1400000, + units: 300000, }), signers: [], }) @@ -346,7 +346,11 @@ export const prepareSettlementBuilder = async ( key: 'prepareSettlement', }); - await addComputeBudgetIxsIfNeeded(prepareSettlementTxBuilder, convergence); + await addComputeBudgetIxsIfNeeded( + prepareSettlementTxBuilder, + convergence, + true + ); return { ataTxBuilderArray, prepareSettlementTxBuilder, diff --git a/packages/js/src/plugins/rfqModule/operations/respondToRfq.ts b/packages/js/src/plugins/rfqModule/operations/respondToRfq.ts index e59f3ecb0..db8764c04 100644 --- a/packages/js/src/plugins/rfqModule/operations/respondToRfq.ts +++ b/packages/js/src/plugins/rfqModule/operations/respondToRfq.ts @@ -1,5 +1,5 @@ import { createRespondToRfqInstruction } from '@convergence-rfq/rfq'; -import { PublicKey, ComputeBudgetProgram, AccountMeta } from '@solana/web3.js'; +import { PublicKey, AccountMeta } from '@solana/web3.js'; import BN from 'bn.js'; import { SendAndConfirmTransactionResponse } from '../../rpcModule'; @@ -299,12 +299,6 @@ export const respondToRfqBuilder = async ( .setContext({ response, }) - .add({ - instruction: ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, - }), - signers: [], - }) .add({ instruction: createRespondToRfqInstruction( { diff --git a/packages/js/src/plugins/rfqModule/operations/settle.ts b/packages/js/src/plugins/rfqModule/operations/settle.ts index 6fedb3a05..7747b6624 100644 --- a/packages/js/src/plugins/rfqModule/operations/settle.ts +++ b/packages/js/src/plugins/rfqModule/operations/settle.ts @@ -277,7 +277,7 @@ export const settleEscrowBuilder = async ( .setFeePayer(payer) .add({ instruction: ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, + units: 300000, }), signers: [], }) @@ -294,7 +294,7 @@ export const settleEscrowBuilder = async ( signers: [], key: 'settle', }); - await addComputeBudgetIxsIfNeeded(settleTxBuilder, cvg); + await addComputeBudgetIxsIfNeeded(settleTxBuilder, cvg, true); return { ataTxBuilderArray, settleTxBuilder, @@ -467,7 +467,7 @@ export const settlePrintTradeBuilder = async ( .add( { instruction: ComputeBudgetProgram.setComputeUnitLimit({ - units: 1_400_000, + units: 300000, }), signers: [], }, @@ -485,7 +485,7 @@ export const settlePrintTradeBuilder = async ( key: 'settle', } ); - + await addComputeBudgetIxsIfNeeded(settleTxBuilder, convergence, true); return { ataTxBuilderArray: [], settleTxBuilder, diff --git a/packages/js/src/plugins/vaultOperatorModule/operations/createVault.ts b/packages/js/src/plugins/vaultOperatorModule/operations/createVault.ts index 78d04ca5f..67bfec4e7 100644 --- a/packages/js/src/plugins/vaultOperatorModule/operations/createVault.ts +++ b/packages/js/src/plugins/vaultOperatorModule/operations/createVault.ts @@ -273,7 +273,7 @@ export const createVaultBuilder = async ( if (receivedAtaBuilder !== undefined) { ataBuilder.add(receivedAtaBuilder); } - await addComputeBudgetIxsIfNeeded(builder, cvg); + await addComputeBudgetIxsIfNeeded(builder, cvg, true); return { builder, diff --git a/packages/js/src/utils/TransactionBuilder.ts b/packages/js/src/utils/TransactionBuilder.ts index 5f8a1bad9..4d49a0f83 100644 --- a/packages/js/src/utils/TransactionBuilder.ts +++ b/packages/js/src/utils/TransactionBuilder.ts @@ -11,7 +11,7 @@ import { import { SendAndConfirmTransactionResponse } from '../plugins/rpcModule'; import type { Convergence } from '../Convergence'; import type { OperationOptions, Signer } from '../types'; -import { TRANSACTION_PRIORITY_FEE_MAP } from '../constants'; +import { COMPUTE_UNIT_PRICE_IN_MICRO_LAMPORTS_MAP } from '../constants'; export const DUMMY_BLOCKHASH = 'H9cCgV1suCbdxMGDGUecdgJPZzdCe4CbNYa6ijP1uBLS'; @@ -296,17 +296,32 @@ export class TransactionBuilder { }; } - addStaticComputeBudgetIxs(convergence: Convergence, computeUnits: number) { + addStaticComputeBudgetIxs( + convergence: Convergence, + computeUnits: number, + disableSettingComputeUnits?: boolean + ) { if (convergence.transactionPriority === 'dynamic') { return this; } - const txPriorityInLamports = + const txPriorityInMicroLamports = typeof convergence.transactionPriority === 'number' ? convergence.transactionPriority - : TRANSACTION_PRIORITY_FEE_MAP[convergence.transactionPriority]; + : COMPUTE_UNIT_PRICE_IN_MICRO_LAMPORTS_MAP[ + convergence.transactionPriority + ]; + + if (disableSettingComputeUnits) { + return this.prepend({ + instruction: ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: txPriorityInMicroLamports, + }), + signers: [], + }); + } return this.prepend({ instruction: ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: txPriorityInLamports * Math.pow(10, 6), + microLamports: txPriorityInMicroLamports, }), signers: [], }).prepend({ @@ -317,7 +332,19 @@ export class TransactionBuilder { }); } - addDynamicComputeBudgetIxs(microLamports: number, computeUnits: number) { + addDynamicComputeBudgetIxs( + microLamports: number, + computeUnits: number, + disableSettingComputeUnits?: boolean + ) { + if (disableSettingComputeUnits) { + return this.prepend({ + instruction: ComputeBudgetProgram.setComputeUnitPrice({ + microLamports, + }), + signers: [], + }); + } return this.prepend({ instruction: ComputeBudgetProgram.setComputeUnitPrice({ microLamports, diff --git a/packages/js/src/utils/helpers.ts b/packages/js/src/utils/helpers.ts index 781a285c4..7b159a391 100644 --- a/packages/js/src/utils/helpers.ts +++ b/packages/js/src/utils/helpers.ts @@ -6,6 +6,7 @@ import { } from '@solana/web3.js'; import { TransactionBuilder } from './TransactionBuilder'; import { Convergence } from '@/Convergence'; +import { DEFAULT_COMPUTE_UNITS, DEFAULT_COMPUTE_UNIT_PRICE } from '@/constants'; type EstimatedPriorityFee = { microLamports: number; @@ -42,7 +43,6 @@ export const getEstimatedPriorityFee = async ( microLamports: avgPriorityFee, }; } catch (error) { - console.error(error); return null; } }; @@ -87,21 +87,21 @@ export const getComputeUnitsToBeConsumed = async ( unitsConsumed, }; } catch (error) { - console.error(error); return null; } }; export const addComputeBudgetIxsIfNeeded = async ( txBuilder: TransactionBuilder, - convergence: Convergence + convergence: Convergence, + disableSettingComputeUnits?: boolean ) => { - const computeUnitsConsumed = await getComputeUnitsToBeConsumed( + let computeUnitsConsumed = await getComputeUnitsToBeConsumed( txBuilder, convergence.connection ); if (!computeUnitsConsumed) { - return txBuilder; + computeUnitsConsumed = { unitsConsumed: DEFAULT_COMPUTE_UNITS }; } if (convergence.transactionPriority === 'dynamic') { const estimatedFee = await getEstimatedPriorityFee( @@ -110,17 +110,23 @@ export const addComputeBudgetIxsIfNeeded = async ( ); if (!estimatedFee) { - return txBuilder; + txBuilder.addDynamicComputeBudgetIxs( + DEFAULT_COMPUTE_UNIT_PRICE, + computeUnitsConsumed.unitsConsumed, + disableSettingComputeUnits + ); + return; } txBuilder.addDynamicComputeBudgetIxs( estimatedFee.microLamports, - computeUnitsConsumed.unitsConsumed + computeUnitsConsumed.unitsConsumed, + disableSettingComputeUnits ); } else { txBuilder.addStaticComputeBudgetIxs( convergence, - computeUnitsConsumed.unitsConsumed + computeUnitsConsumed.unitsConsumed, + disableSettingComputeUnits ); } - return txBuilder; }; diff --git a/packages/js/tests/helpers.ts b/packages/js/tests/helpers.ts index 7fa1d6915..df4aaf705 100644 --- a/packages/js/tests/helpers.ts +++ b/packages/js/tests/helpers.ts @@ -42,7 +42,7 @@ export const createCvg = (options: ConvergenceTestOptions = {}) => { }); return Convergence.make(connection, { skipPreflight: options.skipPreflight, - transactionPriority: 'normal', + transactionPriority: 'dynamic', }); }; diff --git a/packages/js/tests/integration/spot.spec.ts b/packages/js/tests/integration/spot.spec.ts index f640db3e4..90177e0a9 100644 --- a/packages/js/tests/integration/spot.spec.ts +++ b/packages/js/tests/integration/spot.spec.ts @@ -15,7 +15,6 @@ import { DAO_PK, MAKER_PK, QUOTE_MINT_PK, - TAKER_PK, TESTING_PK, } from '../constants'; From 884f61f3e387b16aefaa6613604d92bfed7573b1 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 24 Apr 2024 22:06:07 +0530 Subject: [PATCH 08/20] add changeset --- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 4 ++-- packages/js/CHANGELOG.md | 6 ++++++ packages/js/package.json | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index e62b8e457..060c16a5c 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.6 + +### Patch Changes + +- ComputeUnits Improvement and implement dynamic Priority fee +- Updated dependencies + - @convergence-rfq/sdk@6.6.6 + ## 6.6.5 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index bae372bc8..ff2ce4651 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/cli", "description": "Official Convergence CLI", - "version": "6.6.5", + "version": "6.6.6", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.5", + "@convergence-rfq/sdk": "6.6.6", "@solana/web3.js": "^1.87.6", "@types/cookie": "^0.5.1", "commander": "^10.0.0" diff --git a/packages/js/CHANGELOG.md b/packages/js/CHANGELOG.md index 343d934ab..32733f4ee 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.6 + +### Patch Changes + +- ComputeUnits Improvement and implement dynamic Priority fee + ## 6.6.5 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index b03310022..31cd52015 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/sdk", "description": "Official Convergence RFQ SDK", - "version": "6.6.5", + "version": "6.6.6", "license": "MIT", "publishConfig": { "access": "public" From 0f5bfee98ffa0a2fed9bce1f9361da4b9588865f Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Thu, 25 Apr 2024 15:41:00 +0530 Subject: [PATCH 09/20] fix finalizeRFQConstruction cu --- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 4 ++-- packages/cli/src/cvg.ts | 1 - packages/cli/src/helpers.ts | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 060c16a5c..292fd4b10 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.7 + +### Patch Changes + +- Add Offset of 1000 CUs to simulates CUs +- Updated dependencies + - @convergence-rfq/sdk@6.6.7 + ## 6.6.6 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index ff2ce4651..f80ffb263 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/cli", "description": "Official Convergence CLI", - "version": "6.6.6", + "version": "6.6.7", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.6", + "@convergence-rfq/sdk": "6.6.7", "@solana/web3.js": "^1.87.6", "@types/cookie": "^0.5.1", "commander": "^10.0.0" diff --git a/packages/cli/src/cvg.ts b/packages/cli/src/cvg.ts index e570dfd85..14dfb33e0 100644 --- a/packages/cli/src/cvg.ts +++ b/packages/cli/src/cvg.ts @@ -9,7 +9,6 @@ export const createCvg = async (opts: Opts): Promise => { const buffer = JSON.parse(readFileSync(opts.keypairFile, 'utf8')); const user = Keypair.fromSecretKey(new Uint8Array(buffer)); const txPriorityString: string = opts.txPriorityFee; - const txPriority = resolveTxPriorityArg(txPriorityString); const cvg = new Convergence( new Connection(opts.rpcEndpoint, { diff --git a/packages/cli/src/helpers.ts b/packages/cli/src/helpers.ts index c2f939bb6..9e5e9454c 100644 --- a/packages/cli/src/helpers.ts +++ b/packages/cli/src/helpers.ts @@ -160,6 +160,8 @@ export const resolveTxPriorityArg = ( txPriority: string ): TransactionPriority => { switch (txPriority) { + case 'dynamic': + return 'dynamic'; case 'none': return 'none'; case 'normal': From 06f9f104ab22edb7ff07a6167c8bcf83bfef587d Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Thu, 25 Apr 2024 15:41:13 +0530 Subject: [PATCH 10/20] fix finalizeRFQConstruction cu --- packages/js/CHANGELOG.md | 6 ++++++ packages/js/package.json | 2 +- packages/js/src/constants.ts | 2 ++ .../rfqModule/operations/finalizeRfqConstruction.ts | 10 ++++++++-- packages/js/src/utils/helpers.ts | 9 +++++++-- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/js/CHANGELOG.md b/packages/js/CHANGELOG.md index 32733f4ee..f1894c3b8 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.7 + +### Patch Changes + +- Add Offset of 1000 CUs to simulates CUs + ## 6.6.6 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index 31cd52015..92fc8b008 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/sdk", "description": "Official Convergence RFQ SDK", - "version": "6.6.6", + "version": "6.6.7", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/js/src/constants.ts b/packages/js/src/constants.ts index b0cfca102..82934db11 100644 --- a/packages/js/src/constants.ts +++ b/packages/js/src/constants.ts @@ -10,3 +10,5 @@ export const HXRO_COLLATERAL_LOG_INDEX = 7; export const DEFAULT_COMPUTE_UNITS = 200_000; export const DEFAULT_COMPUTE_UNIT_PRICE = 5000; + +export const DEFAULT_COMPUTE_UNITS_OFFSET = 1000; diff --git a/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts b/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts index fb0585e47..bd84970d7 100644 --- a/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts +++ b/packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts @@ -1,5 +1,5 @@ import { createFinalizeRfqConstructionInstruction } from '@convergence-rfq/rfq'; -import { PublicKey } from '@solana/web3.js'; +import { ComputeBudgetProgram, PublicKey } from '@solana/web3.js'; import { SendAndConfirmTransactionResponse } from '../../rpcModule'; import { assertRfq, Rfq } from '../models'; @@ -205,6 +205,12 @@ export const finalizeRfqConstructionBuilder = async ( .setContext({ rfq, }) + .add({ + instruction: ComputeBudgetProgram.setComputeUnitLimit({ + units: 300000, + }), + signers: [], + }) .add({ instruction: createFinalizeRfqConstructionInstruction( { @@ -221,6 +227,6 @@ export const finalizeRfqConstructionBuilder = async ( key: 'finalizeRfqConstruction', }); - await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + await addComputeBudgetIxsIfNeeded(txBuilder, convergence, true); return txBuilder; }; diff --git a/packages/js/src/utils/helpers.ts b/packages/js/src/utils/helpers.ts index 7b159a391..b9ae10906 100644 --- a/packages/js/src/utils/helpers.ts +++ b/packages/js/src/utils/helpers.ts @@ -6,7 +6,11 @@ import { } from '@solana/web3.js'; import { TransactionBuilder } from './TransactionBuilder'; import { Convergence } from '@/Convergence'; -import { DEFAULT_COMPUTE_UNITS, DEFAULT_COMPUTE_UNIT_PRICE } from '@/constants'; +import { + DEFAULT_COMPUTE_UNITS, + DEFAULT_COMPUTE_UNITS_OFFSET, + DEFAULT_COMPUTE_UNIT_PRICE, +} from '@/constants'; type EstimatedPriorityFee = { microLamports: number; @@ -38,6 +42,7 @@ export const getEstimatedPriorityFee = async ( 0 ); avgPriorityFee /= recentPriorityFeeData.length; + avgPriorityFee = Math.ceil(avgPriorityFee); return { microLamports: avgPriorityFee, @@ -84,7 +89,7 @@ export const getComputeUnitsToBeConsumed = async ( throw new Error('Failed to get units consumed'); } return { - unitsConsumed, + unitsConsumed: unitsConsumed + DEFAULT_COMPUTE_UNITS_OFFSET, }; } catch (error) { return null; From 3f258eeb29bc6619fb5d2d8f09e954d59e0d0f97 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Thu, 25 Apr 2024 15:43:11 +0530 Subject: [PATCH 11/20] add chnageset --- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 4 ++-- packages/js/CHANGELOG.md | 6 ++++++ packages/js/package.json | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 292fd4b10..98fb2883c 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.8 + +### Patch Changes + +- fix FinalizeRFQCOnstruction CU limits +- Updated dependencies + - @convergence-rfq/sdk@6.6.8 + ## 6.6.7 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index f80ffb263..6e14e346a 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/cli", "description": "Official Convergence CLI", - "version": "6.6.7", + "version": "6.6.8", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.7", + "@convergence-rfq/sdk": "6.6.8", "@solana/web3.js": "^1.87.6", "@types/cookie": "^0.5.1", "commander": "^10.0.0" diff --git a/packages/js/CHANGELOG.md b/packages/js/CHANGELOG.md index f1894c3b8..c13839eb5 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.8 + +### Patch Changes + +- fix FinalizeRFQCOnstruction CU limits + ## 6.6.7 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index 92fc8b008..ee2af04ff 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/sdk", "description": "Official Convergence RFQ SDK", - "version": "6.6.7", + "version": "6.6.8", "license": "MIT", "publishConfig": { "access": "public" From 233be13d5041d0dbf11a813f955ebb7b75c539a3 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Thu, 25 Apr 2024 16:16:13 +0530 Subject: [PATCH 12/20] disable cu calculations for createRFQ txs --- .../src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts | 2 +- .../src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts | 2 +- packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts | 2 +- packages/js/src/plugins/rfqModule/operations/createRfq.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts b/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts index f2beef100..4b2a6cb1e 100644 --- a/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts +++ b/packages/js/src/plugins/psyoptionsAmericanInstrumentModule/helpers.ts @@ -113,7 +113,7 @@ export const prepareAmericanOptions = async ( instruction: ixWithSigners.ix, signers: [convergence.identity()], }); - await addComputeBudgetIxsIfNeeded(mintTxBuilder, convergence); + await addComputeBudgetIxsIfNeeded(mintTxBuilder, convergence, true); mintTxBuilderArray.push(mintTxBuilder); } diff --git a/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts b/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts index 8bee31121..2ccdaa436 100644 --- a/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts +++ b/packages/js/src/plugins/psyoptionsEuropeanInstrumentModule/helpers.ts @@ -127,7 +127,7 @@ export const prepareEuropeanOptions = async ( signers: [convergence.identity()], }); - await addComputeBudgetIxsIfNeeded(mintTxBuilder, convergence); + await addComputeBudgetIxsIfNeeded(mintTxBuilder, convergence, true); mintTxBuilderArray.push(mintTxBuilder); } diff --git a/packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts b/packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts index ad696789a..f9f63417c 100644 --- a/packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts +++ b/packages/js/src/plugins/rfqModule/operations/addLegsToRfq.ts @@ -164,6 +164,6 @@ export const addLegsToRfqBuilder = async ( key: 'addLegsToRfq', }); - await addComputeBudgetIxsIfNeeded(txBuilder, convergence); + await addComputeBudgetIxsIfNeeded(txBuilder, convergence, true); return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/createRfq.ts b/packages/js/src/plugins/rfqModule/operations/createRfq.ts index 942a2407a..f75ab5e82 100644 --- a/packages/js/src/plugins/rfqModule/operations/createRfq.ts +++ b/packages/js/src/plugins/rfqModule/operations/createRfq.ts @@ -480,7 +480,7 @@ export const createRfqBuilder = async ( const remainingLegsToAdd = instruments.slice(legsToAdd.length, legs.length); - await addComputeBudgetIxsIfNeeded(rfqBuilder, convergence); + await addComputeBudgetIxsIfNeeded(rfqBuilder, convergence, true); return { createRfqTxBuilder: rfqBuilder, From ae71843fe831c92af36ba7385ca7c55265a336c9 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Thu, 25 Apr 2024 19:28:06 +0530 Subject: [PATCH 13/20] add changeset --- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 4 ++-- packages/js/CHANGELOG.md | 6 ++++++ packages/js/package.json | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 98fb2883c..bb70905bc 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.9 + +### Patch Changes + +- Disable CU calculations for Create RFQ Txs +- Updated dependencies + - @convergence-rfq/sdk@6.6.9 + ## 6.6.8 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 6e14e346a..60ee85ef5 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/cli", "description": "Official Convergence CLI", - "version": "6.6.8", + "version": "6.6.9", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.8", + "@convergence-rfq/sdk": "6.6.9", "@solana/web3.js": "^1.87.6", "@types/cookie": "^0.5.1", "commander": "^10.0.0" diff --git a/packages/js/CHANGELOG.md b/packages/js/CHANGELOG.md index c13839eb5..32eea82b7 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.9 + +### Patch Changes + +- Disable CU calculations for Create RFQ Txs + ## 6.6.8 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index ee2af04ff..1f743e53d 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/sdk", "description": "Official Convergence RFQ SDK", - "version": "6.6.8", + "version": "6.6.9", "license": "MIT", "publishConfig": { "access": "public" From 6edff68f9efaaaab6fc6503626ab0052809c8765 Mon Sep 17 00:00:00 2001 From: Yaroslav Khodakovskij Date: Thu, 25 Apr 2024 17:03:55 +0300 Subject: [PATCH 14/20] Fix hxro sdk issue and simplify build --- packages/js/package.json | 3 ++- .../js/src/plugins/hxroPrintTradeProviderModule/cache.ts | 5 ++++- packages/js/tsconfig.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/js/package.json b/packages/js/package.json index 1f743e53d..c1b1e8abe 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -37,7 +37,8 @@ "lint": "eslint --ext js,ts,tsx src", "lint:fix": "eslint --fix --ext js,ts,tsx src", "clean": "rimraf dist", - "build": "yarn clean && tsc && tsc-alias && tsc -p tsconfig.json && tsc-alias -p tsconfig.json && rollup -c", + "build": "yarn clean && yarn build:types && rollup -c", + "build:types": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json", "test:coverage": "nyc ts-mocha --timeout 100000 tests/**/*.spec.ts", "test": "ts-mocha --paths --timeout 100000 tests/**/*.spec.ts" }, diff --git a/packages/js/src/plugins/hxroPrintTradeProviderModule/cache.ts b/packages/js/src/plugins/hxroPrintTradeProviderModule/cache.ts index 23f74050a..2ce9b8adf 100644 --- a/packages/js/src/plugins/hxroPrintTradeProviderModule/cache.ts +++ b/packages/js/src/plugins/hxroPrintTradeProviderModule/cache.ts @@ -21,7 +21,10 @@ export const hxroManifestCache = useCache(async (cvg: Convergence) => { console.debug = () => {}; let manifest: any; // dexterity doesn't export a type for a manifest try { - manifest = await dexterity.getManifest( + // @ts-ignore the next line fixes a strange issue with dexterity default export when imported from .mjs files + const getManifest = dexterity.getManifest ?? dexterity.default.getManifest; + + manifest = await getManifest( cvg.connection.rpcEndpoint, true, new CvgWallet(cvg) diff --git a/packages/js/tsconfig.json b/packages/js/tsconfig.json index 048b94ed2..9ed74755b 100644 --- a/packages/js/tsconfig.json +++ b/packages/js/tsconfig.json @@ -12,7 +12,7 @@ "esModuleInterop": true, "module": "commonjs", "declaration": true, - "emitDeclarationOnly": false, + "emitDeclarationOnly": true, "declarationDir": "dist/types", } } \ No newline at end of file From 66ede0a2ee785a312c842a5f5ae7dc84b12e3931 Mon Sep 17 00:00:00 2001 From: Yaroslav Khodakovskij Date: Thu, 25 Apr 2024 17:10:31 +0300 Subject: [PATCH 15/20] Publish packages --- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 4 ++-- packages/js/CHANGELOG.md | 6 ++++++ packages/js/package.json | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index bb70905bc..98716692a 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.10 + +### Patch Changes + +- Fix an issue with hxro library when the SDK is imported as .mjs +- Updated dependencies + - @convergence-rfq/sdk@6.6.10 + ## 6.6.9 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 60ee85ef5..333afdb36 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/cli", "description": "Official Convergence CLI", - "version": "6.6.9", + "version": "6.6.10", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.9", + "@convergence-rfq/sdk": "6.6.10", "@solana/web3.js": "^1.87.6", "@types/cookie": "^0.5.1", "commander": "^10.0.0" diff --git a/packages/js/CHANGELOG.md b/packages/js/CHANGELOG.md index 32eea82b7..1a92f7c2f 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.10 + +### Patch Changes + +- Fix an issue with hxro library when the SDK is imported as .mjs + ## 6.6.9 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index c1b1e8abe..af709ca2b 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/sdk", "description": "Official Convergence RFQ SDK", - "version": "6.6.9", + "version": "6.6.10", "license": "MIT", "publishConfig": { "access": "public" From 6a9d4b675f1d9bbb3975af3b4b1b87255620a831 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Tue, 21 May 2024 16:45:15 +0530 Subject: [PATCH 16/20] update logs fetch logic --- packages/js/package.json | 2 +- .../operations/getHxroCollateralForSettlement.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/js/package.json b/packages/js/package.json index af709ca2b..371f49f73 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -62,7 +62,7 @@ "@convergence-rfq/vault-operator": "^3.11.0", "@coral-xyz/anchor": "^0.28.0", "@coral-xyz/borsh": "^0.28.0", - "@hxronetwork/dexterity-ts": "1.6.16", + "@hxronetwork/dexterity-ts": "1.6.40", "@mithraic-labs/psy-american": "^0.2.3", "@mithraic-labs/tokenized-euros": "^0.2.3", "@noble/ed25519": "^1.7.1", diff --git a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts index 20232ca5b..25637a9cb 100644 --- a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts +++ b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts @@ -112,8 +112,12 @@ export const getRequiredHxroCollateralForSettlementOperationHandler: OperationHa if (!logs) { return { remainingCollateral: 0 }; } - const logToParse = logs[HXRO_COLLATERAL_LOG_INDEX]; + const logToParse = logs.find((l) => l.includes('Total Variance')); + if (!logToParse || logToParse === '') { + return { remainingCollateral: 0 }; + } const logsSplit = logToParse.split(','); + let totalVariance = Number(logsSplit[0].split(':')[2]); let openOrdersVariance = Number(logsSplit[1].split(':')[1]); let positionalValue = Number(logsSplit[2].split(':')[1]); From 7e77c0b5cd2d720aff769acbc945f8923a6b4054 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Tue, 21 May 2024 16:45:35 +0530 Subject: [PATCH 17/20] update logs fetch logic --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 76bbc185f..de2824d8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1853,10 +1853,10 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== -"@hxronetwork/dexterity-ts@1.6.16": - version "1.6.16" - resolved "https://registry.yarnpkg.com/@hxronetwork/dexterity-ts/-/dexterity-ts-1.6.16.tgz#2fc4c9b78246756838ffbde09165733b1089c7fe" - integrity sha512-g3SQ8MsMztI1t7WolPG5dWtZhsOYDeCSgLojQNtMm2fCyGhENRnrRweKuz4aJTVOgCb/u0NdtOmmnvB5v66cKw== +"@hxronetwork/dexterity-ts@1.6.40": + version "1.6.40" + resolved "https://registry.yarnpkg.com/@hxronetwork/dexterity-ts/-/dexterity-ts-1.6.40.tgz#5352910705dbb0dc0a7e52f104784bff32149539" + integrity sha512-q0xiXRbgQmy1TD2lhHFfSc7X7a81tefModMq++JpqtnpfaHcovL9PtleFcB+QhVrpXlF1gylBwFr4aYfIdzTGw== dependencies: "@bonfida/aaob" "0.0.3" "@coral-xyz/anchor" "^0.29.0" From 64d0e185d493504c6b0bb8840c814907bd60958e Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Tue, 21 May 2024 16:51:49 +0530 Subject: [PATCH 18/20] update hxro collateral fetch logic --- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 4 ++-- packages/js/CHANGELOG.md | 6 ++++++ packages/js/package.json | 2 +- packages/js/src/constants.ts | 2 -- .../operations/getHxroCollateralForSettlement.ts | 1 - 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 98716692a..d9c49836f 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.11 + +### Patch Changes + +- Update hxro collateral logs fetching logic +- Updated dependencies + - @convergence-rfq/sdk@6.6.11 + ## 6.6.10 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 333afdb36..ff565ae24 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/cli", "description": "Official Convergence CLI", - "version": "6.6.10", + "version": "6.6.11", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.10", + "@convergence-rfq/sdk": "6.6.11", "@solana/web3.js": "^1.87.6", "@types/cookie": "^0.5.1", "commander": "^10.0.0" diff --git a/packages/js/CHANGELOG.md b/packages/js/CHANGELOG.md index 1a92f7c2f..d65e7ca62 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.11 + +### Patch Changes + +- Update hxro collateral logs fetching logic + ## 6.6.10 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index 371f49f73..8fff3aba0 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/sdk", "description": "Official Convergence RFQ SDK", - "version": "6.6.10", + "version": "6.6.11", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/js/src/constants.ts b/packages/js/src/constants.ts index 82934db11..683c87759 100644 --- a/packages/js/src/constants.ts +++ b/packages/js/src/constants.ts @@ -5,8 +5,6 @@ export const COMPUTE_UNIT_PRICE_IN_MICRO_LAMPORTS_MAP = { turbo: 25000, }; -export const HXRO_COLLATERAL_LOG_INDEX = 7; - export const DEFAULT_COMPUTE_UNITS = 200_000; export const DEFAULT_COMPUTE_UNIT_PRICE = 5000; diff --git a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts index 25637a9cb..c0fc088ab 100644 --- a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts +++ b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts @@ -13,7 +13,6 @@ import { PrintTradeRfq, getAuthoritySide, } from '@/plugins/rfqModule'; -import { HXRO_COLLATERAL_LOG_INDEX } from '@/constants'; const Key = 'GetRequiredHxroCollateralForSettlementOperation' as const; From 83244bea7e9d2cf0e06ea0d36f495ca9026c851d Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 22 May 2024 17:48:28 +0530 Subject: [PATCH 19/20] hxro updateMarkPrice integrtaion --- packages/cli/CHANGELOG.md | 48 +++++++++++++++++++ packages/cli/package.json | 4 +- packages/js/CHANGELOG.md | 36 ++++++++++++++ packages/js/package.json | 2 +- .../operations/lockHxroCollateral.ts | 26 +++++++++- .../operations/preparePrintTradeSettlement.ts | 4 +- packages/js/src/utils/helpers.ts | 4 ++ .../hxro/accounts/mark-price-account.json | 13 +++++ .../dependencies/hxro/pubkey-naming.json | 5 +- 9 files changed, 132 insertions(+), 10 deletions(-) create mode 100644 packages/validator/dependencies/hxro/accounts/mark-price-account.json diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index d9c49836f..22b07e550 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,53 @@ # @convergence-rfq/cli +## 6.6.17 + +### Patch Changes + +- finish hxro updateMarkPrice integration +- Updated dependencies + - @convergence-rfq/sdk@6.6.17 + +## 6.6.16 + +### Patch Changes + +- remove console logs +- Updated dependencies + - @convergence-rfq/sdk@6.6.16 + +## 6.6.15 + +### Patch Changes + +- experiment hxro updateMarkPrice +- Updated dependencies + - @convergence-rfq/sdk@6.6.15 + +## 6.6.14 + +### Patch Changes + +- Modify preparePrintTradeSettlement logic +- Updated dependencies + - @convergence-rfq/sdk@6.6.14 + +## 6.6.13 + +### Patch Changes + +- fix sig verify error +- Updated dependencies + - @convergence-rfq/sdk@6.6.13 + +## 6.6.12 + +### Patch Changes + +- add updateMarkPrice ix to lockcollateral +- Updated dependencies + - @convergence-rfq/sdk@6.6.12 + ## 6.6.11 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index ff565ae24..eab341aa8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/cli", "description": "Official Convergence CLI", - "version": "6.6.11", + "version": "6.6.17", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.11", + "@convergence-rfq/sdk": "6.6.17", "@solana/web3.js": "^1.87.6", "@types/cookie": "^0.5.1", "commander": "^10.0.0" diff --git a/packages/js/CHANGELOG.md b/packages/js/CHANGELOG.md index d65e7ca62..ced3d925c 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,41 @@ # @convergence-rfq/sdk +## 6.6.17 + +### Patch Changes + +- finish hxro updateMarkPrice integration + +## 6.6.16 + +### Patch Changes + +- remove console logs + +## 6.6.15 + +### Patch Changes + +- experiment hxro updateMarkPrice + +## 6.6.14 + +### Patch Changes + +- Modify preparePrintTradeSettlement logic + +## 6.6.13 + +### Patch Changes + +- fix sig verify error + +## 6.6.12 + +### Patch Changes + +- add updateMarkPrice ix to lockcollateral + ## 6.6.11 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index 8fff3aba0..585eb5ed4 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/sdk", "description": "Official Convergence RFQ SDK", - "version": "6.6.11", + "version": "6.6.17", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/lockHxroCollateral.ts b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/lockHxroCollateral.ts index fa9084044..879a30a92 100644 --- a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/lockHxroCollateral.ts +++ b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/lockHxroCollateral.ts @@ -1,5 +1,6 @@ import BN from 'bn.js'; import BigNumber from 'bignumber.js'; +import dexterity from '@hxronetwork/dexterity-ts'; import { getHxroProgramFromIDL } from '../program'; import type { HxroContextHelper, HxroLeg } from '../printTrade'; import { HXRO_LEG_DECIMALS } from '../constants'; @@ -11,6 +12,7 @@ import { PrintTradeResponse, PrintTradeRfq, } from '@/plugins/rfqModule'; +import { isLocalEnv } from '@/utils/helpers'; export type LockHxroCollateralParams = { rfq: PrintTradeRfq; @@ -26,7 +28,6 @@ export const lockHxroCollateralBuilder = async ( ): Promise> => { const { rfq, response, side, hxroContext } = params; const { payer = cvg.rpc().getDefaultFeePayer() } = options; - const { mpg, manifest } = hxroContext; const userTrg = await hxroContext.getTrgDataBySide(side).get(); @@ -109,11 +110,32 @@ export const lockHxroCollateralBuilder = async ( ]) .instruction(); - return TransactionBuilder.make<{}>() + const txBuilder = TransactionBuilder.make<{}>() .setFeePayer(payer) .add({ instruction, signers: [payer], key: 'lockHxroCollateral', }); + + if (!isLocalEnv(cvg)) { + let traderRiskGrop: PublicKey; + if (rfq.taker.equals(payer.publicKey)) { + traderRiskGrop = hxroContext.getTakerTrg(); + } else { + traderRiskGrop = hxroContext.getMakerTrg(); + } + const trader = new dexterity.Trader(manifest, traderRiskGrop, true); + + await trader.connect(null, null); + const updateMarkPriceIx = trader.getUpdateMarkPricesIx(); + updateMarkPriceIx.keys[0].pubkey = payer.publicKey; + + txBuilder.prepend({ + instruction: updateMarkPriceIx, + signers: [payer], + key: 'updateMarkPrices', + }); + } + return txBuilder; }; diff --git a/packages/js/src/plugins/rfqModule/operations/preparePrintTradeSettlement.ts b/packages/js/src/plugins/rfqModule/operations/preparePrintTradeSettlement.ts index 8f73412f5..e769873a5 100644 --- a/packages/js/src/plugins/rfqModule/operations/preparePrintTradeSettlement.ts +++ b/packages/js/src/plugins/rfqModule/operations/preparePrintTradeSettlement.ts @@ -84,9 +84,7 @@ export const preparePrintTradeSettlementOperationHandler: OperationHandler x.toTransaction(lastValidBlockHeight)); - const signedTxs = await convergence.identity().signAllTransactions(txs); - const outputs = []; for (const signedTx of signedTxs) { const output = await convergence @@ -96,7 +94,6 @@ export const preparePrintTradeSettlementOperationHandler: OperationHandler( ); } }; + +export const isLocalEnv = (cvg: Convergence) => { + return cvg.connection.rpcEndpoint === 'http://127.0.0.1:8899'; +}; diff --git a/packages/validator/dependencies/hxro/accounts/mark-price-account.json b/packages/validator/dependencies/hxro/accounts/mark-price-account.json new file mode 100644 index 000000000..d554df74e --- /dev/null +++ b/packages/validator/dependencies/hxro/accounts/mark-price-account.json @@ -0,0 +1,13 @@ +{ + "pubkey": "5bdBYhFsh1Zcy656eSssuRNFgACAa1qGSBm4tbiHVrES", + "account": { + "lamports": 61860480, + "data": [ + "8tfj1HZp32z/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+9m3tkuk/N+/GSuX7MVhAJrXgiX1ql9WrwUDKE1JBCpIBAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGvmrQ8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7kuaiDzgmziEWUvA8fCjVx7H4m+6n9RUea0Ssk2/qRyEbAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABr5q0PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHi83SfyZqKY8IdvR/lQz1D7qYz0nVrIi4ugL76mrdxfvipHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "base64" + ], + "owner": "BVDTB61eHY7UnCb4ueatdaV4rctTzqfLAL6sQDeMNSHA", + "executable": false, + "rentEpoch": 0 + } +} diff --git a/packages/validator/dependencies/hxro/pubkey-naming.json b/packages/validator/dependencies/hxro/pubkey-naming.json index e5ae78175..3fa11ef0c 100644 --- a/packages/validator/dependencies/hxro/pubkey-naming.json +++ b/packages/validator/dependencies/hxro/pubkey-naming.json @@ -18,5 +18,6 @@ "FUfpR31LmcP1VSbz5zDaM7nxnH55iBHkpwusgrnhaFjL": "dex-program", "G6b2JSF5M7SySosNC4GkHHmqXczSCGUycppRiYvTQ7aK": "vault", "GBhshm4LFyYTv9iPocz7kmLpRhvvPNoxH9wgB57uNamm": "fee-config", - "GCXr6LDZurWK8Hkm18gZzJ7jUgvrYEVFFeWUR346fd42": "mpg" -} \ No newline at end of file + "GCXr6LDZurWK8Hkm18gZzJ7jUgvrYEVFFeWUR346fd42": "mpg", + "5bdBYhFsh1Zcy656eSssuRNFgACAa1qGSBm4tbiHVrES": "mark-price-account" +} From 22a3bb0aa1a7917dbd0f7253770f8450b194acca Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Wed, 22 May 2024 18:03:32 +0530 Subject: [PATCH 20/20] hxro updateMarkPrice integrtaion --- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 4 ++-- packages/js/CHANGELOG.md | 6 ++++++ packages/js/package.json | 2 +- .../operations/getHxroCollateralForSettlement.ts | 5 ++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 22b07e550..01c680a43 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.18 + +### Patch Changes + +- update getHxroCollateralForSettlement +- Updated dependencies + - @convergence-rfq/sdk@6.6.18 + ## 6.6.17 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index eab341aa8..4e3f5e1ee 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/cli", "description": "Official Convergence CLI", - "version": "6.6.17", + "version": "6.6.18", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.17", + "@convergence-rfq/sdk": "6.6.18", "@solana/web3.js": "^1.87.6", "@types/cookie": "^0.5.1", "commander": "^10.0.0" diff --git a/packages/js/CHANGELOG.md b/packages/js/CHANGELOG.md index ced3d925c..db94e16b0 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.18 + +### Patch Changes + +- update getHxroCollateralForSettlement + ## 6.6.17 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index 585eb5ed4..5a8fea300 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,7 +1,7 @@ { "name": "@convergence-rfq/sdk", "description": "Official Convergence RFQ SDK", - "version": "6.6.17", + "version": "6.6.18", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts index c0fc088ab..98ed8ffa6 100644 --- a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts +++ b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/getHxroCollateralForSettlement.ts @@ -92,10 +92,13 @@ export const getRequiredHxroCollateralForSettlementOperationHandler: OperationHa const lastValidBlockHeight = await convergence.rpc().getLatestBlockhash(); const ixs = txBuilder.getInstructions(); + if (!ixs[1]) { + return { remainingCollateral: 0 }; + } const txMessage = new TransactionMessage({ payerKey: payer, recentBlockhash: lastValidBlockHeight.blockhash, - instructions: ixs, + instructions: [ixs[1]], }).compileToV0Message(); const tx = new VersionedTransaction(txMessage);