From 40d3bbe4f05d53d78955e13fe9b6c86f983aed44 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Mon, 27 May 2024 12:48:16 +0530 Subject: [PATCH 1/7] new changes --- packages/cli/CHANGELOG.md | 24 ++++++++ packages/cli/package.json | 4 +- packages/js/CHANGELOG.md | 18 ++++++ packages/js/package.json | 2 +- .../unlockHxroCollateralByRecord.ts | 56 +++++++++++++++++-- 5 files changed, 95 insertions(+), 9 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 01c680a43..81cb5d495 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,29 @@ # @convergence-rfq/cli +## 6.6.21 + +### Patch Changes + +- add logs to check unlockhxroCollateralTxSize +- Updated dependencies + - @convergence-rfq/sdk@6.6.21 + +## 6.6.20 + +### Patch Changes + +- fix tx size overflow for unlockHxroCollateralTx +- Updated dependencies + - @convergence-rfq/sdk@6.6.20 + +## 6.6.19 + +### Patch Changes + +- modify unclockHxroCollateral and add markPriceUpdate ixs +- Updated dependencies + - @convergence-rfq/sdk@6.6.19 + ## 6.6.18 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 4e3f5e1ee..18aa22a1f 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.18", + "version": "6.6.21", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.18", + "@convergence-rfq/sdk": "6.6.21", "@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 db94e16b0..415ab67d9 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,23 @@ # @convergence-rfq/sdk +## 6.6.21 + +### Patch Changes + +- add logs to check unlockhxroCollateralTxSize + +## 6.6.20 + +### Patch Changes + +- fix tx size overflow for unlockHxroCollateralTx + +## 6.6.19 + +### Patch Changes + +- modify unclockHxroCollateral and add markPriceUpdate ixs + ## 6.6.18 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index 5a8fea300..4097aa49f 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.18", + "version": "6.6.21", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/unlockHxroCollateralByRecord.ts b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/unlockHxroCollateralByRecord.ts index 88fed30bc..7b939992c 100644 --- a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/unlockHxroCollateralByRecord.ts +++ b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/unlockHxroCollateralByRecord.ts @@ -6,6 +6,7 @@ import { import dexterity from '@hxronetwork/dexterity-ts'; import BN from 'bn.js'; +import { Transaction } from '@solana/web3.js'; import { getHxroProgramFromIDL } from '../program'; import { fetchValidHxroMpg } from '../helpers'; import { hxroManifestCache } from '../cache'; @@ -20,6 +21,7 @@ import { } from '@/types'; import { TransactionBuilder, TransactionBuilderOptions } from '@/utils'; import { SendAndConfirmTransactionResponse } from '@/plugins/rpcModule'; +import { isLocalEnv } from '@/utils/helpers'; const Key = 'unlockHxroCollateralByRecord' as const; @@ -79,9 +81,13 @@ export const unlockHxroCollateralByRecordOperationHandler: OperationHandler() + const txBuilder = TransactionBuilder.make<{}>() .setFeePayer(payer) .add({ instruction, signers: [payer], key: 'unlockHxroCollateral', }); + + if (!isLocalEnv(cvg)) { + const trader = new dexterity.Trader(manifest, lockRecord.trg, true); + + await trader.connect(null, null); + const updateMarkPriceIx = trader.getUpdateMarkPricesIx(); + updateMarkPriceIx.keys[0].pubkey = payer.publicKey; + + txBuilder.prepend({ + instruction: updateMarkPriceIx, + signers: [payer], + key: 'updateMarkPrices', + }); + } + console.log('unlockHxroCollateralBuilder', txBuilder.checkTransactionFits()); + return txBuilder; }; From 5e17800c506d4287f76d701301bc5e8d83e34009 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Mon, 3 Jun 2024 15:03:47 +0530 Subject: [PATCH 2/7] finish unlockHxroCollateral --- .../unlockHxroCollateralByRecord.ts | 117 ++++++++++++++++-- 1 file changed, 108 insertions(+), 9 deletions(-) diff --git a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/unlockHxroCollateralByRecord.ts b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/unlockHxroCollateralByRecord.ts index 7b939992c..899e56be8 100644 --- a/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/unlockHxroCollateralByRecord.ts +++ b/packages/js/src/plugins/hxroPrintTradeProviderModule/operations/unlockHxroCollateralByRecord.ts @@ -7,6 +7,7 @@ import dexterity from '@hxronetwork/dexterity-ts'; import BN from 'bn.js'; import { Transaction } from '@solana/web3.js'; +import * as solana from '@solana/web3.js'; import { getHxroProgramFromIDL } from '../program'; import { fetchValidHxroMpg } from '../helpers'; import { hxroManifestCache } from '../cache'; @@ -19,8 +20,7 @@ import { PublicKey, useOperation, } from '@/types'; -import { TransactionBuilder, TransactionBuilderOptions } from '@/utils'; -import { SendAndConfirmTransactionResponse } from '@/plugins/rpcModule'; +import { TransactionBuilder, TransactionBuilderOptions, sleep } from '@/utils'; import { isLocalEnv } from '@/utils/helpers'; const Key = 'unlockHxroCollateralByRecord' as const; @@ -53,8 +53,7 @@ export type UnlockHxroCollateralByRecordInput = { * @category Outputs */ export type UnlockHxroCollateralByRecordOutput = - SendAndConfirmTransactionResponse; - + solana.RpcResponseAndContext; /** * @group Operations * @category Handlers @@ -69,7 +68,7 @@ export const unlockHxroCollateralByRecordOperationHandler: OperationHandler; if ('publicKey' in lockRecord) { lockRecordData = lockRecord; @@ -109,8 +108,86 @@ export const unlockHxroCollateralByRecordOperationHandler: OperationHandler ix.keys.map((k) => k.pubkey)) + .flat(); + + if (addressLookupTableAcc && addressLookupTableAcc.isActive()) { + const remainingAddresses: PublicKey[] = []; + const addressesArray = addressLookupTableAcc.state.addresses.map((a) => + a.toBase58() + ); + for (const addr of unlockHxroCollateralAccouts) { + if (!addressesArray.includes(addr.toBase58())) { + remainingAddresses.push(addr); + break; + } + } + if (remainingAddresses.length > 0) { + const extendInstruction = + solana.AddressLookupTableProgram.extendLookupTable({ + payer: payer.publicKey, + authority: payer.publicKey, + lookupTable: lookupTableAddress, + addresses: remainingAddresses, + }); + const extendLookupTx = new Transaction().add(extendInstruction); + extendLookupTx.feePayer = payer.publicKey; + extendLookupTx.recentBlockhash = lastValidBlockHeight.blockhash; + extendLookupTx.lastValidBlockHeight = + lastValidBlockHeight.lastValidBlockHeight; + lookUpTxs.push(extendLookupTx); + } + } else { + const lookUpCreateTx = new Transaction().add(lookupTableInst); + lookUpCreateTx.feePayer = payer.publicKey; + lookUpCreateTx.recentBlockhash = lastValidBlockHeight.blockhash; + lookUpCreateTx.lastValidBlockHeight = + lastValidBlockHeight.lastValidBlockHeight; + lookUpTxs.push(lookUpCreateTx); + + const extendInstruction = + solana.AddressLookupTableProgram.extendLookupTable({ + payer: payer.publicKey, + authority: payer.publicKey, + lookupTable: lookupTableAddress, + addresses: unlockHxroCollateralAccouts, + }); + const extendLookupTx = new Transaction().add(extendInstruction); + extendLookupTx.feePayer = payer.publicKey; + extendLookupTx.recentBlockhash = lastValidBlockHeight.blockhash; + extendLookupTx.lastValidBlockHeight = + lastValidBlockHeight.lastValidBlockHeight; + lookUpTxs.push(extendLookupTx); + } + + if (lookUpTxs.length > 0) { + const signedLookUpTxs = await cvg + .identity() + .signAllTransactions(lookUpTxs); + for (const tx of signedLookUpTxs) { + await cvg.rpc().serializeAndSendTransaction(tx); + } + } + const txs: Transaction[] = []; + if (action == 'unlock' || action == 'unlock-and-remove-record') { txs.push( unlockHxroCollateralTxBuilder.toTransaction(lastValidBlockHeight) @@ -126,9 +203,32 @@ export const unlockHxroCollateralByRecordOperationHandler: OperationHandler | null = + null; + + const newlookUpTable = await cvg.connection.getAddressLookupTable( + lookupTableAddress + ); + const newAddressLookupTableAcc = newlookUpTable.value; + if (!newAddressLookupTableAcc) { + throw new Error('No lookup table'); + } + const txMessages = signedTxs.map((tx) => + new solana.TransactionMessage({ + payerKey: payer.publicKey, + recentBlockhash: lastValidBlockHeight.blockhash, + instructions: tx.instructions.map((ix) => ix), + }).compileToV0Message([newAddressLookupTableAcc]) + ); + + const versionedTxs = txMessages.map( + (msg) => new solana.VersionedTransaction(msg) + ); + await sleep(1); + for (const tx of versionedTxs) { + tx.sign([cvg.identity() as solana.Signer]); + const sig = await cvg.connection.sendTransaction(tx); + txResponse = await cvg.connection.confirmTransaction(sig); } if (!txResponse) { throw new Error('No transaction response'); @@ -246,6 +346,5 @@ export const unlockHxroCollateralBuilder = async ( key: 'updateMarkPrices', }); } - console.log('unlockHxroCollateralBuilder', txBuilder.checkTransactionFits()); return txBuilder; }; From 2bc97bc53e5d7f3bab806bce9f365438e22b4b97 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Mon, 3 Jun 2024 15:06:29 +0530 Subject: [PATCH 3/7] 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 81cb5d495..65127505c 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.22 + +### Patch Changes + +- add updateMarkPriceIx to unlockHxroCollatera fn +- Updated dependencies + - @convergence-rfq/sdk@6.6.22 + ## 6.6.21 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 18aa22a1f..31c6b4e03 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.21", + "version": "6.6.22", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.21", + "@convergence-rfq/sdk": "6.6.22", "@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 415ab67d9..726bc6f5b 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.22 + +### Patch Changes + +- add updateMarkPriceIx to unlockHxroCollatera fn + ## 6.6.21 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index 4097aa49f..bb3fef881 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.21", + "version": "6.6.22", "license": "MIT", "publishConfig": { "access": "public" From 1910d01a51e09e4380cacb316119e6b698b3b766 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Mon, 3 Jun 2024 16:16:58 +0530 Subject: [PATCH 4/7] split txs --- .../operations/revertSettlementPreparation.ts | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts b/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts index cdbadd3cf..de6799cf4 100644 --- a/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts +++ b/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts @@ -105,11 +105,27 @@ export const revertSettlementPreparationOperationHandler: OperationHandler b.toTransaction(latestBlockhash)); + const signedTxs = await convergence.identity().signAllTransactions(txs); + let output: SendAndConfirmTransactionResponse | undefined; + for (const signedTx of signedTxs) { + output = await convergence.rpc().serializeAndSendTransaction(signedTx); + } + if (!output) { + throw new Error('No transaction was sent'); + } + return { response: output }; }, }; From effed28d015167ca4c50cd79406aaa90ecf5ecfd Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Mon, 3 Jun 2024 16:19:31 +0530 Subject: [PATCH 5/7] 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 65127505c..eba583384 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.23 + +### Patch Changes + +- split txs for revertPrepareSettlement +- Updated dependencies + - @convergence-rfq/sdk@6.6.23 + ## 6.6.22 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 31c6b4e03..190af3469 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.22", + "version": "6.6.23", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.22", + "@convergence-rfq/sdk": "6.6.23", "@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 726bc6f5b..b4e9acf30 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.23 + +### Patch Changes + +- split txs for revertPrepareSettlement + ## 6.6.22 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index bb3fef881..0e9232b68 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.22", + "version": "6.6.23", "license": "MIT", "publishConfig": { "access": "public" From 722d5ec9b8dce71bfe1afb60a8e33964bbf785a3 Mon Sep 17 00:00:00 2001 From: Nagaprasadvr Date: Mon, 3 Jun 2024 16:32:04 +0530 Subject: [PATCH 6/7] add lastvalidblckhash to revertPreparationSettlement --- .../rfqModule/operations/revertSettlementPreparation.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts b/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts index de6799cf4..b748e7134 100644 --- a/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts +++ b/packages/js/src/plugins/rfqModule/operations/revertSettlementPreparation.ts @@ -120,7 +120,9 @@ export const revertSettlementPreparationOperationHandler: OperationHandler Date: Mon, 3 Jun 2024 16:42:56 +0530 Subject: [PATCH 7/7] fix --- 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 eba583384..33656adb3 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # @convergence-rfq/cli +## 6.6.24 + +### Patch Changes + +- add lastValidBlockhash to revertSettlementPreparation txs +- Updated dependencies + - @convergence-rfq/sdk@6.6.24 + ## 6.6.23 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 190af3469..78332c4b8 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.23", + "version": "6.6.24", "license": "MIT", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "cli": "ts-node src/index.ts" }, "dependencies": { - "@convergence-rfq/sdk": "6.6.23", + "@convergence-rfq/sdk": "6.6.24", "@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 b4e9acf30..90bfa4cb6 100644 --- a/packages/js/CHANGELOG.md +++ b/packages/js/CHANGELOG.md @@ -1,5 +1,11 @@ # @convergence-rfq/sdk +## 6.6.24 + +### Patch Changes + +- add lastValidBlockhash to revertSettlementPreparation txs + ## 6.6.23 ### Patch Changes diff --git a/packages/js/package.json b/packages/js/package.json index 0e9232b68..0d6ae327c 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.23", + "version": "6.6.24", "license": "MIT", "publishConfig": { "access": "public"