@lavarage/sdk 4.5.2 → 5.0.0

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
@@ -2686,6 +2686,24 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
2686
2686
  addressLookupTableAddresses: string[];
2687
2687
  };
2688
2688
  }, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
2689
+ declare const createTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
2690
+ pool: PublicKey;
2691
+ seed: PublicKey;
2692
+ userPaid: BN;
2693
+ amount: BN;
2694
+ }>, tpPrice: BN, tpTolerence: BN, prioFee: BN, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
2695
+ declare const modifyTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
2696
+ pool: PublicKey;
2697
+ seed: PublicKey;
2698
+ userPaid: BN;
2699
+ amount: BN;
2700
+ }>, tpPrice: BN, tpTolerence: BN, prioFee: BN, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
2701
+ declare const removeTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
2702
+ pool: PublicKey;
2703
+ seed: PublicKey;
2704
+ userPaid: BN;
2705
+ amount: BN;
2706
+ }>, prioFee: BN) => Promise<VersionedTransaction>;
2689
2707
  declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: ProgramAccount<{
2690
2708
  pool: PublicKey;
2691
2709
  seed: PublicKey;
@@ -2723,4 +2741,4 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
2723
2741
  quoteResponse: any;
2724
2742
  }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, profitFeeMarkup?: number) => Promise<VersionedTransaction>;
2725
2743
 
2726
- export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closeTradeV1, closeTradeV2, getAllPositions, getClosedPositions, getLiquidatedPositions, getOffers, getOpenPositions, getPda, getPositionAccountPDA, openTradeV1, openTradeV2 };
2744
+ 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 };
package/dist/index.d.ts CHANGED
@@ -2686,6 +2686,24 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
2686
2686
  addressLookupTableAddresses: string[];
2687
2687
  };
2688
2688
  }, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
2689
+ declare const createTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
2690
+ pool: PublicKey;
2691
+ seed: PublicKey;
2692
+ userPaid: BN;
2693
+ amount: BN;
2694
+ }>, tpPrice: BN, tpTolerence: BN, prioFee: BN, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
2695
+ declare const modifyTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
2696
+ pool: PublicKey;
2697
+ seed: PublicKey;
2698
+ userPaid: BN;
2699
+ amount: BN;
2700
+ }>, tpPrice: BN, tpTolerence: BN, prioFee: BN, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
2701
+ declare const removeTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
2702
+ pool: PublicKey;
2703
+ seed: PublicKey;
2704
+ userPaid: BN;
2705
+ amount: BN;
2706
+ }>, prioFee: BN) => Promise<VersionedTransaction>;
2689
2707
  declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: ProgramAccount<{
2690
2708
  pool: PublicKey;
2691
2709
  seed: PublicKey;
@@ -2723,4 +2741,4 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
2723
2741
  quoteResponse: any;
2724
2742
  }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, profitFeeMarkup?: number) => Promise<VersionedTransaction>;
2725
2743
 
