@perena/vault-sdk 1.0.42 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -6508,8 +6508,9 @@ type Bankineco = {
6508
6508
  {
6509
6509
  name: "maxApyBps";
6510
6510
  docs: [
6511
- "Maximum annualized APY accepted between oracle NAV updates that advance",
6512
- "the vault's regular performance-fee high-water mark, in basis points."
6511
+ "Maximum linear annualized growth of the settled regular share price",
6512
+ "against `max_apy_anchor`, for settlements advancing its performance-fee",
6513
+ "high-water mark. Basis points; zero disables enforcement, not observation."
6513
6514
  ];
6514
6515
  type: "u16";
6515
6516
  },
@@ -6556,10 +6557,23 @@ type Bankineco = {
6556
6557
  ];
6557
6558
  type: "i64";
6558
6559
  },
6560
+ {
6561
+ name: "maxApyAnchor";
6562
+ docs: [
6563
+ "Independent of the durable fixed-APY accrual anchor above. Carved from",
6564
+ "reserved bytes without changing APYConfig or Vault size/field offsets.",
6565
+ "Existing zero-filled accounts initialize lazily from a known price/time."
6566
+ ];
6567
+ type: {
6568
+ defined: {
6569
+ name: "maxApyAnchor";
6570
+ };
6571
+ };
6572
+ },
6559
6573
  {
6560
6574
  name: "padding1";
6561
6575
  type: {
6562
- array: ["u64", 32];
6576
+ array: ["u64", 28];
6563
6577
  };
6564
6578
  }
6565
6579
  ];
@@ -7146,6 +7160,41 @@ type Bankineco = {
7146
7160
  ];
7147
7161
  };
7148
7162
  },
