@0dotxyz/p0-ts-sdk 2.3.0-alpha.5 → 2.3.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -323,12 +323,11 @@ var MARGINFI_PROGRAM_STAGING_ALT = new web3_js.PublicKey(
323
323
  );
324
324
  var ADDRESS_LOOKUP_TABLE_FOR_GROUP = {
325
325
  "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8": [
326
- new web3_js.PublicKey("BrWF8J3CEuHaXsWk3kqGZ6VHvRp4SJuG9AzvB6ei2kbV"),
327
- new web3_js.PublicKey("8GLUprtyzv6HGrgox7F43EQM5GqE2uKrAHLs69r8DgRj"),
328
- new web3_js.PublicKey("Eg4WY6fmrbhDGfdgSrrTUe6peoUeVhkdXAWT6uvcGKjs"),
329
- new web3_js.PublicKey("qmH8NYYdHkbLYwAdAwnrqiPdBvayjn3DQwRUi9MoXX4")
326
+ new web3_js.PublicKey("8dk6oxKXC4iMLMa8Q4AVtPJPkEfitZuHSB4JqUsLLV2R"),
327
+ new web3_js.PublicKey("43xneYSZYLFkaksMcfBMJANibRiKsWgxkPbsrmcYjqF6"),
328
+ new web3_js.PublicKey("67cS6yqmAy5D1QRJwAXcFv9GLvrMbe88GFGDJcntkL7C")
330
329
  ],
331
- // Main pool
330
+ // Main pool — general group
332
331
  FCPfpHA69EbS8f9KKSreTRkXbzFpunsKuYf5qNmnJjpo: [
333
332
  new web3_js.PublicKey("9p1CwvXMYNEY9CqSwuWySVXsG37NGb36nua94ea5KsiQ")
334
333
  ],
@@ -338,6 +337,13 @@ var ADDRESS_LOOKUP_TABLE_FOR_GROUP = {
338
337
  ]
339
338
  // staging
340
339
  };
340
+ var ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE = {
341
+ "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8": [
342
+ new web3_js.PublicKey("FhVyrX2gfHmxKHq8wWWBJB3ZvHZcAQ6UAcjWxUyfyXuE"),
343
+ new web3_js.PublicKey("GYEJ3BcgwHfNSL2BAuDcth3KKKt9eiK14EHwLCjU9Eoo")
344
+ ]
345
+ // Main pool — native-stake group
346
+ };
341
347
  var ADDRESS_LOOKUP_TABLE_FOR_SWAP = new web3_js.PublicKey(
342
348
  "5X5gDr8Bp9BpizTeZ3VJhxMw4z3q2rwoexJvwttmATs5"
343
349
  );
