@0dotxyz/p0-ts-sdk 2.8.4 → 2.9.0-alpha.1

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,5 +1,6 @@
1
1
  import { PublicKey, SolanaJSONRPCError, ComputeBudgetProgram, SystemProgram, TransactionMessage, VersionedTransaction, AddressLookupTableAccount, Transaction, TransactionInstruction, Keypair, StakeProgram, LAMPORTS_PER_SOL, StakeAuthorizationLayout, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY, STAKE_CONFIG_ID as STAKE_CONFIG_ID$1 } from '@solana/web3.js';
2
2
  import { object, string, enums, array, assert } from 'superstruct';
3
+ import { sha256 } from '@noble/hashes/sha2';
3
4
  import BigNumber3, { BigNumber } from 'bignumber.js';
4
5
  import BN8, { BN } from 'bn.js';
5
6
  import Decimal3, { Decimal } from 'decimal.js';
@@ -258,6 +259,7 @@ var PDA_BANK_FEE_STATE_SEED = Buffer.from("feestate");
258
259
  var PDA_BANK_EMISSIONS_AUTH_SEED = Buffer.from("emissions_auth_seed");
259
260
  var PDA_BANK_EMISSIONS_VAULT_SEED = Buffer.from("emissions_vault");
260
261
  var PDA_MARGINFI_ACCOUNT_SEED = Buffer.from("marginfi_account");