7163
+ {
7164
+ name: "maxApyAnchor";
7165
+ docs: [
7166
+ "Weekly observations of the settled regular share price. Keep the previous",
7167
+ "observation while the newest is younger than seven days, so rollover never",
7168
+ "reduces a mature comparison window to a few seconds. With regular settlement",
7169
+ "the effective lookback is seven to fourteen days; sparse settlement can make",
7170
+ "it longer. A new cohort uses its actual age until seven days of history exist."
7171
+ ];
7172
+ serialization: "bytemuck";
7173
+ repr: {
7174
+ kind: "c";
7175
+ };
7176
+ type: {
7177
+ kind: "struct";
7178
+ fields: [
7179
+ {
7180
+ name: "sharePrice";
7181
+ type: "u64";
7182
+ },
7183
+ {
7184
+ name: "timestamp";
7185
+ type: "i64";
7186
+ },
7187
+ {
7188
+ name: "previousSharePrice";
7189
+ type: "u64";
7190
+ },
7191
+ {
7192
+ name: "previousTimestamp";
7193
+ type: "i64";
7194
+ }
7195
+ ];
7196
+ };
7197
+ },
7149
7198
  {
7150
7199
  name: "pendingManagerWithdrawDestination";
7151
7200
  docs: [
@@ -12252,6 +12301,31 @@ interface SettlementSimulationSnapshot {
12252
12301
  junior?: SimulatedShareClass;
12253
12302
  senior?: SimulatedShareClass;
12254
12303
  }
12304
+ interface MaxApyAnchorSnapshot {
12305
+ sharePrice: bigint;
12306
+ timestamp: bigint;
12307
+ previousSharePrice: bigint;
12308
+ previousTimestamp: bigint;
12309
+ }
12310
+ /** Inputs to the program's linear annualized max-APY comparison. */
12311
+ interface RealizedApySimulation {
12312
+ basis: "regular-share-price";
12313
+ priorValue: bigint;
12314
+ nextValue?: bigint;
12315
+ priorTs: bigint;
12316
+ timestampSource: "apy.max_apy_anchor.timestamp" | "apy.max_apy_anchor.previous_timestamp" | "legacy fixed-APY anchor (initialization)" | "current share-price observation (initialization)";
12317
+ checkpointTs: bigint;
12318
+ nowTs: bigint;
12319
+ elapsedSecs: bigint;
12320
+ /** Signed annualized growth, in millionths of a basis point, truncated. */
12321
+ impliedApyMicroBps?: bigint;
12322
+ /** Ceiling of the positive implied rate; zero for flat/negative growth. */
12323
+ minimumCapBps?: bigint;
12324
+ maxApyBps: number;
12325
+ fixedApyBps: number;
12326
+ hwmBefore: bigint;
12327
+ hwmAfter: bigint;
12328
+ }
12255
12329
  /**
12256
12330
  * Result of replaying the relevant on-chain consensus and NAV-settlement math.
12257
12331
  * All numbers remain in raw on-chain fixed-point/base units.
@@ -12271,6 +12345,10 @@ interface SettlementSimulation {
12271
12345
  /** Per-holding attribution of the gross-NAV change consensus would cause. */
12272
12346
  navContributions: HoldingNavContribution[];
12273
12347
  grossNav?: bigint;
12348
+ /** Also retained when max APY blocks the otherwise-projected settlement. */
12349
+ realizedApy?: RealizedApySimulation;
12350
+ /** Weekly observations after the projected settlement succeeds. */
12351
+ projectedMaxApyAnchor?: MaxApyAnchorSnapshot;
12274
12352
  settledAccountingNav?: bigint;
12275
12353
  current: SettlementSimulationSnapshot;
12276
12354
  /**
@@ -12535,8 +12613,9 @@ interface LogProspectiveApyParams {
12535
12613
  log: (msg: string) => void;
12536
12614
  }
12537
12615
  /**
12538
- * Fetch the current settlement timestamp and log the APY implied by the
12539
- * prospective update, so MaxApyExceeded failures are diagnosable.
12616
+ * @deprecated Raw candidate NAV estimate, retained for SDK compatibility.
12617
+ * Use simulateDryRunSettlement + formatSettlementSimulation for the program's
12618
+ * consensus-aware max-APY diagnostic, including regular-share and HWM rules.
12540
12619
  *
12541
12620
  * NAV is expressed in the vault's accounting unit (scaled by assetDecimals).
12542
12621
  * Mirrors `gross_nav_from_holdings`: consensus updates overlay their target
@@ -12561,8 +12640,8 @@ declare function discoverVaultsForSigner(client: VaultClient, signer: Keypair, o
12561
12640
 
12562
12641
  /**
12563
12642
  * Fail closed while any configured yield account has an unsettled payment.
12564
- * The payout must be confirmed only after it is visible in the same wallet
12565
- * balance source used by this service. Until then, no oracle update is safe.
12643
+ * Confirmed payments reduce tracked value; the oracle does not add the payout's
12644
+ * destination balance to the reported external amount.
12566
12645
  */
12567
12646
  declare function assertNoUnconfirmedYieldPayments(yieldTracker: YieldTracker | undefined, target: ConsensusOracleTarget): Promise<void>;
12568
12647
  /**
@@ -12785,6 +12864,7 @@ declare class MockYieldTracker implements YieldTracker {
12785
12864
  * file owns deterministic program-math parity and is straightforward to test.
12786
12865
  */
12787
12866
 
12867
+ declare const MAX_APY_ANCHOR_WINDOW_SECS = 604800n;
12788
12868
  interface SimulateSettlementArgs {
12789
12869
  vault: DecodedVault;
12790
12870
  oracleData: readonly number[];
@@ -12806,6 +12886,8 @@ declare function formatSettlementSimulation(simulation: SettlementSimulation): s
12806
12886
 
12807
12887
  interface LiveConsensusOracleDepsOptions {
12808
12888
  log?: (msg: string) => void;
12889
+ /** @deprecated Ignored. Manager-wallet balance sourcing has been removed. */
12890
+ rpcOnly?: boolean;
12809
12891
  includeExternalPositions?: boolean;
12810
12892
  }
12811
12893
  declare function createLiveConsensusOracleDeps(connection: Connection, opts?: LiveConsensusOracleDepsOptions): ConsensusOracleDeps;
@@ -12815,6 +12897,8 @@ interface RunLiveConsensusOracleOptions extends RunOptions {
12815
12897
  rpcUrl?: string;
12816
12898
  /** Override the vault program id. Defaults to the environment's configured program. */
12817
12899
  programId?: Address;
12900
+ /** @deprecated Ignored. Manager-wallet balance sourcing has been removed. */
12901
+ rpcOnly?: boolean;
12818
12902
  /** Include live Kamino/Marginfi positions in external amount updates. Defaults to true. */
12819
12903
  includeExternalPositions?: boolean;
12820
12904
  }
@@ -13149,4 +13233,4 @@ declare class TimelockSettlementService {
13149
13233
  private execute;
13150
13234
  }
13151
13235
 
13152
- export { ASSET_DECIMALS, ASSET_REBALANCE_COOLDOWN_SECS, type AccountBalanceResponse, AccountClient, type AccountYieldResponse, ActivateCircuitBreakerBuilder, type ActivateCircuitBreakerIxArgs, type ActivateCircuitBreakerTxArgs, type AddAprCashflowUpdateParams, type AddCashflowUpdateParams, type AddIncentiveRecipientArgs, AddIncentiveRecipientBuilder, type AddIncentiveRecipientIxArgs, 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, type BuildMarginfiWithdrawInteractionArgs, CONSENSUS_ORACLE_VARIANT, type CancelIncentiveProposalArgs, CancelIncentiveProposalBuilder, CancelJuniorTrancheWithdrawBuilder, type CancelJuniorTrancheWithdrawIxArgs, type CancelJuniorTrancheWithdrawTxArgs, ClaimIncentiveBuilder, type ClaimIncentiveIxArgs, type ClaimIncentiveTxArgs, 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, CreateIncentiveBuilder, type CreateIncentiveIxArgs, type CreateIncentiveTxArgs, 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, DistributeIncentiveBuilder, type DistributeIncentiveIxArgs, type DistributeIncentiveTxArgs, 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, type IncentiveRecipient, type IncentiveTotals, InitializeVaultRolesBuilder, type InitializeVaultRolesIxArgs, type InitializeVaultRolesTxArgs, type JuniorWithdrawalMode, 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_INCENTIVE_RECIPIENTS, 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 PendingConsensusSignerSet, 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 ResolveExternalWithdrawArgs, type ResolvedExternalWithdraw, 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, type SetIncentiveLimitsArgs, SetIncentiveLimitsBuilder, 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, SubmitIncentiveBuilder, type SubmitIncentiveIxArgs, type SubmitIncentiveTxArgs, TOKEN_PROGRAM, TOKEN_PROGRAM_ID, type TimelockSettlementKind, type TimelockSettlementOptions, type TimelockSettlementRecord, TimelockSettlementService, type TimelockSettlementSummary, 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 VaultIncentiveAccount, type VaultIncentiveAccountData, 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 WithdrawProtocolFeesIxArgs, type WithdrawProtocolFeesTxArgs, 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, buildMarginfiWithdrawInteraction, buildUpdates, coerceBool, collectSamples, confirmYieldPayment, createAccount, createLiveConsensusOracleDeps, createRpcFromConnection, createTokenMint, createTokenMintIxs, createVaultClient, createYieldPayment, dateToStr, decodePendingConsensusSigners, defaultKeypairPath, deleteAccount, discoverVaultsForSigner, fetchExternalPositions, fetchNestTokenPrice, fetchReceiptMints, filterTargetHoldings, findLargeBalanceChanges, findSquadsWalletRoute, formatSettlementSimulation, fromUiAmount, gatherPricingInputs, getAccount, getAccounts, getAprYield, getBalance, getCashflows, getIncentiveRecipientShareAtas, getIncentiveRecipients, getIncentiveReportRecipients, getIncentiveTotals, 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, resolveExternalWithdraw, resolveKeypairPath, resolveSquadsWalletRoute, resolveTrackedAmounts, roundToNextUtcMidnight, runLiveConsensusOracle, selectReportableHoldings, settleVault, signerInOracleData, simulateConsensusOracleSettlement, simulateDryRunSettlement, simulateSquadsProposalExecution, sumPositionsByMint, systemClock, toBigInt, toUiAmount, toWeb3AccountMeta, trackedValueFromResponse, updateAccount, updateDynamicApr, validateSquadsWalletRoutes, variantName, vaultAuthorityForWallet, withDiscoveredYieldAccounts };
13236
+ export { ASSET_DECIMALS, ASSET_REBALANCE_COOLDOWN_SECS, type AccountBalanceResponse, AccountClient, type AccountYieldResponse, ActivateCircuitBreakerBuilder, type ActivateCircuitBreakerIxArgs, type ActivateCircuitBreakerTxArgs, type AddAprCashflowUpdateParams, type AddCashflowUpdateParams, type AddIncentiveRecipientArgs, AddIncentiveRecipientBuilder, type AddIncentiveRecipientIxArgs, 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, type BuildMarginfiWithdrawInteractionArgs, CONSENSUS_ORACLE_VARIANT, type CancelIncentiveProposalArgs, CancelIncentiveProposalBuilder, CancelJuniorTrancheWithdrawBuilder, type CancelJuniorTrancheWithdrawIxArgs, type CancelJuniorTrancheWithdrawTxArgs, ClaimIncentiveBuilder, type ClaimIncentiveIxArgs, type ClaimIncentiveTxArgs, 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, CreateIncentiveBuilder, type CreateIncentiveIxArgs, type CreateIncentiveTxArgs, 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, DistributeIncentiveBuilder, type DistributeIncentiveIxArgs, type DistributeIncentiveTxArgs, 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, type IncentiveRecipient, type IncentiveTotals, InitializeVaultRolesBuilder, type InitializeVaultRolesIxArgs, type InitializeVaultRolesTxArgs, type JuniorWithdrawalMode, 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_APY_ANCHOR_WINDOW_SECS, MAX_BALANCE_CHANGE_BPS, MAX_CONSENSUS_SIGNERS, MAX_INCENTIVE_RECIPIENTS, 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 MaxApyAnchorSnapshot, 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 PendingConsensusSignerSet, type PreparedDirectTransaction, type PreparedSquadsTransaction, type PreparedVaultTransaction, type PriceOracleTypeArgs, type PriceSource, ProtocolInteractionBuilder, type ProtocolInteractionIxArgs, type ProtocolInteractionTxArgs, type QuoteFeeUnit, REPORTABLE_ORACLE_VARIANTS, type RealizedApySimulation, type RefreshLiveOraclePricesParams, RemoveAssetHoldingBuilder, type RemoveAssetHoldingIxArgs, type RemoveAssetHoldingTxArgs, RequestJuniorTrancheWithdrawBuilder, type RequestJuniorTrancheWithdrawIxArgs, type RequestJuniorTrancheWithdrawTxArgs, type ResolveExternalWithdrawArgs, type ResolvedExternalWithdraw, 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, type SetIncentiveLimitsArgs, SetIncentiveLimitsBuilder, 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, SubmitIncentiveBuilder, type SubmitIncentiveIxArgs, type SubmitIncentiveTxArgs, TOKEN_PROGRAM, TOKEN_PROGRAM_ID, type TimelockSettlementKind, type TimelockSettlementOptions, type TimelockSettlementRecord, TimelockSettlementService, type TimelockSettlementSummary, 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 VaultIncentiveAccount, type VaultIncentiveAccountData, 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 WithdrawProtocolFeesIxArgs, type WithdrawProtocolFeesTxArgs, 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, buildMarginfiWithdrawInteraction, buildUpdates, coerceBool, collectSamples, confirmYieldPayment, createAccount, createLiveConsensusOracleDeps, createRpcFromConnection, createTokenMint, createTokenMintIxs, createVaultClient, createYieldPayment, dateToStr, decodePendingConsensusSigners, defaultKeypairPath, deleteAccount, discoverVaultsForSigner, fetchExternalPositions, fetchNestTokenPrice, fetchReceiptMints, filterTargetHoldings, findLargeBalanceChanges, findSquadsWalletRoute, formatSettlementSimulation, fromUiAmount, gatherPricingInputs, getAccount, getAccounts, getAprYield, getBalance, getCashflows, getIncentiveRecipientShareAtas, getIncentiveRecipients, getIncentiveReportRecipients, getIncentiveTotals, 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, resolveExternalWithdraw, resolveKeypairPath, resolveSquadsWalletRoute, resolveTrackedAmounts, roundToNextUtcMidnight, runLiveConsensusOracle, selectReportableHoldings, settleVault, signerInOracleData, simulateConsensusOracleSettlement, simulateDryRunSettlement, simulateSquadsProposalExecution, sumPositionsByMint, systemClock, toBigInt, toUiAmount, toWeb3AccountMeta, trackedValueFromResponse, updateAccount, updateDynamicApr, validateSquadsWalletRoutes, variantName, vaultAuthorityForWallet, withDiscoveredYieldAccounts };
package/dist/index.js CHANGED
@@ -3249,6 +3249,7 @@ __export(index_exports, {
3249
3249
  LOCAL_PROTOCOL_ADMIN: () => LOCAL_PROTOCOL_ADMIN,
3250
3250
  LargeBalanceChangeError: () => LargeBalanceChangeError,
3251
3251
  LivePriceSource: () => LivePriceSource,
3252
+ MAX_APY_ANCHOR_WINDOW_SECS: () => MAX_APY_ANCHOR_WINDOW_SECS,
3252
3253
  MAX_BALANCE_CHANGE_BPS: () => MAX_BALANCE_CHANGE_BPS,
3253
3254
  MAX_CONSENSUS_SIGNERS: () => MAX_CONSENSUS_SIGNERS,
3254
3255
  MAX_INCENTIVE_RECIPIENTS: () => MAX_INCENTIVE_RECIPIENTS,
@@ -9916,8 +9917,9 @@ var IDL = {
9916
9917
  {
9917
9918
  name: "max_apy_bps",
9918
9919
  docs: [
9919
- "Maximum annualized APY accepted between oracle NAV updates that advance",
9920
- "the vault's regular performance-fee high-water mark, in basis points."
9920
+ "Maximum linear annualized growth of the settled regular share price",
9921
+ "against `max_apy_anchor`, for settlements advancing its performance-fee",
9922
+ "high-water mark. Basis points; zero disables enforcement, not observation."
9921
9923
  ],
9922
9924
  type: "u16"
9923
9925
  },
@@ -9964,10 +9966,23 @@ var IDL = {
9964
9966
  ],
9965
9967
  type: "i64"
9966
9968
  },
9969
+ {
9970
+ name: "max_apy_anchor",
9971
+ docs: [
9972
+ "Independent of the durable fixed-APY accrual anchor above. Carved from",
9973
+ "reserved bytes without changing APYConfig or Vault size/field offsets.",
9974
+ "Existing zero-filled accounts initialize lazily from a known price/time."
9975
+ ],
9976
+ type: {
9977
+ defined: {
9978
+ name: "MaxApyAnchor"
9979
+ }
9980
+ }
9981
+ },
9967
9982
  {
9968
9983
  name: "_padding1",
9969
9984
  type: {
9970
- array: ["u64", 32]
9985
+ array: ["u64", 28]
9971
9986
  }
9972
9987
  }
9973
9988
  ]
@@ -10554,6 +10569,41 @@ var IDL = {
10554
10569
  ]
10555
10570
  }
10556
10571
  },
10572
+ {
10573
+ name: "MaxApyAnchor",
10574
+ docs: [
10575
+ "Weekly observations of the settled regular share price. Keep the previous",
10576
+ "observation while the newest is younger than seven days, so rollover never",
10577
+ "reduces a mature comparison window to a few seconds. With regular settlement",
10578
+ "the effective lookback is seven to fourteen days; sparse settlement can make",
10579
+ "it longer. A new cohort uses its actual age until seven days of history exist."
10580
+ ],
10581
+ serialization: "bytemuck",
10582
+ repr: {
10583
+ kind: "c"
10584
+ },
10585
+ type: {
10586
+ kind: "struct",
10587
+ fields: [
10588
+ {
10589
+ name: "share_price",
10590
+ type: "u64"
10591
+ },
10592
+ {
10593
+ name: "timestamp",
10594
+ type: "i64"
10595
+ },
10596
+ {
10597
+ name: "previous_share_price",
10598
+ type: "u64"
10599
+ },
10600
+ {
10601
+ name: "previous_timestamp",
10602
+ type: "i64"
10603
+ }
10604
+ ]
10605
+ }
10606
+ },
10557
10607
  {
10558
10608
  name: "PendingManagerWithdrawDestination",
10559
10609
  docs: [
@@ -17796,6 +17846,7 @@ var DEFAULT_SHARE_PRICE = 1000000n;
17796
17846
  var BPS_DENOMINATOR3 = 10000n;
17797
17847
  var NAV_LOSS_TOLERANCE_BPS = 25n;
17798
17848
  var SECONDS_PER_YEAR = 31536000n;
17849
+ var MAX_APY_ANCHOR_WINDOW_SECS = 604800n;
17799
17850
  var DEFAULT_STALENESS_SECS = 86400n;
17800
17851
  var CONSENSUS_MAX_DIFF_BPS = 8n;
17801
17852
  var MIN_CONSENSUS_SIGNERS = 2;
@@ -17898,6 +17949,7 @@ function simulateConsensusOracleSettlement(args) {
17898
17949
  current
17899
17950
  };
17900
17951
  }
17952
+ let realizedApy;
17901
17953
  try {
17902
17954
  const settlement = settleVault({
17903
17955
  grossNav,
@@ -17916,7 +17968,11 @@ function simulateConsensusOracleSettlement(args) {
17916
17968
  accruedApyBalance: bigint(apyConfig.accruedApyBalance),
17917
17969
  apyAnchorSharePrice: bigint(apyConfig.anchorSharePrice),
17918
17970
  apyAnchorTs: bigint(apyConfig.anchorTs),
17919
- tranche: currentTranche
17971
+ maxApyAnchor: decodeMaxApyAnchor(apyConfig.maxApyAnchor),
17972
+ tranche: currentTranche,
17973
+ onRealizedApy: (diagnostic) => {
17974
+ realizedApy = diagnostic;
17975
+ }
17920
17976
  });
17921
17977
  return {
17922
17978
  nowTs: args.nowTs,
@@ -17928,6 +17984,8 @@ function simulateConsensusOracleSettlement(args) {
17928
17984
  consensus,
17929
17985
  navContributions,
17930
17986
  grossNav,
17987
+ realizedApy,
17988
+ projectedMaxApyAnchor: settlement.maxApyAnchor,
17931
17989
  settledAccountingNav: settlement.settledAccountingNav,
17932
17990
  current,
17933
17991
  projected: settlement.projected,
@@ -17955,6 +18013,8 @@ function simulateConsensusOracleSettlement(args) {
17955
18013
  });
17956
18014
  return {
17957
18015
  ...projection,
18016
+ // Retain the real configured cap when the projection retries uncapped.
18017
+ realizedApy: realizedApy ?? projection.realizedApy,
17958
18018
  canSettle: false,
17959
18019
  blockers: [...blockers, ...projection.blockers],
17960
18020
  projectionRequiresLossesEnabled: projection.projected ? requiresLossesEnabled || projection.projectionRequiresLossesEnabled : void 0,
@@ -17971,6 +18031,7 @@ function simulateConsensusOracleSettlement(args) {
17971
18031
  consensus,
17972
18032
  navContributions,
17973
18033
  grossNav,
18034
+ realizedApy,
17974
18035
  current
17975
18036
  };
17976
18037
  }
@@ -18045,8 +18106,23 @@ function settleVault(args) {
18045
18106
  `crank would fail LossesDisabled: gross NAV ${args.grossNav} is more than ${NAV_LOSS_TOLERANCE_BPS}bps below physical NAV ${physicalNavBefore}`
18046
18107
  );
18047
18108
  }
18048
- const priorTs = args.priorSettledNavTs > 0n ? args.priorSettledNavTs : max(args.accountingLastUpdateTs, args.apyAnchorTs);
18049
- const nextApyValue = args.tranche ? args.grossNav : sharePriceForValue(args.grossNav, args.totalSupply);
18109
+ const priorSettledTs = args.priorSettledNavTs > 0n ? args.priorSettledNavTs : max(args.accountingLastUpdateTs, args.apyAnchorTs);
18110
+ let maxApyAnchor = { ...args.maxApyAnchor };
18111
+ let timestampSource = "apy.max_apy_anchor.timestamp";
18112
+ if (maxApyAnchor.sharePrice <= 0n || maxApyAnchor.timestamp <= 0n) {
18113
+ const hasFixedAnchor = args.apyAnchorSharePrice > 0n && args.apyAnchorTs > 0n;
18114
+ maxApyAnchor = {
18115
+ sharePrice: hasFixedAnchor ? args.apyAnchorSharePrice : args.currentSharePrice,
18116
+ timestamp: hasFixedAnchor ? args.apyAnchorTs : max(priorSettledTs, args.accountingLastUpdateTs),
18117
+ previousSharePrice: 0n,
18118
+ previousTimestamp: 0n
18119
+ };
18120
+ timestampSource = hasFixedAnchor ? "legacy fixed-APY anchor (initialization)" : "current share-price observation (initialization)";
18121
+ }
18122
+ const usePrevious = args.nowTs - maxApyAnchor.timestamp < MAX_APY_ANCHOR_WINDOW_SECS && maxApyAnchor.previousSharePrice > 0n && maxApyAnchor.previousTimestamp > 0n;
18123
+ const priorApyValue = usePrevious ? maxApyAnchor.previousSharePrice : maxApyAnchor.sharePrice;
18124
+ const priorTs = usePrevious ? maxApyAnchor.previousTimestamp : maxApyAnchor.timestamp;
18125
+ if (usePrevious) timestampSource = "apy.max_apy_anchor.previous_timestamp";
18050
18126
  let regularValue;
18051
18127
  let regularSharePrice = args.currentSharePrice;
18052
18128
  let regularHwmSharePrice = args.hwmSharePrice;
@@ -18119,15 +18195,55 @@ function settleVault(args) {
18119
18195
  curatorFee = regularFees.fees.curator;
18120
18196
  protocolFee = regularFees.fees.protocol;
18121
18197
  }
18198
+ const nextApyValue = args.totalSupply > 0n ? regularSharePrice : void 0;
18199
+ const elapsedSecs = args.nowTs - priorTs;
18200
+ const numerator = nextApyValue === void 0 ? void 0 : (nextApyValue - priorApyValue) * BPS_DENOMINATOR3 * SECONDS_PER_YEAR;
18201
+ const denominator = priorApyValue * elapsedSecs;
18202
+ const rateAvailable = numerator !== void 0 && priorApyValue > 0n && priorTs > 0n && elapsedSecs > 0n;
18203
+ args.onRealizedApy({
18204
+ basis: "regular-share-price",
18205
+ priorValue: priorApyValue,
18206
+ nextValue: nextApyValue,
18207
+ priorTs,
18208
+ timestampSource,
18209
+ checkpointTs: maxApyAnchor.timestamp,
18210
+ nowTs: args.nowTs,
18211
+ elapsedSecs,
18212
+ impliedApyMicroBps: rateAvailable ? numerator * 1000000n / denominator : void 0,
18213
+ minimumCapBps: rateAvailable ? numerator > 0n ? (numerator + denominator - 1n) / denominator : 0n : void 0,
18214
+ maxApyBps: args.maxApyBps,
18215
+ fixedApyBps: args.fixedApyBps,
18216
+ hwmBefore: args.hwmSharePrice,
18217
+ hwmAfter: regularHwmSharePrice
18218
+ });
18122
18219
  if (regularHwmSharePrice > args.hwmSharePrice && nextApyValue !== void 0) {
18123
18220
  validateRealizedApy(
18124
- args.tranche ? physicalNavBefore : args.currentSharePrice,
18221
+ priorApyValue,
18125
18222
  priorTs,
18126
18223
  nextApyValue,
18127
18224
  args.nowTs,
18128
18225
  args.maxApyBps
18129
18226
  );
18130
18227
  }
18228
+ if (args.totalSupply > 0n) {
18229
+ if (maxApyAnchor.sharePrice <= 0n || maxApyAnchor.timestamp <= 0n) {
18230
+ maxApyAnchor = {
18231
+ sharePrice: regularSharePrice,
18232
+ timestamp: args.nowTs,
18233
+ previousSharePrice: 0n,
18234
+ previousTimestamp: 0n
18235
+ };
18236
+ } else if (args.nowTs - maxApyAnchor.timestamp >= MAX_APY_ANCHOR_WINDOW_SECS) {
18237
+ maxApyAnchor = {
18238
+ sharePrice: regularSharePrice,
18239
+ timestamp: args.nowTs,
18240
+ previousSharePrice: maxApyAnchor.sharePrice,
18241
+ previousTimestamp: maxApyAnchor.timestamp
18242
+ };
18243
+ }
18244
+ } else {
18245
+ maxApyAnchor = args.maxApyAnchor;
18246
+ }
18131
18247
  const totalFees = curatorFee + protocolFee;
18132
18248
  const netRegularBacking = mulDiv2(
18133
18249
  args.totalSupply,
@@ -18154,6 +18270,7 @@ function settleVault(args) {
18154
18270
  return {
18155
18271
  settledAccountingNav,
18156
18272
  projected,
18273
+ maxApyAnchor,
18157
18274
  performanceFees: {
18158
18275
  curator: curatorFee,
18159
18276
  protocol: protocolFee,
@@ -18162,6 +18279,15 @@ function settleVault(args) {
18162
18279
  }
18163
18280
  };
18164
18281
  }
18282
+ function decodeMaxApyAnchor(value) {
18283
+ const decoded = record(value);
18284
+ return {
18285
+ sharePrice: bigint(decoded.sharePrice),
18286
+ timestamp: bigint(decoded.timestamp),
18287
+ previousSharePrice: bigint(decoded.previousSharePrice),
18288
+ previousTimestamp: bigint(decoded.previousTimestamp)
18289
+ };
18290
+ }
18165
18291
  function settleTrancheNav(tranche, currentTvl, nextTvl, nowTs) {
18166
18292
  const before = tranche.junior.value + tranche.senior.value;
18167
18293
  if (before === 0n) {
@@ -18343,7 +18469,7 @@ function validateRealizedApy(priorValue, priorTs, nextValue, nextTs, maxApyBps)
18343
18469
  const lhs = (nextValue - priorValue) * BPS_DENOMINATOR3 * SECONDS_PER_YEAR;
18344
18470
  const rhs = BigInt(maxApyBps) * priorValue * elapsed;
18345
18471
  if (lhs > rhs) {
18346
- const implied = lhs / (priorValue * elapsed);
18472
+ const implied = formatUnits(lhs * 1000000n / (priorValue * elapsed), 6);
18347
18473
  throw new Error(
18348
18474
  `crank would fail MaxApyExceeded: implied ${implied}bps > ${maxApyBps}bps`
18349
18475
  );
@@ -18700,6 +18826,13 @@ function formatSettlementSimulation(simulation) {
18700
18826
  lines.push(
18701
18827
  ` crank simulation: ${simulation.canSettle ? "WOULD SETTLE" : "BLOCKED"}`
18702
18828
  );
18829
+ if (simulation.realizedApy) {
18830
+ lines.push(...formatRealizedApy(simulation.realizedApy));
18831
+ } else {
18832
+ lines.push(
18833
+ " max-APY diagnostic unavailable: settlement did not reach the APY check"
18834
+ );
18835
+ }
18703
18836
  for (const holding of simulation.consensus) {
18704
18837
  const detail = holding.settledPrice ? `price=${holding.settledPrice} external=${holding.settledExternalAmount}` : holding.reason ?? "no aggregate";
18705
18838
  lines.push(
@@ -18821,6 +18954,70 @@ function formatSettlementSimulation(simulation) {
18821
18954
  lines.push(` warning: ${warning}`);
18822
18955
  return lines;
18823
18956
  }
18957
+ function formatRealizedApy(apy) {
18958
+ const lines = [
18959
+ ` max-APY share-price anchor -> settled regular share price (after tranche allocation, fixed APY, and fees): ${formatUnits(
18960
+ apy.priorValue,
18961
+ 6
18962
+ )} [${apy.priorValue}] -> ${apy.nextValue === void 0 ? "unavailable (zero supply)" : `${formatUnits(apy.nextValue, 6)} [${apy.nextValue}]`}`,
18963
+ ` weekly checkpoints: every 604800s (7 days); previous checkpoint retained through rollover; latest=${apy.checkpointTs}`,
18964
+ ` observation window: ${formatUnits(
18965
+ apy.elapsedSecs * 1000000n / 86400n,
18966
+ 6
18967
+ )} days${apy.elapsedSecs < MAX_APY_ANCHOR_WINDOW_SECS ? " (initial history is shorter than 7 days)" : ""}`,
18968
+ ` timestamp: ${apy.priorTs} from ${apy.timestampSource}; settlement time estimate=${apy.nowTs}; elapsed=${apy.elapsedSecs}s`,
18969
+ ` configured max: ${apy.maxApyBps}bps (${formatUnits(
18970
+ BigInt(apy.maxApyBps),
18971
+ 2
18972
+ )}%); regular HWM: ${apy.hwmBefore} -> ${apy.hwmAfter}`
18973
+ ];
18974
+ if (apy.impliedApyMicroBps !== void 0) {
18975
+ lines.push(
18976
+ ` implied APY (linear annualization): ${formatUnits(
18977
+ apy.impliedApyMicroBps,
18978
+ 6
18979
+ )}bps (${formatUnits(apy.impliedApyMicroBps, 8)}%)`
18980
+ );
18981
+ lines.push(
18982
+ " formula: (new - anchor) * 10,000 * 31,536,000 / (anchor * elapsed_seconds)"
18983
+ );
18984
+ } else {
18985
+ lines.push(
18986
+ " implied APY: unavailable (missing baseline/supply or non-positive elapsed time)"
18987
+ );
18988
+ }
18989
+ const hwmAdvances = apy.hwmAfter > apy.hwmBefore;
18990
+ const positiveGrowth = apy.nextValue !== void 0 && apy.nextValue > apy.priorValue;
18991
+ const comparisonApplies = hwmAdvances && positiveGrowth && apy.priorValue > 0n && apy.priorTs > 0n;
18992
+ const status = apy.maxApyBps === 0 ? "DISABLED (0 means uncapped)" : !hwmAdvances ? "BYPASSED (regular HWM does not advance)" : apy.nextValue === void 0 ? "BYPASSED (zero regular supply)" : apy.priorValue === 0n || apy.priorTs <= 0n ? "BYPASSED (no valid prior anchor)" : !positiveGrowth ? "BYPASSED (no positive growth)" : apy.elapsedSecs <= 0n ? "BLOCKED (positive growth with no elapsed time; no nonzero cap passes)" : apy.minimumCapBps > BigInt(apy.maxApyBps) ? "BLOCKED (MaxApyExceeded)" : "PASS";
18993
+ lines.push(` max-APY guard: ${status}`);
18994
+ if (comparisonApplies && apy.elapsedSecs > 0n && apy.minimumCapBps !== void 0) {
18995
+ const minimum = max(1n, max(apy.minimumCapBps, BigInt(apy.fixedApyBps)));
18996
+ lines.push(
18997
+ ` minimum nonzero --max-apy-bps for this snapshot: ${minimum} (${formatUnits(
18998
+ minimum,
18999
+ 2
19000
+ )}%; rounded UP, includes fixed-APY config floor)`
19001
+ );
19002
+ if (minimum > BPS_DENOMINATOR3) {
19003
+ lines.push(
19004
+ " exceeds the configurable maximum of 10000bps (100%); no supported nonzero cap passes this snapshot"
19005
+ );
19006
+ }
19007
+ } else if (comparisonApplies && apy.elapsedSecs <= 0n) {
19008
+ lines.push(
19009
+ " no nonzero cap passes positive growth until settlement time advances beyond the anchor"
19010
+ );
19011
+ } else if (!comparisonApplies) {
19012
+ lines.push(
19013
+ " this settlement does not require a higher cap; the HWM/baseline/growth gate bypasses the comparison"
19014
+ );
19015
+ }
19016
+ lines.push(
19017
+ " estimate uses current consensus and sampled time; later reports or settlement time can change it"
19018
+ );
19019
+ return lines;
19020
+ }
18824
19021
  function formatTransition(before, after, decimals) {
18825
19022
  return `${formatUnits(before, decimals)} [${before}] -> ${formatUnits(
18826
19023
  after,
@@ -19042,12 +19239,7 @@ async function gatherPricingInputs(deps, target, vaultState, reportableHoldings,
19042
19239
  `no USD price for base asset ${baseMint} (cannot denominate prices)`
19043
19240
  );
19044
19241
  }
19045
- const lpByMint = await fetchExternalPositions(
19046
- deps,
19047
- target,
19048
- vaultState,
19049
- log
19050
- );
19242
+ const lpByMint = await fetchExternalPositions(deps, target, vaultState, log);
19051
19243
  return {
19052
19244
  assetDecimals: vaultState.config.assetDecimals,
19053
19245
  baseUsd,
@@ -19231,14 +19423,6 @@ async function settleVault2({
19231
19423
  ` holding #${update.holdingIndex} ${update.mint}: price=${update.price} external_amount=${update.externalAmount} [lp=${update.lpAmount} tracked=${update.trackedValueAmount} principal=${update.trackedPrincipalAmount} yield=${update.yieldAmount}]`
19232
19424
  );
19233
19425
  }
19234
- await logProspectiveApy({
19235
- client,
19236
- vault,
19237
- updates,
19238
- vaultState,
19239
- nowSecs,
19240
- log
19241
- });
19242
19426
  try {
19243
19427
  const simulation = await simulateDryRunSettlement({
19244
19428
  client,
@@ -19321,7 +19505,7 @@ async function logProspectiveApy({
19321
19505
  if (elapsedSecs <= 0n) return;
19322
19506
  const apyBps = (prospectiveNav - physicalNavBefore) * SECONDS_PER_YEAR2 * 10000n / (physicalNavBefore * elapsedSecs);
19323
19507
  log(
19324
- `vault ${vault}: prospective NAV ${prospectiveNav} vs physical baseline ${physicalNavBefore} (elapsed ${elapsedSecs}s) \u2192 implied APY ${apyBps}bps`
19508
+ `vault ${vault}: raw candidate estimate (before consensus, not the max-APY check): NAV ${prospectiveNav} vs physical baseline ${physicalNavBefore} (elapsed ${elapsedSecs}s) \u2192 implied APY ${apyBps}bps`
19325
19509
  );
19326
19510
  } catch {
19327
19511
  }
@@ -21024,6 +21208,7 @@ var import_common56 = __toESM(require_dist());
21024
21208
  LOCAL_PROTOCOL_ADMIN,
21025
21209
  LargeBalanceChangeError,
21026
21210
  LivePriceSource,
21211
+ MAX_APY_ANCHOR_WINDOW_SECS,
21027
21212
  MAX_BALANCE_CHANGE_BPS,
21028
21213
  MAX_CONSENSUS_SIGNERS,
21029
21214
  MAX_INCENTIVE_RECIPIENTS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perena/vault-sdk",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "Vault program helpers for Bankineco integrations.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",