@@ -14906,6 +14912,99 @@ var marginfi_0_1_8_default = {
14906
14912
 
14907
14913
  // src/idl/index.ts
14908
14914
  var MARGINFI_IDL = marginfi_0_1_8_default;
14915
+
14916
+ // src/services/bank/types/bank.types.ts
14917
+ var RiskTier = /* @__PURE__ */ ((RiskTier3) => {
14918
+ RiskTier3["Collateral"] = "Collateral";
14919
+ RiskTier3["Isolated"] = "Isolated";
14920
+ return RiskTier3;
14921
+ })(RiskTier || {});
14922
+ var OperationalState = /* @__PURE__ */ ((OperationalState3) => {
14923
+ OperationalState3["Paused"] = "Paused";
14924
+ OperationalState3["Operational"] = "Operational";
14925
+ OperationalState3["ReduceOnly"] = "ReduceOnly";
14926
+ OperationalState3["KilledByBankruptcy"] = "KilledByBankruptcy";
14927
+ return OperationalState3;
14928
+ })(OperationalState || {});
14929
+ var OracleSetup = /* @__PURE__ */ ((OracleSetup3) => {
14930
+ OracleSetup3["None"] = "None";
14931
+ OracleSetup3["PythLegacy"] = "PythLegacy";
14932
+ OracleSetup3["SwitchboardV2"] = "SwitchboardV2";
14933
+ OracleSetup3["PythPushOracle"] = "PythPushOracle";
14934
+ OracleSetup3["SwitchboardPull"] = "SwitchboardPull";
14935
+ OracleSetup3["StakedWithPythPush"] = "StakedWithPythPush";
14936
+ OracleSetup3["KaminoPythPush"] = "KaminoPythPush";
14937
+ OracleSetup3["KaminoSwitchboardPull"] = "KaminoSwitchboardPull";
14938
+ OracleSetup3["Fixed"] = "Fixed";
14939
+ OracleSetup3["DriftPythPull"] = "DriftPythPull";
14940
+ OracleSetup3["DriftSwitchboardPull"] = "DriftSwitchboardPull";
14941
+ OracleSetup3["SolendPythPull"] = "SolendPythPull";
14942
+ OracleSetup3["SolendSwitchboardPull"] = "SolendSwitchboardPull";
14943
+ OracleSetup3["FixedKamino"] = "FixedKamino";
14944
+ OracleSetup3["FixedDrift"] = "FixedDrift";
14945
+ OracleSetup3["JuplendPythPull"] = "JuplendPythPull";
14946
+ OracleSetup3["JuplendSwitchboardPull"] = "JuplendSwitchboardPull";
14947
+ OracleSetup3["FixedJuplend"] = "FixedJuplend";
14948
+ return OracleSetup3;
14949
+ })(OracleSetup || {});
14950
+ var AssetTag = /* @__PURE__ */ ((AssetTag3) => {
14951
+ AssetTag3[AssetTag3["DEFAULT"] = 0] = "DEFAULT";
14952
+ AssetTag3[AssetTag3["SOL"] = 1] = "SOL";
14953
+ AssetTag3[AssetTag3["STAKED"] = 2] = "STAKED";
14954
+ AssetTag3[AssetTag3["KAMINO"] = 3] = "KAMINO";
14955
+ AssetTag3[AssetTag3["DRIFT"] = 4] = "DRIFT";
14956
+ AssetTag3[AssetTag3["SOLEND"] = 5] = "SOLEND";
14957
+ AssetTag3[AssetTag3["JUPLEND"] = 6] = "JUPLEND";
14958
+ return AssetTag3;
14959
+ })(AssetTag || {});
14960
+ var BankConfigFlag = /* @__PURE__ */ ((BankConfigFlag3) => {
14961
+ BankConfigFlag3[BankConfigFlag3["PYTH_MIGRATED"] = 1] = "PYTH_MIGRATED";
14962
+ return BankConfigFlag3;
14963
+ })(BankConfigFlag || {});
14964
+ var EmodeEntryFlags = /* @__PURE__ */ ((EmodeEntryFlags2) => {
14965
+ EmodeEntryFlags2[EmodeEntryFlags2["APPLIES_TO_ISOLATED"] = 1] = "APPLIES_TO_ISOLATED";
14966
+ EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_1"] = 2] = "RESERVED_1";
14967
+ EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_2"] = 4] = "RESERVED_2";
14968
+ EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_3"] = 8] = "RESERVED_3";
14969
+ EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_4"] = 16] = "RESERVED_4";
14970
+ EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_5"] = 32] = "RESERVED_5";
14971
+ return EmodeEntryFlags2;
14972
+ })(EmodeEntryFlags || {});
14973
+ var EmodeFlags = /* @__PURE__ */ ((EmodeFlags3) => {
14974
+ EmodeFlags3[EmodeFlags3["EMODE_ON"] = 1] = "EMODE_ON";
14975
+ EmodeFlags3[EmodeFlags3["RESERVED_1"] = 2] = "RESERVED_1";
14976
+ EmodeFlags3[EmodeFlags3["RESERVED_2"] = 4] = "RESERVED_2";
14977
+ EmodeFlags3[EmodeFlags3["RESERVED_3"] = 8] = "RESERVED_3";
14978
+ return EmodeFlags3;
14979
+ })(EmodeFlags || {});
14980
+ var EmodeTag = /* @__PURE__ */ ((EmodeTag3) => {
14981
+ EmodeTag3[EmodeTag3["UNSET"] = 0] = "UNSET";
14982
+ EmodeTag3[EmodeTag3["SOL"] = 501] = "SOL";
14983
+ EmodeTag3[EmodeTag3["LST_T1"] = 1571] = "LST_T1";
14984
+ EmodeTag3[EmodeTag3["LST_T2"] = 1572] = "LST_T2";
14985
+ EmodeTag3[EmodeTag3["LST_PT"] = 15787] = "LST_PT";
14986
+ EmodeTag3[EmodeTag3["JLP"] = 619] = "JLP";
14987
+ EmodeTag3[EmodeTag3["STABLE_T1"] = 57481] = "STABLE_T1";
14988
+ EmodeTag3[EmodeTag3["STABLE_T2"] = 57482] = "STABLE_T2";
14989
+ EmodeTag3[EmodeTag3["BTC_T1"] = 871] = "BTC_T1";
14990
+ EmodeTag3[EmodeTag3["BTC_T2"] = 872] = "BTC_T2";
14991
+ return EmodeTag3;
14992
+ })(EmodeTag || {});
14993
+ var EmodeImpactStatus = /* @__PURE__ */ ((EmodeImpactStatus3) => {
14994
+ EmodeImpactStatus3[EmodeImpactStatus3["ActivateEmode"] = 0] = "ActivateEmode";
14995
+ EmodeImpactStatus3[EmodeImpactStatus3["ExtendEmode"] = 1] = "ExtendEmode";
14996
+ EmodeImpactStatus3[EmodeImpactStatus3["IncreaseEmode"] = 2] = "IncreaseEmode";
14997
+ EmodeImpactStatus3[EmodeImpactStatus3["ReduceEmode"] = 3] = "ReduceEmode";
14998
+ EmodeImpactStatus3[EmodeImpactStatus3["RemoveEmode"] = 4] = "RemoveEmode";
14999
+ EmodeImpactStatus3[EmodeImpactStatus3["InactiveEmode"] = 5] = "InactiveEmode";
15000
+ return EmodeImpactStatus3;
15001
+ })(EmodeImpactStatus || {});
15002
+ var BankVaultType = /* @__PURE__ */ ((BankVaultType2) => {
15003
+ BankVaultType2[BankVaultType2["LiquidityVault"] = 0] = "LiquidityVault";
15004
+ BankVaultType2[BankVaultType2["InsuranceVault"] = 1] = "InsuranceVault";
15005
+ BankVaultType2[BankVaultType2["FeeVault"] = 2] = "FeeVault";
15006
+ return BankVaultType2;
15007
+ })(BankVaultType || {});
14909
15008
  function decodeInstruction(idl, encoded) {
14910
15009
  const coder = new anchor.BorshInstructionCoder(idl);
14911
15010
  return coder.decode(encoded, "base58");
@@ -15018,6 +15117,37 @@ function getTotalAccountKeys(tx) {
15018
15117
  }
15019
15118
 
15020
15119
  // src/services/transaction/helpers/tx-formatting.ts
15120
+ var NATIVE_STAKE_LUT_KEYS = new Set(
15121
+ Object.values(ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE).flat().map((key) => key.toBase58())
15122
+ );
15123
+ function selectLutsForBanks(luts, banks) {
15124
+ const nativeStakeLuts = luts.filter(
15125
+ (lut) => NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58())
15126
+ );
15127
+ const generalLuts = luts.filter(
15128
+ (lut) => !NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58())
15129
+ );
15130
+ const allStakedOrSol = banks.length > 0 && banks.every(
15131
+ (bank) => bank.config.assetTag === 2 /* STAKED */ || bank.config.assetTag === 1 /* SOL */
15132
+ );
15133
+ if (allStakedOrSol && nativeStakeLuts.length > 0) {
15134
+ return nativeStakeLuts;
15135
+ }
15136
+ return generalLuts.length > 0 ? generalLuts : luts;
15137
+ }
15138
+ function selectLutsForAccountAction(luts, targetBank, balances, bankMap, extraBankAddresses = []) {
15139
+ const banks = [targetBank];
15140
+ for (const balance of balances) {
15141
+ if (!balance.active) continue;
15142
+ const bank = bankMap.get(balance.bankPk.toBase58());
15143
+ if (bank) banks.push(bank);
15144
+ }
15145
+ for (const address of extraBankAddresses) {
15146
+ const bank = bankMap.get(address.toBase58());
15147
+ if (bank) banks.push(bank);
15148
+ }
15149
+ return selectLutsForBanks(luts, banks);
15150
+ }
15021
15151
  function isV0Tx(tx) {
15022
15152
  return "message" in tx;
15023
15153
  }