2726
- export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closeTradeV1, closeTradeV2, getAllPositions, getClosedPositions, getLiquidatedPositions, getOffers, getOpenPositions, getPda, getPositionAccountPDA, openTradeV1, openTradeV2 };
2744
+ 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 };
package/dist/index.js CHANGED
@@ -54,6 +54,7 @@ __export(index_exports, {
54
54
  IDLV2: () => lavaragev2_exports,
55
55
  closeTradeV1: () => closeTradeV1,
56
56
  closeTradeV2: () => closeTradeV2,
57
+ createTpDelegate: () => createTpDelegate,
57
58
  getAllPositions: () => getAllPositions,
58
59
  getClosedPositions: () => getClosedPositions,
59
60
  getLiquidatedPositions: () => getLiquidatedPositions,
@@ -61,8 +62,10 @@ __export(index_exports, {
61
62
  getOpenPositions: () => getOpenPositions,
62
63
  getPda: () => getPda,
63
64
  getPositionAccountPDA: () => getPositionAccountPDA,
65
+ modifyTpDelegate: () => modifyTpDelegate,
64
66
  openTradeV1: () => openTradeV1,
65
- openTradeV2: () => openTradeV2
67
+ openTradeV2: () => openTradeV2,
68
+ removeTpDelegate: () => removeTpDelegate
66
69
  });
67
70
  module.exports = __toCommonJS(index_exports);
68
71
  var import_anchor = require("@coral-xyz/anchor");
@@ -2722,6 +2725,9 @@ var getClosedPositions = (lavarageProgram) => __async(void 0, null, function* ()
2722
2725
  const value2 = BigInt(9998);
2723
2726
  const valueBuffer2 = Buffer.alloc(8);
2724
2727
  valueBuffer2.writeBigUInt64LE(value2);
2728
+ const value3 = BigInt(9996);
2729
+ const valueBuffer3 = Buffer.alloc(8);
2730
+ valueBuffer3.writeBigUInt64LE(value3);
2725
2731
  return (yield lavarageProgram.account.position.all([
2726
2732
  { dataSize: 178 },
2727
2733
  {
@@ -2738,6 +2744,14 @@ var getClosedPositions = (lavarageProgram) => __async(void 0, null, function* ()
2738
2744
  bytes: import_bs58.default.encode(Uint8Array.from(valueBuffer2))
2739
2745
  }
2740
2746
  }
2747
+ ])).concat(yield lavarageProgram.account.position.all([
2748
+ { dataSize: 178 },
2749
+ {
2750
+ memcmp: {
2751
+ offset: 40,
2752
+ bytes: import_bs58.default.encode(Uint8Array.from(valueBuffer3))
2753
+ }
2754
+ }
2741
2755
  ]));
2742
2756
  });
2743
2757
  var getLiquidatedPositions = (lavarageProgram) => {
@@ -2930,6 +2944,86 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
2930
2944
  const tx = new import_web3.VersionedTransaction(messageV0);
2931
2945
  return tx;
2932
2946
  });
