@augustdigital/sdk 9.3.0 → 9.4.0

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.
Files changed (56) hide show
  1. package/lib/adapters/evm/getters.js +40 -0
  2. package/lib/adapters/evm/index.d.ts +106 -2
  3. package/lib/adapters/evm/index.js +125 -0
  4. package/lib/adapters/solana/index.d.ts +12 -5
  5. package/lib/adapters/solana/index.js +12 -4
  6. package/lib/adapters/solana/pricing.d.ts +173 -0
  7. package/lib/adapters/solana/pricing.js +223 -0
  8. package/lib/adapters/solana/types.d.ts +45 -0
  9. package/lib/adapters/solana/vault.actions.d.ts +33 -8
  10. package/lib/adapters/solana/vault.actions.js +185 -28
  11. package/lib/adapters/stellar/actions.d.ts +2 -2
  12. package/lib/adapters/stellar/actions.js +2 -2
  13. package/lib/adapters/stellar/getters.d.ts +1 -1
  14. package/lib/adapters/stellar/getters.js +2 -2
  15. package/lib/adapters/stellar/index.d.ts +1 -1
  16. package/lib/adapters/stellar/index.js +1 -1
  17. package/lib/adapters/stellar/types.d.ts +1 -2
  18. package/lib/core/analytics/method-taxonomy.js +7 -0
  19. package/lib/core/analytics/version.d.ts +1 -1
  20. package/lib/core/analytics/version.js +1 -1
  21. package/lib/core/base.class.d.ts +2 -2
  22. package/lib/core/base.class.js +2 -2
  23. package/lib/core/constants/core.d.ts +17 -3
  24. package/lib/core/constants/core.js +17 -3
  25. package/lib/core/constants/vaults.js +4 -0
  26. package/lib/core/fetcher.js +112 -45
  27. package/lib/core/helpers/concurrency.d.ts +37 -0
  28. package/lib/core/helpers/concurrency.js +58 -0
  29. package/lib/core/helpers/core.d.ts +9 -0
  30. package/lib/core/helpers/core.js +47 -0
  31. package/lib/core/helpers/vaults.d.ts +1 -1
  32. package/lib/core/helpers/vaults.js +1 -1
  33. package/lib/core/helpers/web3.js +14 -1
  34. package/lib/core/logger/curator-alert.d.ts +2 -2
  35. package/lib/core/logger/curator-alert.js +2 -2
  36. package/lib/evm/methods/crossChainVaultRegistry.d.ts +2 -3
  37. package/lib/evm/methods/crossChainVaultRegistry.js +2 -3
  38. package/lib/evm/types/crossChain.d.ts +1 -1
  39. package/lib/main.d.ts +7 -5
  40. package/lib/main.js +7 -5
  41. package/lib/modules/vaults/getters.d.ts +10 -3
  42. package/lib/modules/vaults/getters.js +205 -71
  43. package/lib/modules/vaults/main.d.ts +4 -4
  44. package/lib/modules/vaults/main.js +7 -4
  45. package/lib/modules/vaults/read.actions.d.ts +181 -0
  46. package/lib/modules/vaults/read.actions.js +331 -36
  47. package/lib/modules/vaults/types.d.ts +13 -0
  48. package/lib/modules/vaults/utils.js +5 -1
  49. package/lib/modules/vaults/write.actions.d.ts +74 -6
  50. package/lib/modules/vaults/write.actions.js +133 -23
  51. package/lib/sdk.d.ts +9827 -9342
  52. package/lib/services/subgraph/schema.d.ts +1 -1
  53. package/lib/services/subgraph/schema.js +1 -1
  54. package/lib/types/pools.d.ts +1 -1
  55. package/lib/types/vaults.d.ts +4 -4
  56. package/package.json +1 -1
@@ -6,6 +6,40 @@ const core_1 = require("../../core");
6
6
  const utils_1 = require("../../modules/vaults/utils");
7
7
  const TokenizedVaultV2_1 = require("../../abis/TokenizedVaultV2");
8
8
  const TokenizedVaultV2Receipt_1 = require("../../abis/TokenizedVaultV2Receipt");