@@ -15728,101 +15858,6 @@ var instructions = {
15728
15858
  makePulseHealthIx
15729
15859
  };
15730
15860
  var instructions_default = instructions;
15731
-
15732
- // src/services/bank/types/bank.types.ts
15733
- var RiskTier = /* @__PURE__ */ ((RiskTier3) => {
15734
- RiskTier3["Collateral"] = "Collateral";
15735
- RiskTier3["Isolated"] = "Isolated";
15736
- return RiskTier3;
15737
- })(RiskTier || {});
15738
- var OperationalState = /* @__PURE__ */ ((OperationalState3) => {
15739
- OperationalState3["Paused"] = "Paused";
15740
- OperationalState3["Operational"] = "Operational";
15741
- OperationalState3["ReduceOnly"] = "ReduceOnly";
15742
- OperationalState3["KilledByBankruptcy"] = "KilledByBankruptcy";
15743
- return OperationalState3;
15744
- })(OperationalState || {});
15745
- var OracleSetup = /* @__PURE__ */ ((OracleSetup3) => {
15746
- OracleSetup3["None"] = "None";
15747
- OracleSetup3["PythLegacy"] = "PythLegacy";
15748
- OracleSetup3["SwitchboardV2"] = "SwitchboardV2";
15749
- OracleSetup3["PythPushOracle"] = "PythPushOracle";
15750
- OracleSetup3["SwitchboardPull"] = "SwitchboardPull";
15751
- OracleSetup3["StakedWithPythPush"] = "StakedWithPythPush";
15752
- OracleSetup3["KaminoPythPush"] = "KaminoPythPush";
15753
- OracleSetup3["KaminoSwitchboardPull"] = "KaminoSwitchboardPull";
15754
- OracleSetup3["Fixed"] = "Fixed";
15755
- OracleSetup3["DriftPythPull"] = "DriftPythPull";
15756
- OracleSetup3["DriftSwitchboardPull"] = "DriftSwitchboardPull";
15757
- OracleSetup3["SolendPythPull"] = "SolendPythPull";
15758
- OracleSetup3["SolendSwitchboardPull"] = "SolendSwitchboardPull";
15759
- OracleSetup3["FixedKamino"] = "FixedKamino";
15760
- OracleSetup3["FixedDrift"] = "FixedDrift";
15761
- OracleSetup3["JuplendPythPull"] = "JuplendPythPull";
15762
- OracleSetup3["JuplendSwitchboardPull"] = "JuplendSwitchboardPull";
15763
- OracleSetup3["FixedJuplend"] = "FixedJuplend";
15764
- return OracleSetup3;
15765
- })(OracleSetup || {});
15766
- var AssetTag = /* @__PURE__ */ ((AssetTag3) => {
15767
- AssetTag3[AssetTag3["DEFAULT"] = 0] = "DEFAULT";
15768
- AssetTag3[AssetTag3["SOL"] = 1] = "SOL";
15769
- AssetTag3[AssetTag3["STAKED"] = 2] = "STAKED";
15770
- AssetTag3[AssetTag3["KAMINO"] = 3] = "KAMINO";
15771
- AssetTag3[AssetTag3["DRIFT"] = 4] = "DRIFT";
15772
- AssetTag3[AssetTag3["SOLEND"] = 5] = "SOLEND";
15773
- AssetTag3[AssetTag3["JUPLEND"] = 6] = "JUPLEND";
15774
- return AssetTag3;
15775
- })(AssetTag || {});
15776
- var BankConfigFlag = /* @__PURE__ */ ((BankConfigFlag3) => {
15777
- BankConfigFlag3[BankConfigFlag3["PYTH_MIGRATED"] = 1] = "PYTH_MIGRATED";
15778
- return BankConfigFlag3;
15779
- })(BankConfigFlag || {});
15780
- var EmodeEntryFlags = /* @__PURE__ */ ((EmodeEntryFlags2) => {
15781
- EmodeEntryFlags2[EmodeEntryFlags2["APPLIES_TO_ISOLATED"] = 1] = "APPLIES_TO_ISOLATED";
15782
- EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_1"] = 2] = "RESERVED_1";
15783
- EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_2"] = 4] = "RESERVED_2";
15784
- EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_3"] = 8] = "RESERVED_3";
15785
- EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_4"] = 16] = "RESERVED_4";
15786
- EmodeEntryFlags2[EmodeEntryFlags2["RESERVED_5"] = 32] = "RESERVED_5";
15787
- return EmodeEntryFlags2;
15788
- })(EmodeEntryFlags || {});
15789
- var EmodeFlags = /* @__PURE__ */ ((EmodeFlags3) => {
15790
- EmodeFlags3[EmodeFlags3["EMODE_ON"] = 1] = "EMODE_ON";
15791
- EmodeFlags3[EmodeFlags3["RESERVED_1"] = 2] = "RESERVED_1";
15792
- EmodeFlags3[EmodeFlags3["RESERVED_2"] = 4] = "RESERVED_2";
15793
- EmodeFlags3[EmodeFlags3["RESERVED_3"] = 8] = "RESERVED_3";
15794
- return EmodeFlags3;
15795
- })(EmodeFlags || {});
15796
- var EmodeTag = /* @__PURE__ */ ((EmodeTag3) => {
15797
- EmodeTag3[EmodeTag3["UNSET"] = 0] = "UNSET";
15798
- EmodeTag3[EmodeTag3["SOL"] = 501] = "SOL";
15799
- EmodeTag3[EmodeTag3["LST_T1"] = 1571] = "LST_T1";
15800
- EmodeTag3[EmodeTag3["LST_T2"] = 1572] = "LST_T2";
15801
- EmodeTag3[EmodeTag3["LST_PT"] = 15787] = "LST_PT";
15802
- EmodeTag3[EmodeTag3["JLP"] = 619] = "JLP";
15803
- EmodeTag3[EmodeTag3["STABLE_T1"] = 57481] = "STABLE_T1";
15804
- EmodeTag3[EmodeTag3["STABLE_T2"] = 57482] = "STABLE_T2";
15805
- EmodeTag3[EmodeTag3["BTC_T1"] = 871] = "BTC_T1";
15806
- EmodeTag3[EmodeTag3["BTC_T2"] = 872] = "BTC_T2";
15807
- return EmodeTag3;
15808
- })(EmodeTag || {});
15809
- var EmodeImpactStatus = /* @__PURE__ */ ((EmodeImpactStatus3) => {
15810
- EmodeImpactStatus3[EmodeImpactStatus3["ActivateEmode"] = 0] = "ActivateEmode";
15811
- EmodeImpactStatus3[EmodeImpactStatus3["ExtendEmode"] = 1] = "ExtendEmode";
15812
- EmodeImpactStatus3[EmodeImpactStatus3["IncreaseEmode"] = 2] = "IncreaseEmode";
15813
- EmodeImpactStatus3[EmodeImpactStatus3["ReduceEmode"] = 3] = "ReduceEmode";
15814
- EmodeImpactStatus3[EmodeImpactStatus3["RemoveEmode"] = 4] = "RemoveEmode";
15815
- EmodeImpactStatus3[EmodeImpactStatus3["InactiveEmode"] = 5] = "InactiveEmode";
15816
- return EmodeImpactStatus3;
15817
- })(EmodeImpactStatus || {});
15818
- var BankVaultType = /* @__PURE__ */ ((BankVaultType2) => {
15819
- BankVaultType2[BankVaultType2["LiquidityVault"] = 0] = "LiquidityVault";
15820
- BankVaultType2[BankVaultType2["InsuranceVault"] = 1] = "InsuranceVault";
15821
- BankVaultType2[BankVaultType2["FeeVault"] = 2] = "FeeVault";
15822
- return BankVaultType2;
15823
- })(BankVaultType || {});
15824
-
15825
- // src/services/bank/utils/serialize.utils.ts
15826
15861
  function serializeBankConfigOpt(bankConfigOpt) {
15827
15862
  const toWrappedI80F48 = (value) => value && bigNumberToWrappedI80F48(value);
15828
15863
  const toBN = (value) => value && new BN11__default.default(value.toString());
@@ -59193,6 +59228,12 @@ async function makeDriftWithdrawIx3({
59193
59228
  }
59194
59229
  async function makeDriftWithdrawTx(params) {
59195
59230
  const { luts, connection, ...withdrawIxParams } = params;
59231
+ const selectedLuts = selectLutsForAccountAction(
59232
+ luts,
59233
+ withdrawIxParams.bank,
59234
+ params.marginfiAccount.balances,
59235
+ params.bankMap
59236
+ );
59196
59237
  const hasLiabilities = params.marginfiAccount.balances.some((balance) => {
59197
59238
  return balance.liabilityShares.gt(0);
59198
59239
  });
@@ -59263,7 +59304,7 @@ async function makeDriftWithdrawTx(params) {
59263
59304
  ],
59264
59305
  payerKey: params.authority,
59265
59306
  recentBlockhash: blockhash
59266
- }).compileToV0Message(luts)
59307
+ }).compileToV0Message(selectedLuts)
59267
59308
  ),
