@perena/vault-sdk 1.0.27 → 1.0.28

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +203 -289
  2. package/dist/index.js +523 -555
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3469,13 +3469,13 @@ var import_path = __toESM(require("path"));
3469
3469
  var import_core18 = require("@anchor-lang/core");
3470
3470
  var import_web320 = require("@solana/web3.js");
3471
3471
  var import_kit10 = require("@solana/kit");
3472
- var import_common36 = __toESM(require_dist());
3472
+ var import_common37 = __toESM(require_dist());
3473
3473
 
3474
3474
  // src/client/client.ts
3475
3475
  var import_core17 = require("@anchor-lang/core");
3476
3476
  var import_kit9 = require("@solana/kit");
3477
3477
  var import_web319 = require("@solana/web3.js");
3478
- var import_common35 = __toESM(require_dist());
3478
+ var import_common36 = __toESM(require_dist());
3479
3479
 
3480
3480
  // src/idl/vault.ts
3481
3481
  var IDL = {
@@ -8162,66 +8162,6 @@ var IDL = {
8162
8162
  }
8163
8163
  }
8164
8164
  },
8165
- {
8166
- "name": "fee_collector"
8167
- },
8168
- {
8169
- "name": "fee_collector_output_ata",
8170
- "writable": true,
8171
- "pda": {
8172
- "seeds": [
8173
- {
8174
- "kind": "account",
8175
- "path": "fee_collector"
8176
- },
8177
- {
8178
- "kind": "account",
8179
- "path": "asset_token_program"
8180
- },
8181
- {
8182
- "kind": "account",
8183
- "path": "output_mint"
8184
- }
8185
- ],
8186
- "program": {
8187
- "kind": "const",
8188
- "value": [
8189
- 140,
8190
- 151,
8191
- 37,
8192
- 143,
8193
- 78,
8194
- 36,
8195
- 137,
8196
- 241,
8197
- 187,
8198
- 61,
8199
- 16,
8200
- 41,
8201
- 20,
8202
- 142,
8203
- 13,
8204
- 131,
8205
- 11,
8206
- 90,
8207
- 19,
8208
- 153,
8209
- 218,
8210
- 255,
8211
- 16,
8212
- 132,
8213
- 4,
8214
- 142,
8215
- 123,
8216
- 216,
8217
- 219,
8218
- 233,
8219
- 248,
8220
- 89
8221
- ]
8222
- }
8223
- }
8224
- },
8225
8165
  {
8226
8166
  "name": "queue_input_ata",
8227
8167
  "writable": true,
@@ -8294,7 +8234,24 @@ var IDL = {
8294
8234
  "address": "11111111111111111111111111111111"
8295
8235
  }
8296
8236
  ],
8297
- "args": []
8237
+ "args": [
8238
+ {
8239
+ "name": "external_withdraw_ix_refs",
8240
+ "type": {
8241
+ "option": {
8242
+ "defined": {
8243
+ "name": "InstructionRefs"
8244
+ }
8245
+ }
8246
+ }
8247
+ },
8248
+ {
8249
+ "name": "external_liquidity_source",
8250
+ "type": {
8251
+ "option": "u8"
8252
+ }
8253
+ }
8254
+ ]
8298
8255
  },
8299
8256
  {
8300
8257
  "name": "fulfill_junior_tranche_withdraw_fee_exempt",
@@ -8461,66 +8418,6 @@ var IDL = {
8461
8418
  }
8462
8419
  }
8463
8420
  },
8464
- {
8465
- "name": "fee_collector"
8466
- },
8467
- {
8468
- "name": "fee_collector_output_ata",
8469
- "writable": true,
8470
- "pda": {
8471
- "seeds": [
8472
- {
8473
- "kind": "account",
8474
- "path": "fee_collector"
8475
- },
8476
- {
8477
- "kind": "account",
8478
- "path": "asset_token_program"
8479
- },
8480
- {
8481
- "kind": "account",
8482
- "path": "output_mint"
8483
- }
8484
- ],
8485
- "program": {
8486
- "kind": "const",
8487
- "value": [
8488
- 140,
8489
- 151,
8490
- 37,
8491
- 143,
8492
- 78,
8493
- 36,
8494
- 137,
8495
- 241,
8496
- 187,
8497
- 61,
8498
- 16,
8499
- 41,
8500
- 20,
8501
- 142,
8502
- 13,
8503
- 131,
8504
- 11,
8505
- 90,
8506
- 19,
8507
- 153,
8508
- 218,
8509
- 255,
8510
- 16,
8511
- 132,
8512
- 4,
8513
- 142,
8514
- 123,
8515
- 216,
8516
- 219,
8517
- 233,
8518
- 248,
8519
- 89
8520
- ]
8521
- }
8522
- }
8523
- },
8524
8421
  {
8525
8422
  "name": "queue_input_ata",
8526
8423
  "writable": true,
@@ -8594,6 +8491,22 @@ var IDL = {
8594
8491
  }
8595
8492
  ],
