@0dotxyz/p0-ts-sdk 2.3.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PublicKey, SolanaJSONRPCError, ComputeBudgetProgram, SystemProgram, TransactionMessage, VersionedTransaction, Keypair, Transaction, TransactionInstruction, AddressLookupTableAccount, SYSVAR_RENT_PUBKEY, StakeProgram, LAMPORTS_PER_SOL, StakeAuthorizationLayout, SYSVAR_INSTRUCTIONS_PUBKEY, STAKE_CONFIG_ID as STAKE_CONFIG_ID$1 } from '@solana/web3.js';
2
2
  import { object, string, enums, array, assert } from 'superstruct';
3
3
  import BigNumber3, { BigNumber } from 'bignumber.js';
4
- import BN11, { BN } from 'bn.js';
4
+ import BN8, { BN } from 'bn.js';
5
5
  import Decimal3, { Decimal } from 'decimal.js';
6
6
  import { BorshCoder, BorshAccountsCoder, BorshInstructionCoder, AnchorProvider, Program } from '@coral-xyz/anchor';
7
7
  import { struct, u32, u8 } from '@solana/buffer-layout';
@@ -203,6 +203,15 @@ var TransactionBuildingError = class _TransactionBuildingError extends Error {
203
203
  return new _TransactionBuildingError(code, message, details);
204
204
  }
205
205
  };
206
+ var DECOMPOSABLE_SWAP_ERROR_CODES = /* @__PURE__ */ new Set([
207
+ "SWAP_SIZE_EXCEEDED_LOOP" /* SWAP_SIZE_EXCEEDED_LOOP */,
208
+ "SWAP_SIZE_EXCEEDED_REPAY" /* SWAP_SIZE_EXCEEDED_REPAY */,
209
+ "SWAP_SIZE_EXCEEDED_POSITION_SWAP" /* SWAP_SIZE_EXCEEDED_POSITION_SWAP */,
210
+ "SWAP_QUOTE_FAILED" /* SWAP_QUOTE_FAILED */
211
+ ]);
212
+ function isDecomposableSwapError(e) {
213
+ return e instanceof TransactionBuildingError && DECOMPOSABLE_SWAP_ERROR_CODES.has(e.code);
214
+ }
206
215
  var PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED = Buffer.from("liquidity_vault_auth");
207
216
  var PDA_BANK_INSURANCE_VAULT_AUTH_SEED = Buffer.from("insurance_vault_auth");
208
217
  var PDA_BANK_FEE_VAULT_AUTH_SEED = Buffer.from("fee_vault_auth");
