@lavarage/sdk 8.0.12 → 8.0.14

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/crossbar.ts CHANGED
@@ -2,11 +2,11 @@ import { NATIVE_MINT } from "@solana/spl-token";
2
2
  import { USDC_MINT } from "./constants";
3
3
  import { Program } from "@coral-xyz/anchor";
4
4
  import { PublicKey, TransactionInstruction } from "@solana/web3.js";
5
- import { getQueue, isMainnetConnection, ON_DEMAND_DEVNET_QUEUE, ON_DEMAND_MAINNET_QUEUE } from "@switchboard-xyz/on-demand";
6
5
  import { CrossbarClient } from "@switchboard-xyz/common";
7
6
  import { retryWithBackoff } from "./utils";
8
7
  import { Lavarage as LavarageSOL } from "./idl/lavarageSOL";
9
8
  import { Lavarage as LavarageUSDC } from "./idl/lavarageUSDC";
9
+ import { getSwitchboardQueue } from "./switchboard";
10
10
 
11
11
  export type ApiKeys = {
12
12
  birdeyeApiKey: string;
@@ -35,11 +35,8 @@ function getVariableOverrides(apiKeys: ApiKeys) {
35
35
  }
36
36
 
37
37
  export async function getUpdateOracleIxs(program: Program<LavarageSOL | LavarageUSDC>, feedId: string, payer: PublicKey, apiKeys: ApiKeys): Promise<TransactionInstruction[]> {
38
- const queue = await getQueue({
39
- // @ts-expect-error @coral-xyz/anchor versions mismatch
40
- program,
41
- queueAddress: await isMainnetConnection(program.provider.connection) ? ON_DEMAND_MAINNET_QUEUE : ON_DEMAND_DEVNET_QUEUE,
42
- });
38
+ // @ts-expect-error @coral-xyz/anchor versions mismatch
39
+ const queue = await getSwitchboardQueue(program.provider);
43
40
 
44
41
  return await retryWithBackoff(async () => await queue.fetchManagedUpdateIxs(
45
42
  crossbarClient,
package/dist/index.js CHANGED
@@ -111,7 +111,7 @@ __export(index_exports, {
111
111
  updateMaxLendPerTokenBatchEvm: () => updateMaxLendPerTokenBatchEvm
112
112
  });
113
113
  module.exports = __toCommonJS(index_exports);
114
- var import_anchor2 = require("@coral-xyz/anchor");
114
+ var import_anchor3 = require("@coral-xyz/anchor");
115
115
 
116
116
  // idl/userVault.json
117
117
  var userVault_default = {
@@ -361,7 +361,7 @@ var userVault_default = {
361
361
 
362
362
  // idl/lavarageUSDC.json
363
363
  var lavarageUSDC_default = {
364
- address: "8AD6AnnkdD3MMqQE2v3V7HLaxocSr8kZb1uHNX19PnwF",
364
+ address: "1avaAUcjccXCjSZzwUvB2gS3DzkkieV2Mw8CjdN65uu",
365
365
  metadata: {
366
366
  name: "lavarage",
367
367
  version: "0.1.0",
@@ -5750,11 +5750,10 @@ var queuePubkey = import_on_demand.ON_DEMAND_MAINNET_QUEUE;
5750
5750
  var USDC_MINT = new import_web3.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
5751
5751
 
5752
5752
  // switchboard.ts
5753
- var import_on_demand3 = require("@switchboard-xyz/on-demand");
5753
+ var import_on_demand2 = require("@switchboard-xyz/on-demand");
5754
5754
 
5755
5755
  // crossbar.ts
5756
5756
  var import_spl_token = require("@solana/spl-token");
5757
- var import_on_demand2 = require("@switchboard-xyz/on-demand");
5758
5757
  var import_common = require("@switchboard-xyz/common");
5759
5758
 
5760
5759
  // idl/lavarageSOL.json
@@ -7642,8 +7641,9 @@ var SURGE_FEEDS = [
7642
7641
  var crossbarClient = new import_common.CrossbarClient("https://crossbar.switchboard.xyz");
7643
7642
 
7644
7643
  // switchboard.ts
7644
+ var import_anchor = require("@coral-xyz/anchor");
7645
7645
  function getOracleQuoteForFeedId(feedId) {
7646
- const [oracleQuote] = import_on_demand3.OracleQuote.getCanonicalPubkey(
7646
+ const [oracleQuote] = import_on_demand2.OracleQuote.getCanonicalPubkey(
7647
7647
  queuePubkey,
7648
7648
  [feedId]
7649
7649
  );
@@ -7656,6 +7656,22 @@ function getOracleQuoteForCollateralType(collateralType) {
7656
7656
  }
7657
7657
  return getOracleQuoteForFeedId(feed.feedId);
7658
7658
  }
7659
+ function getSwitchboardProgram(provider) {
7660
+ return __async(this, null, function* () {
7661
+ const programId = (yield (0, import_on_demand2.isMainnetConnection)(provider.connection)) ? import_on_demand2.ON_DEMAND_MAINNET_PID : import_on_demand2.ON_DEMAND_DEVNET_PID;
7662
+ return import_anchor.Program.at(programId, provider);
7663
+ });
7664
+ }
7665
+ function getSwitchboardQueue(provider) {
7666
+ return __async(this, null, function* () {
7667
+ const program = yield getSwitchboardProgram(provider);
7668
+ return yield (0, import_on_demand2.getQueue)({
7669
+ // @ts-expect-error @coral-xyz/anchor versions mismatch
7670
+ program,
7671
+ queueAddress: (yield (0, import_on_demand2.isMainnetConnection)(provider.connection)) ? import_on_demand2.ON_DEMAND_MAINNET_QUEUE : import_on_demand2.ON_DEMAND_DEVNET_QUEUE
7672
+ });
7673
+ });
7674
+ }
7659
7675
 
7660
7676
  // evm.ts
7661
7677
  var import_ethers = require("ethers");
@@ -8688,7 +8704,7 @@ __export(lending_exports, {
8688
8704
  withdrawFundsV1: () => withdrawFundsV1,
8689
8705
  withdrawFundsV2: () => withdrawFundsV2
8690
8706
  });
8691
- var import_anchor = require("@coral-xyz/anchor");
8707
+ var import_anchor2 = require("@coral-xyz/anchor");
8692
8708
  var import_web32 = require("@solana/web3.js");
8693
8709
  var import_spl_token2 = require("@solana/spl-token");
8694
8710
  function getNodeWalletPDA(operatorPublicKey, mintPublicKey, programId) {
@@ -8773,7 +8789,7 @@ function depositFunds(lavarageProgram, params) {
8773
8789
  const computeFeeIx2 = import_web32.ComputeBudgetProgram.setComputeUnitPrice({
8774
8790
  microLamports: (_a = params.computeBudgetMicroLamports) != null ? _a : 15e4
8775
8791
  });
8776
- instruction = yield lavarageProgram.methods.lpOperatorFundNodeWallet(new import_anchor.BN(params.amount)).accounts({
8792
+ instruction = yield lavarageProgram.methods.lpOperatorFundNodeWallet(new import_anchor2.BN(params.amount)).accounts({
8777
8793
  nodeWallet: params.nodeWallet,
8778
8794
  funder: params.funder,
8779
8795
  systemProgram: import_web32.SystemProgram.programId
@@ -8837,7 +8853,7 @@ function withdrawFundsV1(lavarageProgram, params) {
8837
8853
  var _a;
8838
8854
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
8839
8855
  const withdrawalAccessList = getWithdrawalAccessListPDA(lavarageProgram.programId);
8840
- const instruction = yield lavarageProgram.methods.lpOperatorWithdrawFromNodeWallet(new import_anchor.BN(params.amount)).accountsStrict({
8856
+ const instruction = yield lavarageProgram.methods.lpOperatorWithdrawFromNodeWallet(new import_anchor2.BN(params.amount)).accountsStrict({
8841
8857
  nodeWallet: params.nodeWallet,
8842
8858
  funder: params.funder,
8843
8859
  systemProgram: import_web32.SystemProgram.programId,
@@ -8862,7 +8878,7 @@ function withdrawFundsV2(lavarageProgram, params) {
8862
8878
  const fromTokenAccount = params.fromTokenAccount || (0, import_spl_token2.getAssociatedTokenAddressSync)(mintPubkey, params.nodeWallet, true);
8863
8879
  const toTokenAccount = params.toTokenAccount || (0, import_spl_token2.getAssociatedTokenAddressSync)(mintPubkey, params.funder);
8864
8880
  const withdrawalAccessList = getWithdrawalAccessListPDA(lavarageProgram.programId);
8865
- const instruction = yield lavarageProgram.methods.lpOperatorWithdrawFromNodeWallet(new import_anchor.BN(params.amount)).accountsStrict({
8881
+ const instruction = yield lavarageProgram.methods.lpOperatorWithdrawFromNodeWallet(new import_anchor2.BN(params.amount)).accountsStrict({
8866
8882
  nodeWallet: params.nodeWallet,
8867
8883
  funder: params.funder,
8868
8884
  systemProgram: import_web32.SystemProgram.programId,
@@ -8957,14 +8973,14 @@ function createOffer(lavarageProgram, params) {
8957
8973
  interestRate: params.interestRate,
8958
8974
  feedId: params.feedId,
8959
8975
  openLtv: params.openLtv,
8960
- maxExposure: new import_anchor.BN(params.maxExposure)
8976
+ maxExposure: new import_anchor2.BN(params.maxExposure)
8961
8977
  }).accounts({
8962
8978
  operator: params.poolOwner,
8963
8979
  nodeWallet: nodeWalletPubKey,
8964
8980
  mint: new import_web32.PublicKey(params.mint)
8965
8981
  }).instruction();
8966
8982
  const updateMaxExposureInstruction = isSolProgram(lavarageProgram) ? yield lavarageProgram.methods.lpOperatorUpdateMaxExposure({
8967
- maxExposure: new import_anchor.BN(params.maxExposure),
8983
+ maxExposure: new import_anchor2.BN(params.maxExposure),
8968
8984
  interestRate: null,
8969
8985
  openLtv: null,
8970
8986
  feedId: null
@@ -8982,7 +8998,7 @@ function createOffer(lavarageProgram, params) {
8982
8998
  toPubkey: new import_web32.PublicKey("BMME51pfWdBfakTEMuQbNP4NG3wCY4Fo47dKatThhXGQ"),
8983
8999
  lamports: 0.3 * import_web32.LAMPORTS_PER_SOL
8984
9000
  });
8985
- const updateMaxBorrowInstruction = isSolProgram(lavarageProgram) && params.maxBorrow && params.maxBorrow > 0 ? yield lavarageProgram.methods.lpOperatorUpdateMaxBorrow(new import_anchor.BN(params.maxBorrow)).accountsStrict({
9001
+ const updateMaxBorrowInstruction = isSolProgram(lavarageProgram) && params.maxBorrow && params.maxBorrow > 0 ? yield lavarageProgram.methods.lpOperatorUpdateMaxBorrow(new import_anchor2.BN(params.maxBorrow)).accountsStrict({
8986
9002
  tradingPool: params.tradingPool,
8987
9003
  nodeWallet: nodeWalletPubKey,
8988
9004
  operator: params.poolOwner,
@@ -9006,13 +9022,13 @@ function updateMaxExposure(lavarageProgram, params) {
9006
9022
  return __async(this, null, function* () {
9007
9023
  var _a;
9008
9024
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
9009
- const instruction = isSolProgram(lavarageProgram) ? yield lavarageProgram.methods.lpOperatorUpdateMaxExposure(new import_anchor.BN(params.maxExposure)).accountsStrict({
9025
+ const instruction = isSolProgram(lavarageProgram) ? yield lavarageProgram.methods.lpOperatorUpdateMaxExposure(new import_anchor2.BN(params.maxExposure)).accountsStrict({
9010
9026
  tradingPool: params.tradingPool,
9011
9027
  nodeWallet: new import_web32.PublicKey(params.nodeWallet),
9012
9028
  operator: params.poolOwner,
9013
9029
  systemProgram: import_web32.SystemProgram.programId
9014
9030
  }).instruction() : yield lavarageProgram.methods.lpOperatorUpdateTradingPool({
9015
- maxExposure: new import_anchor.BN(params.maxExposure),
9031
+ maxExposure: new import_anchor2.BN(params.maxExposure),
9016
9032
  interestRate: null,
9017
9033
  openLtv: null,
9018
9034
  feedId: null
@@ -9036,14 +9052,14 @@ function updateInterestRate(lavarageProgram, params) {
9036
9052
  return __async(this, null, function* () {
9037
9053
  var _a;
9038
9054
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
9039
- const instruction = isSolProgram(lavarageProgram) ? yield lavarageProgram.methods.lpOperatorUpdateInterestRate(new import_anchor.BN(params.interestRate)).accountsStrict({
9055
+ const instruction = isSolProgram(lavarageProgram) ? yield lavarageProgram.methods.lpOperatorUpdateInterestRate(new import_anchor2.BN(params.interestRate)).accountsStrict({
9040
9056
  tradingPool: params.tradingPool,
9041
9057
  nodeWallet: new import_web32.PublicKey(params.nodeWallet),
9042
9058
  operator: params.poolOwner,
9043
9059
  systemProgram: import_web32.SystemProgram.programId
9044
9060
  }).instruction() : yield lavarageProgram.methods.lpOperatorUpdateTradingPool({
9045
9061
  maxExposure: null,
9046
- interestRate: new import_anchor.BN(params.interestRate),
9062
+ interestRate: new import_anchor2.BN(params.interestRate),
9047
9063
  openLtv: null,
9048
9064
  feedId: null
9049
9065
  }).accounts({
@@ -9069,13 +9085,13 @@ function updateOffer(lavarageProgram, params) {
9069
9085
  const instructions = [];
9070
9086
  if (isSolProgram(lavarageProgram)) {
9071
9087
  instructions.push(
9072
- yield lavarageProgram.methods.lpOperatorUpdateMaxExposure(new import_anchor.BN(params.maxExposure)).accountsStrict({
9088
+ yield lavarageProgram.methods.lpOperatorUpdateMaxExposure(new import_anchor2.BN(params.maxExposure)).accountsStrict({
9073
9089
  tradingPool: params.tradingPool,
9074
9090
  nodeWallet: new import_web32.PublicKey(params.nodeWallet),
9075
9091
  operator: params.poolOwner,
9076
9092
  systemProgram: import_web32.SystemProgram.programId
9077
9093
  }).instruction(),
9078
- yield lavarageProgram.methods.lpOperatorUpdateInterestRate(new import_anchor.BN(params.interestRate)).accountsStrict({
9094
+ yield lavarageProgram.methods.lpOperatorUpdateInterestRate(new import_anchor2.BN(params.interestRate)).accountsStrict({
9079
9095
  tradingPool: params.tradingPool,
9080
9096
  nodeWallet: new import_web32.PublicKey(params.nodeWallet),
9081
9097
  operator: params.poolOwner,
@@ -9085,8 +9101,8 @@ function updateOffer(lavarageProgram, params) {
9085
9101
  } else {
9086
9102
  instructions.push(
9087
9103
  yield lavarageProgram.methods.lpOperatorUpdateTradingPool({
9088
- maxExposure: new import_anchor.BN(params.maxExposure),
9089
- interestRate: new import_anchor.BN(params.interestRate),
9104
+ maxExposure: new import_anchor2.BN(params.maxExposure),
9105
+ interestRate: new import_anchor2.BN(params.interestRate),
9090
9106
  openLtv: null,
9091
9107
  feedId: null
9092
9108
  }).accounts({
@@ -9117,7 +9133,7 @@ function updateMaxBorrow(lavarageProgram, params) {
9117
9133
  throw new Error("updateMaxBorrow is only supported for the SOL program");
9118
9134
  }
9119
9135
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
9120
- const instruction = yield lavarageProgram.methods.lpOperatorUpdateMaxBorrow(new import_anchor.BN(params.maxBorrow)).accountsStrict({
9136
+ const instruction = yield lavarageProgram.methods.lpOperatorUpdateMaxBorrow(new import_anchor2.BN(params.maxBorrow)).accountsStrict({
9121
9137
  tradingPool: params.tradingPool,
9122
9138
  nodeWallet: new import_web32.PublicKey(params.nodeWallet),
9123
9139
  operator: params.oracle,
@@ -9141,7 +9157,7 @@ function updateOpenLtv(lavarageProgram, params) {
9141
9157
  const instruction = yield lavarageProgram.methods.lpOperatorUpdateTradingPool({
9142
9158
  maxExposure: null,
9143
9159
  interestRate: null,
9144
- openLtv: new import_anchor.BN(params.openLtv),
9160
+ openLtv: new import_anchor2.BN(params.openLtv),
9145
9161
  feedId: null
9146
9162
  }).accounts({
9147
9163
  tradingPool: params.tradingPool,
@@ -9214,6 +9230,7 @@ var lavarageUSDC_exports = {};
9214
9230
 
9215
9231
  // index.ts
9216
9232
  var REFFERAL_VAULT_PROGRAM_ID = new import_web33.PublicKey("FFe8xWs9iBdWB6vsxg8yBLirZHsbACFNbXqAM4K3fPPB");
9233
+ var LAVARAGE_LOOKUP_TABLE = "CDPmKb5VggsHABwDCTaxiw5XXLjcgkqSJMNKRTzHWXwK";
9217
9234
  function getPda(seed, programId) {
9218
9235
  const seedsBuffer = Array.isArray(seed) ? seed : [seed];
9219
9236
  return import_web33.PublicKey.findProgramAddressSync(seedsBuffer, programId)[0];
@@ -9379,10 +9396,10 @@ var borrowV1 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, tokenPr
9379
9396
  }
9380
9397
  }
9381
9398
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
9382
- new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9399
+ new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9383
9400
  marginSOL,
9384
- new import_anchor2.BN(discountBps),
9385
- new import_anchor2.BN(referralBps)
9401
+ new import_anchor3.BN(discountBps),
9402
+ new import_anchor3.BN(referralBps)
9386
9403
  ).accountsStrict({
9387
9404
  nodeWallet: offer.account.nodeWallet,
9388
9405
  instructions: import_web33.SYSVAR_INSTRUCTIONS_PUBKEY,
@@ -9407,7 +9424,7 @@ var borrowV1 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, tokenPr
9407
9424
  }
9408
9425
  ] : []
9409
9426
  ).instruction() : yield lavarageProgram.methods.tradingOpenBorrow(
9410
- new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9427
+ new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9411
9428
  marginSOL
9412
9429
  ).accountsStrict({
9413
9430
  nodeWallet: offer.account.nodeWallet,
@@ -9537,10 +9554,10 @@ var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteTo
9537
9554
  }
9538
9555
  }
9539
9556
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrow(
9540
- new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9557
+ new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9541
9558
  marginSOL,
9542
- new import_anchor2.BN(discountBps),
9543
- new import_anchor2.BN(referralBps)
9559
+ new import_anchor3.BN(discountBps),
9560
+ new import_anchor3.BN(referralBps)
9544
9561
  ).accountsStrict({
9545
9562
  nodeWallet: offer.account.nodeWallet,
9546
9563
  instructions: import_web33.SYSVAR_INSTRUCTIONS_PUBKEY,
@@ -9590,7 +9607,7 @@ var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteTo
9590
9607
  }
9591
9608
  ] : []
9592
9609
  ).instruction() : yield lavarageProgram.methods.tradingOpenBorrow(
9593
- new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9610
+ new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9594
9611
  marginSOL,
9595
9612
  null,
9596
9613
  null
@@ -9688,7 +9705,7 @@ var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteTo
9688
9705
  var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps, optionalRPCResults) => __async(null, null, function* () {
9689
9706
  var _a;
9690
9707
  let partnerFeeMarkupAsPkey;
9691
- const referralVaultProgram = new import_anchor2.Program(userVault_default, lavarageProgram.provider);
9708
+ const referralVaultProgram = new import_anchor3.Program(userVault_default, lavarageProgram.provider);
9692
9709
  if (partnerFeeMarkup) {
9693
9710
  const feeBuffer = Buffer.alloc(8);
9694
9711
  feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
@@ -9771,7 +9788,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9771
9788
  const addressLookupTableAccounts = [];
9772
9789
  addressLookupTableAccounts.push(
9773
9790
  ...yield getAddressLookupTableAccounts([
9774
- "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi",
9791
+ LAVARAGE_LOOKUP_TABLE,
9775
9792
  ...addressLookupTableAddresses
9776
9793
  ])
9777
9794
  );
@@ -9795,10 +9812,10 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9795
9812
  }
9796
9813
  }
9797
9814
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
9798
- new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9815
+ new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9799
9816
  marginSOL,
9800
- new import_anchor2.BN(discountBps),
9801
- new import_anchor2.BN(referralBps)
9817
+ new import_anchor3.BN(discountBps),
9818
+ new import_anchor3.BN(referralBps)
9802
9819
  ).accountsStrict({
9803
9820
  nodeWallet: offer.account.nodeWallet,
9804
9821
  instructions: import_web33.SYSVAR_INSTRUCTIONS_PUBKEY,
@@ -9823,7 +9840,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9823
9840
  }
9824
9841
  ] : []
9825
9842
  ).instruction() : yield lavarageProgram.methods.tradingOpenBorrow(
9826
- new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9843
+ new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9827
9844
  marginSOL
9828
9845
  ).accountsStrict({
9829
9846
  nodeWallet: offer.account.nodeWallet,
@@ -9920,8 +9937,8 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9920
9937
  var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps, optionalRPCResults) => __async(null, null, function* () {
9921
9938
  var _a;
9922
9939
  let partnerFeeMarkupAsPkey;
9923
- const referralVaultProgram = new import_anchor2.Program(userVault_default, lavarageProgram.provider);
9924
- const program = new import_anchor2.Program(lavarageUSDC_default, lavarageProgram.provider);
9940
+ const referralVaultProgram = new import_anchor3.Program(userVault_default, lavarageProgram.provider);
9941
+ const program = new import_anchor3.Program(lavarageUSDC_default, lavarageProgram.provider);
9925
9942
  if (partnerFeeMarkup) {
9926
9943
  const feeBuffer = Buffer.alloc(8);
9927
9944
  feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
@@ -10004,12 +10021,15 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
10004
10021
  }, new Array());
10005
10022
  });
10006
10023
  const addressLookupTableAccounts = [];
10024
+ const queue = yield getSwitchboardQueue(program.provider);
10025
+ const switchboardLookupTables = yield queue.loadLookupTable();
10007
10026
  addressLookupTableAccounts.push(
10008
10027
  ...yield getAddressLookupTableAccounts([
10009
10028
  ...addressLookupTableAddresses,
10010
10029
  getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()),
10011
- "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi"
10012
- ])
10030
+ LAVARAGE_LOOKUP_TABLE
10031
+ ]),
10032
+ switchboardLookupTables
10013
10033
  );
10014
10034
  const { blockhash } = yield program.provider.connection.getLatestBlockhash("finalized");
10015
10035
  const useReferral = discountBps !== void 0 && referralBps !== void 0;
@@ -10072,10 +10092,10 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
10072
10092
  }
10073
10093
  }
10074
10094
  const tradingOpenBorrowInstruction = useReferral ? yield program.methods.tradingOpenBorrow(
10075
- new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
10095
+ new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
10076
10096
  marginSOL,
10077
- new import_anchor2.BN(discountBps),
10078
- new import_anchor2.BN(referralBps)
10097
+ new import_anchor3.BN(discountBps),
10098
+ new import_anchor3.BN(referralBps)
10079
10099
  ).accountsStrict({
10080
10100
  nodeWallet: offer.account.nodeWallet,
10081
10101
  instructions: import_web33.SYSVAR_INSTRUCTIONS_PUBKEY,
@@ -10125,7 +10145,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
10125
10145
  }
10126
10146
  ] : []
10127
10147
  ).instruction() : yield program.methods.tradingOpenBorrow(
10128
- new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
10148
+ new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
10129
10149
  marginSOL,
10130
10150
  null,
10131
10151
  null
@@ -10255,7 +10275,7 @@ var createTpDelegate = (lavarageProgram, position, tpPrice, tpTolerence, prioFee
10255
10275
  tpPrice,
10256
10276
  tpTolerence,
10257
10277
  new import_web33.PublicKey("6dA5GTDPWxnw3gvjoy3vYBDyY7iETxcTJzt8RqF9i9MV"),
10258
- new import_anchor2.BN(1e4)
10278
+ new import_anchor3.BN(1e4)
10259
10279
  ).accountsStrict({
10260
10280
  delegate: getPda(
10261
10281
  [Buffer.from("delegate"), position.publicKey.toBuffer()],
@@ -10303,7 +10323,7 @@ var modifyTpDelegate = (lavarageProgram, position, tpPrice, tpTolerence, prioFee
10303
10323
  tpPrice,
10304
10324
  tpTolerence,
10305
10325
  new import_web33.PublicKey("6dA5GTDPWxnw3gvjoy3vYBDyY7iETxcTJzt8RqF9i9MV"),
10306
- new import_anchor2.BN(1e4)
10326
+ new import_anchor3.BN(1e4)
10307
10327
  ).accountsStrict({
10308
10328
  delegate: delegatePda,
10309
10329
  originalOperator: lavarageProgram.provider.publicKey,
@@ -10358,7 +10378,7 @@ var partialRepayV1 = (lavarageProgram, position, repaymentBps) => __async(null,
10358
10378
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
10359
10379
  const pool = yield lavarageProgram.account.pool.fetch(position.account.pool);
10360
10380
  const positionAccountPDA = position.publicKey;
10361
- const ix = yield lavarageProgram.methods.tradingClosePartialRepaySol(new import_anchor2.BN(repaymentBps)).accountsStrict({
10381
+ const ix = yield lavarageProgram.methods.tradingClosePartialRepaySol(new import_anchor3.BN(repaymentBps)).accountsStrict({
10362
10382
  systemProgram: import_web33.SystemProgram.programId,
10363
10383
  positionAccount: positionAccountPDA,
10364
10384
  tradingPool: position.account.pool,
@@ -10379,7 +10399,7 @@ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(null,
10379
10399
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
10380
10400
  const pool = yield lavarageProgram.account.pool.fetch(position.account.pool);
10381
10401
  const positionAccountPDA = position.publicKey;
10382
- const ix = yield lavarageProgram.methods.tradingPartialRepaySol(new import_anchor2.BN(repaymentBps)).accountsStrict({
10402
+ const ix = yield lavarageProgram.methods.tradingPartialRepaySol(new import_anchor3.BN(repaymentBps)).accountsStrict({
10383
10403
  systemProgram: import_web33.SystemProgram.programId,
10384
10404
  positionAccount: positionAccountPDA,
10385
10405
  tradingPool: position.account.pool,
@@ -10413,7 +10433,7 @@ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(null,
10413
10433
  var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps) => __async(null, null, function* () {
10414
10434
  var _a, _b;
10415
10435
  let partnerFeeMarkupAsPkey;
10416
- const referralVaultProgram = new import_anchor2.Program(userVault_default, lavarageProgram.provider);
10436
+ const referralVaultProgram = new import_anchor3.Program(userVault_default, lavarageProgram.provider);
10417
10437
  if (partnerFeeMarkup) {
10418
10438
  const feeBuffer = Buffer.alloc(8);
10419
10439
  feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
@@ -10517,10 +10537,10 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10517
10537
  let jupiterIxs = [];
10518
10538
  if (jupInstruction.instructions == void 0) {
10519
10539
  repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10520
- new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
10521
- new import_anchor2.BN(9997),
10522
- new import_anchor2.BN(discountBps),
10523
- new import_anchor2.BN(referralBps)
10540
+ new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10541
+ new import_anchor3.BN(9997),
10542
+ new import_anchor3.BN(discountBps),
10543
+ new import_anchor3.BN(referralBps)
10524
10544
  ).accountsStrict({
10525
10545
  nodeWallet: pool.account.nodeWallet,
10526
10546
  positionAccount: positionAccountPDA,
@@ -10539,8 +10559,8 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10539
10559
  }
10540
10560
  ] : []
10541
10561
  ).instruction() : yield lavarageProgram.methods.tradingCloseRepaySol(
10542
- new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
10543
- new import_anchor2.BN(9997)
10562
+ new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10563
+ new import_anchor3.BN(9997)
10544
10564
  ).accountsStrict({
10545
10565
  nodeWallet: pool.account.nodeWallet,
10546
10566
  positionAccount: positionAccountPDA,
@@ -10566,10 +10586,10 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10566
10586
  ).instruction();
10567
10587
  } else {
10568
10588
  repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10569
- new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
10570
- new import_anchor2.BN(9998),
10571
- new import_anchor2.BN(discountBps),
10572
- new import_anchor2.BN(referralBps)
10589
+ new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10590
+ new import_anchor3.BN(9998),
10591
+ new import_anchor3.BN(discountBps),
10592
+ new import_anchor3.BN(referralBps)
10573
10593
  ).accountsStrict({
10574
10594
  nodeWallet: pool.account.nodeWallet,
10575
10595
  positionAccount: positionAccountPDA,
@@ -10588,8 +10608,8 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10588
10608
  }
10589
10609
  ] : []
10590
10610
  ).instruction() : yield lavarageProgram.methods.tradingCloseRepaySol(
10591
- new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
10592
- new import_anchor2.BN(9998)
10611
+ new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10612
+ new import_anchor3.BN(9998)
10593
10613
  ).accountsStrict({
10594
10614
  nodeWallet: pool.account.nodeWallet,
10595
10615
  positionAccount: positionAccountPDA,
@@ -10626,12 +10646,12 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10626
10646
  ].filter((i) => !!i);
10627
10647
  addressLookupTableAccounts.push(
10628
10648
  ...yield getAddressLookupTableAccounts([
10629
- "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi",
10649
+ LAVARAGE_LOOKUP_TABLE,
10630
10650
  ...addressLookupTableAddresses
10631
10651
  ])
10632
10652
  );
10633
10653
  }
10634
- const profit = new import_anchor2.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
10654
+ const profit = new import_anchor3.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
10635
10655
  let createAssociatedTokenAccountInstruction2 = (0, import_spl_token3.createAssociatedTokenAccountIdempotentInstruction)(
10636
10656
  lavarageProgram.provider.publicKey,
10637
10657
  toTokenAccount.account.address,
@@ -10692,7 +10712,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10692
10712
  var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps) => __async(null, null, function* () {
10693
10713
  var _a, _b;
10694
10714
  let partnerFeeMarkupAsPkey;
10695
- const referralVaultProgram = new import_anchor2.Program(userVault_default, lavarageProgram.provider);
10715
+ const referralVaultProgram = new import_anchor3.Program(userVault_default, lavarageProgram.provider);
10696
10716
  if (partnerFeeMarkup) {
10697
10717
  const feeBuffer = Buffer.alloc(8);
10698
10718
  feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
@@ -10819,10 +10839,10 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10819
10839
  let jupiterIxs = [];
10820
10840
  if (jupInstruction.instructions == void 0) {
10821
10841
  repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySol(
10822
- new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
10823
- new import_anchor2.BN(9997),
10824
- new import_anchor2.BN(discountBps),
10825
- new import_anchor2.BN(referralBps)
10842
+ new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10843
+ new import_anchor3.BN(9997),
10844
+ new import_anchor3.BN(discountBps),
10845
+ new import_anchor3.BN(referralBps)
10826
10846
  ).accountsStrict({
10827
10847
  nodeWallet: pool.account.nodeWallet,
10828
10848
  positionAccount: positionAccountPDA,
@@ -10866,8 +10886,10 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10866
10886
  }
10867
10887
  ] : []
10868
10888
  ).instruction() : yield lavarageProgram.methods.tradingCloseRepaySol(
10869
- new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
10870
- new import_anchor2.BN(9997)
10889
+ new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10890
+ new import_anchor3.BN(9997),
10891
+ null,
10892
+ null
10871
10893
  ).accountsStrict({
10872
10894
  nodeWallet: pool.account.nodeWallet,
10873
10895
  positionAccount: positionAccountPDA,
@@ -10917,10 +10939,10 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10917
10939
  ).instruction();
10918
10940
  } else {
10919
10941
  repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySol(
10920
- new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
10921
- new import_anchor2.BN(9998),
10922
- new import_anchor2.BN(discountBps),
10923
- new import_anchor2.BN(referralBps)
10942
+ new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10943
+ new import_anchor3.BN(9998),
10944
+ new import_anchor3.BN(discountBps),
10945
+ new import_anchor3.BN(referralBps)
10924
10946
  ).accountsStrict({
10925
10947
  nodeWallet: pool.account.nodeWallet,
10926
10948
  positionAccount: positionAccountPDA,
@@ -10964,8 +10986,10 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10964
10986
  }
10965
10987
  ] : []
10966
10988
  ).instruction() : yield lavarageProgram.methods.tradingCloseRepaySol(
10967
- new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
10968
- new import_anchor2.BN(9998)
10989
+ new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10990
+ new import_anchor3.BN(9998),
10991
+ null,
10992
+ null
10969
10993
  ).accountsStrict({
10970
10994
  nodeWallet: pool.account.nodeWallet,
10971
10995
  positionAccount: positionAccountPDA,
@@ -11028,11 +11052,11 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
11028
11052
  ...yield getAddressLookupTableAccounts([
11029
11053
  ...addressLookupTableAddresses,
11030
11054
  getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()),
11031
- "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi"
11055
+ LAVARAGE_LOOKUP_TABLE
11032
11056
  ])
11033
11057
  );
11034
11058
  }
11035
- const profit = new import_anchor2.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
11059
+ const profit = new import_anchor3.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
11036
11060
  let createAssociatedTokenAccountInstruction2 = (0, import_spl_token3.createAssociatedTokenAccountIdempotentInstruction)(
11037
11061
  lavarageProgram.provider.publicKey,
11038
11062
  toTokenAccount.account.address,
@@ -11107,8 +11131,8 @@ var getDelegateAccounts = (lavarageProgram, userPubKey) => __async(null, null, f
11107
11131
  );
11108
11132
  return delegateAccounts.map((d) => __spreadProps(__spreadValues({}, d), {
11109
11133
  parsed: {
11110
- tpPrice: new import_anchor2.BN(d.account.field1),
11111
- tpThreshold: new import_anchor2.BN(d.account.field2)
11134
+ tpPrice: new import_anchor3.BN(d.account.field1),
11135
+ tpThreshold: new import_anchor3.BN(d.account.field2)
11112
11136
  }
11113
11137
  }));
11114
11138
  });
@@ -11167,7 +11191,7 @@ var splitPositionV2 = (lavarageProgram, position, offer, quoteToken, propotionBp
11167
11191
  tokenProgram
11168
11192
  );
11169
11193
  const ix = yield lavarageProgram.methods.tradingManagementSplitPosition(
11170
- new import_anchor2.BN(propotionBps),
11194
+ new import_anchor3.BN(propotionBps),
11171
11195
  newPosition1Seed,
11172
11196
  newPosition2Seed
11173
11197
  ).accountsStrict({