@perena/vault-sdk 1.0.67 → 1.0.69

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
  }
@@ -14257,6 +14423,7 @@ var VaultQuoteClient = class {
14257
14423
  return info ? (0, import_kit5.address)(info.owner.toBase58()) : null;
14258
14424
  }
14259
14425
  isFeeExemptSigner(signer, owner, seeds) {
14426
+ if (!seeds && WALLET_FEE_EXEMPT_WHITELIST.includes(signer)) return true;
14260
14427
  if (!owner || !seeds) return false;
14261
14428
  const ownerString = owner.toString();
14262
14429
  const approvedOwner = ownerString === this.programId.toString() || PROGRAM_FEE_EXEMPT_OWNER_WHITELIST.some(
@@ -14310,10 +14477,9 @@ var VaultQuoteClient = class {
14310
14477
  totalSupply2,
14311
14478
  backingValue
14312
14479
  );
14313
- const expectedAmountOut = sharesForDeposit(
14314
- netAccountingAmount,
14315
- totalSupply2,
14316
- backingValue
14480
+ const expectedAmountOut = checkedSub(
14481
+ grossAmountOut2,
14482
+ feeForBps(grossAmountOut2, feeBps2)
14317
14483
  );
14318
14484
  return {
14319
14485
  shareClass: args.shareClass,
@@ -14368,7 +14534,16 @@ var VaultQuoteClient = class {
14368
14534
  classValue
14369
14535
  );
14370
14536
  const feeBps2 = feeExempt ? 0 : numberFrom(vault.config.fees.mintFeeBps);
14371
- const feeAmount2 = feeForBps(grossAmountOut2, feeBps2);
14537
+ const netAccountingAmount = checkedSub(
14538
+ accountingAmount,
14539
+ feeForBps(accountingAmount, feeBps2)
14540
+ );
14541
+ const expectedAmountOut = sharesForDeposit(
14542
+ netAccountingAmount,
14543
+ totalSupply,
14544
+ classValue
14545
+ );
14546
+ const feeAmount2 = checkedSub(grossAmountOut2, expectedAmountOut);
14372
14547
  return {
14373
14548
  shareClass: args.shareClass,
14374
14549
  direction: args.direction,
@@ -14377,7 +14552,7 @@ var VaultQuoteClient = class {
14377
14552
  feeExempt,
14378
14553
  feeBps: feeBps2,
14379
14554
  amountIn,
14380
- expectedAmountOut: checkedSub(grossAmountOut2, feeAmount2),
14555
+ expectedAmountOut,
14381
14556
  grossAmountOut: grossAmountOut2,
14382
14557
  feeAmount: feeAmount2,
14383
14558
  feeAmountUnit: "share",
@@ -14389,7 +14564,7 @@ var VaultQuoteClient = class {
14389
14564
  toBigint(trancheClass.value),
14390
14565
  toBigint(trancheClass.totalSupply)
14391
14566
  );
14392
- const feeBps = trancheWithdrawFeeBps(args, trancheState, feeExempt);
14567
+ const feeBps = trancheWithdrawFeeBps(args, vault, trancheState, feeExempt);
14393
14568
  const feeAmount = feeForBps(grossAmountOut, feeBps);
14394
14569
  return {
14395
14570
  shareClass: args.shareClass,
@@ -14407,8 +14582,10 @@ var VaultQuoteClient = class {
14407
14582
  };
14408
14583
  }
14409
14584
  };
14410
- function trancheWithdrawFeeBps(args, trancheState, feeExempt) {
14411
- if (feeExempt || args.shareClass === "senior") return 0;
14585
+ function trancheWithdrawFeeBps(args, vault, trancheState, feeExempt) {
14586
+ if (feeExempt) return 0;
14587
+ if (args.shareClass === "senior")
14588
+ return numberFrom(vault.config.fees.burnFeeBps);
14412
14589
  return args.withdrawalMode === "queued" ? numberFrom(trancheState.config.standardUnstakeFeeBps) : numberFrom(trancheState.config.earlyUnstakeFeeBps);
14413
14590
  }
14414
14591
  function accountingAmountForAsset(vault, mint, tokenAmount) {
@@ -17215,8 +17392,9 @@ async function resolveWithdrawalPlan(args) {
17215
17392
  ),
17216
17393
  args.addressSeeds ? args.connection.getAccountInfo(new import_web317.PublicKey(args.user), "confirmed") : null
17217
17394
  ]);
17218
- let feeExempt = false;
17395
+ let feeExempt = WALLET_FEE_EXEMPT_WHITELIST.includes(args.user);
17219
17396
  if (args.addressSeeds) {
17397
+ feeExempt = false;
17220
17398
  if (!signer)
17221
17399
  throw new Error("Missing fee-exempt withdrawal signer account");
17222
17400
  const owner = signer.owner.toBase58();
@@ -17249,7 +17427,8 @@ async function resolveWithdrawalPlan(args) {
17249
17427
  const state = args.shareClass === "junior" ? tranche.junior : tranche.senior;
17250
17428
  pricing.supply = BigInt(state.totalSupply.toString());
17251
17429
  pricing.value = BigInt(state.value.toString());
17252
- pricing.feeBps = feeExempt || args.shareClass === "senior" ? 0 : tranche.config.earlyUnstakeFeeBps;
17430
+ if (args.shareClass === "junior")
17431
+ pricing.feeBps = feeExempt ? 0 : tranche.config.earlyUnstakeFeeBps;
17253
17432
  }
17254
17433
  }
17255
17434
  const index = args.externalLiquiditySource;
@@ -18860,36 +19039,42 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
18860
19039
  );
18861
19040
  let skipExternalLiquidity = txArgs.skipExternalLiquidity ?? false;
18862
19041
  if (!txArgs.externalWithdrawIxRefs && !skipExternalLiquidity) {
19042
+ const isPriced = BigInt(queue.request.pricedTs.toString()) > 0n;
18863
19043
  const [localAmount, tranche] = await Promise.all([
18864
19044
  readTokenBalance(connection, vaultOutputAta, assetTokenProgram),
18865
- vaultTrancheState ? this.account.fetchVaultTrancheState(vaultTrancheState, {
19045
+ !isPriced && vaultTrancheState ? this.account.fetchVaultTrancheState(vaultTrancheState, {
18866
19046
  fresh: true
18867
19047
  }) : null
18868
19048
  ]);
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;
19049
+ if (isPriced) {
19050
+ skipExternalLiquidity = localAmount >= BigInt(queue.request.outputAmount.toString());
19051
+ } else {
19052
+ const holding = vaultData.holdings.find(
19053
+ (h) => (0, import_common47.fromWeb3Pk)(h.mint) === txArgs.assetMint
19054
+ );
19055
+ if (!holding)
19056
+ throw new Error("Withdrawal asset is not a vault holding");
19057
+ const supply = BigInt(vaultData.accounting.totalMintSupply.toString());
19058
+ const value = BigInt(vaultData.accounting.tvl.toString()) - (tranche ? BigInt(tranche.junior.value.toString()) + BigInt(tranche.senior.value.toString()) : 0n);
19059
+ const price = BigInt(holding.price.toString());
19060
+ if (supply <= 0n || value < 0n || price <= 0n)
19061
+ throw new Error("Invalid async withdrawal pricing state");
19062
+ const quote = quoteWithdrawalPayout(
19063
+ {
19064
+ shareClass: "regular",
19065
+ supply,
19066
+ value,
19067
+ price,
19068
+ decimals: holding.decimals,
19069
+ // The queue owner receives the exemption, not the fulfiller.
19070
+ feeBps: WALLET_FEE_EXEMPT_WHITELIST.includes(
19071
+ (0, import_common47.fromWeb3Pk)(queue.parties.owner)
19072
+ ) ? 0 : vaultData.config.fees.burnFeeBps
19073
+ },
19074
+ BigInt(queue.request.inputAmount.toString())
19075
+ );
19076
+ skipExternalLiquidity = localAmount >= quote.tokens;
19077
+ }
18893
19078
  }
18894
19079
  const {
18895
19080
  externalWithdrawIxRefs,
@@ -18993,6 +19178,125 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
18993
19178
  }
18994
19179
  };
18995
19180
 
19181
+ // src/client/builders/priceAsyncWithdraw.ts
19182
+ var import_common48 = __toESM(require_dist());
19183
+ var PriceAsyncWithdrawBuilder = class extends VaultBuilderBase {
19184
+ async getIx(args) {
19185
+ return this.program.methods.priceAsyncWithdraw().accountsPartial({
19186
+ hwManager: (0, import_common48.toWeb3Pk)(args.hwManager),
19187
+ vault: (0, import_common48.toWeb3Pk)(args.vault),
19188
+ vaultOracle: (0, import_common48.toWeb3Pk)(args.vaultOracle),
19189
+ vaultTrancheState: args.vaultTrancheState ? (0, import_common48.toWeb3Pk)(args.vaultTrancheState) : null,
19190
+ withdrawalQueue: (0, import_common48.toWeb3Pk)(args.withdrawalQueue)
19191
+ }).instruction().then(import_common48.toKitInstruction);
19192
+ }
19193
+ async deriveIxArgs(args) {
19194
+ const [[oracle], tranche] = await Promise.all([
19195
+ this.pda.deriveVaultOraclePda(args.vault),
19196
+ resolveVaultTrancheState(
19197
+ this.account,
19198
+ this.pda,
19199
+ args.vault,
19200
+ args.vaultTrancheState
19201
+ )
19202
+ ]);
19203
+ return {
19204
+ ...args,
19205
+ vaultOracle: args.vaultOracle ?? oracle,
19206
+ vaultTrancheState: tranche
19207
+ };
19208
+ }
19209
+ async buildPlanExtras(args) {
19210
+ return {
19211
+ postSuccessCacheInvalidations: [
19212
+ { vaultPda: args.vault, withdrawalQueuePda: args.withdrawalQueue }
19213
+ ]
19214
+ };
19215
+ }
19216
+ };
19217
+
19218
+ // src/client/builders/cancelAsyncWithdraw.ts
19219
+ var import_spl_token23 = require("@solana/spl-token");
19220
+ var import_web329 = require("@solana/web3.js");
19221
+ var import_common49 = __toESM(require_dist());
19222
+ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
19223
+ async getIx(args) {
19224
+ return this.program.methods.cancelAsyncWithdraw().accountsPartial({
19225
+ user: (0, import_common49.toWeb3Pk)(args.user),
19226
+ payer: (0, import_common49.toWeb3Pk)(args.payer),
19227
+ vault: (0, import_common49.toWeb3Pk)(args.vault),
19228
+ withdrawalQueue: (0, import_common49.toWeb3Pk)(args.withdrawalQueue),
19229
+ inputMint: (0, import_common49.toWeb3Pk)(args.inputMint),
19230
+ userInputAta: (0, import_common49.toWeb3Pk)(args.userInputAta),
19231
+ queueInputAta: (0, import_common49.toWeb3Pk)(args.queueInputAta),
19232
+ shareTokenProgram: (0, import_common49.toWeb3Pk)(args.shareTokenProgram),
19233
+ associatedTokenProgram: import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID,
19234
+ systemProgram: import_web329.SystemProgram.programId
19235
+ }).instruction().then(import_common49.toKitInstruction);
19236
+ }
19237
+ async deriveIxArgs(args) {
19238
+ const [[derived], vault] = await Promise.all([
19239
+ this.pda.deriveVaultWithdrawalQueuePda(
19240
+ args.vault,
19241
+ args.user,
19242
+ args.queueId
19243
+ ),
19244
+ this.account.fetchVault(args.vault, { fresh: true })
19245
+ ]);
19246
+ const withdrawalQueue = args.withdrawalQueue ?? derived;
19247
+ const queue = await this.account.fetchVaultWithdrawalQueue(
19248
+ withdrawalQueue,
19249
+ { fresh: true }
19250
+ );
19251
+ const inputMint = (0, import_common49.fromWeb3Pk)(vault.mint);
19252
+ const shareTokenProgram = tokenProgramAddressFromIdlEnum(
19253
+ vault.mintTokenProgram
19254
+ );
19255
+ return {
19256
+ user: args.user,
19257
+ vault: args.vault,
19258
+ withdrawalQueue,
19259
+ inputMint,
19260
+ shareTokenProgram,
19261
+ payer: (0, import_common49.fromWeb3Pk)(queue.parties.payer),
19262
+ userInputAta: args.userInputAta ?? (0, import_common49.getAtaAddress)(inputMint, args.user, shareTokenProgram, true),
19263
+ queueInputAta: (0, import_common49.getAtaAddress)(
19264
+ inputMint,
19265
+ withdrawalQueue,
19266
+ shareTokenProgram,
19267
+ true
19268
+ )
19269
+ };
19270
+ }
19271
+ async buildPreambleInstructions(args) {
19272
+ const ata = (0, import_common49.getAtaAddress)(
19273
+ args.inputMint,
19274
+ args.user,
19275
+ args.shareTokenProgram,
19276
+ true
19277
+ );
19278
+ if (ata !== args.userInputAta) return [];
19279
+ return [
19280
+ (0, import_common49.toKitInstruction)(
19281
+ (0, import_spl_token23.createAssociatedTokenAccountIdempotentInstruction)(
19282
+ (0, import_common49.toWeb3Pk)(args.user),
19283
+ (0, import_common49.toWeb3Pk)(ata),
19284
+ (0, import_common49.toWeb3Pk)(args.user),
19285
+ (0, import_common49.toWeb3Pk)(args.inputMint),
19286
+ (0, import_common49.toWeb3Pk)(args.shareTokenProgram)
19287
+ )
19288
+ )
19289
+ ];
19290
+ }
19291
+ async buildPlanExtras(args) {
19292
+ return {
19293
+ postSuccessCacheInvalidations: [
19294
+ { vaultPda: args.vault, withdrawalQueuePda: args.withdrawalQueue }
19295
+ ]
19296
+ };
19297
+ }
19298
+ };
19299
+
18996
19300
  // src/client/transaction.ts
18997
19301
  var TransactionClient = class {
18998
19302
  constructor(context) {
@@ -19040,6 +19344,8 @@ var TransactionClient = class {
19040
19344
  );
19041
19345
  this.requestAsyncWithdraw = new RequestAsyncWithdrawBuilder(context);
19042
19346
  this.fulfillAsyncWithdraw = new FulfillAsyncWithdrawBuilder(context);
19347
+ this.priceAsyncWithdraw = new PriceAsyncWithdrawBuilder(context);
19348
+ this.cancelAsyncWithdraw = new CancelAsyncWithdrawBuilder(context);
19043
19349
  this.executeWithdraw = new ExecuteWithdrawBuilder(context);
19044
19350
  this.managerWithdrawAsset = new ManagerWithdrawAssetBuilder(context);
19045
19351
  this.managerRedepositAsset = new ManagerRedepositAssetBuilder(context);
@@ -19088,15 +19394,15 @@ var VaultClient = class {
19088
19394
  this.vaultLookupTables
19089
19395
  );
19090
19396
  const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
19091
- const instructions2 = plan.instructions.map(import_common48.fromKitInstruction);
19397
+ const instructions2 = plan.instructions.map(import_common50.fromKitInstruction);
19092
19398
  let tx;
19093
19399
  if (plan.lookupTables?.length) {
19094
- const tables = await (0, import_common48.fetchLookupTables)(
19400
+ const tables = await (0, import_common50.fetchLookupTables)(
19095
19401
  this.provider.connection,
19096
19402
  plan.lookupTables
19097
19403
  );
19098
- tx = new import_web329.VersionedTransaction(
19099
- new import_web329.TransactionMessage({
19404
+ tx = new import_web330.VersionedTransaction(
19405
+ new import_web330.TransactionMessage({
19100
19406
  payerKey: payer.publicKey,
19101
19407
  recentBlockhash: blockhash,
19102
19408
  instructions: instructions2
@@ -19104,7 +19410,7 @@ var VaultClient = class {
19104
19410
  );
19105
19411
  tx.sign([payer, ...extraSigners]);
19106
19412
  } else {
19107
- tx = new import_web329.Transaction().add(...instructions2);
19413
+ tx = new import_web330.Transaction().add(...instructions2);
19108
19414
  tx.feePayer = payer.publicKey;
19109
19415
  tx.recentBlockhash = blockhash;
19110
19416
  tx.sign(payer, ...extraSigners);
@@ -19143,13 +19449,13 @@ var VaultClient = class {
19143
19449
  const { blockhash } = await this.provider.connection.getLatestBlockhash(
19144
19450
  "confirmed"
19145
19451
  );
19146
- const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common48.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
19147
- const message2 = new import_web329.TransactionMessage({
19452
+ const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common50.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
19453
+ const message2 = new import_web330.TransactionMessage({
19148
19454
  payerKey: payer.publicKey,
19149
19455
  recentBlockhash: blockhash,
19150
- instructions: plan.instructions.map(import_common48.fromKitInstruction)
19456
+ instructions: plan.instructions.map(import_common50.fromKitInstruction)
19151
19457
  }).compileToV0Message(lookupTableAccounts);
19152
- const tx = new import_web329.VersionedTransaction(message2);
19458
+ const tx = new import_web330.VersionedTransaction(message2);
19153
19459
  const result = await this.provider.connection.simulateTransaction(tx, {
19154
19460
  sigVerify: false,
19155
19461
  commitment: "processed"
@@ -19223,7 +19529,7 @@ function resolveKeypairPath(keypairPath) {
19223
19529
  }
19224
19530
  function loadKeypair(keypairPath) {
19225
19531
  const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
19226
- return import_web330.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
19532
+ return import_web331.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
19227
19533
  }
19228
19534
  var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
19229
19535
  function defaultKeypairPath(env, role = "vault") {
@@ -19234,7 +19540,7 @@ function defaultKeypairPath(env, role = "vault") {
19234
19540
  }
19235
19541
  function createVaultClient(env, opts = {}) {
19236
19542
  const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
19237
- const connection = new import_web330.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
19543
+ const connection = new import_web331.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
19238
19544
  const provider = new import_core23.AnchorProvider(connection, new import_core23.Wallet(payer), {
19239
19545
  commitment: "confirmed"
19240
19546
  });
@@ -19251,11 +19557,11 @@ function createVaultClient(env, opts = {}) {
19251
19557
  client,
19252
19558
  provider,
19253
19559
  payer,
19254
- signer: (0, import_common49.fromWeb3Pk)(payer.publicKey)
19560
+ signer: (0, import_common51.fromWeb3Pk)(payer.publicKey)
19255
19561
  };
19256
19562
  }
19257
19563
  function keypairAddress(keypairPath) {
19258
- return (0, import_common49.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
19564
+ return (0, import_common51.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
19259
19565
  }
19260
19566
 
19261
19567
  // src/utils/math.ts
@@ -19278,7 +19584,7 @@ function makeProvider(connection, payer) {
19278
19584
 
19279
19585
  // src/utils/squads.ts
19280
19586
  var squads = __toESM(require("@sqds/multisig"));
19281
- var import_web331 = require("@solana/web3.js");
19587
+ var import_web332 = require("@solana/web3.js");
19282
19588
  var SQUADS_SIMULATION_COMMITMENT = "processed";
19283
19589
  var SquadsProposalExecutionSimulationError = class extends Error {
19284
19590
  constructor(transactionError, logs, unitsConsumed) {
@@ -19302,8 +19608,8 @@ function validateVaultIndex(vaultIndex) {
19302
19608
  }
19303
19609
  function resolveSquadsWalletRoute(route) {
19304
19610
  validateVaultIndex(route.vaultIndex);
19305
- const wallet = new import_web331.PublicKey(route.wallet);
19306
- const multisigPda = new import_web331.PublicKey(route.multisigPda);
19611
+ const wallet = new import_web332.PublicKey(route.wallet);
19612
+ const multisigPda = new import_web332.PublicKey(route.multisigPda);
19307
19613
  const [vaultPda] = squads.getVaultPda({
19308
19614
  multisigPda,
19309
19615
  index: route.vaultIndex
@@ -19311,7 +19617,7 @@ function resolveSquadsWalletRoute(route) {
19311
19617
  return { ...route, wallet, multisigPda, vaultPda };
19312
19618
  }
19313
19619
  function findSquadsWalletRoute(wallet, routes) {
19314
- const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
19620
+ const walletKey = typeof wallet === "string" ? new import_web332.PublicKey(wallet) : wallet;
19315
19621
  const route = routes.find(
19316
19622
  (candidate) => candidate.wallet === walletKey.toBase58()
19317
19623
  );
@@ -19329,18 +19635,18 @@ function validateSquadsWalletRoutes(routes) {
19329
19635
  }
19330
19636
  }
19331
19637
  function vaultAuthorityForWallet(wallet, routes) {
19332
- const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
19638
+ const walletKey = typeof wallet === "string" ? new import_web332.PublicKey(wallet) : wallet;
19333
19639
  return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
19334
19640
  }
19335
19641
  async function simulateSquadsProposalExecution(args) {
19336
19642
  const { connection, feePayer, instructions: instructions2 } = args;
19337
19643
  const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
19338
- const message2 = new import_web331.TransactionMessage({
19644
+ const message2 = new import_web332.TransactionMessage({
19339
19645
  payerKey: feePayer,
19340
19646
  recentBlockhash,
19341
19647
  instructions: [...instructions2]
19342
19648
  }).compileToV0Message(args.addressLookupTableAccounts);
19343
- const transaction = new import_web331.VersionedTransaction(message2);
19649
+ const transaction = new import_web332.VersionedTransaction(message2);
19344
19650
  const { value } = await connection.simulateTransaction(transaction, {
19345
19651
  sigVerify: false,
19346
19652
  commitment: SQUADS_SIMULATION_COMMITMENT,
@@ -19365,7 +19671,7 @@ async function prepareVaultTransaction(args) {
19365
19671
  throw new Error("Ephemeral signers require a Squads route");
19366
19672
  return {
19367
19673
  kind: "direct",
19368
- transaction: new import_web331.Transaction().add(...instructions2),
19674
+ transaction: new import_web332.Transaction().add(...instructions2),
19369
19675
  authority: proposer
19370
19676
  };
19371
19677
  }
@@ -19418,7 +19724,7 @@ async function prepareVaultTransaction(args) {
19418
19724
  });
19419
19725
  if (replacements.size) {
19420
19726
  instructions2 = instructions2.map(
19421
- (ix) => new import_web331.TransactionInstruction({
19727
+ (ix) => new import_web332.TransactionInstruction({
19422
19728
  programId: ix.programId,
19423
19729
  data: ix.data,
19424
19730
  keys: ix.keys.map((meta) => ({
@@ -19446,7 +19752,7 @@ async function prepareVaultTransaction(args) {
19446
19752
  executionSimulationError = error;
19447
19753
  }
19448
19754
  }
19449
- const transactionMessage = new import_web331.TransactionMessage({
19755
+ const transactionMessage = new import_web332.TransactionMessage({
19450
19756
  payerKey: route.vaultPda,
19451
19757
  recentBlockhash: blockhash,
19452
19758
  instructions: [...instructions2]
@@ -19476,7 +19782,7 @@ async function prepareVaultTransaction(args) {
19476
19782
  });
19477
19783
  return {
19478
19784
  kind: "squads",
19479
- transaction: new import_web331.Transaction().add(
19785
+ transaction: new import_web332.Transaction().add(
19480
19786
  createVaultTransactionIx,
19481
19787
  createProposalIx
19482
19788
  ),
@@ -19492,16 +19798,16 @@ async function prepareVaultTransaction(args) {
19492
19798
 
19493
19799
  // src/utils/squadsBuffer.ts
19494
19800
  var squads2 = __toESM(require("@sqds/multisig"));
19495
- var import_web332 = require("@solana/web3.js");
19801
+ var import_web333 = require("@solana/web3.js");
19496
19802
  var PacketSize = 1232;
19497
19803
  var BufferChunkSize = 700;
19498
19804
  var MaxBufferSize = 4e3;
19499
19805
  async function prepareSquadsProposalUpload(args) {
19500
19806
  const { connection, proposer, prepared } = args;
19501
19807
  const transaction = prepared.transaction;
19502
- const sizeProbe = new import_web332.Transaction({
19808
+ const sizeProbe = new import_web333.Transaction({
19503
19809
  feePayer: proposer,
19504
- recentBlockhash: import_web332.PublicKey.default.toBase58()
19810
+ recentBlockhash: import_web333.PublicKey.default.toBase58()
19505
19811
  }).add(...transaction.instructions);
19506
19812
  let fits = false;
19507
19813
  try {
@@ -19521,7 +19827,7 @@ async function prepareSquadsProposalUpload(args) {
19521
19827
  let bufferPda;
19522
19828
  let bufferIndex = 0;
19523
19829
  for (; bufferIndex <= 255; bufferIndex++) {
19524
- const [candidate] = import_web332.PublicKey.findProgramAddressSync(
19830
+ const [candidate] = import_web333.PublicKey.findProgramAddressSync(
19525
19831
  [
19526
19832
  Buffer.from("multisig"),
19527
19833
  prepared.multisigPda.toBuffer(),
@@ -19549,7 +19855,7 @@ async function prepareSquadsProposalUpload(args) {
19549
19855
  creator: proposer
19550
19856
  };
19551
19857
  const setupTransactions = [
19552
- new import_web332.Transaction().add(
19858
+ new import_web333.Transaction().add(
19553
19859
  squads2.generated.createTransactionBufferCreateInstruction(
19554
19860
  {
19555
19861
  ...accounts2,
@@ -19569,7 +19875,7 @@ async function prepareSquadsProposalUpload(args) {
19569
19875
  ];
19570
19876
  for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
19571
19877
  setupTransactions.push(
19572
- new import_web332.Transaction().add(
19878
+ new import_web333.Transaction().add(
19573
19879
  squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
19574
19880
  args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
19575
19881
  })
@@ -19582,7 +19888,7 @@ async function prepareSquadsProposalUpload(args) {
19582
19888
  vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
19583
19889
  vaultTransactionCreateItemCreator: proposer,
19584
19890
  vaultTransactionCreateItemRentPayer: proposer,
19585
- vaultTransactionCreateItemSystemProgram: import_web332.SystemProgram.programId,
19891
+ vaultTransactionCreateItemSystemProgram: import_web333.SystemProgram.programId,
19586
19892
  transactionBuffer: bufferPda,
19587
19893
  creator: proposer
19588
19894
  },
@@ -19594,7 +19900,7 @@ async function prepareSquadsProposalUpload(args) {
19594
19900
  ).isWritable = true;
19595
19901
  return {
19596
19902
  setupTransactions,
19597
- proposalTransaction: new import_web332.Transaction().add(
19903
+ proposalTransaction: new import_web333.Transaction().add(
19598
19904
  finalize,
19599
19905
  ...transaction.instructions.slice(1)
19600
19906
  ),
@@ -19604,21 +19910,21 @@ async function prepareSquadsProposalUpload(args) {
19604
19910
  }
19605
19911
 
19606
19912
  // 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);
19913
+ var import_spl_token24 = require("@solana/spl-token");
19914
+ var import_web334 = require("@solana/web3.js");
19915
+ var import_common52 = __toESM(require_dist());
19916
+ async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID) {
19917
+ const mint = import_web334.Keypair.generate();
19918
+ const lamports = await (0, import_spl_token24.getMinimumBalanceForRentExemptMint)(connection);
19613
19919
  const ixs = [
19614
- import_web333.SystemProgram.createAccount({
19920
+ import_web334.SystemProgram.createAccount({
19615
19921
  fromPubkey: payer,
19616
19922
  newAccountPubkey: mint.publicKey,
19617
- space: import_spl_token23.MINT_SIZE,
19923
+ space: import_spl_token24.MINT_SIZE,
19618
19924
  lamports,
19619
19925
  programId: tokenProgram
19620
19926
  }),
19621
- (0, import_spl_token23.createInitializeMint2Instruction)(
19927
+ (0, import_spl_token24.createInitializeMint2Instruction)(
19622
19928
  mint.publicKey,
19623
19929
  decimals,
19624
19930
  authority,
@@ -19628,7 +19934,7 @@ async function createTokenMintIxs(connection, payer, authority, decimals, tokenP
19628
19934
  ];
19629
19935
  return { mint, ixs };
19630
19936
  }
19631
- async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token23.TOKEN_2022_PROGRAM_ID) {
19937
+ async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID) {
19632
19938
  const { mint, ixs } = await createTokenMintIxs(
19633
19939
  connection,
19634
19940
  payer.publicKey,
@@ -19637,7 +19943,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
19637
19943
  tokenProgram
19638
19944
  );
19639
19945
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
19640
- const tx = new import_web333.Transaction().add(...ixs);
19946
+ const tx = new import_web334.Transaction().add(...ixs);
19641
19947
  tx.feePayer = payer.publicKey;
19642
19948
  tx.recentBlockhash = blockhash;
19643
19949
  tx.sign(payer, mint);
@@ -19650,24 +19956,24 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
19650
19956
  );
19651
19957
  return mint.publicKey;
19652
19958
  }
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)(
19959
+ async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
19960
+ const tokenProgramPk = (0, import_common52.asWeb3PublicKey)(tokenProgram);
19961
+ const ata = (0, import_spl_token24.getAssociatedTokenAddressSync)(
19656
19962
  mint,
19657
19963
  destination,
19658
19964
  allowOwnerOffCurve,
19659
19965
  tokenProgramPk
19660
19966
  );
19661
19967
  const ixs = [
19662
- (0, import_spl_token23.createAssociatedTokenAccountIdempotentInstruction)(
19968
+ (0, import_spl_token24.createAssociatedTokenAccountIdempotentInstruction)(
19663
19969
  payer.publicKey,
19664
19970
  ata,
19665
19971
  destination,
19666
19972
  mint,
19667
19973
  tokenProgramPk,
19668
- import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID
19974
+ import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID
19669
19975
  ),
19670
- (0, import_spl_token23.createMintToInstruction)(
19976
+ (0, import_spl_token24.createMintToInstruction)(
19671
19977
  mint,
19672
19978
  ata,
19673
19979
  payer.publicKey,
@@ -19676,7 +19982,7 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
19676
19982
  tokenProgramPk
19677
19983
  )
19678
19984
  ];
19679
- const tx = new import_web333.Transaction().add(...ixs);
19985
+ const tx = new import_web334.Transaction().add(...ixs);
19680
19986
  await connection.sendTransaction(tx, [payer]);
19681
19987
  }
19682
19988
 
@@ -20066,7 +20372,7 @@ async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
20066
20372
  }
20067
20373
 
20068
20374
  // src/services/withdrawalQueueService.ts
20069
- var import_common51 = __toESM(require_dist());
20375
+ var import_common53 = __toESM(require_dist());
20070
20376
  function bnToBigInt(value) {
20071
20377
  return BigInt(value.toString());
20072
20378
  }
@@ -20132,10 +20438,10 @@ var WithdrawalQueueService = class {
20132
20438
  const vault = await this.client.account.fetchVault(queue.vault, {
20133
20439
  fresh: true
20134
20440
  });
20135
- if (queue.inputMint === (0, import_common51.fromWeb3Pk)(vault.mint)) {
20441
+ if (queue.inputMint === (0, import_common53.fromWeb3Pk)(vault.mint)) {
20136
20442
  const plan2 = await this.client.tx.fulfillAsyncWithdraw.getTx({
20137
20443
  owner: queue.owner,
20138
- signer: (0, import_common51.fromWeb3Pk)(signer.publicKey),
20444
+ signer: (0, import_common53.fromWeb3Pk)(signer.publicKey),
20139
20445
  queuePayer: queue.payer,
20140
20446
  vault: queue.vault,
20141
20447
  withdrawalQueue: queue.pda,
@@ -20149,14 +20455,14 @@ var WithdrawalQueueService = class {
20149
20455
  queue.vault,
20150
20456
  { fresh: true }
20151
20457
  );
20152
- if (queue.inputMint !== (0, import_common51.fromWeb3Pk)(tranche.config.juniorMint)) {
20458
+ if (queue.inputMint !== (0, import_common53.fromWeb3Pk)(tranche.config.juniorMint)) {
20153
20459
  throw new Error(
20154
20460
  `Unsupported withdrawal queue input mint: ${queue.inputMint}`
20155
20461
  );
20156
20462
  }
20157
20463
  const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
20158
20464
  owner: queue.owner,
20159
- signer: (0, import_common51.fromWeb3Pk)(signer.publicKey),
20465
+ signer: (0, import_common53.fromWeb3Pk)(signer.publicKey),
20160
20466
  queuePayer: queue.payer,
20161
20467
  vault: queue.vault,
20162
20468
  withdrawalQueue: queue.pda,
@@ -20210,22 +20516,24 @@ var WithdrawalQueueService = class {
20210
20516
  const a = account;
20211
20517
  return {
20212
20518
  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),
20519
+ vault: (0, import_common53.fromWeb3Pk)(a.parties.vault),
20520
+ owner: (0, import_common53.fromWeb3Pk)(a.parties.owner),
20521
+ payer: (0, import_common53.fromWeb3Pk)(a.parties.payer),
20216
20522
  queueId: a.header.queueId,
20217
- inputMint: (0, import_common51.fromWeb3Pk)(a.mints.inputMint),
20218
- outputMint: (0, import_common51.fromWeb3Pk)(a.mints.outputMint),
20523
+ inputMint: (0, import_common53.fromWeb3Pk)(a.mints.inputMint),
20524
+ outputMint: (0, import_common53.fromWeb3Pk)(a.mints.outputMint),
20219
20525
  inputAmount: bnToBigInt(a.request.inputAmount),
20220
20526
  requestTs: bnToNumber(a.request.requestTs),
20221
- expiryTs: bnToNumber(a.request.expiryTs)
20527
+ expiryTs: bnToNumber(a.request.expiryTs),
20528
+ outputAmount: a.request.pricedTs && bnToNumber(a.request.pricedTs) > 0 ? bnToBigInt(a.request.outputAmount) : null,
20529
+ pricedTs: a.request.pricedTs && bnToNumber(a.request.pricedTs) > 0 ? bnToNumber(a.request.pricedTs) : null
20222
20530
  };
20223
20531
  }
20224
20532
  };
20225
20533
 
20226
20534
  // src/services/oracleService.ts
20227
20535
  var import_kit12 = require("@solana/kit");
20228
- var import_common52 = __toESM(require_dist());
20536
+ var import_common54 = __toESM(require_dist());
20229
20537
  var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
20230
20538
  var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
20231
20539
  var PRICE_ORACLE_TYPES_BY_INDEX2 = [
@@ -20289,7 +20597,7 @@ var OracleService = class {
20289
20597
  */
20290
20598
  async updateAssetConsensusPrice(signer, args, log) {
20291
20599
  const plan = await this.client.tx.updateConsensusOracle.getTx({
20292
- signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
20600
+ signer: (0, import_common54.fromWeb3Pk)(signer.publicKey),
20293
20601
  vault: args.vault,
20294
20602
  updates: args.updates,
20295
20603
  assetMint: args.assetMint,
@@ -20301,11 +20609,69 @@ var OracleService = class {
20301
20609
  );
20302
20610
  return sig;
20303
20611
  }
20612
+ /**
20613
+ * Simulate the update followed by NAV settlement in one transaction. If the
20614
+ * combined plan cannot be built or simulated successfully, publish only the
20615
+ * report. The caller must first verify that the report will reach consensus;
20616
+ * a successful crank alone can still settle unchanged holdings.
20617
+ */
20618
+ async updateAssetConsensusPriceAndCrankNavIfReady(signer, args, log, beforeSubmit) {
20619
+ const updatePlan = await this.client.tx.updateConsensusOracle.getTx({
20620
+ signer: (0, import_common54.fromWeb3Pk)(signer.publicKey),
20621
+ ...args
20622
+ });
20623
+ let plan = updatePlan;
20624
+ let crankSkippedReason;
20625
+ try {
20626
+ const crankPlan = await this.client.tx.crankNav.getTx({
20627
+ cranker: (0, import_common54.fromWeb3Pk)(signer.publicKey),
20628
+ vault: args.vault
20629
+ });
20630
+ const combinedPlan = {
20631
+ instructions: [...updatePlan.instructions, ...crankPlan.instructions],
20632
+ lookupTables: [
20633
+ .../* @__PURE__ */ new Set([
20634
+ ...updatePlan.lookupTables ?? [],
20635
+ ...crankPlan.lookupTables ?? []
20636
+ ])
20637
+ ],
20638
+ postSuccessCacheInvalidations: [
20639
+ ...updatePlan.postSuccessCacheInvalidations ?? [],
20640
+ ...crankPlan.postSuccessCacheInvalidations ?? []
20641
+ ]
20642
+ };
20643
+ const simulation = await this.client.simulateTransaction(
20644
+ signer,
20645
+ combinedPlan
20646
+ );
20647
+ if (simulation.err) {
20648
+ crankSkippedReason = `combined update and NAV crank simulation failed: ${JSON.stringify(
20649
+ simulation.err
20650
+ )}`;
20651
+ for (const line of simulation.logs ?? []) log?.(` | ${line}`);
20652
+ } else {
20653
+ plan = combinedPlan;
20654
+ }
20655
+ } catch (error) {
20656
+ crankSkippedReason = `could not prepare combined update and NAV crank: ${error instanceof Error ? error.message : String(error)}`;
20657
+ }
20658
+ await beforeSubmit?.();
20659
+ const updateSignature = await this.client.sendTransaction(signer, plan);
20660
+ if (crankSkippedReason) {
20661
+ log?.(`record consensus assets ${args.vault}: ${updateSignature}`);
20662
+ log?.(`skip crank nav ${args.vault}: ${crankSkippedReason}`);
20663
+ return { updateSignature, crankSkippedReason };
20664
+ }
20665
+ log?.(
20666
+ `record consensus assets and crank nav ${args.vault}: ${updateSignature}`
20667
+ );
20668
+ return { updateSignature, crankSignature: updateSignature };
20669
+ }
20304
20670
  // ── Permissionless NAV crank ──────────────────────────────────────────────
20305
20671
  /** Settle the vault NAV from its current holdings (permissionless). */
20306
20672
  async crankNav(cranker, args, log) {
20307
20673
  const plan = await this.client.tx.crankNav.getTx({
20308
- cranker: (0, import_common52.fromWeb3Pk)(cranker.publicKey),
20674
+ cranker: (0, import_common54.fromWeb3Pk)(cranker.publicKey),
20309
20675
  vault: args.vault,
20310
20676
  vaultTrancheState: args.vaultTrancheState
20311
20677
  });
@@ -20378,7 +20744,7 @@ var OracleService = class {
20378
20744
  /** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
20379
20745
  async refreshAssetPrice(updater, args, log) {
20380
20746
  const plan = await this.client.tx.updateAssetPrice.getTx({
20381
- updater: (0, import_common52.fromWeb3Pk)(updater.publicKey),
20747
+ updater: (0, import_common54.fromWeb3Pk)(updater.publicKey),
20382
20748
  vault: args.vault,
20383
20749
  mint: args.mint,
20384
20750
  oracleAccount: args.oracleAccount,
@@ -20474,11 +20840,11 @@ function toBigInt2(value) {
20474
20840
  }
20475
20841
 
20476
20842
  // src/services/consensusOracle/utils/holdings.ts
20477
- var import_web334 = require("@solana/web3.js");
20478
- var import_common53 = __toESM(require_dist());
20843
+ var import_web335 = require("@solana/web3.js");
20844
+ var import_common55 = __toESM(require_dist());
20479
20845
  function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
20480
20846
  return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
20481
- const mint = (0, import_common53.fromWeb3Pk)(holding.mint);
20847
+ const mint = (0, import_common55.fromWeb3Pk)(holding.mint);
20482
20848
  return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
20483
20849
  variantName2(holding.priceOracleType).toLowerCase()
20484
20850
  );
@@ -20513,7 +20879,7 @@ function parseExternalLiquidityRefs(vaultState) {
20513
20879
  if (!data || data.length < 40) continue;
20514
20880
  if (data[0] !== 1 && data[0] !== 2) continue;
20515
20881
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
20516
- const userAccount = new import_web334.PublicKey(pubkeyBytes).toBase58();
20882
+ const userAccount = new import_web335.PublicKey(pubkeyBytes).toBase58();
20517
20883
  refs.push(
20518
20884
  data[0] === 1 ? { kind: "marginfi", mint: "", marginfiAccount: userAccount } : {
20519
20885
  kind: "kamino-lend",
@@ -20741,12 +21107,12 @@ function formatBpsAsPercent(bps) {
20741
21107
  }
20742
21108
 
20743
21109
  // src/services/consensusOracle/pipeline/dryRunSettlement.ts
20744
- var import_web336 = require("@solana/web3.js");
20745
- var import_common54 = __toESM(require_dist());
21110
+ var import_web337 = require("@solana/web3.js");
21111
+ var import_common56 = __toESM(require_dist());
20746
21112
 
20747
21113
  // src/services/consensusOracle/settlement/settlementSimulator.ts
20748
21114
  var import_kit13 = require("@solana/kit");
20749
- var import_web335 = require("@solana/web3.js");
21115
+ var import_web336 = require("@solana/web3.js");
20750
21116
  var DEFAULT_SHARE_PRICE = 1000000n;
20751
21117
  var BPS_DENOMINATOR3 = 10000n;
20752
21118
  var NAV_LOSS_TOLERANCE_BPS = 1n;
@@ -21019,7 +21385,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
21019
21385
  continue;
21020
21386
  }
21021
21387
  const reports = entries.filter(
21022
- (entry) => entry.signer !== import_web335.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
21388
+ (entry) => entry.signer !== import_web336.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
21023
21389
  );
21024
21390
  const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
21025
21391
  const prices = reports.map((entry) => entry.prices[index] ?? 0n);
@@ -21520,7 +21886,7 @@ function decodeOracleData(data, nowTs) {
21520
21886
  (_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
21521
21887
  );
21522
21888
  entries.push({
21523
- signer: new import_web335.PublicKey(signerBytes).toBase58(),
21889
+ signer: new import_web336.PublicKey(signerBytes).toBase58(),
21524
21890
  lastUpdateTs: readI64(data, offset + 32),
21525
21891
  prices,
21526
21892
  externalAmounts
@@ -21535,7 +21901,7 @@ function decodeOracleData(data, nowTs) {
21535
21901
  data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
21536
21902
  );
21537
21903
  entries[index] = {
21538
- signer: index < pendingCount ? new import_web335.PublicKey(signerBytes).toBase58() : import_web335.PublicKey.default.toBase58(),
21904
+ signer: index < pendingCount ? new import_web336.PublicKey(signerBytes).toBase58() : import_web336.PublicKey.default.toBase58(),
21539
21905
  lastUpdateTs: 0n,
21540
21906
  prices: Array(MAX_HOLDINGS).fill(0n),
21541
21907
  externalAmounts: Array(MAX_HOLDINGS).fill(0n)
@@ -21563,7 +21929,7 @@ function decodeHolding(value) {
21563
21929
  externalAmount: bigint(holding.externalAmount),
21564
21930
  price: bigint(holding.price),
21565
21931
  lastUpdateTs: bigint(holding.lastUpdateTs),
21566
- cleared: mintString === import_web335.PublicKey.default.toBase58()
21932
+ cleared: mintString === import_web336.PublicKey.default.toBase58()
21567
21933
  };
21568
21934
  }
21569
21935
  function decodeTrancheState(decoded, args, warnings, blockers) {
@@ -22046,11 +22412,11 @@ async function fetchSimulationArgs({
22046
22412
  client.account.fetchVaultOracleForVault(vault, { fresh: true }),
22047
22413
  tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
22048
22414
  ]);
22049
- const mintKeys = [new import_web336.PublicKey(vaultState.mint)];
22415
+ const mintKeys = [new import_web337.PublicKey(vaultState.mint)];
22050
22416
  if (trancheState) {
22051
22417
  mintKeys.push(
22052
- new import_web336.PublicKey(trancheState.config.juniorMint),
22053
- new import_web336.PublicKey(trancheState.config.seniorMint)
22418
+ new import_web337.PublicKey(trancheState.config.juniorMint),
22419
+ new import_web337.PublicKey(trancheState.config.seniorMint)
22054
22420
  );
22055
22421
  }
22056
22422
  const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
@@ -22066,7 +22432,7 @@ async function fetchSimulationArgs({
22066
22432
  oracleData: oracleState.data,
22067
22433
  trancheState,
22068
22434
  updates,
22069
- signer: (0, import_common54.fromWeb3Pk)(signer.publicKey),
22435
+ signer: (0, import_common56.fromWeb3Pk)(signer.publicKey),
22070
22436
  nowTs: nowSecs,
22071
22437
  physicalShareSupply: supplies[0],
22072
22438
  physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
@@ -22075,7 +22441,7 @@ async function fetchSimulationArgs({
22075
22441
  }
22076
22442
 
22077
22443
  // src/services/consensusOracle/pipeline/holdingUpdates.ts
22078
- var import_common55 = __toESM(require_dist());
22444
+ var import_common57 = __toESM(require_dist());
22079
22445
  async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
22080
22446
  const updates = [];
22081
22447
  for (const entry of reportableHoldings) {
@@ -22085,7 +22451,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
22085
22451
  }
22086
22452
  async function buildHoldingUpdate(yieldTracker, entry, inputs) {
22087
22453
  const { holding, holdingIndex } = entry;
22088
- const mint = (0, import_common55.fromWeb3Pk)(holding.mint);
22454
+ const mint = (0, import_common57.fromWeb3Pk)(holding.mint);
22089
22455
  const mintKey = mint.toString();
22090
22456
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
22091
22457
  let usd;
@@ -22147,9 +22513,9 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
22147
22513
  );
22148
22514
  }
22149
22515
  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
22516
+ trackedValueAmount: tracked.totalValue > 0 ? (0, import_common57.fromUiAmount)(tracked.totalValue, decimals) : 0n,
22517
+ principalAmount: tracked.principal > 0 ? (0, import_common57.fromUiAmount)(tracked.principal, decimals) : 0n,
22518
+ yieldAmount: tracked.outstandingYield > 0 ? (0, import_common57.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
22153
22519
  };
22154
22520
  }
22155
22521
 
@@ -22183,7 +22549,7 @@ function assertOracleImpliedApy(vault, simulation, label) {
22183
22549
  }
22184
22550
 
22185
22551
  // src/services/consensusOracle/pipeline/livePriceRefresh.ts
22186
- var import_common56 = __toESM(require_dist());
22552
+ var import_common58 = __toESM(require_dist());
22187
22553
  async function refreshLiveOraclePrices({
22188
22554
  oracle,
22189
22555
  signer,
@@ -22202,7 +22568,7 @@ async function refreshLiveOraclePrices({
22202
22568
  for (const holding of vaultState.holdings) {
22203
22569
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
22204
22570
  if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
22205
- const mint = (0, import_common56.fromWeb3Pk)(holding.mint);
22571
+ const mint = (0, import_common58.fromWeb3Pk)(holding.mint);
22206
22572
  if (mint.toString() === SYSTEM_PROGRAM) continue;
22207
22573
  const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
22208
22574
  if (activeAmount === 0n) continue;
@@ -22217,7 +22583,7 @@ async function refreshLiveOraclePrices({
22217
22583
  );
22218
22584
  continue;
22219
22585
  }
22220
- const oracleAccount = (0, import_common56.fromWeb3Pk)(holding.priceOracleAccount);
22586
+ const oracleAccount = (0, import_common58.fromWeb3Pk)(holding.priceOracleAccount);
22221
22587
  if (oracleAccount.toString() === SYSTEM_PROGRAM) {
22222
22588
  log(
22223
22589
  `vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
@@ -22241,7 +22607,7 @@ async function refreshLiveOraclePrices({
22241
22607
  }
22242
22608
 
22243
22609
  // src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
22244
- var import_common57 = __toESM(require_dist());
22610
+ var import_common59 = __toESM(require_dist());
22245
22611
 
22246
22612
  // src/services/consensusOracle/sources/nestPriceSource.ts
22247
22613
  var import_kit14 = require("@solana/kit");
@@ -22288,13 +22654,13 @@ function candidateGrossNav(state, updates) {
22288
22654
  const byIndex = /* @__PURE__ */ new Map();
22289
22655
  for (const update of updates) {
22290
22656
  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)) {
22657
+ if (!holding || (0, import_common59.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
22292
22658
  throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
22293
22659
  }
22294
22660
  byIndex.set(update.holdingIndex, update);
22295
22661
  }
22296
22662
  return state.holdings.reduce((nav, holding, index) => {
22297
- if ((0, import_common57.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
22663
+ if ((0, import_common59.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
22298
22664
  const update = byIndex.get(index);
22299
22665
  const local = toBigInt2(holding.localAmount);
22300
22666
  const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
@@ -22361,13 +22727,13 @@ async function reconcileManagerWalletBalances({
22361
22727
  throw new Error("Duplicate base mint in manager reconciliation");
22362
22728
  }
22363
22729
  if (vaultState.holdings.some(
22364
- (holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common57.fromWeb3Pk)(holding.mint))
22730
+ (holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common59.fromWeb3Pk)(holding.mint))
22365
22731
  )) {
22366
22732
  throw new Error(
22367
22733
  "Cannot reconcile all vault base assets with oracle reports"
22368
22734
  );
22369
22735
  }
22370
- const manager = (0, import_common57.fromWeb3Pk)(vaultState.roles.manager);
22736
+ const manager = (0, import_common59.fromWeb3Pk)(vaultState.roles.manager);
22371
22737
  if (manager === SYSTEM_PROGRAM || manager === vault) {
22372
22738
  throw new Error("Invalid manager wallet for NAV reconciliation");
22373
22739
  }
@@ -22453,13 +22819,13 @@ function walletReconciliationGuardUpdates(state, reconciliation) {
22453
22819
  }
22454
22820
  function managerReconciliationStateKey(state) {
22455
22821
  return JSON.stringify({
22456
- manager: (0, import_common57.fromWeb3Pk)(state.roles.manager),
22822
+ manager: (0, import_common59.fromWeb3Pk)(state.roles.manager),
22457
22823
  assetDecimals: state.config.assetDecimals,
22458
22824
  holdings: state.holdings.map((holding) => [
22459
- (0, import_common57.fromWeb3Pk)(holding.mint),
22825
+ (0, import_common59.fromWeb3Pk)(holding.mint),
22460
22826
  holding.decimals,
22461
22827
  variantName2(holding.priceOracleType),
22462
- holding.priceOracleAccount ? (0, import_common57.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
22828
+ holding.priceOracleAccount ? (0, import_common59.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
22463
22829
  coerceBool3(holding.isBase),
22464
22830
  toBigInt2(holding.localAmount).toString()
22465
22831
  ])
@@ -22498,14 +22864,14 @@ function assertReconciliationExternalValues(initial, current, errorPrefix) {
22498
22864
  }
22499
22865
 
22500
22866
  // src/services/consensusOracle/pipeline/pricingInputs.ts
22501
- var import_common58 = __toESM(require_dist());
22867
+ var import_common60 = __toESM(require_dist());
22502
22868
  async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
22503
22869
  }) {
22504
22870
  const consensusMints = reportableHoldings.filter(
22505
22871
  ({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
22506
- ).map(({ holding }) => (0, import_common58.fromWeb3Pk)(holding.mint));
22872
+ ).map(({ holding }) => (0, import_common60.fromWeb3Pk)(holding.mint));
22507
22873
  const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
22508
- const baseMint = baseHolding ? (0, import_common58.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
22874
+ const baseMint = baseHolding ? (0, import_common60.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
22509
22875
  if (!baseMint) {
22510
22876
  throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
22511
22877
  }
@@ -22591,11 +22957,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
22591
22957
  }
22592
22958
 
22593
22959
  // src/services/consensusOracle/pipeline/receiptMints.ts
22594
- var import_common59 = __toESM(require_dist());
22960
+ var import_common61 = __toESM(require_dist());
22595
22961
  async function fetchReceiptMints(client, vault, vaultState) {
22596
22962
  const receiptMints = /* @__PURE__ */ new Set();
22597
22963
  if (vaultState.mint) {
22598
- receiptMints.add((0, import_common59.fromWeb3Pk)(vaultState.mint).toString());
22964
+ receiptMints.add((0, import_common61.fromWeb3Pk)(vaultState.mint).toString());
22599
22965
  }
22600
22966
  if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
22601
22967
  const trancheState = await client.account.fetchVaultTrancheStateForVault(
@@ -22603,19 +22969,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
22603
22969
  { fresh: true }
22604
22970
  );
22605
22971
  receiptMints.add(
22606
- (0, import_common59.fromWeb3Pk)(trancheState.config.juniorMint).toString()
22972
+ (0, import_common61.fromWeb3Pk)(trancheState.config.juniorMint).toString()
22607
22973
  );
22608
22974
  receiptMints.add(
22609
- (0, import_common59.fromWeb3Pk)(trancheState.config.seniorMint).toString()
22975
+ (0, import_common61.fromWeb3Pk)(trancheState.config.seniorMint).toString()
22610
22976
  );
22611
22977
  return receiptMints;
22612
22978
  }
22613
22979
 
22614
22980
  // src/services/consensusOracle/pipeline/settlement.ts
22615
- var import_common61 = __toESM(require_dist());
22981
+ var import_common63 = __toESM(require_dist());
22616
22982
 
22617
22983
  // src/services/consensusOracle/pipeline/yieldAccounts.ts
22618
- var import_common60 = __toESM(require_dist());
22984
+ var import_common62 = __toESM(require_dist());
22619
22985
  async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
22620
22986
  const accountNames = [
22621
22987
  ...new Set(
@@ -22657,7 +23023,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
22657
23023
  );
22658
23024
  if (namesToAttach.length === 0) return target;
22659
23025
  const baseHolding = vaultState.holdings.find((holding) => {
22660
- const mint = (0, import_common60.fromWeb3Pk)(holding.mint).toString();
23026
+ const mint = (0, import_common62.fromWeb3Pk)(holding.mint).toString();
22661
23027
  return coerceBool3(holding.isBase) && !excludedMints.has(mint);
22662
23028
  });
22663
23029
  if (!baseHolding) {
@@ -22665,7 +23031,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
22665
23031
  `vault ${target.vault}: tagged yield accounts found but no base holding is available`
22666
23032
  );
22667
23033
  }
22668
- const baseMint = (0, import_common60.fromWeb3Pk)(baseHolding.mint);
23034
+ const baseMint = (0, import_common62.fromWeb3Pk)(baseHolding.mint);
22669
23035
  const holdings = [...target.holdings ?? []];
22670
23036
  const existingIndex = holdings.findIndex(
22671
23037
  (holding) => holding.mint.toString() === baseMint.toString()
@@ -22725,51 +23091,47 @@ async function settleVault2({
22725
23091
  assertOracleImpliedApy(vault, simulations.proposed, "proposed report");
22726
23092
  if (simulations.consensus.realizedApy)
22727
23093
  assertOracleImpliedApy(vault, simulations.consensus, "current consensus");
22728
- await assertNoUnconfirmedYieldPayments(yieldTracker, target);
22729
- await beforeSubmit?.();
23094
+ const consensusBlockers = updates.flatMap((update) => {
23095
+ const holding = vaultState.holdings[update.holdingIndex];
23096
+ const result = simulations.consensus.consensus.find(
23097
+ (item) => item.holdingIndex === update.holdingIndex
23098
+ );
23099
+ if (holding && result?.mint === update.mint && result.settledExternalAmount !== void 0 && (result.wouldUpdateHolding || toBigInt2(holding.externalAmount) === result.settledExternalAmount && (result.settledPrice === void 0 || toBigInt2(holding.price) === result.settledPrice))) {
23100
+ return [];
23101
+ }
23102
+ return [
23103
+ `holding #${update.holdingIndex}: ${result?.reason ?? "no consensus"}`
23104
+ ];
23105
+ });
23106
+ const crankSkippedReason = consensusBlockers.length ? `waiting for consensus after submission: ${consensusBlockers.join("; ")}` : !simulations.consensus.canSettle ? `NAV settlement blocked: ${simulations.consensus.blockers.join("; ")}` : void 0;
23107
+ const publicationArgs = {
23108
+ vault,
23109
+ updates: updates.map((u) => ({
23110
+ holdingIndex: u.holdingIndex,
23111
+ price: u.price,
23112
+ externalAmount: u.externalAmount
23113
+ }))
23114
+ };
23115
+ const revalidateBeforeSubmit = async () => {
23116
+ await assertNoUnconfirmedYieldPayments(yieldTracker, target);
23117
+ await beforeSubmit?.();
23118
+ };
23119
+ if (!crankSkippedReason) {
23120
+ return oracle.updateAssetConsensusPriceAndCrankNavIfReady(
23121
+ signer,
23122
+ publicationArgs,
23123
+ log,
23124
+ revalidateBeforeSubmit
23125
+ );
23126
+ }
23127
+ await revalidateBeforeSubmit();
22730
23128
  const updateSignature = await oracle.updateAssetConsensusPrice(
22731
23129
  signer,
22732
- {
22733
- vault,
22734
- updates: updates.map((u) => ({
22735
- holdingIndex: u.holdingIndex,
22736
- price: u.price,
22737
- externalAmount: u.externalAmount
22738
- }))
22739
- },
23130
+ publicationArgs,
22740
23131
  log
22741
23132
  );
22742
- let crankSkippedReason;
22743
- try {
22744
- const [publishedVault, publishedOracle, publishedAt] = await Promise.all([
22745
- client.account.fetchVault(vault, { fresh: true }),
22746
- client.account.fetchVaultOracleForVault(vault, { fresh: true }),
22747
- client.account.fetchClockUnixTimestamp()
22748
- ]);
22749
- const blockers = publishedConsensusBlockers({
22750
- vault: publishedVault,
22751
- oracleData: publishedOracle.data,
22752
- updates,
22753
- signer: (0, import_common61.fromWeb3Pk)(signer.publicKey),
22754
- nowTs: publishedAt
22755
- });
22756
- if (blockers.length)
22757
- crankSkippedReason = `waiting for published consensus: ${blockers.join(
22758
- "; "
22759
- )}`;
22760
- } catch (error) {
22761
- crankSkippedReason = `could not verify published consensus: ${error instanceof Error ? error.message : String(error)}`;
22762
- }
22763
- if (crankSkippedReason) {
22764
- log(`skip crank nav ${vault}: ${crankSkippedReason}`);
22765
- return { updateSignature, crankSkippedReason };
22766
- }
22767
- const crankResult = await oracle.crankNavIfReady(signer, { vault }, log);
22768
- return {
22769
- updateSignature,
22770
- crankSignature: crankResult.signature,
22771
- crankSkippedReason: crankResult.reason
22772
- };
23133
+ log(`skip crank nav ${vault}: ${crankSkippedReason}`);
23134
+ return { updateSignature, crankSkippedReason };
22773
23135
  }
22774
23136
  async function logProspectiveApy({
22775
23137
  client,
@@ -22792,7 +23154,7 @@ async function logProspectiveApy({
22792
23154
  );
22793
23155
  const prospectiveNav = vaultState.holdings.reduce(
22794
23156
  (sum, holding, holdingIndex) => {
22795
- const mint = (0, import_common61.fromWeb3Pk)(holding.mint).toString();
23157
+ const mint = (0, import_common63.fromWeb3Pk)(holding.mint).toString();
22796
23158
  if (mint === SYSTEM_PROGRAM) return sum;
22797
23159
  const update = updatesByIndex.get(holdingIndex);
22798
23160
  const localAmount = toBigInt2(holding.localAmount);
@@ -23719,7 +24081,7 @@ async function buildJupiterSwapTransaction(params) {
23719
24081
  }
23720
24082
 
23721
24083
  // ../jupiter/src/client.ts
23722
- var import_common62 = __toESM(require_dist());
24084
+ var import_common64 = __toESM(require_dist());
23723
24085
 
23724
24086
  // ../jupiter/src/extract.ts
23725
24087
  var import_kit17 = require("@solana/kit");
@@ -23749,8 +24111,8 @@ async function extractJupiterInstruction(transaction, rpc, jupiterProgramId = JU
23749
24111
 
23750
24112
  // ../jupiter/src/routePreInstructions.ts
23751
24113
  var import_kit18 = require("@solana/kit");
23752
- var import_spl_token24 = require("@solana/spl-token");
23753
- var import_web337 = require("@solana/web3.js");
24114
+ var import_spl_token25 = require("@solana/spl-token");
24115
+ var import_web338 = require("@solana/web3.js");
23754
24116
  async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23755
24117
  const intermediate = /* @__PURE__ */ new Set();
23756
24118
  for (const step of quote.routePlan ?? []) {
@@ -23774,26 +24136,26 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23774
24136
  `getJupiterRoutePreInstructions: route mint ${mint} not found on-chain`
23775
24137
  );
23776
24138
  }
23777
- const ata = (0, import_spl_token24.getAssociatedTokenAddressSync)(
23778
- new import_web337.PublicKey(mint),
23779
- new import_web337.PublicKey(user),
24139
+ const ata = (0, import_spl_token25.getAssociatedTokenAddressSync)(
24140
+ new import_web338.PublicKey(mint),
24141
+ new import_web338.PublicKey(user),
23780
24142
  true,
23781
- new import_web337.PublicKey(tokenProgram),
23782
- import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID
24143
+ new import_web338.PublicKey(tokenProgram),
24144
+ import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID
23783
24145
  ).toBase58();
23784
24146
  const existingAta = await rpc.getAccountInfo(ata, { encoding: "base64" }).send();
23785
24147
  if (existingAta.value) {
23786
24148
  continue;
23787
24149
  }
23788
24150
  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
24151
+ toKitInstruction41(
24152
+ (0, import_spl_token25.createAssociatedTokenAccountIdempotentInstruction)(
24153
+ new import_web338.PublicKey(payer),
24154
+ new import_web338.PublicKey(ata),
24155
+ new import_web338.PublicKey(user),
24156
+ new import_web338.PublicKey(mint),
24157
+ new import_web338.PublicKey(tokenProgram),
24158
+ import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID
23797
24159
  )
23798
24160
  )
23799
24161
  );
@@ -23801,7 +24163,7 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23801
24163
  }
23802
24164
  return { instructions: instructions2, postSuccessCacheInvalidations };
23803
24165
  }
23804
- function toKitInstruction39(ix) {
24166
+ function toKitInstruction41(ix) {
23805
24167
  return {
23806
24168
  programAddress: ix.programId.toBase58(),
23807
24169
  accounts: ix.keys.map((account) => ({
@@ -23918,7 +24280,7 @@ var JupiterSwapClient = class {
23918
24280
  }
23919
24281
  }
23920
24282
  return {
23921
- cpiType: this.config.cpiType ?? import_common62.CpiTypes.JUPITER_SWAP,
24283
+ cpiType: this.config.cpiType ?? import_common64.CpiTypes.JUPITER_SWAP,
23922
24284
  data,
23923
24285
  accounts: accounts2,
23924
24286
  programId: JUPITER_V6_PROGRAM_ID,
@@ -24016,8 +24378,8 @@ var LivePriceSource = class {
24016
24378
  };
24017
24379
 
24018
24380
  // src/services/consensusOracle/sources/managerWalletBalanceSource.ts
24019
- var import_web338 = require("@solana/web3.js");
24020
- var import_spl_token25 = require("@solana/spl-token");
24381
+ var import_web339 = require("@solana/web3.js");
24382
+ var import_spl_token26 = require("@solana/spl-token");
24021
24383
  var RpcManagerWalletBalanceSource = class {
24022
24384
  constructor(connection) {
24023
24385
  this.connection = connection;
@@ -24025,8 +24387,8 @@ var RpcManagerWalletBalanceSource = class {
24025
24387
  async fetchBalances(manager, mints2) {
24026
24388
  const wanted = new Set(mints2);
24027
24389
  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];
24390
+ const owner = new import_web339.PublicKey(manager);
24391
+ const programs = [import_spl_token26.TOKEN_PROGRAM_ID, import_spl_token26.TOKEN_2022_PROGRAM_ID];
24030
24392
  const responses = await Promise.all(
24031
24393
  programs.map(
24032
24394
  (programId) => this.connection.getParsedTokenAccountsByOwner(
@@ -24069,7 +24431,7 @@ var RpcManagerWalletBalanceSource = class {
24069
24431
  };
24070
24432
 
24071
24433
  // src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
24072
- var import_web339 = require("@solana/web3.js");
24434
+ var import_web340 = require("@solana/web3.js");
24073
24435
 
24074
24436
  // src/services/consensusOracle/sources/mpcMarginfiDeposits.ts
24075
24437
  var import_kit19 = require("@solana/kit");
@@ -24158,8 +24520,8 @@ var RpcMpcWalletBalanceSource = class {
24158
24520
  const wallets = /* @__PURE__ */ new Set();
24159
24521
  for (const binding of bindings) {
24160
24522
  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())
24523
+ for (const key of [vault, manager, wallet]) new import_web340.PublicKey(key);
24524
+ if (entries.has(vault) || wallets.has(wallet) || wallet === manager || wallet === vault || wallet === import_web340.PublicKey.default.toBase58())
24163
24525
  throw new Error("Invalid or duplicate MPC wallet binding");
24164
24526
  entries.set(vault, { ...binding });
24165
24527
  wallets.add(wallet);
@@ -24179,8 +24541,8 @@ var RpcMpcWalletBalanceSource = class {
24179
24541
  this.tokens.fetchBalances(binding.wallet, mints2),
24180
24542
  readMarginfiDepositsForAuthority(
24181
24543
  this.connection,
24182
- new import_web339.PublicKey(binding.wallet),
24183
- mints2.map((mint) => new import_web339.PublicKey(mint))
24544
+ new import_web340.PublicKey(binding.wallet),
24545
+ mints2.map((mint) => new import_web340.PublicKey(mint))
24184
24546
  )
24185
24547
  ]);
24186
24548
  return { wallet: binding.wallet, tokens, marginfi: deposits };
@@ -24223,7 +24585,7 @@ var StaticPositionProvider = class {
24223
24585
 
24224
24586
  // src/services/consensusOracle/positions/kaminoPositionProvider.ts
24225
24587
  var import_kit20 = require("@solana/kit");
24226
- var import_web340 = require("@solana/web3.js");
24588
+ var import_web341 = require("@solana/web3.js");
24227
24589
  var import_klend_sdk = require("@kamino-finance/klend-sdk");
24228
24590
  async function readKaminoBalance(manager, vault, sharesHolder) {
24229
24591
  const userShares = await manager.getUserSharesBalanceSingleVault(
@@ -24260,7 +24622,7 @@ var KaminoPositionProvider = class {
24260
24622
  const amount = await readKaminoBalance(
24261
24623
  manager,
24262
24624
  kVault,
24263
- new import_web340.PublicKey(sharesHolder)
24625
+ new import_web341.PublicKey(sharesHolder)
24264
24626
  );
24265
24627
  out.push({ mint: ref.mint, amount });
24266
24628
  }
@@ -24269,11 +24631,11 @@ var KaminoPositionProvider = class {
24269
24631
  };
24270
24632
 
24271
24633
  // src/services/consensusOracle/positions/kaminoLendPositionProvider.ts
24272
- var import_web341 = require("@solana/web3.js");
24634
+ var import_web342 = require("@solana/web3.js");
24273
24635
  var import_Obligation2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
24274
24636
  var import_Reserve2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
24275
24637
  var import_kamino4 = __toESM(require_dist3());
24276
- var ZERO = import_web341.PublicKey.default.toBase58();
24638
+ var ZERO = import_web342.PublicKey.default.toBase58();
24277
24639
  var FRACTION_SCALE = 1n << 60n;
24278
24640
  function accountData(info, label) {
24279
24641
  if (!info || info.executable || info.owner.toBase58() !== import_kamino4.KLEND_PROGRAM_ID)
@@ -24314,7 +24676,7 @@ var KaminoLendPositionProvider = class {
24314
24676
  }
24315
24677
  const positions = [];
24316
24678
  for (const address18 of obligations) {
24317
- const key = new import_web341.PublicKey(address18);
24679
+ const key = new import_web342.PublicKey(address18);
24318
24680
  const discovered = decodeObligation(
24319
24681
  await this.connection.getAccountInfo(key, "confirmed"),
24320
24682
  ctx.vault
@@ -24324,7 +24686,7 @@ var KaminoLendPositionProvider = class {
24324
24686
  (deposit) => deposit.depositReserve
24325
24687
  );
24326
24688
  const infos = await this.connection.getMultipleAccountsInfo(
24327
- [key, ...reserves.map((reserve) => new import_web341.PublicKey(reserve))],
24689
+ [key, ...reserves.map((reserve) => new import_web342.PublicKey(reserve))],
24328
24690
  "confirmed"
24329
24691
  );
24330
24692
  const { obligation, deposits } = decodeObligation(
@@ -24366,7 +24728,7 @@ var KaminoLendPositionProvider = class {
24366
24728
  };
24367
24729
 
24368
24730
  // src/services/consensusOracle/positions/marginfiPositionProvider.ts
24369
- var import_web342 = require("@solana/web3.js");
24731
+ var import_web343 = require("@solana/web3.js");
24370
24732
  var import_marginfi4 = __toESM(require_dist2());
24371
24733
  var MarginfiPositionProvider = class {
24372
24734
  constructor(connection, log = () => {
@@ -24377,8 +24739,8 @@ var MarginfiPositionProvider = class {
24377
24739
  async positionsFor(ctx) {
24378
24740
  const refs = ctx.refs.filter((r) => r.kind === "marginfi");
24379
24741
  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));
24742
+ const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web343.PublicKey(bank));
24743
+ const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new import_web343.PublicKey(account));
24382
24744
  const autoBanks = [];
24383
24745
  for (const accountPk of autoAccountPks) {
24384
24746
  try {
@@ -24407,14 +24769,14 @@ var MarginfiPositionProvider = class {
24407
24769
  if (bank) {
24408
24770
  const amount = await (0, import_marginfi4.readMarginfiBankBalance)(
24409
24771
  client,
24410
- new import_web342.PublicKey(account),
24411
- new import_web342.PublicKey(bank)
24772
+ new import_web343.PublicKey(account),
24773
+ new import_web343.PublicKey(bank)
24412
24774
  );
24413
24775
  out.push({ mint: ref.mint, amount });
24414
24776
  } else {
24415
24777
  const balances = await (0, import_marginfi4.readAllMarginfiBalances)(
24416
24778
  client,
24417
- new import_web342.PublicKey(account)
24779
+ new import_web343.PublicKey(account)
24418
24780
  );
24419
24781
  for (const { mint, amount } of balances) {
24420
24782
  out.push({ mint: mint.toBase58(), amount });
@@ -24684,7 +25046,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
24684
25046
  }
24685
25047
 
24686
25048
  // src/services/consensusOracle/consensusOracleService.ts
24687
- var import_common63 = __toESM(require_dist());
25049
+ var import_common65 = __toESM(require_dist());
24688
25050
  var ConsensusOracleService = class {
24689
25051
  constructor(client, deps) {
24690
25052
  this.client = client;
@@ -24720,7 +25082,7 @@ var ConsensusOracleService = class {
24720
25082
  receiptMints
24721
25083
  );
24722
25084
  const filteredCount = vaultState.holdings.filter(
24723
- (holding) => receiptMints.has((0, import_common63.fromWeb3Pk)(holding.mint).toString())
25085
+ (holding) => receiptMints.has((0, import_common65.fromWeb3Pk)(holding.mint).toString())
24724
25086
  ).length;
24725
25087
  if (filteredCount > 0) {
24726
25088
  log(
@@ -24989,8 +25351,8 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
24989
25351
 
24990
25352
  // src/services/externalLiquidityIntegrityService.ts
24991
25353
  var import_kit22 = require("@solana/kit");
24992
- var import_web343 = require("@solana/web3.js");
24993
- var import_common64 = __toESM(require_dist());
25354
+ var import_web344 = require("@solana/web3.js");
25355
+ var import_common66 = __toESM(require_dist());
24994
25356
  var import_marginfi5 = __toESM(require_dist2());
24995
25357
  var import_kamino5 = __toESM(require_dist3());
24996
25358
  var import_marginfi_client_v23 = require("@mrgnlabs/marginfi-client-v2");
@@ -25100,7 +25462,7 @@ function parseActiveSlots(externalLiquidity) {
25100
25462
  if (discriminant === 0) continue;
25101
25463
  if (discriminant !== 1 && discriminant !== 2) continue;
25102
25464
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
25103
- const userAccount = (0, import_common64.toAddress)(new import_web343.PublicKey(pubkeyBytes));
25465
+ const userAccount = (0, import_common66.toAddress)(new import_web344.PublicKey(pubkeyBytes));
25104
25466
  if (isZeroPubkey2(userAccount))
25105
25467
  throw new Error("Registered external position has a zero address");
25106
25468
  if (results.some((slot) => slot.userAccount === userAccount)) continue;
@@ -25272,7 +25634,7 @@ var ExternalLiquidityIntegrityService = class {
25272
25634
  const decimals = Number(holding.decimals ?? 0);
25273
25635
  const minRaw = toRawAmount(minAmountUi, decimals);
25274
25636
  let targetLocalAmount;
25275
- if (mintAddress === import_common64.USDC_MINT) {
25637
+ if (mintAddress === import_common66.USDC_MINT) {
25276
25638
  const tvl = toBigInt3(vaultState.accounting.tvl);
25277
25639
  const price = toBigInt3(holding.price);
25278
25640
  const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
@@ -25375,25 +25737,25 @@ var ExternalLiquidityIntegrityService = class {
25375
25737
  * from vault accounting as though it were the balance of each separate slot. */
25376
25738
  async loadPositions(vault, mint, slots) {
25377
25739
  const marginfi = (0, import_marginfi5.marginfiAccountsForMint)(mint);
25378
- if (!marginfi && mint !== import_common64.USDC_MINT)
25740
+ if (!marginfi && mint !== import_common66.USDC_MINT)
25379
25741
  return {
25380
25742
  local: 0n,
25381
25743
  positions: [],
25382
- tokenProgram: (0, import_kit22.address)(import_web343.PublicKey.default.toBase58()),
25383
- vaultAta: (0, import_kit22.address)(import_web343.PublicKey.default.toBase58())
25744
+ tokenProgram: (0, import_kit22.address)(import_web344.PublicKey.default.toBase58()),
25745
+ vaultAta: (0, import_kit22.address)(import_web344.PublicKey.default.toBase58())
25384
25746
  };
25385
25747
  const connection = this.client.provider.connection;
25386
25748
  const mintInfo = await connection.getAccountInfo(
25387
- new import_web343.PublicKey(mint),
25749
+ new import_web344.PublicKey(mint),
25388
25750
  "confirmed"
25389
25751
  );
25390
25752
  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);
25753
+ const tokenProgram = (0, import_common66.fromWeb3Pk)(mintInfo.owner);
25754
+ const vaultAta = (0, import_common66.getAtaAddress)(mint, vault, tokenProgram, true);
25393
25755
  const positions = [];
25394
25756
  for (const slot of slots) {
25395
25757
  if (slot.source === "marginfi" && !marginfi) continue;
25396
- if (slot.source === "kamino" && mint !== import_common64.USDC_MINT) continue;
25758
+ if (slot.source === "kamino" && mint !== import_common66.USDC_MINT) continue;
25397
25759
  const kamino = slot.source === "kamino" ? await loadKaminoDeposit({
25398
25760
  connection,
25399
25761
  vault,
@@ -25404,7 +25766,7 @@ var ExternalLiquidityIntegrityService = class {
25404
25766
  throw new Error("Kamino token program mismatch");
25405
25767
  const data = Buffer.alloc(256);
25406
25768
  data[0] = slot.source === "marginfi" ? 1 : 2;
25407
- new import_web343.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
25769
+ new import_web344.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
25408
25770
  const withdrawal = await loadWithdrawalPosition({
25409
25771
  connection,
25410
25772
  vault,
@@ -25440,8 +25802,8 @@ var ExternalLiquidityIntegrityService = class {
25440
25802
  async executeMoves(args) {
25441
25803
  const { vault, mintAddress, hwManager, snapshot: snapshot2, moves, dryRun, log } = args;
25442
25804
  const instructions2 = [
25443
- (0, import_common64.toKitInstruction)(
25444
- import_web343.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
25805
+ (0, import_common66.toKitInstruction)(
25806
+ import_web344.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
25445
25807
  )
25446
25808
  ];
25447
25809
  const lookupTables = /* @__PURE__ */ new Set();
@@ -25454,7 +25816,7 @@ var ExternalLiquidityIntegrityService = class {
25454
25816
  cpiRefs = position.withdrawal.explicitRefs(move.amount);
25455
25817
  } else if (position.source === "kamino") {
25456
25818
  if (!position.kamino) throw new Error("Missing Kamino reserve");
25457
- cpiRefs = (0, import_common64.createCpiRefs)(
25819
+ cpiRefs = (0, import_common66.createCpiRefs)(
25458
25820
  (0, import_kamino5.kaminoDepositCpis)({
25459
25821
  ...position.kamino,
25460
25822
  vault,
@@ -25465,14 +25827,14 @@ var ExternalLiquidityIntegrityService = class {
25465
25827
  );
25466
25828
  } else {
25467
25829
  const configured = (0, import_marginfi5.marginfiAccountsForMint)(mintAddress);
25468
- cpiRefs = (0, import_common64.createCpiRefs)([
25830
+ cpiRefs = (0, import_common66.createCpiRefs)([
25469
25831
  new import_marginfi5.CpiClient({ accounts: configured }).deposit_cpi({
25470
25832
  marginfiAccount: position.userAccount,
25471
25833
  authority: vault,
25472
25834
  signerTokenAccount: snapshot2.vaultAta,
25473
25835
  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)] : []
25836
+ lookupTables: (import_marginfi_client_v23.ADDRESS_LOOKUP_TABLE_FOR_GROUP[configured.group] ?? []).map(import_common66.fromWeb3Pk),
25837
+ remainingAccounts: configured.tokenProgram === "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" ? [(0, import_common66.toCustomAccountMeta)(mintAddress)] : []
25476
25838
  })
25477
25839
  ]);
25478
25840
  }
@@ -25480,7 +25842,7 @@ var ExternalLiquidityIntegrityService = class {
25480
25842
  instructions2.push(
25481
25843
  await this.client.tx.protocolInteraction.getIx({
25482
25844
  vault,
25483
- hwManager: (0, import_common64.fromWeb3Pk)(hwManager.publicKey),
25845
+ hwManager: (0, import_common66.fromWeb3Pk)(hwManager.publicKey),
25484
25846
  ...cpiRefs,
25485
25847
  externalLiquidityIndex: position.index,
25486
25848
  affectedAssetMint: mintAddress,
@@ -25512,10 +25874,10 @@ var ExternalLiquidityIntegrityService = class {
25512
25874
 
25513
25875
  // src/services/idleLiquidityService.ts
25514
25876
  var import_kit23 = require("@solana/kit");
25515
- var import_spl_token26 = require("@solana/spl-token");
25877
+ var import_spl_token27 = require("@solana/spl-token");
25516
25878
  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());
25879
+ var import_web345 = require("@solana/web3.js");
25880
+ var import_common67 = __toESM(require_dist());
25519
25881
  var import_marginfi6 = __toESM(require_dist2());
25520
25882
  var IDLE_RESERVE_FLOOR_BPS = 400;
25521
25883
  var IDLE_RESERVE_TARGET_BPS = 500;
@@ -25619,8 +25981,8 @@ var IdleLiquidityService = class {
25619
25981
  );
25620
25982
  }
25621
25983
  quote = await jupiter.getQuote({
25622
- inputMint: import_common65.PST_MINT,
25623
- outputMint: import_common65.USDC_MINT,
25984
+ inputMint: import_common67.PST_MINT,
25985
+ outputMint: import_common67.USDC_MINT,
25624
25986
  amount: pstInput,
25625
25987
  slippageBps
25626
25988
  });
@@ -25665,13 +26027,13 @@ var IdleLiquidityService = class {
25665
26027
  /** Read live local, Project0 and Kamino USDC, excluding other deployed capital. */
25666
26028
  async fetchIdleUsdc(vault, vaultState) {
25667
26029
  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);
26030
+ const vaultPk = new import_web345.PublicKey(vault);
26031
+ const usdcMint = new import_web345.PublicKey(import_common67.USDC_MINT);
26032
+ const ata = (0, import_spl_token27.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
25671
26033
  const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
25672
26034
  let localAmount = 0n;
25673
26035
  if (tokenInfo) {
25674
- const tokenAccount = (0, import_spl_token26.unpackAccount)(ata, tokenInfo, import_spl_token26.TOKEN_PROGRAM_ID);
26036
+ const tokenAccount = (0, import_spl_token27.unpackAccount)(ata, tokenInfo, import_spl_token27.TOKEN_PROGRAM_ID);
25675
26037
  if (!tokenAccount.mint.equals(usdcMint) || !tokenAccount.owner.equals(vaultPk) || !tokenAccount.isInitialized) {
25676
26038
  throw new Error(`Invalid vault USDC token account: ${ata.toBase58()}`);
25677
26039
  }
@@ -25680,7 +26042,7 @@ var IdleLiquidityService = class {
25680
26042
  const kamino = await this.fetchKaminoUsdc(
25681
26043
  vault,
25682
26044
  vaultState,
25683
- (0, import_common65.fromWeb3Pk)(ata)
26045
+ (0, import_common67.fromWeb3Pk)(ata)
25684
26046
  );
25685
26047
  const slotIndex = vaultState.externalLiquidity.findIndex(
25686
26048
  (slot) => slot.data[0] === 1
@@ -25698,12 +26060,12 @@ var IdleLiquidityService = class {
25698
26060
  if (data.length < 40) {
25699
26061
  throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
25700
26062
  }
25701
- const positionPk = new import_web344.PublicKey(new Uint8Array(data.slice(8, 40)));
26063
+ const positionPk = new import_web345.PublicKey(new Uint8Array(data.slice(8, 40)));
25702
26064
  const positionInfo = await connection.getAccountInfo(
25703
26065
  positionPk,
25704
26066
  "confirmed"
25705
26067
  );
25706
- if (!positionInfo || !positionInfo.owner.equals(new import_web344.PublicKey(import_marginfi6.MARGINFI_PROGRAM_ID))) {
26068
+ if (!positionInfo || !positionInfo.owner.equals(new import_web345.PublicKey(import_marginfi6.MARGINFI_PROGRAM_ID))) {
25707
26069
  throw new Error(
25708
26070
  `Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
25709
26071
  );
@@ -25752,17 +26114,17 @@ var IdleLiquidityService = class {
25752
26114
  if (slot.data[0] !== 2) continue;
25753
26115
  if (slot.data.length < 40)
25754
26116
  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))
26117
+ const key = new import_web345.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
26118
+ if (key.equals(import_web345.PublicKey.default))
25757
26119
  throw new Error(`Missing Kamino position in slot ${index}`);
25758
26120
  if (seen.has(key.toBase58())) continue;
25759
26121
  seen.add(key.toBase58());
25760
26122
  const position = await loadWithdrawalPosition({
25761
26123
  connection: this.client.provider.connection,
25762
26124
  vault,
25763
- assetMint: import_common65.USDC_MINT,
26125
+ assetMint: import_common67.USDC_MINT,
25764
26126
  vaultAssetAta,
25765
- tokenProgram: (0, import_common65.fromWeb3Pk)(import_spl_token26.TOKEN_PROGRAM_ID),
26127
+ tokenProgram: (0, import_common67.fromWeb3Pk)(import_spl_token27.TOKEN_PROGRAM_ID),
25766
26128
  slot,
25767
26129
  index,
25768
26130
  requireUsablePosition: true
@@ -25813,8 +26175,8 @@ var IdleLiquidityService = class {
25813
26175
  log(`Vault ${vault}: ${reason} \u2014 skipping`);
25814
26176
  return { result: { ...empty, status: "no-tvl", reason } };
25815
26177
  }
25816
- const usdc = findHolding2(vaultState, import_common65.USDC_MINT);
25817
- const pst = findHolding2(vaultState, import_common65.PST_MINT);
26178
+ const usdc = findHolding2(vaultState, import_common67.USDC_MINT);
26179
+ const pst = findHolding2(vaultState, import_common67.PST_MINT);
25818
26180
  if (!usdc || !pst) {
25819
26181
  const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
25820
26182
  log(`Vault ${vault}: ${reason} \u2014 skipping`);
@@ -25965,16 +26327,16 @@ var IdleLiquidityService = class {
25965
26327
  */
25966
26328
  async mintTokenProgram(mint) {
25967
26329
  const account = await this.client.provider.connection.getAccountInfo(
25968
- new import_web344.PublicKey(mint),
26330
+ new import_web345.PublicKey(mint),
25969
26331
  "confirmed"
25970
26332
  );
25971
26333
  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)) {
26334
+ if (!account.owner.equals(import_spl_token27.TOKEN_PROGRAM_ID) && !account.owner.equals(import_spl_token27.TOKEN_2022_PROGRAM_ID)) {
25973
26335
  throw new Error(
25974
26336
  `Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
25975
26337
  );
25976
26338
  }
25977
- return (0, import_common65.fromWeb3Pk)(account.owner);
26339
+ return (0, import_common67.fromWeb3Pk)(account.owner);
25978
26340
  }
25979
26341
  /**
25980
26342
  * Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
@@ -25994,23 +26356,23 @@ var IdleLiquidityService = class {
25994
26356
  dryRun,
25995
26357
  log
25996
26358
  } = params;
25997
- const signer = (0, import_common65.fromWeb3Pk)(hwManager.publicKey);
26359
+ const signer = (0, import_common67.fromWeb3Pk)(hwManager.publicKey);
25998
26360
  const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
25999
- this.mintTokenProgram(import_common65.PST_MINT),
26000
- this.mintTokenProgram(import_common65.USDC_MINT)
26361
+ this.mintTokenProgram(import_common67.PST_MINT),
26362
+ this.mintTokenProgram(import_common67.USDC_MINT)
26001
26363
  ]);
26002
26364
  const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
26003
26365
  payer: signer
26004
26366
  });
26005
- const { accounts: accounts2, refs, lookupTables } = (0, import_common65.createCpiRefs)([jupiterCpi]);
26367
+ const { accounts: accounts2, refs, lookupTables } = (0, import_common67.createCpiRefs)([jupiterCpi]);
26006
26368
  const vaultTrancheState = coerceBool4(
26007
26369
  vaultState.tranchingEnabled
26008
26370
  ) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
26009
26371
  const plan = await this.client.tx.jupiterSwap.getTx({
26010
26372
  hwManager: signer,
26011
26373
  vault,
26012
- sourceMint: import_common65.PST_MINT,
26013
- destinationMint: import_common65.USDC_MINT,
26374
+ sourceMint: import_common67.PST_MINT,
26375
+ destinationMint: import_common67.USDC_MINT,
26014
26376
  refs,
26015
26377
  accounts: accounts2,
26016
26378
  sourceTokenProgram,
@@ -26020,26 +26382,26 @@ var IdleLiquidityService = class {
26020
26382
  });
26021
26383
  const connection = this.client.provider.connection;
26022
26384
  const instructions2 = [
26023
- import_web344.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
26385
+ import_web345.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
26024
26386
  ...cuPriceMicroLamports > 0 ? [
26025
- import_web344.ComputeBudgetProgram.setComputeUnitPrice({
26387
+ import_web345.ComputeBudgetProgram.setComputeUnitPrice({
26026
26388
  microLamports: cuPriceMicroLamports
26027
26389
  })
26028
26390
  ] : [],
26029
- ...(jupiterCpi.preInstructions ?? []).map(import_common65.fromKitInstruction),
26030
- ...plan.instructions.map(import_common65.fromKitInstruction)
26391
+ ...(jupiterCpi.preInstructions ?? []).map(import_common67.fromKitInstruction),
26392
+ ...plan.instructions.map(import_common67.fromKitInstruction)
26031
26393
  ];
26032
26394
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
26033
- const lookupTableAccounts = await (0, import_common65.fetchLookupTables)(
26395
+ const lookupTableAccounts = await (0, import_common67.fetchLookupTables)(
26034
26396
  connection,
26035
26397
  plan.lookupTables ?? []
26036
26398
  );
26037
- const message2 = new import_web344.TransactionMessage({
26399
+ const message2 = new import_web345.TransactionMessage({
26038
26400
  payerKey: hwManager.publicKey,
26039
26401
  recentBlockhash: blockhash,
26040
26402
  instructions: instructions2
26041
26403
  }).compileToV0Message(lookupTableAccounts);
26042
- const transaction = new import_web344.VersionedTransaction(message2);
26404
+ const transaction = new import_web345.VersionedTransaction(message2);
26043
26405
  transaction.sign([hwManager]);
26044
26406
  if (!this.client.skipSimulation) {
26045
26407
  const simulation = await connection.simulateTransaction(transaction, {
@@ -26085,9 +26447,9 @@ var IdleLiquidityService = class {
26085
26447
 
26086
26448
  // src/services/timelockSettlementService.ts
26087
26449
  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();
26450
+ var import_web346 = require("@solana/web3.js");
26451
+ var import_common68 = __toESM(require_dist());
26452
+ var ZERO_PUBKEY = import_web346.PublicKey.default.toBase58();
26091
26453
  var CONSENSUS_SIGNER_CAPACITY = 4;
26092
26454
  var CONSENSUS_ENTRY_OFFSET = 40;
26093
26455
  var CONSENSUS_ENTRY_SIZE = 272;
@@ -26127,7 +26489,7 @@ function decodePendingConsensusSigners(data) {
26127
26489
  const signers = [];
26128
26490
  for (let i = 0; i < count; i += 1) {
26129
26491
  const start = CONSENSUS_PENDING_OFFSET + i * 32;
26130
- const signer = new import_web345.PublicKey(bytes.slice(start, start + 32)).toBase58();
26492
+ const signer = new import_web346.PublicKey(bytes.slice(start, start + 32)).toBase58();
26131
26493
  if (signer === ZERO_PUBKEY) {
26132
26494
  throw new Error(`pending consensus signer ${i} is unset`);
26133
26495
  }
@@ -26183,7 +26545,7 @@ var TimelockSettlementService = class {
26183
26545
  });
26184
26546
  const dryRun = opts.dryRun ?? false;
26185
26547
  const now = opts.now ?? await this.chainTime();
26186
- const fulfillerAddress = (0, import_common66.fromWeb3Pk)(fulfiller.publicKey);
26548
+ const fulfillerAddress = (0, import_common68.fromWeb3Pk)(fulfiller.publicKey);
26187
26549
  const allVaults = opts.vault ? [
26188
26550
  {
26189
26551
  publicKey: opts.vault,
@@ -26326,18 +26688,18 @@ var TimelockSettlementService = class {
26326
26688
 
26327
26689
  // src/services/nestWithdrawalService.ts
26328
26690
  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());
26691
+ var import_spl_token28 = require("@solana/spl-token");
26692
+ var import_web347 = require("@solana/web3.js");
26693
+ var import_common69 = __toESM(require_dist());
26332
26694
  var import_nest3 = __toESM(require_dist4());
26333
26695
  var import_nest4 = __toESM(require_dist4());
26334
- var NestOftProgram = new import_web346.PublicKey(
26696
+ var NestOftProgram = new import_web347.PublicKey(
26335
26697
  "ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
26336
26698
  );
26337
- var NestOftStore = new import_web346.PublicKey(
26699
+ var NestOftStore = new import_web347.PublicKey(
26338
26700
  "k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
26339
26701
  );
26340
- var UsdcMint = new import_web346.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26702
+ var UsdcMint = new import_web347.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26341
26703
  var NestPerenaComposer = Buffer.from(
26342
26704
  "000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
26343
26705
  "hex"
@@ -26354,7 +26716,7 @@ async function buildNestWithdrawalRequest(args) {
26354
26716
  return decodeNestWithdrawalRequest({ ...args, txBase64 });
26355
26717
  }
26356
26718
  async function decodeNestWithdrawalRequest(args) {
26357
- const transaction = import_web346.VersionedTransaction.deserialize(
26719
+ const transaction = import_web347.VersionedTransaction.deserialize(
26358
26720
  Buffer.from(args.txBase64, "base64")
26359
26721
  );
26360
26722
  const message2 = transaction.message;
@@ -26375,19 +26737,19 @@ async function decodeNestWithdrawalRequest(args) {
26375
26737
  return value;
26376
26738
  })
26377
26739
  );
26378
- const decoded = import_web346.TransactionMessage.decompile(message2, {
26740
+ const decoded = import_web347.TransactionMessage.decompile(message2, {
26379
26741
  addressLookupTableAccounts: tables
26380
26742
  });
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);
26743
+ const nestMint = new import_web347.PublicKey(NEST_RWA_SHARE_MINT);
26744
+ const sourceAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
26745
+ const usdcAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
26384
26746
  const instructions2 = decoded.instructions.filter(
26385
- (ix) => !ix.programId.equals(import_web346.ComputeBudgetProgram.programId)
26747
+ (ix) => !ix.programId.equals(import_web347.ComputeBudgetProgram.programId)
26386
26748
  );
26387
26749
  let sends = 0;
26388
26750
  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)) {
26751
+ if (ix.programId.equals(import_spl_token28.ASSOCIATED_TOKEN_PROGRAM_ID)) {
26752
+ 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
26753
  throw new Error("Unexpected token account creation in Nest withdrawal");
26392
26754
  }
26393
26755
  continue;
@@ -26404,20 +26766,20 @@ async function decodeNestWithdrawalRequest(args) {
26404
26766
  if (sends !== 1)
26405
26767
  throw new Error("Nest withdrawal must contain exactly one OFT send");
26406
26768
  return {
26407
- instructions: instructions2.map(import_common67.toKitInstruction),
26769
+ instructions: instructions2.map(import_common69.toKitInstruction),
26408
26770
  lookupTables: tables.map((table) => (0, import_kit25.address)(table.key.toBase58()))
26409
26771
  };
26410
26772
  }
26411
26773
 
26412
26774
  // src/services/nestDepositService.ts
26413
26775
  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());
26776
+ var import_spl_token29 = require("@solana/spl-token");
26777
+ var import_web348 = require("@solana/web3.js");
26778
+ var import_common70 = __toESM(require_dist());
26417
26779
  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(
26780
+ var Usdc = new import_web348.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26781
+ var Messenger = new import_web348.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
26782
+ var Transmitter = new import_web348.PublicKey(
26421
26783
  "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
26422
26784
  );
26423
26785
  var Router = Buffer.from(
@@ -26470,7 +26832,7 @@ async function decodeNestDepositRequest(args) {
26470
26832
  "Nest deposit must be a positive, safely representable USDC base-unit amount"
26471
26833
  );
26472
26834
  }
26473
- const message2 = import_web347.VersionedTransaction.deserialize(
26835
+ const message2 = import_web348.VersionedTransaction.deserialize(
26474
26836
  Buffer.from(args.txBase64, "base64")
26475
26837
  ).message;
26476
26838
  if (!message2.staticAccountKeys[0].equals(args.owner))
@@ -26485,23 +26847,23 @@ async function decodeNestDepositRequest(args) {
26485
26847
  return value;
26486
26848
  })
26487
26849
  );
26488
- const instructions2 = import_web347.TransactionMessage.decompile(message2, {
26850
+ const instructions2 = import_web348.TransactionMessage.decompile(message2, {
26489
26851
  addressLookupTableAccounts: tables
26490
26852
  }).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);
26853
+ const shareMint = new import_web348.PublicKey(NEST_RWA_SHARE_MINT);
26854
+ const shareAta = (0, import_spl_token29.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
26855
+ const usdcAta = (0, import_spl_token29.getAssociatedTokenAddressSync)(Usdc, args.owner, true);
26494
26856
  let burn;
26495
26857
  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))
26858
+ if (ix.programId.equals(import_web348.ComputeBudgetProgram.programId)) continue;
26859
+ if (ix.programId.equals(import_spl_token29.ASSOCIATED_TOKEN_PROGRAM_ID)) {
26860
+ 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
26861
  throw new Error("Unexpected Nest deposit token account creation");
26500
26862
  continue;
26501
26863
  }
26502
26864
  const d = ix.data;
26503
26865
  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(
26866
+ 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
26867
  (meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
26506
26868
  )) {
26507
26869
  throw new Error(
@@ -26520,33 +26882,33 @@ async function decodeNestDepositRequest(args) {
26520
26882
  burn.keys[1] = { pubkey: args.owner, isSigner: true, isWritable: true };
26521
26883
  return {
26522
26884
  instructions: [
26523
- (0, import_spl_token28.createAssociatedTokenAccountIdempotentInstruction)(
26885
+ (0, import_spl_token29.createAssociatedTokenAccountIdempotentInstruction)(
26524
26886
  args.owner,
26525
26887
  shareAta,
26526
26888
  args.owner,
26527
26889
  shareMint
26528
26890
  ),
26529
26891
  burn
26530
- ].map(import_common68.toKitInstruction),
26892
+ ].map(import_common70.toKitInstruction),
26531
26893
  lookupTables: tables.map((table) => (0, import_kit26.address)(table.key.toBase58())),
26532
26894
  ephemeralSignerKeys: [eventKey]
26533
26895
  };
26534
26896
  }
26535
26897
 
26536
26898
  // src/services/vaultLutManager.ts
26537
- var import_web348 = require("@solana/web3.js");
26899
+ var import_web349 = require("@solana/web3.js");
26538
26900
  var MAX_LUT_ADDRESSES = 256;
26539
26901
  var ACTIVE = (1n << 64n) - 1n;
26540
26902
  var asAddress = (key) => key.toBase58();
26541
26903
  function uniqueLutAddresses(addresses) {
26542
- return [...new Set(addresses)].filter((a) => a !== import_web348.PublicKey.default.toBase58()).map((a) => asAddress(new import_web348.PublicKey(a)));
26904
+ return [...new Set(addresses)].filter((a) => a !== import_web349.PublicKey.default.toBase58()).map((a) => asAddress(new import_web349.PublicKey(a)));
26543
26905
  }
26544
26906
  var VaultLutManager = class {
26545
26907
  constructor(connection) {
26546
26908
  this.connection = connection;
26547
26909
  }
26548
26910
  async fetch(table) {
26549
- const account = (await this.connection.getAddressLookupTable(new import_web348.PublicKey(table), {
26911
+ const account = (await this.connection.getAddressLookupTable(new import_web349.PublicKey(table), {
26550
26912
  commitment: "confirmed"
26551
26913
  })).value;
26552
26914
  if (!account) throw new Error(`Lookup table not found: ${table}`);
@@ -26558,14 +26920,14 @@ var VaultLutManager = class {
26558
26920
  * mapping is lost. Also accepts older tables containing the vault elsewhere. */
26559
26921
  async findForVault(authority, vault) {
26560
26922
  const accounts2 = await this.connection.getProgramAccounts(
26561
- import_web348.AddressLookupTableProgram.programId,
26923
+ import_web349.AddressLookupTableProgram.programId,
26562
26924
  {
26563
26925
  commitment: "confirmed",
26564
26926
  filters: [{ memcmp: { offset: 22, bytes: authority.toBase58() } }]
26565
26927
  }
26566
26928
  );
26567
26929
  return accounts2.flatMap(({ pubkey: pubkey2, account }) => {
26568
- const state = import_web348.AddressLookupTableAccount.deserialize(account.data);
26930
+ const state = import_web349.AddressLookupTableAccount.deserialize(account.data);
26569
26931
  return state.deactivationSlot === ACTIVE && state.authority?.equals(authority) && state.addresses.some((a) => a.toBase58() === vault) ? [asAddress(pubkey2)] : [];
26570
26932
  });
26571
26933
  }
@@ -26597,7 +26959,7 @@ var VaultLutManager = class {
26597
26959
  let created = false;
26598
26960
  const send = async (instructions2) => {
26599
26961
  const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash("confirmed");
26600
- const tx = new import_web348.Transaction({
26962
+ const tx = new import_web349.Transaction({
26601
26963
  feePayer: args.payer.publicKey,
26602
26964
  blockhash,
26603
26965
  lastValidBlockHeight
@@ -26624,7 +26986,7 @@ var VaultLutManager = class {
26624
26986
  };
26625
26987
  if (!table) {
26626
26988
  const hashes = await this.connection.getAccountInfo(
26627
- import_web348.SYSVAR_SLOT_HASHES_PUBKEY,
26989
+ import_web349.SYSVAR_SLOT_HASHES_PUBKEY,
26628
26990
  "confirmed"
26629
26991
  );
26630
26992
  if (!hashes || hashes.data.length < 48 || hashes.data.readBigUInt64LE(0) === 0n)
@@ -26632,7 +26994,7 @@ var VaultLutManager = class {
26632
26994
  const recentSlot = Number(hashes.data.readBigUInt64LE(8));
26633
26995
  if (!Number.isSafeInteger(recentSlot))
26634
26996
  throw new Error("Recent slot exceeds safe integer range");
26635
- const [create, key] = import_web348.AddressLookupTableProgram.createLookupTable({
26997
+ const [create, key] = import_web349.AddressLookupTableProgram.createLookupTable({
26636
26998
  authority: authority.publicKey,
26637
26999
  payer: args.payer.publicKey,
26638
27000
  recentSlot
@@ -26647,11 +27009,11 @@ var VaultLutManager = class {
26647
27009
  args.onProgress?.(`Creating vault LUT: ${table}`);
26648
27010
  await send([
26649
27011
  create,
26650
- import_web348.AddressLookupTableProgram.extendLookupTable({
27012
+ import_web349.AddressLookupTableProgram.extendLookupTable({
26651
27013
  lookupTable: key,
26652
27014
  authority: authority.publicKey,
26653
27015
  payer: args.payer.publicKey,
26654
- addresses: [new import_web348.PublicKey(args.vault)]
27016
+ addresses: [new import_web349.PublicKey(args.vault)]
26655
27017
  })
26656
27018
  ]);
26657
27019
  created = true;
@@ -26671,11 +27033,11 @@ var VaultLutManager = class {
26671
27033
  for (let i = 0; i < missing.length; i += 20) {
26672
27034
  const batch = missing.slice(i, i + 20);
26673
27035
  await send([
26674
- import_web348.AddressLookupTableProgram.extendLookupTable({
26675
- lookupTable: new import_web348.PublicKey(table),
27036
+ import_web349.AddressLookupTableProgram.extendLookupTable({
27037
+ lookupTable: new import_web349.PublicKey(table),
26676
27038
  authority: authority.publicKey,
26677
27039
  payer: args.payer.publicKey,
26678
- addresses: batch.map((a) => new import_web348.PublicKey(a))
27040
+ addresses: batch.map((a) => new import_web349.PublicKey(a))
26679
27041
  })
26680
27042
  ]);
26681
27043
  args.onProgress?.(
@@ -26698,12 +27060,12 @@ var VaultLutManager = class {
26698
27060
 
26699
27061
  // src/services/vaultLookupTableAccounts.ts
26700
27062
  var import_core26 = require("@anchor-lang/core");
26701
- var import_web349 = require("@solana/web3.js");
26702
- var import_spl_token29 = require("@solana/spl-token");
27063
+ var import_web350 = require("@solana/web3.js");
27064
+ var import_spl_token30 = require("@solana/spl-token");
26703
27065
  var import_marginfi_client_v25 = require("@mrgnlabs/marginfi-client-v2");
26704
27066
  var import_Obligation3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
26705
27067
  var import_Reserve3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
26706
- var import_common69 = __toESM(require_dist());
27068
+ var import_common71 = __toESM(require_dist());
26707
27069
  var import_marginfi7 = __toESM(require_dist2());
26708
27070
  var import_kamino6 = __toESM(require_dist3());
26709
27071
  async function collectVaultLookupTableAccounts(client, vault, options = {}) {
@@ -26718,13 +27080,13 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26718
27080
  const add = (key) => addresses.push(typeof key === "string" ? key : key.toBase58());
26719
27081
  [
26720
27082
  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
27083
+ import_spl_token30.ASSOCIATED_TOKEN_PROGRAM_ID,
27084
+ import_spl_token30.TOKEN_PROGRAM_ID,
27085
+ import_spl_token30.TOKEN_2022_PROGRAM_ID,
27086
+ import_web350.SYSVAR_INSTRUCTIONS_PUBKEY
26725
27087
  ].forEach(add);
26726
27088
  const publicKeys = (value) => {
26727
- if (value instanceof import_web349.PublicKey) {
27089
+ if (value instanceof import_web350.PublicKey) {
26728
27090
  add(value);
26729
27091
  return;
26730
27092
  }
@@ -26743,7 +27105,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26743
27105
  }
26744
27106
  ];
26745
27107
  const tranche = await client.program.account.vaultTrancheState.fetchNullable(
26746
- new import_web349.PublicKey(tranchePda)
27108
+ new import_web350.PublicKey(tranchePda)
26747
27109
  );
26748
27110
  if (tranche) {
26749
27111
  publicKeys(tranche.config);
@@ -26763,30 +27125,30 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26763
27125
  );
26764
27126
  }
26765
27127
  const holdings = state.holdings.filter(
26766
- (h) => !h.mint.equals(import_web349.PublicKey.default)
27128
+ (h) => !h.mint.equals(import_web350.PublicKey.default)
26767
27129
  );
26768
27130
  for (const h of holdings) {
26769
27131
  const mint = h.mint.toBase58(), program = tokenProgramAddressFromIdlEnum(h.tokenProgram);
26770
27132
  add(mint);
26771
27133
  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));
27134
+ add((0, import_common71.getAtaAddress)(mint, vault, program, true));
27135
+ add((0, import_common71.getAtaAddress)(mint, fee, program, true));
27136
+ if (options.user) add((0, import_common71.getAtaAddress)(mint, options.user, program, true));
26775
27137
  }
26776
27138
  for (const share of shares) {
26777
27139
  add(share.mint);
26778
27140
  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));
27141
+ add((0, import_common71.getAtaAddress)(share.mint, vault, share.program, true));
27142
+ add((0, import_common71.getAtaAddress)(share.mint, fee, share.program, true));
26781
27143
  if (options.user)
26782
- add((0, import_common69.getAtaAddress)(share.mint, options.user, share.program, true));
27144
+ add((0, import_common71.getAtaAddress)(share.mint, options.user, share.program, true));
26783
27145
  }
26784
27146
  const slots = state.externalLiquidity.filter(
26785
27147
  (s) => [1, 2].includes(s.data[0])
26786
27148
  );
26787
27149
  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;
27150
+ const position = new import_web350.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
27151
+ if (position.equals(import_web350.PublicKey.default)) continue;
26790
27152
  add(position);
26791
27153
  const info = await connection.getAccountInfo(position, "confirmed");
26792
27154
  if (slot.data[0] === 1) {
@@ -26797,7 +27159,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26797
27159
  const cpi = new import_marginfi7.CpiClient({ accounts: config }).withdraw_cpi({
26798
27160
  marginfiAccount: position.toBase58(),
26799
27161
  authority: vault,
26800
- destinationTokenAccount: (0, import_common69.getAtaAddress)(
27162
+ destinationTokenAccount: (0, import_common71.getAtaAddress)(
26801
27163
  mint,
26802
27164
  vault,
26803
27165
  config.tokenProgram,
@@ -26850,7 +27212,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26850
27212
  if (!reserveKeys.length)
26851
27213
  throw new Error(`No reserves found for Kamino obligation ${position}`);
26852
27214
  const infos = await connection.getMultipleAccountsInfo(
26853
- reserveKeys.map((a) => new import_web349.PublicKey(a)),
27215
+ reserveKeys.map((a) => new import_web350.PublicKey(a)),
26854
27216
  "confirmed"
26855
27217
  );
26856
27218
  const reserves = infos.map((info2, i) => {
@@ -26880,7 +27242,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26880
27242
  obligation: position.toBase58(),
26881
27243
  reserves,
26882
27244
  reserve,
26883
- destination: (0, import_common69.getAtaAddress)(
27245
+ destination: (0, import_common71.getAtaAddress)(
26884
27246
  reserve.liquidityMint,
26885
27247
  vault,
26886
27248
  reserve.liquidityTokenProgram,
@@ -26900,17 +27262,19 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26900
27262
  }
26901
27263
 
26902
27264
  // src/index.ts
26903
- var import_common70 = __toESM(require_dist());
27265
+ var import_common72 = __toESM(require_dist());
26904
27266
  // Annotate the CommonJS export names for ESM import in node:
26905
27267
  0 && (module.exports = {
26906
27268
  ASSET_DECIMALS,
26907
27269
  ASSET_REBALANCE_COOLDOWN_SECS,
27270
+ ASYNC_REDEMPTION_CANCEL_DELAY_SECS,
26908
27271
  AccountClient,
26909
27272
  ActivateCircuitBreakerBuilder,
26910
27273
  AddIncentiveRecipientBuilder,
26911
27274
  AddIncentiveRecipientV3Builder,
26912
27275
  BALANCE_CHANGE_BASELINE_MAX_AGE_SECS,
26913
27276
  CONSENSUS_ORACLE_VARIANT,
27277
+ CancelAsyncWithdrawBuilder,
26914
27278
  CancelIncentiveProposalBuilder,
26915
27279
  CancelJuniorTrancheWithdrawBuilder,
26916
27280
  ClaimIncentiveBuilder,
@@ -27004,6 +27368,7 @@ var import_common70 = __toESM(require_dist());
27004
27368
  PROTOCOL_FEE_RECIPIENT,
27005
27369
  PST_TO_USDC_MAX_SLIPPAGE_BPS,
27006
27370
  PdaClient,
27371
+ PriceAsyncWithdrawBuilder,
27007
27372
  ProtocolInteractionBuilder,
27008
27373
  RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS,
27009
27374
  REPORTABLE_ORACLE_VARIANTS,