@@ -395,7 +404,7 @@ function bigNumberToWrappedI80F48(value) {
395
404
  let decimalValue = new Decimal(value.toString());
396
405
  const isNegative = decimalValue.isNegative();
397
406
  decimalValue = decimalValue.times(I80F48_DIVISOR);
398
- let wrappedValue = new BN11(decimalValue.round().toFixed()).toArray();
407
+ let wrappedValue = new BN8(decimalValue.round().toFixed()).toArray();
399
408
  if (wrappedValue.length < I80F48_TOTAL_BYTES) {
400
409
  const padding = Array(I80F48_TOTAL_BYTES - wrappedValue.length).fill(0);
401
410
  wrappedValue.unshift(...padding);
@@ -429,7 +438,7 @@ function toBigNumber(amount) {
429
438
  }
430
439
  function uiToNative(amount, decimals) {
431
440
  let amt = toBigNumber(amount);
432
- return new BN11(amt.times(10 ** decimals).toFixed(0, BigNumber3.ROUND_FLOOR));
441
+ return new BN8(amt.times(10 ** decimals).toFixed(0, BigNumber3.ROUND_FLOOR));
433
442
  }
434
443
  function uiToNativeBigNumber(amount, decimals) {
435
444
  let amt = toBigNumber(amount);
@@ -15770,7 +15779,7 @@ async function makePoolAddPermissionlessStakedBankIx(mfProgram, accounts, remain
15770
15779
  tokenProgram = TOKEN_PROGRAM_ID,
15771
15780
  ...optionalAccounts
15772
15781
  } = accounts;
15773
- return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new BN11(0)).accounts({
15782
+ return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new BN8(0)).accounts({
15774
15783
  stakedSettings,
15775
15784
  feePayer,
15776
15785
  bankMint,
@@ -15834,7 +15843,7 @@ var instructions = {
15834
15843
  var instructions_default = instructions;
15835
15844
  function serializeBankConfigOpt(bankConfigOpt) {
15836
15845
  const toWrappedI80F48 = (value) => value && bigNumberToWrappedI80F48(value);
15837
- const toBN = (value) => value && new BN11(value.toString());
15846
+ const toBN = (value) => value && new BN8(value.toString());
15838
15847
  return {
15839
15848
  assetWeightInit: toWrappedI80F48(bankConfigOpt.assetWeightInit),
15840
15849
  assetWeightMaint: toWrappedI80F48(bankConfigOpt.assetWeightMaint),
@@ -16187,16 +16196,16 @@ function bankConfigToBankConfigRaw(config) {
16187
16196
  assetWeightMaint: bigNumberToWrappedI80F48(config.assetWeightMaint),
16188
16197
  liabilityWeightInit: bigNumberToWrappedI80F48(config.liabilityWeightInit),
16189
16198
  liabilityWeightMaint: bigNumberToWrappedI80F48(config.liabilityWeightMaint),
16190
- depositLimit: new BN11(config.depositLimit.toString()),
16199
+ depositLimit: new BN8(config.depositLimit.toString()),
16191
16200
  interestRateConfig: serializeInterestRateConfig(config.interestRateConfig),
16192
16201
  operationalState: serializeOperationalState(config.operationalState),
16193
16202
  oracleSetup: serializeOracleSetup(config.oracleSetup),
16194
16203
  oracleKeys: config.oracleKeys,
16195
16204
  configFlags: config.configFlags,
16196
- borrowLimit: new BN11(config.borrowLimit.toString()),
16205
+ borrowLimit: new BN8(config.borrowLimit.toString()),
16197
16206
  riskTier: serializeRiskTier(config.riskTier),
16198
16207
  assetTag: config.assetTag,
16199
- totalAssetValueInitLimit: new BN11(config.totalAssetValueInitLimit.toString()),
16208
+ totalAssetValueInitLimit: new BN8(config.totalAssetValueInitLimit.toString()),
16200
16209
  oracleMaxAge: config.oracleMaxAge,
16201
16210
  oracleMaxConfidence: config.oracleMaxConfidence,
16202
16211
  fixedPrice: bigNumberToWrappedI80F48(config.fixedPrice)
@@ -16528,12 +16537,12 @@ function dtoToBankRaw(bankDto) {
16528
16537
  feeVaultBump: bankDto.feeVaultBump,
16529
16538
  feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
16530
16539
  collectedGroupFeesOutstanding: bankDto.collectedGroupFeesOutstanding,
16531
- lastUpdate: new BN11(bankDto.lastUpdate),
16540
+ lastUpdate: new BN8(bankDto.lastUpdate),
16532
16541
  config: dtoToBankConfigRaw(bankDto.config),
16533
16542
  totalAssetShares: bankDto.totalAssetShares,
16534
16543
  totalLiabilityShares: bankDto.totalLiabilityShares,
16535
- flags: new BN11(bankDto.flags),
16536
- emissionsRate: new BN11(bankDto.emissionsRate),
16544
+ flags: new BN8(bankDto.flags),
16545
+ emissionsRate: new BN8(bankDto.emissionsRate),
16537
16546
  emissionsRemaining: bankDto.emissionsRemaining,
16538
16547
  emissionsMint: new PublicKey(bankDto.emissionsMint),
16539
16548
  collectedProgramFeesOutstanding: bankDto.collectedProgramFeesOutstanding,
@@ -16549,11 +16558,11 @@ function dtoToBankRaw(bankDto) {
16549
16558
  }
16550
16559
  function dtoToRateLimitWindowRaw(window) {
16551
16560
  return {
16552
- maxOutflow: new BN11(window.maxOutflow),
16553
- windowDuration: new BN11(window.windowDuration),
16554
- windowStart: new BN11(window.windowStart),
16555
- prevWindowOutflow: new BN11(window.prevWindowOutflow),
16556
- curWindowOutflow: new BN11(window.curWindowOutflow)
16561
+ maxOutflow: new BN8(window.maxOutflow),
16562
+ windowDuration: new BN8(window.windowDuration),
16563
+ windowStart: new BN8(window.windowStart),
16564
+ prevWindowOutflow: new BN8(window.prevWindowOutflow),
16565
+ curWindowOutflow: new BN8(window.curWindowOutflow)
16557
16566
  };
16558
16567
  }
16559
16568
  function dtoToBankRateLimiterRaw(rateLimiter) {
@@ -16565,8 +16574,8 @@ function dtoToBankRateLimiterRaw(rateLimiter) {
16565
16574
  function dtoToEmodeSettingsRaw(emodeSettingsDto) {
16566
16575
  return {
16567
16576
  emodeTag: emodeSettingsDto.emodeTag,
16568
- timestamp: new BN11(emodeSettingsDto.timestamp),
16569
- flags: new BN11(emodeSettingsDto.flags),
16577
+ timestamp: new BN8(emodeSettingsDto.timestamp),
16578
+ flags: new BN8(emodeSettingsDto.flags),
16570
16579
  emodeConfig: {
16571
16580
  entries: emodeSettingsDto.emodeConfig.entries.map((entry) => {
16572
16581
  return {
@@ -16585,11 +16594,11 @@ function dtoToBankConfigRaw(bankConfigDto) {
16585
16594
  assetWeightMaint: bankConfigDto.assetWeightMaint,
16586
16595
  liabilityWeightInit: bankConfigDto.liabilityWeightInit,
16587
16596
  liabilityWeightMaint: bankConfigDto.liabilityWeightMaint,
16588
- depositLimit: new BN11(bankConfigDto.depositLimit),
16589
- borrowLimit: new BN11(bankConfigDto.borrowLimit),
16597
+ depositLimit: new BN8(bankConfigDto.depositLimit),
16598
+ borrowLimit: new BN8(bankConfigDto.borrowLimit),
16590
16599
  riskTier: bankConfigDto.riskTier,
16591
16600
  operationalState: bankConfigDto.operationalState,
16592
- totalAssetValueInitLimit: new BN11(bankConfigDto.totalAssetValueInitLimit),
16601
+ totalAssetValueInitLimit: new BN8(bankConfigDto.totalAssetValueInitLimit),
16593
16602
  assetTag: bankConfigDto.assetTag,
16594
16603
  configFlags: bankConfigDto.configFlags,
16595
16604
  oracleSetup: bankConfigDto.oracleSetup,
@@ -16737,7 +16746,7 @@ function getActiveEmodeFlags(flags) {
16737
16746
  return activeFlags;
16738
16747
  }
16739
16748
  function hasEmodeFlag(flags, flag) {
16740
- return !flags.and(new BN11(flag)).isZero();
16749
+ return !flags.and(new BN8(flag)).isZero();
16741
16750
  }
16742
16751
  function getActiveEmodeEntryFlags(flags) {
16743
16752
  const activeFlags = [];
@@ -19726,8 +19735,8 @@ var mapSwbBanksToOraclePrices = (banks, swbOracleAiDataByKey, crossbarResponse)
19726
19735
  const crossbarData = crossbarResponse[oracleFeed]?.results;
19727
19736
  const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
19728
19737
  const oraclePrice = parseSwbOraclePriceData(
19729
- crossbarData ?? new BN11(oracleData.rawPrice),
19730
- new BN11(oracleData.stdev),
19738
+ crossbarData ?? new BN8(oracleData.rawPrice),
19739
+ new BN8(oracleData.stdev),
19731
19740
  timestamp,
19732
19741
  oracleData
19733
19742
  );
@@ -19753,7 +19762,7 @@ var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey, birdeyeResponse
19753
19762
  const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
19754
19763
  const oraclePrice = parseSwbOraclePriceData(
19755
19764
  [birdeyeData],
19756
- new BN11(oracleData.stdev),
19765
+ new BN8(oracleData.stdev),
19757
19766
  timestamp,
19758
19767
  oracleData
19759
19768
  );
@@ -20369,7 +20378,7 @@ var EMPTY_HEALTH_CACHE = {
20369
20378
  liabilityValue: {
20370
20379
  value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
20371
20380
  },
20372
- timestamp: new BN11(0),
20381
+ timestamp: new BN8(0),
20373
20382
  flags: 0,
20374
20383
  prices: [],
20375
20384
  assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3(0)),
@@ -20456,7 +20465,7 @@ function getActiveAccountFlags(flags) {
20456
20465
  return activeFlags;
20457
20466
  }
20458
20467
  function hasAccountFlag(flags, flag) {
20459
- return !flags.and(new BN11(flag)).isZero();
20468
+ return !flags.and(new BN8(flag)).isZero();
20460
20469
  }
20461
20470
  function getActiveHealthCacheFlags(flags) {
20462
20471
  const activeFlags = [];
@@ -20526,7 +20535,7 @@ function dtoToHealthCache(healthCacheDto) {
20526
20535
  };
20527
20536
  }
20528
20537
  function accountFlagToBN(flag) {
20529
- return new BN11(flag);
20538
+ return new BN8(flag);
20530
20539
  }
20531
20540
  function marginfiAccountToDto(marginfiAccount) {
20532
20541
  return {
@@ -35716,23 +35725,23 @@ function dtoToDriftUserStatsRaw(userStatsDto) {
35716
35725
  authority: new PublicKey(userStatsDto.authority),
35717
35726
  referrer: new PublicKey(userStatsDto.referrer),
35718
35727
  fees: {
35719
- totalFeePaid: new BN11(userStatsDto.fees.totalFeePaid),
35720
- totalFeeRebate: new BN11(userStatsDto.fees.totalFeeRebate),
35721
- totalTokenDiscount: new BN11(userStatsDto.fees.totalTokenDiscount),
35722
- totalRefereeDiscount: new BN11(userStatsDto.fees.totalRefereeDiscount),
35723
- totalReferrerReward: new BN11(userStatsDto.fees.totalReferrerReward),
35724
- currentEpochReferrerReward: new BN11(
35728
+ totalFeePaid: new BN8(userStatsDto.fees.totalFeePaid),
35729
+ totalFeeRebate: new BN8(userStatsDto.fees.totalFeeRebate),
35730
+ totalTokenDiscount: new BN8(userStatsDto.fees.totalTokenDiscount),
35731
+ totalRefereeDiscount: new BN8(userStatsDto.fees.totalRefereeDiscount),
35732
+ totalReferrerReward: new BN8(userStatsDto.fees.totalReferrerReward),
35733
+ currentEpochReferrerReward: new BN8(
35725
35734
  userStatsDto.fees.currentEpochReferrerReward
35726
35735
  )
35727
35736
  },
35728
- nextEpochTs: new BN11(userStatsDto.nextEpochTs),
35729
- makerVolume30d: new BN11(userStatsDto.makerVolume30d),
35730
- takerVolume30d: new BN11(userStatsDto.takerVolume30d),
35731
- fillerVolume30d: new BN11(userStatsDto.fillerVolume30d),
35732
- lastMakerVolume30dTs: new BN11(userStatsDto.lastMakerVolume30dTs),
35733
- lastTakerVolume30dTs: new BN11(userStatsDto.lastTakerVolume30dTs),
35734
- lastFillerVolume30dTs: new BN11(userStatsDto.lastFillerVolume30dTs),
35735
- ifStakedQuoteAssetAmount: new BN11(userStatsDto.ifStakedQuoteAssetAmount),
35737
+ nextEpochTs: new BN8(userStatsDto.nextEpochTs),
35738
+ makerVolume30d: new BN8(userStatsDto.makerVolume30d),
35739
+ takerVolume30d: new BN8(userStatsDto.takerVolume30d),
35740
+ fillerVolume30d: new BN8(userStatsDto.fillerVolume30d),
35741
+ lastMakerVolume30dTs: new BN8(userStatsDto.lastMakerVolume30dTs),
35742
+ lastTakerVolume30dTs: new BN8(userStatsDto.lastTakerVolume30dTs),
35743
+ lastFillerVolume30dTs: new BN8(userStatsDto.lastFillerVolume30dTs),
35744
+ ifStakedQuoteAssetAmount: new BN8(userStatsDto.ifStakedQuoteAssetAmount),
35736
35745
  numberOfSubAccounts: userStatsDto.numberOfSubAccounts,
35737
35746
  numberOfSubAccountsCreated: userStatsDto.numberOfSubAccountsCreated,
35738
35747
  referrerStatus: userStatsDto.referrerStatus,
@@ -35745,7 +35754,7 @@ function dtoToDriftUserStatsRaw(userStatsDto) {
35745
35754
  fuelPositions: userStatsDto.fuelPositions,
35746
35755
  fuelTaker: userStatsDto.fuelTaker,
35747
35756
  fuelMaker: userStatsDto.fuelMaker,
35748
- ifStakedGovTokenAmount: new BN11(userStatsDto.ifStakedGovTokenAmount),
35757
+ ifStakedGovTokenAmount: new BN8(userStatsDto.ifStakedGovTokenAmount),
35749
35758
  lastFuelIfBonusUpdateTs: userStatsDto.lastFuelIfBonusUpdateTs,
35750
35759
  padding: userStatsDto.padding
35751
35760
  };
@@ -35754,10 +35763,10 @@ function dtoToDriftUserRaw(userDto) {
35754
35763
  return {
35755
35764
  authority: new PublicKey(userDto.authority),
35756
35765
  spotPositions: userDto.spotPositions.map((p) => ({
35757
- scaledBalance: new BN11(p.scaledBalance),
35758
- openBids: new BN11(p.openBids),
35759
- openAsks: new BN11(p.openAsks),
35760
- cumulativeDeposits: new BN11(p.cumulativeDeposits),
35766
+ scaledBalance: new BN8(p.scaledBalance),
35767
+ openBids: new BN8(p.openBids),
35768
+ openAsks: new BN8(p.openAsks),
35769
+ cumulativeDeposits: new BN8(p.cumulativeDeposits),
35761
35770
  marketIndex: p.marketIndex,
35762
35771
  balanceType: p.balanceType,
35763
35772
  openOrders: p.openOrders,
@@ -35772,10 +35781,10 @@ function dtoToDriftRewardsRaw(rewardsDto) {
35772
35781
  spotMarket: new PublicKey(rewardsDto.spotMarket),
35773
35782
  mint: new PublicKey(rewardsDto.mint),
35774
35783
  spotPosition: {
35775
- scaledBalance: new BN11(rewardsDto.spotPosition.scaledBalance),
35776
- openBids: new BN11(rewardsDto.spotPosition.openBids),
35777
- openAsks: new BN11(rewardsDto.spotPosition.openAsks),
35778
- cumulativeDeposits: new BN11(rewardsDto.spotPosition.cumulativeDeposits),
35784
+ scaledBalance: new BN8(rewardsDto.spotPosition.scaledBalance),
35785
+ openBids: new BN8(rewardsDto.spotPosition.openBids),
35786
+ openAsks: new BN8(rewardsDto.spotPosition.openAsks),
35787
+ cumulativeDeposits: new BN8(rewardsDto.spotPosition.cumulativeDeposits),
35779
35788
  marketIndex: rewardsDto.spotPosition.marketIndex,
35780
35789
  balanceType: rewardsDto.spotPosition.balanceType,
35781
35790
  openOrders: rewardsDto.spotPosition.openOrders,
@@ -35789,11 +35798,11 @@ function dtoToDriftSpotMarketRaw(spotMarketDto) {
35789
35798
  oracle: new PublicKey(spotMarketDto.oracle),
35790
35799
  mint: new PublicKey(spotMarketDto.mint),
35791
35800
  decimals: spotMarketDto.decimals,
35792
- cumulativeDepositInterest: new BN11(spotMarketDto.cumulativeDepositInterest),
35801
+ cumulativeDepositInterest: new BN8(spotMarketDto.cumulativeDepositInterest),
35793
35802
  marketIndex: spotMarketDto.marketIndex,
35794
- depositBalance: new BN11(spotMarketDto.depositBalance),
35795
- borrowBalance: new BN11(spotMarketDto.borrowBalance),
35796
- cumulativeBorrowInterest: new BN11(spotMarketDto.cumulativeBorrowInterest),
35803
+ depositBalance: new BN8(spotMarketDto.depositBalance),
35804
+ borrowBalance: new BN8(spotMarketDto.borrowBalance),
35805
+ cumulativeBorrowInterest: new BN8(spotMarketDto.cumulativeBorrowInterest),
35797
35806
  optimalUtilization: spotMarketDto.optimalUtilization,
35798
35807
  optimalBorrowRate: spotMarketDto.optimalBorrowRate,
35799
35808
  maxBorrowRate: spotMarketDto.maxBorrowRate,
@@ -35882,10 +35891,10 @@ function decodeDriftUserData(data) {
35882
35891
  return {
35883
35892
  authority: decoded.authority,
35884
35893
  spotPositions: decoded.spot_positions.map((p) => ({
35885
- scaledBalance: new BN11(p.scaled_balance),
35886
- openBids: new BN11(p.open_bids),
35887
- openAsks: new BN11(p.open_asks),
35888
- cumulativeDeposits: new BN11(p.cumulative_deposits),
35894
+ scaledBalance: new BN8(p.scaled_balance),
35895
+ openBids: new BN8(p.open_bids),
35896
+ openAsks: new BN8(p.open_asks),
35897
+ cumulativeDeposits: new BN8(p.cumulative_deposits),
35889
35898
  marketIndex: p.market_index,
35890
35899
  balanceType: p.balance_type,
35891
35900
  openOrders: p.open_orders,
@@ -35955,7 +35964,7 @@ function deriveDriftSpotMarket(marketIndex, programId = DRIFT_PROGRAM_ID) {
35955
35964
  return PublicKey.findProgramAddressSync(
35956
35965
  [
35957
35966
  Buffer.from(SEED_SPOT_MARKET),
35958
- new BN11(marketIndex).toArrayLike(Buffer, "le", 2)
35967
+ new BN8(marketIndex).toArrayLike(Buffer, "le", 2)
35959
35968
  ],
35960
35969
  programId
35961
35970
  );
@@ -35964,7 +35973,7 @@ function deriveDriftSpotMarketVault(marketIndex, programId = DRIFT_PROGRAM_ID) {
35964
35973
  return PublicKey.findProgramAddressSync(
35965
35974
  [
35966
35975
  Buffer.from(SEED_SPOT_MARKET_VAULT),
35967
- new BN11(marketIndex).toArrayLike(Buffer, "le", 2)
35976
+ new BN8(marketIndex).toArrayLike(Buffer, "le", 2)
35968
35977
  ],
35969
35978
  programId
35970
35979
  );
@@ -36358,7 +36367,7 @@ function generateDummyAccount(group, authority, accountKey) {
36358
36367
  assetShares: dummyWrappedI80F48,
36359
36368
  liabilityShares: dummyWrappedI80F48,
36360
36369
  emissionsOutstanding: dummyWrappedI80F48,
36361
- lastUpdate: new BN11(0)
36370
+ lastUpdate: new BN8(0)
36362
36371
  });
36363
36372
  const rawAccount = {
36364
36373
  group,
@@ -36371,7 +36380,7 @@ function generateDummyAccount(group, authority, accountKey) {
36371
36380
  liabilityValue: {
36372
36381
  value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
36373
36382
  },
36374
- timestamp: new BN11(0),
36383
+ timestamp: new BN8(0),
36375
36384
  flags: 0,
36376
36385
  prices: [],
36377
36386
  assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3(0)),
@@ -36385,7 +36394,7 @@ function generateDummyAccount(group, authority, accountKey) {
36385
36394
  mrgnErr: 0
36386
36395
  },
36387
36396
  emissionsDestinationAccount: new PublicKey("11111111111111111111111111111111"),
36388
- accountFlags: new BN11([0, 0, 0])
36397
+ accountFlags: new BN8([0, 0, 0])
36389
36398
  };
36390
36399
  return parseMarginfiAccountRaw(accountKey, rawAccount);
36391
36400
  }
@@ -36418,233 +36427,63 @@ async function makeRefreshingIxs({
36418
36427
  }
36419
36428
 
36420
36429
  // src/vendor/klend/utils/klend/serialize.utils.ts
36421
- function obligationRawToDto(obligationRaw) {
36422
- return {
36423
- tag: obligationRaw.tag.toString(),
36424
- lastUpdate: {
36425
- slot: obligationRaw.lastUpdate.slot.toString(),
36426
- stale: obligationRaw.lastUpdate.stale,
36427
- priceStatus: obligationRaw.lastUpdate.priceStatus,
36428
- placeholder: obligationRaw.lastUpdate.placeholder
36429
- },
36430
- lendingMarket: obligationRaw.lendingMarket.toBase58(),
36431
- owner: obligationRaw.owner.toBase58(),
36432
- deposits: obligationRaw.deposits.map(
36433
- (item) => obligationCollateralToDto(item)
36434
- ),
36435
- lowestReserveDepositLiquidationLtv: obligationRaw.lowestReserveDepositLiquidationLtv.toString(),
36436
- depositedValueSf: obligationRaw.depositedValueSf.toString(),
36437
- borrows: obligationRaw.borrows.map(
36438
- (item) => obligationLiquidityToDto(item)
36439
- ),
36440
- borrowFactorAdjustedDebtValueSf: obligationRaw.borrowFactorAdjustedDebtValueSf.toString(),
36441
- borrowedAssetsMarketValueSf: obligationRaw.borrowedAssetsMarketValueSf.toString(),
36442
- allowedBorrowValueSf: obligationRaw.allowedBorrowValueSf.toString(),
36443
- unhealthyBorrowValueSf: obligationRaw.unhealthyBorrowValueSf.toString(),
36444
- depositsAssetTiers: obligationRaw.depositsAssetTiers,
36445
- borrowsAssetTiers: obligationRaw.borrowsAssetTiers,
36446
- elevationGroup: obligationRaw.elevationGroup,
36447
- numOfObsoleteDepositReserves: obligationRaw.numOfObsoleteDepositReserves,
36448
- hasDebt: obligationRaw.hasDebt,
36449
- referrer: obligationRaw.referrer.toBase58(),
36450
- borrowingDisabled: obligationRaw.borrowingDisabled,
36451
- autodeleverageTargetLtvPct: obligationRaw.autodeleverageTargetLtvPct,
36452
- lowestReserveDepositMaxLtvPct: obligationRaw.lowestReserveDepositMaxLtvPct,
36453
- numOfObsoleteBorrowReserves: obligationRaw.numOfObsoleteBorrowReserves,
36454
- reserved: obligationRaw.reserved,
36455
- highestBorrowFactorPct: obligationRaw.highestBorrowFactorPct.toString(),
36456
- autodeleverageMarginCallStartedTimestamp: obligationRaw.autodeleverageMarginCallStartedTimestamp.toString(),
36457
- orders: obligationRaw.orders.map((item) => obligationOrderToDto(item)),
36458
- padding3: obligationRaw.padding3.map((item) => item.toString())
36459
- };
36460
- }
36461
- function reserveRawToDto(reserveRaw) {
36462
- return {
36463
- version: reserveRaw.version.toString(),
36464
- lastUpdate: {
36465
- slot: reserveRaw.lastUpdate.slot.toString(),
36466
- stale: reserveRaw.lastUpdate.stale,
36467
- priceStatus: reserveRaw.lastUpdate.priceStatus,
36468
- placeholder: reserveRaw.lastUpdate.placeholder
36469
- },
36470
- lendingMarket: reserveRaw.lendingMarket.toBase58(),
36471
- farmCollateral: reserveRaw.farmCollateral.toBase58(),
36472
- farmDebt: reserveRaw.farmDebt.toBase58(),
36473
- liquidity: reserveLiquidityFieldsToDto(reserveRaw.liquidity),
36474
- reserveLiquidityPadding: reserveRaw.reserveLiquidityPadding.map(
36475
- (item) => item.toString()
36476
- ),
36477
- collateral: {
36478
- mintPubkey: reserveRaw.collateral.mintPubkey.toBase58(),
36479
- mintTotalSupply: reserveRaw.collateral.mintTotalSupply.toString(),
36480
- supplyVault: reserveRaw.collateral.supplyVault.toBase58(),
36481
- padding1: reserveRaw.collateral.padding1.map((item) => item.toString()),
36482
- padding2: reserveRaw.collateral.padding2.map((item) => item.toString())
36483
- },
36484
- reserveCollateralPadding: reserveRaw.reserveCollateralPadding.map(
36485
- (item) => item.toString()
36486
- ),
36487
- config: reserveConfigFieldsToDto(reserveRaw.config),
36488
- configPadding: reserveRaw.configPadding.map((item) => item.toString()),
36489
- borrowedAmountOutsideElevationGroup: reserveRaw.borrowedAmountOutsideElevationGroup.toString(),
36490
- borrowedAmountsAgainstThisReserveInElevationGroups: reserveRaw.borrowedAmountsAgainstThisReserveInElevationGroups.map(
36491
- (item) => item.toString()
36492
- ),
36493
- padding: reserveRaw.padding.map((item) => item.toString())
36494
- };
36495
- }
36496
- function reserveLiquidityFieldsToDto(reserveLiquidityFields) {
36497
- return {
36498
- mintPubkey: reserveLiquidityFields.mintPubkey.toBase58(),
36499
- supplyVault: reserveLiquidityFields.supplyVault.toBase58(),
36500
- feeVault: reserveLiquidityFields.feeVault.toBase58(),
36501
- availableAmount: reserveLiquidityFields.availableAmount.toString(),
36502
- borrowedAmountSf: reserveLiquidityFields.borrowedAmountSf.toString(),
36503
- marketPriceSf: reserveLiquidityFields.marketPriceSf.toString(),
36504
- marketPriceLastUpdatedTs: reserveLiquidityFields.marketPriceLastUpdatedTs.toString(),
36505
- mintDecimals: reserveLiquidityFields.mintDecimals.toString(),
36506
- depositLimitCrossedTimestamp: reserveLiquidityFields.depositLimitCrossedTimestamp.toString(),
36507
- borrowLimitCrossedTimestamp: reserveLiquidityFields.borrowLimitCrossedTimestamp.toString(),
36508
- cumulativeBorrowRateBsf: {
36509
- value: reserveLiquidityFields.cumulativeBorrowRateBsf.value.map(
36510
- (item) => item.toString()
36511
- ),
36512
- padding: reserveLiquidityFields.cumulativeBorrowRateBsf.padding.map(
36513
- (item) => item.toString()
36514
- )
36515
- },
36516
- accumulatedProtocolFeesSf: reserveLiquidityFields.accumulatedProtocolFeesSf.toString(),
36517
- accumulatedReferrerFeesSf: reserveLiquidityFields.accumulatedReferrerFeesSf.toString(),
36518
- pendingReferrerFeesSf: reserveLiquidityFields.pendingReferrerFeesSf.toString(),
36519
- absoluteReferralRateSf: reserveLiquidityFields.absoluteReferralRateSf.toString(),
36520
- tokenProgram: reserveLiquidityFields.tokenProgram.toBase58(),
36521
- padding2: reserveLiquidityFields.padding2.map((item) => item.toString()),
36522
- padding3: reserveLiquidityFields.padding3.map((item) => item.toString())
36523
- };
36524
- }
36525
- function reserveConfigFieldsToDto(reserveConfigFields) {
36526
- return {
36527
- status: reserveConfigFields.status,
36528
- assetTier: reserveConfigFields.assetTier,
36529
- hostFixedInterestRateBps: reserveConfigFields.hostFixedInterestRateBps,
36530
- reserved2: reserveConfigFields.reserved2,
36531
- protocolOrderExecutionFeePct: reserveConfigFields.protocolOrderExecutionFeePct,
36532
- protocolTakeRatePct: reserveConfigFields.protocolTakeRatePct,
36533
- protocolLiquidationFeePct: reserveConfigFields.protocolLiquidationFeePct,
36534
- loanToValuePct: reserveConfigFields.loanToValuePct,
36535
- liquidationThresholdPct: reserveConfigFields.liquidationThresholdPct,
36536
- minLiquidationBonusBps: reserveConfigFields.minLiquidationBonusBps,
36537
- maxLiquidationBonusBps: reserveConfigFields.maxLiquidationBonusBps,
36538
- badDebtLiquidationBonusBps: reserveConfigFields.badDebtLiquidationBonusBps,
36539
- deleveragingMarginCallPeriodSecs: reserveConfigFields.deleveragingMarginCallPeriodSecs.toString(),
36540
- deleveragingThresholdDecreaseBpsPerDay: reserveConfigFields.deleveragingThresholdDecreaseBpsPerDay.toString(),
36541
- fees: {
36542
- borrowFeeSf: reserveConfigFields.fees.borrowFeeSf.toString(),
36543
- flashLoanFeeSf: reserveConfigFields.fees.flashLoanFeeSf.toString(),
36544
- padding: reserveConfigFields.fees.padding
36545
- },
36546
- borrowRateCurve: {
36547
- points: reserveConfigFields.borrowRateCurve.points.map((item) => ({
36548
- utilizationRateBps: item.utilizationRateBps,
36549
- borrowRateBps: item.borrowRateBps
36550
- }))
36551
- },
36552
- borrowFactorPct: reserveConfigFields.borrowFactorPct.toString(),
36553
- depositLimit: reserveConfigFields.depositLimit.toString(),
36554
- borrowLimit: reserveConfigFields.borrowLimit.toString(),
36555
- tokenInfo: tokenInfoFieldsToDto(reserveConfigFields.tokenInfo),
36556
- depositWithdrawalCap: withdrawalCapsFieldsToDto(
36557
- reserveConfigFields.depositWithdrawalCap
36558
- ),
36559
- debtWithdrawalCap: withdrawalCapsFieldsToDto(
36560
- reserveConfigFields.debtWithdrawalCap
36561
- ),
36562
- elevationGroups: reserveConfigFields.elevationGroups,
36563
- disableUsageAsCollOutsideEmode: reserveConfigFields.disableUsageAsCollOutsideEmode,
36564
- utilizationLimitBlockBorrowingAbovePct: reserveConfigFields.utilizationLimitBlockBorrowingAbovePct,
36565
- autodeleverageEnabled: reserveConfigFields.autodeleverageEnabled,
36566
- reserved1: reserveConfigFields.reserved1,
36567
- borrowLimitOutsideElevationGroup: reserveConfigFields.borrowLimitOutsideElevationGroup.toString(),
36568
- borrowLimitAgainstThisCollateralInElevationGroup: reserveConfigFields.borrowLimitAgainstThisCollateralInElevationGroup.map(
36569
- (item) => item.toString()
36570
- ),
36571
- deleveragingBonusIncreaseBpsPerDay: reserveConfigFields.deleveragingBonusIncreaseBpsPerDay.toString()
36572
- };
36573
- }
36574
- function tokenInfoFieldsToDto(tokenInfoFields) {
36575
- return {
36576
- name: tokenInfoFields.name,
36577
- heuristic: {
36578
- lower: tokenInfoFields.heuristic.lower.toString(),
36579
- upper: tokenInfoFields.heuristic.upper.toString(),
36580
- exp: tokenInfoFields.heuristic.exp.toString()
36581
- },
36582
- maxTwapDivergenceBps: tokenInfoFields.maxTwapDivergenceBps.toString(),
36583
- maxAgePriceSeconds: tokenInfoFields.maxAgePriceSeconds.toString(),
36584
- maxAgeTwapSeconds: tokenInfoFields.maxAgeTwapSeconds.toString(),
36585
- scopeConfiguration: {
36586
- priceFeed: tokenInfoFields.scopeConfiguration.priceFeed.toBase58(),
36587
- priceChain: tokenInfoFields.scopeConfiguration.priceChain,
36588
- twapChain: tokenInfoFields.scopeConfiguration.twapChain
36589
- },
36590
- switchboardConfiguration: {
36591
- priceAggregator: tokenInfoFields.switchboardConfiguration.priceAggregator.toBase58(),
36592
- twapAggregator: tokenInfoFields.switchboardConfiguration.twapAggregator.toBase58()
36593
- },
36594
- pythConfiguration: {
36595
- price: tokenInfoFields.pythConfiguration.price.toBase58()
36596
- },
36597
- blockPriceUsage: tokenInfoFields.blockPriceUsage,
36598
- reserved: tokenInfoFields.reserved,
36599
- padding: tokenInfoFields.padding.map((item) => item.toString())
36600
- };
36601
- }
36602
- function withdrawalCapsFieldsToDto(withdrawalCapsFields) {
36430
+ function kaminoObligationToDto(obligation) {
36603
36431
  return {
36604
- configCapacity: withdrawalCapsFields.configCapacity.toString(),
36605
- currentTotal: withdrawalCapsFields.currentTotal.toString(),
36606
- lastIntervalStartTimestamp: withdrawalCapsFields.lastIntervalStartTimestamp.toString(),
36607
- configIntervalLengthSeconds: withdrawalCapsFields.configIntervalLengthSeconds.toString()
36608
- };
36609
- }
36610
- function obligationCollateralToDto(obligationCollateralFields) {
36611
- return {
36612
- depositReserve: obligationCollateralFields.depositReserve.toBase58(),
36613
- depositedAmount: obligationCollateralFields.depositedAmount.toString(),
36614
- marketValueSf: obligationCollateralFields.marketValueSf.toString(),
36615
- borrowedAmountAgainstThisCollateralInElevationGroup: obligationCollateralFields.borrowedAmountAgainstThisCollateralInElevationGroup.toString(),
36616
- padding: obligationCollateralFields.padding.map((item) => item.toString())
36432
+ lendingMarket: obligation.lendingMarket.toBase58(),
36433
+ owner: obligation.owner.toBase58(),
36434
+ deposits: obligation.deposits.map((item) => ({
36435
+ depositReserve: item.depositReserve.toBase58(),
36436
+ depositedAmount: item.depositedAmount.toString(),
36437
+ marketValueSf: item.marketValueSf.toString()
36438
+ })),
36439
+ borrows: obligation.borrows.map((item) => ({
36440
+ borrowReserve: item.borrowReserve.toBase58(),
36441
+ borrowedAmountSf: item.borrowedAmountSf.toString(),
36442
+ marketValueSf: item.marketValueSf.toString()
36443
+ }))
36617
36444
  };
36618
36445
  }
36619
- function obligationLiquidityToDto(obligationLiquidityFields) {
36446
+ function kaminoReserveToDto(reserve) {
36620
36447
  return {
36621
- borrowReserve: obligationLiquidityFields.borrowReserve.toBase58(),
36622
- cumulativeBorrowRateBsf: {
36623
- value: obligationLiquidityFields.cumulativeBorrowRateBsf.value.map(
36624
- (item) => item.toString()
36625
- ),
36626
- padding: obligationLiquidityFields.cumulativeBorrowRateBsf.padding.map(
36627
- (item) => item.toString()
36628
- )
36448
+ lendingMarket: reserve.lendingMarket.toBase58(),
36449
+ farmCollateral: reserve.farmCollateral.toBase58(),
36450
+ liquidity: {
36451
+ mintPubkey: reserve.liquidity.mintPubkey.toBase58(),
36452
+ supplyVault: reserve.liquidity.supplyVault.toBase58(),
36453
+ mintDecimals: reserve.liquidity.mintDecimals.toString(),
36454
+ availableAmount: reserve.liquidity.availableAmount.toString(),
36455
+ borrowedAmountSf: reserve.liquidity.borrowedAmountSf.toString(),
36456
+ accumulatedProtocolFeesSf: reserve.liquidity.accumulatedProtocolFeesSf.toString(),
36457
+ accumulatedReferrerFeesSf: reserve.liquidity.accumulatedReferrerFeesSf.toString(),
36458
+ pendingReferrerFeesSf: reserve.liquidity.pendingReferrerFeesSf.toString()
36629
36459
  },
36630
- padding: obligationLiquidityFields.padding.toString(),
36631
- borrowedAmountSf: obligationLiquidityFields.borrowedAmountSf.toString(),
36632
- marketValueSf: obligationLiquidityFields.marketValueSf.toString(),
36633
- borrowFactorAdjustedMarketValueSf: obligationLiquidityFields.borrowFactorAdjustedMarketValueSf.toString(),
36634
- borrowedAmountOutsideElevationGroups: obligationLiquidityFields.borrowedAmountOutsideElevationGroups.toString(),
36635
- padding2: obligationLiquidityFields.padding2.map((item) => item.toString())
36636
- };
36637
- }
36638
- function obligationOrderToDto(obligationOrderFields) {
36639
- return {
36640
- conditionThresholdSf: obligationOrderFields.conditionThresholdSf.toString(),
36641
- opportunityParameterSf: obligationOrderFields.opportunityParameterSf.toString(),
36642
- minExecutionBonusBps: obligationOrderFields.minExecutionBonusBps,
36643
- maxExecutionBonusBps: obligationOrderFields.maxExecutionBonusBps,
36644
- conditionType: obligationOrderFields.conditionType,
36645
- opportunityType: obligationOrderFields.opportunityType,
36646
- padding1: obligationOrderFields.padding1,
36647
- padding2: obligationOrderFields.padding2.map((item) => item.toString())
36460
+ collateral: {
36461
+ mintPubkey: reserve.collateral.mintPubkey.toBase58(),
36462
+ mintTotalSupply: reserve.collateral.mintTotalSupply.toString(),
36463
+ supplyVault: reserve.collateral.supplyVault.toBase58()
36464
+ },
36465
+ config: {
36466
+ protocolTakeRatePct: reserve.config.protocolTakeRatePct,
36467
+ hostFixedInterestRateBps: reserve.config.hostFixedInterestRateBps,
36468
+ borrowRateCurve: {
36469
+ points: reserve.config.borrowRateCurve.points.map((item) => ({
36470
+ utilizationRateBps: item.utilizationRateBps,
36471
+ borrowRateBps: item.borrowRateBps
36472
+ }))
36473
+ },
36474
+ tokenInfo: {
36475
+ scopeConfiguration: {
36476
+ priceFeed: reserve.config.tokenInfo.scopeConfiguration.priceFeed.toBase58()
36477
+ },
36478
+ switchboardConfiguration: {
36479
+ priceAggregator: reserve.config.tokenInfo.switchboardConfiguration.priceAggregator.toBase58(),
36480
+ twapAggregator: reserve.config.tokenInfo.switchboardConfiguration.twapAggregator.toBase58()
36481
+ },
36482
+ pythConfiguration: {
36483
+ price: reserve.config.tokenInfo.pythConfiguration.price.toBase58()
36484
+ }
36485
+ }
36486
+ }
36648
36487
  };
36649
36488
  }
36650
36489
 
@@ -43142,267 +42981,75 @@ function decodeKlendObligationData(data) {
43142
42981
  const dec = obligationLayout.decode(data.slice(8));
43143
42982
  return dec;
43144
42983
  }
43145
- function dtoToObligationRaw(obligationDto) {
42984
+ function dtoToKaminoObligation(obligationDto) {
43146
42985
  return {
43147
- tag: new BN11(obligationDto.tag),
43148
- lastUpdate: {
43149
- slot: new BN11(obligationDto.lastUpdate.slot),
43150
- stale: obligationDto.lastUpdate.stale,
43151
- priceStatus: obligationDto.lastUpdate.priceStatus,
43152
- placeholder: obligationDto.lastUpdate.placeholder
43153
- },
43154
42986
  lendingMarket: new PublicKey(obligationDto.lendingMarket),
43155
42987
  owner: new PublicKey(obligationDto.owner),
43156
- deposits: obligationDto.deposits.map(
43157
- (item) => dtoToObligationCollateralFields(item)
43158
- ),
43159
- lowestReserveDepositLiquidationLtv: new BN11(
43160
- obligationDto.lowestReserveDepositLiquidationLtv
43161
- ),
43162
- depositedValueSf: new BN11(obligationDto.depositedValueSf),
43163
- borrows: obligationDto.borrows.map(
43164
- (item) => dtoToObligationLiquidityFields(item)
43165
- ),
43166
- borrowFactorAdjustedDebtValueSf: new BN11(
43167
- obligationDto.borrowFactorAdjustedDebtValueSf
43168
- ),
43169
- borrowedAssetsMarketValueSf: new BN11(
43170
- obligationDto.borrowedAssetsMarketValueSf
43171
- ),
43172
- allowedBorrowValueSf: new BN11(obligationDto.allowedBorrowValueSf),
43173
- unhealthyBorrowValueSf: new BN11(obligationDto.unhealthyBorrowValueSf),
43174
- depositsAssetTiers: obligationDto.depositsAssetTiers,
43175
- borrowsAssetTiers: obligationDto.borrowsAssetTiers,
43176
- elevationGroup: obligationDto.elevationGroup,
43177
- numOfObsoleteDepositReserves: obligationDto.numOfObsoleteDepositReserves,
43178
- hasDebt: obligationDto.hasDebt,
43179
- referrer: new PublicKey(obligationDto.referrer),
43180
- borrowingDisabled: obligationDto.borrowingDisabled,
43181
- autodeleverageTargetLtvPct: obligationDto.autodeleverageTargetLtvPct,
43182
- lowestReserveDepositMaxLtvPct: obligationDto.lowestReserveDepositMaxLtvPct,
43183
- numOfObsoleteBorrowReserves: obligationDto.numOfObsoleteBorrowReserves,
43184
- reserved: obligationDto.reserved,
43185
- highestBorrowFactorPct: new BN11(obligationDto.highestBorrowFactorPct),
43186
- autodeleverageMarginCallStartedTimestamp: new BN11(
43187
- obligationDto.autodeleverageMarginCallStartedTimestamp
43188
- ),
43189
- orders: obligationDto.orders.map(
43190
- (item) => dtoToObligationOrderFields(item)
43191
- ),
43192
- padding3: obligationDto.padding3.map((item) => new BN11(item))
42988
+ deposits: obligationDto.deposits.map((item) => ({
42989
+ depositReserve: new PublicKey(item.depositReserve),
42990
+ depositedAmount: new BN8(item.depositedAmount),
42991
+ marketValueSf: new BN8(item.marketValueSf)
42992
+ })),
42993
+ borrows: obligationDto.borrows.map((item) => ({
42994
+ borrowReserve: new PublicKey(item.borrowReserve),
42995
+ borrowedAmountSf: new BN8(item.borrowedAmountSf),
42996
+ marketValueSf: new BN8(item.marketValueSf)
42997
+ }))
43193
42998
  };
43194
42999
  }
43195
- function dtoToReserveRaw(reserveDto) {
43000
+ function dtoToKaminoReserve(reserveDto) {
43196
43001
  return {
43197
- version: new BN11(reserveDto.version),
43198
- lastUpdate: {
43199
- slot: new BN11(reserveDto.lastUpdate.slot),
43200
- stale: reserveDto.lastUpdate.stale,
43201
- priceStatus: reserveDto.lastUpdate.priceStatus,
43202
- placeholder: reserveDto.lastUpdate.placeholder
43203
- },
43204
43002
  lendingMarket: new PublicKey(reserveDto.lendingMarket),
43205
43003
  farmCollateral: new PublicKey(reserveDto.farmCollateral),
43206
- farmDebt: new PublicKey(reserveDto.farmDebt),
43207
- liquidity: dtoToReserveLiquidityFields(reserveDto.liquidity),
43208
- reserveLiquidityPadding: reserveDto.reserveLiquidityPadding.map(
43209
- (item) => new BN11(item)
43210
- ),
43211
- collateral: {
43212
- mintPubkey: new PublicKey(reserveDto.collateral.mintPubkey),
43213
- mintTotalSupply: new BN11(reserveDto.collateral.mintTotalSupply),
43214
- supplyVault: new PublicKey(reserveDto.collateral.supplyVault),
43215
- padding1: reserveDto.collateral.padding1.map((item) => new BN11(item)),
43216
- padding2: reserveDto.collateral.padding2.map((item) => new BN11(item))
43217
- },
43218
- reserveCollateralPadding: reserveDto.reserveCollateralPadding.map(
43219
- (item) => new BN11(item)
43220
- ),
43221
- config: dtoToReserveConfigFields(reserveDto.config),
43222
- configPadding: reserveDto.configPadding.map((item) => new BN11(item)),
43223
- borrowedAmountOutsideElevationGroup: new BN11(
43224
- reserveDto.borrowedAmountOutsideElevationGroup
43225
- ),
43226
- borrowedAmountsAgainstThisReserveInElevationGroups: reserveDto.borrowedAmountsAgainstThisReserveInElevationGroups.map(
43227
- (item) => new BN11(item)
43228
- ),
43229
- padding: reserveDto.padding.map((item) => new BN11(item))
43230
- };
43231
- }
43232
- function dtoToReserveLiquidityFields(reserveDto) {
43233
- return {
43234
- mintPubkey: new PublicKey(reserveDto.mintPubkey),
43235
- supplyVault: new PublicKey(reserveDto.supplyVault),
43236
- feeVault: new PublicKey(reserveDto.feeVault),
43237
- availableAmount: new BN11(reserveDto.availableAmount),
43238
- borrowedAmountSf: new BN11(reserveDto.borrowedAmountSf),
43239
- marketPriceSf: new BN11(reserveDto.marketPriceSf),
43240
- marketPriceLastUpdatedTs: new BN11(reserveDto.marketPriceLastUpdatedTs),
43241
- mintDecimals: new BN11(reserveDto.mintDecimals),
43242
- depositLimitCrossedTimestamp: new BN11(
43243
- reserveDto.depositLimitCrossedTimestamp
43244
- ),
43245
- borrowLimitCrossedTimestamp: new BN11(reserveDto.borrowLimitCrossedTimestamp),
43246
- cumulativeBorrowRateBsf: {
43247
- value: reserveDto.cumulativeBorrowRateBsf.value.map(
43248
- (item) => new BN11(item)
43249
- ),
43250
- padding: reserveDto.cumulativeBorrowRateBsf.padding.map(
43251
- (item) => new BN11(item)
43252
- )
43253
- },
43254
- accumulatedProtocolFeesSf: new BN11(reserveDto.accumulatedProtocolFeesSf),
43255
- accumulatedReferrerFeesSf: new BN11(reserveDto.accumulatedReferrerFeesSf),
43256
- pendingReferrerFeesSf: new BN11(reserveDto.pendingReferrerFeesSf),
43257
- absoluteReferralRateSf: new BN11(reserveDto.absoluteReferralRateSf),
43258
- tokenProgram: new PublicKey(reserveDto.tokenProgram),
43259
- padding2: reserveDto.padding2.map((item) => new BN11(item)),
43260
- padding3: reserveDto.padding3.map((item) => new BN11(item))
43261
- };
43262
- }
43263
- function dtoToReserveConfigFields(reserveDto) {
43264
- return {
43265
- status: reserveDto.status,
43266
- assetTier: reserveDto.assetTier,
43267
- hostFixedInterestRateBps: reserveDto.hostFixedInterestRateBps,
43268
- reserved2: reserveDto.reserved2,
43269
- protocolOrderExecutionFeePct: reserveDto.protocolOrderExecutionFeePct,
43270
- protocolTakeRatePct: reserveDto.protocolTakeRatePct,
43271
- protocolLiquidationFeePct: reserveDto.protocolLiquidationFeePct,
43272
- loanToValuePct: reserveDto.loanToValuePct,
43273
- liquidationThresholdPct: reserveDto.liquidationThresholdPct,
43274
- minLiquidationBonusBps: reserveDto.minLiquidationBonusBps,
43275
- maxLiquidationBonusBps: reserveDto.maxLiquidationBonusBps,
43276
- badDebtLiquidationBonusBps: reserveDto.badDebtLiquidationBonusBps,
43277
- deleveragingMarginCallPeriodSecs: new BN11(
43278
- reserveDto.deleveragingMarginCallPeriodSecs
43279
- ),
43280
- deleveragingThresholdDecreaseBpsPerDay: new BN11(
43281
- reserveDto.deleveragingThresholdDecreaseBpsPerDay
43282
- ),
43283
- fees: {
43284
- borrowFeeSf: new BN11(reserveDto.fees.borrowFeeSf),
43285
- flashLoanFeeSf: new BN11(reserveDto.fees.flashLoanFeeSf),
43286
- padding: reserveDto.fees.padding
43287
- },
43288
- borrowRateCurve: {
43289
- points: reserveDto.borrowRateCurve.points.map((item) => ({
43290
- utilizationRateBps: item.utilizationRateBps,
43291
- borrowRateBps: item.borrowRateBps
43292
- }))
43293
- },
43294
- borrowFactorPct: new BN11(reserveDto.borrowFactorPct),
43295
- depositLimit: new BN11(reserveDto.depositLimit),
43296
- borrowLimit: new BN11(reserveDto.borrowLimit),
43297
- tokenInfo: dtoToTokenInfoFields(reserveDto.tokenInfo),
43298
- depositWithdrawalCap: dtoToWithdrawalCapsFields(
43299
- reserveDto.depositWithdrawalCap
43300
- ),
43301
- debtWithdrawalCap: dtoToWithdrawalCapsFields(reserveDto.debtWithdrawalCap),
43302
- elevationGroups: reserveDto.elevationGroups,
43303
- disableUsageAsCollOutsideEmode: reserveDto.disableUsageAsCollOutsideEmode,
43304
- utilizationLimitBlockBorrowingAbovePct: reserveDto.utilizationLimitBlockBorrowingAbovePct,
43305
- autodeleverageEnabled: reserveDto.autodeleverageEnabled,
43306
- reserved1: reserveDto.reserved1,
43307
- borrowLimitOutsideElevationGroup: new BN11(
43308
- reserveDto.borrowLimitOutsideElevationGroup
43309
- ),
43310
- borrowLimitAgainstThisCollateralInElevationGroup: reserveDto.borrowLimitAgainstThisCollateralInElevationGroup.map(
43311
- (item) => new BN11(item)
43312
- ),
43313
- deleveragingBonusIncreaseBpsPerDay: new BN11(
43314
- reserveDto.deleveragingBonusIncreaseBpsPerDay
43315
- )
43316
- };
43317
- }
43318
- function dtoToTokenInfoFields(tokenInfoDto) {
43319
- return {
43320
- name: tokenInfoDto.name,
43321
- heuristic: {
43322
- lower: new BN11(tokenInfoDto.heuristic.lower),
43323
- upper: new BN11(tokenInfoDto.heuristic.upper),
43324
- exp: new BN11(tokenInfoDto.heuristic.exp)
43325
- },
43326
- maxTwapDivergenceBps: new BN11(tokenInfoDto.maxTwapDivergenceBps),
43327
- maxAgePriceSeconds: new BN11(tokenInfoDto.maxAgePriceSeconds),
43328
- maxAgeTwapSeconds: new BN11(tokenInfoDto.maxAgeTwapSeconds),
43329
- scopeConfiguration: {
43330
- priceFeed: new PublicKey(tokenInfoDto.scopeConfiguration.priceFeed),
43331
- priceChain: tokenInfoDto.scopeConfiguration.priceChain,
43332
- twapChain: tokenInfoDto.scopeConfiguration.twapChain
43333
- },
43334
- switchboardConfiguration: {
43335
- priceAggregator: new PublicKey(
43336
- tokenInfoDto.switchboardConfiguration.priceAggregator
43004
+ liquidity: {
43005
+ mintPubkey: new PublicKey(reserveDto.liquidity.mintPubkey),
43006
+ supplyVault: new PublicKey(reserveDto.liquidity.supplyVault),
43007
+ mintDecimals: new BN8(reserveDto.liquidity.mintDecimals),
43008
+ availableAmount: new BN8(reserveDto.liquidity.availableAmount),
43009
+ borrowedAmountSf: new BN8(reserveDto.liquidity.borrowedAmountSf),
43010
+ accumulatedProtocolFeesSf: new BN8(
43011
+ reserveDto.liquidity.accumulatedProtocolFeesSf
43337
43012
  ),
43338
- twapAggregator: new PublicKey(
43339
- tokenInfoDto.switchboardConfiguration.twapAggregator
43340
- )
43341
- },
43342
- pythConfiguration: {
43343
- price: new PublicKey(tokenInfoDto.pythConfiguration.price)
43344
- },
43345
- blockPriceUsage: tokenInfoDto.blockPriceUsage,
43346
- reserved: tokenInfoDto.reserved,
43347
- padding: tokenInfoDto.padding.map((item) => new BN11(item))
43348
- };
43349
- }
43350
- function dtoToWithdrawalCapsFields(withdrawalCapsDto) {
43351
- return {
43352
- configCapacity: new BN11(withdrawalCapsDto.configCapacity),
43353
- currentTotal: new BN11(withdrawalCapsDto.currentTotal),
43354
- lastIntervalStartTimestamp: new BN11(
43355
- withdrawalCapsDto.lastIntervalStartTimestamp
43356
- ),
43357
- configIntervalLengthSeconds: new BN11(
43358
- withdrawalCapsDto.configIntervalLengthSeconds
43359
- )
43360
- };
43361
- }
43362
- function dtoToObligationCollateralFields(obligationCollateralDto) {
43363
- return {
43364
- depositReserve: new PublicKey(obligationCollateralDto.depositReserve),
43365
- depositedAmount: new BN11(obligationCollateralDto.depositedAmount),
43366
- marketValueSf: new BN11(obligationCollateralDto.marketValueSf),
43367
- borrowedAmountAgainstThisCollateralInElevationGroup: new BN11(
43368
- obligationCollateralDto.borrowedAmountAgainstThisCollateralInElevationGroup
43369
- ),
43370
- padding: obligationCollateralDto.padding.map((item) => new BN11(item))
43371
- };
43372
- }
43373
- function dtoToObligationLiquidityFields(obligationLiquidityDto) {
43374
- return {
43375
- borrowReserve: new PublicKey(obligationLiquidityDto.borrowReserve),
43376
- cumulativeBorrowRateBsf: {
43377
- value: obligationLiquidityDto.cumulativeBorrowRateBsf.value.map(
43378
- (item) => new BN11(item)
43013
+ accumulatedReferrerFeesSf: new BN8(
43014
+ reserveDto.liquidity.accumulatedReferrerFeesSf
43379
43015
  ),
43380
- padding: obligationLiquidityDto.cumulativeBorrowRateBsf.padding.map(
43381
- (item) => new BN11(item)
43382
- )
43016
+ pendingReferrerFeesSf: new BN8(reserveDto.liquidity.pendingReferrerFeesSf)
43383
43017
  },
43384
- padding: new BN11(obligationLiquidityDto.padding),
43385
- borrowedAmountSf: new BN11(obligationLiquidityDto.borrowedAmountSf),
43386
- marketValueSf: new BN11(obligationLiquidityDto.marketValueSf),
43387
- borrowFactorAdjustedMarketValueSf: new BN11(
43388
- obligationLiquidityDto.borrowFactorAdjustedMarketValueSf
43389
- ),
43390
- borrowedAmountOutsideElevationGroups: new BN11(
43391
- obligationLiquidityDto.borrowedAmountOutsideElevationGroups
43392
- ),
43393
- padding2: obligationLiquidityDto.padding2.map((item) => new BN11(item))
43394
- };
43395
- }
43396
- function dtoToObligationOrderFields(obligationOrderDto) {
43397
- return {
43398
- conditionThresholdSf: new BN11(obligationOrderDto.conditionThresholdSf),
43399
- opportunityParameterSf: new BN11(obligationOrderDto.opportunityParameterSf),
43400
- minExecutionBonusBps: obligationOrderDto.minExecutionBonusBps,
43401
- maxExecutionBonusBps: obligationOrderDto.maxExecutionBonusBps,
43402
- conditionType: obligationOrderDto.conditionType,
43403
- opportunityType: obligationOrderDto.opportunityType,
43404
- padding1: obligationOrderDto.padding1,
43405
- padding2: obligationOrderDto.padding2.map((item) => new BN11(item))
43018
+ collateral: {
43019
+ mintPubkey: new PublicKey(reserveDto.collateral.mintPubkey),
43020
+ mintTotalSupply: new BN8(reserveDto.collateral.mintTotalSupply),
43021
+ supplyVault: new PublicKey(reserveDto.collateral.supplyVault)
43022
+ },
43023
+ config: {
43024
+ protocolTakeRatePct: reserveDto.config.protocolTakeRatePct,
43025
+ hostFixedInterestRateBps: reserveDto.config.hostFixedInterestRateBps,
43026
+ borrowRateCurve: {
43027
+ points: reserveDto.config.borrowRateCurve.points.map((item) => ({
43028
+ utilizationRateBps: item.utilizationRateBps,
43029
+ borrowRateBps: item.borrowRateBps
43030
+ }))
43031
+ },
43032
+ tokenInfo: {
43033
+ scopeConfiguration: {
43034
+ priceFeed: new PublicKey(
43035
+ reserveDto.config.tokenInfo.scopeConfiguration.priceFeed
43036
+ )
43037
+ },
43038
+ switchboardConfiguration: {
43039
+ priceAggregator: new PublicKey(
43040
+ reserveDto.config.tokenInfo.switchboardConfiguration.priceAggregator
43041
+ ),
43042
+ twapAggregator: new PublicKey(
43043
+ reserveDto.config.tokenInfo.switchboardConfiguration.twapAggregator
43044
+ )
43045
+ },
43046
+ pythConfiguration: {
43047
+ price: new PublicKey(
43048
+ reserveDto.config.tokenInfo.pythConfiguration.price
43049
+ )
43050
+ }
43051
+ }
43052
+ }
43406
43053
  };
43407
43054
  }
43408
43055
  var SEED_LENDING_MARKET_AUTH = "lma";
@@ -43469,9 +43116,9 @@ var Fraction = class _Fraction {
43469
43116
  static MAX_SIZE_BF = 256;
43470
43117
  static FRACTIONS = 60;
43471
43118
  static MULTIPLIER = new FractionDecimal(2).pow(_Fraction.FRACTIONS);
43472
- static MAX_F_BN = new BN11(2).pow(new BN11(_Fraction.MAX_SIZE_F)).sub(new BN11(1));
43473
- static MAX_BF_BN = new BN11(2).pow(new BN11(_Fraction.MAX_SIZE_BF)).sub(new BN11(1));
43474
- static MIN_BN = new BN11(0);
43119
+ static MAX_F_BN = new BN8(2).pow(new BN8(_Fraction.MAX_SIZE_F)).sub(new BN8(1));
43120
+ static MAX_BF_BN = new BN8(2).pow(new BN8(_Fraction.MAX_SIZE_BF)).sub(new BN8(1));
43121
+ static MIN_BN = new BN8(0);
43475
43122
  valueSf;
43476
43123
  constructor(valueSf) {
43477
43124
  if (valueSf.lt(_Fraction.MIN_BN) || valueSf.gt(_Fraction.MAX_BF_BN)) {
@@ -43487,7 +43134,7 @@ var Fraction = class _Fraction {
43487
43134
  static fromDecimal(n) {
43488
43135
  const scaledDecimal = new FractionDecimal(n).mul(_Fraction.MULTIPLIER);
43489
43136
  const roundedScaledDecimal = roundNearest(scaledDecimal);
43490
- const scaledValue = new BN11(roundedScaledDecimal.toFixed());
43137
+ const scaledValue = new BN8(roundedScaledDecimal.toFixed());
43491
43138
  return new _Fraction(scaledValue);
43492
43139
  }
43493
43140
  static fromBps(n) {
@@ -43517,7 +43164,7 @@ var Fraction = class _Fraction {
43517
43164
  return this.valueSf.eq(x.getValue());
43518
43165
  }
43519
43166
  };
43520
- new Fraction(new BN11(0));
43167
+ new Fraction(new BN8(0));
43521
43168
  function roundNearest(decimal) {
43522
43169
  return decimal.toDecimalPlaces(0, Decimal3.ROUND_HALF_CEIL);
43523
43170
  }
@@ -44117,29 +43764,29 @@ function decodeJupTokenReserveData(data, pubkey) {
44117
43764
  offset += 2;
44118
43765
  const lastUtilization = data.readUInt16LE(offset);
44119
43766
  offset += 2;
44120
- const lastUpdateTimestamp = new BN11(data.slice(offset, offset + 8), "le");
43767
+ const lastUpdateTimestamp = new BN8(data.slice(offset, offset + 8), "le");
44121
43768
  offset += 8;
44122
- const supplyExchangePrice = new BN11(data.slice(offset, offset + 8), "le");
43769
+ const supplyExchangePrice = new BN8(data.slice(offset, offset + 8), "le");
44123
43770
  offset += 8;
44124
- const borrowExchangePrice = new BN11(data.slice(offset, offset + 8), "le");
43771
+ const borrowExchangePrice = new BN8(data.slice(offset, offset + 8), "le");
44125
43772
  offset += 8;
44126
43773
  const maxUtilization = data.readUInt16LE(offset);
44127
43774
  offset += 2;
44128
- const totalSupplyWithInterest = new BN11(data.slice(offset, offset + 8), "le");
43775
+ const totalSupplyWithInterest = new BN8(data.slice(offset, offset + 8), "le");
44129
43776
  offset += 8;
44130
- const totalSupplyInterestFree = new BN11(data.slice(offset, offset + 8), "le");
43777
+ const totalSupplyInterestFree = new BN8(data.slice(offset, offset + 8), "le");
44131
43778
  offset += 8;
44132
- const totalBorrowWithInterest = new BN11(data.slice(offset, offset + 8), "le");
43779
+ const totalBorrowWithInterest = new BN8(data.slice(offset, offset + 8), "le");
44133
43780
  offset += 8;
44134
- const totalBorrowInterestFree = new BN11(data.slice(offset, offset + 8), "le");
43781
+ const totalBorrowInterestFree = new BN8(data.slice(offset, offset + 8), "le");
44135
43782
  offset += 8;
44136
- const totalClaimAmount = new BN11(data.slice(offset, offset + 8), "le");
43783
+ const totalClaimAmount = new BN8(data.slice(offset, offset + 8), "le");
44137
43784
  offset += 8;
44138
43785
  const interactingProtocol = new PublicKey(data.slice(offset, offset + 32));
44139
43786
  offset += 32;
44140
- const interactingTimestamp = new BN11(data.slice(offset, offset + 8), "le");
43787
+ const interactingTimestamp = new BN8(data.slice(offset, offset + 8), "le");
44141
43788
  offset += 8;
44142
- const interactingBalance = new BN11(data.slice(offset, offset + 8), "le");
43789
+ const interactingBalance = new BN8(data.slice(offset, offset + 8), "le");
44143
43790
  return {
44144
43791
  pubkey,
44145
43792
  mint,
@@ -44201,9 +43848,9 @@ function dtoToJupLendingStateRaw(dto) {
44201
43848
  lendingId: dto.lendingId,
44202
43849
  decimals: dto.decimals,
44203
43850
  rewardsRateModel: new PublicKey(dto.rewardsRateModel),
44204
- liquidityExchangePrice: new BN11(dto.liquidityExchangePrice),
44205
- tokenExchangePrice: new BN11(dto.tokenExchangePrice),
44206
- lastUpdateTimestamp: new BN11(dto.lastUpdateTimestamp),
43851
+ liquidityExchangePrice: new BN8(dto.liquidityExchangePrice),
43852
+ tokenExchangePrice: new BN8(dto.tokenExchangePrice),
43853
+ lastUpdateTimestamp: new BN8(dto.lastUpdateTimestamp),
44207
43854
  tokenReservesLiquidity: new PublicKey(dto.tokenReservesLiquidity),
44208
43855
  supplyPositionOnLiquidity: new PublicKey(dto.supplyPositionOnLiquidity)
44209
43856
  };
@@ -44216,30 +43863,30 @@ function dtoToJupTokenReserveRaw(dto) {
44216
43863
  borrowRate: dto.borrowRate,
44217
43864
  feeOnInterest: dto.feeOnInterest,
44218
43865
  lastUtilization: dto.lastUtilization,
44219
- lastUpdateTimestamp: new BN11(dto.lastUpdateTimestamp),
44220
- supplyExchangePrice: new BN11(dto.supplyExchangePrice),
44221
- borrowExchangePrice: new BN11(dto.borrowExchangePrice),
43866
+ lastUpdateTimestamp: new BN8(dto.lastUpdateTimestamp),
43867
+ supplyExchangePrice: new BN8(dto.supplyExchangePrice),
43868
+ borrowExchangePrice: new BN8(dto.borrowExchangePrice),
44222
43869
  maxUtilization: dto.maxUtilization,
44223
- totalSupplyWithInterest: new BN11(dto.totalSupplyWithInterest),
44224
- totalSupplyInterestFree: new BN11(dto.totalSupplyInterestFree),
44225
- totalBorrowWithInterest: new BN11(dto.totalBorrowWithInterest),
44226
- totalBorrowInterestFree: new BN11(dto.totalBorrowInterestFree),
44227
- totalClaimAmount: new BN11(dto.totalClaimAmount),
43870
+ totalSupplyWithInterest: new BN8(dto.totalSupplyWithInterest),
43871
+ totalSupplyInterestFree: new BN8(dto.totalSupplyInterestFree),
43872
+ totalBorrowWithInterest: new BN8(dto.totalBorrowWithInterest),
43873
+ totalBorrowInterestFree: new BN8(dto.totalBorrowInterestFree),
43874
+ totalClaimAmount: new BN8(dto.totalClaimAmount),
44228
43875
  interactingProtocol: new PublicKey(dto.interactingProtocol),
44229
- interactingTimestamp: new BN11(dto.interactingTimestamp),
44230
- interactingBalance: new BN11(dto.interactingBalance)
43876
+ interactingTimestamp: new BN8(dto.interactingTimestamp),
43877
+ interactingBalance: new BN8(dto.interactingBalance)
44231
43878
  };
44232
43879
  }
44233
43880
  function dtoToJupLendingRewardsRateModelRaw(dto) {
44234
43881
  return {
44235
43882
  pubkey: new PublicKey(dto.pubkey),
44236
43883
  mint: new PublicKey(dto.mint),
44237
- startTvl: new BN11(dto.startTvl),
44238
- duration: new BN11(dto.duration),
44239
- startTime: new BN11(dto.startTime),
44240
- yearlyReward: new BN11(dto.yearlyReward),
44241
- nextDuration: new BN11(dto.nextDuration),
44242
- nextRewardAmount: new BN11(dto.nextRewardAmount)
43884
+ startTvl: new BN8(dto.startTvl),
43885
+ duration: new BN8(dto.duration),
43886
+ startTime: new BN8(dto.startTime),
43887
+ yearlyReward: new BN8(dto.yearlyReward),
43888
+ nextDuration: new BN8(dto.nextDuration),
43889
+ nextRewardAmount: new BN8(dto.nextRewardAmount)
44243
43890
  };
44244
43891
  }
44245
43892
  function dtoToJupRateModelRaw(dto) {
@@ -44330,14 +43977,14 @@ function deriveJupLendLiquiditySupplyPositionPda(underlyingMint, lendingPda, liq
44330
43977
  liquidityProgramId
44331
43978
  );
44332
43979
  }
44333
- var JUP_EXCHANGE_PRICES_PRECISION = new BN11("1000000000000");
44334
- var JUP_SECONDS_PER_YEAR = new BN11(31536e3);
44335
- var JUP_MAX_REWARDS_RATE = new BN11("50000000000000");
43980
+ var JUP_EXCHANGE_PRICES_PRECISION = new BN8("1000000000000");
43981
+ var JUP_SECONDS_PER_YEAR = new BN8(31536e3);
43982
+ var JUP_MAX_REWARDS_RATE = new BN8("50000000000000");
44336
43983
  function calculateJupLendTotalAssets(lendingState, fTokenTotalSupply) {
44337
43984
  return lendingState.tokenExchangePrice.mul(fTokenTotalSupply).div(JUP_EXCHANGE_PRICES_PRECISION);
44338
43985
  }
44339
43986
  function calculateJupLendRewardsRateForExchangePrice(rewardsModel, totalAssets, currentTimestamp) {
44340
- const defaultResult = { rate: new BN11(0), rewardsStartTime: rewardsModel.startTime };
43987
+ const defaultResult = { rate: new BN8(0), rewardsStartTime: rewardsModel.startTime };
44341
43988
  if (rewardsModel.startTime.isZero() || rewardsModel.duration.isZero()) {
44342
43989
  return defaultResult;
44343
43990
  }
@@ -44357,7 +44004,7 @@ function calculateJupLendNewExchangePrice(lendingState, tokenReserve, rewardsMod
44357
44004
  const oldTokenExchangePrice = lendingState.tokenExchangePrice;
44358
44005
  const oldLiquidityExchangePrice = lendingState.liquidityExchangePrice;
44359
44006
  const currentLiquidityExchangePrice = tokenReserve.supplyExchangePrice;
44360
- let rewardsRate = new BN11(0);
44007
+ let rewardsRate = new BN8(0);
44361
44008
  let rewardsStartTime = lendingState.lastUpdateTimestamp;
44362
44009
  if (rewardsModel) {
44363
44010
  const totalAssets = calculateJupLendTotalAssets(lendingState, fTokenTotalSupply);
@@ -44374,12 +44021,12 @@ function calculateJupLendNewExchangePrice(lendingState, tokenReserve, rewardsMod
44374
44021
  lastUpdateTime = rewardsStartTime;
44375
44022
  }
44376
44023
  const secondsElapsed = currentTimestamp.sub(lastUpdateTime);
44377
- let totalReturnPercent = rewardsRate.mul(secondsElapsed).div(JUP_SECONDS_PER_YEAR).mul(new BN11(100));
44024
+ let totalReturnPercent = rewardsRate.mul(secondsElapsed).div(JUP_SECONDS_PER_YEAR).mul(new BN8(100));
44378
44025
  const delta = currentLiquidityExchangePrice.sub(oldLiquidityExchangePrice);
44379
44026
  totalReturnPercent = totalReturnPercent.add(
44380
- delta.mul(new BN11(1e14)).div(oldLiquidityExchangePrice)
44027
+ delta.mul(new BN8(1e14)).div(oldLiquidityExchangePrice)
44381
44028
  );
44382
- return oldTokenExchangePrice.add(oldTokenExchangePrice.mul(totalReturnPercent).div(new BN11(1e14)));
44029
+ return oldTokenExchangePrice.add(oldTokenExchangePrice.mul(totalReturnPercent).div(new BN8(1e14)));
44383
44030
  }
44384
44031
  var UPDATE_RATE_DISCRIMINATOR = Buffer.from([
44385
44032
  24,
@@ -57860,7 +57507,7 @@ function exponentNumberToBigNumber(raw) {
57860
57507
  let value = new BigNumber(0);
57861
57508
  const TWO_64 = new BigNumber(2).pow(64);
57862
57509
  words.forEach((w, i) => {
57863
- const word = new BigNumber(BN11.isBN(w) ? w.toString() : String(w));
57510
+ const word = new BigNumber(BN8.isBN(w) ? w.toString() : String(w));
57864
57511
  value = value.plus(word.times(TWO_64.pow(i)));
57865
57512
  });
57866
57513
  return value.div(EXPONENT_NUMBER_DENOM);
@@ -57871,7 +57518,7 @@ function pk(v) {
57871
57518
  function decodeExponentVault(data) {
57872
57519
  const d = EXPONENT_ACCOUNTS_CODER.decode("Vault", data);
57873
57520
  const get = (snake, camel) => d[snake] ?? d[camel];
57874
- const u646 = (v) => BigInt(BN11.isBN(v) ? v.toString() : String(v ?? 0));
57521
+ const u646 = (v) => BigInt(BN8.isBN(v) ? v.toString() : String(v ?? 0));
57875
57522
  const cpi = get("cpi_accounts", "cpiAccounts") ?? {};
57876
57523
  return {
57877
57524
  authority: pk(get("authority", "authority")),
@@ -58218,76 +57865,25 @@ function scaledSupplies(state) {
58218
57865
  }
58219
57866
 
58220
57867
  // src/vendor/klend/utils/farms/serialize.utils.ts
58221
- function farmRawToDto(farmRaw) {
57868
+ function kaminoFarmStateToDto(farmState) {
58222
57869
  return {
58223
- farmAdmin: farmRaw.farmAdmin.toBase58(),
58224
- globalConfig: farmRaw.globalConfig.toBase58(),
58225
57870
  token: {
58226
- mint: farmRaw.token.mint.toBase58(),
58227
- decimals: farmRaw.token.decimals.toString(),
58228
- tokenProgram: farmRaw.token.tokenProgram.toBase58(),
58229
- padding: farmRaw.token.padding.map((p) => p.toString())
57871
+ mint: farmState.token.mint.toBase58(),
57872
+ decimals: farmState.token.decimals.toString()
58230
57873
  },
58231
- rewardInfos: farmRaw.rewardInfos.map((item) => ({
57874
+ rewardInfos: farmState.rewardInfos.map((item) => ({
58232
57875
  token: {
58233
57876
  mint: item.token.mint.toBase58(),
58234
- decimals: item.token.decimals.toString(),
58235
- tokenProgram: item.token.tokenProgram.toBase58(),
58236
- padding: item.token.padding.map((p) => p.toString())
57877
+ decimals: item.token.decimals.toString()
58237
57878
  },
58238
- rewardsVault: item.rewardsVault.toBase58(),
58239
- rewardsAvailable: item.rewardsAvailable.toString(),
57879
+ rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
58240
57880
  rewardScheduleCurve: {
58241
57881
  points: item.rewardScheduleCurve.points.map((p) => ({
58242
57882
  tsStart: p.tsStart.toString(),
58243
57883
  rewardPerTimeUnit: p.rewardPerTimeUnit.toString()
58244
57884
  }))
58245
- },
58246
- minClaimDurationSeconds: item.minClaimDurationSeconds.toString(),
58247
- lastIssuanceTs: item.lastIssuanceTs.toString(),
58248
- rewardsIssuedUnclaimed: item.rewardsIssuedUnclaimed.toString(),
58249
- rewardsIssuedCumulative: item.rewardsIssuedCumulative.toString(),
58250
- rewardPerShareScaled: item.rewardPerShareScaled.toString(),
58251
- placeholder0: item.placeholder0.toString(),
58252
- rewardType: item.rewardType,
58253
- rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
58254
- padding0: item.padding0,
58255
- padding1: item.padding1.map((p) => p.toString())
58256
- })),
58257
- numRewardTokens: farmRaw.numRewardTokens.toString(),
58258
- numUsers: farmRaw.numUsers.toString(),
58259
- totalStakedAmount: farmRaw.totalStakedAmount.toString(),
58260
- farmVault: farmRaw.farmVault.toBase58(),
58261
- farmVaultsAuthority: farmRaw.farmVaultsAuthority.toBase58(),
58262
- farmVaultsAuthorityBump: farmRaw.farmVaultsAuthorityBump.toString(),
58263
- delegateAuthority: farmRaw.delegateAuthority.toBase58(),
58264
- timeUnit: farmRaw.timeUnit,
58265
- isFarmFrozen: farmRaw.isFarmFrozen,
58266
- isFarmDelegated: farmRaw.isFarmDelegated,
58267
- padding0: farmRaw.padding0,
58268
- withdrawAuthority: farmRaw.withdrawAuthority.toBase58(),
58269
- depositWarmupPeriod: farmRaw.depositWarmupPeriod,
58270
- withdrawalCooldownPeriod: farmRaw.withdrawalCooldownPeriod,
58271
- totalActiveStakeScaled: farmRaw.totalActiveStakeScaled.toString(),
58272
- totalPendingStakeScaled: farmRaw.totalPendingStakeScaled.toString(),
58273
- totalPendingAmount: farmRaw.totalPendingAmount.toString(),
58274
- slashedAmountCurrent: farmRaw.slashedAmountCurrent.toString(),
58275
- slashedAmountCumulative: farmRaw.slashedAmountCumulative.toString(),
58276
- slashedAmountSpillAddress: farmRaw.slashedAmountSpillAddress.toBase58(),
58277
- lockingMode: farmRaw.lockingMode.toString(),
58278
- lockingStartTimestamp: farmRaw.lockingStartTimestamp.toString(),
58279
- lockingDuration: farmRaw.lockingDuration.toString(),
58280
- lockingEarlyWithdrawalPenaltyBps: farmRaw.lockingEarlyWithdrawalPenaltyBps.toString(),
58281
- depositCapAmount: farmRaw.depositCapAmount.toString(),
58282
- scopePrices: farmRaw.scopePrices.toBase58(),
58283
- scopeOraclePriceId: farmRaw.scopeOraclePriceId.toString(),
58284
- scopeOracleMaxAge: farmRaw.scopeOracleMaxAge.toString(),
58285
- pendingFarmAdmin: farmRaw.pendingFarmAdmin.toBase58(),
58286
- strategyId: farmRaw.strategyId.toBase58(),
58287
- delegatedRpsAdmin: farmRaw.delegatedRpsAdmin.toBase58(),
58288
- vaultId: farmRaw.vaultId.toBase58(),
58289
- secondDelegatedAuthority: farmRaw.secondDelegatedAuthority.toBase58(),
58290
- padding: farmRaw.padding.map((item) => item.toString())
57885
+ }
57886
+ }))
58291
57887
  };
58292
57888
  }
58293
57889
  var farmDiscriminator = Buffer.from([198, 102, 216, 74, 63, 66, 163, 190]);
@@ -58382,78 +57978,25 @@ function decodeFarmDataRaw(data) {
58382
57978
  const dec = farmLayout.decode(data.slice(8));
58383
57979
  return dec;
58384
57980
  }
58385
- function dtoToFarmRaw(dto) {
57981
+ function dtoToKaminoFarmState(dto) {
58386
57982
  return {
58387
- farmAdmin: new PublicKey(dto.farmAdmin),
58388
- globalConfig: new PublicKey(dto.globalConfig),
58389
57983
  token: {
58390
57984
  mint: new PublicKey(dto.token.mint),
58391
- decimals: new BN11(dto.token.decimals),
58392
- tokenProgram: new PublicKey(dto.token.tokenProgram),
58393
- padding: dto.token.padding.map((item) => new BN11(item))
57985
+ decimals: new BN8(dto.token.decimals)
58394
57986
  },
58395
57987
  rewardInfos: dto.rewardInfos.map((item) => ({
58396
57988
  token: {
58397
57989
  mint: new PublicKey(item.token.mint),
58398
- decimals: new BN11(item.token.decimals),
58399
- tokenProgram: new PublicKey(item.token.tokenProgram),
58400
- padding: item.token.padding.map((p) => new BN11(p))
57990
+ decimals: new BN8(item.token.decimals)
58401
57991
  },
58402
- rewardsVault: new PublicKey(item.rewardsVault),
58403
- rewardsAvailable: new BN11(item.rewardsAvailable),
57992
+ rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
58404
57993
  rewardScheduleCurve: {
58405
57994
  points: item.rewardScheduleCurve.points.map((p) => ({
58406
- tsStart: new BN11(p.tsStart),
58407
- rewardPerTimeUnit: new BN11(p.rewardPerTimeUnit)
57995
+ tsStart: new BN8(p.tsStart),
57996
+ rewardPerTimeUnit: new BN8(p.rewardPerTimeUnit)
58408
57997
  }))
58409
- },
58410
- minClaimDurationSeconds: new BN11(item.minClaimDurationSeconds),
58411
- lastIssuanceTs: new BN11(item.lastIssuanceTs),
58412
- rewardsIssuedUnclaimed: new BN11(item.rewardsIssuedUnclaimed),
58413
- rewardsIssuedCumulative: new BN11(item.rewardsIssuedCumulative),
58414
- rewardPerShareScaled: new BN11(item.rewardPerShareScaled),
58415
- placeholder0: new BN11(item.placeholder0),
58416
- rewardType: item.rewardType,
58417
- rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
58418
- padding0: item.padding0,
58419
- padding1: item.padding1.map((p) => new BN11(p))
58420
- })),
58421
- numRewardTokens: new BN11(dto.numRewardTokens),
58422
- numUsers: new BN11(dto.numUsers),
58423
- totalStakedAmount: new BN11(dto.totalStakedAmount),
58424
- farmVault: new PublicKey(dto.farmVault),
58425
- farmVaultsAuthority: new PublicKey(dto.farmVaultsAuthority),
58426
- farmVaultsAuthorityBump: new BN11(dto.farmVaultsAuthorityBump),
58427
- delegateAuthority: new PublicKey(dto.delegateAuthority),
58428
- timeUnit: dto.timeUnit,
58429
- isFarmFrozen: dto.isFarmFrozen,
58430
- isFarmDelegated: dto.isFarmDelegated,
58431
- padding0: dto.padding0,
58432
- withdrawAuthority: new PublicKey(dto.withdrawAuthority),
58433
- depositWarmupPeriod: dto.depositWarmupPeriod,
58434
- withdrawalCooldownPeriod: dto.withdrawalCooldownPeriod,
58435
- totalActiveStakeScaled: new BN11(dto.totalActiveStakeScaled),
58436
- totalPendingStakeScaled: new BN11(dto.totalPendingStakeScaled),
58437
- totalPendingAmount: new BN11(dto.totalPendingAmount),
58438
- slashedAmountCurrent: new BN11(dto.slashedAmountCurrent),
58439
- slashedAmountCumulative: new BN11(dto.slashedAmountCumulative),
58440
- slashedAmountSpillAddress: new PublicKey(dto.slashedAmountSpillAddress),
58441
- lockingMode: new BN11(dto.lockingMode),
58442
- lockingStartTimestamp: new BN11(dto.lockingStartTimestamp),
58443
- lockingDuration: new BN11(dto.lockingDuration),
58444
- lockingEarlyWithdrawalPenaltyBps: new BN11(
58445
- dto.lockingEarlyWithdrawalPenaltyBps
58446
- ),
58447
- depositCapAmount: new BN11(dto.depositCapAmount),
58448
- scopePrices: new PublicKey(dto.scopePrices),
58449
- scopeOraclePriceId: new BN11(dto.scopeOraclePriceId),
58450
- scopeOracleMaxAge: new BN11(dto.scopeOracleMaxAge),
58451
- pendingFarmAdmin: new PublicKey(dto.pendingFarmAdmin),
58452
- strategyId: new PublicKey(dto.strategyId),
58453
- delegatedRpsAdmin: new PublicKey(dto.delegatedRpsAdmin),
58454
- vaultId: new PublicKey(dto.vaultId),
58455
- secondDelegatedAuthority: new PublicKey(dto.secondDelegatedAuthority),
58456
- padding: dto.padding.map((item) => new BN11(item))
57998
+ }
57999
+ }))
58457
58000
  };
58458
58001
  }
58459
58002
  var KAMINO_PROGRAM_ID = new PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD");
@@ -59128,7 +58671,7 @@ function makePoolAddPermissionlessStakedBankIx2(programId, accounts, remainingAc
59128
58671
  keys.push(...remainingAccounts);
59129
58672
  const data = Buffer.concat([
59130
58673
  DISCRIMINATORS.LENDING_POOL_ADD_BANK_PERMISSIONLESS,
59131
- encodeU64(args.seed || new BN11(0))
58674
+ encodeU64(args.seed || new BN8(0))
59132
58675
  ]);
59133
58676
  return new TransactionInstruction({
59134
58677
  keys,
@@ -60632,7 +60175,7 @@ function deserializeSwapEngineResult(s) {
60632
60175
  setupInstructions: s.setupInstructions.map(deserializeInstruction),
60633
60176
  swapLuts: s.swapLuts.map(deserializeLut),
60634
60177
  quoteResponse: s.quoteResponse,
60635
- outputAmountNative: new BN11(s.outputAmountNative),
60178
+ outputAmountNative: new BN8(s.outputAmountNative),
60636
60179
  provider: s.provider
60637
60180
  };
60638
60181
  }
@@ -61431,8 +60974,8 @@ async function buildCandidates(req, apiConfig) {
61431
60974
  swapInstructions: [deserializeJupiterInstruction2(build.swapInstruction)],
61432
60975
  setupInstructions: (build.setupInstructions ?? []).map(deserializeJupiterInstruction2),
61433
60976
  luts,
61434
- outAmountNative: new BN11(build.outAmount),
61435
- otherAmountThresholdNative: new BN11(build.otherAmountThreshold),
60977
+ outAmountNative: new BN8(build.outAmount),
60978
+ otherAmountThresholdNative: new BN8(build.otherAmountThreshold),
61436
60979
  quoteResult: mapBuildToQuoteResult(build),
61437
60980
  label: `jupiter:maxAccounts=${maxAccounts}`
61438
60981
  };
@@ -61529,8 +61072,8 @@ async function buildCandidates2(req, apiConfig) {
61529
61072
  swapInstructions,
61530
61073
  setupInstructions: [],
61531
61074
  luts,
61532
- outAmountNative: new BN11(quote.outAmount),
61533
- otherAmountThresholdNative: new BN11(quote.otherAmountThreshold),
61075
+ outAmountNative: new BN8(quote.outAmount),
61076
+ otherAmountThresholdNative: new BN8(quote.otherAmountThreshold),
61534
61077
  quoteResult: { ...quote, provider: "TITAN" /* TITAN */ },
61535
61078
  label: "titan:v3"
61536
61079
  }
@@ -61586,14 +61129,14 @@ async function makeBeginFlashLoanIx3(program, marginfiAccountPk, endIndex, autho
61586
61129
  marginfiAccount: marginfiAccountPk,
61587
61130
  authority
61588
61131
  },
61589
- { endIndex: new BN11(endIndex) }
61132
+ { endIndex: new BN8(endIndex) }
61590
61133
  ) : await instructions_default.makeBeginFlashLoanIx(
61591
61134
  program,
61592
61135
  {
61593
61136
  marginfiAccount: marginfiAccountPk,
61594
61137
  authority
61595
61138
  },
61596
- { endIndex: new BN11(endIndex) }
61139
+ { endIndex: new BN8(endIndex) }
61597
61140
  );
61598
61141
  return { instructions: [ix], keys: [] };
61599
61142
  }
@@ -62159,6 +61702,7 @@ async function buildRepayWithCollatFlashloanTx({
62159
61702
  // src/services/account/utils/flashloan-size.utils.ts
62160
61703
  var SWAP_MERGE_OVERHEAD = 150;
62161
61704
  var FL_IX_OVERHEAD = 52;
61705
+ var OVERSIZED_TX_SENTINEL = MAX_TX_SIZE * 4;
62162
61706
  function compactU16Size(n) {
62163
61707
  return n < 128 ? 1 : n < 16384 ? 2 : 3;
62164
61708
  }
@@ -62271,7 +61815,7 @@ function computeFlashLoanNonSwapBudget({
62271
61815
  const beginFlIx = sync_instructions_default.makeBeginFlashLoanIx(
62272
61816
  program.programId,
62273
61817
  { marginfiAccount: marginfiAccount.address, authority: marginfiAccount.authority },
62274
- { endIndex: new BN11(endIndex) }
61818
+ { endIndex: new BN8(endIndex) }
62275
61819
  );
62276
61820
  const endFlRemainingAccounts = computeHealthAccountMetas(projectedActiveBanks);
62277
61821
  const endFlIx = sync_instructions_default.makeEndFlashLoanIx(
@@ -62315,7 +61859,13 @@ function compileFlashloanPrecheck({
62315
61859
  recentBlockhash: PublicKey.default.toBase58(),
62316
61860
  instructions: allIxs
62317
61861
  }).compileToV0Message(luts);
62318
- const rawSize = new VersionedTransaction(msg).serialize().length;
61862
+ let rawSize;
61863
+ try {
61864
+ rawSize = new VersionedTransaction(msg).serialize().length;
61865
+ } catch (e) {
61866
+ if (!(e instanceof RangeError)) throw e;
61867
+ rawSize = OVERSIZED_TX_SENTINEL;
61868
+ }
62319
61869
  const fullTxSize = rawSize + FL_IX_OVERHEAD;
62320
61870
  const overshoot = fullTxSize - MAX_TX_SIZE;
62321
61871
  const { header, staticAccountKeys, addressTableLookups } = msg;
@@ -62844,7 +62394,7 @@ async function buildLoopFlashloanTx(params) {
62844
62394
  const engineResult = await runLoopSwapEngine(descriptor, params);
62845
62395
  const finalIxs = [...descriptor.innerIxs];
62846
62396
  finalIxs.splice(descriptor.swapSlotIndex, 0, ...engineResult.swapInstructions);
62847
- const principalNative = depositOpts.loopMode === "DEPOSIT" ? uiToNative(depositOpts.inputDepositAmount, depositOpts.depositBank.mintDecimals) : new BN11(0);
62397
+ const principalNative = depositOpts.loopMode === "DEPOSIT" ? uiToNative(depositOpts.inputDepositAmount, depositOpts.depositBank.mintDecimals) : new BN8(0);
62848
62398
  const finalDepositNative = engineResult.outputAmountNative.add(principalNative);
62849
62399
  const depositIxPosition = descriptor.depositIxIndex + engineResult.swapInstructions.length;
62850
62400
  patchDepositAmount(finalIxs[depositIxPosition], finalDepositNative);
@@ -63056,7 +62606,7 @@ async function runLoopSwapEngine(descriptor, params) {
63056
62606
  otherAmountThreshold: "0",
63057
62607
  slippageBps: 0
63058
62608
  },
63059
- outputAmountNative: new BN11(0)
62609
+ outputAmountNative: new BN8(0)
63060
62610
  };
63061
62611
  }
63062
62612
  const runEngine = swapEngineRunner ?? runSwapEngine;
@@ -64077,7 +63627,7 @@ async function buildRollPtFlashloanTx({
64077
63627
  if (!depositIxToPatch) {
64078
63628
  throw new Error("roll-pt: could not locate deposit instruction for amount patching");
64079
63629
  }
64080
- patchDepositAmount(depositIxToPatch, new BN11(minPtOut.toString()));
63630
+ patchDepositAmount(depositIxToPatch, new BN8(minPtOut.toString()));
64081
63631
  const allNonFlIxs = [
64082
63632
  ...cuRequestIxs,
64083
63633
  ...withdrawIxs.instructions,
@@ -65315,7 +64865,7 @@ function composeBundle(firstLegTxs, secondLegTxs, payer, blockhash, maxBundleTxs
65315
64865
  if (result.length > maxBundleTxs) return null;
65316
64866
  return result;
65317
64867
  }
65318
- function mergeBridgeQuotes(firstLeg, secondLeg) {
64868
+ function compoundQuoteRisk(firstLeg, secondLeg) {
65319
64869
  const compound = (a, b) => {
65320
64870
  if (a == null && b == null) return void 0;
65321
64871
  const x = Number(a ?? 0);
@@ -65323,13 +64873,36 @@ function mergeBridgeQuotes(firstLeg, secondLeg) {
65323
64873
  return String(1 - (1 - x) * (1 - y));
65324
64874
  };
65325
64875
  return {
65326
- inAmount: firstLeg.inAmount,
65327
- outAmount: secondLeg.outAmount,
65328
- otherAmountThreshold: secondLeg.otherAmountThreshold,
65329
64876
  slippageBps: Math.round(
65330
64877
  (1 - (1 - firstLeg.slippageBps / 1e4) * (1 - secondLeg.slippageBps / 1e4)) * 1e4
65331
64878
  ),
65332
- priceImpactPct: compound(firstLeg.priceImpactPct, secondLeg.priceImpactPct),
64879
+ priceImpactPct: compound(firstLeg.priceImpactPct, secondLeg.priceImpactPct)
64880
+ };
64881
+ }
64882
+ function mergeBridgeQuotes(firstLeg, secondLeg) {
64883
+ return {
64884
+ inAmount: firstLeg.inAmount,
64885
+ outAmount: secondLeg.outAmount,
64886
+ otherAmountThreshold: secondLeg.otherAmountThreshold,
64887
+ ...compoundQuoteRisk(firstLeg, secondLeg),
64888
+ provider: firstLeg.provider
64889
+ };
64890
+ }
64891
+ function mergeBridgeQuotesDebt(firstLeg, secondLeg) {
64892
+ return {
64893
+ inAmount: firstLeg.outAmount,
64894
+ outAmount: secondLeg.inAmount,
64895
+ otherAmountThreshold: secondLeg.inAmount,
64896
+ ...compoundQuoteRisk(firstLeg, secondLeg),
64897
+ provider: firstLeg.provider
64898
+ };
64899
+ }
64900
+ function mergeBridgeQuotesLoop(firstLeg, secondLeg) {
64901
+ return {
64902
+ inAmount: secondLeg.inAmount,
64903
+ outAmount: firstLeg.outAmount,
64904
+ otherAmountThreshold: firstLeg.otherAmountThreshold,
64905
+ ...compoundQuoteRisk(firstLeg, secondLeg),
65333
64906
  provider: firstLeg.provider
65334
64907
  };
65335
64908
  }
@@ -66118,6 +65691,33 @@ function patchDepositAmount(ix, amountNative) {
66118
65691
  amountNative.toArrayLike(Buffer, "le", 8).copy(ix.data, DEPOSIT_AMOUNT_OFFSET);
66119
65692
  }
66120
65693
 
65694
+ // src/services/account/utils/bridge.utils.ts
65695
+ function accountConflictsWithBridge(account, bankPk, side) {
65696
+ const balance = account.balances.find((b) => b.active && b.bankPk.equals(bankPk));
65697
+ if (!balance) return false;
65698
+ return side === "deposit" ? balance.liabilityShares.gt(0) : balance.assetShares.gt(0);
65699
+ }
65700
+ function resolveBridgeBanks(params) {
65701
+ const { orderedBridgeMints, banks, marginfiAccount, side } = params;
65702
+ const passesSideFilter = side === "borrow" ? isStandardBorrowable : isStandardDepositable;
65703
+ const bridges = [];
65704
+ const conflicts = [];
65705
+ const seenMints = /* @__PURE__ */ new Set();
65706
+ for (const mint of orderedBridgeMints) {
65707
+ const mintKey = mint.toBase58();
65708
+ if (seenMints.has(mintKey)) continue;
65709
+ seenMints.add(mintKey);
65710
+ const bank = banks.find((b) => b.mint.equals(mint) && passesSideFilter(b));
65711
+ if (!bank) continue;
65712
+ if (accountConflictsWithBridge(marginfiAccount, bank.address, side)) {
65713
+ conflicts.push(bank);
65714
+ } else {
65715
+ bridges.push(bank);
65716
+ }
65717
+ }
65718
+ return { bridges, conflicts };
65719
+ }
65720
+
66121
65721
  // src/services/price/utils/smart-crank.utils.ts
66122
65722
  async function computeSmartCrank({
66123
65723
  marginfiAccount,
@@ -66577,9 +66177,9 @@ function dtoToBankMetadataMap(bankMetadataDto) {
66577
66177
  function dtoToBankMetadata(bankMetadataDto) {
66578
66178
  return {
66579
66179
  kaminoStates: bankMetadataDto.kaminoStates ? {
66580
- reserveState: dtoToReserveRaw(bankMetadataDto.kaminoStates.reserveState),
66581
- obligationState: dtoToObligationRaw(bankMetadataDto.kaminoStates.obligationState),
66582
- farmState: bankMetadataDto.kaminoStates.farmState ? dtoToFarmRaw(bankMetadataDto.kaminoStates.farmState) : void 0
66180
+ reserveState: dtoToKaminoReserve(bankMetadataDto.kaminoStates.reserveState),
66181
+ obligationState: dtoToKaminoObligation(bankMetadataDto.kaminoStates.obligationState),
66182
+ farmState: bankMetadataDto.kaminoStates.farmState ? dtoToKaminoFarmState(bankMetadataDto.kaminoStates.farmState) : void 0
66583
66183
  } : void 0,
66584
66184
  driftStates: bankMetadataDto.driftStates ? {
66585
66185
  spotMarketState: dtoToDriftSpotMarketRaw(bankMetadataDto.driftStates.spotMarketState),
@@ -66594,16 +66194,16 @@ function dtoToBankMetadata(bankMetadataDto) {
66594
66194
  ),
66595
66195
  jupRewardsRateModel: bankMetadataDto.jupLendStates.jupRewardsRateModel ? dtoToJupLendingRewardsRateModelRaw(bankMetadataDto.jupLendStates.jupRewardsRateModel) : null,
66596
66196
  jupRateModel: bankMetadataDto.jupLendStates.jupRateModel ? dtoToJupRateModelRaw(bankMetadataDto.jupLendStates.jupRateModel) : null,
66597
- fTokenTotalSupply: new BN11(bankMetadataDto.jupLendStates.fTokenTotalSupply)
66197
+ fTokenTotalSupply: new BN8(bankMetadataDto.jupLendStates.fTokenTotalSupply)
66598
66198
  } : void 0
66599
66199
  };
66600
66200
  }
66601
66201
  function bankMetadataToDto(bankMetadata) {
66602
66202
  return {
66603
66203
  kaminoStates: bankMetadata.kaminoStates ? {
66604
- reserveState: reserveRawToDto(bankMetadata.kaminoStates.reserveState),
66605
- obligationState: obligationRawToDto(bankMetadata.kaminoStates.obligationState),
66606
- farmState: bankMetadata.kaminoStates.farmState ? farmRawToDto(bankMetadata.kaminoStates.farmState) : void 0
66204
+ reserveState: kaminoReserveToDto(bankMetadata.kaminoStates.reserveState),
66205
+ obligationState: kaminoObligationToDto(bankMetadata.kaminoStates.obligationState),
66206
+ farmState: bankMetadata.kaminoStates.farmState ? kaminoFarmStateToDto(bankMetadata.kaminoStates.farmState) : void 0
66607
66207
  } : void 0,
66608
66208
  driftStates: bankMetadata.driftStates ? {
66609
66209
  spotMarketState: driftSpotMarketRawToDto(bankMetadata.driftStates.spotMarketState),
@@ -66912,8 +66512,8 @@ var fetchSwbOracleData = async (banks, opts) => {
66912
66512
  const brokenSwbFeeds = [];
66913
66513
  Object.keys(swbOracleAiDataByKey).forEach((oracleKey) => {
66914
66514
  const oracleAiData = swbOracleAiDataByKey[oracleKey];
66915
- const rawPriceBN = new BN11(oracleAiData.rawPrice);
66916
- const isFeedBroken = rawPriceBN.isZero() || rawPriceBN.eq(new BN11(1e-6)) || rawPriceBN.eq(new BN11(1e-8));
66515
+ const rawPriceBN = new BN8(oracleAiData.rawPrice);
66516
+ const isFeedBroken = rawPriceBN.isZero() || rawPriceBN.eq(new BN8(1e-6)) || rawPriceBN.eq(new BN8(1e-8));
66917
66517
  if (isFeedBroken) {
66918
66518
  const bank = switchboardBanks.find(
66919
66519
  (bank2) => bank2.config.oracleKeys[0].toBase58() === oracleKey
@@ -67618,6 +67218,14 @@ function computeRemainingCapacity(bank) {
67618
67218
  }
67619
67219
 
67620
67220
  // src/services/bank/utils/bank-metrics.utils.ts
67221
+ function isStandardBorrowable(bank) {
67222
+ const { assetTag, operationalState, borrowLimit } = bank.config;
67223
+ return (assetTag === 0 /* DEFAULT */ || assetTag === 1 /* SOL */) && operationalState === "Operational" /* Operational */ && borrowLimit.gt(0);
67224
+ }
67225
+ function isStandardDepositable(bank) {
67226
+ const { assetTag, operationalState } = bank.config;
67227
+ return (assetTag === 0 /* DEFAULT */ || assetTag === 1 /* SOL */) && operationalState === "Operational" /* Operational */;
67228
+ }
67621
67229
  function computeBankTotalDeposits(bank, assetShareValueMultiplier) {
67622
67230
  const totalAssets = getTotalAssetQuantity(bank).times(
67623
67231
  assetShareValueMultiplier ?? 1
@@ -67804,7 +67412,7 @@ async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddr
67804
67412
  isWritable: false
67805
67413
  })),
67806
67414
  {
67807
- seed: new BN11(0)
67415
+ seed: new BN8(0)
67808
67416
  }
67809
67417
  );
67810
67418
  return {
@@ -68736,9 +68344,9 @@ async function getKaminoMetadata(options) {
68736
68344
  for (const [bankAddress, state] of Object.entries(kaminoStates)) {
68737
68345
  kaminoMetadataMap.set(bankAddress, {
68738
68346
  kaminoStates: {
68739
- reserveState: dtoToReserveRaw(state.reserveState),
68740
- obligationState: dtoToObligationRaw(state.obligationState),
68741
- farmState: state.farmState ? dtoToFarmRaw(state.farmState) : void 0
68347
+ reserveState: dtoToKaminoReserve(state.reserveState),
68348
+ obligationState: dtoToKaminoObligation(state.obligationState),
68349
+ farmState: state.farmState ? dtoToKaminoFarmState(state.farmState) : void 0
68742
68350
  }
68743
68351
  });
68744
68352
  }
@@ -68770,8 +68378,8 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
68770
68378
  bankByFarmKey[reserveState.farmCollateral.toBase58()] = bank.bankAddress;
68771
68379
  }
68772
68380
  kaminoStatesMap[bank.bankAddress] = {
68773
- reserveState: reserveRawToDto(reserveState),
68774
- obligationState: obligationRawToDto(obligationState)
68381
+ reserveState: kaminoReserveToDto(reserveState),
68382
+ obligationState: kaminoObligationToDto(obligationState)
68775
68383
  };
68776
68384
  }
68777
68385
  const allFarmKeys = Object.keys(bankByFarmKey);
@@ -68794,7 +68402,7 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
68794
68402
  const decodedFarmState = decodeFarmDataRaw(farmState.data);
68795
68403
  kaminoStatesMap[bankKey] = {
68796
68404
  ...kaminoState,
68797
- farmState: farmRawToDto(decodedFarmState)
68405
+ farmState: kaminoFarmStateToDto(decodedFarmState)
68798
68406
  };
68799
68407
  }
68800
68408
  }
@@ -68925,7 +68533,7 @@ async function getJupLendMetadata(options) {
68925
68533
  jupTokenReserveState: dtoToJupTokenReserveRaw(state.jupTokenReserveState),
68926
68534
  jupRewardsRateModel: state.jupRewardsRateModel ? dtoToJupLendingRewardsRateModelRaw(state.jupRewardsRateModel) : null,
68927
68535
  jupRateModel: state.jupRateModel ? dtoToJupRateModelRaw(state.jupRateModel) : null,
68928
- fTokenTotalSupply: new BN11(state.fTokenTotalSupply)
68536
+ fTokenTotalSupply: new BN8(state.fTokenTotalSupply)
68929
68537
  }
68930
68538
  });
68931
68539
  }
@@ -69040,7 +68648,7 @@ async function getJupLendStatesDto(connection, jupLendBanks) {
69040
68648
  return jupLendStatesMap;
69041
68649
  }
69042
68650
  function getJupLendFTokenMultiplier(lendingState, tokenReserve, rewardsModel, fTokenTotalSupply, nowSeconds) {
69043
- const currentTimestamp = new BN11(nowSeconds);
68651
+ const currentTimestamp = new BN8(nowSeconds);
69044
68652
  const newExchangePrice = calculateJupLendNewExchangePrice(
69045
68653
  lendingState,
69046
68654
  tokenReserve,
@@ -70563,6 +70171,6 @@ var EmodeSettings = class _EmodeSettings {
70563
70171
  }
70564
70172
  };
70565
70173
 
70566
- export { ADDRESS_LOOKUP_TABLE_FOR_GROUP, ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE, ADDRESS_LOOKUP_TABLE_FOR_SWAP, AccountFlags, AccountType, AssetTag, BUNDLE_TX_SIZE, Balance, Bank, BankConfig, BankConfigFlag, BankVaultType, DEFAULT_CROSSBAR_URL, DEFAULT_FALLBACK_CROSSBAR_URL, DEFAULT_ORACLE_MAX_AGE, DEFAULT_REPAY_ALL_EXTRA_BUFFER_BPS, DISABLED_FLAG, EMPTY_HEALTH_CACHE, EmodeEntryFlags, EmodeFlags, EmodeImpactStatus, EmodeSettings, EmodeTag, FLASHLOAN_ENABLED_FLAG, HOURS_PER_YEAR, HealthCache, HealthCacheFlags, HealthCacheSimulationError, HealthCacheStatus, JUPITER_V6_PROGRAM, JUP_SWAP_LUT_PROGRAM_AUTHORITY_INDEX, LST_MINT, MARGINFI_IDL, MARGINFI_PROGRAM, MARGINFI_PROGRAM_STAGING, MARGINFI_PROGRAM_STAGING_ALT, MARGINFI_SPONSORED_SHARD_ID, MAX_ACCOUNT_LOCKS, MAX_CONFIDENCE_INTERVAL_RATIO, MAX_TX_SIZE, MAX_U64, MPL_METADATA_PROGRAM_ID, MarginRequirementType, MarginfiAccount, MarginfiAccountWrapper, MarginfiGroup, OperationalState, OracleSetup, PDA_BANK_EMISSIONS_AUTH_SEED, PDA_BANK_EMISSIONS_VAULT_SEED, PDA_BANK_FEE_STATE_SEED, PDA_BANK_FEE_VAULT_AUTH_SEED, PDA_BANK_FEE_VAULT_SEED, PDA_BANK_INSURANCE_VAULT_AUTH_SEED, PDA_BANK_INSURANCE_VAULT_SEED, PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED, PDA_BANK_LIQUIDITY_VAULT_SEED, PDA_MARGINFI_ACCOUNT_SEED, PRIORITY_TX_SIZE, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID, PriceBias, Project0Client, RiskTier, SINGLE_POOL_PROGRAM_ID, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWAP_ADAPTERS, SWB_PRICE_CONF_INTERVALS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, SwapProvider, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionBuildingError, TransactionBuildingErrorCode, TransactionConfigMap, TransactionType, USDC_DECIMALS, USDC_MINT, WSOL_MINT, ZERO_ORACLE_KEY, accountFlagToBN, addOracleToBanksIx, addTransactionMetadata, adjustPriceComponent, aprToApy, apyToApr, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankMetadataMapToDto, bankMetadataToDto, bankRateLimiterRawToDto, bankRawToDto, bigNumberToWrappedI80F48, bpsToPercentile, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkBatchOracleCrankability, checkJupiterFeeAccount, checkMultipleOraclesCrankability, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, compileFlashloanPrecheck, composeBridgedSwap, composeRemainingAccounts, computeAccountValue, computeActiveEmodePairs, computeAssetHealthComponent, computeAssetUsdValue, computeBalanceUsdValue, computeBankBorrowApy, computeBankBorrowCapRemaining, computeBankDepositCapRemaining, computeBankMetrics, computeBankPoolSize, computeBankSupplyApy, computeBankTotalBorrows, computeBankTotalBorrowsUsd, computeBankTotalDeposits, computeBankTotalDepositsUsd, computeBaseInterestRate, computeBorrowEstimateForRepay, computeClaimedEmissions, computeClosePositionTokenAmount, computeEmodeImpacts, computeFlashLoanNonSwapBudget, computeFlashloanSwapConstraints, computeFreeCollateralFromBalances, computeFreeCollateralFromCache, computeHealthAccountMetas, computeHealthCacheStatus, computeHealthCheckAccounts, computeHealthComponentsFromBalances, computeHealthComponentsFromCache, computeInterestRates, computeLiabilityHealthComponent, computeLiabilityUsdValue, computeLiquidationPriceForBank, computeLoopingParams, computeLowestEmodeWeights, computeMaxBorrowForBank, computeMaxLeverage, computeMaxWithdrawForBank, computeNetApy, computeProjectedActiveBalancesNoCpi, computeProjectedActiveBanksNoCpi, computeQuantity, computeQuantityUi, computeRemainingCapacity, computeSmartCrank, computeStakedBankMultipliers, computeTotalOutstandingEmissions, computeTvl, computeUsdValue, computeUtilizationRate, computeV0TxSize, convertVoteAccCoeffsToBankCoeffs, createActiveEmodePairFromPairs, createEmptyBalance, decodeAccountRaw, decodeBankRaw, decodeInstruction, decompileV0Transaction, deriveBankEmissionsAuth, deriveBankEmissionsVault, deriveBankFeeVault, deriveBankFeeVaultAuthority, deriveBankInsuranceVault, deriveBankInsuranceVaultAuthority, deriveBankLiquidityVault, deriveBankLiquidityVaultAuthority, deriveFeeState, deriveMarginfiAccount, deserializeInstruction, deserializeLut, deserializeSwapEngineRequest, deserializeSwapEngineResult, dtoToBalance, dtoToBank, dtoToBankConfig, dtoToBankConfigRaw, dtoToBankMetadata, dtoToBankMetadataMap, dtoToBankRateLimiter, dtoToBankRateLimiterRaw, dtoToBankRaw, dtoToEmodeSettings, dtoToEmodeSettingsRaw, dtoToGroup, dtoToHealthCache, dtoToInterestRateConfig, dtoToMarginfiAccount, dtoToOraclePrice, dtoToValidatorStakeGroup, emodeSettingsRawToDto, extractPythOracleKeys, fetchBank, fetchBankIntegrationMetadata, fetchMarginfiAccountActiveBalancesForBank, fetchMarginfiAccountAddresses, fetchMarginfiAccountAddressesHoldingBank, fetchMarginfiAccountData, fetchMultipleBanks, fetchNativeStakeAccounts, fetchOracleData, fetchProgramForMints, fetchPythOracleData, fetchPythOraclePricesFromAPI, fetchPythOraclePricesFromChain, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, fetchSwbOracleAccountsFromAPI, fetchSwbOracleAccountsFromChain, fetchSwbOracleData, fetchSwbOraclePricesFromAPI, fetchSwbOraclePricesFromCrossbar, findRandomAvailableAccountIndex, freezeBankConfigIx, generateDummyAccount, getAccountKeys, getActiveAccountFlags, getActiveBalances, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getAssetQuantity, getAssetShares, getAssetWeight, getBalance, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getBirdeyeFallbackPricesByFeedId, getBirdeyePricesForMints, getConfig, getDriftCTokenMultiplier, getDriftMetadata, getDriftStatesDto, getEmodePairs, getExactOutEstimate, getHealthCacheStatusDescription, getHealthSimulationTransactions, getJupLendFTokenMultiplier, getJupLendMetadata, getJupLendStatesDto, getJupiterReferralFeeAccount, getJupiterSwapIxsForFlashloan, getKaminoCTokenMultiplier, getKaminoMetadata, getKaminoStatesDto, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getOracleSourceFromBank, getOracleSourceFromOracleSetup, getOracleSourceNameFromKey, getPrice, getPriceWithConfidence, getStakedBankMetadataMap, getSwapAdapter, getSwapIxsForFlashloan, getTitanExactOutEstimate, getTitanSwapIxsForFlashloan, getTotalAccountKeys, getTotalAssetQuantity, getTotalLiabilityQuantity, getTxSize, getValidatorVoteAccountByBank, getWritableAccountKeys, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, isDepositIx, isFlashloan, isV0Tx, isWeightedPrice, isWholePosition, makeAccountTransferToNewAccountTx, makeAddPermissionlessStakedBankIx, makeBeginFlashLoanIx3 as makeBeginFlashLoanIx, makeBorrowIx3 as makeBorrowIx, makeBorrowTx, makeBundleTipIx, makeClearEmissionsIx, makeCloseMarginfiAccountIx, makeCloseMarginfiAccountTx, makeCrankSwbFeedIx, makeCreateAccountIxWithProjection, makeCreateAccountTxWithProjection, makeCreateMarginfiAccountIx, makeCreateMarginfiAccountTx, makeDepositIx3 as makeDepositIx, makeDepositTx, makeDriftDepositIx3 as makeDriftDepositIx, makeDriftDepositTx, makeDriftWithdrawIx3 as makeDriftWithdrawIx, makeDriftWithdrawTx, makeEndFlashLoanIx3 as makeEndFlashLoanIx, makeFlashLoanTx, makeJuplendDepositIx2 as makeJuplendDepositIx, makeJuplendDepositTx, makeJuplendWithdrawIx2 as makeJuplendWithdrawIx, makeJuplendWithdrawTx, makeKaminoDepositIx3 as makeKaminoDepositIx, makeKaminoDepositTx, makeKaminoWithdrawIx3 as makeKaminoWithdrawIx, makeKaminoWithdrawTx, makeLoopTx, makeMergeStakeAccountsTx, makeMintStakedLstIx, makeMintStakedLstTx, makePoolAddBankIx3 as makePoolAddBankIx, makePoolConfigureBankIx3 as makePoolConfigureBankIx, makePriorityFeeIx, makePriorityFeeMicroIx, makePulseHealthIx2 as makePulseHealthIx, makeRedeemStakedLstIx, makeRedeemStakedLstTx, makeRefreshKaminoBanksIxs, makeRepayIx3 as makeRepayIx, makeRepayTx, makeRepayWithCollatTx, makeRollPtTx, makeSetupIx, makeSmartCrankSwbFeedIx, makeSwapCollateralTx, makeSwapDebtTx, makeTxPriorityIx, makeUnwrapSolIx, makeUpdateDriftMarketIxs, makeUpdateJupLendRateIxs, makeUpdateSwbFeedIx, makeVersionedTransaction, makeWithdrawIx3 as makeWithdrawIx, makeWithdrawTx, makeWrapSolIxs, mapBrokenFeedsToOraclePrices, mapJupiterQuoteToSwapQuoteResult, mapPythBanksToOraclePrices, mapSwbBanksToOraclePrices, marginfiAccountToDto, mergeBridgeQuotes, nativeToUi, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRateLimiterRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseHealthCacheRaw, parseMarginfiAccountRaw, parseOperationalState, parseOracleSetup, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseRpcPythPriceData, parseSwbOraclePriceData, partitionBanksByCrankability, patchDepositAmount, resolveAmount, runSwapEngine, selectLutsForAccountAction, selectLutsForBanks, serializeBankConfigOpt, serializeInstruction, serializeInterestRateConfig, serializeLut, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, serializeSwapEngineRequest, serializeSwapEngineResult, shortenAddress, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateBundle, splitInstructionsToFitTransactions, swapEngineProvidersFromOpts, swapEngineQuoteFieldsFromOpts, toBankConfigDto, toBankDto, toBigNumber, toEmodeSettingsDto, toInterestRateConfigDto, toJupiterConfig, toNumber, uiToNative, uiToNativeBigNumber, validatorStakeGroupToDto, wrappedI80F48toBigNumber };
70174
+ export { ADDRESS_LOOKUP_TABLE_FOR_GROUP, ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE, ADDRESS_LOOKUP_TABLE_FOR_SWAP, AccountFlags, AccountType, AssetTag, BUNDLE_TX_SIZE, Balance, Bank, BankConfig, BankConfigFlag, BankVaultType, DEFAULT_CROSSBAR_URL, DEFAULT_FALLBACK_CROSSBAR_URL, DEFAULT_ORACLE_MAX_AGE, DEFAULT_REPAY_ALL_EXTRA_BUFFER_BPS, DISABLED_FLAG, EMPTY_HEALTH_CACHE, EmodeEntryFlags, EmodeFlags, EmodeImpactStatus, EmodeSettings, EmodeTag, FLASHLOAN_ENABLED_FLAG, HOURS_PER_YEAR, HealthCache, HealthCacheFlags, HealthCacheSimulationError, HealthCacheStatus, JUPITER_V6_PROGRAM, JUP_SWAP_LUT_PROGRAM_AUTHORITY_INDEX, LST_MINT, MARGINFI_IDL, MARGINFI_PROGRAM, MARGINFI_PROGRAM_STAGING, MARGINFI_PROGRAM_STAGING_ALT, MARGINFI_SPONSORED_SHARD_ID, MAX_ACCOUNT_LOCKS, MAX_CONFIDENCE_INTERVAL_RATIO, MAX_TX_SIZE, MAX_U64, MPL_METADATA_PROGRAM_ID, MarginRequirementType, MarginfiAccount, MarginfiAccountWrapper, MarginfiGroup, OperationalState, OracleSetup, PDA_BANK_EMISSIONS_AUTH_SEED, PDA_BANK_EMISSIONS_VAULT_SEED, PDA_BANK_FEE_STATE_SEED, PDA_BANK_FEE_VAULT_AUTH_SEED, PDA_BANK_FEE_VAULT_SEED, PDA_BANK_INSURANCE_VAULT_AUTH_SEED, PDA_BANK_INSURANCE_VAULT_SEED, PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED, PDA_BANK_LIQUIDITY_VAULT_SEED, PDA_MARGINFI_ACCOUNT_SEED, PRIORITY_TX_SIZE, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID, PriceBias, Project0Client, RiskTier, SINGLE_POOL_PROGRAM_ID, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWAP_ADAPTERS, SWB_PRICE_CONF_INTERVALS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, SwapProvider, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionBuildingError, TransactionBuildingErrorCode, TransactionConfigMap, TransactionType, USDC_DECIMALS, USDC_MINT, WSOL_MINT, ZERO_ORACLE_KEY, accountConflictsWithBridge, accountFlagToBN, addOracleToBanksIx, addTransactionMetadata, adjustPriceComponent, aprToApy, apyToApr, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankMetadataMapToDto, bankMetadataToDto, bankRateLimiterRawToDto, bankRawToDto, bigNumberToWrappedI80F48, bpsToPercentile, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkBatchOracleCrankability, checkJupiterFeeAccount, checkMultipleOraclesCrankability, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, compileFlashloanPrecheck, composeBridgedSwap, composeRemainingAccounts, computeAccountValue, computeActiveEmodePairs, computeAssetHealthComponent, computeAssetUsdValue, computeBalanceUsdValue, computeBankBorrowApy, computeBankBorrowCapRemaining, computeBankDepositCapRemaining, computeBankMetrics, computeBankPoolSize, computeBankSupplyApy, computeBankTotalBorrows, computeBankTotalBorrowsUsd, computeBankTotalDeposits, computeBankTotalDepositsUsd, computeBaseInterestRate, computeBorrowEstimateForRepay, computeClaimedEmissions, computeClosePositionTokenAmount, computeEmodeImpacts, computeFlashLoanNonSwapBudget, computeFlashloanSwapConstraints, computeFreeCollateralFromBalances, computeFreeCollateralFromCache, computeHealthAccountMetas, computeHealthCacheStatus, computeHealthCheckAccounts, computeHealthComponentsFromBalances, computeHealthComponentsFromCache, computeInterestRates, computeLiabilityHealthComponent, computeLiabilityUsdValue, computeLiquidationPriceForBank, computeLoopingParams, computeLowestEmodeWeights, computeMaxBorrowForBank, computeMaxLeverage, computeMaxWithdrawForBank, computeNetApy, computeProjectedActiveBalancesNoCpi, computeProjectedActiveBanksNoCpi, computeQuantity, computeQuantityUi, computeRemainingCapacity, computeSmartCrank, computeStakedBankMultipliers, computeTotalOutstandingEmissions, computeTvl, computeUsdValue, computeUtilizationRate, computeV0TxSize, convertVoteAccCoeffsToBankCoeffs, createActiveEmodePairFromPairs, createEmptyBalance, decodeAccountRaw, decodeBankRaw, decodeInstruction, decompileV0Transaction, deriveBankEmissionsAuth, deriveBankEmissionsVault, deriveBankFeeVault, deriveBankFeeVaultAuthority, deriveBankInsuranceVault, deriveBankInsuranceVaultAuthority, deriveBankLiquidityVault, deriveBankLiquidityVaultAuthority, deriveFeeState, deriveMarginfiAccount, deserializeInstruction, deserializeLut, deserializeSwapEngineRequest, deserializeSwapEngineResult, dtoToBalance, dtoToBank, dtoToBankConfig, dtoToBankConfigRaw, dtoToBankMetadata, dtoToBankMetadataMap, dtoToBankRateLimiter, dtoToBankRateLimiterRaw, dtoToBankRaw, dtoToEmodeSettings, dtoToEmodeSettingsRaw, dtoToGroup, dtoToHealthCache, dtoToInterestRateConfig, dtoToMarginfiAccount, dtoToOraclePrice, dtoToValidatorStakeGroup, emodeSettingsRawToDto, extractPythOracleKeys, fetchBank, fetchBankIntegrationMetadata, fetchMarginfiAccountActiveBalancesForBank, fetchMarginfiAccountAddresses, fetchMarginfiAccountAddressesHoldingBank, fetchMarginfiAccountData, fetchMultipleBanks, fetchNativeStakeAccounts, fetchOracleData, fetchProgramForMints, fetchPythOracleData, fetchPythOraclePricesFromAPI, fetchPythOraclePricesFromChain, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, fetchSwbOracleAccountsFromAPI, fetchSwbOracleAccountsFromChain, fetchSwbOracleData, fetchSwbOraclePricesFromAPI, fetchSwbOraclePricesFromCrossbar, findRandomAvailableAccountIndex, freezeBankConfigIx, generateDummyAccount, getAccountKeys, getActiveAccountFlags, getActiveBalances, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getAssetQuantity, getAssetShares, getAssetWeight, getBalance, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getBirdeyeFallbackPricesByFeedId, getBirdeyePricesForMints, getConfig, getDriftCTokenMultiplier, getDriftMetadata, getDriftStatesDto, getEmodePairs, getExactOutEstimate, getHealthCacheStatusDescription, getHealthSimulationTransactions, getJupLendFTokenMultiplier, getJupLendMetadata, getJupLendStatesDto, getJupiterReferralFeeAccount, getJupiterSwapIxsForFlashloan, getKaminoCTokenMultiplier, getKaminoMetadata, getKaminoStatesDto, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getOracleSourceFromBank, getOracleSourceFromOracleSetup, getOracleSourceNameFromKey, getPrice, getPriceWithConfidence, getStakedBankMetadataMap, getSwapAdapter, getSwapIxsForFlashloan, getTitanExactOutEstimate, getTitanSwapIxsForFlashloan, getTotalAccountKeys, getTotalAssetQuantity, getTotalLiabilityQuantity, getTxSize, getValidatorVoteAccountByBank, getWritableAccountKeys, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, isDecomposableSwapError, isDepositIx, isFlashloan, isStandardBorrowable, isStandardDepositable, isV0Tx, isWeightedPrice, isWholePosition, makeAccountTransferToNewAccountTx, makeAddPermissionlessStakedBankIx, makeBeginFlashLoanIx3 as makeBeginFlashLoanIx, makeBorrowIx3 as makeBorrowIx, makeBorrowTx, makeBundleTipIx, makeClearEmissionsIx, makeCloseMarginfiAccountIx, makeCloseMarginfiAccountTx, makeCrankSwbFeedIx, makeCreateAccountIxWithProjection, makeCreateAccountTxWithProjection, makeCreateMarginfiAccountIx, makeCreateMarginfiAccountTx, makeDepositIx3 as makeDepositIx, makeDepositTx, makeDriftDepositIx3 as makeDriftDepositIx, makeDriftDepositTx, makeDriftWithdrawIx3 as makeDriftWithdrawIx, makeDriftWithdrawTx, makeEndFlashLoanIx3 as makeEndFlashLoanIx, makeFlashLoanTx, makeJuplendDepositIx2 as makeJuplendDepositIx, makeJuplendDepositTx, makeJuplendWithdrawIx2 as makeJuplendWithdrawIx, makeJuplendWithdrawTx, makeKaminoDepositIx3 as makeKaminoDepositIx, makeKaminoDepositTx, makeKaminoWithdrawIx3 as makeKaminoWithdrawIx, makeKaminoWithdrawTx, makeLoopTx, makeMergeStakeAccountsTx, makeMintStakedLstIx, makeMintStakedLstTx, makePoolAddBankIx3 as makePoolAddBankIx, makePoolConfigureBankIx3 as makePoolConfigureBankIx, makePriorityFeeIx, makePriorityFeeMicroIx, makePulseHealthIx2 as makePulseHealthIx, makeRedeemStakedLstIx, makeRedeemStakedLstTx, makeRefreshKaminoBanksIxs, makeRepayIx3 as makeRepayIx, makeRepayTx, makeRepayWithCollatTx, makeRollPtTx, makeSetupIx, makeSmartCrankSwbFeedIx, makeSwapCollateralTx, makeSwapDebtTx, makeTxPriorityIx, makeUnwrapSolIx, makeUpdateDriftMarketIxs, makeUpdateJupLendRateIxs, makeUpdateSwbFeedIx, makeVersionedTransaction, makeWithdrawIx3 as makeWithdrawIx, makeWithdrawTx, makeWrapSolIxs, mapBrokenFeedsToOraclePrices, mapJupiterQuoteToSwapQuoteResult, mapPythBanksToOraclePrices, mapSwbBanksToOraclePrices, marginfiAccountToDto, mergeBridgeQuotes, mergeBridgeQuotesDebt, mergeBridgeQuotesLoop, nativeToUi, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRateLimiterRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseHealthCacheRaw, parseMarginfiAccountRaw, parseOperationalState, parseOracleSetup, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseRpcPythPriceData, parseSwbOraclePriceData, partitionBanksByCrankability, patchDepositAmount, resolveAmount, resolveBridgeBanks, runSwapEngine, selectLutsForAccountAction, selectLutsForBanks, serializeBankConfigOpt, serializeInstruction, serializeInterestRateConfig, serializeLut, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, serializeSwapEngineRequest, serializeSwapEngineResult, shortenAddress, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateBundle, splitInstructionsToFitTransactions, swapEngineProvidersFromOpts, swapEngineQuoteFieldsFromOpts, toBankConfigDto, toBankDto, toBigNumber, toEmodeSettingsDto, toInterestRateConfigDto, toJupiterConfig, toNumber, uiToNative, uiToNativeBigNumber, validatorStakeGroupToDto, wrappedI80F48toBigNumber };
70567
70175
  //# sourceMappingURL=index.js.map
70568
70176
  //# sourceMappingURL=index.js.map