@perena/vault-sdk 1.0.34 → 1.0.37

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/README.md CHANGED
@@ -72,6 +72,59 @@ const client = new VaultClient(makeProvider(connection, payer));
72
72
  const [vault] = await client.pda.deriveVaultPda(0); // vault id
73
73
  ```
74
74
 
75
+ ## NAV-priced yield-tracker accounts
76
+
77
+ The SDK supports both legacy APR accounts and NAV accounts whose share price is
78
+ read by the yield tracker from a configured JSON API. Cashflow amounts are USDC
79
+ base units; for NAV accounts the tracker records the exact shares purchased or
80
+ redeemed at the fetched price.
81
+
82
+ ```typescript
83
+ import {
84
+ addCashflowUpdate,
85
+ createAccount,
86
+ getNavValue,
87
+ getTrackedValue,
88
+ } from "@perena/vault-sdk";
89
+
90
+ await createAccount({
91
+ name: "piku-basis-trade",
92
+ type: "stockmarkettrbasistrade",
93
+ valuationModel: "nav",
94
+ navConfig: {
95
+ url: "https://public-api.piku.co/v1/tokens/stockmarkettrbasistrade",
96
+ price_path: "price",
97
+ },
98
+ tag: vault.toString(),
99
+ password: accountPassword,
100
+ adminSecret,
101
+ });
102
+
103
+ const deposit = await addCashflowUpdate({
104
+ accountName: "piku-basis-trade",
105
+ amount: 1_000_000, // 1 USDC at six decimals
106
+ cashflowType: "deposit",
107
+ valuationModel: "nav",
108
+ password: accountPassword,
109
+ });
110
+ console.log(deposit.share_amount, deposit.nav_price);
111
+
112
+ const nav = await getNavValue("piku-basis-trade");
113
+ console.log(nav.shares, nav.nav_price, nav.total_nav);
114
+
115
+ // Works for either APR or NAV accounts.
116
+ const tracked = await getTrackedValue("piku-basis-trade");
117
+ console.log(tracked.totalValue, tracked.valuationModel);
118
+ ```
119
+
120
+ Use `getAprYield(...)` when an APR-only response is required. The general
121
+ `getYield(...)` and `getBalance(...)` methods return discriminated APR/NAV
122
+ unions, with `isNavAccountValue(...)` and `isNavAccountBalance(...)` available
123
+ as type guards. Historical `start`, `end`, or `as_of` valuation is unavailable
124
+ for NAV accounts backed only by a current-price API. NAV cashflows have no
125
+ `date` or `fundingNextDay` parameter: they execute immediately at the price the
126
+ tracker fetches during submission.
127
+
75
128
  ## Creating transactions
76
129
 
77
130
  ### The builder pattern
@@ -138,7 +191,13 @@ transaction and proposal. The member signs and submits that outer transaction;
138
191
  the multisig must still approve and execute the proposal. When no route matches,
139
192
  the helper returns the original instructions as a normal direct transaction.
140
193
  The configured member must have Squads' `Initiate` permission, and the vault
141
- program role must be assigned to the derived Squads vault PDA.
194
+ program role must be assigned to the derived Squads vault PDA. Before returning
195
+ a Squads transaction, `prepareVaultTransaction` simulates the inner instructions
196
+ with signature verification disabled so the derived vault PDA has the signer
197
+ privileges it will receive during execution. A failed simulation throws
198
+ `SquadsProposalExecutionSimulationError`, including the RPC error and program
199
+ logs. This dry run validates current program and account state, but not proposal
200
+ approvals or the Squads execution wrapper.
142
201
 
143
202
  `VaultTransactionPlan` contains:
144
203
 
package/dist/index.d.ts CHANGED
@@ -15115,6 +15115,13 @@ interface PreparedSquadsTransaction {
15115
15115
  vaultTransactionPda: PublicKey;
15116
15116
  }
15117
15117
  type PreparedVaultTransaction = PreparedDirectTransaction | PreparedSquadsTransaction;
15118
+ type SquadsSimulationTransactionError = NonNullable<SimulatedTransactionResponse["err"]>;
15119
+ declare class SquadsProposalExecutionSimulationError extends Error {
15120
+ readonly transactionError: SquadsSimulationTransactionError;
15121
+ readonly logs: string[];
15122
+ readonly unitsConsumed?: number;
15123
+ constructor(transactionError: SquadsSimulationTransactionError, logs: readonly string[], unitsConsumed?: number);
15124
+ }
15118
15125
  /** Resolve and validate a configured wallet route, including its vault PDA. */
15119
15126
  declare function resolveSquadsWalletRoute(route: SquadsWalletRouteConfig): ResolvedSquadsWalletRoute;
15120
15127
  /** Find the optional Squads route for a connected proposer wallet. */
@@ -15127,6 +15134,24 @@ declare function validateSquadsWalletRoutes(routes: readonly SquadsWalletRouteCo
15127
15134
  * the wallet itself.
15128
15135
  */
15129
15136
  declare function vaultAuthorityForWallet(wallet: PublicKey | string, routes: readonly SquadsWalletRouteConfig[]): PublicKey;
15137
+ /**
15138
+ * Simulate the instructions stored in a Squads proposal before creating it.
15139
+ *
15140
+ * Signature verification is intentionally disabled so the runtime treats the
15141
+ * Squads vault PDA's signer account meta as signed, matching the privileges it
15142
+ * receives from Squads' eventual `invoke_signed` execution. This validates the
15143
+ * inner instructions against current chain state; it does not validate Squads
15144
+ * approvals or the execution wrapper itself.
15145
+ *
15146
+ * Throws {@link SquadsProposalExecutionSimulationError} when the simulated
15147
+ * instructions fail.
15148
+ */
15149
+ declare function simulateSquadsProposalExecution(args: {
15150
+ connection: Connection;
15151
+ feePayer: PublicKey;
15152
+ instructions: readonly TransactionInstruction[];
15153
+ recentBlockhash?: string;
15154
+ }): Promise<SimulatedTransactionResponse>;
15130
15155
  /**
15131
15156
  * Build either a normal transaction or a Squads proposal-creation transaction,
15132
15157
  * based on whether `proposer` has a configured wallet route.
@@ -15161,29 +15186,73 @@ interface BasicAuthCredentials {
15161
15186
  }
15162
15187
  declare function dateToStr(date: Date): string;
15163
15188
  declare function roundToNextUtcMidnight(date: Date): Date;
15189
+ type YieldValuationModel = "apr" | "nav";
15190
+ interface NavPriceConfig {
15191
+ url: string;
15192
+ price_path: string;
15193
+ }
15194
+ interface YieldCashflow {
15195
+ id: string;
15196
+ account_name: string;
15197
+ /** Signed USDC amount in tracker base units. */
15198
+ amount: number;
15199
+ /** Present for NAV accounts: exact signed shares derived at submission. */
15200
+ share_amount?: string;
15201
+ nav_price?: string;
15202
+ nav_fetched_at?: Date;
15203
+ timestamp: Date;
15204
+ description?: string | null;
15205
+ created_at: Date;
15206
+ }
15164
15207
  interface YieldAccount {
15165
15208
  name: string;
15166
15209
  tag: string | null;
15167
15210
  type: string;
15168
- apy: number | null;
15211
+ /** `apr` is returned by single-account/create/update endpoints. */
15212
+ apr?: number | null;
15213
+ /** `apy` is the legacy list-endpoint name for the same APR value. */
15214
+ apy?: number | null;
15215
+ valuation_model?: YieldValuationModel;
15216
+ nav_config?: NavPriceConfig | null;
15169
15217
  description?: string | null;
15218
+ created_at?: Date;
15219
+ updated_at?: Date;
15220
+ cashflows?: YieldCashflow[];
15170
15221
  }
15222
+ interface NavYieldAccount extends YieldAccount {
15223
+ valuation_model: "nav";
15224
+ nav_config: NavPriceConfig;
15225
+ apr?: null;
15226
+ apy?: null;
15227
+ }
15228
+ declare function isNavYieldAccount(account: YieldAccount): account is NavYieldAccount;
15171
15229
  interface CreateAccountBaseParams {
15172
15230
  name: string;
15173
15231
  password: string;
15174
15232
  adminSecret?: string;
15175
- tag?: string;
15233
+ /** Vault address used by consensus-oracle account discovery. */
15234
+ tag: string;
15176
15235
  description?: string;
15177
15236
  }
15178
- type CreateAccountParams<TType extends string = string> = CreateAccountBaseParams & {
15237
+ type AprCreateAccountParams<TType extends string> = CreateAccountBaseParams & {
15179
15238
  type: TType;
15239
+ valuationModel?: "apr";
15240
+ navConfig?: never;
15180
15241
  } & (TType extends "dynamic" ? {
15181
15242
  apr: number;
15182
15243
  } : {
15183
15244
  apr?: number;
15184
15245
  });
15185
- declare function createAccount<TType extends string>(params: CreateAccountParams<TType>): Promise<any>;
15246
+ type NavCreateAccountParams<TType extends string> = CreateAccountBaseParams & {
15247
+ type: TType;
15248
+ valuationModel: "nav";
15249
+ navConfig: NavPriceConfig;
15250
+ apr?: never;
15251
+ };
15252
+ type CreateAccountParams<TType extends string = string> = AprCreateAccountParams<TType> | NavCreateAccountParams<TType>;
15253
+ declare function createAccount<TType extends string>(params: CreateAccountParams<TType>): Promise<YieldAccount>;
15186
15254
  declare function getAccounts(): Promise<YieldAccount[]>;
15255
+ declare function getAccount(accountName: string): Promise<YieldAccount>;
15187
15256
  interface UpdateAccountParams {
15188
15257
  accountName: string;
15189
15258
  password: string;
@@ -15192,6 +15261,8 @@ interface UpdateAccountParams {
15192
15261
  apr?: number;
15193
15262
  tag?: string | null;
15194
15263
  description?: string | null;
15264
+ valuationModel?: YieldValuationModel;
15265
+ navConfig?: NavPriceConfig;
15195
15266
  }
15196
15267
  declare function updateAccount(params: UpdateAccountParams): Promise<YieldAccount>;
15197
15268
  interface DeleteAccountParams {
@@ -15207,24 +15278,45 @@ interface UpdateDynamicAprParams {
15207
15278
  password: string;
15208
15279
  }
15209
15280
  declare function updateDynamicApr(params: UpdateDynamicAprParams): Promise<any>;
15210
- interface AddCashflowUpdateParams {
15281
+ interface AddCashflowUpdateBaseParams {
15211
15282
  accountName: string;
15212
15283
  amount: number;
15213
- date: Date;
15214
15284
  description?: string;
15215
15285
  password: string;
15216
15286
  cashflowType: "deposit" | "withdraw";
15287
+ }
15288
+ interface AddNavCashflowUpdateParams extends AddCashflowUpdateBaseParams {
15289
+ /** NAV cashflows always execute immediately at the fetched price. */
15290
+ valuationModel: "nav";
15291
+ }
15292
+ interface AddAprCashflowUpdateParams extends AddCashflowUpdateBaseParams {
15293
+ valuationModel?: "apr";
15294
+ date?: Date;
15217
15295
  fundingNextDay?: boolean;
15218
15296
  }
15219
- declare function addCashflowUpdate(params: AddCashflowUpdateParams): Promise<any>;
15220
- declare function getCashflows(accountName: string): Promise<any>;
15221
- interface AccountBalanceResponse {
15297
+ type AddCashflowUpdateParams = AddNavCashflowUpdateParams | AddAprCashflowUpdateParams;
15298
+ declare function addCashflowUpdate(params: AddCashflowUpdateParams): Promise<YieldCashflow>;
15299
+ declare function getCashflows(accountName: string): Promise<YieldCashflow[]>;
15300
+ interface AprAccountBalanceResponse {
15222
15301
  account_name: string;
15223
15302
  account_type: string;
15303
+ valuation_model?: "apr";
15224
15304
  apr: number;
15225
15305
  balance: number;
15226
15306
  as_of: Date;
15227
15307
  }
15308
+ interface NavAccountBalanceResponse {
15309
+ account_name: string;
15310
+ account_type: string;
15311
+ valuation_model: "nav";
15312
+ total_nav: string;
15313
+ shares: string;
15314
+ nav_price: string;
15315
+ nav_fetched_at: Date;
15316
+ as_of: Date;
15317
+ }
15318
+ type AccountBalanceResponse = AprAccountBalanceResponse | NavAccountBalanceResponse;
15319
+ declare function isNavAccountBalance(response: AccountBalanceResponse): response is NavAccountBalanceResponse;
15228
15320
  declare function getBalance(accountName: string, atTime?: Date): Promise<AccountBalanceResponse>;
15229
15321
  interface YieldCalculationLog {
15230
15322
  segment_number: number;
@@ -15237,7 +15329,8 @@ interface YieldCalculationLog {
15237
15329
  cumulative_yield: number;
15238
15330
  calculation_formula: string;
15239
15331
  }
15240
- interface AccountYieldResponse {
15332
+ interface AprAccountYieldResponse {
15333
+ valuation_model?: "apr";
15241
15334
  account: {
15242
15335
  name: string;
15243
15336
  type: string;
@@ -15256,6 +15349,16 @@ interface AccountYieldResponse {
15256
15349
  apr_used: number;
15257
15350
  calculation_log: YieldCalculationLog[];
15258
15351
  }
15352
+ interface NavAccountValueResponse {
15353
+ account: AprAccountYieldResponse["account"];
15354
+ valuation_model: "nav";
15355
+ total_nav: string;
15356
+ shares: string;
15357
+ nav_price: string;
15358
+ nav_fetched_at: Date;
15359
+ }
15360
+ type AccountYieldResponse = AprAccountYieldResponse | NavAccountValueResponse;
15361
+ declare function isNavAccountValue(response: AccountYieldResponse): response is NavAccountValueResponse;
15259
15362
  interface CreateYieldPaymentParams {
15260
15363
  accountName: string;
15261
15364
  amount: number;
@@ -15283,9 +15386,26 @@ declare function confirmYieldPayment(params: {
15283
15386
  }): Promise<YieldPaymentResponse>;
15284
15387
  declare function getYieldPayments(accountName: string): Promise<YieldPaymentResponse[]>;
15285
15388
  declare function getYield(accountName: string, start?: Date, end?: Date): Promise<AccountYieldResponse>;
15389
+ declare function getAprYield(accountName: string, start?: Date, end?: Date): Promise<AprAccountYieldResponse>;
15390
+ declare function getNavValue(accountName: string): Promise<NavAccountValueResponse>;
15391
+ interface TrackedAccountValue {
15392
+ totalValue: number;
15393
+ principal: number;
15394
+ outstandingYield: number;
15395
+ valuationModel: YieldValuationModel;
15396
+ }
15397
+ /** Normalize either yield-tracker response model into one current base-unit value. */
15398
+ declare function trackedValueFromResponse(response: AccountYieldResponse): TrackedAccountValue;
15399
+ declare function getTrackedValue(accountName: string): Promise<TrackedAccountValue>;
15286
15400
  declare function getTotalYield(accountNames: string[], start?: Date, end?: Date): Promise<BN>;
15287
15401
  /** Sum only confirmed-payment-adjusted yield that remains receivable. */
15288
15402
  declare function getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
15403
+ /** Sum the complete current value of APR and NAV accounts in tracker base units. */
15404
+ declare function getTotalTrackedValue(accountNames: string[], start?: Date, end?: Date): Promise<{
15405
+ totalValue: number;
15406
+ principal: number;
15407
+ outstandingYield: number;
15408
+ }>;
15289
15409
 
15290
15410
  /**
15291
15411
  * Junior-tranche withdrawal-queue fulfillment.
@@ -15544,13 +15664,21 @@ interface YieldTracker {
15544
15664
  getAccountNamesForVault?(vault: Address): Promise<string[]>;
15545
15665
  /** All payments for an account, including payments not yet confirmed. */
15546
15666
  getYieldPayments(accountName: string): Promise<YieldPaymentSnapshot[]>;
15547
- /** Sum of oracle-safe outstanding yield across the named accounts. */
15667
+ /** Sum of oracle-safe outstanding yield across APR accounts. */
15548
15668
  getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
15549
15669
  /**
15550
- * Sum the external principal and confirmed-payment-adjusted outstanding yield
15551
- * across the named accounts. Both values are UI token amounts.
15670
+ * Sum complete current account value across APR and NAV accounts. APR
15671
+ * diagnostics remain separate; NAV accounts contribute only to totalValue.
15672
+ * All values are UI token amounts.
15552
15673
  */
15553
- getTotalTrackedAmounts(accountNames: string[], start?: Date, end?: Date): Promise<{
15674
+ getTotalTrackedValue?(accountNames: string[], start?: Date, end?: Date): Promise<{
15675
+ totalValue: number;
15676
+ /** APR-account diagnostics; NAV accounts contribute zero here. */
15677
+ principal: number;
15678
+ outstandingYield: number;
15679
+ }>;
15680
+ /** @deprecated APR-only compatibility surface; use getTotalTrackedValue. */
15681
+ getTotalTrackedAmounts?(accountNames: string[], start?: Date, end?: Date): Promise<{
15554
15682
  principal: number;
15555
15683
  outstandingYield: number;
15556
15684
  }>;
@@ -15608,7 +15736,9 @@ interface HoldingUpdatePreview {
15608
15736
  yieldAmount: bigint;
15609
15737
  /** Yield-tracker principal attributed to this holding (base units). */
15610
15738
  trackedPrincipalAmount: bigint;
15611
- /** Total external balance pushed = wallet + LP + tracked principal + yield. */
15739
+ /** Complete tracked value, including NAV accounts (base units). */
15740
+ trackedValueAmount: bigint;
15741
+ /** Total external balance pushed = wallet + LP + complete tracked value. */
15612
15742
  externalAmount: bigint;
15613
15743
  }
15614
15744
  interface VaultOracleResult {
@@ -15905,6 +16035,7 @@ interface LargeBalanceChangeViolation {
15905
16035
  walletAmount: bigint;
15906
16036
  lpAmount: bigint;
15907
16037
  trackedPrincipalAmount: bigint;
16038
+ trackedValueAmount: bigint;
15908
16039
  yieldAmount: bigint;
15909
16040
  }
15910
16041
  interface StaleBalanceChangeBypass extends LargeBalanceChangeViolation {
@@ -15939,8 +16070,9 @@ declare function simulateDryRunSettlement({ client, signer, vault, vaultState, u
15939
16070
 
15940
16071
  declare function buildUpdates(yieldTracker: YieldTracker | undefined, reportableHoldings: ConsensusHoldingEntry[], inputs: VaultPricingInputs): Promise<HoldingUpdatePreview[]>;
15941
16072
  declare function buildHoldingUpdate(yieldTracker: YieldTracker | undefined, entry: ConsensusHoldingEntry, inputs: VaultPricingInputs): Promise<HoldingUpdatePreview>;
15942
- /** Tracked external principal + outstanding yield attributed to a holding. */
16073
+ /** Complete tracked account value attributed to a holding. */
15943
16074
  declare function resolveTrackedAmounts(yieldTracker: YieldTracker | undefined, cfg: ConsensusOracleHoldingConfig | undefined, decimals: number): Promise<{
16075
+ trackedValueAmount: bigint;
15944
16076
  principalAmount: bigint;
15945
16077
  yieldAmount: bigint;
15946
16078
  }>;
@@ -16268,6 +16400,12 @@ declare class MockYieldTracker implements YieldTracker {
16268
16400
  getYield(accountName: string, start?: Date, end?: Date): Promise<YieldAccountSnapshot>;
16269
16401
  getTotalYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
16270
16402
  getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
16403
+ getTotalTrackedValue(accountNames: string[], start?: Date, end?: Date): Promise<{
16404
+ totalValue: number;
16405
+ principal: number;
16406
+ outstandingYield: number;
16407
+ }>;
16408
+ /** Backward-compatible APR-only breakdown. */
16271
16409
  getTotalTrackedAmounts(accountNames: string[], start?: Date, end?: Date): Promise<{
16272
16410
  principal: number;
16273
16411
  outstandingYield: number;
@@ -16613,4 +16751,4 @@ declare class IdleLiquidityService {
16613
16751
  private executeSwap;
16614
16752
  }
16615
16753
 
16616
- export { ASSET_DECIMALS, ASSET_REBALANCE_COOLDOWN_SECS, type AccountBalanceResponse, AccountClient, type AccountYieldResponse, ActivateCircuitBreakerBuilder, type ActivateCircuitBreakerIxArgs, type ActivateCircuitBreakerTxArgs, type AssetPriceOracleConfigIxArgs, type AssetPriceOracleConfigTxArgs, type AssetPriceRefreshTarget, type AssetRefreshResult, type AssetType, BALANCE_CHANGE_BASELINE_MAX_AGE_SECS, type Bankineco, type BasicAuthCredentials, type Bigintish, CONSENSUS_ORACLE_VARIANT, CancelJuniorTrancheWithdrawBuilder, type CancelJuniorTrancheWithdrawIxArgs, type CancelJuniorTrancheWithdrawTxArgs, type Clock, type CollectSamplesOptions, type ConsensusAssetUpdate, type ConsensusHoldingEntry, type ConsensusHoldingSimulation, type ConsensusOracleDeps, type ConsensusOracleHoldingConfig, ConsensusOracleService, type ConsensusOracleTarget, CrankNavBuilder, type CrankNavIxArgs, type CrankNavTxArgs, CrankPerformanceFeesBuilder, type CrankPerformanceFeesIxArgs, type CrankPerformanceFeesTxArgs, type CreateAccountParams, CreateAssetHoldingBuilder, type CreateAssetHoldingIxArgs, type CreateAssetHoldingTxArgs, type CreateTokenMintIxs, CreateTrancheStateBuilder, type CreateTrancheStateIxArgs, type CreateTrancheStateTxArgs, CreateVaultBuilder, type CreateVaultClientOptions, type CreateVaultIxArgs, type CreateVaultParams, type CreateVaultTxArgs, type CreateYieldPaymentParams, DEFAULT_CU_PRICE_MICRO_LAMPORTS, DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS, DEFAULT_MAX_ACCEPTABLE_APY_BPS, DEFAULT_MAX_ACCOUNTS, DEFAULT_MINTS, DEFAULT_MIN_AMOUNT_UI, DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS, DEFAULT_PRICE_ORACLE_ACCOUNT, DEFAULT_PRICE_STALENESS_SECS, DEFAULT_PRICE_STALENESS_THRESHOLD_SECS, DEFAULT_REBALANCE_BAND_BPS, DEFAULT_SLIPPAGE_BPS, DEFAULT_TARGET_LOCAL_BPS, DEFAULT_VAULT_ID, type DecodedHolding, type DecodedVault, type DecodedVaultTrancheState, type DeleteAccountParams, DisableCircuitBreakerBuilder, type DisableCircuitBreakerIxArgs, type DisableCircuitBreakerTxArgs, EXTERNAL_POSITION_SAMPLES, ExecuteDepositBuilder, type ExecuteDepositIxArgs, type ExecuteDepositTxArgs, ExecuteShareSwapBuilder, type ExecuteShareSwapIxArgs, type ExecuteShareSwapTxArgs, ExecuteTrancheDepositBuilder, type ExecuteTrancheDepositIxArgs, type ExecuteTrancheDepositTxArgs, ExecuteTrancheWithdrawBuilder, type ExecuteTrancheWithdrawIxArgs, type ExecuteTrancheWithdrawTxArgs, ExecuteWithdrawBuilder, type ExecuteWithdrawIxArgs, type ExecuteWithdrawTxArgs, type ExternalLiquidityIntegrityOptions, type ExternalLiquidityIntegrityResult, ExternalLiquidityIntegrityService, type ExternalLiquidityIntegritySummary, type ExternalLiquiditySlot, type ExternalLiquiditySourceArgs, type ExternalPosition, type ExternalPositionContext, type ExternalPositionProvider, type ExternalPositionRef, ExternalPositionRegistry, FEE_VAULT_CACHE_CATEGORY, type FeeVaultAccountData, type FetchNestTokenPriceOptions, FulfillJuniorTrancheWithdrawBuilder, type FulfillJuniorTrancheWithdrawIxArgs, type FulfillJuniorTrancheWithdrawTxArgs, type FulfillSummary, type HoldingNavContribution, type HoldingUpdatePreview, IDL, IDLE_RESERVE_FLOOR_BPS, IDLE_RESERVE_TARGET_BPS, type IdleLiquidityOptions, type IdleLiquidityResult, IdleLiquidityService, type IdleLiquidityStatus, InitializeVaultRolesBuilder, type InitializeVaultRolesIxArgs, type InitializeVaultRolesTxArgs, type JuniorWithdrawalMode, JupiterBalanceSource, type JupiterBalanceSourceOptions, JupiterPriceSource, type JupiterPriceSourceOptions, JupiterSwapBuilder, type JupiterSwapIxArgs, type JupiterSwapTxArgs, KaminoPositionProvider, LIVE_ORACLE_VARIANTS, LIVE_PRICE_REFRESH_INTERVAL_SECS, LOCAL_PROTOCOL_ADMIN, LargeBalanceChangeError, type LargeBalanceChangeViolation, type LiveConsensusOracleDepsOptions, LivePriceSource, type LivePriceSourceOptions, MAX_BALANCE_CHANGE_BPS, MAX_CONSENSUS_SIGNERS, MAX_MANAGER_WITHDRAW_DESTINATIONS, MAX_PRICE_STALENESS_THRESHOLD_SECS, MIN_EXTERNAL_POSITION_SAMPLES, ManagerRedepositAssetBuilder, type ManagerRedepositAssetIxArgs, type ManagerRedepositAssetTxArgs, ManagerWithdrawAssetBuilder, type ManagerWithdrawAssetIxArgs, type ManagerWithdrawAssetTxArgs, MarginfiPositionProvider, type MintConfig, type MintIdentifier, type MintInfo, MintRegistry, type MintRegistryOptions, type MockYieldAccountConfig, MockYieldTracker, type MockYieldTrackerOptions, NEST_API_BASE_URL, NEST_RWA_SHARE_MINT, NEST_VAULT_SLUG, type NavCrankBlocker, type NavCrankBlockerReason, type NavCrankReadiness, type NavCrankResult, NestPriceSource, type NestPriceSourceOptions, ORACLE_ENTRIES_OFFSET, ORACLE_ENTRY_SIZE, ORACLE_SETTLED_NAV_TS_OFFSET, OracleService, PRICE_ORACLE_TYPES_BY_INDEX, PROGRAM_FEE_EXEMPT_OWNER_WHITELIST, PROTOCOL_ADMIN, PROTOCOL_FEE_RECIPIENT, PdaClient, type PreparedDirectTransaction, type PreparedSquadsTransaction, type PreparedVaultTransaction, type PriceOracleTypeArgs, type PriceSource, ProtocolInteractionBuilder, type ProtocolInteractionIxArgs, type ProtocolInteractionTxArgs, type QuoteFeeUnit, REPORTABLE_ORACLE_VARIANTS, type RefreshLiveOraclePricesParams, RemoveAssetHoldingBuilder, type RemoveAssetHoldingIxArgs, type RemoveAssetHoldingTxArgs, RequestJuniorTrancheWithdrawBuilder, type RequestJuniorTrancheWithdrawIxArgs, type RequestJuniorTrancheWithdrawTxArgs, type ResolvedSquadsWalletRoute, type RollingLimitConfig, type RollingRebalanceLimitConfig, type RunLiveConsensusOracleOptions, type RunOptions, type RunSummary, SHARE_DECIMALS, SYSTEM_PROGRAM, SetAssetPriceOracleBuilder, type SetAssetPriceOracleIxArgs, type SetAssetPriceOracleTxArgs, SetExternalLiquidityBuilder, type SetExternalLiquidityIxArgs, type SetExternalLiquidityTxArgs, SetManagerWithdrawDestinationBuilder, type SetManagerWithdrawDestinationIxArgs, type SetManagerWithdrawDestinationTxArgs, SetProtocolFeeBuilder, type SetProtocolFeeIxArgs, type SetProtocolFeeTxArgs, SetVaultConfigBuilder, type SetVaultConfigIxArgs, type SetVaultConfigTxArgs, type SettleVaultParams, type SettleVaultResult, type SettlementSimulation, type SettlementSimulationSnapshot, type SimulateDryRunSettlementParams, type SimulateSettlementArgs, type SimulatedShareClass, type SquadsWalletRouteConfig, type StaleBalanceChangeBypass, StaticPositionProvider, TOKEN_PROGRAM, TOKEN_PROGRAM_ID, type TrancheKindArgs, type TransactionBuilder, TransactionClient, USDC_MINT, USD_STAR_JUNIOR_MINT, USD_STAR_MINT, USD_STAR_PRINCIPAL_MINT, type UpdateAccountParams, UpdateAssetPriceBuilder, type UpdateAssetPriceIxArgs, type UpdateAssetPriceTxArgs, UpdateConsensusOracleBuilder, type UpdateConsensusOracleIxArgs, type UpdateConsensusOracleTxArgs, UpdateConsensusSignersBuilder, type UpdateConsensusSignersIxArgs, type UpdateConsensusSignersTxArgs, type UpdateDynamicAprParams, UpdateTrancheConfigBuilder, type UpdateTrancheConfigIxArgs, type UpdateTrancheConfigTxArgs, VAULT_CACHE_CATEGORY, VAULT_CREATOR_WHITELIST, VAULT_ENVIRONMENTS, VAULT_ORACLE_CACHE_CATEGORY, VAULT_PROGRAM_ID, VAULT_PROGRAM_IDS, VAULT_PROGRAM_PUBLIC_KEY, VAULT_ROLE_UPDATE_TIMELOCK_SECS, VAULT_TRANCHE_STATE_CACHE_CATEGORY, VAULT_TRANCHE_WITHDRAWAL_QUEUE_CACHE_CATEGORY, type Vault, type VaultAccountData, VaultBuilderBase, type VaultBuilderContext, type VaultCacheInvalidation, VaultClient, type VaultClientBundle, type VaultEnv, type VaultOracleAccountData, type VaultOracleResult, type VaultPricingInputs, type VaultQuote, type VaultQuoteArgs, VaultQuoteClient, type VaultQuoteDirection, type VaultQuoteShareClass, VaultReallocationBuilder, type VaultReallocationIxArgs, type VaultReallocationTxArgs, type VaultTrancheStateAccountData, type VaultTrancheWithdrawalQueueAccountData, type VaultTransactionPlan, type WalletBalanceSource, type WithdrawProtocolFeesIxArgs, type WithdrawProtocolFeesTxArgs, type WithdrawTrancheFeesIxArgs, type WithdrawTrancheFeesTxArgs, WithdrawalQueueService, type WithdrawalQueueSnapshot, type YieldAccount, type YieldAccountSnapshot, type YieldCalculationLog, type YieldPaymentResponse, type YieldPaymentSnapshot, type YieldTracker, accountingUnitPriceToUsd, addCashflowUpdate, applyEffectiveApy, assertNoLargeBalanceChanges, assertNoUnconfirmedYieldPayments, buildHoldingUpdate, buildUpdates, coerceBool, collectSamples, confirmYieldPayment, createAccount, createLiveConsensusOracleDeps, createRpcFromConnection, createTokenMint, createTokenMintIxs, createVaultClient, createYieldPayment, dateToStr, defaultKeypairPath, deleteAccount, discoverVaultsForSigner, fetchExternalPositions, fetchNestTokenPrice, fetchReceiptMints, filterTargetHoldings, findLargeBalanceChanges, findSquadsWalletRoute, formatSettlementSimulation, fromUiAmount, gatherPricingInputs, getAccounts, getBalance, getCashflows, getRpcUrl, getTotalOutstandingYield, getTotalYield, getVaultProgramId, getYield, getYieldPayments, indexConfigByMint, isVaultEnv, keypairAddress, loadKeypair, logProspectiveApy, makeProvider, mintTokensTo, mints, mostFrequent, parseExternalLiquidityRefs, planRebalance, prepareVaultTransaction, priceInAccountingUnit, readI64LE, readSplMintSupply, refreshLiveOraclePrices, resolveKeypairPath, resolveSquadsWalletRoute, resolveTrackedAmounts, roundToNextUtcMidnight, runLiveConsensusOracle, selectReportableHoldings, settleVault, signerInOracleData, simulateConsensusOracleSettlement, simulateDryRunSettlement, sumPositionsByMint, systemClock, toBigInt, toUiAmount, updateAccount, updateDynamicApr, validateSquadsWalletRoutes, variantName, vaultAuthorityForWallet, withDiscoveredYieldAccounts };
16754
+ export { ASSET_DECIMALS, ASSET_REBALANCE_COOLDOWN_SECS, type AccountBalanceResponse, AccountClient, type AccountYieldResponse, ActivateCircuitBreakerBuilder, type ActivateCircuitBreakerIxArgs, type ActivateCircuitBreakerTxArgs, type AddAprCashflowUpdateParams, type AddCashflowUpdateParams, type AddNavCashflowUpdateParams, type AprAccountBalanceResponse, type AprAccountYieldResponse, type AssetPriceOracleConfigIxArgs, type AssetPriceOracleConfigTxArgs, type AssetPriceRefreshTarget, type AssetRefreshResult, type AssetType, BALANCE_CHANGE_BASELINE_MAX_AGE_SECS, type Bankineco, type BasicAuthCredentials, type Bigintish, CONSENSUS_ORACLE_VARIANT, CancelJuniorTrancheWithdrawBuilder, type CancelJuniorTrancheWithdrawIxArgs, type CancelJuniorTrancheWithdrawTxArgs, type Clock, type CollectSamplesOptions, type ConsensusAssetUpdate, type ConsensusHoldingEntry, type ConsensusHoldingSimulation, type ConsensusOracleDeps, type ConsensusOracleHoldingConfig, ConsensusOracleService, type ConsensusOracleTarget, CrankNavBuilder, type CrankNavIxArgs, type CrankNavTxArgs, CrankPerformanceFeesBuilder, type CrankPerformanceFeesIxArgs, type CrankPerformanceFeesTxArgs, type CreateAccountParams, CreateAssetHoldingBuilder, type CreateAssetHoldingIxArgs, type CreateAssetHoldingTxArgs, type CreateTokenMintIxs, CreateTrancheStateBuilder, type CreateTrancheStateIxArgs, type CreateTrancheStateTxArgs, CreateVaultBuilder, type CreateVaultClientOptions, type CreateVaultIxArgs, type CreateVaultParams, type CreateVaultTxArgs, type CreateYieldPaymentParams, DEFAULT_CU_PRICE_MICRO_LAMPORTS, DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS, DEFAULT_MAX_ACCEPTABLE_APY_BPS, DEFAULT_MAX_ACCOUNTS, DEFAULT_MINTS, DEFAULT_MIN_AMOUNT_UI, DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS, DEFAULT_PRICE_ORACLE_ACCOUNT, DEFAULT_PRICE_STALENESS_SECS, DEFAULT_PRICE_STALENESS_THRESHOLD_SECS, DEFAULT_REBALANCE_BAND_BPS, DEFAULT_SLIPPAGE_BPS, DEFAULT_TARGET_LOCAL_BPS, DEFAULT_VAULT_ID, type DecodedHolding, type DecodedVault, type DecodedVaultTrancheState, type DeleteAccountParams, DisableCircuitBreakerBuilder, type DisableCircuitBreakerIxArgs, type DisableCircuitBreakerTxArgs, EXTERNAL_POSITION_SAMPLES, ExecuteDepositBuilder, type ExecuteDepositIxArgs, type ExecuteDepositTxArgs, ExecuteShareSwapBuilder, type ExecuteShareSwapIxArgs, type ExecuteShareSwapTxArgs, ExecuteTrancheDepositBuilder, type ExecuteTrancheDepositIxArgs, type ExecuteTrancheDepositTxArgs, ExecuteTrancheWithdrawBuilder, type ExecuteTrancheWithdrawIxArgs, type ExecuteTrancheWithdrawTxArgs, ExecuteWithdrawBuilder, type ExecuteWithdrawIxArgs, type ExecuteWithdrawTxArgs, type ExternalLiquidityIntegrityOptions, type ExternalLiquidityIntegrityResult, ExternalLiquidityIntegrityService, type ExternalLiquidityIntegritySummary, type ExternalLiquiditySlot, type ExternalLiquiditySourceArgs, type ExternalPosition, type ExternalPositionContext, type ExternalPositionProvider, type ExternalPositionRef, ExternalPositionRegistry, FEE_VAULT_CACHE_CATEGORY, type FeeVaultAccountData, type FetchNestTokenPriceOptions, FulfillJuniorTrancheWithdrawBuilder, type FulfillJuniorTrancheWithdrawIxArgs, type FulfillJuniorTrancheWithdrawTxArgs, type FulfillSummary, type HoldingNavContribution, type HoldingUpdatePreview, IDL, IDLE_RESERVE_FLOOR_BPS, IDLE_RESERVE_TARGET_BPS, type IdleLiquidityOptions, type IdleLiquidityResult, IdleLiquidityService, type IdleLiquidityStatus, InitializeVaultRolesBuilder, type InitializeVaultRolesIxArgs, type InitializeVaultRolesTxArgs, type JuniorWithdrawalMode, JupiterBalanceSource, type JupiterBalanceSourceOptions, JupiterPriceSource, type JupiterPriceSourceOptions, JupiterSwapBuilder, type JupiterSwapIxArgs, type JupiterSwapTxArgs, KaminoPositionProvider, LIVE_ORACLE_VARIANTS, LIVE_PRICE_REFRESH_INTERVAL_SECS, LOCAL_PROTOCOL_ADMIN, LargeBalanceChangeError, type LargeBalanceChangeViolation, type LiveConsensusOracleDepsOptions, LivePriceSource, type LivePriceSourceOptions, MAX_BALANCE_CHANGE_BPS, MAX_CONSENSUS_SIGNERS, MAX_MANAGER_WITHDRAW_DESTINATIONS, MAX_PRICE_STALENESS_THRESHOLD_SECS, MIN_EXTERNAL_POSITION_SAMPLES, ManagerRedepositAssetBuilder, type ManagerRedepositAssetIxArgs, type ManagerRedepositAssetTxArgs, ManagerWithdrawAssetBuilder, type ManagerWithdrawAssetIxArgs, type ManagerWithdrawAssetTxArgs, MarginfiPositionProvider, type MintConfig, type MintIdentifier, type MintInfo, MintRegistry, type MintRegistryOptions, type MockYieldAccountConfig, MockYieldTracker, type MockYieldTrackerOptions, NEST_API_BASE_URL, NEST_RWA_SHARE_MINT, NEST_VAULT_SLUG, type NavAccountBalanceResponse, type NavAccountValueResponse, type NavCrankBlocker, type NavCrankBlockerReason, type NavCrankReadiness, type NavCrankResult, type NavPriceConfig, type NavYieldAccount, NestPriceSource, type NestPriceSourceOptions, ORACLE_ENTRIES_OFFSET, ORACLE_ENTRY_SIZE, ORACLE_SETTLED_NAV_TS_OFFSET, OracleService, PRICE_ORACLE_TYPES_BY_INDEX, PROGRAM_FEE_EXEMPT_OWNER_WHITELIST, PROTOCOL_ADMIN, PROTOCOL_FEE_RECIPIENT, PdaClient, type PreparedDirectTransaction, type PreparedSquadsTransaction, type PreparedVaultTransaction, type PriceOracleTypeArgs, type PriceSource, ProtocolInteractionBuilder, type ProtocolInteractionIxArgs, type ProtocolInteractionTxArgs, type QuoteFeeUnit, REPORTABLE_ORACLE_VARIANTS, type RefreshLiveOraclePricesParams, RemoveAssetHoldingBuilder, type RemoveAssetHoldingIxArgs, type RemoveAssetHoldingTxArgs, RequestJuniorTrancheWithdrawBuilder, type RequestJuniorTrancheWithdrawIxArgs, type RequestJuniorTrancheWithdrawTxArgs, type ResolvedSquadsWalletRoute, type RollingLimitConfig, type RollingRebalanceLimitConfig, type RunLiveConsensusOracleOptions, type RunOptions, type RunSummary, SHARE_DECIMALS, SYSTEM_PROGRAM, SetAssetPriceOracleBuilder, type SetAssetPriceOracleIxArgs, type SetAssetPriceOracleTxArgs, SetExternalLiquidityBuilder, type SetExternalLiquidityIxArgs, type SetExternalLiquidityTxArgs, SetManagerWithdrawDestinationBuilder, type SetManagerWithdrawDestinationIxArgs, type SetManagerWithdrawDestinationTxArgs, SetProtocolFeeBuilder, type SetProtocolFeeIxArgs, type SetProtocolFeeTxArgs, SetVaultConfigBuilder, type SetVaultConfigIxArgs, type SetVaultConfigTxArgs, type SettleVaultParams, type SettleVaultResult, type SettlementSimulation, type SettlementSimulationSnapshot, type SimulateDryRunSettlementParams, type SimulateSettlementArgs, type SimulatedShareClass, SquadsProposalExecutionSimulationError, type SquadsWalletRouteConfig, type StaleBalanceChangeBypass, StaticPositionProvider, TOKEN_PROGRAM, TOKEN_PROGRAM_ID, type TrackedAccountValue, type TrancheKindArgs, type TransactionBuilder, TransactionClient, USDC_MINT, USD_STAR_JUNIOR_MINT, USD_STAR_MINT, USD_STAR_PRINCIPAL_MINT, type UpdateAccountParams, UpdateAssetPriceBuilder, type UpdateAssetPriceIxArgs, type UpdateAssetPriceTxArgs, UpdateConsensusOracleBuilder, type UpdateConsensusOracleIxArgs, type UpdateConsensusOracleTxArgs, UpdateConsensusSignersBuilder, type UpdateConsensusSignersIxArgs, type UpdateConsensusSignersTxArgs, type UpdateDynamicAprParams, UpdateTrancheConfigBuilder, type UpdateTrancheConfigIxArgs, type UpdateTrancheConfigTxArgs, VAULT_CACHE_CATEGORY, VAULT_CREATOR_WHITELIST, VAULT_ENVIRONMENTS, VAULT_ORACLE_CACHE_CATEGORY, VAULT_PROGRAM_ID, VAULT_PROGRAM_IDS, VAULT_PROGRAM_PUBLIC_KEY, VAULT_ROLE_UPDATE_TIMELOCK_SECS, VAULT_TRANCHE_STATE_CACHE_CATEGORY, VAULT_TRANCHE_WITHDRAWAL_QUEUE_CACHE_CATEGORY, type Vault, type VaultAccountData, VaultBuilderBase, type VaultBuilderContext, type VaultCacheInvalidation, VaultClient, type VaultClientBundle, type VaultEnv, type VaultOracleAccountData, type VaultOracleResult, type VaultPricingInputs, type VaultQuote, type VaultQuoteArgs, VaultQuoteClient, type VaultQuoteDirection, type VaultQuoteShareClass, VaultReallocationBuilder, type VaultReallocationIxArgs, type VaultReallocationTxArgs, type VaultTrancheStateAccountData, type VaultTrancheWithdrawalQueueAccountData, type VaultTransactionPlan, type WalletBalanceSource, type WithdrawProtocolFeesIxArgs, type WithdrawProtocolFeesTxArgs, type WithdrawTrancheFeesIxArgs, type WithdrawTrancheFeesTxArgs, WithdrawalQueueService, type WithdrawalQueueSnapshot, type YieldAccount, type YieldAccountSnapshot, type YieldCalculationLog, type YieldCashflow, type YieldPaymentResponse, type YieldPaymentSnapshot, type YieldTracker, type YieldValuationModel, accountingUnitPriceToUsd, addCashflowUpdate, applyEffectiveApy, assertNoLargeBalanceChanges, assertNoUnconfirmedYieldPayments, buildHoldingUpdate, buildUpdates, coerceBool, collectSamples, confirmYieldPayment, createAccount, createLiveConsensusOracleDeps, createRpcFromConnection, createTokenMint, createTokenMintIxs, createVaultClient, createYieldPayment, dateToStr, defaultKeypairPath, deleteAccount, discoverVaultsForSigner, fetchExternalPositions, fetchNestTokenPrice, fetchReceiptMints, filterTargetHoldings, findLargeBalanceChanges, findSquadsWalletRoute, formatSettlementSimulation, fromUiAmount, gatherPricingInputs, getAccount, getAccounts, getAprYield, getBalance, getCashflows, getNavValue, getRpcUrl, getTotalOutstandingYield, getTotalTrackedValue, getTotalYield, getTrackedValue, getVaultProgramId, getYield, getYieldPayments, indexConfigByMint, isNavAccountBalance, isNavAccountValue, isNavYieldAccount, isVaultEnv, keypairAddress, loadKeypair, logProspectiveApy, makeProvider, mintTokensTo, mints, mostFrequent, parseExternalLiquidityRefs, planRebalance, prepareVaultTransaction, priceInAccountingUnit, readI64LE, readSplMintSupply, refreshLiveOraclePrices, resolveKeypairPath, resolveSquadsWalletRoute, resolveTrackedAmounts, roundToNextUtcMidnight, runLiveConsensusOracle, selectReportableHoldings, settleVault, signerInOracleData, simulateConsensusOracleSettlement, simulateDryRunSettlement, simulateSquadsProposalExecution, sumPositionsByMint, systemClock, toBigInt, toUiAmount, trackedValueFromResponse, updateAccount, updateDynamicApr, validateSquadsWalletRoutes, variantName, vaultAuthorityForWallet, withDiscoveredYieldAccounts };
package/dist/index.js CHANGED
@@ -3335,6 +3335,7 @@ __export(index_exports, {
3335
3335
  SetManagerWithdrawDestinationBuilder: () => SetManagerWithdrawDestinationBuilder,
3336
3336
  SetProtocolFeeBuilder: () => SetProtocolFeeBuilder,
3337
3337
  SetVaultConfigBuilder: () => SetVaultConfigBuilder,
3338
+ SquadsProposalExecutionSimulationError: () => SquadsProposalExecutionSimulationError,
3338
3339
  StaticPositionProvider: () => StaticPositionProvider,
3339
3340
  TOKEN_PROGRAM: () => TOKEN_PROGRAM,
3340
3341
  TOKEN_PROGRAM_ID: () => TOKEN_PROGRAM_ID,
@@ -3393,16 +3394,24 @@ __export(index_exports, {
3393
3394
  formatSettlementSimulation: () => formatSettlementSimulation,
3394
3395
  fromUiAmount: () => fromUiAmount,
3395
3396
  gatherPricingInputs: () => gatherPricingInputs,
3397
+ getAccount: () => getAccount,
3396
3398
  getAccounts: () => getAccounts,
3399
+ getAprYield: () => getAprYield,
3397
3400
  getBalance: () => getBalance,
3398
3401
  getCashflows: () => getCashflows,
3402
+ getNavValue: () => getNavValue,
3399
3403
  getRpcUrl: () => getRpcUrl,
3400
3404
  getTotalOutstandingYield: () => getTotalOutstandingYield,
3405
+ getTotalTrackedValue: () => getTotalTrackedValue,
3401
3406
  getTotalYield: () => getTotalYield,
3407
+ getTrackedValue: () => getTrackedValue,
3402
3408
  getVaultProgramId: () => getVaultProgramId,
3403
3409
  getYield: () => getYield,
3404
3410
  getYieldPayments: () => getYieldPayments,
3405
3411
  indexConfigByMint: () => indexConfigByMint,
3412
+ isNavAccountBalance: () => isNavAccountBalance,
3413
+ isNavAccountValue: () => isNavAccountValue,
3414
+ isNavYieldAccount: () => isNavYieldAccount,
3406
3415
  isVaultEnv: () => isVaultEnv,
3407
3416
  keypairAddress: () => keypairAddress,
3408
3417
  loadKeypair: () => loadKeypair,
@@ -3428,10 +3437,12 @@ __export(index_exports, {
3428
3437
  signerInOracleData: () => signerInOracleData,
3429
3438
  simulateConsensusOracleSettlement: () => simulateConsensusOracleSettlement,
3430
3439
  simulateDryRunSettlement: () => simulateDryRunSettlement,
3440
+ simulateSquadsProposalExecution: () => simulateSquadsProposalExecution,
3431
3441
  sumPositionsByMint: () => sumPositionsByMint,
3432
3442
  systemClock: () => systemClock,
3433
3443
  toBigInt: () => toBigInt2,
3434
3444
  toUiAmount: () => toUiAmount,
3445
+ trackedValueFromResponse: () => trackedValueFromResponse,
3435
3446
  updateAccount: () => updateAccount,
3436
3447
  updateDynamicApr: () => updateDynamicApr,
3437
3448
  validateSquadsWalletRoutes: () => validateSquadsWalletRoutes,
@@ -19990,6 +20001,22 @@ function makeProvider(connection, payer) {
19990
20001
  // src/utils/squads.ts
19991
20002
  var squads = __toESM(require("@sqds/multisig"));
19992
20003
  var import_web321 = require("@solana/web3.js");
20004
+ var SQUADS_SIMULATION_COMMITMENT = "processed";
20005
+ var SquadsProposalExecutionSimulationError = class extends Error {
20006
+ constructor(transactionError, logs, unitsConsumed) {
20007
+ const programLogs = logs.length > 0 ? `
20008
+ ${logs.join("\n")}` : "";
20009
+ super(
20010
+ `Squads proposal execution simulation failed: ${JSON.stringify(
20011
+ transactionError
20012
+ )}${programLogs}`
20013
+ );
20014
+ this.name = "SquadsProposalExecutionSimulationError";
20015
+ this.transactionError = transactionError;
20016
+ this.logs = [...logs];
20017
+ this.unitsConsumed = unitsConsumed;
20018
+ }
20019
+ };
19993
20020
  function validateVaultIndex(vaultIndex) {
19994
20021
  if (!Number.isSafeInteger(vaultIndex) || vaultIndex < 0) {
19995
20022
  throw new Error("Squads vaultIndex must be a non-negative safe integer");
@@ -20027,6 +20054,29 @@ function vaultAuthorityForWallet(wallet, routes) {
20027
20054
  const walletKey = typeof wallet === "string" ? new import_web321.PublicKey(wallet) : wallet;
20028
20055
  return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
20029
20056
  }
20057
+ async function simulateSquadsProposalExecution(args) {
20058
+ const { connection, feePayer, instructions: instructions2 } = args;
20059
+ const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
20060
+ const message2 = new import_web321.TransactionMessage({
20061
+ payerKey: feePayer,
20062
+ recentBlockhash,
20063
+ instructions: [...instructions2]
20064
+ }).compileToV0Message();
20065
+ const transaction = new import_web321.VersionedTransaction(message2);
20066
+ const { value } = await connection.simulateTransaction(transaction, {
20067
+ sigVerify: false,
20068
+ commitment: SQUADS_SIMULATION_COMMITMENT,
20069
+ innerInstructions: true
20070
+ });
20071
+ if (value.err) {
20072
+ throw new SquadsProposalExecutionSimulationError(
20073
+ value.err,
20074
+ value.logs ?? [],
20075
+ value.unitsConsumed
20076
+ );
20077
+ }
20078
+ return value;
20079
+ }
20030
20080
  async function prepareVaultTransaction(args) {
20031
20081
  const { connection, proposer, instructions: instructions2 } = args;
20032
20082
  const route = findSquadsWalletRoute(proposer, args.squadsRoutes ?? []);
@@ -20059,6 +20109,12 @@ async function prepareVaultTransaction(args) {
20059
20109
  }
20060
20110
  const transactionIndex = BigInt(multisig.transactionIndex.toString()) + 1n;
20061
20111
  const { blockhash } = await connection.getLatestBlockhash("confirmed");
20112
+ await simulateSquadsProposalExecution({
20113
+ connection,
20114
+ feePayer: proposer,
20115
+ instructions: instructions2,
20116
+ recentBlockhash: blockhash
20117
+ });
20062
20118
  const transactionMessage = new import_web321.TransactionMessage({
20063
20119
  payerKey: route.vaultPda,
20064
20120
  recentBlockhash: blockhash,
@@ -20259,33 +20315,60 @@ function getAdminSecret(adminSecret) {
20259
20315
  }
20260
20316
  return secret;
20261
20317
  }
20318
+ function isNavYieldAccount(account) {
20319
+ return account.valuation_model === "nav";
20320
+ }
20262
20321
  async function createAccount(params) {
20263
- if (params.type === "dynamic" && params.apr === void 0) {
20322
+ const valuationModel = params.valuationModel ?? "apr";
20323
+ if (valuationModel === "nav" && !params.navConfig) {
20324
+ throw new Error("navConfig is required when creating a NAV account");
20325
+ }
20326
+ if (valuationModel === "nav" && params.apr !== void 0) {
20327
+ throw new Error("NAV accounts cannot define apr");
20328
+ }
20329
+ if (valuationModel === "apr" && params.type === "dynamic" && params.apr === void 0) {
20264
20330
  throw new Error("apr is required when creating a dynamic yield account");
20265
20331
  }
20266
20332
  if (params.apr !== void 0) {
20267
20333
  assertValidApr(params.apr);
20268
20334
  }
20269
- return await yieldApiReq(
20270
- "accounts/new",
20271
- "POST",
20272
- {
20273
- name: params.name,
20274
- type: params.type,
20275
- apr: params.apr,
20276
- tag: params.tag,
20277
- password: params.password,
20278
- description: params.description
20279
- },
20280
- {
20281
- adminSecret: getAdminSecret(params.adminSecret)
20282
- }
20335
+ return unwrapData(
20336
+ await yieldApiReq(
20337
+ "accounts/new",
20338
+ "POST",
20339
+ {
20340
+ name: params.name,
20341
+ type: params.type,
20342
+ apr: params.apr,
20343
+ valuation_model: valuationModel,
20344
+ nav_config: params.navConfig,
20345
+ tag: params.tag,
20346
+ password: params.password,
20347
+ description: params.description
20348
+ },
20349
+ {
20350
+ adminSecret: getAdminSecret(params.adminSecret)
20351
+ }
20352
+ )
20283
20353
  );
20284
20354
  }
20285
20355
  async function getAccounts() {
20286
20356
  return unwrapData(await yieldApiReq("accounts", "GET"));
20287
20357
  }
20358
+ async function getAccount(accountName) {
20359
+ return unwrapData(
20360
+ await yieldApiReq(accountEndpoint(accountName), "GET")
20361
+ );
20362
+ }
20288
20363
  async function updateAccount(params) {
20364
+ if (params.valuationModel === "nav") {
20365
+ if (!params.navConfig) {
20366
+ throw new Error("navConfig is required when switching to a NAV account");
20367
+ }
20368
+ if (params.apr !== void 0) {
20369
+ throw new Error("NAV accounts cannot define apr");
20370
+ }
20371
+ }
20289
20372
  if (params.apr !== void 0) {
20290
20373
  assertValidApr(params.apr);
20291
20374
  }
@@ -20306,7 +20389,9 @@ async function updateAccount(params) {
20306
20389
  type: params.type,
20307
20390
  apr: params.apr,
20308
20391
  tag: params.tag,
20309
- description: params.description
20392
+ description: params.description,
20393
+ valuation_model: params.valuationModel,
20394
+ nav_config: params.navConfig
20310
20395
  },
20311
20396
  auth.options
20312
20397
  )
@@ -20346,28 +20431,51 @@ async function updateDynamicApr(params) {
20346
20431
  );
20347
20432
  }
20348
20433
  async function addCashflowUpdate(params) {
20349
- if (params.fundingNextDay) {
20350
- params.date = roundToNextUtcMidnight(params.date);
20351
- }
20352
- return await yieldApiReq(
20353
- accountEndpoint(params.accountName, "cashflows"),
20354
- "POST",
20355
- {
20356
- amount: params.cashflowType === "deposit" ? params.amount : params.amount * -1,
20357
- timestamp: params.date ? dateToStr(params.date) : void 0,
20358
- description: params.description,
20359
- password: params.password
20434
+ const runtimeParams = params;
20435
+ if (params.valuationModel === "nav") {
20436
+ if (runtimeParams.date !== void 0 || runtimeParams.fundingNextDay !== void 0) {
20437
+ throw new Error(
20438
+ "NAV cashflows execute immediately and cannot specify date or fundingNextDay"
20439
+ );
20440
+ }
20441
+ if (!Number.isSafeInteger(params.amount)) {
20442
+ throw new Error(
20443
+ "NAV cashflow amount must be an integer number of base units"
20444
+ );
20360
20445
  }
20446
+ }
20447
+ const effectiveDate = params.valuationModel === "nav" ? void 0 : params.fundingNextDay ? roundToNextUtcMidnight(params.date ?? /* @__PURE__ */ new Date()) : params.date;
20448
+ return unwrapData(
20449
+ await yieldApiReq(
20450
+ accountEndpoint(params.accountName, "cashflows"),
20451
+ "POST",
20452
+ {
20453
+ amount: params.cashflowType === "deposit" ? Math.abs(params.amount) : -Math.abs(params.amount),
20454
+ timestamp: params.valuationModel === "nav" || !effectiveDate ? void 0 : dateToStr(effectiveDate),
20455
+ description: params.description,
20456
+ password: params.password
20457
+ }
20458
+ )
20361
20459
  );
20362
20460
  }
20363
20461
  async function getCashflows(accountName) {
20364
- return (await yieldApiReq(accountEndpoint(accountName, "cashflows"), "GET")).data;
20462
+ return unwrapData(
20463
+ await yieldApiReq(accountEndpoint(accountName, "cashflows"), "GET")
20464
+ );
20465
+ }
20466
+ function isNavAccountBalance(response) {
20467
+ return response.valuation_model === "nav";
20365
20468
  }
20366
20469
  async function getBalance(accountName, atTime) {
20367
- return (await yieldApiReq(
20368
- accountEndpoint(accountName, "balance") + (atTime ? `?as_of=${dateToStr(atTime)}` : ""),
20369
- "GET"
20370
- )).data;
20470
+ return unwrapData(
20471
+ await yieldApiReq(
20472
+ accountEndpoint(accountName, "balance") + (atTime ? `?as_of=${dateToStr(atTime)}` : ""),
20473
+ "GET"
20474
+ )
20475
+ );
20476
+ }
20477
+ function isNavAccountValue(response) {
20478
+ return response.valuation_model === "nav";
20371
20479
  }
20372
20480
  async function createYieldPayment(params) {
20373
20481
  return unwrapData(
@@ -20404,15 +20512,63 @@ async function getYieldPayments(accountName) {
20404
20512
  );
20405
20513
  }
20406
20514
  async function getYield(accountName, start, end) {
20407
- return (await yieldApiReq(
20408
- accountEndpoint(accountName, "yield") + (start ? `?start=${dateToStr(start)}` : "") + (start && end ? `&end=${dateToStr(end)}` : end ? `?end=${dateToStr(end)}` : ""),
20409
- "GET"
20410
- )).data;
20515
+ return unwrapData(
20516
+ await yieldApiReq(
20517
+ accountEndpoint(accountName, "yield") + (start ? `?start=${dateToStr(start)}` : "") + (start && end ? `&end=${dateToStr(end)}` : end ? `?end=${dateToStr(end)}` : ""),
20518
+ "GET"
20519
+ )
20520
+ );
20521
+ }
20522
+ async function getAprYield(accountName, start, end) {
20523
+ const response = await getYield(accountName, start, end);
20524
+ if (isNavAccountValue(response)) {
20525
+ throw new Error(`Account "${accountName}" uses NAV valuation, not APR`);
20526
+ }
20527
+ return response;
20528
+ }
20529
+ async function getNavValue(accountName) {
20530
+ const response = await getYield(accountName);
20531
+ if (!isNavAccountValue(response)) {
20532
+ throw new Error(`Account "${accountName}" uses APR valuation, not NAV`);
20533
+ }
20534
+ return response;
20535
+ }
20536
+ function trackedValueFromResponse(response) {
20537
+ if (isNavAccountValue(response)) {
20538
+ const totalValue2 = Number(response.total_nav);
20539
+ if (!Number.isFinite(totalValue2) || totalValue2 < 0) {
20540
+ throw new Error("NAV account returned an invalid total_nav");
20541
+ }
20542
+ return {
20543
+ totalValue: totalValue2,
20544
+ principal: 0,
20545
+ outstandingYield: 0,
20546
+ valuationModel: "nav"
20547
+ };
20548
+ }
20549
+ const totalValue = response.principal_at_end + response.outstanding_yield;
20550
+ if (!Number.isFinite(totalValue)) {
20551
+ throw new Error("APR account returned an invalid tracked value");
20552
+ }
20553
+ return {
20554
+ totalValue,
20555
+ principal: response.principal_at_end,
20556
+ outstandingYield: response.outstanding_yield,
20557
+ valuationModel: "apr"
20558
+ };
20559
+ }
20560
+ async function getTrackedValue(accountName) {
20561
+ return trackedValueFromResponse(await getYield(accountName));
20411
20562
  }
20412
20563
  async function getTotalYield(accountNames, start, end) {
20413
20564
  let totalYield = new import_core20.BN(0);
20414
20565
  for (const accountName of accountNames) {
20415
20566
  const res = await getYield(accountName, start, end);
20567
+ if (isNavAccountValue(res)) {
20568
+ throw new Error(
20569
+ `NAV account "${accountName}" does not report accrued yield`
20570
+ );
20571
+ }
20416
20572
  console.log(res);
20417
20573
  totalYield = totalYield.add(new import_core20.BN(res.total_yield));
20418
20574
  }
@@ -20422,10 +20578,28 @@ async function getTotalOutstandingYield(accountNames, start, end) {
20422
20578
  let total = 0;
20423
20579
  for (const accountName of accountNames) {
20424
20580
  const response = await getYield(accountName, start, end);
20581
+ if (isNavAccountValue(response)) {
20582
+ throw new Error(
20583
+ `NAV account "${accountName}" does not report outstanding yield`
20584
+ );
20585
+ }
20425
20586
  total += response.outstanding_yield;
20426
20587
  }
20427
20588
  return total;
20428
20589
  }
20590
+ async function getTotalTrackedValue(accountNames, start, end) {
20591
+ let totalValue = 0;
20592
+ let principal = 0;
20593
+ let outstandingYield = 0;
20594
+ for (const accountName of accountNames) {
20595
+ const response = await getYield(accountName, start, end);
20596
+ const tracked = trackedValueFromResponse(response);
20597
+ totalValue += tracked.totalValue;
20598
+ principal += tracked.principal;
20599
+ outstandingYield += tracked.outstandingYield;
20600
+ }
20601
+ return { totalValue, principal, outstandingYield };
20602
+ }
20429
20603
 
20430
20604
  // src/services/withdrawalQueueService.ts
20431
20605
  var import_common40 = __toESM(require_dist());
@@ -20987,6 +21161,7 @@ function evaluateBalanceChanges(vaultState, updates, thresholdBps, nowSecs) {
20987
21161
  walletAmount: update.walletAmount,
20988
21162
  lpAmount: update.lpAmount,
20989
21163
  trackedPrincipalAmount: update.trackedPrincipalAmount,
21164
+ trackedValueAmount: update.trackedValueAmount,
20990
21165
  yieldAmount: update.yieldAmount
20991
21166
  };
20992
21167
  const lastUpdateTs = toBigInt2(holding.lastUpdateTs);
@@ -21051,6 +21226,9 @@ function assertNoLargeBalanceChanges(vault, vaultState, updates, nowSecs, log =
21051
21226
  )} lp=${formatTokenAmount(
21052
21227
  violation.lpAmount,
21053
21228
  violation.decimals
21229
+ )} tracked=${formatTokenAmount(
21230
+ violation.trackedValueAmount,
21231
+ violation.decimals
21054
21232
  )} principal=${formatTokenAmount(
21055
21233
  violation.trackedPrincipalAmount,
21056
21234
  violation.decimals
@@ -22202,7 +22380,7 @@ async function buildHoldingUpdate(yieldTracker, entry, inputs) {
22202
22380
  }
22203
22381
  const walletAmount = inputs.walletBalances[mintKey] ?? 0n;
22204
22382
  const lpAmount = inputs.lpByMint.get(mintKey) ?? 0n;
22205
- const { principalAmount, yieldAmount } = await resolveTrackedAmounts(
22383
+ const { trackedValueAmount, principalAmount, yieldAmount } = await resolveTrackedAmounts(
22206
22384
  yieldTracker,
22207
22385
  inputs.configByMint.get(mintKey),
22208
22386
  holding.decimals
@@ -22217,17 +22395,36 @@ async function buildHoldingUpdate(yieldTracker, entry, inputs) {
22217
22395
  lpAmount,
22218
22396
  yieldAmount,
22219
22397
  trackedPrincipalAmount: principalAmount,
22220
- externalAmount: walletAmount + lpAmount + principalAmount + yieldAmount
22398
+ trackedValueAmount,
22399
+ externalAmount: walletAmount + lpAmount + trackedValueAmount
22221
22400
  };
22222
22401
  }
22223
22402
  async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
22224
22403
  if (!yieldTracker || !cfg?.yieldAccountNames?.length) {
22225
- return { principalAmount: 0n, yieldAmount: 0n };
22404
+ return {
22405
+ trackedValueAmount: 0n,
22406
+ principalAmount: 0n,
22407
+ yieldAmount: 0n
22408
+ };
22409
+ }
22410
+ let tracked;
22411
+ if (yieldTracker.getTotalTrackedValue) {
22412
+ tracked = await yieldTracker.getTotalTrackedValue(cfg.yieldAccountNames);
22413
+ } else if (yieldTracker.getTotalTrackedAmounts) {
22414
+ const legacy = await yieldTracker.getTotalTrackedAmounts(
22415
+ cfg.yieldAccountNames
22416
+ );
22417
+ tracked = {
22418
+ totalValue: legacy.principal + legacy.outstandingYield,
22419
+ ...legacy
22420
+ };
22421
+ } else {
22422
+ throw new Error(
22423
+ "yield tracker does not implement getTotalTrackedValue or its legacy fallback"
22424
+ );
22226
22425
  }
22227
- const tracked = await yieldTracker.getTotalTrackedAmounts(
22228
- cfg.yieldAccountNames
22229
- );
22230
22426
  return {
22427
+ trackedValueAmount: tracked.totalValue > 0 ? (0, import_common44.fromUiAmount)(tracked.totalValue, decimals) : 0n,
22231
22428
  principalAmount: tracked.principal > 0 ? (0, import_common44.fromUiAmount)(tracked.principal, decimals) : 0n,
22232
22429
  yieldAmount: tracked.outstandingYield > 0 ? (0, import_common44.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
22233
22430
  };
@@ -22506,7 +22703,7 @@ async function settleVault2({
22506
22703
  log(`vault ${vault}: submitting ${updates.length} consensus asset update(s)`);
22507
22704
  for (const update of updates) {
22508
22705
  log(
22509
- ` holding #${update.holdingIndex} ${update.mint}: price=${update.price} external_amount=${update.externalAmount} [wallet=${update.walletAmount} lp=${update.lpAmount} principal=${update.trackedPrincipalAmount} yield=${update.yieldAmount}]`
22706
+ ` holding #${update.holdingIndex} ${update.mint}: price=${update.price} external_amount=${update.externalAmount} [wallet=${update.walletAmount} lp=${update.lpAmount} tracked=${update.trackedValueAmount} principal=${update.trackedPrincipalAmount} yield=${update.yieldAmount}]`
22510
22707
  );
