@perena/vault-sdk 1.0.64 → 1.0.66

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
@@ -11366,6 +11366,8 @@ declare class AccountClient extends BaseAccountClient {
11366
11366
  fetchVaultOracleForVault(vault: Address, opts?: {
11367
11367
  fresh?: boolean;
11368
11368
  }): Promise<VaultOracleAccountData>;
11369
+ /** Fresh discovery read: only an absent oracle returns null; RPC errors propagate. */
11370
+ fetchVaultOracleForVaultNullable(vault: Address): Promise<VaultOracleAccountData | null>;
11369
11371
  fetchVaultTrancheState(vaultTrancheState: Address, opts?: {
11370
11372
  fresh?: boolean;
11371
11373
  }): Promise<VaultTrancheStateAccountData>;
@@ -14867,6 +14869,8 @@ declare const MANAGER_WALLET_NAV_DROP_TRIGGER_BPS = 10n;
14867
14869
  declare const MANAGER_WALLET_NAV_TOLERANCE_BPS = 5n;
14868
14870
  /** Wallet USDC must match pending Nest value within ±5%, inclusively. */
14869
14871
  declare const NEST_WITHDRAWAL_MATCH_TOLERANCE_BPS = 500n;
14872
+ /** Maximum per-holding external-value drift while preparing a report. */
14873
+ declare const RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS = 3n;
14870
14874
  /** Previous physical NAV, including banked APY, adjusted for recorded cash flows. */
14871
14875
  declare function previousPhysicalNav(state: DecodedVault): bigint;
14872
14876
  /** Same per-holding integer valuation as the program's gross_nav_from_holdings. */
@@ -14895,8 +14899,16 @@ declare function reconcileManagerWalletBalances({ vault, vaultState, updates, so
14895
14899
  }): Promise<ManagerWalletReconciliation>;
14896
14900
  /** Exempt only the matched Nest-to-USDC conversion from the per-asset guard. */
14897
14901
  declare function walletReconciliationGuardUpdates(state: DecodedVault, reconciliation: ManagerWalletReconciliation): HoldingUpdatePreview[];
14898
- /** The vault fields whose changes would invalidate a wallet reconciliation. */
14902
+ /** Holding identities and local token balances must still match exactly. */
14899
14903
  declare function managerReconciliationStateKey(state: DecodedVault): string;
14904
+ /**
14905
+ * Capture immutable external amount × price numerators, optionally overlaying
14906
+ * the report. Decimal scales cancel in a per-holding comparison; keeping the
14907
+ * numerators avoids rounding away changes in small or high-precision holdings.
14908
+ */
14909
+ declare function reconciliationExternalValues(state: DecodedVault, updates?: readonly HoldingUpdatePreview[]): bigint[];
14910
+ /** Inclusive ±3 bps against each initial value; zero must remain zero. */
14911
+ declare function assertReconciliationExternalValues(initial: readonly bigint[], current: readonly bigint[], errorPrefix: string): void;
14900
14912
 
14901
14913
  declare function gatherPricingInputs(deps: ConsensusOracleDeps, target: ConsensusOracleTarget, vaultState: DecodedVault, reportableHoldings: ConsensusHoldingEntry[], log?: (msg: string) => void): Promise<VaultPricingInputs>;
14902
14914
  /**
@@ -15779,4 +15791,4 @@ declare function collectVaultLookupTableAccounts(client: VaultClient, vault: Add
15779
15791
  extraAccounts?: Address[];
15780
15792
  }): Promise<Address[]>;
15781
15793
 
15782
- 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, AddIncentiveRecipientV3Builder, type AddIncentiveRecipientV3IxArgs, type AddIncentiveRecipientV3TxArgs, 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, ClaimIncentiveV3Builder, type ClaimIncentiveV3IxArgs, type ClaimIncentiveV3TxArgs, 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, CreateIncentiveV3Builder, type CreateIncentiveV3IxArgs, type CreateIncentiveV3TxArgs, type CreateTokenMintIxs, CreateTrancheStateBuilder, type CreateTrancheStateIxArgs, type CreateTrancheStateTxArgs, CreateVaultBuilder, type CreateVaultClientOptions, type CreateVaultIxArgs, type CreateVaultParams, type CreateVaultTxArgs, type CreateYieldPaymentParams, DEFAULT_CU_PRICE_MICRO_LAMPORTS, DEFAULT_EXTERNAL_WEIGHT_BAND_BPS, DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS, DEFAULT_MARGINFI_WEIGHT_BPS, DEFAULT_MAX_ACCEPTABLE_APY_BPS, 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_TARGET_LOCAL_USDC_TVL_BPS, DEFAULT_VAULT_ID, type DecodedHolding, type DecodedVault, type DecodedVaultTrancheState, type DeleteAccountParams, DepositCuratorFeesBuilder, type DepositCuratorFeesIxArgs, type DepositCuratorFeesTxArgs, DisableCircuitBreakerBuilder, type DisableCircuitBreakerIxArgs, type DisableCircuitBreakerTxArgs, DistributeIncentiveBuilder, type DistributeIncentiveIxArgs, type DistributeIncentiveTxArgs, DistributeIncentiveV3Builder, type DistributeIncentiveV3IxArgs, type DistributeIncentiveV3TxArgs, EXTERNAL_POSITION_SAMPLES, type EvmCallArg, type EvmContractCall, type EvmContractNavPriceConfig, 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, type HttpJsonNavPriceConfig, IDL, IDLE_RESERVE_FLOOR_BPS, IDLE_RESERVE_TARGET_BPS, type IdleLiquidityOptions, type IdleLiquidityResult, IdleLiquidityService, type IdleLiquidityStatus, type IncentiveRecipient, type IncentiveTotals, type IncentiveUsdUpdateArgs, type IncentiveV3OracleState, type IncentiveV3Recipient, type IncentiveV3Totals, InitializeVaultRolesBuilder, type InitializeVaultRolesIxArgs, type InitializeVaultRolesTxArgs, type JuniorWithdrawalMode, JupiterPriceSource, type JupiterPriceSourceOptions, JupiterSwapBuilder, type JupiterSwapIxArgs, type JupiterSwapTxArgs, KaminoLendPositionProvider, KaminoPositionProvider, LIVE_ORACLE_VARIANTS, LIVE_PRICE_REFRESH_INTERVAL_SECS, LOCAL_PROTOCOL_ADMIN, LargeBalanceChangeError, type LargeBalanceChangeViolation, type LiveConsensusOracleDepsOptions, LivePriceSource, type LivePriceSourceOptions, MANAGER_WALLET_NAV_DROP_TRIGGER_BPS, MANAGER_WALLET_NAV_TOLERANCE_BPS, MAX_APY_ANCHOR_WINDOW_SECS, MAX_APY_PREVIOUS_ANCHOR_AGE_SECS, MAX_BALANCE_CHANGE_BPS, MAX_CONSENSUS_SIGNERS, MAX_INCENTIVE_RECIPIENTS, MAX_INCENTIVE_REPORT_TTL, MAX_LUT_ADDRESSES, MAX_MANAGER_WITHDRAW_DESTINATIONS, MAX_ORACLE_IMPLIED_APY_BPS, MAX_PRICE_STALENESS_THRESHOLD_SECS, MIN_EXTERNAL_POSITION_SAMPLES, ManagerRedepositAssetBuilder, type ManagerRedepositAssetIxArgs, type ManagerRedepositAssetTxArgs, type ManagerWalletBalanceSource, type ManagerWalletReconciliation, ManagerWithdrawAssetBuilder, type ManagerWithdrawAssetIxArgs, type ManagerWithdrawAssetTxArgs, MarginfiPositionProvider, type MaxApyAnchorSnapshot, type MintConfig, type MintIdentifier, type MintInfo, MintRegistry, type MintRegistryOptions, type MockYieldAccountConfig, MockYieldTracker, type MockYieldTrackerOptions, type MpcWalletBalanceSource, type MpcWalletBalances, type MpcWalletConfig, NEST_API_BASE_URL, NEST_RWA_SHARE_MINT, NEST_VAULT_SLUG, NEST_WITHDRAWAL_MATCH_TOLERANCE_BPS, type NavAccountBalanceResponse, type NavAccountValueResponse, type NavCrankBlocker, type NavCrankBlockerReason, type NavCrankReadiness, type NavCrankResult, type NavPriceConfig, type NavPricePreview, type NavPriceProvenance, type NavYieldAccount, NestApiError, type NestApiOptions, type NestDepositPlan, NestPriceSource, type NestPriceSourceOptions, type NestRedemptionQuote, type NestRedemptionStatus, 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, PST_TO_USDC_MAX_SLIPPAGE_BPS, PdaClient, type PendingConsensusSignerSet, type PreparedDirectTransaction, type PreparedSquadsTransaction, type PreparedVaultTransaction, type PreviewNavPriceParams, type PriceOracleTypeArgs, type PriceSource, ProtocolInteractionBuilder, type ProtocolInteractionIxArgs, type ProtocolInteractionTxArgs, type QuoteFeeUnit, REPORTABLE_ORACLE_VARIANTS, type RealizedApySimulation, type RefreshLiveOraclePricesParams, RemoveAssetHoldingBuilder, type RemoveAssetHoldingIxArgs, type RemoveAssetHoldingTxArgs, ReportIncentiveV3Builder, type ReportIncentiveV3IxArgs, type ReportIncentiveV3TxArgs, RequestJuniorTrancheWithdrawBuilder, type RequestJuniorTrancheWithdrawIxArgs, type RequestJuniorTrancheWithdrawTxArgs, type ResolveExternalWithdrawArgs, type ResolvedExternalWithdraw, type ResolvedSquadsWalletRoute, type RollingLimitConfig, type RollingRebalanceLimitConfig, RpcManagerWalletBalanceSource, RpcMpcWalletBalanceSource, type RunLiveConsensusOracleOptions, type RunOptions, type RunSummary, SHARE_DECIMALS, SYSTEM_PROGRAM, SetAssetPriceOracleBuilder, type SetAssetPriceOracleIxArgs, type SetAssetPriceOracleTxArgs, SetExternalLiquidityBuilder, type SetExternalLiquidityIxArgs, type SetExternalLiquidityTxArgs, type SetIncentiveLimitsArgs, SetIncentiveLimitsBuilder, type SetIncentiveLimitsV3Args, SetIncentiveLimitsV3Builder, SetManagerWithdrawDestinationBuilder, type SetManagerWithdrawDestinationIxArgs, type SetManagerWithdrawDestinationTxArgs, SetProtocolFeeBuilder, type SetProtocolFeeIxArgs, type SetProtocolFeeTxArgs, SetVaultConfigBuilder, type SetVaultConfigIxArgs, type SetVaultConfigTxArgs, SettleIncentiveV3Builder, type SettleIncentiveV3IxArgs, type SettleIncentiveV3TxArgs, type SettleVaultParams, type SettleVaultResult, type SettlementSimulation, type SettlementSimulationSnapshot, type SimulateDryRunSettlementParams, type SimulateSettlementArgs, type SimulatedShareClass, SquadsProposalExecutionSimulationError, type SquadsProposalUpload, 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_LOOKUP_TABLES, 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 VaultIncentiveV3Account, type VaultIncentiveV3AccountData, type VaultLookupTableMap, VaultLutManager, 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, WITHDRAWABLE_RESERVE_FLOOR_BPS, type WithdrawProtocolFeesIxArgs, type WithdrawProtocolFeesTxArgs, type WithdrawalLeg, type WithdrawalPlan, type WithdrawalPricing, WithdrawalQueueService, type WithdrawalQueueSnapshot, type YieldAccount, type YieldAccountSnapshot, type YieldCalculationLog, type YieldCashflow, type YieldPaymentResponse, type YieldPaymentSnapshot, type YieldTracker, type YieldValuationModel, accountingUnitPriceToUsd, addCashflowUpdate, applyEffectiveApy, assertNoLargeBalanceChanges, assertNoUnconfirmedYieldPayments, assertOracleImpliedApy, buildHoldingUpdate, buildKaminoDepositInteraction, buildKaminoWithdrawInteraction, buildMarginfiWithdrawInteraction, buildNestDepositRequest, buildNestWithdrawalRequest, buildUpdates, candidateGrossNav, coerceBool, collectSamples, collectVaultLookupTableAccounts, confirmYieldPayment, createAccount, createLiveConsensusOracleDeps, createRpcFromConnection, createTokenMint, createTokenMintIxs, createVaultClient, createYieldPayment, dateToStr, decodeNestDepositRequest, decodeNestWithdrawalRequest, decodePendingConsensusSigners, defaultKeypairPath, deleteAccount, discoverVaultsForSigner, externalWithdrawComputeBudget, externalWithdrawLookupTables, fetchExternalPositions, fetchNestRedemptionQuote, fetchNestRedemptionStatus, fetchNestTokenPrice, fetchReceiptMints, filterTargetHoldings, findLargeBalanceChanges, findSquadsWalletRoute, formatSettlementSimulation, fromUiAmount, gatherPricingInputs, getAccount, getAccounts, getAprYield, getBalance, getCashflows, getIncentiveRecipientShareAtas, getIncentiveRecipients, getIncentiveReportRecipients, getIncentiveTotals, getIncentiveV3OracleState, getIncentiveV3RecipientShareAtas, getIncentiveV3Recipients, getIncentiveV3Totals, getNavValue, getRpcUrl, getTotalOutstandingYield, getTotalTrackedValue, getTotalYield, getTrackedValue, getVaultLookupTables, getVaultProgramId, getYield, getYieldPayments, indexConfigByMint, isEvmNavPriceConfig, isNavAccountBalance, isNavAccountValue, isNavYieldAccount, isVaultEnv, keypairAddress, loadKaminoDeposit, loadKaminoWithdrawal, loadKeypair, logProspectiveApy, makeProvider, managerReconciliationStateKey, mintTokensTo, mints, mostFrequent, parseExternalLiquidityRefs, planExternalAllocation, planRebalance, planWithdrawalLegs, prepareSquadsProposalUpload, prepareVaultTransaction, previewNavPrice, previousPhysicalNav, priceInAccountingUnit, publishedConsensusBlockers, readI64LE, readSplMintSupply, reconcileManagerWalletBalances, refreshLiveOraclePrices, resolveExternalWithdraw, resolveKeypairPath, resolveSquadsWalletRoute, resolveTrackedAmounts, resolveWithdrawalPlan, roundToNextUtcMidnight, runLiveConsensusOracle, selectReportableHoldings, settleVault, signerInOracleData, simulateConsensusOracleSettlement, simulateDryRunSettlement, simulateOraclePublication, simulateSquadsProposalExecution, sumPositionsByMint, systemClock, toBigInt, toUiAmount, toWeb3AccountMeta, trackedValueFromResponse, uniqueLutAddresses, updateAccount, updateDynamicApr, validateSquadsWalletRoutes, variantName, vaultAuthorityForWallet, walletReconciliationGuardUpdates, withDiscoveredYieldAccounts, withVaultLookupTables, withdrawalComputeBudget };
15794
+ 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, AddIncentiveRecipientV3Builder, type AddIncentiveRecipientV3IxArgs, type AddIncentiveRecipientV3TxArgs, 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, ClaimIncentiveV3Builder, type ClaimIncentiveV3IxArgs, type ClaimIncentiveV3TxArgs, 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, CreateIncentiveV3Builder, type CreateIncentiveV3IxArgs, type CreateIncentiveV3TxArgs, type CreateTokenMintIxs, CreateTrancheStateBuilder, type CreateTrancheStateIxArgs, type CreateTrancheStateTxArgs, CreateVaultBuilder, type CreateVaultClientOptions, type CreateVaultIxArgs, type CreateVaultParams, type CreateVaultTxArgs, type CreateYieldPaymentParams, DEFAULT_CU_PRICE_MICRO_LAMPORTS, DEFAULT_EXTERNAL_WEIGHT_BAND_BPS, DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS, DEFAULT_MARGINFI_WEIGHT_BPS, DEFAULT_MAX_ACCEPTABLE_APY_BPS, 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_TARGET_LOCAL_USDC_TVL_BPS, DEFAULT_VAULT_ID, type DecodedHolding, type DecodedVault, type DecodedVaultTrancheState, type DeleteAccountParams, DepositCuratorFeesBuilder, type DepositCuratorFeesIxArgs, type DepositCuratorFeesTxArgs, DisableCircuitBreakerBuilder, type DisableCircuitBreakerIxArgs, type DisableCircuitBreakerTxArgs, DistributeIncentiveBuilder, type DistributeIncentiveIxArgs, type DistributeIncentiveTxArgs, DistributeIncentiveV3Builder, type DistributeIncentiveV3IxArgs, type DistributeIncentiveV3TxArgs, EXTERNAL_POSITION_SAMPLES, type EvmCallArg, type EvmContractCall, type EvmContractNavPriceConfig, 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, type HttpJsonNavPriceConfig, IDL, IDLE_RESERVE_FLOOR_BPS, IDLE_RESERVE_TARGET_BPS, type IdleLiquidityOptions, type IdleLiquidityResult, IdleLiquidityService, type IdleLiquidityStatus, type IncentiveRecipient, type IncentiveTotals, type IncentiveUsdUpdateArgs, type IncentiveV3OracleState, type IncentiveV3Recipient, type IncentiveV3Totals, InitializeVaultRolesBuilder, type InitializeVaultRolesIxArgs, type InitializeVaultRolesTxArgs, type JuniorWithdrawalMode, JupiterPriceSource, type JupiterPriceSourceOptions, JupiterSwapBuilder, type JupiterSwapIxArgs, type JupiterSwapTxArgs, KaminoLendPositionProvider, KaminoPositionProvider, LIVE_ORACLE_VARIANTS, LIVE_PRICE_REFRESH_INTERVAL_SECS, LOCAL_PROTOCOL_ADMIN, LargeBalanceChangeError, type LargeBalanceChangeViolation, type LiveConsensusOracleDepsOptions, LivePriceSource, type LivePriceSourceOptions, MANAGER_WALLET_NAV_DROP_TRIGGER_BPS, MANAGER_WALLET_NAV_TOLERANCE_BPS, MAX_APY_ANCHOR_WINDOW_SECS, MAX_APY_PREVIOUS_ANCHOR_AGE_SECS, MAX_BALANCE_CHANGE_BPS, MAX_CONSENSUS_SIGNERS, MAX_INCENTIVE_RECIPIENTS, MAX_INCENTIVE_REPORT_TTL, MAX_LUT_ADDRESSES, MAX_MANAGER_WITHDRAW_DESTINATIONS, MAX_ORACLE_IMPLIED_APY_BPS, MAX_PRICE_STALENESS_THRESHOLD_SECS, MIN_EXTERNAL_POSITION_SAMPLES, ManagerRedepositAssetBuilder, type ManagerRedepositAssetIxArgs, type ManagerRedepositAssetTxArgs, type ManagerWalletBalanceSource, type ManagerWalletReconciliation, ManagerWithdrawAssetBuilder, type ManagerWithdrawAssetIxArgs, type ManagerWithdrawAssetTxArgs, MarginfiPositionProvider, type MaxApyAnchorSnapshot, type MintConfig, type MintIdentifier, type MintInfo, MintRegistry, type MintRegistryOptions, type MockYieldAccountConfig, MockYieldTracker, type MockYieldTrackerOptions, type MpcWalletBalanceSource, type MpcWalletBalances, type MpcWalletConfig, NEST_API_BASE_URL, NEST_RWA_SHARE_MINT, NEST_VAULT_SLUG, NEST_WITHDRAWAL_MATCH_TOLERANCE_BPS, type NavAccountBalanceResponse, type NavAccountValueResponse, type NavCrankBlocker, type NavCrankBlockerReason, type NavCrankReadiness, type NavCrankResult, type NavPriceConfig, type NavPricePreview, type NavPriceProvenance, type NavYieldAccount, NestApiError, type NestApiOptions, type NestDepositPlan, NestPriceSource, type NestPriceSourceOptions, type NestRedemptionQuote, type NestRedemptionStatus, 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, PST_TO_USDC_MAX_SLIPPAGE_BPS, PdaClient, type PendingConsensusSignerSet, type PreparedDirectTransaction, type PreparedSquadsTransaction, type PreparedVaultTransaction, type PreviewNavPriceParams, type PriceOracleTypeArgs, type PriceSource, ProtocolInteractionBuilder, type ProtocolInteractionIxArgs, type ProtocolInteractionTxArgs, type QuoteFeeUnit, RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS, REPORTABLE_ORACLE_VARIANTS, type RealizedApySimulation, type RefreshLiveOraclePricesParams, RemoveAssetHoldingBuilder, type RemoveAssetHoldingIxArgs, type RemoveAssetHoldingTxArgs, ReportIncentiveV3Builder, type ReportIncentiveV3IxArgs, type ReportIncentiveV3TxArgs, RequestJuniorTrancheWithdrawBuilder, type RequestJuniorTrancheWithdrawIxArgs, type RequestJuniorTrancheWithdrawTxArgs, type ResolveExternalWithdrawArgs, type ResolvedExternalWithdraw, type ResolvedSquadsWalletRoute, type RollingLimitConfig, type RollingRebalanceLimitConfig, RpcManagerWalletBalanceSource, RpcMpcWalletBalanceSource, type RunLiveConsensusOracleOptions, type RunOptions, type RunSummary, SHARE_DECIMALS, SYSTEM_PROGRAM, SetAssetPriceOracleBuilder, type SetAssetPriceOracleIxArgs, type SetAssetPriceOracleTxArgs, SetExternalLiquidityBuilder, type SetExternalLiquidityIxArgs, type SetExternalLiquidityTxArgs, type SetIncentiveLimitsArgs, SetIncentiveLimitsBuilder, type SetIncentiveLimitsV3Args, SetIncentiveLimitsV3Builder, SetManagerWithdrawDestinationBuilder, type SetManagerWithdrawDestinationIxArgs, type SetManagerWithdrawDestinationTxArgs, SetProtocolFeeBuilder, type SetProtocolFeeIxArgs, type SetProtocolFeeTxArgs, SetVaultConfigBuilder, type SetVaultConfigIxArgs, type SetVaultConfigTxArgs, SettleIncentiveV3Builder, type SettleIncentiveV3IxArgs, type SettleIncentiveV3TxArgs, type SettleVaultParams, type SettleVaultResult, type SettlementSimulation, type SettlementSimulationSnapshot, type SimulateDryRunSettlementParams, type SimulateSettlementArgs, type SimulatedShareClass, SquadsProposalExecutionSimulationError, type SquadsProposalUpload, 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_LOOKUP_TABLES, 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 VaultIncentiveV3Account, type VaultIncentiveV3AccountData, type VaultLookupTableMap, VaultLutManager, 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, WITHDRAWABLE_RESERVE_FLOOR_BPS, type WithdrawProtocolFeesIxArgs, type WithdrawProtocolFeesTxArgs, type WithdrawalLeg, type WithdrawalPlan, type WithdrawalPricing, WithdrawalQueueService, type WithdrawalQueueSnapshot, type YieldAccount, type YieldAccountSnapshot, type YieldCalculationLog, type YieldCashflow, type YieldPaymentResponse, type YieldPaymentSnapshot, type YieldTracker, type YieldValuationModel, accountingUnitPriceToUsd, addCashflowUpdate, applyEffectiveApy, assertNoLargeBalanceChanges, assertNoUnconfirmedYieldPayments, assertOracleImpliedApy, assertReconciliationExternalValues, buildHoldingUpdate, buildKaminoDepositInteraction, buildKaminoWithdrawInteraction, buildMarginfiWithdrawInteraction, buildNestDepositRequest, buildNestWithdrawalRequest, buildUpdates, candidateGrossNav, coerceBool, collectSamples, collectVaultLookupTableAccounts, confirmYieldPayment, createAccount, createLiveConsensusOracleDeps, createRpcFromConnection, createTokenMint, createTokenMintIxs, createVaultClient, createYieldPayment, dateToStr, decodeNestDepositRequest, decodeNestWithdrawalRequest, decodePendingConsensusSigners, defaultKeypairPath, deleteAccount, discoverVaultsForSigner, externalWithdrawComputeBudget, externalWithdrawLookupTables, fetchExternalPositions, fetchNestRedemptionQuote, fetchNestRedemptionStatus, fetchNestTokenPrice, fetchReceiptMints, filterTargetHoldings, findLargeBalanceChanges, findSquadsWalletRoute, formatSettlementSimulation, fromUiAmount, gatherPricingInputs, getAccount, getAccounts, getAprYield, getBalance, getCashflows, getIncentiveRecipientShareAtas, getIncentiveRecipients, getIncentiveReportRecipients, getIncentiveTotals, getIncentiveV3OracleState, getIncentiveV3RecipientShareAtas, getIncentiveV3Recipients, getIncentiveV3Totals, getNavValue, getRpcUrl, getTotalOutstandingYield, getTotalTrackedValue, getTotalYield, getTrackedValue, getVaultLookupTables, getVaultProgramId, getYield, getYieldPayments, indexConfigByMint, isEvmNavPriceConfig, isNavAccountBalance, isNavAccountValue, isNavYieldAccount, isVaultEnv, keypairAddress, loadKaminoDeposit, loadKaminoWithdrawal, loadKeypair, logProspectiveApy, makeProvider, managerReconciliationStateKey, mintTokensTo, mints, mostFrequent, parseExternalLiquidityRefs, planExternalAllocation, planRebalance, planWithdrawalLegs, prepareSquadsProposalUpload, prepareVaultTransaction, previewNavPrice, previousPhysicalNav, priceInAccountingUnit, publishedConsensusBlockers, readI64LE, readSplMintSupply, reconcileManagerWalletBalances, reconciliationExternalValues, refreshLiveOraclePrices, resolveExternalWithdraw, resolveKeypairPath, resolveSquadsWalletRoute, resolveTrackedAmounts, resolveWithdrawalPlan, roundToNextUtcMidnight, runLiveConsensusOracle, selectReportableHoldings, settleVault, signerInOracleData, simulateConsensusOracleSettlement, simulateDryRunSettlement, simulateOraclePublication, simulateSquadsProposalExecution, sumPositionsByMint, systemClock, toBigInt, toUiAmount, toWeb3AccountMeta, trackedValueFromResponse, uniqueLutAddresses, updateAccount, updateDynamicApr, validateSquadsWalletRoutes, variantName, vaultAuthorityForWallet, walletReconciliationGuardUpdates, withDiscoveredYieldAccounts, withVaultLookupTables, withdrawalComputeBudget };
package/dist/index.js CHANGED
@@ -2147,6 +2147,7 @@ __export(index_exports, {
2147
2147
  PST_TO_USDC_MAX_SLIPPAGE_BPS: () => PST_TO_USDC_MAX_SLIPPAGE_BPS,
2148
2148
  PdaClient: () => PdaClient,
2149
2149
  ProtocolInteractionBuilder: () => ProtocolInteractionBuilder,
2150
+ RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS: () => RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS,
2150
2151
  REPORTABLE_ORACLE_VARIANTS: () => REPORTABLE_ORACLE_VARIANTS,
2151
2152
  RemoveAssetHoldingBuilder: () => RemoveAssetHoldingBuilder,
2152
2153
  ReportIncentiveV3Builder: () => ReportIncentiveV3Builder,
@@ -2203,6 +2204,7 @@ __export(index_exports, {
2203
2204
  assertNoLargeBalanceChanges: () => assertNoLargeBalanceChanges,
2204
2205
  assertNoUnconfirmedYieldPayments: () => assertNoUnconfirmedYieldPayments,
2205
2206
  assertOracleImpliedApy: () => assertOracleImpliedApy,
2207
+ assertReconciliationExternalValues: () => assertReconciliationExternalValues,
2206
2208
  buildHoldingUpdate: () => buildHoldingUpdate,
2207
2209
  buildKaminoDepositInteraction: () => buildKaminoDepositInteraction,
2208
2210
  buildKaminoWithdrawInteraction: () => buildKaminoWithdrawInteraction,
@@ -2294,6 +2296,7 @@ __export(index_exports, {
2294
2296
  readI64LE: () => readI64LE,
2295
2297
  readSplMintSupply: () => readSplMintSupply,
2296
2298
  reconcileManagerWalletBalances: () => reconcileManagerWalletBalances,
2299
+ reconciliationExternalValues: () => reconciliationExternalValues,
2297
2300
  refreshLiveOraclePrices: () => refreshLiveOraclePrices,
2298
2301
  resolveExternalWithdraw: () => resolveExternalWithdraw,
2299
2302
  resolveKeypairPath: () => resolveKeypairPath,
@@ -13600,6 +13603,13 @@ var AccountClient = class extends import_common.BaseAccountClient {
13600
13603
  const [vaultOracle] = await this.pda.deriveVaultOraclePda(vault);
13601
13604
  return this.fetchVaultOracle(vaultOracle, opts);
13602
13605
  }
13606
+ /** Fresh discovery read: only an absent oracle returns null; RPC errors propagate. */
13607
+ async fetchVaultOracleForVaultNullable(vault) {
13608
+ const [vaultOracle] = await this.pda.deriveVaultOraclePda(vault);
13609
+ return this.program.account.vaultOracle.fetchNullable(
13610
+ (0, import_common.toWeb3Pk)(vaultOracle)
13611
+ );
13612
+ }
13603
13613
  async fetchVaultTrancheState(vaultTrancheState, opts) {
13604
13614
  if (opts?.fresh) {
13605
13615
  this.dataCache.clearCacheEntry(
@@ -21494,6 +21504,7 @@ var NestPriceSource = class {
21494
21504
  var MANAGER_WALLET_NAV_DROP_TRIGGER_BPS = 10n;
21495
21505
  var MANAGER_WALLET_NAV_TOLERANCE_BPS = 5n;
21496
21506
  var NEST_WITHDRAWAL_MATCH_TOLERANCE_BPS = 500n;
21507
+ var RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS = 3n;
21497
21508
  var BPS = 10000n;
21498
21509
  var U64_MAX2 = 0xffffffffffffffffn;
21499
21510
  function previousPhysicalNav(state) {
@@ -21670,18 +21681,48 @@ function walletReconciliationGuardUpdates(state, reconciliation) {
21670
21681
  function managerReconciliationStateKey(state) {
21671
21682
  return JSON.stringify({
21672
21683
  manager: (0, import_common55.fromWeb3Pk)(state.roles.manager),
21673
- previousNav: previousPhysicalNav(state).toString(),
21684
+ assetDecimals: state.config.assetDecimals,
21674
21685
  holdings: state.holdings.map((holding) => [
21675
21686
  (0, import_common55.fromWeb3Pk)(holding.mint),
21676
21687
  holding.decimals,
21677
21688
  variantName2(holding.priceOracleType),
21689
+ holding.priceOracleAccount ? (0, import_common55.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
21678
21690
  coerceBool3(holding.isBase),
21679
- toBigInt2(holding.localAmount).toString(),
21680
- toBigInt2(holding.externalAmount).toString(),
21681
- toBigInt2(holding.price).toString()
21691
+ toBigInt2(holding.localAmount).toString()
21682
21692
  ])
21683
21693
  });
21684
21694
  }
21695
+ function reconciliationExternalValues(state, updates = []) {
21696
+ const byIndex = new Map(
21697
+ updates.map((update) => [update.holdingIndex, update])
21698
+ );
21699
+ return state.holdings.map((holding, index) => {
21700
+ const update = byIndex.get(index);
21701
+ const amount = update?.externalAmount ?? toBigInt2(holding.externalAmount);
21702
+ const price = update && variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT ? update.price : toBigInt2(holding.price);
21703
+ if (amount < 0n || amount > U64_MAX2 || price < 0n || amount > 0n && price === 0n) {
21704
+ throw new Error(`Invalid external value for holding #${index}`);
21705
+ }
21706
+ return amount * price;
21707
+ });
21708
+ }
21709
+ function assertReconciliationExternalValues(initial, current, errorPrefix) {
21710
+ if (initial.length !== current.length) {
21711
+ throw new Error(
21712
+ `${errorPrefix}: holding count changed; retry with fresh inputs`
21713
+ );
21714
+ }
21715
+ for (let index = 0; index < initial.length; index++) {
21716
+ const before = initial[index];
21717
+ const after = current[index];
21718
+ const delta = after >= before ? after - before : before - after;
21719
+ if (before < 0n || after < 0n || delta * BPS > before * RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS) {
21720
+ throw new Error(
21721
+ `${errorPrefix}: holding #${index} external value changed by more than ${RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS} bps; retry with fresh inputs`
21722
+ );
21723
+ }
21724
+ }
21725
+ }
21685
21726
 
21686
21727
  // src/services/consensusOracle/pipeline/pricingInputs.ts
21687
21728
  var import_common56 = __toESM(require_dist());
@@ -22016,20 +22057,38 @@ async function discoverVaultsForSigner(client, signer, opts = {}) {
22016
22057
  log(
22017
22058
  `Discovered ${allVaults.length} vault(s) on-chain, checking oracle membership\u2026`
22018
22059
  );
22019
- const results = [];
22020
- await Promise.all(
22060
+ const inspections = await Promise.allSettled(
22021
22061
  allVaults.map(async ({ publicKey: vault }) => {
22022
- try {
22023
- const oracle = await client.account.fetchVaultOracleForVault(vault);
22024
- const data = oracle.data;
22025
- if (signerInOracleData(data, signerBytes)) {
22026
- log(` ${vault}: signer is registered oracle`);
22027
- results.push({ vault });
22028
- }
22029
- } catch {
22030
- }
22062
+ const oracle = await client.account.fetchVaultOracleForVaultNullable(
22063
+ vault
22064
+ );
22065
+ if (!oracle) {
22066
+ log(` ${vault}: no oracle account, skipping`);
22067
+ return null;
22068
+ }
22069
+ const data = oracle.data;
22070
+ if (!signerInOracleData(data, signerBytes)) return null;
22071
+ log(` ${vault}: signer is registered oracle`);
22072
+ return { vault };
22031
22073
  })
22032
22074
  );
22075
+ const results = [];
22076
+ const unreadable = [];
22077
+ inspections.forEach((inspection, index) => {
22078
+ if (inspection.status === "fulfilled") {
22079
+ if (inspection.value) results.push(inspection.value);
22080
+ return;
22081
+ }
22082
+ const vault = allVaults[index].publicKey;
22083
+ const error = inspection.reason instanceof Error ? inspection.reason.message : String(inspection.reason);
22084
+ log(`FAILED oracle discovery ${vault}: ${error}`);
22085
+ unreadable.push(vault.toString());
22086
+ });
22087
+ if (unreadable.length > 0) {
22088
+ throw new Error(
22089
+ `Oracle discovery incomplete: could not inspect ${unreadable.length}/${allVaults.length} vault(s) (${unreadable.join(", ")}); refusing to run a partial target list`
22090
+ );
22091
+ }
22033
22092
  return results;
22034
22093
  }
22035
22094
 
@@ -23930,6 +23989,8 @@ var ConsensusOracleService = class {
23930
23989
  const needsRevalidation = reconciliation.walletBalancesChecked || // A new withdrawal can be queued after the first vault read, too.
23931
23990
  updates.some((update) => update.mint === NEST_RWA_SHARE_MINT);
23932
23991
  const reconciliationStateKey = needsRevalidation ? managerReconciliationStateKey(vaultState) : void 0;
23992
+ const initialExternalValues = needsRevalidation ? reconciliationExternalValues(vaultState) : [];
23993
+ const initialReportExternalValues = needsRevalidation ? reconciliationExternalValues(vaultState, updates) : [];
23933
23994
  assertNoLargeBalanceChanges(
23934
23995
  target.vault,
23935
23996
  vaultState,
@@ -24000,21 +24061,56 @@ var ConsensusOracleService = class {
24000
24061
  "Vault changed during manager-wallet reconciliation; retry with fresh inputs"
24001
24062
  );
24002
24063
  }
24003
- if (!reconciliation.walletBalancesChecked) return;
24004
- const fresh = await reconcileManagerWalletBalances({
24064
+ assertReconciliationExternalValues(
24065
+ initialExternalValues,
24066
+ reconciliationExternalValues(freshState),
24067
+ "Vault changed during manager-wallet reconciliation"
24068
+ );
24069
+ if (reconciliation.walletBalancesChecked) {
24070
+ const fresh = await reconcileManagerWalletBalances({
24071
+ vault: target.vault,
24072
+ vaultState: freshState,
24073
+ updates: sourcedUpdates,
24074
+ source: this.deps.managerWalletBalances,
24075
+ mpcSource: this.deps.mpcWalletBalances
24076
+ });
24077
+ if (!fresh.walletBalancesChecked || fresh.accepted !== reconciliation.accepted) {
24078
+ throw new Error(
24079
+ "Manager wallet changed or MPC balances changed during reconciliation; retry with fresh inputs"
24080
+ );
24081
+ }
24082
+ assertReconciliationExternalValues(
24083
+ initialReportExternalValues,
24084
+ reconciliationExternalValues(freshState, fresh.updates),
24085
+ "Manager wallet changed or MPC balances changed during reconciliation"
24086
+ );
24087
+ }
24088
+ assertNoLargeBalanceChanges(
24089
+ target.vault,
24090
+ freshState,
24091
+ walletReconciliationGuardUpdates(freshState, reconciliation),
24092
+ this.nowSecs(),
24093
+ log
24094
+ );
24095
+ const simulations = await simulateOraclePublication({
24096
+ client: this.client,
24097
+ signer,
24005
24098
  vault: target.vault,
24006
24099
  vaultState: freshState,
24007
- updates: sourcedUpdates,
24008
- source: this.deps.managerWalletBalances,
24009
- mpcSource: this.deps.mpcWalletBalances
24100
+ updates,
24101
+ nowSecs: this.nowSecs()
24010
24102
  });
24011
- if (!fresh.walletBalancesChecked || fresh.accepted !== reconciliation.accepted || fresh.updates.some(
24012
- (update, index) => update.externalAmount !== updates[index].externalAmount || update.managerWalletAmount !== updates[index].managerWalletAmount || update.mpcWalletAmount !== updates[index].mpcWalletAmount || update.mpcMarginfiAmount !== updates[index].mpcMarginfiAmount
24013
- )) {
24014
- throw new Error(
24015
- "Manager wallet changed or MPC balances changed during reconciliation; retry with fresh inputs"
24103
+ assertOracleImpliedApy(
24104
+ target.vault,
24105
+ simulations.proposed,
24106
+ "proposed report"
24107
+ );
24108
+ if (simulations.consensus.realizedApy)
24109
+ assertOracleImpliedApy(
24110
+ target.vault,
24111
+ simulations.consensus,
24112
+ "current consensus"
24016
24113
  );
24017
- }
24018
24114
  } : void 0
24019
24115
  });
24020
24116
  return {
@@ -26130,6 +26226,7 @@ var import_common68 = __toESM(require_dist());
26130
26226
  PST_TO_USDC_MAX_SLIPPAGE_BPS,
26131
26227
  PdaClient,
26132
26228
  ProtocolInteractionBuilder,
26229
+ RECONCILIATION_EXTERNAL_VALUE_TOLERANCE_BPS,
26133
26230
  REPORTABLE_ORACLE_VARIANTS,
26134
26231
  RemoveAssetHoldingBuilder,
26135
26232
  ReportIncentiveV3Builder,
@@ -26186,6 +26283,7 @@ var import_common68 = __toESM(require_dist());
26186
26283
  assertNoLargeBalanceChanges,
26187
26284
  assertNoUnconfirmedYieldPayments,
26188
26285
  assertOracleImpliedApy,
26286
+ assertReconciliationExternalValues,
26189
26287
  buildHoldingUpdate,
26190
26288
  buildKaminoDepositInteraction,
26191
26289
  buildKaminoWithdrawInteraction,
@@ -26277,6 +26375,7 @@ var import_common68 = __toESM(require_dist());
26277
26375
  readI64LE,
26278
26376
  readSplMintSupply,
26279
26377
  reconcileManagerWalletBalances,
26378
+ reconciliationExternalValues,
26280
26379
  refreshLiveOraclePrices,
26281
26380
  resolveExternalWithdraw,
26282
26381
  resolveKeypairPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perena/vault-sdk",
3
- "version": "1.0.64",
3
+ "version": "1.0.66",
4
4
  "description": "Vault program helpers for Bankineco integrations.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",