@lavarage/sdk 7.5.13 → 7.5.15

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 CHANGED
@@ -2241,13 +2241,23 @@ type Lavarage = {
2241
2241
  },
2242
2242
  {
2243
2243
  "name": "toTokenAccount";
2244
- "isMut": false;
2244
+ "isMut": true;
2245
2245
  "isSigner": false;
2246
2246
  },
2247
2247
  {
2248
2248
  "name": "randomAccountAsId";
2249
2249
  "isMut": false;
2250
2250
  "isSigner": false;
2251
+ },
2252
+ {
2253
+ "name": "tokenProgram";
2254
+ "isMut": false;
2255
+ "isSigner": false;
2256
+ },
2257
+ {
2258
+ "name": "associatedTokenProgram";
2259
+ "isMut": false;
2260
+ "isSigner": false;
2251
2261
  }
2252
2262
  ];
2253
2263
  "args": [
@@ -2314,6 +2324,11 @@ type Lavarage = {
2314
2324
  "name": "randomAccountAsId";
2315
2325
  "isMut": false;
2316
2326
  "isSigner": false;
2327
+ },
2328
+ {
2329
+ "name": "associatedTokenProgram";
2330
+ "isMut": false;
2331
+ "isSigner": false;
2317
2332
  }
2318
2333
  ];
2319
2334
  "args": [];
@@ -3007,6 +3022,57 @@ type Lavarage = {
3007
3022
  "type": "string";
3008
3023
  }
3009
3024
  ];
3025
+ },
3026
+ {
3027
+ "name": "rescueStuckTokens";
3028
+ "accounts": [
3029
+ {
3030
+ "name": "position";
3031
+ "isMut": true;
3032
+ "isSigner": false;
3033
+ },
3034
+ {
3035
+ "name": "pool";
3036
+ "isMut": true;
3037
+ "isSigner": false;
3038
+ },
3039
+ {
3040
+ "name": "nodeWallet";
3041
+ "isMut": true;
3042
+ "isSigner": false;
3043
+ },
3044
+ {
3045
+ "name": "positionTokenAccount";
3046
+ "isMut": true;
3047
+ "isSigner": false;
3048
+ },
3049
+ {
3050
+ "name": "traderTokenAccount";
3051
+ "isMut": true;
3052
+ "isSigner": false;
3053
+ },
3054
+ {
3055
+ "name": "positionMint";
3056
+ "isMut": true;
3057
+ "isSigner": false;
3058
+ },
3059
+ {
3060
+ "name": "admin";
3061
+ "isMut": true;
3062
+ "isSigner": true;
3063
+ },
3064
+ {
3065
+ "name": "tokenProgram";
3066
+ "isMut": false;
3067
+ "isSigner": false;
3068
+ }
3069
+ ];
3070
+ "args": [
3071
+ {
3072
+ "name": "amount";
3073
+ "type": "u64";
3074
+ }
3075
+ ];
3010
3076
  }
3011
3077
  ];
3012
3078
  "accounts": [
package/dist/index.d.ts CHANGED
@@ -2241,13 +2241,23 @@ type Lavarage = {
2241
2241
  },
2242
2242
  {
2243
2243
  "name": "toTokenAccount";
2244
- "isMut": false;
2244
+ "isMut": true;
2245
2245
  "isSigner": false;
2246
2246
  },
2247
2247
  {
2248
2248
  "name": "randomAccountAsId";
2249
2249
  "isMut": false;
2250
2250
  "isSigner": false;
2251
+ },
2252
+ {
2253
+ "name": "tokenProgram";
2254
+ "isMut": false;
2255
+ "isSigner": false;
2256
+ },
2257
+ {
2258
+ "name": "associatedTokenProgram";
2259
+ "isMut": false;
2260
+ "isSigner": false;
2251
2261
  }
2252
2262
  ];