59268
59309
  {
59269
59310
  signers: [
@@ -59272,7 +59313,7 @@ async function makeDriftWithdrawTx(params) {
59272
59313
  ...updateJupLendRateIxs.keys,
59273
59314
  ...withdrawIxs.keys
59274
59315
  ],
59275
- addressLookupTables: luts,
59316
+ addressLookupTables: selectedLuts,
59276
59317
  type: "WITHDRAW" /* WITHDRAW */
59277
59318
  }
59278
59319
  );
@@ -59477,6 +59518,12 @@ async function makeWithdrawIx3({
59477
59518
  }
59478
59519
  async function makeWithdrawTx(params) {
59479
59520
  const { luts, connection, ...withdrawIxParams } = params;
59521
+ const selectedLuts = selectLutsForAccountAction(
59522
+ luts,
59523
+ withdrawIxParams.bank,
59524
+ params.marginfiAccount.balances,
59525
+ params.bankMap
59526
+ );
59480
59527
  const hasLiabilities = params.marginfiAccount.balances.some((balance) => {
59481
59528
  return balance.liabilityShares.gt(0);
59482
59529
  });
@@ -59547,7 +59594,7 @@ async function makeWithdrawTx(params) {
59547
59594
  ],
59548
59595
  payerKey: params.authority,
59549
59596
  recentBlockhash: blockhash
59550
- }).compileToV0Message(luts)
59597
+ }).compileToV0Message(selectedLuts)
59551
59598
  ),