2947
+ var createTpDelegate = (lavarageProgram, position, tpPrice, tpTolerence, prioFee, quoteToken, partnerFeeRecipient) => __async(void 0, null, function* () {
2948
+ const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
2949
+ const ix = yield lavarageProgram.methods.tradingCreateTpDelegate(tpPrice, tpTolerence, new import_web3.PublicKey("6dA5GTDPWxnw3gvjoy3vYBDyY7iETxcTJzt8RqF9i9MV"), new import_anchor.BN(1e4)).accountsStrict({
2950
+ delegate: getPda([Buffer.from("delegate"), position.publicKey.toBuffer()], lavarageProgram.programId),
2951
+ originalOperator: lavarageProgram.provider.publicKey,
2952
+ delegatedAccount: position.publicKey,
2953
+ systemProgram: import_web3.SystemProgram.programId
2954
+ }).remainingAccounts(partnerFeeRecipient ? [{
2955
+ pubkey: quoteToken.toBase58() == "So11111111111111111111111111111111111111112" ? partnerFeeRecipient : (0, import_spl_token.getAssociatedTokenAddressSync)(quoteToken, partnerFeeRecipient, true),
2956
+ isSigner: false,
2957
+ isWritable: true
2958
+ }] : []).instruction();
2959
+ const computeFeeIx = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
2960
+ microLamports: prioFee.toNumber()
2961
+ });
2962
+ const messageV0 = new import_web3.TransactionMessage({
2963
+ payerKey: lavarageProgram.provider.publicKey,
2964
+ recentBlockhash: blockhash,
2965
+ instructions: [
2966
+ ix,
2967
+ computeFeeIx
2968
+ ].filter(Boolean)
2969
+ }).compileToV0Message();
2970
+ return new import_web3.VersionedTransaction(messageV0);
2971
+ });
2972
+ var modifyTpDelegate = (lavarageProgram, position, tpPrice, tpTolerence, prioFee, quoteToken, partnerFeeRecipient) => __async(void 0, null, function* () {
2973
+ const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
2974
+ const delegatePda = getPda([Buffer.from("delegate"), position.publicKey.toBuffer()], lavarageProgram.programId);
2975
+ const removeIx = yield lavarageProgram.methods.tradingRemoveTpDelegate().accountsStrict({
2976
+ delegate: delegatePda,
2977
+ originalOperator: lavarageProgram.provider.publicKey,
2978
+ delegatedAccount: position.publicKey,
2979
+ systemProgram: import_web3.SystemProgram.programId
2980
+ }).instruction();
2981
+ const ix = yield lavarageProgram.methods.tradingCreateTpDelegate(tpPrice, tpTolerence, new import_web3.PublicKey("6dA5GTDPWxnw3gvjoy3vYBDyY7iETxcTJzt8RqF9i9MV"), new import_anchor.BN(1e4)).accountsStrict({
2982
+ delegate: delegatePda,
2983
+ originalOperator: lavarageProgram.provider.publicKey,
2984
+ delegatedAccount: position.publicKey,
2985
+ systemProgram: import_web3.SystemProgram.programId
2986
+ }).remainingAccounts(partnerFeeRecipient ? [{
2987
+ pubkey: quoteToken.toBase58() == "So11111111111111111111111111111111111111112" ? partnerFeeRecipient : (0, import_spl_token.getAssociatedTokenAddressSync)(quoteToken, partnerFeeRecipient, true),
2988
+ isSigner: false,
2989
+ isWritable: true
2990
+ }] : []).instruction();
2991
+ const computeFeeIx = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
2992
+ microLamports: prioFee.toNumber()
2993
+ });
2994
+ const messageV0 = new import_web3.TransactionMessage({
2995
+ payerKey: lavarageProgram.provider.publicKey,
2996
+ recentBlockhash: blockhash,
2997
+ instructions: [
2998
+ removeIx,
2999
+ ix,
3000
+ computeFeeIx
3001
+ ].filter(Boolean)
3002
+ }).compileToV0Message();
3003
+ return new import_web3.VersionedTransaction(messageV0);
3004
+ });
3005
+ var removeTpDelegate = (lavarageProgram, position, prioFee) => __async(void 0, null, function* () {
3006
+ const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
3007
+ const delegatePda = getPda([Buffer.from("delegate"), position.publicKey.toBuffer()], lavarageProgram.programId);
3008
+ const removeIx = yield lavarageProgram.methods.tradingRemoveTpDelegate().accountsStrict({
3009
+ delegate: delegatePda,
3010
+ originalOperator: lavarageProgram.provider.publicKey,
3011
+ delegatedAccount: position.publicKey,
3012
+ systemProgram: import_web3.SystemProgram.programId
3013
+ }).instruction();
3014
+ const computeFeeIx = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
3015
+ microLamports: prioFee.toNumber()
3016
+ });
3017
+ const messageV0 = new import_web3.TransactionMessage({
3018
+ payerKey: lavarageProgram.provider.publicKey,
3019
+ recentBlockhash: blockhash,
3020
+ instructions: [
3021
+ removeIx,
3022
+ computeFeeIx
3023
+ ].filter(Boolean)
3024
+ }).compileToV0Message();
3025
+ return new import_web3.VersionedTransaction(messageV0);
3026
+ });
2933
3027
  var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, profitFeeMarkup) => __async(void 0, null, function* () {
2934
3028
  if (position.account.pool.toBase58() != offer.publicKey.toBase58()) throw "Mismatch offer";
2935
3029
  const pool = offer;
@@ -3029,7 +3123,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
3029
3123
  {
3030
3124
  fromPubkey: lavarageProgram.provider.publicKey,
3031
3125
  toPubkey: partnerFeeRecipient,
3032
- lamports: profit.toNumber() > 0 ? profit.mul(new import_anchor.BN(profitFeeMarkup * 1e3)).div(new import_anchor.BN(1e3)).toNumber() : 0
3126
+ lamports: profit.toNumber() > 0 ? profit.mul(new import_anchor.BN(profitFeeMarkup * 1e4)).div(new import_anchor.BN(1e4)).toNumber() : 0
3033
3127
  }
3034
3128
  ) : null
3035
3129
  ].filter((i) => !!i);
@@ -3166,6 +3260,7 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
3166
3260
  IDLV2,
3167
3261
  closeTradeV1,
3168
3262
  closeTradeV2,
3263
+ createTpDelegate,
3169
3264
  getAllPositions,
3170
3265
  getClosedPositions,
3171
3266
  getLiquidatedPositions,
@@ -3173,7 +3268,9 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
3173
3268
  getOpenPositions,
3174
3269
  getPda,
3175
3270
  getPositionAccountPDA,
3271
+ modifyTpDelegate,
3176
3272
  openTradeV1,
3177
- openTradeV2
3273
+ openTradeV2,
3274
+ removeTpDelegate
3178
3275
  });
3179
3276
  //# sourceMappingURL=index.js.map