9
+ /**
10
+ * Read the vault's on-chain deposit-pause switch.
11
+ *
12
+ * A curator pausing deposits is the only signal that the deposit CTA must be
13
+ * disabled — without this read the UI offers a deposit that always reverts with
14
+ * `DepositsPaused` at estimateGas.
15
+ *
16
+ * Only a contract **revert** is treated as "getter absent". Transport failures
17
+ * (rate limit, timeout, network blip) are re-thrown: swallowing them would
18
+ * render a paused vault as open and send the user into a deposit that reverts
19
+ * at estimateGas — exactly the failure this read exists to prevent.
20
+ * @param vaultContract Vault contract instance (v1 lending pool or v2 tokenized vault).
21
+ * @returns `true` when deposits are paused on-chain; `false` when they are open
22
+ * OR when the deployment predates the getter — an older vault without
23
+ * `depositsPaused()` reverts the call, and a reverting read must not drop the
24
+ * whole vault from the marketplace.
25
+ * @throws The underlying RPC error when the read fails for a transport reason
26
+ * rather than a contract revert, so a flaky node cannot masquerade as
27
+ * "deposits open".
28
+ */
29
+ const readDepositsPaused = async (vaultContract) => {
30
+ try {
31
+ return await vaultContract.depositsPaused();
32
+ }
33
+ catch (error) {
34
+ // Old deployments without `depositsPaused()` revert — treat as open.
35
+ // Anything else is a transport fault and must surface.
36
+ const isMissingGetter = (0, core_1.isExpectedRevertError)(error);
37
+ (0, core_1.logChainError)('readDepositsPaused', error, isMissingGetter);
38
+ if (isMissingGetter)
39
+ return false;
40
+ throw error;
41
+ }
42
+ };
9
43
  /**
10
44
  * Fetch EVM vault data for v1 vault contracts (legacy format).
11
45
  * Queries on-chain state and combines with backend metadata.
@@ -49,6 +83,9 @@ const getEvmVaultV1 = async (tokenizedVault, options) => {
49
83
  return null;
50
84
  }
51
85
  }
86
+ if (f === 'depositsPaused') {
87
+ return readDepositsPaused(vaultContract);
88
+ }
52
89
  if (f === 'symbol') {
53
90
  return (0, core_1.getSymbol)(provider, vault);
54
91
  }
@@ -133,6 +170,9 @@ const getEvmVaultV2 = async (tokenizedVault, options) => {
133
170
  return null;
134
171
  }
135
172
  }
173
+ if (f === 'depositsPaused') {
174
+ return readDepositsPaused(vaultContract);
175
+ }
136
176
  return vaultContract[f]();
137
177
  }));
138
178
  const receiptAddress = vaultContractCalls[core_1.VAULT_FUNCTIONS_V2.length - 1];
@@ -1,6 +1,6 @@
1
- import { type IContractWriteOptions, type INativeDepositOptions, type ApproveResult } from '../../modules/vaults/write.actions';
1
+ import { type IContractWriteOptions, type INativeDepositOptions, type ApproveResult, type IClaimWithdrawalOptions } from '../../modules/vaults/write.actions';
2
2
  import type { ISwapAndDepositOptions, ISwapRouterDirectDepositOptions, ISwapRouterNativeDepositOptions, ISwapRouterDepositOptions, ISwapRouterDepositResultOptions } from '../../types';
3
- import { type IPreviewDepositOptions, type IPreviewRedeemOptions, type IAllowanceOptions, type IBalanceOfOptions, type IMaxDepositOptions } from '../../modules/vaults/read.actions';
3
+ import { type IPreviewDepositOptions, type IPreviewRedeemOptions, type IAllowanceOptions, type IBalanceOfOptions, type IMaxDepositOptions, type IGetIdleLiquidityOptions, type ILagDurationOptions, type IGetWithdrawalEpochOptions, type IWithdrawalEpoch, type IGetBurnableAmountByReceiverOptions, type IGetRequirementByDateOptions, type IGetScheduledTransactionsByDateOptions, type IScheduledTransactionsByDate } from '../../modules/vaults/read.actions';
4
4
  import { type CompatibleSigner } from '../../core/helpers/signer';
5
5
  import type { IAddress } from '../../types';
6
6
  export * from './getters';
@@ -265,6 +265,36 @@ declare class EVMAdapter {
265
265
  day: string;
266
266
  receiverIndex: string;
267
267
  }): Promise<string>;
268
+ /**
269
+ * Claim a previously-requested queued withdrawal on an EVM-2 (Tokenized
270
+ * Vault V2) vault, once its withdrawal epoch has passed. EVM-2 only — v1/v0
271
+ * vaults use {@link EVMAdapter.vaultRedeem} instead.
272
+ *
273
+ * @param options - {@link IClaimWithdrawalOptions}: `target` / `wallet`
274
+ * plus the `year` / `month` / `day` tuple returned by
275
+ * `vaultRequestRedeem`.
276
+ * @returns Claim transaction hash.
277
+ * @throws AugustValidationError on invalid inputs or a non-EVM-2 vault.
278
+ * @throws AugustSDKError on RPC / contract revert.
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * const { year, month, day } = await augustSdk.evm.vaultRequestRedeem({
283
+ * target: vaultAddress,
284
+ * wallet: walletAddress,
285
+ * amount: '10',
286
+ * });
287
+ * await augustSdk.evm.claimWithdrawal({
288
+ * target: vaultAddress,
289
+ * wallet: walletAddress,
290
+ * year,
291
+ * month,
292
+ * day,
293
+ * wait: true,
294
+ * });
295
+ * ```
296
+ */
297
+ claimWithdrawal(options: IClaimWithdrawalOptions): Promise<string>;
268
298
  sendersWhitelistAddress(options: {
269
299
  vault: IAddress;
270
300
  }): Promise<`0x${string}`>;