59552
59599
  {
59553
59600
  signers: [
@@ -59556,7 +59603,7 @@ async function makeWithdrawTx(params) {
59556
59603
  ...updateJupLendRateIxs.keys,
59557
59604
  ...withdrawIxs.keys
59558
59605
  ],
59559
- addressLookupTables: luts,
59606
+ addressLookupTables: selectedLuts,
59560
59607
  type: "WITHDRAW" /* WITHDRAW */
59561
59608
  }
59562
59609
  );
@@ -59565,6 +59612,12 @@ async function makeWithdrawTx(params) {
59565
59612
  }
59566
59613
  async function makeKaminoWithdrawTx(params) {
59567
59614
  const { luts, connection, amount, assetShareValueMultiplierByBank, ...withdrawIxParams } = params;
59615
+ const selectedLuts = selectLutsForAccountAction(
59616
+ luts,
59617
+ withdrawIxParams.bank,
59618
+ params.marginfiAccount.balances,
59619
+ params.bankMap
59620
+ );
59568
59621
  if (!withdrawIxParams.bank.kaminoIntegrationAccounts) {
59569
59622
  throw new Error("Bank has no kamino integration accounts");
59570
59623
  }
@@ -59635,7 +59688,7 @@ async function makeKaminoWithdrawTx(params) {
59635
59688
  ],
59636
59689
  payerKey: params.authority,
59637
59690
  recentBlockhash: blockhash
59638
- }).compileToV0Message(luts)
59691
+ }).compileToV0Message(selectedLuts)
59639
59692
  ),
