@lavarage/sdk 7.5.13 → 7.5.14

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.
Files changed (3) hide show
  1. package/idl/lavaragev2.ts +134 -2
  2. package/index.ts +29 -11
  3. package/package.json +1 -1
package/idl/lavaragev2.ts CHANGED
@@ -553,13 +553,23 @@ export type Lavarage = {
553
553
  },
554
554
  {
555
555
  "name": "toTokenAccount",
556
- "isMut": false,
556
+ "isMut": true,
557
557
  "isSigner": false
558
558
  },
559
559
  {
560
560
  "name": "randomAccountAsId",
561
561
  "isMut": false,
562
562
  "isSigner": false
563
+ },
564
+ {
565
+ "name": "tokenProgram",
566
+ "isMut": false,
567
+ "isSigner": false
568
+ },
569
+ {
570
+ "name": "associatedTokenProgram",
571
+ "isMut": false,
572
+ "isSigner": false
563
573
  }
564
574
  ],
565
575
  "args": [
@@ -626,6 +636,11 @@ export type Lavarage = {
626
636
  "name": "randomAccountAsId",
627
637
  "isMut": false,
628
638
  "isSigner": false
639
+ },
640
+ {
641
+ "name": "associatedTokenProgram",
642
+ "isMut": false,
643
+ "isSigner": false
629
644
  }
630
645
  ],
631
646
  "args": []
@@ -1319,6 +1334,57 @@ export type Lavarage = {
1319
1334
  "type": "string"
1320
1335
  }
1321
1336
  ]
1337
+ },
1338
+ {
1339
+ "name": "rescueStuckTokens",
1340
+ "accounts": [
1341
+ {
1342
+ "name": "position",
1343
+ "isMut": true,
1344
+ "isSigner": false
1345
+ },
1346
+ {
1347
+ "name": "pool",
1348
+ "isMut": true,
1349
+ "isSigner": false
1350
+ },
1351
+ {
1352
+ "name": "nodeWallet",
1353
+ "isMut": true,
1354
+ "isSigner": false
1355
+ },
1356
+ {
1357
+ "name": "positionTokenAccount",
1358
+ "isMut": true,
1359
+ "isSigner": false
1360
+ },
1361
+ {
1362
+ "name": "traderTokenAccount",
1363
+ "isMut": true,
1364
+ "isSigner": false
1365
+ },
1366
+ {
1367
+ "name": "positionMint",
1368
+ "isMut": true,
1369
+ "isSigner": false
1370
+ },
1371
+ {
1372
+ "name": "admin",
1373
+ "isMut": true,
1374
+ "isSigner": true
1375
+ },
1376
+ {
1377
+ "name": "tokenProgram",
1378
+ "isMut": false,
1379
+ "isSigner": false
1380
+ }
1381
+ ],
1382
+ "args": [
1383
+ {
1384
+ "name": "amount",
1385
+ "type": "u64"
1386
+ }
1387
+ ]
1322
1388
  }
1323
1389
  ],
1324
1390
  "accounts": [
@@ -2323,13 +2389,23 @@ export const IDL: Lavarage = {
2323
2389
  },
2324
2390
  {
2325
2391
  "name": "toTokenAccount",
2326
- "isMut": false,
2392
+ "isMut": true,
2327
2393
  "isSigner": false
2328
2394
  },
2329
2395
  {
2330
2396
  "name": "randomAccountAsId",
2331
2397
  "isMut": false,
2332
2398
  "isSigner": false
2399
+ },
2400
+ {
2401
+ "name": "tokenProgram",
2402
+ "isMut": false,
2403
+ "isSigner": false
2404
+ },
2405
+ {
2406
+ "name": "associatedTokenProgram",
2407
+ "isMut": false,
2408
+ "isSigner": false
2333
2409
  }
2334
2410
  ],