2253
2263
  "args": [
@@ -2314,6 +2324,11 @@ type Lavarage = {
2314
2324
  "name": "randomAccountAsId";
2315
2325
  "isMut": false;
2316
2326
  "isSigner": false;
2327
+ },
2328
+ {
2329
+ "name": "associatedTokenProgram";
2330
+ "isMut": false;
2331
+ "isSigner": false;
2317
2332
  }
2318
2333
  ];
2319
2334
  "args": [];
@@ -3007,6 +3022,57 @@ type Lavarage = {
3007
3022
  "type": "string";
3008
3023
  }
3009
3024
  ];
3025
+ },
3026
+ {
3027
+ "name": "rescueStuckTokens";
3028
+ "accounts": [
3029
+ {
3030
+ "name": "position";
3031
+ "isMut": true;
3032
+ "isSigner": false;
3033
+ },
3034
+ {
3035
+ "name": "pool";
3036
+ "isMut": true;
3037
+ "isSigner": false;
3038
+ },
3039
+ {
3040
+ "name": "nodeWallet";
3041
+ "isMut": true;
3042
+ "isSigner": false;
3043
+ },
3044
+ {
3045
+ "name": "positionTokenAccount";
3046
+ "isMut": true;
3047
+ "isSigner": false;
3048
+ },
3049
+ {
3050
+ "name": "traderTokenAccount";
3051
+ "isMut": true;
3052
+ "isSigner": false;
3053
+ },
3054
+ {
3055
+ "name": "positionMint";
3056
+ "isMut": true;
3057
+ "isSigner": false;
3058
+ },
3059
+ {
3060
+ "name": "admin";
3061
+ "isMut": true;
3062
+ "isSigner": true;
3063
+ },
3064
+ {
3065
+ "name": "tokenProgram";
3066
+ "isMut": false;
3067
+ "isSigner": false;
3068
+ }
3069
+ ];
3070
+ "args": [
3071
+ {
3072
+ "name": "amount";
3073
+ "type": "u64";
3074
+ }
3075
+ ];
3010
3076
  }
3011
3077
  ];
3012
3078
  "accounts": [
package/dist/index.js CHANGED
@@ -3981,13 +3981,23 @@ var IDL3 = {
3981
3981
  },
3982
3982
  {
3983
3983
  "name": "toTokenAccount",
3984
- "isMut": false,
3984
+ "isMut": true,
3985
3985
  "isSigner": false
3986
3986
  },
3987
3987
  {
3988
3988
  "name": "randomAccountAsId",
3989
3989
  "isMut": false,
3990
3990
  "isSigner": false
3991
+ },
3992
+ {
3993
+ "name": "tokenProgram",
3994
+ "isMut": false,
3995
+ "isSigner": false
3996
+ },
3997
+ {
3998
+ "name": "associatedTokenProgram",
3999
+ "isMut": false,
4000
+ "isSigner": false
3991
4001
  }
3992
4002
  ],
3993
4003
  "args": [
@@ -4054,6 +4064,11 @@ var IDL3 = {
4054
4064
  "name": "randomAccountAsId",
4055
4065
  "isMut": false,
4056
4066
  "isSigner": false
4067
+ },
4068
+ {
4069
+ "name": "associatedTokenProgram",
4070
+ "isMut": false,
4071
+ "isSigner": false
4057
4072
  }
4058
4073
  ],
4059
4074
  "args": []
@@ -4747,6 +4762,57 @@ var IDL3 = {
4747
4762
  "type": "string"
4748
4763
  }
4749
4764
  ]
