@lavarage/sdk 6.4.0 → 6.4.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 CHANGED
@@ -2105,11 +2105,31 @@ type Lavarage = {
2105
2105
  {
2106
2106
  "name": "newPositionOne";
2107
2107
  "isMut": true;
2108
- "isSigner": true;
2108
+ "isSigner": false;
2109
2109
  },
2110
2110
  {
2111
2111
  "name": "newPositionTwo";
2112
2112
  "isMut": true;
2113
+ "isSigner": false;
2114
+ },
2115
+ {
2116
+ "name": "mint";
2117
+ "isMut": false;
2118
+ "isSigner": false;
2119
+ },
2120
+ {
2121
+ "name": "originalPositionTokenAccount";
2122
+ "isMut": false;
2123
+ "isSigner": false;
2124
+ },
2125
+ {
2126
+ "name": "newPositionTokenAccountOne";
2127
+ "isMut": true;
2128
+ "isSigner": true;
2129
+ },
2130
+ {
2131
+ "name": "newPositionTokenAccountTwo";
2132
+ "isMut": true;
2113
2133
  "isSigner": true;
2114
2134
  },
2115
2135
  {
@@ -2117,6 +2137,11 @@ type Lavarage = {
2117
2137
  "isMut": true;
2118
2138
  "isSigner": true;
2119
2139
  },
2140
+ {
2141
+ "name": "tokenProgram";
2142
+ "isMut": false;
2143
+ "isSigner": false;
2144
+ },
2120
2145
  {
2121
2146
  "name": "systemProgram";
2122
2147
  "isMut": false;
@@ -2154,7 +2179,7 @@ type Lavarage = {
2154
2179
  {
2155
2180
  "name": "mergedPosition";
2156
2181
  "isMut": true;
2157
- "isSigner": true;
2182
+ "isSigner": false;
2158
2183
  },
2159
2184
  {
2160
2185
  "name": "trader";
@@ -2718,6 +2743,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
2718
2743
  swapInstruction: Record<string, unknown>;
2719
2744
  cleanupInstruction: Record<string, unknown>;
2720
2745
  addressLookupTableAddresses: string[];
2746
+ tokenLedgerInstruction?: Record<string, unknown>;
2721
2747
  };
2722
2748
  quoteResponse: any;
2723
2749
  }, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
@@ -2736,6 +2762,7 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
2736
2762
  swapInstruction: Record<string, unknown>;
2737
2763
  cleanupInstruction: Record<string, unknown>;
2738
2764
  addressLookupTableAddresses: string[];
2765
+ tokenLedgerInstruction?: Record<string, unknown>;
2739
2766
  };
2740
2767
  quoteResponse: any;
2741
2768
  }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
package/dist/index.d.ts CHANGED
@@ -2105,11 +2105,31 @@ type Lavarage = {
2105
2105
  {
2106
2106
  "name": "newPositionOne";
2107
2107
  "isMut": true;
2108
- "isSigner": true;
2108
+ "isSigner": false;
2109
2109
  },
2110
2110
  {
2111
2111
  "name": "newPositionTwo";
2112
2112
  "isMut": true;
2113
+ "isSigner": false;
2114
+ },
2115
+ {
2116
+ "name": "mint";
2117
+ "isMut": false;
2118
+ "isSigner": false;
2119
+ },
2120
+ {
2121
+ "name": "originalPositionTokenAccount";
2122
+ "isMut": false;
2123
+ "isSigner": false;
2124
+ },
2125
+ {
2126
+ "name": "newPositionTokenAccountOne";
2127
+ "isMut": true;
2128
+ "isSigner": true;
2129
+ },
2130
+ {
2131
+ "name": "newPositionTokenAccountTwo";
2132
+ "isMut": true;
2113
2133
  "isSigner": true;
2114
2134
  },
2115
2135
  {
@@ -2117,6 +2137,11 @@ type Lavarage = {
2117
2137
  "isMut": true;
2118
2138
  "isSigner": true;
2119
2139
  },
2140
+ {
2141
+ "name": "tokenProgram";
2142
+ "isMut": false;
2143
+ "isSigner": false;
2144
+ },
2120
2145
  {
2121
2146
  "name": "systemProgram";
2122
2147
  "isMut": false;
@@ -2154,7 +2179,7 @@ type Lavarage = {
2154
2179
  {
2155
2180
  "name": "mergedPosition";
2156
2181
  "isMut": true;
2157
- "isSigner": true;
2182
+ "isSigner": false;
2158
2183
  },
2159
2184
  {
2160
2185
  "name": "trader";
@@ -2718,6 +2743,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
2718
2743
  swapInstruction: Record<string, unknown>;
2719
2744
  cleanupInstruction: Record<string, unknown>;
2720
2745
  addressLookupTableAddresses: string[];
2746
+ tokenLedgerInstruction?: Record<string, unknown>;
2721
2747
  };
2722
2748
  quoteResponse: any;
2723
2749
  }, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
@@ -2736,6 +2762,7 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
2736
2762
  swapInstruction: Record<string, unknown>;
2737
2763
  cleanupInstruction: Record<string, unknown>;
2738
2764
  addressLookupTableAddresses: string[];
2765
+ tokenLedgerInstruction?: Record<string, unknown>;
2739
2766
  };
2740
2767
  quoteResponse: any;
2741
2768
  }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
package/dist/index.js CHANGED
@@ -2204,11 +2204,31 @@ var IDL2 = {
2204
2204
  {
2205
2205
  "name": "newPositionOne",
2206
2206
  "isMut": true,
2207
- "isSigner": true
2207
+ "isSigner": false
2208
2208
  },
2209
2209
  {
2210
2210
  "name": "newPositionTwo",
2211
2211
  "isMut": true,
2212
+ "isSigner": false
2213
+ },
2214
+ {
2215
+ "name": "mint",
2216
+ "isMut": false,
2217
+ "isSigner": false
2218
+ },
2219
+ {
2220
+ "name": "originalPositionTokenAccount",
2221
+ "isMut": false,
2222
+ "isSigner": false
2223
+ },
2224
+ {
2225
+ "name": "newPositionTokenAccountOne",
2226
+ "isMut": true,
2227
+ "isSigner": true
2228
+ },
2229
+ {
2230
+ "name": "newPositionTokenAccountTwo",
2231
+ "isMut": true,
2212
2232
  "isSigner": true
2213
2233
  },
2214
2234
  {
@@ -2216,6 +2236,11 @@ var IDL2 = {
2216
2236
  "isMut": true,
2217
2237
  "isSigner": true
2218
2238
  },
2239
+ {
2240
+ "name": "tokenProgram",
2241
+ "isMut": false,
2242
+ "isSigner": false
2243
+ },
2219
2244
  {
2220
2245
  "name": "systemProgram",
2221
2246
  "isMut": false,
@@ -2253,7 +2278,7 @@ var IDL2 = {
2253
2278
  {
2254
2279
  "name": "mergedPosition",
2255
2280
  "isMut": true,
2256
- "isSigner": true
2281
+ "isSigner": false
2257
2282
  },
2258
2283
  {
2259
2284
  "name": "trader",
@@ -3110,6 +3135,7 @@ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(void 0
3110
3135
  return new import_web3.VersionedTransaction(messageV0);
3111
3136
  });
3112
3137
  var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
3138
+ var _a;
3113
3139
  let partnerFeeMarkupAsPkey;
3114
3140
  if (partnerFeeMarkup) {
3115
3141
  const feeBuffer = Buffer.alloc(8);
@@ -3218,6 +3244,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
3218
3244
  }
3219
3245
  const profit = new import_anchor.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
3220
3246
  const allInstructions = [
3247
+ ((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? deserializeInstruction(jupInstruction.instructions.tokenLedgerInstruction) : null,
3221
3248
  toTokenAccount.instruction,
3222
3249
  closePositionIx,
3223
3250
  ...jupiterIxs,
@@ -3232,6 +3259,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
3232
3259
  return tx;
3233
3260
  });
3234
3261
  var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
3262
+ var _a;
3235
3263
  let partnerFeeMarkupAsPkey;
3236
3264
  if (partnerFeeMarkup) {
3237
3265
  const feeBuffer = Buffer.alloc(8);
@@ -3350,6 +3378,7 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
3350
3378
  }
3351
3379
  const profit = new import_anchor.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
3352
3380
  const allInstructions = [
3381
+ ((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? deserializeInstruction(jupInstruction.instructions.tokenLedgerInstruction) : null,
3353
3382
  toTokenAccount.instruction,
3354
3383
  closePositionIx,
3355
3384
  ...jupiterIxs,
@@ -3393,15 +3422,26 @@ var splitPositionV2 = (lavarageProgram, position, offer, quoteToken, propotionBp
3393
3422
  const newPosition2Seed = import_web3.Keypair.generate().publicKey;
3394
3423
  const newPosition1AccountPDA = getPositionAccountPDA(lavarageProgram, offer, newPosition1Seed);
3395
3424
  const newPosition2AccountPDA = getPositionAccountPDA(lavarageProgram, offer, newPosition2Seed);
3425
+ const mintAccount = yield lavarageProgram.provider.connection.getAccountInfo(offer.account.collateralType);
3426
+ const tokenProgram = mintAccount == null ? void 0 : mintAccount.owner;
3396
3427
  const ix = yield lavarageProgram.methods.tradingManagementSplitPosition(new import_anchor.BN(propotionBps), newPosition1Seed, newPosition2Seed).accountsStrict({
3397
3428
  originalPosition: positionAccountPDA,
3398
3429
  newPositionOne: newPosition1AccountPDA,
3399
3430
  newPositionTwo: newPosition2AccountPDA,
3400
3431
  trader: lavarageProgram.provider.publicKey,
3401
- systemProgram: import_web3.SystemProgram.programId
3432
+ systemProgram: import_web3.SystemProgram.programId,
3433
+ mint: offer.account.collateralType,
3434
+ tokenProgram,
3435
+ originalPositionTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(offer.account.collateralType, positionAccountPDA, true, tokenProgram),
3436
+ newPositionTokenAccountOne: (0, import_spl_token.getAssociatedTokenAddressSync)(offer.account.collateralType, newPosition1AccountPDA, true, tokenProgram),
3437
+ newPositionTokenAccountTwo: (0, import_spl_token.getAssociatedTokenAddressSync)(offer.account.collateralType, newPosition2AccountPDA, true, tokenProgram)
3402
3438
  }).instruction();
3439
+ const computeBudgetIx = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
3440
+ microLamports: 1e5
3441
+ });
3403
3442
  const allInstructions = [
3404
- ix
3443
+ ix,
3444
+ computeBudgetIx
3405
3445
  ].filter((i) => !!i);
3406
3446
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
3407
3447
  const messageV0 = new import_web3.TransactionMessage({