@lavarage/sdk 6.4.4 → 6.4.6
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 +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +67 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -7
- package/dist/index.mjs.map +1 -1
- package/idl/lavaragev2.ts +50 -0
- package/index.ts +43 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2190,6 +2190,31 @@ type Lavarage = {
|
|
|
2190
2190
|
"name": "systemProgram";
|
|
2191
2191
|
"isMut": false;
|
|
2192
2192
|
"isSigner": false;
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
"name": "tokenProgram";
|
|
2196
|
+
"isMut": false;
|
|
2197
|
+
"isSigner": false;
|
|
2198
|
+
},
|
|
2199
|
+
{
|
|
2200
|
+
"name": "mint";
|
|
2201
|
+
"isMut": false;
|
|
2202
|
+
"isSigner": false;
|
|
2203
|
+
},
|
|
2204
|
+
{
|
|
2205
|
+
"name": "positionOneTokenAccount";
|
|
2206
|
+
"isMut": true;
|
|
2207
|
+
"isSigner": false;
|
|
2208
|
+
},
|
|
2209
|
+
{
|
|
2210
|
+
"name": "positionTwoTokenAccount";
|
|
2211
|
+
"isMut": true;
|
|
2212
|
+
"isSigner": false;
|
|
2213
|
+
},
|
|
2214
|
+
{
|
|
2215
|
+
"name": "mergedPositionTokenAccount";
|
|
2216
|
+
"isMut": true;
|
|
2217
|
+
"isSigner": false;
|
|
2193
2218
|
}
|
|
2194
2219
|
];
|
|
2195
2220
|
"args": [
|
package/dist/index.d.ts
CHANGED
|
@@ -2190,6 +2190,31 @@ type Lavarage = {
|
|
|
2190
2190
|
"name": "systemProgram";
|
|
2191
2191
|
"isMut": false;
|
|
2192
2192
|
"isSigner": false;
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
"name": "tokenProgram";
|
|
2196
|
+
"isMut": false;
|
|
2197
|
+
"isSigner": false;
|
|
2198
|
+
},
|
|
2199
|
+
{
|
|
2200
|
+
"name": "mint";
|
|
2201
|
+
"isMut": false;
|
|
2202
|
+
"isSigner": false;
|
|
2203
|
+
},
|
|
2204
|
+
{
|
|
2205
|
+
"name": "positionOneTokenAccount";
|
|
2206
|
+
"isMut": true;
|
|
2207
|
+
"isSigner": false;
|
|
2208
|
+
},
|
|
2209
|
+
{
|
|
2210
|
+
"name": "positionTwoTokenAccount";
|
|
2211
|
+
"isMut": true;
|
|
2212
|
+
"isSigner": false;
|
|
2213
|
+
},
|
|
2214
|
+
{
|
|
2215
|
+
"name": "mergedPositionTokenAccount";
|
|
2216
|
+
"isMut": true;
|
|
2217
|
+
"isSigner": false;
|
|
2193
2218
|
}
|
|
2194
2219
|
];
|
|
2195
2220
|
"args": [
|
package/dist/index.js
CHANGED
|
@@ -2289,6 +2289,31 @@ var IDL2 = {
|
|
|
2289
2289
|
"name": "systemProgram",
|
|
2290
2290
|
"isMut": false,
|
|
2291
2291
|
"isSigner": false
|
|
2292
|
+
},
|
|
2293
|
+
{
|
|
2294
|
+
"name": "tokenProgram",
|
|
2295
|
+
"isMut": false,
|
|
2296
|
+
"isSigner": false
|
|
2297
|
+
},
|
|
2298
|
+
{
|
|
2299
|
+
"name": "mint",
|
|
2300
|
+
"isMut": false,
|
|
2301
|
+
"isSigner": false
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
"name": "positionOneTokenAccount",
|
|
2305
|
+
"isMut": true,
|
|
2306
|
+
"isSigner": false
|
|
2307
|
+
},
|
|
2308
|
+
{
|
|
2309
|
+
"name": "positionTwoTokenAccount",
|
|
2310
|
+
"isMut": true,
|
|
2311
|
+
"isSigner": false
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
"name": "mergedPositionTokenAccount",
|
|
2315
|
+
"isMut": true,
|
|
2316
|
+
"isSigner": false
|
|
2292
2317
|
}
|
|
2293
2318
|
],
|
|
2294
2319
|
"args": [
|
|
@@ -3135,7 +3160,7 @@ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(void 0
|
|
|
3135
3160
|
return new import_web3.VersionedTransaction(messageV0);
|
|
3136
3161
|
});
|
|
3137
3162
|
var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
3138
|
-
var _a;
|
|
3163
|
+
var _a, _b;
|
|
3139
3164
|
let partnerFeeMarkupAsPkey;
|
|
3140
3165
|
if (partnerFeeMarkup) {
|
|
3141
3166
|
const feeBuffer = Buffer.alloc(8);
|
|
@@ -3243,8 +3268,16 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
3243
3268
|
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts(["5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi", ...addressLookupTableAddresses]));
|
|
3244
3269
|
}
|
|
3245
3270
|
const profit = new import_anchor.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
|
|
3271
|
+
let createAssociatedTokenAccountInstruction2 = (0, import_spl_token.createAssociatedTokenAccountIdempotentInstruction)(
|
|
3272
|
+
lavarageProgram.provider.publicKey,
|
|
3273
|
+
toTokenAccount.account.address,
|
|
3274
|
+
lavarageProgram.provider.publicKey,
|
|
3275
|
+
offer.account.collateralType,
|
|
3276
|
+
tokenProgram
|
|
3277
|
+
);
|
|
3246
3278
|
const allInstructions = [
|
|
3247
|
-
((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ?
|
|
3279
|
+
((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? createAssociatedTokenAccountInstruction2 : null,
|
|
3280
|
+
((_b = jupInstruction.instructions) == null ? void 0 : _b.tokenLedgerInstruction) ? deserializeInstruction(jupInstruction.instructions.tokenLedgerInstruction) : null,
|
|
3248
3281
|
toTokenAccount.instruction,
|
|
3249
3282
|
closePositionIx,
|
|
3250
3283
|
...jupiterIxs,
|
|
@@ -3259,7 +3292,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
3259
3292
|
return tx;
|
|
3260
3293
|
});
|
|
3261
3294
|
var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
3262
|
-
var _a;
|
|
3295
|
+
var _a, _b;
|
|
3263
3296
|
let partnerFeeMarkupAsPkey;
|
|
3264
3297
|
if (partnerFeeMarkup) {
|
|
3265
3298
|
const feeBuffer = Buffer.alloc(8);
|
|
@@ -3377,8 +3410,16 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
|
|
|
3377
3410
|
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts([...addressLookupTableAddresses, getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()), "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi"]));
|
|
3378
3411
|
}
|
|
3379
3412
|
const profit = new import_anchor.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
|
|
3413
|
+
let createAssociatedTokenAccountInstruction2 = (0, import_spl_token.createAssociatedTokenAccountIdempotentInstruction)(
|
|
3414
|
+
lavarageProgram.provider.publicKey,
|
|
3415
|
+
toTokenAccount.account.address,
|
|
3416
|
+
lavarageProgram.provider.publicKey,
|
|
3417
|
+
offer.account.collateralType,
|
|
3418
|
+
tokenProgram
|
|
3419
|
+
);
|
|
3380
3420
|
const allInstructions = [
|
|
3381
|
-
((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ?
|
|
3421
|
+
((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? createAssociatedTokenAccountInstruction2 : null,
|
|
3422
|
+
((_b = jupInstruction.instructions) == null ? void 0 : _b.tokenLedgerInstruction) ? deserializeInstruction(jupInstruction.instructions.tokenLedgerInstruction) : null,
|
|
3382
3423
|
toTokenAccount.instruction,
|
|
3383
3424
|
closePositionIx,
|
|
3384
3425
|
...jupiterIxs,
|
|
@@ -3475,15 +3516,35 @@ var mergePositionV2 = (lavarageProgram, position1, position2, offer, quoteToken)
|
|
|
3475
3516
|
const positionAccountPDA2 = position2.publicKey;
|
|
3476
3517
|
const newPositionSeed = import_web3.Keypair.generate().publicKey;
|
|
3477
3518
|
const newPositionAccountPDA = getPositionAccountPDA(lavarageProgram, offer, newPositionSeed);
|
|
3519
|
+
const mintAccount = yield lavarageProgram.provider.connection.getAccountInfo(offer.account.collateralType);
|
|
3520
|
+
const tokenProgram = mintAccount == null ? void 0 : mintAccount.owner;
|
|
3521
|
+
const newPositionTokenAccount = (0, import_spl_token.getAssociatedTokenAddressSync)(offer.account.collateralType, newPositionAccountPDA, true, tokenProgram);
|
|
3522
|
+
const createNewPositionTokenAccountIx = (0, import_spl_token.createAssociatedTokenAccountInstruction)(
|
|
3523
|
+
lavarageProgram.provider.publicKey,
|
|
3524
|
+
newPositionTokenAccount,
|
|
3525
|
+
newPositionAccountPDA,
|
|
3526
|
+
offer.account.collateralType,
|
|
3527
|
+
tokenProgram
|
|
3528
|
+
);
|
|
3478
3529
|
const ix = yield lavarageProgram.methods.tradingManagementMergePositions(newPositionSeed).accountsStrict({
|
|
3479
3530
|
mergedPosition: newPositionAccountPDA,
|
|
3480
3531
|
positionOne: positionAccountPDA1,
|
|
3481
3532
|
positionTwo: positionAccountPDA2,
|
|
3482
3533
|
trader: lavarageProgram.provider.publicKey,
|
|
3483
|
-
systemProgram: import_web3.SystemProgram.programId
|
|
3534
|
+
systemProgram: import_web3.SystemProgram.programId,
|
|
3535
|
+
mint: offer.account.collateralType,
|
|
3536
|
+
tokenProgram,
|
|
3537
|
+
positionOneTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(offer.account.collateralType, positionAccountPDA1, true, tokenProgram),
|
|
3538
|
+
positionTwoTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(offer.account.collateralType, positionAccountPDA2, true, tokenProgram),
|
|
3539
|
+
mergedPositionTokenAccount: newPositionTokenAccount
|
|
3484
3540
|
}).instruction();
|
|
3541
|
+
const computeBudgetIx = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
|
|
3542
|
+
microLamports: 1e5
|
|
3543
|
+
});
|
|
3485
3544
|
const allInstructions = [
|
|
3486
|
-
|
|
3545
|
+
createNewPositionTokenAccountIx,
|
|
3546
|
+
ix,
|
|
3547
|
+
computeBudgetIx
|
|
3487
3548
|
].filter((i) => !!i);
|
|
3488
3549
|
const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
3489
3550
|
const messageV0 = new import_web3.TransactionMessage({
|