8596
8493
  "args": [
8494
+ {
8495
+ "name": "external_withdraw_ix_refs",
8496
+ "type": {
8497
+ "option": {
8498
+ "defined": {
8499
+ "name": "InstructionRefs"
8500
+ }
8501
+ }
8502
+ }
8503
+ },
8504
+ {
8505
+ "name": "external_liquidity_source",
8506
+ "type": {
8507
+ "option": "u8"
8508
+ }
8509
+ },
8597
8510
  {
8598
8511
  "name": "signer_seeds",
8599
8512
  "type": {
@@ -12933,239 +12846,229 @@ var IDL = {
12933
12846
  ],
12934
12847
  "errors": [
12935
12848
  {
12936
- "code": 14001,
12937
- "name": "Unauthorized",
12938
- "msg": "You are not authorized to perform this action."
12939
- },
12940
- {
12941
- "code": 14002,
12942
- "name": "InvalidBankMint",
12943
- "msg": "Invalid mint"
12944
- },
12945
- {
12946
- "code": 14003,
12947
- "name": "AccountingIssue",
12948
- "msg": "Accounting issue"
12849
+ "code": 6e3,
12850
+ "name": "MintSupplyNonZero",
12851
+ "msg": "Supplied share mint already has non-zero supply"
12949
12852
  },
12950
12853
  {
12951
- "code": 14004,
12952
- "name": "VaultAccountingIssue",
12953
- "msg": "Vault accounting issue"
12854
+ "code": 6001,
12855
+ "name": "InvalidAssetMint",
12856
+ "msg": "Supplied mint is not accepted by this vault"
12954
12857
  },
12955
12858
  {
12956
- "code": 14005,
12957
- "name": "BankAccountingIssue",
12958
- "msg": "Bank accounting issue"
12859
+ "code": 6002,
12860
+ "name": "ZeroDepositAmount",
12861
+ "msg": "Deposit amount must be greater than zero"
12959
12862
  },
12960
12863
  {
12961
- "code": 14006,
12962
- "name": "OnchainAccountingIssue",
12963
- "msg": "Onchain accounting issue"
12864
+ "code": 6003,
12865
+ "name": "ExceedsTvlLimit",
12866
+ "msg": "Deposit would exceed the vault's TVL limit"
12964
12867
  },
12965
12868
  {
12966
- "code": 14007,
12967
- "name": "ExternalAccountingIssue",
12968
- "msg": "External accounting issue"
12869
+ "code": 6004,
12870
+ "name": "ZeroBurnAmount",
12871
+ "msg": "Burn amount must be greater than zero"
12969
12872
  },
12970
12873
  {
12971
- "code": 14008,
12972
- "name": "MintSlippage",
12973
- "msg": "Minting failed due to slippage."
12874
+ "code": 6005,
12875
+ "name": "ZeroAssetAmount",
12876
+ "msg": "Asset amount must be greater than zero"
12974
12877
  },
12975
12878
  {
12976
- "code": 14009,
12977
- "name": "BurningSlippage",
12978
- "msg": "Burning failed due to slippage."
12879
+ "code": 6006,
12880
+ "name": "InsufficientVaultLiquidity",
12881
+ "msg": "Insufficient vault liquidity to satisfy withdrawal"
12979
12882
  },
12980
12883
  {
12981
- "code": 14010,
12982
- "name": "TeamAccountAlreadyExists",
12983
- "msg": "Team account already exists"
12884
+ "code": 6007,
12885
+ "name": "MintAuthorityNotCurator",
12886
+ "msg": "Mint authority is not the curator"
12984
12887
  },
12985
12888
  {
12986
- "code": 14011,
12987
- "name": "OracleAccountAlreadyExists",
12988
- "msg": "Oracle account already exists"
12889
+ "code": 6008,
12890
+ "name": "ZeroTotalSupply",
12891
+ "msg": "Vault total supply is zero"
12989
12892
  },
12990
12893
  {
12991
- "code": 14012,
12894
+ "code": 6009,
12992
12895
  "name": "StaleOracle",
12993
- "msg": "Stale oracle"
12896
+ "msg": "Vault oracle is stale"
12994
12897
  },
12995
12898
  {
12996
- "code": 14013,
12997
- "name": "LocalSignificantPriceChange",
12998
- "msg": "Price change is too large locally"
12899
+ "code": 6010,
12900
+ "name": "InvalidOracleUpdate",
12901
+ "msg": "Invalid oracle update"
12999
12902
  },
13000
12903
  {
13001
- "code": 14014,
13002
- "name": "SignificantPriceChange",
13003
- "msg": "Price change is too large"
12904
+ "code": 6011,
12905
+ "name": "InvalidInitialMintSharePrice",
12906
+ "msg": "Initial mint share price must be greater than zero"
13004
12907
  },
13005
12908
  {
13006
- "code": 14015,
13007
- "name": "RoundingImpact",
13008
- "msg": "Rounding impacts the protocol"
12909
+ "code": 6012,
12910
+ "name": "MaxApyExceeded",
12911
+ "msg": "Oracle NAV update exceeds the vault's maximum acceptable APY"
13009
12912
  },
13010
12913
  {
13011
- "code": 14016,
13012
- "name": "BankIsHalted",
13013
- "msg": "Bank is halted"
12914
+ "code": 6013,
12915
+ "name": "InvalidApyConfig",
12916
+ "msg": "Invalid APY configuration"
13014
12917
  },
13015
12918
  {
13016
- "code": 14017,
13017
- "name": "VaultIsHalted",
13018
- "msg": "Vault is halted"
12919
+ "code": 6014,
12920
+ "name": "InvalidFeeConfig",
12921
+ "msg": "Invalid fee configuration"
13019
12922
  },
13020
12923
  {
13021
- "code": 14018,
13022
- "name": "ConversionOverflow",
13023
- "msg": "Conversion Overflow"
12924
+ "code": 6015,
12925
+ "name": "VaultHasLiveAssets",
12926
+ "msg": "Vault has live supply, TVL, or holdings"
13024
12927
  },
13025
12928
  {
13026
- "code": 14019,
13027
- "name": "_Reserved8019",
13028
- "msg": "Reserved"
12929
+ "code": 6016,
12930
+ "name": "DepositMintsZeroShares",
12931
+ "msg": "Deposit would mint zero shares"
13029
12932
  },
13030
12933
  {
13031
- "code": 14020,
13032
- "name": "InvalidArgument",
13033
- "msg": "Invalid argument"
12934
+ "code": 6017,
12935
+ "name": "InsufficientAccruedApyBalance",
12936
+ "msg": "Insufficient accrued APY balance"
13034
12937
  },
13035
12938
  {
13036
- "code": 14021,
13037
- "name": "UserSanityCheck",
13038
- "msg": "User Sanity Check"
12939
+ "code": 6018,
12940
+ "name": "InvalidRole",
12941
+ "msg": "Invalid role configuration"
13039
12942
  },
13040
12943
  {
13041
- "code": 14022,
13042
- "name": "MathOverflow",
13043
- "msg": "Math overflow"
12944
+ "code": 6019,
12945
+ "name": "InvalidProtocolInteraction",
12946
+ "msg": "Invalid protocol interaction CPI"
13044
12947
  },
13045
12948
  {
13046
- "code": 14023,
13047
- "name": "InvalidMarginFiAccount",
13048
- "msg": "Invalid MarginFi account - must be correct PDA for this vault"
12949
+ "code": 6020,
12950
+ "name": "_Reserved7020",
12951
+ "msg": "Reserved"
13049
12952
  },
13050
12953
  {
13051
- "code": 14024,
13052
- "name": "InvalidStartMarker",
13053
- "msg": "Invalid start marker"
12954
+ "code": 6021,
12955
+ "name": "InvalidExternalLiquidity",
12956
+ "msg": "Invalid external liquidity configuration"
13054
12957
  },
13055
12958
  {
13056
- "code": 14025,
13057
- "name": "OracleUpdateOnEmptyReserve",
13058
- "msg": "Unable to push oracle update on an empty vault reserve"
12959
+ "code": 6022,
12960
+ "name": "SwapBalanceUnchanged",
12961
+ "msg": "Swap did not change both source and destination balances"
13059
12962
  },
13060
12963
  {
13061
- "code": 14026,
13062
- "name": "InvalidRemainingAccountsLength",
13063
- "msg": "Invalid remaining accounts length"
12964
+ "code": 6023,
12965
+ "name": "ProtocolBalanceUnchanged",
12966
+ "msg": "Protocol interaction did not change the affected token balance"
13064
12967
  },
13065
12968
  {
13066
- "code": 14027,
13067
- "name": "WithdrawalExceedsBalance",
13068
- "msg": "Specified withdrawal exceeds available balance"
12969
+ "code": 6024,
12970
+ "name": "ExcessiveSwapSlippage",
12971
+ "msg": "Swap TVL loss exceeds the allowed slippage"
13069
12972
  },
13070
12973
  {
13071
- "code": 14028,
13072
- "name": "InsufficientPendingYield",
13073
- "msg": "Insufficient pending yield"
12974
+ "code": 6025,
12975
+ "name": "TranchingNotEnabled",
12976
+ "msg": "Vault tranching is not enabled"
13074
12977
  },
13075
12978
  {
13076
- "code": 14029,
13077
- "name": "NotSupported",
13078
- "msg": "Not supported"
12979
+ "code": 6026,
12980
+ "name": "TranchingAlreadyEnabled",
12981
+ "msg": "Vault tranching is already enabled"
13079
12982
  },
13080
12983
  {
13081
- "code": 14030,
13082
- "name": "ExceedsMaxYieldingTvl",
13083
- "msg": "Exceeds maximum yielding TVL"
12984
+ "code": 6027,
12985
+ "name": "TrancheStateRequired",
12986
+ "msg": "Tranche state account is required"
13084
12987
  },
13085
12988
  {
13086
- "code": 14031,
13087
- "name": "TranchingNotEnabled",
13088
- "msg": "Tranching is not enabled for this bank"
12989
+ "code": 6028,
12990
+ "name": "InvalidTrancheConfig",
12991
+ "msg": "Invalid tranche configuration"
13089
12992
  },
13090
12993
  {
13091
- "code": 14032,
13092
- "name": "InvalidLeverageFactor",
13093
- "msg": "Invalid leverage factor - must be at least 10000 (1x)"
12994
+ "code": 6029,
12995
+ "name": "InvalidTrancheMint",
12996
+ "msg": "Invalid tranche mint"
13094
12997
  },
13095
12998
  {
13096
- "code": 14033,
13097
- "name": "InsufficientStakedAmount",
13098
- "msg": "Insufficient staked amount"
12999
+ "code": 6030,
13000
+ "name": "LossesDisabled",
13001
+ "msg": "Vault losses are not enabled"
13099
13002
  },
13100
13003
  {
13101
- "code": 14034,
13102
- "name": "JuniorTrancheEmpty",
13103
- "msg": "Junior tranche has no value"
13004
+ "code": 6031,
13005
+ "name": "WithdrawalQueueNotExpired",
13006
+ "msg": "Withdrawal queue is not yet expired"
13104
13007
  },
13105
13008
  {
13106
- "code": 14035,
13107
- "name": "InvalidTrancheConfig",
13108
- "msg": "Invalid tranche config parameter"
13009
+ "code": 6032,
13010
+ "name": "InvalidWithdrawalQueue",
13011
+ "msg": "Invalid withdrawal queue"
13109
13012
  },
13110
13013
  {
13111
- "code": 14036,
13112
- "name": "WithdrawalQueueNotExpired",
13113
- "msg": "Withdrawal queue lockup period has not expired"
13014
+ "code": 6033,
13015
+ "name": "AssetPriceNotSet",
13016
+ "msg": "Destination asset has no price set; a consensus oracle price is required before swapping"
13114
13017
  },
13115
13018
  {
13116
- "code": 14037,
13117
- "name": "InvalidWithdrawalQueue",
13118
- "msg": "Withdrawal queue entry is not in a valid state"
13019
+ "code": 6034,
13020
+ "name": "AssetHoldingNotEmpty",
13021
+ "msg": "Asset holding still has a balance and cannot be removed"
13119
13022
  },
13120
13023
  {
13121
- "code": 14038,
13122
- "name": "InvalidAccount",
13123
- "msg": "Account does not belong to the expected parent"
13024
+ "code": 6035,
13025
+ "name": "CannotRemoveBaseHolding",
13026
+ "msg": "The base asset holding cannot be removed"
13124
13027
  },
13125
13028
  {
13126
- "code": 14039,
13127
- "name": "MissingAccount",
13128
- "msg": "Required optional account is missing"
13029
+ "code": 6036,
13030
+ "name": "UnauthorizedPriceUpdater",
13031
+ "msg": "Caller is not authorized to trigger an asset price update"
13129
13032
  },
13130
13033
  {
13131
- "code": 14040,
13132
- "name": "TrancheWipedOut",
13133
- "msg": "Junior tranche is wiped out and cannot accept new stakes"
13034
+ "code": 6037,
13035
+ "name": "InvalidStalenessConfig",
13036
+ "msg": "Invalid asset-price staleness threshold"
13134
13037
  },
13135
13038
  {
13136
- "code": 14041,
13137
- "name": "VaultLossNotAccepted",
13138
- "msg": "Vault does not accept losses \u2014 enable losses_accepted before retrying"
13039
+ "code": 6038,
13040
+ "name": "AssetRebalanceRateLimitExceeded",
13041
+ "msg": "Asset was rebalanced too recently"
13139
13042
  },
13140
13043
  {
13141
- "code": 14042,
13142
- "name": "CapitalLossExceedsReserve",
13143
- "msg": "Capital loss exceeds available yielding reserve"
13044
+ "code": 6039,
13045
+ "name": "InvalidShareTokenProgram",
13046
+ "msg": "Share token program does not match the vault/tranche mint configuration"
13144
13047
  },
13145
13048
  {
13146
- "code": 14043,
13147
- "name": "RollingWithdrawalLimitExceeded",
13148
- "msg": "Rolling withdrawal limit exceeded"
13049
+ "code": 6040,
13050
+ "name": "UnauthorizedVaultCreator",
13051
+ "msg": "Caller is not on the vault-creator whitelist"
13149
13052
  },
13150
13053
  {
13151
- "code": 14044,
13152
- "name": "VaultAlreadyMigrated",
13153
- "msg": "Legacy vault has already been migrated"
13054
+ "code": 6041,
13055
+ "name": "InvalidShareMintDecimals",
13056
+ "msg": "Share mint decimals must match the vault accounting decimals"
13154
13057
  },
13155
13058
  {
13156
- "code": 14045,
13157
- "name": "InvalidMigrationState",
13158
- "msg": "Legacy vault migration is incomplete or invalid"
13059
+ "code": 6042,
13060
+ "name": "InvalidFeeExemption",
13061
+ "msg": "Invalid fee-exemption PDA signer or seeds"
13159
13062
  },
13160
13063
  {
13161
- "code": 14046,
13162
- "name": "InvalidMigrationMintAuthority",
13163
- "msg": "Mint authority does not match the expected migration source"
13064
+ "code": 6043,
13065
+ "name": "ExceedsJuniorDepositCap",
13066
+ "msg": "Deposit would exceed the junior tranche deposit cap"
13164
13067
  },
13165
13068
  {
13166
- "code": 14047,
13167
- "name": "BankMigrationIncomplete",
13168
- "msg": "Legacy bank or tranche migration is incomplete \u2014 source accounting and escrow must be fully drained before mint authority transfer"
13069
+ "code": 6044,
13070
+ "name": "InvalidShareSupply",
13071
+ "msg": "Physical share-mint supply does not match effective supply accounting"
13169
13072
  }
13170
13073
  ],
13171
13074
  "types": [
@@ -13546,9 +13449,7 @@ var IDL = {
13546
13449
  "Holdings are addressed by their slot index (1 byte) to keep instruction data",
13547
13450
  "small. To register a brand-new consensus holding, set `mint` to its mint",
13548
13451
  "(and pass the matching `asset_mint` account); the created slot's index is used",
13549
- "and `holding_index` is ignored. For existing holdings leave `mint` as `None`.",
13550
- "The price is authoritative only for ConsensusOracle holdings. Pyth and nested-vault",
13551
- "holdings use the report only for external_amount and retain their live-oracle price."
13452
+ "and `holding_index` is ignored. For existing holdings leave `mint` as `None`."
13552
13453
  ],
13553
13454
  "type": {
13554
13455
  "kind": "struct",
@@ -15293,7 +15194,8 @@ var IDL = {
15293
15194
  {
15294
15195
  "name": "losses_enabled",
15295
15196
  "docs": [
15296
- "Allows consensus-oracle NAV losses beyond the protocol's small-loss tolerance. Losses inside that tolerance settle without this flag."
15197
+ "Allows consensus-oracle NAV losses beyond the protocol's small-loss",
15198
+ "tolerance. Losses inside that tolerance settle without this flag."
15297
15199
  ],
15298
15200
  "type": {
15299
15201
  "defined": {
@@ -18466,10 +18368,13 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
18466
18368
  vault: txArgs.vault,
18467
18369
  shareMint,
18468
18370
  feeCollector,
18371
+ // The vault fee collector is a role that is routinely a Squads vault
18372
+ // (off-curve PDA), so allow an off-curve owner here too.
18469
18373
  feeCollectorShareAta: (0, import_common18.getAtaAddress)(
18470
18374
  shareMint,
18471
18375
  feeCollector,
18472
- shareTokenProgram
18376
+ shareTokenProgram,
18377
+ true
18473
18378
  ),
18474
18379
  protocolFeeCollector,
18475
18380
  // The protocol fee recipient is a hardcoded protocol-controlled address
@@ -19195,8 +19100,11 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
19195
19100
 
19196
19101
  // src/client/builders/executeWithdraw.ts
19197
19102
  var import_core10 = require("@anchor-lang/core");
19198
- var import_kit7 = require("@solana/kit");
19199
19103
  var import_spl_token11 = require("@solana/spl-token");
19104
+ var import_common28 = __toESM(require_dist());
19105
+
19106
+ // src/client/builders/externalLiquidity.ts
19107
+ var import_kit7 = require("@solana/kit");
19200
19108
  var import_web312 = require("@solana/web3.js");
19201
19109
  var import_common27 = __toESM(require_dist());
19202
19110
  var import_marginfi = __toESM(require_dist2());
@@ -19215,22 +19123,71 @@ function toWeb3AccountMeta(account) {
19215
19123
  isSigner: account.role === import_kit7.AccountRole.READONLY_SIGNER || account.role === import_kit7.AccountRole.WRITABLE_SIGNER
19216
19124
  };
19217
19125
  }
19126
+ function resolveExternalWithdraw({
19127
+ externalLiquidity,
19128
+ vault,
19129
+ assetMint,
19130
+ vaultAssetAta,
19131
+ overrides
19132
+ }) {
19133
+ const externalWithdrawIxRefs = overrides?.externalWithdrawIxRefs ?? null;
19134
+ const externalLiquiditySource = overrides?.externalLiquiditySource ?? null;
19135
+ const externalWithdrawAccounts = overrides?.externalWithdrawAccounts ?? [];
19136
+ if (externalWithdrawIxRefs != null || externalLiquiditySource != null || overrides?.skipExternalLiquidity) {
19137
+ return {
19138
+ externalWithdrawIxRefs,
19139
+ externalLiquiditySource,
19140
+ externalWithdrawAccounts
19141
+ };
19142
+ }
19143
+ const slot0 = parseMarginfiSlot(externalLiquidity[0]);
19144
+ if (!slot0) {
19145
+ return {
19146
+ externalWithdrawIxRefs: null,
19147
+ externalLiquiditySource: null,
19148
+ externalWithdrawAccounts
19149
+ };
19150
+ }
19151
+ const marginfiAccounts = (0, import_marginfi.marginfiAccountsForMint)(assetMint);
19152
+ if (!marginfiAccounts) {
19153
+ return {
19154
+ externalWithdrawIxRefs: null,
19155
+ externalLiquiditySource: null,
19156
+ externalWithdrawAccounts
19157
+ };
19158
+ }
19159
+ const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
19160
+ const withdrawRefs = (0, import_common27.createCpiRefs)([
19161
+ marginfiClient.withdraw_cpi({
19162
+ marginfiAccount: slot0.userAccount,
19163
+ authority: vault,
19164
+ destinationTokenAccount: vaultAssetAta
19165
+ })
19166
+ ]);
19167
+ return {
19168
+ externalWithdrawIxRefs: withdrawRefs.refs,
19169
+ externalLiquiditySource: 0,
19170
+ externalWithdrawAccounts: withdrawRefs.accounts
19171
+ };
19172
+ }
19173
+
19174
+ // src/client/builders/executeWithdraw.ts
19218
19175
  var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
19219
19176
  getIxAccounts(args) {
19220
19177
  return {
19221
- user: (0, import_common27.toWeb3Pk)(args.user),
19222
- vault: (0, import_common27.toWeb3Pk)(args.vault),
19223
- vaultOracle: (0, import_common27.toWeb3Pk)(args.vaultOracle),
19224
- vaultTrancheState: args.vaultTrancheState ? (0, import_common27.toWeb3Pk)(args.vaultTrancheState) : null,
19225
- assetMint: (0, import_common27.toWeb3Pk)(args.assetMint),
19226
- shareMint: (0, import_common27.toWeb3Pk)(args.shareMint),
19227
- userAssetAta: (0, import_common27.toWeb3Pk)(args.userAssetAta),
19228
- vaultAssetAta: (0, import_common27.toWeb3Pk)(args.vaultAssetAta),
19229
- feeVault: (0, import_common27.toWeb3Pk)(args.feeVault),
19230
- feeVaultAta: (0, import_common27.toWeb3Pk)(args.feeVaultAta),
19231
- userShareAta: (0, import_common27.toWeb3Pk)(args.userShareAta),
19232
- assetTokenProgram: (0, import_common27.toWeb3Pk)(args.assetTokenProgram),
19233
- shareTokenProgram: (0, import_common27.toWeb3Pk)(args.shareTokenProgram)
19178
+ user: (0, import_common28.toWeb3Pk)(args.user),
19179
+ vault: (0, import_common28.toWeb3Pk)(args.vault),
19180
+ vaultOracle: (0, import_common28.toWeb3Pk)(args.vaultOracle),
19181
+ vaultTrancheState: args.vaultTrancheState ? (0, import_common28.toWeb3Pk)(args.vaultTrancheState) : null,
19182
+ assetMint: (0, import_common28.toWeb3Pk)(args.assetMint),
19183
+ shareMint: (0, import_common28.toWeb3Pk)(args.shareMint),
19184
+ userAssetAta: (0, import_common28.toWeb3Pk)(args.userAssetAta),
19185
+ vaultAssetAta: (0, import_common28.toWeb3Pk)(args.vaultAssetAta),
19186
+ feeVault: (0, import_common28.toWeb3Pk)(args.feeVault),
19187
+ feeVaultAta: (0, import_common28.toWeb3Pk)(args.feeVaultAta),
19188
+ userShareAta: (0, import_common28.toWeb3Pk)(args.userShareAta),
19189
+ assetTokenProgram: (0, import_common28.toWeb3Pk)(args.assetTokenProgram),
19190
+ shareTokenProgram: (0, import_common28.toWeb3Pk)(args.shareTokenProgram)
19234
19191
  };
19235
19192
  }
19236
19193
  getIxData(args) {
@@ -19260,7 +19217,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
19260
19217
  ) : this.program.methods.executeWithdraw(data.shareAmount);
19261
19218
  return methods.accountsPartial(
19262
19219
  this.getIxAccounts(args)
19263
- ).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common27.toKitInstruction);
19220
+ ).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common28.toKitInstruction);
19264
19221
  }
19265
19222
  async deriveIxArgs(txArgs) {
19266
19223
  const connection = this.program.provider.connection;
@@ -19294,36 +19251,23 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
19294
19251
  ),
19295
19252
  this.account.fetchVault(txArgs.vault)
19296
19253
  ]);
19297
- const vaultAssetAta = (0, import_common27.getAtaAddress)(
19254
+ const vaultAssetAta = (0, import_common28.getAtaAddress)(
19298
19255
  txArgs.assetMint,
19299
19256
  txArgs.vault,
19300
19257
  assetTokenProgram,
19301
19258
  true
19302
19259
  );
19303
- let externalWithdrawIxRefs = txArgs.externalWithdrawIxRefs ?? null;
19304
- let externalLiquiditySource = txArgs.externalLiquiditySource ?? null;
19305
- let externalWithdrawAccounts = txArgs.externalWithdrawAccounts ?? [];
19306
- if (externalWithdrawIxRefs == null && externalLiquiditySource == null && !txArgs.skipExternalLiquidity) {
19307
- const slot0 = parseMarginfiSlot(vaultData.externalLiquidity[0]);
19308
- if (slot0) {
19309
- const marginfiAccounts = (0, import_marginfi.marginfiAccountsForMint)(txArgs.assetMint);
19310
- if (marginfiAccounts) {
19311
- const marginfiClient = new import_marginfi.CpiClient({
19312
- accounts: marginfiAccounts
19313
- });
19314
- const withdrawRefs = (0, import_common27.createCpiRefs)([
19315
- marginfiClient.withdraw_cpi({
19316
- marginfiAccount: slot0.userAccount,
19317
- authority: txArgs.vault,
19318
- destinationTokenAccount: vaultAssetAta
19319
- })
19320
- ]);
19321
- externalWithdrawIxRefs = withdrawRefs.refs;
19322
- externalLiquiditySource = 0;
19323
- externalWithdrawAccounts = withdrawRefs.accounts;
19324
- }
19325
- }
19326
- }
19260
+ const {
19261
+ externalWithdrawIxRefs,
19262
+ externalLiquiditySource,
19263
+ externalWithdrawAccounts
19264
+ } = resolveExternalWithdraw({
19265
+ externalLiquidity: vaultData.externalLiquidity,
19266
+ vault: txArgs.vault,
19267
+ assetMint: txArgs.assetMint,
19268
+ vaultAssetAta,
19269
+ overrides: txArgs
19270
+ });
19327
19271
  return {
19328
19272
  user: txArgs.user,
19329
19273
  vault: txArgs.vault,
@@ -19334,16 +19278,16 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
19334
19278
  shareAmount: new import_core10.BN(txArgs.shareAmount.toString()),
19335
19279
  assetTokenProgram,
19336
19280
  shareTokenProgram,
19337
- userAssetAta: txArgs.userAssetAta ?? (0, import_common27.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
19281
+ userAssetAta: txArgs.userAssetAta ?? (0, import_common28.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
19338
19282
  vaultAssetAta,
19339
19283
  feeVault,
19340
- feeVaultAta: (0, import_common27.getAtaAddress)(
19284
+ feeVaultAta: (0, import_common28.getAtaAddress)(
19341
19285
  txArgs.assetMint,
19342
19286
  feeVault,
19343
19287
  assetTokenProgram,
19344
19288
  true
19345
19289
  ),
19346
- userShareAta: txArgs.userShareAta ?? (0, import_common27.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram),
19290
+ userShareAta: txArgs.userShareAta ?? (0, import_common28.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram),
19347
19291
  externalWithdrawIxRefs,
19348
19292
  externalLiquiditySource,
19349
19293
  externalWithdrawAccounts,
@@ -19354,31 +19298,31 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
19354
19298
  return txArgs.lookupTables;
19355
19299
  }
19356
19300
  async buildPreambleInstructions(args) {
19357
- const defaultUserAssetAta = (0, import_common27.getAtaAddress)(
19301
+ const defaultUserAssetAta = (0, import_common28.getAtaAddress)(
19358
19302
  args.assetMint,
19359
19303
  args.user,
19360
19304
  args.assetTokenProgram
19361
19305
  );
19362
- const payer = (0, import_common27.toWeb3Pk)(args.user);
19363
- const createUserAssetAta = (0, import_common27.toWeb3Pk)(args.userAssetAta).equals(
19364
- (0, import_common27.toWeb3Pk)(defaultUserAssetAta)
19306
+ const payer = (0, import_common28.toWeb3Pk)(args.user);
19307
+ const createUserAssetAta = (0, import_common28.toWeb3Pk)(args.userAssetAta).equals(
19308
+ (0, import_common28.toWeb3Pk)(defaultUserAssetAta)
19365
19309
  ) ? (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
19366
19310
  payer,
19367
- (0, import_common27.toWeb3Pk)(args.userAssetAta),
19311
+ (0, import_common28.toWeb3Pk)(args.userAssetAta),
19368
19312
  payer,
19369
- (0, import_common27.toWeb3Pk)(args.assetMint),
19370
- (0, import_common27.toWeb3Pk)(args.assetTokenProgram),
19313
+ (0, import_common28.toWeb3Pk)(args.assetMint),
19314
+ (0, import_common28.toWeb3Pk)(args.assetTokenProgram),
19371
19315
  import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
19372
19316
  ) : null;
19373
19317
  const createFeeVaultAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
19374
19318
  payer,
19375
- (0, import_common27.toWeb3Pk)(args.feeVaultAta),
19376
- (0, import_common27.toWeb3Pk)(args.feeVault),
19377
- (0, import_common27.toWeb3Pk)(args.assetMint),
19378
- (0, import_common27.toWeb3Pk)(args.assetTokenProgram),
19319
+ (0, import_common28.toWeb3Pk)(args.feeVaultAta),
19320
+ (0, import_common28.toWeb3Pk)(args.feeVault),
19321
+ (0, import_common28.toWeb3Pk)(args.assetMint),
19322
+ (0, import_common28.toWeb3Pk)(args.assetTokenProgram),
19379
19323
  import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
19380
19324
  );
19381
- return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common27.toKitInstruction);
19325
+ return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common28.toKitInstruction);
19382
19326
  }
19383
19327
  async buildPlanExtras(args) {
19384
19328
  return {
@@ -19390,33 +19334,38 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
19390
19334
  // src/client/builders/fulfillJuniorTrancheWithdraw.ts
19391
19335
  var import_spl_token12 = require("@solana/spl-token");
19392
19336
  var import_web313 = require("@solana/web3.js");
19393
- var import_common28 = __toESM(require_dist());
19337
+ var import_common29 = __toESM(require_dist());
19394
19338
  var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19395
19339
  async getIx(args) {
19340
+ const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
19341
+ const externalLiquiditySource = args.externalLiquiditySource ?? null;
19396
19342
  const methods = args.addressSeeds ? this.program.methods.fulfillJuniorTrancheWithdrawFeeExempt(
19343
+ externalWithdrawIxRefs,
19344
+ externalLiquiditySource,
19397
19345
  args.addressSeeds.map((seed) => Buffer.from(seed))
19398
- ) : this.program.methods.fulfillJuniorTrancheWithdraw();
19346
+ ) : this.program.methods.fulfillJuniorTrancheWithdraw(
19347
+ externalWithdrawIxRefs,
19348
+ externalLiquiditySource
19349
+ );
19399
19350
  return methods.accountsPartial({
19400
- signer: (0, import_common28.toWeb3Pk)(args.signer),
19401
- owner: (0, import_common28.toWeb3Pk)(args.owner),
19402
- queuePayer: (0, import_common28.toWeb3Pk)(args.queuePayer),
19403
- vault: (0, import_common28.toWeb3Pk)(args.vault),
19404
- vaultOracle: (0, import_common28.toWeb3Pk)(args.vaultOracle),
19405
- vaultTrancheState: (0, import_common28.toWeb3Pk)(args.vaultTrancheState),
19406
- withdrawalQueue: (0, import_common28.toWeb3Pk)(args.withdrawalQueue),
19407
- outputMint: (0, import_common28.toWeb3Pk)(args.outputMint),
19408
- inputMint: (0, import_common28.toWeb3Pk)(args.inputMint),
19409
- ownerInputAta: (0, import_common28.toWeb3Pk)(args.ownerInputAta),
19410
- ownerOutputAta: (0, import_common28.toWeb3Pk)(args.ownerOutputAta),
19411
- vaultOutputAta: (0, import_common28.toWeb3Pk)(args.vaultOutputAta),
19412
- feeCollector: (0, import_common28.toWeb3Pk)(args.feeCollector),
19413
- feeCollectorOutputAta: (0, import_common28.toWeb3Pk)(args.feeCollectorOutputAta),
19414
- queueInputAta: (0, import_common28.toWeb3Pk)(args.queueInputAta),
19415
- assetTokenProgram: (0, import_common28.toWeb3Pk)(args.assetTokenProgram),
19416
- shareTokenProgram: (0, import_common28.toWeb3Pk)(args.shareTokenProgram),
19351
+ signer: (0, import_common29.toWeb3Pk)(args.signer),
19352
+ owner: (0, import_common29.toWeb3Pk)(args.owner),
19353
+ queuePayer: (0, import_common29.toWeb3Pk)(args.queuePayer),
19354
+ vault: (0, import_common29.toWeb3Pk)(args.vault),
19355
+ vaultOracle: (0, import_common29.toWeb3Pk)(args.vaultOracle),
19356
+ vaultTrancheState: (0, import_common29.toWeb3Pk)(args.vaultTrancheState),
19357
+ withdrawalQueue: (0, import_common29.toWeb3Pk)(args.withdrawalQueue),
19358
+ outputMint: (0, import_common29.toWeb3Pk)(args.outputMint),
19359
+ inputMint: (0, import_common29.toWeb3Pk)(args.inputMint),
19360
+ ownerInputAta: (0, import_common29.toWeb3Pk)(args.ownerInputAta),
19361
+ ownerOutputAta: (0, import_common29.toWeb3Pk)(args.ownerOutputAta),
19362
+ vaultOutputAta: (0, import_common29.toWeb3Pk)(args.vaultOutputAta),
19363
+ queueInputAta: (0, import_common29.toWeb3Pk)(args.queueInputAta),
19364
+ assetTokenProgram: (0, import_common29.toWeb3Pk)(args.assetTokenProgram),
19365
+ shareTokenProgram: (0, import_common29.toWeb3Pk)(args.shareTokenProgram),
19417
19366
  associatedTokenProgram: import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID,
19418
19367
  systemProgram: import_web313.SystemProgram.programId
19419
- }).instruction().then(import_common28.toKitInstruction);
19368
+ }).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common29.toKitInstruction);
19420
19369
  }
19421
19370
  async deriveIxArgs(txArgs) {
19422
19371
  const connection = this.program.provider.connection;
@@ -19426,9 +19375,9 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19426
19375
  [vaultOracle],
19427
19376
  [vaultTrancheState],
19428
19377
  [withdrawalQueue],
19429
- feeCollector,
19430
19378
  assetTokenProgram,
19431
- juniorShare
19379
+ juniorShare,
19380
+ vaultData
19432
19381
  ] = await Promise.all([
19433
19382
  this.pda.deriveVaultOraclePda(txArgs.vault),
19434
19383
  this.pda.deriveVaultTrancheStatePda(txArgs.vault),
@@ -19437,7 +19386,6 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19437
19386
  txArgs.owner,
19438
19387
  txArgs.queueId
19439
19388
  ),
19440
- resolveVaultFeeCollector(this.account, txArgs.vault, txArgs.feeCollector),
19441
19389
  resolveHoldingTokenProgram(
19442
19390
  this.account,
19443
19391
  connection,
@@ -19453,10 +19401,28 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19453
19401
  mint: txArgs.juniorShareMint,
19454
19402
  tokenProgram: txArgs.shareTokenProgram
19455
19403
  }
19456
- )
19404
+ ),
19405
+ this.account.fetchVault(txArgs.vault)
19457
19406
  ]);
