@drift-labs/sdk 2.108.0-beta.1 → 2.108.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/lib/browser/adminClient.d.ts +2 -4
- package/lib/browser/adminClient.js +4 -21
- package/lib/browser/driftClient.d.ts +8 -7
- package/lib/browser/driftClient.js +20 -16
- package/lib/browser/idl/drift.json +7 -35
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.js +1 -0
- package/lib/browser/math/liquidation.d.ts +3 -0
- package/lib/browser/math/liquidation.js +89 -1
- package/lib/browser/math/oracles.js +16 -0
- package/lib/browser/oracles/oracleId.js +4 -0
- package/lib/browser/swift/swiftOrderSubscriber.js +1 -1
- package/lib/browser/tx/txHandler.d.ts +1 -0
- package/lib/browser/tx/txHandler.js +18 -7
- package/lib/browser/tx/utils.d.ts +3 -1
- package/lib/browser/tx/utils.js +73 -1
- package/lib/browser/util/pythOracleUtils.js +2 -1
- package/lib/node/adminClient.d.ts +2 -4
- package/lib/node/adminClient.js +4 -21
- package/lib/node/driftClient.d.ts +8 -7
- package/lib/node/driftClient.js +20 -16
- package/lib/node/idl/drift.json +7 -35
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/node/math/liquidation.d.ts +3 -0
- package/lib/node/math/liquidation.js +89 -1
- package/lib/node/math/oracles.js +16 -0
- package/lib/node/oracles/oracleId.js +4 -0
- package/lib/node/swift/swiftOrderSubscriber.js +1 -1
- package/lib/node/tx/txHandler.d.ts +1 -0
- package/lib/node/tx/txHandler.js +18 -7
- package/lib/node/tx/utils.d.ts +3 -1
- package/lib/node/tx/utils.js +73 -1
- package/lib/node/util/pythOracleUtils.js +2 -1
- package/package.json +1 -1
- package/src/adminClient.ts +17 -57
- package/src/driftClient.ts +58 -21
- package/src/idl/drift.json +7 -35
- package/src/index.ts +1 -0
- package/src/math/liquidation.ts +130 -0
- package/src/math/oracles.ts +28 -0
- package/src/oracles/oracleId.ts +2 -0
- package/src/swift/swiftOrderSubscriber.ts +1 -4
- package/src/tx/txHandler.ts +27 -8
- package/src/tx/utils.ts +115 -1
- package/src/util/pythOracleUtils.ts +2 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.108.0-beta.
|
|
1
|
+
2.108.0-beta.10
|
|
@@ -197,10 +197,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
197
197
|
getInitUserFuelIx(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionInstruction>;
|
|
198
198
|
initializePythPullOracle(feedId: string): Promise<TransactionSignature>;
|
|
199
199
|
getInitializePythPullOracleIx(feedId: string): Promise<TransactionInstruction>;
|
|
200
|
-
initializePythLazerOracle(feedId: number
|
|
201
|
-
getInitializePythLazerOracleIx(feedId: number
|
|
202
|
-
updatePythLazerOracleExponent(feedId: number, exponent: number): Promise<TransactionSignature>;
|
|
203
|
-
getUpdatePythLazerOracleExponentIx(feedId: number, exponent: number): Promise<TransactionInstruction>;
|
|
200
|
+
initializePythLazerOracle(feedId: number): Promise<TransactionSignature>;
|
|
201
|
+
getInitializePythLazerOracleIx(feedId: number): Promise<TransactionInstruction>;
|
|
204
202
|
initializeHighLeverageModeConfig(maxUsers: number): Promise<TransactionSignature>;
|
|
205
203
|
getInitializeHighLeverageModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
|
|
206
204
|
updateUpdateHighLeverageModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
|
|
@@ -1809,14 +1809,14 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1809
1809
|
},
|
|
1810
1810
|
});
|
|
1811
1811
|
}
|
|
1812
|
-
async initializePythLazerOracle(feedId
|
|
1813
|
-
const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId
|
|
1812
|
+
async initializePythLazerOracle(feedId) {
|
|
1813
|
+
const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId);
|
|
1814
1814
|
const tx = await this.buildTransaction(initializePythPullOracleIx);
|
|
1815
1815
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1816
1816
|
return txSig;
|
|
1817
1817
|
}
|
|
1818
|
-
async getInitializePythLazerOracleIx(feedId
|
|
1819
|
-
return await this.program.instruction.initializePythLazerOracle(feedId,
|
|
1818
|
+
async getInitializePythLazerOracleIx(feedId) {
|
|
1819
|
+
return await this.program.instruction.initializePythLazerOracle(feedId, {
|
|
1820
1820
|
accounts: {
|
|
1821
1821
|
admin: this.useHotWalletAdmin
|
|
1822
1822
|
? this.wallet.publicKey
|
|
@@ -1828,23 +1828,6 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1828
1828
|
},
|
|
1829
1829
|
});
|
|
1830
1830
|
}
|
|
1831
|
-
async updatePythLazerOracleExponent(feedId, exponent) {
|
|
1832
|
-
const initializePythPullOracleIx = await this.getUpdatePythLazerOracleExponentIx(feedId, exponent);
|
|
1833
|
-
const tx = await this.buildTransaction(initializePythPullOracleIx);
|
|
1834
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1835
|
-
return txSig;
|
|
1836
|
-
}
|
|
1837
|
-
async getUpdatePythLazerOracleExponentIx(feedId, exponent) {
|
|
1838
|
-
return await this.program.instruction.updatePythLazerOracleExponent(feedId, exponent, {
|
|
1839
|
-
accounts: {
|
|
1840
|
-
admin: this.useHotWalletAdmin
|
|
1841
|
-
? this.wallet.publicKey
|
|
1842
|
-
: this.getStateAccount().admin,
|
|
1843
|
-
state: await this.getStatePublicKey(),
|
|
1844
|
-
lazerOracle: (0, pda_1.getPythLazerOraclePublicKey)(this.program.programId, feedId),
|
|
1845
|
-
},
|
|
1846
|
-
});
|
|
1847
|
-
}
|
|
1848
1831
|
async initializeHighLeverageModeConfig(maxUsers) {
|
|
1849
1832
|
const initializeHighLeverageModeConfigIx = await this.getInitializeHighLeverageModeConfigIx(maxUsers);
|
|
1850
1833
|
const tx = await this.buildTransaction(initializeHighLeverageModeConfigIx);
|
|
@@ -389,8 +389,8 @@ export declare class DriftClient {
|
|
|
389
389
|
marketIndex?: number;
|
|
390
390
|
direction?: PositionDirection;
|
|
391
391
|
}, placeOrderParams: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
392
|
-
placeOrders(params: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
393
|
-
preparePlaceOrdersTx(params: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<{
|
|
392
|
+
placeOrders(params: OrderParams[], txParams?: TxParams, subAccountId?: number, optionalIxs?: TransactionInstruction[]): Promise<TransactionSignature>;
|
|
393
|
+
preparePlaceOrdersTx(params: OrderParams[], txParams?: TxParams, subAccountId?: number, optionalIxs?: TransactionInstruction[]): Promise<{
|
|
394
394
|
placeOrdersTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
|
|
395
395
|
}>;
|
|
396
396
|
getPlaceOrdersIx(params: OptionalOrderParams[], subAccountId?: number): Promise<TransactionInstruction>;
|
|
@@ -520,7 +520,7 @@ export declare class DriftClient {
|
|
|
520
520
|
updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
521
521
|
getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
522
522
|
placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
523
|
-
preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean, auctionDurationPercentage?: number): Promise<{
|
|
523
|
+
preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean, auctionDurationPercentage?: number, optionalIxs?: TransactionInstruction[]): Promise<{
|
|
524
524
|
placeAndTakeTx: Transaction | VersionedTransaction;
|
|
525
525
|
cancelExistingOrdersTx: Transaction | VersionedTransaction;
|
|
526
526
|
settlePnlTx: Transaction | VersionedTransaction;
|
|
@@ -706,7 +706,7 @@ export declare class DriftClient {
|
|
|
706
706
|
settleeUserAccountPublicKey: PublicKey;
|
|
707
707
|
settleeUserAccount: UserAccount;
|
|
708
708
|
}[], marketIndexes: number[]): Promise<Array<TransactionInstruction>>;
|
|
709
|
-
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
709
|
+
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams, optionalIxs?: TransactionInstruction[]): Promise<TransactionSignature>;
|
|
710
710
|
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
711
711
|
settleMultiplePNLs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature>;
|
|
712
712
|
settleMultiplePNLsMultipleTxs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature[]>;
|
|
@@ -719,13 +719,13 @@ export declare class DriftClient {
|
|
|
719
719
|
getLiquidatePerpWithFillIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, makerInfos: MakerInfo[], liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
720
720
|
liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
721
721
|
getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
722
|
-
getJupiterLiquidateSpotWithSwapIxV6({ jupiterClient, liabilityMarketIndex, assetMarketIndex, swapAmount, assetTokenAccount, liabilityTokenAccount, slippageBps, swapMode, onlyDirectRoutes, quote, userAccount, userAccountPublicKey, userStatsAccountPublicKey, liquidatorSubAccountId, }: {
|
|
722
|
+
getJupiterLiquidateSpotWithSwapIxV6({ jupiterClient, liabilityMarketIndex, assetMarketIndex, swapAmount, assetTokenAccount, liabilityTokenAccount, slippageBps, swapMode, onlyDirectRoutes, quote, userAccount, userAccountPublicKey, userStatsAccountPublicKey, liquidatorSubAccountId, maxAccounts, }: {
|
|
723
723
|
jupiterClient: JupiterClient;
|
|
724
724
|
liabilityMarketIndex: number;
|
|
725
725
|
assetMarketIndex: number;
|
|
726
|
+
swapAmount: BN;
|
|
726
727
|
assetTokenAccount?: PublicKey;
|
|
727
728
|
liabilityTokenAccount?: PublicKey;
|
|
728
|
-
swapAmount: BN;
|
|
729
729
|
slippageBps?: number;
|
|
730
730
|
swapMode?: SwapMode;
|
|
731
731
|
onlyDirectRoutes?: boolean;
|
|
@@ -734,6 +734,7 @@ export declare class DriftClient {
|
|
|
734
734
|
userAccountPublicKey: PublicKey;
|
|
735
735
|
userStatsAccountPublicKey: PublicKey;
|
|
736
736
|
liquidatorSubAccountId?: number;
|
|
737
|
+
maxAccounts?: number;
|
|
737
738
|
}): Promise<{
|
|
738
739
|
ixs: TransactionInstruction[];
|
|
739
740
|
lookupTables: AddressLookupTableAccount[];
|
|
@@ -895,7 +896,7 @@ export declare class DriftClient {
|
|
|
895
896
|
* @returns
|
|
896
897
|
*/
|
|
897
898
|
sendTransaction(tx: Transaction | VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
898
|
-
buildTransaction(instructions: TransactionInstruction | TransactionInstruction[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean, recentBlockhash?: BlockhashWithExpiryBlockHeight): Promise<Transaction | VersionedTransaction>;
|
|
899
|
+
buildTransaction(instructions: TransactionInstruction | TransactionInstruction[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean, recentBlockhash?: BlockhashWithExpiryBlockHeight, optionalIxs?: TransactionInstruction[]): Promise<Transaction | VersionedTransaction>;
|
|
899
900
|
buildBulkTransactions(instructions: (TransactionInstruction | TransactionInstruction[])[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<(Transaction | VersionedTransaction)[]>;
|
|
900
901
|
buildTransactionsMap(instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>, txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<MappedRecord<Record<string, anchor.web3.TransactionInstruction | anchor.web3.TransactionInstruction[]>, anchor.web3.Transaction | anchor.web3.VersionedTransaction>>;
|
|
901
902
|
buildAndSignTransactionsMap(instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>, txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<{
|
|
@@ -2069,13 +2069,13 @@ class DriftClient {
|
|
|
2069
2069
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2070
2070
|
return txSig;
|
|
2071
2071
|
}
|
|
2072
|
-
async placeOrders(params, txParams, subAccountId) {
|
|
2073
|
-
const { txSig } = await this.sendTransaction((await this.preparePlaceOrdersTx(params, txParams, subAccountId))
|
|
2074
|
-
.placeOrdersTx, [], this.opts, false);
|
|
2072
|
+
async placeOrders(params, txParams, subAccountId, optionalIxs) {
|
|
2073
|
+
const { txSig } = await this.sendTransaction((await this.preparePlaceOrdersTx(params, txParams, subAccountId, optionalIxs)).placeOrdersTx, [], this.opts, false);
|
|
2075
2074
|
return txSig;
|
|
2076
2075
|
}
|
|
2077
|
-
async preparePlaceOrdersTx(params, txParams, subAccountId) {
|
|
2078
|
-
const
|
|
2076
|
+
async preparePlaceOrdersTx(params, txParams, subAccountId, optionalIxs) {
|
|
2077
|
+
const lookupTableAccount = await this.fetchMarketLookupTableAccount();
|
|
2078
|
+
const tx = await this.buildTransaction(await this.getPlaceOrdersIx(params, subAccountId), txParams, undefined, [lookupTableAccount], undefined, undefined, optionalIxs);
|
|
2079
2079
|
return {
|
|
2080
2080
|
placeOrdersTx: tx,
|
|
2081
2081
|
};
|
|
@@ -2989,7 +2989,7 @@ class DriftClient {
|
|
|
2989
2989
|
this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
2990
2990
|
return txSig;
|
|
2991
2991
|
}
|
|
2992
|
-
async preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams, makerInfo, referrerInfo, bracketOrdersParams = new Array(), txParams, subAccountId, cancelExistingOrders, settlePnl, exitEarlyIfSimFails, auctionDurationPercentage) {
|
|
2992
|
+
async preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams, makerInfo, referrerInfo, bracketOrdersParams = new Array(), txParams, subAccountId, cancelExistingOrders, settlePnl, exitEarlyIfSimFails, auctionDurationPercentage, optionalIxs) {
|
|
2993
2993
|
const placeAndTakeIxs = [];
|
|
2994
2994
|
const txsToSign = {
|
|
2995
2995
|
placeAndTakeTx: undefined,
|
|
@@ -2998,6 +2998,7 @@ class DriftClient {
|
|
|
2998
2998
|
};
|
|
2999
2999
|
// Get recent block hash so that we can re-use it for all transactions. Makes this logic run faster with fewer RPC requests
|
|
3000
3000
|
const recentBlockHash = await this.txHandler.getLatestBlockhashForTransaction();
|
|
3001
|
+
const lookupTableAccount = await this.fetchMarketLookupTableAccount();
|
|
3001
3002
|
let earlyExitFailedPlaceAndTakeSim = false;
|
|
3002
3003
|
const prepPlaceAndTakeTx = async () => {
|
|
3003
3004
|
var _a;
|
|
@@ -3014,7 +3015,7 @@ class DriftClient {
|
|
|
3014
3015
|
useSimulatedComputeUnits: false,
|
|
3015
3016
|
};
|
|
3016
3017
|
if (shouldUseSimulationComputeUnits || shouldExitIfSimulationFails) {
|
|
3017
|
-
const placeAndTakeTxToSim = (await this.buildTransaction(placeAndTakeIxs, txParams, undefined,
|
|
3018
|
+
const placeAndTakeTxToSim = (await this.buildTransaction(placeAndTakeIxs, txParams, undefined, [lookupTableAccount], true, recentBlockHash, optionalIxs));
|
|
3018
3019
|
const simulationResult = await txParamProcessor_1.TransactionParamProcessor.getTxSimComputeUnits(placeAndTakeTxToSim, this.connection, (_a = txParams.computeUnitsBufferMultiplier) !== null && _a !== void 0 ? _a : 1.2, txParams.lowerBoundCu);
|
|
3019
3020
|
if (shouldExitIfSimulationFails && !simulationResult.success) {
|
|
3020
3021
|
earlyExitFailedPlaceAndTakeSim = true;
|
|
@@ -3023,17 +3024,17 @@ class DriftClient {
|
|
|
3023
3024
|
txsToSign.placeAndTakeTx = await this.buildTransaction(placeAndTakeIxs, {
|
|
3024
3025
|
...txParamsWithoutImplicitSimulation,
|
|
3025
3026
|
computeUnits: simulationResult.computeUnits,
|
|
3026
|
-
}, undefined,
|
|
3027
|
+
}, undefined, [lookupTableAccount], undefined, recentBlockHash, optionalIxs);
|
|
3027
3028
|
}
|
|
3028
3029
|
else {
|
|
3029
|
-
txsToSign.placeAndTakeTx = await this.buildTransaction(placeAndTakeIxs, txParams, undefined,
|
|
3030
|
+
txsToSign.placeAndTakeTx = await this.buildTransaction(placeAndTakeIxs, txParams, undefined, [lookupTableAccount], undefined, recentBlockHash, optionalIxs);
|
|
3030
3031
|
}
|
|
3031
3032
|
return;
|
|
3032
3033
|
};
|
|
3033
3034
|
const prepCancelOrderTx = async () => {
|
|
3034
3035
|
if (cancelExistingOrders && (0, types_1.isVariant)(orderParams.marketType, 'perp')) {
|
|
3035
3036
|
const cancelOrdersIx = await this.getCancelOrdersIx(orderParams.marketType, orderParams.marketIndex, null, subAccountId);
|
|
3036
|
-
txsToSign.cancelExistingOrdersTx = await this.buildTransaction([cancelOrdersIx], txParams, this.txVersion,
|
|
3037
|
+
txsToSign.cancelExistingOrdersTx = await this.buildTransaction([cancelOrdersIx], txParams, this.txVersion, [lookupTableAccount], undefined, recentBlockHash, optionalIxs);
|
|
3037
3038
|
}
|
|
3038
3039
|
return;
|
|
3039
3040
|
};
|
|
@@ -3041,7 +3042,7 @@ class DriftClient {
|
|
|
3041
3042
|
if (settlePnl && (0, types_1.isVariant)(orderParams.marketType, 'perp')) {
|
|
3042
3043
|
const userAccountPublicKey = await this.getUserAccountPublicKey(subAccountId);
|
|
3043
3044
|
const settlePnlIx = await this.settlePNLIx(userAccountPublicKey, this.getUserAccount(subAccountId), orderParams.marketIndex);
|
|
3044
|
-
txsToSign.settlePnlTx = await this.buildTransaction([settlePnlIx], txParams, this.txVersion,
|
|
3045
|
+
txsToSign.settlePnlTx = await this.buildTransaction([settlePnlIx], txParams, this.txVersion, [lookupTableAccount], undefined, recentBlockHash, optionalIxs);
|
|
3045
3046
|
}
|
|
3046
3047
|
return;
|
|
3047
3048
|
};
|
|
@@ -3186,7 +3187,7 @@ class DriftClient {
|
|
|
3186
3187
|
* Borsh encode swift taker order params
|
|
3187
3188
|
*/
|
|
3188
3189
|
encodeSwiftOrderParamsMessage(orderParamsMessage) {
|
|
3189
|
-
const anchorIxName = 'global' + ':' + '
|
|
3190
|
+
const anchorIxName = 'global' + ':' + 'SwiftOrderParamsMessage';
|
|
3190
3191
|
const prefix = Buffer.from((0, sha256_1.sha256)(anchorIxName).slice(0, 8));
|
|
3191
3192
|
const buf = Buffer.concat([
|
|
3192
3193
|
prefix,
|
|
@@ -3647,8 +3648,9 @@ class DriftClient {
|
|
|
3647
3648
|
}
|
|
3648
3649
|
return ixs;
|
|
3649
3650
|
}
|
|
3650
|
-
async settlePNL(settleeUserAccountPublicKey, settleeUserAccount, marketIndex, txParams) {
|
|
3651
|
-
const
|
|
3651
|
+
async settlePNL(settleeUserAccountPublicKey, settleeUserAccount, marketIndex, txParams, optionalIxs) {
|
|
3652
|
+
const lookupTableAccount = await this.fetchMarketLookupTableAccount();
|
|
3653
|
+
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex), txParams, undefined, [lookupTableAccount], undefined, undefined, optionalIxs), [], this.opts);
|
|
3652
3654
|
return txSig;
|
|
3653
3655
|
}
|
|
3654
3656
|
async settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex) {
|
|
@@ -3829,7 +3831,7 @@ class DriftClient {
|
|
|
3829
3831
|
remainingAccounts: remainingAccounts,
|
|
3830
3832
|
});
|
|
3831
3833
|
}
|
|
3832
|
-
async getJupiterLiquidateSpotWithSwapIxV6({ jupiterClient, liabilityMarketIndex, assetMarketIndex, swapAmount, assetTokenAccount, liabilityTokenAccount, slippageBps, swapMode, onlyDirectRoutes, quote, userAccount, userAccountPublicKey, userStatsAccountPublicKey, liquidatorSubAccountId, }) {
|
|
3834
|
+
async getJupiterLiquidateSpotWithSwapIxV6({ jupiterClient, liabilityMarketIndex, assetMarketIndex, swapAmount, assetTokenAccount, liabilityTokenAccount, slippageBps, swapMode, onlyDirectRoutes, quote, userAccount, userAccountPublicKey, userStatsAccountPublicKey, liquidatorSubAccountId, maxAccounts, }) {
|
|
3833
3835
|
const liabilityMarket = this.getSpotMarketAccount(liabilityMarketIndex);
|
|
3834
3836
|
const assetMarket = this.getSpotMarketAccount(assetMarketIndex);
|
|
3835
3837
|
if (!quote) {
|
|
@@ -3840,6 +3842,7 @@ class DriftClient {
|
|
|
3840
3842
|
slippageBps,
|
|
3841
3843
|
swapMode,
|
|
3842
3844
|
onlyDirectRoutes,
|
|
3845
|
+
maxAccounts,
|
|
3843
3846
|
});
|
|
3844
3847
|
quote = fetchedQuote;
|
|
3845
3848
|
}
|
|
@@ -4893,7 +4896,7 @@ class DriftClient {
|
|
|
4893
4896
|
return this.txSender.send(tx, additionalSigners, opts !== null && opts !== void 0 ? opts : this.opts, preSigned);
|
|
4894
4897
|
}
|
|
4895
4898
|
}
|
|
4896
|
-
async buildTransaction(instructions, txParams, txVersion, lookupTables, forceVersionedTransaction, recentBlockhash) {
|
|
4899
|
+
async buildTransaction(instructions, txParams, txVersion, lookupTables, forceVersionedTransaction, recentBlockhash, optionalIxs) {
|
|
4897
4900
|
return this.txHandler.buildTransaction({
|
|
4898
4901
|
instructions,
|
|
4899
4902
|
txVersion: txVersion !== null && txVersion !== void 0 ? txVersion : this.txVersion,
|
|
@@ -4904,6 +4907,7 @@ class DriftClient {
|
|
|
4904
4907
|
lookupTables,
|
|
4905
4908
|
forceVersionedTransaction,
|
|
4906
4909
|
recentBlockhash,
|
|
4910
|
+
optionalIxs,
|
|
4907
4911
|
});
|
|
4908
4912
|
}
|
|
4909
4913
|
async buildBulkTransactions(instructions, txParams, txVersion, lookupTables, forceVersionedTransaction) {
|
|
@@ -6667,40 +6667,6 @@
|
|
|
6667
6667
|
{
|
|
6668
6668
|
"name": "feedId",
|
|
6669
6669
|
"type": "u32"
|
|
6670
|
-
},
|
|
6671
|
-
{
|
|
6672
|
-
"name": "exponent",
|
|
6673
|
-
"type": "i32"
|
|
6674
|
-
}
|
|
6675
|
-
]
|
|
6676
|
-
},
|
|
6677
|
-
{
|
|
6678
|
-
"name": "updatePythLazerOracleExponent",
|
|
6679
|
-
"accounts": [
|
|
6680
|
-
{
|
|
6681
|
-
"name": "admin",
|
|
6682
|
-
"isMut": true,
|
|
6683
|
-
"isSigner": true
|
|
6684
|
-
},
|
|
6685
|
-
{
|
|
6686
|
-
"name": "lazerOracle",
|
|
6687
|
-
"isMut": true,
|
|
6688
|
-
"isSigner": false
|
|
6689
|
-
},
|
|
6690
|
-
{
|
|
6691
|
-
"name": "state",
|
|
6692
|
-
"isMut": false,
|
|
6693
|
-
"isSigner": false
|
|
6694
|
-
}
|
|
6695
|
-
],
|
|
6696
|
-
"args": [
|
|
6697
|
-
{
|
|
6698
|
-
"name": "feedId",
|
|
6699
|
-
"type": "u32"
|
|
6700
|
-
},
|
|
6701
|
-
{
|
|
6702
|
-
"name": "exponent",
|
|
6703
|
-
"type": "i32"
|
|
6704
6670
|
}
|
|
6705
6671
|
]
|
|
6706
6672
|
},
|
|
@@ -11393,7 +11359,8 @@
|
|
|
11393
11359
|
"name": "Match",
|
|
11394
11360
|
"fields": [
|
|
11395
11361
|
"publicKey",
|
|
11396
|
-
"u16"
|
|
11362
|
+
"u16",
|
|
11363
|
+
"u64"
|
|
11397
11364
|
]
|
|
11398
11365
|
}
|
|
11399
11366
|
]
|
|
@@ -14675,6 +14642,11 @@
|
|
|
14675
14642
|
"code": 6308,
|
|
14676
14643
|
"name": "InvalidLiquidateSpotWithSwap",
|
|
14677
14644
|
"msg": "InvalidLiquidateSpotWithSwap"
|
|
14645
|
+
},
|
|
14646
|
+
{
|
|
14647
|
+
"code": 6309,
|
|
14648
|
+
"name": "SwiftUserContextUserMismatch",
|
|
14649
|
+
"msg": "User in swift message does not match user in ix context"
|
|
14678
14650
|
}
|
|
14679
14651
|
],
|
|
14680
14652
|
"metadata": {
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ export * from './oracles/pythClient';
|
|
|
86
86
|
export * from './oracles/pythPullClient';
|
|
87
87
|
export * from './oracles/pythLazerClient';
|
|
88
88
|
export * from './oracles/switchboardOnDemandClient';
|
|
89
|
+
export * from './oracles/oracleId';
|
|
89
90
|
export * from './swift/swiftOrderSubscriber';
|
|
90
91
|
export * from './tx/fastSingleTxSender';
|
|
91
92
|
export * from './tx/retryTxSender';
|
package/lib/browser/index.js
CHANGED
|
@@ -109,6 +109,7 @@ __exportStar(require("./oracles/pythClient"), exports);
|
|
|
109
109
|
__exportStar(require("./oracles/pythPullClient"), exports);
|
|
110
110
|
__exportStar(require("./oracles/pythLazerClient"), exports);
|
|
111
111
|
__exportStar(require("./oracles/switchboardOnDemandClient"), exports);
|
|
112
|
+
__exportStar(require("./oracles/oracleId"), exports);
|
|
112
113
|
__exportStar(require("./swift/swiftOrderSubscriber"), exports);
|
|
113
114
|
__exportStar(require("./tx/fastSingleTxSender"), exports);
|
|
114
115
|
__exportStar(require("./tx/retryTxSender"), exports);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { BN } from '@coral-xyz/anchor';
|
|
3
3
|
export declare function calculateBaseAssetAmountToCoverMarginShortage(marginShortage: BN, marginRatio: number, liquidationFee: number, ifLiquidationFee: number, oraclePrice: BN, quoteOraclePrice: BN): BN | undefined;
|
|
4
|
+
export declare function calculateLiabilityTransferToCoverMarginShortage(marginShortage: BN, assetWeight: number, assetLiquidationMultiplier: number, liabilityWeight: number, liabilityLiquidationMultiplier: number, liabilityDecimals: number, liabilityPrice: BN, ifLiquidationFee: number): BN | undefined;
|
|
5
|
+
export declare function calculateAssetTransferForLiabilityTransfer(assetAmount: BN, assetLiquidationMultiplier: number, assetDecimals: number, assetPrice: BN, liabilityAmount: BN, liabilityLiquidationMultiplier: number, liabilityDecimals: number, liabilityPrice: BN): BN | undefined;
|
|
4
6
|
export declare function calculateMaxPctToLiquidate(userLastActiveSlot: BN, userLiquidationMarginFreed: BN, marginShortage: BN, slot: BN, initialPctToLiquidate: BN, liquidationDuration: BN): BN;
|
|
7
|
+
export declare function getMarginShortage(maintenanceMarginRequirementPlusBuffer: BN, maintenanceTotalCollateral: BN): BN;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateMaxPctToLiquidate = exports.calculateBaseAssetAmountToCoverMarginShortage = void 0;
|
|
3
|
+
exports.getMarginShortage = exports.calculateMaxPctToLiquidate = exports.calculateAssetTransferForLiabilityTransfer = exports.calculateLiabilityTransferToCoverMarginShortage = exports.calculateBaseAssetAmountToCoverMarginShortage = void 0;
|
|
4
4
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
5
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
6
6
|
function calculateBaseAssetAmountToCoverMarginShortage(marginShortage, marginRatio, liquidationFee, ifLiquidationFee, oraclePrice, quoteOraclePrice) {
|
|
@@ -20,6 +20,88 @@ function calculateBaseAssetAmountToCoverMarginShortage(marginShortage, marginRat
|
|
|
20
20
|
.sub(oraclePrice.mul(new anchor_1.BN(ifLiquidationFee)).div(numericConstants_1.LIQUIDATION_FEE_PRECISION)));
|
|
21
21
|
}
|
|
22
22
|
exports.calculateBaseAssetAmountToCoverMarginShortage = calculateBaseAssetAmountToCoverMarginShortage;
|
|
23
|
+
function calculateLiabilityTransferToCoverMarginShortage(marginShortage, assetWeight, assetLiquidationMultiplier, liabilityWeight, liabilityLiquidationMultiplier, liabilityDecimals, liabilityPrice, ifLiquidationFee) {
|
|
24
|
+
if (assetWeight >= liabilityWeight) {
|
|
25
|
+
// undefined is max
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
let numeratorScale;
|
|
29
|
+
let denominatorScale;
|
|
30
|
+
if (liabilityDecimals > 6) {
|
|
31
|
+
numeratorScale = new anchor_1.BN(10).pow(new anchor_1.BN(liabilityDecimals - 6));
|
|
32
|
+
denominatorScale = new anchor_1.BN(1);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
numeratorScale = new anchor_1.BN(1);
|
|
36
|
+
denominatorScale = new anchor_1.BN(10).pow(new anchor_1.BN(6 - liabilityDecimals));
|
|
37
|
+
}
|
|
38
|
+
// multiply market weights by extra 10 to increase precision
|
|
39
|
+
const liabilityWeightComponent = liabilityWeight * 10;
|
|
40
|
+
const assetWeightComponent = (assetWeight * 10 * assetLiquidationMultiplier) /
|
|
41
|
+
liabilityLiquidationMultiplier;
|
|
42
|
+
if (assetWeightComponent >= liabilityWeightComponent) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return anchor_1.BN.max(marginShortage
|
|
46
|
+
.mul(numeratorScale)
|
|
47
|
+
.mul(numericConstants_1.PRICE_PRECISION.mul(numericConstants_1.SPOT_MARKET_WEIGHT_PRECISION).mul(numericConstants_1.TEN))
|
|
48
|
+
.div(liabilityPrice
|
|
49
|
+
.mul(new anchor_1.BN(liabilityWeightComponent).sub(new anchor_1.BN(assetWeightComponent)))
|
|
50
|
+
.sub(liabilityPrice
|
|
51
|
+
.mul(new anchor_1.BN(ifLiquidationFee))
|
|
52
|
+
.div(numericConstants_1.LIQUIDATION_FEE_PRECISION)
|
|
53
|
+
.mul(new anchor_1.BN(liabilityWeight))
|
|
54
|
+
.mul(new anchor_1.BN(10))))
|
|
55
|
+
.div(denominatorScale), numericConstants_1.ONE);
|
|
56
|
+
}
|
|
57
|
+
exports.calculateLiabilityTransferToCoverMarginShortage = calculateLiabilityTransferToCoverMarginShortage;
|
|
58
|
+
function calculateAssetTransferForLiabilityTransfer(assetAmount, assetLiquidationMultiplier, assetDecimals, assetPrice, liabilityAmount, liabilityLiquidationMultiplier, liabilityDecimals, liabilityPrice) {
|
|
59
|
+
let numeratorScale;
|
|
60
|
+
let denominatorScale;
|
|
61
|
+
if (assetDecimals > liabilityDecimals) {
|
|
62
|
+
numeratorScale = new anchor_1.BN(10).pow(new anchor_1.BN(assetDecimals - liabilityDecimals));
|
|
63
|
+
denominatorScale = new anchor_1.BN(1);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
numeratorScale = new anchor_1.BN(1);
|
|
67
|
+
denominatorScale = new anchor_1.BN(10).pow(new anchor_1.BN(liabilityDecimals - assetDecimals));
|
|
68
|
+
}
|
|
69
|
+
let assetTransfer = liabilityAmount
|
|
70
|
+
.mul(numeratorScale)
|
|
71
|
+
.mul(liabilityPrice)
|
|
72
|
+
.mul(new anchor_1.BN(assetLiquidationMultiplier))
|
|
73
|
+
.div(assetPrice.mul(new anchor_1.BN(liabilityLiquidationMultiplier)))
|
|
74
|
+
.div(denominatorScale);
|
|
75
|
+
assetTransfer = anchor_1.BN.max(assetTransfer, numericConstants_1.ONE);
|
|
76
|
+
// Need to check if asset_transfer should be rounded to asset amount
|
|
77
|
+
let assetValueNumeratorScale;
|
|
78
|
+
let assetValueDenominatorScale;
|
|
79
|
+
if (assetDecimals > 6) {
|
|
80
|
+
assetValueNumeratorScale = new anchor_1.BN(10).pow(new anchor_1.BN(assetDecimals - 6));
|
|
81
|
+
assetValueDenominatorScale = new anchor_1.BN(1);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
assetValueNumeratorScale = new anchor_1.BN(1);
|
|
85
|
+
assetValueDenominatorScale = new anchor_1.BN(10).pow(new anchor_1.BN(6 - assetDecimals));
|
|
86
|
+
}
|
|
87
|
+
let assetDelta;
|
|
88
|
+
if (assetTransfer > assetAmount) {
|
|
89
|
+
assetDelta = assetTransfer.sub(assetAmount);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
assetDelta = assetAmount.sub(assetTransfer);
|
|
93
|
+
}
|
|
94
|
+
const assetValueDelta = assetDelta
|
|
95
|
+
.mul(assetPrice)
|
|
96
|
+
.div(numericConstants_1.PRICE_PRECISION)
|
|
97
|
+
.mul(assetValueNumeratorScale)
|
|
98
|
+
.div(assetValueDenominatorScale);
|
|
99
|
+
if (assetValueDelta.lt(numericConstants_1.QUOTE_PRECISION)) {
|
|
100
|
+
assetTransfer = assetAmount;
|
|
101
|
+
}
|
|
102
|
+
return assetTransfer;
|
|
103
|
+
}
|
|
104
|
+
exports.calculateAssetTransferForLiabilityTransfer = calculateAssetTransferForLiabilityTransfer;
|
|
23
105
|
function calculateMaxPctToLiquidate(userLastActiveSlot, userLiquidationMarginFreed, marginShortage, slot, initialPctToLiquidate, liquidationDuration) {
|
|
24
106
|
// if margin shortage is tiny, accelerate liquidation
|
|
25
107
|
if (marginShortage.lt(new anchor_1.BN(50).mul(numericConstants_1.QUOTE_PRECISION))) {
|
|
@@ -44,3 +126,9 @@ function calculateMaxPctToLiquidate(userLastActiveSlot, userLiquidationMarginFre
|
|
|
44
126
|
return marginFreeable.mul(numericConstants_1.LIQUIDATION_PCT_PRECISION).div(marginShortage);
|
|
45
127
|
}
|
|
46
128
|
exports.calculateMaxPctToLiquidate = calculateMaxPctToLiquidate;
|
|
129
|
+
function getMarginShortage(maintenanceMarginRequirementPlusBuffer, maintenanceTotalCollateral) {
|
|
130
|
+
return maintenanceMarginRequirementPlusBuffer
|
|
131
|
+
.sub(maintenanceTotalCollateral)
|
|
132
|
+
.abs();
|
|
133
|
+
}
|
|
134
|
+
exports.getMarginShortage = getMarginShortage;
|
|
@@ -149,6 +149,22 @@ function getMultipleBetweenOracleSources(firstOracleSource, secondOracleSource)
|
|
|
149
149
|
(0, types_1.isVariant)(secondOracleSource, 'pythPull')) {
|
|
150
150
|
return { numerator: new index_1.BN(1), denominator: new index_1.BN(1000) };
|
|
151
151
|
}
|
|
152
|
+
if ((0, types_1.isVariant)(firstOracleSource, 'pythLazer') &&
|
|
153
|
+
(0, types_1.isVariant)(secondOracleSource, 'pythLazer1M')) {
|
|
154
|
+
return { numerator: new index_1.BN(1000000), denominator: new index_1.BN(1) };
|
|
155
|
+
}
|
|
156
|
+
if ((0, types_1.isVariant)(firstOracleSource, 'pythLazer') &&
|
|
157
|
+
(0, types_1.isVariant)(secondOracleSource, 'pythLazer1K')) {
|
|
158
|
+
return { numerator: new index_1.BN(1000), denominator: new index_1.BN(1) };
|
|
159
|
+
}
|
|
160
|
+
if ((0, types_1.isVariant)(firstOracleSource, 'pythLazer1M') &&
|
|
161
|
+
(0, types_1.isVariant)(secondOracleSource, 'pythLazer')) {
|
|
162
|
+
return { numerator: new index_1.BN(1), denominator: new index_1.BN(1000000) };
|
|
163
|
+
}
|
|
164
|
+
if ((0, types_1.isVariant)(firstOracleSource, 'pythLazer1K') &&
|
|
165
|
+
(0, types_1.isVariant)(secondOracleSource, 'pythLazer')) {
|
|
166
|
+
return { numerator: new index_1.BN(1), denominator: new index_1.BN(1000) };
|
|
167
|
+
}
|
|
152
168
|
return { numerator: new index_1.BN(1), denominator: new index_1.BN(1) };
|
|
153
169
|
}
|
|
154
170
|
exports.getMultipleBetweenOracleSources = getMultipleBetweenOracleSources;
|
|
@@ -29,6 +29,10 @@ function getOracleSourceNum(source) {
|
|
|
29
29
|
return types_1.OracleSourceNum.SWITCHBOARD_ON_DEMAND;
|
|
30
30
|
if ('pythLazer' in source)
|
|
31
31
|
return types_1.OracleSourceNum.PYTH_LAZER;
|
|
32
|
+
if ('pythLazer1K' in source)
|
|
33
|
+
return types_1.OracleSourceNum.PYTH_LAZER_1K;
|
|
34
|
+
if ('pythLazer1M' in source)
|
|
35
|
+
return types_1.OracleSourceNum.PYTH_LAZER_1M;
|
|
32
36
|
throw new Error('Invalid oracle source');
|
|
33
37
|
}
|
|
34
38
|
exports.getOracleSourceNum = getOracleSourceNum;
|
|
@@ -72,7 +72,7 @@ class SwiftOrderSubscriber {
|
|
|
72
72
|
if (message['order']) {
|
|
73
73
|
const order = JSON.parse(message['order']);
|
|
74
74
|
const swiftOrderParamsBuf = Buffer.from(order['order_message'], 'hex');
|
|
75
|
-
const swiftOrderParamsMessage = this.driftClient.
|
|
75
|
+
const swiftOrderParamsMessage = this.driftClient.decodeSwiftOrderParamsMessage(swiftOrderParamsBuf);
|
|
76
76
|
if (!swiftOrderParamsMessage.swiftOrderParams.price) {
|
|
77
77
|
console.error(`order has no price: ${JSON.stringify(swiftOrderParamsMessage.swiftOrderParams)}`);
|
|
78
78
|
return;
|
|
@@ -277,24 +277,35 @@ class TxHandler {
|
|
|
277
277
|
*/
|
|
278
278
|
async buildTransaction(props) {
|
|
279
279
|
var _a;
|
|
280
|
-
const {
|
|
280
|
+
const { txVersion, txParams, connection: _connection, preFlightCommitment: _preFlightCommitment, fetchMarketLookupTableAccount, forceVersionedTransaction, instructions, } = props;
|
|
281
281
|
let { lookupTables } = props;
|
|
282
282
|
// # Collect and process Tx Params
|
|
283
283
|
let baseTxParams = {
|
|
284
284
|
computeUnits: txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits,
|
|
285
285
|
computeUnitsPrice: txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice,
|
|
286
286
|
};
|
|
287
|
+
const instructionsArray = Array.isArray(instructions)
|
|
288
|
+
? instructions
|
|
289
|
+
: [instructions];
|
|
290
|
+
let instructionsToUse;
|
|
291
|
+
// add optional ixs if there's room (usually oracle cranks)
|
|
292
|
+
if (props.optionalIxs && txVersion === 0) {
|
|
293
|
+
instructionsToUse = (0, utils_1.getCombinedInstructions)(instructionsArray, props.optionalIxs, txVersion === 0, lookupTables);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
instructionsToUse = instructionsArray;
|
|
297
|
+
}
|
|
287
298
|
if (txParams === null || txParams === void 0 ? void 0 : txParams.useSimulatedComputeUnits) {
|
|
288
|
-
const processedTxParams = await this.getProcessedTransactionParams(
|
|
299
|
+
const processedTxParams = await this.getProcessedTransactionParams({
|
|
300
|
+
...props,
|
|
301
|
+
instructions: instructionsToUse,
|
|
302
|
+
});
|
|
289
303
|
baseTxParams = {
|
|
290
304
|
...baseTxParams,
|
|
291
305
|
...processedTxParams,
|
|
292
306
|
};
|
|
293
307
|
}
|
|
294
|
-
const
|
|
295
|
-
? instructions
|
|
296
|
-
: [instructions];
|
|
297
|
-
const { hasSetComputeUnitLimitIx, hasSetComputeUnitPriceIx } = (0, computeUnits_1.containsComputeUnitIxs)(instructionsArray);
|
|
308
|
+
const { hasSetComputeUnitLimitIx, hasSetComputeUnitPriceIx } = (0, computeUnits_1.containsComputeUnitIxs)(instructionsToUse);
|
|
298
309
|
// # Create Tx Instructions
|
|
299
310
|
const allIx = [];
|
|
300
311
|
const computeUnits = baseTxParams === null || baseTxParams === void 0 ? void 0 : baseTxParams.computeUnits;
|
|
@@ -314,7 +325,7 @@ class TxHandler {
|
|
|
314
325
|
microLamports: computeUnitsPrice,
|
|
315
326
|
}));
|
|
316
327
|
}
|
|
317
|
-
allIx.push(...
|
|
328
|
+
allIx.push(...instructionsToUse);
|
|
318
329
|
const recentBlockhash = (_a = props === null || props === void 0 ? void 0 : props.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.getLatestBlockhashForTransaction());
|
|
319
330
|
// # Create and return Transaction
|
|
320
331
|
if (txVersion === 'legacy') {
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
1
|
+
import { AddressLookupTableAccount, Transaction, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
|
|
2
2
|
export declare const isVersionedTransaction: (tx: Transaction | VersionedTransaction) => boolean;
|
|
3
|
+
export declare const getSizeOfTransaction: (instructions: TransactionInstruction[], versionedTransaction?: boolean, addressLookupTables?: AddressLookupTableAccount[]) => number;
|
|
4
|
+
export declare const getCombinedInstructions: (baseInstructions: TransactionInstruction[], optionalInstructions?: TransactionInstruction[], versionedTransaction?: boolean, addressLookupTables?: AddressLookupTableAccount[]) => TransactionInstruction[];
|