59640
59693
  {
59641
59694
  signers: [
@@ -59644,7 +59697,7 @@ async function makeKaminoWithdrawTx(params) {
59644
59697
  ...updateJupLendRateIxs.keys,
59645
59698
  ...withdrawIxs.keys
59646
59699
  ],
59647
- addressLookupTables: luts,
59700
+ addressLookupTables: selectedLuts,
59648
59701
  type: "WITHDRAW" /* WITHDRAW */
59649
59702
  }
59650
59703
  );
@@ -59739,6 +59792,12 @@ async function makeJuplendWithdrawIx2({
59739
59792
  }
59740
59793
  async function makeJuplendWithdrawTx(params) {
59741
59794
  const { luts, connection, ...withdrawIxParams } = params;
59795
+ const selectedLuts = selectLutsForAccountAction(
59796
+ luts,
59797
+ withdrawIxParams.bank,
59798
+ params.marginfiAccount.balances,
59799
+ params.bankMap
59800
+ );
59742
59801
  const hasLiabilities = params.marginfiAccount.balances.some((balance) => {
59743
59802
  return balance.liabilityShares.gt(0);
59744
59803
  });
@@ -59809,11 +59868,11 @@ async function makeJuplendWithdrawTx(params) {
59809
59868
  ],
59810
59869
  payerKey: params.authority,
59811
59870
  recentBlockhash: blockhash
59812
- }).compileToV0Message(luts)
59871
+ }).compileToV0Message(selectedLuts)
59813
59872
  ),
59814
59873
  {
59815
59874
  signers: [...refreshIxs.keys, ...withdrawIxs.keys],
59816
- addressLookupTables: luts,
59875
+ addressLookupTables: selectedLuts,
59817
59876
  type: "WITHDRAW" /* WITHDRAW */
59818
59877
  }
59819
59878
  );
@@ -59906,6 +59965,13 @@ async function makeBorrowIx3({
59906
59965
  }
59907
59966
  async function makeBorrowTx(params) {
59908
59967
  const { luts, connection, ...borrowIxParams } = params;
59968
+ const selectedLuts = selectLutsForAccountAction(
59969
+ luts,
59970
+ borrowIxParams.bank,
59971
+ params.marginfiAccount.balances,
59972
+ params.bankMap,
59973
+ borrowIxParams.opts?.additionalHealthCheckBanks
59974
+ );
59909
59975
  const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
59910
59976
  params.marginfiAccount,
59911
59977
  params.bankMap,
@@ -59967,11 +60033,11 @@ async function makeBorrowTx(params) {
59967
60033
  ],
59968
60034
  payerKey: params.authority,
59969
60035
  recentBlockhash: blockhash
59970
- }).compileToV0Message(luts)
60036
+ }).compileToV0Message(selectedLuts)
59971
60037
  ),
59972
60038
  {
59973
60039
  signers: [...kaminoRefreshIxs.keys, ...borrowIxs.keys],
59974
- addressLookupTables: luts,
60040
+ addressLookupTables: selectedLuts,
59975
60041
  type: "BORROW" /* BORROW */
59976
60042
  }
59977
60043
  );
@@ -60053,6 +60119,7 @@ async function makeDriftDepositIx3({
60053
60119
  }
60054
60120
  async function makeDriftDepositTx(params) {
60055
60121
  const { luts, connection, amount, ...depositIxParams } = params;
60122
+ const selectedLuts = selectLutsForBanks(luts, [depositIxParams.bank]);
60056
60123
  if (!depositIxParams.bank.driftIntegrationAccounts) {
60057
60124
  throw new Error("Bank has no drift integration accounts");
60058
60125
  }
@@ -60067,18 +60134,18 @@ async function makeDriftDepositTx(params) {
60067
60134
  instructions: [...depositIxs.instructions],
60068
60135
  payerKey: params.authority,
60069
60136
  recentBlockhash: blockhash
60070
- }).compileToV0Message(luts)
60137
+ }).compileToV0Message(selectedLuts)
60071
60138
  ),
60072
60139
  {
60073
60140
  signers: depositIxs.keys,
60074
- addressLookupTables: luts,
60141
+ addressLookupTables: selectedLuts,
60075
60142
  type: "DEPOSIT" /* DEPOSIT */
60076
60143
  }
60077
60144
  );
