@perena/vault-sdk 1.0.59 → 1.0.61
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 +5 -2
- package/dist/index.d.ts +15 -12
- package/dist/index.js +83 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -928,8 +928,11 @@ use that protocol; both initialized, registered positions are required for the
|
|
|
928
928
|
USDC split. Other configured stablecoins continue to use Marginfi.
|
|
929
929
|
|
|
930
930
|
Allocation uses each live position's supplied balance, including accrued value,
|
|
931
|
-
and the actual vault token balance.
|
|
932
|
-
cash
|
|
931
|
+
and the actual vault token balance. Marginfi withdrawal capacity is capped by both
|
|
932
|
+
bank cash and total assets minus total liabilities, retaining 0.1% of that capacity
|
|
933
|
+
for interest accrual and rounding. This cap does not reduce the position value
|
|
934
|
+
used for allocation weights. Kamino capacity checks reserve cash, withdrawal caps
|
|
935
|
+
and queued redemptions. Utilization can limit a
|
|
933
936
|
rebalance to a partial transfer; subsequent runs retry if weights remain outside
|
|
934
937
|
the band. Each
|
|
935
938
|
mint's withdrawals and deposits share one atomic transaction and use the vault's
|
package/dist/index.d.ts
CHANGED
|
@@ -13248,6 +13248,8 @@ declare function loadKaminoWithdrawal(args: {
|
|
|
13248
13248
|
assetMint: Address;
|
|
13249
13249
|
/** Include an unfunded deposit destination. Used only for deposit planning. */
|
|
13250
13250
|
depositReserve?: Address;
|
|
13251
|
+
/** Fail closed when a registered position disappears during reserve checks. */
|
|
13252
|
+
requireInitialized?: boolean;
|
|
13251
13253
|
}): Promise<{
|
|
13252
13254
|
reserves: KaminoWithdrawReserve[];
|
|
13253
13255
|
reserve: KaminoWithdrawReserve;
|
|
@@ -13299,7 +13301,7 @@ interface WithdrawalPosition {
|
|
|
13299
13301
|
index: number;
|
|
13300
13302
|
/** Same account registered twice must not be spent twice. */
|
|
13301
13303
|
positionKey: string;
|
|
13302
|
-
/** Multiple positions
|
|
13304
|
+
/** Multiple positions share one bank/reserve's cash and protocol limits. */
|
|
13303
13305
|
poolKey: string;
|
|
13304
13306
|
poolAvailable: bigint;
|
|
13305
13307
|
capacity(poolAvailable: bigint): bigint;
|
|
@@ -15505,18 +15507,19 @@ declare class ExternalLiquidityIntegrityService {
|
|
|
15505
15507
|
* payouts can be served without unwinding yield positions on demand.
|
|
15506
15508
|
*
|
|
15507
15509
|
* Idle USDC is the live balance of the vault's USDC token account plus USDC
|
|
15508
|
-
* deposits in the first Project0 (Marginfi)
|
|
15509
|
-
* valued at the holding price.
|
|
15510
|
+
* deposits in the first Project0 (Marginfi) position and all registered Kamino
|
|
15511
|
+
* lending positions, valued at the holding price.
|
|
15510
15512
|
* The holding's aggregate `external_amount` includes other deployed capital
|
|
15511
15513
|
* and must not be used as the idle reserve.
|
|
15512
15514
|
*
|
|
15513
15515
|
* When idle USDC drops below {@link IDLE_RESERVE_FLOOR_BPS} of vault TVL, the
|
|
15514
15516
|
* service swaps PST into USDC through the permissioned `jupiter_swap`
|
|
15515
15517
|
* instruction, sizing the swap to land at {@link IDLE_RESERVE_TARGET_BPS} of
|
|
15516
|
-
* TVL. Independently, local USDC plus withdrawable Project0
|
|
15517
|
-
* {@link WITHDRAWABLE_RESERVE_FLOOR_BPS} of TVL.
|
|
15518
|
-
*
|
|
15519
|
-
*
|
|
15518
|
+
* TVL. Independently, local USDC plus withdrawable Project0 and Kamino deposits
|
|
15519
|
+
* must cover {@link WITHDRAWABLE_RESERVE_FLOOR_BPS} of TVL. Project0 liquidity is
|
|
15520
|
+
* capped by deposits minus borrows; Kamino also respects reserve cash, withdrawal
|
|
15521
|
+
* caps and queued withdrawals. Shared Kamino reserve liquidity is counted once.
|
|
15522
|
+
* The swap covers the larger of the two triggered shortfalls.
|
|
15520
15523
|
* PST is never deployed externally, so the vault's local PST balance is
|
|
15521
15524
|
* the whole swappable inventory; if it cannot cover the full top-up the run is
|
|
15522
15525
|
* skipped rather than partially filled.
|
|
@@ -15530,11 +15533,10 @@ declare class ExternalLiquidityIntegrityService {
|
|
|
15530
15533
|
declare const IDLE_RESERVE_FLOOR_BPS = 400;
|
|
15531
15534
|
/** Top-ups are sized to land idle USDC at this share of TVL. */
|
|
15532
15535
|
declare const IDLE_RESERVE_TARGET_BPS = 500;
|
|
15533
|
-
/** Local USDC + withdrawable Project0 deposits must cover 1.5% of TVL. */
|
|
15536
|
+
/** Local USDC + withdrawable Project0/Kamino deposits must cover 1.5% of TVL. */
|
|
15534
15537
|
declare const WITHDRAWABLE_RESERVE_FLOOR_BPS = 150;
|
|
15535
15538
|
declare const DEFAULT_SLIPPAGE_BPS = 30;
|
|
15536
15539
|
declare const DEFAULT_CU_PRICE_MICRO_LAMPORTS = 10000;
|
|
15537
|
-
declare const DEFAULT_MAX_ACCOUNTS = 20;
|
|
15538
15540
|
/**
|
|
15539
15541
|
* Mirrors `ASSET_REBALANCE_COOLDOWN_SECS` on-chain. Swapping inside the cooldown
|
|
15540
15542
|
* reverts with `AssetRebalanceRateLimitExceeded`, so the run is skipped instead.
|
|
@@ -15550,7 +15552,7 @@ interface IdleLiquidityResult {
|
|
|
15550
15552
|
reason: string;
|
|
15551
15553
|
/** Vault TVL in accounting units. */
|
|
15552
15554
|
tvl: bigint;
|
|
15553
|
-
/**
|
|
15555
|
+
/** Local, first Project0 and registered Kamino USDC, in accounting units. */
|
|
15554
15556
|
idleValue: bigint;
|
|
15555
15557
|
/** Idle USDC as a share of TVL, in bps. */
|
|
15556
15558
|
idleBps: number;
|
|
@@ -15590,8 +15592,9 @@ declare class IdleLiquidityService {
|
|
|
15590
15592
|
* Never throws for an expected no-op — inspect `status` on the result.
|
|
15591
15593
|
*/
|
|
15592
15594
|
run(vault: Address, hwManager: Keypair, opts?: IdleLiquidityOptions): Promise<IdleLiquidityResult>;
|
|
15593
|
-
/** Read
|
|
15595
|
+
/** Read live local, Project0 and Kamino USDC, excluding other deployed capital. */
|
|
15594
15596
|
private fetchIdleUsdc;
|
|
15597
|
+
private fetchKaminoUsdc;
|
|
15595
15598
|
/**
|
|
15596
15599
|
* Decide whether a top-up is warranted. Returns either a terminal `result`
|
|
15597
15600
|
* (nothing to do) or the holdings and sizing needed to build the swap.
|
|
@@ -15766,4 +15769,4 @@ declare function collectVaultLookupTableAccounts(client: VaultClient, vault: Add
|
|
|
15766
15769
|
extraAccounts?: Address[];
|
|
15767
15770
|
}): Promise<Address[]>;
|
|
15768
15771
|
|
|
15769
|
-
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_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_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, 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, 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, withDiscoveredYieldAccounts, withVaultLookupTables, withdrawalComputeBudget };
|
|
15772
|
+
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, 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, 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, withDiscoveredYieldAccounts, withVaultLookupTables, withdrawalComputeBudget };
|
package/dist/index.js
CHANGED
|
@@ -3736,7 +3736,6 @@ __export(index_exports, {
|
|
|
3736
3736
|
DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS: () => DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
|
|
3737
3737
|
DEFAULT_MARGINFI_WEIGHT_BPS: () => DEFAULT_MARGINFI_WEIGHT_BPS,
|
|
3738
3738
|
DEFAULT_MAX_ACCEPTABLE_APY_BPS: () => DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
3739
|
-
DEFAULT_MAX_ACCOUNTS: () => DEFAULT_MAX_ACCOUNTS,
|
|
3740
3739
|
DEFAULT_MINTS: () => import_common67.DEFAULT_MINTS,
|
|
3741
3740
|
DEFAULT_MIN_AMOUNT_UI: () => DEFAULT_MIN_AMOUNT_UI,
|
|
3742
3741
|
DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS: () => DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
|
|
@@ -4010,7 +4009,8 @@ var PROGRAM_FEE_EXEMPT_OWNER_WHITELIST = [
|
|
|
4010
4009
|
(0, import_kit.address)("Hobbakk1LmW2DhE4nAKnCeU1iK7V7pKHTq3ihaE2i8qG"),
|
|
4011
4010
|
(0, import_kit.address)("7C39GeKrqLygmgV9D4bicUaiyFhKrX6Eevk6PDACwuj7"),
|
|
4012
4011
|
(0, import_kit.address)("LYC8YiiSzQfPpxUW2tpxfuPKGZwywAJhXKUfDP2B66f"),
|
|
4013
|
-
(0, import_kit.address)("soBBAHNhFyWF4QBCK9BJLVkX6d6NZt37ozNaPV5aq3H")
|
|
4012
|
+
(0, import_kit.address)("soBBAHNhFyWF4QBCK9BJLVkX6d6NZt37ozNaPV5aq3H"),
|
|
4013
|
+
(0, import_kit.address)("GooseA4bSoxitTMPa4ppe2zUQ9fu4139u8pEk6x65SR")
|
|
4014
4014
|
];
|
|
4015
4015
|
var VAULT_CREATOR_WHITELIST = [
|
|
4016
4016
|
(0, import_kit.address)("4jMRBkpWrfhhwFYTwG3o7hmsXQwbJUwdyUX8htB6KwLJ"),
|
|
@@ -17922,7 +17922,7 @@ async function loadKaminoWithdrawal(args) {
|
|
|
17922
17922
|
"confirmed"
|
|
17923
17923
|
);
|
|
17924
17924
|
if (!info) {
|
|
17925
|
-
if (args.depositReserve)
|
|
17925
|
+
if (args.depositReserve || args.requireInitialized)
|
|
17926
17926
|
throw new Error("Registered Kamino obligation is not initialized");
|
|
17927
17927
|
return null;
|
|
17928
17928
|
}
|
|
@@ -18072,6 +18072,12 @@ function marginfiFixedPointBits(value) {
|
|
|
18072
18072
|
}
|
|
18073
18073
|
return BigInt(value.toString());
|
|
18074
18074
|
}
|
|
18075
|
+
function marginfiWithdrawablePoolLiquidity(bank, cash) {
|
|
18076
|
+
const assets = marginfiFixedPointBits(bank.totalAssetShares.value) * marginfiFixedPointBits(bank.assetShareValue.value) >> 48n;
|
|
18077
|
+
const liabilities = marginfiFixedPointBits(bank.totalLiabilityShares.value) * marginfiFixedPointBits(bank.liabilityShareValue.value) >> 48n;
|
|
18078
|
+
const available = nonnegative(min(cash, assets - liabilities >> 48n));
|
|
18079
|
+
return available * 9990n / 10000n;
|
|
18080
|
+
}
|
|
18075
18081
|
async function readTokenBalance(connection, tokenAccount, tokenProgram) {
|
|
18076
18082
|
const key = new import_web316.PublicKey(tokenAccount);
|
|
18077
18083
|
const info = await connection.getAccountInfo(key, "confirmed");
|
|
@@ -18121,7 +18127,8 @@ async function loadWithdrawalPosition(args) {
|
|
|
18121
18127
|
connection,
|
|
18122
18128
|
vault,
|
|
18123
18129
|
obligation: userAccount,
|
|
18124
|
-
assetMint
|
|
18130
|
+
assetMint,
|
|
18131
|
+
requireInitialized: args.requireUsablePosition
|
|
18125
18132
|
});
|
|
18126
18133
|
if (!context) return null;
|
|
18127
18134
|
if (context.reserve.liquidityTokenProgram !== tokenProgram)
|
|
@@ -18239,10 +18246,9 @@ async function loadWithdrawalPosition(args) {
|
|
|
18239
18246
|
const deposited = nonnegative(
|
|
18240
18247
|
marginfiFixedPointBits(balances[target].assetShares.value) * marginfiFixedPointBits(bank.assetShareValue.value) >> 96n
|
|
18241
18248
|
);
|
|
18242
|
-
const poolAvailable =
|
|
18243
|
-
|
|
18244
|
-
configured.liquidityVault,
|
|
18245
|
-
tokenProgram
|
|
18249
|
+
const poolAvailable = marginfiWithdrawablePoolLiquidity(
|
|
18250
|
+
bank,
|
|
18251
|
+
await readTokenBalance(connection, configured.liquidityVault, tokenProgram)
|
|
18246
18252
|
);
|
|
18247
18253
|
const cpi = new import_marginfi.CpiClient({ accounts: configured }).withdraw_cpi({
|
|
18248
18254
|
marginfiAccount: userAccount,
|
|
@@ -24937,6 +24943,14 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
24937
24943
|
result.skipped++;
|
|
24938
24944
|
continue;
|
|
24939
24945
|
}
|
|
24946
|
+
for (const position of snapshot2.positions) {
|
|
24947
|
+
const capacity = position.capacity(position.poolAvailable);
|
|
24948
|
+
if (capacity < position.balance) {
|
|
24949
|
+
log(
|
|
24950
|
+
`Vault ${vault} slot ${position.index} (${position.source}): withdrawal capacity ${formatUi(capacity, decimals)} of ${formatUi(position.balance, decimals)} supplied ${mintAddress}`
|
|
24951
|
+
);
|
|
24952
|
+
}
|
|
24953
|
+
}
|
|
24940
24954
|
const externalAmount = snapshot2.positions.reduce(
|
|
24941
24955
|
(total, p) => total + p.balance,
|
|
24942
24956
|
0n
|
|
@@ -25155,7 +25169,6 @@ var IDLE_RESERVE_TARGET_BPS = 500;
|
|
|
25155
25169
|
var WITHDRAWABLE_RESERVE_FLOOR_BPS = 150;
|
|
25156
25170
|
var DEFAULT_SLIPPAGE_BPS = 30;
|
|
25157
25171
|
var DEFAULT_CU_PRICE_MICRO_LAMPORTS = 1e4;
|
|
25158
|
-
var DEFAULT_MAX_ACCOUNTS = 20;
|
|
25159
25172
|
var COMPUTE_UNIT_LIMIT = 12e5;
|
|
25160
25173
|
var ASSET_REBALANCE_COOLDOWN_SECS = 60;
|
|
25161
25174
|
function toBigInt4(value) {
|
|
@@ -25250,8 +25263,7 @@ var IdleLiquidityService = class {
|
|
|
25250
25263
|
inputMint: import_common62.PST_MINT,
|
|
25251
25264
|
outputMint: import_common62.USDC_MINT,
|
|
25252
25265
|
amount: pstInput,
|
|
25253
|
-
slippageBps: opts.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
25254
|
-
maxAccounts: DEFAULT_MAX_ACCOUNTS
|
|
25266
|
+
slippageBps: opts.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
25255
25267
|
});
|
|
25256
25268
|
} catch (err) {
|
|
25257
25269
|
log(`Vault ${vault}: Jupiter quote failed \u2014 ${err.message}`);
|
|
@@ -25291,7 +25303,7 @@ var IdleLiquidityService = class {
|
|
|
25291
25303
|
}
|
|
25292
25304
|
}
|
|
25293
25305
|
// ── Assessment ──────────────────────────────────────────────────────────
|
|
25294
|
-
/** Read
|
|
25306
|
+
/** Read live local, Project0 and Kamino USDC, excluding other deployed capital. */
|
|
25295
25307
|
async fetchIdleUsdc(vault, vaultState) {
|
|
25296
25308
|
const connection = this.client.provider.connection;
|
|
25297
25309
|
const vaultPk = new import_web341.PublicKey(vault);
|
|
@@ -25306,6 +25318,11 @@ var IdleLiquidityService = class {
|
|
|
25306
25318
|
}
|
|
25307
25319
|
localAmount = tokenAccount.amount;
|
|
25308
25320
|
}
|
|
25321
|
+
const kamino = await this.fetchKaminoUsdc(
|
|
25322
|
+
vault,
|
|
25323
|
+
vaultState,
|
|
25324
|
+
(0, import_common62.fromWeb3Pk)(ata)
|
|
25325
|
+
);
|
|
25309
25326
|
const slotIndex = vaultState.externalLiquidity.findIndex(
|
|
25310
25327
|
(slot) => slot.data[0] === 1
|
|
25311
25328
|
);
|
|
@@ -25314,7 +25331,8 @@ var IdleLiquidityService = class {
|
|
|
25314
25331
|
localAmount,
|
|
25315
25332
|
marginfiAmount: 0n,
|
|
25316
25333
|
withdrawableMarginfiAmount: 0n,
|
|
25317
|
-
slotIndex
|
|
25334
|
+
slotIndex,
|
|
25335
|
+
...kamino
|
|
25318
25336
|
};
|
|
25319
25337
|
}
|
|
25320
25338
|
const data = vaultState.externalLiquidity[slotIndex].data;
|
|
@@ -25363,9 +25381,55 @@ var IdleLiquidityService = class {
|
|
|
25363
25381
|
localAmount,
|
|
25364
25382
|
marginfiAmount,
|
|
25365
25383
|
withdrawableMarginfiAmount,
|
|
25366
|
-
slotIndex
|
|
25384
|
+
slotIndex,
|
|
25385
|
+
...kamino
|
|
25367
25386
|
};
|
|
25368
25387
|
}
|
|
25388
|
+
async fetchKaminoUsdc(vault, vaultState, vaultAssetAta) {
|
|
25389
|
+
const positions = [];
|
|
25390
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25391
|
+
const pools = /* @__PURE__ */ new Map();
|
|
25392
|
+
for (const [index, slot] of vaultState.externalLiquidity.entries()) {
|
|
25393
|
+
if (slot.data[0] !== 2) continue;
|
|
25394
|
+
if (slot.data.length < 40)
|
|
25395
|
+
throw new Error(`Invalid Kamino external-liquidity slot ${index}`);
|
|
25396
|
+
const key = new import_web341.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
|
|
25397
|
+
if (key.equals(import_web341.PublicKey.default))
|
|
25398
|
+
throw new Error(`Missing Kamino position in slot ${index}`);
|
|
25399
|
+
if (seen.has(key.toBase58())) continue;
|
|
25400
|
+
seen.add(key.toBase58());
|
|
25401
|
+
const position = await loadWithdrawalPosition({
|
|
25402
|
+
connection: this.client.provider.connection,
|
|
25403
|
+
vault,
|
|
25404
|
+
assetMint: import_common62.USDC_MINT,
|
|
25405
|
+
vaultAssetAta,
|
|
25406
|
+
tokenProgram: (0, import_common62.fromWeb3Pk)(import_spl_token23.TOKEN_PROGRAM_ID),
|
|
25407
|
+
slot,
|
|
25408
|
+
index,
|
|
25409
|
+
requireUsablePosition: true
|
|
25410
|
+
});
|
|
25411
|
+
if (!position) continue;
|
|
25412
|
+
positions.push(position);
|
|
25413
|
+
const available = pools.get(position.poolKey);
|
|
25414
|
+
pools.set(
|
|
25415
|
+
position.poolKey,
|
|
25416
|
+
available === void 0 || position.poolAvailable < available ? position.poolAvailable : available
|
|
25417
|
+
);
|
|
25418
|
+
}
|
|
25419
|
+
let kaminoAmount = 0n;
|
|
25420
|
+
let withdrawableKaminoAmount = 0n;
|
|
25421
|
+
for (const position of positions) {
|
|
25422
|
+
kaminoAmount += position.capacity((1n << 64n) - 1n);
|
|
25423
|
+
const available = pools.get(position.poolKey);
|
|
25424
|
+
const amount = position.capacity(available);
|
|
25425
|
+
withdrawableKaminoAmount += amount;
|
|
25426
|
+
pools.set(
|
|
25427
|
+
position.poolKey,
|
|
25428
|
+
available - (amount > 0n ? position.receipt(amount) : 0n)
|
|
25429
|
+
);
|
|
25430
|
+
}
|
|
25431
|
+
return { kaminoAmount, withdrawableKaminoAmount };
|
|
25432
|
+
}
|
|
25369
25433
|
/**
|
|
25370
25434
|
* Decide whether a top-up is warranted. Returns either a terminal `result`
|
|
25371
25435
|
* (nothing to do) or the holdings and sizing needed to build the swap.
|
|
@@ -25422,10 +25486,10 @@ var IdleLiquidityService = class {
|
|
|
25422
25486
|
log(`Vault ${vault}: ${reason}`);
|
|
25423
25487
|
return { result: { ...empty, status: "failed", reason } };
|
|
25424
25488
|
}
|
|
25425
|
-
const idleAmount = balances.localAmount + balances.marginfiAmount;
|
|
25489
|
+
const idleAmount = balances.localAmount + balances.marginfiAmount + balances.kaminoAmount;
|
|
25426
25490
|
const idleValue = holdingValue2(usdc, idleAmount);
|
|
25427
25491
|
const idleBps = Number(idleValue * 10000n / tvl);
|
|
25428
|
-
const withdrawableAmount = balances.localAmount + balances.withdrawableMarginfiAmount;
|
|
25492
|
+
const withdrawableAmount = balances.localAmount + balances.withdrawableMarginfiAmount + balances.withdrawableKaminoAmount;
|
|
25429
25493
|
const withdrawableValue = holdingValue2(usdc, withdrawableAmount);
|
|
25430
25494
|
const withdrawableBps = Number(withdrawableValue * 10000n / tvl);
|
|
25431
25495
|
const base = {
|
|
@@ -25445,6 +25509,9 @@ var IdleLiquidityService = class {
|
|
|
25445
25509
|
)} + Project0 slot ${balances.slotIndex} ${formatUi2(
|
|
25446
25510
|
balances.marginfiAmount,
|
|
25447
25511
|
usdc.decimals
|
|
25512
|
+
)} + Kamino ${formatUi2(
|
|
25513
|
+
balances.kaminoAmount,
|
|
25514
|
+
usdc.decimals
|
|
25448
25515
|
)}) = ${idleBps}bps of TVL (floor ${IDLE_RESERVE_FLOOR_BPS}bps, target ${IDLE_RESERVE_TARGET_BPS}bps)`
|
|
25449
25516
|
);
|
|
25450
25517
|
log(
|
|
@@ -26504,7 +26571,6 @@ var import_common67 = __toESM(require_dist());
|
|
|
26504
26571
|
DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
|
|
26505
26572
|
DEFAULT_MARGINFI_WEIGHT_BPS,
|
|
26506
26573
|
DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
26507
|
-
DEFAULT_MAX_ACCOUNTS,
|
|
26508
26574
|
DEFAULT_MINTS,
|
|
26509
26575
|
DEFAULT_MIN_AMOUNT_UI,
|
|
26510
26576
|
DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
|