@perena/vault-sdk 1.0.66 → 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 = {
@@ -7342,16 +7349,16 @@ var IDL = {
7342
7349
  ]
7343
7350
  },
7344
7351
  {
7345
- "name": "fulfill_junior_tranche_withdraw",
7352
+ "name": "fulfill_async_withdraw",
7346
7353
  "discriminator": [
7347
- 127,
7348
- 229,
7349
- 153,
7350
- 168,
7351
- 116,
7352
- 50,
7353
- 248,
7354
- 103
7354
+ 115,
7355
+ 156,
7356
+ 99,
7357
+ 78,
7358
+ 105,
7359
+ 35,
7360
+ 212,
7361
+ 150
7355
7362
  ],
7356
7363
  "accounts": [
7357
7364
  {
@@ -7375,7 +7382,7 @@ var IDL = {
7375
7382
  },
7376
7383
  {
7377
7384
  "name": "vault_tranche_state",
7378
- "writable": true
7385
+ "optional": true
7379
7386
  },
7380
7387
  {
7381
7388
  "name": "withdrawal_queue",
@@ -7598,16 +7605,16 @@ var IDL = {
7598
7605
  ]
7599
7606
  },
7600
7607
  {
7601
- "name": "fulfill_junior_tranche_withdraw_fee_exempt",
7608
+ "name": "fulfill_junior_tranche_withdraw",
7602
7609
  "discriminator": [
7603
- 148,
7604
- 163,
7605
- 159,
7606
- 43,
7607
- 165,
7608
- 131,
7609
- 51,
7610
- 85
7610
+ 127,
7611
+ 229,
7612
+ 153,
7613
+ 168,
7614
+ 116,
7615
+ 50,
7616
+ 248,
7617
+ 103
7611
7618
  ],
7612
7619
  "accounts": [
7613
7620
  {
@@ -7850,150 +7857,119 @@ var IDL = {
7850
7857
  "type": {
7851
7858
  "option": "u8"
7852
7859
  }
7853
- },
7854
- {
7855
- "name": "signer_seeds",
7856
- "type": {
7857
- "vec": "bytes"
7858
- }
7859
7860
  }
7860
7861
  ]
7861
7862
  },
7862
7863
  {
7863
- "name": "get_nav",
7864
+ "name": "fulfill_junior_tranche_withdraw_fee_exempt",
7864
7865
  "discriminator": [
7865
- 200,
7866
- 89,
7867
- 76,
7868
- 53,
7869
- 215,
7870
- 218,
7871
- 63,
7872
- 21
7866
+ 148,
7867
+ 163,
7868
+ 159,
7869
+ 43,
7870
+ 165,
7871
+ 131,
7872
+ 51,
7873
+ 85
7873
7874
  ],
7874
7875
  "accounts": [
7875
7876
  {
7876
- "name": "vault"
7877
- },
7878
- {
7879
- "name": "vault_tranche_state",
7880
- "optional": true
7877
+ "name": "signer",
7878
+ "writable": true,
7879
+ "signer": true
7881
7880
  },
7882
7881
  {
7883
- "name": "share_mint"
7882
+ "name": "owner"
7884
7883
  },
7885
7884
  {
7886
- "name": "user_share_ata"
7887
- }
7888
- ],
7889
- "args": [],
7890
- "returns": "u64"
7891
- },
7892
- {
7893
- "name": "get_tranche_nav",
7894
- "discriminator": [
7895
- 173,
7896
- 139,
7897
- 168,
7898
- 42,
7899
- 15,
7900
- 25,
7901
- 206,
7902
- 236
7903
- ],
7904
- "accounts": [
7905
- {
7906
- "name": "vault"
7885
+ "name": "queue_payer",
7886
+ "writable": true
7907
7887
  },
7908
7888
  {
7909
- "name": "vault_tranche_state"
7889
+ "name": "vault",
7890
+ "writable": true
7910
7891
  },
7911
7892
  {
7912
- "name": "tranche_share_mint"
7893
+ "name": "vault_oracle"
7913
7894
  },
7914
7895
  {
7915
- "name": "user_tranche_share_ata"
7916
- }
7917
- ],
7918
- "args": [
7919
- {
7920
- "name": "kind",
7921
- "type": {
7922
- "defined": {
7923
- "name": "TrancheKind"
7924
- }
7925
- }
7926
- }
7927
- ],
7928
- "returns": "u64"
7929
- },
7930
- {
7931
- "name": "initialize_vault_roles",
7932
- "docs": [
7933
- "Set manager and fulfiller roles directly, bypassing the timelock.",
7934
- "Only callable when both roles are still unset (i.e. `Pubkey::default()`).",
7935
- "Intended for use immediately after vault creation during migration."
7936
- ],
7937
- "discriminator": [
7938
- 227,
7939
- 251,
7940
- 100,
7941
- 86,
7942
- 154,
7943
- 59,
7944
- 199,
7945
- 29
7946
- ],
7947
- "accounts": [
7948
- {
7949
- "name": "curator",
7950
- "signer": true
7896
+ "name": "vault_tranche_state",
7897
+ "writable": true
7951
7898
  },
7952
7899
  {
7953
- "name": "vault",
7900
+ "name": "withdrawal_queue",
7954
7901
  "writable": true
7955
- }
7956
- ],
7957
- "args": [
7958
- {
7959
- "name": "args",
7960
- "type": {
7961
- "defined": {
7962
- "name": "InitializeVaultRolesArgs"
7963
- }
7964
- }
7965
- }
7966
- ]
7967
- },
7968
- {
7969
- "name": "jupiter_swap",
7970
- "discriminator": [
7971
- 116,
7972
- 207,
7973
- 0,
7974
- 196,
7975
- 252,
7976
- 120,
7977
- 243,
7978
- 18
7979
- ],
7980
- "accounts": [
7902
+ },
7981
7903
  {
7982
- "name": "hw_manager",
7983
- "signer": true
7904
+ "name": "output_mint"
7984
7905
  },
7985
7906
  {
7986
- "name": "vault",
7907
+ "name": "input_mint",
7987
7908
  "writable": true
7988
7909
  },
7989
7910
  {
7990
- "name": "source_mint"
7911
+ "name": "owner_input_ata",
7912
+ "writable": true
7991
7913
  },
7992
7914
  {
7993
- "name": "destination_mint"
7915
+ "name": "owner_output_ata",
7916
+ "writable": true,
7917
+ "pda": {
7918
+ "seeds": [
7919
+ {
7920
+ "kind": "account",
7921
+ "path": "owner"
7922
+ },
7923
+ {
7924
+ "kind": "account",
7925
+ "path": "asset_token_program"
7926
+ },
7927
+ {
7928
+ "kind": "account",
7929
+ "path": "output_mint"
7930
+ }
7931
+ ],
7932
+ "program": {
7933
+ "kind": "const",
7934
+ "value": [
7935
+ 140,
7936
+ 151,
7937
+ 37,
7938
+ 143,
7939
+ 78,
7940
+ 36,
7941
+ 137,
7942
+ 241,
7943
+ 187,
7944
+ 61,
7945
+ 16,
7946
+ 41,
7947
+ 20,
7948
+ 142,
7949
+ 13,
7950
+ 131,
7951
+ 11,
7952
+ 90,
7953
+ 19,
7954
+ 153,
7955
+ 218,
7956
+ 255,
7957
+ 16,
7958
+ 132,
7959
+ 4,
7960
+ 142,
7961
+ 123,
7962
+ 216,
7963
+ 219,
7964
+ 233,
7965
+ 248,
7966
+ 89
7967
+ ]
7968
+ }
7969
+ }
7994
7970
  },
7995
7971
  {
7996
- "name": "vault_source_ata",
7972
+ "name": "vault_output_ata",
7997
7973
  "writable": true,
7998
7974
  "pda": {
7999
7975
  "seeds": [
@@ -8003,11 +7979,11 @@ var IDL = {
8003
7979
  },
8004
7980
  {
8005
7981
  "kind": "account",
8006
- "path": "source_token_program"
7982
+ "path": "asset_token_program"
8007
7983
  },
8008
7984
  {
8009
7985
  "kind": "account",
8010
- "path": "source_mint"
7986
+ "path": "output_mint"
8011
7987
  }
8012
7988
  ],
8013
7989
  "program": {
@@ -8050,21 +8026,308 @@ var IDL = {
8050
8026
  }
8051
8027
  },
8052
8028
  {
8053
- "name": "vault_destination_ata",
8029
+ "name": "queue_input_ata",
8054
8030
  "writable": true,
8055
8031
  "pda": {
8056
8032
  "seeds": [
8057
8033
  {
8058
8034
  "kind": "account",
8059
- "path": "vault"
8035
+ "path": "withdrawal_queue"
8060
8036
  },
8061
8037
  {
8062
8038
  "kind": "account",
8063
- "path": "destination_token_program"
8039
+ "path": "share_token_program"
8064
8040
  },
8065
8041
  {
8066
8042
  "kind": "account",
8067
- "path": "destination_mint"
8043
+ "path": "input_mint"
8044
+ }
8045
+ ],
8046
+ "program": {
8047
+ "kind": "const",
8048
+ "value": [
8049
+ 140,
8050
+ 151,
8051
+ 37,
8052
+ 143,
8053
+ 78,
8054
+ 36,
8055
+ 137,
8056
+ 241,
8057
+ 187,
8058
+ 61,
8059
+ 16,
8060
+ 41,
8061
+ 20,
8062
+ 142,
8063
+ 13,
8064
+ 131,
8065
+ 11,
8066
+ 90,
8067
+ 19,
8068
+ 153,
8069
+ 218,
8070
+ 255,
8071
+ 16,
8072
+ 132,
8073
+ 4,
8074
+ 142,
8075
+ 123,
8076
+ 216,
8077
+ 219,
8078
+ 233,
8079
+ 248,
8080
+ 89
8081
+ ]
8082
+ }
8083
+ }
8084
+ },
8085
+ {
8086
+ "name": "asset_token_program"
8087
+ },
8088
+ {
8089
+ "name": "share_token_program"
8090
+ },
8091
+ {
8092
+ "name": "associated_token_program",
8093
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
8094
+ },
8095
+ {
8096
+ "name": "system_program",
8097
+ "address": "11111111111111111111111111111111"
8098
+ }
8099
+ ],
8100
+ "args": [
8101
+ {
8102
+ "name": "external_withdraw_ix_refs",
8103
+ "type": {
8104
+ "option": {
8105
+ "defined": {
8106
+ "name": "InstructionRefs"
8107
+ }
8108
+ }
8109
+ }
8110
+ },
8111
+ {
8112
+ "name": "external_liquidity_source",
8113
+ "type": {
8114
+ "option": "u8"
8115
+ }
8116
+ },
8117
+ {
8118
+ "name": "signer_seeds",
8119
+ "type": {
8120
+ "vec": "bytes"
8121
+ }
8122
+ }
8123
+ ]
8124
+ },
8125
+ {
8126
+ "name": "get_nav",
8127
+ "discriminator": [
8128
+ 200,
8129
+ 89,
8130
+ 76,
8131
+ 53,
8132
+ 215,
8133
+ 218,
8134
+ 63,
8135
+ 21
8136
+ ],
8137
+ "accounts": [
8138
+ {
8139
+ "name": "vault"
8140
+ },
8141
+ {
8142
+ "name": "vault_tranche_state",
8143
+ "optional": true
8144
+ },
8145
+ {
8146
+ "name": "share_mint"
8147
+ },
8148
+ {
8149
+ "name": "user_share_ata"
8150
+ }
8151
+ ],
8152
+ "args": [],
8153
+ "returns": "u64"
8154
+ },
8155
+ {
8156
+ "name": "get_tranche_nav",
8157
+ "discriminator": [
8158
+ 173,
8159
+ 139,
8160
+ 168,
8161
+ 42,
8162
+ 15,
8163
+ 25,
8164
+ 206,
8165
+ 236
8166
+ ],
8167
+ "accounts": [
8168
+ {
8169
+ "name": "vault"
8170
+ },
8171
+ {
8172
+ "name": "vault_tranche_state"
8173
+ },
8174
+ {
8175
+ "name": "tranche_share_mint"
8176
+ },
8177
+ {
8178
+ "name": "user_tranche_share_ata"
8179
+ }
8180
+ ],
8181
+ "args": [
8182
+ {
8183
+ "name": "kind",
8184
+ "type": {
8185
+ "defined": {
8186
+ "name": "TrancheKind"
8187
+ }
8188
+ }
8189
+ }
8190
+ ],
8191
+ "returns": "u64"
8192
+ },
8193
+ {
8194
+ "name": "initialize_vault_roles",
8195
+ "docs": [
8196
+ "Set manager and fulfiller roles directly, bypassing the timelock.",
8197
+ "Only callable when both roles are still unset (i.e. `Pubkey::default()`).",
8198
+ "Intended for use immediately after vault creation during migration."
8199
+ ],
8200
+ "discriminator": [
8201
+ 227,
8202
+ 251,
8203
+ 100,
8204
+ 86,
8205
+ 154,
8206
+ 59,
8207
+ 199,
8208
+ 29
8209
+ ],
8210
+ "accounts": [
8211
+ {
8212
+ "name": "curator",
8213
+ "signer": true
8214
+ },
8215
+ {
8216
+ "name": "vault",
8217
+ "writable": true
8218
+ }
8219
+ ],
8220
+ "args": [
8221
+ {
8222
+ "name": "args",
8223
+ "type": {
8224
+ "defined": {
8225
+ "name": "InitializeVaultRolesArgs"
8226
+ }
8227
+ }
8228
+ }
8229
+ ]
8230
+ },
8231
+ {
8232
+ "name": "jupiter_swap",
8233
+ "discriminator": [
8234
+ 116,
8235
+ 207,
8236
+ 0,
8237
+ 196,
8238
+ 252,
8239
+ 120,
8240
+ 243,
8241
+ 18
8242
+ ],
8243
+ "accounts": [
8244
+ {
8245
+ "name": "hw_manager",
8246
+ "signer": true
8247
+ },
8248
+ {
8249
+ "name": "vault",
8250
+ "writable": true
8251
+ },
8252
+ {
8253
+ "name": "source_mint"
8254
+ },
8255
+ {
8256
+ "name": "destination_mint"
8257
+ },
8258
+ {
8259
+ "name": "vault_source_ata",
8260
+ "writable": true,
8261
+ "pda": {
8262
+ "seeds": [
8263
+ {
8264
+ "kind": "account",
8265
+ "path": "vault"
8266
+ },
8267
+ {
8268
+ "kind": "account",
8269
+ "path": "source_token_program"
8270
+ },
8271
+ {
8272
+ "kind": "account",
8273
+ "path": "source_mint"
8274
+ }
8275
+ ],
8276
+ "program": {
8277
+ "kind": "const",
8278
+ "value": [
8279
+ 140,
8280
+ 151,
8281
+ 37,
8282
+ 143,
8283
+ 78,
8284
+ 36,
8285
+ 137,
8286
+ 241,
8287
+ 187,
8288
+ 61,
8289
+ 16,
8290
+ 41,
8291
+ 20,
8292
+ 142,
8293
+ 13,
8294
+ 131,
8295
+ 11,
8296
+ 90,
8297
+ 19,
8298
+ 153,
8299
+ 218,
8300
+ 255,
8301
+ 16,
8302
+ 132,
8303
+ 4,
8304
+ 142,
8305
+ 123,
8306
+ 216,
8307
+ 219,
8308
+ 233,
8309
+ 248,
8310
+ 89
8311
+ ]
8312
+ }
8313
+ }
8314
+ },
8315
+ {
8316
+ "name": "vault_destination_ata",
8317
+ "writable": true,
8318
+ "pda": {
8319
+ "seeds": [
8320
+ {
8321
+ "kind": "account",
8322
+ "path": "vault"
8323
+ },
8324
+ {
8325
+ "kind": "account",
8326
+ "path": "destination_token_program"
8327
+ },
8328
+ {
8329
+ "kind": "account",
8330
+ "path": "destination_mint"
8068
8331
  }
8069
8332
  ],
8070
8333
  "program": {
@@ -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
  },
@@ -13632,6 +14051,32 @@ var AccountClient = class extends import_common.BaseAccountClient {
13632
14051
  );
13633
14052
  return this.fetchVaultTrancheState(vaultTrancheState, opts);
13634
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
+ }
13635
14080
  async fetchVaultTrancheWithdrawalQueue(withdrawalQueue, opts) {
13636
14081
  if (opts?.fresh) {
13637
14082
  this.dataCache.clearCacheEntry(
@@ -13757,11 +14202,14 @@ var PdaClient = class {
13757
14202
  });
13758
14203
  }
13759
14204
  /**
13760
- * Junior tranche withdrawal queue PDA.
14205
+ * Shared withdrawal queue PDA for regular and junior shares.
13761
14206
  *
13762
14207
  * Seeds: `["vault_withdrawal_queue", vault, owner, queue_id]`
13763
14208
  */
13764
- 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
+ }
13765
14213
  return (0, import_kit4.getProgramDerivedAddress)({
13766
14214
  programAddress: this.programAddress,
13767
14215
  seeds: [
@@ -13772,6 +14220,10 @@ var PdaClient = class {
13772
14220
  ]
13773
14221
  });
13774
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
+ }
13775
14227
  };
13776
14228
 
13777
14229
  // src/client/quote.ts
@@ -15126,6 +15578,7 @@ function toAnchorSetVaultConfigArgs(args) {
15126
15578
  maxApyBps: args.maxApyBps,
15127
15579
  tvlLimit: args.tvlLimit,
15128
15580
  lossesEnabled: args.lossesEnabled,
15581
+ redemptionMode: args.redemptionMode ?? null,
15129
15582
  priceStalenessThresholdSecs: args.priceStalenessThresholdSecs,
15130
15583
  userBurnLimit: args.userBurnLimit,
15131
15584
  managerPullLimit: args.managerPullLimit,
@@ -15324,6 +15777,7 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
15324
15777
  maxApyBps: txArgs.maxApyBps ?? null,
15325
15778
  tvlLimit: txArgs.tvlLimit !== void 0 ? new import_core7.BN(txArgs.tvlLimit.toString()) : null,
15326
15779
  lossesEnabled: txArgs.lossesEnabled ?? null,
15780
+ redemptionMode: txArgs.redemptionMode ?? null,
15327
15781
  priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new import_core7.BN(txArgs.priceStalenessThresholdSecs.toString()) : null,
15328
15782
  userBurnLimit: txArgs.userBurnLimit !== void 0 ? {
15329
15783
  windowLimit: new import_core7.BN(
@@ -16639,7 +17093,7 @@ async function loadWithdrawalPosition(args) {
16639
17093
  }
16640
17094
 
16641
17095
  // src/client/builders/withdrawalPlan.ts
16642
- function payout(pricing, shares) {
17096
+ function quoteWithdrawalPayout(pricing, shares) {
16643
17097
  const gross = shares * pricing.value / pricing.supply;
16644
17098
  const fee = gross * BigInt(pricing.feeBps) / 10000n;
16645
17099
  const feeShares = shares * BigInt(pricing.feeBps) / 10000n;
@@ -16654,11 +17108,11 @@ function payout(pricing, shares) {
16654
17108
  }
16655
17109
  function isRedeemable(pricing, shares) {
16656
17110
  if (shares <= 0n) return false;
16657
- const quote = payout(pricing, shares);
17111
+ const quote = quoteWithdrawalPayout(pricing, shares);
16658
17112
  return quote.gross > 0n && (quote.net === 0n || quote.tokens > 0n) && (pricing.shareClass !== "regular" || quote.fee === 0n || quote.feeShares > 0n);
16659
17113
  }
16660
17114
  function afterBurn(pricing, shares) {
16661
- const quote = payout(pricing, shares);
17115
+ const quote = quoteWithdrawalPayout(pricing, shares);
16662
17116
  return {
16663
17117
  ...pricing,
16664
17118
  supply: pricing.supply - (pricing.shareClass === "regular" ? shares - quote.feeShares : shares),
@@ -16669,7 +17123,7 @@ function sharesWithinCapacity(pricing, remaining, capacity) {
16669
17123
  let low = 0n, high = remaining;
16670
17124
  while (low < high) {
16671
17125
  const mid = (low + high + 1n) / 2n;
16672
- if (payout(pricing, mid).tokens <= capacity) low = mid;
17126
+ if (quoteWithdrawalPayout(pricing, mid).tokens <= capacity) low = mid;
16673
17127
  else high = mid - 1n;
16674
17128
  }
16675
17129
  const maximum = low;
@@ -16693,7 +17147,7 @@ async function planWithdrawalLegs(args) {
16693
17147
  const pools = /* @__PURE__ */ new Map();
16694
17148
  const positions = /* @__PURE__ */ new Set();
16695
17149
  const append = (shares, position) => {
16696
- const quote = payout(pricing, shares);
17150
+ const quote = quoteWithdrawalPayout(pricing, shares);
16697
17151
  if (!isRedeemable(pricing, shares)) return false;
16698
17152
  const needed = quote.tokens > local ? quote.tokens - local : 0n;
16699
17153
  const receipt = needed > 0n ? position.receipt(needed) : 0n;
@@ -16715,7 +17169,8 @@ async function planWithdrawalLegs(args) {
16715
17169
  remaining -= shares;
16716
17170
  return true;
16717
17171
  };
16718
- if (payout(pricing, remaining).tokens <= local) append(remaining);
17172
+ if (quoteWithdrawalPayout(pricing, remaining).tokens <= local)
17173
+ append(remaining);
16719
17174
  else {
16720
17175
  for await (const position of args.positions) {
16721
17176
  if (positions.has(position.positionKey)) continue;
@@ -16732,7 +17187,7 @@ async function planWithdrawalLegs(args) {
16732
17187
  if (shares > 0n) append(shares, position);
16733
17188
  if (remaining === 0n) break;
16734
17189
  }
16735
- if (remaining > 0n && payout(pricing, remaining).tokens <= local)
17190
+ if (remaining > 0n && quoteWithdrawalPayout(pricing, remaining).tokens <= local)
16736
17191
  append(remaining);
16737
17192
  }
16738
17193
  if (remaining > 0n)
@@ -18123,131 +18578,419 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
18123
18578
  destinationVaultTrancheState: txArgs.destinationVaultTrancheState ?? null,
18124
18579
  assetOracleAccount: txArgs.assetOracleAccount ?? null,
18125
18580
  assetTokenProgram,
18126
- sourceShareTokenProgram,
18127
- destinationShareTokenProgram,
18128
- allocationMintAta: (0, import_common45.getAtaAddress)(
18129
- txArgs.mint,
18130
- txArgs.allocationVault,
18131
- assetTokenProgram,
18132
- true
18133
- ),
18134
- sourceVaultMintAta: sourceVault ? (0, import_common45.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
18135
- destinationVaultMintAta: (0, import_common45.getAtaAddress)(
18136
- txArgs.mint,
18137
- txArgs.destinationVault,
18581
+ sourceShareTokenProgram,
18582
+ destinationShareTokenProgram,
18583
+ allocationMintAta: (0, import_common45.getAtaAddress)(
18584
+ txArgs.mint,
18585
+ txArgs.allocationVault,
18586
+ assetTokenProgram,
18587
+ true
18588
+ ),
18589
+ sourceVaultMintAta: sourceVault ? (0, import_common45.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
18590
+ destinationVaultMintAta: (0, import_common45.getAtaAddress)(
18591
+ txArgs.mint,
18592
+ txArgs.destinationVault,
18593
+ assetTokenProgram,
18594
+ true
18595
+ ),
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,
18138
18926
  assetTokenProgram,
18139
18927
  true
18140
18928
  ),
18141
- destinationFeeVault,
18142
- destinationFeeVaultMintAta: (0, import_common45.getAtaAddress)(
18143
- txArgs.mint,
18144
- destinationFeeVault,
18145
- assetTokenProgram,
18929
+ vaultOutputAta,
18930
+ queueInputAta: (0, import_common47.getAtaAddress)(
18931
+ shareMint,
18932
+ queuePda,
18933
+ shareTokenProgram,
18146
18934
  true
18147
18935
  ),
18148
- allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common45.getAtaAddress)(
18149
- sourceShareMint,
18150
- txArgs.allocationVault,
18151
- sourceShareTokenProgram,
18152
- true
18153
- ) : null,
18154
- allocationDestinationShareAta: (0, import_common45.getAtaAddress)(
18155
- txArgs.destinationShareMint,
18156
- txArgs.allocationVault,
18157
- destinationShareTokenProgram,
18158
- true
18159
- )
18936
+ externalWithdrawIxRefs,
18937
+ externalLiquiditySource,
18938
+ externalWithdrawAccounts
18160
18939
  };
18161
18940
  }
18941
+ async buildLookupTables(args, txArgs) {
18942
+ return externalWithdrawLookupTables(
18943
+ args.externalWithdrawIxRefs,
18944
+ txArgs.lookupTables
18945
+ );
18946
+ }
18162
18947
  async buildPreambleInstructions(args) {
18163
- const payer = (0, import_common45.toWeb3Pk)(args.manager);
18164
- const instructions2 = [
18165
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18166
- payer,
18167
- (0, import_common45.toWeb3Pk)(args.allocationMintAta),
18168
- (0, import_common45.toWeb3Pk)(args.allocationVault),
18169
- (0, import_common45.toWeb3Pk)(args.mint),
18170
- (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18171
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18172
- ),
18173
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18174
- payer,
18175
- (0, import_common45.toWeb3Pk)(args.destinationVaultMintAta),
18176
- (0, import_common45.toWeb3Pk)(args.destinationVault),
18177
- (0, import_common45.toWeb3Pk)(args.mint),
18178
- (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18179
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18180
- ),
18181
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18182
- payer,
18183
- (0, import_common45.toWeb3Pk)(args.destinationFeeVaultMintAta),
18184
- (0, import_common45.toWeb3Pk)(args.destinationFeeVault),
18185
- (0, import_common45.toWeb3Pk)(args.mint),
18186
- (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18187
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18188
- ),
18189
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18190
- payer,
18191
- (0, import_common45.toWeb3Pk)(args.allocationDestinationShareAta),
18192
- (0, import_common45.toWeb3Pk)(args.allocationVault),
18193
- (0, import_common45.toWeb3Pk)(args.destinationShareMint),
18194
- (0, import_common45.toWeb3Pk)(args.destinationShareTokenProgram),
18195
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18196
- )
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
+ }
18197
18960
  ];
18198
- if (args.sourceVault && args.sourceShareMint && args.sourceVaultMintAta && args.allocationSourceShareAta) {
18199
- instructions2.push(
18200
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18201
- payer,
18202
- (0, import_common45.toWeb3Pk)(args.sourceVaultMintAta),
18203
- (0, import_common45.toWeb3Pk)(args.sourceVault),
18204
- (0, import_common45.toWeb3Pk)(args.mint),
18205
- (0, import_common45.toWeb3Pk)(args.assetTokenProgram),
18206
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18207
- ),
18208
- (0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
18209
- payer,
18210
- (0, import_common45.toWeb3Pk)(args.allocationSourceShareAta),
18211
- (0, import_common45.toWeb3Pk)(args.allocationVault),
18212
- (0, import_common45.toWeb3Pk)(args.sourceShareMint),
18213
- (0, import_common45.toWeb3Pk)(args.sourceShareTokenProgram),
18214
- import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
18215
- )
18216
- );
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
+ });
18217
18967
  }
18218
- 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
+ ];
18219
18982
  }
18220
18983
  async buildPlanExtras(args) {
18221
18984
  return {
18222
18985
  postSuccessCacheInvalidations: [
18223
- { vaultPda: args.allocationVault },
18224
- { vaultPda: args.destinationVault },
18225
- ...args.sourceVault ? [{ vaultPda: args.sourceVault }] : [],
18226
- ...args.sourceVault && args.sourceVaultTrancheState ? [
18227
- {
18228
- vaultPda: args.sourceVault,
18229
- vaultTrancheStatePda: args.sourceVaultTrancheState
18230
- }
18231
- ] : [],
18232
- ...args.destinationVaultTrancheState ? [
18233
- {
18234
- vaultPda: args.destinationVault,
18235
- vaultTrancheStatePda: args.destinationVaultTrancheState
18236
- }
18237
- ] : []
18986
+ {
18987
+ vaultPda: args.vault,
18988
+ vaultTrancheStatePda: args.vaultTrancheState ?? void 0,
18989
+ withdrawalQueuePda: args.withdrawalQueue
18990
+ }
18238
18991
  ]
18239
18992
  };
18240
18993
  }
18241
- async getTx(txArgs) {
18242
- const args = await this.deriveIxArgs(txArgs);
18243
- const preambleInstructions = await this.buildPreambleInstructions(args);
18244
- const instruction = await this.getIx(args);
18245
- const extras = await this.buildPlanExtras(args);
18246
- return this.withVaultLookupTables({
18247
- instructions: [...preambleInstructions, instruction],
18248
- ...extras
18249
- });
18250
- }
18251
18994
  };
18252
18995
 
18253
18996
  // src/client/transaction.ts
@@ -18295,6 +19038,8 @@ var TransactionClient = class {
18295
19038
  this.fulfillJuniorTrancheWithdraw = new FulfillJuniorTrancheWithdrawBuilder(
18296
19039
  context
18297
19040
  );
19041
+ this.requestAsyncWithdraw = new RequestAsyncWithdrawBuilder(context);
19042
+ this.fulfillAsyncWithdraw = new FulfillAsyncWithdrawBuilder(context);
18298
19043
  this.executeWithdraw = new ExecuteWithdrawBuilder(context);
18299
19044
  this.managerWithdrawAsset = new ManagerWithdrawAssetBuilder(context);
18300
19045
  this.managerRedepositAsset = new ManagerRedepositAssetBuilder(context);
@@ -18315,7 +19060,7 @@ var VaultClient = class {
18315
19060
  this.skipSimulation = options.skipSimulation ?? false;
18316
19061
  this.vaultLookupTables = options.vaultLookupTables;
18317
19062
  const idl = { ...IDL, address: programId };
18318
- this.program = new import_core21.Program(idl, provider);
19063
+ this.program = new import_core22.Program(idl, provider);
18319
19064
  this.pda = new PdaClient((0, import_kit10.address)(this.program.programId.toBase58()));
18320
19065
  const rpc = createRpcFromConnection(provider.connection);
18321
19066
  this.account = new AccountClient(this.program, this.pda, rpc);
@@ -18343,15 +19088,15 @@ var VaultClient = class {
18343
19088
  this.vaultLookupTables
18344
19089
  );
18345
19090
  const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
18346
- const instructions2 = plan.instructions.map(import_common46.fromKitInstruction);
19091
+ const instructions2 = plan.instructions.map(import_common48.fromKitInstruction);
18347
19092
  let tx;
18348
19093
  if (plan.lookupTables?.length) {
18349
- const tables = await (0, import_common46.fetchLookupTables)(
19094
+ const tables = await (0, import_common48.fetchLookupTables)(
18350
19095
  this.provider.connection,
18351
19096
  plan.lookupTables
18352
19097
  );
18353
- tx = new import_web327.VersionedTransaction(
18354
- new import_web327.TransactionMessage({
19098
+ tx = new import_web329.VersionedTransaction(
19099
+ new import_web329.TransactionMessage({
18355
19100
  payerKey: payer.publicKey,
18356
19101
  recentBlockhash: blockhash,
18357
19102
  instructions: instructions2
@@ -18359,7 +19104,7 @@ var VaultClient = class {
18359
19104
  );
18360
19105
  tx.sign([payer, ...extraSigners]);
18361
19106
  } else {
18362
- tx = new import_web327.Transaction().add(...instructions2);
19107
+ tx = new import_web329.Transaction().add(...instructions2);
18363
19108
  tx.feePayer = payer.publicKey;
18364
19109
  tx.recentBlockhash = blockhash;
18365
19110
  tx.sign(payer, ...extraSigners);
@@ -18398,13 +19143,13 @@ var VaultClient = class {
18398
19143
  const { blockhash } = await this.provider.connection.getLatestBlockhash(
18399
19144
  "confirmed"
18400
19145
  );
18401
- const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common46.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
18402
- 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({
18403
19148
  payerKey: payer.publicKey,
18404
19149
  recentBlockhash: blockhash,
18405
- instructions: plan.instructions.map(import_common46.fromKitInstruction)
19150
+ instructions: plan.instructions.map(import_common48.fromKitInstruction)
18406
19151
  }).compileToV0Message(lookupTableAccounts);
18407
- const tx = new import_web327.VersionedTransaction(message2);
19152
+ const tx = new import_web329.VersionedTransaction(message2);
18408
19153
  const result = await this.provider.connection.simulateTransaction(tx, {
18409
19154
  sigVerify: false,
18410
19155
  commitment: "processed"
@@ -18478,7 +19223,7 @@ function resolveKeypairPath(keypairPath) {
18478
19223
  }
18479
19224
  function loadKeypair(keypairPath) {
18480
19225
  const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
18481
- return import_web328.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
19226
+ return import_web330.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
18482
19227
  }
18483
19228
  var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
18484
19229
  function defaultKeypairPath(env, role = "vault") {
@@ -18489,8 +19234,8 @@ function defaultKeypairPath(env, role = "vault") {
18489
19234
  }
18490
19235
  function createVaultClient(env, opts = {}) {
18491
19236
  const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
18492
- const connection = new import_web328.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
18493
- 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), {
18494
19239
  commitment: "confirmed"
18495
19240
  });
18496
19241
  const client = new VaultClient(
@@ -18506,11 +19251,11 @@ function createVaultClient(env, opts = {}) {
18506
19251
  client,
18507
19252
  provider,
18508
19253
  payer,
18509
- signer: (0, import_common47.fromWeb3Pk)(payer.publicKey)
19254
+ signer: (0, import_common49.fromWeb3Pk)(payer.publicKey)
18510
19255
  };
18511
19256
  }
18512
19257
  function keypairAddress(keypairPath) {
18513
- return (0, import_common47.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
19258
+ return (0, import_common49.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
18514
19259
  }
18515
19260
 
18516
19261
  // src/utils/math.ts
@@ -18524,16 +19269,16 @@ function fromUiAmount(amount, decimals) {
18524
19269
  }
18525
19270
 
18526
19271
  // src/utils/provider.ts
18527
- var import_core23 = require("@anchor-lang/core");
19272
+ var import_core24 = require("@anchor-lang/core");
18528
19273
  function makeProvider(connection, payer) {
18529
- return new import_core23.AnchorProvider(connection, new import_core23.Wallet(payer), {
19274
+ return new import_core24.AnchorProvider(connection, new import_core24.Wallet(payer), {
18530
19275
  commitment: "confirmed"
18531
19276
  });
18532
19277
  }
18533
19278
 
18534
19279
  // src/utils/squads.ts
18535
19280
  var squads = __toESM(require("@sqds/multisig"));
18536
- var import_web329 = require("@solana/web3.js");
19281
+ var import_web331 = require("@solana/web3.js");
18537
19282
  var SQUADS_SIMULATION_COMMITMENT = "processed";
18538
19283
  var SquadsProposalExecutionSimulationError = class extends Error {
18539
19284
  constructor(transactionError, logs, unitsConsumed) {
@@ -18557,8 +19302,8 @@ function validateVaultIndex(vaultIndex) {
18557
19302
  }
18558
19303
  function resolveSquadsWalletRoute(route) {
18559
19304
  validateVaultIndex(route.vaultIndex);
18560
- const wallet = new import_web329.PublicKey(route.wallet);
18561
- 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);
18562
19307
  const [vaultPda] = squads.getVaultPda({
18563
19308
  multisigPda,
18564
19309
  index: route.vaultIndex
@@ -18566,7 +19311,7 @@ function resolveSquadsWalletRoute(route) {
18566
19311
  return { ...route, wallet, multisigPda, vaultPda };
18567
19312
  }
18568
19313
  function findSquadsWalletRoute(wallet, routes) {
18569
- const walletKey = typeof wallet === "string" ? new import_web329.PublicKey(wallet) : wallet;
19314
+ const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
18570
19315
  const route = routes.find(
18571
19316
  (candidate) => candidate.wallet === walletKey.toBase58()
18572
19317
  );
@@ -18584,18 +19329,18 @@ function validateSquadsWalletRoutes(routes) {
18584
19329
  }
18585
19330
  }
18586
19331
  function vaultAuthorityForWallet(wallet, routes) {
18587
- const walletKey = typeof wallet === "string" ? new import_web329.PublicKey(wallet) : wallet;
19332
+ const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
18588
19333
  return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
18589
19334
  }
18590
19335
  async function simulateSquadsProposalExecution(args) {
18591
19336
  const { connection, feePayer, instructions: instructions2 } = args;
18592
19337
  const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
18593
- const message2 = new import_web329.TransactionMessage({
19338
+ const message2 = new import_web331.TransactionMessage({
18594
19339
  payerKey: feePayer,
18595
19340
  recentBlockhash,
18596
19341
  instructions: [...instructions2]
18597
19342
  }).compileToV0Message(args.addressLookupTableAccounts);
18598
- const transaction = new import_web329.VersionedTransaction(message2);
19343
+ const transaction = new import_web331.VersionedTransaction(message2);
18599
19344
  const { value } = await connection.simulateTransaction(transaction, {
18600
19345
  sigVerify: false,
18601
19346
  commitment: SQUADS_SIMULATION_COMMITMENT,
@@ -18620,7 +19365,7 @@ async function prepareVaultTransaction(args) {
18620
19365
  throw new Error("Ephemeral signers require a Squads route");
18621
19366
  return {
18622
19367
  kind: "direct",
18623
- transaction: new import_web329.Transaction().add(...instructions2),
19368
+ transaction: new import_web331.Transaction().add(...instructions2),
18624
19369
  authority: proposer
18625
19370
  };
18626
19371
  }
@@ -18673,7 +19418,7 @@ async function prepareVaultTransaction(args) {
18673
19418
  });
18674
19419
  if (replacements.size) {
18675
19420
  instructions2 = instructions2.map(
18676
- (ix) => new import_web329.TransactionInstruction({
19421
+ (ix) => new import_web331.TransactionInstruction({
18677
19422
  programId: ix.programId,
18678
19423
  data: ix.data,
18679
19424
  keys: ix.keys.map((meta) => ({
@@ -18701,7 +19446,7 @@ async function prepareVaultTransaction(args) {
18701
19446
  executionSimulationError = error;
18702
19447
  }
18703
19448
  }
18704
- const transactionMessage = new import_web329.TransactionMessage({
19449
+ const transactionMessage = new import_web331.TransactionMessage({
18705
19450
  payerKey: route.vaultPda,
18706
19451
  recentBlockhash: blockhash,
18707
19452
  instructions: [...instructions2]
@@ -18731,7 +19476,7 @@ async function prepareVaultTransaction(args) {
18731
19476
  });
18732
19477
  return {
18733
19478
  kind: "squads",
18734
- transaction: new import_web329.Transaction().add(
19479
+ transaction: new import_web331.Transaction().add(
18735
19480
  createVaultTransactionIx,
18736
19481
  createProposalIx
18737
19482
  ),
@@ -18747,16 +19492,16 @@ async function prepareVaultTransaction(args) {
18747
19492
 
18748
19493
  // src/utils/squadsBuffer.ts
18749
19494
  var squads2 = __toESM(require("@sqds/multisig"));
18750
- var import_web330 = require("@solana/web3.js");
19495
+ var import_web332 = require("@solana/web3.js");
18751
19496
  var PacketSize = 1232;
18752
19497
  var BufferChunkSize = 700;
18753
19498
  var MaxBufferSize = 4e3;
18754
19499
  async function prepareSquadsProposalUpload(args) {
18755
19500
  const { connection, proposer, prepared } = args;
18756
19501
  const transaction = prepared.transaction;
18757
- const sizeProbe = new import_web330.Transaction({
19502
+ const sizeProbe = new import_web332.Transaction({
18758
19503
  feePayer: proposer,
18759
- recentBlockhash: import_web330.PublicKey.default.toBase58()
19504
+ recentBlockhash: import_web332.PublicKey.default.toBase58()
18760
19505
  }).add(...transaction.instructions);
18761
19506
  let fits = false;
18762
19507
  try {
@@ -18776,7 +19521,7 @@ async function prepareSquadsProposalUpload(args) {
18776
19521
  let bufferPda;
18777
19522
  let bufferIndex = 0;
18778
19523
  for (; bufferIndex <= 255; bufferIndex++) {
18779
- const [candidate] = import_web330.PublicKey.findProgramAddressSync(
19524
+ const [candidate] = import_web332.PublicKey.findProgramAddressSync(
18780
19525
  [
18781
19526
  Buffer.from("multisig"),
18782
19527
  prepared.multisigPda.toBuffer(),
@@ -18804,7 +19549,7 @@ async function prepareSquadsProposalUpload(args) {
18804
19549
  creator: proposer
18805
19550
  };
18806
19551
  const setupTransactions = [
18807
- new import_web330.Transaction().add(
19552
+ new import_web332.Transaction().add(
18808
19553
  squads2.generated.createTransactionBufferCreateInstruction(
18809
19554
  {
18810
19555
  ...accounts2,
@@ -18824,7 +19569,7 @@ async function prepareSquadsProposalUpload(args) {
18824
19569
  ];
18825
19570
  for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
18826
19571
  setupTransactions.push(
18827
- new import_web330.Transaction().add(
19572
+ new import_web332.Transaction().add(
18828
19573
  squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
18829
19574
  args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
18830
19575
  })
@@ -18837,7 +19582,7 @@ async function prepareSquadsProposalUpload(args) {
18837
19582
  vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
18838
19583
  vaultTransactionCreateItemCreator: proposer,
18839
19584
  vaultTransactionCreateItemRentPayer: proposer,
18840
- vaultTransactionCreateItemSystemProgram: import_web330.SystemProgram.programId,
19585
+ vaultTransactionCreateItemSystemProgram: import_web332.SystemProgram.programId,
18841
19586
  transactionBuffer: bufferPda,
18842
19587
  creator: proposer
18843
19588
  },
@@ -18849,7 +19594,7 @@ async function prepareSquadsProposalUpload(args) {
18849
19594
  ).isWritable = true;
18850
19595
  return {
18851
19596
  setupTransactions,
18852
- proposalTransaction: new import_web330.Transaction().add(
19597
+ proposalTransaction: new import_web332.Transaction().add(
18853
19598
  finalize,
18854
19599
  ...transaction.instructions.slice(1)
18855
19600
  ),
@@ -18859,21 +19604,21 @@ async function prepareSquadsProposalUpload(args) {
18859
19604
  }
18860
19605
 
18861
19606
  // src/utils/token.ts
18862
- var import_spl_token21 = require("@solana/spl-token");
18863
- var import_web331 = require("@solana/web3.js");
18864
- var import_common48 = __toESM(require_dist());
18865
- async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token21.TOKEN_2022_PROGRAM_ID) {
18866
- const mint = import_web331.Keypair.generate();
18867
- 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);
18868
19613
  const ixs = [
18869
- import_web331.SystemProgram.createAccount({
19614
+ import_web333.SystemProgram.createAccount({
18870
19615
  fromPubkey: payer,
18871
19616
  newAccountPubkey: mint.publicKey,
18872
- space: import_spl_token21.MINT_SIZE,
19617
+ space: import_spl_token23.MINT_SIZE,
18873
19618
  lamports,
18874
19619
  programId: tokenProgram
18875
19620
  }),
18876
- (0, import_spl_token21.createInitializeMint2Instruction)(
19621
+ (0, import_spl_token23.createInitializeMint2Instruction)(
18877
19622
  mint.publicKey,
18878
19623
  decimals,
18879
19624
  authority,
@@ -18883,7 +19628,7 @@ async function createTokenMintIxs(connection, payer, authority, decimals, tokenP
18883
19628
  ];
18884
19629
  return { mint, ixs };
18885
19630
  }
18886
- 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) {
18887
19632
  const { mint, ixs } = await createTokenMintIxs(
18888
19633
  connection,
18889
19634
  payer.publicKey,
@@ -18892,7 +19637,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
18892
19637
  tokenProgram
18893
19638
  );
18894
19639
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
18895
- const tx = new import_web331.Transaction().add(...ixs);
19640
+ const tx = new import_web333.Transaction().add(...ixs);
18896
19641
  tx.feePayer = payer.publicKey;
18897
19642
  tx.recentBlockhash = blockhash;
18898
19643
  tx.sign(payer, mint);
@@ -18905,24 +19650,24 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
18905
19650
  );
18906
19651
  return mint.publicKey;
18907
19652
  }
18908
- async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token21.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
18909
- const tokenProgramPk = (0, import_common48.asWeb3PublicKey)(tokenProgram);
18910
- 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)(
18911
19656
  mint,
18912
19657
  destination,
18913
19658
  allowOwnerOffCurve,
18914
19659
  tokenProgramPk
18915
19660
  );
18916
19661
  const ixs = [
18917
- (0, import_spl_token21.createAssociatedTokenAccountIdempotentInstruction)(
19662
+ (0, import_spl_token23.createAssociatedTokenAccountIdempotentInstruction)(
18918
19663
  payer.publicKey,
18919
19664
  ata,
18920
19665
  destination,
18921
19666
  mint,
18922
19667
  tokenProgramPk,
18923
- import_spl_token21.ASSOCIATED_TOKEN_PROGRAM_ID
19668
+ import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID
18924
19669
  ),
18925
- (0, import_spl_token21.createMintToInstruction)(
19670
+ (0, import_spl_token23.createMintToInstruction)(
18926
19671
  mint,
18927
19672
  ata,
18928
19673
  payer.publicKey,
@@ -18931,12 +19676,12 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
18931
19676
  tokenProgramPk
18932
19677
  )
18933
19678
  ];
18934
- const tx = new import_web331.Transaction().add(...ixs);
19679
+ const tx = new import_web333.Transaction().add(...ixs);
18935
19680
  await connection.sendTransaction(tx, [payer]);
18936
19681
  }
18937
19682
 
18938
19683
  // src/utils/yieldApi.ts
18939
- var import_core24 = require("@anchor-lang/core");
19684
+ var import_core25 = require("@anchor-lang/core");
18940
19685
  var YIELD_API_BASE = process.env.YIELD_API_BASE ?? "https://yield-tracker.perena.org";
18941
19686
  async function yieldApiReq(endpoint, reqType, bodyData, options) {
18942
19687
  const headers = {
@@ -19279,7 +20024,7 @@ async function getTrackedValue(accountName) {
19279
20024
  return trackedValueFromResponse(await getYield(accountName));
19280
20025
  }
19281
20026
  async function getTotalYield(accountNames, start, end) {
19282
- let totalYield = new import_core24.BN(0);
20027
+ let totalYield = new import_core25.BN(0);
19283
20028
  for (const accountName of accountNames) {
19284
20029
  const res = await getYield(accountName, start, end);
19285
20030
  if (isNavAccountValue(res)) {
@@ -19288,7 +20033,7 @@ async function getTotalYield(accountNames, start, end) {
19288
20033
  );
19289
20034
  }
19290
20035
  console.log(res);
19291
- totalYield = totalYield.add(new import_core24.BN(res.total_yield));
20036
+ totalYield = totalYield.add(new import_core25.BN(res.total_yield));
19292
20037
  }
19293
20038
  return totalYield;
19294
20039
  }
@@ -19321,7 +20066,7 @@ async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
19321
20066
  }
19322
20067
 
19323
20068
  // src/services/withdrawalQueueService.ts
19324
- var import_common49 = __toESM(require_dist());
20069
+ var import_common51 = __toESM(require_dist());
19325
20070
  function bnToBigInt(value) {
19326
20071
  return BigInt(value.toString());
19327
20072
  }
@@ -19339,16 +20084,19 @@ var WithdrawalQueueService = class {
19339
20084
  // ── Discovery ───────────────────────────────────────────────────────────
19340
20085
  /** All withdrawal-queue accounts owned by the vault program. */
19341
20086
  async fetchAllQueues() {
19342
- const program = this.client.program.account;
19343
- const accounts2 = await program.vaultWithdrawalQueue.all();
20087
+ const accounts2 = await this.client.account.fetchAllWithdrawalQueues();
19344
20088
  return accounts2.map(
19345
- (entry) => this.toSnapshot((0, import_common49.fromWeb3Pk)(entry.publicKey), entry.account)
20089
+ ({ publicKey, account }) => this.toSnapshot(publicKey, account)
19346
20090
  );
19347
20091
  }
19348
20092
  /** Withdrawal queues for a single vault. */
19349
20093
  async fetchQueuesForVault(vault) {
19350
- const all = await this.fetchAllQueues();
19351
- 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
+ );
19352
20100
  }
19353
20101
  /** Fetch a single queue snapshot by owner/queueId for a vault. */
19354
20102
  async fetchQueue(vault, owner, queueId) {
@@ -19377,13 +20125,38 @@ var WithdrawalQueueService = class {
19377
20125
  }
19378
20126
  // ── Fulfillment ─────────────────────────────────────────────────────────
19379
20127
  /**
19380
- * Fulfill a single queued junior withdrawal. `signer` pays fees and, if
20128
+ * Fulfill a single regular or junior withdrawal. `signer` pays fees and, if
19381
20129
  * needed, initializes the owner's output ATA.
19382
20130
  */
19383
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
+ }
19384
20157
  const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
19385
20158
  owner: queue.owner,
19386
- signer: (0, import_common49.fromWeb3Pk)(signer.publicKey),
20159
+ signer: (0, import_common51.fromWeb3Pk)(signer.publicKey),
19387
20160
  queuePayer: queue.payer,
19388
20161
  vault: queue.vault,
19389
20162
  withdrawalQueue: queue.pda,
@@ -19417,7 +20190,7 @@ var WithdrawalQueueService = class {
19417
20190
  }
19418
20191
  try {
19419
20192
  log?.(
19420
- `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}`
19421
20194
  );
19422
20195
  const sig = await this.fulfill(signer, queue);
19423
20196
  summary.fulfilled += 1;
@@ -19437,12 +20210,12 @@ var WithdrawalQueueService = class {
19437
20210
  const a = account;
19438
20211
  return {
19439
20212
  pda,
19440
- vault: (0, import_common49.fromWeb3Pk)(a.parties.vault),
19441
- owner: (0, import_common49.fromWeb3Pk)(a.parties.owner),
19442
- 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),
19443
20216
  queueId: a.header.queueId,
19444
- inputMint: (0, import_common49.fromWeb3Pk)(a.mints.inputMint),
19445
- 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),
19446
20219
  inputAmount: bnToBigInt(a.request.inputAmount),
19447
20220
  requestTs: bnToNumber(a.request.requestTs),
19448
20221
  expiryTs: bnToNumber(a.request.expiryTs)
@@ -19452,7 +20225,7 @@ var WithdrawalQueueService = class {
19452
20225
 
19453
20226
  // src/services/oracleService.ts
19454
20227
  var import_kit12 = require("@solana/kit");
19455
- var import_common50 = __toESM(require_dist());
20228
+ var import_common52 = __toESM(require_dist());
19456
20229
  var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
19457
20230
  var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
19458
20231
  var PRICE_ORACLE_TYPES_BY_INDEX2 = [
@@ -19516,7 +20289,7 @@ var OracleService = class {
19516
20289
  */
19517
20290
  async updateAssetConsensusPrice(signer, args, log) {
19518
20291
  const plan = await this.client.tx.updateConsensusOracle.getTx({
19519
- signer: (0, import_common50.fromWeb3Pk)(signer.publicKey),
20292
+ signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
19520
20293
  vault: args.vault,
19521
20294
  updates: args.updates,
19522
20295
  assetMint: args.assetMint,
@@ -19532,7 +20305,7 @@ var OracleService = class {
19532
20305
  /** Settle the vault NAV from its current holdings (permissionless). */
19533
20306
  async crankNav(cranker, args, log) {
19534
20307
  const plan = await this.client.tx.crankNav.getTx({
19535
- cranker: (0, import_common50.fromWeb3Pk)(cranker.publicKey),
20308
+ cranker: (0, import_common52.fromWeb3Pk)(cranker.publicKey),
19536
20309
  vault: args.vault,
19537
20310
  vaultTrancheState: args.vaultTrancheState
19538
20311
  });
@@ -19605,7 +20378,7 @@ var OracleService = class {
19605
20378
  /** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
19606
20379
  async refreshAssetPrice(updater, args, log) {
19607
20380
  const plan = await this.client.tx.updateAssetPrice.getTx({
19608
- updater: (0, import_common50.fromWeb3Pk)(updater.publicKey),
20381
+ updater: (0, import_common52.fromWeb3Pk)(updater.publicKey),
19609
20382
  vault: args.vault,
19610
20383
  mint: args.mint,
19611
20384
  oracleAccount: args.oracleAccount,
@@ -19701,11 +20474,11 @@ function toBigInt2(value) {
19701
20474
  }
19702
20475
 
19703
20476
  // src/services/consensusOracle/utils/holdings.ts
19704
- var import_web332 = require("@solana/web3.js");
19705
- var import_common51 = __toESM(require_dist());
20477
+ var import_web334 = require("@solana/web3.js");
20478
+ var import_common53 = __toESM(require_dist());
19706
20479
  function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
19707
20480
  return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
19708
- const mint = (0, import_common51.fromWeb3Pk)(holding.mint);
20481
+ const mint = (0, import_common53.fromWeb3Pk)(holding.mint);
19709
20482
  return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
19710
20483
  variantName2(holding.priceOracleType).toLowerCase()
19711
20484
  );
@@ -19740,7 +20513,7 @@ function parseExternalLiquidityRefs(vaultState) {
19740
20513
  if (!data || data.length < 40) continue;
19741
20514
  if (data[0] !== 1 && data[0] !== 2) continue;
19742
20515
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
19743
- const userAccount = new import_web332.PublicKey(pubkeyBytes).toBase58();
20516
+ const userAccount = new import_web334.PublicKey(pubkeyBytes).toBase58();
19744
20517
  refs.push(
19745
20518
  data[0] === 1 ? { kind: "marginfi", mint: "", marginfiAccount: userAccount } : {
19746
20519
  kind: "kamino-lend",
@@ -19968,12 +20741,12 @@ function formatBpsAsPercent(bps) {
19968
20741
  }
19969
20742
 
19970
20743
  // src/services/consensusOracle/pipeline/dryRunSettlement.ts
19971
- var import_web334 = require("@solana/web3.js");
19972
- var import_common52 = __toESM(require_dist());
20744
+ var import_web336 = require("@solana/web3.js");
20745
+ var import_common54 = __toESM(require_dist());
19973
20746
 
19974
20747
  // src/services/consensusOracle/settlement/settlementSimulator.ts
19975
20748
  var import_kit13 = require("@solana/kit");
19976
- var import_web333 = require("@solana/web3.js");
20749
+ var import_web335 = require("@solana/web3.js");
19977
20750
  var DEFAULT_SHARE_PRICE = 1000000n;
19978
20751
  var BPS_DENOMINATOR3 = 10000n;
19979
20752
  var NAV_LOSS_TOLERANCE_BPS = 1n;
@@ -20246,7 +21019,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
20246
21019
  continue;
20247
21020
  }
20248
21021
  const reports = entries.filter(
20249
- (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
20250
21023
  );
20251
21024
  const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
20252
21025
  const prices = reports.map((entry) => entry.prices[index] ?? 0n);
@@ -20747,7 +21520,7 @@ function decodeOracleData(data, nowTs) {
20747
21520
  (_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
20748
21521
  );
20749
21522
  entries.push({
20750
- signer: new import_web333.PublicKey(signerBytes).toBase58(),
21523
+ signer: new import_web335.PublicKey(signerBytes).toBase58(),
20751
21524
  lastUpdateTs: readI64(data, offset + 32),
20752
21525
  prices,
20753
21526
  externalAmounts
@@ -20762,7 +21535,7 @@ function decodeOracleData(data, nowTs) {
20762
21535
  data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
20763
21536
  );
20764
21537
  entries[index] = {
20765
- 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(),
20766
21539
  lastUpdateTs: 0n,
20767
21540
  prices: Array(MAX_HOLDINGS).fill(0n),
20768
21541
  externalAmounts: Array(MAX_HOLDINGS).fill(0n)
@@ -20790,7 +21563,7 @@ function decodeHolding(value) {
20790
21563
  externalAmount: bigint(holding.externalAmount),
20791
21564
  price: bigint(holding.price),
20792
21565
  lastUpdateTs: bigint(holding.lastUpdateTs),
20793
- cleared: mintString === import_web333.PublicKey.default.toBase58()
21566
+ cleared: mintString === import_web335.PublicKey.default.toBase58()
20794
21567
  };
20795
21568
  }
20796
21569
  function decodeTrancheState(decoded, args, warnings, blockers) {
@@ -21273,11 +22046,11 @@ async function fetchSimulationArgs({
21273
22046
  client.account.fetchVaultOracleForVault(vault, { fresh: true }),
21274
22047
  tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
21275
22048
  ]);
21276
- const mintKeys = [new import_web334.PublicKey(vaultState.mint)];
22049
+ const mintKeys = [new import_web336.PublicKey(vaultState.mint)];
21277
22050
  if (trancheState) {
21278
22051
  mintKeys.push(
21279
- new import_web334.PublicKey(trancheState.config.juniorMint),
21280
- new import_web334.PublicKey(trancheState.config.seniorMint)
22052
+ new import_web336.PublicKey(trancheState.config.juniorMint),
22053
+ new import_web336.PublicKey(trancheState.config.seniorMint)
21281
22054
  );
21282
22055
  }
21283
22056
  const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
@@ -21293,7 +22066,7 @@ async function fetchSimulationArgs({
21293
22066
  oracleData: oracleState.data,
21294
22067
  trancheState,
21295
22068
  updates,
21296
- signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
22069
+ signer: (0, import_common54.fromWeb3Pk)(signer.publicKey),
21297
22070
  nowTs: nowSecs,
21298
22071
  physicalShareSupply: supplies[0],
21299
22072
  physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
@@ -21302,7 +22075,7 @@ async function fetchSimulationArgs({
21302
22075
  }
21303
22076
 
21304
22077
  // src/services/consensusOracle/pipeline/holdingUpdates.ts
21305
- var import_common53 = __toESM(require_dist());
22078
+ var import_common55 = __toESM(require_dist());
21306
22079
  async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
21307
22080
  const updates = [];
21308
22081
  for (const entry of reportableHoldings) {
@@ -21312,7 +22085,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
21312
22085
  }
21313
22086
  async function buildHoldingUpdate(yieldTracker, entry, inputs) {
21314
22087
  const { holding, holdingIndex } = entry;
21315
- const mint = (0, import_common53.fromWeb3Pk)(holding.mint);
22088
+ const mint = (0, import_common55.fromWeb3Pk)(holding.mint);
21316
22089
  const mintKey = mint.toString();
21317
22090
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
21318
22091
  let usd;
@@ -21374,9 +22147,9 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
21374
22147
  );
21375
22148
  }
21376
22149
  return {
21377
- trackedValueAmount: tracked.totalValue > 0 ? (0, import_common53.fromUiAmount)(tracked.totalValue, decimals) : 0n,
21378
- principalAmount: tracked.principal > 0 ? (0, import_common53.fromUiAmount)(tracked.principal, decimals) : 0n,
21379
- 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
21380
22153
  };
21381
22154
  }
21382
22155
 
@@ -21410,7 +22183,7 @@ function assertOracleImpliedApy(vault, simulation, label) {
21410
22183
  }
21411
22184
 
21412
22185
  // src/services/consensusOracle/pipeline/livePriceRefresh.ts
21413
- var import_common54 = __toESM(require_dist());
22186
+ var import_common56 = __toESM(require_dist());
21414
22187
  async function refreshLiveOraclePrices({
21415
22188
  oracle,
21416
22189
  signer,
@@ -21429,7 +22202,7 @@ async function refreshLiveOraclePrices({
21429
22202
  for (const holding of vaultState.holdings) {
21430
22203
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
21431
22204
  if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
21432
- const mint = (0, import_common54.fromWeb3Pk)(holding.mint);
22205
+ const mint = (0, import_common56.fromWeb3Pk)(holding.mint);
21433
22206
  if (mint.toString() === SYSTEM_PROGRAM) continue;
21434
22207
  const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
21435
22208
  if (activeAmount === 0n) continue;
@@ -21444,7 +22217,7 @@ async function refreshLiveOraclePrices({
21444
22217
  );
21445
22218
  continue;
21446
22219
  }
21447
- const oracleAccount = (0, import_common54.fromWeb3Pk)(holding.priceOracleAccount);
22220
+ const oracleAccount = (0, import_common56.fromWeb3Pk)(holding.priceOracleAccount);
21448
22221
  if (oracleAccount.toString() === SYSTEM_PROGRAM) {
21449
22222
  log(
21450
22223
  `vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
@@ -21468,7 +22241,7 @@ async function refreshLiveOraclePrices({
21468
22241
  }
21469
22242
 
21470
22243
  // src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
21471
- var import_common55 = __toESM(require_dist());
22244
+ var import_common57 = __toESM(require_dist());
21472
22245
 
21473
22246
  // src/services/consensusOracle/sources/nestPriceSource.ts
21474
22247
  var import_kit14 = require("@solana/kit");
@@ -21515,13 +22288,13 @@ function candidateGrossNav(state, updates) {
21515
22288
  const byIndex = /* @__PURE__ */ new Map();
21516
22289
  for (const update of updates) {
21517
22290
  const holding = state.holdings[update.holdingIndex];
21518
- 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)) {
21519
22292
  throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
21520
22293
  }
21521
22294
  byIndex.set(update.holdingIndex, update);
21522
22295
  }
21523
22296
  return state.holdings.reduce((nav, holding, index) => {
21524
- if ((0, import_common55.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
22297
+ if ((0, import_common57.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
21525
22298
  const update = byIndex.get(index);
21526
22299
  const local = toBigInt2(holding.localAmount);
21527
22300
  const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
@@ -21588,13 +22361,13 @@ async function reconcileManagerWalletBalances({
21588
22361
  throw new Error("Duplicate base mint in manager reconciliation");
21589
22362
  }
21590
22363
  if (vaultState.holdings.some(
21591
- (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))
21592
22365
  )) {
21593
22366
  throw new Error(
21594
22367
  "Cannot reconcile all vault base assets with oracle reports"
21595
22368
  );
21596
22369
  }
21597
- const manager = (0, import_common55.fromWeb3Pk)(vaultState.roles.manager);
22370
+ const manager = (0, import_common57.fromWeb3Pk)(vaultState.roles.manager);
21598
22371
  if (manager === SYSTEM_PROGRAM || manager === vault) {
21599
22372
  throw new Error("Invalid manager wallet for NAV reconciliation");
21600
22373
  }
@@ -21680,13 +22453,13 @@ function walletReconciliationGuardUpdates(state, reconciliation) {
21680
22453
  }
21681
22454
  function managerReconciliationStateKey(state) {
21682
22455
  return JSON.stringify({
21683
- manager: (0, import_common55.fromWeb3Pk)(state.roles.manager),
22456
+ manager: (0, import_common57.fromWeb3Pk)(state.roles.manager),
21684
22457
  assetDecimals: state.config.assetDecimals,
21685
22458
  holdings: state.holdings.map((holding) => [
21686
- (0, import_common55.fromWeb3Pk)(holding.mint),
22459
+ (0, import_common57.fromWeb3Pk)(holding.mint),
21687
22460
  holding.decimals,
21688
22461
  variantName2(holding.priceOracleType),
21689
- holding.priceOracleAccount ? (0, import_common55.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
22462
+ holding.priceOracleAccount ? (0, import_common57.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
21690
22463
  coerceBool3(holding.isBase),
21691
22464
  toBigInt2(holding.localAmount).toString()
21692
22465
  ])
@@ -21725,14 +22498,14 @@ function assertReconciliationExternalValues(initial, current, errorPrefix) {
21725
22498
  }
21726
22499
 
21727
22500
  // src/services/consensusOracle/pipeline/pricingInputs.ts
21728
- var import_common56 = __toESM(require_dist());
22501
+ var import_common58 = __toESM(require_dist());
21729
22502
  async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
21730
22503
  }) {
21731
22504
  const consensusMints = reportableHoldings.filter(
21732
22505
  ({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
21733
- ).map(({ holding }) => (0, import_common56.fromWeb3Pk)(holding.mint));
22506
+ ).map(({ holding }) => (0, import_common58.fromWeb3Pk)(holding.mint));
21734
22507
  const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
21735
- const baseMint = baseHolding ? (0, import_common56.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
22508
+ const baseMint = baseHolding ? (0, import_common58.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
21736
22509
  if (!baseMint) {
21737
22510
  throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
21738
22511
  }
@@ -21818,11 +22591,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
21818
22591
  }
21819
22592
 
21820
22593
  // src/services/consensusOracle/pipeline/receiptMints.ts
21821
- var import_common57 = __toESM(require_dist());
22594
+ var import_common59 = __toESM(require_dist());
21822
22595
  async function fetchReceiptMints(client, vault, vaultState) {
21823
22596
  const receiptMints = /* @__PURE__ */ new Set();
21824
22597
  if (vaultState.mint) {
21825
- receiptMints.add((0, import_common57.fromWeb3Pk)(vaultState.mint).toString());
22598
+ receiptMints.add((0, import_common59.fromWeb3Pk)(vaultState.mint).toString());
21826
22599
  }
21827
22600
  if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
21828
22601
  const trancheState = await client.account.fetchVaultTrancheStateForVault(
@@ -21830,19 +22603,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
21830
22603
  { fresh: true }
21831
22604
  );
21832
22605
  receiptMints.add(
21833
- (0, import_common57.fromWeb3Pk)(trancheState.config.juniorMint).toString()
22606
+ (0, import_common59.fromWeb3Pk)(trancheState.config.juniorMint).toString()
21834
22607
  );
21835
22608
  receiptMints.add(
21836
- (0, import_common57.fromWeb3Pk)(trancheState.config.seniorMint).toString()
22609
+ (0, import_common59.fromWeb3Pk)(trancheState.config.seniorMint).toString()
21837
22610
  );
21838
22611
  return receiptMints;
21839
22612
  }
21840
22613
 
21841
22614
  // src/services/consensusOracle/pipeline/settlement.ts
21842
- var import_common59 = __toESM(require_dist());
22615
+ var import_common61 = __toESM(require_dist());
21843
22616
 
21844
22617
  // src/services/consensusOracle/pipeline/yieldAccounts.ts
21845
- var import_common58 = __toESM(require_dist());
22618
+ var import_common60 = __toESM(require_dist());
21846
22619
  async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
21847
22620
  const accountNames = [
21848
22621
  ...new Set(
@@ -21884,7 +22657,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
21884
22657
  );
21885
22658
  if (namesToAttach.length === 0) return target;
21886
22659
  const baseHolding = vaultState.holdings.find((holding) => {
21887
- const mint = (0, import_common58.fromWeb3Pk)(holding.mint).toString();
22660
+ const mint = (0, import_common60.fromWeb3Pk)(holding.mint).toString();
21888
22661
  return coerceBool3(holding.isBase) && !excludedMints.has(mint);
21889
22662
  });
21890
22663
  if (!baseHolding) {
@@ -21892,7 +22665,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
21892
22665
  `vault ${target.vault}: tagged yield accounts found but no base holding is available`
21893
22666
  );
21894
22667
  }
21895
- const baseMint = (0, import_common58.fromWeb3Pk)(baseHolding.mint);
22668
+ const baseMint = (0, import_common60.fromWeb3Pk)(baseHolding.mint);
21896
22669
  const holdings = [...target.holdings ?? []];
21897
22670
  const existingIndex = holdings.findIndex(
21898
22671
  (holding) => holding.mint.toString() === baseMint.toString()
@@ -21977,7 +22750,7 @@ async function settleVault2({
21977
22750
  vault: publishedVault,
21978
22751
  oracleData: publishedOracle.data,
21979
22752
  updates,
21980
- signer: (0, import_common59.fromWeb3Pk)(signer.publicKey),
22753
+ signer: (0, import_common61.fromWeb3Pk)(signer.publicKey),
21981
22754
  nowTs: publishedAt
21982
22755
  });
21983
22756
  if (blockers.length)
@@ -22019,7 +22792,7 @@ async function logProspectiveApy({
22019
22792
  );
22020
22793
  const prospectiveNav = vaultState.holdings.reduce(
22021
22794
  (sum, holding, holdingIndex) => {
22022
- const mint = (0, import_common59.fromWeb3Pk)(holding.mint).toString();
22795
+ const mint = (0, import_common61.fromWeb3Pk)(holding.mint).toString();
22023
22796
  if (mint === SYSTEM_PROGRAM) return sum;
22024
22797
  const update = updatesByIndex.get(holdingIndex);
22025
22798
  const localAmount = toBigInt2(holding.localAmount);
@@ -22946,7 +23719,7 @@ async function buildJupiterSwapTransaction(params) {
22946
23719
  }
22947
23720
 
22948
23721
  // ../jupiter/src/client.ts
22949
- var import_common60 = __toESM(require_dist());
23722
+ var import_common62 = __toESM(require_dist());
22950
23723
 
22951
23724
  // ../jupiter/src/extract.ts
22952
23725
  var import_kit17 = require("@solana/kit");
@@ -22976,8 +23749,8 @@ async function extractJupiterInstruction(transaction, rpc, jupiterProgramId = JU
22976
23749
 
22977
23750
  // ../jupiter/src/routePreInstructions.ts
22978
23751
  var import_kit18 = require("@solana/kit");
22979
- var import_spl_token22 = require("@solana/spl-token");
22980
- var import_web335 = require("@solana/web3.js");
23752
+ var import_spl_token24 = require("@solana/spl-token");
23753
+ var import_web337 = require("@solana/web3.js");
22981
23754
  async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
22982
23755
  const intermediate = /* @__PURE__ */ new Set();
22983
23756
  for (const step of quote.routePlan ?? []) {
@@ -23001,26 +23774,26 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23001
23774
  `getJupiterRoutePreInstructions: route mint ${mint} not found on-chain`
23002
23775
  );
23003
23776
  }
23004
- const ata = (0, import_spl_token22.getAssociatedTokenAddressSync)(
23005
- new import_web335.PublicKey(mint),
23006
- 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),
23007
23780
  true,
23008
- new import_web335.PublicKey(tokenProgram),
23009
- import_spl_token22.ASSOCIATED_TOKEN_PROGRAM_ID
23781
+ new import_web337.PublicKey(tokenProgram),
23782
+ import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID
23010
23783
  ).toBase58();
23011
23784
  const existingAta = await rpc.getAccountInfo(ata, { encoding: "base64" }).send();
23012
23785
  if (existingAta.value) {
23013
23786
  continue;
23014
23787
  }
23015
23788
  instructions2.push(
23016
- toKitInstruction37(
23017
- (0, import_spl_token22.createAssociatedTokenAccountIdempotentInstruction)(
23018
- new import_web335.PublicKey(payer),
23019
- new import_web335.PublicKey(ata),
23020
- new import_web335.PublicKey(user),
23021
- new import_web335.PublicKey(mint),
23022
- new import_web335.PublicKey(tokenProgram),
23023
- 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
23024
23797
  )
23025
23798
  )
23026
23799
  );
@@ -23028,7 +23801,7 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
23028
23801
  }
23029
23802
  return { instructions: instructions2, postSuccessCacheInvalidations };
23030
23803
  }
23031
- function toKitInstruction37(ix) {
23804
+ function toKitInstruction39(ix) {
23032
23805
  return {
23033
23806
  programAddress: ix.programId.toBase58(),
23034
23807
  accounts: ix.keys.map((account) => ({
@@ -23145,7 +23918,7 @@ var JupiterSwapClient = class {
23145
23918
  }
23146
23919
  }
23147
23920
  return {
23148
- cpiType: this.config.cpiType ?? import_common60.CpiTypes.JUPITER_SWAP,
23921
+ cpiType: this.config.cpiType ?? import_common62.CpiTypes.JUPITER_SWAP,
23149
23922
  data,
23150
23923
  accounts: accounts2,
23151
23924
  programId: JUPITER_V6_PROGRAM_ID,
@@ -23243,8 +24016,8 @@ var LivePriceSource = class {
23243
24016
  };
23244
24017
 
23245
24018
  // src/services/consensusOracle/sources/managerWalletBalanceSource.ts
23246
- var import_web336 = require("@solana/web3.js");
23247
- 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");
23248
24021
  var RpcManagerWalletBalanceSource = class {
23249
24022
  constructor(connection) {
23250
24023
  this.connection = connection;
@@ -23252,8 +24025,8 @@ var RpcManagerWalletBalanceSource = class {
23252
24025
  async fetchBalances(manager, mints2) {
23253
24026
  const wanted = new Set(mints2);
23254
24027
  if (wanted.size === 0) return /* @__PURE__ */ new Map();
23255
- const owner = new import_web336.PublicKey(manager);
23256
- 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];
23257
24030
  const responses = await Promise.all(
23258
24031
  programs.map(
23259
24032
  (programId) => this.connection.getParsedTokenAccountsByOwner(
@@ -23296,7 +24069,7 @@ var RpcManagerWalletBalanceSource = class {
23296
24069
  };
23297
24070
 
23298
24071
  // src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
23299
- var import_web337 = require("@solana/web3.js");
24072
+ var import_web339 = require("@solana/web3.js");
23300
24073
 
23301
24074
  // src/services/consensusOracle/sources/mpcMarginfiDeposits.ts
23302
24075
  var import_kit19 = require("@solana/kit");
@@ -23385,8 +24158,8 @@ var RpcMpcWalletBalanceSource = class {
23385
24158
  const wallets = /* @__PURE__ */ new Set();
23386
24159
  for (const binding of bindings) {
23387
24160
  const { vault, manager, wallet } = binding;
23388
- for (const key of [vault, manager, wallet]) new import_web337.PublicKey(key);
23389
- 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())
23390
24163
  throw new Error("Invalid or duplicate MPC wallet binding");
23391
24164
  entries.set(vault, { ...binding });
23392
24165
  wallets.add(wallet);
@@ -23406,8 +24179,8 @@ var RpcMpcWalletBalanceSource = class {
23406
24179
  this.tokens.fetchBalances(binding.wallet, mints2),
23407
24180
  readMarginfiDepositsForAuthority(
23408
24181
  this.connection,
23409
- new import_web337.PublicKey(binding.wallet),
23410
- mints2.map((mint) => new import_web337.PublicKey(mint))
24182
+ new import_web339.PublicKey(binding.wallet),
24183
+ mints2.map((mint) => new import_web339.PublicKey(mint))
23411
24184
  )
23412
24185
  ]);
23413
24186
  return { wallet: binding.wallet, tokens, marginfi: deposits };
@@ -23450,7 +24223,7 @@ var StaticPositionProvider = class {
23450
24223
 
23451
24224
  // src/services/consensusOracle/positions/kaminoPositionProvider.ts
23452
24225
  var import_kit20 = require("@solana/kit");
23453
- var import_web338 = require("@solana/web3.js");
24226
+ var import_web340 = require("@solana/web3.js");
23454
24227
  var import_klend_sdk = require("@kamino-finance/klend-sdk");
23455
24228
  async function readKaminoBalance(manager, vault, sharesHolder) {
23456
24229
  const userShares = await manager.getUserSharesBalanceSingleVault(
@@ -23487,7 +24260,7 @@ var KaminoPositionProvider = class {
23487
24260
  const amount = await readKaminoBalance(
23488
24261
  manager,
23489
24262
  kVault,
23490
- new import_web338.PublicKey(sharesHolder)
24263
+ new import_web340.PublicKey(sharesHolder)
23491
24264
  );
23492
24265
  out.push({ mint: ref.mint, amount });
23493
24266
  }
@@ -23496,11 +24269,11 @@ var KaminoPositionProvider = class {
23496
24269
  };
23497
24270
 
23498
24271
  // src/services/consensusOracle/positions/kaminoLendPositionProvider.ts
23499
- var import_web339 = require("@solana/web3.js");
24272
+ var import_web341 = require("@solana/web3.js");
23500
24273
  var import_Obligation2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
23501
24274
  var import_Reserve2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
23502
24275
  var import_kamino4 = __toESM(require_dist3());
23503
- var ZERO = import_web339.PublicKey.default.toBase58();
24276
+ var ZERO = import_web341.PublicKey.default.toBase58();
23504
24277
  var FRACTION_SCALE = 1n << 60n;
23505
24278
  function accountData(info, label) {
23506
24279
  if (!info || info.executable || info.owner.toBase58() !== import_kamino4.KLEND_PROGRAM_ID)
@@ -23541,7 +24314,7 @@ var KaminoLendPositionProvider = class {
23541
24314
  }
23542
24315
  const positions = [];
23543
24316
  for (const address18 of obligations) {
23544
- const key = new import_web339.PublicKey(address18);
24317
+ const key = new import_web341.PublicKey(address18);
23545
24318
  const discovered = decodeObligation(
23546
24319
  await this.connection.getAccountInfo(key, "confirmed"),
23547
24320
  ctx.vault
@@ -23551,7 +24324,7 @@ var KaminoLendPositionProvider = class {
23551
24324
  (deposit) => deposit.depositReserve
23552
24325
  );
23553
24326
  const infos = await this.connection.getMultipleAccountsInfo(
23554
- [key, ...reserves.map((reserve) => new import_web339.PublicKey(reserve))],
24327
+ [key, ...reserves.map((reserve) => new import_web341.PublicKey(reserve))],
23555
24328
  "confirmed"
23556
24329
  );
23557
24330
  const { obligation, deposits } = decodeObligation(
@@ -23593,7 +24366,7 @@ var KaminoLendPositionProvider = class {
23593
24366
  };
23594
24367
 
23595
24368
  // src/services/consensusOracle/positions/marginfiPositionProvider.ts
23596
- var import_web340 = require("@solana/web3.js");
24369
+ var import_web342 = require("@solana/web3.js");
23597
24370
  var import_marginfi4 = __toESM(require_dist2());
23598
24371
  var MarginfiPositionProvider = class {
23599
24372
  constructor(connection, log = () => {
@@ -23604,8 +24377,8 @@ var MarginfiPositionProvider = class {
23604
24377
  async positionsFor(ctx) {
23605
24378
  const refs = ctx.refs.filter((r) => r.kind === "marginfi");
23606
24379
  if (refs.length === 0) return [];
23607
- const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web340.PublicKey(bank));
23608
- 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));
23609
24382
  const autoBanks = [];
23610
24383
  for (const accountPk of autoAccountPks) {
23611
24384
  try {
@@ -23634,14 +24407,14 @@ var MarginfiPositionProvider = class {
23634
24407
  if (bank) {
23635
24408
  const amount = await (0, import_marginfi4.readMarginfiBankBalance)(
23636
24409
  client,
23637
- new import_web340.PublicKey(account),
23638
- new import_web340.PublicKey(bank)
24410
+ new import_web342.PublicKey(account),
24411
+ new import_web342.PublicKey(bank)
23639
24412
  );
23640
24413
  out.push({ mint: ref.mint, amount });
23641
24414
  } else {
23642
24415
  const balances = await (0, import_marginfi4.readAllMarginfiBalances)(
23643
24416
  client,
23644
- new import_web340.PublicKey(account)
24417
+ new import_web342.PublicKey(account)
23645
24418
  );
23646
24419
  for (const { mint, amount } of balances) {
23647
24420
  out.push({ mint: mint.toBase58(), amount });
@@ -23848,6 +24621,11 @@ var MPC_WALLETS = [
23848
24621
  vault: (0, import_kit21.address)("ECJGrTZ6QYMEwiEAnL4oReWF126uc22e9Lojy9qyCjHT"),
23849
24622
  manager: (0, import_kit21.address)("4jMRBkpWrfhhwFYTwG3o7hmsXQwbJUwdyUX8htB6KwLJ"),
23850
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")
23851
24629
  }
23852
24630
  ];
23853
24631
 
@@ -23906,7 +24684,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
23906
24684
  }
23907
24685
 
23908
24686
  // src/services/consensusOracle/consensusOracleService.ts
23909
- var import_common61 = __toESM(require_dist());
24687
+ var import_common63 = __toESM(require_dist());
23910
24688
  var ConsensusOracleService = class {
23911
24689
  constructor(client, deps) {
23912
24690
  this.client = client;
@@ -23942,7 +24720,7 @@ var ConsensusOracleService = class {
23942
24720
  receiptMints
23943
24721
  );
23944
24722
  const filteredCount = vaultState.holdings.filter(
23945
- (holding) => receiptMints.has((0, import_common61.fromWeb3Pk)(holding.mint).toString())
24723
+ (holding) => receiptMints.has((0, import_common63.fromWeb3Pk)(holding.mint).toString())
23946
24724
  ).length;
23947
24725
  if (filteredCount > 0) {
23948
24726
  log(
@@ -24211,8 +24989,8 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
24211
24989
 
24212
24990
  // src/services/externalLiquidityIntegrityService.ts
24213
24991
  var import_kit22 = require("@solana/kit");
24214
- var import_web341 = require("@solana/web3.js");
24215
- var import_common62 = __toESM(require_dist());
24992
+ var import_web343 = require("@solana/web3.js");
24993
+ var import_common64 = __toESM(require_dist());
24216
24994
  var import_marginfi5 = __toESM(require_dist2());
24217
24995
  var import_kamino5 = __toESM(require_dist3());
24218
24996
  var import_marginfi_client_v23 = require("@mrgnlabs/marginfi-client-v2");
@@ -24322,7 +25100,7 @@ function parseActiveSlots(externalLiquidity) {
24322
25100
  if (discriminant === 0) continue;
24323
25101
  if (discriminant !== 1 && discriminant !== 2) continue;
24324
25102
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
24325
- const userAccount = (0, import_common62.toAddress)(new import_web341.PublicKey(pubkeyBytes));
25103
+ const userAccount = (0, import_common64.toAddress)(new import_web343.PublicKey(pubkeyBytes));
24326
25104
  if (isZeroPubkey2(userAccount))
24327
25105
  throw new Error("Registered external position has a zero address");
24328
25106
  if (results.some((slot) => slot.userAccount === userAccount)) continue;
@@ -24494,7 +25272,7 @@ var ExternalLiquidityIntegrityService = class {
24494
25272
  const decimals = Number(holding.decimals ?? 0);
24495
25273
  const minRaw = toRawAmount(minAmountUi, decimals);
24496
25274
  let targetLocalAmount;
24497
- if (mintAddress === import_common62.USDC_MINT) {
25275
+ if (mintAddress === import_common64.USDC_MINT) {
24498
25276
  const tvl = toBigInt3(vaultState.accounting.tvl);
24499
25277
  const price = toBigInt3(holding.price);
24500
25278
  const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
@@ -24597,25 +25375,25 @@ var ExternalLiquidityIntegrityService = class {
24597
25375
  * from vault accounting as though it were the balance of each separate slot. */
24598
25376
  async loadPositions(vault, mint, slots) {
24599
25377
  const marginfi = (0, import_marginfi5.marginfiAccountsForMint)(mint);
24600
- if (!marginfi && mint !== import_common62.USDC_MINT)
25378
+ if (!marginfi && mint !== import_common64.USDC_MINT)
24601
25379
  return {
24602
25380
  local: 0n,
24603
25381
  positions: [],
24604
- tokenProgram: (0, import_kit22.address)(import_web341.PublicKey.default.toBase58()),
24605
- 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())
24606
25384
  };
24607
25385
  const connection = this.client.provider.connection;
24608
25386
  const mintInfo = await connection.getAccountInfo(
24609
- new import_web341.PublicKey(mint),
25387
+ new import_web343.PublicKey(mint),
24610
25388
  "confirmed"
24611
25389
  );
24612
25390
  if (!mintInfo) throw new Error(`Missing mint ${mint}`);
24613
- const tokenProgram = (0, import_common62.fromWeb3Pk)(mintInfo.owner);
24614
- 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);
24615
25393
  const positions = [];
24616
25394
  for (const slot of slots) {
24617
25395
  if (slot.source === "marginfi" && !marginfi) continue;
24618
- if (slot.source === "kamino" && mint !== import_common62.USDC_MINT) continue;
25396
+ if (slot.source === "kamino" && mint !== import_common64.USDC_MINT) continue;
24619
25397
  const kamino = slot.source === "kamino" ? await loadKaminoDeposit({
24620
25398
  connection,
24621
25399
  vault,
@@ -24626,7 +25404,7 @@ var ExternalLiquidityIntegrityService = class {
24626
25404
  throw new Error("Kamino token program mismatch");
24627
25405
  const data = Buffer.alloc(256);
24628
25406
  data[0] = slot.source === "marginfi" ? 1 : 2;
24629
- new import_web341.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
25407
+ new import_web343.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
24630
25408
  const withdrawal = await loadWithdrawalPosition({
24631
25409
  connection,
24632
25410
  vault,
@@ -24662,8 +25440,8 @@ var ExternalLiquidityIntegrityService = class {
24662
25440
  async executeMoves(args) {
24663
25441
  const { vault, mintAddress, hwManager, snapshot: snapshot2, moves, dryRun, log } = args;
24664
25442
  const instructions2 = [
24665
- (0, import_common62.toKitInstruction)(
24666
- import_web341.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
25443
+ (0, import_common64.toKitInstruction)(
25444
+ import_web343.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
24667
25445
  )
24668
25446
  ];
24669
25447
  const lookupTables = /* @__PURE__ */ new Set();
@@ -24676,7 +25454,7 @@ var ExternalLiquidityIntegrityService = class {
24676
25454
  cpiRefs = position.withdrawal.explicitRefs(move.amount);
24677
25455
  } else if (position.source === "kamino") {
24678
25456
  if (!position.kamino) throw new Error("Missing Kamino reserve");
24679
- cpiRefs = (0, import_common62.createCpiRefs)(
25457
+ cpiRefs = (0, import_common64.createCpiRefs)(
24680
25458
  (0, import_kamino5.kaminoDepositCpis)({
24681
25459
  ...position.kamino,
24682
25460
  vault,
@@ -24687,14 +25465,14 @@ var ExternalLiquidityIntegrityService = class {
24687
25465
  );
24688
25466
  } else {
24689
25467
  const configured = (0, import_marginfi5.marginfiAccountsForMint)(mintAddress);
24690
- cpiRefs = (0, import_common62.createCpiRefs)([
25468
+ cpiRefs = (0, import_common64.createCpiRefs)([
24691
25469
  new import_marginfi5.CpiClient({ accounts: configured }).deposit_cpi({
24692
25470
  marginfiAccount: position.userAccount,
24693
25471
  authority: vault,
24694
25472
  signerTokenAccount: snapshot2.vaultAta,
24695
25473
  amount: move.amount,
24696
- lookupTables: (import_marginfi_client_v23.ADDRESS_LOOKUP_TABLE_FOR_GROUP[configured.group] ?? []).map(import_common62.fromWeb3Pk),
24697
- 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)] : []
24698
25476
  })
24699
25477
  ]);
24700
25478
  }
@@ -24702,7 +25480,7 @@ var ExternalLiquidityIntegrityService = class {
24702
25480
  instructions2.push(
24703
25481
  await this.client.tx.protocolInteraction.getIx({
24704
25482
  vault,
24705
- hwManager: (0, import_common62.fromWeb3Pk)(hwManager.publicKey),
25483
+ hwManager: (0, import_common64.fromWeb3Pk)(hwManager.publicKey),
24706
25484
  ...cpiRefs,
24707
25485
  externalLiquidityIndex: position.index,
24708
25486
  affectedAssetMint: mintAddress,
@@ -24734,10 +25512,10 @@ var ExternalLiquidityIntegrityService = class {
24734
25512
 
24735
25513
  // src/services/idleLiquidityService.ts
24736
25514
  var import_kit23 = require("@solana/kit");
24737
- var import_spl_token24 = require("@solana/spl-token");
25515
+ var import_spl_token26 = require("@solana/spl-token");
24738
25516
  var import_marginfi_client_v24 = require("@mrgnlabs/marginfi-client-v2");
24739
- var import_web342 = require("@solana/web3.js");
24740
- var import_common63 = __toESM(require_dist());
25517
+ var import_web344 = require("@solana/web3.js");
25518
+ var import_common65 = __toESM(require_dist());
24741
25519
  var import_marginfi6 = __toESM(require_dist2());
24742
25520
  var IDLE_RESERVE_FLOOR_BPS = 400;
24743
25521
  var IDLE_RESERVE_TARGET_BPS = 500;
@@ -24841,8 +25619,8 @@ var IdleLiquidityService = class {
24841
25619
  );
24842
25620
  }
24843
25621
  quote = await jupiter.getQuote({
24844
- inputMint: import_common63.PST_MINT,
24845
- outputMint: import_common63.USDC_MINT,
25622
+ inputMint: import_common65.PST_MINT,
25623
+ outputMint: import_common65.USDC_MINT,
24846
25624
  amount: pstInput,
24847
25625
  slippageBps
24848
25626
  });
@@ -24887,13 +25665,13 @@ var IdleLiquidityService = class {
24887
25665
  /** Read live local, Project0 and Kamino USDC, excluding other deployed capital. */
24888
25666
  async fetchIdleUsdc(vault, vaultState) {
24889
25667
  const connection = this.client.provider.connection;
24890
- const vaultPk = new import_web342.PublicKey(vault);
24891
- const usdcMint = new import_web342.PublicKey(import_common63.USDC_MINT);
24892
- 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);
24893
25671
  const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
24894
25672
  let localAmount = 0n;
24895
25673
  if (tokenInfo) {
24896
- 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);
24897
25675
  if (!tokenAccount.mint.equals(usdcMint) || !tokenAccount.owner.equals(vaultPk) || !tokenAccount.isInitialized) {
24898
25676
  throw new Error(`Invalid vault USDC token account: ${ata.toBase58()}`);
24899
25677
  }
@@ -24902,7 +25680,7 @@ var IdleLiquidityService = class {
24902
25680
  const kamino = await this.fetchKaminoUsdc(
24903
25681
  vault,
24904
25682
  vaultState,
24905
- (0, import_common63.fromWeb3Pk)(ata)
25683
+ (0, import_common65.fromWeb3Pk)(ata)
24906
25684
  );
24907
25685
  const slotIndex = vaultState.externalLiquidity.findIndex(
24908
25686
  (slot) => slot.data[0] === 1
@@ -24920,12 +25698,12 @@ var IdleLiquidityService = class {
24920
25698
  if (data.length < 40) {
24921
25699
  throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
24922
25700
  }
24923
- 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)));
24924
25702
  const positionInfo = await connection.getAccountInfo(
24925
25703
  positionPk,
24926
25704
  "confirmed"
24927
25705
  );
24928
- 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))) {
24929
25707
  throw new Error(
24930
25708
  `Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
24931
25709
  );
@@ -24974,17 +25752,17 @@ var IdleLiquidityService = class {
24974
25752
  if (slot.data[0] !== 2) continue;
24975
25753
  if (slot.data.length < 40)
24976
25754
  throw new Error(`Invalid Kamino external-liquidity slot ${index}`);
24977
- const key = new import_web342.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
24978
- 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))
24979
25757
  throw new Error(`Missing Kamino position in slot ${index}`);
24980
25758
  if (seen.has(key.toBase58())) continue;
24981
25759
  seen.add(key.toBase58());
24982
25760
  const position = await loadWithdrawalPosition({
24983
25761
  connection: this.client.provider.connection,
24984
25762
  vault,
24985
- assetMint: import_common63.USDC_MINT,
25763
+ assetMint: import_common65.USDC_MINT,
24986
25764
  vaultAssetAta,
24987
- tokenProgram: (0, import_common63.fromWeb3Pk)(import_spl_token24.TOKEN_PROGRAM_ID),
25765
+ tokenProgram: (0, import_common65.fromWeb3Pk)(import_spl_token26.TOKEN_PROGRAM_ID),
24988
25766
  slot,
24989
25767
  index,
24990
25768
  requireUsablePosition: true
@@ -25035,8 +25813,8 @@ var IdleLiquidityService = class {
25035
25813
  log(`Vault ${vault}: ${reason} \u2014 skipping`);
25036
25814
  return { result: { ...empty, status: "no-tvl", reason } };
25037
25815
  }
25038
- const usdc = findHolding2(vaultState, import_common63.USDC_MINT);
25039
- 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);
25040
25818
  if (!usdc || !pst) {
25041
25819
  const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
25042
25820
  log(`Vault ${vault}: ${reason} \u2014 skipping`);
@@ -25187,16 +25965,16 @@ var IdleLiquidityService = class {
25187
25965
  */
25188
25966
  async mintTokenProgram(mint) {
25189
25967
  const account = await this.client.provider.connection.getAccountInfo(
25190
- new import_web342.PublicKey(mint),
25968
+ new import_web344.PublicKey(mint),
25191
25969
  "confirmed"
25192
25970
  );
25193
25971
  if (!account) throw new Error(`Mint account not found: ${mint}`);
25194
- 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)) {
25195
25973
  throw new Error(
25196
25974
  `Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
25197
25975
  );
25198
25976
  }
25199
- return (0, import_common63.fromWeb3Pk)(account.owner);
25977
+ return (0, import_common65.fromWeb3Pk)(account.owner);
25200
25978
  }
25201
25979
  /**
25202
25980
  * Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
@@ -25216,23 +25994,23 @@ var IdleLiquidityService = class {
25216
25994
  dryRun,
25217
25995
  log
25218
25996
  } = params;
25219
- const signer = (0, import_common63.fromWeb3Pk)(hwManager.publicKey);
25997
+ const signer = (0, import_common65.fromWeb3Pk)(hwManager.publicKey);
25220
25998
  const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
25221
- this.mintTokenProgram(import_common63.PST_MINT),
25222
- this.mintTokenProgram(import_common63.USDC_MINT)
25999
+ this.mintTokenProgram(import_common65.PST_MINT),
26000
+ this.mintTokenProgram(import_common65.USDC_MINT)
25223
26001
  ]);
25224
26002
  const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
25225
26003
  payer: signer
25226
26004
  });
25227
- const { accounts: accounts2, refs, lookupTables } = (0, import_common63.createCpiRefs)([jupiterCpi]);
26005
+ const { accounts: accounts2, refs, lookupTables } = (0, import_common65.createCpiRefs)([jupiterCpi]);
25228
26006
  const vaultTrancheState = coerceBool4(
25229
26007
  vaultState.tranchingEnabled
25230
26008
  ) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
25231
26009
  const plan = await this.client.tx.jupiterSwap.getTx({
25232
26010
  hwManager: signer,
25233
26011
  vault,
25234
- sourceMint: import_common63.PST_MINT,
25235
- destinationMint: import_common63.USDC_MINT,
26012
+ sourceMint: import_common65.PST_MINT,
26013
+ destinationMint: import_common65.USDC_MINT,
25236
26014
  refs,
25237
26015
  accounts: accounts2,
25238
26016
  sourceTokenProgram,
@@ -25242,26 +26020,26 @@ var IdleLiquidityService = class {
25242
26020
  });
25243
26021
  const connection = this.client.provider.connection;
25244
26022
  const instructions2 = [
25245
- import_web342.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
26023
+ import_web344.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
25246
26024
  ...cuPriceMicroLamports > 0 ? [
25247
- import_web342.ComputeBudgetProgram.setComputeUnitPrice({
26025
+ import_web344.ComputeBudgetProgram.setComputeUnitPrice({
25248
26026
  microLamports: cuPriceMicroLamports
25249
26027
  })
25250
26028
  ] : [],
25251
- ...(jupiterCpi.preInstructions ?? []).map(import_common63.fromKitInstruction),
25252
- ...plan.instructions.map(import_common63.fromKitInstruction)
26029
+ ...(jupiterCpi.preInstructions ?? []).map(import_common65.fromKitInstruction),
26030
+ ...plan.instructions.map(import_common65.fromKitInstruction)
25253
26031
  ];
25254
26032
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
25255
- const lookupTableAccounts = await (0, import_common63.fetchLookupTables)(
26033
+ const lookupTableAccounts = await (0, import_common65.fetchLookupTables)(
25256
26034
  connection,
25257
26035
  plan.lookupTables ?? []
25258
26036
  );
25259
- const message2 = new import_web342.TransactionMessage({
26037
+ const message2 = new import_web344.TransactionMessage({
25260
26038
  payerKey: hwManager.publicKey,
25261
26039
  recentBlockhash: blockhash,
25262
26040
  instructions: instructions2
25263
26041
  }).compileToV0Message(lookupTableAccounts);
25264
- const transaction = new import_web342.VersionedTransaction(message2);
26042
+ const transaction = new import_web344.VersionedTransaction(message2);
25265
26043
  transaction.sign([hwManager]);
25266
26044
  if (!this.client.skipSimulation) {
25267
26045
  const simulation = await connection.simulateTransaction(transaction, {
@@ -25307,9 +26085,9 @@ var IdleLiquidityService = class {
25307
26085
 
25308
26086
  // src/services/timelockSettlementService.ts
25309
26087
  var import_kit24 = require("@solana/kit");
25310
- var import_web343 = require("@solana/web3.js");
25311
- var import_common64 = __toESM(require_dist());
25312
- 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();
25313
26091
  var CONSENSUS_SIGNER_CAPACITY = 4;
25314
26092
  var CONSENSUS_ENTRY_OFFSET = 40;
25315
26093
  var CONSENSUS_ENTRY_SIZE = 272;
@@ -25349,7 +26127,7 @@ function decodePendingConsensusSigners(data) {
25349
26127
  const signers = [];
25350
26128
  for (let i = 0; i < count; i += 1) {
25351
26129
  const start = CONSENSUS_PENDING_OFFSET + i * 32;
25352
- 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();
25353
26131
  if (signer === ZERO_PUBKEY) {
25354
26132
  throw new Error(`pending consensus signer ${i} is unset`);
25355
26133
  }
@@ -25405,7 +26183,7 @@ var TimelockSettlementService = class {
25405
26183
  });
25406
26184
  const dryRun = opts.dryRun ?? false;
25407
26185
  const now = opts.now ?? await this.chainTime();
25408
- const fulfillerAddress = (0, import_common64.fromWeb3Pk)(fulfiller.publicKey);
26186
+ const fulfillerAddress = (0, import_common66.fromWeb3Pk)(fulfiller.publicKey);
25409
26187
  const allVaults = opts.vault ? [
25410
26188
  {
25411
26189
  publicKey: opts.vault,
@@ -25548,18 +26326,18 @@ var TimelockSettlementService = class {
25548
26326
 
25549
26327
  // src/services/nestWithdrawalService.ts
25550
26328
  var import_kit25 = require("@solana/kit");
25551
- var import_spl_token25 = require("@solana/spl-token");
25552
- var import_web344 = require("@solana/web3.js");
25553
- 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());
25554
26332
  var import_nest3 = __toESM(require_dist4());
25555
26333
  var import_nest4 = __toESM(require_dist4());
25556
- var NestOftProgram = new import_web344.PublicKey(
26334
+ var NestOftProgram = new import_web346.PublicKey(
25557
26335
  "ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
25558
26336
  );
25559
- var NestOftStore = new import_web344.PublicKey(
26337
+ var NestOftStore = new import_web346.PublicKey(
25560
26338
  "k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
25561
26339
  );
25562
- var UsdcMint = new import_web344.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
26340
+ var UsdcMint = new import_web346.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
25563
26341
  var NestPerenaComposer = Buffer.from(
25564
26342
  "000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
25565
26343
  "hex"
@@ -25576,7 +26354,7 @@ async function buildNestWithdrawalRequest(args) {
25576
26354
  return decodeNestWithdrawalRequest({ ...args, txBase64 });
25577
26355
  }
25578
26356
  async function decodeNestWithdrawalRequest(args) {
25579
- const transaction = import_web344.VersionedTransaction.deserialize(
26357
+ const transaction = import_web346.VersionedTransaction.deserialize(
25580
26358
  Buffer.from(args.txBase64, "base64")
25581
26359
  );
25582
26360
  const message2 = transaction.message;
@@ -25597,19 +26375,19 @@ async function decodeNestWithdrawalRequest(args) {
25597
26375
  return value;
25598
26376
  })
25599
26377
  );
25600
- const decoded = import_web344.TransactionMessage.decompile(message2, {
26378
+ const decoded = import_web346.TransactionMessage.decompile(message2, {
25601
26379
  addressLookupTableAccounts: tables
25602
26380
  });
25603
- const nestMint = new import_web344.PublicKey(NEST_RWA_SHARE_MINT);
25604
- const sourceAta = (0, import_spl_token25.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
25605
- 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);
25606
26384
  const instructions2 = decoded.instructions.filter(
25607
- (ix) => !ix.programId.equals(import_web344.ComputeBudgetProgram.programId)
26385
+ (ix) => !ix.programId.equals(import_web346.ComputeBudgetProgram.programId)
25608
26386
  );
25609
26387
  let sends = 0;
25610
26388
  for (const ix of instructions2) {
25611
- if (ix.programId.equals(import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID)) {
25612
- 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)) {
25613
26391
  throw new Error("Unexpected token account creation in Nest withdrawal");
25614
26392
  }
25615
26393
  continue;
@@ -25626,20 +26404,20 @@ async function decodeNestWithdrawalRequest(args) {
25626
26404
  if (sends !== 1)
25627
26405
  throw new Error("Nest withdrawal must contain exactly one OFT send");
25628
26406
  return {
25629
- instructions: instructions2.map(import_common65.toKitInstruction),
26407
+ instructions: instructions2.map(import_common67.toKitInstruction),
25630
26408
  lookupTables: tables.map((table) => (0, import_kit25.address)(table.key.toBase58()))
25631
26409
  };
25632
26410
  }
25633
26411
 
25634
26412
  // src/services/nestDepositService.ts
25635
26413
  var import_kit26 = require("@solana/kit");
25636
- var import_spl_token26 = require("@solana/spl-token");
25637
- var import_web345 = require("@solana/web3.js");
25638
- 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());
25639
26417
  var import_nest5 = __toESM(require_dist4());
25640
- var Usdc = new import_web345.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
25641
- var Messenger = new import_web345.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
25642
- 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(
25643
26421
  "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
25644
26422
  );
25645
26423
  var Router = Buffer.from(
@@ -25692,7 +26470,7 @@ async function decodeNestDepositRequest(args) {
25692
26470
  "Nest deposit must be a positive, safely representable USDC base-unit amount"
25693
26471
  );
25694
26472
  }
25695
- const message2 = import_web345.VersionedTransaction.deserialize(
26473
+ const message2 = import_web347.VersionedTransaction.deserialize(
25696
26474
  Buffer.from(args.txBase64, "base64")
25697
26475
  ).message;
25698
26476
  if (!message2.staticAccountKeys[0].equals(args.owner))
@@ -25707,23 +26485,23 @@ async function decodeNestDepositRequest(args) {
25707
26485
  return value;
25708
26486
  })
25709
26487
  );
25710
- const instructions2 = import_web345.TransactionMessage.decompile(message2, {
26488
+ const instructions2 = import_web347.TransactionMessage.decompile(message2, {
25711
26489
  addressLookupTableAccounts: tables
25712
26490
  }).instructions;
25713
- const shareMint = new import_web345.PublicKey(NEST_RWA_SHARE_MINT);
25714
- const shareAta = (0, import_spl_token26.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
25715
- 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);
25716
26494
  let burn;
25717
26495
  for (const ix of instructions2) {
25718
- if (ix.programId.equals(import_web345.ComputeBudgetProgram.programId)) continue;
25719
- if (ix.programId.equals(import_spl_token26.ASSOCIATED_TOKEN_PROGRAM_ID)) {
25720
- 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))
25721
26499
  throw new Error("Unexpected Nest deposit token account creation");
25722
26500
  continue;
25723
26501
  }
25724
26502
  const d = ix.data;
25725
26503
  const matches = (index, key) => ix.keys[index]?.pubkey.equals(key);
25726
- 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(
25727
26505
  (meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
25728
26506
  )) {
25729
26507
  throw new Error(
@@ -25742,33 +26520,33 @@ async function decodeNestDepositRequest(args) {
25742
26520
  burn.keys[1] = { pubkey: args.owner, isSigner: true, isWritable: true };
25743
26521
  return {
25744
26522
  instructions: [
25745
- (0, import_spl_token26.createAssociatedTokenAccountIdempotentInstruction)(
26523
+ (0, import_spl_token28.createAssociatedTokenAccountIdempotentInstruction)(
25746
26524
  args.owner,
25747
26525
  shareAta,
25748
26526
  args.owner,
25749
26527
  shareMint
25750
26528
  ),
25751
26529
  burn
25752
- ].map(import_common66.toKitInstruction),
26530
+ ].map(import_common68.toKitInstruction),
25753
26531
  lookupTables: tables.map((table) => (0, import_kit26.address)(table.key.toBase58())),
25754
26532
  ephemeralSignerKeys: [eventKey]
25755
26533
  };
25756
26534
  }
25757
26535
 
25758
26536
  // src/services/vaultLutManager.ts
25759
- var import_web346 = require("@solana/web3.js");
26537
+ var import_web348 = require("@solana/web3.js");
25760
26538
  var MAX_LUT_ADDRESSES = 256;
25761
26539
  var ACTIVE = (1n << 64n) - 1n;
25762
26540
  var asAddress = (key) => key.toBase58();
25763
26541
  function uniqueLutAddresses(addresses) {
25764
- 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)));
25765
26543
  }
25766
26544
  var VaultLutManager = class {
25767
26545
  constructor(connection) {
25768
26546
  this.connection = connection;
25769
26547
  }
25770
26548
  async fetch(table) {
25771
- const account = (await this.connection.getAddressLookupTable(new import_web346.PublicKey(table), {
26549
+ const account = (await this.connection.getAddressLookupTable(new import_web348.PublicKey(table), {
25772
26550
  commitment: "confirmed"
25773
26551
  })).value;
25774
26552
  if (!account) throw new Error(`Lookup table not found: ${table}`);
@@ -25780,14 +26558,14 @@ var VaultLutManager = class {
25780
26558
  * mapping is lost. Also accepts older tables containing the vault elsewhere. */
25781
26559
  async findForVault(authority, vault) {
25782
26560
  const accounts2 = await this.connection.getProgramAccounts(
25783
- import_web346.AddressLookupTableProgram.programId,
26561
+ import_web348.AddressLookupTableProgram.programId,
25784
26562
  {
25785
26563
  commitment: "confirmed",
25786
26564
  filters: [{ memcmp: { offset: 22, bytes: authority.toBase58() } }]
25787
26565
  }
25788
26566
  );
25789
26567
  return accounts2.flatMap(({ pubkey: pubkey2, account }) => {
25790
- const state = import_web346.AddressLookupTableAccount.deserialize(account.data);
26568
+ const state = import_web348.AddressLookupTableAccount.deserialize(account.data);
25791
26569
  return state.deactivationSlot === ACTIVE && state.authority?.equals(authority) && state.addresses.some((a) => a.toBase58() === vault) ? [asAddress(pubkey2)] : [];
25792
26570
  });
25793
26571
  }
@@ -25819,7 +26597,7 @@ var VaultLutManager = class {
25819
26597
  let created = false;
25820
26598
  const send = async (instructions2) => {
25821
26599
  const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash("confirmed");
25822
- const tx = new import_web346.Transaction({
26600
+ const tx = new import_web348.Transaction({
25823
26601
  feePayer: args.payer.publicKey,
25824
26602
  blockhash,
25825
26603
  lastValidBlockHeight
@@ -25846,7 +26624,7 @@ var VaultLutManager = class {
25846
26624
  };
25847
26625
  if (!table) {
25848
26626
  const hashes = await this.connection.getAccountInfo(
25849
- import_web346.SYSVAR_SLOT_HASHES_PUBKEY,
26627
+ import_web348.SYSVAR_SLOT_HASHES_PUBKEY,
25850
26628
  "confirmed"
25851
26629
  );
25852
26630
  if (!hashes || hashes.data.length < 48 || hashes.data.readBigUInt64LE(0) === 0n)
@@ -25854,7 +26632,7 @@ var VaultLutManager = class {
25854
26632
  const recentSlot = Number(hashes.data.readBigUInt64LE(8));
25855
26633
  if (!Number.isSafeInteger(recentSlot))
25856
26634
  throw new Error("Recent slot exceeds safe integer range");
25857
- const [create, key] = import_web346.AddressLookupTableProgram.createLookupTable({
26635
+ const [create, key] = import_web348.AddressLookupTableProgram.createLookupTable({
25858
26636
  authority: authority.publicKey,
25859
26637
  payer: args.payer.publicKey,
25860
26638
  recentSlot
@@ -25869,11 +26647,11 @@ var VaultLutManager = class {
25869
26647
  args.onProgress?.(`Creating vault LUT: ${table}`);
25870
26648
  await send([
25871
26649
  create,
25872
- import_web346.AddressLookupTableProgram.extendLookupTable({
26650
+ import_web348.AddressLookupTableProgram.extendLookupTable({
25873
26651
  lookupTable: key,
25874
26652
  authority: authority.publicKey,
25875
26653
  payer: args.payer.publicKey,
25876
- addresses: [new import_web346.PublicKey(args.vault)]
26654
+ addresses: [new import_web348.PublicKey(args.vault)]
25877
26655
  })
25878
26656
  ]);
25879
26657
  created = true;
@@ -25893,11 +26671,11 @@ var VaultLutManager = class {
25893
26671
  for (let i = 0; i < missing.length; i += 20) {
25894
26672
  const batch = missing.slice(i, i + 20);
25895
26673
  await send([
25896
- import_web346.AddressLookupTableProgram.extendLookupTable({
25897
- lookupTable: new import_web346.PublicKey(table),
26674
+ import_web348.AddressLookupTableProgram.extendLookupTable({
26675
+ lookupTable: new import_web348.PublicKey(table),
25898
26676
  authority: authority.publicKey,
25899
26677
  payer: args.payer.publicKey,
25900
- addresses: batch.map((a) => new import_web346.PublicKey(a))
26678
+ addresses: batch.map((a) => new import_web348.PublicKey(a))
25901
26679
  })
25902
26680
  ]);
25903
26681
  args.onProgress?.(
@@ -25919,13 +26697,13 @@ var VaultLutManager = class {
25919
26697
  };
25920
26698
 
25921
26699
  // src/services/vaultLookupTableAccounts.ts
25922
- var import_core25 = require("@anchor-lang/core");
25923
- var import_web347 = require("@solana/web3.js");
25924
- 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");
25925
26703
  var import_marginfi_client_v25 = require("@mrgnlabs/marginfi-client-v2");
25926
26704
  var import_Obligation3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
25927
26705
  var import_Reserve3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
25928
- var import_common67 = __toESM(require_dist());
26706
+ var import_common69 = __toESM(require_dist());
25929
26707
  var import_marginfi7 = __toESM(require_dist2());
25930
26708
  var import_kamino6 = __toESM(require_dist3());
25931
26709
  async function collectVaultLookupTableAccounts(client, vault, options = {}) {
@@ -25940,13 +26718,13 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
25940
26718
  const add = (key) => addresses.push(typeof key === "string" ? key : key.toBase58());
25941
26719
  [
25942
26720
  client.program.programId,
25943
- import_spl_token27.ASSOCIATED_TOKEN_PROGRAM_ID,
25944
- import_spl_token27.TOKEN_PROGRAM_ID,
25945
- import_spl_token27.TOKEN_2022_PROGRAM_ID,
25946
- 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
25947
26725
  ].forEach(add);
25948
26726
  const publicKeys = (value) => {
25949
- if (value instanceof import_web347.PublicKey) {
26727
+ if (value instanceof import_web349.PublicKey) {
25950
26728
  add(value);
25951
26729
  return;
25952
26730
  }
@@ -25965,7 +26743,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
25965
26743
  }
25966
26744
  ];
25967
26745
  const tranche = await client.program.account.vaultTrancheState.fetchNullable(
25968
- new import_web347.PublicKey(tranchePda)
26746
+ new import_web349.PublicKey(tranchePda)
25969
26747
  );
25970
26748
  if (tranche) {
25971
26749
  publicKeys(tranche.config);
@@ -25985,30 +26763,30 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
25985
26763
  );
25986
26764
  }
25987
26765
  const holdings = state.holdings.filter(
25988
- (h) => !h.mint.equals(import_web347.PublicKey.default)
26766
+ (h) => !h.mint.equals(import_web349.PublicKey.default)
25989
26767
  );
25990
26768
  for (const h of holdings) {
25991
26769
  const mint = h.mint.toBase58(), program = tokenProgramAddressFromIdlEnum(h.tokenProgram);
25992
26770
  add(mint);
25993
26771
  add(program);
25994
- add((0, import_common67.getAtaAddress)(mint, vault, program, true));
25995
- add((0, import_common67.getAtaAddress)(mint, fee, program, true));
25996
- 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));
25997
26775
  }
25998
26776
  for (const share of shares) {
25999
26777
  add(share.mint);
26000
26778
  add(share.program);
26001
- add((0, import_common67.getAtaAddress)(share.mint, vault, share.program, true));
26002
- 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));
26003
26781
  if (options.user)
26004
- 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));
26005
26783
  }
26006
26784
  const slots = state.externalLiquidity.filter(
26007
26785
  (s) => [1, 2].includes(s.data[0])
26008
26786
  );
26009
26787
  for (const slot of slots) {
26010
- const position = new import_web347.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
26011
- 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;
26012
26790
  add(position);
26013
26791
  const info = await connection.getAccountInfo(position, "confirmed");
26014
26792
  if (slot.data[0] === 1) {
@@ -26019,7 +26797,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26019
26797
  const cpi = new import_marginfi7.CpiClient({ accounts: config }).withdraw_cpi({
26020
26798
  marginfiAccount: position.toBase58(),
26021
26799
  authority: vault,
26022
- destinationTokenAccount: (0, import_common67.getAtaAddress)(
26800
+ destinationTokenAccount: (0, import_common69.getAtaAddress)(
26023
26801
  mint,
26024
26802
  vault,
26025
26803
  config.tokenProgram,
@@ -26031,7 +26809,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26031
26809
  if (!info) continue;
26032
26810
  if (info.owner.toBase58() !== import_marginfi7.MARGINFI_PROGRAM_ID)
26033
26811
  throw new Error("Invalid Marginfi position owner");
26034
- const idl = new import_core25.Program(
26812
+ const idl = new import_core26.Program(
26035
26813
  { ...import_marginfi_client_v25.MARGINFI_IDL, address: import_marginfi7.MARGINFI_PROGRAM_ID },
26036
26814
  { connection }
26037
26815
  ).idl;
@@ -26072,7 +26850,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26072
26850
  if (!reserveKeys.length)
26073
26851
  throw new Error(`No reserves found for Kamino obligation ${position}`);
26074
26852
  const infos = await connection.getMultipleAccountsInfo(
26075
- reserveKeys.map((a) => new import_web347.PublicKey(a)),
26853
+ reserveKeys.map((a) => new import_web349.PublicKey(a)),
26076
26854
  "confirmed"
26077
26855
  );
26078
26856
  const reserves = infos.map((info2, i) => {
@@ -26102,7 +26880,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26102
26880
  obligation: position.toBase58(),
26103
26881
  reserves,
26104
26882
  reserve,
26105
- destination: (0, import_common67.getAtaAddress)(
26883
+ destination: (0, import_common69.getAtaAddress)(
26106
26884
  reserve.liquidityMint,
26107
26885
  vault,
26108
26886
  reserve.liquidityTokenProgram,
@@ -26122,7 +26900,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
26122
26900
  }
26123
26901
 
26124
26902
  // src/index.ts
26125
- var import_common68 = __toESM(require_dist());
26903
+ var import_common70 = __toESM(require_dist());
26126
26904
  // Annotate the CommonJS export names for ESM import in node:
26127
26905
  0 && (module.exports = {
26128
26906
  ASSET_DECIMALS,
@@ -26176,6 +26954,7 @@ var import_common68 = __toESM(require_dist());
26176
26954
  ExternalLiquidityIntegrityService,
26177
26955
  ExternalPositionRegistry,
26178
26956
  FEE_VAULT_CACHE_CATEGORY,
26957
+ FulfillAsyncWithdrawBuilder,
26179
26958
  FulfillJuniorTrancheWithdrawBuilder,
26180
26959
  IDL,
26181
26960
  IDLE_RESERVE_FLOOR_BPS,
@@ -26230,6 +27009,7 @@ var import_common68 = __toESM(require_dist());
26230
27009
  REPORTABLE_ORACLE_VARIANTS,
26231
27010
  RemoveAssetHoldingBuilder,
26232
27011
  ReportIncentiveV3Builder,
27012
+ RequestAsyncWithdrawBuilder,
26233
27013
  RequestJuniorTrancheWithdrawBuilder,
26234
27014
  RpcManagerWalletBalanceSource,
26235
27015
  RpcMpcWalletBalanceSource,
@@ -26274,6 +27054,7 @@ var import_common68 = __toESM(require_dist());
26274
27054
  VaultLutManager,
26275
27055
  VaultQuoteClient,
26276
27056
  VaultReallocationBuilder,
27057
+ WALLET_FEE_EXEMPT_WHITELIST,
26277
27058
  WITHDRAWABLE_RESERVE_FLOOR_BPS,
26278
27059
  WithdrawalQueueService,
26279
27060
  accountingUnitPriceToUsd,
@@ -26372,6 +27153,7 @@ var import_common68 = __toESM(require_dist());
26372
27153
  previousPhysicalNav,
26373
27154
  priceInAccountingUnit,
26374
27155
  publishedConsensusBlockers,
27156
+ quoteWithdrawalPayout,
26375
27157
  readI64LE,
26376
27158
  readSplMintSupply,
26377
27159
  reconcileManagerWalletBalances,