60078
60145
  const solanaTx = addTransactionMetadata(depositTx, {
60079
60146
  type: "DEPOSIT" /* DEPOSIT */,
60080
60147
  signers: depositIxs.keys,
60081
- addressLookupTables: luts
60148
+ addressLookupTables: selectedLuts
60082
60149
  });
60083
60150
  return solanaTx;
60084
60151
  }
@@ -60170,6 +60237,7 @@ async function makeKaminoDepositIx3({
60170
60237
  }
60171
60238
  async function makeKaminoDepositTx(params) {
60172
60239
  const { luts, connection, amount, ...depositIxParams } = params;
60240
+ const selectedLuts = selectLutsForBanks(luts, [depositIxParams.bank]);
60173
60241
  if (!depositIxParams.bank.kaminoIntegrationAccounts) {
60174
60242
  throw new Error("Bank has no kamino integration accounts");
60175
60243
  }
@@ -60203,18 +60271,18 @@ async function makeKaminoDepositTx(params) {
60203
60271
  instructions: [...refreshIxs, ...depositIxs.instructions],
60204
60272
  payerKey: params.authority,
60205
60273
  recentBlockhash: blockhash
60206
- }).compileToV0Message(luts)
60274
+ }).compileToV0Message(selectedLuts)
60207
60275
  ),
60208
60276
  {
60209
60277
  signers: depositIxs.keys,
60210
- addressLookupTables: luts,
60278
+ addressLookupTables: selectedLuts,
60211
60279
  type: "DEPOSIT" /* DEPOSIT */
60212
60280
  }
60213
60281
  );
60214
60282
  const solanaTx = addTransactionMetadata(depositTx, {
60215
60283
  type: "DEPOSIT" /* DEPOSIT */,
60216
60284
  signers: depositIxs.keys,
60217
- addressLookupTables: luts
60285
+ addressLookupTables: selectedLuts
60218
60286
  });
60219
60287
  return solanaTx;
60220
60288
  }
@@ -60280,10 +60348,11 @@ async function makeDepositTx(params) {
60280
60348
  const ixs = await makeDepositIx3(depositIxParams);
60281
60349
  const tx = new web3_js.Transaction().add(...ixs.instructions);
60282
60350
  tx.feePayer = params.authority;
60351
+ const selectedLuts = selectLutsForBanks(luts, [depositIxParams.bank]);
60283
60352
  const solanaTx = addTransactionMetadata(tx, {
60284
60353
  type: "DEPOSIT" /* DEPOSIT */,
60285
60354
  signers: ixs.keys,
60286
- addressLookupTables: luts
60355
+ addressLookupTables: selectedLuts
60287
60356
  });
60288
60357
  return solanaTx;
60289
60358
  }
@@ -60355,6 +60424,7 @@ async function makeJuplendDepositIx2({
60355
60424
  }
60356
60425
  async function makeJuplendDepositTx(params) {
60357
60426
  const { luts, connection, amount, ...depositIxParams } = params;
60427
+ const selectedLuts = selectLutsForBanks(luts, [depositIxParams.bank]);
60358
60428
  if (!depositIxParams.bank.jupLendIntegrationAccounts) {
60359
60429
  throw new Error("Bank has no JupLend integration accounts");
60360
60430
  }
@@ -60369,18 +60439,18 @@ async function makeJuplendDepositTx(params) {
60369
60439
  instructions: [...depositIxs.instructions],
60370
60440
  payerKey: params.authority,
60371
60441
  recentBlockhash: blockhash
60372
- }).compileToV0Message(luts)
60442
+ }).compileToV0Message(selectedLuts)
60373
60443
  ),
60374
60444
  {
60375
60445
  signers: depositIxs.keys,
60376
- addressLookupTables: luts,
60446
+ addressLookupTables: selectedLuts,
60377
60447
  type: "DEPOSIT" /* DEPOSIT */
60378
60448
  }
60379
60449
  );
60380
60450
  const solanaTx = addTransactionMetadata(depositTx, {
60381
60451
  type: "DEPOSIT" /* DEPOSIT */,
60382
60452
  signers: depositIxs.keys,
60383
- addressLookupTables: luts
60453
+ addressLookupTables: selectedLuts
60384
60454
  });
60385
60455
  return solanaTx;
60386
60456
  }
