@0dotxyz/p0-ts-sdk 2.5.5-alpha.2 → 2.5.5-alpha.4

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.cjs CHANGED
@@ -20084,12 +20084,8 @@ var NATIVE_STAKE_LUT_KEYS = new Set(
20084
20084
  Object.values(ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE).flat().map((key) => key.toBase58())
20085
20085
  );
20086
20086
  function selectLutsForBanks(luts, banks) {
20087
- const nativeStakeLuts = luts.filter(
20088
- (lut) => NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58())
20089
- );
20090
- const generalLuts = luts.filter(
20091
- (lut) => !NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58())
20092
- );
20087
+ const nativeStakeLuts = luts.filter((lut) => NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58()));
20088
+ const generalLuts = luts.filter((lut) => !NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58()));
20093
20089
  const allStakedOrSol = banks.length > 0 && banks.every(
20094
20090
  (bank) => bank.config.assetTag === 2 /* STAKED */ || bank.config.assetTag === 1 /* SOL */
20095
20091
  );
@@ -20136,37 +20132,54 @@ async function makeVersionedTransaction(blockhash, transaction, payer, addressLo
20136
20132
  const versionedMessage = addressLookupTables ? message.compileToV0Message(addressLookupTables) : message.compileToLegacyMessage();
20137
20133
  return new web3_js.VersionedTransaction(versionedMessage);
20138
20134
  }
20135
+ function countTxAccountLocks(tx) {
20136
+ const message = tx.message;
20137
+ const lookupKeys = (message.addressTableLookups ?? []).reduce(
20138
+ (count, lookup) => count + lookup.writableIndexes.length + lookup.readonlyIndexes.length,
20139
+ 0
20140
+ );
20141
+ return message.staticAccountKeys.length + lookupKeys;
20142
+ }
20139
20143
  function splitInstructionsToFitTransactions(mandatoryIxs, ixs, opts) {
20140
20144
  const result = [];
20141
20145
  let buffer = [];
20142
- function buildTx(mandatoryIxs2, extraIxs, opts2) {
20146
+ const maxSize = MAX_TX_SIZE - (opts.sizeMargin ?? 0);
20147
+ function buildTx(extraIxs) {
20143
20148
  const messageV0 = new web3_js.TransactionMessage({
20144
- payerKey: opts2.payerKey,
20145
- recentBlockhash: opts2.blockhash,
20146
- instructions: [...mandatoryIxs2, ...extraIxs]
20147
- }).compileToV0Message(opts2.luts);
20149
+ payerKey: opts.payerKey,
20150
+ recentBlockhash: opts.blockhash,
20151
+ instructions: [...mandatoryIxs, ...extraIxs]
20152
+ }).compileToV0Message(opts.luts);
20148
20153
  return new web3_js.VersionedTransaction(messageV0);
20149
20154
  }
20155
+ function fits(extraIxs) {
20156
+ try {
20157
+ const tx = buildTx(extraIxs);
20158
+ if (getTxSize(tx) > maxSize) return false;
20159
+ if (opts.maxAccountLocks !== void 0 && countTxAccountLocks(tx) > opts.maxAccountLocks) {
20160
+ return false;
20161
+ }
20162
+ return true;
20163
+ } catch {
20164
+ return false;
20165
+ }
20166
+ }
20150
20167
  for (const ix of ixs) {
20151
- const trial = buildTx(mandatoryIxs, [...buffer, ix], opts);
20152
- if (getTxSize(trial) <= MAX_TX_SIZE) {
20168
+ if (fits([...buffer, ix])) {
20153
20169
  buffer.push(ix);
20154
- } else {
20155
- if (buffer.length === 0) {
20156
- throw new Error("Single instruction too large to fit in a transaction");
20157
- }
20158
- const tx = buildTx(mandatoryIxs, buffer, opts);
20159
- result.push(tx);
20160
- buffer = [ix];
20161
- const solo = buildTx(mandatoryIxs, buffer, opts);
20162
- if (getTxSize(solo) > MAX_TX_SIZE) {
20163
- throw new Error("Single instruction too large to fit in a transaction");
20164
- }
20170
+ continue;
20171
+ }
20172
+ if (buffer.length === 0) {
20173
+ throw new Error("Single instruction too large to fit in a transaction");
20174
+ }
20175
+ result.push(buildTx(buffer));
20176
+ buffer = [ix];
20177
+ if (!fits(buffer)) {
20178
+ throw new Error("Single instruction too large to fit in a transaction");
20165
20179
  }
20166
20180
  }
20167
20181
  if (buffer.length > 0) {
20168
- const tx = buildTx(mandatoryIxs, buffer, opts);
20169
- result.push(tx);
20182
+ result.push(buildTx(buffer));
20170
20183
  }
20171
20184
  return result;
20172
20185
  }
@@ -26425,7 +26438,13 @@ BigInt(200);
26425
26438
  BigInt(82);
26426
26439
 
26427
26440
  // src/services/account/utils/compute/transaction-projection.utils.ts
26428
- function computeHealthCheckAccounts(balances, banksMap, mandatoryBanks = [], excludedBanks = []) {
26441
+ function computeHealthCheckAccounts({
26442
+ account,
26443
+ banksMap,
26444
+ mandatoryBanks = [],
26445
+ excludedBanks = []
26446
+ }) {
26447
+ const balances = account.balances;
26429
26448
  const activeBalances = balances.filter((b) => b.active);
26430
26449
  const mandatoryBanksSet = new Set(mandatoryBanks.map((b) => b.toBase58()));
26431
26450
  const excludedBanksSet = new Set(excludedBanks.map((b) => b.toBase58()));
@@ -26455,7 +26474,11 @@ function computeHealthCheckAccounts(balances, banksMap, mandatoryBanks = [], exc
26455
26474
  });
26456
26475
  return projectedActiveBanks;
26457
26476
  }