22511
22708
  }
22512
22709
  await logProspectiveApy({
@@ -22943,7 +23140,7 @@ var MockYieldTracker = class {
22943
23140
  }
22944
23141
  return total;
22945
23142
  }
22946
- async getTotalTrackedAmounts(accountNames, start, end) {
23143
+ async getTotalTrackedValue(accountNames, start, end) {
22947
23144
  let principal = 0;
22948
23145
  let outstandingYield = 0;
22949
23146
  for (const name of accountNames) {
@@ -22951,7 +23148,19 @@ var MockYieldTracker = class {
22951
23148
  principal += snapshot2.principalAtEnd;
22952
23149
  outstandingYield += snapshot2.outstandingYield;
22953
23150
  }
22954
- return { principal, outstandingYield };
23151
+ return {
23152
+ totalValue: principal + outstandingYield,
23153
+ principal,
23154
+ outstandingYield
23155
+ };
23156
+ }
23157
+ /** Backward-compatible APR-only breakdown. */
23158
+ async getTotalTrackedAmounts(accountNames, start, end) {
23159
+ const tracked = await this.getTotalTrackedValue(accountNames, start, end);
23160
+ return {
23161
+ principal: tracked.principal,
23162
+ outstandingYield: tracked.outstandingYield
23163
+ };
22955
23164
  }
22956
23165
  async getBalance(accountName, atTime) {
22957
23166
  const snapshot2 = await this.getYield(accountName, void 0, atTime);
@@ -23041,17 +23250,12 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
23041
23250
  const raw = await getTotalOutstandingYield(accountNames, start, end);
23042
23251
  return raw / 10 ** YIELD_TRACKER_DECIMALS;
23043
23252
  },
23044
- async getTotalTrackedAmounts(accountNames, start, end) {
23045
- let principal = 0;
23046
- let outstandingYield = 0;
23047
- for (const accountName of accountNames) {
23048
- const snapshot2 = await getYield(accountName, start, end);
23049
- principal += snapshot2.principal_at_end;
23050
- outstandingYield += snapshot2.outstanding_yield;
23051
- }
23253
+ async getTotalTrackedValue(accountNames, start, end) {
23254
+ const tracked = await getTotalTrackedValue(accountNames, start, end);
23052
23255
  return {
23053
- principal: principal / 10 ** YIELD_TRACKER_DECIMALS,
23054
- outstandingYield: outstandingYield / 10 ** YIELD_TRACKER_DECIMALS
23256
+ totalValue: tracked.totalValue / 10 ** YIELD_TRACKER_DECIMALS,
23257
+ principal: tracked.principal / 10 ** YIELD_TRACKER_DECIMALS,
23258
+ outstandingYield: tracked.outstandingYield / 10 ** YIELD_TRACKER_DECIMALS
23055
23259
  };
23056
23260
  },
23057
23261
  getYieldPayments
@@ -24082,6 +24286,7 @@ var import_common53 = __toESM(require_dist());
24082
24286
  SetManagerWithdrawDestinationBuilder,
24083
24287
  SetProtocolFeeBuilder,
24084
24288
  SetVaultConfigBuilder,
24289
+ SquadsProposalExecutionSimulationError,
24085
24290
  StaticPositionProvider,
24086
24291
  TOKEN_PROGRAM,
24087
24292
  TOKEN_PROGRAM_ID,
@@ -24140,16 +24345,24 @@ var import_common53 = __toESM(require_dist());
24140
24345
  formatSettlementSimulation,
24141
24346
  fromUiAmount,
24142
24347
  gatherPricingInputs,
24348
+ getAccount,
24143
24349
  getAccounts,
24350
+ getAprYield,
24144
24351
  getBalance,
24145
24352
  getCashflows,
24353
+ getNavValue,
24146
24354
  getRpcUrl,
24147
24355
  getTotalOutstandingYield,
24356
+ getTotalTrackedValue,
24148
24357
  getTotalYield,
24358
+ getTrackedValue,
24149
24359
  getVaultProgramId,
24150
24360
  getYield,
24151
24361
  getYieldPayments,
24152
24362
  indexConfigByMint,
24363
+ isNavAccountBalance,
24364
+ isNavAccountValue,
24365
+ isNavYieldAccount,
24153
24366
  isVaultEnv,
24154
24367
  keypairAddress,
24155
24368
  loadKeypair,
@@ -24175,10 +24388,12 @@ var import_common53 = __toESM(require_dist());
24175
24388
  signerInOracleData,
24176
24389
  simulateConsensusOracleSettlement,
24177
24390
  simulateDryRunSettlement,
24391
+ simulateSquadsProposalExecution,
24178
24392
  sumPositionsByMint,
24179
24393
  systemClock,
24180
24394
  toBigInt,
24181
24395
  toUiAmount,
24396
+ trackedValueFromResponse,
24182
24397
  updateAccount,
24183
24398
  updateDynamicApr,
24184
24399
  validateSquadsWalletRoutes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perena/vault-sdk",
3
- "version": "1.0.34",
3
+ "version": "1.0.37",
4
4
  "description": "Vault program helpers for Bankineco integrations.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",