@lavarage/sdk 6.0.2 → 6.1.3

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
@@ -2470,6 +2470,18 @@ declare const removeTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<
2470
2470
  userPaid: BN;
2471
2471
  amount: BN;
2472
2472
  }>, prioFee: BN) => Promise<VersionedTransaction>;
2473
+ declare const partialRepayV1: (lavarageProgram: Program<Lavarage$1>, position: ProgramAccount<{
2474
+ pool: PublicKey;
2475
+ seed: PublicKey;
2476
+ userPaid: BN;
2477
+ amount: BN;
2478
+ }>, repaymentBps: number) => Promise<VersionedTransaction>;
2479
+ declare const partialRepayV2: (lavarageProgram: Program<Lavarage>, position: ProgramAccount<{
2480
+ pool: PublicKey;
2481
+ seed: PublicKey;
2482
+ userPaid: BN;
2483
+ amount: BN;
2484
+ }>, repaymentBps: number) => Promise<VersionedTransaction>;
2473
2485
  declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: ProgramAccount<{
2474
2486
  pool: PublicKey;
2475
2487
  seed: PublicKey;
@@ -2506,5 +2518,23 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
2506
2518
  };
2507
2519
  quoteResponse: any;
2508
2520
  }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, profitFeeMarkup?: number) => Promise<VersionedTransaction>;
2521
+ declare const getDelegateAccounts: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, userPubKey?: PublicKey) => Promise<{
2522
+ parsed: {
2523
+ tpPrice: any;
2524
+ tpThreshold: any;
2525
+ };
2526
+ publicKey: PublicKey;
2527
+ account: {
2528
+ delegateType: number;
2529
+ field1: BN;
2530
+ field2: BN;
2531
+ field3: BN;
2532
+ field4: PublicKey;
2533
+ field5: PublicKey;
2534
+ originalOperator: PublicKey;
2535
+ delegateOperator: PublicKey;
2536
+ account: PublicKey;
2537
+ };
2538
+ }[]>;
2509
2539
 
2510
- export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closeTradeV1, closeTradeV2, createTpDelegate, getAllPositions, getClosedPositions, getLiquidatedPositions, getOffers, getOpenPositions, getPda, getPositionAccountPDA, modifyTpDelegate, openTradeV1, openTradeV2, removeTpDelegate };
2540
+ export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closeTradeV1, closeTradeV2, createTpDelegate, getAllPositions, getClosedPositions, getDelegateAccounts, getLiquidatedPositions, getOffers, getOpenPositions, getPda, getPositionAccountPDA, modifyTpDelegate, openTradeV1, openTradeV2, partialRepayV1, partialRepayV2, removeTpDelegate };
package/dist/index.d.ts CHANGED
@@ -2470,6 +2470,18 @@ declare const removeTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<
2470
2470
  userPaid: BN;
2471
2471
  amount: BN;
2472
2472
  }>, prioFee: BN) => Promise<VersionedTransaction>;
2473
+ declare const partialRepayV1: (lavarageProgram: Program<Lavarage$1>, position: ProgramAccount<{
2474
+ pool: PublicKey;
2475
+ seed: PublicKey;
2476
+ userPaid: BN;
2477
+ amount: BN;
2478
+ }>, repaymentBps: number) => Promise<VersionedTransaction>;
2479
+ declare const partialRepayV2: (lavarageProgram: Program<Lavarage>, position: ProgramAccount<{
2480
+ pool: PublicKey;
2481
+ seed: PublicKey;
2482
+ userPaid: BN;
2483
+ amount: BN;
2484
+ }>, repaymentBps: number) => Promise<VersionedTransaction>;
2473
2485
  declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: ProgramAccount<{
2474
2486
  pool: PublicKey;
2475
2487
  seed: PublicKey;
@@ -2506,5 +2518,23 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
2506
2518
  };
2507
2519
  quoteResponse: any;
2508
2520
  }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, profitFeeMarkup?: number) => Promise<VersionedTransaction>;
2521
+ declare const getDelegateAccounts: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, userPubKey?: PublicKey) => Promise<{
2522
+ parsed: {
2523
+ tpPrice: any;
2524
+ tpThreshold: any;
2525
+ };
2526
+ publicKey: PublicKey;
2527
+ account: {
2528
+ delegateType: number;
2529
+ field1: BN;
2530
+ field2: BN;
2531
+ field3: BN;
2532
+ field4: PublicKey;
2533
+ field5: PublicKey;
2534
+ originalOperator: PublicKey;
2535
+ delegateOperator: PublicKey;
2536
+ account: PublicKey;
2537
+ };
2538
+ }[]>;
2509
2539
 
2510
- export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closeTradeV1, closeTradeV2, createTpDelegate, getAllPositions, getClosedPositions, getLiquidatedPositions, getOffers, getOpenPositions, getPda, getPositionAccountPDA, modifyTpDelegate, openTradeV1, openTradeV2, removeTpDelegate };
2540
+ export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closeTradeV1, closeTradeV2, createTpDelegate, getAllPositions, getClosedPositions, getDelegateAccounts, getLiquidatedPositions, getOffers, getOpenPositions, getPda, getPositionAccountPDA, modifyTpDelegate, openTradeV1, openTradeV2, partialRepayV1, partialRepayV2, removeTpDelegate };
package/dist/index.js CHANGED
@@ -1,10 +1,27 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
9
  var __getProtoOf = Object.getPrototypeOf;
