@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.mjs CHANGED
@@ -1,4 +1,22 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2
20
  var __export = (target, all) => {
3
21
  for (var name in all)
4
22
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -28,7 +46,7 @@ var __async = (__this, __arguments, generator) => {
28
46
  import { BN } from "@coral-xyz/anchor";
29
47
  import bs58 from "bs58";
30
48
  import { AddressLookupTableAccount, ComputeBudgetProgram, PublicKey, SystemProgram, SYSVAR_CLOCK_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, Transaction, TransactionInstruction, TransactionMessage, VersionedTransaction } from "@solana/web3.js";
31
- import { ASSOCIATED_TOKEN_PROGRAM_ID, createAssociatedTokenAccountInstruction, createTransferInstruction, getAccount, getAssociatedTokenAddressSync, TokenAccountNotFoundError, TokenInvalidAccountOwnerError } from "@solana/spl-token";
49
+ import { ASSOCIATED_TOKEN_PROGRAM_ID, createAssociatedTokenAccountInstruction, createTransferInstruction, getAccount, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, TokenAccountNotFoundError, TokenInvalidAccountOwnerError } from "@solana/spl-token";
32
50
 
33
51
  // idl/lavarage.ts
34
52
  var IDL = {
@@ -2753,6 +2771,52 @@ var removeTpDelegate = (lavarageProgram, position, prioFee) => __async(void 0, n
2753
2771
  }).compileToV0Message();
2754
2772
  return new VersionedTransaction(messageV0);
2755
2773
  });
2774
+ var partialRepayV1 = (lavarageProgram, position, repaymentBps) => __async(void 0, null, function* () {
2775
+ const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
2776
+ const pool = yield lavarageProgram.account.pool.fetch(position.account.pool);
2777
+ const positionAccountPDA = position.publicKey;
2778
+ const ix = yield lavarageProgram.methods.tradingClosePartialRepaySol(new BN(repaymentBps)).accountsStrict({
2779
+ systemProgram: SystemProgram.programId,
2780
+ positionAccount: positionAccountPDA,
2781
+ tradingPool: position.account.pool,
2782
+ nodeWallet: pool.nodeWallet,
2783
+ trader: lavarageProgram.provider.publicKey,
2784
+ clock: SYSVAR_CLOCK_PUBKEY,
2785
+ randomAccountAsId: position.account.seed,
2786
+ feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"
2787
+ }).instruction();
2788
+ const messageV0 = new TransactionMessage({
2789
+ payerKey: lavarageProgram.provider.publicKey,
2790
+ recentBlockhash: blockhash,
2791
+ instructions: [ix]
2792
+ }).compileToV0Message();
2793
+ return new VersionedTransaction(messageV0);
2794
+ });
2795
+ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(void 0, null, function* () {
2796
+ const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
2797
+ const pool = yield lavarageProgram.account.pool.fetch(position.account.pool);
2798
+ const positionAccountPDA = position.publicKey;
2799
+ const ix = yield lavarageProgram.methods.tradingPartialRepaySol(new BN(repaymentBps)).accountsStrict({
2800
+ systemProgram: SystemProgram.programId,
2801
+ positionAccount: positionAccountPDA,
2802
+ tradingPool: position.account.pool,
2803
+ nodeWallet: pool.nodeWallet,
2804
+ trader: lavarageProgram.provider.publicKey,
2805
+ clock: SYSVAR_CLOCK_PUBKEY,
2806
+ randomAccountAsId: position.account.seed,
2807
+ fromTokenAccount: getAssociatedTokenAddressSync(pool.qtType, lavarageProgram.provider.publicKey),
2808
+ toTokenAccount: getAssociatedTokenAddressSync(pool.qtType, pool.nodeWallet),
2809
+ mint: pool.qtType,
2810
+ feeTokenAccount: getAssociatedTokenAddressSync(pool.qtType, new PublicKey("6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF")),
2811
+ tokenProgram: TOKEN_PROGRAM_ID
2812
+ }).instruction();
2813
+ const messageV0 = new TransactionMessage({
2814
+ payerKey: lavarageProgram.provider.publicKey,
2815
+ recentBlockhash: blockhash,
2816
+ instructions: [ix]
2817
+ }).compileToV0Message();
2818
+ return new VersionedTransaction(messageV0);
2819
+ });
2756
2820
  var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, profitFeeMarkup) => __async(void 0, null, function* () {
2757
2821
  if (position.account.pool.toBase58() != offer.publicKey.toBase58()) throw "Mismatch offer";
2758
2822
  const pool = offer;
@@ -2990,6 +3054,20 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
2990
3054
  const tx = new VersionedTransaction(messageV0);
2991
3055
  return tx;
2992
3056
  });
3057
+ var getDelegateAccounts = (lavarageProgram, userPubKey) => __async(void 0, null, function* () {
3058
+ const delegateAccounts = yield lavarageProgram.account.delegate.all(userPubKey ? [{
3059
+ memcmp: {
3060
+ offset: 104,
3061
+ bytes: userPubKey.toBase58()
3062
+ }
3063
+ }] : void 0);
3064
+ return delegateAccounts.map((d) => __spreadProps(__spreadValues({}, d), {
3065
+ parsed: {
3066
+ tpPrice: new BN(d.account.field1),
3067
+ tpThreshold: new BN(d.account.field2)
3068
+ }
3069
+ }));
3070
+ });
2993
3071
  export {
2994
3072
  IDL,
2995
3073
  lavaragev2_exports as IDLV2,
@@ -2998,6 +3076,7 @@ export {
2998
3076
  createTpDelegate,
2999
3077
  getAllPositions,
3000
3078
  getClosedPositions,
3079
+ getDelegateAccounts,
3001
3080
  getLiquidatedPositions,
3002
3081
  getOffers,
3003
3082
  getOpenPositions,
@@ -3006,6 +3085,8 @@ export {
3006
3085
  modifyTpDelegate,
3007
3086
  openTradeV1,
3008
3087
  openTradeV2,
3088
+ partialRepayV1,
3089
+ partialRepayV2,
3009
3090
  removeTpDelegate
3010
3091
  };
3011
3092
  //# sourceMappingURL=index.mjs.map