19458
19407
  const { mint: juniorShareMint, tokenProgram: shareTokenProgram } = juniorShare;
19459
19408
  const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
19409
+ const vaultOutputAta = (0, import_common29.getAtaAddress)(
19410
+ txArgs.assetMint,
19411
+ txArgs.vault,
19412
+ assetTokenProgram,
19413
+ true
19414
+ );
19415
+ const {
19416
+ externalWithdrawIxRefs,
19417
+ externalLiquiditySource,
19418
+ externalWithdrawAccounts
19419
+ } = resolveExternalWithdraw({
19420
+ externalLiquidity: vaultData.externalLiquidity,
19421
+ vault: txArgs.vault,
19422
+ assetMint: txArgs.assetMint,
19423
+ vaultAssetAta: vaultOutputAta,
19424
+ overrides: txArgs
19425
+ });
19460
19426
  return {
19461
19427
  signer,
19462
19428
  owner: txArgs.owner,
@@ -19469,50 +19435,45 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19469
19435
  inputMint: juniorShareMint,
19470
19436
  assetTokenProgram,
19471
19437
  shareTokenProgram,
19472
- ownerInputAta: txArgs.ownerInputAta ?? (0, import_common28.getAtaAddress)(juniorShareMint, txArgs.owner, shareTokenProgram),
19473
- ownerOutputAta: (0, import_common28.getAtaAddress)(
19438
+ ownerInputAta: txArgs.ownerInputAta ?? (0, import_common29.getAtaAddress)(juniorShareMint, txArgs.owner, shareTokenProgram),
19439
+ ownerOutputAta: (0, import_common29.getAtaAddress)(
19474
19440
  txArgs.assetMint,
19475
19441
  txArgs.owner,
19476
19442
  assetTokenProgram
19477
19443
  ),
19478
- vaultOutputAta: (0, import_common28.getAtaAddress)(
19479
- txArgs.assetMint,
19480
- txArgs.vault,
19481
- assetTokenProgram,
19482
- true
19483
- ),
19484
- feeCollector,
19485
- feeCollectorOutputAta: (0, import_common28.getAtaAddress)(
19486
- txArgs.assetMint,
19487
- feeCollector,
19488
- assetTokenProgram
19489
- ),
19490
- queueInputAta: (0, import_common28.getAtaAddress)(
19444
+ vaultOutputAta,
19445
+ queueInputAta: (0, import_common29.getAtaAddress)(
19491
19446
  juniorShareMint,
19492
19447
  queuePda,
19493
19448
  shareTokenProgram,
19494
19449
  true
19495
19450
  ),
19451
+ externalWithdrawIxRefs,
19452
+ externalLiquiditySource,
19453
+ externalWithdrawAccounts,
19496
19454
  addressSeeds: txArgs.addressSeeds
19497
19455
  };
19498
19456
  }
19457
+ async buildLookupTables(_args, txArgs) {
19458
+ return txArgs.lookupTables;
19459
+ }
19499
19460
  async buildPreambleInstructions(args) {
19500
- const defaultOwnerInputAta = (0, import_common28.getAtaAddress)(
19461
+ const defaultOwnerInputAta = (0, import_common29.getAtaAddress)(
19501
19462
  args.inputMint,
19502
19463
  args.owner,
19503
19464
  args.shareTokenProgram
19504
19465
  );
19505
- if (!(0, import_common28.toWeb3Pk)(args.ownerInputAta).equals((0, import_common28.toWeb3Pk)(defaultOwnerInputAta))) {
19466
+ if (!(0, import_common29.toWeb3Pk)(args.ownerInputAta).equals((0, import_common29.toWeb3Pk)(defaultOwnerInputAta))) {
19506
19467
  return [];
19507
19468
  }
19508
19469
  return [
19509
- (0, import_common28.toKitInstruction)(
19470
+ (0, import_common29.toKitInstruction)(
19510
19471
  (0, import_spl_token12.createAssociatedTokenAccountIdempotentInstruction)(
19511
- (0, import_common28.toWeb3Pk)(args.signer),
19512
- (0, import_common28.toWeb3Pk)(args.ownerInputAta),
19513
- (0, import_common28.toWeb3Pk)(args.owner),
19514
- (0, import_common28.toWeb3Pk)(args.inputMint),
19515
- (0, import_common28.toWeb3Pk)(args.shareTokenProgram),
19472
+ (0, import_common29.toWeb3Pk)(args.signer),
19473
+ (0, import_common29.toWeb3Pk)(args.ownerInputAta),
19474
+ (0, import_common29.toWeb3Pk)(args.owner),
19475
+ (0, import_common29.toWeb3Pk)(args.inputMint),
19476
+ (0, import_common29.toWeb3Pk)(args.shareTokenProgram),
19516
19477
  import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID
19517
19478
  )
19518
19479
  )
@@ -19533,7 +19494,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19533
19494
 
19534
19495
  // src/client/builders/updateTrancheConfig.ts
19535
19496
  var import_core11 = require("@anchor-lang/core");
19536
- var import_common29 = __toESM(require_dist());
19497
+ var import_common30 = __toESM(require_dist());
19537
19498
  var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
19538
19499
  async getIx(args) {
19539
19500
  return this.program.methods.vaultUpdateTrancheConfig({
@@ -19543,11 +19504,11 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
19543
19504
  targetLockupDurationSecs: args.targetLockupDurationSecs,
19544
19505
  juniorDepositCap: args.juniorDepositCap
19545
19506
  }).accountsPartial({
19546
- curator: (0, import_common29.toWeb3Pk)(args.curator),
19547
- vault: (0, import_common29.toWeb3Pk)(args.vault),
19548
- vaultTrancheState: (0, import_common29.toWeb3Pk)(args.vaultTrancheState),
19549
- vaultOracle: (0, import_common29.toWeb3Pk)(args.vaultOracle)
19550
- }).instruction().then(import_common29.toKitInstruction);
19507
+ curator: (0, import_common30.toWeb3Pk)(args.curator),
19508
+ vault: (0, import_common30.toWeb3Pk)(args.vault),
19509
+ vaultTrancheState: (0, import_common30.toWeb3Pk)(args.vaultTrancheState),
19510
+ vaultOracle: (0, import_common30.toWeb3Pk)(args.vaultOracle)
19511
+ }).instruction().then(import_common30.toKitInstruction);
19551
19512
  }
19552
19513
  async deriveIxArgs(txArgs) {
19553
19514
  const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
@@ -19579,22 +19540,22 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
19579
19540
  var import_core12 = require("@anchor-lang/core");
19580
19541
  var import_spl_token13 = require("@solana/spl-token");
19581
19542
  var import_web314 = require("@solana/web3.js");
19582
- var import_common30 = __toESM(require_dist());
19543
+ var import_common31 = __toESM(require_dist());
19583
19544
  var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
19584
19545
  async getIx(args) {
19585
19546
  return this.program.methods.managerRedepositAsset({
19586
19547
  depositAmount: args.depositAmount,
19587
19548
  externalAmount: args.externalAmount
19588
19549
  }).accountsPartial({
19589
- manager: (0, import_common30.toWeb3Pk)(args.manager),
19590
- vault: (0, import_common30.toWeb3Pk)(args.vault),
19591
- assetMint: (0, import_common30.toWeb3Pk)(args.assetMint),
19592
- vaultAssetAta: (0, import_common30.toWeb3Pk)(args.vaultAssetAta),
19593
- managerAssetAta: (0, import_common30.toWeb3Pk)(args.managerAssetAta),
19594
- assetTokenProgram: (0, import_common30.toWeb3Pk)(args.assetTokenProgram),
19550
+ manager: (0, import_common31.toWeb3Pk)(args.manager),
19551
+ vault: (0, import_common31.toWeb3Pk)(args.vault),
19552
+ assetMint: (0, import_common31.toWeb3Pk)(args.assetMint),
19553
+ vaultAssetAta: (0, import_common31.toWeb3Pk)(args.vaultAssetAta),
19554
+ managerAssetAta: (0, import_common31.toWeb3Pk)(args.managerAssetAta),
19555
+ assetTokenProgram: (0, import_common31.toWeb3Pk)(args.assetTokenProgram),
19595
19556
  associatedTokenProgram: import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID,
19596
19557
  systemProgram: import_web314.SystemProgram.programId
19597
- }).instruction().then(import_common30.toKitInstruction);
19558
+ }).instruction().then(import_common31.toKitInstruction);
19598
19559
  }
19599
19560
  async deriveIxArgs(txArgs) {
19600
19561
  const connection = this.program.provider.connection;
@@ -19611,13 +19572,13 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
19611
19572
  depositAmount: new import_core12.BN(txArgs.depositAmount.toString()),
19612
19573
  externalAmount: new import_core12.BN(externalAmount.toString()),
19613
19574
  assetTokenProgram,
19614
- vaultAssetAta: (0, import_common30.getAtaAddress)(
19575
+ vaultAssetAta: (0, import_common31.getAtaAddress)(
19615
19576
  txArgs.assetMint,
19616
19577
  txArgs.vault,
19617
19578
  assetTokenProgram,
19618
19579
  true
19619
19580
  ),
19620
- managerAssetAta: (0, import_common30.getAtaAddress)(
19581
+ managerAssetAta: (0, import_common31.getAtaAddress)(
19621
19582
  txArgs.assetMint,
19622
19583
  txArgs.manager,
19623
19584
  assetTokenProgram
@@ -19635,19 +19596,19 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
19635
19596
  var import_core13 = require("@anchor-lang/core");
19636
19597
  var import_spl_token14 = require("@solana/spl-token");
19637
19598
  var import_web315 = require("@solana/web3.js");
19638
- var import_common31 = __toESM(require_dist());
19599
+ var import_common32 = __toESM(require_dist());
19639
19600
  var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
19640
19601
  async getIx(args) {
19641
19602
  return this.program.methods.managerWithdrawAsset(args.amount).accountsPartial({
19642
- manager: (0, import_common31.toWeb3Pk)(args.manager),
19643
- vault: (0, import_common31.toWeb3Pk)(args.vault),
19644
- assetMint: (0, import_common31.toWeb3Pk)(args.assetMint),
19645
- vaultAssetAta: (0, import_common31.toWeb3Pk)(args.vaultAssetAta),
19646
- managerAssetAta: (0, import_common31.toWeb3Pk)(args.managerAssetAta),
19647
- assetTokenProgram: (0, import_common31.toWeb3Pk)(args.assetTokenProgram),
19603
+ manager: (0, import_common32.toWeb3Pk)(args.manager),
19604
+ vault: (0, import_common32.toWeb3Pk)(args.vault),
19605
+ assetMint: (0, import_common32.toWeb3Pk)(args.assetMint),
19606
+ vaultAssetAta: (0, import_common32.toWeb3Pk)(args.vaultAssetAta),
19607
+ managerAssetAta: (0, import_common32.toWeb3Pk)(args.managerAssetAta),
19608
+ assetTokenProgram: (0, import_common32.toWeb3Pk)(args.assetTokenProgram),
19648
19609
  associatedTokenProgram: import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID,
19649
19610
  systemProgram: import_web315.SystemProgram.programId
19650
- }).instruction().then(import_common31.toKitInstruction);
19611
+ }).instruction().then(import_common32.toKitInstruction);
19651
19612
  }
19652
19613
  async deriveIxArgs(txArgs) {
19653
19614
  const connection = this.program.provider.connection;
@@ -19662,13 +19623,13 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
19662
19623
  assetMint: txArgs.assetMint,
19663
19624
  amount: new import_core13.BN(txArgs.amount.toString()),
19664
19625
  assetTokenProgram,
19665
- vaultAssetAta: (0, import_common31.getAtaAddress)(
19626
+ vaultAssetAta: (0, import_common32.getAtaAddress)(
19666
19627
  txArgs.assetMint,
19667
19628
  txArgs.vault,
19668
19629
  assetTokenProgram,
19669
19630
  true
19670
19631
  ),
19671
- managerAssetAta: (0, import_common31.getAtaAddress)(
19632
+ managerAssetAta: (0, import_common32.getAtaAddress)(
19672
19633
  txArgs.assetMint,
19673
19634
  txArgs.manager,
19674
19635
  assetTokenProgram
@@ -19687,7 +19648,7 @@ var import_core14 = require("@anchor-lang/core");
19687
19648
  var import_kit8 = require("@solana/kit");
19688
19649
  var import_spl_token15 = require("@solana/spl-token");
19689
19650
  var import_web316 = require("@solana/web3.js");
19690
- var import_common32 = __toESM(require_dist());
19651
+ var import_common33 = __toESM(require_dist());
19691
19652
  var DEFAULT_PYTH_PRICE_MAX_AGE_SECS = 90n;
19692
19653
  function toAssetPriceOracleConfig(args) {
19693
19654
  return {
@@ -19702,7 +19663,7 @@ function toAssetPriceOracleConfig(args) {
19702
19663
  function toAnchorAssetPriceOracleConfig(config) {
19703
19664
  return {
19704
19665
  ...config,
19705
- priceOracleAccount: (0, import_common32.toWeb3Pk)(config.priceOracleAccount)
19666
+ priceOracleAccount: (0, import_common33.toWeb3Pk)(config.priceOracleAccount)
19706
19667
  };
19707
19668
  }
19708
19669
  function toWeb3AccountMeta2(account) {
@@ -19716,14 +19677,14 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
19716
19677
  async getIx(args) {
19717
19678
  return this.program.methods.protocolInteraction(args.refs, {
19718
19679
  externalLiquidityIndex: args.externalLiquidityIndex,
19719
- affectedAssetMint: args.affectedAssetMint ? (0, import_common32.toWeb3Pk)(args.affectedAssetMint) : null
19680
+ affectedAssetMint: args.affectedAssetMint ? (0, import_common33.toWeb3Pk)(args.affectedAssetMint) : null
19720
19681
  }).accountsPartial({
19721
- hwManager: (0, import_common32.toWeb3Pk)(args.hwManager),
19722
- vault: (0, import_common32.toWeb3Pk)(args.vault),
19723
- affectedAssetMint: args.affectedAssetMint ? (0, import_common32.toWeb3Pk)(args.affectedAssetMint) : null,
19724
- affectedVaultAta: args.affectedVaultAta ? (0, import_common32.toWeb3Pk)(args.affectedVaultAta) : null,
19725
- affectedTokenProgram: args.affectedTokenProgram ? (0, import_common32.toWeb3Pk)(args.affectedTokenProgram) : null
19726
- }).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common32.toKitInstruction);
19682
+ hwManager: (0, import_common33.toWeb3Pk)(args.hwManager),
19683
+ vault: (0, import_common33.toWeb3Pk)(args.vault),
19684
+ affectedAssetMint: args.affectedAssetMint ? (0, import_common33.toWeb3Pk)(args.affectedAssetMint) : null,
19685
+ affectedVaultAta: args.affectedVaultAta ? (0, import_common33.toWeb3Pk)(args.affectedVaultAta) : null,
19686
+ affectedTokenProgram: args.affectedTokenProgram ? (0, import_common33.toWeb3Pk)(args.affectedTokenProgram) : null
19687
+ }).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common33.toKitInstruction);
19727
19688
  }
19728
19689
  async deriveIxArgs(txArgs) {
19729
19690
  const affectedTokenProgram = txArgs.affectedAssetMint ? txArgs.affectedTokenProgram ?? TOKEN_PROGRAM_ID : null;
@@ -19735,7 +19696,7 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
19735
19696
  accounts: txArgs.accounts,
19736
19697
  affectedAssetMint: txArgs.affectedAssetMint ?? null,
19737
19698
  affectedTokenProgram,
19738
- affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0, import_common32.getAtaAddress)(
19699
+ affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0, import_common33.getAtaAddress)(
19739
19700
  txArgs.affectedAssetMint,
19740
19701
  txArgs.vault,
19741
19702
  affectedTokenProgram,
@@ -19754,18 +19715,18 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
19754
19715
  args.destinationPriceOracle
19755
19716
  )
19756
19717
  }).accountsPartial({
19757
- hwManager: (0, import_common32.toWeb3Pk)(args.hwManager),
19758
- vault: (0, import_common32.toWeb3Pk)(args.vault),
19759
- sourceMint: (0, import_common32.toWeb3Pk)(args.sourceMint),
19760
- destinationMint: (0, import_common32.toWeb3Pk)(args.destinationMint),
19761
- vaultSourceAta: (0, import_common32.toWeb3Pk)(args.vaultSourceAta),
19762
- vaultDestinationAta: (0, import_common32.toWeb3Pk)(args.vaultDestinationAta),
19763
- sourceTokenProgram: (0, import_common32.toWeb3Pk)(args.sourceTokenProgram),
19764
- destinationTokenProgram: (0, import_common32.toWeb3Pk)(args.destinationTokenProgram),
19765
- destinationOracleAccount: args.destinationOracleAccount ? (0, import_common32.toWeb3Pk)(args.destinationOracleAccount) : null,
19766
- vaultOracle: (0, import_common32.toWeb3Pk)(args.vaultOracle),
19767
- vaultTrancheState: args.vaultTrancheState ? (0, import_common32.toWeb3Pk)(args.vaultTrancheState) : null
19768
- }).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common32.toKitInstruction);
19718
+ hwManager: (0, import_common33.toWeb3Pk)(args.hwManager),
19719
+ vault: (0, import_common33.toWeb3Pk)(args.vault),
19720
+ sourceMint: (0, import_common33.toWeb3Pk)(args.sourceMint),
19721
+ destinationMint: (0, import_common33.toWeb3Pk)(args.destinationMint),
19722
+ vaultSourceAta: (0, import_common33.toWeb3Pk)(args.vaultSourceAta),
19723
+ vaultDestinationAta: (0, import_common33.toWeb3Pk)(args.vaultDestinationAta),
19724
+ sourceTokenProgram: (0, import_common33.toWeb3Pk)(args.sourceTokenProgram),
19725
+ destinationTokenProgram: (0, import_common33.toWeb3Pk)(args.destinationTokenProgram),
19726
+ destinationOracleAccount: args.destinationOracleAccount ? (0, import_common33.toWeb3Pk)(args.destinationOracleAccount) : null,
19727
+ vaultOracle: (0, import_common33.toWeb3Pk)(args.vaultOracle),
19728
+ vaultTrancheState: args.vaultTrancheState ? (0, import_common33.toWeb3Pk)(args.vaultTrancheState) : null
19729
+ }).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common33.toKitInstruction);
19769
19730
  }
19770
19731
  async deriveIxArgs(txArgs) {
19771
19732
  const sourceTokenProgram = txArgs.sourceTokenProgram ?? TOKEN_PROGRAM_ID;
@@ -19786,13 +19747,13 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
19786
19747
  accounts: txArgs.accounts,
19787
19748
  sourceTokenProgram,
19788
19749
  destinationTokenProgram,
19789
- vaultSourceAta: (0, import_common32.getAtaAddress)(
19750
+ vaultSourceAta: (0, import_common33.getAtaAddress)(
19790
19751
  txArgs.sourceMint,
19791
19752
  txArgs.vault,
19792
19753
  sourceTokenProgram,
19793
19754
  true
19794
19755
  ),
19795
- vaultDestinationAta: (0, import_common32.getAtaAddress)(
19756
+ vaultDestinationAta: (0, import_common33.getAtaAddress)(
19796
19757
  txArgs.destinationMint,
19797
19758
  txArgs.vault,
19798
19759
  destinationTokenProgram,
@@ -19801,24 +19762,24 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
19801
19762
  };
19802
19763
  }
19803
19764
  async buildPreambleInstructions(args) {
19804
- const payer = (0, import_common32.toWeb3Pk)(args.hwManager);
19765
+ const payer = (0, import_common33.toWeb3Pk)(args.hwManager);
19805
19766
  const createSourceAta = (0, import_spl_token15.createAssociatedTokenAccountIdempotentInstruction)(
19806
19767
  payer,
19807
- (0, import_common32.toWeb3Pk)(args.vaultSourceAta),
19808
- (0, import_common32.toWeb3Pk)(args.vault),
19809
- (0, import_common32.toWeb3Pk)(args.sourceMint),
19810
- (0, import_common32.toWeb3Pk)(args.sourceTokenProgram),
19768
+ (0, import_common33.toWeb3Pk)(args.vaultSourceAta),
19769
+ (0, import_common33.toWeb3Pk)(args.vault),
19770
+ (0, import_common33.toWeb3Pk)(args.sourceMint),
19771
+ (0, import_common33.toWeb3Pk)(args.sourceTokenProgram),
19811
19772
  import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID
19812
19773
  );
19813
19774
  const createDestinationAta = (0, import_spl_token15.createAssociatedTokenAccountIdempotentInstruction)(
19814
19775
  payer,
19815
- (0, import_common32.toWeb3Pk)(args.vaultDestinationAta),
19816
- (0, import_common32.toWeb3Pk)(args.vault),
19817
- (0, import_common32.toWeb3Pk)(args.destinationMint),
19818
- (0, import_common32.toWeb3Pk)(args.destinationTokenProgram),
19776
+ (0, import_common33.toWeb3Pk)(args.vaultDestinationAta),
19777
+ (0, import_common33.toWeb3Pk)(args.vault),
19778
+ (0, import_common33.toWeb3Pk)(args.destinationMint),
19779
+ (0, import_common33.toWeb3Pk)(args.destinationTokenProgram),
19819
19780
  import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID
19820
19781
  );
19821
- return [createSourceAta, createDestinationAta].map(import_common32.toKitInstruction);
19782
+ return [createSourceAta, createDestinationAta].map(import_common33.toKitInstruction);
19822
19783
  }
19823
19784
  async buildLookupTables(_args, txArgs) {
19824
19785
  return txArgs.lookupTables;
@@ -19854,24 +19815,24 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
19854
19815
  var import_core15 = require("@anchor-lang/core");
19855
19816
  var import_spl_token16 = require("@solana/spl-token");
19856
19817
  var import_web317 = require("@solana/web3.js");
19857
- var import_common33 = __toESM(require_dist());
19818
+ var import_common34 = __toESM(require_dist());
19858
19819
  var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19859
19820
  async getIx(args) {
19860
19821
  return this.program.methods.requestJuniorTrancheWithdraw(args.queueId, args.shareAmount).accountsPartial({
19861
- user: (0, import_common33.toWeb3Pk)(args.user),
19862
- payer: (0, import_common33.toWeb3Pk)(args.payer),
19863
- vault: (0, import_common33.toWeb3Pk)(args.vault),
19864
- vaultOracle: (0, import_common33.toWeb3Pk)(args.vaultOracle),
19865
- vaultTrancheState: (0, import_common33.toWeb3Pk)(args.vaultTrancheState),
19866
- withdrawalQueue: (0, import_common33.toWeb3Pk)(args.withdrawalQueue),
19867
- outputMint: (0, import_common33.toWeb3Pk)(args.outputMint),
19868
- inputMint: (0, import_common33.toWeb3Pk)(args.inputMint),
19869
- userInputAta: (0, import_common33.toWeb3Pk)(args.userInputAta),
19870
- queueInputAta: (0, import_common33.toWeb3Pk)(args.queueInputAta),
19871
- shareTokenProgram: (0, import_common33.toWeb3Pk)(args.shareTokenProgram),
19822
+ user: (0, import_common34.toWeb3Pk)(args.user),
19823
+ payer: (0, import_common34.toWeb3Pk)(args.payer),
19824
+ vault: (0, import_common34.toWeb3Pk)(args.vault),
19825
+ vaultOracle: (0, import_common34.toWeb3Pk)(args.vaultOracle),
19826
+ vaultTrancheState: (0, import_common34.toWeb3Pk)(args.vaultTrancheState),
19827
+ withdrawalQueue: (0, import_common34.toWeb3Pk)(args.withdrawalQueue),
19828
+ outputMint: (0, import_common34.toWeb3Pk)(args.outputMint),
19829
+ inputMint: (0, import_common34.toWeb3Pk)(args.inputMint),
19830
+ userInputAta: (0, import_common34.toWeb3Pk)(args.userInputAta),
19831
+ queueInputAta: (0, import_common34.toWeb3Pk)(args.queueInputAta),
19832
+ shareTokenProgram: (0, import_common34.toWeb3Pk)(args.shareTokenProgram),
19872
19833
  associatedTokenProgram: import_spl_token16.ASSOCIATED_TOKEN_PROGRAM_ID,
19873
19834
  systemProgram: import_web317.SystemProgram.programId
19874
- }).instruction().then(import_common33.toKitInstruction);
19835
+ }).instruction().then(import_common34.toKitInstruction);
19875
19836
  }
19876
19837
  async deriveIxArgs(txArgs) {
19877
19838
  const payer = txArgs.payer ?? txArgs.user;
@@ -19907,8 +19868,8 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19907
19868
  queueId: txArgs.queueId,
19908
19869
  shareAmount: new import_core15.BN(txArgs.shareAmount.toString()),
19909
19870
  shareTokenProgram,
19910
- userInputAta: txArgs.userInputAta ?? (0, import_common33.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
19911
- queueInputAta: (0, import_common33.getAtaAddress)(
19871
+ userInputAta: txArgs.userInputAta ?? (0, import_common34.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
19872
+ queueInputAta: (0, import_common34.getAtaAddress)(
19912
19873
  juniorShareMint,
19913
19874
  queuePda,
19914
19875
  shareTokenProgram,
@@ -19933,7 +19894,7 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
19933
19894
  var import_core16 = require("@anchor-lang/core");
19934
19895
  var import_spl_token17 = require("@solana/spl-token");
19935
19896
  var import_web318 = require("@solana/web3.js");
19936
- var import_common34 = __toESM(require_dist());
19897
+ var import_common35 = __toESM(require_dist());
19937
19898
  var DEFAULT_PYTH_PRICE_MAX_AGE_SECS2 = 90n;
19938
19899
  function toAssetPriceOracleConfig2(args) {
19939
19900
  return {
@@ -19948,7 +19909,7 @@ function toAssetPriceOracleConfig2(args) {
19948
19909
  function toAnchorAssetPriceOracleConfig2(config) {
19949
19910
  return {
19950
19911
  ...config,
19951
- priceOracleAccount: (0, import_common34.toWeb3Pk)(config.priceOracleAccount)
19912
+ priceOracleAccount: (0, import_common35.toWeb3Pk)(config.priceOracleAccount)
19952
19913
  };
19953
19914
  }
19954
19915
  var VaultReallocationBuilder = class extends VaultBuilderBase {
@@ -19957,35 +19918,35 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
19957
19918
  amount: args.amount,
19958
19919
  assetPriceOracle: toAnchorAssetPriceOracleConfig2(args.assetPriceOracle)
19959
19920
  }).accountsPartial({
19960
- manager: (0, import_common34.toWeb3Pk)(args.manager),
19961
- allocationVault: (0, import_common34.toWeb3Pk)(args.allocationVault),
19962
- sourceVault: args.sourceVault ? (0, import_common34.toWeb3Pk)(args.sourceVault) : null,
19963
- sourceVaultOracle: args.sourceVaultOracle ? (0, import_common34.toWeb3Pk)(args.sourceVaultOracle) : null,
19964
- destinationVault: (0, import_common34.toWeb3Pk)(args.destinationVault),
19965
- destinationVaultOracle: (0, import_common34.toWeb3Pk)(args.destinationVaultOracle),
19966
- mint: (0, import_common34.toWeb3Pk)(args.mint),
19967
- sourceShareMint: args.sourceShareMint ? (0, import_common34.toWeb3Pk)(args.sourceShareMint) : null,
19968
- destinationShareMint: (0, import_common34.toWeb3Pk)(args.destinationShareMint),
19969
- allocationMintAta: (0, import_common34.toWeb3Pk)(args.allocationMintAta),
19970
- sourceVaultMintAta: args.sourceVaultMintAta ? (0, import_common34.toWeb3Pk)(args.sourceVaultMintAta) : null,
19971
- destinationVaultMintAta: (0, import_common34.toWeb3Pk)(args.destinationVaultMintAta),
19972
- destinationFeeVault: (0, import_common34.toWeb3Pk)(args.destinationFeeVault),
19973
- destinationFeeVaultMintAta: (0, import_common34.toWeb3Pk)(args.destinationFeeVaultMintAta),
19974
- allocationSourceShareAta: args.allocationSourceShareAta ? (0, import_common34.toWeb3Pk)(args.allocationSourceShareAta) : null,
19975
- allocationDestinationShareAta: (0, import_common34.toWeb3Pk)(
19921
+ manager: (0, import_common35.toWeb3Pk)(args.manager),
19922
+ allocationVault: (0, import_common35.toWeb3Pk)(args.allocationVault),
19923
+ sourceVault: args.sourceVault ? (0, import_common35.toWeb3Pk)(args.sourceVault) : null,
19924
+ sourceVaultOracle: args.sourceVaultOracle ? (0, import_common35.toWeb3Pk)(args.sourceVaultOracle) : null,
19925
+ destinationVault: (0, import_common35.toWeb3Pk)(args.destinationVault),
19926
+ destinationVaultOracle: (0, import_common35.toWeb3Pk)(args.destinationVaultOracle),
19927
+ mint: (0, import_common35.toWeb3Pk)(args.mint),
19928
+ sourceShareMint: args.sourceShareMint ? (0, import_common35.toWeb3Pk)(args.sourceShareMint) : null,
19929
+ destinationShareMint: (0, import_common35.toWeb3Pk)(args.destinationShareMint),
19930
+ allocationMintAta: (0, import_common35.toWeb3Pk)(args.allocationMintAta),
19931
+ sourceVaultMintAta: args.sourceVaultMintAta ? (0, import_common35.toWeb3Pk)(args.sourceVaultMintAta) : null,
19932
+ destinationVaultMintAta: (0, import_common35.toWeb3Pk)(args.destinationVaultMintAta),
19933
+ destinationFeeVault: (0, import_common35.toWeb3Pk)(args.destinationFeeVault),
19934
+ destinationFeeVaultMintAta: (0, import_common35.toWeb3Pk)(args.destinationFeeVaultMintAta),
19935
+ allocationSourceShareAta: args.allocationSourceShareAta ? (0, import_common35.toWeb3Pk)(args.allocationSourceShareAta) : null,
19936
+ allocationDestinationShareAta: (0, import_common35.toWeb3Pk)(
19976
19937
  args.allocationDestinationShareAta
19977
19938
  ),
19978
- sourceVaultTrancheState: args.sourceVaultTrancheState ? (0, import_common34.toWeb3Pk)(args.sourceVaultTrancheState) : null,
19979
- destinationVaultTrancheState: args.destinationVaultTrancheState ? (0, import_common34.toWeb3Pk)(args.destinationVaultTrancheState) : null,
19980
- assetOracleAccount: args.assetOracleAccount ? (0, import_common34.toWeb3Pk)(args.assetOracleAccount) : null,
19981
- assetTokenProgram: (0, import_common34.toWeb3Pk)(args.assetTokenProgram),
19982
- sourceShareTokenProgram: (0, import_common34.toWeb3Pk)(args.sourceShareTokenProgram),
19983
- destinationShareTokenProgram: (0, import_common34.toWeb3Pk)(
19939
+ sourceVaultTrancheState: args.sourceVaultTrancheState ? (0, import_common35.toWeb3Pk)(args.sourceVaultTrancheState) : null,
19940
+ destinationVaultTrancheState: args.destinationVaultTrancheState ? (0, import_common35.toWeb3Pk)(args.destinationVaultTrancheState) : null,
19941
+ assetOracleAccount: args.assetOracleAccount ? (0, import_common35.toWeb3Pk)(args.assetOracleAccount) : null,
19942
+ assetTokenProgram: (0, import_common35.toWeb3Pk)(args.assetTokenProgram),
19943
+ sourceShareTokenProgram: (0, import_common35.toWeb3Pk)(args.sourceShareTokenProgram),
19944
+ destinationShareTokenProgram: (0, import_common35.toWeb3Pk)(
19984
19945
  args.destinationShareTokenProgram
19985
19946
  ),
19986
19947
  associatedTokenProgram: import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID,
19987
19948
  systemProgram: import_web318.SystemProgram.programId
19988
- }).instruction().then(import_common34.toKitInstruction);
19949
+ }).instruction().then(import_common35.toKitInstruction);
19989
19950
  }
19990
19951
  async deriveIxArgs(txArgs) {
19991
19952
  const assetTokenProgram = txArgs.assetTokenProgram ?? TOKEN_PROGRAM_ID;
@@ -20018,33 +19979,33 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
20018
19979
  assetTokenProgram,
20019
19980
  sourceShareTokenProgram,
20020
19981
  destinationShareTokenProgram,
20021
- allocationMintAta: (0, import_common34.getAtaAddress)(
19982
+ allocationMintAta: (0, import_common35.getAtaAddress)(
20022
19983
  txArgs.mint,
20023
19984
  txArgs.allocationVault,
20024
19985
  assetTokenProgram,
20025
19986
  true
20026
19987
  ),
20027
- sourceVaultMintAta: sourceVault ? (0, import_common34.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
20028
- destinationVaultMintAta: (0, import_common34.getAtaAddress)(
19988
+ sourceVaultMintAta: sourceVault ? (0, import_common35.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
19989
+ destinationVaultMintAta: (0, import_common35.getAtaAddress)(
20029
19990
  txArgs.mint,
20030
19991
  txArgs.destinationVault,
20031
19992
  assetTokenProgram,
20032
19993
  true
20033
19994
  ),
20034
19995
  destinationFeeVault,
20035
- destinationFeeVaultMintAta: (0, import_common34.getAtaAddress)(
19996
+ destinationFeeVaultMintAta: (0, import_common35.getAtaAddress)(
20036
19997
  txArgs.mint,
20037
19998
  destinationFeeVault,
20038
19999
  assetTokenProgram,
20039
20000
  true
20040
20001
  ),
20041
- allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common34.getAtaAddress)(
20002
+ allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common35.getAtaAddress)(
20042
20003
  sourceShareMint,
20043
20004
  txArgs.allocationVault,
20044
20005
  sourceShareTokenProgram,
20045
20006
  true
20046
20007
  ) : null,
20047
- allocationDestinationShareAta: (0, import_common34.getAtaAddress)(
20008
+ allocationDestinationShareAta: (0, import_common35.getAtaAddress)(
20048
20009
  txArgs.destinationShareMint,
20049
20010
  txArgs.allocationVault,
20050
20011
  destinationShareTokenProgram,
@@ -20053,38 +20014,38 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
20053
20014
  };
20054
20015
  }
20055
20016
  async buildPreambleInstructions(args) {
20056
- const payer = (0, import_common34.toWeb3Pk)(args.manager);
20017
+ const payer = (0, import_common35.toWeb3Pk)(args.manager);
20057
20018
  const instructions2 = [
20058
20019
  (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
20059
20020
  payer,
20060
- (0, import_common34.toWeb3Pk)(args.allocationMintAta),
20061
- (0, import_common34.toWeb3Pk)(args.allocationVault),
20062
- (0, import_common34.toWeb3Pk)(args.mint),
20063
- (0, import_common34.toWeb3Pk)(args.assetTokenProgram),
20021
+ (0, import_common35.toWeb3Pk)(args.allocationMintAta),
20022
+ (0, import_common35.toWeb3Pk)(args.allocationVault),
20023
+ (0, import_common35.toWeb3Pk)(args.mint),
20024
+ (0, import_common35.toWeb3Pk)(args.assetTokenProgram),
20064
20025
  import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
20065
20026
  ),
20066
20027
  (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
20067
20028
  payer,
20068
- (0, import_common34.toWeb3Pk)(args.destinationVaultMintAta),
20069
- (0, import_common34.toWeb3Pk)(args.destinationVault),
20070
- (0, import_common34.toWeb3Pk)(args.mint),
20071
- (0, import_common34.toWeb3Pk)(args.assetTokenProgram),
20029
+ (0, import_common35.toWeb3Pk)(args.destinationVaultMintAta),
20030
+ (0, import_common35.toWeb3Pk)(args.destinationVault),
20031
+ (0, import_common35.toWeb3Pk)(args.mint),
20032
+ (0, import_common35.toWeb3Pk)(args.assetTokenProgram),
20072
20033
  import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
20073
20034
  ),
20074
20035
  (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
20075
20036
  payer,
20076
- (0, import_common34.toWeb3Pk)(args.destinationFeeVaultMintAta),
20077
- (0, import_common34.toWeb3Pk)(args.destinationFeeVault),
20078
- (0, import_common34.toWeb3Pk)(args.mint),
20079
- (0, import_common34.toWeb3Pk)(args.assetTokenProgram),
20037
+ (0, import_common35.toWeb3Pk)(args.destinationFeeVaultMintAta),
20038
+ (0, import_common35.toWeb3Pk)(args.destinationFeeVault),
20039
+ (0, import_common35.toWeb3Pk)(args.mint),
20040
+ (0, import_common35.toWeb3Pk)(args.assetTokenProgram),
20080
20041
  import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
20081
20042
  ),
20082
20043
  (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
20083
20044
  payer,
20084
- (0, import_common34.toWeb3Pk)(args.allocationDestinationShareAta),
20085
- (0, import_common34.toWeb3Pk)(args.allocationVault),
20086
- (0, import_common34.toWeb3Pk)(args.destinationShareMint),
20087
- (0, import_common34.toWeb3Pk)(args.destinationShareTokenProgram),
20045
+ (0, import_common35.toWeb3Pk)(args.allocationDestinationShareAta),
20046
+ (0, import_common35.toWeb3Pk)(args.allocationVault),
20047
+ (0, import_common35.toWeb3Pk)(args.destinationShareMint),
20048
+ (0, import_common35.toWeb3Pk)(args.destinationShareTokenProgram),
20088
20049
  import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
20089
20050
  )
20090
20051
  ];
@@ -20092,23 +20053,23 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
20092
20053
  instructions2.push(
20093
20054
  (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
20094
20055
  payer,
20095
- (0, import_common34.toWeb3Pk)(args.sourceVaultMintAta),
20096
- (0, import_common34.toWeb3Pk)(args.sourceVault),
20097
- (0, import_common34.toWeb3Pk)(args.mint),
20098
- (0, import_common34.toWeb3Pk)(args.assetTokenProgram),
20056
+ (0, import_common35.toWeb3Pk)(args.sourceVaultMintAta),
20057
+ (0, import_common35.toWeb3Pk)(args.sourceVault),
20058
+ (0, import_common35.toWeb3Pk)(args.mint),
20059
+ (0, import_common35.toWeb3Pk)(args.assetTokenProgram),
20099
20060
  import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
20100
20061
  ),
20101
20062
  (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
20102
20063
  payer,
20103
- (0, import_common34.toWeb3Pk)(args.allocationSourceShareAta),
20104
- (0, import_common34.toWeb3Pk)(args.allocationVault),
20105
- (0, import_common34.toWeb3Pk)(args.sourceShareMint),
20106
- (0, import_common34.toWeb3Pk)(args.sourceShareTokenProgram),
20064
+ (0, import_common35.toWeb3Pk)(args.allocationSourceShareAta),
20065
+ (0, import_common35.toWeb3Pk)(args.allocationVault),
20066
+ (0, import_common35.toWeb3Pk)(args.sourceShareMint),
20067
+ (0, import_common35.toWeb3Pk)(args.sourceShareTokenProgram),
20107
20068
  import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
20108
20069
  )
20109
20070
  );
20110
20071
  }
20111
- return instructions2.map(import_common34.toKitInstruction);
20072
+ return instructions2.map(import_common35.toKitInstruction);
20112
20073
  }
20113
20074
  async buildPlanExtras(args) {
20114
20075
  return {
@@ -20213,7 +20174,7 @@ var VaultClient = class {
20213
20174
  async sendTransaction(payer, plan, extraSigners = []) {
20214
20175
  const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
20215
20176
  const tx = new import_web319.Transaction().add(
20216
- ...plan.instructions.map(import_common35.fromKitInstruction)
20177
+ ...plan.instructions.map(import_common36.fromKitInstruction)
20217
20178
  );
20218
20179
  tx.feePayer = payer.publicKey;
20219
20180
  tx.recentBlockhash = blockhash;
@@ -20240,11 +20201,11 @@ var VaultClient = class {
20240
20201
  const { blockhash } = await this.provider.connection.getLatestBlockhash(
20241
20202
  "confirmed"
20242
20203
  );
20243
- const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common35.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
20204
+ const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common36.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
20244
20205
  const message2 = new import_web319.TransactionMessage({
20245
20206
  payerKey: payer.publicKey,
20246
20207
  recentBlockhash: blockhash,
20247
- instructions: plan.instructions.map(import_common35.fromKitInstruction)
20208
+ instructions: plan.instructions.map(import_common36.fromKitInstruction)
20248
20209
  }).compileToV0Message(lookupTableAccounts);
20249
20210
  const tx = new import_web319.VersionedTransaction(message2);
20250
20211
  const result = await this.provider.connection.simulateTransaction(tx, {
@@ -20322,7 +20283,11 @@ function loadKeypair(keypairPath) {
20322
20283
  const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
20323
20284
  return import_web320.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
20324
20285
  }
20286
+ var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
20325
20287
  function defaultKeypairPath(env, role = "vault") {
20288
+ if (ENV_AGNOSTIC_ROLES.has(role)) {
20289
+ return `~/.config/solana/${role}.json`;
20290
+ }
20326
20291
  return `~/.config/solana/${role}-${env}.json`;
20327
20292
  }
20328
20293
  function createVaultClient(env, opts = {}) {
@@ -20340,11 +20305,11 @@ function createVaultClient(env, opts = {}) {
20340
20305
  client,
20341
20306
  provider,
20342
20307
  payer,
20343
- signer: (0, import_common36.fromWeb3Pk)(payer.publicKey)
20308
+ signer: (0, import_common37.fromWeb3Pk)(payer.publicKey)
20344
20309
  };
20345
20310
  }
20346
20311
  function keypairAddress(keypairPath) {
20347
- return (0, import_common36.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
20312
+ return (0, import_common37.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
20348
20313
  }
20349
20314
 
20350
20315
  // src/utils/math.ts
@@ -20482,7 +20447,7 @@ async function prepareVaultTransaction(args) {
20482
20447
  // src/utils/token.ts
20483
20448
  var import_spl_token18 = require("@solana/spl-token");
20484
20449
  var import_web322 = require("@solana/web3.js");
20485
- var import_common37 = __toESM(require_dist());
20450
+ var import_common38 = __toESM(require_dist());
20486
20451
  async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token18.TOKEN_2022_PROGRAM_ID) {
20487
20452
  const mint = import_web322.Keypair.generate();
20488
20453
  const lamports = await (0, import_spl_token18.getMinimumBalanceForRentExemptMint)(connection);
@@ -20527,7 +20492,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
20527
20492
  return mint.publicKey;
20528
20493
  }
20529
20494
  async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token18.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = false) {
20530
- const tokenProgramPk = (0, import_common37.asWeb3PublicKey)(tokenProgram);
20495
+ const tokenProgramPk = (0, import_common38.asWeb3PublicKey)(tokenProgram);
20531
20496
  const ata = (0, import_spl_token18.getAssociatedTokenAddressSync)(
20532
20497
  mint,
20533
20498
  destination,
@@ -20806,7 +20771,7 @@ async function getTotalOutstandingYield(accountNames, start, end) {
20806
20771
  }
20807
20772
 
20808
20773
  // src/services/withdrawalQueueService.ts
20809
- var import_common38 = __toESM(require_dist());
20774
+ var import_common39 = __toESM(require_dist());
20810
20775
  function bnToBigInt(value) {
20811
20776
  return BigInt(value.toString());
20812
20777
  }
@@ -20827,7 +20792,7 @@ var WithdrawalQueueService = class {
20827
20792
  const program = this.client.program.account;
20828
20793
  const accounts2 = await program.vaultWithdrawalQueue.all();
20829
20794
  return accounts2.map(
20830
- (entry) => this.toSnapshot((0, import_common38.fromWeb3Pk)(entry.publicKey), entry.account)
20795
+ (entry) => this.toSnapshot((0, import_common39.fromWeb3Pk)(entry.publicKey), entry.account)
20831
20796
  );
20832
20797
  }
20833
20798
  /** Withdrawal queues for a single vault. */
@@ -20868,7 +20833,7 @@ var WithdrawalQueueService = class {
20868
20833
  async fulfill(signer, queue) {
20869
20834
  const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
20870
20835
  owner: queue.owner,
20871
- signer: (0, import_common38.fromWeb3Pk)(signer.publicKey),
20836
+ signer: (0, import_common39.fromWeb3Pk)(signer.publicKey),
20872
20837
  queuePayer: queue.payer,
20873
20838
  vault: queue.vault,
20874
20839
  withdrawalQueue: queue.pda,
@@ -20901,6 +20866,9 @@ var WithdrawalQueueService = class {
20901
20866
  continue;
20902
20867
  }
20903
20868
  try {
20869
+ log?.(
20870
+ `fulfilling ${queue.pda} \u2014 paying ${queue.inputAmount} junior shares worth of ${queue.outputMint} to owner ${queue.owner}`
20871
+ );
20904
20872
  const sig = await this.fulfill(signer, queue);
20905
20873
  summary.fulfilled += 1;
20906
20874
  summary.signatures.push(sig);
@@ -20919,12 +20887,12 @@ var WithdrawalQueueService = class {
20919
20887
  const a = account;
20920
20888
  return {
20921
20889
  pda,
20922
- vault: (0, import_common38.fromWeb3Pk)(a.parties.vault),
20923
- owner: (0, import_common38.fromWeb3Pk)(a.parties.owner),
20924
- payer: (0, import_common38.fromWeb3Pk)(a.parties.payer),
20890
+ vault: (0, import_common39.fromWeb3Pk)(a.parties.vault),
20891
+ owner: (0, import_common39.fromWeb3Pk)(a.parties.owner),
20892
+ payer: (0, import_common39.fromWeb3Pk)(a.parties.payer),
20925
20893
  queueId: a.header.queueId,
20926
- inputMint: (0, import_common38.fromWeb3Pk)(a.mints.inputMint),
20927
- outputMint: (0, import_common38.fromWeb3Pk)(a.mints.outputMint),
20894
+ inputMint: (0, import_common39.fromWeb3Pk)(a.mints.inputMint),
20895
+ outputMint: (0, import_common39.fromWeb3Pk)(a.mints.outputMint),
20928
20896
  inputAmount: bnToBigInt(a.request.inputAmount),
20929
20897
  requestTs: bnToNumber(a.request.requestTs),
20930
20898
  expiryTs: bnToNumber(a.request.expiryTs)
@@ -20934,7 +20902,7 @@ var WithdrawalQueueService = class {
20934
20902
 
20935
20903
  // src/services/oracleService.ts
20936
20904
  var import_kit11 = require("@solana/kit");
20937
- var import_common39 = __toESM(require_dist());
20905
+ var import_common40 = __toESM(require_dist());
20938
20906
  var SYSTEM_PROGRAM = "11111111111111111111111111111111";
20939
20907
  var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
20940
20908
  var PRICE_ORACLE_TYPES_BY_INDEX = [
@@ -20998,7 +20966,7 @@ var OracleService = class {
20998
20966
  */
20999
20967
  async updateAssetConsensusPrice(signer, args, log) {
21000
20968
  const plan = await this.client.tx.updateConsensusOracle.getTx({
21001
- signer: (0, import_common39.fromWeb3Pk)(signer.publicKey),
20969
+ signer: (0, import_common40.fromWeb3Pk)(signer.publicKey),
21002
20970
  vault: args.vault,
21003
20971
  updates: args.updates,
21004
20972
  assetMint: args.assetMint,
@@ -21014,7 +20982,7 @@ var OracleService = class {
21014
20982
  /** Settle the vault NAV from its current holdings (permissionless). */
21015
20983
  async crankNav(cranker, args, log) {
21016
20984
  const plan = await this.client.tx.crankNav.getTx({
21017
- cranker: (0, import_common39.fromWeb3Pk)(cranker.publicKey),
20985
+ cranker: (0, import_common40.fromWeb3Pk)(cranker.publicKey),
21018
20986
  vault: args.vault,
21019
20987
  vaultTrancheState: args.vaultTrancheState
21020
20988
  });
@@ -21087,7 +21055,7 @@ var OracleService = class {
21087
21055
  /** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
21088
21056
  async refreshAssetPrice(updater, args, log) {
21089
21057
  const plan = await this.client.tx.updateAssetPrice.getTx({
21090
- updater: (0, import_common39.fromWeb3Pk)(updater.publicKey),
21058
+ updater: (0, import_common40.fromWeb3Pk)(updater.publicKey),
21091
21059
  vault: args.vault,
21092
21060
  mint: args.mint,
21093
21061
  oracleAccount: args.oracleAccount,
@@ -21209,10 +21177,10 @@ function toBigInt2(value) {
21209
21177
 
21210
21178
  // src/services/consensusOracle/utils/holdings.ts
21211
21179
  var import_web323 = require("@solana/web3.js");
21212
- var import_common40 = __toESM(require_dist());
21180
+ var import_common41 = __toESM(require_dist());
21213
21181
  function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
21214
21182
  return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
21215
- const mint = (0, import_common40.fromWeb3Pk)(holding.mint);
21183
+ const mint = (0, import_common41.fromWeb3Pk)(holding.mint);
21216
21184
  return mint !== SYSTEM_PROGRAM2 && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
21217
21185
  variantName2(holding.priceOracleType).toLowerCase()
21218
21186
  );
@@ -21308,7 +21276,7 @@ async function collectSamples(read, { samples, minSamples, onError }) {
21308
21276
 
21309
21277
  // src/services/consensusOracle/pipeline/dryRunSettlement.ts
21310
21278
  var import_web325 = require("@solana/web3.js");
21311
- var import_common41 = __toESM(require_dist());
21279
+ var import_common42 = __toESM(require_dist());
21312
21280
 
21313
21281
  // src/services/consensusOracle/settlement/settlementSimulator.ts
21314
21282
  var import_kit12 = require("@solana/kit");
@@ -22338,7 +22306,7 @@ async function simulateDryRunSettlement({
22338
22306
  oracleData: oracleState.data,
22339
22307
  trancheState,
22340
22308
  updates,
22341
- signer: (0, import_common41.fromWeb3Pk)(signer.publicKey),
22309
+ signer: (0, import_common42.fromWeb3Pk)(signer.publicKey),
22342
22310
  nowTs: nowSecs,
22343
22311
  physicalShareSupply: supplies[0],
22344
22312
  physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
@@ -22347,7 +22315,7 @@ async function simulateDryRunSettlement({
22347
22315
  }
22348
22316
 
22349
22317
  // src/services/consensusOracle/pipeline/holdingUpdates.ts
22350
- var import_common42 = __toESM(require_dist());
22318
+ var import_common43 = __toESM(require_dist());
22351
22319
  async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
22352
22320
  const updates = [];
22353
22321
  for (const entry of reportableHoldings) {
@@ -22357,7 +22325,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
22357
22325
  }
22358
22326
  async function buildHoldingUpdate(yieldTracker, entry, inputs) {
22359
22327
  const { holding, holdingIndex } = entry;
22360
- const mint = (0, import_common42.fromWeb3Pk)(holding.mint);
22328
+ const mint = (0, import_common43.fromWeb3Pk)(holding.mint);
22361
22329
  const mintKey = mint.toString();
22362
22330
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
22363
22331
  let usd;
@@ -22407,13 +22375,13 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
22407
22375
  cfg.yieldAccountNames
22408
22376
  );
22409
22377
  return {
22410
- principalAmount: tracked.principal > 0 ? (0, import_common42.fromUiAmount)(tracked.principal, decimals) : 0n,
22411
- yieldAmount: tracked.outstandingYield > 0 ? (0, import_common42.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
22378
+ principalAmount: tracked.principal > 0 ? (0, import_common43.fromUiAmount)(tracked.principal, decimals) : 0n,
22379
+ yieldAmount: tracked.outstandingYield > 0 ? (0, import_common43.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
22412
22380
  };
22413
22381
  }
22414
22382
 
22415
22383
  // src/services/consensusOracle/pipeline/livePriceRefresh.ts
22416
- var import_common43 = __toESM(require_dist());
22384
+ var import_common44 = __toESM(require_dist());
22417
22385
  async function refreshLiveOraclePrices({
22418
22386
  oracle,
22419
22387
  signer,
@@ -22432,7 +22400,7 @@ async function refreshLiveOraclePrices({
22432
22400
  for (const holding of vaultState.holdings) {
22433
22401
  const oracleType = variantName2(holding.priceOracleType).toLowerCase();
22434
22402
  if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
22435
- const mint = (0, import_common43.fromWeb3Pk)(holding.mint);
22403
+ const mint = (0, import_common44.fromWeb3Pk)(holding.mint);
22436
22404
  if (mint.toString() === SYSTEM_PROGRAM2) continue;
22437
22405
  const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
22438
22406
  if (activeAmount === 0n) continue;
@@ -22447,7 +22415,7 @@ async function refreshLiveOraclePrices({
22447
22415
  );
22448
22416
  continue;
22449
22417
  }
22450
- const oracleAccount = (0, import_common43.fromWeb3Pk)(holding.priceOracleAccount);
22418
+ const oracleAccount = (0, import_common44.fromWeb3Pk)(holding.priceOracleAccount);
22451
22419
  if (oracleAccount.toString() === SYSTEM_PROGRAM2) {
22452
22420
  log(
22453
22421
  `vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
@@ -22471,15 +22439,15 @@ async function refreshLiveOraclePrices({
22471
22439
  }
22472
22440
 
22473
22441
  // src/services/consensusOracle/pipeline/pricingInputs.ts
22474
- var import_common44 = __toESM(require_dist());
22442
+ var import_common45 = __toESM(require_dist());
22475
22443
  async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
22476
22444
  }) {
22477
- const manager = (0, import_common44.fromWeb3Pk)(vaultState.roles.manager);
22445
+ const manager = (0, import_common45.fromWeb3Pk)(vaultState.roles.manager);
22478
22446
  const consensusMints = reportableHoldings.filter(
22479
22447
  ({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
22480
- ).map(({ holding }) => (0, import_common44.fromWeb3Pk)(holding.mint));
22448
+ ).map(({ holding }) => (0, import_common45.fromWeb3Pk)(holding.mint));
22481
22449
  const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
22482
- const baseMint = baseHolding ? (0, import_common44.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
22450
+ const baseMint = baseHolding ? (0, import_common45.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
22483
22451
  if (!baseMint) {
22484
22452
  throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
22485
22453
  }
@@ -22572,11 +22540,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
22572
22540
  }
22573
22541
 
22574
22542
  // src/services/consensusOracle/pipeline/receiptMints.ts
22575
- var import_common45 = __toESM(require_dist());
22543
+ var import_common46 = __toESM(require_dist());
22576
22544
  async function fetchReceiptMints(client, vault, vaultState) {
22577
22545
  const receiptMints = /* @__PURE__ */ new Set();
22578
22546
  if (vaultState.mint) {
22579
- receiptMints.add((0, import_common45.fromWeb3Pk)(vaultState.mint).toString());
22547
+ receiptMints.add((0, import_common46.fromWeb3Pk)(vaultState.mint).toString());
22580
22548
  }
22581
22549
  if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
22582
22550
  const trancheState = await client.account.fetchVaultTrancheStateForVault(
@@ -22584,19 +22552,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
22584
22552
  { fresh: true }
22585
22553
  );
22586
22554
  receiptMints.add(
22587
- (0, import_common45.fromWeb3Pk)(trancheState.config.juniorMint).toString()
22555
+ (0, import_common46.fromWeb3Pk)(trancheState.config.juniorMint).toString()
22588
22556
  );
22589
22557
  receiptMints.add(
22590
- (0, import_common45.fromWeb3Pk)(trancheState.config.seniorMint).toString()
22558
+ (0, import_common46.fromWeb3Pk)(trancheState.config.seniorMint).toString()
22591
22559
  );
22592
22560
  return receiptMints;
22593
22561
  }
22594
22562
 
22595
22563
  // src/services/consensusOracle/pipeline/settlement.ts
22596
- var import_common47 = __toESM(require_dist());
22564
+ var import_common48 = __toESM(require_dist());
22597
22565
 
22598
22566
  // src/services/consensusOracle/pipeline/yieldAccounts.ts
22599
- var import_common46 = __toESM(require_dist());
22567
+ var import_common47 = __toESM(require_dist());
22600
22568
  async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
22601
22569
  const accountNames = [
22602
22570
  ...new Set(
@@ -22636,7 +22604,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
22636
22604
  );
22637
22605
  if (namesToAttach.length === 0) return target;
22638
22606
  const baseHolding = vaultState.holdings.find((holding) => {
22639
- const mint = (0, import_common46.fromWeb3Pk)(holding.mint).toString();
22607
+ const mint = (0, import_common47.fromWeb3Pk)(holding.mint).toString();
22640
22608
  return coerceBool3(holding.isBase) && !excludedMints.has(mint);
22641
22609
  });
22642
22610
  if (!baseHolding) {
@@ -22644,7 +22612,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
22644
22612
  `vault ${target.vault}: tagged yield accounts found but no base holding is available`
22645
22613
  );
22646
22614
  }
22647
- const baseMint = (0, import_common46.fromWeb3Pk)(baseHolding.mint);
22615
+ const baseMint = (0, import_common47.fromWeb3Pk)(baseHolding.mint);
22648
22616
  const holdings = [...target.holdings ?? []];
22649
22617
  const existingIndex = holdings.findIndex(
22650
22618
  (holding) => holding.mint.toString() === baseMint.toString()
@@ -22735,7 +22703,7 @@ async function logProspectiveApy({
22735
22703
  );
22736
22704
  const prospectiveNav = vaultState.holdings.reduce(
22737
22705
  (sum, holding, holdingIndex) => {
22738
- const mint = (0, import_common47.fromWeb3Pk)(holding.mint).toString();
22706
+ const mint = (0, import_common48.fromWeb3Pk)(holding.mint).toString();
22739
22707
  if (mint === SYSTEM_PROGRAM2) return sum;
22740
22708
  const update = updatesByIndex.get(holdingIndex);
22741
22709
  const localAmount = toBigInt2(holding.localAmount);
@@ -23244,7 +23212,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
23244
23212
  }
23245
23213
 
23246
23214
  // src/services/consensusOracle/consensusOracleService.ts
23247
- var import_common48 = __toESM(require_dist());
23215
+ var import_common49 = __toESM(require_dist());
23248
23216
  var ConsensusOracleService = class {
23249
23217
  constructor(client, deps) {
23250
23218
  this.client = client;
@@ -23280,7 +23248,7 @@ var ConsensusOracleService = class {
23280
23248
  receiptMints
23281
23249
  );
23282
23250
  const filteredCount = vaultState.holdings.filter(
23283
- (holding) => receiptMints.has((0, import_common48.fromWeb3Pk)(holding.mint).toString())
23251
+ (holding) => receiptMints.has((0, import_common49.fromWeb3Pk)(holding.mint).toString())
23284
23252
  ).length;
23285
23253
  if (filteredCount > 0) {
23286
23254
  log(
@@ -23456,7 +23424,7 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
23456
23424
  // src/services/externalLiquidityIntegrityService.ts
23457
23425
  var import_kit15 = require("@solana/kit");
23458
23426
  var import_web328 = require("@solana/web3.js");
23459
- var import_common49 = __toESM(require_dist());
23427
+ var import_common50 = __toESM(require_dist());
23460
23428
  var import_marginfi3 = __toESM(require_dist2());
23461
23429
  var DEFAULT_MIN_AMOUNT_UI = 1;
23462
23430
  function toRawAmount(uiAmount, decimals) {
@@ -23475,7 +23443,7 @@ function parseActiveSlots(externalLiquidity) {
23475
23443
  if (discriminant === 0) continue;
23476
23444
  if (discriminant !== 1) continue;
23477
23445
  const pubkeyBytes = new Uint8Array(data.slice(8, 40));
23478
- const userAccount = (0, import_common49.toAddress)(new import_web328.PublicKey(pubkeyBytes));
23446
+ const userAccount = (0, import_common50.toAddress)(new import_web328.PublicKey(pubkeyBytes));
23479
23447
  results.push({ index: i, source: "marginfi", userAccount });
23480
23448
  }
23481
23449
  return results;
@@ -23553,7 +23521,7 @@ var ExternalLiquidityIntegrityService = class {
23553
23521
  result.skipped++;
23554
23522
  return result;
23555
23523
  }
23556
- const hwManagerAddress = (0, import_common49.fromWeb3Pk)(hwManager.publicKey);
23524
+ const hwManagerAddress = (0, import_common50.fromWeb3Pk)(hwManager.publicKey);
23557
23525
  const vaultPk = new import_web328.PublicKey(vault.toString());
23558
23526
  const registeredHwManager = pubkeyStr(
23559
23527
  vaultState.roles.hwManager
@@ -23657,7 +23625,7 @@ var ExternalLiquidityIntegrityService = class {
23657
23625
  marginfiAccounts.tokenProgram,
23658
23626
  true
23659
23627
  );
23660
- const depositRefs = (0, import_common49.createCpiRefs)([
23628
+ const depositRefs = (0, import_common50.createCpiRefs)([
23661
23629
  marginfiClient.deposit_cpi({
23662
23630
  marginfiAccount: slot.userAccount,
23663
23631
  authority: vault,