@perena/vault-sdk 1.0.33 → 1.0.36

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
package/dist/index.d.ts CHANGED
@@ -11763,6 +11763,16 @@ type Bankineco = {
11763
11763
  ];
11764
11764
  type: "pubkey";
11765
11765
  },
11766
+ {
11767
+ name: "consensusSigners";
11768
+ docs: [
11769
+ "Initial consensus-oracle signer set. When provided, it must contain",
11770
+ "between two and four distinct, non-default addresses."
11771
+ ];
11772
+ type: {
11773
+ vec: "pubkey";
11774
+ };
11775
+ },
11766
11776
  {
11767
11777
  name: "forMigration";
11768
11778
  docs: [
@@ -13494,6 +13504,7 @@ interface CreateVaultParams {
13494
13504
  basePriceOracleType: number;
13495
13505
  basePrice: BN;
13496
13506
  basePriceOracleAccount: Address;
13507
+ consensusSigners: Address[];
13497
13508
  forMigration: boolean;
13498
13509
  }
13499
13510
  interface CreateVaultIxArgs {
@@ -13527,6 +13538,8 @@ interface CreateVaultTxArgs {
13527
13538
  basePrice?: bigint;
13528
13539
  /** Price-source account when basePriceOracleType is Pyth/PerenaVault. */
13529
13540
  basePriceOracleAccount?: Address;
13541
+ /** Initial consensus-oracle signer set. Must contain 2–4 distinct addresses when provided. */
13542
+ consensusSigners?: Address[];
13530
13543
  assetTokenProgram?: Address;
13531
13544
  /** Use legacy bank mint as share mint; defer mint-authority transfer. */
13532
13545
  forMigration?: boolean;
@@ -15148,29 +15161,73 @@ interface BasicAuthCredentials {
15148
15161
  }
15149
15162
  declare function dateToStr(date: Date): string;
15150
15163
  declare function roundToNextUtcMidnight(date: Date): Date;
15164
+ type YieldValuationModel = "apr" | "nav";
15165
+ interface NavPriceConfig {
15166
+ url: string;
15167
+ price_path: string;
15168
+ }
15169
+ interface YieldCashflow {
15170
+ id: string;
15171
+ account_name: string;
15172
+ /** Signed USDC amount in tracker base units. */
15173
+ amount: number;
15174
+ /** Present for NAV accounts: exact signed shares derived at submission. */
15175
+ share_amount?: string;
15176
+ nav_price?: string;
15177
+ nav_fetched_at?: Date;
15178
+ timestamp: Date;
15179
+ description?: string | null;
15180
+ created_at: Date;
15181
+ }
15151
15182
  interface YieldAccount {
15152
15183
  name: string;
15153
15184
  tag: string | null;
15154
15185
  type: string;
15155
- apy: number | null;
15186
+ /** `apr` is returned by single-account/create/update endpoints. */
15187
+ apr?: number | null;
15188
+ /** `apy` is the legacy list-endpoint name for the same APR value. */
15189
+ apy?: number | null;
15190
+ valuation_model?: YieldValuationModel;
15191
+ nav_config?: NavPriceConfig | null;
15156
15192
  description?: string | null;
15193
+ created_at?: Date;
15194
+ updated_at?: Date;
15195
+ cashflows?: YieldCashflow[];
15157
15196
  }
15197
+ interface NavYieldAccount extends YieldAccount {
15198
+ valuation_model: "nav";
15199
+ nav_config: NavPriceConfig;
15200
+ apr?: null;
15201
+ apy?: null;
15202
+ }
15203
+ declare function isNavYieldAccount(account: YieldAccount): account is NavYieldAccount;
15158
15204
  interface CreateAccountBaseParams {
15159
15205
  name: string;
15160
15206
  password: string;
15161
15207
  adminSecret?: string;
15162
- tag?: string;
15208
+ /** Vault address used by consensus-oracle account discovery. */
15209
+ tag: string;
15163
15210
  description?: string;
15164
15211
  }
15165
- type CreateAccountParams<TType extends string = string> = CreateAccountBaseParams & {
15212
+ type AprCreateAccountParams<TType extends string> = CreateAccountBaseParams & {
15166
15213
  type: TType;
15214
+ valuationModel?: "apr";
15215
+ navConfig?: never;
15167
15216
  } & (TType extends "dynamic" ? {
15168
15217
  apr: number;
15169
15218
  } : {
15170
15219
  apr?: number;
15171
15220
  });
15172
- declare function createAccount<TType extends string>(params: CreateAccountParams<TType>): Promise<any>;
15221
+ type NavCreateAccountParams<TType extends string> = CreateAccountBaseParams & {
15222
+ type: TType;
15223
+ valuationModel: "nav";
15224
+ navConfig: NavPriceConfig;
15225
+ apr?: never;
15226
+ };
15227
+ type CreateAccountParams<TType extends string = string> = AprCreateAccountParams<TType> | NavCreateAccountParams<TType>;
15228
+ declare function createAccount<TType extends string>(params: CreateAccountParams<TType>): Promise<YieldAccount>;
15173
15229
  declare function getAccounts(): Promise<YieldAccount[]>;
15230
+ declare function getAccount(accountName: string): Promise<YieldAccount>;
15174
15231
  interface UpdateAccountParams {
15175
15232
  accountName: string;
15176
15233
  password: string;
@@ -15179,6 +15236,8 @@ interface UpdateAccountParams {
15179
15236
  apr?: number;
15180
15237
  tag?: string | null;
15181
15238
  description?: string | null;
15239
+ valuationModel?: YieldValuationModel;
15240
+ navConfig?: NavPriceConfig;
15182
15241
  }
15183
15242
  declare function updateAccount(params: UpdateAccountParams): Promise<YieldAccount>;
15184
15243
  interface DeleteAccountParams {
@@ -15194,24 +15253,45 @@ interface UpdateDynamicAprParams {
15194
15253
  password: string;
15195
15254
  }
15196
15255
  declare function updateDynamicApr(params: UpdateDynamicAprParams): Promise<any>;
15197
- interface AddCashflowUpdateParams {
15256
+ interface AddCashflowUpdateBaseParams {
15198
15257
  accountName: string;
15199
15258
  amount: number;
15200
- date: Date;
15201
15259
  description?: string;
15202
15260
  password: string;
15203
15261
  cashflowType: "deposit" | "withdraw";
15262
+ }
15263
+ interface AddNavCashflowUpdateParams extends AddCashflowUpdateBaseParams {
15264
+ /** NAV cashflows always execute immediately at the fetched price. */
15265
+ valuationModel: "nav";
15266
+ }
15267
+ interface AddAprCashflowUpdateParams extends AddCashflowUpdateBaseParams {
15268
+ valuationModel?: "apr";
15269
+ date?: Date;
15204
15270
  fundingNextDay?: boolean;
15205
15271
  }
15206
- declare function addCashflowUpdate(params: AddCashflowUpdateParams): Promise<any>;
15207
- declare function getCashflows(accountName: string): Promise<any>;
15208
- interface AccountBalanceResponse {
15272
+ type AddCashflowUpdateParams = AddNavCashflowUpdateParams | AddAprCashflowUpdateParams;
15273
+ declare function addCashflowUpdate(params: AddCashflowUpdateParams): Promise<YieldCashflow>;
15274
+ declare function getCashflows(accountName: string): Promise<YieldCashflow[]>;
15275
+ interface AprAccountBalanceResponse {
15209
15276
  account_name: string;
15210
15277
  account_type: string;
15278
+ valuation_model?: "apr";
15211
15279
  apr: number;
15212
15280
  balance: number;
15213
15281
  as_of: Date;
15214
15282
  }
15283
+ interface NavAccountBalanceResponse {
15284
+ account_name: string;
15285
+ account_type: string;
15286
+ valuation_model: "nav";
15287
+ total_nav: string;
15288
+ shares: string;
15289
+ nav_price: string;
15290
+ nav_fetched_at: Date;
15291
+ as_of: Date;
15292
+ }
15293
+ type AccountBalanceResponse = AprAccountBalanceResponse | NavAccountBalanceResponse;
15294
+ declare function isNavAccountBalance(response: AccountBalanceResponse): response is NavAccountBalanceResponse;
15215
15295
  declare function getBalance(accountName: string, atTime?: Date): Promise<AccountBalanceResponse>;
15216
15296
  interface YieldCalculationLog {
15217
15297
  segment_number: number;
@@ -15224,7 +15304,8 @@ interface YieldCalculationLog {
15224
15304
  cumulative_yield: number;
15225
15305
  calculation_formula: string;
15226
15306
  }
15227
- interface AccountYieldResponse {
15307
+ interface AprAccountYieldResponse {
15308
+ valuation_model?: "apr";
15228
15309
  account: {
15229
15310
  name: string;
15230
15311
  type: string;
@@ -15243,6 +15324,16 @@ interface AccountYieldResponse {
15243
15324
  apr_used: number;
15244
15325
  calculation_log: YieldCalculationLog[];
15245
15326
  }
15327
+ interface NavAccountValueResponse {
15328
+ account: AprAccountYieldResponse["account"];
15329
+ valuation_model: "nav";
15330
+ total_nav: string;
15331
+ shares: string;
15332
+ nav_price: string;
15333
+ nav_fetched_at: Date;
15334
+ }
15335
+ type AccountYieldResponse = AprAccountYieldResponse | NavAccountValueResponse;
15336
+ declare function isNavAccountValue(response: AccountYieldResponse): response is NavAccountValueResponse;
15246
15337
  interface CreateYieldPaymentParams {
15247
15338
  accountName: string;
15248
15339
  amount: number;
@@ -15270,9 +15361,26 @@ declare function confirmYieldPayment(params: {
15270
15361
  }): Promise<YieldPaymentResponse>;
15271
15362
  declare function getYieldPayments(accountName: string): Promise<YieldPaymentResponse[]>;
15272
15363
  declare function getYield(accountName: string, start?: Date, end?: Date): Promise<AccountYieldResponse>;
15364
+ declare function getAprYield(accountName: string, start?: Date, end?: Date): Promise<AprAccountYieldResponse>;
15365
+ declare function getNavValue(accountName: string): Promise<NavAccountValueResponse>;
15366
+ interface TrackedAccountValue {
15367
+ totalValue: number;
15368
+ principal: number;
15369
+ outstandingYield: number;
15370
+ valuationModel: YieldValuationModel;
15371
+ }
15372
+ /** Normalize either yield-tracker response model into one current base-unit value. */
15373
+ declare function trackedValueFromResponse(response: AccountYieldResponse): TrackedAccountValue;
15374
+ declare function getTrackedValue(accountName: string): Promise<TrackedAccountValue>;
15273
15375
  declare function getTotalYield(accountNames: string[], start?: Date, end?: Date): Promise<BN>;
15274
15376
  /** Sum only confirmed-payment-adjusted yield that remains receivable. */
15275
15377
  declare function getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
15378
+ /** Sum the complete current value of APR and NAV accounts in tracker base units. */
15379
+ declare function getTotalTrackedValue(accountNames: string[], start?: Date, end?: Date): Promise<{
15380
+ totalValue: number;
15381
+ principal: number;
15382
+ outstandingYield: number;
15383
+ }>;
15276
15384
 
15277
15385
  /**
15278
15386
  * Junior-tranche withdrawal-queue fulfillment.
@@ -15531,13 +15639,21 @@ interface YieldTracker {
15531
15639
  getAccountNamesForVault?(vault: Address): Promise<string[]>;
15532
15640
  /** All payments for an account, including payments not yet confirmed. */
15533
15641
  getYieldPayments(accountName: string): Promise<YieldPaymentSnapshot[]>;
15534
- /** Sum of oracle-safe outstanding yield across the named accounts. */
15642
+ /** Sum of oracle-safe outstanding yield across APR accounts. */
15535
15643
  getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
15536
15644
  /**
15537
- * Sum the external principal and confirmed-payment-adjusted outstanding yield
15538
- * across the named accounts. Both values are UI token amounts.
15645
+ * Sum complete current account value across APR and NAV accounts. APR
15646
+ * diagnostics remain separate; NAV accounts contribute only to totalValue.
15647
+ * All values are UI token amounts.
15539
15648
  */
15540
- getTotalTrackedAmounts(accountNames: string[], start?: Date, end?: Date): Promise<{
15649
+ getTotalTrackedValue?(accountNames: string[], start?: Date, end?: Date): Promise<{
15650
+ totalValue: number;
15651
+ /** APR-account diagnostics; NAV accounts contribute zero here. */
15652
+ principal: number;
15653
+ outstandingYield: number;
15654
+ }>;
15655
+ /** @deprecated APR-only compatibility surface; use getTotalTrackedValue. */
15656
+ getTotalTrackedAmounts?(accountNames: string[], start?: Date, end?: Date): Promise<{
15541
15657
  principal: number;
15542
15658
  outstandingYield: number;
15543
15659
  }>;
@@ -15595,7 +15711,9 @@ interface HoldingUpdatePreview {
15595
15711
  yieldAmount: bigint;
15596
15712
  /** Yield-tracker principal attributed to this holding (base units). */
15597
15713
  trackedPrincipalAmount: bigint;
15598
- /** Total external balance pushed = wallet + LP + tracked principal + yield. */
15714
+ /** Complete tracked value, including NAV accounts (base units). */
15715
+ trackedValueAmount: bigint;
15716
+ /** Total external balance pushed = wallet + LP + complete tracked value. */
15599
15717
  externalAmount: bigint;
15600
15718
  }
15601
15719
  interface VaultOracleResult {
@@ -15892,6 +16010,7 @@ interface LargeBalanceChangeViolation {
15892
16010
  walletAmount: bigint;
15893
16011
  lpAmount: bigint;
15894
16012
  trackedPrincipalAmount: bigint;
16013
+ trackedValueAmount: bigint;
15895
16014
  yieldAmount: bigint;
15896
16015
  }
15897
16016
  interface StaleBalanceChangeBypass extends LargeBalanceChangeViolation {
@@ -15926,8 +16045,9 @@ declare function simulateDryRunSettlement({ client, signer, vault, vaultState, u
15926
16045
 
15927
16046
  declare function buildUpdates(yieldTracker: YieldTracker | undefined, reportableHoldings: ConsensusHoldingEntry[], inputs: VaultPricingInputs): Promise<HoldingUpdatePreview[]>;
15928
16047
  declare function buildHoldingUpdate(yieldTracker: YieldTracker | undefined, entry: ConsensusHoldingEntry, inputs: VaultPricingInputs): Promise<HoldingUpdatePreview>;
15929
- /** Tracked external principal + outstanding yield attributed to a holding. */
16048
+ /** Complete tracked account value attributed to a holding. */
15930
16049
  declare function resolveTrackedAmounts(yieldTracker: YieldTracker | undefined, cfg: ConsensusOracleHoldingConfig | undefined, decimals: number): Promise<{
16050
+ trackedValueAmount: bigint;
15931
16051
  principalAmount: bigint;
15932
16052
  yieldAmount: bigint;
15933
16053
  }>;
@@ -16255,6 +16375,12 @@ declare class MockYieldTracker implements YieldTracker {
16255
16375
  getYield(accountName: string, start?: Date, end?: Date): Promise<YieldAccountSnapshot>;
16256
16376
  getTotalYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
16257
16377
  getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
16378
+ getTotalTrackedValue(accountNames: string[], start?: Date, end?: Date): Promise<{
16379
+ totalValue: number;
16380
+ principal: number;
16381
+ outstandingYield: number;
16382
+ }>;
16383
+ /** Backward-compatible APR-only breakdown. */
16258
16384
  getTotalTrackedAmounts(accountNames: string[], start?: Date, end?: Date): Promise<{
16259
16385
  principal: number;
16260
16386
  outstandingYield: number;
@@ -16600,4 +16726,4 @@ declare class IdleLiquidityService {
16600
16726
  private executeSwap;
16601
16727
  }
16602
16728
 
16603
- 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 };
16729
+ 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, 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, sumPositionsByMint, systemClock, toBigInt, toUiAmount, trackedValueFromResponse, updateAccount, updateDynamicApr, validateSquadsWalletRoutes, variantName, vaultAuthorityForWallet, withDiscoveredYieldAccounts };
package/dist/index.js CHANGED
@@ -3393,16 +3393,24 @@ __export(index_exports, {
3393
3393
  formatSettlementSimulation: () => formatSettlementSimulation,
3394
3394
  fromUiAmount: () => fromUiAmount,
3395
3395
  gatherPricingInputs: () => gatherPricingInputs,
3396
+ getAccount: () => getAccount,
3396
3397
  getAccounts: () => getAccounts,
3398
+ getAprYield: () => getAprYield,
3397
3399
  getBalance: () => getBalance,
3398
3400
  getCashflows: () => getCashflows,
3401
+ getNavValue: () => getNavValue,
3399
3402
  getRpcUrl: () => getRpcUrl,
3400
3403
  getTotalOutstandingYield: () => getTotalOutstandingYield,
3404
+ getTotalTrackedValue: () => getTotalTrackedValue,
3401
3405
  getTotalYield: () => getTotalYield,
3406
+ getTrackedValue: () => getTrackedValue,
3402
3407
  getVaultProgramId: () => getVaultProgramId,
3403
3408
  getYield: () => getYield,
3404
3409
  getYieldPayments: () => getYieldPayments,
3405
3410
  indexConfigByMint: () => indexConfigByMint,
3411
+ isNavAccountBalance: () => isNavAccountBalance,
3412
+ isNavAccountValue: () => isNavAccountValue,
3413
+ isNavYieldAccount: () => isNavYieldAccount,
3406
3414
  isVaultEnv: () => isVaultEnv,
3407
3415
  keypairAddress: () => keypairAddress,
3408
3416
  loadKeypair: () => loadKeypair,
@@ -3432,6 +3440,7 @@ __export(index_exports, {
3432
3440
  systemClock: () => systemClock,
3433
3441
  toBigInt: () => toBigInt2,
3434
3442
  toUiAmount: () => toUiAmount,
3443
+ trackedValueFromResponse: () => trackedValueFromResponse,
3435
3444
  updateAccount: () => updateAccount,
3436
3445
  updateDynamicApr: () => updateDynamicApr,
3437
3446
  validateSquadsWalletRoutes: () => validateSquadsWalletRoutes,
@@ -15199,6 +15208,16 @@ var IDL = {
15199
15208
  ],
15200
15209
  type: "pubkey"
15201
15210
  },
15211
+ {
15212
+ name: "consensus_signers",
15213
+ docs: [
15214
+ "Initial consensus-oracle signer set. When provided, it must contain",
15215
+ "between two and four distinct, non-default addresses."
15216
+ ],
15217
+ type: {
15218
+ vec: "pubkey"
15219
+ }
15220
+ },
15202
15221
  {
15203
15222
  name: "for_migration",
15204
15223
  docs: [
@@ -17463,7 +17482,8 @@ function toAnchorCreateVaultParams(params) {
17463
17482
  cbTrigger: (0, import_common10.toWeb3Pk)(params.cbTrigger),
17464
17483
  feeCollector: (0, import_common10.toWeb3Pk)(params.feeCollector),
17465
17484
  baseAssetMint: (0, import_common10.toWeb3Pk)(params.baseAssetMint),
17466
- basePriceOracleAccount: (0, import_common10.toWeb3Pk)(params.basePriceOracleAccount)
17485
+ basePriceOracleAccount: (0, import_common10.toWeb3Pk)(params.basePriceOracleAccount),
17486
+ consensusSigners: params.consensusSigners.map(import_common10.toWeb3Pk)
17467
17487
  };
17468
17488
  }
17469
17489
  function toAnchorSetVaultConfigArgs(args) {
@@ -17544,6 +17564,7 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
17544
17564
  (txArgs.basePrice ?? 10n ** BigInt(accountingDecimals)).toString()
17545
17565
  ),
17546
17566
  basePriceOracleAccount: txArgs.basePriceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
17567
+ consensusSigners: txArgs.consensusSigners ?? [],
17547
17568
  forMigration: txArgs.forMigration ?? false
17548
17569
  }
17549
17570
  };
@@ -20247,33 +20268,60 @@ function getAdminSecret(adminSecret) {
20247
20268
  }
20248
20269
  return secret;
20249
20270
  }
20271
+ function isNavYieldAccount(account) {
20272
+ return account.valuation_model === "nav";
20273
+ }
20250
20274
  async function createAccount(params) {
20251
- if (params.type === "dynamic" && params.apr === void 0) {
20275
+ const valuationModel = params.valuationModel ?? "apr";
20276
+ if (valuationModel === "nav" && !params.navConfig) {
20277
+ throw new Error("navConfig is required when creating a NAV account");
20278
+ }
20279
+ if (valuationModel === "nav" && params.apr !== void 0) {
20280
+ throw new Error("NAV accounts cannot define apr");
20281
+ }
20282
+ if (valuationModel === "apr" && params.type === "dynamic" && params.apr === void 0) {
20252
20283
  throw new Error("apr is required when creating a dynamic yield account");
20253
20284
  }
20254
20285
  if (params.apr !== void 0) {
20255
20286
  assertValidApr(params.apr);
20256
20287
  }
20257
- return await yieldApiReq(
20258
- "accounts/new",
20259
- "POST",
20260
- {
20261
- name: params.name,
20262
- type: params.type,
20263
- apr: params.apr,
20264
- tag: params.tag,
20265
- password: params.password,
20266
- description: params.description
20267
- },
20268
- {
20269
- adminSecret: getAdminSecret(params.adminSecret)
20270
- }
20288
+ return unwrapData(
20289
+ await yieldApiReq(
20290
+ "accounts/new",
20291
+ "POST",
20292
+ {
20293
+ name: params.name,
20294
+ type: params.type,
20295
+ apr: params.apr,
20296
+ valuation_model: valuationModel,
20297
+ nav_config: params.navConfig,
20298
+ tag: params.tag,
20299
+ password: params.password,
20300
+ description: params.description
20301
+ },
20302
+ {
20303
+ adminSecret: getAdminSecret(params.adminSecret)
20304
+ }
20305
+ )
20271
20306
  );
20272
20307
  }
20273
20308
  async function getAccounts() {
20274
20309
  return unwrapData(await yieldApiReq("accounts", "GET"));
20275
20310
  }
20311
+ async function getAccount(accountName) {
20312
+ return unwrapData(
20313
+ await yieldApiReq(accountEndpoint(accountName), "GET")
20314
+ );
20315
+ }
20276
20316
  async function updateAccount(params) {
20317
+ if (params.valuationModel === "nav") {
20318
+ if (!params.navConfig) {
20319
+ throw new Error("navConfig is required when switching to a NAV account");
20320
+ }
20321
+ if (params.apr !== void 0) {
20322
+ throw new Error("NAV accounts cannot define apr");
20323
+ }
20324
+ }
20277
20325
  if (params.apr !== void 0) {
20278
20326
  assertValidApr(params.apr);
20279
20327
  }
@@ -20294,7 +20342,9 @@ async function updateAccount(params) {
20294
20342
  type: params.type,
20295
20343
  apr: params.apr,
20296
20344
  tag: params.tag,
20297
- description: params.description
20345
+ description: params.description,
20346
+ valuation_model: params.valuationModel,
20347
+ nav_config: params.navConfig
20298
20348
  },
20299
20349
  auth.options
20300
20350
  )
@@ -20334,28 +20384,51 @@ async function updateDynamicApr(params) {
20334
20384
  );
20335
20385
  }
20336
20386
  async function addCashflowUpdate(params) {
20337
- if (params.fundingNextDay) {
20338
- params.date = roundToNextUtcMidnight(params.date);
20339
- }
20340
- return await yieldApiReq(
20341
- accountEndpoint(params.accountName, "cashflows"),
20342
- "POST",
20343
- {
20344
- amount: params.cashflowType === "deposit" ? params.amount : params.amount * -1,
20345
- timestamp: params.date ? dateToStr(params.date) : void 0,
20346
- description: params.description,
20347
- password: params.password
20387
+ const runtimeParams = params;
20388
+ if (params.valuationModel === "nav") {
20389
+ if (runtimeParams.date !== void 0 || runtimeParams.fundingNextDay !== void 0) {
20390
+ throw new Error(
20391
+ "NAV cashflows execute immediately and cannot specify date or fundingNextDay"
20392
+ );
20348
20393
  }
20394
+ if (!Number.isSafeInteger(params.amount)) {
20395
+ throw new Error(
20396
+ "NAV cashflow amount must be an integer number of base units"
20397
+ );
20398
+ }
20399
+ }
20400
+ const effectiveDate = params.valuationModel === "nav" ? void 0 : params.fundingNextDay ? roundToNextUtcMidnight(params.date ?? /* @__PURE__ */ new Date()) : params.date;
20401
+ return unwrapData(
20402
+ await yieldApiReq(
20403
+ accountEndpoint(params.accountName, "cashflows"),
20404
+ "POST",
20405
+ {
20406
+ amount: params.cashflowType === "deposit" ? Math.abs(params.amount) : -Math.abs(params.amount),
20407
+ timestamp: params.valuationModel === "nav" || !effectiveDate ? void 0 : dateToStr(effectiveDate),
20408
+ description: params.description,
20409
+ password: params.password
20410
+ }
20411
+ )
20349
20412
  );
20350
20413
  }
20351
20414
  async function getCashflows(accountName) {
20352
- return (await yieldApiReq(accountEndpoint(accountName, "cashflows"), "GET")).data;
20415
+ return unwrapData(
20416
+ await yieldApiReq(accountEndpoint(accountName, "cashflows"), "GET")
20417
+ );
20418
+ }
20419
+ function isNavAccountBalance(response) {
20420
+ return response.valuation_model === "nav";
20353
20421
  }
20354
20422
  async function getBalance(accountName, atTime) {
20355
- return (await yieldApiReq(
20356
- accountEndpoint(accountName, "balance") + (atTime ? `?as_of=${dateToStr(atTime)}` : ""),
20357
- "GET"
20358
- )).data;
20423
+ return unwrapData(
20424
+ await yieldApiReq(
20425
+ accountEndpoint(accountName, "balance") + (atTime ? `?as_of=${dateToStr(atTime)}` : ""),
20426
+ "GET"
20427
+ )
20428
+ );
20429
+ }
20430
+ function isNavAccountValue(response) {
20431
+ return response.valuation_model === "nav";
20359
20432
  }
20360
20433
  async function createYieldPayment(params) {
20361
20434
  return unwrapData(
@@ -20392,15 +20465,63 @@ async function getYieldPayments(accountName) {
20392
20465
  );
20393
20466
  }
20394
20467
  async function getYield(accountName, start, end) {
20395
- return (await yieldApiReq(
20396
- accountEndpoint(accountName, "yield") + (start ? `?start=${dateToStr(start)}` : "") + (start && end ? `&end=${dateToStr(end)}` : end ? `?end=${dateToStr(end)}` : ""),
20397
- "GET"
20398
- )).data;
20468
+ return unwrapData(
20469
+ await yieldApiReq(
20470
+ accountEndpoint(accountName, "yield") + (start ? `?start=${dateToStr(start)}` : "") + (start && end ? `&end=${dateToStr(end)}` : end ? `?end=${dateToStr(end)}` : ""),
20471
+ "GET"
20472
+ )
20473
+ );
20474
+ }
20475
+ async function getAprYield(accountName, start, end) {
20476
+ const response = await getYield(accountName, start, end);
20477
+ if (isNavAccountValue(response)) {
20478
+ throw new Error(`Account "${accountName}" uses NAV valuation, not APR`);
20479
+ }
20480
+ return response;
20481
+ }
20482
+ async function getNavValue(accountName) {
20483
+ const response = await getYield(accountName);
20484
+ if (!isNavAccountValue(response)) {
20485
+ throw new Error(`Account "${accountName}" uses APR valuation, not NAV`);
20486
+ }
20487
+ return response;
20488
+ }
20489
+ function trackedValueFromResponse(response) {
20490
+ if (isNavAccountValue(response)) {
20491
+ const totalValue2 = Number(response.total_nav);
20492
+ if (!Number.isFinite(totalValue2) || totalValue2 < 0) {
20493
+ throw new Error("NAV account returned an invalid total_nav");
20494
+ }
20495
+ return {
20496
+ totalValue: totalValue2,
20497
+ principal: 0,
20498
+ outstandingYield: 0,
20499
+ valuationModel: "nav"
20500
+ };
20501
+ }
20502
+ const totalValue = response.principal_at_end + response.outstanding_yield;
20503
+ if (!Number.isFinite(totalValue)) {
20504
+ throw new Error("APR account returned an invalid tracked value");
20505
+ }
20506
+ return {
20507
+ totalValue,
20508
+ principal: response.principal_at_end,
20509
+ outstandingYield: response.outstanding_yield,
20510
+ valuationModel: "apr"
20511
+ };
20512
+ }
20513
+ async function getTrackedValue(accountName) {
20514
+ return trackedValueFromResponse(await getYield(accountName));
20399
20515
  }
20400
20516
  async function getTotalYield(accountNames, start, end) {
20401
20517
  let totalYield = new import_core20.BN(0);
20402
20518
  for (const accountName of accountNames) {
20403
20519
  const res = await getYield(accountName, start, end);
20520
+ if (isNavAccountValue(res)) {
20521
+ throw new Error(
20522
+ `NAV account "${accountName}" does not report accrued yield`
20523
+ );
20524
+ }
20404
20525
  console.log(res);
20405
20526
  totalYield = totalYield.add(new import_core20.BN(res.total_yield));
20406
20527
  }
@@ -20410,10 +20531,28 @@ async function getTotalOutstandingYield(accountNames, start, end) {
20410
20531
  let total = 0;
20411
20532
  for (const accountName of accountNames) {
20412
20533
  const response = await getYield(accountName, start, end);
20534
+ if (isNavAccountValue(response)) {
20535
+ throw new Error(
20536
+ `NAV account "${accountName}" does not report outstanding yield`
20537
+ );
20538
+ }
20413
20539
  total += response.outstanding_yield;
20414
20540
  }
20415
20541
  return total;
20416
20542
  }
20543
+ async function getTotalTrackedValue(accountNames, start, end) {
20544
+ let totalValue = 0;
20545
+ let principal = 0;
20546
+ let outstandingYield = 0;
20547
+ for (const accountName of accountNames) {
20548
+ const response = await getYield(accountName, start, end);
20549
+ const tracked = trackedValueFromResponse(response);
20550
+ totalValue += tracked.totalValue;
20551
+ principal += tracked.principal;
20552
+ outstandingYield += tracked.outstandingYield;
20553
+ }
20554
+ return { totalValue, principal, outstandingYield };
20555
+ }
20417
20556
 
20418
20557
  // src/services/withdrawalQueueService.ts
20419
20558
  var import_common40 = __toESM(require_dist());
@@ -20975,6 +21114,7 @@ function evaluateBalanceChanges(vaultState, updates, thresholdBps, nowSecs) {
20975
21114
  walletAmount: update.walletAmount,
20976
21115
  lpAmount: update.lpAmount,
20977
21116
  trackedPrincipalAmount: update.trackedPrincipalAmount,
21117
+ trackedValueAmount: update.trackedValueAmount,
20978
21118
  yieldAmount: update.yieldAmount
20979
21119
  };
20980
21120
  const lastUpdateTs = toBigInt2(holding.lastUpdateTs);
@@ -21039,6 +21179,9 @@ function assertNoLargeBalanceChanges(vault, vaultState, updates, nowSecs, log =
21039
21179
  )} lp=${formatTokenAmount(
21040
21180
  violation.lpAmount,
21041
21181
  violation.decimals
21182
+ )} tracked=${formatTokenAmount(
21183
+ violation.trackedValueAmount,
21184
+ violation.decimals
21042
21185
  )} principal=${formatTokenAmount(
21043
21186
  violation.trackedPrincipalAmount,
21044
21187
  violation.decimals
@@ -22190,7 +22333,7 @@ async function buildHoldingUpdate(yieldTracker, entry, inputs) {
22190
22333
  }
22191
22334
  const walletAmount = inputs.walletBalances[mintKey] ?? 0n;
22192
22335
  const lpAmount = inputs.lpByMint.get(mintKey) ?? 0n;
22193
- const { principalAmount, yieldAmount } = await resolveTrackedAmounts(
22336
+ const { trackedValueAmount, principalAmount, yieldAmount } = await resolveTrackedAmounts(
22194
22337
  yieldTracker,
22195
22338
  inputs.configByMint.get(mintKey),
22196
22339
  holding.decimals
@@ -22205,17 +22348,36 @@ async function buildHoldingUpdate(yieldTracker, entry, inputs) {
22205
22348
  lpAmount,
22206
22349
  yieldAmount,
22207
22350
  trackedPrincipalAmount: principalAmount,
22208
- externalAmount: walletAmount + lpAmount + principalAmount + yieldAmount
22351
+ trackedValueAmount,
22352
+ externalAmount: walletAmount + lpAmount + trackedValueAmount
22209
22353
  };
22210
22354
  }
22211
22355
  async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
22212
22356
  if (!yieldTracker || !cfg?.yieldAccountNames?.length) {
22213
- return { principalAmount: 0n, yieldAmount: 0n };
22357
+ return {
22358
+ trackedValueAmount: 0n,
22359
+ principalAmount: 0n,
22360
+ yieldAmount: 0n
22361
+ };
22362
+ }
22363
+ let tracked;
22364
+ if (yieldTracker.getTotalTrackedValue) {
22365
+ tracked = await yieldTracker.getTotalTrackedValue(cfg.yieldAccountNames);
22366
+ } else if (yieldTracker.getTotalTrackedAmounts) {
22367
+ const legacy = await yieldTracker.getTotalTrackedAmounts(
22368
+ cfg.yieldAccountNames
22369
+ );
22370
+ tracked = {
22371
+ totalValue: legacy.principal + legacy.outstandingYield,
22372
+ ...legacy
22373
+ };
22374
+ } else {
22375
+ throw new Error(
22376
+ "yield tracker does not implement getTotalTrackedValue or its legacy fallback"
22377
+ );
22214
22378
  }
22215
- const tracked = await yieldTracker.getTotalTrackedAmounts(
22216
- cfg.yieldAccountNames
22217
- );
22218
22379
  return {
22380
+ trackedValueAmount: tracked.totalValue > 0 ? (0, import_common44.fromUiAmount)(tracked.totalValue, decimals) : 0n,
22219
22381
  principalAmount: tracked.principal > 0 ? (0, import_common44.fromUiAmount)(tracked.principal, decimals) : 0n,
22220
22382
  yieldAmount: tracked.outstandingYield > 0 ? (0, import_common44.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
22221
22383
  };
@@ -22494,7 +22656,7 @@ async function settleVault2({
22494
22656
  log(`vault ${vault}: submitting ${updates.length} consensus asset update(s)`);
22495
22657
  for (const update of updates) {
22496
22658
  log(
22497
- ` holding #${update.holdingIndex} ${update.mint}: price=${update.price} external_amount=${update.externalAmount} [wallet=${update.walletAmount} lp=${update.lpAmount} principal=${update.trackedPrincipalAmount} yield=${update.yieldAmount}]`
22659
+ ` 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}]`
22498
22660
  );
22499
22661
  }
22500
22662
  await logProspectiveApy({
@@ -22931,7 +23093,7 @@ var MockYieldTracker = class {
22931
23093
  }
22932
23094
  return total;
22933
23095
  }
22934
- async getTotalTrackedAmounts(accountNames, start, end) {
23096
+ async getTotalTrackedValue(accountNames, start, end) {
22935
23097
  let principal = 0;
22936
23098
  let outstandingYield = 0;
22937
23099
  for (const name of accountNames) {
@@ -22939,7 +23101,19 @@ var MockYieldTracker = class {
22939
23101
  principal += snapshot2.principalAtEnd;
22940
23102
  outstandingYield += snapshot2.outstandingYield;
22941
23103
  }
22942
- return { principal, outstandingYield };
23104
+ return {
23105
+ totalValue: principal + outstandingYield,
23106
+ principal,
23107
+ outstandingYield
23108
+ };
23109
+ }
23110
+ /** Backward-compatible APR-only breakdown. */
23111
+ async getTotalTrackedAmounts(accountNames, start, end) {
23112
+ const tracked = await this.getTotalTrackedValue(accountNames, start, end);
23113
+ return {
23114
+ principal: tracked.principal,
23115
+ outstandingYield: tracked.outstandingYield
23116
+ };
22943
23117
  }
22944
23118
  async getBalance(accountName, atTime) {
22945
23119
  const snapshot2 = await this.getYield(accountName, void 0, atTime);
@@ -23029,17 +23203,12 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
23029
23203
  const raw = await getTotalOutstandingYield(accountNames, start, end);
23030
23204
  return raw / 10 ** YIELD_TRACKER_DECIMALS;
23031
23205
  },
23032
- async getTotalTrackedAmounts(accountNames, start, end) {
23033
- let principal = 0;
23034
- let outstandingYield = 0;
23035
- for (const accountName of accountNames) {
23036
- const snapshot2 = await getYield(accountName, start, end);
23037
- principal += snapshot2.principal_at_end;
23038
- outstandingYield += snapshot2.outstanding_yield;
23039
- }
23206
+ async getTotalTrackedValue(accountNames, start, end) {
23207
+ const tracked = await getTotalTrackedValue(accountNames, start, end);
23040
23208
  return {
23041
- principal: principal / 10 ** YIELD_TRACKER_DECIMALS,
23042
- outstandingYield: outstandingYield / 10 ** YIELD_TRACKER_DECIMALS
23209
+ totalValue: tracked.totalValue / 10 ** YIELD_TRACKER_DECIMALS,
23210
+ principal: tracked.principal / 10 ** YIELD_TRACKER_DECIMALS,
23211
+ outstandingYield: tracked.outstandingYield / 10 ** YIELD_TRACKER_DECIMALS
23043
23212
  };
23044
23213
  },
23045
23214
  getYieldPayments
@@ -24128,16 +24297,24 @@ var import_common53 = __toESM(require_dist());
24128
24297
  formatSettlementSimulation,
24129
24298
  fromUiAmount,
24130
24299
  gatherPricingInputs,
24300
+ getAccount,
24131
24301
  getAccounts,
24302
+ getAprYield,
24132
24303
  getBalance,
24133
24304
  getCashflows,
24305
+ getNavValue,
24134
24306
  getRpcUrl,
24135
24307
  getTotalOutstandingYield,
24308
+ getTotalTrackedValue,
24136
24309
  getTotalYield,
24310
+ getTrackedValue,
24137
24311
  getVaultProgramId,
24138
24312
  getYield,
24139
24313
  getYieldPayments,
24140
24314
  indexConfigByMint,
24315
+ isNavAccountBalance,
24316
+ isNavAccountValue,
24317
+ isNavYieldAccount,
24141
24318
  isVaultEnv,
24142
24319
  keypairAddress,
24143
24320
  loadKeypair,
@@ -24167,6 +24344,7 @@ var import_common53 = __toESM(require_dist());
24167
24344
  systemClock,
24168
24345
  toBigInt,
24169
24346
  toUiAmount,
24347
+ trackedValueFromResponse,
24170
24348
  updateAccount,
24171
24349
  updateDynamicApr,
24172
24350
  validateSquadsWalletRoutes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perena/vault-sdk",
3
- "version": "1.0.33",
3
+ "version": "1.0.36",
4
4
  "description": "Vault program helpers for Bankineco integrations.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",