@@ -349,5 +379,79 @@ declare class EVMAdapter {
349
379
  * ```
350
380
  */
351
381
  maxDeposit(options: IMaxDepositOptions): Promise<bigint>;
382
+ /**
383
+ * Read an EVM-2 vault's idle liquidity (`getTotalAssets() -
384
+ * externalAssets()`) — the balance available to an instant redemption
385
+ * without a synchronous recall from the settlement module.
386
+ *
387
+ * @returns Idle liquidity as a raw `bigint`.
388
+ *
389
+ * @example
390
+ * ```ts
391
+ * const idle = await augustSdk.evm.getIdleLiquidity({ vault });
392
+ * ```
393
+ */
394
+ getIdleLiquidity(options: IGetIdleLiquidityOptions): Promise<bigint>;
395
+ /**
396
+ * Read an EVM-2 vault's queued-withdrawal lag, in seconds.
397
+ *
398
+ * @returns Lag duration as a raw `bigint`.
399
+ *
400
+ * @example
401
+ * ```ts
402
+ * const seconds = await augustSdk.evm.lagDuration({ vault });
403
+ * ```
404
+ */
405
+ lagDuration(options: ILagDurationOptions): Promise<bigint>;
406
+ /**
407
+ * Read an EVM-2 vault's current withdrawal epoch by named field
408
+ * (`year`/`month`/`day`/`claimableEpoch`).
409
+ *
410
+ * @returns {@link IWithdrawalEpoch}.
411
+ *
412
+ * @example
413
+ * ```ts
414
+ * const epoch = await augustSdk.evm.getWithdrawalEpoch({ vault });
415
+ * ```
416
+ */
417
+ getWithdrawalEpoch(options: IGetWithdrawalEpochOptions): Promise<IWithdrawalEpoch>;
418
+ /**
419
+ * Read how much of a withdrawal-epoch date's queue a receiver can
420
+ * currently claim, before calling {@link EVMAdapter.claimWithdrawal}.
421
+ *
422
+ * @returns Claimable amount as a raw `bigint`.
423
+ *
424
+ * @example
425
+ * ```ts
426
+ * const claimable = await augustSdk.evm.getBurnableAmountByReceiver({
427
+ * vault, receiver, year, month, day,
428
+ * });
429
+ * ```
430
+ */
431
+ getBurnableAmountByReceiver(options: IGetBurnableAmountByReceiverOptions): Promise<bigint>;
432
+ /**
433
+ * Read the total shares required to settle a withdrawal-epoch date's
434
+ * entire queue.
435
+ *
436
+ * @returns Required shares as a raw `bigint`.
437
+ *
438
+ * @example
439
+ * ```ts
440
+ * const shares = await augustSdk.evm.getRequirementByDate({ vault, year, month, day });
441
+ * ```
442
+ */
443
+ getRequirementByDate(options: IGetRequirementByDateOptions): Promise<bigint>;
444
+ /**
445
+ * Read the scheduled queued-withdrawal volume for a withdrawal-epoch date.
446
+ *
447
+ * @returns {@link IScheduledTransactionsByDate}.
448
+ *
449
+ * @example
450
+ * ```ts
451
+ * const { totalTransactions, executionEpoch } =
452
+ * await augustSdk.evm.getScheduledTransactionsByDate({ vault, year, month, day });
453
+ * ```
454
+ */
455
+ getScheduledTransactionsByDate(options: IGetScheduledTransactionsByDateOptions): Promise<IScheduledTransactionsByDate>;
352
456
  }
353
457
  export default EVMAdapter;
@@ -332,6 +332,39 @@ class EVMAdapter {
332
332
  const signer = await this.getSigner();
333
333
  return (0, write_actions_1.vaultRedeem)(signer, options);
334
334
  }
335
+ /**
336
+ * Claim a previously-requested queued withdrawal on an EVM-2 (Tokenized
337
+ * Vault V2) vault, once its withdrawal epoch has passed. EVM-2 only — v1/v0
338
+ * vaults use {@link EVMAdapter.vaultRedeem} instead.
339
+ *
340
+ * @param options - {@link IClaimWithdrawalOptions}: `target` / `wallet`
341
+ * plus the `year` / `month` / `day` tuple returned by
342
+ * `vaultRequestRedeem`.
343
+ * @returns Claim transaction hash.
344
+ * @throws AugustValidationError on invalid inputs or a non-EVM-2 vault.
345
+ * @throws AugustSDKError on RPC / contract revert.
346
+ *
347
+ * @example
348
+ * ```ts
349
+ * const { year, month, day } = await augustSdk.evm.vaultRequestRedeem({
350
+ * target: vaultAddress,
351
+ * wallet: walletAddress,
352
+ * amount: '10',
353
+ * });
354
+ * await augustSdk.evm.claimWithdrawal({
355
+ * target: vaultAddress,
356
+ * wallet: walletAddress,
357
+ * year,
358
+ * month,
359
+ * day,
360
+ * wait: true,
361
+ * });
362
+ * ```
363
+ */
364
+ async claimWithdrawal(options) {
365
+ const signer = await this.getSigner();
366
+ return (0, write_actions_1.claimWithdrawal)(signer, options);
367
+ }
335
368
  async sendersWhitelistAddress(options) {
336
369
  const signer = await this.getSigner();
337
370
  return (0, read_actions_1.sendersWhitelistAddress)(signer, options);
@@ -429,6 +462,98 @@ class EVMAdapter {
429
462
  const signer = await this.getSigner();
430
463
  return (0, read_actions_1.maxDeposit)(signer, options);
431
464
  }
465
+ /**
466
+ * Read an EVM-2 vault's idle liquidity (`getTotalAssets() -
467
+ * externalAssets()`) — the balance available to an instant redemption
468
+ * without a synchronous recall from the settlement module.
469
+ *
470
+ * @returns Idle liquidity as a raw `bigint`.
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * const idle = await augustSdk.evm.getIdleLiquidity({ vault });
475
+ * ```
476
+ */
477
+ async getIdleLiquidity(options) {
478
+ const signer = await this.getSigner();
479
+ return (0, read_actions_1.getIdleLiquidity)(signer, options);
480
+ }
481
+ /**
482
+ * Read an EVM-2 vault's queued-withdrawal lag, in seconds.
483
+ *
484
+ * @returns Lag duration as a raw `bigint`.
485
+ *
486
+ * @example
487
+ * ```ts
488
+ * const seconds = await augustSdk.evm.lagDuration({ vault });
489
+ * ```
490
+ */
491
+ async lagDuration(options) {
492
+ const signer = await this.getSigner();
493
+ return (0, read_actions_1.lagDuration)(signer, options);
494
+ }
495
+ /**
496
+ * Read an EVM-2 vault's current withdrawal epoch by named field
497
+ * (`year`/`month`/`day`/`claimableEpoch`).
498
+ *
499
+ * @returns {@link IWithdrawalEpoch}.
500
+ *
501
+ * @example
502
+ * ```ts
503
+ * const epoch = await augustSdk.evm.getWithdrawalEpoch({ vault });
504
+ * ```
505
+ */
506
+ async getWithdrawalEpoch(options) {
507
+ const signer = await this.getSigner();
508
+ return (0, read_actions_1.getWithdrawalEpoch)(signer, options);
509
+ }
510
+ /**
511
+ * Read how much of a withdrawal-epoch date's queue a receiver can
512
+ * currently claim, before calling {@link EVMAdapter.claimWithdrawal}.
513
+ *
514
+ * @returns Claimable amount as a raw `bigint`.
515
+ *
516
+ * @example
517
+ * ```ts
518
+ * const claimable = await augustSdk.evm.getBurnableAmountByReceiver({
519
+ * vault, receiver, year, month, day,
520
+ * });
521
+ * ```
522
+ */
523
+ async getBurnableAmountByReceiver(options) {
524
+ const signer = await this.getSigner();
525
+ return (0, read_actions_1.getBurnableAmountByReceiver)(signer, options);
526
+ }
527
+ /**
528
+ * Read the total shares required to settle a withdrawal-epoch date's
529
+ * entire queue.
530
+ *
531
+ * @returns Required shares as a raw `bigint`.
532
+ *
533
+ * @example
534
+ * ```ts
535
+ * const shares = await augustSdk.evm.getRequirementByDate({ vault, year, month, day });
536
+ * ```
537
+ */
538
+ async getRequirementByDate(options) {
539
+ const signer = await this.getSigner();
540
+ return (0, read_actions_1.getRequirementByDate)(signer, options);
541
+ }
542
+ /**
543
+ * Read the scheduled queued-withdrawal volume for a withdrawal-epoch date.
544
+ *
545
+ * @returns {@link IScheduledTransactionsByDate}.
546
+ *
547
+ * @example
548
+ * ```ts
549
+ * const { totalTransactions, executionEpoch } =
550
+ * await augustSdk.evm.getScheduledTransactionsByDate({ vault, year, month, day });
551
+ * ```
552
+ */
553
+ async getScheduledTransactionsByDate(options) {
554
+ const signer = await this.getSigner();
555
+ return (0, read_actions_1.getScheduledTransactionsByDate)(signer, options);
556
+ }
432
557
  }