@@ -61351,6 +61421,12 @@ async function buildCandidates2(req, apiConfig) {
61351
61421
  transaction: {
61352
61422
  userPublicKey: req.taker.toBytes(),
61353
61423
  outputAccount: req.destinationTokenAccount.toBytes(),
61424
+ // Keep a wSOL output wrapped in the destination ATA (the analog of
61425
+ // Jupiter's `wrapAndUnwrapSol: false`). Our flashloan flows consume the
61426
+ // output with a subsequent marginfi ix built with `wrapAndUnwrapSol:
61427
+ // false`, so the wSOL must NOT be unwrapped to native lamports. Ignored
61428
+ // by Titan when the output mint isn't wSOL.
61429
+ outputWsol: true,
61354
61430
  titanSwapVersion: 3 /* V3 */,
61355
61431
  ...fee !== void 0 && feeAccount ? { feeBps: fee, feeAccount: new web3_js.PublicKey(feeAccount).toBytes() } : {}
61356
61432
  },
@@ -61590,10 +61666,11 @@ async function makeRepayTx(params) {
61590
61666
  const ixs = await makeRepayIx3(depositIxParams);
61591
61667
  const tx = new web3_js.Transaction().add(...ixs.instructions);
61592
61668
  tx.feePayer = params.authority;
61669
+ const selectedLuts = selectLutsForBanks(luts, [depositIxParams.bank]);
61593
61670
  const solanaTx = addTransactionMetadata(tx, {
61594
61671
  type: "REPAY" /* REPAY */,
61595
61672
  signers: ixs.keys,
61596
- addressLookupTables: luts
61673
+ addressLookupTables: selectedLuts
61597
61674
  });
61598
61675
  return solanaTx;
61599
61676
  }
@@ -61730,7 +61807,7 @@ async function buildRepayWithCollatFlashloanTx({
61730
61807
  const swapNeeded = !repayOpts.repayBank.mint.equals(withdrawOpts.withdrawBank.mint);
61731
61808
  let amountToRepay = swapNeeded ? 0 : withdrawOpts.withdrawAmount;
61732
61809
  let swapInstructions = [];
61733
- const setupInstructions = [];
61810
+ let setupInstructions = [];
61734
61811
  let swapLookupTables = [];
61735
61812
  let swapQuote;
61736
61813
  let sizeConstraintUsed = 0;
@@ -61943,6 +62020,7 @@ async function buildRepayWithCollatFlashloanTx({
61943
62020
  );
61944
62021
  amountToRepay = outAmount > repayOpts.totalPositionAmount ? repayOpts.totalPositionAmount : outAmountThreshold;
61945
62022
  swapInstructions = engineResult.swapInstructions;
62023
+ setupInstructions = engineResult.setupInstructions;
61946
62024
  swapLookupTables = engineResult.swapLuts;
61947
62025
  swapQuote = engineResult.quoteResponse;
61948
62026
  }
@@ -70030,11 +70108,15 @@ var Project0Client = class _Project0Client {
70030
70108
  });
70031
70109
  }
70032
70110
  });
70033
- const lutKeys = ADDRESS_LOOKUP_TABLE_FOR_GROUP[groupPk.toBase58()];
70034
- let addressLookupTables = [];
70035
- if (lutKeys) {
70036
- addressLookupTables = (await Promise.all(lutKeys.map((lut) => connection.getAddressLookupTable(lut)))).map((response) => response?.value ?? null).filter((table) => table !== null);
70037
- }
70111
+ const fetchLuts = async (keys) => {
70112
+ if (!keys || keys.length === 0) return [];
70113
+ return (await Promise.all(keys.map((lut) => connection.getAddressLookupTable(lut)))).map((response) => response?.value ?? null).filter((table) => table !== null);
70114
+ };
70115
+ const [generalLuts, nativeStakeLuts] = await Promise.all([
70116
+ fetchLuts(ADDRESS_LOOKUP_TABLE_FOR_GROUP[groupPk.toBase58()]),
70117
+ fetchLuts(ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE[groupPk.toBase58()])
70118
+ ]);
70119
+ const addressLookupTables = [...generalLuts, ...nativeStakeLuts];
70038
70120
  const bankIntegrationMap = await fetchBankIntegrationMetadata({
70039
70121
  connection,
70040
70122
  banks: banksArray
@@ -70143,6 +70225,7 @@ var EmodeSettings = class _EmodeSettings {
70143
70225
  };
70144
70226
 
70145
70227
  exports.ADDRESS_LOOKUP_TABLE_FOR_GROUP = ADDRESS_LOOKUP_TABLE_FOR_GROUP;
70228
+ exports.ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE = ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE;
70146
70229
  exports.ADDRESS_LOOKUP_TABLE_FOR_SWAP = ADDRESS_LOOKUP_TABLE_FOR_SWAP;
70147
70230
  exports.AccountFlags = AccountFlags;
70148
70231
  exports.AccountType = AccountType;
@@ -70508,6 +70591,8 @@ exports.partitionBanksByCrankability = partitionBanksByCrankability;
70508
70591
  exports.patchDepositAmount = patchDepositAmount;
70509
70592
  exports.resolveAmount = resolveAmount;
70510
70593
  exports.runSwapEngine = runSwapEngine;
70594
+ exports.selectLutsForAccountAction = selectLutsForAccountAction;
70595
+ exports.selectLutsForBanks = selectLutsForBanks;
70511
70596
  exports.serializeBankConfigOpt = serializeBankConfigOpt;
70512
70597
  exports.serializeInstruction = serializeInstruction;
70513
70598
  exports.serializeInterestRateConfig = serializeInterestRateConfig;