@lavarage/sdk 7.4.4 → 7.5.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.js CHANGED
@@ -1836,7 +1836,7 @@ var IDL = {
1836
1836
  },
1837
1837
  {
1838
1838
  "name": "toTokenAccount",
1839
- "isMut": false,
1839
+ "isMut": true,
1840
1840
  "isSigner": false
1841
1841
  },
1842
1842
  {
@@ -1907,7 +1907,7 @@ var IDL = {
1907
1907
  },
1908
1908
  {
1909
1909
  "name": "toTokenAccount",
1910
- "isMut": false,
1910
+ "isMut": true,
1911
1911
  "isSigner": false
1912
1912
  },
1913
1913
  {
@@ -2008,6 +2008,74 @@ var IDL = {
2008
2008
  }
2009
2009
  ]
2010
2010
  },
2011
+ {
2012
+ "name": "tradingOpenBorrowWithReferral",
2013
+ "accounts": [
2014
+ {
2015
+ "name": "positionAccount",
2016
+ "isMut": true,
2017
+ "isSigner": false
2018
+ },
2019
+ {
2020
+ "name": "trader",
2021
+ "isMut": true,
2022
+ "isSigner": true
2023
+ },
2024
+ {
2025
+ "name": "tradingPool",
2026
+ "isMut": true,
2027
+ "isSigner": false
2028
+ },
2029
+ {
2030
+ "name": "nodeWallet",
2031
+ "isMut": true,
2032
+ "isSigner": false
2033
+ },
2034
+ {
2035
+ "name": "instructions",
2036
+ "isMut": false,
2037
+ "isSigner": false
2038
+ },
2039
+ {
2040
+ "name": "systemProgram",
2041
+ "isMut": false,
2042
+ "isSigner": false
2043
+ },
2044
+ {
2045
+ "name": "clock",
2046
+ "isMut": false,
2047
+ "isSigner": false
2048
+ },
2049
+ {
2050
+ "name": "randomAccountAsId",
2051
+ "isMut": false,
2052
+ "isSigner": false
2053
+ },
2054
+ {
2055
+ "name": "feeReceipient",
2056
+ "isMut": true,
2057
+ "isSigner": false
2058
+ }
2059
+ ],
2060
+ "args": [
2061
+ {
2062
+ "name": "positionSize",
2063
+ "type": "u64"
2064
+ },
2065
+ {
2066
+ "name": "userPays",
2067
+ "type": "u64"
2068
+ },
2069
+ {
2070
+ "name": "discountBps",
2071
+ "type": "u64"
2072
+ },
2073
+ {
2074
+ "name": "referralBps",
2075
+ "type": "u64"
2076
+ }
2077
+ ]
2078
+ },
2011
2079
  {
2012
2080
  "name": "tradingOpenAddCollateral",
2013
2081
  "accounts": [
@@ -2554,6 +2622,57 @@ var IDL = {
2554
2622
  }
2555
2623
  ]
2556
2624
  },
2625
+ {
2626
+ "name": "rescueStuckTokens",
2627
+ "accounts": [
2628
+ {
2629
+ "name": "position",
2630
+ "isMut": true,
2631
+ "isSigner": false
2632
+ },
2633
+ {
2634
+ "name": "pool",
2635
+ "isMut": true,
2636
+ "isSigner": false
2637
+ },
2638
+ {
2639
+ "name": "nodeWallet",
2640
+ "isMut": true,
2641
+ "isSigner": false
2642
+ },
2643
+ {
2644
+ "name": "positionTokenAccount",
2645
+ "isMut": true,
2646
+ "isSigner": false
2647
+ },
2648
+ {
2649
+ "name": "traderTokenAccount",
2650
+ "isMut": true,
2651
+ "isSigner": false
2652
+ },
2653
+ {
2654
+ "name": "positionMint",
2655
+ "isMut": true,
2656
+ "isSigner": false
2657
+ },
2658
+ {
2659
+ "name": "admin",
2660
+ "isMut": true,
2661
+ "isSigner": true
2662
+ },
2663
+ {
2664
+ "name": "tokenProgram",
2665
+ "isMut": false,
2666
+ "isSigner": false
2667
+ }
2668
+ ],
2669
+ "args": [
2670
+ {
2671
+ "name": "amount",
2672
+ "type": "u64"
2673
+ }
2674
+ ]
2675
+ },
2557
2676
  {
2558
2677
  "name": "initWithdrawalAccessList",
2559
2678
  "accounts": [
@@ -3517,6 +3636,89 @@ var IDL2 = {
3517
3636
  }
3518
3637
  ]
3519
3638
  },