2335
2411
  "args": [
@@ -2396,6 +2472,11 @@ export const IDL: Lavarage = {
2396
2472
  "name": "randomAccountAsId",
2397
2473
  "isMut": false,
2398
2474
  "isSigner": false
2475
+ },
2476
+ {
2477
+ "name": "associatedTokenProgram",
2478
+ "isMut": false,
2479
+ "isSigner": false
2399
2480
  }
2400
2481
  ],
2401
2482
  "args": []
@@ -3089,6 +3170,57 @@ export const IDL: Lavarage = {
3089
3170
  "type": "string"
3090
3171
  }
3091
3172
  ]
3173
+ },
3174
+ {
3175
+ "name": "rescueStuckTokens",
3176
+ "accounts": [
3177
+ {
3178
+ "name": "position",
3179
+ "isMut": true,
3180
+ "isSigner": false
3181
+ },
3182
+ {
3183
+ "name": "pool",
3184
+ "isMut": true,
3185
+ "isSigner": false
3186
+ },
3187
+ {
3188
+ "name": "nodeWallet",
3189
+ "isMut": true,
3190
+ "isSigner": false
3191
+ },
3192
+ {
3193
+ "name": "positionTokenAccount",
3194
+ "isMut": true,
3195
+ "isSigner": false
3196
+ },
3197
+ {
3198
+ "name": "traderTokenAccount",
3199
+ "isMut": true,
3200
+ "isSigner": false
3201
+ },
3202
+ {
3203
+ "name": "positionMint",
3204
+ "isMut": true,
3205
+ "isSigner": false
3206
+ },
3207
+ {
3208
+ "name": "admin",
3209
+ "isMut": true,
3210
+ "isSigner": true
3211
+ },
3212
+ {
3213
+ "name": "tokenProgram",
3214
+ "isMut": false,
3215
+ "isSigner": false
3216
+ }
3217
+ ],
3218
+ "args": [
3219
+ {
3220
+ "name": "amount",
3221
+ "type": "u64"
3222
+ }
3223
+ ]
3092
3224
  }
3093
3225
  ],
3094
3226
  "accounts": [
package/index.ts CHANGED
@@ -816,6 +816,8 @@ export const borrowV2 = async (
816
816
  systemProgram: SystemProgram.programId,
817
817
  positionAccount,
818
818
  randomAccountAsId: randomSeed.publicKey.toBase58(),
819
+ tokenProgram: tokenProgram,
820
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
819
821
  })
820
822
  .instruction();
821
823
 