7
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8
25
  var __export = (target, all) => {
9
26
  for (var name in all)
10
27
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -57,6 +74,7 @@ __export(index_exports, {
57
74
  createTpDelegate: () => createTpDelegate,
58
75
  getAllPositions: () => getAllPositions,
59
76
  getClosedPositions: () => getClosedPositions,
77
+ getDelegateAccounts: () => getDelegateAccounts,
60
78
  getLiquidatedPositions: () => getLiquidatedPositions,
61
79
  getOffers: () => getOffers,
62
80
  getOpenPositions: () => getOpenPositions,
@@ -65,6 +83,8 @@ __export(index_exports, {
65
83
  modifyTpDelegate: () => modifyTpDelegate,
66
84
  openTradeV1: () => openTradeV1,
67
85
  openTradeV2: () => openTradeV2,
86
+ partialRepayV1: () => partialRepayV1,
87
+ partialRepayV2: () => partialRepayV2,
68
88
  removeTpDelegate: () => removeTpDelegate
69
89
  });
70
90
  module.exports = __toCommonJS(index_exports);
@@ -2796,6 +2816,52 @@ var removeTpDelegate = (lavarageProgram, position, prioFee) => __async(void 0, n
2796
2816
  }).compileToV0Message();
2797
2817
  return new import_web3.VersionedTransaction(messageV0);
2798
2818
  });
2819
+ var partialRepayV1 = (lavarageProgram, position, repaymentBps) => __async(void 0, null, function* () {
2820
+ const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
2821
+ const pool = yield lavarageProgram.account.pool.fetch(position.account.pool);
2822
+ const positionAccountPDA = position.publicKey;
2823
+ const ix = yield lavarageProgram.methods.tradingClosePartialRepaySol(new import_anchor.BN(repaymentBps)).accountsStrict({
2824
+ systemProgram: import_web3.SystemProgram.programId,
2825
+ positionAccount: positionAccountPDA,
2826
+ tradingPool: position.account.pool,
2827
+ nodeWallet: pool.nodeWallet,
2828
+ trader: lavarageProgram.provider.publicKey,
2829
+ clock: import_web3.SYSVAR_CLOCK_PUBKEY,
2830
+ randomAccountAsId: position.account.seed,
2831
+ feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"
2832
+ }).instruction();
2833
+ const messageV0 = new import_web3.TransactionMessage({
2834
+ payerKey: lavarageProgram.provider.publicKey,
2835
+ recentBlockhash: blockhash,
2836
+ instructions: [ix]
2837
+ }).compileToV0Message();
2838
+ return new import_web3.VersionedTransaction(messageV0);
2839
+ });
2840
+ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(void 0, null, function* () {
2841
+ const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
2842
+ const pool = yield lavarageProgram.account.pool.fetch(position.account.pool);
2843
+ const positionAccountPDA = position.publicKey;
2844
+ const ix = yield lavarageProgram.methods.tradingPartialRepaySol(new import_anchor.BN(repaymentBps)).accountsStrict({
2845
+ systemProgram: import_web3.SystemProgram.programId,
2846
+ positionAccount: positionAccountPDA,
2847
+ tradingPool: position.account.pool,
2848
+ nodeWallet: pool.nodeWallet,
2849
+ trader: lavarageProgram.provider.publicKey,
2850
+ clock: import_web3.SYSVAR_CLOCK_PUBKEY,
2851
+ randomAccountAsId: position.account.seed,
2852
+ fromTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(pool.qtType, lavarageProgram.provider.publicKey),
2853
+ toTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(pool.qtType, pool.nodeWallet),
2854
+ mint: pool.qtType,
2855
+ feeTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(pool.qtType, new import_web3.PublicKey("6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF")),
2856
+ tokenProgram: import_spl_token.TOKEN_PROGRAM_ID
2857
+ }).instruction();
2858
+ const messageV0 = new import_web3.TransactionMessage({
2859
+ payerKey: lavarageProgram.provider.publicKey,
2860
+ recentBlockhash: blockhash,
2861
+ instructions: [ix]
2862
+ }).compileToV0Message();
2863
+ return new import_web3.VersionedTransaction(messageV0);
2864
+ });
2799
2865
  var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, profitFeeMarkup) => __async(void 0, null, function* () {
2800
2866
  if (position.account.pool.toBase58() != offer.publicKey.toBase58()) throw "Mismatch offer";
2801
2867
  const pool = offer;
@@ -3033,6 +3099,20 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
3033
3099
  const tx = new import_web3.VersionedTransaction(messageV0);
3034
3100
  return tx;
3035
3101
  });
3102
+ var getDelegateAccounts = (lavarageProgram, userPubKey) => __async(void 0, null, function* () {
3103
+ const delegateAccounts = yield lavarageProgram.account.delegate.all(userPubKey ? [{
3104
+ memcmp: {
3105
+ offset: 104,
3106
+ bytes: userPubKey.toBase58()
3107
+ }
3108
+ }] : void 0);
3109
+ return delegateAccounts.map((d) => __spreadProps(__spreadValues({}, d), {
3110
+ parsed: {
3111
+ tpPrice: new import_anchor.BN(d.account.field1),
3112
+ tpThreshold: new import_anchor.BN(d.account.field2)
3113
+ }
3114
+ }));
3115
+ });
3036
3116
  // Annotate the CommonJS export names for ESM import in node:
3037
3117
  0 && (module.exports = {
3038
3118
  IDL,
@@ -3042,6 +3122,7 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
3042
3122
  createTpDelegate,
3043
3123
  getAllPositions,
3044
3124
  getClosedPositions,
3125
+ getDelegateAccounts,
3045
3126
  getLiquidatedPositions,
3046
3127
  getOffers,
3047
3128
  getOpenPositions,
@@ -3050,6 +3131,8 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
3050
3131
  modifyTpDelegate,
3051
3132
  openTradeV1,
3052
3133
  openTradeV2,
3134
+ partialRepayV1,
3135
+ partialRepayV2,
3053
3136
  removeTpDelegate
3054
3137
  });
3055
3138
  //# sourceMappingURL=index.js.map