@perena/vault-sdk 1.0.19 → 1.0.23

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
@@ -2,7 +2,7 @@ import * as _solana_kit from '@solana/kit';
2
2
  import { Address, ProgramDerivedAddressBump, Rpc, SolanaRpcApi, Instruction } from '@solana/kit';
3
3
  export { address } from '@solana/kit';
4
4
  import * as _solana_web3_js from '@solana/web3.js';
5
- import { PublicKey, Connection, Keypair, TransactionInstruction } from '@solana/web3.js';
5
+ import { PublicKey, Connection, Keypair, Transaction, TransactionInstruction } from '@solana/web3.js';
6
6
  import * as _anchor_lang_core from '@anchor-lang/core';
7
7
  import { Program, IdlAccounts, BN, AnchorProvider } from '@anchor-lang/core';
8
8
  import * as common from 'common';
@@ -9543,219 +9543,239 @@ type Bankineco = {
9543
9543
  ];
9544
9544
  "errors": [
9545
9545
  {
9546
- "code": 6000;
9547
- "name": "mintSupplyNonZero";
9548
- "msg": "Supplied share mint already has non-zero supply";
9546
+ "code": 14001;
9547
+ "name": "unauthorized";
9548
+ "msg": "You are not authorized to perform this action.";
9549
9549
  },
9550
9550
  {
9551
- "code": 6001;
9552
- "name": "invalidAssetMint";
9553
- "msg": "Supplied mint is not accepted by this vault";
9551
+ "code": 14002;
9552
+ "name": "invalidBankMint";
9553
+ "msg": "Invalid mint";
9554
9554
  },
9555
9555
  {
9556
- "code": 6002;
9557
- "name": "zeroDepositAmount";
9558
- "msg": "Deposit amount must be greater than zero";
9556
+ "code": 14003;
9557
+ "name": "accountingIssue";
9558
+ "msg": "Accounting issue";
9559
9559
  },
9560
9560
  {
9561
- "code": 6003;
9562
- "name": "exceedsTvlLimit";
9563
- "msg": "Deposit would exceed the vault's TVL limit";
9561
+ "code": 14004;
9562
+ "name": "vaultAccountingIssue";
9563
+ "msg": "Vault accounting issue";
9564
9564
  },
9565
9565
  {
9566
- "code": 6004;
9567
- "name": "zeroBurnAmount";
9568
- "msg": "Burn amount must be greater than zero";
9566
+ "code": 14005;
9567
+ "name": "bankAccountingIssue";
9568
+ "msg": "Bank accounting issue";
9569
9569
  },
9570
9570
  {
9571
- "code": 6005;
9572
- "name": "zeroAssetAmount";
9573
- "msg": "Asset amount must be greater than zero";
9571
+ "code": 14006;
9572
+ "name": "onchainAccountingIssue";
9573
+ "msg": "Onchain accounting issue";
9574
9574
  },
9575
9575
  {
9576
- "code": 6006;
9577
- "name": "insufficientVaultLiquidity";
9578
- "msg": "Insufficient vault liquidity to satisfy withdrawal";
9576
+ "code": 14007;
9577
+ "name": "externalAccountingIssue";
9578
+ "msg": "External accounting issue";
9579
9579
  },
9580
9580
  {
9581
- "code": 6007;
9582
- "name": "mintAuthorityNotCurator";
9583
- "msg": "Mint authority is not the curator";
9581
+ "code": 14008;
9582
+ "name": "mintSlippage";
9583
+ "msg": "Minting failed due to slippage.";
9584
9584
  },
9585
9585
  {
9586
- "code": 6008;
9587
- "name": "zeroTotalSupply";
9588
- "msg": "Vault total supply is zero";
9586
+ "code": 14009;
9587
+ "name": "burningSlippage";
9588
+ "msg": "Burning failed due to slippage.";
9589
9589
  },
9590
9590
  {
9591
- "code": 6009;
9591
+ "code": 14010;
9592
+ "name": "teamAccountAlreadyExists";
9593
+ "msg": "Team account already exists";
9594
+ },
9595
+ {
9596
+ "code": 14011;
9597
+ "name": "oracleAccountAlreadyExists";
9598
+ "msg": "Oracle account already exists";
9599
+ },
9600
+ {
9601
+ "code": 14012;
9592
9602
  "name": "staleOracle";
9593
- "msg": "Vault oracle is stale";
9603
+ "msg": "Stale oracle";
9594
9604
  },
9595
9605
  {
9596
- "code": 6010;
9597
- "name": "invalidOracleUpdate";
9598
- "msg": "Invalid oracle update";
9606
+ "code": 14013;
9607
+ "name": "localSignificantPriceChange";
9608
+ "msg": "Price change is too large locally";
9599
9609
  },
9600
9610
  {
9601
- "code": 6011;
9602
- "name": "invalidInitialMintSharePrice";
9603
- "msg": "Initial mint share price must be greater than zero";
9611
+ "code": 14014;
9612
+ "name": "significantPriceChange";
9613
+ "msg": "Price change is too large";
9604
9614
  },
9605
9615
  {
9606
- "code": 6012;
9607
- "name": "maxApyExceeded";
9608
- "msg": "Oracle NAV update exceeds the vault's maximum acceptable APY";
9616
+ "code": 14015;
9617
+ "name": "roundingImpact";
9618
+ "msg": "Rounding impacts the protocol";
9609
9619
  },
9610
9620
  {
9611
- "code": 6013;
9612
- "name": "invalidApyConfig";
9613
- "msg": "Invalid APY configuration";
9621
+ "code": 14016;
9622
+ "name": "bankIsHalted";
9623
+ "msg": "Bank is halted";
9614
9624
  },
9615
9625
  {
9616
- "code": 6014;
9617
- "name": "invalidFeeConfig";
9618
- "msg": "Invalid fee configuration";
9626
+ "code": 14017;
9627
+ "name": "vaultIsHalted";
9628
+ "msg": "Vault is halted";
9619
9629
  },
9620
9630
  {
9621
- "code": 6015;
9622
- "name": "vaultHasLiveAssets";
9623
- "msg": "Vault has live supply, TVL, or holdings";
9631
+ "code": 14018;
9632
+ "name": "conversionOverflow";
9633
+ "msg": "Conversion Overflow";
9624
9634
  },
9625
9635
  {
9626
- "code": 6016;
9627
- "name": "depositMintsZeroShares";
9628
- "msg": "Deposit would mint zero shares";
9636
+ "code": 14019;
9637
+ "name": "reserved8019";
9638
+ "msg": "reserved";
9629
9639
  },
9630
9640
  {
9631
- "code": 6017;
9632
- "name": "insufficientAccruedApyBalance";
9633
- "msg": "Insufficient accrued APY balance";
9641
+ "code": 14020;
9642
+ "name": "invalidArgument";
9643
+ "msg": "Invalid argument";
9634
9644
  },
9635
9645
  {
9636
- "code": 6018;
9637
- "name": "invalidRole";
9638
- "msg": "Invalid role configuration";
9646
+ "code": 14021;
9647
+ "name": "userSanityCheck";
9648
+ "msg": "User Sanity Check";
9639
9649
  },
9640
9650
  {
9641
- "code": 6019;
9642
- "name": "invalidProtocolInteraction";
9643
- "msg": "Invalid protocol interaction CPI";
9651
+ "code": 14022;
9652
+ "name": "mathOverflow";
9653
+ "msg": "Math overflow";
9644
9654
  },
9645
9655
  {
9646
- "code": 6020;
9647
- "name": "reserved7020";
9648
- "msg": "reserved";
9656
+ "code": 14023;
9657
+ "name": "invalidMarginFiAccount";
9658
+ "msg": "Invalid MarginFi account - must be correct PDA for this vault";
9649
9659
  },
9650
9660
  {
9651
- "code": 6021;
9652
- "name": "invalidExternalLiquidity";
9653
- "msg": "Invalid external liquidity configuration";
9661
+ "code": 14024;
9662
+ "name": "invalidStartMarker";
9663
+ "msg": "Invalid start marker";
9654
9664
  },
9655
9665
  {
9656
- "code": 6022;
9657
- "name": "swapBalanceUnchanged";
9658
- "msg": "Swap did not change both source and destination balances";
9666
+ "code": 14025;
9667
+ "name": "oracleUpdateOnEmptyReserve";
9668
+ "msg": "Unable to push oracle update on an empty vault reserve";
9659
9669
  },
9660
9670
  {
9661
- "code": 6023;
9662
- "name": "protocolBalanceUnchanged";
9663
- "msg": "Protocol interaction did not change the affected token balance";
9671
+ "code": 14026;
9672
+ "name": "invalidRemainingAccountsLength";
9673
+ "msg": "Invalid remaining accounts length";
9664
9674
  },
9665
9675
  {
9666
- "code": 6024;
9667
- "name": "excessiveSwapSlippage";
9668
- "msg": "Swap TVL loss exceeds the allowed slippage";
9676
+ "code": 14027;
9677
+ "name": "withdrawalExceedsBalance";
9678
+ "msg": "Specified withdrawal exceeds available balance";
9669
9679
  },
9670
9680
  {
9671
- "code": 6025;
9672
- "name": "tranchingNotEnabled";
9673
- "msg": "Vault tranching is not enabled";
9681
+ "code": 14028;
9682
+ "name": "insufficientPendingYield";
9683
+ "msg": "Insufficient pending yield";
9674
9684
  },
9675
9685
  {
9676
- "code": 6026;
9677
- "name": "tranchingAlreadyEnabled";
9678
- "msg": "Vault tranching is already enabled";
9686
+ "code": 14029;
9687
+ "name": "notSupported";
9688
+ "msg": "Not supported";
9679
9689
  },
9680
9690
  {
9681
- "code": 6027;
9682
- "name": "trancheStateRequired";
9683
- "msg": "Tranche state account is required";
9691
+ "code": 14030;
9692
+ "name": "exceedsMaxYieldingTvl";
9693
+ "msg": "Exceeds maximum yielding TVL";
9684
9694
  },
9685
9695
  {
9686
- "code": 6028;
9687
- "name": "invalidTrancheConfig";
9688
- "msg": "Invalid tranche configuration";
9696
+ "code": 14031;
9697
+ "name": "tranchingNotEnabled";
9698
+ "msg": "Tranching is not enabled for this bank";
9689
9699
  },
9690
9700
  {
9691
- "code": 6029;
9692
- "name": "invalidTrancheMint";
9693
- "msg": "Invalid tranche mint";
9701
+ "code": 14032;
9702
+ "name": "invalidLeverageFactor";
9703
+ "msg": "Invalid leverage factor - must be at least 10000 (1x)";
9694
9704
  },
9695
9705
  {
9696
- "code": 6030;
9697
- "name": "lossesDisabled";
9698
- "msg": "Vault losses are not enabled";
9706
+ "code": 14033;
9707
+ "name": "insufficientStakedAmount";
9708
+ "msg": "Insufficient staked amount";
9699
9709
  },
9700
9710
  {
9701
- "code": 6031;
9711
+ "code": 14034;
9712
+ "name": "juniorTrancheEmpty";
9713
+ "msg": "Junior tranche has no value";
9714
+ },
9715
+ {
9716
+ "code": 14035;
9717
+ "name": "invalidTrancheConfig";
9718
+ "msg": "Invalid tranche config parameter";
9719
+ },
9720
+ {
9721
+ "code": 14036;
9702
9722
  "name": "withdrawalQueueNotExpired";
9703
- "msg": "Withdrawal queue is not yet expired";
9723
+ "msg": "Withdrawal queue lockup period has not expired";
9704
9724
  },
9705
9725
  {
9706
- "code": 6032;
9726
+ "code": 14037;
9707
9727
  "name": "invalidWithdrawalQueue";
9708
- "msg": "Invalid withdrawal queue";
9728
+ "msg": "Withdrawal queue entry is not in a valid state";
9709
9729
  },
9710
9730
  {
9711
- "code": 6033;
9712
- "name": "assetPriceNotSet";
9713
- "msg": "Destination asset has no price set; a consensus oracle price is required before swapping";
9731
+ "code": 14038;
9732
+ "name": "invalidAccount";
9733
+ "msg": "Account does not belong to the expected parent";
9714
9734
  },
9715
9735
  {
9716
- "code": 6034;
9717
- "name": "assetHoldingNotEmpty";
9718
- "msg": "Asset holding still has a balance and cannot be removed";
9736
+ "code": 14039;
9737
+ "name": "missingAccount";
9738
+ "msg": "Required optional account is missing";
9719
9739
  },
9720
9740
  {
9721
- "code": 6035;
9722
- "name": "cannotRemoveBaseHolding";
9723
- "msg": "The base asset holding cannot be removed";
9741
+ "code": 14040;
9742
+ "name": "trancheWipedOut";
9743
+ "msg": "Junior tranche is wiped out and cannot accept new stakes";
9724
9744
  },
9725
9745
  {
9726
- "code": 6036;
9727
- "name": "unauthorizedPriceUpdater";
9728
- "msg": "Caller is not authorized to trigger an asset price update";
9746
+ "code": 14041;
9747
+ "name": "vaultLossNotAccepted";
9748
+ "msg": "Vault does not accept losses enable losses_accepted before retrying";
9729
9749
  },
9730
9750
  {
9731
- "code": 6037;
9732
- "name": "invalidStalenessConfig";
9733
- "msg": "Invalid asset-price staleness threshold";
9751
+ "code": 14042;
9752
+ "name": "capitalLossExceedsReserve";
9753
+ "msg": "Capital loss exceeds available yielding reserve";
9734
9754
  },
9735
9755
  {
9736
- "code": 6038;
9737
- "name": "assetRebalanceRateLimitExceeded";
9738
- "msg": "Asset was rebalanced too recently";
9756
+ "code": 14043;
9757
+ "name": "rollingWithdrawalLimitExceeded";
9758
+ "msg": "Rolling withdrawal limit exceeded";
9739
9759
  },
9740
9760
  {
9741
- "code": 6039;
9742
- "name": "invalidShareTokenProgram";
9743
- "msg": "Share token program does not match the vault/tranche mint configuration";
9761
+ "code": 14044;
9762
+ "name": "vaultAlreadyMigrated";
9763
+ "msg": "Legacy vault has already been migrated";
9744
9764
  },
9745
9765
  {
9746
- "code": 6040;
9747
- "name": "unauthorizedVaultCreator";
9748
- "msg": "Caller is not on the vault-creator whitelist";
9766
+ "code": 14045;
9767
+ "name": "invalidMigrationState";
9768
+ "msg": "Legacy vault migration is incomplete or invalid";
9749
9769
  },
9750
9770
  {
9751
- "code": 6041;
9752
- "name": "invalidShareMintDecimals";
9753
- "msg": "Share mint decimals must match the deposit asset mint decimals";
9771
+ "code": 14046;
9772
+ "name": "invalidMigrationMintAuthority";
9773
+ "msg": "Mint authority does not match the expected migration source";
9754
9774
  },
9755
9775
  {
9756
- "code": 6042;
9757
- "name": "invalidFeeExemption";
9758
- "msg": "Invalid fee-exemption PDA signer or seeds";
9776
+ "code": 14047;
9777
+ "name": "bankMigrationIncomplete";
9778
+ "msg": "Legacy bank or tranche migration is incomplete — source accounting and escrow must be fully drained before mint authority transfer";
9759
9779
  }
9760
9780
  ];