4765
+ },
4766
+ {
4767
+ "name": "rescueStuckTokens",
4768
+ "accounts": [
4769
+ {
4770
+ "name": "position",
4771
+ "isMut": true,
4772
+ "isSigner": false
4773
+ },
4774
+ {
4775
+ "name": "pool",
4776
+ "isMut": true,
4777
+ "isSigner": false
4778
+ },
4779
+ {
4780
+ "name": "nodeWallet",
4781
+ "isMut": true,
4782
+ "isSigner": false
4783
+ },
4784
+ {
4785
+ "name": "positionTokenAccount",
4786
+ "isMut": true,
4787
+ "isSigner": false
4788
+ },
4789
+ {
4790
+ "name": "traderTokenAccount",
4791
+ "isMut": true,
4792
+ "isSigner": false
4793
+ },
4794
+ {
4795
+ "name": "positionMint",
4796
+ "isMut": true,
4797
+ "isSigner": false
4798
+ },
4799
+ {
4800
+ "name": "admin",
4801
+ "isMut": true,
4802
+ "isSigner": true
4803
+ },
4804
+ {
4805
+ "name": "tokenProgram",
4806
+ "isMut": false,
4807
+ "isSigner": false
4808
+ }
4809
+ ],
4810
+ "args": [
4811
+ {
4812
+ "name": "amount",
4813
+ "type": "u64"
4814
+ }
4815
+ ]
4750
4816
  }
4751
4817
  ],
4752
4818
  "accounts": [
@@ -5614,14 +5680,15 @@ var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteTo
5614
5680
  toTokenAccount: toTokenAccount.account.address,
5615
5681
  systemProgram: import_web32.SystemProgram.programId,
5616
5682
  positionAccount,
5617
- randomAccountAsId: randomSeed.publicKey.toBase58()
5683
+ randomAccountAsId: randomSeed.publicKey.toBase58(),
5684
+ tokenProgram,
5685
+ associatedTokenProgram: import_spl_token2.ASSOCIATED_TOKEN_PROGRAM_ID
5618
5686
  }).instruction();
5619
5687
  const computeFeeIx = import_web32.ComputeBudgetProgram.setComputeUnitPrice({
5620
5688
  microLamports: computeBudgetMicroLamports != null ? computeBudgetMicroLamports : 1e5
5621
5689
  });
5622
5690
  const allInstructions = [
5623
5691
  fromTokenAccount.instruction,
5624
- toTokenAccount.instruction,
5625
5692
  partnerFeeRecipientVaultCreateIx,
5626
5693
  partnerFeeRecipientTokenAccountCreateIx,
5627
5694
  tradingOpenBorrowInstruction,
@@ -5955,6 +6022,12 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5955
6022
  let partnerFeeRecipientVaultCreateIx;
5956
6023
  let partnerFeeRecipientTokenAccountCreateIx;
5957
6024
  let userVaultPda;
6025
+ const partnerDirectAta = partnerFeeRecipient ? (0, import_spl_token2.getAssociatedTokenAddressSync)(
6026
+ quoteToken,
6027
+ partnerFeeRecipient,
6028
+ true,
6029
+ quoteTokenProgram
6030
+ ) : void 0;
5958
6031
  if (partnerFeeRecipient && partnerFeeMarkupAsPkey && referralVaultProgram) {
5959
6032
  [userVaultPda] = import_web32.PublicKey.findProgramAddressSync(
5960
6033
  [Buffer.from("user_vault"), new import_web32.PublicKey(partnerFeeRecipient).toBuffer()],
@@ -5989,13 +6062,21 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5989
6062
  import_spl_token2.ASSOCIATED_TOKEN_PROGRAM_ID
5990
6063
  );
5991
6064
  }
6065
+ } else if (partnerFeeRecipient && partnerDirectAta) {
6066
+ const [partnerDirectAtaInfo] = yield lavarageProgram.provider.connection.getMultipleAccountsInfo([
6067
+ partnerDirectAta
6068
+ ]);
6069
+ if (!partnerDirectAtaInfo) {
6070
+ partnerFeeRecipientTokenAccountCreateIx = (0, import_spl_token2.createAssociatedTokenAccountIdempotentInstruction)(
6071
+ lavarageProgram.provider.publicKey,
6072
+ partnerDirectAta,
6073
+ partnerFeeRecipient,
6074
+ quoteToken,
6075
+ quoteTokenProgram,
6076
+ import_spl_token2.ASSOCIATED_TOKEN_PROGRAM_ID
6077
+ );
6078
+ }
5992
6079
  }