433
558
  exports.default = EVMAdapter;
434
559
  //# sourceMappingURL=index.js.map
@@ -8,7 +8,7 @@ import * as SolanaGetters from './getters';
8
8
  import * as SolanaActions from './vault.actions';
9
9
  import type { AnchorProvider, web3 } from '@coral-xyz/anchor';
10
10
  import { type Commitment, Connection, PublicKey, type Transaction } from '@solana/web3.js';
11
- import type { ISolanaNetwork, ISolanaRpcEndpoint } from './types';
11
+ import type { ISolanaDepositOptions, ISolanaNetwork, ISolanaRedeemOptions, ISolanaRpcEndpoint } from './types';
12
12
  import type { SendTransactionOptions } from '@solana/wallet-adapter-base';
13
13
  export declare const Solana: {
14
14
  utils: {
@@ -228,7 +228,7 @@ declare class SolanaAdapter {
228
228
  /**
229
229
  * Deposit funds into a Solana August vault.
230
230
  * @param depositAmount `bigint` (raw on-chain units) or `number` (UI amount).
231
- * @param sendTransaction - **Ignored; scheduled for removal (AUGUST-7221).**
231
+ * @param sendTransaction - **Ignored; scheduled for removal in the next major release.**
232
232
  * Share-account creation is now prepended to the deposit instruction, so
233
233
  * the SDK sends no second transaction and never invokes this callback —
234
234
  * signing goes through the provider's wallet.
@@ -237,12 +237,15 @@ declare class SolanaAdapter {
237
237
  * `vaultAddress`, so removing it shifts your vault address into this slot
238
238
  * and leaves `vaultAddress` undefined — which silently falls back to the
239
239
  * legacy single-vault PDA derivation and targets a different vault.
240
+ * @param options - Slippage protection. By default the SDK quotes the shares this deposit should mint
241
+ * from the vault's current state and passes that quote, lowered by 50 bps,
242
+ * as the floor to the program's checked instruction. See {@link ISolanaDepositOptions}.
240
243
  */
241
- vaultDeposit(vaultProgramId: PublicKey | string, idl: any, publicKey: PublicKey | string, depositAmount: number | bigint, sendTransaction?: (transaction: Transaction | web3.VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<web3.TransactionSignature>, vaultAddress?: PublicKey | string): Promise<any>;
244
+ vaultDeposit(vaultProgramId: PublicKey | string, idl: any, publicKey: PublicKey | string, depositAmount: number | bigint, sendTransaction?: (transaction: Transaction | web3.VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<web3.TransactionSignature>, vaultAddress?: PublicKey | string, options?: ISolanaDepositOptions): Promise<any>;
242
245
  /**
243
246
  * Redeem vault shares from a Solana August vault.
244
247
  * @param redeemShares `bigint` (raw share units) or `number` (UI amount).
245
- * @param sendTransaction - **Ignored; scheduled for removal (AUGUST-7221).**
248
+ * @param sendTransaction - **Ignored; scheduled for removal in the next major release.**
246
249
  * Payout- and fee-recipient-account creation is now prepended to the redeem
247
250
  * instruction, so the SDK sends no second transaction and never invokes
248
251
  * this callback — signing goes through the provider's wallet.
@@ -251,8 +254,11 @@ declare class SolanaAdapter {
251
254
  * `vaultAddress`, so removing it shifts your vault address into this slot
252
255
  * and leaves `vaultAddress` undefined — which silently falls back to the
253
256
  * legacy single-vault PDA derivation and targets a different vault.
257
+ * @param options - Slippage protection. By default the SDK quotes the net payout these shares should return
258
+ * from the vault's current state and passes that quote, lowered by 50 bps,
259
+ * as the floor to the program's checked instruction. See {@link ISolanaRedeemOptions}.
254
260
  */
255
- vaultRedeem(vaultProgramId: PublicKey | string, idl: any, publicKey: PublicKey | string, redeemShares: number | bigint, sendTransaction?: (transaction: Transaction | web3.VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<web3.TransactionSignature>, vaultAddress?: PublicKey | string): Promise<any>;
261
+ vaultRedeem(vaultProgramId: PublicKey | string, idl: any, publicKey: PublicKey | string, redeemShares: number | bigint, sendTransaction?: (transaction: Transaction | web3.VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<web3.TransactionSignature>, vaultAddress?: PublicKey | string, options?: ISolanaRedeemOptions): Promise<any>;
256
262
  /**
257
263
  * Canonical program id for a program type on this adapter's network.
258
264
  *
@@ -264,4 +270,5 @@ declare class SolanaAdapter {
264
270
  */
265
271
  getProgramId(type: 'vault'): string;
266
272
  }
273
+ export type { ISolanaDepositOptions, ISolanaRedeemOptions } from './types';
267
274
  export default SolanaAdapter;
@@ -257,7 +257,7 @@ class SolanaAdapter {
257
257
  /**
258
258
  * Deposit funds into a Solana August vault.
259
259
  * @param depositAmount `bigint` (raw on-chain units) or `number` (UI amount).
260
- * @param sendTransaction - **Ignored; scheduled for removal (AUGUST-7221).**
260
+ * @param sendTransaction - **Ignored; scheduled for removal in the next major release.**
261
261
  * Share-account creation is now prepended to the deposit instruction, so
262
262
  * the SDK sends no second transaction and never invokes this callback —
263
263
  * signing goes through the provider's wallet.
@@ -266,8 +266,11 @@ class SolanaAdapter {
266
266
  * `vaultAddress`, so removing it shifts your vault address into this slot
267
267
  * and leaves `vaultAddress` undefined — which silently falls back to the
268
268
  * legacy single-vault PDA derivation and targets a different vault.
269
+ * @param options - Slippage protection. By default the SDK quotes the shares this deposit should mint
270
+ * from the vault's current state and passes that quote, lowered by 50 bps,
271
+ * as the floor to the program's checked instruction. See {@link ISolanaDepositOptions}.
269
272
  */
270
- async vaultDeposit(vaultProgramId, idl, publicKey, depositAmount, sendTransaction, vaultAddress) {
273
+ async vaultDeposit(vaultProgramId, idl, publicKey, depositAmount, sendTransaction, vaultAddress, options) {
271
274
  return await (0, vault_actions_1.handleSolanaDeposit)({
272
275
  network: this._network,
273
276
  provider: this._provider,
@@ -278,12 +281,13 @@ class SolanaAdapter {
278
281
  publicKey,
279
282
  depositAmount,
280
283
  sendTransaction,
284
+ options,
281
285
  });
282
286
  }
283
287
  /**
284
288
  * Redeem vault shares from a Solana August vault.
285
289
  * @param redeemShares `bigint` (raw share units) or `number` (UI amount).
286
- * @param sendTransaction - **Ignored; scheduled for removal (AUGUST-7221).**
290
+ * @param sendTransaction - **Ignored; scheduled for removal in the next major release.**
287
291
  * Payout- and fee-recipient-account creation is now prepended to the redeem
288
292
  * instruction, so the SDK sends no second transaction and never invokes
289
293
  * this callback — signing goes through the provider's wallet.
@@ -292,8 +296,11 @@ class SolanaAdapter {
292
296
  * `vaultAddress`, so removing it shifts your vault address into this slot
293
297
  * and leaves `vaultAddress` undefined — which silently falls back to the
294
298
  * legacy single-vault PDA derivation and targets a different vault.
299
+ * @param options - Slippage protection. By default the SDK quotes the net payout these shares should return
300
+ * from the vault's current state and passes that quote, lowered by 50 bps,
301
+ * as the floor to the program's checked instruction. See {@link ISolanaRedeemOptions}.
295
302
  */
296
- async vaultRedeem(vaultProgramId, idl, publicKey, redeemShares, sendTransaction, vaultAddress) {
303
+ async vaultRedeem(vaultProgramId, idl, publicKey, redeemShares, sendTransaction, vaultAddress, options) {
297
304
  return await (0, vault_actions_1.handleSolanaRedeem)({
298
305
  network: this._network,
299
306
  provider: this._provider,
@@ -304,6 +311,7 @@ class SolanaAdapter {
304
311
  publicKey,
305
312
  redeemShares,
306
313
  sendTransaction,
314
+ options,
307
315
  });
308
316
  }
309
317
  /**
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Off-chain mirror of the `august_vault` pricing math.
3
+ *
4
+ * Used to quote what a deposit or redeem is expected to return so a slippage
5
+ * floor can be handed to `deposit_checked` / `redeem_checked`. Mirrors
6
+ * `VaultState::shares_for_deposit_with_offset` and
7
+ * `assets_for_redeem_with_offset` (`programs/august-vault/src/state/vault.rs`):
8
+ * `u128` intermediates, a per-vault virtual-share offset defaulting to
9
+ * `EXTRA_SHARES = 1_000_000`, a pro-rata floor (deposit) or cap (redeem),
10
+ * every division rounded down; plus the withdrawal fee `redeem_checked` takes,
11
+ * `ceil(assets * fee / 1e6)` at `FEE_RATE_DENOMINATOR_VALUE = 1_000_000`.
12
+ *
13
+ * A quote is only a quote. The program prices at execution, against state
14
+ * that may have moved since the read; the floor derived here is what protects
15
+ * the caller when the two differ.
16
+ *
17
+ * This mirror cannot validate itself — agreeing with its own tests proves
18
+ * nothing about the program — so every claim below about program behaviour is
19
+ * cited to its handler in `fractal-protocol/solana-upshift-vault-programs`, by
20
+ * file and function rather than line. Verified against that repo at 3b91c86.
21
+ * Do not "fix" the math here against intuition; re-read the handler.
22
+ *
23
+ * Adapter-internal. These functions are exported for `vault.actions.ts` and
24
+ * the unit tests only — deliberately absent from the `adapters/solana` barrel,
25
+ * so they are not public SDK surface and carry no benchmark or telemetry
26
+ * taxonomy obligation. Promoting one to the barrel means taking both on.
27
+ *
28
+ * @packageDocumentation
29
+ */
30
+ /** What the program uses when a vault stores `share_offset == 0` (vaults created before the field existed). */
31
+ export declare const DEFAULT_SHARE_OFFSET = 1000000n;
32
+ /** Slippage tolerance applied when a caller gives neither `slippageBps` nor an explicit floor. */
33
+ export declare const DEFAULT_SLIPPAGE_BPS = 50;
34
+ /**
35
+ * Coerce an on-chain integer as Anchor decodes it (`BN`, `number`, decimal
36
+ * string, or `bigint`) to `bigint`.
37
+ *
38
+ * @param value - The decoded field.
39
+ * @param label - Named in the error when the value is not a non-negative integer.
40
+ * @throws AugustSDKError when the value cannot be read as a non-negative integer.
41
+ */
42
+ export declare function toBigInt(value: unknown, label: string): bigint;
43
+ /**
44
+ * The vault's effective share offset. A stored zero (or a state decoded from
45
+ * an IDL that predates the field) resolves to the program default, exactly as
46
+ * `VaultState::share_offset()` does on-chain.
47
+ *
48
+ * @param raw - `VaultState.shareOffset` as decoded, or `undefined`.
49
+ */
50
+ export declare function resolveShareOffset(raw: unknown): bigint;
51
+ /**
52
+ * `localAum + deployedAum`, the `total_assets()` the program prices against.
53
+ *
54
+ * @param state - Decoded `VaultState`.
55
+ * @throws AugustSDKError when either field is missing, which means the state
56
+ * was decoded with an IDL this SDK cannot price against.
57
+ */
58
+ export declare function totalAssetsOf(state: {
59
+ localAum?: unknown;
60
+ deployedAum?: unknown;
61
+ }): bigint;
62
+ /**
63
+ * Shares minted for depositing `amount` base units.
64
+ *
65
+ * `floor(max(amount * (supply + offset) / (totalAssets + offset), amount * supply / totalAssets))`.
66
+ * Above par the offset term is the larger and binds; below par the pro-rata
67
+ * floor binds so a depositor never hands value to incumbents on arrival.
68
+ *
69
+ * @param input - Share supply, total assets and the vault's resolved offset,
70
+ * all in raw base units.
71
+ * @throws AugustValidationError when the vault has no share price.
72
+ */
73
+ export declare function sharesForDeposit(input: {
74
+ supply: bigint;
75
+ totalAssets: bigint;
76
+ amount: bigint;
77
+ offset: bigint;
78
+ }): bigint;
79
+ /**
80
+ * Assets paid, before the withdrawal fee, for burning `shares`.
81
+ *
82
+ * `floor(min(shares * (totalAssets + offset) / (supply + offset), shares * totalAssets / supply))`.
83
+ * The mirror of {@link sharesForDeposit}: above par the offset term binds,
84
+ * below par the pro-rata cap does, so no redeemer takes more than its share.
85
+ *
86
+ * @param input - Share supply, total assets and the vault's resolved offset,
87
+ * all in raw base units.
88
+ * @throws AugustValidationError when the vault has no share price.
89
+ */
90
+ export declare function assetsForRedeem(input: {
91
+ supply: bigint;
92
+ totalAssets: bigint;
93
+ shares: bigint;
94
+ offset: bigint;
95
+ }): bigint;
96
+ /**
97
+ * The withdrawal fee the program takes from a gross redemption:
98
+ * `ceil(assets * feePpm / 1e6)`, rounded **up** as on-chain.
99
+ *
100
+ * @param assets - Gross assets from {@link assetsForRedeem}.
101
+ * @param feePpm - `VaultState.withdrawalFee`, parts per million.
102
+ */
103
+ export declare function withdrawalFee(assets: bigint, feePpm: bigint): bigint;
104
+ /**
105
+ * Lower `expected` by `slippageBps` basis points, rounding down.
106
+ *
107
+ * @param expected - The quoted output in raw base units.
108
+ * @param slippageBps - Integer basis points, `0` to `10_000`.
109
+ * @throws AugustValidationError when `slippageBps` is out of range or not an integer.
110
+ */
111
+ export declare function applySlippage(expected: bigint, slippageBps: number): bigint;
112
+ /**
113
+ * The `min_shares_out` to pass to `deposit_checked`: the quoted shares for
114
+ * `amount`, lowered by `slippageBps`.
115
+ *
116
+ * Nothing is netted out, because there is no deposit-side fee. In
117
+ * `instructions/deposit.rs::handler_checked` the comparison is
118
+ * `require!(shares >= min_shares_out, SlippageExceeded)` directly on the
119
+ * `shares_for_deposit` result, with no fee term anywhere in the handler.
120
+ * Structurally too: `VaultState` carries exactly one fee field,
121
+ * `withdrawal_fee`, and `deposit_checked` takes no `fee_recipient_account`
122
+ * among its accounts (`redeem_checked` does), so it has no account to pay one
123
+ * to. Gross and net are the same quantity here.
124
+ *
125
+ * Quoting from state read *before* the transaction is correct despite the
126
+ * handler transferring the deposit in first: `transfer_in_ctx` moves SPL
127
+ * tokens into the vault ATA, but `total_assets()` sums the stored `local_aum`
128
+ * and `deployed_aum` fields, and `local_aum` is incremented only *after*
129
+ * `shares_for_deposit` has been computed. Supply is likewise read before the
130
+ * mint. The handler prices against the same pre-deposit figures this quote
131
+ * does.
132
+ *
133
+ * @param input - Vault state, deposit amount and tolerance.
134
+ */
135
+ export declare function quoteDepositFloor(input: {
136
+ supply: bigint;
137
+ totalAssets: bigint;
138
+ amount: bigint;
139
+ offset: bigint;
140
+ slippageBps: number;
141
+ }): bigint;
142
+ /**
143
+ * The `min_assets_out` to pass to `redeem_checked`: the quoted payout for
144
+ * `shares` **net of the withdrawal fee** — which is what `redeem_checked`
145
+ * compares against — lowered by `slippageBps`.
146
+ *
147
+ * Net rather than gross is the hinge of the whole guarantee, so it is pinned
148
+ * here rather than left to be re-derived. In
149
+ * `instructions/redeem.rs::handler_checked` the program computes the gross
150
+ * `assets`, subtracts `fees` — the `ceil_div` of `assets * withdrawal_fee`
151
+ * over `FEE_RATE_DENOMINATOR_VALUE` — and compares `min_assets_out` against
152
+ * that difference, which is the figure the caller actually receives.
153
+ * `Redeem::ceil_div` is `(n + d - 1) / d`, which is what
154
+ * {@link withdrawalFee} reproduces.
155
+ *
156
+ * Getting this wrong fails quietly in the dangerous direction. Quote against
157
+ * the gross payout and the floor sits a whole fee above what the program
158
+ * measures, so it binds early and reverts healthy redemptions. Net it twice —
159
+ * or drop the fee from a vault that charges one — and the floor sits below the
160
+ * real payout by the fee, leaving protection weaker than the advertised
161
+ * `slippageBps` instead of visibly broken. `withdrawal_fee` is capped just
162
+ * under 10% (`set_withdrawal_fee`), which bounds that silent gap.
163
+ *
164
+ * @param input - Vault state, shares to burn, fee and tolerance.
165
+ */
166
+ export declare function quoteRedeemFloor(input: {
167
+ supply: bigint;
168
+ totalAssets: bigint;
169
+ shares: bigint;
170
+ offset: bigint;
171
+ feePpm: bigint;
172
+ slippageBps: number;
173
+ }): bigint;