@perena/vault-sdk 1.0.65 → 1.0.67

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 = toKitInstruction41;
159
+ exports2.toKitInstruction = toKitInstruction43;
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 toKitInstruction41(ix) {
175
+ function toKitInstruction43(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 = getAtaAddress24;
204
+ exports2.getAtaAddress = getAtaAddress26;
205
205
  var spl_token_1 = require("@solana/spl-token");
206
206
  var compat_1 = require_compat();
207
- function getAtaAddress24(mint, owner, tokenProgram, allowOwnerOffCurve = true) {
207
+ function getAtaAddress26(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
  }
@@ -2073,7 +2073,7 @@ __export(index_exports, {
2073
2073
  DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS: () => DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
2074
2074
  DEFAULT_MARGINFI_WEIGHT_BPS: () => DEFAULT_MARGINFI_WEIGHT_BPS,
2075
2075
  DEFAULT_MAX_ACCEPTABLE_APY_BPS: () => DEFAULT_MAX_ACCEPTABLE_APY_BPS,
2076
- DEFAULT_MINTS: () => import_common68.DEFAULT_MINTS,
2076
+ DEFAULT_MINTS: () => import_common70.DEFAULT_MINTS,
2077
2077
  DEFAULT_MIN_AMOUNT_UI: () => DEFAULT_MIN_AMOUNT_UI,
2078
2078
  DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS: () => DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
2079
2079
  DEFAULT_PRICE_ORACLE_ACCOUNT: () => DEFAULT_PRICE_ORACLE_ACCOUNT,
@@ -2097,6 +2097,7 @@ __export(index_exports, {
2097
2097
  ExternalLiquidityIntegrityService: () => ExternalLiquidityIntegrityService,
2098
2098
  ExternalPositionRegistry: () => ExternalPositionRegistry,
2099
2099
  FEE_VAULT_CACHE_CATEGORY: () => FEE_VAULT_CACHE_CATEGORY,
2100
+ FulfillAsyncWithdrawBuilder: () => FulfillAsyncWithdrawBuilder,
2100
2101
  FulfillJuniorTrancheWithdrawBuilder: () => FulfillJuniorTrancheWithdrawBuilder,
2101
2102
  IDL: () => IDL,
2102
2103
  IDLE_RESERVE_FLOOR_BPS: () => IDLE_RESERVE_FLOOR_BPS,
@@ -2128,7 +2129,7 @@ __export(index_exports, {
2128
2129
  ManagerRedepositAssetBuilder: () => ManagerRedepositAssetBuilder,
2129
2130
  ManagerWithdrawAssetBuilder: () => ManagerWithdrawAssetBuilder,
2130
2131
  MarginfiPositionProvider: () => MarginfiPositionProvider,
2131
- MintRegistry: () => import_common68.MintRegistry,
2132
+ MintRegistry: () => import_common70.MintRegistry,
2132
2133
  MockYieldTracker: () => MockYieldTracker,
2133
2134
  NEST_API_BASE_URL: () => import_nest2.NEST_API_BASE_URL,
2134
2135
  NEST_RWA_SHARE_MINT: () => NEST_RWA_SHARE_MINT,
@@ -2151,6 +2152,7 @@ __export(index_exports, {
2151
2152
  REPORTABLE_ORACLE_VARIANTS: () => REPORTABLE_ORACLE_VARIANTS,
2152
2153
  RemoveAssetHoldingBuilder: () => RemoveAssetHoldingBuilder,
2153
2154
  ReportIncentiveV3Builder: () => ReportIncentiveV3Builder,
2155
+ RequestAsyncWithdrawBuilder: () => RequestAsyncWithdrawBuilder,
2154
2156
  RequestJuniorTrancheWithdrawBuilder: () => RequestJuniorTrancheWithdrawBuilder,
2155
2157
  RpcManagerWalletBalanceSource: () => RpcManagerWalletBalanceSource,
2156
2158
  RpcMpcWalletBalanceSource: () => RpcMpcWalletBalanceSource,
@@ -2195,6 +2197,7 @@ __export(index_exports, {
2195
2197
  VaultLutManager: () => VaultLutManager,
2196
2198
  VaultQuoteClient: () => VaultQuoteClient,
2197
2199
  VaultReallocationBuilder: () => VaultReallocationBuilder,
2200
+ WALLET_FEE_EXEMPT_WHITELIST: () => WALLET_FEE_EXEMPT_WHITELIST,
2198
2201
  WITHDRAWABLE_RESERVE_FLOOR_BPS: () => WITHDRAWABLE_RESERVE_FLOOR_BPS,
2199
2202
  WithdrawalQueueService: () => WithdrawalQueueService,
2200
2203
  accountingUnitPriceToUsd: () => accountingUnitPriceToUsd,
@@ -2281,7 +2284,7 @@ __export(index_exports, {
2281
2284
  makeProvider: () => makeProvider,
2282
2285
  managerReconciliationStateKey: () => managerReconciliationStateKey,
2283
2286
  mintTokensTo: () => mintTokensTo,
2284
- mints: () => import_common68.mints,
2287
+ mints: () => import_common70.mints,
2285
2288
  mostFrequent: () => mostFrequent,
2286
2289
  parseExternalLiquidityRefs: () => parseExternalLiquidityRefs,
2287
2290
  planExternalAllocation: () => planExternalAllocation,
@@ -2293,6 +2296,7 @@ __export(index_exports, {
2293
2296
  previousPhysicalNav: () => previousPhysicalNav,
2294
2297
  priceInAccountingUnit: () => priceInAccountingUnit,
2295
2298
  publishedConsensusBlockers: () => publishedConsensusBlockers,
2299
+ quoteWithdrawalPayout: () => quoteWithdrawalPayout,
2296
2300
  readI64LE: () => readI64LE,
2297
2301
  readSplMintSupply: () => readSplMintSupply,
2298
2302
  reconcileManagerWalletBalances: () => reconcileManagerWalletBalances,
@@ -2355,6 +2359,9 @@ var PROGRAM_FEE_EXEMPT_OWNER_WHITELIST = [
2355
2359
  (0, import_kit.address)("soBBAHNhFyWF4QBCK9BJLVkX6d6NZt37ozNaPV5aq3H"),
2356
2360
  (0, import_kit.address)("GooseA4bSoxitTMPa4ppe2zUQ9fu4139u8pEk6x65SR")
2357
2361
  ];
2362
+ var WALLET_FEE_EXEMPT_WHITELIST = [
2363
+ (0, import_kit.address)("He4ka5Q3N1UvZikZvykdi47xyk5PoVP2tcQL5sVp31Sz")
2364
+ ];
2358
2365
  var VAULT_CREATOR_WHITELIST = [
2359
2366
  (0, import_kit.address)("4jMRBkpWrfhhwFYTwG3o7hmsXQwbJUwdyUX8htB6KwLJ"),
2360
2367
  (0, import_kit.address)("4YrMcKqx6CYpHJs7Bp8eMKLpRzZRRhKyFMoBmoPvGKM1")
@@ -2428,16 +2435,16 @@ function withVaultLookupTables(plan, programId, overrides) {
2428
2435
  var import_fs = __toESM(require("fs"));
2429
2436
  var import_os = __toESM(require("os"));
2430
2437
  var import_path = __toESM(require("path"));
2431
- var import_core22 = require("@anchor-lang/core");
2432
- var import_web328 = require("@solana/web3.js");
2438
+ var import_core23 = require("@anchor-lang/core");
2439
+ var import_web330 = require("@solana/web3.js");
2433
2440
  var import_kit11 = require("@solana/kit");
2434
- var import_common47 = __toESM(require_dist());
2441
+ var import_common49 = __toESM(require_dist());
2435
2442
 
2436
2443
  // src/client/client.ts
2437
- var import_core21 = require("@anchor-lang/core");
2444
+ var import_core22 = require("@anchor-lang/core");
2438
2445
  var import_kit10 = require("@solana/kit");
2439
- var import_web327 = require("@solana/web3.js");
2440
- var import_common46 = __toESM(require_dist());
2446
+ var import_web329 = require("@solana/web3.js");
2447
+ var import_common48 = __toESM(require_dist());
2441
2448
 
2442
2449
  // src/idl/vault.ts
2443
2450
  var IDL = {
@@ -7341,6 +7348,262 @@ var IDL = {
7341
7348
  }
7342
7349
  ]
7343
7350
  },
7351
+ {
7352
+ "name": "fulfill_async_withdraw",
7353
+ "discriminator": [
7354
+ 115,
7355
+ 156,
7356
+ 99,
7357
+ 78,
7358
+ 105,
7359
+ 35,
7360
+ 212,
7361
+ 150
7362
+ ],
7363
+ "accounts": [
7364
+ {
7365
+ "name": "signer",
7366
+ "writable": true,
7367
+ "signer": true
7368
+ },
7369
+ {
7370
+ "name": "owner"
7371
+ },
7372
+ {
7373
+ "name": "queue_payer",
7374
+ "writable": true
7375
+ },
7376
+ {
7377
+ "name": "vault",
7378
+ "writable": true
7379
+ },
7380
+ {
7381
+ "name": "vault_oracle"
7382
+ },
7383
+ {
7384
+ "name": "vault_tranche_state",
7385
+ "optional": true
7386
+ },
7387
+ {
7388
+ "name": "withdrawal_queue",
7389
+ "writable": true
7390
+ },
7391
+ {
7392
+ "name": "output_mint"
7393
+ },
7394
+ {
7395
+ "name": "input_mint",
7396
+ "writable": true
7397
+ },
7398
+ {
7399
+ "name": "owner_input_ata",
7400
+ "writable": true
7401
+ },
7402
+ {
7403
+ "name": "owner_output_ata",
7404
+ "writable": true,
7405
+ "pda": {
7406
+ "seeds": [
7407
+ {
7408
+ "kind": "account",
7409
+ "path": "owner"
7410
+ },
7411
+ {
7412
+ "kind": "account",
7413
+ "path": "asset_token_program"
7414
+ },
7415
+ {
7416
+ "kind": "account",
7417
+ "path": "output_mint"
7418
+ }
7419
+ ],
7420
+ "program": {
7421
+ "kind": "const",
7422
+ "value": [
7423
+ 140,
7424
+ 151,
7425
+ 37,
7426
+ 143,
7427
+ 78,
7428
+ 36,
7429
+ 137,
7430
+ 241,
7431
+ 187,
7432
+ 61,
7433
+ 16,
7434
+ 41,
7435
+ 20,
7436
+ 142,
7437
+ 13,
7438
+ 131,
7439
+ 11,
7440
+ 90,
7441
+ 19,
7442
+ 153,
7443
+ 218,
7444
+ 255,
7445
+ 16,
7446
+ 132,
7447
+ 4,
7448
+ 142,
7449
+ 123,
7450
+ 216,
7451
+ 219,
7452
+ 233,
7453
+ 248,
7454
+ 89
7455
+ ]
7456
+ }
7457
+ }
7458
+ },
7459
+ {
7460
+ "name": "vault_output_ata",
7461
+ "writable": true,
7462
+ "pda": {
7463
+ "seeds": [
7464
+ {
7465
+ "kind": "account",
7466
+ "path": "vault"
7467
+ },
7468
+ {
7469
+ "kind": "account",
7470
+ "path": "asset_token_program"
7471
+ },
7472
+ {
7473
+ "kind": "account",
7474
+ "path": "output_mint"
7475
+ }
7476
+ ],
7477
+ "program": {
7478
+ "kind": "const",
7479
+ "value": [
7480
+ 140,
7481
+ 151,
7482
+ 37,
7483
+ 143,
7484
+ 78,
7485
+ 36,
7486
+ 137,
7487
+ 241,
7488
+ 187,
7489
+ 61,
7490
+ 16,
7491
+ 41,
7492
+ 20,
7493
+ 142,
7494
+ 13,
7495
+ 131,
7496
+ 11,
7497
+ 90,
7498
+ 19,
7499
+ 153,
7500
+ 218,
7501
+ 255,
7502
+ 16,
7503
+ 132,
7504
+ 4,
7505
+ 142,
7506
+ 123,
7507
+ 216,
7508
+ 219,
7509
+ 233,
7510
+ 248,
7511
+ 89
7512
+ ]
7513
+ }
7514
+ }
7515
+ },
7516
+ {
7517
+ "name": "queue_input_ata",
7518
+ "writable": true,
7519
+ "pda": {
7520
+ "seeds": [
7521
+ {
7522
+ "kind": "account",
7523
+ "path": "withdrawal_queue"
7524
+ },
7525
+ {
7526
+ "kind": "account",
7527
+ "path": "share_token_program"
7528
+ },
7529
+ {
7530
+ "kind": "account",
7531
+ "path": "input_mint"
7532
+ }
7533
+ ],
7534
+ "program": {
7535
+ "kind": "const",
7536
+ "value": [
7537
+ 140,
7538
+ 151,
7539
+ 37,
7540
+ 143,
7541
+ 78,
7542
+ 36,
7543
+ 137,
7544
+ 241,
7545
+ 187,
7546
+ 61,
7547
+ 16,
7548
+ 41,
7549
+ 20,
7550
+ 142,
7551
+ 13,
7552
+ 131,
7553
+ 11,
7554
+ 90,
7555
+ 19,
7556
+ 153,
7557
+ 218,
7558
+ 255,
7559
+ 16,
7560
+ 132,
7561
+ 4,
7562
+ 142,
7563
+ 123,
7564
+ 216,
7565
+ 219,
7566
+ 233,
7567
+ 248,
7568
+ 89
7569
+ ]
7570
+ }
7571
+ }
7572
+ },
7573
+ {
7574
+ "name": "asset_token_program"
7575
+ },
7576
+ {
7577
+ "name": "share_token_program"
7578
+ },
7579
+ {
7580
+ "name": "associated_token_program",
7581
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
7582
+ },
7583
+ {
7584
+ "name": "system_program",
7585
+ "address": "11111111111111111111111111111111"
7586
+ }
7587
+ ],
7588
+ "args": [
7589
+ {
7590
+ "name": "external_withdraw_ix_refs",
7591
+ "type": {
7592
+ "option": {
7593
+ "defined": {
7594
+ "name": "InstructionRefs"
7595
+ }
7596
+ }
7597
+ }
7598
+ },
7599
+ {
7600
+ "name": "external_liquidity_source",
7601
+ "type": {
7602
+ "option": "u8"
7603
+ }
7604
+ }
7605
+ ]
7606
+ },
7344
7607
  {
7345
7608
  "name": "fulfill_junior_tranche_withdraw",
7346
7609
  "discriminator": [
@@ -8607,6 +8870,129 @@ var IDL = {
8607
8870
  }
8608
8871
  ]
8609
8872
  },
8873
+ {
8874
+ "name": "request_async_withdraw",
8875
+ "discriminator": [
8876
+ 90,
8877
+ 83,
8878
+ 61,
8879
+ 227,
8880
+ 146,
8881
+ 51,
8882
+ 252,
8883
+ 225
8884
+ ],
8885
+ "accounts": [
8886
+ {
8887
+ "name": "user",
8888
+ "writable": true,
8889
+ "signer": true
8890
+ },
8891
+ {
8892
+ "name": "payer",
8893
+ "writable": true,
8894
+ "signer": true
8895
+ },
8896
+ {
8897
+ "name": "vault"
8898
+ },
8899
+ {
8900
+ "name": "vault_oracle"
8901
+ },
8902
+ {
8903
+ "name": "withdrawal_queue",
8904
+ "writable": true
8905
+ },
8906
+ {
8907
+ "name": "output_mint"
8908
+ },
8909
+ {
8910
+ "name": "input_mint"
8911
+ },
8912
+ {
8913
+ "name": "user_input_ata",
8914
+ "writable": true
8915
+ },
8916
+ {
8917
+ "name": "queue_input_ata",
8918
+ "writable": true,
8919
+ "pda": {
8920
+ "seeds": [
8921
+ {
8922
+ "kind": "account",
8923
+ "path": "withdrawal_queue"
8924
+ },
8925
+ {
8926
+ "kind": "account",
8927
+ "path": "share_token_program"
8928
+ },
8929
+ {
8930
+ "kind": "account",
8931
+ "path": "input_mint"
8932
+ }
8933
+ ],
8934
+ "program": {
8935
+ "kind": "const",
8936
+ "value": [
8937
+ 140,
8938
+ 151,
8939
+ 37,
8940
+ 143,
8941
+ 78,
8942
+ 36,
8943
+ 137,
8944
+ 241,
8945
+ 187,
8946
+ 61,
8947
+ 16,
8948
+ 41,
8949
+ 20,
8950
+ 142,
8951
+ 13,
8952
+ 131,
8953
+ 11,
8954
+ 90,
8955
+ 19,
8956
+ 153,
8957
+ 218,
8958
+ 255,
8959
+ 16,
8960
+ 132,
8961
+ 4,
8962
+ 142,
8963
+ 123,
8964
+ 216,
8965
+ 219,
8966
+ 233,
8967
+ 248,
8968
+ 89
8969
+ ]
8970
+ }
8971
+ }
8972
+ },
8973
+ {
8974
+ "name": "share_token_program"
8975
+ },
8976
+ {
8977
+ "name": "associated_token_program",
8978
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
8979
+ },
8980
+ {
8981
+ "name": "system_program",
8982
+ "address": "11111111111111111111111111111111"
8983
+ }
8984
+ ],
8985
+ "args": [
8986
+ {
8987
+ "name": "queue_id",
8988
+ "type": "u8"
8989
+ },
8990
+ {
8991
+ "name": "share_amount",
8992
+ "type": "u64"
8993
+ }
8994
+ ]
8995
+ },
8610
8996
  {
8611
8997
  "name": "request_junior_tranche_withdraw",
8612
8998
  "discriminator": [
@@ -11123,6 +11509,26 @@ var IDL = {
11123
11509
  ]
11124
11510
  }
11125
11511
  },
11512
+ {
11513
+ "name": "RedemptionMode",
11514
+ "docs": [
11515
+ "Redemption policy for regular vault shares. Zero preserves existing vault behavior."
11516
+ ],
11517
+ "repr": {
11518
+ "kind": "rust"
11519
+ },
11520
+ "type": {
11521
+ "kind": "enum",
11522
+ "variants": [
11523
+ {
11524
+ "name": "Synchronous"
11525
+ },
11526
+ {
11527
+ "name": "AsyncOnly"
11528
+ }
11529
+ ]
11530
+ }
11531
+ },
11126
11532
  {
11127
11533
  "name": "ReportIncentiveV3Args",
11128
11534
  "type": {
@@ -11582,6 +11988,19 @@ var IDL = {
11582
11988
  }
11583
11989
  }
11584
11990
  }
11991
+ },
11992
+ {
11993
+ "name": "redemption_mode",
11994
+ "docs": [
11995
+ "Regular-share redemption policy. None leaves unchanged."
11996
+ ],
11997
+ "type": {
11998
+ "option": {
11999
+ "defined": {
12000
+ "name": "RedemptionMode"
12001
+ }
12002
+ }
12003
+ }
11585
12004
  }
11586
12005
  ]
11587
12006
  }
@@ -11834,13 +12253,13 @@ var IDL = {
11834
12253
  }
11835
12254
  },
11836
12255
  {
11837
- "name": "_padding_bool",
12256
+ "name": "redemption_mode",
11838
12257
  "docs": [
11839
- "Reserved byte retained for on-chain account layout compatibility."
12258
+ "Regular-share redemption policy; occupies the former zeroed padding byte."
11840
12259
  ],
11841
12260
  "type": {
11842
12261
  "defined": {
11843
- "name": "PodBool"
12262
+ "name": "RedemptionMode"
11844
12263
  }
11845
12264
  }
11846
12265
  },
@@ -12931,7 +13350,7 @@ var IDL = {
12931
13350
  {
12932
13351
  "name": "fulfiller",
12933
13352
  "docs": [
12934
- "Hot wallet authorised to fulfill expired junior withdrawal queues."
13353
+ "Hot wallet authorised to fulfill regular and expired junior withdrawal queues."
12935
13354
  ],
12936
13355
  "type": "pubkey"
12937
13356
  },
@@ -13603,6 +14022,13 @@ var AccountClient = class extends import_common.BaseAccountClient {
13603
14022
  const [vaultOracle] = await this.pda.deriveVaultOraclePda(vault);
13604
14023
  return this.fetchVaultOracle(vaultOracle, opts);
13605
14024
  }
14025
+ /** Fresh discovery read: only an absent oracle returns null; RPC errors propagate. */
14026
+ async fetchVaultOracleForVaultNullable(vault) {
14027
+ const [vaultOracle] = await this.pda.deriveVaultOraclePda(vault);
14028
+ return this.program.account.vaultOracle.fetchNullable(
14029
+ (0, import_common.toWeb3Pk)(vaultOracle)
14030
+ );
14031
+ }
13606
14032
  async fetchVaultTrancheState(vaultTrancheState, opts) {
13607
14033
  if (opts?.fresh) {
13608
14034
  this.dataCache.clearCacheEntry(
@@ -13625,6 +14051,32 @@ var AccountClient = class extends import_common.BaseAccountClient {
13625
14051
  );
13626
14052
  return this.fetchVaultTrancheState(vaultTrancheState, opts);
13627
14053
  }
14054
+ /** Shared queue fetcher, for either regular or junior shares. */
14055
+ async fetchVaultWithdrawalQueue(withdrawalQueue, opts) {
14056
+ return this.fetchVaultTrancheWithdrawalQueue(withdrawalQueue, opts);
14057
+ }
14058
+ /** Fresh pending requests. Fulfilled/cancelled queues are closed on chain. */
14059
+ async fetchAllWithdrawalQueues(opts = {}) {
14060
+ const filters = [
14061
+ ...opts.owner ? [{ memcmp: { offset: 16, bytes: opts.owner } }] : [],
14062
+ ...opts.vault ? [{ memcmp: { offset: 48, bytes: opts.vault } }] : [],
14063
+ ...opts.inputMint ? [{ memcmp: { offset: 112, bytes: opts.inputMint } }] : []
14064
+ ];
14065
+ const queues = await this.program.account.vaultWithdrawalQueue.all(filters);
14066
+ return queues.map(({ publicKey, account }) => ({
14067
+ publicKey: (0, import_common.fromWeb3Pk)(publicKey),
14068
+ account
14069
+ }));
14070
+ }
14071
+ /** All pending regular-share redemptions for a vault, optionally restricted to an owner. */
14072
+ async fetchPendingRedemptionQueues(vault, owner) {
14073
+ const data = await this.fetchVault(vault, { fresh: true });
14074
+ return this.fetchAllWithdrawalQueues({
14075
+ vault,
14076
+ owner,
14077
+ inputMint: (0, import_common.fromWeb3Pk)(data.mint)
14078
+ });
14079
+ }
13628
14080
  async fetchVaultTrancheWithdrawalQueue(withdrawalQueue, opts) {
13629
14081
  if (opts?.fresh) {
13630
14082
  this.dataCache.clearCacheEntry(
@@ -13750,11 +14202,14 @@ var PdaClient = class {
13750
14202
  });
13751
14203
  }
13752
14204
  /**
13753
- * Junior tranche withdrawal queue PDA.
14205
+ * Shared withdrawal queue PDA for regular and junior shares.
13754
14206
  *
13755
14207
  * Seeds: `["vault_withdrawal_queue", vault, owner, queue_id]`
13756
14208
  */
13757
- async deriveVaultTrancheWithdrawalQueuePda(vault, owner, queueId) {
14209
+ async deriveVaultWithdrawalQueuePda(vault, owner, queueId) {
14210
+ if (!Number.isInteger(queueId) || queueId < 0 || queueId > 255) {
14211
+ throw new RangeError("Withdrawal queue ID must fit u8");
14212
+ }
13758
14213
  return (0, import_kit4.getProgramDerivedAddress)({
13759
14214
  programAddress: this.programAddress,
13760
14215
  seeds: [
@@ -13765,6 +14220,10 @@ var PdaClient = class {
13765
14220
  ]
13766
14221
  });
13767
14222
  }
14223
+ /** Backward-compatible alias; queue IDs are shared by both share classes. */
14224
+ async deriveVaultTrancheWithdrawalQueuePda(vault, owner, queueId) {
14225
+ return this.deriveVaultWithdrawalQueuePda(vault, owner, queueId);
14226
+ }
13768
14227
  };
13769
14228
 
13770
14229
  // src/client/quote.ts
@@ -15119,6 +15578,7 @@ function toAnchorSetVaultConfigArgs(args) {
15119
15578
  maxApyBps: args.maxApyBps,
15120
15579
  tvlLimit: args.tvlLimit,
15121
15580
  lossesEnabled: args.lossesEnabled,
15581
+ redemptionMode: args.redemptionMode ?? null,
15122
15582
  priceStalenessThresholdSecs: args.priceStalenessThresholdSecs,
15123
15583
  userBurnLimit: args.userBurnLimit,
15124
15584
  managerPullLimit: args.managerPullLimit,
@@ -15317,6 +15777,7 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
15317
15777
  maxApyBps: txArgs.maxApyBps ?? null,
15318
15778
  tvlLimit: txArgs.tvlLimit !== void 0 ? new import_core7.BN(txArgs.tvlLimit.toString()) : null,
15319
15779
  lossesEnabled: txArgs.lossesEnabled ?? null,
15780
+ redemptionMode: txArgs.redemptionMode ?? null,
15320
15781
  priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new import_core7.BN(txArgs.priceStalenessThresholdSecs.toString()) : null,
15321
15782
  userBurnLimit: txArgs.userBurnLimit !== void 0 ? {
15322
15783
  windowLimit: new import_core7.BN(
@@ -16632,7 +17093,7 @@ async function loadWithdrawalPosition(args) {
16632
17093
  }
16633
17094
 
16634
17095
  // src/client/builders/withdrawalPlan.ts
16635
- function payout(pricing, shares) {
17096
+ function quoteWithdrawalPayout(pricing, shares) {
16636
17097
  const gross = shares * pricing.value / pricing.supply;
16637
17098
  const fee = gross * BigInt(pricing.feeBps) / 10000n;
16638
17099
  const feeShares = shares * BigInt(pricing.feeBps) / 10000n;
@@ -16647,11 +17108,11 @@ function payout(pricing, shares) {
16647
17108
  }
16648
17109
  function isRedeemable(pricing, shares) {
16649
17110
  if (shares <= 0n) return false;
16650
- const quote = payout(pricing, shares);
17111
+ const quote = quoteWithdrawalPayout(pricing, shares);
16651
17112
  return quote.gross > 0n && (quote.net === 0n || quote.tokens > 0n) && (pricing.shareClass !== "regular" || quote.fee === 0n || quote.feeShares > 0n);
16652
17113
  }
16653
17114
  function afterBurn(pricing, shares) {
16654
- const quote = payout(pricing, shares);
17115
+ const quote = quoteWithdrawalPayout(pricing, shares);
16655
17116
  return {
16656
17117
  ...pricing,
16657
17118
  supply: pricing.supply - (pricing.shareClass === "regular" ? shares - quote.feeShares : shares),
@@ -16662,7 +17123,7 @@ function sharesWithinCapacity(pricing, remaining, capacity) {
16662
17123
  let low = 0n, high = remaining;
16663
17124
  while (low < high) {
16664
17125
  const mid = (low + high + 1n) / 2n;
16665
- if (payout(pricing, mid).tokens <= capacity) low = mid;
17126
+ if (quoteWithdrawalPayout(pricing, mid).tokens <= capacity) low = mid;
16666
17127
  else high = mid - 1n;
16667
17128
  }
16668
17129
  const maximum = low;
@@ -16686,7 +17147,7 @@ async function planWithdrawalLegs(args) {
16686
17147
  const pools = /* @__PURE__ */ new Map();
16687
17148
  const positions = /* @__PURE__ */ new Set();
16688
17149
  const append = (shares, position) => {
16689
- const quote = payout(pricing, shares);
17150
+ const quote = quoteWithdrawalPayout(pricing, shares);
16690
17151
  if (!isRedeemable(pricing, shares)) return false;
16691
17152
  const needed = quote.tokens > local ? quote.tokens - local : 0n;
16692
17153
  const receipt = needed > 0n ? position.receipt(needed) : 0n;
@@ -16708,7 +17169,8 @@ async function planWithdrawalLegs(args) {
16708
17169
  remaining -= shares;
16709
17170
  return true;
16710
17171
  };
16711
- if (payout(pricing, remaining).tokens <= local) append(remaining);
17172
+ if (quoteWithdrawalPayout(pricing, remaining).tokens <= local)
17173
+ append(remaining);
16712
17174
  else {
16713
17175
  for await (const position of args.positions) {
16714
17176
  if (positions.has(position.positionKey)) continue;
@@ -16725,7 +17187,7 @@ async function planWithdrawalLegs(args) {
16725
17187
  if (shares > 0n) append(shares, position);
16726
17188
  if (remaining === 0n) break;
16727
17189
  }
16728
- if (remaining > 0n && payout(pricing, remaining).tokens <= local)
17190
+ if (remaining > 0n && quoteWithdrawalPayout(pricing, remaining).tokens <= local)
16729
17191
  append(remaining);
16730
17192
  }
16731
17193
  if (remaining > 0n)
@@ -18131,116 +18593,404 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
18131
18593
  assetTokenProgram,
18132
18594
  true
18133
18595
  ),
18134
- destinationFeeVault,
18135
- destinationFeeVaultMintAta: (0, import_common45.getAtaAddress)(
18136
- txArgs.mint,
18137
- destinationFeeVault,
18138
- assetTokenProgram,
18596
+ destinationFeeVault,
18597
+ destinationFeeVaultMintAta: (0, import_common45.getAtaAddress)(
18598
+ txArgs.mint,
18599
+ destinationFeeVault,
18600
+ assetTokenProgram,
18601
+ true
18602
+ ),
18603
+ allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common45.getAtaAddress)(
18604
+ sourceShareMint,
18605
+ txArgs.allocationVault,
18606
+ sourceShareTokenProgram,
18607
+ true
18608
+ ) : null,
18609
+ allocationDestinationShareAta: (0, import_common45.getAtaAddress)(
18610
+ txArgs.destinationShareMint,
18611
+ txArgs.allocationVault,
18612
+ destinationShareTokenProgram,
18613
+ true
18614
+ )
18615
+ };
18616
+ }
18617
+ async buildPreambleInstructions(args) {
18618
+ const payer = (0, import_common45.toWeb3Pk)(args.manager);
18619
+ const instructions2 = [
18620
+ (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18621
+ payer,
18622
+ (0, import_common45.toWeb3Pk)(args.allocationMintAta),
18623
+ (0, import_common45.toWeb3Pk)(args.allocationVault),
18624
+ (0, import_common45.toWeb3Pk)(args.mint),
18625
+ (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18626
+ import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18627
+ ),
18628
+ (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18629
+ payer,
18630
+ (0, import_common45.toWeb3Pk)(args.destinationVaultMintAta),
18631
+ (0, import_common45.toWeb3Pk)(args.destinationVault),
18632
+ (0, import_common45.toWeb3Pk)(args.mint),
18633
+ (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18634
+ import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18635
+ ),
18636
+ (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18637
+ payer,
18638
+ (0, import_common45.toWeb3Pk)(args.destinationFeeVaultMintAta),
18639
+ (0, import_common45.toWeb3Pk)(args.destinationFeeVault),
18640
+ (0, import_common45.toWeb3Pk)(args.mint),
18641
+ (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18642
+ import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18643
+ ),
18644
+ (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18645
+ payer,
18646
+ (0, import_common45.toWeb3Pk)(args.allocationDestinationShareAta),
18647
+ (0, import_common45.toWeb3Pk)(args.allocationVault),
18648
+ (0, import_common45.toWeb3Pk)(args.destinationShareMint),
18649
+ (0, import_common45.toWeb3Pk)(args.destinationShareTokenProgram),
18650
+ import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18651
+ )
18652
+ ];
18653
+ if (args.sourceVault && args.sourceShareMint && args.sourceVaultMintAta && args.allocationSourceShareAta) {
18654
+ instructions2.push(
18655
+ (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18656
+ payer,
18657
+ (0, import_common45.toWeb3Pk)(args.sourceVaultMintAta),
18658
+ (0, import_common45.toWeb3Pk)(args.sourceVault),
18659
+ (0, import_common45.toWeb3Pk)(args.mint),
18660
+ (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18661
+ import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18662
+ ),
18663
+ (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18664
+ payer,
18665
+ (0, import_common45.toWeb3Pk)(args.allocationSourceShareAta),
18666
+ (0, import_common45.toWeb3Pk)(args.allocationVault),
18667
+ (0, import_common45.toWeb3Pk)(args.sourceShareMint),
18668
+ (0, import_common45.toWeb3Pk)(args.sourceShareTokenProgram),
18669
+ import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18670
+ )
18671
+ );
18672
+ }
18673
+ return instructions2.map(import_common45.toKitInstruction);
18674
+ }
18675
+ async buildPlanExtras(args) {
18676
+ return {
18677
+ postSuccessCacheInvalidations: [
18678
+ { vaultPda: args.allocationVault },
18679
+ { vaultPda: args.destinationVault },
18680
+ ...args.sourceVault ? [{ vaultPda: args.sourceVault }] : [],
18681
+ ...args.sourceVault && args.sourceVaultTrancheState ? [
18682
+ {
18683
+ vaultPda: args.sourceVault,
18684
+ vaultTrancheStatePda: args.sourceVaultTrancheState
18685
+ }
18686
+ ] : [],
18687
+ ...args.destinationVaultTrancheState ? [
18688
+ {
18689
+ vaultPda: args.destinationVault,
18690
+ vaultTrancheStatePda: args.destinationVaultTrancheState
18691
+ }
18692
+ ] : []
18693
+ ]
18694
+ };
18695
+ }
18696
+ async getTx(txArgs) {
18697
+ const args = await this.deriveIxArgs(txArgs);
18698
+ const preambleInstructions = await this.buildPreambleInstructions(args);
18699
+ const instruction = await this.getIx(args);
18700
+ const extras = await this.buildPlanExtras(args);
18701
+ return this.withVaultLookupTables({
18702
+ instructions: [...preambleInstructions, instruction],
18703
+ ...extras
18704
+ });
18705
+ }
18706
+ };
18707
+
18708
+ // src/client/builders/requestAsyncWithdraw.ts
18709
+ var import_core21 = require("@anchor-lang/core");
18710
+ var import_spl_token21 = require("@solana/spl-token");
18711
+ var import_web327 = require("@solana/web3.js");
18712
+ var import_common46 = __toESM(require_dist());
18713
+ var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
18714
+ async getIx(args) {
18715
+ return this.program.methods.requestAsyncWithdraw(args.queueId, args.shareAmount).accountsPartial({
18716
+ user: (0, import_common46.toWeb3Pk)(args.user),
18717
+ payer: (0, import_common46.toWeb3Pk)(args.payer),
18718
+ vault: (0, import_common46.toWeb3Pk)(args.vault),
18719
+ vaultOracle: (0, import_common46.toWeb3Pk)(args.vaultOracle),
18720
+ withdrawalQueue: (0, import_common46.toWeb3Pk)(args.withdrawalQueue),
18721
+ outputMint: (0, import_common46.toWeb3Pk)(args.outputMint),
18722
+ inputMint: (0, import_common46.toWeb3Pk)(args.inputMint),
18723
+ userInputAta: (0, import_common46.toWeb3Pk)(args.userInputAta),
18724
+ queueInputAta: (0, import_common46.toWeb3Pk)(args.queueInputAta),
18725
+ shareTokenProgram: (0, import_common46.toWeb3Pk)(args.shareTokenProgram),
18726
+ associatedTokenProgram: import_spl_token21.ASSOCIATED_TOKEN_PROGRAM_ID,
18727
+ systemProgram: import_web327.SystemProgram.programId
18728
+ }).instruction().then(import_common46.toKitInstruction);
18729
+ }
18730
+ async deriveIxArgs(txArgs) {
18731
+ const payer = txArgs.payer ?? txArgs.user;
18732
+ const [[vaultOracle], [withdrawalQueue], shareTokenProgram, vaultData] = await Promise.all([
18733
+ this.pda.deriveVaultOraclePda(txArgs.vault),
18734
+ this.pda.deriveVaultWithdrawalQueuePda(
18735
+ txArgs.vault,
18736
+ txArgs.user,
18737
+ txArgs.queueId
18738
+ ),
18739
+ resolveVaultShareTokenProgram(
18740
+ this.account,
18741
+ txArgs.vault,
18742
+ txArgs.shareTokenProgram
18743
+ ),
18744
+ this.account.fetchVault(txArgs.vault)
18745
+ ]);
18746
+ const shareMint = txArgs.shareMint ?? (0, import_common46.fromWeb3Pk)(vaultData.mint);
18747
+ const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
18748
+ return {
18749
+ user: txArgs.user,
18750
+ payer,
18751
+ vault: txArgs.vault,
18752
+ vaultOracle: txArgs.vaultOracle ?? vaultOracle,
18753
+ withdrawalQueue: queuePda,
18754
+ outputMint: txArgs.assetMint,
18755
+ inputMint: shareMint,
18756
+ queueId: txArgs.queueId,
18757
+ shareAmount: new import_core21.BN(txArgs.shareAmount.toString()),
18758
+ shareTokenProgram,
18759
+ userInputAta: txArgs.userInputAta ?? (0, import_common46.getAtaAddress)(shareMint, txArgs.user, shareTokenProgram, true),
18760
+ queueInputAta: (0, import_common46.getAtaAddress)(
18761
+ shareMint,
18762
+ queuePda,
18763
+ shareTokenProgram,
18764
+ true
18765
+ )
18766
+ };
18767
+ }
18768
+ async buildPlanExtras(args) {
18769
+ return {
18770
+ postSuccessCacheInvalidations: [
18771
+ {
18772
+ vaultPda: args.vault,
18773
+ withdrawalQueuePda: args.withdrawalQueue
18774
+ }
18775
+ ]
18776
+ };
18777
+ }
18778
+ };
18779
+
18780
+ // src/client/builders/fulfillAsyncWithdraw.ts
18781
+ var import_spl_token22 = require("@solana/spl-token");
18782
+ var import_web328 = require("@solana/web3.js");
18783
+ var import_common47 = __toESM(require_dist());
18784
+ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
18785
+ async getIx(args) {
18786
+ const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
18787
+ const externalLiquiditySource = args.externalLiquiditySource ?? null;
18788
+ const methods = this.program.methods.fulfillAsyncWithdraw(
18789
+ externalWithdrawIxRefs,
18790
+ externalLiquiditySource
18791
+ );
18792
+ return methods.accountsPartial({
18793
+ signer: (0, import_common47.toWeb3Pk)(args.signer),
18794
+ owner: (0, import_common47.toWeb3Pk)(args.owner),
18795
+ queuePayer: (0, import_common47.toWeb3Pk)(args.queuePayer),
18796
+ vault: (0, import_common47.toWeb3Pk)(args.vault),
18797
+ vaultOracle: (0, import_common47.toWeb3Pk)(args.vaultOracle),
18798
+ vaultTrancheState: args.vaultTrancheState ? (0, import_common47.toWeb3Pk)(args.vaultTrancheState) : null,
18799
+ withdrawalQueue: (0, import_common47.toWeb3Pk)(args.withdrawalQueue),
18800
+ outputMint: (0, import_common47.toWeb3Pk)(args.outputMint),
18801
+ inputMint: (0, import_common47.toWeb3Pk)(args.inputMint),
18802
+ ownerInputAta: (0, import_common47.toWeb3Pk)(args.ownerInputAta),
18803
+ ownerOutputAta: (0, import_common47.toWeb3Pk)(args.ownerOutputAta),
18804
+ vaultOutputAta: (0, import_common47.toWeb3Pk)(args.vaultOutputAta),
18805
+ queueInputAta: (0, import_common47.toWeb3Pk)(args.queueInputAta),
18806
+ assetTokenProgram: (0, import_common47.toWeb3Pk)(args.assetTokenProgram),
18807
+ shareTokenProgram: (0, import_common47.toWeb3Pk)(args.shareTokenProgram),
18808
+ associatedTokenProgram: import_spl_token22.ASSOCIATED_TOKEN_PROGRAM_ID,
18809
+ systemProgram: import_web328.SystemProgram.programId
18810
+ }).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common47.toKitInstruction);
18811
+ }
18812
+ async deriveIxArgs(txArgs) {
18813
+ const connection = this.program.provider.connection;
18814
+ const signer = txArgs.signer;
18815
+ const [
18816
+ [vaultOracle],
18817
+ vaultTrancheState,
18818
+ [withdrawalQueue],
18819
+ assetTokenProgram,
18820
+ shareTokenProgram,
18821
+ vaultData
18822
+ ] = await Promise.all([
18823
+ this.pda.deriveVaultOraclePda(txArgs.vault),
18824
+ resolveVaultTrancheState(
18825
+ this.account,
18826
+ this.pda,
18827
+ txArgs.vault,
18828
+ txArgs.vaultTrancheState
18829
+ ),
18830
+ this.pda.deriveVaultWithdrawalQueuePda(
18831
+ txArgs.vault,
18832
+ txArgs.owner,
18833
+ txArgs.queueId
18834
+ ),
18835
+ resolveHoldingTokenProgram(
18836
+ this.account,
18837
+ connection,
18838
+ txArgs.vault,
18839
+ txArgs.assetMint,
18840
+ txArgs.assetTokenProgram
18841
+ ),
18842
+ resolveVaultShareTokenProgram(
18843
+ this.account,
18844
+ txArgs.vault,
18845
+ txArgs.shareTokenProgram
18846
+ ),
18847
+ this.account.fetchVault(txArgs.vault, { fresh: true })
18848
+ ]);
18849
+ const shareMint = txArgs.shareMint ?? (0, import_common47.fromWeb3Pk)(vaultData.mint);
18850
+ const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
18851
+ const queue = await this.account.fetchVaultWithdrawalQueue(queuePda, {
18852
+ fresh: true
18853
+ });
18854
+ const queuePayer = txArgs.queuePayer ?? (0, import_common47.fromWeb3Pk)(queue.parties.payer);
18855
+ const vaultOutputAta = (0, import_common47.getAtaAddress)(
18856
+ txArgs.assetMint,
18857
+ txArgs.vault,
18858
+ assetTokenProgram,
18859
+ true
18860
+ );
18861
+ let skipExternalLiquidity = txArgs.skipExternalLiquidity ?? false;
18862
+ if (!txArgs.externalWithdrawIxRefs && !skipExternalLiquidity) {
18863
+ const [localAmount, tranche] = await Promise.all([
18864
+ readTokenBalance(connection, vaultOutputAta, assetTokenProgram),
18865
+ vaultTrancheState ? this.account.fetchVaultTrancheState(vaultTrancheState, {
18866
+ fresh: true
18867
+ }) : null
18868
+ ]);
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;
18893
+ }
18894
+ const {
18895
+ externalWithdrawIxRefs,
18896
+ externalLiquiditySource,
18897
+ externalWithdrawAccounts
18898
+ } = skipExternalLiquidity && !txArgs.externalWithdrawIxRefs ? {
18899
+ externalWithdrawIxRefs: null,
18900
+ externalLiquiditySource: null,
18901
+ externalWithdrawAccounts: []
18902
+ } : await resolveExternalWithdraw({
18903
+ connection,
18904
+ externalLiquidity: vaultData.externalLiquidity,
18905
+ vault: txArgs.vault,
18906
+ assetMint: txArgs.assetMint,
18907
+ vaultAssetAta: vaultOutputAta,
18908
+ overrides: txArgs
18909
+ });
18910
+ return {
18911
+ signer,
18912
+ owner: txArgs.owner,
18913
+ queuePayer,
18914
+ vault: txArgs.vault,
18915
+ vaultOracle: txArgs.vaultOracle ?? vaultOracle,
18916
+ vaultTrancheState: vaultTrancheState ?? null,
18917
+ withdrawalQueue: queuePda,
18918
+ outputMint: txArgs.assetMint,
18919
+ inputMint: shareMint,
18920
+ assetTokenProgram,
18921
+ shareTokenProgram,
18922
+ ownerInputAta: txArgs.ownerInputAta ?? (0, import_common47.getAtaAddress)(shareMint, txArgs.owner, shareTokenProgram, true),
18923
+ ownerOutputAta: (0, import_common47.getAtaAddress)(
18924
+ txArgs.assetMint,
18925
+ txArgs.owner,
18926
+ assetTokenProgram,
18927
+ true
18928
+ ),
18929
+ vaultOutputAta,
18930
+ queueInputAta: (0, import_common47.getAtaAddress)(
18931
+ shareMint,
18932
+ queuePda,
18933
+ shareTokenProgram,
18139
18934
  true
18140
18935
  ),
18141
- allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common45.getAtaAddress)(
18142
- sourceShareMint,
18143
- txArgs.allocationVault,
18144
- sourceShareTokenProgram,
18145
- true
18146
- ) : null,
18147
- allocationDestinationShareAta: (0, import_common45.getAtaAddress)(
18148
- txArgs.destinationShareMint,
18149
- txArgs.allocationVault,
18150
- destinationShareTokenProgram,
18151
- true
18152
- )
18936
+ externalWithdrawIxRefs,
18937
+ externalLiquiditySource,
18938
+ externalWithdrawAccounts
18153
18939
  };
18154
18940
  }
18941
+ async buildLookupTables(args, txArgs) {
18942
+ return externalWithdrawLookupTables(
18943
+ args.externalWithdrawIxRefs,
18944
+ txArgs.lookupTables
18945
+ );
18946
+ }
18155
18947
  async buildPreambleInstructions(args) {
18156
- const payer = (0, import_common45.toWeb3Pk)(args.manager);
18157
- const instructions2 = [
18158
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18159
- payer,
18160
- (0, import_common45.toWeb3Pk)(args.allocationMintAta),
18161
- (0, import_common45.toWeb3Pk)(args.allocationVault),
18162
- (0, import_common45.toWeb3Pk)(args.mint),
18163
- (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18164
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18165
- ),
18166
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18167
- payer,
18168
- (0, import_common45.toWeb3Pk)(args.destinationVaultMintAta),
18169
- (0, import_common45.toWeb3Pk)(args.destinationVault),
18170
- (0, import_common45.toWeb3Pk)(args.mint),
18171
- (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18172
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18173
- ),
18174
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18175
- payer,
18176
- (0, import_common45.toWeb3Pk)(args.destinationFeeVaultMintAta),
18177
- (0, import_common45.toWeb3Pk)(args.destinationFeeVault),
18178
- (0, import_common45.toWeb3Pk)(args.mint),
18179
- (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18180
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18181
- ),
18182
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18183
- payer,
18184
- (0, import_common45.toWeb3Pk)(args.allocationDestinationShareAta),
18185
- (0, import_common45.toWeb3Pk)(args.allocationVault),
18186
- (0, import_common45.toWeb3Pk)(args.destinationShareMint),
18187
- (0, import_common45.toWeb3Pk)(args.destinationShareTokenProgram),
18188
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18189
- )
18948
+ const defaultOwnerInputAta = (0, import_common47.getAtaAddress)(
18949
+ args.inputMint,
18950
+ args.owner,
18951
+ args.shareTokenProgram,
18952
+ true
18953
+ );
18954
+ const atas = [
18955
+ {
18956
+ mint: args.outputMint,
18957
+ ata: args.ownerOutputAta,
18958
+ program: args.assetTokenProgram
18959
+ }
18190
18960
  ];
18191
- if (args.sourceVault && args.sourceShareMint && args.sourceVaultMintAta && args.allocationSourceShareAta) {
18192
- instructions2.push(
18193
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18194
- payer,
18195
- (0, import_common45.toWeb3Pk)(args.sourceVaultMintAta),
18196
- (0, import_common45.toWeb3Pk)(args.sourceVault),
18197
- (0, import_common45.toWeb3Pk)(args.mint),
18198
- (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18199
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18200
- ),
18201
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18202
- payer,
18203
- (0, import_common45.toWeb3Pk)(args.allocationSourceShareAta),
18204
- (0, import_common45.toWeb3Pk)(args.allocationVault),
18205
- (0, import_common45.toWeb3Pk)(args.sourceShareMint),
18206
- (0, import_common45.toWeb3Pk)(args.sourceShareTokenProgram),
18207
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18208
- )
18209
- );
18961
+ if ((0, import_common47.toWeb3Pk)(args.ownerInputAta).equals((0, import_common47.toWeb3Pk)(defaultOwnerInputAta))) {
18962
+ atas.push({
18963
+ mint: args.inputMint,
18964
+ ata: args.ownerInputAta,
18965
+ program: args.shareTokenProgram
18966
+ });
18210
18967
  }
18211
- return instructions2.map(import_common45.toKitInstruction);
18968
+ return [
18969
+ ...externalWithdrawComputeBudget(args.externalWithdrawIxRefs),
18970
+ ...atas.map(
18971
+ ({ mint, ata, program }) => (0, import_common47.toKitInstruction)(
18972
+ (0, import_spl_token22.createAssociatedTokenAccountIdempotentInstruction)(
18973
+ (0, import_common47.toWeb3Pk)(args.signer),
18974
+ (0, import_common47.toWeb3Pk)(ata),
18975
+ (0, import_common47.toWeb3Pk)(args.owner),
18976
+ (0, import_common47.toWeb3Pk)(mint),
18977
+ (0, import_common47.toWeb3Pk)(program)
18978
+ )
18979
+ )
18980
+ )
18981
+ ];
18212
18982
  }
18213
18983
  async buildPlanExtras(args) {
18214
18984
  return {
18215
18985
  postSuccessCacheInvalidations: [
18216
- { vaultPda: args.allocationVault },
18217
- { vaultPda: args.destinationVault },
18218
- ...args.sourceVault ? [{ vaultPda: args.sourceVault }] : [],
18219
- ...args.sourceVault && args.sourceVaultTrancheState ? [
18220
- {
18221
- vaultPda: args.sourceVault,
18222
- vaultTrancheStatePda: args.sourceVaultTrancheState
18223
- }
18224
- ] : [],
18225
- ...args.destinationVaultTrancheState ? [
18226
- {
18227
- vaultPda: args.destinationVault,
18228
- vaultTrancheStatePda: args.destinationVaultTrancheState
18229
- }
18230
- ] : []
18986
+ {
18987
+ vaultPda: args.vault,
18988
+ vaultTrancheStatePda: args.vaultTrancheState ?? void 0,
18989
+ withdrawalQueuePda: args.withdrawalQueue
18990
+ }
18231
18991
  ]
18232
18992
  };
18233
18993
  }
18234
- async getTx(txArgs) {
18235
- const args = await this.deriveIxArgs(txArgs);
18236
- const preambleInstructions = await this.buildPreambleInstructions(args);
18237
- const instruction = await this.getIx(args);
18238
- const extras = await this.buildPlanExtras(args);
18239
- return this.withVaultLookupTables({
18240
- instructions: [...preambleInstructions, instruction],
18241
- ...extras
18242
- });
18243
- }
18244
18994
  };
18245
18995
 
18246
18996
  // src/client/transaction.ts
@@ -18288,6 +19038,8 @@ var TransactionClient = class {
18288
19038
  this.fulfillJuniorTrancheWithdraw = new FulfillJuniorTrancheWithdrawBuilder(
18289
19039
  context
18290
19040
  );
19041
+ this.requestAsyncWithdraw = new RequestAsyncWithdrawBuilder(context);
19042
+ this.fulfillAsyncWithdraw = new FulfillAsyncWithdrawBuilder(context);
18291
19043
  this.executeWithdraw = new ExecuteWithdrawBuilder(context);
18292
19044
  this.managerWithdrawAsset = new ManagerWithdrawAssetBuilder(context);
18293
19045
  this.managerRedepositAsset = new ManagerRedepositAssetBuilder(context);
@@ -18308,7 +19060,7 @@ var VaultClient = class {
18308
19060
  this.skipSimulation = options.skipSimulation ?? false;
18309
19061
  this.vaultLookupTables = options.vaultLookupTables;
18310
19062
  const idl = { ...IDL, address: programId };
18311
- this.program = new import_core21.Program(idl, provider);
19063
+ this.program = new import_core22.Program(idl, provider);
18312
19064
  this.pda = new PdaClient((0, import_kit10.address)(this.program.programId.toBase58()));
18313
19065
  const rpc = createRpcFromConnection(provider.connection);
18314
19066
  this.account = new AccountClient(this.program, this.pda, rpc);
@@ -18336,15 +19088,15 @@ var VaultClient = class {
18336
19088
  this.vaultLookupTables
18337
19089
  );
18338
19090
  const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
18339
- const instructions2 = plan.instructions.map(import_common46.fromKitInstruction);
19091
+ const instructions2 = plan.instructions.map(import_common48.fromKitInstruction);
18340
19092
  let tx;
18341
19093
  if (plan.lookupTables?.length) {
18342
- const tables = await (0, import_common46.fetchLookupTables)(
19094
+ const tables = await (0, import_common48.fetchLookupTables)(
18343
19095
  this.provider.connection,
18344
19096
  plan.lookupTables
18345
19097
  );
18346
- tx = new import_web327.VersionedTransaction(
18347
- new import_web327.TransactionMessage({
19098
+ tx = new import_web329.VersionedTransaction(
19099
+ new import_web329.TransactionMessage({
18348
19100
  payerKey: payer.publicKey,
18349
19101
  recentBlockhash: blockhash,
18350
19102
  instructions: instructions2
@@ -18352,7 +19104,7 @@ var VaultClient = class {
18352
19104
  );
18353
19105
  tx.sign([payer, ...extraSigners]);
18354
19106
  } else {
18355
- tx = new import_web327.Transaction().add(...instructions2);
19107
+ tx = new import_web329.Transaction().add(...instructions2);
18356
19108
  tx.feePayer = payer.publicKey;
18357
19109
  tx.recentBlockhash = blockhash;
18358
19110
  tx.sign(payer, ...extraSigners);
@@ -18391,13 +19143,13 @@ var VaultClient = class {
18391
19143
  const { blockhash } = await this.provider.connection.getLatestBlockhash(
18392
19144
  "confirmed"
18393
19145
  );
18394
- const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common46.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
18395
- const message2 = new import_web327.TransactionMessage({
19146
+ const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common48.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
19147
+ const message2 = new import_web329.TransactionMessage({
18396
19148
  payerKey: payer.publicKey,
18397
19149
  recentBlockhash: blockhash,
18398
- instructions: plan.instructions.map(import_common46.fromKitInstruction)
19150
+ instructions: plan.instructions.map(import_common48.fromKitInstruction)
18399
19151
  }).compileToV0Message(lookupTableAccounts);
18400
- const tx = new import_web327.VersionedTransaction(message2);
19152
+ const tx = new import_web329.VersionedTransaction(message2);
18401
19153
  const result = await this.provider.connection.simulateTransaction(tx, {
18402
19154
  sigVerify: false,
18403
19155
  commitment: "processed"
@@ -18471,7 +19223,7 @@ function resolveKeypairPath(keypairPath) {
18471
19223
  }
18472
19224
  function loadKeypair(keypairPath) {
18473
19225
  const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
18474
- return import_web328.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
19226
+ return import_web330.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
18475
19227
  }
18476
19228
  var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
18477
19229
  function defaultKeypairPath(env, role = "vault") {
@@ -18482,8 +19234,8 @@ function defaultKeypairPath(env, role = "vault") {
18482
19234
  }
18483
19235
  function createVaultClient(env, opts = {}) {
18484
19236
  const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
18485
- const connection = new import_web328.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
18486
- const provider = new import_core22.AnchorProvider(connection, new import_core22.Wallet(payer), {
19237
+ const connection = new import_web330.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
19238
+ const provider = new import_core23.AnchorProvider(connection, new import_core23.Wallet(payer), {
18487
19239
  commitment: "confirmed"
18488
19240
  });
18489
19241
  const client = new VaultClient(
@@ -18499,11 +19251,11 @@ function createVaultClient(env, opts = {}) {
18499
19251
  client,
18500
19252
  provider,
18501
19253
  payer,
18502
- signer: (0, import_common47.fromWeb3Pk)(payer.publicKey)
19254
+ signer: (0, import_common49.fromWeb3Pk)(payer.publicKey)
18503
19255
  };
18504
19256
  }
18505
19257
  function keypairAddress(keypairPath) {
18506
- return (0, import_common47.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
19258
+ return (0, import_common49.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
18507
19259
  }
18508
19260
 
18509
19261
  // src/utils/math.ts
@@ -18517,16 +19269,16 @@ function fromUiAmount(amount, decimals) {
18517
19269
  }
18518
19270
 
18519
19271
  // src/utils/provider.ts
18520
- var import_core23 = require("@anchor-lang/core");
19272
+ var import_core24 = require("@anchor-lang/core");
18521
19273
  function makeProvider(connection, payer) {
18522
- return new import_core23.AnchorProvider(connection, new import_core23.Wallet(payer), {
19274
+ return new import_core24.AnchorProvider(connection, new import_core24.Wallet(payer), {
18523
19275
  commitment: "confirmed"
18524
19276
  });
18525
19277
  }
18526
19278
 
18527
19279
  // src/utils/squads.ts
18528
19280
  var squads = __toESM(require("@sqds/multisig"));
18529
- var import_web329 = require("@solana/web3.js");
19281
+ var import_web331 = require("@solana/web3.js");
18530
19282
  var SQUADS_SIMULATION_COMMITMENT = "processed";
18531
19283
  var SquadsProposalExecutionSimulationError = class extends Error {
18532
19284
  constructor(transactionError, logs, unitsConsumed) {
@@ -18550,8 +19302,8 @@ function validateVaultIndex(vaultIndex) {
18550
19302
  }
18551
19303
  function resolveSquadsWalletRoute(route) {
18552
19304
  validateVaultIndex(route.vaultIndex);
18553
- const wallet = new import_web329.PublicKey(route.wallet);
18554
- const multisigPda = new import_web329.PublicKey(route.multisigPda);
19305
+ const wallet = new import_web331.PublicKey(route.wallet);
19306
+ const multisigPda = new import_web331.PublicKey(route.multisigPda);
18555
19307
  const [vaultPda] = squads.getVaultPda({
18556
19308
  multisigPda,
18557
19309
  index: route.vaultIndex
@@ -18559,7 +19311,7 @@ function resolveSquadsWalletRoute(route) {
18559
19311
  return { ...route, wallet, multisigPda, vaultPda };
18560
19312
  }
18561
19313
  function findSquadsWalletRoute(wallet, routes) {
18562
- const walletKey = typeof wallet === "string" ? new import_web329.PublicKey(wallet) : wallet;
19314
+ const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
18563
19315
  const route = routes.find(
18564
19316
  (candidate) => candidate.wallet === walletKey.toBase58()
18565
19317
  );
@@ -18577,18 +19329,18 @@ function validateSquadsWalletRoutes(routes) {
18577
19329
  }
18578
19330
  }
18579
19331
  function vaultAuthorityForWallet(wallet, routes) {
18580
- const walletKey = typeof wallet === "string" ? new import_web329.PublicKey(wallet) : wallet;
19332
+ const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
18581
19333
  return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
18582
19334
  }
18583
19335
  async function simulateSquadsProposalExecution(args) {
18584
19336
  const { connection, feePayer, instructions: instructions2 } = args;
18585
19337
  const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
18586
- const message2 = new import_web329.TransactionMessage({
19338
+ const message2 = new import_web331.TransactionMessage({
18587
19339
  payerKey: feePayer,
18588
19340
  recentBlockhash,
18589
19341
  instructions: [...instructions2]
18590
19342
  }).compileToV0Message(args.addressLookupTableAccounts);
18591
- const transaction = new import_web329.VersionedTransaction(message2);
19343
+ const transaction = new import_web331.VersionedTransaction(message2);
18592
19344
  const { value } = await connection.simulateTransaction(transaction, {
18593
19345
  sigVerify: false,
18594
19346
  commitment: SQUADS_SIMULATION_COMMITMENT,
@@ -18613,7 +19365,7 @@ async function prepareVaultTransaction(args) {
18613
19365
  throw new Error("Ephemeral signers require a Squads route");
18614
19366
  return {
18615
19367
  kind: "direct",
18616
- transaction: new import_web329.Transaction().add(...instructions2),
19368
+ transaction: new import_web331.Transaction().add(...instructions2),
18617
19369
  authority: proposer
18618
19370
  };
18619
19371
  }
@@ -18666,7 +19418,7 @@ async function prepareVaultTransaction(args) {
18666
19418
  });
18667
19419
  if (replacements.size) {
18668
19420
  instructions2 = instructions2.map(
18669
- (ix) => new import_web329.TransactionInstruction({
19421
+ (ix) => new import_web331.TransactionInstruction({
18670
19422
  programId: ix.programId,
18671
19423
  data: ix.data,
18672
19424
  keys: ix.keys.map((meta) => ({
@@ -18694,7 +19446,7 @@ async function prepareVaultTransaction(args) {
18694
19446
  executionSimulationError = error;
18695
19447
  }
18696
19448
  }
18697
- const transactionMessage = new import_web329.TransactionMessage({
19449
+ const transactionMessage = new import_web331.TransactionMessage({
18698
19450
  payerKey: route.vaultPda,
18699
19451
  recentBlockhash: blockhash,
18700
19452
  instructions: [...instructions2]
@@ -18724,7 +19476,7 @@ async function prepareVaultTransaction(args) {
18724
19476
  });
18725
19477
  return {
18726
19478
  kind: "squads",
18727
- transaction: new import_web329.Transaction().add(
19479
+ transaction: new import_web331.Transaction().add(
18728
19480
  createVaultTransactionIx,
18729
19481
  createProposalIx
18730
19482
  ),
@@ -18740,16 +19492,16 @@ async function prepareVaultTransaction(args) {
18740
19492
 
18741
19493
  // src/utils/squadsBuffer.ts
18742
19494
  var squads2 = __toESM(require("@sqds/multisig"));
18743
- var import_web330 = require("@solana/web3.js");
19495
+ var import_web332 = require("@solana/web3.js");
18744
19496
  var PacketSize = 1232;
18745
19497
  var BufferChunkSize = 700;
18746
19498
  var MaxBufferSize = 4e3;
18747
19499
  async function prepareSquadsProposalUpload(args) {
18748
19500
  const { connection, proposer, prepared } = args;
18749
19501
  const transaction = prepared.transaction;
18750
- const sizeProbe = new import_web330.Transaction({
19502
+ const sizeProbe = new import_web332.Transaction({
18751
19503
  feePayer: proposer,
18752
- recentBlockhash: import_web330.PublicKey.default.toBase58()
19504
+ recentBlockhash: import_web332.PublicKey.default.toBase58()
18753
19505
  }).add(...transaction.instructions);
18754
19506
  let fits = false;
18755
19507
  try {
@@ -18769,7 +19521,7 @@ async function prepareSquadsProposalUpload(args) {
18769
19521
  let bufferPda;
18770
19522
  let bufferIndex = 0;
18771
19523
  for (; bufferIndex <= 255; bufferIndex++) {
18772
- const [candidate] = import_web330.PublicKey.findProgramAddressSync(
19524
+ const [candidate] = import_web332.PublicKey.findProgramAddressSync(
18773
19525
  [
18774
19526
  Buffer.from("multisig"),
18775
19527
  prepared.multisigPda.toBuffer(),
@@ -18797,7 +19549,7 @@ async function prepareSquadsProposalUpload(args) {
18797
19549
  creator: proposer
18798
19550
  };
18799
19551
  const setupTransactions = [
18800
- new import_web330.Transaction().add(
19552
+ new import_web332.Transaction().add(
18801
19553
  squads2.generated.createTransactionBufferCreateInstruction(
18802
19554
  {
18803
19555
  ...accounts2,
@@ -18817,7 +19569,7 @@ async function prepareSquadsProposalUpload(args) {
18817
19569
  ];
18818
19570
  for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
18819
19571
  setupTransactions.push(
18820
- new import_web330.Transaction().add(
19572
+ new import_web332.Transaction().add(
18821
19573
  squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
18822
19574
  args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
18823
19575
  })
@@ -18830,7 +19582,7 @@ async function prepareSquadsProposalUpload(args) {
18830
19582
  vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
18831
19583
  vaultTransactionCreateItemCreator: proposer,
18832
19584
  vaultTransactionCreateItemRentPayer: proposer,
18833
- vaultTransactionCreateItemSystemProgram: import_web330.SystemProgram.programId,
19585
+ vaultTransactionCreateItemSystemProgram: import_web332.SystemProgram.programId,
18834
19586
  transactionBuffer: bufferPda,
18835
19587
  creator: proposer
18836
19588
  },
@@ -18842,7 +19594,7 @@ async function prepareSquadsProposalUpload(args) {
18842
19594
  ).isWritable = true;
18843
19595
  return {
18844
19596
  setupTransactions,
18845
- proposalTransaction: new import_web330.Transaction().add(
19597
+ proposalTransaction: new import_web332.Transaction().add(
18846
19598
  finalize,
18847
19599
  ...transaction.instructions.slice(1)
18848
19600
  ),
@@ -18852,21 +19604,21 @@ async function prepareSquadsProposalUpload(args) {
18852
19604
  }
18853
19605
 
18854
19606
  // src/utils/token.ts
18855
- var import_spl_token21 = require("@solana/spl-token");
18856
- var import_web331 = require("@solana/web3.js");
18857
- var import_common48 = __toESM(require_dist());
18858
- async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token21.TOKEN_2022_PROGRAM_ID) {
18859
- const mint = import_web331.Keypair.generate();
18860
- const lamports = await (0, import_spl_token21.getMinimumBalanceForRentExemptMint)(connection);
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);
18861
19613
  const ixs = [
18862
- import_web331.SystemProgram.createAccount({
19614
+ import_web333.SystemProgram.createAccount({
18863
19615
  fromPubkey: payer,
18864
19616
  newAccountPubkey: mint.publicKey,
18865
- space: import_spl_token21.MINT_SIZE,
19617
+ space: import_spl_token23.MINT_SIZE,
18866
19618
  lamports,
18867
19619
  programId: tokenProgram
18868
19620
  }),
18869
- (0, import_spl_token21.createInitializeMint2Instruction)(
19621
+ (0, import_spl_token23.createInitializeMint2Instruction)(
18870
19622
  mint.publicKey,
18871
19623
  decimals,
18872
19624
  authority,
@@ -18876,7 +19628,7 @@ async function createTokenMintIxs(connection, payer, authority, decimals, tokenP
18876
19628
  ];
18877
19629
  return { mint, ixs };
18878
19630
  }
18879
- async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token21.TOKEN_2022_PROGRAM_ID) {
19631
+ async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token23.TOKEN_2022_PROGRAM_ID) {
18880
19632
  const { mint, ixs } = await createTokenMintIxs(
18881
19633
  connection,
18882
19634
  payer.publicKey,
@@ -18885,7 +19637,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
18885
19637
  tokenProgram
18886
19638
  );
18887
19639
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
18888
- const tx = new import_web331.Transaction().add(...ixs);
19640
+ const tx = new import_web333.Transaction().add(...ixs);
18889
19641
  tx.feePayer = payer.publicKey;
18890
19642
  tx.recentBlockhash = blockhash;
18891
19643
  tx.sign(payer, mint);
@@ -18898,24 +19650,24 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
18898
19650
  );
18899
19651
  return mint.publicKey;
18900
19652
  }
18901
- async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token21.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
18902
- const tokenProgramPk = (0, import_common48.asWeb3PublicKey)(tokenProgram);
18903
- const ata = (0, import_spl_token21.getAssociatedTokenAddressSync)(
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)(
18904
19656
  mint,
18905
19657
  destination,
18906
19658
  allowOwnerOffCurve,
18907
19659
  tokenProgramPk
18908
19660
  );
18909
19661
  const ixs = [
18910
- (0, import_spl_token21.createAssociatedTokenAccountIdempotentInstruction)(
19662
+ (0, import_spl_token23.createAssociatedTokenAccountIdempotentInstruction)(
18911
19663
  payer.publicKey,
18912
19664
  ata,
18913
19665
  destination,
18914
19666
  mint,
18915
19667
  tokenProgramPk,
18916
- import_spl_token21.ASSOCIATED_TOKEN_PROGRAM_ID
19668
+ import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID
18917
19669
  ),
18918
- (0, import_spl_token21.createMintToInstruction)(
19670
+ (0, import_spl_token23.createMintToInstruction)(
18919
19671
  mint,
18920
19672
  ata,
18921
19673
  payer.publicKey,
@@ -18924,12 +19676,12 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
18924
19676
  tokenProgramPk
18925
19677
  )
18926
19678
  ];
18927
- const tx = new import_web331.Transaction().add(...ixs);
19679
+ const tx = new import_web333.Transaction().add(...ixs);
18928
19680
  await connection.sendTransaction(tx, [payer]);
18929
19681
  }
18930
19682
 
18931
19683
  // src/utils/yieldApi.ts
18932
- var import_core24 = require("@anchor-lang/core");
19684
+ var import_core25 = require("@anchor-lang/core");
18933
19685
  var YIELD_API_BASE = process.env.YIELD_API_BASE ?? "https://yield-tracker.perena.org";
18934
19686
  async function yieldApiReq(endpoint, reqType, bodyData, options) {
18935
19687
  const headers = {
@@ -19272,7 +20024,7 @@ async function getTrackedValue(accountName) {
19272
20024
  return trackedValueFromResponse(await getYield(accountName));
19273
20025
  }
19274
20026
  async function getTotalYield(accountNames, start, end) {
19275
- let totalYield = new import_core24.BN(0);
20027
+ let totalYield = new import_core25.BN(0);
19276
20028
  for (const accountName of accountNames) {
19277
20029
  const res = await getYield(accountName, start, end);
19278
20030
  if (isNavAccountValue(res)) {
@@ -19281,7 +20033,7 @@ async function getTotalYield(accountNames, start, end) {
19281
20033
  );
19282
20034
  }
19283
20035
  console.log(res);
19284
- totalYield = totalYield.add(new import_core24.BN(res.total_yield));
20036
+ totalYield = totalYield.add(new import_core25.BN(res.total_yield));
19285
20037
  }
19286
20038
  return totalYield;
19287
20039
  }
@@ -19314,7 +20066,7 @@ async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
19314
20066
  }
19315
20067
 
19316
20068
  // src/services/withdrawalQueueService.ts
19317
- var import_common49 = __toESM(require_dist());
20069
+ var import_common51 = __toESM(require_dist());
19318
20070
  function bnToBigInt(value) {
19319
20071
  return BigInt(value.toString());
19320
20072
  }
@@ -19332,16 +20084,19 @@ var WithdrawalQueueService = class {
19332
20084
  // ── Discovery ───────────────────────────────────────────────────────────
19333
20085
  /** All withdrawal-queue accounts owned by the vault program. */
19334
20086
  async fetchAllQueues() {
19335
- const program = this.client.program.account;
19336
- const accounts2 = await program.vaultWithdrawalQueue.all();
20087
+ const accounts2 = await this.client.account.fetchAllWithdrawalQueues();
19337
20088
  return accounts2.map(
19338
- (entry) => this.toSnapshot((0, import_common49.fromWeb3Pk)(entry.publicKey), entry.account)
20089
+ ({ publicKey, account }) => this.toSnapshot(publicKey, account)
19339
20090
  );
19340
20091
  }
19341
20092
  /** Withdrawal queues for a single vault. */
19342
20093
  async fetchQueuesForVault(vault) {
19343
- const all = await this.fetchAllQueues();
19344
- return all.filter((q) => q.vault === vault);
20094
+ const accounts2 = await this.client.account.fetchAllWithdrawalQueues({
20095
+ vault
20096
+ });
20097
+ return accounts2.map(
20098
+ ({ publicKey, account }) => this.toSnapshot(publicKey, account)
20099
+ );
19345
20100
  }
19346
20101
  /** Fetch a single queue snapshot by owner/queueId for a vault. */
19347
20102
  async fetchQueue(vault, owner, queueId) {
@@ -19370,13 +20125,38 @@ var WithdrawalQueueService = class {
19370
20125
  }
19371
20126
  // ── Fulfillment ─────────────────────────────────────────────────────────
19372
20127
  /**
19373
- * Fulfill a single queued junior withdrawal. `signer` pays fees and, if
20128
+ * Fulfill a single regular or junior withdrawal. `signer` pays fees and, if
19374
20129
  * needed, initializes the owner's output ATA.
19375
20130
  */
19376
20131
  async fulfill(signer, queue) {
20132
+ const vault = await this.client.account.fetchVault(queue.vault, {
20133
+ fresh: true
20134
+ });
20135
+ if (queue.inputMint === (0, import_common51.fromWeb3Pk)(vault.mint)) {
20136
+ const plan2 = await this.client.tx.fulfillAsyncWithdraw.getTx({
20137
+ owner: queue.owner,
20138
+ signer: (0, import_common51.fromWeb3Pk)(signer.publicKey),
20139
+ queuePayer: queue.payer,
20140
+ vault: queue.vault,
20141
+ withdrawalQueue: queue.pda,
20142
+ assetMint: queue.outputMint,
20143
+ shareMint: queue.inputMint,
20144
+ queueId: queue.queueId
20145
+ });
20146
+ return this.client.sendTransaction(signer, plan2);
20147
+ }
20148
+ const tranche = await this.client.account.fetchVaultTrancheStateForVault(
20149
+ queue.vault,
20150
+ { fresh: true }
20151
+ );
20152
+ if (queue.inputMint !== (0, import_common51.fromWeb3Pk)(tranche.config.juniorMint)) {
20153
+ throw new Error(
20154
+ `Unsupported withdrawal queue input mint: ${queue.inputMint}`
20155
+ );
20156
+ }
19377
20157
  const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
19378
20158
  owner: queue.owner,
19379
- signer: (0, import_common49.fromWeb3Pk)(signer.publicKey),
20159
+ signer: (0, import_common51.fromWeb3Pk)(signer.publicKey),
19380
20160
  queuePayer: queue.payer,
19381
20161
  vault: queue.vault,
19382
20162
  withdrawalQueue: queue.pda,
@@ -19410,7 +20190,7 @@ var WithdrawalQueueService = class {
19410
20190
  }
19411
20191
  try {
19412
20192
  log?.(
19413
- `fulfilling ${queue.pda} \u2014 paying ${queue.inputAmount} junior shares worth of ${queue.outputMint} to owner ${queue.owner}`
20193
+ `fulfilling ${queue.pda} \u2014 paying ${queue.inputAmount} shares worth of ${queue.outputMint} to owner ${queue.owner}`
19414
20194
  );
19415
20195
  const sig = await this.fulfill(signer, queue);
19416
20196
  summary.fulfilled += 1;
@@ -19430,12 +20210,12 @@ var WithdrawalQueueService = class {
19430
20210
  const a = account;
19431
20211
  return {
19432
20212
  pda,
19433
- vault: (0, import_common49.fromWeb3Pk)(a.parties.vault),
19434
- owner: (0, import_common49.fromWeb3Pk)(a.parties.owner),
19435
- payer: (0, import_common49.fromWeb3Pk)(a.parties.payer),
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),
19436
20216
  queueId: a.header.queueId,
19437
- inputMint: (0, import_common49.fromWeb3Pk)(a.mints.inputMint),
19438
- outputMint: (0, import_common49.fromWeb3Pk)(a.mints.outputMint),
20217
+ inputMint: (0, import_common51.fromWeb3Pk)(a.mints.inputMint),
20218
+ outputMint: (0, import_common51.fromWeb3Pk)(a.mints.outputMint),
19439
20219
  inputAmount: bnToBigInt(a.request.inputAmount),
19440
20220
  requestTs: bnToNumber(a.request.requestTs),
19441
20221
  expiryTs: bnToNumber(a.request.expiryTs)
@@ -19445,7 +20225,7 @@ var WithdrawalQueueService = class {
19445
20225
 
19446
20226
  // src/services/oracleService.ts
19447
20227
  var import_kit12 = require("@solana/kit");
19448
- var import_common50 = __toESM(require_dist());
20228
+ var import_common52 = __toESM(require_dist());
19449
20229
  var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
19450
20230
  var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
19451
20231
  var PRICE_ORACLE_TYPES_BY_INDEX2 = [
@@ -19509,7 +20289,7 @@ var OracleService = class {
19509
20289
  */
19510
20290
  async updateAssetConsensusPrice(signer, args, log) {
19511
20291
  const plan = await this.client.tx.updateConsensusOracle.getTx({
19512
- signer: (0, import_common50.fromWeb3Pk)(signer.publicKey),
20292
+ signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
19513
20293
  vault: args.vault,
19514
20294
  updates: args.updates,
19515
20295
  assetMint: args.assetMint,
@@ -19525,7 +20305,7 @@ var OracleService = class {
19525
20305
  /** Settle the vault NAV from its current holdings (permissionless). */
19526
20306
  async crankNav(cranker, args, log) {
19527
20307
  const plan = await this.client.tx.crankNav.getTx({
19528
- cranker: (0, import_common50.fromWeb3Pk)(cranker.publicKey),
20308
+ cranker: (0, import_common52.fromWeb3Pk)(cranker.publicKey),
19529
20309
  vault: args.vault,
19530
20310
  vaultTrancheState: args.vaultTrancheState
19531
20311
  });
@@ -19598,7 +20378,7 @@ var OracleService = class {
19598
20378
  /** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
19599
20379
  async refreshAssetPrice(updater, args, log) {
19600
20380
  const plan = await this.client.tx.updateAssetPrice.getTx({
19601
- updater: (0, import_common50.fromWeb3Pk)(updater.publicKey),
20381
+ updater: (0, import_common52.fromWeb3Pk)(updater.publicKey),
19602
20382
  vault: args.vault,
19603
20383
  mint: args.mint,
19604
20384
  oracleAccount: args.oracleAccount,
@@ -19694,11 +20474,11 @@ function toBigInt2(value) {
19694
20474
  }
19695
20475
 
19696
20476
  // src/services/consensusOracle/utils/holdings.ts
19697
- var import_web332 = require("@solana/web3.js");
19698
- var import_common51 = __toESM(require_dist());
20477
+ var import_web334 = require("@solana/web3.js");
20478
+ var import_common53 = __toESM(require_dist());
19699
20479
  function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
19700
20480
  return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
19701
- const mint = (0, import_common51.fromWeb3Pk)(holding.mint);
20481
+ const mint = (0, import_common53.fromWeb3Pk)(holding.mint);
19702
20482
  return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
19703
20483
  variantName2(holding.priceOracleType).toLowerCase()
19704
20484
  );
@@ -19733,7 +20513,7 @@ function parseExternalLiquidityRefs(vaultState) {
19733
20513
  if (!data || data.length < 40) continue;
19734
20514
  if (data[0] !== 1 && data[0] !== 2) continue;
19735
20515
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
19736
- const userAccount = new import_web332.PublicKey(pubkeyBytes).toBase58();
20516
+ const userAccount = new import_web334.PublicKey(pubkeyBytes).toBase58();
19737
20517
  refs.push(
19738
20518
  data[0] === 1 ? { kind: "marginfi", mint: "", marginfiAccount: userAccount } : {
19739
20519
  kind: "kamino-lend",
@@ -19961,12 +20741,12 @@ function formatBpsAsPercent(bps) {
19961
20741
  }
19962
20742
 
19963
20743
  // src/services/consensusOracle/pipeline/dryRunSettlement.ts
19964
- var import_web334 = require("@solana/web3.js");
19965
- var import_common52 = __toESM(require_dist());
20744
+ var import_web336 = require("@solana/web3.js");
20745
+ var import_common54 = __toESM(require_dist());
19966
20746
 
19967
20747
  // src/services/consensusOracle/settlement/settlementSimulator.ts
19968
20748
  var import_kit13 = require("@solana/kit");
19969
- var import_web333 = require("@solana/web3.js");
20749
+ var import_web335 = require("@solana/web3.js");
19970
20750
  var DEFAULT_SHARE_PRICE = 1000000n;
19971
20751
  var BPS_DENOMINATOR3 = 10000n;
19972
20752
  var NAV_LOSS_TOLERANCE_BPS = 1n;
@@ -20239,7 +21019,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
20239
21019
  continue;
20240
21020
  }
20241
21021
  const reports = entries.filter(
20242
- (entry) => entry.signer !== import_web333.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
21022
+ (entry) => entry.signer !== import_web335.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
20243
21023
  );
20244
21024
  const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
20245
21025
  const prices = reports.map((entry) => entry.prices[index] ?? 0n);
@@ -20740,7 +21520,7 @@ function decodeOracleData(data, nowTs) {
20740
21520
  (_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
20741
21521
  );
20742
21522
  entries.push({
20743
- signer: new import_web333.PublicKey(signerBytes).toBase58(),
21523
+ signer: new import_web335.PublicKey(signerBytes).toBase58(),
20744
21524
  lastUpdateTs: readI64(data, offset + 32),
20745
21525
  prices,
20746
21526
  externalAmounts
@@ -20755,7 +21535,7 @@ function decodeOracleData(data, nowTs) {
20755
21535
  data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
20756
21536
  );
20757
21537
  entries[index] = {
20758
- signer: index < pendingCount ? new import_web333.PublicKey(signerBytes).toBase58() : import_web333.PublicKey.default.toBase58(),
21538
+ signer: index < pendingCount ? new import_web335.PublicKey(signerBytes).toBase58() : import_web335.PublicKey.default.toBase58(),
20759
21539
  lastUpdateTs: 0n,
20760
21540
  prices: Array(MAX_HOLDINGS).fill(0n),
20761
21541
  externalAmounts: Array(MAX_HOLDINGS).fill(0n)
@@ -20783,7 +21563,7 @@ function decodeHolding(value) {
20783
21563
  externalAmount: bigint(holding.externalAmount),
20784
21564
  price: bigint(holding.price),
20785
21565
  lastUpdateTs: bigint(holding.lastUpdateTs),
20786
- cleared: mintString === import_web333.PublicKey.default.toBase58()
21566
+ cleared: mintString === import_web335.PublicKey.default.toBase58()
20787
21567
  };
20788
21568
  }
20789
21569
  function decodeTrancheState(decoded, args, warnings, blockers) {
@@ -21266,11 +22046,11 @@ async function fetchSimulationArgs({
21266
22046
  client.account.fetchVaultOracleForVault(vault, { fresh: true }),
21267
22047
  tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
21268
22048
  ]);
21269
- const mintKeys = [new import_web334.PublicKey(vaultState.mint)];
22049
+ const mintKeys = [new import_web336.PublicKey(vaultState.mint)];
21270
22050
  if (trancheState) {
21271
22051
  mintKeys.push(
21272
- new import_web334.PublicKey(trancheState.config.juniorMint),
21273
- new import_web334.PublicKey(trancheState.config.seniorMint)
22052
+ new import_web336.PublicKey(trancheState.config.juniorMint),
22053
+ new import_web336.PublicKey(trancheState.config.seniorMint)
21274
22054
  );
21275
22055
  }
21276
22056
  const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
@@ -21286,7 +22066,7 @@ async function fetchSimulationArgs({
21286
22066
  oracleData: oracleState.data,
21287
22067
  trancheState,
21288
22068
  updates,
21289
- signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
22069
+ signer: (0, import_common54.fromWeb3Pk)(signer.publicKey),
21290
22070
  nowTs: nowSecs,
21291
22071
  physicalShareSupply: supplies[0],
21292
22072
  physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
@@ -21295,7 +22075,7 @@ async function fetchSimulationArgs({
21295
22075
  }
21296
22076
 
21297
22077
  // src/services/consensusOracle/pipeline/holdingUpdates.ts
21298
- var import_common53 = __toESM(require_dist());
22078
+ var import_common55 = __toESM(require_dist());
21299
22079
  async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
21300
22080
  const updates = [];
21301
22081
  for (const entry of reportableHoldings) {
@@ -21305,7 +22085,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
21305
22085
  }
21306
22086
  async function buildHoldingUpdate(yieldTracker, entry, inputs) {
21307
22087
  const { holding, holdingIndex } = entry;
21308
- const mint = (0, import_common53.fromWeb3Pk)(holding.mint);
22088
+ const mint = (0, import_common55.fromWeb3Pk)(holding.mint);
21309
22089
  const mintKey = mint.toString();
21310
22090
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
21311
22091
  let usd;
@@ -21367,9 +22147,9 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
21367
22147
  );
21368
22148
  }
21369
22149
  return {
21370
- trackedValueAmount: tracked.totalValue > 0 ? (0, import_common53.fromUiAmount)(tracked.totalValue, decimals) : 0n,
21371
- principalAmount: tracked.principal > 0 ? (0, import_common53.fromUiAmount)(tracked.principal, decimals) : 0n,
21372
- yieldAmount: tracked.outstandingYield > 0 ? (0, import_common53.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
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
21373
22153
  };
21374
22154
  }
21375
22155
 
@@ -21403,7 +22183,7 @@ function assertOracleImpliedApy(vault, simulation, label) {
21403
22183
  }
21404
22184
 
21405
22185
  // src/services/consensusOracle/pipeline/livePriceRefresh.ts
21406
- var import_common54 = __toESM(require_dist());
22186
+ var import_common56 = __toESM(require_dist());
21407
22187
  async function refreshLiveOraclePrices({
21408
22188
  oracle,
21409
22189
  signer,
@@ -21422,7 +22202,7 @@ async function refreshLiveOraclePrices({
21422
22202
  for (const holding of vaultState.holdings) {
21423
22203
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
21424
22204
  if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
21425
- const mint = (0, import_common54.fromWeb3Pk)(holding.mint);
22205
+ const mint = (0, import_common56.fromWeb3Pk)(holding.mint);
21426
22206
  if (mint.toString() === SYSTEM_PROGRAM) continue;
21427
22207
  const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
21428
22208
  if (activeAmount === 0n) continue;
@@ -21437,7 +22217,7 @@ async function refreshLiveOraclePrices({
21437
22217
  );
21438
22218
  continue;
21439
22219
  }
21440
- const oracleAccount = (0, import_common54.fromWeb3Pk)(holding.priceOracleAccount);
22220
+ const oracleAccount = (0, import_common56.fromWeb3Pk)(holding.priceOracleAccount);
21441
22221
  if (oracleAccount.toString() === SYSTEM_PROGRAM) {
21442
22222
  log(
21443
22223
  `vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
@@ -21461,7 +22241,7 @@ async function refreshLiveOraclePrices({
21461
22241
  }
21462
22242
 
21463
22243
  // src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
21464
- var import_common55 = __toESM(require_dist());
22244
+ var import_common57 = __toESM(require_dist());
21465
22245
 
21466
22246
  // src/services/consensusOracle/sources/nestPriceSource.ts
21467
22247
  var import_kit14 = require("@solana/kit");
@@ -21508,13 +22288,13 @@ function candidateGrossNav(state, updates) {
21508
22288
  const byIndex = /* @__PURE__ */ new Map();
21509
22289
  for (const update of updates) {
21510
22290
  const holding = state.holdings[update.holdingIndex];
21511
- if (!holding || (0, import_common55.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
22291
+ if (!holding || (0, import_common57.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
21512
22292
  throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
21513
22293
  }
21514
22294
  byIndex.set(update.holdingIndex, update);
21515
22295
  }
21516
22296
  return state.holdings.reduce((nav, holding, index) => {
21517
- if ((0, import_common55.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
22297
+ if ((0, import_common57.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
21518
22298
  const update = byIndex.get(index);
21519
22299
  const local = toBigInt2(holding.localAmount);
21520
22300
  const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
@@ -21581,13 +22361,13 @@ async function reconcileManagerWalletBalances({
21581
22361
  throw new Error("Duplicate base mint in manager reconciliation");
21582
22362
  }
21583
22363
  if (vaultState.holdings.some(
21584
- (holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common55.fromWeb3Pk)(holding.mint))
22364
+ (holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common57.fromWeb3Pk)(holding.mint))
21585
22365
  )) {
21586
22366
  throw new Error(
21587
22367
  "Cannot reconcile all vault base assets with oracle reports"
21588
22368
  );
21589
22369
  }
21590
- const manager = (0, import_common55.fromWeb3Pk)(vaultState.roles.manager);
22370
+ const manager = (0, import_common57.fromWeb3Pk)(vaultState.roles.manager);
21591
22371
  if (manager === SYSTEM_PROGRAM || manager === vault) {
21592
22372
  throw new Error("Invalid manager wallet for NAV reconciliation");
21593
22373
  }
@@ -21673,13 +22453,13 @@ function walletReconciliationGuardUpdates(state, reconciliation) {
21673
22453
  }
21674
22454
  function managerReconciliationStateKey(state) {
21675
22455
  return JSON.stringify({
21676
- manager: (0, import_common55.fromWeb3Pk)(state.roles.manager),
22456
+ manager: (0, import_common57.fromWeb3Pk)(state.roles.manager),
21677
22457
  assetDecimals: state.config.assetDecimals,
21678
22458
  holdings: state.holdings.map((holding) => [
21679
- (0, import_common55.fromWeb3Pk)(holding.mint),
22459
+ (0, import_common57.fromWeb3Pk)(holding.mint),
21680
22460
  holding.decimals,
21681
22461
  variantName2(holding.priceOracleType),
21682
- holding.priceOracleAccount ? (0, import_common55.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
22462
+ holding.priceOracleAccount ? (0, import_common57.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
21683
22463
  coerceBool3(holding.isBase),
21684
22464
  toBigInt2(holding.localAmount).toString()
21685
22465
  ])
@@ -21718,14 +22498,14 @@ function assertReconciliationExternalValues(initial, current, errorPrefix) {
21718
22498
  }
21719
22499
 
21720
22500
  // src/services/consensusOracle/pipeline/pricingInputs.ts
21721
- var import_common56 = __toESM(require_dist());
22501
+ var import_common58 = __toESM(require_dist());
21722
22502
  async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
21723
22503
  }) {
21724
22504
  const consensusMints = reportableHoldings.filter(
21725
22505
  ({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
21726
- ).map(({ holding }) => (0, import_common56.fromWeb3Pk)(holding.mint));
22506
+ ).map(({ holding }) => (0, import_common58.fromWeb3Pk)(holding.mint));
21727
22507
  const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
21728
- const baseMint = baseHolding ? (0, import_common56.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
22508
+ const baseMint = baseHolding ? (0, import_common58.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
21729
22509
  if (!baseMint) {
21730
22510
  throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
21731
22511
  }
@@ -21811,11 +22591,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
21811
22591
  }
21812
22592
 
21813
22593
  // src/services/consensusOracle/pipeline/receiptMints.ts
21814
- var import_common57 = __toESM(require_dist());
22594
+ var import_common59 = __toESM(require_dist());
21815
22595
  async function fetchReceiptMints(client, vault, vaultState) {
21816
22596
  const receiptMints = /* @__PURE__ */ new Set();
21817
22597
  if (vaultState.mint) {
21818
- receiptMints.add((0, import_common57.fromWeb3Pk)(vaultState.mint).toString());
22598
+ receiptMints.add((0, import_common59.fromWeb3Pk)(vaultState.mint).toString());
21819
22599
  }
21820
22600
  if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
21821
22601
  const trancheState = await client.account.fetchVaultTrancheStateForVault(
@@ -21823,19 +22603,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
21823
22603
  { fresh: true }
21824
22604
  );
21825
22605
  receiptMints.add(
21826
- (0, import_common57.fromWeb3Pk)(trancheState.config.juniorMint).toString()
22606
+ (0, import_common59.fromWeb3Pk)(trancheState.config.juniorMint).toString()
21827
22607
  );
21828
22608
  receiptMints.add(
21829
- (0, import_common57.fromWeb3Pk)(trancheState.config.seniorMint).toString()
22609
+ (0, import_common59.fromWeb3Pk)(trancheState.config.seniorMint).toString()
21830
22610
  );
21831
22611
  return receiptMints;
21832
22612
  }
21833
22613
 
21834
22614
  // src/services/consensusOracle/pipeline/settlement.ts
21835
- var import_common59 = __toESM(require_dist());
22615
+ var import_common61 = __toESM(require_dist());
21836
22616
 
21837
22617
  // src/services/consensusOracle/pipeline/yieldAccounts.ts
21838
- var import_common58 = __toESM(require_dist());
22618
+ var import_common60 = __toESM(require_dist());
21839
22619
  async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
21840
22620
  const accountNames = [
21841
22621
  ...new Set(
@@ -21877,7 +22657,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
21877
22657
  );
21878
22658
  if (namesToAttach.length === 0) return target;
21879
22659
  const baseHolding = vaultState.holdings.find((holding) => {
21880
- const mint = (0, import_common58.fromWeb3Pk)(holding.mint).toString();
22660
+ const mint = (0, import_common60.fromWeb3Pk)(holding.mint).toString();
21881
22661
  return coerceBool3(holding.isBase) && !excludedMints.has(mint);
21882
22662
  });
21883
22663
  if (!baseHolding) {
@@ -21885,7 +22665,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
21885
22665
  `vault ${target.vault}: tagged yield accounts found but no base holding is available`
21886
22666
  );
21887
22667
  }
21888
- const baseMint = (0, import_common58.fromWeb3Pk)(baseHolding.mint);
22668
+ const baseMint = (0, import_common60.fromWeb3Pk)(baseHolding.mint);
21889
22669
  const holdings = [...target.holdings ?? []];
21890
22670
  const existingIndex = holdings.findIndex(
21891
22671
  (holding) => holding.mint.toString() === baseMint.toString()
@@ -21970,7 +22750,7 @@ async function settleVault2({
21970
22750
  vault: publishedVault,
21971
22751
  oracleData: publishedOracle.data,
21972
22752
  updates,
21973
- signer: (0, import_common59.fromWeb3Pk)(signer.publicKey),
22753
+ signer: (0, import_common61.fromWeb3Pk)(signer.publicKey),
21974
22754
  nowTs: publishedAt
21975
22755
  });
21976
22756
  if (blockers.length)
@@ -22012,7 +22792,7 @@ async function logProspectiveApy({
22012
22792
  );
22013
22793
  const prospectiveNav = vaultState.holdings.reduce(
22014
22794
  (sum, holding, holdingIndex) => {
22015
- const mint = (0, import_common59.fromWeb3Pk)(holding.mint).toString();
22795
+ const mint = (0, import_common61.fromWeb3Pk)(holding.mint).toString();
22016
22796
  if (mint === SYSTEM_PROGRAM) return sum;
22017
22797
  const update = updatesByIndex.get(holdingIndex);
22018
22798
  const localAmount = toBigInt2(holding.localAmount);
@@ -22050,20 +22830,38 @@ async function discoverVaultsForSigner(client, signer, opts = {}) {
22050
22830
  log(
22051
22831
  `Discovered ${allVaults.length} vault(s) on-chain, checking oracle membership\u2026`
22052
22832
  );
22053
- const results = [];
22054
- await Promise.all(
22833
+ const inspections = await Promise.allSettled(
22055
22834
  allVaults.map(async ({ publicKey: vault }) => {
22056
- try {
22057
- const oracle = await client.account.fetchVaultOracleForVault(vault);
22058
- const data = oracle.data;
22059
- if (signerInOracleData(data, signerBytes)) {
22060
- log(` ${vault}: signer is registered oracle`);
22061
- results.push({ vault });
22062
- }
22063
- } catch {
22064
- }
22835
+ const oracle = await client.account.fetchVaultOracleForVaultNullable(
22836
+ vault
22837
+ );
22838
+ if (!oracle) {
22839
+ log(` ${vault}: no oracle account, skipping`);
22840
+ return null;
22841
+ }
22842
+ const data = oracle.data;
22843
+ if (!signerInOracleData(data, signerBytes)) return null;
22844
+ log(` ${vault}: signer is registered oracle`);
22845
+ return { vault };
22065
22846
  })
22066
22847
  );
22848
+ const results = [];
22849
+ const unreadable = [];
22850
+ inspections.forEach((inspection, index) => {
22851
+ if (inspection.status === "fulfilled") {
22852
+ if (inspection.value) results.push(inspection.value);
22853
+ return;
22854
+ }
22855
+ const vault = allVaults[index].publicKey;
22856
+ const error = inspection.reason instanceof Error ? inspection.reason.message : String(inspection.reason);
22857
+ log(`FAILED oracle discovery ${vault}: ${error}`);
22858
+ unreadable.push(vault.toString());
22859
+ });
22860
+ if (unreadable.length > 0) {
22861
+ throw new Error(
22862
+ `Oracle discovery incomplete: could not inspect ${unreadable.length}/${allVaults.length} vault(s) (${unreadable.join(", ")}); refusing to run a partial target list`
22863
+ );
22864
+ }
22067
22865
  return results;
22068
22866
  }
22069
22867
 
@@ -22921,7 +23719,7 @@ async function buildJupiterSwapTransaction(params) {
22921
23719
  }
22922
23720
 
22923
23721
  // ../jupiter/src/client.ts
22924
- var import_common60 = __toESM(require_dist());
23722
+ var import_common62 = __toESM(require_dist());
22925
23723
 
22926
23724
  // ../jupiter/src/extract.ts
22927
23725
  var import_kit17 = require("@solana/kit");
@@ -22951,8 +23749,8 @@ async function extractJupiterInstruction(transaction, rpc, jupiterProgramId = JU
22951
23749
 
22952
23750
  // ../jupiter/src/routePreInstructions.ts
22953
23751
  var import_kit18 = require("@solana/kit");
22954
- var import_spl_token22 = require("@solana/spl-token");
22955
- var import_web335 = require("@solana/web3.js");
23752
+ var import_spl_token24 = require("@solana/spl-token");
23753
+ var import_web337 = require("@solana/web3.js");
22956
23754
  async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
22957
23755
  const intermediate = /* @__PURE__ */ new Set();
22958
23756
  for (const step of quote.routePlan ?? []) {
@@ -22976,26 +23774,26 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
22976
23774
  `getJupiterRoutePreInstructions: route mint ${mint} not found on-chain`
22977
23775
  );
22978
23776
  }
22979
- const ata = (0, import_spl_token22.getAssociatedTokenAddressSync)(
22980
- new import_web335.PublicKey(mint),
22981
- new import_web335.PublicKey(user),
23777
+ const ata = (0, import_spl_token24.getAssociatedTokenAddressSync)(
23778
+ new import_web337.PublicKey(mint),
23779
+ new import_web337.PublicKey(user),
22982
23780
  true,
22983
- new import_web335.PublicKey(tokenProgram),
22984
- import_spl_token22.ASSOCIATED_TOKEN_PROGRAM_ID
23781
+ new import_web337.PublicKey(tokenProgram),
23782
+ import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID
22985
23783
  ).toBase58();
22986
23784
  const existingAta = await rpc.getAccountInfo(ata, { encoding: "base64" }).send();
22987
23785
  if (existingAta.value) {
22988
23786
  continue;
22989
23787
  }
22990
23788
  instructions2.push(
22991
- toKitInstruction37(
22992
- (0, import_spl_token22.createAssociatedTokenAccountIdempotentInstruction)(
22993
- new import_web335.PublicKey(payer),
22994
- new import_web335.PublicKey(ata),
22995
- new import_web335.PublicKey(user),
22996
- new import_web335.PublicKey(mint),
22997
- new import_web335.PublicKey(tokenProgram),
22998
- import_spl_token22.ASSOCIATED_TOKEN_PROGRAM_ID
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
22999
23797
  )
23000
23798
  )
23001
23799
  );
@@ -23003,7 +23801,7 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23003
23801
  }
23004
23802
  return { instructions: instructions2, postSuccessCacheInvalidations };
23005
23803
  }
23006
- function toKitInstruction37(ix) {
23804
+ function toKitInstruction39(ix) {
23007
23805
  return {
23008
23806
  programAddress: ix.programId.toBase58(),
23009
23807
  accounts: ix.keys.map((account) => ({
@@ -23120,7 +23918,7 @@ var JupiterSwapClient = class {
23120
23918
  }
23121
23919
  }
23122
23920
  return {
23123
- cpiType: this.config.cpiType ?? import_common60.CpiTypes.JUPITER_SWAP,
23921
+ cpiType: this.config.cpiType ?? import_common62.CpiTypes.JUPITER_SWAP,
23124
23922
  data,
23125
23923
  accounts: accounts2,
23126
23924
  programId: JUPITER_V6_PROGRAM_ID,
@@ -23218,8 +24016,8 @@ var LivePriceSource = class {
23218
24016
  };
23219
24017
 
23220
24018
  // src/services/consensusOracle/sources/managerWalletBalanceSource.ts
23221
- var import_web336 = require("@solana/web3.js");
23222
- var import_spl_token23 = require("@solana/spl-token");
24019
+ var import_web338 = require("@solana/web3.js");
24020
+ var import_spl_token25 = require("@solana/spl-token");
23223
24021
  var RpcManagerWalletBalanceSource = class {
23224
24022
  constructor(connection) {
23225
24023
  this.connection = connection;
@@ -23227,8 +24025,8 @@ var RpcManagerWalletBalanceSource = class {
23227
24025
  async fetchBalances(manager, mints2) {
23228
24026
  const wanted = new Set(mints2);
23229
24027
  if (wanted.size === 0) return /* @__PURE__ */ new Map();
23230
- const owner = new import_web336.PublicKey(manager);
23231
- const programs = [import_spl_token23.TOKEN_PROGRAM_ID, import_spl_token23.TOKEN_2022_PROGRAM_ID];
24028
+ const owner = new import_web338.PublicKey(manager);
24029
+ const programs = [import_spl_token25.TOKEN_PROGRAM_ID, import_spl_token25.TOKEN_2022_PROGRAM_ID];
23232
24030
  const responses = await Promise.all(
23233
24031
  programs.map(
23234
24032
  (programId) => this.connection.getParsedTokenAccountsByOwner(
@@ -23271,7 +24069,7 @@ var RpcManagerWalletBalanceSource = class {
23271
24069
  };
23272
24070
 
23273
24071
  // src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
23274
- var import_web337 = require("@solana/web3.js");
24072
+ var import_web339 = require("@solana/web3.js");
23275
24073
 
23276
24074
  // src/services/consensusOracle/sources/mpcMarginfiDeposits.ts
23277
24075
  var import_kit19 = require("@solana/kit");
@@ -23360,8 +24158,8 @@ var RpcMpcWalletBalanceSource = class {
23360
24158
  const wallets = /* @__PURE__ */ new Set();
23361
24159
  for (const binding of bindings) {
23362
24160
  const { vault, manager, wallet } = binding;
23363
- for (const key of [vault, manager, wallet]) new import_web337.PublicKey(key);
23364
- if (entries.has(vault) || wallets.has(wallet) || wallet === manager || wallet === vault || wallet === import_web337.PublicKey.default.toBase58())
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())
23365
24163
  throw new Error("Invalid or duplicate MPC wallet binding");
23366
24164
  entries.set(vault, { ...binding });
23367
24165
  wallets.add(wallet);
@@ -23381,8 +24179,8 @@ var RpcMpcWalletBalanceSource = class {
23381
24179
  this.tokens.fetchBalances(binding.wallet, mints2),
23382
24180
  readMarginfiDepositsForAuthority(
23383
24181
  this.connection,
23384
- new import_web337.PublicKey(binding.wallet),
23385
- mints2.map((mint) => new import_web337.PublicKey(mint))
24182
+ new import_web339.PublicKey(binding.wallet),
24183
+ mints2.map((mint) => new import_web339.PublicKey(mint))
23386
24184
  )
23387
24185
  ]);
23388
24186
  return { wallet: binding.wallet, tokens, marginfi: deposits };
@@ -23425,7 +24223,7 @@ var StaticPositionProvider = class {
23425
24223
 
23426
24224
  // src/services/consensusOracle/positions/kaminoPositionProvider.ts
23427
24225
  var import_kit20 = require("@solana/kit");
23428
- var import_web338 = require("@solana/web3.js");
24226
+ var import_web340 = require("@solana/web3.js");
23429
24227
  var import_klend_sdk = require("@kamino-finance/klend-sdk");
23430
24228
  async function readKaminoBalance(manager, vault, sharesHolder) {
23431
24229
  const userShares = await manager.getUserSharesBalanceSingleVault(
@@ -23462,7 +24260,7 @@ var KaminoPositionProvider = class {
23462
24260
  const amount = await readKaminoBalance(
23463
24261
  manager,
23464
24262
  kVault,
23465
- new import_web338.PublicKey(sharesHolder)
24263
+ new import_web340.PublicKey(sharesHolder)
23466
24264
  );
23467
24265
  out.push({ mint: ref.mint, amount });
23468
24266
  }
@@ -23471,11 +24269,11 @@ var KaminoPositionProvider = class {
23471
24269
  };
23472
24270
 
23473
24271
  // src/services/consensusOracle/positions/kaminoLendPositionProvider.ts
23474
- var import_web339 = require("@solana/web3.js");
24272
+ var import_web341 = require("@solana/web3.js");
23475
24273
  var import_Obligation2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
23476
24274
  var import_Reserve2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
23477
24275
  var import_kamino4 = __toESM(require_dist3());
23478
- var ZERO = import_web339.PublicKey.default.toBase58();
24276
+ var ZERO = import_web341.PublicKey.default.toBase58();
23479
24277
  var FRACTION_SCALE = 1n << 60n;
23480
24278
  function accountData(info, label) {
23481
24279
  if (!info || info.executable || info.owner.toBase58() !== import_kamino4.KLEND_PROGRAM_ID)
@@ -23516,7 +24314,7 @@ var KaminoLendPositionProvider = class {
23516
24314
  }
23517
24315
  const positions = [];
23518
24316
  for (const address18 of obligations) {
23519
- const key = new import_web339.PublicKey(address18);
24317
+ const key = new import_web341.PublicKey(address18);
23520
24318
  const discovered = decodeObligation(
23521
24319
  await this.connection.getAccountInfo(key, "confirmed"),
23522
24320
  ctx.vault
@@ -23526,7 +24324,7 @@ var KaminoLendPositionProvider = class {
23526
24324
  (deposit) => deposit.depositReserve
23527
24325
  );
23528
24326
  const infos = await this.connection.getMultipleAccountsInfo(
23529
- [key, ...reserves.map((reserve) => new import_web339.PublicKey(reserve))],
24327
+ [key, ...reserves.map((reserve) => new import_web341.PublicKey(reserve))],
23530
24328
  "confirmed"
23531
24329
  );
23532
24330
  const { obligation, deposits } = decodeObligation(
@@ -23568,7 +24366,7 @@ var KaminoLendPositionProvider = class {
23568
24366
  };
23569
24367
 
23570
24368
  // src/services/consensusOracle/positions/marginfiPositionProvider.ts
23571
- var import_web340 = require("@solana/web3.js");
24369
+ var import_web342 = require("@solana/web3.js");
23572
24370
  var import_marginfi4 = __toESM(require_dist2());
23573
24371
  var MarginfiPositionProvider = class {
23574
24372
  constructor(connection, log = () => {
@@ -23579,8 +24377,8 @@ var MarginfiPositionProvider = class {
23579
24377
  async positionsFor(ctx) {
23580
24378
  const refs = ctx.refs.filter((r) => r.kind === "marginfi");
23581
24379
  if (refs.length === 0) return [];
23582
- const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web340.PublicKey(bank));
23583
- const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new import_web340.PublicKey(account));
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));
23584
24382
  const autoBanks = [];
23585
24383
  for (const accountPk of autoAccountPks) {
23586
24384
  try {
@@ -23609,14 +24407,14 @@ var MarginfiPositionProvider = class {
23609
24407
  if (bank) {
23610
24408
  const amount = await (0, import_marginfi4.readMarginfiBankBalance)(
23611
24409
  client,
23612
- new import_web340.PublicKey(account),
23613
- new import_web340.PublicKey(bank)
24410
+ new import_web342.PublicKey(account),
24411
+ new import_web342.PublicKey(bank)
23614
24412
  );
23615
24413
  out.push({ mint: ref.mint, amount });
23616
24414
  } else {
23617
24415
  const balances = await (0, import_marginfi4.readAllMarginfiBalances)(
23618
24416
  client,
23619
- new import_web340.PublicKey(account)
24417
+ new import_web342.PublicKey(account)
23620
24418
  );
23621
24419
  for (const { mint, amount } of balances) {
23622
24420
  out.push({ mint: mint.toBase58(), amount });
@@ -23823,6 +24621,11 @@ var MPC_WALLETS = [
23823
24621
  vault: (0, import_kit21.address)("ECJGrTZ6QYMEwiEAnL4oReWF126uc22e9Lojy9qyCjHT"),
23824
24622
  manager: (0, import_kit21.address)("4jMRBkpWrfhhwFYTwG3o7hmsXQwbJUwdyUX8htB6KwLJ"),
23825
24623
  wallet: (0, import_kit21.address)("4EXphBhAWcm8NHEENzURiJBPtMPsg2PoXWf95E6sRyfB")
24624
+ },
24625
+ {
24626
+ vault: (0, import_kit21.address)("JBmJMnnGfw4gL3e6Xs4a6H4NV1cC9jitRx1GUP2bGq37"),
24627
+ manager: (0, import_kit21.address)("AybcEps9z8eUug3ct6L7KkLMH3SVG2Ss3dRVya7ave9n"),
24628
+ wallet: (0, import_kit21.address)("7U4ZkXNGVi3648fbAXpUD47DARsP6kpRWqrXFoMxk2t1")
23826
24629
  }
23827
24630
  ];
23828
24631
 
@@ -23881,7 +24684,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
23881
24684
  }
23882
24685
 
23883
24686
  // src/services/consensusOracle/consensusOracleService.ts
23884
- var import_common61 = __toESM(require_dist());
24687
+ var import_common63 = __toESM(require_dist());
23885
24688
  var ConsensusOracleService = class {
23886
24689
  constructor(client, deps) {
23887
24690
  this.client = client;
@@ -23917,7 +24720,7 @@ var ConsensusOracleService = class {
23917
24720
  receiptMints
23918
24721
  );
23919
24722
  const filteredCount = vaultState.holdings.filter(
23920
- (holding) => receiptMints.has((0, import_common61.fromWeb3Pk)(holding.mint).toString())
24723
+ (holding) => receiptMints.has((0, import_common63.fromWeb3Pk)(holding.mint).toString())
23921
24724
  ).length;
23922
24725
  if (filteredCount > 0) {
23923
24726
  log(
@@ -24186,8 +24989,8 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
24186
24989
 
24187
24990
  // src/services/externalLiquidityIntegrityService.ts
24188
24991
  var import_kit22 = require("@solana/kit");
24189
- var import_web341 = require("@solana/web3.js");
24190
- var import_common62 = __toESM(require_dist());
24992
+ var import_web343 = require("@solana/web3.js");
24993
+ var import_common64 = __toESM(require_dist());
24191
24994
  var import_marginfi5 = __toESM(require_dist2());
24192
24995
  var import_kamino5 = __toESM(require_dist3());
24193
24996
  var import_marginfi_client_v23 = require("@mrgnlabs/marginfi-client-v2");
@@ -24297,7 +25100,7 @@ function parseActiveSlots(externalLiquidity) {
24297
25100
  if (discriminant === 0) continue;
24298
25101
  if (discriminant !== 1 && discriminant !== 2) continue;
24299
25102
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
24300
- const userAccount = (0, import_common62.toAddress)(new import_web341.PublicKey(pubkeyBytes));
25103
+ const userAccount = (0, import_common64.toAddress)(new import_web343.PublicKey(pubkeyBytes));
24301
25104
  if (isZeroPubkey2(userAccount))
24302
25105
  throw new Error("Registered external position has a zero address");
24303
25106
  if (results.some((slot) => slot.userAccount === userAccount)) continue;
@@ -24469,7 +25272,7 @@ var ExternalLiquidityIntegrityService = class {
24469
25272
  const decimals = Number(holding.decimals ?? 0);
24470
25273
  const minRaw = toRawAmount(minAmountUi, decimals);
24471
25274
  let targetLocalAmount;
24472
- if (mintAddress === import_common62.USDC_MINT) {
25275
+ if (mintAddress === import_common64.USDC_MINT) {
24473
25276
  const tvl = toBigInt3(vaultState.accounting.tvl);
24474
25277
  const price = toBigInt3(holding.price);
24475
25278
  const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
@@ -24572,25 +25375,25 @@ var ExternalLiquidityIntegrityService = class {
24572
25375
  * from vault accounting as though it were the balance of each separate slot. */
24573
25376
  async loadPositions(vault, mint, slots) {
24574
25377
  const marginfi = (0, import_marginfi5.marginfiAccountsForMint)(mint);
24575
- if (!marginfi && mint !== import_common62.USDC_MINT)
25378
+ if (!marginfi && mint !== import_common64.USDC_MINT)
24576
25379
  return {
24577
25380
  local: 0n,
24578
25381
  positions: [],
24579
- tokenProgram: (0, import_kit22.address)(import_web341.PublicKey.default.toBase58()),
24580
- vaultAta: (0, import_kit22.address)(import_web341.PublicKey.default.toBase58())
25382
+ tokenProgram: (0, import_kit22.address)(import_web343.PublicKey.default.toBase58()),
25383
+ vaultAta: (0, import_kit22.address)(import_web343.PublicKey.default.toBase58())
24581
25384
  };
24582
25385
  const connection = this.client.provider.connection;
24583
25386
  const mintInfo = await connection.getAccountInfo(
24584
- new import_web341.PublicKey(mint),
25387
+ new import_web343.PublicKey(mint),
24585
25388
  "confirmed"
24586
25389
  );
24587
25390
  if (!mintInfo) throw new Error(`Missing mint ${mint}`);
24588
- const tokenProgram = (0, import_common62.fromWeb3Pk)(mintInfo.owner);
24589
- const vaultAta = (0, import_common62.getAtaAddress)(mint, vault, tokenProgram, true);
25391
+ const tokenProgram = (0, import_common64.fromWeb3Pk)(mintInfo.owner);
25392
+ const vaultAta = (0, import_common64.getAtaAddress)(mint, vault, tokenProgram, true);
24590
25393
  const positions = [];
24591
25394
  for (const slot of slots) {
24592
25395
  if (slot.source === "marginfi" && !marginfi) continue;
24593
- if (slot.source === "kamino" && mint !== import_common62.USDC_MINT) continue;
25396
+ if (slot.source === "kamino" && mint !== import_common64.USDC_MINT) continue;
24594
25397
  const kamino = slot.source === "kamino" ? await loadKaminoDeposit({
24595
25398
  connection,
24596
25399
  vault,
@@ -24601,7 +25404,7 @@ var ExternalLiquidityIntegrityService = class {
24601
25404
  throw new Error("Kamino token program mismatch");
24602
25405
  const data = Buffer.alloc(256);
24603
25406
  data[0] = slot.source === "marginfi" ? 1 : 2;
24604
- new import_web341.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
25407
+ new import_web343.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
24605
25408
  const withdrawal = await loadWithdrawalPosition({
24606
25409
  connection,
24607
25410
  vault,
@@ -24637,8 +25440,8 @@ var ExternalLiquidityIntegrityService = class {
24637
25440
  async executeMoves(args) {
24638
25441
  const { vault, mintAddress, hwManager, snapshot: snapshot2, moves, dryRun, log } = args;
24639
25442
  const instructions2 = [
24640
- (0, import_common62.toKitInstruction)(
24641
- import_web341.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
25443
+ (0, import_common64.toKitInstruction)(
25444
+ import_web343.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
24642
25445
  )
24643
25446
  ];
24644
25447
  const lookupTables = /* @__PURE__ */ new Set();
@@ -24651,7 +25454,7 @@ var ExternalLiquidityIntegrityService = class {
24651
25454
  cpiRefs = position.withdrawal.explicitRefs(move.amount);
24652
25455
  } else if (position.source === "kamino") {
24653
25456
  if (!position.kamino) throw new Error("Missing Kamino reserve");
24654
- cpiRefs = (0, import_common62.createCpiRefs)(
25457
+ cpiRefs = (0, import_common64.createCpiRefs)(
24655
25458
  (0, import_kamino5.kaminoDepositCpis)({
24656
25459
  ...position.kamino,
24657
25460
  vault,
@@ -24662,14 +25465,14 @@ var ExternalLiquidityIntegrityService = class {
24662
25465
  );
24663
25466
  } else {
24664
25467
  const configured = (0, import_marginfi5.marginfiAccountsForMint)(mintAddress);
24665
- cpiRefs = (0, import_common62.createCpiRefs)([
25468
+ cpiRefs = (0, import_common64.createCpiRefs)([
24666
25469
  new import_marginfi5.CpiClient({ accounts: configured }).deposit_cpi({
24667
25470
  marginfiAccount: position.userAccount,
24668
25471
  authority: vault,
24669
25472
  signerTokenAccount: snapshot2.vaultAta,
24670
25473
  amount: move.amount,
24671
- lookupTables: (import_marginfi_client_v23.ADDRESS_LOOKUP_TABLE_FOR_GROUP[configured.group] ?? []).map(import_common62.fromWeb3Pk),
24672
- remainingAccounts: configured.tokenProgram === "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" ? [(0, import_common62.toCustomAccountMeta)(mintAddress)] : []
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)] : []
24673
25476
  })
24674
25477
  ]);
24675
25478
  }
@@ -24677,7 +25480,7 @@ var ExternalLiquidityIntegrityService = class {
24677
25480
  instructions2.push(
24678
25481
  await this.client.tx.protocolInteraction.getIx({
24679
25482
  vault,
24680
- hwManager: (0, import_common62.fromWeb3Pk)(hwManager.publicKey),
25483
+ hwManager: (0, import_common64.fromWeb3Pk)(hwManager.publicKey),
24681
25484
  ...cpiRefs,
24682
25485
  externalLiquidityIndex: position.index,
24683
25486
  affectedAssetMint: mintAddress,
@@ -24709,10 +25512,10 @@ var ExternalLiquidityIntegrityService = class {
24709
25512
 
24710
25513
  // src/services/idleLiquidityService.ts
24711
25514
  var import_kit23 = require("@solana/kit");
24712
- var import_spl_token24 = require("@solana/spl-token");
25515
+ var import_spl_token26 = require("@solana/spl-token");
24713
25516
  var import_marginfi_client_v24 = require("@mrgnlabs/marginfi-client-v2");
24714
- var import_web342 = require("@solana/web3.js");
24715
- var import_common63 = __toESM(require_dist());
25517
+ var import_web344 = require("@solana/web3.js");
25518
+ var import_common65 = __toESM(require_dist());
24716
25519
  var import_marginfi6 = __toESM(require_dist2());
24717
25520
  var IDLE_RESERVE_FLOOR_BPS = 400;
24718
25521
  var IDLE_RESERVE_TARGET_BPS = 500;
@@ -24816,8 +25619,8 @@ var IdleLiquidityService = class {
24816
25619
  );
24817
25620
  }
24818
25621
  quote = await jupiter.getQuote({
24819
- inputMint: import_common63.PST_MINT,
24820
- outputMint: import_common63.USDC_MINT,
25622
+ inputMint: import_common65.PST_MINT,
25623
+ outputMint: import_common65.USDC_MINT,
24821
25624
  amount: pstInput,
24822
25625
  slippageBps
24823
25626
  });
@@ -24862,13 +25665,13 @@ var IdleLiquidityService = class {
24862
25665
  /** Read live local, Project0 and Kamino USDC, excluding other deployed capital. */
24863
25666
  async fetchIdleUsdc(vault, vaultState) {
24864
25667
  const connection = this.client.provider.connection;
24865
- const vaultPk = new import_web342.PublicKey(vault);
24866
- const usdcMint = new import_web342.PublicKey(import_common63.USDC_MINT);
24867
- const ata = (0, import_spl_token24.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
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);
24868
25671
  const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
24869
25672
  let localAmount = 0n;
24870
25673
  if (tokenInfo) {
24871
- const tokenAccount = (0, import_spl_token24.unpackAccount)(ata, tokenInfo, import_spl_token24.TOKEN_PROGRAM_ID);
25674
+ const tokenAccount = (0, import_spl_token26.unpackAccount)(ata, tokenInfo, import_spl_token26.TOKEN_PROGRAM_ID);
24872
25675
  if (!tokenAccount.mint.equals(usdcMint) || !tokenAccount.owner.equals(vaultPk) || !tokenAccount.isInitialized) {
24873
25676
  throw new Error(`Invalid vault USDC token account: ${ata.toBase58()}`);
24874
25677
  }
@@ -24877,7 +25680,7 @@ var IdleLiquidityService = class {
24877
25680
  const kamino = await this.fetchKaminoUsdc(
24878
25681
  vault,
24879
25682
  vaultState,
24880
- (0, import_common63.fromWeb3Pk)(ata)
25683
+ (0, import_common65.fromWeb3Pk)(ata)
24881
25684
  );
24882
25685
  const slotIndex = vaultState.externalLiquidity.findIndex(
24883
25686
  (slot) => slot.data[0] === 1
@@ -24895,12 +25698,12 @@ var IdleLiquidityService = class {
24895
25698
  if (data.length < 40) {
24896
25699
  throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
24897
25700
  }
24898
- const positionPk = new import_web342.PublicKey(new Uint8Array(data.slice(8, 40)));
25701
+ const positionPk = new import_web344.PublicKey(new Uint8Array(data.slice(8, 40)));
24899
25702
  const positionInfo = await connection.getAccountInfo(
24900
25703
  positionPk,
24901
25704
  "confirmed"
24902
25705
  );
24903
- if (!positionInfo || !positionInfo.owner.equals(new import_web342.PublicKey(import_marginfi6.MARGINFI_PROGRAM_ID))) {
25706
+ if (!positionInfo || !positionInfo.owner.equals(new import_web344.PublicKey(import_marginfi6.MARGINFI_PROGRAM_ID))) {
24904
25707
  throw new Error(
24905
25708
  `Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
24906
25709
  );
@@ -24949,17 +25752,17 @@ var IdleLiquidityService = class {
24949
25752
  if (slot.data[0] !== 2) continue;
24950
25753
  if (slot.data.length < 40)
24951
25754
  throw new Error(`Invalid Kamino external-liquidity slot ${index}`);
24952
- const key = new import_web342.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
24953
- if (key.equals(import_web342.PublicKey.default))
25755
+ const key = new import_web344.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
25756
+ if (key.equals(import_web344.PublicKey.default))
24954
25757
  throw new Error(`Missing Kamino position in slot ${index}`);
24955
25758
  if (seen.has(key.toBase58())) continue;
24956
25759
  seen.add(key.toBase58());
24957
25760
  const position = await loadWithdrawalPosition({
24958
25761
  connection: this.client.provider.connection,
24959
25762
  vault,
24960
- assetMint: import_common63.USDC_MINT,
25763
+ assetMint: import_common65.USDC_MINT,
24961
25764
  vaultAssetAta,
24962
- tokenProgram: (0, import_common63.fromWeb3Pk)(import_spl_token24.TOKEN_PROGRAM_ID),
25765
+ tokenProgram: (0, import_common65.fromWeb3Pk)(import_spl_token26.TOKEN_PROGRAM_ID),
24963
25766
  slot,
24964
25767
  index,
24965
25768
  requireUsablePosition: true
@@ -25010,8 +25813,8 @@ var IdleLiquidityService = class {
25010
25813
  log(`Vault ${vault}: ${reason} \u2014 skipping`);
25011
25814
  return { result: { ...empty, status: "no-tvl", reason } };
25012
25815
  }
25013
- const usdc = findHolding2(vaultState, import_common63.USDC_MINT);
25014
- const pst = findHolding2(vaultState, import_common63.PST_MINT);
25816
+ const usdc = findHolding2(vaultState, import_common65.USDC_MINT);
25817
+ const pst = findHolding2(vaultState, import_common65.PST_MINT);
25015
25818
  if (!usdc || !pst) {
25016
25819
  const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
25017
25820
  log(`Vault ${vault}: ${reason} \u2014 skipping`);
@@ -25162,16 +25965,16 @@ var IdleLiquidityService = class {
25162
25965
  */
25163
25966
  async mintTokenProgram(mint) {
25164
25967
  const account = await this.client.provider.connection.getAccountInfo(
25165
- new import_web342.PublicKey(mint),
25968
+ new import_web344.PublicKey(mint),
25166
25969
  "confirmed"
25167
25970
  );
25168
25971
  if (!account) throw new Error(`Mint account not found: ${mint}`);
25169
- if (!account.owner.equals(import_spl_token24.TOKEN_PROGRAM_ID) && !account.owner.equals(import_spl_token24.TOKEN_2022_PROGRAM_ID)) {
25972
+ if (!account.owner.equals(import_spl_token26.TOKEN_PROGRAM_ID) && !account.owner.equals(import_spl_token26.TOKEN_2022_PROGRAM_ID)) {
25170
25973
  throw new Error(
25171
25974
  `Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
25172
25975
  );
25173
25976
  }
25174
- return (0, import_common63.fromWeb3Pk)(account.owner);
25977
+ return (0, import_common65.fromWeb3Pk)(account.owner);
25175
25978
  }
25176
25979
  /**
25177
25980
  * Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
@@ -25191,23 +25994,23 @@ var IdleLiquidityService = class {
25191
25994
  dryRun,
25192
25995
  log
25193
25996
  } = params;
25194
- const signer = (0, import_common63.fromWeb3Pk)(hwManager.publicKey);
25997
+ const signer = (0, import_common65.fromWeb3Pk)(hwManager.publicKey);
25195
25998
  const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
25196
- this.mintTokenProgram(import_common63.PST_MINT),
25197
- this.mintTokenProgram(import_common63.USDC_MINT)
25999
+ this.mintTokenProgram(import_common65.PST_MINT),
26000
+ this.mintTokenProgram(import_common65.USDC_MINT)
25198
26001
  ]);
25199
26002
  const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
25200
26003
  payer: signer
25201
26004
  });
25202
- const { accounts: accounts2, refs, lookupTables } = (0, import_common63.createCpiRefs)([jupiterCpi]);
26005
+ const { accounts: accounts2, refs, lookupTables } = (0, import_common65.createCpiRefs)([jupiterCpi]);
25203
26006
  const vaultTrancheState = coerceBool4(
25204
26007
  vaultState.tranchingEnabled
25205
26008
  ) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
25206
26009
  const plan = await this.client.tx.jupiterSwap.getTx({
25207
26010
  hwManager: signer,
25208
26011
  vault,
25209
- sourceMint: import_common63.PST_MINT,
25210
- destinationMint: import_common63.USDC_MINT,
26012
+ sourceMint: import_common65.PST_MINT,
26013
+ destinationMint: import_common65.USDC_MINT,
25211
26014
  refs,
25212
26015
  accounts: accounts2,
25213
26016
  sourceTokenProgram,
@@ -25217,26 +26020,26 @@ var IdleLiquidityService = class {
25217
26020
  });
25218
26021
  const connection = this.client.provider.connection;
25219
26022
  const instructions2 = [
25220
- import_web342.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
26023
+ import_web344.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
25221
26024
  ...cuPriceMicroLamports > 0 ? [
25222
- import_web342.ComputeBudgetProgram.setComputeUnitPrice({
26025
+ import_web344.ComputeBudgetProgram.setComputeUnitPrice({
25223
26026
  microLamports: cuPriceMicroLamports
25224
26027
  })
25225
26028
  ] : [],
25226
- ...(jupiterCpi.preInstructions ?? []).map(import_common63.fromKitInstruction),
25227
- ...plan.instructions.map(import_common63.fromKitInstruction)
26029
+ ...(jupiterCpi.preInstructions ?? []).map(import_common65.fromKitInstruction),
26030
+ ...plan.instructions.map(import_common65.fromKitInstruction)
25228
26031
  ];
25229
26032
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
25230
- const lookupTableAccounts = await (0, import_common63.fetchLookupTables)(
26033
+ const lookupTableAccounts = await (0, import_common65.fetchLookupTables)(
25231
26034
  connection,
25232
26035
  plan.lookupTables ?? []
25233
26036
  );
25234
- const message2 = new import_web342.TransactionMessage({
26037
+ const message2 = new import_web344.TransactionMessage({
25235
26038
  payerKey: hwManager.publicKey,
25236
26039
  recentBlockhash: blockhash,
25237
26040
  instructions: instructions2
25238
26041
  }).compileToV0Message(lookupTableAccounts);
25239
- const transaction = new import_web342.VersionedTransaction(message2);
26042
+ const transaction = new import_web344.VersionedTransaction(message2);
25240
26043
  transaction.sign([hwManager]);
25241
26044
  if (!this.client.skipSimulation) {
25242
26045
  const simulation = await connection.simulateTransaction(transaction, {
@@ -25282,9 +26085,9 @@ var IdleLiquidityService = class {
25282
26085
 
25283
26086
  // src/services/timelockSettlementService.ts
25284
26087
  var import_kit24 = require("@solana/kit");
25285
- var import_web343 = require("@solana/web3.js");
25286
- var import_common64 = __toESM(require_dist());
25287
- var ZERO_PUBKEY = import_web343.PublicKey.default.toBase58();
26088
+ var import_web345 = require("@solana/web3.js");
26089
+ var import_common66 = __toESM(require_dist());
26090
+ var ZERO_PUBKEY = import_web345.PublicKey.default.toBase58();
25288
26091
  var CONSENSUS_SIGNER_CAPACITY = 4;
25289
26092
  var CONSENSUS_ENTRY_OFFSET = 40;
25290
26093
  var CONSENSUS_ENTRY_SIZE = 272;
@@ -25324,7 +26127,7 @@ function decodePendingConsensusSigners(data) {
25324
26127
  const signers = [];
25325
26128
  for (let i = 0; i < count; i += 1) {
25326
26129
  const start = CONSENSUS_PENDING_OFFSET + i * 32;
25327
- const signer = new import_web343.PublicKey(bytes.slice(start, start + 32)).toBase58();
26130
+ const signer = new import_web345.PublicKey(bytes.slice(start, start + 32)).toBase58();
25328
26131
  if (signer === ZERO_PUBKEY) {
25329
26132
  throw new Error(`pending consensus signer ${i} is unset`);
25330
26133
  }
@@ -25380,7 +26183,7 @@ var TimelockSettlementService = class {
25380
26183
  });
25381
26184
  const dryRun = opts.dryRun ?? false;
25382
26185
  const now = opts.now ?? await this.chainTime();
25383
- const fulfillerAddress = (0, import_common64.fromWeb3Pk)(fulfiller.publicKey);
26186
+ const fulfillerAddress = (0, import_common66.fromWeb3Pk)(fulfiller.publicKey);
25384
26187
  const allVaults = opts.vault ? [
25385
26188
  {
25386
26189
  publicKey: opts.vault,
@@ -25523,18 +26326,18 @@ var TimelockSettlementService = class {
25523
26326
 
25524
26327
  // src/services/nestWithdrawalService.ts
25525
26328
  var import_kit25 = require("@solana/kit");
25526
- var import_spl_token25 = require("@solana/spl-token");
25527
- var import_web344 = require("@solana/web3.js");
25528
- var import_common65 = __toESM(require_dist());
26329
+ var import_spl_token27 = require("@solana/spl-token");
26330
+ var import_web346 = require("@solana/web3.js");
26331
+ var import_common67 = __toESM(require_dist());
25529
26332
  var import_nest3 = __toESM(require_dist4());
25530
26333
  var import_nest4 = __toESM(require_dist4());
25531
- var NestOftProgram = new import_web344.PublicKey(
26334
+ var NestOftProgram = new import_web346.PublicKey(
25532
26335
  "ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
25533
26336
  );
25534
- var NestOftStore = new import_web344.PublicKey(
26337
+ var NestOftStore = new import_web346.PublicKey(
25535
26338
  "k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
25536
26339
  );
25537
- var UsdcMint = new import_web344.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26340
+ var UsdcMint = new import_web346.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
25538
26341
  var NestPerenaComposer = Buffer.from(
25539
26342
  "000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
25540
26343
  "hex"
@@ -25551,7 +26354,7 @@ async function buildNestWithdrawalRequest(args) {
25551
26354
  return decodeNestWithdrawalRequest({ ...args, txBase64 });
25552
26355
  }
25553
26356
  async function decodeNestWithdrawalRequest(args) {
25554
- const transaction = import_web344.VersionedTransaction.deserialize(
26357
+ const transaction = import_web346.VersionedTransaction.deserialize(
25555
26358
  Buffer.from(args.txBase64, "base64")
25556
26359
  );
25557
26360
  const message2 = transaction.message;
@@ -25572,19 +26375,19 @@ async function decodeNestWithdrawalRequest(args) {
25572
26375
  return value;
25573
26376
  })
25574
26377
  );
25575
- const decoded = import_web344.TransactionMessage.decompile(message2, {
26378
+ const decoded = import_web346.TransactionMessage.decompile(message2, {
25576
26379
  addressLookupTableAccounts: tables
25577
26380
  });
25578
- const nestMint = new import_web344.PublicKey(NEST_RWA_SHARE_MINT);
25579
- const sourceAta = (0, import_spl_token25.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
25580
- const usdcAta = (0, import_spl_token25.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
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);
25581
26384
  const instructions2 = decoded.instructions.filter(
25582
- (ix) => !ix.programId.equals(import_web344.ComputeBudgetProgram.programId)
26385
+ (ix) => !ix.programId.equals(import_web346.ComputeBudgetProgram.programId)
25583
26386
  );
25584
26387
  let sends = 0;
25585
26388
  for (const ix of instructions2) {
25586
- if (ix.programId.equals(import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID)) {
25587
- 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_token25.TOKEN_PROGRAM_ID)) {
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)) {
25588
26391
  throw new Error("Unexpected token account creation in Nest withdrawal");
25589
26392
  }
25590
26393
  continue;
@@ -25601,20 +26404,20 @@ async function decodeNestWithdrawalRequest(args) {
25601
26404
  if (sends !== 1)
25602
26405
  throw new Error("Nest withdrawal must contain exactly one OFT send");
25603
26406
  return {
25604
- instructions: instructions2.map(import_common65.toKitInstruction),
26407
+ instructions: instructions2.map(import_common67.toKitInstruction),
25605
26408
  lookupTables: tables.map((table) => (0, import_kit25.address)(table.key.toBase58()))
25606
26409
  };
25607
26410
  }
25608
26411
 
25609
26412
  // src/services/nestDepositService.ts
25610
26413
  var import_kit26 = require("@solana/kit");
25611
- var import_spl_token26 = require("@solana/spl-token");
25612
- var import_web345 = require("@solana/web3.js");
25613
- var import_common66 = __toESM(require_dist());
26414
+ var import_spl_token28 = require("@solana/spl-token");
26415
+ var import_web347 = require("@solana/web3.js");
26416
+ var import_common68 = __toESM(require_dist());
25614
26417
  var import_nest5 = __toESM(require_dist4());
25615
- var Usdc = new import_web345.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
25616
- var Messenger = new import_web345.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
25617
- var Transmitter = new import_web345.PublicKey(
26418
+ var Usdc = new import_web347.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26419
+ var Messenger = new import_web347.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
26420
+ var Transmitter = new import_web347.PublicKey(
25618
26421
  "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
25619
26422
  );
25620
26423
  var Router = Buffer.from(
@@ -25667,7 +26470,7 @@ async function decodeNestDepositRequest(args) {
25667
26470
  "Nest deposit must be a positive, safely representable USDC base-unit amount"
25668
26471
  );
25669
26472
  }
25670
- const message2 = import_web345.VersionedTransaction.deserialize(
26473
+ const message2 = import_web347.VersionedTransaction.deserialize(
25671
26474
  Buffer.from(args.txBase64, "base64")
25672
26475
  ).message;
25673
26476
  if (!message2.staticAccountKeys[0].equals(args.owner))
@@ -25682,23 +26485,23 @@ async function decodeNestDepositRequest(args) {
25682
26485
  return value;
25683
26486
  })
25684
26487
  );
25685
- const instructions2 = import_web345.TransactionMessage.decompile(message2, {
26488
+ const instructions2 = import_web347.TransactionMessage.decompile(message2, {
25686
26489
  addressLookupTableAccounts: tables
25687
26490
  }).instructions;
25688
- const shareMint = new import_web345.PublicKey(NEST_RWA_SHARE_MINT);
25689
- const shareAta = (0, import_spl_token26.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
25690
- const usdcAta = (0, import_spl_token26.getAssociatedTokenAddressSync)(Usdc, args.owner, true);
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);
25691
26494
  let burn;
25692
26495
  for (const ix of instructions2) {
25693
- if (ix.programId.equals(import_web345.ComputeBudgetProgram.programId)) continue;
25694
- if (ix.programId.equals(import_spl_token26.ASSOCIATED_TOKEN_PROGRAM_ID)) {
25695
- 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_web345.SystemProgram.programId) || !ix.keys[5]?.pubkey.equals(import_spl_token26.TOKEN_PROGRAM_ID))
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))
25696
26499
  throw new Error("Unexpected Nest deposit token account creation");
25697
26500
  continue;
25698
26501
  }
25699
26502
  const d = ix.data;
25700
26503
  const matches = (index, key) => ix.keys[index]?.pubkey.equals(key);
25701
- 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_token26.TOKEN_PROGRAM_ID) || !matches(15, import_web345.SystemProgram.programId) || !matches(17, Messenger) || ![0, 1, 11].every((index) => ix.keys[index].isSigner) || ix.keys.some(
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(
25702
26505
  (meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
25703
26506
  )) {
25704
26507
  throw new Error(
@@ -25717,33 +26520,33 @@ async function decodeNestDepositRequest(args) {
25717
26520
  burn.keys[1] = { pubkey: args.owner, isSigner: true, isWritable: true };
25718
26521
  return {
25719
26522
  instructions: [
25720
- (0, import_spl_token26.createAssociatedTokenAccountIdempotentInstruction)(
26523
+ (0, import_spl_token28.createAssociatedTokenAccountIdempotentInstruction)(
25721
26524
  args.owner,
25722
26525
  shareAta,
25723
26526
  args.owner,
25724
26527
  shareMint
25725
26528
  ),
25726
26529
  burn
25727
- ].map(import_common66.toKitInstruction),
26530
+ ].map(import_common68.toKitInstruction),
25728
26531
  lookupTables: tables.map((table) => (0, import_kit26.address)(table.key.toBase58())),
25729
26532
  ephemeralSignerKeys: [eventKey]
25730
26533
  };
25731
26534
  }
25732
26535
 
25733
26536
  // src/services/vaultLutManager.ts
25734
- var import_web346 = require("@solana/web3.js");
26537
+ var import_web348 = require("@solana/web3.js");
25735
26538
  var MAX_LUT_ADDRESSES = 256;
25736
26539
  var ACTIVE = (1n << 64n) - 1n;
25737
26540
  var asAddress = (key) => key.toBase58();
25738
26541
  function uniqueLutAddresses(addresses) {
25739
- return [...new Set(addresses)].filter((a) => a !== import_web346.PublicKey.default.toBase58()).map((a) => asAddress(new import_web346.PublicKey(a)));
26542
+ return [...new Set(addresses)].filter((a) => a !== import_web348.PublicKey.default.toBase58()).map((a) => asAddress(new import_web348.PublicKey(a)));
25740
26543
  }
25741
26544
  var VaultLutManager = class {
25742
26545
  constructor(connection) {
25743
26546
  this.connection = connection;
25744
26547
  }
25745
26548
  async fetch(table) {
25746
- const account = (await this.connection.getAddressLookupTable(new import_web346.PublicKey(table), {
26549
+ const account = (await this.connection.getAddressLookupTable(new import_web348.PublicKey(table), {
25747
26550
  commitment: "confirmed"
25748
26551
  })).value;
25749
26552
  if (!account) throw new Error(`Lookup table not found: ${table}`);
@@ -25755,14 +26558,14 @@ var VaultLutManager = class {
25755
26558
  * mapping is lost. Also accepts older tables containing the vault elsewhere. */
25756
26559
  async findForVault(authority, vault) {
25757
26560
  const accounts2 = await this.connection.getProgramAccounts(
25758
- import_web346.AddressLookupTableProgram.programId,
26561
+ import_web348.AddressLookupTableProgram.programId,
25759
26562
  {
25760
26563
  commitment: "confirmed",
25761
26564
  filters: [{ memcmp: { offset: 22, bytes: authority.toBase58() } }]
25762
26565
  }
25763
26566
  );
25764
26567
  return accounts2.flatMap(({ pubkey: pubkey2, account }) => {
25765
- const state = import_web346.AddressLookupTableAccount.deserialize(account.data);
26568
+ const state = import_web348.AddressLookupTableAccount.deserialize(account.data);
25766
26569
  return state.deactivationSlot === ACTIVE && state.authority?.equals(authority) && state.addresses.some((a) => a.toBase58() === vault) ? [asAddress(pubkey2)] : [];
25767
26570
  });
25768
26571
  }
@@ -25794,7 +26597,7 @@ var VaultLutManager = class {
25794
26597
  let created = false;
25795
26598
  const send = async (instructions2) => {
25796
26599
  const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash("confirmed");
25797
- const tx = new import_web346.Transaction({
26600
+ const tx = new import_web348.Transaction({
25798
26601
  feePayer: args.payer.publicKey,
25799
26602
  blockhash,
25800
26603
  lastValidBlockHeight
@@ -25821,7 +26624,7 @@ var VaultLutManager = class {
25821
26624
  };
25822
26625
  if (!table) {
25823
26626
  const hashes = await this.connection.getAccountInfo(
25824
- import_web346.SYSVAR_SLOT_HASHES_PUBKEY,
26627
+ import_web348.SYSVAR_SLOT_HASHES_PUBKEY,
25825
26628
  "confirmed"
25826
26629
  );
25827
26630
  if (!hashes || hashes.data.length < 48 || hashes.data.readBigUInt64LE(0) === 0n)
@@ -25829,7 +26632,7 @@ var VaultLutManager = class {
25829
26632
  const recentSlot = Number(hashes.data.readBigUInt64LE(8));
25830
26633
  if (!Number.isSafeInteger(recentSlot))
25831
26634
  throw new Error("Recent slot exceeds safe integer range");
25832
- const [create, key] = import_web346.AddressLookupTableProgram.createLookupTable({
26635
+ const [create, key] = import_web348.AddressLookupTableProgram.createLookupTable({
25833
26636
  authority: authority.publicKey,
25834
26637
  payer: args.payer.publicKey,
25835
26638
  recentSlot
@@ -25844,11 +26647,11 @@ var VaultLutManager = class {
25844
26647
  args.onProgress?.(`Creating vault LUT: ${table}`);
25845
26648
  await send([
25846
26649
  create,
25847
- import_web346.AddressLookupTableProgram.extendLookupTable({
26650
+ import_web348.AddressLookupTableProgram.extendLookupTable({
25848
26651
  lookupTable: key,
25849
26652
  authority: authority.publicKey,
25850
26653
  payer: args.payer.publicKey,
25851
- addresses: [new import_web346.PublicKey(args.vault)]
26654
+ addresses: [new import_web348.PublicKey(args.vault)]
25852
26655
  })
25853
26656
  ]);
25854
26657
  created = true;
@@ -25868,11 +26671,11 @@ var VaultLutManager = class {
25868
26671
  for (let i = 0; i < missing.length; i += 20) {
25869
26672
  const batch = missing.slice(i, i + 20);
25870
26673
  await send([
25871
- import_web346.AddressLookupTableProgram.extendLookupTable({
25872
- lookupTable: new import_web346.PublicKey(table),
26674
+ import_web348.AddressLookupTableProgram.extendLookupTable({
26675
+ lookupTable: new import_web348.PublicKey(table),
25873
26676
  authority: authority.publicKey,
25874
26677
  payer: args.payer.publicKey,
25875
- addresses: batch.map((a) => new import_web346.PublicKey(a))
26678
+ addresses: batch.map((a) => new import_web348.PublicKey(a))
25876
26679
  })
25877
26680
  ]);
25878
26681
  args.onProgress?.(
@@ -25894,13 +26697,13 @@ var VaultLutManager = class {
25894
26697
  };
25895
26698
 
25896
26699
  // src/services/vaultLookupTableAccounts.ts
25897
- var import_core25 = require("@anchor-lang/core");
25898
- var import_web347 = require("@solana/web3.js");
25899
- var import_spl_token27 = require("@solana/spl-token");
26700
+ var import_core26 = require("@anchor-lang/core");
26701
+ var import_web349 = require("@solana/web3.js");
26702
+ var import_spl_token29 = require("@solana/spl-token");
25900
26703
  var import_marginfi_client_v25 = require("@mrgnlabs/marginfi-client-v2");
25901
26704
  var import_Obligation3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
25902
26705
  var import_Reserve3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
25903
- var import_common67 = __toESM(require_dist());
26706
+ var import_common69 = __toESM(require_dist());
25904
26707
  var import_marginfi7 = __toESM(require_dist2());
25905
26708
  var import_kamino6 = __toESM(require_dist3());
25906
26709
  async function collectVaultLookupTableAccounts(client, vault, options = {}) {
@@ -25915,13 +26718,13 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
25915
26718
  const add = (key) => addresses.push(typeof key === "string" ? key : key.toBase58());
25916
26719
  [
25917
26720
  client.program.programId,
25918
- import_spl_token27.ASSOCIATED_TOKEN_PROGRAM_ID,
25919
- import_spl_token27.TOKEN_PROGRAM_ID,
25920
- import_spl_token27.TOKEN_2022_PROGRAM_ID,
25921
- import_web347.SYSVAR_INSTRUCTIONS_PUBKEY
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
25922
26725
  ].forEach(add);
25923
26726
  const publicKeys = (value) => {
25924
- if (value instanceof import_web347.PublicKey) {
26727
+ if (value instanceof import_web349.PublicKey) {
25925
26728
  add(value);
25926
26729
  return;
25927
26730
  }
@@ -25940,7 +26743,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
25940
26743
  }
25941
26744
  ];
25942
26745
  const tranche = await client.program.account.vaultTrancheState.fetchNullable(
25943
- new import_web347.PublicKey(tranchePda)
26746
+ new import_web349.PublicKey(tranchePda)
25944
26747
  );
25945
26748
  if (tranche) {
25946
26749
  publicKeys(tranche.config);
@@ -25960,30 +26763,30 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
25960
26763
  );
25961
26764
  }
25962
26765
  const holdings = state.holdings.filter(
25963
- (h) => !h.mint.equals(import_web347.PublicKey.default)
26766
+ (h) => !h.mint.equals(import_web349.PublicKey.default)
25964
26767
  );
25965
26768
  for (const h of holdings) {
25966
26769
  const mint = h.mint.toBase58(), program = tokenProgramAddressFromIdlEnum(h.tokenProgram);
25967
26770
  add(mint);
25968
26771
  add(program);
25969
- add((0, import_common67.getAtaAddress)(mint, vault, program, true));
25970
- add((0, import_common67.getAtaAddress)(mint, fee, program, true));
25971
- if (options.user) add((0, import_common67.getAtaAddress)(mint, options.user, program, true));
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));
25972
26775
  }
25973
26776
  for (const share of shares) {
25974
26777
  add(share.mint);
25975
26778
  add(share.program);
25976
- add((0, import_common67.getAtaAddress)(share.mint, vault, share.program, true));
25977
- add((0, import_common67.getAtaAddress)(share.mint, fee, share.program, true));
26779
+ add((0, import_common69.getAtaAddress)(share.mint, vault, share.program, true));
26780
+ add((0, import_common69.getAtaAddress)(share.mint, fee, share.program, true));
25978
26781
  if (options.user)
25979
- add((0, import_common67.getAtaAddress)(share.mint, options.user, share.program, true));
26782
+ add((0, import_common69.getAtaAddress)(share.mint, options.user, share.program, true));
25980
26783
  }
25981
26784
  const slots = state.externalLiquidity.filter(
25982
26785
  (s) => [1, 2].includes(s.data[0])
25983
26786
  );
25984
26787
  for (const slot of slots) {
25985
- const position = new import_web347.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
25986
- if (position.equals(import_web347.PublicKey.default)) continue;
26788
+ const position = new import_web349.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
26789
+ if (position.equals(import_web349.PublicKey.default)) continue;
25987
26790
  add(position);
25988
26791
  const info = await connection.getAccountInfo(position, "confirmed");
25989
26792
  if (slot.data[0] === 1) {
@@ -25994,7 +26797,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
25994
26797
  const cpi = new import_marginfi7.CpiClient({ accounts: config }).withdraw_cpi({
25995
26798
  marginfiAccount: position.toBase58(),
25996
26799
  authority: vault,
25997
- destinationTokenAccount: (0, import_common67.getAtaAddress)(
26800
+ destinationTokenAccount: (0, import_common69.getAtaAddress)(
25998
26801
  mint,
25999
26802
  vault,
26000
26803
  config.tokenProgram,
@@ -26006,7 +26809,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26006
26809
  if (!info) continue;
26007
26810
  if (info.owner.toBase58() !== import_marginfi7.MARGINFI_PROGRAM_ID)
26008
26811
  throw new Error("Invalid Marginfi position owner");
26009
- const idl = new import_core25.Program(
26812
+ const idl = new import_core26.Program(
26010
26813
  { ...import_marginfi_client_v25.MARGINFI_IDL, address: import_marginfi7.MARGINFI_PROGRAM_ID },
26011
26814
  { connection }
26012
26815
  ).idl;
@@ -26047,7 +26850,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26047
26850
  if (!reserveKeys.length)
26048
26851
  throw new Error(`No reserves found for Kamino obligation ${position}`);
26049
26852
  const infos = await connection.getMultipleAccountsInfo(
26050
- reserveKeys.map((a) => new import_web347.PublicKey(a)),
26853
+ reserveKeys.map((a) => new import_web349.PublicKey(a)),
26051
26854
  "confirmed"
26052
26855
  );
26053
26856
  const reserves = infos.map((info2, i) => {
@@ -26077,7 +26880,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26077
26880
  obligation: position.toBase58(),
26078
26881
  reserves,
26079
26882
  reserve,
26080
- destination: (0, import_common67.getAtaAddress)(
26883
+ destination: (0, import_common69.getAtaAddress)(
26081
26884
  reserve.liquidityMint,
26082
26885
  vault,
26083
26886
  reserve.liquidityTokenProgram,
@@ -26097,7 +26900,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26097
26900
  }
26098
26901
 
26099
26902
  // src/index.ts
26100
- var import_common68 = __toESM(require_dist());
26903
+ var import_common70 = __toESM(require_dist());
26101
26904
  // Annotate the CommonJS export names for ESM import in node:
26102
26905
  0 && (module.exports = {
26103
26906
  ASSET_DECIMALS,
@@ -26151,6 +26954,7 @@ var import_common68 = __toESM(require_dist());
26151
26954
  ExternalLiquidityIntegrityService,
26152
26955
  ExternalPositionRegistry,
26153
26956
  FEE_VAULT_CACHE_CATEGORY,
26957
+ FulfillAsyncWithdrawBuilder,
26154
26958
  FulfillJuniorTrancheWithdrawBuilder,
26155
26959
  IDL,
26156
26960
  IDLE_RESERVE_FLOOR_BPS,
@@ -26205,6 +27009,7 @@ var import_common68 = __toESM(require_dist());
26205
27009
  REPORTABLE_ORACLE_VARIANTS,
26206
27010
  RemoveAssetHoldingBuilder,
26207
27011
  ReportIncentiveV3Builder,
27012
+ RequestAsyncWithdrawBuilder,
26208
27013
  RequestJuniorTrancheWithdrawBuilder,
26209
27014
  RpcManagerWalletBalanceSource,
26210
27015
  RpcMpcWalletBalanceSource,
@@ -26249,6 +27054,7 @@ var import_common68 = __toESM(require_dist());
26249
27054
  VaultLutManager,
26250
27055
  VaultQuoteClient,
26251
27056
  VaultReallocationBuilder,
27057
+ WALLET_FEE_EXEMPT_WHITELIST,
26252
27058
  WITHDRAWABLE_RESERVE_FLOOR_BPS,
26253
27059
  WithdrawalQueueService,
26254
27060
  accountingUnitPriceToUsd,
@@ -26347,6 +27153,7 @@ var import_common68 = __toESM(require_dist());
26347
27153
  previousPhysicalNav,
26348
27154
  priceInAccountingUnit,
26349
27155
  publishedConsensusBlockers,
27156
+ quoteWithdrawalPayout,
26350
27157
  readI64LE,
26351
27158
  readSplMintSupply,
26352
27159
  reconcileManagerWalletBalances,