26458
- function computeHealthAccountMetas(banksToInclude, enableSorting = true, trailingBanks = []) {
26477
+ function computeHealthAccountMetas({
26478
+ banksToInclude,
26479
+ enableSorting = true,
26480
+ trailingBanks = []
26481
+ }) {
26459
26482
  let wrapperFn = enableSorting ? composeRemainingAccounts : (banksAndOracles) => banksAndOracles.flat();
26460
26483
  const accounts = wrapperFn(banksToInclude.map(computeBankRiskAccountKeys));
26461
26484
  for (const bank of trailingBanks) {
@@ -26485,14 +26508,22 @@ function computeBankRiskAccountKeys(bank) {
26485
26508
  }
26486
26509
  return keys;
26487
26510
  }
26488
- function computeProjectedActiveBanksNoCpi(balances, instructions2, program) {
26489
- let projectedBalances = [...balances.map((b) => ({ active: b.active, bankPk: b.bankPk }))];
26511
+ function computeProjectedActiveBanksNoCpi({
26512
+ account,
26513
+ instructions: instructions2,
26514
+ program
26515
+ }) {
26516
+ let projectedBalances = [
26517
+ ...account.balances.map((b) => ({ active: b.active, bankPk: b.bankPk }))
26518
+ ];
26490
26519
  for (let index = 0; index < instructions2.length; index++) {
26491
26520
  const ix = instructions2[index];
26492
26521
  if (!ix?.programId.equals(program.programId)) continue;
26493
26522
  const borshCoder = new anchor.BorshInstructionCoder(program.idl);
26494
26523
  const decoded = borshCoder.decode(ix.data, "base58");
26495
26524
  if (!decoded) continue;
26525
+ const ixMarginfiAccount = ix.keys[1]?.pubkey;
26526
+ if (!ixMarginfiAccount?.equals(account.address)) continue;
26496
26527
  const ixArgs = decoded.data;
26497
26528
  switch (decoded.name) {
26498
26529
  case "lendingAccountBorrow":
@@ -26540,8 +26571,14 @@ function computeProjectedActiveBanksNoCpi(balances, instructions2, program) {
26540
26571
  }
26541
26572
  return projectedBalances.filter((b) => b.active).map((b) => b.bankPk);
26542
26573
  }
26543
- function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, banksMap, assetShareValueMultiplierByBank) {
26544
- let projectedBalances = balances.map((b) => ({
26574
+ function computeProjectedActiveBalancesNoCpi({
26575
+ account,
26576
+ instructions: instructions2,
26577
+ program,
26578
+ banksMap,
26579
+ assetShareValueMultiplierByBank
26580
+ }) {
26581
+ let projectedBalances = account.balances.map((b) => ({
26545
26582
  active: b.active,
26546
26583
  bankPk: b.bankPk,
26547
26584
  assetShares: new BigNumber3__default.default(b.assetShares),
@@ -26558,6 +26595,8 @@ function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, b
26558
26595
  const borshCoder = new anchor.BorshInstructionCoder(program.idl);
26559
26596
  const decoded = borshCoder.decode(ix.data, "base58");
26560
26597
  if (!decoded) continue;
26598
+ const ixMarginfiAccount = ix.keys[1]?.pubkey;
26599
+ if (!ixMarginfiAccount?.equals(account.address)) continue;
26561
26600
  const ixArgs = decoded.data;
26562
26601
  switch (decoded.name) {
26563
26602
  // Instructions that open or add to a position
@@ -41567,13 +41606,18 @@ async function makeSetupIx({ connection, authority, tokens }) {
41567
41606
  return [];
41568
41607
  }
41569
41608
  }
41570
- async function makePulseHealthIx2(program, marginfiAccountPk, banks, balances, mandatoryBanks, excludedBanks) {
41571
- const healthAccounts = computeHealthCheckAccounts(balances, banks, mandatoryBanks, excludedBanks);
41572
- const accountMetas = computeHealthAccountMetas(healthAccounts);
41609
+ async function makePulseHealthIx2(program, marginfiAccount, banks, mandatoryBanks, excludedBanks) {
41610
+ const healthAccounts = computeHealthCheckAccounts({
41611
+ account: marginfiAccount,
41612
+ banksMap: banks,
41613
+ mandatoryBanks,
41614
+ excludedBanks
41615
+ });
41616
+ const accountMetas = computeHealthAccountMetas({ banksToInclude: healthAccounts });
41573
41617
  const ix = await instructions_default.makePulseHealthIx(
41574
41618
  program,
41575
41619
  {
41576
- marginfiAccount: marginfiAccountPk
41620
+ marginfiAccount: marginfiAccount.address
41577
41621
  },
41578
41622
  accountMetas.map((account) => ({
41579
41623
  pubkey: account,
@@ -63746,7 +63790,15 @@ async function makeDriftWithdrawIx3({
63746
63790
  );
63747
63791
  withdrawIxs.push(createAtaIdempotentIx);
63748
63792
  }
63749
- const healthAccounts = withdrawAll ? computeHealthCheckAccounts(marginfiAccount.balances, bankMap, [], [bank.address]) : computeHealthCheckAccounts(marginfiAccount.balances, bankMap, [bank.address], []);
63793
+ const healthAccounts = withdrawAll ? computeHealthCheckAccounts({
63794
+ account: marginfiAccount,
63795
+ banksMap: bankMap,
63796
+ excludedBanks: [bank.address]
63797
+ }) : computeHealthCheckAccounts({
63798
+ account: marginfiAccount,
63799
+ banksMap: bankMap,
63800
+ mandatoryBanks: [bank.address]
63801
+ });
63750
63802
  const marketIndex = driftSpotMarket.marketIndex;
63751
63803
  const driftOracle = driftSpotMarket.oracle;
63752
63804
  const { driftState, driftSigner, driftSpotMarketVault } = getAllDerivedDriftAccounts(marketIndex);
@@ -63756,7 +63808,10 @@ async function makeDriftWithdrawIx3({
63756
63808
  if (opts.observationBanksOverride) {
63757
63809
  remainingAccounts.push(...opts.observationBanksOverride);
63758
63810
  } else {
63759
- const accountMetas = computeHealthAccountMetas(healthAccounts, true, withdrawAll ? [bank] : []);
63811
+ const accountMetas = computeHealthAccountMetas({
63812
+ banksToInclude: healthAccounts,
63813
+ trailingBanks: withdrawAll ? [bank] : []
63814
+ });
63760
63815
  remainingAccounts.push(...accountMetas);
63761
63816
  }
63762
63817
  if (userRewards.length > 2) {
@@ -63871,19 +63926,7 @@ async function makeDriftWithdrawTx(params) {
63871
63926
  updateFeedIxs = _updateFeedIxs;
63872
63927
  feedLuts = _feedLuts;
63873
63928
  }
63874
- const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
63875
- params.marginfiAccount,
63876
- params.bankMap,
63877
- [withdrawIxParams.bank.address],
63878
- params.bankMetadataMap
63879
- );
63880
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
63881
- params.marginfiAccount,
63882
- params.bankMap,
63883
- [withdrawIxParams.bank.address],
63884
- params.bankMetadataMap
63885
- );
63886
- const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
63929
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
63887
63930
  params.marginfiAccount,
63888
63931
  params.bankMap,
63889
63932
  [withdrawIxParams.bank.address],
@@ -63913,23 +63956,13 @@ async function makeDriftWithdrawTx(params) {
63913
63956
  const withdrawTx = addTransactionMetadata(
63914
63957
  new web3_js.VersionedTransaction(
63915
63958
  new web3_js.TransactionMessage({
63916
- instructions: [
63917
- ...kaminoRefreshIxs.instructions,
63918
- ...updateDriftMarketIxs.instructions,
63919
- ...updateJupLendRateIxs.instructions,
63920
- ...withdrawIxs.instructions
63921
- ],
63959
+ instructions: [...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
63922
63960
  payerKey: params.authority,
63923
63961
  recentBlockhash: blockhash
63924
63962
  }).compileToV0Message(selectedLuts)
63925
63963
  ),
63926
63964
  {
63927
- signers: [
63928
- ...kaminoRefreshIxs.keys,
63929
- ...updateDriftMarketIxs.keys,
63930
- ...updateJupLendRateIxs.keys,
63931
- ...withdrawIxs.keys
63932
- ],
63965
+ signers: [...refreshIntegrationIxs.keys, ...withdrawIxs.keys],
63933
63966
  addressLookupTables: selectedLuts,
63934
63967
  type: "WITHDRAW" /* WITHDRAW */
63935
63968
  }
@@ -63965,7 +63998,15 @@ async function makeKaminoWithdrawIx3({
63965
63998
  );
63966
63999
  withdrawIxs.push(createAtaIdempotentIx);
63967
64000
  }
63968
- const healthAccounts = withdrawAll ? computeHealthCheckAccounts(marginfiAccount.balances, bankMap, [], [bank.address]) : computeHealthCheckAccounts(marginfiAccount.balances, bankMap, [bank.address], []);
64001
+ const healthAccounts = withdrawAll ? computeHealthCheckAccounts({
64002
+ account: marginfiAccount,
64003
+ banksMap: bankMap,
64004
+ excludedBanks: [bank.address]
64005
+ }) : computeHealthCheckAccounts({
64006
+ account: marginfiAccount,
64007
+ banksMap: bankMap,
64008
+ mandatoryBanks: [bank.address]
64009
+ });
63969
64010
  const lendingMarket = reserve.lendingMarket;
63970
64011
  const reserveLiquiditySupply = reserve.liquidity.supplyVault;
63971
64012
  const reserveCollateralMint = reserve.collateral.mintPubkey;
@@ -63985,7 +64026,10 @@ async function makeKaminoWithdrawIx3({
63985
64026
  if (opts.observationBanksOverride) {
63986
64027
  remainingAccounts.push(...opts.observationBanksOverride);
63987
64028
  } else {
63988
- const accountMetas = computeHealthAccountMetas(healthAccounts, true, withdrawAll ? [bank] : []);
64029
+ const accountMetas = computeHealthAccountMetas({
64030
+ banksToInclude: healthAccounts,
64031
+ trailingBanks: withdrawAll ? [bank] : []
64032
+ });
63989
64033
  remainingAccounts.push(...accountMetas);
63990
64034
  }
63991
64035
  const withdrawIx = isSync ? sync_instructions_default.makeKaminoWithdrawIx(
@@ -64080,7 +64124,15 @@ async function makeWithdrawIx3({
64080
64124
  );
64081
64125
  withdrawIxs.push(createAtaIdempotentIx);
64082
64126
  }
64083
- const healthAccounts = withdrawAll ? computeHealthCheckAccounts(marginfiAccount.balances, bankMap, [], [bank.address]) : computeHealthCheckAccounts(marginfiAccount.balances, bankMap, [bank.address], []);
64127
+ const healthAccounts = withdrawAll ? computeHealthCheckAccounts({
64128
+ account: marginfiAccount,
64129
+ banksMap: bankMap,
64130
+ excludedBanks: [bank.address]
64131
+ }) : computeHealthCheckAccounts({
64132
+ account: marginfiAccount,
64133
+ banksMap: bankMap,
64134
+ mandatoryBanks: [bank.address]
64135
+ });
64084
64136
  const remainingAccounts = [];
64085
64137
  if (tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
64086
64138
  remainingAccounts.push(bank.mint);
@@ -64088,7 +64140,10 @@ async function makeWithdrawIx3({
64088
64140
  if (opts.observationBanksOverride) {
64089
64141
  remainingAccounts.push(...opts.observationBanksOverride);
64090
64142
  } else {
64091
- const accountMetas = computeHealthAccountMetas(healthAccounts, true, withdrawAll ? [bank] : []);
64143
+ const accountMetas = computeHealthAccountMetas({
64144
+ banksToInclude: healthAccounts,
64145
+ trailingBanks: withdrawAll ? [bank] : []
64146
+ });
64092
64147
  remainingAccounts.push(...accountMetas);
64093
64148
  }
64094
64149
  const withdrawIx = isSync ? sync_instructions_default.makeWithdrawIx(
@@ -64161,19 +64216,7 @@ async function makeWithdrawTx(params) {
64161
64216
  updateFeedIxs = _updateFeedIxs;
64162
64217
  feedLuts = _feedLuts;
64163
64218
  }
64164
- const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
64165
- params.marginfiAccount,
64166
- params.bankMap,
64167
- [withdrawIxParams.bank.address],
64168
- params.bankMetadataMap
64169
- );
64170
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
64171
- params.marginfiAccount,
64172
- params.bankMap,
64173
- [withdrawIxParams.bank.address],
64174
- params.bankMetadataMap
64175
- );
64176
- const refreshIxs = makeRefreshKaminoBanksIxs(
64219
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
64177
64220
  params.marginfiAccount,
64178
64221
  params.bankMap,
64179
64222
  [withdrawIxParams.bank.address],
@@ -64203,23 +64246,13 @@ async function makeWithdrawTx(params) {
64203
64246
  const withdrawTx = addTransactionMetadata(
64204
64247
  new web3_js.VersionedTransaction(
64205
64248
  new web3_js.TransactionMessage({
64206
- instructions: [
64207
- ...refreshIxs.instructions,
64208
- ...updateDriftMarketIxs.instructions,
64209
- ...updateJupLendRateIxs.instructions,
64210
- ...withdrawIxs.instructions
64211
- ],
64249
+ instructions: [...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
64212
64250
  payerKey: params.authority,
64213
64251
  recentBlockhash: blockhash
64214
64252
  }).compileToV0Message(selectedLuts)
64215
64253
  ),
64216
64254
  {
64217
- signers: [
64218
- ...refreshIxs.keys,
64219
- ...updateDriftMarketIxs.keys,
64220
- ...updateJupLendRateIxs.keys,
64221
- ...withdrawIxs.keys
64222
- ],
64255
+ signers: [...refreshIntegrationIxs.keys, ...withdrawIxs.keys],
64223
64256
  addressLookupTables: selectedLuts,
64224
64257
  type: "WITHDRAW" /* WITHDRAW */
64225
64258
  }
@@ -64241,19 +64274,7 @@ async function makeKaminoWithdrawTx(params) {
64241
64274
  const { value: amountValue, type: amountType } = resolveAmount(amount);
64242
64275
  const multiplier = assetShareValueMultiplierByBank.get(withdrawIxParams.bank.address.toBase58()) ?? new BigNumber3.BigNumber(1);
64243
64276
  const adjustedAmount = amountType === "cToken" ? new BigNumber3.BigNumber(amountValue).toNumber() : new BigNumber3.BigNumber(amountValue).div(multiplier).toNumber();
64244
- const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
64245
- params.marginfiAccount,
64246
- params.bankMap,
64247
- [withdrawIxParams.bank.address],
64248
- params.bankMetadataMap
64249
- );
64250
- const refreshIxs = makeRefreshKaminoBanksIxs(
64251
- params.marginfiAccount,
64252
- params.bankMap,
64253
- [withdrawIxParams.bank.address],
64254
- params.bankMetadataMap
64255
- );
64256
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
64277
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
64257
64278
  params.marginfiAccount,
64258
64279
  params.bankMap,
64259
64280
  [withdrawIxParams.bank.address],
@@ -64297,23 +64318,13 @@ async function makeKaminoWithdrawTx(params) {
64297
64318
  const withdrawTx = addTransactionMetadata(
64298
64319
  new web3_js.VersionedTransaction(
64299
64320
  new web3_js.TransactionMessage({
64300
- instructions: [
64301
- ...refreshIxs.instructions,
64302
- ...updateDriftMarketIxs.instructions,
64303
- ...updateJupLendRateIxs.instructions,
64304
- ...withdrawIxs.instructions
64305
- ],
64321
+ instructions: [...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
64306
64322
  payerKey: params.authority,
64307
64323
  recentBlockhash: blockhash
64308
64324
  }).compileToV0Message(selectedLuts)
64309
64325
  ),
64310
64326
  {
64311
- signers: [
64312
- ...refreshIxs.keys,
64313
- ...updateDriftMarketIxs.keys,
64314
- ...updateJupLendRateIxs.keys,
64315
- ...withdrawIxs.keys
64316
- ],
64327
+ signers: [...refreshIntegrationIxs.keys, ...withdrawIxs.keys],
64317
64328
  addressLookupTables: selectedLuts,
64318
64329
  type: "WITHDRAW" /* WITHDRAW */
64319
64330
  }
@@ -64348,7 +64359,15 @@ async function makeJuplendWithdrawIx2({
64348
64359
  );
64349
64360
  withdrawIxs.push(createAtaIdempotentIx);
64350
64361
  }
64351
- const healthAccounts = withdrawAll ? computeHealthCheckAccounts(marginfiAccount.balances, bankMap, [], [bank.address]) : computeHealthCheckAccounts(marginfiAccount.balances, bankMap, [bank.address], []);
64362
+ const healthAccounts = withdrawAll ? computeHealthCheckAccounts({
64363
+ account: marginfiAccount,
64364
+ banksMap: bankMap,
64365
+ excludedBanks: [bank.address]
64366
+ }) : computeHealthCheckAccounts({
64367
+ account: marginfiAccount,
64368
+ banksMap: bankMap,
64369
+ mandatoryBanks: [bank.address]
64370
+ });
64352
64371
  if (!bank.jupLendIntegrationAccounts) {
64353
64372
  throw new Error("Bank has no JupLend integration accounts");
64354
64373
  }
@@ -64361,7 +64380,10 @@ async function makeJuplendWithdrawIx2({
64361
64380
  if (opts.observationBanksOverride) {
64362
64381
  remainingAccounts.push(...opts.observationBanksOverride);
64363
64382
  } else {
64364
- const accountMetas = computeHealthAccountMetas(healthAccounts, true, withdrawAll ? [bank] : []);
64383
+ const accountMetas = computeHealthAccountMetas({
64384
+ banksToInclude: healthAccounts,
64385
+ trailingBanks: withdrawAll ? [bank] : []
64386
+ });
64365
64387
  remainingAccounts.push(...accountMetas);
64366
64388
  }
64367
64389
  const withdrawIx = await instructions_default.makeJuplendWithdrawIx(
@@ -64435,19 +64457,7 @@ async function makeJuplendWithdrawTx(params) {
64435
64457
  updateFeedIxs = _updateFeedIxs;
64436
64458
  feedLuts = _feedLuts;
64437
64459
  }
64438
- const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
64439
- params.marginfiAccount,
64440
- params.bankMap,
64441
- [withdrawIxParams.bank.address],
64442
- params.bankMetadataMap
64443
- );
64444
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
64445
- params.marginfiAccount,
64446
- params.bankMap,
64447
- [withdrawIxParams.bank.address],
64448
- params.bankMetadataMap
64449
- );
64450
- const refreshIxs = makeRefreshKaminoBanksIxs(
64460
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
64451
64461
  params.marginfiAccount,
64452
64462
  params.bankMap,
64453
64463
  [withdrawIxParams.bank.address],
@@ -64477,18 +64487,13 @@ async function makeJuplendWithdrawTx(params) {
64477
64487
  const withdrawTx = addTransactionMetadata(
64478
64488
  new web3_js.VersionedTransaction(
64479
64489
  new web3_js.TransactionMessage({
64480
- instructions: [
64481
- ...refreshIxs.instructions,
64482
- ...updateDriftMarketIxs.instructions,
64483
- ...updateJupLendRateIxs.instructions,
64484
- ...withdrawIxs.instructions
64485
- ],
64490
+ instructions: [...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
64486
64491
  payerKey: params.authority,
64487
64492
  recentBlockhash: blockhash
64488
64493
  }).compileToV0Message(selectedLuts)
64489
64494
  ),
64490
64495
  {
64491
- signers: [...refreshIxs.keys, ...withdrawIxs.keys],
64496
+ signers: [...refreshIntegrationIxs.keys, ...withdrawIxs.keys],
64492
64497
  addressLookupTables: selectedLuts,
64493
64498
  type: "WITHDRAW" /* WITHDRAW */
64494
64499
  }
@@ -64522,12 +64527,11 @@ async function makeBorrowIx3({
64522
64527
  borrowIxs.push(createAtaIdempotentIx);
64523
64528
  }
64524
64529
  const mandatoryBanks = [bank.address, ...opts.additionalHealthCheckBanks ?? []];
64525
- const healthAccounts = computeHealthCheckAccounts(
64526
- marginfiAccount.balances,
64527
- bankMap,
64528
- mandatoryBanks,
64529
- []
64530
- );
64530
+ const healthAccounts = computeHealthCheckAccounts({
64531
+ account: marginfiAccount,
64532
+ banksMap: bankMap,
64533
+ mandatoryBanks
64534
+ });
64531
64535
  const remainingAccounts = [];
64532
64536
  if (tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
64533
64537
  remainingAccounts.push(bank.mint);
@@ -64535,7 +64539,7 @@ async function makeBorrowIx3({
64535
64539
  if (opts?.observationBanksOverride) {
64536
64540
  remainingAccounts.push(...opts.observationBanksOverride);
64537
64541
  } else {
64538
- const accountMetas = computeHealthAccountMetas(healthAccounts);
64542
+ const accountMetas = computeHealthAccountMetas({ banksToInclude: healthAccounts });
64539
64543
  remainingAccounts.push(...accountMetas);
64540
64544
  }
64541
64545
  const borrowIx = isSync ? sync_instructions_default.makeBorrowIx(
@@ -64589,19 +64593,7 @@ async function makeBorrowTx(params) {
64589
64593
  params.bankMap,
64590
64594
  borrowIxParams.opts?.additionalHealthCheckBanks
64591
64595
  );
64592
- const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
64593
- params.marginfiAccount,
64594
- params.bankMap,
64595
- [borrowIxParams.bank.address],
64596
- params.bankMetadataMap
64597
- );
64598
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
64599
- params.marginfiAccount,
64600
- params.bankMap,
64601
- [borrowIxParams.bank.address],
64602
- params.bankMetadataMap
64603
- );
64604
- const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
64596
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
64605
64597
  params.marginfiAccount,
64606
64598
  params.bankMap,
64607
64599
  [borrowIxParams.bank.address],
@@ -64642,18 +64634,13 @@ async function makeBorrowTx(params) {
64642
64634
  const borrowTx = addTransactionMetadata(
64643
64635
  new web3_js.VersionedTransaction(
64644
64636
  new web3_js.TransactionMessage({
64645
- instructions: [
64646
- ...kaminoRefreshIxs.instructions,
64647
- ...updateDriftMarketIxs.instructions,
64648
- ...updateJupLendRateIxs.instructions,
64649
- ...borrowIxs.instructions
64650
- ],
64637
+ instructions: [...refreshIntegrationIxs.instructions, ...borrowIxs.instructions],
64651
64638
  payerKey: params.authority,
64652
64639
  recentBlockhash: blockhash
64653
64640
  }).compileToV0Message(selectedLuts)
64654
64641
  ),
64655
64642
  {
64656
- signers: [...kaminoRefreshIxs.keys, ...borrowIxs.keys],
64643
+ signers: [...refreshIntegrationIxs.keys, ...borrowIxs.keys],
64657
64644
  addressLookupTables: selectedLuts,
64658
64645
  type: "BORROW" /* BORROW */
64659
64646
  }
@@ -66157,7 +66144,7 @@ async function makeBeginFlashLoanIx3(program, marginfiAccountPk, endIndex, autho
66157
66144
  return { instructions: [ix], keys: [] };
66158
66145
  }
66159
66146
  async function makeEndFlashLoanIx3(program, marginfiAccountPk, projectedActiveBanks, authority, isSync) {
66160
- const remainingAccounts = computeHealthAccountMetas(projectedActiveBanks);
66147
+ const remainingAccounts = computeHealthAccountMetas({ banksToInclude: projectedActiveBanks });
66161
66148
  const ix = isSync && authority ? sync_instructions_default.makeEndFlashLoanIx(
66162
66149
  program.programId,
66163
66150
  {
@@ -66194,11 +66181,11 @@ async function makeFlashLoanTx({
66194
66181
  isSync
66195
66182
  }) {
66196
66183
  const endIndex = ixs.length + 1;
66197
- const projectedActiveBanksKeys = computeProjectedActiveBanksNoCpi(
66198
- marginfiAccount.balances,
66199
- ixs,
66184
+ const projectedActiveBanksKeys = computeProjectedActiveBanksNoCpi({
66185
+ account: marginfiAccount,
66186
+ instructions: ixs,
66200
66187
  program
66201
- );
66188
+ });
66202
66189
  const projectedActiveBanks = projectedActiveBanksKeys.map((account) => {
66203
66190
  const b = bankMap.get(account.toBase58());
66204
66191
  if (!b) throw Error(`Bank ${account.toBase58()} not found, in makeFlashLoanTx function`);
@@ -66327,23 +66314,12 @@ async function makeRepayWithCollatTx(params) {
66327
66314
  }
66328
66315
  ]
66329
66316
  });
66330
- const updateJuplendMarketIxs = makeUpdateJupLendRateIxs(
66317
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
66331
66318
  marginfiAccount,
66332
66319
  bankMap,
66333
66320
  [withdrawOpts.withdrawBank.address],
66334
- bankMetadataMap
66335
- );
66336
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
66337
- marginfiAccount,
66338
- bankMap,
66339
- [withdrawOpts.withdrawBank.address],
66340
- bankMetadataMap
66341
- );
66342
- const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
66343
- marginfiAccount,
66344
- bankMap,
66345
- [withdrawOpts.withdrawBank.address, repayOpts.repayBank.address],
66346
- bankMetadataMap
66321
+ bankMetadataMap,
66322
+ [withdrawOpts.withdrawBank.address, repayOpts.repayBank.address]
66347
66323
  );
66348
66324
  const { flashloanTx, setupInstructions, swapQuote, amountToRepay, withdrawIxs, repayIxs } = await buildRepayWithCollatFlashloanTx({
66349
66325
  ...params,
@@ -66373,13 +66349,8 @@ async function makeRepayWithCollatTx(params) {
66373
66349
  crossbarUrl
66374
66350
  });
66375
66351
  let additionalTxs = [];
66376
- if (setupIxs.length > 0 || kaminoRefreshIxs.instructions.length > 0 || updateDriftMarketIxs.instructions.length > 0 || updateJuplendMarketIxs.instructions.length > 0) {
66377
- const ixs = [
66378
- ...setupIxs,
66379
- ...kaminoRefreshIxs.instructions,
66380
- ...updateDriftMarketIxs.instructions,
66381
- ...updateJuplendMarketIxs.instructions
66382
- ];
66352
+ if (setupIxs.length > 0 || refreshIntegrationIxs.instructions.length > 0) {
66353
+ const ixs = [...setupIxs, ...refreshIntegrationIxs.instructions];
66383
66354
  const txs = splitInstructionsToFitTransactions([], ixs, {
66384
66355
  blockhash,
66385
66356
  payerKey: marginfiAccount.authority,
@@ -66817,11 +66788,11 @@ function computeFlashLoanNonSwapBudget({
66817
66788
  bankMap,
66818
66789
  addressLookupTableAccounts
66819
66790
  }) {
66820
- const projectedActiveBanksKeys = computeProjectedActiveBanksNoCpi(
66821
- marginfiAccount.balances,
66822
- ixs,
66791
+ const projectedActiveBanksKeys = computeProjectedActiveBanksNoCpi({
66792
+ account: marginfiAccount,
66793
+ instructions: ixs,
66823
66794
  program
66824
- );
66795
+ });
66825
66796
  const projectedActiveBanks = projectedActiveBanksKeys.map((key) => {
66826
66797
  const b = bankMap.get(key.toBase58());
66827
66798
  if (!b) throw new Error(`Bank ${key.toBase58()} not found in computeFlashLoanNonSwapBudget`);
@@ -66833,7 +66804,9 @@ function computeFlashLoanNonSwapBudget({
66833
66804
  { marginfiAccount: marginfiAccount.address, authority: marginfiAccount.authority },
66834
66805
  { endIndex: new BN9__default.default(endIndex) }
66835
66806
  );
66836
- const endFlRemainingAccounts = computeHealthAccountMetas(projectedActiveBanks);
66807
+ const endFlRemainingAccounts = computeHealthAccountMetas({
66808
+ banksToInclude: projectedActiveBanks
66809
+ });
66837
66810
  const endFlIx = sync_instructions_default.makeEndFlashLoanIx(
66838
66811
  program.programId,
66839
66812
  { marginfiAccount: marginfiAccount.address, authority: marginfiAccount.authority },
@@ -67294,23 +67267,12 @@ async function makeLoopTx(params) {
67294
67267
  }
67295
67268
  ]
67296
67269
  });
67297
- const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
67270
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
67298
67271
  params.marginfiAccount,
67299
67272
  params.bankMap,
67300
67273
  [depositOpts.depositBank.address],
67301
- params.bankMetadataMap
67302
- );
67303
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
67304
- params.marginfiAccount,
67305
- params.bankMap,
67306
- [depositOpts.depositBank.address],
67307
- params.bankMetadataMap
67308
- );
67309
- const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
67310
- marginfiAccount,
67311
- bankMap,
67312
- [borrowOpts.borrowBank.address, depositOpts.depositBank.address],
67313
- bankMetadataMap
67274
+ params.bankMetadataMap,
67275
+ [borrowOpts.borrowBank.address, depositOpts.depositBank.address]
67314
67276
  );
67315
67277
  const { flashloanTx, setupInstructions, swapQuote, depositIxs, borrowIxs } = await buildLoopFlashloanTx({
67316
67278
  ...params,
@@ -67345,14 +67307,8 @@ async function makeLoopTx(params) {
67345
67307
  ...makeWrapSolIxs(marginfiAccount.authority, new BigNumber3.BigNumber(depositOpts.inputDepositAmount))
67346
67308
  );
67347
67309
  }
67348
- if (setupIxs.length > 0 || additionalIxs.length > 0 || kaminoRefreshIxs.instructions.length > 0 || updateDriftMarketIxs.instructions.length > 0 || updateJupLendRateIxs.instructions.length > 0) {
67349
- const ixs = [
67350
- ...additionalIxs,
67351
- ...setupIxs,
67352
- ...kaminoRefreshIxs.instructions,
67353
- ...updateDriftMarketIxs.instructions,
67354
- ...updateJupLendRateIxs.instructions
67355
- ];
67310
+ if (setupIxs.length > 0 || additionalIxs.length > 0 || refreshIntegrationIxs.instructions.length > 0) {
67311
+ const ixs = [...additionalIxs, ...setupIxs, ...refreshIntegrationIxs.instructions];
67356
67312
  const txs = splitInstructionsToFitTransactions([], ixs, {
67357
67313
  blockhash,
67358
67314
  payerKey: marginfiAccount.authority,
@@ -67504,7 +67460,9 @@ async function buildLoopNonSwapIxs(params) {
67504
67460
  const innerIxs = [...innerIxsBeforeSwap, ...depositIxs.instructions];
67505
67461
  const depositIxIndex = innerIxs.findIndex(isDepositIx);
67506
67462
  if (depositIxIndex < 0) {
67507
- throw new Error("buildLoopNonSwapIxs: could not locate deposit instruction for amount patching");
67463
+ throw new Error(
67464
+ "buildLoopNonSwapIxs: could not locate deposit instruction for amount patching"
67465
+ );
67508
67466
  }
67509
67467
  const descriptor = {
67510
67468
  innerIxs,
@@ -67715,19 +67673,7 @@ async function makeSwapCollateralTx(params) {
67715
67673
  { mint: depositOpts.depositBank.mint, tokenProgram: depositOpts.tokenProgram }
67716
67674
  ]
67717
67675
  });
67718
- const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
67719
- params.marginfiAccount,
67720
- params.bankMap,
67721
- [depositOpts.depositBank.address],
67722
- params.bankMetadataMap
67723
- );
67724
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
67725
- marginfiAccount,
67726
- bankMap,
67727
- [withdrawOpts.withdrawBank.address],
67728
- bankMetadataMap
67729
- );
67730
- const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
67676
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
67731
67677
  marginfiAccount,
67732
67678
  bankMap,
67733
67679
  [withdrawOpts.withdrawBank.address, depositOpts.depositBank.address],
@@ -67761,13 +67707,8 @@ async function makeSwapCollateralTx(params) {
67761
67707
  crossbarUrl
67762
67708
  });
67763
67709
  let additionalTxs = [];
67764
- if (setupIxs.length > 0 || kaminoRefreshIxs.instructions.length > 0 || updateDriftMarketIxs.instructions.length > 0 || updateJupLendRateIxs.instructions.length > 0) {
67765
- const ixs = [
67766
- ...setupIxs,
67767
- ...kaminoRefreshIxs.instructions,
67768
- ...updateDriftMarketIxs.instructions,
67769
- ...updateJupLendRateIxs.instructions
67770
- ];
67710
+ if (setupIxs.length > 0 || refreshIntegrationIxs.instructions.length > 0) {
67711
+ const ixs = [...setupIxs, ...refreshIntegrationIxs.instructions];
67771
67712
  const txs = splitInstructionsToFitTransactions([], ixs, {
67772
67713
  blockhash,
67773
67714
  payerKey: marginfiAccount.authority,
@@ -68156,23 +68097,12 @@ async function makeSwapDebtTx(params) {
68156
68097
  { mint: borrowOpts.borrowBank.mint, tokenProgram: borrowOpts.tokenProgram }
68157
68098
  ]
68158
68099
  });
68159
- const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
68160
- params.marginfiAccount,
68161
- params.bankMap,
68162
- [],
68163
- params.bankMetadataMap
68164
- );
68165
- const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
68100
+ const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
68166
68101
  marginfiAccount,
68167
68102
  bankMap,
68168
68103
  [],
68169
- bankMetadataMap
68170
- );
68171
- const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
68172
- marginfiAccount,
68173
- bankMap,
68174
- [repayOpts.repayBank.address, borrowOpts.borrowBank.address],
68175
- bankMetadataMap
68104
+ bankMetadataMap,
68105
+ [repayOpts.repayBank.address, borrowOpts.borrowBank.address]
68176
68106
  );
68177
68107
  const { flashloanTx, setupInstructions, swapQuote, borrowIxs, repayIxs } = await buildSwapDebtFlashloanTx({
68178
68108
  ...params,
@@ -68202,14 +68132,8 @@ async function makeSwapDebtTx(params) {
68202
68132
  crossbarUrl
68203
68133
  });
68204
68134
  let additionalTxs = [];
68205
- if (setupIxs.length > 0 || kaminoRefreshIxs.instructions.length > 0 || updateDriftMarketIxs.instructions.length > 0 || updateJupLendRateIxs.instructions.length > 0) {
68206
- const ixs = [
68207
- ...additionalIxs,
68208
- ...setupIxs,
68209
- ...kaminoRefreshIxs.instructions,
68210
- ...updateDriftMarketIxs.instructions,
68211
- ...updateJupLendRateIxs.instructions
68212
- ];
68135
+ if (setupIxs.length > 0 || refreshIntegrationIxs.instructions.length > 0) {
68136
+ const ixs = [...additionalIxs, ...setupIxs, ...refreshIntegrationIxs.instructions];
68213
68137
  const txs = splitInstructionsToFitTransactions([], ixs, {
68214
68138
  blockhash,
68215
68139
  payerKey: marginfiAccount.authority,
@@ -69160,7 +69084,12 @@ var MarginfiAccount = class _MarginfiAccount {
69160
69084
  * @returns Array of banks needed for health checks
69161
69085
  */
69162
69086
  getHealthCheckAccounts(banks, mandatoryBanks = [], excludedBanks = []) {
69163
- return computeHealthCheckAccounts(this.balances, banks, mandatoryBanks, excludedBanks);
69087
+ return computeHealthCheckAccounts({
69088
+ account: this,
69089
+ banksMap: banks,
69090
+ mandatoryBanks,
69091
+ excludedBanks
69092
+ });
69164
69093
  }
69165
69094
  /**
69166
69095
  * Determines which E-mode pairs are currently active for this account.
@@ -69360,14 +69289,7 @@ var MarginfiAccount = class _MarginfiAccount {
69360
69289
  * @see {@link makePulseHealthIx} for implementation
69361
69290
  */
69362
69291
  async makePulseHealthIx(program, banks, mandatoryBanks, excludedBanks) {
69363
- return makePulseHealthIx2(
69364
- program,
69365
- this.address,
69366
- banks,
69367
- this.balances,
69368
- mandatoryBanks,
69369
- excludedBanks
69370
- );
69292
+ return makePulseHealthIx2(program, this, banks, mandatoryBanks, excludedBanks);
69371
69293
  }
69372
69294
  /**
69373
69295
  * Computes which banks will be active after executing the given instructions.
@@ -69383,7 +69305,7 @@ var MarginfiAccount = class _MarginfiAccount {
69383
69305
  * @see {@link computeProjectedActiveBanksNoCpi} for implementation
69384
69306
  */
69385
69307
  computeProjectedActiveBanksNoCpi(program, instructions2) {
69386
- return computeProjectedActiveBanksNoCpi(this.balances, instructions2, program);
69308
+ return computeProjectedActiveBanksNoCpi({ account: this, instructions: instructions2, program });
69387
69309
  }
69388
69310
  /**
69389
69311
  * Computes projected active balances after executing the given instructions.
@@ -69400,13 +69322,13 @@ var MarginfiAccount = class _MarginfiAccount {
69400
69322
  * @see {@link computeProjectedActiveBalancesNoCpi} for implementation
69401
69323
  */
69402
69324
  computeProjectedActiveBalancesNoCpi(program, instructions2, banksMap, assetShareValueMultiplierByBank) {
69403
- const { projectedBalances, ...rest } = computeProjectedActiveBalancesNoCpi(
69404
- this.balances,
69405
- instructions2,
69325
+ const { projectedBalances, ...rest } = computeProjectedActiveBalancesNoCpi({
69326
+ account: this,
69327
+ instructions: instructions2,
69406
69328
  program,
69407
69329
  banksMap,
69408
69330
  assetShareValueMultiplierByBank
69409
- );
69331
+ });
69410
69332
  return {
69411
69333
  projectedBalances: projectedBalances.map(Balance.fromBalanceType),
69412
69334
  ...rest
@@ -69837,13 +69759,13 @@ function projectAccountAfterFirstLeg(account, firstLegFlashloanTxs, program, ban
69837
69759
  const luts = tx.addressLookupTables ?? [];
69838
69760
  ixs.push(...decompileV0Transaction(tx, luts).instructions);
69839
69761
  }
69840
- const { projectedBalances } = computeProjectedActiveBalancesNoCpi(
69841
- account.balances,
69842
- ixs,
69762
+ const { projectedBalances } = computeProjectedActiveBalancesNoCpi({
69763
+ account,
69764
+ instructions: ixs,
69843
69765
  program,
69844
69766
  banksMap,
69845
- multipliers
69846
- );
69767
+ assetShareValueMultiplierByBank: multipliers
69768
+ });
69847
69769
  return new MarginfiAccount(
69848
69770
  account.address,
69849
69771
  account.group,
@@ -69954,26 +69876,9 @@ var CU_IXS = () => [
69954
69876
  web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 }),
69955
69877
  web3_js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1 })
69956
69878
  ];
69957
- function requireBank(bankMap, address) {
69958
- const bank = bankMap.get(address.toBase58());
69959
- if (!bank) {
69960
- throw TransactionBuildingError.transferPositionsInvalidSelection(
69961
- `bank ${address.toBase58()} not found`,
69962
- [address.toBase58()]
69963
- );
69964
- }
69965
- return bank;
69966
- }
69967
- function requireTokenProgram(tokenProgramsByBank, address) {
69968
- const tp = tokenProgramsByBank.get(address.toBase58());
69969
- if (!tp) {
69970
- throw TransactionBuildingError.transferPositionsInvalidSelection(
69971
- `token program for bank ${address.toBase58()} not provided`,
69972
- [address.toBase58()]
69973
- );
69974
- }
69975
- return tp;
69976
- }
69879
+ var invalidSelection = (address) => (message) => TransactionBuildingError.transferPositionsInvalidSelection(message, [
69880
+ address.toBase58()
69881
+ ]);
69977
69882
  function classifyAndValidate(params) {
69978
69883
  const {
69979
69884
  marginfiAccount: accountA,
@@ -69996,8 +69901,8 @@ function classifyAndValidate(params) {
69996
69901
  const activeBalancesA = accountA.balances.filter((b) => b.active);
69997
69902
  const positions = [];
69998
69903
  for (const bankAddress of bankAddresses) {
69999
- const bank = requireBank(bankMap, bankAddress);
70000
- const tokenProgram = requireTokenProgram(tokenProgramsByBank, bankAddress);
69904
+ const bank = requireBank(bankMap, bankAddress, invalidSelection(bankAddress));
69905
+ const tokenProgram = requireTokenProgram(tokenProgramsByBank, bankAddress, invalidSelection(bankAddress));
70001
69906
  const balance = activeBalancesA.find((b) => b.bankPk.equals(bankAddress));
70002
69907
  if (!balance) {
70003
69908
  throw TransactionBuildingError.transferPositionsInvalidSelection(
@@ -70220,7 +70125,7 @@ async function buildInnerIxs(ctx, positions, isSync) {
70220
70125
  const borrowIxs = [];
70221
70126
  const repayIxs = [];
70222
70127
  for (const position of collateral) {
70223
- const observationBanksOverride = ctx.groupRateLimiterEnabled ? computeHealthAccountMetas([], true, [position.bank]) : [];
70128
+ const observationBanksOverride = ctx.groupRateLimiterEnabled ? computeHealthAccountMetas({ banksToInclude: [], trailingBanks: [position.bank] }) : [];
70224
70129
  const legs = await buildCollateralLegIxs(ctx, position, isSync, observationBanksOverride);
70225
70130
  withdrawIxs.push(...legs.withdrawIxs);
70226
70131
  depositIxs.push(...legs.depositIxs);
@@ -70241,7 +70146,7 @@ async function buildInnerIxs(ctx, positions, isSync) {
70241
70146
  ...collateralBanks,
70242
70147
  ...borrowedSoFar
70243
70148
  ]);
70244
- const observationBanksOverride = computeHealthAccountMetas(activeBanks);
70149
+ const observationBanksOverride = computeHealthAccountMetas({ banksToInclude: activeBanks });
70245
70150
  const borrowUi = position.uiAmount.times(1 + ctx.borrowPaddingBps / 1e4);
70246
70151
  const borrow = await makeBorrowIx3({
70247
70152
  program: ctx.program,
@@ -70362,7 +70267,7 @@ async function makeTransferPositionsTx(params) {
70362
70267
  const innerIxs = await buildInnerIxs(ctx, positions, false);
70363
70268
  const transferred = new Set(positions.map((p) => p.bankAddress.toBase58()));
70364
70269
  const projectedActiveBanksA = dedupeBanks(
70365
- accountA.balances.filter((b) => b.active && !transferred.has(b.bankPk.toBase58())).map((b) => requireBank(bankMap, b.bankPk))
70270
+ accountA.balances.filter((b) => b.active && !transferred.has(b.bankPk.toBase58())).map((b) => requireBank(bankMap, b.bankPk, invalidSelection(b.bankPk)))
70366
70271
  );
70367
70272
  const blockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
70368
70273
  const preIxs = createIx ? [createIx] : [];
@@ -70410,15 +70315,8 @@ async function makeTransferPositionsTx(params) {
70410
70315
  )
70411
70316
  );
70412
70317
  }
70413
- const destinationOnlyBalances = accountB.balances.filter(
70414
- (b) => b.active && !accountA.balances.some((a) => a.active && a.bankPk.equals(b.bankPk))
70415
- );
70416
- const crankBalanceView = {
70417
- ...accountA,
70418
- balances: [...accountA.balances, ...destinationOnlyBalances]
70419
- };
70420
- const { instructions: updateFeedIxs, luts: feedLuts } = await makeSmartCrankSwbFeedIx({
70421
- marginfiAccount: crankBalanceView,
70318
+ const { instructions: updateFeedIxs, luts: feedLuts } = await makeSmartCrankSwbFeedIxForAccounts({
70319
+ marginfiAccounts: [accountA, accountB],
70422
70320
  bankMap,
70423
70321
  oraclePrices,
70424
70322
  assetShareValueMultiplierByBank,
@@ -70447,6 +70345,262 @@ async function makeTransferPositionsTx(params) {
70447
70345
  destinationAccount: accountB
70448
70346
  };
70449
70347
  }
70348
+ var BULK_TX_SIZE_MARGIN = 128;
70349
+ async function makeBulkWithdrawTx(params) {
70350
+ const {
70351
+ program,
70352
+ connection,
70353
+ marginfiAccount,
70354
+ bankAddresses,
70355
+ bankMap,
70356
+ bankMetadataMap,
70357
+ oraclePrices,
70358
+ assetShareValueMultiplierByBank,
70359
+ tokenProgramsByBank,
70360
+ overrideInferAccounts,
70361
+ luts
70362
+ } = params;
70363
+ const authority = marginfiAccount.authority;
70364
+ if (bankAddresses.length === 0) throw new Error("no banks to withdraw");
70365
+ const activeBalances = marginfiAccount.balances.filter((b) => b.active);
70366
+ const involvedBanks = [
70367
+ ...bankAddresses.map((pk2) => requireBank(bankMap, pk2)),
70368
+ ...activeBalances.flatMap((b) => bankMap.get(b.bankPk.toBase58()) ?? [])
70369
+ ];
70370
+ const selectedLuts = selectLutsForBanks(luts, involvedBanks);
70371
+ const withdrawIxs = [];
70372
+ const setupTokens = [];
70373
+ const withdrawnSoFar = [];
70374
+ for (const bankAddress of bankAddresses) {
70375
+ const bank = requireBank(bankMap, bankAddress);
70376
+ const tokenProgram = requireTokenProgram(tokenProgramsByBank, bankAddress);
70377
+ const balance = activeBalances.find((b) => b.bankPk.equals(bankAddress));
70378
+ if (!balance || !balance.assetShares.gt(0)) {
70379
+ throw new Error(`no active deposit for bank ${bankAddress.toBase58()}`);
70380
+ }
70381
+ const packBanks = computeHealthCheckAccounts({
70382
+ account: marginfiAccount,
70383
+ banksMap: bankMap,
70384
+ excludedBanks: [...withdrawnSoFar, bankAddress]
70385
+ });
70386
+ const observationBanksOverride = computeHealthAccountMetas({
70387
+ banksToInclude: packBanks,
70388
+ trailingBanks: [bank]
70389
+ });
70390
+ const shared = {
70391
+ program,
70392
+ bank,
70393
+ bankMap,
70394
+ tokenProgram,
70395
+ marginfiAccount,
70396
+ authority,
70397
+ bankMetadataMap,
70398
+ // every venue's withdraw ix ignores the amount when the withdraw-all flag is
70399
+ // set and derives the full position on-chain, so all legs pass amount 0
70400
+ withdrawAll: true,
70401
+ opts: {
70402
+ createAtas: false,
70403
+ // ATAs are created in the prelude txs
70404
+ wrapAndUnwrapSol: false,
70405
+ // one unwrap ix is appended after the last withdraw
70406
+ overrideInferAccounts,
70407
+ observationBanksOverride
70408
+ }
70409
+ };
70410
+ let instructions2;
70411
+ switch (bank.config.assetTag) {
70412
+ case 3 /* KAMINO */: {
70413
+ const reserve = bankMetadataMap[bankAddress.toBase58()]?.kaminoStates?.reserveState;
70414
+ if (!reserve) {
70415
+ throw new Error(`kamino reserve state missing for bank ${bankAddress.toBase58()}`);
70416
+ }
70417
+ const withdraw = await makeKaminoWithdrawIx3({
70418
+ ...shared,
70419
+ cTokenAmount: 0,
70420
+ reserve
70421
+ });
70422
+ instructions2 = withdraw.instructions;
70423
+ break;
70424
+ }
70425
+ case 6 /* JUPLEND */: {
70426
+ const jupLendingState = bankMetadataMap[bankAddress.toBase58()]?.jupLendStates?.jupLendingState;
70427
+ if (!jupLendingState) {
70428
+ throw new Error(`juplend lending state missing for bank ${bankAddress.toBase58()}`);
70429
+ }
70430
+ const withdraw = await makeJuplendWithdrawIx2({
70431
+ ...shared,
70432
+ amount: 0,
70433
+ jupLendingState
70434
+ });
70435
+ instructions2 = withdraw.instructions;
70436
+ break;
70437
+ }
70438
+ case 4 /* DRIFT */: {
70439
+ const driftState = bankMetadataMap[bankAddress.toBase58()]?.driftStates;
70440
+ if (!driftState) {
70441
+ throw new Error(`drift state missing for bank ${bankAddress.toBase58()}`);
70442
+ }
70443
+ const withdraw = await makeDriftWithdrawIx3({
70444
+ ...shared,
70445
+ amount: 0,
70446
+ driftSpotMarket: driftState.spotMarketState,
70447
+ userRewards: driftState.userRewards
70448
+ });
70449
+ instructions2 = withdraw.instructions;
70450
+ break;
70451
+ }
70452
+ default: {
70453
+ const withdraw = await makeWithdrawIx3({
70454
+ ...shared,
70455
+ amount: 0
70456
+ });
70457
+ instructions2 = withdraw.instructions;
70458
+ break;
70459
+ }
70460
+ }
70461
+ withdrawIxs.push(...instructions2);
70462
+ setupTokens.push({ mint: bank.mint, tokenProgram });
70463
+ withdrawnSoFar.push(bankAddress);
70464
+ }
70465
+ if (setupTokens.some((t) => t.mint.equals(NATIVE_MINT))) {
70466
+ withdrawIxs.push(makeUnwrapSolIx(authority));
70467
+ }
70468
+ const { blockhash } = await connection.getLatestBlockhash("confirmed");
70469
+ const withdrawTxs = splitInstructionsToFitTransactions([], withdrawIxs, {
70470
+ blockhash,
70471
+ payerKey: authority,
70472
+ luts: selectedLuts,
70473
+ sizeMargin: BULK_TX_SIZE_MARGIN,
70474
+ maxAccountLocks: MAX_ACCOUNT_LOCKS
70475
+ }).map(
70476
+ (tx) => addTransactionMetadata(tx, {
70477
+ addressLookupTables: selectedLuts,
70478
+ type: "WITHDRAW" /* WITHDRAW */
70479
+ })
70480
+ );
70481
+ const additionalTxs = [];
70482
+ const setupIxs = await makeSetupIx({
70483
+ connection,
70484
+ authority,
70485
+ tokens: setupTokens
70486
+ });
70487
+ if (setupIxs.length > 0) {
70488
+ const setupTxs = splitInstructionsToFitTransactions([], setupIxs, {
70489
+ blockhash,
70490
+ payerKey: authority,
70491
+ luts: selectedLuts
70492
+ });
70493
+ additionalTxs.push(
70494
+ ...setupTxs.map(
70495
+ (tx) => addTransactionMetadata(tx, {
70496
+ type: "CREATE_ATA" /* CREATE_ATA */,
70497
+ addressLookupTables: selectedLuts
70498
+ })
70499
+ )
70500
+ );
70501
+ }
70502
+ const { instructions: crankIxs, luts: feedLuts } = await makeSmartCrankSwbFeedIx({
70503
+ marginfiAccount,
70504
+ bankMap,
70505
+ oraclePrices,
70506
+ assetShareValueMultiplierByBank,
70507
+ instructions: withdrawIxs,
70508
+ program,
70509
+ connection,
70510
+ crossbarUrl: params.crossbarUrl
70511
+ });
70512
+ if (crankIxs.length > 0) {
70513
+ const message = new web3_js.TransactionMessage({
70514
+ payerKey: authority,
70515
+ recentBlockhash: blockhash,
70516
+ instructions: crankIxs
70517
+ }).compileToV0Message(feedLuts);
70518
+ additionalTxs.push(
70519
+ addTransactionMetadata(new web3_js.VersionedTransaction(message), {
70520
+ addressLookupTables: feedLuts,
70521
+ type: "CRANK" /* CRANK */
70522
+ })
70523
+ );
70524
+ }
70525
+ const refreshIxs = makeRefreshIntegrationBanksIxs(
70526
+ marginfiAccount,
70527
+ bankMap,
70528
+ bankAddresses,
70529
+ bankMetadataMap
70530
+ ).instructions;
70531
+ if (refreshIxs.length > 0) {
70532
+ const refreshTxs = splitInstructionsToFitTransactions([], refreshIxs, {
70533
+ blockhash,
70534
+ payerKey: authority,
70535
+ luts: selectedLuts
70536
+ });
70537
+ additionalTxs.push(
70538
+ ...refreshTxs.map(
70539
+ (tx) => addTransactionMetadata(tx, {
70540
+ type: "CRANK" /* CRANK */,
70541
+ addressLookupTables: selectedLuts
70542
+ })
70543
+ )
70544
+ );
70545
+ }
70546
+ return {
70547
+ transactions: [...additionalTxs, ...withdrawTxs],
70548
+ actionTxIndex: additionalTxs.length
70549
+ };
70550
+ }
70551
+ async function makeBulkRepayTx(params) {
70552
+ const {
70553
+ program,
70554
+ connection,
70555
+ marginfiAccount,
70556
+ bankAddresses,
70557
+ bankMap,
70558
+ tokenProgramsByBank,
70559
+ overrideInferAccounts
70560
+ } = params;
70561
+ const luts = params.addressLookupTableAccounts ?? [];
70562
+ const authority = marginfiAccount.authority;
70563
+ if (bankAddresses.length === 0) throw new Error("no banks to repay");
70564
+ const activeBalances = marginfiAccount.balances.filter((b) => b.active);
70565
+ const repayIxs = [];
70566
+ for (const bankAddress of bankAddresses) {
70567
+ const bank = requireBank(bankMap, bankAddress);
70568
+ const tokenProgram = requireTokenProgram(tokenProgramsByBank, bankAddress);
70569
+ const balance = activeBalances.find((b) => b.bankPk.equals(bankAddress));
70570
+ if (!balance || !balance.liabilityShares.gt(0)) {
70571
+ throw new Error(`no active debt for bank ${bankAddress.toBase58()}`);
70572
+ }
70573
+ const uiAmount = computeQuantityUi(balance, bank).liabilities;
70574
+ const repay = await makeRepayIx3({
70575
+ program,
70576
+ bank,
70577
+ tokenProgram,
70578
+ amount: uiAmount,
70579
+ accountAddress: marginfiAccount.address,
70580
+ authority,
70581
+ repayAll: true,
70582
+ opts: {
70583
+ wrapAndUnwrapSol: true,
70584
+ overrideInferAccounts
70585
+ }
70586
+ });
70587
+ repayIxs.push(...repay.instructions);
70588
+ }
70589
+ const { blockhash } = await connection.getLatestBlockhash("confirmed");
70590
+ const transactions = splitInstructionsToFitTransactions([], repayIxs, {
70591
+ blockhash,
70592
+ payerKey: authority,
70593
+ luts,
70594
+ sizeMargin: BULK_TX_SIZE_MARGIN,
70595
+ maxAccountLocks: MAX_ACCOUNT_LOCKS
70596
+ }).map(
70597
+ (tx) => addTransactionMetadata(tx, {
70598
+ addressLookupTables: luts,
70599
+ type: "REPAY" /* REPAY */
70600
+ })
70601
+ );
70602
+ return { transactions, actionTxIndex: 0 };
70603
+ }
70450
70604
 
70451
70605
  // src/services/account/services/account-simulation.service.ts
70452
70606
  async function simulateAccountHealthCacheWithFallback(params) {
@@ -70583,9 +70737,8 @@ async function simulateAccountHealthCache(params) {
70583
70737
  );
70584
70738
  const healthPulseIxs = await makePulseHealthIx2(
70585
70739
  program,
70586
- marginfiAccount.address,
70740
+ marginfiAccount,
70587
70741
  banksMap,
70588
- marginfiAccount.balances,
70589
70742
  activeBalances.map((b) => b.bankPk),
70590
70743
  []
70591
70744
  );
@@ -70773,9 +70926,8 @@ async function getHealthSimulationTransactions({
70773
70926
  );
70774
70927
  const healthPulseIx = await makePulseHealthIx2(
70775
70928
  program,
70776
- marginfiAccount.address,
70929
+ marginfiAccount,
70777
70930
  bankMap,
70778
- marginfiAccount.balances,
70779
70931
  mandatoryBanks,
70780
70932
  excludedBanks
70781
70933
  );
@@ -71236,13 +71388,13 @@ async function computeSmartCrank({
71236
71388
  assetShareValueMultiplierByBank,
71237
71389
  groupRateLimiterEnabled = false
71238
71390
  }) {
71239
- const { projectedBalances, withdrawnBanks } = computeProjectedActiveBalancesNoCpi(
71240
- marginfiAccount.balances,
71241
- instructions2,
71391
+ const { projectedBalances, withdrawnBanks } = computeProjectedActiveBalancesNoCpi({
71392
+ account: marginfiAccount,
71393
+ instructions: instructions2,
71242
71394
  program,
71243
- bankMap,
71395
+ banksMap: bankMap,
71244
71396
  assetShareValueMultiplierByBank
71245
- );
71397
+ });
71246
71398
  const isSwitchboard = (bank) => getOracleSourceFromBank(bank).key === "switchboard";
71247
71399
  const rateLimitBanks = groupRateLimiterEnabled ? withdrawnBanks.map((pk2) => bankMap.get(pk2)).filter((bank) => bank !== void 0).filter(isSwitchboard) : [];
71248
71400
  let rateLimitOracles = [];
@@ -71550,6 +71702,55 @@ async function makeSmartCrankSwbFeedIx(params) {
71550
71702
  });
71551
71703
  return { instructions: instructions2, luts };
71552
71704
  }
71705
+ async function makeSmartCrankSwbFeedIxForAccounts(params) {
71706
+ const crankResults = await Promise.all(
71707
+ params.marginfiAccounts.map(
71708
+ (marginfiAccount) => computeSmartCrank({ ...params, marginfiAccount })
71709
+ )
71710
+ );
71711
+ const uncrankableLiabilities = crankResults.flatMap((r) => r.uncrankableLiabilities);
71712
+ const uncrankableAssets = crankResults.flatMap((r) => r.uncrankableAssets);
71713
+ if (uncrankableLiabilities.length > 0) {
71714
+ console.log(
71715
+ "Uncrankable liability details:",
71716
+ uncrankableLiabilities.map((l) => ({
71717
+ symbol: l.bank.tokenSymbol,
71718
+ reason: l.reason
71719
+ }))
71720
+ );
71721
+ }
71722
+ if (uncrankableAssets.length > 0) {
71723
+ console.log(
71724
+ "Uncrankable asset details:",
71725
+ uncrankableAssets.map((a) => ({
71726
+ symbol: a.bank.tokenSymbol,
71727
+ reason: a.reason
71728
+ }))
71729
+ );
71730
+ }
71731
+ if (crankResults.some((r) => !r.isCrankable)) {
71732
+ throw TransactionBuildingError.oracleCrankFailed(
71733
+ uncrankableLiabilities.map((liability) => ({
71734
+ bankAddress: liability.bank.address.toBase58(),
71735
+ mint: liability.bank.mint.toBase58(),
71736
+ symbol: liability.bank.tokenSymbol,
71737
+ reason: liability.reason
71738
+ })),
71739
+ uncrankableAssets.map((asset) => ({
71740
+ bankAddress: asset.bank.address.toBase58(),
71741
+ mint: asset.bank.mint.toBase58(),
71742
+ symbol: asset.bank.tokenSymbol,
71743
+ reason: asset.reason
71744
+ }))
71745
+ );
71746
+ }
71747
+ return makeUpdateSwbFeedIx({
71748
+ swbPullOracles: crankResults.flatMap((r) => r.requiredOracles),
71749
+ feePayer: params.marginfiAccounts[0].authority,
71750
+ connection: params.connection,
71751
+ crossbarUrl: params.crossbarUrl
71752
+ });
71753
+ }
71553
71754
  var DEFAULT_CROSSBAR_URL = "https://crossbar.0.xyz";
71554
71755
  var DEFAULT_FALLBACK_CROSSBAR_URL = "https://crossbar.switchboard.xyz";
71555
71756
  async function makeCrankSwbFeedIx(marginfiAccount, bankMap, newBanksPk, provider, crossbarUrl) {
@@ -71720,6 +71921,36 @@ function makeUpdateJupLendRateIxs(marginfiAccount, bankMap, banksToExclude, bank
71720
71921
  keys: []
71721
71922
  };
71722
71923
  }
71924
+
71925
+ // src/services/price/actions/refresh-integration-banks.ts
71926
+ function makeRefreshIntegrationBanksIxs(marginfiAccount, bankMap, banksToExclude, bankMetadataMap, kaminoNewBanksPk = banksToExclude) {
71927
+ const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
71928
+ marginfiAccount,
71929
+ bankMap,
71930
+ kaminoNewBanksPk,
71931
+ bankMetadataMap
71932
+ );
71933
+ const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
71934
+ marginfiAccount,
71935
+ bankMap,
71936
+ banksToExclude,
71937
+ bankMetadataMap
71938
+ );
71939
+ const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
71940
+ marginfiAccount,
71941
+ bankMap,
71942
+ banksToExclude,
71943
+ bankMetadataMap
71944
+ );
71945
+ return {
71946
+ instructions: [
71947
+ ...kaminoRefreshIxs.instructions,
71948
+ ...updateDriftMarketIxs.instructions,
71949
+ ...updateJupLendRateIxs.instructions
71950
+ ],
71951
+ keys: [...kaminoRefreshIxs.keys, ...updateDriftMarketIxs.keys, ...updateJupLendRateIxs.keys]
71952
+ };
71953
+ }
71723
71954
  function bankMetadataMapToDto(bankMetadataMap) {
71724
71955
  return Object.fromEntries(
71725
71956
  Object.entries(bankMetadataMap).map(([bankPk, bankMetadata]) => [
@@ -72859,6 +73090,22 @@ function computeBankMetrics(params) {
72859
73090
  };
72860
73091
  }
72861
73092
 
73093
+ // src/services/bank/utils/lookup.utils.ts
73094
+ function requireBank(bankMap, address, makeError = (message) => new Error(message)) {
73095
+ const bank = bankMap.get(address.toBase58());
73096
+ if (!bank) {
73097
+ throw makeError(`bank ${address.toBase58()} not found`);
73098
+ }
73099
+ return bank;
73100
+ }
73101
+ function requireTokenProgram(tokenProgramsByBank, address, makeError = (message) => new Error(message)) {
73102
+ const tokenProgram = tokenProgramsByBank.get(address.toBase58());
73103
+ if (!tokenProgram) {
73104
+ throw makeError(`token program for bank ${address.toBase58()} not provided`);
73105
+ }
73106
+ return tokenProgram;
73107
+ }
73108
+
72862
73109
  // src/services/bank/bank.service.ts
72863
73110
  async function freezeBankConfigIx(program, bankAddress, bankConfigOpt) {
72864
73111
  let bankConfigRaw;
@@ -76072,6 +76319,8 @@ exports.makeAddPermissionlessStakedBankIx = makeAddPermissionlessStakedBankIx;
76072
76319
  exports.makeBeginFlashLoanIx = makeBeginFlashLoanIx3;
76073
76320
  exports.makeBorrowIx = makeBorrowIx3;
76074
76321
  exports.makeBorrowTx = makeBorrowTx;
76322
+ exports.makeBulkRepayTx = makeBulkRepayTx;
76323
+ exports.makeBulkWithdrawTx = makeBulkWithdrawTx;
76075
76324
  exports.makeBundleTipIx = makeBundleTipIx;
76076
76325
  exports.makeCloseMarginfiAccountIx = makeCloseMarginfiAccountIx;
76077
76326
  exports.makeCloseMarginfiAccountTx = makeCloseMarginfiAccountTx;
@@ -76107,6 +76356,7 @@ exports.makePriorityFeeMicroIx = makePriorityFeeMicroIx;
76107
76356
  exports.makePulseHealthIx = makePulseHealthIx2;
76108
76357
  exports.makeRedeemStakedLstIx = makeRedeemStakedLstIx;
76109
76358
  exports.makeRedeemStakedLstTx = makeRedeemStakedLstTx;
76359
+ exports.makeRefreshIntegrationBanksIxs = makeRefreshIntegrationBanksIxs;
76110
76360
  exports.makeRefreshKaminoBanksIxs = makeRefreshKaminoBanksIxs;
76111
76361
  exports.makeRepayIx = makeRepayIx3;
76112
76362
  exports.makeRepayTx = makeRepayTx;
@@ -76114,6 +76364,7 @@ exports.makeRepayWithCollatTx = makeRepayWithCollatTx;
76114
76364
  exports.makeRollPtTx = makeRollPtTx;
76115
76365
  exports.makeSetupIx = makeSetupIx;
76116
76366
  exports.makeSmartCrankSwbFeedIx = makeSmartCrankSwbFeedIx;
76367
+ exports.makeSmartCrankSwbFeedIxForAccounts = makeSmartCrankSwbFeedIxForAccounts;
76117
76368
  exports.makeSwapCollateralTx = makeSwapCollateralTx;
76118
76369
  exports.makeSwapDebtTx = makeSwapDebtTx;
76119
76370
  exports.makeTransferPositionsTx = makeTransferPositionsTx;
@@ -76152,6 +76403,8 @@ exports.parseRpcPythPriceData = parseRpcPythPriceData;
76152
76403
  exports.parseSwbOraclePriceData = parseSwbOraclePriceData;
76153
76404
  exports.partitionBanksByCrankability = partitionBanksByCrankability;
76154
76405
  exports.patchDepositAmount = patchDepositAmount;
76406
+ exports.requireBank = requireBank;
76407
+ exports.requireTokenProgram = requireTokenProgram;
76155
76408
  exports.resolveAmount = resolveAmount;
76156
76409
  exports.resolveBridgeBanks = resolveBridgeBanks;
76157
76410
  exports.runSwapEngine = runSwapEngine;