@lavarage/sdk 7.2.0 → 7.2.2
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/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +122 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -9
- package/dist/index.mjs.map +1 -1
- package/index.ts +263 -120
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4733,7 +4733,7 @@ var getLiquidatedPositions = (lavarageProgram) => {
|
|
|
4733
4733
|
var getAllPositions = (lavarageProgram) => {
|
|
4734
4734
|
return lavarageProgram.account.position.all([{ dataSize: 178 }]);
|
|
4735
4735
|
};
|
|
4736
|
-
var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient) => __async(void 0, null, function* () {
|
|
4736
|
+
var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions) => __async(void 0, null, function* () {
|
|
4737
4737
|
let partnerFeeMarkupAsPkey;
|
|
4738
4738
|
if (partnerFeeMarkup) {
|
|
4739
4739
|
const feeBuffer = Buffer.alloc(8);
|
|
@@ -4861,6 +4861,33 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
4861
4861
|
const computeFeeIx = ComputeBudgetProgram2.setComputeUnitPrice({
|
|
4862
4862
|
microLamports: computeBudgetMicroLamports != null ? computeBudgetMicroLamports : 1e5
|
|
4863
4863
|
});
|
|
4864
|
+
if (splitTransactions) {
|
|
4865
|
+
const setUpInstructions = [
|
|
4866
|
+
fromTokenAccount.instruction,
|
|
4867
|
+
toTokenAccount.instruction,
|
|
4868
|
+
...setupInstructions.map(deserializeInstruction)
|
|
4869
|
+
];
|
|
4870
|
+
const allInstructions2 = [
|
|
4871
|
+
tradingOpenBorrowInstruction,
|
|
4872
|
+
deserializeInstruction(swapInstructionPayload),
|
|
4873
|
+
,
|
|
4874
|
+
openAddCollateralInstruction,
|
|
4875
|
+
computeBudgetMicroLamports ? computeFeeIx : void 0
|
|
4876
|
+
].filter(Boolean);
|
|
4877
|
+
const messageV01 = new TransactionMessage2({
|
|
4878
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
4879
|
+
recentBlockhash: blockhash,
|
|
4880
|
+
instructions: setUpInstructions
|
|
4881
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
4882
|
+
const tx2 = new VersionedTransaction2(messageV01);
|
|
4883
|
+
const messageV02 = new TransactionMessage2({
|
|
4884
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
4885
|
+
recentBlockhash: blockhash,
|
|
4886
|
+
instructions: allInstructions2
|
|
4887
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
4888
|
+
const tx3 = new VersionedTransaction2(messageV02);
|
|
4889
|
+
return [tx2, tx3];
|
|
4890
|
+
}
|
|
4864
4891
|
const allInstructions = [
|
|
4865
4892
|
fromTokenAccount.instruction,
|
|
4866
4893
|
toTokenAccount.instruction,
|
|
@@ -4877,7 +4904,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
4877
4904
|
const tx = new VersionedTransaction2(messageV0);
|
|
4878
4905
|
return tx;
|
|
4879
4906
|
});
|
|
4880
|
-
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient) => __async(void 0, null, function* () {
|
|
4907
|
+
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions) => __async(void 0, null, function* () {
|
|
4881
4908
|
let partnerFeeMarkupAsPkey;
|
|
4882
4909
|
if (partnerFeeMarkup) {
|
|
4883
4910
|
const feeBuffer = Buffer.alloc(8);
|
|
@@ -5031,6 +5058,33 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
5031
5058
|
const computeFeeIx = ComputeBudgetProgram2.setComputeUnitPrice({
|
|
5032
5059
|
microLamports: computeBudgetMicroLamports != null ? computeBudgetMicroLamports : 1e5
|
|
5033
5060
|
});
|
|
5061
|
+
if (splitTransactions) {
|
|
5062
|
+
const setUpInstructions = [
|
|
5063
|
+
fromTokenAccount.instruction,
|
|
5064
|
+
toTokenAccount.instruction,
|
|
5065
|
+
...setupInstructions.map(deserializeInstruction)
|
|
5066
|
+
];
|
|
5067
|
+
const allInstructions2 = [
|
|
5068
|
+
tradingOpenBorrowInstruction,
|
|
5069
|
+
deserializeInstruction(swapInstructionPayload),
|
|
5070
|
+
,
|
|
5071
|
+
openAddCollateralInstruction,
|
|
5072
|
+
computeBudgetMicroLamports ? computeFeeIx : void 0
|
|
5073
|
+
].filter(Boolean);
|
|
5074
|
+
const messageV01 = new TransactionMessage2({
|
|
5075
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
5076
|
+
recentBlockhash: blockhash,
|
|
5077
|
+
instructions: setUpInstructions
|
|
5078
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
5079
|
+
const tx2 = new VersionedTransaction2(messageV01);
|
|
5080
|
+
const messageV02 = new TransactionMessage2({
|
|
5081
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
5082
|
+
recentBlockhash: blockhash,
|
|
5083
|
+
instructions: allInstructions2
|
|
5084
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
5085
|
+
const tx3 = new VersionedTransaction2(messageV02);
|
|
5086
|
+
return [tx2, tx3];
|
|
5087
|
+
}
|
|
5034
5088
|
const allInstructions = [
|
|
5035
5089
|
fromTokenAccount.instruction,
|
|
5036
5090
|
toTokenAccount.instruction,
|
|
@@ -5208,7 +5262,7 @@ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(void 0
|
|
|
5208
5262
|
}).compileToV0Message();
|
|
5209
5263
|
return new VersionedTransaction2(messageV0);
|
|
5210
5264
|
});
|
|
5211
|
-
var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient) => __async(void 0, null, function* () {
|
|
5265
|
+
var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions) => __async(void 0, null, function* () {
|
|
5212
5266
|
var _a, _b;
|
|
5213
5267
|
let partnerFeeMarkupAsPkey;
|
|
5214
5268
|
if (partnerFeeMarkup) {
|
|
@@ -5376,13 +5430,40 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
5376
5430
|
const computeFeeIx = ComputeBudgetProgram2.setComputeUnitPrice({
|
|
5377
5431
|
microLamports: computeBudgetMicroLamports != null ? computeBudgetMicroLamports : 1e5
|
|
5378
5432
|
});
|
|
5433
|
+
if (splitTransactions) {
|
|
5434
|
+
const setUpInstructions = [
|
|
5435
|
+
jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
|
|
5436
|
+
createAssociatedTokenAccountInstruction2
|
|
5437
|
+
].filter((i) => !!i);
|
|
5438
|
+
const allInstructions2 = [
|
|
5439
|
+
((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? deserializeInstruction(
|
|
5440
|
+
jupInstruction.instructions.tokenLedgerInstruction
|
|
5441
|
+
) : null,
|
|
5442
|
+
closePositionIx,
|
|
5443
|
+
...jupiterIxs,
|
|
5444
|
+
repaySolIx,
|
|
5445
|
+
computeBudgetMicroLamports ? computeFeeIx : void 0
|
|
5446
|
+
].filter((i) => !!i);
|
|
5447
|
+
const messageV01 = new TransactionMessage2({
|
|
5448
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
5449
|
+
recentBlockhash: blockhash,
|
|
5450
|
+
instructions: setUpInstructions
|
|
5451
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
5452
|
+
const tx2 = new VersionedTransaction2(messageV01);
|
|
5453
|
+
const messageV02 = new TransactionMessage2({
|
|
5454
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
5455
|
+
recentBlockhash: blockhash,
|
|
5456
|
+
instructions: allInstructions2
|
|
5457
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
5458
|
+
const tx22 = new VersionedTransaction2(messageV02);
|
|
5459
|
+
return [tx2, tx22];
|
|
5460
|
+
}
|
|
5379
5461
|
const allInstructions = [
|
|
5380
5462
|
jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
|
|
5381
|
-
|
|
5463
|
+
createAssociatedTokenAccountInstruction2,
|
|
5382
5464
|
((_b = jupInstruction.instructions) == null ? void 0 : _b.tokenLedgerInstruction) ? deserializeInstruction(
|
|
5383
5465
|
jupInstruction.instructions.tokenLedgerInstruction
|
|
5384
5466
|
) : null,
|
|
5385
|
-
toTokenAccount.instruction,
|
|
5386
5467
|
closePositionIx,
|
|
5387
5468
|
...jupiterIxs,
|
|
5388
5469
|
repaySolIx,
|
|
@@ -5396,7 +5477,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
5396
5477
|
const tx = new VersionedTransaction2(messageV0);
|
|
5397
5478
|
return tx;
|
|
5398
5479
|
});
|
|
5399
|
-
var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient) => __async(void 0, null, function* () {
|
|
5480
|
+
var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions) => __async(void 0, null, function* () {
|
|
5400
5481
|
var _a, _b;
|
|
5401
5482
|
let partnerFeeMarkupAsPkey;
|
|
5402
5483
|
if (partnerFeeMarkup) {
|
|
@@ -5569,7 +5650,12 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
|
|
|
5569
5650
|
}).remainingAccounts(
|
|
5570
5651
|
partnerFeeRecipient && partnerFeeMarkupAsPkey ? [
|
|
5571
5652
|
{
|
|
5572
|
-
pubkey:
|
|
5653
|
+
pubkey: getAssociatedTokenAddressSync2(
|
|
5654
|
+
quoteToken,
|
|
5655
|
+
partnerFeeRecipient,
|
|
5656
|
+
false,
|
|
5657
|
+
quoteTokenProgram
|
|
5658
|
+
),
|
|
5573
5659
|
isSigner: false,
|
|
5574
5660
|
isWritable: true
|
|
5575
5661
|
},
|
|
@@ -5610,13 +5696,40 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
|
|
|
5610
5696
|
const computeFeeIx = ComputeBudgetProgram2.setComputeUnitPrice({
|
|
5611
5697
|
microLamports: computeBudgetMicroLamports != null ? computeBudgetMicroLamports : 1e5
|
|
5612
5698
|
});
|
|
5699
|
+
if (splitTransactions) {
|
|
5700
|
+
const setUpInstructions = [
|
|
5701
|
+
jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
|
|
5702
|
+
createAssociatedTokenAccountInstruction2
|
|
5703
|
+
].filter((i) => !!i);
|
|
5704
|
+
const allInstructions2 = [
|
|
5705
|
+
((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? deserializeInstruction(
|
|
5706
|
+
jupInstruction.instructions.tokenLedgerInstruction
|
|
5707
|
+
) : null,
|
|
5708
|
+
closePositionIx,
|
|
5709
|
+
...jupiterIxs,
|
|
5710
|
+
repaySolIx,
|
|
5711
|
+
computeBudgetMicroLamports ? computeFeeIx : void 0
|
|
5712
|
+
].filter((i) => !!i);
|
|
5713
|
+
const messageV01 = new TransactionMessage2({
|
|
5714
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
5715
|
+
recentBlockhash: blockhash,
|
|
5716
|
+
instructions: setUpInstructions
|
|
5717
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
5718
|
+
const tx2 = new VersionedTransaction2(messageV01);
|
|
5719
|
+
const messageV02 = new TransactionMessage2({
|
|
5720
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
5721
|
+
recentBlockhash: blockhash,
|
|
5722
|
+
instructions: allInstructions2
|
|
5723
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
5724
|
+
const tx22 = new VersionedTransaction2(messageV02);
|
|
5725
|
+
return [tx2, tx22];
|
|
5726
|
+
}
|
|
5613
5727
|
const allInstructions = [
|
|
5614
5728
|
jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
|
|
5615
|
-
|
|
5729
|
+
createAssociatedTokenAccountInstruction2,
|
|
5616
5730
|
((_b = jupInstruction.instructions) == null ? void 0 : _b.tokenLedgerInstruction) ? deserializeInstruction(
|
|
5617
5731
|
jupInstruction.instructions.tokenLedgerInstruction
|
|
5618
5732
|
) : null,
|
|
5619
|
-
toTokenAccount.instruction,
|
|
5620
5733
|
closePositionIx,
|
|
5621
5734
|
...jupiterIxs,
|
|
5622
5735
|
repaySolIx,
|