9761
9781
  "types": [
@@ -12140,6 +12160,13 @@ type Bankineco = {
12140
12160
  "name": "targetLockupDurationSecs";
12141
12161
  "type": "i64";
12142
12162
  },
12163
+ {
12164
+ "name": "juniorDepositCap";
12165
+ "docs": [
12166
+ "Maximum junior tranche value in accounting units. Zero means uncapped."
12167
+ ];
12168
+ "type": "u64";
12169
+ },
12143
12170
  {
12144
12171
  "name": "forMigration";
12145
12172
  "docs": [
@@ -12937,12 +12964,21 @@ type Bankineco = {
12937
12964
  "name": "targetLockupDurationSecs";
12938
12965
  "type": "i64";
12939
12966
  },
12967
+ {
12968
+ "name": "juniorDepositCap";
12969
+ "docs": [
12970
+ "Maximum junior tranche value in vault accounting units. Zero disables",
12971
+ "the cap. Yield may carry the tranche above this value, but further",
12972
+ "junior deposits remain blocked until its value falls below the cap."
12973
+ ];
12974
+ "type": "u64";
12975
+ },
12940
12976
  {
12941
12977
  "name": "padding2";
12942
12978
  "type": {
12943
12979
  "array": [
12944
12980
  "u64",
12945
- 14
12981
+ 13
12946
12982
  ];
12947
12983
  };
12948
12984
  }
@@ -13060,6 +13096,15 @@ type Bankineco = {
13060
13096
  "type": {
13061
13097
  "option": "i64";
13062
13098
  };
13099
+ },
13100
+ {
13101
+ "name": "juniorDepositCap";
13102
+ "docs": [
13103
+ "Maximum junior tranche value in accounting units. Zero means uncapped."
13104
+ ];
13105
+ "type": {
13106
+ "option": "u64";
13107
+ };
13063
13108
  }
13064
13109
  ];
13065
13110
  };
@@ -14133,6 +14178,7 @@ interface CreateTrancheStateIxArgs {
14133
14178
  earlyUnstakeFeeBps: number;
14134
14179
  standardUnstakeFeeBps: number;
14135
14180
  targetLockupDurationSecs: BN;
14181
+ juniorDepositCap: BN;
14136
14182
  forMigration: boolean;
14137
14183
  tokenProgram: Address;
14138
14184
  }
@@ -14146,6 +14192,8 @@ interface CreateTrancheStateTxArgs {
14146
14192
  earlyUnstakeFeeBps?: number;
14147
14193
  standardUnstakeFeeBps?: number;
14148
14194
  targetLockupDurationSecs?: number;
14195
+ /** Maximum junior tranche value in accounting units. Zero means uncapped. */
14196
+ juniorDepositCap?: bigint;
14149
14197
  forMigration?: boolean;
14150
14198
  tokenProgram?: Address;
14151
14199
  }
@@ -14158,6 +14206,7 @@ interface UpdateTrancheConfigIxArgs {
14158
14206
  earlyUnstakeFeeBps: number | null;
14159
14207
  standardUnstakeFeeBps: number | null;
14160
14208
  targetLockupDurationSecs: BN | null;
14209
+ juniorDepositCap: BN | null;
14161
14210
  }
14162
14211
  interface UpdateTrancheConfigTxArgs {
14163
14212
  curator: Address;
@@ -14168,6 +14217,8 @@ interface UpdateTrancheConfigTxArgs {
14168
14217
  earlyUnstakeFeeBps?: number;
14169
14218
  standardUnstakeFeeBps?: number;
14170
14219
  targetLockupDurationSecs?: number;
14220
+ /** Maximum junior tranche value in accounting units. Zero means uncapped. */
14221
+ juniorDepositCap?: bigint;
14171
14222
  }
14172
14223
  interface InitializeVaultRolesIxArgs {
14173
14224
  curator: Address;
@@ -15361,6 +15412,68 @@ declare function makeProvider(connection: Connection, payer: Keypair): AnchorPro
15361
15412
 
15362
15413
  declare function createRpcFromConnection(connection: Connection): Rpc<SolanaRpcApi>;
15363
15414
 
15415
+ /**
15416
+ * Maps a transaction-proposing wallet to the Squads vault it operates.
15417
+ *
15418
+ * The member wallet pays for and signs proposal creation. The derived Squads
15419
+ * vault PDA is the authority that signs the instructions when the proposal is
15420
+ * eventually executed.
15421
+ */
15422
+ interface SquadsWalletRouteConfig {
15423
+ wallet: string;
15424
+ multisigPda: string;
15425
+ vaultIndex: number;
15426
+ memo?: string;
15427
+ }
15428
+ interface ResolvedSquadsWalletRoute {
15429
+ wallet: PublicKey;
15430
+ multisigPda: PublicKey;
15431
+ vaultIndex: number;
15432
+ vaultPda: PublicKey;
15433
+ memo?: string;
15434
+ }
15435
+ interface PreparedDirectTransaction {
15436
+ kind: "direct";
15437
+ transaction: Transaction;
15438
+ authority: PublicKey;
15439
+ }
15440
+ interface PreparedSquadsTransaction {
15441
+ kind: "squads";
15442
+ transaction: Transaction;
15443
+ authority: PublicKey;
15444
+ multisigPda: PublicKey;
15445
+ vaultIndex: number;
15446
+ transactionIndex: bigint;
15447
+ proposalPda: PublicKey;
15448
+ vaultTransactionPda: PublicKey;
15449
+ }
15450
+ type PreparedVaultTransaction = PreparedDirectTransaction | PreparedSquadsTransaction;
15451
+ /** Resolve and validate a configured wallet route, including its vault PDA. */
15452
+ declare function resolveSquadsWalletRoute(route: SquadsWalletRouteConfig): ResolvedSquadsWalletRoute;
15453
+ /** Find the optional Squads route for a connected proposer wallet. */
15454
+ declare function findSquadsWalletRoute(wallet: PublicKey | string, routes: readonly SquadsWalletRouteConfig[]): ResolvedSquadsWalletRoute | undefined;
15455
+ /** Fail fast on ambiguous wallet mappings or malformed route values. */
15456
+ declare function validateSquadsWalletRoutes(routes: readonly SquadsWalletRouteConfig[]): void;
15457
+ /**
15458
+ * Return the authority that should be used while building vault instructions.
15459
+ * For a configured member wallet this is the Squads vault PDA; otherwise it is
15460
+ * the wallet itself.
15461
+ */
15462
+ declare function vaultAuthorityForWallet(wallet: PublicKey | string, routes: readonly SquadsWalletRouteConfig[]): PublicKey;
15463
+ /**
15464
+ * Build either a normal transaction or a Squads proposal-creation transaction,
15465
+ * based on whether `proposer` has a configured wallet route.
15466
+ *
15467
+ * The returned Squads transaction creates both the vault transaction and its
15468
+ * proposal. It does not approve or execute the proposal.
15469
+ */
15470
+ declare function prepareVaultTransaction(args: {
15471
+ connection: Connection;
15472
+ proposer: PublicKey;
15473
+ instructions: readonly TransactionInstruction[];
15474
+ squadsRoutes?: readonly SquadsWalletRouteConfig[];
15475
+ }): Promise<PreparedVaultTransaction>;
15476
+
15364
15477
  interface CreateTokenMintIxs {
15365
15478
  mint: Keypair;
15366
15479
  ixs: TransactionInstruction[];
@@ -15466,6 +15579,9 @@ interface AccountYieldResponse {
15466
15579
  updated_at: Date;
15467
15580
  };
15468
15581
  total_yield: number;
15582
+ gross_yield: number;
15583
+ paid_yield: number;
15584
+ outstanding_yield: number;
15469
15585
  principal_at_end: number;
15470
15586
  accrual_start: Date;
15471
15587
  accrual_end: Date;
@@ -15473,8 +15589,36 @@ interface AccountYieldResponse {
15473
15589
  apr_used: number;
15474
15590
  calculation_log: YieldCalculationLog[];
15475
15591
  }
15592
+ interface CreateYieldPaymentParams {
15593
+ accountName: string;
15594
+ amount: number;
15595
+ effectiveAt: Date;
15596
+ idempotencyKey: string;
15597
+ password: string;
15598
+ }
15599
+ interface YieldPaymentResponse {
15600
+ id: string;
15601
+ account_name: string;
15602
+ idempotency_key: string;
15603
+ amount: number;
15604
+ effective_at: Date;
15605
+ status: "pending" | "confirmed";
15606
+ transaction_signature?: string;
15607
+ confirmed_at?: Date;
15608
+ created_at: Date;
15609
+ }
15610
+ declare function createYieldPayment(params: CreateYieldPaymentParams): Promise<YieldPaymentResponse>;
15611
+ declare function confirmYieldPayment(params: {
15612
+ accountName: string;
15613
+ paymentId: string;
15614
+ transactionSignature: string;
15615
+ password: string;
15616
+ }): Promise<YieldPaymentResponse>;
15617
+ declare function getYieldPayments(accountName: string): Promise<YieldPaymentResponse[]>;
15476
15618
  declare function getYield(accountName: string, start?: Date, end?: Date): Promise<AccountYieldResponse>;
15477
15619
  declare function getTotalYield(accountNames: string[], start?: Date, end?: Date): Promise<BN>;
15620
+ /** Sum only confirmed-payment-adjusted yield that remains receivable. */
15621
+ declare function getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
15478
15622
 
15479
15623
  /**
15480
15624
  * Junior-tranche withdrawal-queue fulfillment.
@@ -15705,29 +15849,34 @@ interface ExternalPositionProvider {
15705
15849
  */
15706
15850
  interface YieldAccountSnapshot {
15707
15851
  account: string;
15852
+ /** Gross accrued yield before payment settlements. */
15708
15853
  totalYield: number;
15854
+ grossYield: number;
15855
+ /** Confirmed payments inside the requested accrual window. */
15856
+ paidYield: number;
15857
+ /** Gross yield less confirmed payments; this is the oracle-safe receivable. */
15858
+ outstandingYield: number;
15709
15859
  principalAtEnd: number;
15710
15860
  aprUsed: number;
15711
15861
  accrualStart: Date;
15712
15862
  accrualEnd: Date;
15713
15863
  }
15864
+ /** Payment state used to interlock oracle publication with yield settlement. */
15865
+ interface YieldPaymentSnapshot {
15866
+ id: string;
15867
+ /** Only `confirmed` is safe; present or future intermediate states block. */
15868
+ status: string;
15869
+ }
15714
15870
  /**
15715
- * Queries accrued yield for named accounts. Mirrors the method surface of the
15716
- * real HTTP client (`yieldApi.ts`) so a production implementation can be dropped
15717
- * in without touching {@link ConsensusOracleService}.
15871
+ * Read-only yield-tracker surface required by the oracle. The live implementation
15872
+ * delegates to the HTTP API; the in-memory implementation also exposes mutation
15873
+ * helpers for tests and local operation.
15718
15874
  */
15719
15875
  interface YieldTracker {
15720
- getYield(accountName: string, start?: Date, end?: Date): Promise<YieldAccountSnapshot>;
15721
- /** Sum of `totalYield` (UI amount) across the named accounts. */
15722
- getTotalYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
15723
- /** Current balance (principal + accrued yield), UI amount. */
15724
- getBalance(accountName: string, atTime?: Date): Promise<number>;
15725
- addCashflow(params: {
15726
- accountName: string;
15727
- amount: number;
15728
- date?: Date;
15729
- cashflowType: "deposit" | "withdraw";
15730
- }): Promise<void>;
15876
+ /** All payments for an account, including payments not yet confirmed. */
15877
+ getYieldPayments(accountName: string): Promise<YieldPaymentSnapshot[]>;
15878
+ /** Sum of oracle-safe outstanding yield across the named accounts. */
15879
+ getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
15731
15880
  }
15732
15881
  /** Injectable wall clock (ms since epoch). Lets tests pin time deterministically. */
15733
15882
  interface Clock {
@@ -15986,8 +16135,10 @@ declare class MockYieldTracker implements YieldTracker {
15986
16135
  /** Register (or replace) a tracked account. */
15987
16136
  setAccount(name: string, cfg: MockYieldAccountConfig): void;
15988
16137
  private require;
16138
+ getYieldPayments(accountName: string): Promise<YieldPaymentSnapshot[]>;
15989
16139
  getYield(accountName: string, start?: Date, end?: Date): Promise<YieldAccountSnapshot>;
15990
16140
  getTotalYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
16141
+ getTotalOutstandingYield(accountNames: string[], start?: Date, end?: Date): Promise<number>;
15991
16142
  getBalance(accountName: string, atTime?: Date): Promise<number>;
15992
16143
  addCashflow(params: {
15993
16144
  accountName: string;
@@ -15995,6 +16146,17 @@ declare class MockYieldTracker implements YieldTracker {
15995
16146
  date?: Date;
15996
16147
  cashflowType: "deposit" | "withdraw";
15997
16148
  }): Promise<void>;
16149
+ createYieldPayment(params: {
16150
+ accountName: string;
16151
+ paymentId: string;
16152
+ amount: number;
16153
+ effectiveAt: Date;
16154
+ }): Promise<void>;
16155
+ confirmYieldPayment(params: {
16156
+ accountName: string;
16157
+ paymentId: string;
16158
+ transactionSignature: string;
16159
+ }): Promise<void>;
15998
16160
  }
15999
16161
 
16000
16162
  declare class ConsensusOracleService {
@@ -16005,6 +16167,12 @@ declare class ConsensusOracleService {
16005
16167
  constructor(client: VaultClient, deps: ConsensusOracleDeps);
16006
16168
  /** Drive one vault: source prices/balances, push consensus update, crank NAV. */
16007
16169
  runOnce(signer: Keypair, target: ConsensusOracleTarget, opts?: RunOptions): Promise<VaultOracleResult>;
16170
+ /**
16171
+ * Fail closed while any configured yield account has an unsettled payment.
16172
+ * The payout must be confirmed only after it is visible in the same wallet
16173
+ * balance source used by this service. Until then, no oracle update is safe.
16174
+ */
16175
+ private assertNoUnconfirmedYieldPayments;
16008
16176
  /**
16009
16177
  * Drive several vaults in sequence. Non-fatal: a failure on one vault is
16010
16178
  * recorded and the rest still run (mirrors the oracle-updater daemon).
@@ -16087,4 +16255,4 @@ declare class ExternalLiquidityIntegrityService {
16087
16255
  private depositIntoMarginfi;
16088
16256
  }
16089
16257
 
16090
- export { ASSET_DECIMALS, type AccountBalanceResponse, AccountClient, type AccountYieldResponse, ActivateCircuitBreakerBuilder, type ActivateCircuitBreakerIxArgs, type ActivateCircuitBreakerTxArgs, type AssetPriceOracleConfigIxArgs, type AssetPriceOracleConfigTxArgs, type AssetPriceRefreshTarget, type AssetRefreshResult, type Bankineco, type BasicAuthCredentials, type Bigintish, CancelJuniorTrancheWithdrawBuilder, type CancelJuniorTrancheWithdrawIxArgs, type CancelJuniorTrancheWithdrawTxArgs, type Clock, type ConsensusAssetUpdate, type ConsensusHoldingEntry, type ConsensusOracleDeps, type ConsensusOracleHoldingConfig, ConsensusOracleService, type ConsensusOracleTarget, CrankNavBuilder, type CrankNavIxArgs, type CrankNavTxArgs, CrankPerformanceFeesBuilder, type CrankPerformanceFeesIxArgs, type CrankPerformanceFeesTxArgs, type CreateAccountParams, CreateAssetHoldingBuilder, type CreateAssetHoldingIxArgs, type CreateAssetHoldingTxArgs, type CreateTokenMintIxs, CreateTrancheStateBuilder, type CreateTrancheStateIxArgs, type CreateTrancheStateTxArgs, CreateVaultBuilder, type CreateVaultClientOptions, type CreateVaultIxArgs, type CreateVaultParams, type CreateVaultTxArgs, DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS, DEFAULT_MAX_ACCEPTABLE_APY_BPS, DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS, DEFAULT_PRICE_ORACLE_ACCOUNT, DEFAULT_PRICE_STALENESS_THRESHOLD_SECS, DEFAULT_VAULT_ID, type DecodedHolding, type DecodedVault, type DeleteAccountParams, DisableCircuitBreakerBuilder, type DisableCircuitBreakerIxArgs, type DisableCircuitBreakerTxArgs, 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 ExternalLiquidityIntegrityResult, ExternalLiquidityIntegrityService, type ExternalLiquidityIntegritySummary, type ExternalLiquiditySlot, type ExternalLiquiditySourceArgs, type ExternalPosition, type ExternalPositionContext, type ExternalPositionProvider, type ExternalPositionRef, ExternalPositionRegistry, FEE_VAULT_CACHE_CATEGORY, type FeeVaultAccountData, FulfillJuniorTrancheWithdrawBuilder, type FulfillJuniorTrancheWithdrawIxArgs, type FulfillJuniorTrancheWithdrawTxArgs, type FulfillSummary, type HoldingUpdatePreview, IDL, InitializeVaultRolesBuilder, type InitializeVaultRolesIxArgs, type InitializeVaultRolesTxArgs, type JuniorWithdrawalMode, JupiterBalanceSource, type JupiterBalanceSourceOptions, JupiterPriceSource, type JupiterPriceSourceOptions, JupiterSwapBuilder, type JupiterSwapIxArgs, type JupiterSwapTxArgs, KaminoPositionProvider, type LiveConsensusOracleDepsOptions, MAX_PRICE_STALENESS_THRESHOLD_SECS, ManagerRedepositAssetBuilder, type ManagerRedepositAssetIxArgs, type ManagerRedepositAssetTxArgs, ManagerWithdrawAssetBuilder, type ManagerWithdrawAssetIxArgs, type ManagerWithdrawAssetTxArgs, MarginfiPositionProvider, type MockYieldAccountConfig, MockYieldTracker, type MockYieldTrackerOptions, type NavCrankBlocker, type NavCrankBlockerReason, type NavCrankReadiness, type NavCrankResult, OracleService, PROGRAM_FEE_EXEMPT_OWNER_WHITELIST, PROTOCOL_ADMIN, PROTOCOL_FEE_RECIPIENT, PdaClient, type PriceOracleTypeArgs, type PriceSource, ProtocolInteractionBuilder, type ProtocolInteractionIxArgs, type ProtocolInteractionTxArgs, type QuoteFeeUnit, RemoveAssetHoldingBuilder, type RemoveAssetHoldingIxArgs, type RemoveAssetHoldingTxArgs, RequestJuniorTrancheWithdrawBuilder, type RequestJuniorTrancheWithdrawIxArgs, type RequestJuniorTrancheWithdrawTxArgs, type RollingLimitConfig, type RunLiveConsensusOracleOptions, type RunOptions, type RunSummary, SHARE_DECIMALS, SetAssetPriceOracleBuilder, type SetAssetPriceOracleIxArgs, type SetAssetPriceOracleTxArgs, SetExternalLiquidityBuilder, type SetExternalLiquidityIxArgs, type SetExternalLiquidityTxArgs, SetProtocolFeeBuilder, type SetProtocolFeeIxArgs, type SetProtocolFeeTxArgs, SetVaultConfigBuilder, type SetVaultConfigIxArgs, type SetVaultConfigTxArgs, StaticPositionProvider, TOKEN_PROGRAM, TOKEN_PROGRAM_ID, type TrancheKindArgs, type TransactionBuilder, TransactionClient, USDC_MINT, USD_STAR_JUNIOR_MINT, USD_STAR_MINT, USD_STAR_PRINCIPAL_MINT, type UpdateAccountParams, UpdateAssetPriceBuilder, type UpdateAssetPriceIxArgs, type UpdateAssetPriceTxArgs, UpdateConsensusOracleBuilder, type UpdateConsensusOracleIxArgs, type UpdateConsensusOracleTxArgs, UpdateConsensusSignersBuilder, type UpdateConsensusSignersIxArgs, type UpdateConsensusSignersTxArgs, type UpdateDynamicAprParams, UpdateTrancheConfigBuilder, type UpdateTrancheConfigIxArgs, type UpdateTrancheConfigTxArgs, VAULT_CACHE_CATEGORY, VAULT_CREATOR_WHITELIST, VAULT_ENVIRONMENTS, VAULT_ORACLE_CACHE_CATEGORY, VAULT_PROGRAM_ID, VAULT_PROGRAM_IDS, VAULT_PROGRAM_PUBLIC_KEY, VAULT_ROLE_UPDATE_TIMELOCK_SECS, VAULT_TRANCHE_STATE_CACHE_CATEGORY, VAULT_TRANCHE_WITHDRAWAL_QUEUE_CACHE_CATEGORY, type Vault, type VaultAccountData, VaultBuilderBase, type VaultBuilderContext, type VaultCacheInvalidation, VaultClient, type VaultClientBundle, type VaultEnv, type VaultOracleAccountData, type VaultOracleResult, type VaultPricingInputs, type VaultQuote, type VaultQuoteArgs, VaultQuoteClient, type VaultQuoteDirection, type VaultQuoteShareClass, VaultReallocationBuilder, type VaultReallocationIxArgs, type VaultReallocationTxArgs, type VaultTrancheStateAccountData, type VaultTrancheWithdrawalQueueAccountData, type VaultTransactionPlan, type WalletBalanceSource, type WithdrawProtocolFeesIxArgs, type WithdrawProtocolFeesTxArgs, type WithdrawTrancheFeesIxArgs, type WithdrawTrancheFeesTxArgs, WithdrawalQueueService, type WithdrawalQueueSnapshot, type YieldAccount, type YieldAccountSnapshot, type YieldCalculationLog, type YieldTracker, addCashflowUpdate, createAccount, createLiveConsensusOracleDeps, createRpcFromConnection, createTokenMint, createTokenMintIxs, createVaultClient, dateToStr, defaultKeypairPath, deleteAccount, fromUiAmount, getAccounts, getBalance, getCashflows, getRpcUrl, getTotalYield, getVaultProgramId, getYield, isVaultEnv, keypairAddress, loadKeypair, makeProvider, mintTokensTo, resolveKeypairPath, roundToNextUtcMidnight, runLiveConsensusOracle, systemClock, toUiAmount, updateAccount, updateDynamicApr };
16258
+ export { ASSET_DECIMALS, type AccountBalanceResponse, AccountClient, type AccountYieldResponse, ActivateCircuitBreakerBuilder, type ActivateCircuitBreakerIxArgs, type ActivateCircuitBreakerTxArgs, type AssetPriceOracleConfigIxArgs, type AssetPriceOracleConfigTxArgs, type AssetPriceRefreshTarget, type AssetRefreshResult, type Bankineco, type BasicAuthCredentials, type Bigintish, CancelJuniorTrancheWithdrawBuilder, type CancelJuniorTrancheWithdrawIxArgs, type CancelJuniorTrancheWithdrawTxArgs, type Clock, type ConsensusAssetUpdate, type ConsensusHoldingEntry, type ConsensusOracleDeps, type ConsensusOracleHoldingConfig, ConsensusOracleService, type ConsensusOracleTarget, CrankNavBuilder, type CrankNavIxArgs, type CrankNavTxArgs, CrankPerformanceFeesBuilder, type CrankPerformanceFeesIxArgs, type CrankPerformanceFeesTxArgs, type CreateAccountParams, CreateAssetHoldingBuilder, type CreateAssetHoldingIxArgs, type CreateAssetHoldingTxArgs, type CreateTokenMintIxs, CreateTrancheStateBuilder, type CreateTrancheStateIxArgs, type CreateTrancheStateTxArgs, CreateVaultBuilder, type CreateVaultClientOptions, type CreateVaultIxArgs, type CreateVaultParams, type CreateVaultTxArgs, type CreateYieldPaymentParams, DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS, DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS, DEFAULT_MAX_ACCEPTABLE_APY_BPS, DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS, DEFAULT_PRICE_ORACLE_ACCOUNT, DEFAULT_PRICE_STALENESS_THRESHOLD_SECS, DEFAULT_VAULT_ID, type DecodedHolding, type DecodedVault, type DeleteAccountParams, DisableCircuitBreakerBuilder, type DisableCircuitBreakerIxArgs, type DisableCircuitBreakerTxArgs, 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 ExternalLiquidityIntegrityResult, ExternalLiquidityIntegrityService, type ExternalLiquidityIntegritySummary, type ExternalLiquiditySlot, type ExternalLiquiditySourceArgs, type ExternalPosition, type ExternalPositionContext, type ExternalPositionProvider, type ExternalPositionRef, ExternalPositionRegistry, FEE_VAULT_CACHE_CATEGORY, type FeeVaultAccountData, FulfillJuniorTrancheWithdrawBuilder, type FulfillJuniorTrancheWithdrawIxArgs, type FulfillJuniorTrancheWithdrawTxArgs, type FulfillSummary, type HoldingUpdatePreview, IDL, InitializeVaultRolesBuilder, type InitializeVaultRolesIxArgs, type InitializeVaultRolesTxArgs, type JuniorWithdrawalMode, JupiterBalanceSource, type JupiterBalanceSourceOptions, JupiterPriceSource, type JupiterPriceSourceOptions, JupiterSwapBuilder, type JupiterSwapIxArgs, type JupiterSwapTxArgs, KaminoPositionProvider, type LiveConsensusOracleDepsOptions, MAX_PRICE_STALENESS_THRESHOLD_SECS, ManagerRedepositAssetBuilder, type ManagerRedepositAssetIxArgs, type ManagerRedepositAssetTxArgs, ManagerWithdrawAssetBuilder, type ManagerWithdrawAssetIxArgs, type ManagerWithdrawAssetTxArgs, MarginfiPositionProvider, type MockYieldAccountConfig, MockYieldTracker, type MockYieldTrackerOptions, type NavCrankBlocker, type NavCrankBlockerReason, type NavCrankReadiness, type NavCrankResult, OracleService, PROGRAM_FEE_EXEMPT_OWNER_WHITELIST, PROTOCOL_ADMIN, PROTOCOL_FEE_RECIPIENT, PdaClient, type PreparedDirectTransaction, type PreparedSquadsTransaction, type PreparedVaultTransaction, type PriceOracleTypeArgs, type PriceSource, ProtocolInteractionBuilder, type ProtocolInteractionIxArgs, type ProtocolInteractionTxArgs, type QuoteFeeUnit, RemoveAssetHoldingBuilder, type RemoveAssetHoldingIxArgs, type RemoveAssetHoldingTxArgs, RequestJuniorTrancheWithdrawBuilder, type RequestJuniorTrancheWithdrawIxArgs, type RequestJuniorTrancheWithdrawTxArgs, type ResolvedSquadsWalletRoute, type RollingLimitConfig, type RunLiveConsensusOracleOptions, type RunOptions, type RunSummary, SHARE_DECIMALS, SetAssetPriceOracleBuilder, type SetAssetPriceOracleIxArgs, type SetAssetPriceOracleTxArgs, SetExternalLiquidityBuilder, type SetExternalLiquidityIxArgs, type SetExternalLiquidityTxArgs, SetProtocolFeeBuilder, type SetProtocolFeeIxArgs, type SetProtocolFeeTxArgs, SetVaultConfigBuilder, type SetVaultConfigIxArgs, type SetVaultConfigTxArgs, type SquadsWalletRouteConfig, StaticPositionProvider, TOKEN_PROGRAM, TOKEN_PROGRAM_ID, type TrancheKindArgs, type TransactionBuilder, TransactionClient, USDC_MINT, USD_STAR_JUNIOR_MINT, USD_STAR_MINT, USD_STAR_PRINCIPAL_MINT, type UpdateAccountParams, UpdateAssetPriceBuilder, type UpdateAssetPriceIxArgs, type UpdateAssetPriceTxArgs, UpdateConsensusOracleBuilder, type UpdateConsensusOracleIxArgs, type UpdateConsensusOracleTxArgs, UpdateConsensusSignersBuilder, type UpdateConsensusSignersIxArgs, type UpdateConsensusSignersTxArgs, type UpdateDynamicAprParams, UpdateTrancheConfigBuilder, type UpdateTrancheConfigIxArgs, type UpdateTrancheConfigTxArgs, VAULT_CACHE_CATEGORY, VAULT_CREATOR_WHITELIST, VAULT_ENVIRONMENTS, VAULT_ORACLE_CACHE_CATEGORY, VAULT_PROGRAM_ID, VAULT_PROGRAM_IDS, VAULT_PROGRAM_PUBLIC_KEY, VAULT_ROLE_UPDATE_TIMELOCK_SECS, VAULT_TRANCHE_STATE_CACHE_CATEGORY, VAULT_TRANCHE_WITHDRAWAL_QUEUE_CACHE_CATEGORY, type Vault, type VaultAccountData, VaultBuilderBase, type VaultBuilderContext, type VaultCacheInvalidation, VaultClient, type VaultClientBundle, type VaultEnv, type VaultOracleAccountData, type VaultOracleResult, type VaultPricingInputs, type VaultQuote, type VaultQuoteArgs, VaultQuoteClient, type VaultQuoteDirection, type VaultQuoteShareClass, VaultReallocationBuilder, type VaultReallocationIxArgs, type VaultReallocationTxArgs, type VaultTrancheStateAccountData, type VaultTrancheWithdrawalQueueAccountData, type VaultTransactionPlan, type WalletBalanceSource, type WithdrawProtocolFeesIxArgs, type WithdrawProtocolFeesTxArgs, type WithdrawTrancheFeesIxArgs, type WithdrawTrancheFeesTxArgs, WithdrawalQueueService, type WithdrawalQueueSnapshot, type YieldAccount, type YieldAccountSnapshot, type YieldCalculationLog, type YieldPaymentResponse, type YieldPaymentSnapshot, type YieldTracker, addCashflowUpdate, confirmYieldPayment, createAccount, createLiveConsensusOracleDeps, createRpcFromConnection, createTokenMint, createTokenMintIxs, createVaultClient, createYieldPayment, dateToStr, defaultKeypairPath, deleteAccount, findSquadsWalletRoute, fromUiAmount, getAccounts, getBalance, getCashflows, getRpcUrl, getTotalOutstandingYield, getTotalYield, getVaultProgramId, getYield, getYieldPayments, isVaultEnv, keypairAddress, loadKeypair, makeProvider, mintTokensTo, prepareVaultTransaction, resolveKeypairPath, resolveSquadsWalletRoute, roundToNextUtcMidnight, runLiveConsensusOracle, systemClock, toUiAmount, updateAccount, updateDynamicApr, validateSquadsWalletRoutes, vaultAuthorityForWallet };