262
+ var PDA_ORDER_SEED = Buffer.from("order");
261
263
  function deriveBankLiquidityVaultAuthority(programId, bank) {
262
264
  return PublicKey.findProgramAddressSync(
263
265
  [PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED, bank.toBuffer()],
@@ -322,6 +324,14 @@ function deriveMarginfiAccount(programId, group, authority, accountIndex, thirdP
322
324
  programId
323
325
  );
324
326
  }
327
+ function deriveOrderPda(programId, marginfiAccount, bankKeys) {
328
+ const sortedBankKeys = bankKeys.map((key) => key.toBuffer()).sort(Buffer.compare);
329
+ const bankKeysHash = Buffer.from(sha256(Buffer.concat(sortedBankKeys)));
330
+ return PublicKey.findProgramAddressSync(
331
+ [PDA_ORDER_SEED, marginfiAccount.toBuffer(), bankKeysHash],
332
+ programId
333
+ );
334
+ }
325
335
  var PYTH_PUSH_ORACLE_ID = new PublicKey("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
326
336
  var PYTH_SPONSORED_SHARD_ID = 0;
327
337
  var MARGINFI_SPONSORED_SHARD_ID = 3301;
@@ -493,6 +503,19 @@ function shortenAddress(pubkey, chars = 4) {
493
503
  function bpsToPercentile(bps) {
494
504
  return bps / 1e4;
495
505
  }
506
+ var U32_MAX = 4294967295;
507
+ var MAX_ORDER_SLIPPAGE_PERCENT = 10;
508
+ function percentToMaxSlippageU32(percent) {
509
+ if (!(percent > 0) || percent > MAX_ORDER_SLIPPAGE_PERCENT) {
510
+ throw new Error(
511
+ `Max slippage percent must be in (0, ${MAX_ORDER_SLIPPAGE_PERCENT}], got ${percent}`
512
+ );
513
+ }
514
+ return Math.floor(percent / 100 * U32_MAX);
515
+ }
516
+ function maxSlippageU32ToPercent(maxSlippage) {
517
+ return maxSlippage / U32_MAX * 100;
518
+ }
496
519
  var composeRemainingAccounts = (banksAndOracles) => {
497
520
  banksAndOracles.sort((a, b) => {
498
521
  const A = a[0].toBytes();
@@ -21432,6 +21455,9 @@ var TransactionType = /* @__PURE__ */ ((TransactionType2) => {
21432
21455
  TransactionType2["UNSTAKE_LST"] = "UNSTAKE_LST";
21433
21456
  TransactionType2["WITHDRAW_EMISSIONS"] = "WITHDRAW_EMISSIONS";
21434
21457
  TransactionType2["LIQUIDATE_ACCOUNT"] = "LIQUIDATE_ACCOUNT";
21458
+ TransactionType2["PLACE_ORDER"] = "PLACE_ORDER";
21459
+ TransactionType2["CLOSE_ORDER"] = "CLOSE_ORDER";
21460
+ TransactionType2["UPDATE_ORDER"] = "UPDATE_ORDER";
21435
21461
  TransactionType2["CREATE_PERM_BANK"] = "CREATE_PERM_BANK";
21436
21462
  TransactionType2["CREATE_GROUP"] = "CREATE_GROUP";
21437
21463
  TransactionType2["JUPITER_SWAP"] = "JUPITER_SWAP";
@@ -21518,6 +21544,14 @@ var TransactionConfigMap = {
21518
21544
  ["WITHDRAW_EMISSIONS" /* WITHDRAW_EMISSIONS */]: { label: () => "Withdraw emissions" },
21519
21545
  // LIQUIDATE
21520
21546
  ["LIQUIDATE_ACCOUNT" /* LIQUIDATE_ACCOUNT */]: { label: () => "Liquidate account" },
21547
+ // ORDERS (TP/SL)
21548
+ ["PLACE_ORDER" /* PLACE_ORDER */]: {
21549
+ label: ({ collateralToken, debtToken } = {}) => collateralToken && debtToken ? `Place TP/SL order on ${collateralToken}/${debtToken}` : "Place TP/SL order"
21550
+ },
21551
+ ["CLOSE_ORDER" /* CLOSE_ORDER */]: { label: () => "Close TP/SL order" },
21552
+ ["UPDATE_ORDER" /* UPDATE_ORDER */]: {
21553
+ label: ({ collateralToken, debtToken } = {}) => collateralToken && debtToken ? `Update TP/SL order on ${collateralToken}/${debtToken}` : "Update TP/SL order"
21554
+ },
21521
21555
  // BANK and GROUPS
21522
21556
  ["CREATE_PERM_BANK" /* CREATE_PERM_BANK */]: { label: () => "Create permissionless bank" },
21523
21557
  ["CREATE_GROUP" /* CREATE_GROUP */]: { label: () => "Create marginfi group" },
@@ -22634,6 +22668,10 @@ var AccountFlags = /* @__PURE__ */ ((AccountFlags2) => {
22634
22668
  AccountFlags2[AccountFlags2["ACCOUNT_IN_FLASHLOAN"] = 2] = "ACCOUNT_IN_FLASHLOAN";
22635
22669
  AccountFlags2[AccountFlags2["ACCOUNT_FLAG_DEPRECATED"] = 4] = "ACCOUNT_FLAG_DEPRECATED";
22636
22670
  AccountFlags2[AccountFlags2["ACCOUNT_TRANSFER_AUTHORITY_ALLOWED"] = 8] = "ACCOUNT_TRANSFER_AUTHORITY_ALLOWED";
22671
+ AccountFlags2[AccountFlags2["ACCOUNT_IN_RECEIVERSHIP"] = 16] = "ACCOUNT_IN_RECEIVERSHIP";
22672
+ AccountFlags2[AccountFlags2["ACCOUNT_IN_DELEVERAGE"] = 32] = "ACCOUNT_IN_DELEVERAGE";
22673
+ AccountFlags2[AccountFlags2["ACCOUNT_FROZEN"] = 64] = "ACCOUNT_FROZEN";
22674
+ AccountFlags2[AccountFlags2["ACCOUNT_IN_ORDER_EXECUTION"] = 128] = "ACCOUNT_IN_ORDER_EXECUTION";
22637
22675
  return AccountFlags2;
22638
22676
  })(AccountFlags || {});
22639
22677
  var MarginRequirementType = /* @__PURE__ */ ((MarginRequirementType5) => {
@@ -71294,13 +71332,13 @@ function computeInterestRates(bank) {
71294
71332
  const borrowingRate = baseInterestRate.times(new BigNumber3(1).plus(rateFee)).plus(fixedFee);
71295
71333
  return { lendingRate, borrowingRate };
71296
71334
  }
71297
- var U32_MAX = 4294967295;
71335
+ var U32_MAX2 = 4294967295;
71298
71336
  function rateFromU32(rate) {
71299
- const ratio = new BigNumber3(rate).div(U32_MAX);
71337
+ const ratio = new BigNumber3(rate).div(U32_MAX2);
71300
71338
  return ratio.times(10);
71301
71339
  }
71302
71340
  function utilFromU32(util) {
71303
- return new BigNumber3(util).div(U32_MAX);
71341
+ return new BigNumber3(util).div(U32_MAX2);
71304
71342
  }
71305
71343
  function calculateRateBetweenPoints(startX, startY, endX, endY, targetX) {
71306
71344
  if (endX.lte(startX)) return startY;
@@ -71909,6 +71947,22 @@ async function makePulseHealthIx(mfProgram, accounts, remainingAccounts = []) {
71909
71947
  marginfiAccount: accounts.marginfiAccount
71910
71948
  }).remainingAccounts(remainingAccounts).instruction();
71911
71949
  }
71950
+ async function makePlaceOrderIx(mfProgram, accounts, args, remainingAccounts = []) {
71951
+ const { marginfiAccount, feePayer, authority, order, globalFeeWallet, ...optionalAccounts } = accounts;
71952
+ return mfProgram.methods.marginfiAccountPlaceOrder(args.bankKeys, args.trigger).accounts({
71953
+ marginfiAccount,
71954
+ feePayer,
71955
+ order
71956
+ }).accountsPartial({ authority, globalFeeWallet, ...optionalAccounts }).remainingAccounts(remainingAccounts).instruction();
71957
+ }
71958
+ async function makeCloseOrderIx(mfProgram, accounts, remainingAccounts = []) {
71959
+ const { marginfiAccount, authority, order, feeRecipient, ...optionalAccounts } = accounts;
71960
+ return mfProgram.methods.marginfiAccountCloseOrder().accounts({
71961
+ authority,
71962
+ order,
71963
+ feeRecipient
71964
+ }).accountsPartial({ marginfiAccount, ...optionalAccounts }).remainingAccounts(remainingAccounts).instruction();
71965
+ }
71912
71966
  var instructions = {
71913
71967
  makeDepositIx,
71914
71968
  makeJuplendDepositIx,
@@ -71934,7 +71988,9 @@ var instructions = {
71934
71988
  makeLendingPoolConfigureBankOracleIx,
71935
71989
  makeLendingPoolConfigureBankOracleScopeIx,
71936
71990
  makeLendingPoolSetOraclePriceIx,
71937
- makePulseHealthIx
71991
+ makePulseHealthIx,
71992
+ makePlaceOrderIx,
71993
+ makeCloseOrderIx
71938
71994
  };
71939
71995
  var instructions_default3 = instructions;
71940
71996
 
@@ -72100,9 +72156,25 @@ function decodeAccountRaw(encoded, idl) {
72100
72156
  const coder = new BorshCoder(idl);
72101
72157
  return coder.accounts.decode("marginfiAccount" /* MarginfiAccount */, encoded);
72102
72158
  }
72159
+ function parseOrderRaw(orderAddress, orderRaw) {
72160
+ let trigger = "stopLoss";
72161
+ if ("takeProfit" in orderRaw.trigger) trigger = "takeProfit";
72162
+ if ("both" in orderRaw.trigger) trigger = "both";
72163
+ return {
72164
+ address: orderAddress,
72165
+ marginfiAccount: orderRaw.marginfiAccount,
72166
+ trigger,
72167
+ stopLoss: trigger === "takeProfit" ? null : wrappedI80F48toBigNumber(orderRaw.stopLoss),
72168
+ takeProfit: trigger === "stopLoss" ? null : wrappedI80F48toBigNumber(orderRaw.takeProfit),
72169
+ tags: [orderRaw.tags[0], orderRaw.tags[1]],
72170
+ createdAt: orderRaw.createdAt.toNumber(),
72171
+ maxSlippagePercent: maxSlippageU32ToPercent(orderRaw.maxSlippage)
72172
+ };
72173
+ }
72103
72174
  function parseBalanceRaw(balanceRaw) {
72104
72175
  const active = typeof balanceRaw.active === "number" ? balanceRaw.active === 1 : balanceRaw.active;
72105
72176
  const bankPk = balanceRaw.bankPk;
72177
+ const tag = balanceRaw.tag;
72106
72178
  const assetShares = wrappedI80F48toBigNumber(balanceRaw.assetShares);
72107
72179
  const liabilityShares = wrappedI80F48toBigNumber(balanceRaw.liabilityShares);
72108
72180
  const emissionsOutstanding = wrappedI80F48toBigNumber(balanceRaw.emissionsOutstanding);
@@ -72110,6 +72182,7 @@ function parseBalanceRaw(balanceRaw) {
72110
72182
  return {
72111
72183
  active,
72112
72184
  bankPk,
72185
+ tag,
72113
72186
  assetShares,
72114
72187
  liabilityShares,
72115
72188
  emissionsOutstanding,
@@ -72156,7 +72229,8 @@ function parseMarginfiAccountRaw(marginfiAccountPk, accountData) {
72156
72229
  balances,
72157
72230
  accountFlags,
72158
72231
  emissionsDestinationAccount,
72159
- healthCache
72232
+ healthCache,
72233
+ activeOrders: accountData.activeOrders
72160
72234
  };
72161
72235
  }
72162
72236
  function getActiveAccountFlags(flags) {
@@ -72212,13 +72286,15 @@ function dtoToMarginfiAccount(marginfiAccountDto) {
72212
72286
  balances: marginfiAccountDto.balances.map(dtoToBalance),
72213
72287
  accountFlags: marginfiAccountDto.accountFlags,
72214
72288
  emissionsDestinationAccount: new PublicKey(marginfiAccountDto.emissionsDestinationAccount),
72215
- healthCache: dtoToHealthCache(marginfiAccountDto.healthCache)
72289
+ healthCache: dtoToHealthCache(marginfiAccountDto.healthCache),
72290
+ activeOrders: marginfiAccountDto.activeOrders ?? 0
72216
72291
  };
72217
72292
  }
72218
72293
  function dtoToBalance(balanceDto) {
72219
72294
  return {
72220
72295
  active: balanceDto.active,
72221
72296
  bankPk: new PublicKey(balanceDto.bankPk),
72297
+ tag: balanceDto.tag ?? 0,
72222
72298
  assetShares: new BigNumber3(balanceDto.assetShares),
72223
72299
  liabilityShares: new BigNumber3(balanceDto.liabilityShares),
72224
72300
  emissionsOutstanding: new BigNumber3(balanceDto.emissionsOutstanding),
@@ -72250,13 +72326,15 @@ function marginfiAccountToDto(marginfiAccount) {
72250
72326
  balances: marginfiAccount.balances.map(balanceToDto),
72251
72327
  accountFlags: marginfiAccount.accountFlags,
72252
72328
  emissionsDestinationAccount: marginfiAccount.emissionsDestinationAccount.toBase58(),
72253
- healthCache: healthCacheToDto(marginfiAccount.healthCache)
72329
+ healthCache: healthCacheToDto(marginfiAccount.healthCache),
72330
+ activeOrders: marginfiAccount.activeOrders
72254
72331
  };
72255
72332
  }
72256
72333
  function balanceToDto(balance) {
72257
72334
  return {
72258
72335
  active: balance.active,
72259
72336
  bankPk: balance.bankPk.toBase58(),
72337
+ tag: balance.tag,
72260
72338
  assetShares: balance.assetShares.toString(),
72261
72339
  liabilityShares: balance.liabilityShares.toString(),
72262
72340
  emissionsOutstanding: balance.emissionsOutstanding.toString(),
@@ -72565,6 +72643,23 @@ function getBalanceUsdValueWithPriceBias(params) {
72565
72643
  });
72566
72644
  return { assets: assetsValue, liabilities: liabilitiesValue };
72567
72645
  }
72646
+ function computeOrderPairNetValue(params) {
72647
+ const { collateral, debt } = params;
72648
+ const { assets: collateralUsd } = getBalanceUsdValueWithPriceBias({
72649
+ balance: collateral.balance,
72650
+ bank: collateral.bank,
72651
+ oraclePrice: collateral.oraclePrice,
72652
+ marginRequirement: 2 /* Equity */,
72653
+ assetShareValueMultiplier: collateral.assetShareValueMultiplier
72654
+ });
72655
+ const { liabilities: debtUsd } = getBalanceUsdValueWithPriceBias({
72656
+ balance: debt.balance,
72657
+ bank: debt.bank,
72658
+ oraclePrice: debt.oraclePrice,
72659
+ marginRequirement: 2 /* Equity */
72660
+ });
72661
+ return { collateralUsd, debtUsd, netUsd: collateralUsd.minus(debtUsd) };
72662
+ }
72568
72663
  function computeQuantity(balance, bank) {
72569
72664
  const assetsQuantity = getAssetQuantity(bank, balance.assetShares);
72570
72665
  const liabilitiesQuantity = getLiabilityQuantity(bank, balance.liabilityShares);
@@ -72774,6 +72869,7 @@ function createEmptyBalance(bankPk) {
72774
72869
  const balance = {
72775
72870
  active: false,
72776
72871
  bankPk,
72872
+ tag: 0,
72777
72873
  assetShares: new BigNumber3(0),
72778
72874
  liabilityShares: new BigNumber3(0),
72779
72875
  emissionsOutstanding: new BigNumber3(0),
@@ -73076,6 +73172,7 @@ function computeProjectedActiveBalancesNoCpi({
73076
73172
  const projectedBalances = account.balances.map((b) => ({
73077
73173
  active: b.active,
73078
73174
  bankPk: b.bankPk,
73175
+ tag: b.tag,
73079
73176
  assetShares: new BigNumber3(b.assetShares),
73080
73177
  liabilityShares: new BigNumber3(b.liabilityShares),
73081
73178
  emissionsOutstanding: new BigNumber3(b.emissionsOutstanding),
@@ -73349,6 +73446,49 @@ var fetchMarginfiAccountData = async (program, marginfiAccountPk, banksMap, bank
73349
73446
  return { marginfiAccount };
73350
73447
  }
73351
73448
  };
73449
+ var fetchOrder = async (program, orderAddress) => {
73450
+ const orderRaw = await program.account.order.fetchNullable(orderAddress);
73451
+ if (!orderRaw) return null;
73452
+ return parseOrderRaw(orderAddress, orderRaw);
73453
+ };
73454
+ var fetchOrdersForAccount = async (program, marginfiAccount) => {
73455
+ const orders = await program.account.order.all([
73456
+ {
73457
+ memcmp: {
73458
+ bytes: marginfiAccount.toBase58(),
73459
+ offset: 8
73460
+ // first field after the discriminator
73461
+ }
73462
+ }
73463
+ ]);
73464
+ return orders.map(({ publicKey: publicKey5, account }) => parseOrderRaw(publicKey5, account));
73465
+ };
73466
+ var resolveOrderLegs = (marginfiAccount, order) => {
73467
+ const taggedBalances = marginfiAccount.balances.filter(
73468
+ (balance) => balance.active && balance.tag !== 0 && order.tags.includes(balance.tag)
73469
+ );
73470
+ return {
73471
+ collateralBank: taggedBalances.find((balance) => balance.assetShares.gt(0))?.bankPk ?? null,
73472
+ debtBank: taggedBalances.find((balance) => balance.liabilityShares.gt(0))?.bankPk ?? null
73473
+ };
73474
+ };
73475
+ var resolveOrderBanks = (marginfiAccount, order) => {
73476
+ const { collateralBank, debtBank } = resolveOrderLegs(marginfiAccount, order);
73477
+ if (!collateralBank || !debtBank) {
73478
+ throw new Error(
73479
+ `Could not resolve banks for order ${order.address.toBase58()}: tagged balances are missing or closed`
73480
+ );
73481
+ }
73482
+ return { collateralBank, debtBank };
73483
+ };
73484
+ var fetchOrderFees = async (program) => {
73485
+ const [feeStateAddress] = deriveFeeState(program.programId);
73486
+ const feeState = await program.account.feeState.fetch(feeStateAddress);
73487
+ return {
73488
+ placementFeeLamports: feeState.orderInitFlatSolFee,
73489
+ executionMaxFee: wrappedI80F48toBigNumber(feeState.orderExecutionMaxFee)
73490
+ };
73491
+ };
73352
73492
  function randomDistinctIndices(count, maxExclusive) {
73353
73493
  const chosen = /* @__PURE__ */ new Set();
73354
73494
  while (chosen.size < count) {
@@ -78073,6 +78213,7 @@ function generateDummyAccount(group, authority, accountKey) {
78073
78213
  const dummyBalances = Array(15).fill({
78074
78214
  active: false,
78075
78215
  bankPk: new PublicKey("11111111111111111111111111111111"),
78216
+ tag: 0,
78076
78217
  assetShares: dummyWrappedI80F48,
78077
78218
  liabilityShares: dummyWrappedI80F48,
78078
78219
  emissionsOutstanding: dummyWrappedI80F48,
@@ -78081,7 +78222,7 @@ function generateDummyAccount(group, authority, accountKey) {
78081
78222
  const rawAccount = {
78082
78223
  group,
78083
78224
  authority,
78084
- lendingAccount: { balances: dummyBalances },
78225
+ lendingAccount: { balances: dummyBalances, lastTagUsed: 0 },
78085
78226
  healthCache: {
78086
78227
  assetValue: {
78087
78228
  value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
@@ -78103,20 +78244,22 @@ function generateDummyAccount(group, authority, accountKey) {
78103
78244
  mrgnErr: 0
78104
78245
  },
78105
78246
  emissionsDestinationAccount: new PublicKey("11111111111111111111111111111111"),
78106
- accountFlags: new BN8([0, 0, 0])
78247
+ accountFlags: new BN8([0, 0, 0]),
78248
+ activeOrders: 0
78107
78249
  };
78108
78250
  return parseMarginfiAccountRaw(accountKey, rawAccount);
78109
78251
  }
78110
78252
 
78111
78253
  // src/models/balance.ts
78112
78254
  var Balance = class _Balance {
78113
- constructor(active, bankPk, assetShares, liabilityShares, emissionsOutstanding, lastUpdate) {
78255
+ constructor(active, bankPk, assetShares, liabilityShares, emissionsOutstanding, lastUpdate, tag) {
78114
78256
  this.active = active;
78115
78257
  this.bankPk = bankPk;
78116
78258
  this.assetShares = assetShares;
78117
78259
  this.liabilityShares = liabilityShares;
78118
78260
  this.emissionsOutstanding = emissionsOutstanding;
78119
78261
  this.lastUpdate = lastUpdate;
78262
+ this.tag = tag;
78120
78263
  }
78121
78264
  static from(balanceRaw) {
78122
78265
  const props = parseBalanceRaw(balanceRaw);
@@ -78126,7 +78269,8 @@ var Balance = class _Balance {
78126
78269
  props.assetShares,
78127
78270
  props.liabilityShares,
78128
78271
  props.emissionsOutstanding,
78129
- props.lastUpdate
78272
+ props.lastUpdate,
78273
+ props.tag
78130
78274
  );
78131
78275
  }
78132
78276
  static fromBalanceType(balance) {
@@ -78136,7 +78280,8 @@ var Balance = class _Balance {
78136
78280
  balance.assetShares,
78137
78281
  balance.liabilityShares,
78138
78282
  balance.emissionsOutstanding,
78139
- balance.lastUpdate
78283
+ balance.lastUpdate,
78284
+ balance.tag
78140
78285
  );
78141
78286
  }
78142
78287
  static createEmpty(bankPk) {
@@ -78212,7 +78357,7 @@ var HealthCache = class _HealthCache {
78212
78357
 
78213
78358
  // src/models/account.ts
78214
78359
  var MarginfiAccount = class _MarginfiAccount {
78215
- constructor(address, group, authority, balances, accountFlags, emissionsDestinationAccount, healthCache) {
78360
+ constructor(address, group, authority, balances, accountFlags, emissionsDestinationAccount, healthCache, activeOrders = 0) {
78216
78361
  this.address = address;
78217
78362
  this.group = group;
78218
78363
  this.authority = authority;
@@ -78220,6 +78365,7 @@ var MarginfiAccount = class _MarginfiAccount {
78220
78365
  this.accountFlags = accountFlags;
78221
78366
  this.emissionsDestinationAccount = emissionsDestinationAccount;
78222
78367
  this.healthCache = healthCache;
78368
+ this.activeOrders = activeOrders;
78223
78369
  }
78224
78370
  /**
78225
78371
  * Fetches a marginfi account from on-chain data.
@@ -78244,7 +78390,8 @@ var MarginfiAccount = class _MarginfiAccount {
78244
78390
  account.balances.map((b) => Balance.fromBalanceType(b)),
78245
78391
  account.accountFlags,
78246
78392
  account.emissionsDestinationAccount,
78247
- account.healthCache
78393
+ account.healthCache,
78394
+ account.activeOrders
78248
78395
  );
78249
78396
  }
78250
78397
  /**
@@ -78264,7 +78411,8 @@ var MarginfiAccount = class _MarginfiAccount {
78264
78411
  props.balances.map((b) => Balance.fromBalanceType(b)),
78265
78412
  props.accountFlags,
78266
78413
  props.emissionsDestinationAccount,
78267
- HealthCache.fromHealthCacheType(props.healthCache)
78414
+ HealthCache.fromHealthCacheType(props.healthCache),
78415
+ props.activeOrders
78268
78416
  );
78269
78417
  }
78270
78418
  /**
@@ -79100,6 +79248,41 @@ var MarginfiAccount = class _MarginfiAccount {
79100
79248
  }
79101
79249
  });
79102
79250
  }
79251
+ // ----------------------------------------------------------------------------
79252
+ // Orders (take-profit / stop-loss)
79253
+ // ----------------------------------------------------------------------------
79254
+ /**
79255
+ * Creates a place-order instruction for this marginfi account.
79256
+ *
79257
+ * @see {@link makePlaceOrderIx} for detailed implementation
79258
+ */
79259
+ async makePlaceOrderIx(params) {
79260
+ return makePlaceOrderIx2({ ...params, marginfiAccount: this });
79261
+ }
79262
+ /**
79263
+ * Creates a transaction placing a take-profit / stop-loss order on a collateral/debt pair.
79264
+ *
79265
+ * @see {@link makePlaceOrderTx} for detailed implementation
79266
+ */
79267
+ async makePlaceOrderTx(params) {
79268
+ return makePlaceOrderTx({ ...params, marginfiAccount: this });
79269
+ }
79270
+ /**
79271
+ * Creates a transaction closing an existing order.
79272
+ *
79273
+ * @see {@link makeCloseOrderTx} for detailed implementation
79274
+ */
79275
+ async makeCloseOrderTx(params) {
79276
+ return makeCloseOrderTx({ ...params, marginfiAccount: this });
79277
+ }
79278
+ /**
79279
+ * Creates a transaction replacing the pair's existing order with new thresholds.
79280
+ *
79281
+ * @see {@link makeUpdateOrderTx} for detailed implementation
79282
+ */
79283
+ async makeUpdateOrderTx(params) {
79284
+ return makeUpdateOrderTx({ ...params, marginfiAccount: this });
79285
+ }
79103
79286
  /**
79104
79287
  * Creates a repay transaction.
79105
79288
  *
@@ -79257,7 +79440,8 @@ function projectAccountAfterFirstLeg(account, firstLegFlashloanTxs, program, ban
79257
79440
  projectedBalances.map((b) => Balance.fromBalanceType(b)),
79258
79441
  account.accountFlags,
79259
79442
  account.emissionsDestinationAccount,
79260
- account.healthCache
79443
+ account.healthCache,
79444
+ account.activeOrders
79261
79445
  );
79262
79446
  }
79263
79447
  function composeBundle(firstLegTxs, secondLegTxs, payer, blockhash, maxBundleTxs) {
@@ -81660,6 +81844,100 @@ async function makeBulkRepayTx(params) {
81660
81844
  );
81661
81845
  return { transactions, actionTxIndex: 0, mustBeAtomicBundle: false };
81662
81846
  }
81847
+ function buildOrderTrigger(params) {
81848
+ const { stopLossUsd, takeProfitUsd } = params;
81849
+ const maxSlippage = percentToMaxSlippageU32(params.maxSlippagePercent);
81850
+ if (stopLossUsd && takeProfitUsd) {
81851
+ if (takeProfitUsd.lte(stopLossUsd)) {
81852
+ throw new Error(
81853
+ `Take-profit threshold (${takeProfitUsd}) must be above stop-loss threshold (${stopLossUsd})`
81854
+ );
81855
+ }
81856
+ return {
81857
+ both: {
81858
+ stopLoss: bigNumberToWrappedI80F48(stopLossUsd),
81859
+ takeProfit: bigNumberToWrappedI80F48(takeProfitUsd),
81860
+ maxSlippage
81861
+ }
81862
+ };
81863
+ }
81864
+ if (stopLossUsd) {
81865
+ return { stopLoss: { threshold: bigNumberToWrappedI80F48(stopLossUsd), maxSlippage } };
81866
+ }
81867
+ if (takeProfitUsd) {
81868
+ return { takeProfit: { threshold: bigNumberToWrappedI80F48(takeProfitUsd), maxSlippage } };
81869
+ }
81870
+ throw new Error("An order needs a stop-loss threshold, a take-profit threshold, or both");
81871
+ }
81872
+ async function makePlaceOrderIx2(params) {
81873
+ const { program, marginfiAccount, collateralBank, debtBank, trigger, feePayer } = params;
81874
+ const [order] = deriveOrderPda(program.programId, marginfiAccount.address, [
81875
+ collateralBank,
81876
+ debtBank
81877
+ ]);
81878
+ const globalFeeWallet = params.globalFeeWallet ?? (await program.account.feeState.fetch(deriveFeeState(program.programId)[0])).globalFeeWallet;
81879
+ const placeOrderIx = await instructions_default3.makePlaceOrderIx(
81880
+ program,
81881
+ {
81882
+ marginfiAccount: marginfiAccount.address,
81883
+ feePayer: feePayer ?? marginfiAccount.authority,
81884
+ authority: marginfiAccount.authority,
81885
+ order,
81886
+ globalFeeWallet,
81887
+ group: marginfiAccount.group
81888
+ },
81889
+ { bankKeys: [collateralBank, debtBank], trigger: buildOrderTrigger(trigger) }
81890
+ );
81891
+ return { instructions: [placeOrderIx], keys: [] };
81892
+ }
81893
+ async function makeCloseOrderIx2(params) {
81894
+ const { program, marginfiAccount, order, feeRecipient } = params;
81895
+ const closeOrderIx = await instructions_default3.makeCloseOrderIx(program, {
81896
+ marginfiAccount: marginfiAccount.address,
81897
+ authority: marginfiAccount.authority,
81898
+ order,
81899
+ feeRecipient: feeRecipient ?? marginfiAccount.authority,
81900
+ group: marginfiAccount.group
81901
+ });
81902
+ return { instructions: [closeOrderIx], keys: [] };
81903
+ }
81904
+ async function compileOrderTx(params, payerKey, ixs, type) {
81905
+ const blockhash = params.blockhash ?? (await params.connection.getLatestBlockhashAndContext("confirmed")).value.blockhash;
81906
+ return addTransactionMetadata(
81907
+ new VersionedTransaction(
81908
+ new TransactionMessage({
81909
+ instructions: ixs.flatMap((ix) => ix.instructions),
81910
+ payerKey,
81911
+ recentBlockhash: blockhash
81912
+ }).compileToV0Message(params.luts)
81913
+ ),
81914
+ { type, signers: ixs.flatMap((ix) => ix.keys), addressLookupTables: params.luts }
81915
+ );
81916
+ }
81917
+ async function makePlaceOrderTx(params) {
81918
+ const placeIxs = await makePlaceOrderIx2(params);
81919
+ const payerKey = params.feePayer ?? params.marginfiAccount.authority;
81920
+ return compileOrderTx(params, payerKey, [placeIxs], "PLACE_ORDER" /* PLACE_ORDER */);
81921
+ }
81922
+ async function makeCloseOrderTx(params) {
81923
+ const closeIxs = await makeCloseOrderIx2(params);
81924
+ return compileOrderTx(
81925
+ params,
81926
+ params.marginfiAccount.authority,
81927
+ [closeIxs],
81928
+ "CLOSE_ORDER" /* CLOSE_ORDER */
81929
+ );
81930
+ }
81931
+ async function makeUpdateOrderTx(params) {
81932
+ const [order] = deriveOrderPda(params.program.programId, params.marginfiAccount.address, [
81933
+ params.collateralBank,
81934
+ params.debtBank
81935
+ ]);
81936
+ const closeIxs = await makeCloseOrderIx2({ ...params, order, feeRecipient: params.feePayer });
81937
+ const placeIxs = await makePlaceOrderIx2(params);
81938
+ const payerKey = params.feePayer ?? params.marginfiAccount.authority;
81939
+ return compileOrderTx(params, payerKey, [closeIxs, placeIxs], "UPDATE_ORDER" /* UPDATE_ORDER */);
81940
+ }
81663
81941
 
81664
81942
  // src/services/account/services/account-simulation.service.ts
81665
81943
  async function simulateAccountHealthCacheWithFallback(params) {
@@ -84520,6 +84798,52 @@ var MarginfiAccountWrapper = class {
84520
84798
  opts
84521
84799
  });
84522
84800
  }
84801
+ // ----------------------------------------------------------------------------
84802
+ // Orders (take-profit / stop-loss)
84803
+ // ----------------------------------------------------------------------------
84804
+ /**
84805
+ * Creates a transaction placing a take-profit / stop-loss order on a collateral/debt pair.
84806
+ *
84807
+ * @param collateralBank - Bank of the asset-side balance
84808
+ * @param debtBank - Bank of the liability-side balance
84809
+ * @param trigger - USD pair-equity thresholds and max slippage
84810
+ */
84811
+ async makePlaceOrderTx(collateralBank, debtBank, trigger) {
84812
+ return this.account.makePlaceOrderTx({
84813
+ program: this.client.program,
84814
+ collateralBank,
84815
+ debtBank,
84816
+ trigger,
84817
+ luts: this.client.addressLookupTables,
84818
+ connection: this.client.program.provider.connection
84819
+ });
84820
+ }
84821
+ /**
84822
+ * Creates a transaction replacing the pair's existing order with new thresholds.
84823
+ */
84824
+ async makeUpdateOrderTx(collateralBank, debtBank, trigger) {
84825
+ return this.account.makeUpdateOrderTx({
84826
+ program: this.client.program,
84827
+ collateralBank,
84828
+ debtBank,
84829
+ trigger,
84830
+ luts: this.client.addressLookupTables,
84831
+ connection: this.client.program.provider.connection
84832
+ });
84833
+ }
84834
+ /**
84835
+ * Creates a transaction closing an existing order.
84836
+ *
84837
+ * @param order - The order PDA (from `fetchOrdersForAccount` or `deriveOrderPda`)
84838
+ */
84839
+ async makeCloseOrderTx(order) {
84840
+ return this.account.makeCloseOrderTx({
84841
+ program: this.client.program,
84842
+ order,
84843
+ luts: this.client.addressLookupTables,
84844
+ connection: this.client.program.provider.connection
84845
+ });
84846
+ }
84523
84847
  /**
84524
84848
  * Creates a repay transaction with auto-injected client data.
84525
84849
  *
@@ -85204,6 +85528,6 @@ var EmodeSettings = class _EmodeSettings {
85204
85528
  }
85205
85529
  };
85206
85530
 
85207
- 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_BRIDGE_MINTS, DEFAULT_ORACLE_MAX_AGE, DEFAULT_REPAY_ALL_EXTRA_BUFFER_BPS, DISABLED_FLAG, EMPTY_HEALTH_CACHE, EXECUTION_HEADROOM_SECONDS, 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, SECONDS_PER_YEAR, SINGLE_POOL_PROGRAM_ID, STAKED_ORACLE_DISABLED_FLAG, STAKED_ORACLE_USES_ONRAMP_FLAG, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWAP_ADAPTERS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, SwapProvider, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionBuildingError, TransactionBuildingErrorCode, TransactionConfigMap, TransactionType, U64_MAX2 as U64_MAX, USDC_DECIMALS, USDC_MINT, USDT_MINT, VENUE_AVAILABLE_LIQUIDITY_BUFFER, WSOL_MINT, ZERO_ORACLE_KEY, accountConflictsWithBridgeBank, accountFlagToBN, addOracleToBanksIx, addTransactionMetadata, adjustPriceComponent, aprToApy, apyToApr, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankMetadataMapToDto, bankMetadataToDto, bankRateLimiterRawToDto, bankRawToDto, bigNumberToWrappedI80F48, bpsToPercentile, buildCollateralLegIxs, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkJupiterFeeAccount, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, classifyAndValidate, compileFlashloanPrecheck, composeBridgedSwap, composeRemainingAccounts, computeAccountValue, computeAccrualProjectionSeconds, computeActiveEmodePairs, computeAssetHealthComponent, computeAssetUsdValue, computeBalanceUsdValue, computeBankAvailableLiquidity, computeBankBorrowApy, computeBankBorrowCapRemaining, computeBankDepositCapRemaining, computeBankMetrics, computeBankPoolSize, computeBankProjectedAvailableLiquidity, computeBankRateLimitRemaining, computeBankSupplyApy, computeBankTotalBorrows, computeBankTotalBorrowsUsd, computeBankTotalDeposits, computeBankTotalDepositsUsd, computeBaseInterestRate, computeBorrowEstimateForRepay, computeClaimedEmissions, computeClosePositionTokenAmount, computeEmodeImpacts, computeFlashLoanNonSwapBudget, computeFlashloanSwapConstraints, computeFreeCollateralFromBalances, computeFreeCollateralFromCache, computeGroupRateLimitRemainingUsd, computeHealthAccountMetas, computeHealthCacheStatus, computeHealthCheckAccounts, computeHealthComponentsFromBalances, computeHealthComponentsFromCache, computeInterestRates, computeLiabilityHealthComponent, computeLiabilityUsdValue, computeLiquidationPriceForBank, computeLoopingParams, computeLowestEmodeWeights, computeMaxBorrowForBank, computeMaxDepositForBank, computeMaxLeverage, computeMaxWithdrawForBank, computeNetApy, computeOracleMultiplier, computeOracleMultipliers, computeProjectedActiveBalancesNoCpi, computeProjectedActiveBanksNoCpi, computePtMultiplier, computeQuantity, computeQuantityUi, computeRateLimitWindowRemainingCapacity, computeRateLimiterRemainingCapacity, computeRemainingCapacity, computeStakedBankMultipliers, computeTotalOutstandingEmissions, computeTvl, computeUsdValue, computeUtilizationRate, computeV0TxSize, computeVenueAvailableLiquidity, configureScopeOracleIx, convertVoteAccCoeffsToBankCoeffs, createActiveEmodePairFromPairs, createEmptyBalance, decodeAccountRaw, decodeBankRaw, decodeInstruction, decodeMultiplierAccount, 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, fetchGammaLpVault, fetchGammaWithdrawReceipt, fetchMarginfiAccountActiveBalancesForBank, fetchMarginfiAccountAddresses, fetchMarginfiAccountAddressesHoldingBank, fetchMarginfiAccountData, fetchMultipleBanks, fetchMultiplierAccountStates, fetchMultiplierAccountStatesFromAPI, fetchNativeStakeAccounts, fetchOracleData, fetchOracleMultipliers, fetchOracleMultipliersFromAPI, fetchOracleMultipliersFromChain, fetchProgramForMints, fetchPythOracleData, fetchPythOraclePricesFromAPI, fetchPythOraclePricesFromChain, fetchScopeOracleData, fetchScopeOraclePricesFromAPI, fetchScopeOraclePricesFromChain, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, findRandomAvailableAccountIndex, freezeBankConfigIx, generateDummyAccount, getAccountKeys, getActiveAccountFlags, getActiveBalances, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getAssetQuantity, getAssetShares, getAssetWeight, getBalance, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getBirdeyeFallbackPricesByFeedId, getBirdeyePricesForMints, getConfig, getDriftCTokenMultiplier, getDriftMetadata, getDriftStatesDto, getEffectiveDepositLimit, getEmodePairs, getExactOutEstimate, getFallbackPricesByFeedId, getFallbackPricesForMints, getHealthCacheStatusDescription, getHealthSimulationTransactions, getJupLendFTokenMultiplier, getJupLendMetadata, getJupLendStatesDto, getJupiterReferralFeeAccount, getJupiterSwapIxsForFlashloan, getKaminoCTokenMultiplier, getKaminoMetadata, getKaminoStatesDto, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getOracleMultiplierBankInput, getOracleSourceFromBank, getOracleSourceFromOracleSetup, getOracleSourceNameFromKey, getPrice, getPriceWithConfidence, getStakedBankMetadataMap, getSwapAdapter, getSwapIxsForFlashloan, getTitanExactOutEstimate, getTitanSwapIxsForFlashloan, getTotalAccountKeys, getTotalAssetQuantity, getTotalLiabilityQuantity, getTxSize, getValidatorVoteAccountByBank, getWritableAccountKeys, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, isBorrowLimitActive, isBridgeConflictError, isDecomposableSwapError, isDepositIx, isDepositLimitActive, isFlashloan, isGroupRateLimiterEnabled, isStandardBorrowable, isStandardDepositable, isV0Tx, isWeightedPrice, isWholePosition, makeAccountTransferToNewAccountTx, makeAddPermissionlessStakedBankIx, makeBeginFlashLoanIx3 as makeBeginFlashLoanIx, makeBorrowIx3 as makeBorrowIx, makeBorrowTx, makeBridgedLoopTx, makeBridgedSwapCollateralTx, makeBridgedSwapDebtTx, makeBulkRepayTx, makeBulkWithdrawTx, makeBundleTipIx, makeCloseMarginfiAccountIx, makeCloseMarginfiAccountTx, 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, makePulseHealthIx3 as makePulseHealthIx, makeRedeemStakedLstIx, makeRedeemStakedLstTx, makeRefreshIntegrationBanksIxs, makeRefreshKaminoBanksIxs, makeRepayIx3 as makeRepayIx, makeRepayTx, makeRepayWithCollatTx, makeRollPtTx, makeSetupIx, makeSwapCollateralTx, makeSwapDebtTx, makeTransferPositionsTx, makeTxPriorityIx, makeUnwrapSolIx, makeUpdateDriftMarketIxs, makeUpdateJupLendRateIxs, makeVaultCompleteWithdrawalIx, makeVaultCompleteWithdrawalTx, makeVaultDepositIx, makeVaultDepositTx, makeVaultDepositWithSwapTx, makeVaultWithdrawIx, makeVaultWithdrawTx, makeVersionedTransaction, makeWithdrawIx3 as makeWithdrawIx, makeWithdrawTx, makeWrapSolIxs, mapJupiterQuoteToSwapQuoteResult, mapPythBanksToOraclePrices, marginfiAccountToDto, mergeBridgeQuotes, mergeBridgeQuotesDebt, mergeBridgeQuotesLoop, nativeToUi, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRateLimiterRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseHealthCacheRaw, parseMarginfiAccountRaw, parseOperationalState, parseOracleSetup, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseRpcPythPriceData, patchDepositAmount, requireBank, requireTokenProgram, resolveAmount, resolveBridgeCandidateBanks, resolvePinnedSwapRoute, resolveTokenProgramForMint, resolveVaultTokenProgram, runSwapEngine, selectLutsForAccountAction, selectLutsForBanks, selectSwapBridges, serializeBankConfigOpt, serializeInstruction, serializeInterestRateConfig, serializeLut, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, serializeSwapEngineRequest, serializeSwapEngineResult, setOraclePriceIx, sharedBridgeLegContext, shortenAddress, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateBundle, splitInstructionsToFitTransactions, swapEngineProvidersFromOpts, swapEngineQuoteFieldsFromOpts, toBankConfigDto, toBankDto, toBankRateLimiterDto, toBigNumber, toEmodeSettingsDto, toInterestRateConfigDto, toJupiterConfig, toNumber, tryBridgeCandidates, uiToNative, uiToNativeBigNumber, validatorStakeGroupToDto, wrappedI80F48toBigNumber };
85531
+ 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_BRIDGE_MINTS, DEFAULT_ORACLE_MAX_AGE, DEFAULT_REPAY_ALL_EXTRA_BUFFER_BPS, DISABLED_FLAG, EMPTY_HEALTH_CACHE, EXECUTION_HEADROOM_SECONDS, 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, PDA_ORDER_SEED, PRIORITY_TX_SIZE, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID, PriceBias, Project0Client, RiskTier, SECONDS_PER_YEAR, SINGLE_POOL_PROGRAM_ID, STAKED_ORACLE_DISABLED_FLAG, STAKED_ORACLE_USES_ONRAMP_FLAG, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWAP_ADAPTERS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, SwapProvider, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionBuildingError, TransactionBuildingErrorCode, TransactionConfigMap, TransactionType, U64_MAX2 as U64_MAX, USDC_DECIMALS, USDC_MINT, USDT_MINT, VENUE_AVAILABLE_LIQUIDITY_BUFFER, WSOL_MINT, ZERO_ORACLE_KEY, accountConflictsWithBridgeBank, accountFlagToBN, addOracleToBanksIx, addTransactionMetadata, adjustPriceComponent, aprToApy, apyToApr, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankMetadataMapToDto, bankMetadataToDto, bankRateLimiterRawToDto, bankRawToDto, bigNumberToWrappedI80F48, bpsToPercentile, buildCollateralLegIxs, buildOrderTrigger, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkJupiterFeeAccount, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, classifyAndValidate, compileFlashloanPrecheck, composeBridgedSwap, composeRemainingAccounts, computeAccountValue, computeAccrualProjectionSeconds, computeActiveEmodePairs, computeAssetHealthComponent, computeAssetUsdValue, computeBalanceUsdValue, computeBankAvailableLiquidity, computeBankBorrowApy, computeBankBorrowCapRemaining, computeBankDepositCapRemaining, computeBankMetrics, computeBankPoolSize, computeBankProjectedAvailableLiquidity, computeBankRateLimitRemaining, computeBankSupplyApy, computeBankTotalBorrows, computeBankTotalBorrowsUsd, computeBankTotalDeposits, computeBankTotalDepositsUsd, computeBaseInterestRate, computeBorrowEstimateForRepay, computeClaimedEmissions, computeClosePositionTokenAmount, computeEmodeImpacts, computeFlashLoanNonSwapBudget, computeFlashloanSwapConstraints, computeFreeCollateralFromBalances, computeFreeCollateralFromCache, computeGroupRateLimitRemainingUsd, computeHealthAccountMetas, computeHealthCacheStatus, computeHealthCheckAccounts, computeHealthComponentsFromBalances, computeHealthComponentsFromCache, computeInterestRates, computeLiabilityHealthComponent, computeLiabilityUsdValue, computeLiquidationPriceForBank, computeLoopingParams, computeLowestEmodeWeights, computeMaxBorrowForBank, computeMaxDepositForBank, computeMaxLeverage, computeMaxWithdrawForBank, computeNetApy, computeOracleMultiplier, computeOracleMultipliers, computeOrderPairNetValue, computeProjectedActiveBalancesNoCpi, computeProjectedActiveBanksNoCpi, computePtMultiplier, computeQuantity, computeQuantityUi, computeRateLimitWindowRemainingCapacity, computeRateLimiterRemainingCapacity, computeRemainingCapacity, computeStakedBankMultipliers, computeTotalOutstandingEmissions, computeTvl, computeUsdValue, computeUtilizationRate, computeV0TxSize, computeVenueAvailableLiquidity, configureScopeOracleIx, convertVoteAccCoeffsToBankCoeffs, createActiveEmodePairFromPairs, createEmptyBalance, decodeAccountRaw, decodeBankRaw, decodeInstruction, decodeMultiplierAccount, decompileV0Transaction, deriveBankEmissionsAuth, deriveBankEmissionsVault, deriveBankFeeVault, deriveBankFeeVaultAuthority, deriveBankInsuranceVault, deriveBankInsuranceVaultAuthority, deriveBankLiquidityVault, deriveBankLiquidityVaultAuthority, deriveFeeState, deriveMarginfiAccount, deriveOrderPda, 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, fetchGammaLpVault, fetchGammaWithdrawReceipt, fetchMarginfiAccountActiveBalancesForBank, fetchMarginfiAccountAddresses, fetchMarginfiAccountAddressesHoldingBank, fetchMarginfiAccountData, fetchMultipleBanks, fetchMultiplierAccountStates, fetchMultiplierAccountStatesFromAPI, fetchNativeStakeAccounts, fetchOracleData, fetchOracleMultipliers, fetchOracleMultipliersFromAPI, fetchOracleMultipliersFromChain, fetchOrder, fetchOrderFees, fetchOrdersForAccount, fetchProgramForMints, fetchPythOracleData, fetchPythOraclePricesFromAPI, fetchPythOraclePricesFromChain, fetchScopeOracleData, fetchScopeOraclePricesFromAPI, fetchScopeOraclePricesFromChain, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, findRandomAvailableAccountIndex, freezeBankConfigIx, generateDummyAccount, getAccountKeys, getActiveAccountFlags, getActiveBalances, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getAssetQuantity, getAssetShares, getAssetWeight, getBalance, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getBirdeyeFallbackPricesByFeedId, getBirdeyePricesForMints, getConfig, getDriftCTokenMultiplier, getDriftMetadata, getDriftStatesDto, getEffectiveDepositLimit, getEmodePairs, getExactOutEstimate, getFallbackPricesByFeedId, getFallbackPricesForMints, getHealthCacheStatusDescription, getHealthSimulationTransactions, getJupLendFTokenMultiplier, getJupLendMetadata, getJupLendStatesDto, getJupiterReferralFeeAccount, getJupiterSwapIxsForFlashloan, getKaminoCTokenMultiplier, getKaminoMetadata, getKaminoStatesDto, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getOracleMultiplierBankInput, getOracleSourceFromBank, getOracleSourceFromOracleSetup, getOracleSourceNameFromKey, getPrice, getPriceWithConfidence, getStakedBankMetadataMap, getSwapAdapter, getSwapIxsForFlashloan, getTitanExactOutEstimate, getTitanSwapIxsForFlashloan, getTotalAccountKeys, getTotalAssetQuantity, getTotalLiabilityQuantity, getTxSize, getValidatorVoteAccountByBank, getWritableAccountKeys, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, isBorrowLimitActive, isBridgeConflictError, isDecomposableSwapError, isDepositIx, isDepositLimitActive, isFlashloan, isGroupRateLimiterEnabled, isStandardBorrowable, isStandardDepositable, isV0Tx, isWeightedPrice, isWholePosition, makeAccountTransferToNewAccountTx, makeAddPermissionlessStakedBankIx, makeBeginFlashLoanIx3 as makeBeginFlashLoanIx, makeBorrowIx3 as makeBorrowIx, makeBorrowTx, makeBridgedLoopTx, makeBridgedSwapCollateralTx, makeBridgedSwapDebtTx, makeBulkRepayTx, makeBulkWithdrawTx, makeBundleTipIx, makeCloseMarginfiAccountIx, makeCloseMarginfiAccountTx, makeCloseOrderIx2 as makeCloseOrderIx, makeCloseOrderTx, 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, makePlaceOrderIx2 as makePlaceOrderIx, makePlaceOrderTx, makePoolAddBankIx3 as makePoolAddBankIx, makePoolConfigureBankIx3 as makePoolConfigureBankIx, makePriorityFeeIx, makePriorityFeeMicroIx, makePulseHealthIx3 as makePulseHealthIx, makeRedeemStakedLstIx, makeRedeemStakedLstTx, makeRefreshIntegrationBanksIxs, makeRefreshKaminoBanksIxs, makeRepayIx3 as makeRepayIx, makeRepayTx, makeRepayWithCollatTx, makeRollPtTx, makeSetupIx, makeSwapCollateralTx, makeSwapDebtTx, makeTransferPositionsTx, makeTxPriorityIx, makeUnwrapSolIx, makeUpdateDriftMarketIxs, makeUpdateJupLendRateIxs, makeUpdateOrderTx, makeVaultCompleteWithdrawalIx, makeVaultCompleteWithdrawalTx, makeVaultDepositIx, makeVaultDepositTx, makeVaultDepositWithSwapTx, makeVaultWithdrawIx, makeVaultWithdrawTx, makeVersionedTransaction, makeWithdrawIx3 as makeWithdrawIx, makeWithdrawTx, makeWrapSolIxs, mapJupiterQuoteToSwapQuoteResult, mapPythBanksToOraclePrices, marginfiAccountToDto, maxSlippageU32ToPercent, mergeBridgeQuotes, mergeBridgeQuotesDebt, mergeBridgeQuotesLoop, nativeToUi, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRateLimiterRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseHealthCacheRaw, parseMarginfiAccountRaw, parseOperationalState, parseOracleSetup, parseOrderRaw, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseRpcPythPriceData, patchDepositAmount, percentToMaxSlippageU32, requireBank, requireTokenProgram, resolveAmount, resolveBridgeCandidateBanks, resolveOrderBanks, resolveOrderLegs, resolvePinnedSwapRoute, resolveTokenProgramForMint, resolveVaultTokenProgram, runSwapEngine, selectLutsForAccountAction, selectLutsForBanks, selectSwapBridges, serializeBankConfigOpt, serializeInstruction, serializeInterestRateConfig, serializeLut, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, serializeSwapEngineRequest, serializeSwapEngineResult, setOraclePriceIx, sharedBridgeLegContext, shortenAddress, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateBundle, splitInstructionsToFitTransactions, swapEngineProvidersFromOpts, swapEngineQuoteFieldsFromOpts, toBankConfigDto, toBankDto, toBankRateLimiterDto, toBigNumber, toEmodeSettingsDto, toInterestRateConfigDto, toJupiterConfig, toNumber, tryBridgeCandidates, uiToNative, uiToNativeBigNumber, validatorStakeGroupToDto, wrappedI80F48toBigNumber };
85208
85532
  //# sourceMappingURL=index.js.map
85209
85533
  //# sourceMappingURL=index.js.map