5993
- const partnerDirectAta = partnerFeeRecipient ? (0, import_spl_token2.getAssociatedTokenAddressSync)(
5994
- quoteToken,
5995
- partnerFeeRecipient,
5996
- true,
5997
- quoteTokenProgram
5998
- ) : void 0;
5999
6080
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
6000
6081
  new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
6001
6082
  marginSOL,
@@ -6095,7 +6176,9 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
6095
6176
  toTokenAccount: toTokenAccount.account.address,
6096
6177
  systemProgram: import_web32.SystemProgram.programId,
6097
6178
  positionAccount,
6098
- randomAccountAsId: randomSeed.publicKey.toBase58()
6179
+ randomAccountAsId: randomSeed.publicKey.toBase58(),
6180
+ tokenProgram,
6181
+ associatedTokenProgram: import_spl_token2.ASSOCIATED_TOKEN_PROGRAM_ID
6099
6182
  }).instruction();
6100
6183
  const jupiterIxs = [
6101
6184
  ...setupInstructions.map(deserializeInstruction),
@@ -6107,7 +6190,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
6107
6190
  if (splitTransactions) {
6108
6191
  const setUpInstructions = [
6109
6192
  fromTokenAccount.instruction,
6110
- toTokenAccount.instruction,
6111
6193
  partnerFeeRecipientVaultCreateIx,
6112
6194
  partnerFeeRecipientTokenAccountCreateIx,
6113
6195
  ...setupInstructions.map(deserializeInstruction)
@@ -6135,7 +6217,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
6135
6217
  }
6136
6218
  const allInstructions = [
6137
6219
  fromTokenAccount.instruction,
6138
- toTokenAccount.instruction,
6139
6220
  partnerFeeRecipientVaultCreateIx,
6140
6221
  partnerFeeRecipientTokenAccountCreateIx,
6141
6222
  tradingOpenBorrowInstruction,
@@ -6714,7 +6795,8 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
6714
6795
  systemProgram: import_web32.SystemProgram.programId,
6715
6796
  trader: lavarageProgram.provider.publicKey,
6716
6797
  tokenProgram,
6717
- randomAccountAsId: position.account.seed
6798
+ randomAccountAsId: position.account.seed,
6799
+ associatedTokenProgram: import_spl_token2.ASSOCIATED_TOKEN_PROGRAM_ID
6718
6800
  }).instruction();
6719
6801
  let repaySolIx = null;
6720
6802
  let jupiterIxs = [];
@@ -6948,8 +7030,8 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
6948
7030
  const setUpInstructions = [
6949
7031
  partnerFeeRecipientVaultCreateIx,
6950
7032
  partnerFeeRecipientTokenAccountCreateIx,
6951
- jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
6952
- createAssociatedTokenAccountInstruction2
7033
+ jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null
7034
+ //createAssociatedTokenAccountInstruction,
6953
7035
  ].filter((i) => !!i);
6954
7036
  const allInstructions2 = [
6955
7037
  ((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? deserializeInstruction(
@@ -6978,7 +7060,7 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
6978
7060
  partnerFeeRecipientVaultCreateIx,
6979
7061
  partnerFeeRecipientTokenAccountCreateIx,
6980
7062
  jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
6981
- createAssociatedTokenAccountInstruction2,
7063
+ //createAssociatedTokenAccountInstruction,
6982
7064
  ((_b = jupInstruction.instructions) == null ? void 0 : _b.tokenLedgerInstruction) ? deserializeInstruction(
6983
7065
  jupInstruction.instructions.tokenLedgerInstruction
6984
7066
  ) : null,