@perena/vault-sdk 1.0.67 → 1.0.68

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
@@ -156,7 +156,7 @@ var require_compat = __commonJS({
156
156
  exports2.fromWeb3PublicKey = fromWeb3PublicKey;
157
157
  exports2.toWeb3PublicKey = toWeb3PublicKey;
158
158
  exports2.asWeb3PublicKey = asWeb3PublicKey2;
159
- exports2.toKitInstruction = toKitInstruction43;
159
+ exports2.toKitInstruction = toKitInstruction45;
160
160
  exports2.fromKitInstruction = fromKitInstruction3;
161
161
  var kit_1 = require("@solana/kit");
162
162
  var web3_js_1 = require("@solana/web3.js");
@@ -172,7 +172,7 @@ var require_compat = __commonJS({
172
172
  exports2.toAddress = fromWeb3PublicKey;
173
173
  exports2.fromWeb3Pk = fromWeb3PublicKey;
174
174
  exports2.toWeb3Pk = toWeb3PublicKey;
175
- function toKitInstruction43(ix) {
175
+ function toKitInstruction45(ix) {
176
176
  return {
177
177
  programAddress: ix.programId.toBase58(),
178
178
  data: new Uint8Array(ix.data),
@@ -201,10 +201,10 @@ var require_ata = __commonJS({
201
201
  "../common/dist/utils/accounts/ata.js"(exports2) {
202
202
  "use strict";
203
203
  Object.defineProperty(exports2, "__esModule", { value: true });
204
- exports2.getAtaAddress = getAtaAddress26;
204
+ exports2.getAtaAddress = getAtaAddress27;
205
205
  var spl_token_1 = require("@solana/spl-token");
206
206
  var compat_1 = require_compat();
207
- function getAtaAddress26(mint, owner, tokenProgram, allowOwnerOffCurve = true) {
207
+ function getAtaAddress27(mint, owner, tokenProgram, allowOwnerOffCurve = true) {
208
208
  const ata = (0, spl_token_1.getAssociatedTokenAddressSync)((0, compat_1.toWeb3PublicKey)(mint), (0, compat_1.toWeb3PublicKey)(owner), allowOwnerOffCurve, (0, compat_1.toWeb3PublicKey)(tokenProgram), spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
209
209
  return ata.toBase58();
210
210
  }
@@ -2048,12 +2048,14 @@ var index_exports = {};
2048
2048
  __export(index_exports, {
2049
2049
  ASSET_DECIMALS: () => ASSET_DECIMALS,
2050
2050
  ASSET_REBALANCE_COOLDOWN_SECS: () => ASSET_REBALANCE_COOLDOWN_SECS,
2051
+ ASYNC_REDEMPTION_CANCEL_DELAY_SECS: () => ASYNC_REDEMPTION_CANCEL_DELAY_SECS,
2051
2052
  AccountClient: () => AccountClient,
2052
2053
  ActivateCircuitBreakerBuilder: () => ActivateCircuitBreakerBuilder,
2053
2054
  AddIncentiveRecipientBuilder: () => AddIncentiveRecipientBuilder,
2054
2055
  AddIncentiveRecipientV3Builder: () => AddIncentiveRecipientV3Builder,
2055
2056
  BALANCE_CHANGE_BASELINE_MAX_AGE_SECS: () => BALANCE_CHANGE_BASELINE_MAX_AGE_SECS,
2056
2057
  CONSENSUS_ORACLE_VARIANT: () => CONSENSUS_ORACLE_VARIANT,
2058
+ CancelAsyncWithdrawBuilder: () => CancelAsyncWithdrawBuilder,
2057
2059
  CancelIncentiveProposalBuilder: () => CancelIncentiveProposalBuilder,
2058
2060
  CancelJuniorTrancheWithdrawBuilder: () => CancelJuniorTrancheWithdrawBuilder,
2059
2061
  ClaimIncentiveBuilder: () => ClaimIncentiveBuilder,
@@ -2073,7 +2075,7 @@ __export(index_exports, {
2073
2075
  DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS: () => DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
2074
2076
  DEFAULT_MARGINFI_WEIGHT_BPS: () => DEFAULT_MARGINFI_WEIGHT_BPS,
2075
2077
  DEFAULT_MAX_ACCEPTABLE_APY_BPS: () => DEFAULT_MAX_ACCEPTABLE_APY_BPS,
2076
- DEFAULT_MINTS: () => import_common70.DEFAULT_MINTS,
2078
+ DEFAULT_MINTS: () => import_common72.DEFAULT_MINTS,
2077
2079
  DEFAULT_MIN_AMOUNT_UI: () => DEFAULT_MIN_AMOUNT_UI,
2078
2080
  DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS: () => DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
2079
2081
  DEFAULT_PRICE_ORACLE_ACCOUNT: () => DEFAULT_PRICE_ORACLE_ACCOUNT,
@@ -2129,7 +2131,7 @@ __export(index_exports, {
2129
2131
  ManagerRedepositAssetBuilder: () => ManagerRedepositAssetBuilder,
2130
2132
  ManagerWithdrawAssetBuilder: () => ManagerWithdrawAssetBuilder,
2131
2133
  MarginfiPositionProvider: () => MarginfiPositionProvider,
2132
- MintRegistry: () => import_common70.MintRegistry,
2134
+ MintRegistry: () => import_common72.MintRegistry,
2133
2135
  MockYieldTracker: () => MockYieldTracker,
2134
2136
  NEST_API_BASE_URL: () => import_nest2.NEST_API_BASE_URL,
2135
2137
  NEST_RWA_SHARE_MINT: () => NEST_RWA_SHARE_MINT,
@@ -2147,6 +2149,7 @@ __export(index_exports, {
2147
2149
  PROTOCOL_FEE_RECIPIENT: () => PROTOCOL_FEE_RECIPIENT,
2148
2150
  PST_TO_USDC_MAX_SLIPPAGE_BPS: () => PST_TO_USDC_MAX_SLIPPAGE_BPS,
2149
2151
  PdaClient: () => PdaClient,
2152
+ PriceAsyncWithdrawBuilder: () => PriceAsyncWithdrawBuilder,
2150
2153
  ProtocolInteractionBuilder: () => ProtocolInteractionBuilder,
2151
2154
  RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS: () => RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS,
2152
2155
  REPORTABLE_ORACLE_VARIANTS: () => REPORTABLE_ORACLE_VARIANTS,
@@ -2284,7 +2287,7 @@ __export(index_exports, {
2284
2287
  makeProvider: () => makeProvider,
2285
2288
  managerReconciliationStateKey: () => managerReconciliationStateKey,
2286
2289
  mintTokensTo: () => mintTokensTo,
2287
- mints: () => import_common70.mints,
2290
+ mints: () => import_common72.mints,
2288
2291
  mostFrequent: () => mostFrequent,
2289
2292
  parseExternalLiquidityRefs: () => parseExternalLiquidityRefs,
2290
2293
  planExternalAllocation: () => planExternalAllocation,
@@ -2384,6 +2387,7 @@ var MAX_PRICE_STALENESS_THRESHOLD_SECS = 7 * 24 * 60 * 60;
2384
2387
  var DEFAULT_VAULT_ID = 0;
2385
2388
  var DEFAULT_MAX_ACCEPTABLE_APY_BPS = 1e4;
2386
2389
  var DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS = 7 * 24 * 60 * 60;
2390
+ var ASYNC_REDEMPTION_CANCEL_DELAY_SECS = 30 * 24 * 60 * 60;
2387
2391
  var DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS = 100;
2388
2392
  var DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS = 50;
2389
2393
  var USDC_MINT = (0, import_kit.address)(
@@ -2436,15 +2440,15 @@ var import_fs = __toESM(require("fs"));
2436
2440
  var import_os = __toESM(require("os"));
2437
2441
  var import_path = __toESM(require("path"));
2438
2442
  var import_core23 = require("@anchor-lang/core");
2439
- var import_web330 = require("@solana/web3.js");
2443
+ var import_web331 = require("@solana/web3.js");
2440
2444
  var import_kit11 = require("@solana/kit");
2441
- var import_common49 = __toESM(require_dist());
2445
+ var import_common51 = __toESM(require_dist());
2442
2446
 
2443
2447
  // src/client/client.ts
2444
2448
  var import_core22 = require("@anchor-lang/core");
2445
2449
  var import_kit10 = require("@solana/kit");
2446
- var import_web329 = require("@solana/web3.js");
2447
- var import_common48 = __toESM(require_dist());
2450
+ var import_web330 = require("@solana/web3.js");
2451
+ var import_common50 = __toESM(require_dist());
2448
2452
 
2449
2453
  // src/idl/vault.ts
2450
2454
  var IDL = {
@@ -2552,6 +2556,113 @@ var IDL = {
2552
2556
  }
2553
2557
  ]
2554
2558
  },
2559
+ {
2560
+ "name": "cancel_async_withdraw",
2561
+ "discriminator": [
2562
+ 121,
2563
+ 182,
2564
+ 87,
2565
+ 166,
2566
+ 240,
2567
+ 240,
2568
+ 181,
2569
+ 178
2570
+ ],
2571
+ "accounts": [
2572
+ {
2573
+ "name": "user",
2574
+ "writable": true,
2575
+ "signer": true
2576
+ },
2577
+ {
2578
+ "name": "payer",
2579
+ "writable": true
2580
+ },
2581
+ {
2582
+ "name": "vault"
2583
+ },
2584
+ {
2585
+ "name": "withdrawal_queue",
2586
+ "writable": true
2587
+ },
2588
+ {
2589
+ "name": "input_mint"
2590
+ },
2591
+ {
2592
+ "name": "user_input_ata",
2593
+ "writable": true
2594
+ },
2595
+ {
2596
+ "name": "queue_input_ata",
2597
+ "writable": true,
2598
+ "pda": {
2599
+ "seeds": [
2600
+ {
2601
+ "kind": "account",
2602
+ "path": "withdrawal_queue"
2603
+ },
2604
+ {
2605
+ "kind": "account",
2606
+ "path": "share_token_program"
2607
+ },
2608
+ {
2609
+ "kind": "account",
2610
+ "path": "input_mint"
2611
+ }
2612
+ ],
2613
+ "program": {
2614
+ "kind": "const",
2615
+ "value": [
2616
+ 140,
2617
+ 151,
2618
+ 37,
2619
+ 143,
2620
+ 78,
2621
+ 36,
2622
+ 137,
2623
+ 241,
2624
+ 187,
2625
+ 61,
2626
+ 16,
2627
+ 41,
2628
+ 20,
2629
+ 142,
2630
+ 13,
2631
+ 131,
2632
+ 11,
2633
+ 90,
2634
+ 19,
2635
+ 153,
2636
+ 218,
2637
+ 255,
2638
+ 16,
2639
+ 132,
2640
+ 4,
2641
+ 142,
2642
+ 123,
2643
+ 216,
2644
+ 219,
2645
+ 233,
2646
+ 248,
2647
+ 89
2648
+ ]
2649
+ }
2650
+ }
2651
+ },
2652
+ {
2653
+ "name": "share_token_program"
2654
+ },
2655
+ {
2656
+ "name": "associated_token_program",
2657
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
2658
+ },
2659
+ {
2660
+ "name": "system_program",
2661
+ "address": "11111111111111111111111111111111"
2662
+ }
2663
+ ],
2664
+ "args": []
2665
+ },
2555
2666
  {
2556
2667
  "name": "cancel_incentive_proposal",
2557
2668
  "discriminator": [
@@ -8745,6 +8856,40 @@ var IDL = {
8745
8856
  }
8746
8857
  ]
8747
8858
  },
8859
+ {
8860
+ "name": "price_async_withdraw",
8861
+ "discriminator": [
8862
+ 101,
8863
+ 85,
8864
+ 188,
8865
+ 156,
8866
+ 108,
8867
+ 105,
8868
+ 104,
8869
+ 94
8870
+ ],
8871
+ "accounts": [
8872
+ {
8873
+ "name": "hw_manager",
8874
+ "signer": true
8875
+ },
8876
+ {
8877
+ "name": "vault"
8878
+ },
8879
+ {
8880
+ "name": "vault_oracle"
8881
+ },
8882
+ {
8883
+ "name": "vault_tranche_state",
8884
+ "optional": true
8885
+ },
8886
+ {
8887
+ "name": "withdrawal_queue",
8888
+ "writable": true
8889
+ }
8890
+ ],
8891
+ "args": []
8892
+ },
8748
8893
  {
8749
8894
  "name": "protocol_interaction",
8750
8895
  "discriminator": [
@@ -13863,12 +14008,33 @@ var IDL = {
13863
14008
  "name": "expiry_ts",
13864
14009
  "type": "i64"
13865
14010
  },
14011
+ {
14012
+ "name": "output_amount",
14013
+ "docs": [
14014
+ "Locked net payout in output-mint atomic units. Valid when priced_ts > 0."
14015
+ ],
14016
+ "type": "u64"
14017
+ },
14018
+ {
14019
+ "name": "priced_ts",
14020
+ "docs": [
14021
+ "Zero means unpriced, including queues created before pricing existed."
14022
+ ],
14023
+ "type": "i64"
14024
+ },
14025
+ {
14026
+ "name": "fee_share_amount",
14027
+ "docs": [
14028
+ "Curator fee shares fixed alongside the net payout."
14029
+ ],
14030
+ "type": "u64"
14031
+ },
13866
14032
  {
13867
14033
  "name": "_padding",
13868
14034
  "type": {
13869
14035
  "array": [
13870
14036
  "u64",
13871
- 12
14037
+ 9
13872
14038
  ]
13873
14039
  }
13874
14040
  }
@@ -18860,36 +19026,42 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
18860
19026
  );
18861
19027
  let skipExternalLiquidity = txArgs.skipExternalLiquidity ?? false;
18862
19028
  if (!txArgs.externalWithdrawIxRefs && !skipExternalLiquidity) {
19029
+ const isPriced = BigInt(queue.request.pricedTs.toString()) > 0n;
18863
19030
  const [localAmount, tranche] = await Promise.all([
18864
19031
  readTokenBalance(connection, vaultOutputAta, assetTokenProgram),
18865
- vaultTrancheState ? this.account.fetchVaultTrancheState(vaultTrancheState, {
19032
+ !isPriced && vaultTrancheState ? this.account.fetchVaultTrancheState(vaultTrancheState, {
18866
19033
  fresh: true
18867
19034
  }) : null
18868
19035
  ]);
18869
- const holding = vaultData.holdings.find(
18870
- (h) => (0, import_common47.fromWeb3Pk)(h.mint) === txArgs.assetMint
18871
- );
18872
- if (!holding) throw new Error("Withdrawal asset is not a vault holding");
18873
- const supply = BigInt(vaultData.accounting.totalMintSupply.toString());
18874
- const value = BigInt(vaultData.accounting.tvl.toString()) - (tranche ? BigInt(tranche.junior.value.toString()) + BigInt(tranche.senior.value.toString()) : 0n);
18875
- const price = BigInt(holding.price.toString());
18876
- if (supply <= 0n || value < 0n || price <= 0n)
18877
- throw new Error("Invalid async withdrawal pricing state");
18878
- const quote = quoteWithdrawalPayout(
18879
- {
18880
- shareClass: "regular",
18881
- supply,
18882
- value,
18883
- price,
18884
- decimals: holding.decimals,
18885
- // The queue owner receives the exemption, not the fulfiller.
18886
- feeBps: WALLET_FEE_EXEMPT_WHITELIST.includes(
18887
- (0, import_common47.fromWeb3Pk)(queue.parties.owner)
18888
- ) ? 0 : vaultData.config.fees.burnFeeBps
18889
- },
18890
- BigInt(queue.request.inputAmount.toString())
18891
- );
18892
- skipExternalLiquidity = localAmount >= quote.tokens;
19036
+ if (isPriced) {
19037
+ skipExternalLiquidity = localAmount >= BigInt(queue.request.outputAmount.toString());
19038
+ } else {
19039
+ const holding = vaultData.holdings.find(
19040
+ (h) => (0, import_common47.fromWeb3Pk)(h.mint) === txArgs.assetMint
19041
+ );
19042
+ if (!holding)
19043
+ throw new Error("Withdrawal asset is not a vault holding");
19044
+ const supply = BigInt(vaultData.accounting.totalMintSupply.toString());
19045
+ const value = BigInt(vaultData.accounting.tvl.toString()) - (tranche ? BigInt(tranche.junior.value.toString()) + BigInt(tranche.senior.value.toString()) : 0n);
19046
+ const price = BigInt(holding.price.toString());
19047
+ if (supply <= 0n || value < 0n || price <= 0n)
19048
+ throw new Error("Invalid async withdrawal pricing state");
19049
+ const quote = quoteWithdrawalPayout(
19050
+ {
19051
+ shareClass: "regular",
19052
+ supply,
19053
+ value,
19054
+ price,
19055
+ decimals: holding.decimals,
19056
+ // The queue owner receives the exemption, not the fulfiller.
19057
+ feeBps: WALLET_FEE_EXEMPT_WHITELIST.includes(
19058
+ (0, import_common47.fromWeb3Pk)(queue.parties.owner)
19059
+ ) ? 0 : vaultData.config.fees.burnFeeBps
19060
+ },
19061
+ BigInt(queue.request.inputAmount.toString())
19062
+ );
19063
+ skipExternalLiquidity = localAmount >= quote.tokens;
19064
+ }
18893
19065
  }
18894
19066
  const {
18895
19067
  externalWithdrawIxRefs,
@@ -18993,6 +19165,125 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
18993
19165
  }
18994
19166
  };
18995
19167
 
19168
+ // src/client/builders/priceAsyncWithdraw.ts
19169
+ var import_common48 = __toESM(require_dist());
19170
+ var PriceAsyncWithdrawBuilder = class extends VaultBuilderBase {
19171
+ async getIx(args) {
19172
+ return this.program.methods.priceAsyncWithdraw().accountsPartial({
19173
+ hwManager: (0, import_common48.toWeb3Pk)(args.hwManager),
19174
+ vault: (0, import_common48.toWeb3Pk)(args.vault),
19175
+ vaultOracle: (0, import_common48.toWeb3Pk)(args.vaultOracle),
19176
+ vaultTrancheState: args.vaultTrancheState ? (0, import_common48.toWeb3Pk)(args.vaultTrancheState) : null,
19177
+ withdrawalQueue: (0, import_common48.toWeb3Pk)(args.withdrawalQueue)
19178
+ }).instruction().then(import_common48.toKitInstruction);
19179
+ }
19180
+ async deriveIxArgs(args) {
19181
+ const [[oracle], tranche] = await Promise.all([
19182
+ this.pda.deriveVaultOraclePda(args.vault),
19183
+ resolveVaultTrancheState(
19184
+ this.account,
19185
+ this.pda,
19186
+ args.vault,
19187
+ args.vaultTrancheState
19188
+ )
19189
+ ]);
19190
+ return {
19191
+ ...args,
19192
+ vaultOracle: args.vaultOracle ?? oracle,
19193
+ vaultTrancheState: tranche
19194
+ };
19195
+ }
19196
+ async buildPlanExtras(args) {
19197
+ return {
19198
+ postSuccessCacheInvalidations: [
19199
+ { vaultPda: args.vault, withdrawalQueuePda: args.withdrawalQueue }
19200
+ ]
19201
+ };
19202
+ }
19203
+ };
19204
+
19205
+ // src/client/builders/cancelAsyncWithdraw.ts
19206
+ var import_spl_token23 = require("@solana/spl-token");
19207
+ var import_web329 = require("@solana/web3.js");
19208
+ var import_common49 = __toESM(require_dist());
19209
+ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
19210
+ async getIx(args) {
19211
+ return this.program.methods.cancelAsyncWithdraw().accountsPartial({
19212
+ user: (0, import_common49.toWeb3Pk)(args.user),
19213
+ payer: (0, import_common49.toWeb3Pk)(args.payer),
19214
+ vault: (0, import_common49.toWeb3Pk)(args.vault),
19215
+ withdrawalQueue: (0, import_common49.toWeb3Pk)(args.withdrawalQueue),
19216
+ inputMint: (0, import_common49.toWeb3Pk)(args.inputMint),
19217
+ userInputAta: (0, import_common49.toWeb3Pk)(args.userInputAta),
19218
+ queueInputAta: (0, import_common49.toWeb3Pk)(args.queueInputAta),
19219
+ shareTokenProgram: (0, import_common49.toWeb3Pk)(args.shareTokenProgram),
19220
+ associatedTokenProgram: import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID,
19221
+ systemProgram: import_web329.SystemProgram.programId
19222
+ }).instruction().then(import_common49.toKitInstruction);
19223
+ }
19224
+ async deriveIxArgs(args) {
19225
+ const [[derived], vault] = await Promise.all([
19226
+ this.pda.deriveVaultWithdrawalQueuePda(
19227
+ args.vault,
19228
+ args.user,
19229
+ args.queueId
19230
+ ),
19231
+ this.account.fetchVault(args.vault, { fresh: true })
19232
+ ]);
19233
+ const withdrawalQueue = args.withdrawalQueue ?? derived;
19234
+ const queue = await this.account.fetchVaultWithdrawalQueue(
19235
+ withdrawalQueue,
19236
+ { fresh: true }
19237
+ );
19238
+ const inputMint = (0, import_common49.fromWeb3Pk)(vault.mint);
19239
+ const shareTokenProgram = tokenProgramAddressFromIdlEnum(
19240
+ vault.mintTokenProgram
19241
+ );
19242
+ return {
19243
+ user: args.user,
19244
+ vault: args.vault,
19245
+ withdrawalQueue,
19246
+ inputMint,
19247
+ shareTokenProgram,
19248
+ payer: (0, import_common49.fromWeb3Pk)(queue.parties.payer),
19249
+ userInputAta: args.userInputAta ?? (0, import_common49.getAtaAddress)(inputMint, args.user, shareTokenProgram, true),
19250
+ queueInputAta: (0, import_common49.getAtaAddress)(
19251
+ inputMint,
19252
+ withdrawalQueue,
19253
+ shareTokenProgram,
19254
+ true
19255
+ )
19256
+ };
19257
+ }
19258
+ async buildPreambleInstructions(args) {
19259
+ const ata = (0, import_common49.getAtaAddress)(
19260
+ args.inputMint,
19261
+ args.user,
19262
+ args.shareTokenProgram,
19263
+ true
19264
+ );
19265
+ if (ata !== args.userInputAta) return [];
19266
+ return [
19267
+ (0, import_common49.toKitInstruction)(
19268
+ (0, import_spl_token23.createAssociatedTokenAccountIdempotentInstruction)(
19269
+ (0, import_common49.toWeb3Pk)(args.user),
19270
+ (0, import_common49.toWeb3Pk)(ata),
19271
+ (0, import_common49.toWeb3Pk)(args.user),
19272
+ (0, import_common49.toWeb3Pk)(args.inputMint),
19273
+ (0, import_common49.toWeb3Pk)(args.shareTokenProgram)
19274
+ )
19275
+ )
19276
+ ];
19277
+ }
19278
+ async buildPlanExtras(args) {
19279
+ return {
19280
+ postSuccessCacheInvalidations: [
19281
+ { vaultPda: args.vault, withdrawalQueuePda: args.withdrawalQueue }
19282
+ ]
19283
+ };
19284
+ }
19285
+ };
19286
+
18996
19287
  // src/client/transaction.ts
18997
19288
  var TransactionClient = class {
18998
19289
  constructor(context) {
@@ -19040,6 +19331,8 @@ var TransactionClient = class {
19040
19331
  );
19041
19332
  this.requestAsyncWithdraw = new RequestAsyncWithdrawBuilder(context);
19042
19333
  this.fulfillAsyncWithdraw = new FulfillAsyncWithdrawBuilder(context);
19334
+ this.priceAsyncWithdraw = new PriceAsyncWithdrawBuilder(context);
19335
+ this.cancelAsyncWithdraw = new CancelAsyncWithdrawBuilder(context);
19043
19336
  this.executeWithdraw = new ExecuteWithdrawBuilder(context);
19044
19337
  this.managerWithdrawAsset = new ManagerWithdrawAssetBuilder(context);
19045
19338
  this.managerRedepositAsset = new ManagerRedepositAssetBuilder(context);
@@ -19088,15 +19381,15 @@ var VaultClient = class {
19088
19381
  this.vaultLookupTables
19089
19382
  );
19090
19383
  const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
19091
- const instructions2 = plan.instructions.map(import_common48.fromKitInstruction);
19384
+ const instructions2 = plan.instructions.map(import_common50.fromKitInstruction);
19092
19385
  let tx;
19093
19386
  if (plan.lookupTables?.length) {
19094
- const tables = await (0, import_common48.fetchLookupTables)(
19387
+ const tables = await (0, import_common50.fetchLookupTables)(
19095
19388
  this.provider.connection,
19096
19389
  plan.lookupTables
19097
19390
  );
19098
- tx = new import_web329.VersionedTransaction(
19099
- new import_web329.TransactionMessage({
19391
+ tx = new import_web330.VersionedTransaction(
19392
+ new import_web330.TransactionMessage({
19100
19393
  payerKey: payer.publicKey,
19101
19394
  recentBlockhash: blockhash,
19102
19395
  instructions: instructions2
@@ -19104,7 +19397,7 @@ var VaultClient = class {
19104
19397
  );
19105
19398
  tx.sign([payer, ...extraSigners]);
19106
19399
  } else {
19107
- tx = new import_web329.Transaction().add(...instructions2);
19400
+ tx = new import_web330.Transaction().add(...instructions2);
19108
19401
  tx.feePayer = payer.publicKey;
19109
19402
  tx.recentBlockhash = blockhash;
19110
19403
  tx.sign(payer, ...extraSigners);
@@ -19143,13 +19436,13 @@ var VaultClient = class {
19143
19436
  const { blockhash } = await this.provider.connection.getLatestBlockhash(
19144
19437
  "confirmed"
19145
19438
  );
19146
- const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common48.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
19147
- const message2 = new import_web329.TransactionMessage({
19439
+ const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common50.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
19440
+ const message2 = new import_web330.TransactionMessage({
19148
19441
  payerKey: payer.publicKey,
19149
19442
  recentBlockhash: blockhash,
19150
- instructions: plan.instructions.map(import_common48.fromKitInstruction)
19443
+ instructions: plan.instructions.map(import_common50.fromKitInstruction)
19151
19444
  }).compileToV0Message(lookupTableAccounts);
19152
- const tx = new import_web329.VersionedTransaction(message2);
19445
+ const tx = new import_web330.VersionedTransaction(message2);
19153
19446
  const result = await this.provider.connection.simulateTransaction(tx, {
19154
19447
  sigVerify: false,
19155
19448
  commitment: "processed"
@@ -19223,7 +19516,7 @@ function resolveKeypairPath(keypairPath) {
19223
19516
  }
19224
19517
  function loadKeypair(keypairPath) {
19225
19518
  const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
19226
- return import_web330.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
19519
+ return import_web331.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
19227
19520
  }
19228
19521
  var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
19229
19522
  function defaultKeypairPath(env, role = "vault") {
@@ -19234,7 +19527,7 @@ function defaultKeypairPath(env, role = "vault") {
19234
19527
  }
19235
19528
  function createVaultClient(env, opts = {}) {
19236
19529
  const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
19237
- const connection = new import_web330.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
19530
+ const connection = new import_web331.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
19238
19531
  const provider = new import_core23.AnchorProvider(connection, new import_core23.Wallet(payer), {
19239
19532
  commitment: "confirmed"
19240
19533
  });
@@ -19251,11 +19544,11 @@ function createVaultClient(env, opts = {}) {
19251
19544
  client,
19252
19545
  provider,
19253
19546
  payer,
19254
- signer: (0, import_common49.fromWeb3Pk)(payer.publicKey)
19547
+ signer: (0, import_common51.fromWeb3Pk)(payer.publicKey)
19255
19548
  };
19256
19549
  }
19257
19550
  function keypairAddress(keypairPath) {
19258
- return (0, import_common49.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
19551
+ return (0, import_common51.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
19259
19552
  }
19260
19553
 
19261
19554
  // src/utils/math.ts
@@ -19278,7 +19571,7 @@ function makeProvider(connection, payer) {
19278
19571
 
19279
19572
  // src/utils/squads.ts
19280
19573
  var squads = __toESM(require("@sqds/multisig"));
19281
- var import_web331 = require("@solana/web3.js");
19574
+ var import_web332 = require("@solana/web3.js");
19282
19575
  var SQUADS_SIMULATION_COMMITMENT = "processed";
19283
19576
  var SquadsProposalExecutionSimulationError = class extends Error {
19284
19577
  constructor(transactionError, logs, unitsConsumed) {
@@ -19302,8 +19595,8 @@ function validateVaultIndex(vaultIndex) {
19302
19595
  }
19303
19596
  function resolveSquadsWalletRoute(route) {
19304
19597
  validateVaultIndex(route.vaultIndex);
19305
- const wallet = new import_web331.PublicKey(route.wallet);
19306
- const multisigPda = new import_web331.PublicKey(route.multisigPda);
19598
+ const wallet = new import_web332.PublicKey(route.wallet);
19599
+ const multisigPda = new import_web332.PublicKey(route.multisigPda);
19307
19600
  const [vaultPda] = squads.getVaultPda({
19308
19601
  multisigPda,
19309
19602
  index: route.vaultIndex
@@ -19311,7 +19604,7 @@ function resolveSquadsWalletRoute(route) {
19311
19604
  return { ...route, wallet, multisigPda, vaultPda };
19312
19605
  }
19313
19606
  function findSquadsWalletRoute(wallet, routes) {
19314
- const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
19607
+ const walletKey = typeof wallet === "string" ? new import_web332.PublicKey(wallet) : wallet;
19315
19608
  const route = routes.find(
19316
19609
  (candidate) => candidate.wallet === walletKey.toBase58()
19317
19610
  );
@@ -19329,18 +19622,18 @@ function validateSquadsWalletRoutes(routes) {
19329
19622
  }
19330
19623
  }
19331
19624
  function vaultAuthorityForWallet(wallet, routes) {
19332
- const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
19625
+ const walletKey = typeof wallet === "string" ? new import_web332.PublicKey(wallet) : wallet;
19333
19626
  return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
19334
19627
  }
19335
19628
  async function simulateSquadsProposalExecution(args) {
19336
19629
  const { connection, feePayer, instructions: instructions2 } = args;
19337
19630
  const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
19338
- const message2 = new import_web331.TransactionMessage({
19631
+ const message2 = new import_web332.TransactionMessage({
19339
19632
  payerKey: feePayer,
19340
19633
  recentBlockhash,
19341
19634
  instructions: [...instructions2]
19342
19635
  }).compileToV0Message(args.addressLookupTableAccounts);
19343
- const transaction = new import_web331.VersionedTransaction(message2);
19636
+ const transaction = new import_web332.VersionedTransaction(message2);
19344
19637
  const { value } = await connection.simulateTransaction(transaction, {
19345
19638
  sigVerify: false,
19346
19639
  commitment: SQUADS_SIMULATION_COMMITMENT,
@@ -19365,7 +19658,7 @@ async function prepareVaultTransaction(args) {
19365
19658
  throw new Error("Ephemeral signers require a Squads route");
19366
19659
  return {
19367
19660
  kind: "direct",
19368
- transaction: new import_web331.Transaction().add(...instructions2),
19661
+ transaction: new import_web332.Transaction().add(...instructions2),
19369
19662
  authority: proposer
19370
19663
  };
19371
19664
  }
@@ -19418,7 +19711,7 @@ async function prepareVaultTransaction(args) {
19418
19711
  });
19419
19712
  if (replacements.size) {
19420
19713
  instructions2 = instructions2.map(
19421
- (ix) => new import_web331.TransactionInstruction({
19714
+ (ix) => new import_web332.TransactionInstruction({
19422
19715
  programId: ix.programId,
19423
19716
  data: ix.data,
19424
19717
  keys: ix.keys.map((meta) => ({
@@ -19446,7 +19739,7 @@ async function prepareVaultTransaction(args) {
19446
19739
  executionSimulationError = error;
19447
19740
  }
19448
19741
  }
19449
- const transactionMessage = new import_web331.TransactionMessage({
19742
+ const transactionMessage = new import_web332.TransactionMessage({
19450
19743
  payerKey: route.vaultPda,
19451
19744
  recentBlockhash: blockhash,
19452
19745
  instructions: [...instructions2]
@@ -19476,7 +19769,7 @@ async function prepareVaultTransaction(args) {
19476
19769
  });
19477
19770
  return {
19478
19771
  kind: "squads",
19479
- transaction: new import_web331.Transaction().add(
19772
+ transaction: new import_web332.Transaction().add(
19480
19773
  createVaultTransactionIx,
19481
19774
  createProposalIx
19482
19775
  ),
@@ -19492,16 +19785,16 @@ async function prepareVaultTransaction(args) {
19492
19785
 
19493
19786
  // src/utils/squadsBuffer.ts
19494
19787
  var squads2 = __toESM(require("@sqds/multisig"));
19495
- var import_web332 = require("@solana/web3.js");
19788
+ var import_web333 = require("@solana/web3.js");
19496
19789
  var PacketSize = 1232;
19497
19790
  var BufferChunkSize = 700;
19498
19791
  var MaxBufferSize = 4e3;
19499
19792
  async function prepareSquadsProposalUpload(args) {
19500
19793
  const { connection, proposer, prepared } = args;
19501
19794
  const transaction = prepared.transaction;
19502
- const sizeProbe = new import_web332.Transaction({
19795
+ const sizeProbe = new import_web333.Transaction({
19503
19796
  feePayer: proposer,
19504
- recentBlockhash: import_web332.PublicKey.default.toBase58()
19797
+ recentBlockhash: import_web333.PublicKey.default.toBase58()
19505
19798
  }).add(...transaction.instructions);
19506
19799
  let fits = false;
19507
19800
  try {
@@ -19521,7 +19814,7 @@ async function prepareSquadsProposalUpload(args) {
19521
19814
  let bufferPda;
19522
19815
  let bufferIndex = 0;
19523
19816
  for (; bufferIndex <= 255; bufferIndex++) {
19524
- const [candidate] = import_web332.PublicKey.findProgramAddressSync(
19817
+ const [candidate] = import_web333.PublicKey.findProgramAddressSync(
19525
19818
  [
19526
19819
  Buffer.from("multisig"),
19527
19820
  prepared.multisigPda.toBuffer(),
@@ -19549,7 +19842,7 @@ async function prepareSquadsProposalUpload(args) {
19549
19842
  creator: proposer
19550
19843
  };
19551
19844
  const setupTransactions = [
19552
- new import_web332.Transaction().add(
19845
+ new import_web333.Transaction().add(
19553
19846
  squads2.generated.createTransactionBufferCreateInstruction(
19554
19847
  {
19555
19848
  ...accounts2,
@@ -19569,7 +19862,7 @@ async function prepareSquadsProposalUpload(args) {
19569
19862
  ];
19570
19863
  for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
19571
19864
  setupTransactions.push(
19572
- new import_web332.Transaction().add(
19865
+ new import_web333.Transaction().add(
19573
19866
  squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
19574
19867
  args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
19575
19868
  })
@@ -19582,7 +19875,7 @@ async function prepareSquadsProposalUpload(args) {
19582
19875
  vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
19583
19876
  vaultTransactionCreateItemCreator: proposer,
19584
19877
  vaultTransactionCreateItemRentPayer: proposer,
19585
- vaultTransactionCreateItemSystemProgram: import_web332.SystemProgram.programId,
19878
+ vaultTransactionCreateItemSystemProgram: import_web333.SystemProgram.programId,
19586
19879
  transactionBuffer: bufferPda,
19587
19880
  creator: proposer
19588
19881
  },
@@ -19594,7 +19887,7 @@ async function prepareSquadsProposalUpload(args) {
19594
19887
  ).isWritable = true;
19595
19888
  return {
19596
19889
  setupTransactions,
19597
- proposalTransaction: new import_web332.Transaction().add(
19890
+ proposalTransaction: new import_web333.Transaction().add(
19598
19891
  finalize,
19599
19892
  ...transaction.instructions.slice(1)
19600
19893
  ),
@@ -19604,21 +19897,21 @@ async function prepareSquadsProposalUpload(args) {
19604
19897
  }
19605
19898
 
19606
19899
  // src/utils/token.ts
19607
- var import_spl_token23 = require("@solana/spl-token");
19608
- var import_web333 = require("@solana/web3.js");
19609
- var import_common50 = __toESM(require_dist());
19610
- async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token23.TOKEN_2022_PROGRAM_ID) {
19611
- const mint = import_web333.Keypair.generate();
19612
- const lamports = await (0, import_spl_token23.getMinimumBalanceForRentExemptMint)(connection);
19900
+ var import_spl_token24 = require("@solana/spl-token");
19901
+ var import_web334 = require("@solana/web3.js");
19902
+ var import_common52 = __toESM(require_dist());
19903
+ async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID) {
19904
+ const mint = import_web334.Keypair.generate();
19905
+ const lamports = await (0, import_spl_token24.getMinimumBalanceForRentExemptMint)(connection);
19613
19906
  const ixs = [
19614
- import_web333.SystemProgram.createAccount({
19907
+ import_web334.SystemProgram.createAccount({
19615
19908
  fromPubkey: payer,
19616
19909
  newAccountPubkey: mint.publicKey,
19617
- space: import_spl_token23.MINT_SIZE,
19910
+ space: import_spl_token24.MINT_SIZE,
19618
19911
  lamports,
19619
19912
  programId: tokenProgram
19620
19913
  }),
19621
- (0, import_spl_token23.createInitializeMint2Instruction)(
19914
+ (0, import_spl_token24.createInitializeMint2Instruction)(
19622
19915
  mint.publicKey,
19623
19916
  decimals,
19624
19917
  authority,
@@ -19628,7 +19921,7 @@ async function createTokenMintIxs(connection, payer, authority, decimals, tokenP
19628
19921
  ];
19629
19922
  return { mint, ixs };
19630
19923
  }
19631
- async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token23.TOKEN_2022_PROGRAM_ID) {
19924
+ async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID) {
19632
19925
  const { mint, ixs } = await createTokenMintIxs(
19633
19926
  connection,
19634
19927
  payer.publicKey,
@@ -19637,7 +19930,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
19637
19930
  tokenProgram
19638
19931
  );
19639
19932
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
19640
- const tx = new import_web333.Transaction().add(...ixs);
19933
+ const tx = new import_web334.Transaction().add(...ixs);
19641
19934
  tx.feePayer = payer.publicKey;
19642
19935
  tx.recentBlockhash = blockhash;
19643
19936
  tx.sign(payer, mint);
@@ -19650,24 +19943,24 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
19650
19943
  );
19651
19944
  return mint.publicKey;
19652
19945
  }
19653
- async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token23.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
19654
- const tokenProgramPk = (0, import_common50.asWeb3PublicKey)(tokenProgram);
19655
- const ata = (0, import_spl_token23.getAssociatedTokenAddressSync)(
19946
+ async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
19947
+ const tokenProgramPk = (0, import_common52.asWeb3PublicKey)(tokenProgram);
19948
+ const ata = (0, import_spl_token24.getAssociatedTokenAddressSync)(
19656
19949
  mint,
19657
19950
  destination,
19658
19951
  allowOwnerOffCurve,
19659
19952
  tokenProgramPk
19660
19953
  );
19661
19954
  const ixs = [
19662
- (0, import_spl_token23.createAssociatedTokenAccountIdempotentInstruction)(
19955
+ (0, import_spl_token24.createAssociatedTokenAccountIdempotentInstruction)(
19663
19956
  payer.publicKey,
19664
19957
  ata,
19665
19958
  destination,
19666
19959
  mint,
19667
19960
  tokenProgramPk,
19668
- import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID
19961
+ import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID
19669
19962
  ),
19670
- (0, import_spl_token23.createMintToInstruction)(
19963
+ (0, import_spl_token24.createMintToInstruction)(
19671
19964
  mint,
19672
19965
  ata,
19673
19966
  payer.publicKey,
@@ -19676,7 +19969,7 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
19676
19969
  tokenProgramPk
19677
19970
  )
19678
19971
  ];
19679
- const tx = new import_web333.Transaction().add(...ixs);
19972
+ const tx = new import_web334.Transaction().add(...ixs);
19680
19973
  await connection.sendTransaction(tx, [payer]);
19681
19974
  }
19682
19975
 
@@ -20066,7 +20359,7 @@ async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
20066
20359
  }
20067
20360
 
20068
20361
  // src/services/withdrawalQueueService.ts
20069
- var import_common51 = __toESM(require_dist());
20362
+ var import_common53 = __toESM(require_dist());
20070
20363
  function bnToBigInt(value) {
20071
20364
  return BigInt(value.toString());
20072
20365
  }
@@ -20132,10 +20425,10 @@ var WithdrawalQueueService = class {
20132
20425
  const vault = await this.client.account.fetchVault(queue.vault, {
20133
20426
  fresh: true
20134
20427
  });
20135
- if (queue.inputMint === (0, import_common51.fromWeb3Pk)(vault.mint)) {
20428
+ if (queue.inputMint === (0, import_common53.fromWeb3Pk)(vault.mint)) {
20136
20429
  const plan2 = await this.client.tx.fulfillAsyncWithdraw.getTx({
20137
20430
  owner: queue.owner,
20138
- signer: (0, import_common51.fromWeb3Pk)(signer.publicKey),
20431
+ signer: (0, import_common53.fromWeb3Pk)(signer.publicKey),
20139
20432
  queuePayer: queue.payer,
20140
20433
  vault: queue.vault,
20141
20434
  withdrawalQueue: queue.pda,
@@ -20149,14 +20442,14 @@ var WithdrawalQueueService = class {
20149
20442
  queue.vault,
20150
20443
  { fresh: true }
20151
20444
  );
20152
- if (queue.inputMint !== (0, import_common51.fromWeb3Pk)(tranche.config.juniorMint)) {
20445
+ if (queue.inputMint !== (0, import_common53.fromWeb3Pk)(tranche.config.juniorMint)) {
20153
20446
  throw new Error(
20154
20447
  `Unsupported withdrawal queue input mint: ${queue.inputMint}`
20155
20448
  );
20156
20449
  }
20157
20450
  const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
20158
20451
  owner: queue.owner,
20159
- signer: (0, import_common51.fromWeb3Pk)(signer.publicKey),
20452
+ signer: (0, import_common53.fromWeb3Pk)(signer.publicKey),
20160
20453
  queuePayer: queue.payer,
20161
20454
  vault: queue.vault,
20162
20455
  withdrawalQueue: queue.pda,
@@ -20210,22 +20503,24 @@ var WithdrawalQueueService = class {
20210
20503
  const a = account;
20211
20504
  return {
20212
20505
  pda,
20213
- vault: (0, import_common51.fromWeb3Pk)(a.parties.vault),
20214
- owner: (0, import_common51.fromWeb3Pk)(a.parties.owner),
20215
- payer: (0, import_common51.fromWeb3Pk)(a.parties.payer),
20506
+ vault: (0, import_common53.fromWeb3Pk)(a.parties.vault),
20507
+ owner: (0, import_common53.fromWeb3Pk)(a.parties.owner),
20508
+ payer: (0, import_common53.fromWeb3Pk)(a.parties.payer),
20216
20509
  queueId: a.header.queueId,
20217
- inputMint: (0, import_common51.fromWeb3Pk)(a.mints.inputMint),
20218
- outputMint: (0, import_common51.fromWeb3Pk)(a.mints.outputMint),
20510
+ inputMint: (0, import_common53.fromWeb3Pk)(a.mints.inputMint),
20511
+ outputMint: (0, import_common53.fromWeb3Pk)(a.mints.outputMint),
20219
20512
  inputAmount: bnToBigInt(a.request.inputAmount),
20220
20513
  requestTs: bnToNumber(a.request.requestTs),
20221
- expiryTs: bnToNumber(a.request.expiryTs)
20514
+ expiryTs: bnToNumber(a.request.expiryTs),
20515
+ outputAmount: a.request.pricedTs && bnToNumber(a.request.pricedTs) > 0 ? bnToBigInt(a.request.outputAmount) : null,
20516
+ pricedTs: a.request.pricedTs && bnToNumber(a.request.pricedTs) > 0 ? bnToNumber(a.request.pricedTs) : null
20222
20517
  };
20223
20518
  }
20224
20519
  };
20225
20520
 
20226
20521
  // src/services/oracleService.ts
20227
20522
  var import_kit12 = require("@solana/kit");
20228
- var import_common52 = __toESM(require_dist());
20523
+ var import_common54 = __toESM(require_dist());
20229
20524
  var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
20230
20525
  var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
20231
20526
  var PRICE_ORACLE_TYPES_BY_INDEX2 = [
@@ -20289,7 +20584,7 @@ var OracleService = class {
20289
20584
  */
20290
20585
  async updateAssetConsensusPrice(signer, args, log) {
20291
20586
  const plan = await this.client.tx.updateConsensusOracle.getTx({
20292
- signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
20587
+ signer: (0, import_common54.fromWeb3Pk)(signer.publicKey),
20293
20588
  vault: args.vault,
20294
20589
  updates: args.updates,
20295
20590
  assetMint: args.assetMint,
@@ -20305,7 +20600,7 @@ var OracleService = class {
20305
20600
  /** Settle the vault NAV from its current holdings (permissionless). */
20306
20601
  async crankNav(cranker, args, log) {
20307
20602
  const plan = await this.client.tx.crankNav.getTx({
20308
- cranker: (0, import_common52.fromWeb3Pk)(cranker.publicKey),
20603
+ cranker: (0, import_common54.fromWeb3Pk)(cranker.publicKey),
20309
20604
  vault: args.vault,
20310
20605
  vaultTrancheState: args.vaultTrancheState
20311
20606
  });
@@ -20378,7 +20673,7 @@ var OracleService = class {
20378
20673
  /** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
20379
20674
  async refreshAssetPrice(updater, args, log) {
20380
20675
  const plan = await this.client.tx.updateAssetPrice.getTx({
20381
- updater: (0, import_common52.fromWeb3Pk)(updater.publicKey),
20676
+ updater: (0, import_common54.fromWeb3Pk)(updater.publicKey),
20382
20677
  vault: args.vault,
20383
20678
  mint: args.mint,
20384
20679
  oracleAccount: args.oracleAccount,
@@ -20474,11 +20769,11 @@ function toBigInt2(value) {
20474
20769
  }
20475
20770
 
20476
20771
  // src/services/consensusOracle/utils/holdings.ts
20477
- var import_web334 = require("@solana/web3.js");
20478
- var import_common53 = __toESM(require_dist());
20772
+ var import_web335 = require("@solana/web3.js");
20773
+ var import_common55 = __toESM(require_dist());
20479
20774
  function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
20480
20775
  return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
20481
- const mint = (0, import_common53.fromWeb3Pk)(holding.mint);
20776
+ const mint = (0, import_common55.fromWeb3Pk)(holding.mint);
20482
20777
  return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
20483
20778
  variantName2(holding.priceOracleType).toLowerCase()
20484
20779
  );
@@ -20513,7 +20808,7 @@ function parseExternalLiquidityRefs(vaultState) {
20513
20808
  if (!data || data.length < 40) continue;
20514
20809
  if (data[0] !== 1 && data[0] !== 2) continue;
20515
20810
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
20516
- const userAccount = new import_web334.PublicKey(pubkeyBytes).toBase58();
20811
+ const userAccount = new import_web335.PublicKey(pubkeyBytes).toBase58();
20517
20812
  refs.push(
20518
20813
  data[0] === 1 ? { kind: "marginfi", mint: "", marginfiAccount: userAccount } : {
20519
20814
  kind: "kamino-lend",
@@ -20741,12 +21036,12 @@ function formatBpsAsPercent(bps) {
20741
21036
  }
20742
21037
 
20743
21038
  // src/services/consensusOracle/pipeline/dryRunSettlement.ts
20744
- var import_web336 = require("@solana/web3.js");
20745
- var import_common54 = __toESM(require_dist());
21039
+ var import_web337 = require("@solana/web3.js");
21040
+ var import_common56 = __toESM(require_dist());
20746
21041
 
20747
21042
  // src/services/consensusOracle/settlement/settlementSimulator.ts
20748
21043
  var import_kit13 = require("@solana/kit");
20749
- var import_web335 = require("@solana/web3.js");
21044
+ var import_web336 = require("@solana/web3.js");
20750
21045
  var DEFAULT_SHARE_PRICE = 1000000n;
20751
21046
  var BPS_DENOMINATOR3 = 10000n;
20752
21047
  var NAV_LOSS_TOLERANCE_BPS = 1n;
@@ -21019,7 +21314,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
21019
21314
  continue;
21020
21315
  }
21021
21316
  const reports = entries.filter(
21022
- (entry) => entry.signer !== import_web335.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
21317
+ (entry) => entry.signer !== import_web336.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
21023
21318
  );
21024
21319
  const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
21025
21320
  const prices = reports.map((entry) => entry.prices[index] ?? 0n);
@@ -21520,7 +21815,7 @@ function decodeOracleData(data, nowTs) {
21520
21815
  (_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
21521
21816
  );
21522
21817
  entries.push({
21523
- signer: new import_web335.PublicKey(signerBytes).toBase58(),
21818
+ signer: new import_web336.PublicKey(signerBytes).toBase58(),
21524
21819
  lastUpdateTs: readI64(data, offset + 32),
21525
21820
  prices,
21526
21821
  externalAmounts
@@ -21535,7 +21830,7 @@ function decodeOracleData(data, nowTs) {
21535
21830
  data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
21536
21831
  );
21537
21832
  entries[index] = {
21538
- signer: index < pendingCount ? new import_web335.PublicKey(signerBytes).toBase58() : import_web335.PublicKey.default.toBase58(),
21833
+ signer: index < pendingCount ? new import_web336.PublicKey(signerBytes).toBase58() : import_web336.PublicKey.default.toBase58(),
21539
21834
  lastUpdateTs: 0n,
21540
21835
  prices: Array(MAX_HOLDINGS).fill(0n),
21541
21836
  externalAmounts: Array(MAX_HOLDINGS).fill(0n)
@@ -21563,7 +21858,7 @@ function decodeHolding(value) {
21563
21858
  externalAmount: bigint(holding.externalAmount),
21564
21859
  price: bigint(holding.price),
21565
21860
  lastUpdateTs: bigint(holding.lastUpdateTs),
21566
- cleared: mintString === import_web335.PublicKey.default.toBase58()
21861
+ cleared: mintString === import_web336.PublicKey.default.toBase58()
21567
21862
  };
21568
21863
  }
21569
21864
  function decodeTrancheState(decoded, args, warnings, blockers) {
@@ -22046,11 +22341,11 @@ async function fetchSimulationArgs({
22046
22341
  client.account.fetchVaultOracleForVault(vault, { fresh: true }),
22047
22342
  tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
22048
22343
  ]);
22049
- const mintKeys = [new import_web336.PublicKey(vaultState.mint)];
22344
+ const mintKeys = [new import_web337.PublicKey(vaultState.mint)];
22050
22345
  if (trancheState) {
22051
22346
  mintKeys.push(
22052
- new import_web336.PublicKey(trancheState.config.juniorMint),
22053
- new import_web336.PublicKey(trancheState.config.seniorMint)
22347
+ new import_web337.PublicKey(trancheState.config.juniorMint),
22348
+ new import_web337.PublicKey(trancheState.config.seniorMint)
22054
22349
  );
22055
22350
  }
22056
22351
  const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
@@ -22066,7 +22361,7 @@ async function fetchSimulationArgs({
22066
22361
  oracleData: oracleState.data,
22067
22362
  trancheState,
22068
22363
  updates,
22069
- signer: (0, import_common54.fromWeb3Pk)(signer.publicKey),
22364
+ signer: (0, import_common56.fromWeb3Pk)(signer.publicKey),
22070
22365
  nowTs: nowSecs,
22071
22366
  physicalShareSupply: supplies[0],
22072
22367
  physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
@@ -22075,7 +22370,7 @@ async function fetchSimulationArgs({
22075
22370
  }
22076
22371
 
22077
22372
  // src/services/consensusOracle/pipeline/holdingUpdates.ts
22078
- var import_common55 = __toESM(require_dist());
22373
+ var import_common57 = __toESM(require_dist());
22079
22374
  async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
22080
22375
  const updates = [];
22081
22376
  for (const entry of reportableHoldings) {
@@ -22085,7 +22380,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
22085
22380
  }
22086
22381
  async function buildHoldingUpdate(yieldTracker, entry, inputs) {
22087
22382
  const { holding, holdingIndex } = entry;
22088
- const mint = (0, import_common55.fromWeb3Pk)(holding.mint);
22383
+ const mint = (0, import_common57.fromWeb3Pk)(holding.mint);
22089
22384
  const mintKey = mint.toString();
22090
22385
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
22091
22386
  let usd;
@@ -22147,9 +22442,9 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
22147
22442
  );
22148
22443
  }
22149
22444
  return {
22150
- trackedValueAmount: tracked.totalValue > 0 ? (0, import_common55.fromUiAmount)(tracked.totalValue, decimals) : 0n,
22151
- principalAmount: tracked.principal > 0 ? (0, import_common55.fromUiAmount)(tracked.principal, decimals) : 0n,
22152
- yieldAmount: tracked.outstandingYield > 0 ? (0, import_common55.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
22445
+ trackedValueAmount: tracked.totalValue > 0 ? (0, import_common57.fromUiAmount)(tracked.totalValue, decimals) : 0n,
22446
+ principalAmount: tracked.principal > 0 ? (0, import_common57.fromUiAmount)(tracked.principal, decimals) : 0n,
22447
+ yieldAmount: tracked.outstandingYield > 0 ? (0, import_common57.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
22153
22448
  };
22154
22449
  }
22155
22450
 
@@ -22183,7 +22478,7 @@ function assertOracleImpliedApy(vault, simulation, label) {
22183
22478
  }
22184
22479
 
22185
22480
  // src/services/consensusOracle/pipeline/livePriceRefresh.ts
22186
- var import_common56 = __toESM(require_dist());
22481
+ var import_common58 = __toESM(require_dist());
22187
22482
  async function refreshLiveOraclePrices({
22188
22483
  oracle,
22189
22484
  signer,
@@ -22202,7 +22497,7 @@ async function refreshLiveOraclePrices({
22202
22497
  for (const holding of vaultState.holdings) {
22203
22498
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
22204
22499
  if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
22205
- const mint = (0, import_common56.fromWeb3Pk)(holding.mint);
22500
+ const mint = (0, import_common58.fromWeb3Pk)(holding.mint);
22206
22501
  if (mint.toString() === SYSTEM_PROGRAM) continue;
22207
22502
  const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
22208
22503
  if (activeAmount === 0n) continue;
@@ -22217,7 +22512,7 @@ async function refreshLiveOraclePrices({
22217
22512
  );
22218
22513
  continue;
22219
22514
  }
22220
- const oracleAccount = (0, import_common56.fromWeb3Pk)(holding.priceOracleAccount);
22515
+ const oracleAccount = (0, import_common58.fromWeb3Pk)(holding.priceOracleAccount);
22221
22516
  if (oracleAccount.toString() === SYSTEM_PROGRAM) {
22222
22517
  log(
22223
22518
  `vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
@@ -22241,7 +22536,7 @@ async function refreshLiveOraclePrices({
22241
22536
  }
22242
22537
 
22243
22538
  // src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
22244
- var import_common57 = __toESM(require_dist());
22539
+ var import_common59 = __toESM(require_dist());
22245
22540
 
22246
22541
  // src/services/consensusOracle/sources/nestPriceSource.ts
22247
22542
  var import_kit14 = require("@solana/kit");
@@ -22288,13 +22583,13 @@ function candidateGrossNav(state, updates) {
22288
22583
  const byIndex = /* @__PURE__ */ new Map();
22289
22584
  for (const update of updates) {
22290
22585
  const holding = state.holdings[update.holdingIndex];
22291
- if (!holding || (0, import_common57.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
22586
+ if (!holding || (0, import_common59.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
22292
22587
  throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
22293
22588
  }
22294
22589
  byIndex.set(update.holdingIndex, update);
22295
22590
  }
22296
22591
  return state.holdings.reduce((nav, holding, index) => {
22297
- if ((0, import_common57.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
22592
+ if ((0, import_common59.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
22298
22593
  const update = byIndex.get(index);
22299
22594
  const local = toBigInt2(holding.localAmount);
22300
22595
  const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
@@ -22361,13 +22656,13 @@ async function reconcileManagerWalletBalances({
22361
22656
  throw new Error("Duplicate base mint in manager reconciliation");
22362
22657
  }
22363
22658
  if (vaultState.holdings.some(
22364
- (holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common57.fromWeb3Pk)(holding.mint))
22659
+ (holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common59.fromWeb3Pk)(holding.mint))
22365
22660
  )) {
22366
22661
  throw new Error(
22367
22662
  "Cannot reconcile all vault base assets with oracle reports"
22368
22663
  );
22369
22664
  }
22370
- const manager = (0, import_common57.fromWeb3Pk)(vaultState.roles.manager);
22665
+ const manager = (0, import_common59.fromWeb3Pk)(vaultState.roles.manager);
22371
22666
  if (manager === SYSTEM_PROGRAM || manager === vault) {
22372
22667
  throw new Error("Invalid manager wallet for NAV reconciliation");
22373
22668
  }
@@ -22453,13 +22748,13 @@ function walletReconciliationGuardUpdates(state, reconciliation) {
22453
22748
  }
22454
22749
  function managerReconciliationStateKey(state) {
22455
22750
  return JSON.stringify({
22456
- manager: (0, import_common57.fromWeb3Pk)(state.roles.manager),
22751
+ manager: (0, import_common59.fromWeb3Pk)(state.roles.manager),
22457
22752
  assetDecimals: state.config.assetDecimals,
22458
22753
  holdings: state.holdings.map((holding) => [
22459
- (0, import_common57.fromWeb3Pk)(holding.mint),
22754
+ (0, import_common59.fromWeb3Pk)(holding.mint),
22460
22755
  holding.decimals,
22461
22756
  variantName2(holding.priceOracleType),
22462
- holding.priceOracleAccount ? (0, import_common57.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
22757
+ holding.priceOracleAccount ? (0, import_common59.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
22463
22758
  coerceBool3(holding.isBase),
22464
22759
  toBigInt2(holding.localAmount).toString()
22465
22760
  ])
@@ -22498,14 +22793,14 @@ function assertReconciliationExternalValues(initial, current, errorPrefix) {
22498
22793
  }
22499
22794
 
22500
22795
  // src/services/consensusOracle/pipeline/pricingInputs.ts
22501
- var import_common58 = __toESM(require_dist());
22796
+ var import_common60 = __toESM(require_dist());
22502
22797
  async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
22503
22798
  }) {
22504
22799
  const consensusMints = reportableHoldings.filter(
22505
22800
  ({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
22506
- ).map(({ holding }) => (0, import_common58.fromWeb3Pk)(holding.mint));
22801
+ ).map(({ holding }) => (0, import_common60.fromWeb3Pk)(holding.mint));
22507
22802
  const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
22508
- const baseMint = baseHolding ? (0, import_common58.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
22803
+ const baseMint = baseHolding ? (0, import_common60.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
22509
22804
  if (!baseMint) {
22510
22805
  throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
22511
22806
  }
@@ -22591,11 +22886,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
22591
22886
  }
22592
22887
 
22593
22888
  // src/services/consensusOracle/pipeline/receiptMints.ts
22594
- var import_common59 = __toESM(require_dist());
22889
+ var import_common61 = __toESM(require_dist());
22595
22890
  async function fetchReceiptMints(client, vault, vaultState) {
22596
22891
  const receiptMints = /* @__PURE__ */ new Set();
22597
22892
  if (vaultState.mint) {
22598
- receiptMints.add((0, import_common59.fromWeb3Pk)(vaultState.mint).toString());
22893
+ receiptMints.add((0, import_common61.fromWeb3Pk)(vaultState.mint).toString());
22599
22894
  }
22600
22895
  if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
22601
22896
  const trancheState = await client.account.fetchVaultTrancheStateForVault(
@@ -22603,19 +22898,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
22603
22898
  { fresh: true }
22604
22899
  );
22605
22900
  receiptMints.add(
22606
- (0, import_common59.fromWeb3Pk)(trancheState.config.juniorMint).toString()
22901
+ (0, import_common61.fromWeb3Pk)(trancheState.config.juniorMint).toString()
22607
22902
  );
22608
22903
  receiptMints.add(
22609
- (0, import_common59.fromWeb3Pk)(trancheState.config.seniorMint).toString()
22904
+ (0, import_common61.fromWeb3Pk)(trancheState.config.seniorMint).toString()
22610
22905
  );
22611
22906
  return receiptMints;
22612
22907
  }
22613
22908
 
22614
22909
  // src/services/consensusOracle/pipeline/settlement.ts
22615
- var import_common61 = __toESM(require_dist());
22910
+ var import_common63 = __toESM(require_dist());
22616
22911
 
22617
22912
  // src/services/consensusOracle/pipeline/yieldAccounts.ts
22618
- var import_common60 = __toESM(require_dist());
22913
+ var import_common62 = __toESM(require_dist());
22619
22914
  async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
22620
22915
  const accountNames = [
22621
22916
  ...new Set(
@@ -22657,7 +22952,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
22657
22952
  );
22658
22953
  if (namesToAttach.length === 0) return target;
22659
22954
  const baseHolding = vaultState.holdings.find((holding) => {
22660
- const mint = (0, import_common60.fromWeb3Pk)(holding.mint).toString();
22955
+ const mint = (0, import_common62.fromWeb3Pk)(holding.mint).toString();
22661
22956
  return coerceBool3(holding.isBase) && !excludedMints.has(mint);
22662
22957
  });
22663
22958
  if (!baseHolding) {
@@ -22665,7 +22960,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
22665
22960
  `vault ${target.vault}: tagged yield accounts found but no base holding is available`
22666
22961
  );
22667
22962
  }
22668
- const baseMint = (0, import_common60.fromWeb3Pk)(baseHolding.mint);
22963
+ const baseMint = (0, import_common62.fromWeb3Pk)(baseHolding.mint);
22669
22964
  const holdings = [...target.holdings ?? []];
22670
22965
  const existingIndex = holdings.findIndex(
22671
22966
  (holding) => holding.mint.toString() === baseMint.toString()
@@ -22750,7 +23045,7 @@ async function settleVault2({
22750
23045
  vault: publishedVault,
22751
23046
  oracleData: publishedOracle.data,
22752
23047
  updates,
22753
- signer: (0, import_common61.fromWeb3Pk)(signer.publicKey),
23048
+ signer: (0, import_common63.fromWeb3Pk)(signer.publicKey),
22754
23049
  nowTs: publishedAt
22755
23050
  });
22756
23051
  if (blockers.length)
@@ -22792,7 +23087,7 @@ async function logProspectiveApy({
22792
23087
  );
22793
23088
  const prospectiveNav = vaultState.holdings.reduce(
22794
23089
  (sum, holding, holdingIndex) => {
22795
- const mint = (0, import_common61.fromWeb3Pk)(holding.mint).toString();
23090
+ const mint = (0, import_common63.fromWeb3Pk)(holding.mint).toString();
22796
23091
  if (mint === SYSTEM_PROGRAM) return sum;
22797
23092
  const update = updatesByIndex.get(holdingIndex);
22798
23093
  const localAmount = toBigInt2(holding.localAmount);
@@ -23719,7 +24014,7 @@ async function buildJupiterSwapTransaction(params) {
23719
24014
  }
23720
24015
 
23721
24016
  // ../jupiter/src/client.ts
23722
- var import_common62 = __toESM(require_dist());
24017
+ var import_common64 = __toESM(require_dist());
23723
24018
 
23724
24019
  // ../jupiter/src/extract.ts
23725
24020
  var import_kit17 = require("@solana/kit");
@@ -23749,8 +24044,8 @@ async function extractJupiterInstruction(transaction, rpc, jupiterProgramId = JU
23749
24044
 
23750
24045
  // ../jupiter/src/routePreInstructions.ts
23751
24046
  var import_kit18 = require("@solana/kit");
23752
- var import_spl_token24 = require("@solana/spl-token");
23753
- var import_web337 = require("@solana/web3.js");
24047
+ var import_spl_token25 = require("@solana/spl-token");
24048
+ var import_web338 = require("@solana/web3.js");
23754
24049
  async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23755
24050
  const intermediate = /* @__PURE__ */ new Set();
23756
24051
  for (const step of quote.routePlan ?? []) {
@@ -23774,26 +24069,26 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23774
24069
  `getJupiterRoutePreInstructions: route mint ${mint} not found on-chain`
23775
24070
  );
23776
24071
  }
23777
- const ata = (0, import_spl_token24.getAssociatedTokenAddressSync)(
23778
- new import_web337.PublicKey(mint),
23779
- new import_web337.PublicKey(user),
24072
+ const ata = (0, import_spl_token25.getAssociatedTokenAddressSync)(
24073
+ new import_web338.PublicKey(mint),
24074
+ new import_web338.PublicKey(user),
23780
24075
  true,
23781
- new import_web337.PublicKey(tokenProgram),
23782
- import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID
24076
+ new import_web338.PublicKey(tokenProgram),
24077
+ import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID
23783
24078
  ).toBase58();
23784
24079
  const existingAta = await rpc.getAccountInfo(ata, { encoding: "base64" }).send();
23785
24080
  if (existingAta.value) {
23786
24081
  continue;
23787
24082
  }
23788
24083
  instructions2.push(
23789
- toKitInstruction39(
23790
- (0, import_spl_token24.createAssociatedTokenAccountIdempotentInstruction)(
23791
- new import_web337.PublicKey(payer),
23792
- new import_web337.PublicKey(ata),
23793
- new import_web337.PublicKey(user),
23794
- new import_web337.PublicKey(mint),
23795
- new import_web337.PublicKey(tokenProgram),
23796
- import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID
24084
+ toKitInstruction41(
24085
+ (0, import_spl_token25.createAssociatedTokenAccountIdempotentInstruction)(
24086
+ new import_web338.PublicKey(payer),
24087
+ new import_web338.PublicKey(ata),
24088
+ new import_web338.PublicKey(user),
24089
+ new import_web338.PublicKey(mint),
24090
+ new import_web338.PublicKey(tokenProgram),
24091
+ import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID
23797
24092
  )
23798
24093
  )
23799
24094
  );
@@ -23801,7 +24096,7 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23801
24096
  }
23802
24097
  return { instructions: instructions2, postSuccessCacheInvalidations };
23803
24098
  }
23804
- function toKitInstruction39(ix) {
24099
+ function toKitInstruction41(ix) {
23805
24100
  return {
23806
24101
  programAddress: ix.programId.toBase58(),
23807
24102
  accounts: ix.keys.map((account) => ({
@@ -23918,7 +24213,7 @@ var JupiterSwapClient = class {
23918
24213
  }
23919
24214
  }
23920
24215
  return {
23921
- cpiType: this.config.cpiType ?? import_common62.CpiTypes.JUPITER_SWAP,
24216
+ cpiType: this.config.cpiType ?? import_common64.CpiTypes.JUPITER_SWAP,
23922
24217
  data,
23923
24218
  accounts: accounts2,
23924
24219
  programId: JUPITER_V6_PROGRAM_ID,
@@ -24016,8 +24311,8 @@ var LivePriceSource = class {
24016
24311
  };
24017
24312
 
24018
24313
  // src/services/consensusOracle/sources/managerWalletBalanceSource.ts
24019
- var import_web338 = require("@solana/web3.js");
24020
- var import_spl_token25 = require("@solana/spl-token");
24314
+ var import_web339 = require("@solana/web3.js");
24315
+ var import_spl_token26 = require("@solana/spl-token");
24021
24316
  var RpcManagerWalletBalanceSource = class {
24022
24317
  constructor(connection) {
24023
24318
  this.connection = connection;
@@ -24025,8 +24320,8 @@ var RpcManagerWalletBalanceSource = class {
24025
24320
  async fetchBalances(manager, mints2) {
24026
24321
  const wanted = new Set(mints2);
24027
24322
  if (wanted.size === 0) return /* @__PURE__ */ new Map();
24028
- const owner = new import_web338.PublicKey(manager);
24029
- const programs = [import_spl_token25.TOKEN_PROGRAM_ID, import_spl_token25.TOKEN_2022_PROGRAM_ID];
24323
+ const owner = new import_web339.PublicKey(manager);
24324
+ const programs = [import_spl_token26.TOKEN_PROGRAM_ID, import_spl_token26.TOKEN_2022_PROGRAM_ID];
24030
24325
  const responses = await Promise.all(
24031
24326
  programs.map(
24032
24327
  (programId) => this.connection.getParsedTokenAccountsByOwner(
@@ -24069,7 +24364,7 @@ var RpcManagerWalletBalanceSource = class {
24069
24364
  };
24070
24365
 
24071
24366
  // src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
24072
- var import_web339 = require("@solana/web3.js");
24367
+ var import_web340 = require("@solana/web3.js");
24073
24368
 
24074
24369
  // src/services/consensusOracle/sources/mpcMarginfiDeposits.ts
24075
24370
  var import_kit19 = require("@solana/kit");
@@ -24158,8 +24453,8 @@ var RpcMpcWalletBalanceSource = class {
24158
24453
  const wallets = /* @__PURE__ */ new Set();
24159
24454
  for (const binding of bindings) {
24160
24455
  const { vault, manager, wallet } = binding;
24161
- for (const key of [vault, manager, wallet]) new import_web339.PublicKey(key);
24162
- if (entries.has(vault) || wallets.has(wallet) || wallet === manager || wallet === vault || wallet === import_web339.PublicKey.default.toBase58())
24456
+ for (const key of [vault, manager, wallet]) new import_web340.PublicKey(key);
24457
+ if (entries.has(vault) || wallets.has(wallet) || wallet === manager || wallet === vault || wallet === import_web340.PublicKey.default.toBase58())
24163
24458
  throw new Error("Invalid or duplicate MPC wallet binding");
24164
24459
  entries.set(vault, { ...binding });
24165
24460
  wallets.add(wallet);
@@ -24179,8 +24474,8 @@ var RpcMpcWalletBalanceSource = class {
24179
24474
  this.tokens.fetchBalances(binding.wallet, mints2),
24180
24475
  readMarginfiDepositsForAuthority(
24181
24476
  this.connection,
24182
- new import_web339.PublicKey(binding.wallet),
24183
- mints2.map((mint) => new import_web339.PublicKey(mint))
24477
+ new import_web340.PublicKey(binding.wallet),
24478
+ mints2.map((mint) => new import_web340.PublicKey(mint))
24184
24479
  )
24185
24480
  ]);
24186
24481
  return { wallet: binding.wallet, tokens, marginfi: deposits };
@@ -24223,7 +24518,7 @@ var StaticPositionProvider = class {
24223
24518
 
24224
24519
  // src/services/consensusOracle/positions/kaminoPositionProvider.ts
24225
24520
  var import_kit20 = require("@solana/kit");
24226
- var import_web340 = require("@solana/web3.js");
24521
+ var import_web341 = require("@solana/web3.js");
24227
24522
  var import_klend_sdk = require("@kamino-finance/klend-sdk");
24228
24523
  async function readKaminoBalance(manager, vault, sharesHolder) {
24229
24524
  const userShares = await manager.getUserSharesBalanceSingleVault(
@@ -24260,7 +24555,7 @@ var KaminoPositionProvider = class {
24260
24555
  const amount = await readKaminoBalance(
24261
24556
  manager,
24262
24557
  kVault,
24263
- new import_web340.PublicKey(sharesHolder)
24558
+ new import_web341.PublicKey(sharesHolder)
24264
24559
  );
24265
24560
  out.push({ mint: ref.mint, amount });
24266
24561
  }
@@ -24269,11 +24564,11 @@ var KaminoPositionProvider = class {
24269
24564
  };
24270
24565
 
24271
24566
  // src/services/consensusOracle/positions/kaminoLendPositionProvider.ts
24272
- var import_web341 = require("@solana/web3.js");
24567
+ var import_web342 = require("@solana/web3.js");
24273
24568
  var import_Obligation2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
24274
24569
  var import_Reserve2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
24275
24570
  var import_kamino4 = __toESM(require_dist3());
24276
- var ZERO = import_web341.PublicKey.default.toBase58();
24571
+ var ZERO = import_web342.PublicKey.default.toBase58();
24277
24572
  var FRACTION_SCALE = 1n << 60n;
24278
24573
  function accountData(info, label) {
24279
24574
  if (!info || info.executable || info.owner.toBase58() !== import_kamino4.KLEND_PROGRAM_ID)
@@ -24314,7 +24609,7 @@ var KaminoLendPositionProvider = class {
24314
24609
  }
24315
24610
  const positions = [];
24316
24611
  for (const address18 of obligations) {
24317
- const key = new import_web341.PublicKey(address18);
24612
+ const key = new import_web342.PublicKey(address18);
24318
24613
  const discovered = decodeObligation(
24319
24614
  await this.connection.getAccountInfo(key, "confirmed"),
24320
24615
  ctx.vault
@@ -24324,7 +24619,7 @@ var KaminoLendPositionProvider = class {
24324
24619
  (deposit) => deposit.depositReserve
24325
24620
  );
24326
24621
  const infos = await this.connection.getMultipleAccountsInfo(
24327
- [key, ...reserves.map((reserve) => new import_web341.PublicKey(reserve))],
24622
+ [key, ...reserves.map((reserve) => new import_web342.PublicKey(reserve))],
24328
24623
  "confirmed"
24329
24624
  );
24330
24625
  const { obligation, deposits } = decodeObligation(
@@ -24366,7 +24661,7 @@ var KaminoLendPositionProvider = class {
24366
24661
  };
24367
24662
 
24368
24663
  // src/services/consensusOracle/positions/marginfiPositionProvider.ts
24369
- var import_web342 = require("@solana/web3.js");
24664
+ var import_web343 = require("@solana/web3.js");
24370
24665
  var import_marginfi4 = __toESM(require_dist2());
24371
24666
  var MarginfiPositionProvider = class {
24372
24667
  constructor(connection, log = () => {
@@ -24377,8 +24672,8 @@ var MarginfiPositionProvider = class {
24377
24672
  async positionsFor(ctx) {
24378
24673
  const refs = ctx.refs.filter((r) => r.kind === "marginfi");
24379
24674
  if (refs.length === 0) return [];
24380
- const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web342.PublicKey(bank));
24381
- const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new import_web342.PublicKey(account));
24675
+ const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web343.PublicKey(bank));
24676
+ const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new import_web343.PublicKey(account));
24382
24677
  const autoBanks = [];
24383
24678
  for (const accountPk of autoAccountPks) {
24384
24679
  try {
@@ -24407,14 +24702,14 @@ var MarginfiPositionProvider = class {
24407
24702
  if (bank) {
24408
24703
  const amount = await (0, import_marginfi4.readMarginfiBankBalance)(
24409
24704
  client,
24410
- new import_web342.PublicKey(account),
24411
- new import_web342.PublicKey(bank)
24705
+ new import_web343.PublicKey(account),
24706
+ new import_web343.PublicKey(bank)
24412
24707
  );
24413
24708
  out.push({ mint: ref.mint, amount });
24414
24709
  } else {
24415
24710
  const balances = await (0, import_marginfi4.readAllMarginfiBalances)(
24416
24711
  client,
24417
- new import_web342.PublicKey(account)
24712
+ new import_web343.PublicKey(account)
24418
24713
  );
24419
24714
  for (const { mint, amount } of balances) {
24420
24715
  out.push({ mint: mint.toBase58(), amount });
@@ -24684,7 +24979,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
24684
24979
  }
24685
24980
 
24686
24981
  // src/services/consensusOracle/consensusOracleService.ts
24687
- var import_common63 = __toESM(require_dist());
24982
+ var import_common65 = __toESM(require_dist());
24688
24983
  var ConsensusOracleService = class {
24689
24984
  constructor(client, deps) {
24690
24985
  this.client = client;
@@ -24720,7 +25015,7 @@ var ConsensusOracleService = class {
24720
25015
  receiptMints
24721
25016
  );
24722
25017
  const filteredCount = vaultState.holdings.filter(
24723
- (holding) => receiptMints.has((0, import_common63.fromWeb3Pk)(holding.mint).toString())
25018
+ (holding) => receiptMints.has((0, import_common65.fromWeb3Pk)(holding.mint).toString())
24724
25019
  ).length;
24725
25020
  if (filteredCount > 0) {
24726
25021
  log(
@@ -24989,8 +25284,8 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
24989
25284
 
24990
25285
  // src/services/externalLiquidityIntegrityService.ts
24991
25286
  var import_kit22 = require("@solana/kit");
24992
- var import_web343 = require("@solana/web3.js");
24993
- var import_common64 = __toESM(require_dist());
25287
+ var import_web344 = require("@solana/web3.js");
25288
+ var import_common66 = __toESM(require_dist());
24994
25289
  var import_marginfi5 = __toESM(require_dist2());
24995
25290
  var import_kamino5 = __toESM(require_dist3());
24996
25291
  var import_marginfi_client_v23 = require("@mrgnlabs/marginfi-client-v2");
@@ -25100,7 +25395,7 @@ function parseActiveSlots(externalLiquidity) {
25100
25395
  if (discriminant === 0) continue;
25101
25396
  if (discriminant !== 1 && discriminant !== 2) continue;
25102
25397
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
25103
- const userAccount = (0, import_common64.toAddress)(new import_web343.PublicKey(pubkeyBytes));
25398
+ const userAccount = (0, import_common66.toAddress)(new import_web344.PublicKey(pubkeyBytes));
25104
25399
  if (isZeroPubkey2(userAccount))
25105
25400
  throw new Error("Registered external position has a zero address");
25106
25401
  if (results.some((slot) => slot.userAccount === userAccount)) continue;
@@ -25272,7 +25567,7 @@ var ExternalLiquidityIntegrityService = class {
25272
25567
  const decimals = Number(holding.decimals ?? 0);
25273
25568
  const minRaw = toRawAmount(minAmountUi, decimals);
25274
25569
  let targetLocalAmount;
25275
- if (mintAddress === import_common64.USDC_MINT) {
25570
+ if (mintAddress === import_common66.USDC_MINT) {
25276
25571
  const tvl = toBigInt3(vaultState.accounting.tvl);
25277
25572
  const price = toBigInt3(holding.price);
25278
25573
  const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
@@ -25375,25 +25670,25 @@ var ExternalLiquidityIntegrityService = class {
25375
25670
  * from vault accounting as though it were the balance of each separate slot. */
25376
25671
  async loadPositions(vault, mint, slots) {
25377
25672
  const marginfi = (0, import_marginfi5.marginfiAccountsForMint)(mint);
25378
- if (!marginfi && mint !== import_common64.USDC_MINT)
25673
+ if (!marginfi && mint !== import_common66.USDC_MINT)
25379
25674
  return {
25380
25675
  local: 0n,
25381
25676
  positions: [],
25382
- tokenProgram: (0, import_kit22.address)(import_web343.PublicKey.default.toBase58()),
25383
- vaultAta: (0, import_kit22.address)(import_web343.PublicKey.default.toBase58())
25677
+ tokenProgram: (0, import_kit22.address)(import_web344.PublicKey.default.toBase58()),
25678
+ vaultAta: (0, import_kit22.address)(import_web344.PublicKey.default.toBase58())
25384
25679
  };
25385
25680
  const connection = this.client.provider.connection;
25386
25681
  const mintInfo = await connection.getAccountInfo(
25387
- new import_web343.PublicKey(mint),
25682
+ new import_web344.PublicKey(mint),
25388
25683
  "confirmed"
25389
25684
  );
25390
25685
  if (!mintInfo) throw new Error(`Missing mint ${mint}`);
25391
- const tokenProgram = (0, import_common64.fromWeb3Pk)(mintInfo.owner);
25392
- const vaultAta = (0, import_common64.getAtaAddress)(mint, vault, tokenProgram, true);
25686
+ const tokenProgram = (0, import_common66.fromWeb3Pk)(mintInfo.owner);
25687
+ const vaultAta = (0, import_common66.getAtaAddress)(mint, vault, tokenProgram, true);
25393
25688
  const positions = [];
25394
25689
  for (const slot of slots) {
25395
25690
  if (slot.source === "marginfi" && !marginfi) continue;
25396
- if (slot.source === "kamino" && mint !== import_common64.USDC_MINT) continue;
25691
+ if (slot.source === "kamino" && mint !== import_common66.USDC_MINT) continue;
25397
25692
  const kamino = slot.source === "kamino" ? await loadKaminoDeposit({
25398
25693
  connection,
25399
25694
  vault,
@@ -25404,7 +25699,7 @@ var ExternalLiquidityIntegrityService = class {
25404
25699
  throw new Error("Kamino token program mismatch");
25405
25700
  const data = Buffer.alloc(256);
25406
25701
  data[0] = slot.source === "marginfi" ? 1 : 2;
25407
- new import_web343.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
25702
+ new import_web344.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
25408
25703
  const withdrawal = await loadWithdrawalPosition({
25409
25704
  connection,
25410
25705
  vault,
@@ -25440,8 +25735,8 @@ var ExternalLiquidityIntegrityService = class {
25440
25735
  async executeMoves(args) {
25441
25736
  const { vault, mintAddress, hwManager, snapshot: snapshot2, moves, dryRun, log } = args;
25442
25737
  const instructions2 = [
25443
- (0, import_common64.toKitInstruction)(
25444
- import_web343.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
25738
+ (0, import_common66.toKitInstruction)(
25739
+ import_web344.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
25445
25740
  )
25446
25741
  ];
25447
25742
  const lookupTables = /* @__PURE__ */ new Set();
@@ -25454,7 +25749,7 @@ var ExternalLiquidityIntegrityService = class {
25454
25749
  cpiRefs = position.withdrawal.explicitRefs(move.amount);
25455
25750
  } else if (position.source === "kamino") {
25456
25751
  if (!position.kamino) throw new Error("Missing Kamino reserve");
25457
- cpiRefs = (0, import_common64.createCpiRefs)(
25752
+ cpiRefs = (0, import_common66.createCpiRefs)(
25458
25753
  (0, import_kamino5.kaminoDepositCpis)({
25459
25754
  ...position.kamino,
25460
25755
  vault,
@@ -25465,14 +25760,14 @@ var ExternalLiquidityIntegrityService = class {
25465
25760
  );
25466
25761
  } else {
25467
25762
  const configured = (0, import_marginfi5.marginfiAccountsForMint)(mintAddress);
25468
- cpiRefs = (0, import_common64.createCpiRefs)([
25763
+ cpiRefs = (0, import_common66.createCpiRefs)([
25469
25764
  new import_marginfi5.CpiClient({ accounts: configured }).deposit_cpi({
25470
25765
  marginfiAccount: position.userAccount,
25471
25766
  authority: vault,
25472
25767
  signerTokenAccount: snapshot2.vaultAta,
25473
25768
  amount: move.amount,
25474
- lookupTables: (import_marginfi_client_v23.ADDRESS_LOOKUP_TABLE_FOR_GROUP[configured.group] ?? []).map(import_common64.fromWeb3Pk),
25475
- remainingAccounts: configured.tokenProgram === "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" ? [(0, import_common64.toCustomAccountMeta)(mintAddress)] : []
25769
+ lookupTables: (import_marginfi_client_v23.ADDRESS_LOOKUP_TABLE_FOR_GROUP[configured.group] ?? []).map(import_common66.fromWeb3Pk),
25770
+ remainingAccounts: configured.tokenProgram === "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" ? [(0, import_common66.toCustomAccountMeta)(mintAddress)] : []
25476
25771
  })
25477
25772
  ]);
25478
25773
  }
@@ -25480,7 +25775,7 @@ var ExternalLiquidityIntegrityService = class {
25480
25775
  instructions2.push(
25481
25776
  await this.client.tx.protocolInteraction.getIx({
25482
25777
  vault,
25483
- hwManager: (0, import_common64.fromWeb3Pk)(hwManager.publicKey),
25778
+ hwManager: (0, import_common66.fromWeb3Pk)(hwManager.publicKey),
25484
25779
  ...cpiRefs,
25485
25780
  externalLiquidityIndex: position.index,
25486
25781
  affectedAssetMint: mintAddress,
@@ -25512,10 +25807,10 @@ var ExternalLiquidityIntegrityService = class {
25512
25807
 
25513
25808
  // src/services/idleLiquidityService.ts
25514
25809
  var import_kit23 = require("@solana/kit");
25515
- var import_spl_token26 = require("@solana/spl-token");
25810
+ var import_spl_token27 = require("@solana/spl-token");
25516
25811
  var import_marginfi_client_v24 = require("@mrgnlabs/marginfi-client-v2");
25517
- var import_web344 = require("@solana/web3.js");
25518
- var import_common65 = __toESM(require_dist());
25812
+ var import_web345 = require("@solana/web3.js");
25813
+ var import_common67 = __toESM(require_dist());
25519
25814
  var import_marginfi6 = __toESM(require_dist2());
25520
25815
  var IDLE_RESERVE_FLOOR_BPS = 400;
25521
25816
  var IDLE_RESERVE_TARGET_BPS = 500;
@@ -25619,8 +25914,8 @@ var IdleLiquidityService = class {
25619
25914
  );
25620
25915
  }
25621
25916
  quote = await jupiter.getQuote({
25622
- inputMint: import_common65.PST_MINT,
25623
- outputMint: import_common65.USDC_MINT,
25917
+ inputMint: import_common67.PST_MINT,
25918
+ outputMint: import_common67.USDC_MINT,
25624
25919
  amount: pstInput,
25625
25920
  slippageBps
25626
25921
  });
@@ -25665,13 +25960,13 @@ var IdleLiquidityService = class {
25665
25960
  /** Read live local, Project0 and Kamino USDC, excluding other deployed capital. */
25666
25961
  async fetchIdleUsdc(vault, vaultState) {
25667
25962
  const connection = this.client.provider.connection;
25668
- const vaultPk = new import_web344.PublicKey(vault);
25669
- const usdcMint = new import_web344.PublicKey(import_common65.USDC_MINT);
25670
- const ata = (0, import_spl_token26.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
25963
+ const vaultPk = new import_web345.PublicKey(vault);
25964
+ const usdcMint = new import_web345.PublicKey(import_common67.USDC_MINT);
25965
+ const ata = (0, import_spl_token27.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
25671
25966
  const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
25672
25967
  let localAmount = 0n;
25673
25968
  if (tokenInfo) {
25674
- const tokenAccount = (0, import_spl_token26.unpackAccount)(ata, tokenInfo, import_spl_token26.TOKEN_PROGRAM_ID);
25969
+ const tokenAccount = (0, import_spl_token27.unpackAccount)(ata, tokenInfo, import_spl_token27.TOKEN_PROGRAM_ID);
25675
25970
  if (!tokenAccount.mint.equals(usdcMint) || !tokenAccount.owner.equals(vaultPk) || !tokenAccount.isInitialized) {
25676
25971
  throw new Error(`Invalid vault USDC token account: ${ata.toBase58()}`);
25677
25972
  }
@@ -25680,7 +25975,7 @@ var IdleLiquidityService = class {
25680
25975
  const kamino = await this.fetchKaminoUsdc(
25681
25976
  vault,
25682
25977
  vaultState,
25683
- (0, import_common65.fromWeb3Pk)(ata)
25978
+ (0, import_common67.fromWeb3Pk)(ata)
25684
25979
  );
25685
25980
  const slotIndex = vaultState.externalLiquidity.findIndex(
25686
25981
  (slot) => slot.data[0] === 1
@@ -25698,12 +25993,12 @@ var IdleLiquidityService = class {
25698
25993
  if (data.length < 40) {
25699
25994
  throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
25700
25995
  }
25701
- const positionPk = new import_web344.PublicKey(new Uint8Array(data.slice(8, 40)));
25996
+ const positionPk = new import_web345.PublicKey(new Uint8Array(data.slice(8, 40)));
25702
25997
  const positionInfo = await connection.getAccountInfo(
25703
25998
  positionPk,
25704
25999
  "confirmed"
25705
26000
  );
25706
- if (!positionInfo || !positionInfo.owner.equals(new import_web344.PublicKey(import_marginfi6.MARGINFI_PROGRAM_ID))) {
26001
+ if (!positionInfo || !positionInfo.owner.equals(new import_web345.PublicKey(import_marginfi6.MARGINFI_PROGRAM_ID))) {
25707
26002
  throw new Error(
25708
26003
  `Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
25709
26004
  );
@@ -25752,17 +26047,17 @@ var IdleLiquidityService = class {
25752
26047
  if (slot.data[0] !== 2) continue;
25753
26048
  if (slot.data.length < 40)
25754
26049
  throw new Error(`Invalid Kamino external-liquidity slot ${index}`);
25755
- const key = new import_web344.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
25756
- if (key.equals(import_web344.PublicKey.default))
26050
+ const key = new import_web345.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
26051
+ if (key.equals(import_web345.PublicKey.default))
25757
26052
  throw new Error(`Missing Kamino position in slot ${index}`);
25758
26053
  if (seen.has(key.toBase58())) continue;
25759
26054
  seen.add(key.toBase58());
25760
26055
  const position = await loadWithdrawalPosition({
25761
26056
  connection: this.client.provider.connection,
25762
26057
  vault,
25763
- assetMint: import_common65.USDC_MINT,
26058
+ assetMint: import_common67.USDC_MINT,
25764
26059
  vaultAssetAta,
25765
- tokenProgram: (0, import_common65.fromWeb3Pk)(import_spl_token26.TOKEN_PROGRAM_ID),
26060
+ tokenProgram: (0, import_common67.fromWeb3Pk)(import_spl_token27.TOKEN_PROGRAM_ID),
25766
26061
  slot,
25767
26062
  index,
25768
26063
  requireUsablePosition: true
@@ -25813,8 +26108,8 @@ var IdleLiquidityService = class {
25813
26108
  log(`Vault ${vault}: ${reason} \u2014 skipping`);
25814
26109
  return { result: { ...empty, status: "no-tvl", reason } };
25815
26110
  }
25816
- const usdc = findHolding2(vaultState, import_common65.USDC_MINT);
25817
- const pst = findHolding2(vaultState, import_common65.PST_MINT);
26111
+ const usdc = findHolding2(vaultState, import_common67.USDC_MINT);
26112
+ const pst = findHolding2(vaultState, import_common67.PST_MINT);
25818
26113
  if (!usdc || !pst) {
25819
26114
  const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
25820
26115
  log(`Vault ${vault}: ${reason} \u2014 skipping`);
@@ -25965,16 +26260,16 @@ var IdleLiquidityService = class {
25965
26260
  */
25966
26261
  async mintTokenProgram(mint) {
25967
26262
  const account = await this.client.provider.connection.getAccountInfo(
25968
- new import_web344.PublicKey(mint),
26263
+ new import_web345.PublicKey(mint),
25969
26264
  "confirmed"
25970
26265
  );
25971
26266
  if (!account) throw new Error(`Mint account not found: ${mint}`);
25972
- if (!account.owner.equals(import_spl_token26.TOKEN_PROGRAM_ID) && !account.owner.equals(import_spl_token26.TOKEN_2022_PROGRAM_ID)) {
26267
+ if (!account.owner.equals(import_spl_token27.TOKEN_PROGRAM_ID) && !account.owner.equals(import_spl_token27.TOKEN_2022_PROGRAM_ID)) {
25973
26268
  throw new Error(
25974
26269
  `Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
25975
26270
  );
25976
26271
  }
25977
- return (0, import_common65.fromWeb3Pk)(account.owner);
26272
+ return (0, import_common67.fromWeb3Pk)(account.owner);
25978
26273
  }
25979
26274
  /**
25980
26275
  * Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
@@ -25994,23 +26289,23 @@ var IdleLiquidityService = class {
25994
26289
  dryRun,
25995
26290
  log
25996
26291
  } = params;
25997
- const signer = (0, import_common65.fromWeb3Pk)(hwManager.publicKey);
26292
+ const signer = (0, import_common67.fromWeb3Pk)(hwManager.publicKey);
25998
26293
  const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
25999
- this.mintTokenProgram(import_common65.PST_MINT),
26000
- this.mintTokenProgram(import_common65.USDC_MINT)
26294
+ this.mintTokenProgram(import_common67.PST_MINT),
26295
+ this.mintTokenProgram(import_common67.USDC_MINT)
26001
26296
  ]);
26002
26297
  const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
26003
26298
  payer: signer
26004
26299
  });
26005
- const { accounts: accounts2, refs, lookupTables } = (0, import_common65.createCpiRefs)([jupiterCpi]);
26300
+ const { accounts: accounts2, refs, lookupTables } = (0, import_common67.createCpiRefs)([jupiterCpi]);
26006
26301
  const vaultTrancheState = coerceBool4(
26007
26302
  vaultState.tranchingEnabled
26008
26303
  ) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
26009
26304
  const plan = await this.client.tx.jupiterSwap.getTx({
26010
26305
  hwManager: signer,
26011
26306
  vault,
26012
- sourceMint: import_common65.PST_MINT,
26013
- destinationMint: import_common65.USDC_MINT,
26307
+ sourceMint: import_common67.PST_MINT,
26308
+ destinationMint: import_common67.USDC_MINT,
26014
26309
  refs,
26015
26310
  accounts: accounts2,
26016
26311
  sourceTokenProgram,
@@ -26020,26 +26315,26 @@ var IdleLiquidityService = class {
26020
26315
  });
26021
26316
  const connection = this.client.provider.connection;
26022
26317
  const instructions2 = [
26023
- import_web344.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
26318
+ import_web345.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
26024
26319
  ...cuPriceMicroLamports > 0 ? [
26025
- import_web344.ComputeBudgetProgram.setComputeUnitPrice({
26320
+ import_web345.ComputeBudgetProgram.setComputeUnitPrice({
26026
26321
  microLamports: cuPriceMicroLamports
26027
26322
  })
26028
26323
  ] : [],
26029
- ...(jupiterCpi.preInstructions ?? []).map(import_common65.fromKitInstruction),
26030
- ...plan.instructions.map(import_common65.fromKitInstruction)
26324
+ ...(jupiterCpi.preInstructions ?? []).map(import_common67.fromKitInstruction),
26325
+ ...plan.instructions.map(import_common67.fromKitInstruction)
26031
26326
  ];
26032
26327
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
26033
- const lookupTableAccounts = await (0, import_common65.fetchLookupTables)(
26328
+ const lookupTableAccounts = await (0, import_common67.fetchLookupTables)(
26034
26329
  connection,
26035
26330
  plan.lookupTables ?? []
26036
26331
  );
26037
- const message2 = new import_web344.TransactionMessage({
26332
+ const message2 = new import_web345.TransactionMessage({
26038
26333
  payerKey: hwManager.publicKey,
26039
26334
  recentBlockhash: blockhash,
26040
26335
  instructions: instructions2
26041
26336
  }).compileToV0Message(lookupTableAccounts);
26042
- const transaction = new import_web344.VersionedTransaction(message2);
26337
+ const transaction = new import_web345.VersionedTransaction(message2);
26043
26338
  transaction.sign([hwManager]);
26044
26339
  if (!this.client.skipSimulation) {
26045
26340
  const simulation = await connection.simulateTransaction(transaction, {
@@ -26085,9 +26380,9 @@ var IdleLiquidityService = class {
26085
26380
 
26086
26381
  // src/services/timelockSettlementService.ts
26087
26382
  var import_kit24 = require("@solana/kit");
26088
- var import_web345 = require("@solana/web3.js");
26089
- var import_common66 = __toESM(require_dist());
26090
- var ZERO_PUBKEY = import_web345.PublicKey.default.toBase58();
26383
+ var import_web346 = require("@solana/web3.js");
26384
+ var import_common68 = __toESM(require_dist());
26385
+ var ZERO_PUBKEY = import_web346.PublicKey.default.toBase58();
26091
26386
  var CONSENSUS_SIGNER_CAPACITY = 4;
26092
26387
  var CONSENSUS_ENTRY_OFFSET = 40;
26093
26388
  var CONSENSUS_ENTRY_SIZE = 272;
@@ -26127,7 +26422,7 @@ function decodePendingConsensusSigners(data) {
26127
26422
  const signers = [];
26128
26423
  for (let i = 0; i < count; i += 1) {
26129
26424
  const start = CONSENSUS_PENDING_OFFSET + i * 32;
26130
- const signer = new import_web345.PublicKey(bytes.slice(start, start + 32)).toBase58();
26425
+ const signer = new import_web346.PublicKey(bytes.slice(start, start + 32)).toBase58();
26131
26426
  if (signer === ZERO_PUBKEY) {
26132
26427
  throw new Error(`pending consensus signer ${i} is unset`);
26133
26428
  }
@@ -26183,7 +26478,7 @@ var TimelockSettlementService = class {
26183
26478
  });
26184
26479
  const dryRun = opts.dryRun ?? false;
26185
26480
  const now = opts.now ?? await this.chainTime();
26186
- const fulfillerAddress = (0, import_common66.fromWeb3Pk)(fulfiller.publicKey);
26481
+ const fulfillerAddress = (0, import_common68.fromWeb3Pk)(fulfiller.publicKey);
26187
26482
  const allVaults = opts.vault ? [
26188
26483
  {
26189
26484
  publicKey: opts.vault,
@@ -26326,18 +26621,18 @@ var TimelockSettlementService = class {
26326
26621
 
26327
26622
  // src/services/nestWithdrawalService.ts
26328
26623
  var import_kit25 = require("@solana/kit");
26329
- var import_spl_token27 = require("@solana/spl-token");
26330
- var import_web346 = require("@solana/web3.js");
26331
- var import_common67 = __toESM(require_dist());
26624
+ var import_spl_token28 = require("@solana/spl-token");
26625
+ var import_web347 = require("@solana/web3.js");
26626
+ var import_common69 = __toESM(require_dist());
26332
26627
  var import_nest3 = __toESM(require_dist4());
26333
26628
  var import_nest4 = __toESM(require_dist4());
26334
- var NestOftProgram = new import_web346.PublicKey(
26629
+ var NestOftProgram = new import_web347.PublicKey(
26335
26630
  "ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
26336
26631
  );
26337
- var NestOftStore = new import_web346.PublicKey(
26632
+ var NestOftStore = new import_web347.PublicKey(
26338
26633
  "k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
26339
26634
  );
26340
- var UsdcMint = new import_web346.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26635
+ var UsdcMint = new import_web347.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26341
26636
  var NestPerenaComposer = Buffer.from(
26342
26637
  "000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
26343
26638
  "hex"
@@ -26354,7 +26649,7 @@ async function buildNestWithdrawalRequest(args) {
26354
26649
  return decodeNestWithdrawalRequest({ ...args, txBase64 });
26355
26650
  }
26356
26651
  async function decodeNestWithdrawalRequest(args) {
26357
- const transaction = import_web346.VersionedTransaction.deserialize(
26652
+ const transaction = import_web347.VersionedTransaction.deserialize(
26358
26653
  Buffer.from(args.txBase64, "base64")
26359
26654
  );
26360
26655
  const message2 = transaction.message;
@@ -26375,19 +26670,19 @@ async function decodeNestWithdrawalRequest(args) {
26375
26670
  return value;
26376
26671
  })
26377
26672
  );
26378
- const decoded = import_web346.TransactionMessage.decompile(message2, {
26673
+ const decoded = import_web347.TransactionMessage.decompile(message2, {
26379
26674
  addressLookupTableAccounts: tables
26380
26675
  });
26381
- const nestMint = new import_web346.PublicKey(NEST_RWA_SHARE_MINT);
26382
- const sourceAta = (0, import_spl_token27.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
26383
- const usdcAta = (0, import_spl_token27.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
26676
+ const nestMint = new import_web347.PublicKey(NEST_RWA_SHARE_MINT);
26677
+ const sourceAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
26678
+ const usdcAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
26384
26679
  const instructions2 = decoded.instructions.filter(
26385
- (ix) => !ix.programId.equals(import_web346.ComputeBudgetProgram.programId)
26680
+ (ix) => !ix.programId.equals(import_web347.ComputeBudgetProgram.programId)
26386
26681
  );
26387
26682
  let sends = 0;
26388
26683
  for (const ix of instructions2) {
26389
- if (ix.programId.equals(import_spl_token27.ASSOCIATED_TOKEN_PROGRAM_ID)) {
26390
- if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(usdcAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(UsdcMint) || !ix.keys[5]?.pubkey.equals(import_spl_token27.TOKEN_PROGRAM_ID)) {
26684
+ if (ix.programId.equals(import_spl_token28.ASSOCIATED_TOKEN_PROGRAM_ID)) {
26685
+ if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(usdcAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(UsdcMint) || !ix.keys[5]?.pubkey.equals(import_spl_token28.TOKEN_PROGRAM_ID)) {
26391
26686
  throw new Error("Unexpected token account creation in Nest withdrawal");
26392
26687
  }
26393
26688
  continue;
@@ -26404,20 +26699,20 @@ async function decodeNestWithdrawalRequest(args) {
26404
26699
  if (sends !== 1)
26405
26700
  throw new Error("Nest withdrawal must contain exactly one OFT send");
26406
26701
  return {
26407
- instructions: instructions2.map(import_common67.toKitInstruction),
26702
+ instructions: instructions2.map(import_common69.toKitInstruction),
26408
26703
  lookupTables: tables.map((table) => (0, import_kit25.address)(table.key.toBase58()))
26409
26704
  };
26410
26705
  }
26411
26706
 
26412
26707
  // src/services/nestDepositService.ts
26413
26708
  var import_kit26 = require("@solana/kit");
26414
- var import_spl_token28 = require("@solana/spl-token");
26415
- var import_web347 = require("@solana/web3.js");
26416
- var import_common68 = __toESM(require_dist());
26709
+ var import_spl_token29 = require("@solana/spl-token");
26710
+ var import_web348 = require("@solana/web3.js");
26711
+ var import_common70 = __toESM(require_dist());
26417
26712
  var import_nest5 = __toESM(require_dist4());
26418
- var Usdc = new import_web347.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26419
- var Messenger = new import_web347.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
26420
- var Transmitter = new import_web347.PublicKey(
26713
+ var Usdc = new import_web348.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26714
+ var Messenger = new import_web348.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
26715
+ var Transmitter = new import_web348.PublicKey(
26421
26716
  "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
26422
26717
  );
26423
26718
  var Router = Buffer.from(
@@ -26470,7 +26765,7 @@ async function decodeNestDepositRequest(args) {
26470
26765
  "Nest deposit must be a positive, safely representable USDC base-unit amount"
26471
26766
  );
26472
26767
  }
26473
- const message2 = import_web347.VersionedTransaction.deserialize(
26768
+ const message2 = import_web348.VersionedTransaction.deserialize(
26474
26769
  Buffer.from(args.txBase64, "base64")
26475
26770
  ).message;
26476
26771
  if (!message2.staticAccountKeys[0].equals(args.owner))
@@ -26485,23 +26780,23 @@ async function decodeNestDepositRequest(args) {
26485
26780
  return value;
26486
26781
  })
26487
26782
  );
26488
- const instructions2 = import_web347.TransactionMessage.decompile(message2, {
26783
+ const instructions2 = import_web348.TransactionMessage.decompile(message2, {
26489
26784
  addressLookupTableAccounts: tables
26490
26785
  }).instructions;
26491
- const shareMint = new import_web347.PublicKey(NEST_RWA_SHARE_MINT);
26492
- const shareAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
26493
- const usdcAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(Usdc, args.owner, true);
26786
+ const shareMint = new import_web348.PublicKey(NEST_RWA_SHARE_MINT);
26787
+ const shareAta = (0, import_spl_token29.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
26788
+ const usdcAta = (0, import_spl_token29.getAssociatedTokenAddressSync)(Usdc, args.owner, true);
26494
26789
  let burn;
26495
26790
  for (const ix of instructions2) {
26496
- if (ix.programId.equals(import_web347.ComputeBudgetProgram.programId)) continue;
26497
- if (ix.programId.equals(import_spl_token28.ASSOCIATED_TOKEN_PROGRAM_ID)) {
26498
- if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(shareAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(shareMint) || !ix.keys[4]?.pubkey.equals(import_web347.SystemProgram.programId) || !ix.keys[5]?.pubkey.equals(import_spl_token28.TOKEN_PROGRAM_ID))
26791
+ if (ix.programId.equals(import_web348.ComputeBudgetProgram.programId)) continue;
26792
+ if (ix.programId.equals(import_spl_token29.ASSOCIATED_TOKEN_PROGRAM_ID)) {
26793
+ if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(shareAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(shareMint) || !ix.keys[4]?.pubkey.equals(import_web348.SystemProgram.programId) || !ix.keys[5]?.pubkey.equals(import_spl_token29.TOKEN_PROGRAM_ID))
26499
26794
  throw new Error("Unexpected Nest deposit token account creation");
26500
26795
  continue;
26501
26796
  }
26502
26797
  const d = ix.data;
26503
26798
  const matches = (index, key) => ix.keys[index]?.pubkey.equals(key);
26504
- if (burn || !ix.programId.equals(Messenger) || ix.keys.length !== 18 || d.length < 316 || !d.subarray(0, 8).equals(BurnWithHook) || d.readBigUInt64LE(8) !== args.rawAmountUsdc || d.readUInt32LE(16) !== 22 || !d.subarray(20, 52).equals(Router) || !d.subarray(52, 84).equals(Router) || d.readBigUInt64LE(84) !== 0n || d.readUInt32LE(92) !== 2e3 || d.readUInt32LE(96) !== d.length - 100 || !d.subarray(100, 120).equals(Composer) || !d.subarray(120, 124).equals(MintAndSend) || !d.subarray(124, 156).equals(PerenaAssetId) || BigInt(`0x${d.subarray(156, 188).toString("hex")}`) !== args.rawAmountUsdc || BigInt(`0x${d.subarray(188, 220).toString("hex")}`) !== 128n || !d.subarray(220, 252).equals(Buffer.concat([Buffer.alloc(12), Composer])) || BigInt(`0x${d.subarray(252, 284).toString("hex")}`) !== 30168n || !d.subarray(284, 316).equals(args.owner.toBuffer()) || !matches(0, args.owner) || !matches(3, usdcAta) || !matches(10, Usdc) || !matches(12, Transmitter) || !matches(13, Messenger) || !matches(14, import_spl_token28.TOKEN_PROGRAM_ID) || !matches(15, import_web347.SystemProgram.programId) || !matches(17, Messenger) || ![0, 1, 11].every((index) => ix.keys[index].isSigner) || ix.keys.some(
26799
+ if (burn || !ix.programId.equals(Messenger) || ix.keys.length !== 18 || d.length < 316 || !d.subarray(0, 8).equals(BurnWithHook) || d.readBigUInt64LE(8) !== args.rawAmountUsdc || d.readUInt32LE(16) !== 22 || !d.subarray(20, 52).equals(Router) || !d.subarray(52, 84).equals(Router) || d.readBigUInt64LE(84) !== 0n || d.readUInt32LE(92) !== 2e3 || d.readUInt32LE(96) !== d.length - 100 || !d.subarray(100, 120).equals(Composer) || !d.subarray(120, 124).equals(MintAndSend) || !d.subarray(124, 156).equals(PerenaAssetId) || BigInt(`0x${d.subarray(156, 188).toString("hex")}`) !== args.rawAmountUsdc || BigInt(`0x${d.subarray(188, 220).toString("hex")}`) !== 128n || !d.subarray(220, 252).equals(Buffer.concat([Buffer.alloc(12), Composer])) || BigInt(`0x${d.subarray(252, 284).toString("hex")}`) !== 30168n || !d.subarray(284, 316).equals(args.owner.toBuffer()) || !matches(0, args.owner) || !matches(3, usdcAta) || !matches(10, Usdc) || !matches(12, Transmitter) || !matches(13, Messenger) || !matches(14, import_spl_token29.TOKEN_PROGRAM_ID) || !matches(15, import_web348.SystemProgram.programId) || !matches(17, Messenger) || ![0, 1, 11].every((index) => ix.keys[index].isSigner) || ix.keys.some(
26505
26800
  (meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
26506
26801
  )) {
26507
26802
  throw new Error(
@@ -26520,33 +26815,33 @@ async function decodeNestDepositRequest(args) {
26520
26815
  burn.keys[1] = { pubkey: args.owner, isSigner: true, isWritable: true };
26521
26816
  return {
26522
26817
  instructions: [
26523
- (0, import_spl_token28.createAssociatedTokenAccountIdempotentInstruction)(
26818
+ (0, import_spl_token29.createAssociatedTokenAccountIdempotentInstruction)(
26524
26819
  args.owner,
26525
26820
  shareAta,
26526
26821
  args.owner,
26527
26822
  shareMint
26528
26823
  ),
26529
26824
  burn
26530
- ].map(import_common68.toKitInstruction),
26825
+ ].map(import_common70.toKitInstruction),
26531
26826
  lookupTables: tables.map((table) => (0, import_kit26.address)(table.key.toBase58())),
26532
26827
  ephemeralSignerKeys: [eventKey]
26533
26828
  };
26534
26829
  }
26535
26830
 
26536
26831
  // src/services/vaultLutManager.ts
26537
- var import_web348 = require("@solana/web3.js");
26832
+ var import_web349 = require("@solana/web3.js");
26538
26833
  var MAX_LUT_ADDRESSES = 256;
26539
26834
  var ACTIVE = (1n << 64n) - 1n;
26540
26835
  var asAddress = (key) => key.toBase58();
26541
26836
  function uniqueLutAddresses(addresses) {
26542
- return [...new Set(addresses)].filter((a) => a !== import_web348.PublicKey.default.toBase58()).map((a) => asAddress(new import_web348.PublicKey(a)));
26837
+ return [...new Set(addresses)].filter((a) => a !== import_web349.PublicKey.default.toBase58()).map((a) => asAddress(new import_web349.PublicKey(a)));
26543
26838
  }
26544
26839
  var VaultLutManager = class {
26545
26840
  constructor(connection) {
26546
26841
  this.connection = connection;
26547
26842
  }
26548
26843
  async fetch(table) {
26549
- const account = (await this.connection.getAddressLookupTable(new import_web348.PublicKey(table), {
26844
+ const account = (await this.connection.getAddressLookupTable(new import_web349.PublicKey(table), {
26550
26845
  commitment: "confirmed"
26551
26846
  })).value;
26552
26847
  if (!account) throw new Error(`Lookup table not found: ${table}`);
@@ -26558,14 +26853,14 @@ var VaultLutManager = class {
26558
26853
  * mapping is lost. Also accepts older tables containing the vault elsewhere. */
26559
26854
  async findForVault(authority, vault) {
26560
26855
  const accounts2 = await this.connection.getProgramAccounts(
26561
- import_web348.AddressLookupTableProgram.programId,
26856
+ import_web349.AddressLookupTableProgram.programId,
26562
26857
  {
26563
26858
  commitment: "confirmed",
26564
26859
  filters: [{ memcmp: { offset: 22, bytes: authority.toBase58() } }]
26565
26860
  }
26566
26861
  );
26567
26862
  return accounts2.flatMap(({ pubkey: pubkey2, account }) => {
26568
- const state = import_web348.AddressLookupTableAccount.deserialize(account.data);
26863
+ const state = import_web349.AddressLookupTableAccount.deserialize(account.data);
26569
26864
  return state.deactivationSlot === ACTIVE && state.authority?.equals(authority) && state.addresses.some((a) => a.toBase58() === vault) ? [asAddress(pubkey2)] : [];
26570
26865
  });
26571
26866
  }
@@ -26597,7 +26892,7 @@ var VaultLutManager = class {
26597
26892
  let created = false;
26598
26893
  const send = async (instructions2) => {
26599
26894
  const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash("confirmed");
26600
- const tx = new import_web348.Transaction({
26895
+ const tx = new import_web349.Transaction({
26601
26896
  feePayer: args.payer.publicKey,
26602
26897
  blockhash,
26603
26898
  lastValidBlockHeight
@@ -26624,7 +26919,7 @@ var VaultLutManager = class {
26624
26919
  };
26625
26920
  if (!table) {
26626
26921
  const hashes = await this.connection.getAccountInfo(
26627
- import_web348.SYSVAR_SLOT_HASHES_PUBKEY,
26922
+ import_web349.SYSVAR_SLOT_HASHES_PUBKEY,
26628
26923
  "confirmed"
26629
26924
  );
26630
26925
  if (!hashes || hashes.data.length < 48 || hashes.data.readBigUInt64LE(0) === 0n)
@@ -26632,7 +26927,7 @@ var VaultLutManager = class {
26632
26927
  const recentSlot = Number(hashes.data.readBigUInt64LE(8));
26633
26928
  if (!Number.isSafeInteger(recentSlot))
26634
26929
  throw new Error("Recent slot exceeds safe integer range");
26635
- const [create, key] = import_web348.AddressLookupTableProgram.createLookupTable({
26930
+ const [create, key] = import_web349.AddressLookupTableProgram.createLookupTable({
26636
26931
  authority: authority.publicKey,
26637
26932
  payer: args.payer.publicKey,
26638
26933
  recentSlot
@@ -26647,11 +26942,11 @@ var VaultLutManager = class {
26647
26942
  args.onProgress?.(`Creating vault LUT: ${table}`);
26648
26943
  await send([
26649
26944
  create,
26650
- import_web348.AddressLookupTableProgram.extendLookupTable({
26945
+ import_web349.AddressLookupTableProgram.extendLookupTable({
26651
26946
  lookupTable: key,
26652
26947
  authority: authority.publicKey,
26653
26948
  payer: args.payer.publicKey,
26654
- addresses: [new import_web348.PublicKey(args.vault)]
26949
+ addresses: [new import_web349.PublicKey(args.vault)]
26655
26950
  })
26656
26951
  ]);
26657
26952
  created = true;
@@ -26671,11 +26966,11 @@ var VaultLutManager = class {
26671
26966
  for (let i = 0; i < missing.length; i += 20) {
26672
26967
  const batch = missing.slice(i, i + 20);
26673
26968
  await send([
26674
- import_web348.AddressLookupTableProgram.extendLookupTable({
26675
- lookupTable: new import_web348.PublicKey(table),
26969
+ import_web349.AddressLookupTableProgram.extendLookupTable({
26970
+ lookupTable: new import_web349.PublicKey(table),
26676
26971
  authority: authority.publicKey,
26677
26972
  payer: args.payer.publicKey,
26678
- addresses: batch.map((a) => new import_web348.PublicKey(a))
26973
+ addresses: batch.map((a) => new import_web349.PublicKey(a))
26679
26974
  })
26680
26975
  ]);
26681
26976
  args.onProgress?.(
@@ -26698,12 +26993,12 @@ var VaultLutManager = class {
26698
26993
 
26699
26994
  // src/services/vaultLookupTableAccounts.ts
26700
26995
  var import_core26 = require("@anchor-lang/core");
26701
- var import_web349 = require("@solana/web3.js");
26702
- var import_spl_token29 = require("@solana/spl-token");
26996
+ var import_web350 = require("@solana/web3.js");
26997
+ var import_spl_token30 = require("@solana/spl-token");
26703
26998
  var import_marginfi_client_v25 = require("@mrgnlabs/marginfi-client-v2");
26704
26999
  var import_Obligation3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
26705
27000
  var import_Reserve3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
26706
- var import_common69 = __toESM(require_dist());
27001
+ var import_common71 = __toESM(require_dist());
26707
27002
  var import_marginfi7 = __toESM(require_dist2());
26708
27003
  var import_kamino6 = __toESM(require_dist3());
26709
27004
  async function collectVaultLookupTableAccounts(client, vault, options = {}) {
@@ -26718,13 +27013,13 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26718
27013
  const add = (key) => addresses.push(typeof key === "string" ? key : key.toBase58());
26719
27014
  [
26720
27015
  client.program.programId,
26721
- import_spl_token29.ASSOCIATED_TOKEN_PROGRAM_ID,
26722
- import_spl_token29.TOKEN_PROGRAM_ID,
26723
- import_spl_token29.TOKEN_2022_PROGRAM_ID,
26724
- import_web349.SYSVAR_INSTRUCTIONS_PUBKEY
27016
+ import_spl_token30.ASSOCIATED_TOKEN_PROGRAM_ID,
27017
+ import_spl_token30.TOKEN_PROGRAM_ID,
27018
+ import_spl_token30.TOKEN_2022_PROGRAM_ID,
27019
+ import_web350.SYSVAR_INSTRUCTIONS_PUBKEY
26725
27020
  ].forEach(add);
26726
27021
  const publicKeys = (value) => {
26727
- if (value instanceof import_web349.PublicKey) {
27022
+ if (value instanceof import_web350.PublicKey) {
26728
27023
  add(value);
26729
27024
  return;
26730
27025
  }
@@ -26743,7 +27038,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26743
27038
  }
26744
27039
  ];
26745
27040
  const tranche = await client.program.account.vaultTrancheState.fetchNullable(
26746
- new import_web349.PublicKey(tranchePda)
27041
+ new import_web350.PublicKey(tranchePda)
26747
27042
  );
26748
27043
  if (tranche) {
26749
27044
  publicKeys(tranche.config);
@@ -26763,30 +27058,30 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26763
27058
  );
26764
27059
  }
26765
27060
  const holdings = state.holdings.filter(
26766
- (h) => !h.mint.equals(import_web349.PublicKey.default)
27061
+ (h) => !h.mint.equals(import_web350.PublicKey.default)
26767
27062
  );
26768
27063
  for (const h of holdings) {
26769
27064
  const mint = h.mint.toBase58(), program = tokenProgramAddressFromIdlEnum(h.tokenProgram);
26770
27065
  add(mint);
26771
27066
  add(program);
26772
- add((0, import_common69.getAtaAddress)(mint, vault, program, true));
26773
- add((0, import_common69.getAtaAddress)(mint, fee, program, true));
26774
- if (options.user) add((0, import_common69.getAtaAddress)(mint, options.user, program, true));
27067
+ add((0, import_common71.getAtaAddress)(mint, vault, program, true));
27068
+ add((0, import_common71.getAtaAddress)(mint, fee, program, true));
27069
+ if (options.user) add((0, import_common71.getAtaAddress)(mint, options.user, program, true));
26775
27070
  }
26776
27071
  for (const share of shares) {
26777
27072
  add(share.mint);
26778
27073
  add(share.program);
26779
- add((0, import_common69.getAtaAddress)(share.mint, vault, share.program, true));
26780
- add((0, import_common69.getAtaAddress)(share.mint, fee, share.program, true));
27074
+ add((0, import_common71.getAtaAddress)(share.mint, vault, share.program, true));
27075
+ add((0, import_common71.getAtaAddress)(share.mint, fee, share.program, true));
26781
27076
  if (options.user)
26782
- add((0, import_common69.getAtaAddress)(share.mint, options.user, share.program, true));
27077
+ add((0, import_common71.getAtaAddress)(share.mint, options.user, share.program, true));
26783
27078
  }
26784
27079
  const slots = state.externalLiquidity.filter(
26785
27080
  (s) => [1, 2].includes(s.data[0])
26786
27081
  );
26787
27082
  for (const slot of slots) {
26788
- const position = new import_web349.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
26789
- if (position.equals(import_web349.PublicKey.default)) continue;
27083
+ const position = new import_web350.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
27084
+ if (position.equals(import_web350.PublicKey.default)) continue;
26790
27085
  add(position);
26791
27086
  const info = await connection.getAccountInfo(position, "confirmed");
26792
27087
  if (slot.data[0] === 1) {
@@ -26797,7 +27092,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26797
27092
  const cpi = new import_marginfi7.CpiClient({ accounts: config }).withdraw_cpi({
26798
27093
  marginfiAccount: position.toBase58(),
26799
27094
  authority: vault,
26800
- destinationTokenAccount: (0, import_common69.getAtaAddress)(
27095
+ destinationTokenAccount: (0, import_common71.getAtaAddress)(
26801
27096
  mint,
26802
27097
  vault,
26803
27098
  config.tokenProgram,
@@ -26850,7 +27145,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26850
27145
  if (!reserveKeys.length)
26851
27146
  throw new Error(`No reserves found for Kamino obligation ${position}`);
26852
27147
  const infos = await connection.getMultipleAccountsInfo(
26853
- reserveKeys.map((a) => new import_web349.PublicKey(a)),
27148
+ reserveKeys.map((a) => new import_web350.PublicKey(a)),
26854
27149
  "confirmed"
26855
27150
  );
26856
27151
  const reserves = infos.map((info2, i) => {
@@ -26880,7 +27175,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26880
27175
  obligation: position.toBase58(),
26881
27176
  reserves,
26882
27177
  reserve,
26883
- destination: (0, import_common69.getAtaAddress)(
27178
+ destination: (0, import_common71.getAtaAddress)(
26884
27179
  reserve.liquidityMint,
26885
27180
  vault,
26886
27181
  reserve.liquidityTokenProgram,
@@ -26900,17 +27195,19 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26900
27195
  }
26901
27196
 
26902
27197
  // src/index.ts
26903
- var import_common70 = __toESM(require_dist());
27198
+ var import_common72 = __toESM(require_dist());
26904
27199
  // Annotate the CommonJS export names for ESM import in node:
26905
27200
  0 && (module.exports = {
26906
27201
  ASSET_DECIMALS,
26907
27202
  ASSET_REBALANCE_COOLDOWN_SECS,
27203
+ ASYNC_REDEMPTION_CANCEL_DELAY_SECS,
26908
27204
  AccountClient,
26909
27205
  ActivateCircuitBreakerBuilder,
26910
27206
  AddIncentiveRecipientBuilder,
26911
27207
  AddIncentiveRecipientV3Builder,
26912
27208
  BALANCE_CHANGE_BASELINE_MAX_AGE_SECS,
26913
27209
  CONSENSUS_ORACLE_VARIANT,
27210
+ CancelAsyncWithdrawBuilder,
26914
27211
  CancelIncentiveProposalBuilder,
26915
27212
  CancelJuniorTrancheWithdrawBuilder,
26916
27213
  ClaimIncentiveBuilder,
@@ -27004,6 +27301,7 @@ var import_common70 = __toESM(require_dist());
27004
27301
  PROTOCOL_FEE_RECIPIENT,
27005
27302
  PST_TO_USDC_MAX_SLIPPAGE_BPS,
27006
27303
  PdaClient,
27304
+ PriceAsyncWithdrawBuilder,
27007
27305
  ProtocolInteractionBuilder,
27008
27306
  RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS,
27009
27307
  REPORTABLE_ORACLE_VARIANTS,