@@ -825,7 +827,6 @@ export const borrowV2 = async (
825
827
 
826
828
  const allInstructions = [
827
829
  fromTokenAccount.instruction!,
828
- toTokenAccount.instruction!,
829
830
  partnerFeeRecipientVaultCreateIx,
830
831
  partnerFeeRecipientTokenAccountCreateIx,
831
832
  tradingOpenBorrowInstruction!,
@@ -1418,6 +1419,13 @@ export const openTradeV2 = async (
1418
1419
  let partnerFeeRecipientVaultCreateIx: TransactionInstruction | undefined;
1419
1420
  let partnerFeeRecipientTokenAccountCreateIx: TransactionInstruction | undefined;
1420
1421
  let userVaultPda: PublicKey | undefined;
1422
+
1423
+ const partnerDirectAta = partnerFeeRecipient ? getAssociatedTokenAddressSync(
1424
+ quoteToken,
1425
+ partnerFeeRecipient,
1426
+ true,
1427
+ quoteTokenProgram
1428
+ ) : undefined;
1421
1429
 
1422
1430
  if (partnerFeeRecipient && partnerFeeMarkupAsPkey && referralVaultProgram) {
1423
1431
  // Derive the userVault PDA
@@ -1464,14 +1472,23 @@ export const openTradeV2 = async (
1464
1472
  ASSOCIATED_TOKEN_PROGRAM_ID
1465
1473
  );
1466
1474
  }
1475
+ } else if (partnerFeeRecipient && partnerDirectAta) {
1476
+ const [partnerDirectAtaInfo] = await lavarageProgram.provider.connection.getMultipleAccountsInfo([
1477
+ partnerDirectAta
1478
+ ]);
1479
+ if (!partnerDirectAtaInfo) {
1480
+ partnerFeeRecipientTokenAccountCreateIx = createAssociatedTokenAccountIdempotentInstruction(
1481
+ lavarageProgram.provider.publicKey!,
1482
+ partnerDirectAta,
1483
+ partnerFeeRecipient!,
1484
+ quoteToken,
1485
+ quoteTokenProgram,
1486
+ ASSOCIATED_TOKEN_PROGRAM_ID
1487
+ );
1488
+ }
1467
1489
  }
1468
1490
 
1469
- const partnerDirectAta = partnerFeeRecipient ? getAssociatedTokenAddressSync(
1470
- quoteToken,
1471
- partnerFeeRecipient,
1472
- true,
1473
- quoteTokenProgram
1474
- ) : undefined;
1491
+
1475
1492
 
1476
1493
  const tradingOpenBorrowInstruction = useReferral
1477
1494
  ? await lavarageProgram.methods
@@ -1589,6 +1606,8 @@ export const openTradeV2 = async (
1589
1606
  systemProgram: SystemProgram.programId,
1590
1607
  positionAccount,
1591
1608
  randomAccountAsId: randomSeed.publicKey.toBase58(),
1609
+ tokenProgram: tokenProgram,
1610
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
1592
1611
  })
1593
1612
  .instruction();
1594
1613
 
@@ -1604,7 +1623,6 @@ export const openTradeV2 = async (
1604
1623
  if (splitTransactions) {
1605
1624
  const setUpInstructions = [
1606
1625
  fromTokenAccount.instruction!,
1607
- toTokenAccount.instruction!,
1608
1626
  partnerFeeRecipientVaultCreateIx,
1609
1627
  partnerFeeRecipientTokenAccountCreateIx,
1610
1628
  ...setupInstructions.map(deserializeInstruction),
@@ -1638,7 +1656,6 @@ export const openTradeV2 = async (
1638
1656
 
1639
1657
  const allInstructions = [
1640
1658
  fromTokenAccount.instruction!,
1641
- toTokenAccount.instruction!,
1642
1659
  partnerFeeRecipientVaultCreateIx,
1643
1660
  partnerFeeRecipientTokenAccountCreateIx,
1644
1661
  tradingOpenBorrowInstruction!,
@@ -2740,6 +2757,7 @@ export const closeTradeV2 = async (
2740
2757
  trader: lavarageProgram.provider.publicKey!,
2741
2758
  tokenProgram: tokenProgram!,
2742
2759
  randomAccountAsId: position.account.seed,
2760
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
2743
2761
  })
2744
2762
  .instruction();
2745
2763
 
@@ -3010,7 +3028,7 @@ export const closeTradeV2 = async (
3010
3028
  partnerFeeRecipientVaultCreateIx,
3011
3029
  partnerFeeRecipientTokenAccountCreateIx,
3012
3030
  jupInstruction.instructions && platformFeeRecipientAccount?.instruction ? platformFeeRecipientAccount.instruction : null,
3013
- createAssociatedTokenAccountInstruction,
3031
+ //createAssociatedTokenAccountInstruction,
3014
3032
  ].filter((i) => !!i);
3015
3033
 
3016
3034
  const allInstructions = [
@@ -3048,7 +3066,7 @@ export const closeTradeV2 = async (
3048
3066
  partnerFeeRecipientVaultCreateIx,
3049
3067
  partnerFeeRecipientTokenAccountCreateIx,
3050
3068
  jupInstruction.instructions && platformFeeRecipientAccount?.instruction ? platformFeeRecipientAccount.instruction : null,
3051
- createAssociatedTokenAccountInstruction,
3069
+ //createAssociatedTokenAccountInstruction,
3052
3070
  jupInstruction.instructions?.tokenLedgerInstruction
3053
3071
  ? deserializeInstruction(
3054
3072
  jupInstruction.instructions.tokenLedgerInstruction
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavarage/sdk",
3
- "version": "7.5.13",
3
+ "version": "7.5.14",
4
4
  "description": "Lavarage SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",