3639
+ {
3640
+ "name": "tradingOpenBorrowWithReferral",
3641
+ "accounts": [
3642
+ {
3643
+ "name": "positionAccount",
3644
+ "isMut": true,
3645
+ "isSigner": false
3646
+ },
3647
+ {
3648
+ "name": "trader",
3649
+ "isMut": true,
3650
+ "isSigner": true
3651
+ },
3652
+ {
3653
+ "name": "tradingPool",
3654
+ "isMut": true,
3655
+ "isSigner": false
3656
+ },
3657
+ {
3658
+ "name": "nodeWallet",
3659
+ "isMut": true,
3660
+ "isSigner": false
3661
+ },
3662
+ {
3663
+ "name": "instructions",
3664
+ "isMut": false,
3665
+ "isSigner": false
3666
+ },
3667
+ {
3668
+ "name": "systemProgram",
3669
+ "isMut": false,
3670
+ "isSigner": false
3671
+ },
3672
+ {
3673
+ "name": "clock",
3674
+ "isMut": false,
3675
+ "isSigner": false
3676
+ },
3677
+ {
3678
+ "name": "randomAccountAsId",
3679
+ "isMut": false,
3680
+ "isSigner": false
3681
+ },
3682
+ {
3683
+ "name": "feeTokenAccount",
3684
+ "isMut": true,
3685
+ "isSigner": false
3686
+ },
3687
+ {
3688
+ "name": "fromTokenAccount",
3689
+ "isMut": true,
3690
+ "isSigner": false
3691
+ },
3692
+ {
3693
+ "name": "toTokenAccount",
3694
+ "isMut": true,
3695
+ "isSigner": false
3696
+ },
3697
+ {
3698
+ "name": "tokenProgram",
3699
+ "isMut": false,
3700
+ "isSigner": false
3701
+ }
3702
+ ],
3703
+ "args": [
3704
+ {
3705
+ "name": "positionSize",
3706
+ "type": "u64"
3707
+ },
3708
+ {
3709
+ "name": "userPays",
3710
+ "type": "u64"
3711
+ },
3712
+ {
3713
+ "name": "discountBps",
3714
+ "type": "u64"
3715
+ },
3716
+ {
3717
+ "name": "referralBps",
3718
+ "type": "u64"
3719
+ }
3720
+ ]
3721
+ },
3520
3722
  {
3521
3723
  "name": "tradingOpenAddCollateral",
3522
3724
  "accounts": [
@@ -4791,7 +4993,7 @@ var getLiquidatedPositions = (lavarageProgram) => {
4791
4993
  var getAllPositions = (lavarageProgram) => {
4792
4994
  return lavarageProgram.account.position.all([{ dataSize: 178 }]);
4793
4995
  };
4794
- var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions) => __async(void 0, null, function* () {
4996
+ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps) => __async(void 0, null, function* () {
4795
4997
  let partnerFeeMarkupAsPkey;
4796
4998
  if (partnerFeeMarkup) {
4797
4999
  const feeBuffer = Buffer.alloc(8);
@@ -4876,7 +5078,36 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
4876
5078
  ])
4877
5079
  );
4878
5080
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
4879
- const tradingOpenBorrowInstruction = yield lavarageProgram.methods.tradingOpenBorrow(
5081
+ const useReferral = discountBps !== void 0 && referralBps !== void 0;
5082
+ const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
5083
+ new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
5084
+ marginSOL,
5085
+ new import_anchor2.BN(discountBps),
5086
+ new import_anchor2.BN(referralBps)
5087
+ ).accountsStrict({
5088
+ nodeWallet: offer.account.nodeWallet,
5089
+ instructions: import_web32.SYSVAR_INSTRUCTIONS_PUBKEY,
5090
+ tradingPool: offer.publicKey,
5091
+ positionAccount,
5092
+ trader: lavarageProgram.provider.publicKey,
5093
+ systemProgram: import_web32.SystemProgram.programId,
5094
+ clock: import_web32.SYSVAR_CLOCK_PUBKEY,
5095
+ randomAccountAsId: randomSeed.publicKey.toBase58(),
5096
+ feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"
5097
+ }).remainingAccounts(
5098
+ partnerFeeRecipient && partnerFeeMarkupAsPkey ? [
5099
+ {
5100
+ pubkey: partnerFeeRecipient,
5101
+ isSigner: false,
5102
+ isWritable: true
5103
+ },
5104
+ {
5105
+ pubkey: partnerFeeMarkupAsPkey,
5106
+ isSigner: false,
5107
+ isWritable: false
5108
+ }
5109
+ ] : []
5110
+ ).instruction() : yield lavarageProgram.methods.tradingOpenBorrow(
4880
5111
  new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
4881
5112
  marginSOL
4882
5113
  ).accountsStrict({
@@ -4962,7 +5193,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
4962
5193
  const tx = new import_web32.VersionedTransaction(messageV0);
4963
5194
  return tx;
4964
5195
  });
4965
- var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions) => __async(void 0, null, function* () {
5196
+ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps) => __async(void 0, null, function* () {
4966
5197
  let partnerFeeMarkupAsPkey;
4967
5198
  if (partnerFeeMarkup) {
4968
5199
  const feeBuffer = Buffer.alloc(8);
@@ -5050,7 +5281,59 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5050
5281
  ])
5051
5282
  );
5052
5283
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
5053
- const tradingOpenBorrowInstruction = yield lavarageProgram.methods.tradingOpenBorrow(
5284
+ const useReferral = discountBps !== void 0 && referralBps !== void 0;
5285
+ const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
5286
+ new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
5287
+ marginSOL,
5288
+ new import_anchor2.BN(discountBps),
5289
+ new import_anchor2.BN(referralBps)
5290
+ ).accountsStrict({
5291
+ nodeWallet: offer.account.nodeWallet,
5292
+ instructions: import_web32.SYSVAR_INSTRUCTIONS_PUBKEY,
5293
+ tradingPool: offer.publicKey,
5294
+ positionAccount,
5295
+ trader: lavarageProgram.provider.publicKey,
5296
+ systemProgram: import_web32.SystemProgram.programId,
5297
+ clock: import_web32.SYSVAR_CLOCK_PUBKEY,
5298
+ randomAccountAsId: randomSeed.publicKey.toBase58(),
5299
+ feeTokenAccount: (0, import_spl_token2.getAssociatedTokenAddressSync)(
5300
+ quoteToken,
5301
+ new import_web32.PublicKey("6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"),
5302
+ true,
5303
+ quoteTokenProgram
5304
+ ),
5305
+ toTokenAccount: (0, import_spl_token2.getAssociatedTokenAddressSync)(
5306
+ quoteToken,
5307
+ lavarageProgram.provider.publicKey,
5308
+ true,
5309
+ quoteTokenProgram
5310
+ ),
5311
+ tokenProgram: quoteTokenProgram,
5312
+ fromTokenAccount: (0, import_spl_token2.getAssociatedTokenAddressSync)(
5313
+ quoteToken,
5314
+ offer.account.nodeWallet,
5315
+ true,
5316
+ quoteTokenProgram
5317
+ )
5318
+ }).remainingAccounts(
5319
+ partnerFeeRecipient && partnerFeeMarkupAsPkey ? [
5320
+ {
5321
+ pubkey: (0, import_spl_token2.getAssociatedTokenAddressSync)(
5322
+ quoteToken,
5323
+ partnerFeeRecipient,
5324
+ false,
5325
+ quoteTokenProgram
5326
+ ),
5327
+ isSigner: false,
5328
+ isWritable: true
5329
+ },
5330
+ {
5331
+ pubkey: partnerFeeMarkupAsPkey,
5332
+ isSigner: false,
5333
+ isWritable: false
5334
+ }
5335
+ ] : []
5336
+ ).instruction() : yield lavarageProgram.methods.tradingOpenBorrow(
5054
5337
  new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
5055
5338
  marginSOL
5056
5339
  ).accountsStrict({