@augustdigital/sdk 9.11.0 → 9.13.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 (40) hide show
  1. package/lib/adapters/solana/constants.d.ts +12 -4
  2. package/lib/adapters/solana/constants.js +8 -3
  3. package/lib/adapters/solana/getters.d.ts +5 -0
  4. package/lib/adapters/solana/getters.js +35 -1
  5. package/lib/adapters/solana/idl/vault-idl.d.ts +334 -7
  6. package/lib/adapters/solana/idl/vault-idl.js +600 -59
  7. package/lib/adapters/solana/idl/withdrawal-queue-idl.d.ts +790 -0
  8. package/lib/adapters/solana/idl/withdrawal-queue-idl.js +1868 -0
  9. package/lib/adapters/solana/index.d.ts +108 -10
  10. package/lib/adapters/solana/index.js +137 -12
  11. package/lib/adapters/solana/pricing.d.ts +11 -0
  12. package/lib/adapters/solana/pricing.js +24 -8
  13. package/lib/adapters/solana/queue.actions.d.ts +98 -0
  14. package/lib/adapters/solana/queue.actions.js +488 -0
  15. package/lib/adapters/solana/token-reads.d.ts +108 -0
  16. package/lib/adapters/solana/token-reads.js +145 -0
  17. package/lib/adapters/solana/types.d.ts +200 -1
  18. package/lib/adapters/solana/utils.d.ts +16 -0
  19. package/lib/adapters/solana/utils.js +41 -4
  20. package/lib/adapters/solana/vault.actions.d.ts +17 -0
  21. package/lib/adapters/solana/vault.actions.js +14 -125
  22. package/lib/adapters/solana/withdrawal-queue.d.ts +125 -0
  23. package/lib/adapters/solana/withdrawal-queue.js +301 -0
  24. package/lib/core/analytics/method-taxonomy.js +2 -0
  25. package/lib/core/analytics/version.d.ts +1 -1
  26. package/lib/core/analytics/version.js +1 -1
  27. package/lib/main.d.ts +16 -0
  28. package/lib/main.js +16 -0
  29. package/lib/modules/vaults/getters.d.ts +2 -2
  30. package/lib/modules/vaults/getters.js +103 -3
  31. package/lib/modules/vaults/main.d.ts +12 -0
  32. package/lib/modules/vaults/main.js +17 -1
  33. package/lib/modules/vaults/types.d.ts +14 -1
  34. package/lib/modules/vaults/utils.d.ts +8 -0
  35. package/lib/modules/vaults/utils.js +19 -0
  36. package/lib/sdk.d.ts +2406 -1723
  37. package/lib/types/vaults.d.ts +55 -1
  38. package/lib/types/vaults.js +5 -0
  39. package/lib/types/webserver.d.ts +8 -0
  40. package/package.json +1 -1
package/lib/main.js CHANGED
@@ -317,8 +317,24 @@ class AugustSDK extends core_1.AugustBase {
317
317
  }
318
318
  /**
319
319
  * Get redemption requests that are ready to be claimed.
320
+ *
321
+ * For a Solana vault, `wallet` is the holder's base58 address and the result
322
+ * lists their withdrawal-queue requests: waiting (`AWAITING_COOLDOWN`) and
323
+ * past-window (`EXPIRED`, cancel-only) ones in `availableRedemptions`, and
324
+ * claimable ones (`READY_TO_CLAIM`) in `pendingRedemptions`, each with
325
+ * `estimatedAssets`, the net payout at the current share price. Without a
326
+ * Solana wallet, or for a vault with no queue, both lists are empty. Solana
327
+ * RPC: the vault state, one `getAccountInfo` for the queue, and, when it
328
+ * exists, one `getProgramAccounts` and one `getMultipleAccountsInfo` (the
329
+ * vault state, share mint and payout accounts, read together).
330
+ *
320
331
  * @param props - Vault address, chain ID, and optional wallet filter
321
332
  * @returns Array of available redemption requests with amounts and timestamps
333
+ * @example
334
+ * ```ts
335
+ * const { availableRedemptions, pendingRedemptions } =
336
+ * await sdk.getVaultAvailableRedemptions({ vault: solanaVault, wallet: holder });
337
+ * ```
322
338
  */
323
339
  async getVaultAvailableRedemptions(props) {
324
340
  return await this.vaults.getVaultAvailableRedemptions(props);
@@ -1,4 +1,4 @@
1
- import { type IAddress, type IHistoricalTimeseriesPoint, type IHistoricalTimeseriesResponse, type INormalizedNumber, type ISubgraphReserveDeposit, type ISubgraphTransfer, type ISubgraphUserHistoryItem, type ITokenizedVault, type ISubgraphWithdrawProccessed, type IVault, type IVaultAllocations, type IVaultAnnualizedApy, type IVaultAvailableRedemption, type IVaultLoan, type IVaultPosition, type IVaultRedemptionHistoryItem, type IVaultSummary, type IVaultWithdrawals, type IVaultPendingRedemptions, type IActiveStakingPosition, type IVaultHistoricalParams, type IVaultUserLifetimePnl, type IVaultBorrowerHealthFactor, type IVaultPnl, type VaultAddress } from '../../types';
1
+ import { type IAddress, type IHistoricalTimeseriesPoint, type IHistoricalTimeseriesResponse, type INormalizedNumber, type ISubgraphReserveDeposit, type ISubgraphTransfer, type ISubgraphUserHistoryItem, type ITokenizedVault, type ISubgraphWithdrawProccessed, type ISubgraphWithdrawRequest, type IVault, type IVaultAllocations, type IVaultAnnualizedApy, type IVaultAvailableRedemption, type IVaultLoan, type IVaultPosition, type IVaultRedemptionHistoryItem, type IVaultSummary, type IVaultWithdrawals, type IVaultPendingRedemptions, type IActiveStakingPosition, type IVaultHistoricalParams, type IVaultUserLifetimePnl, type IVaultBorrowerHealthFactor, type IVaultPnl, type VaultAddress } from '../../types';
2
2
  import type { IVaultBaseOptions } from './types';
3
3
  /**
4
4
  * Vault Data Getters
@@ -98,7 +98,7 @@ export declare function getVaultAvailableRedemptions({ vault, wallet, options, p
98
98
  };
99
99
  }): Promise<{
100
100
  processedWithdrawals: ISubgraphWithdrawProccessed[];
101
- requestedWithdrawals: import("../../types").ISubgraphWithdrawRequest[];
101
+ requestedWithdrawals: ISubgraphWithdrawRequest[];
102
102
  availableRedemptions: IVaultAvailableRedemption[];
103
103
  pendingRedemptions: IVaultAvailableRedemption[];
104
104
  }>;
@@ -85,6 +85,8 @@ const debank_1 = require("../../services/debank");
85
85
  const utils_2 = require("../../adapters/solana/utils");
86
86
  const SolanaGetters = __importStar(require("../../adapters/solana/getters"));
87
87
  const SolanaConstants = __importStar(require("../../adapters/solana/constants"));
88
+ const withdrawal_queue_1 = require("../../adapters/solana/withdrawal-queue");
89
+ const web3_js_1 = require("@solana/web3.js");
88
90
  const StellarGetters = __importStar(require("../../adapters/stellar/getters"));
89
91
  const utils_3 = require("../../adapters/stellar/utils");
90
92
  const constants_1 = require("../../adapters/stellar/constants");
@@ -935,6 +937,51 @@ async function readLagDuration(vaultContract, vault, scope) {
935
937
  * an empty response to any *other* view still surfaces as an error.
936
938
  */
937
939
  const LAG_DURATION_SELECTOR = '0x24e86d67';
940
+ /**
941
+ * A Solana wallet's withdrawal-queue requests on one vault, for
942
+ * `getVaultPositions` and `getVaultAvailableRedemptions`. Empty when the vault
943
+ * has no queue, the wallet has no request, or the service cannot name the queue
944
+ * program (including where the queue is not deployed); a failed read is logged
945
+ * and reads as empty, like the balance reads beside it.
946
+ *
947
+ * RPC: see `getSolanaWithdrawalRedemptions` (one `getAccountInfo` for a vault
948
+ * with no queue; up to one more `getProgramAccounts` and one
949
+ * `getMultipleAccountsInfo`).
950
+ */
951
+ async function readSolanaRedemptions(input) {
952
+ const empty = {
953
+ availableRedemptions: [],
954
+ pendingRedemptions: [],
955
+ };
956
+ const { tokenizedVault, solanaService, vaultState } = input;
957
+ if (!vaultState.shareMint)
958
+ return empty;
959
+ try {
960
+ const queueProgramId = (0, withdrawal_queue_1.resolveQueueProgramId)(solanaService);
961
+ if (!queueProgramId)
962
+ return empty;
963
+ const metadata = tokenizedVault.solana_vault_metadata;
964
+ const programId = utils_2.SolanaUtils.resolveProgramId(String(tokenizedVault.address), metadata);
965
+ return await (0, withdrawal_queue_1.getSolanaWithdrawalRedemptions)({
966
+ connection: solanaService.connection,
967
+ queueProgramId,
968
+ vaultStateAddress: metadata?.vault_state_pda
969
+ ? new web3_js_1.PublicKey(metadata.vault_state_pda)
970
+ : utils_2.SolanaUtils.deriveVaultStatePda(programId),
971
+ shareMint: new web3_js_1.PublicKey(vaultState.shareMint),
972
+ owner: new web3_js_1.PublicKey(input.wallet),
973
+ vault: tokenizedVault.address,
974
+ depositDecimals: input.depositDecimals,
975
+ });
976
+ }
977
+ catch (error) {
978
+ core_1.Logger.log.warn('readSolanaRedemptions', 'Withdrawal requests read failed', {
979
+ vault: tokenizedVault.address,
980
+ error,
981
+ });
982
+ return empty;
983
+ }
984
+ }
938
985
  async function getVaultAvailableRedemptions({ vault, wallet, options, prefetchedReads, }) {
939
986
  try {
940
987
  // Stellar vaults don't support on-chain redemptions yet
@@ -949,6 +996,41 @@ async function getVaultAvailableRedemptions({ vault, wallet, options, prefetched
949
996
  }),
950
997
  };
951
998
  }
999
+ // Solana: the wallet's withdrawal-queue requests. There is no processed
1000
+ // history to report, so the verbose lists are always empty.
1001
+ if (utils_2.SolanaUtils.isSolanaAddress(vault)) {
1002
+ const empty = {
1003
+ availableRedemptions: [],
1004
+ pendingRedemptions: [],
1005
+ ...(options.verbose && {
1006
+ processedWithdrawals: [],
1007
+ requestedWithdrawals: [],
1008
+ }),
1009
+ };
1010
+ const solanaService = options.solanaService;
1011
+ if (!wallet || !utils_2.SolanaUtils.isSolanaAddress(wallet) || !solanaService) {
1012
+ return empty;
1013
+ }
1014
+ const solanaVault = (await (0, core_1.fetchTokenizedVault)(vault, options?.headers, false, false))?.[0];
1015
+ if (!solanaVault)
1016
+ return empty;
1017
+ const vaultStateRes = await solanaService.getVaultState(utils_2.SolanaUtils.resolveProgramId(String(solanaVault.address), solanaVault.solana_vault_metadata), SolanaConstants.vaultIdl, solanaVault.solana_vault_metadata?.vault_state_pda ?? undefined);
1018
+ const vaultState = vaultStateRes?.vaultState;
1019
+ if (!vaultState)
1020
+ return empty;
1021
+ return {
1022
+ ...empty,
1023
+ ...(await readSolanaRedemptions({
1024
+ tokenizedVault: solanaVault,
1025
+ wallet,
1026
+ solanaService,
1027
+ vaultState,
1028
+ depositDecimals: vaultStateRes?.depositMintDecimals ??
1029
+ solanaVault.solana_vault_metadata?.deposit_token_decimals ??
1030
+ SolanaConstants.fallbackDecimals,
1031
+ })),
1032
+ };
1033
+ }
952
1034
  // setup
953
1035
  const provider = (0, core_1.createProvider)(options.rpcUrl);
954
1036
  const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault, options?.headers, false, false))?.[0];
@@ -1435,6 +1517,10 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
1435
1517
  const fallbackShareDecimals = v.solana_vault_metadata?.deposit_token_decimals ??
1436
1518
  SolanaConstants.fallbackDecimals;
1437
1519
  let balance = (0, core_1.toNormalizedBn)(0, fallbackShareDecimals);
1520
+ let redemptions = {
1521
+ availableRedemptions: [],
1522
+ pendingRedemptions: [],
1523
+ };
1438
1524
  // Defensive: without a Solana adapter we can't fetch on-chain
1439
1525
  // state. The outer filter in modules/vaults/main.ts already gates
1440
1526
  // on `this.solanaService`, so this is a belt-and-suspenders guard
@@ -1456,6 +1542,15 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
1456
1542
  const decimals = raw.decimals ?? fallbackShareDecimals;
1457
1543
  balance = (0, core_1.toNormalizedBn)(BigInt(raw.amount), decimals);
1458
1544
  }
1545
+ if (vaultState) {
1546
+ redemptions = await readSolanaRedemptions({
1547
+ tokenizedVault: v,
1548
+ wallet: solanaWallet,
1549
+ solanaService: options.solanaService,
1550
+ vaultState,
1551
+ depositDecimals: vaultStateRes?.depositMintDecimals ?? fallbackShareDecimals,
1552
+ });
1553
+ }
1459
1554
  }
1460
1555
  return {
1461
1556
  // Mirror the Stellar branch — return the backend's `v.address`,
@@ -1464,9 +1559,14 @@ async function getVaultPositions({ vault, wallet, solanaWallet, stellarWallet, o
1464
1559
  // not 0x-hex; the IAddress typing across non-EVM positions is a
1465
1560
  // known wart documented in IVaultPosition.
1466
1561
  vault: v.address,
1467
- status: renderStatus([], balance),
1468
- availableRedemptions: [],
1469
- pendingRedemptions: [],
1562
+ // Any queued request, waiting or claimable, marks the position
1563
+ // REDEEM; the shares it escrows are no longer in the wallet.
1564
+ status: renderStatus([
1565
+ ...redemptions.availableRedemptions,
1566
+ ...redemptions.pendingRedemptions,
1567
+ ], balance),
1568
+ availableRedemptions: redemptions.availableRedemptions,
1569
+ pendingRedemptions: redemptions.pendingRedemptions,
1470
1570
  redeemable: balance,
1471
1571
  walletBalance: balance,
1472
1572
  };
@@ -68,6 +68,8 @@ export declare class AugustVaults extends AugustBase {
68
68
  /**
69
69
  * Calculate total deposited across all tokenized vaults by summing latest_reported_tvl.
70
70
  * Uses the /tokenized_vault endpoint which returns latest_reported_tvl in USD.
71
+ * Wrapper vaults (non-null `underlying_vault_address`) are skipped: their
72
+ * deposits sit in the underlying vault as LP and are already counted there.
71
73
  * @param options Optional configuration for loading vaults
72
74
  * @returns Total deposited amount in USD (sum of all latest_reported_tvl values)
73
75
  */
@@ -160,7 +162,17 @@ export declare class AugustVaults extends AugustBase {
160
162
  nDays?: number;
161
163
  }): Promise<import("../../types").IHistoricalTimeseriesResponse>;
162
164
  /**
165
+ * A wallet's redemption requests on one vault, split into
166
+ * `availableRedemptions` and `pendingRedemptions`. EVM, Stellar and Solana
167
+ * vault addresses are accepted; see `AugustSDK.getVaultAvailableRedemptions`
168
+ * for what each list holds on Solana.
163
169
  *
170
+ * @param props - `vault`, the vault address; `chainId`, the EVM chain whose
171
+ * RPC to use (the active network when omitted); `wallet`, the holder,
172
+ * required for Solana, where it is base58; `verbose`, to also return the
173
+ * processed and requested withdrawal lists (always empty for Solana).
174
+ * @returns `{ availableRedemptions, pendingRedemptions }`, plus the verbose lists.
175
+ * @throws Error when unauthorized, or when `vault` is missing or not an address.
164
176
  */
165
177
  getVaultAvailableRedemptions({ vault, chainId, wallet, verbose, }: {
166
178
  vault: IAddress;
@@ -339,6 +339,8 @@ class AugustVaults extends core_1.AugustBase {
339
339
  /**
340
340
  * Calculate total deposited across all tokenized vaults by summing latest_reported_tvl.
341
341
  * Uses the /tokenized_vault endpoint which returns latest_reported_tvl in USD.
342
+ * Wrapper vaults (non-null `underlying_vault_address`) are skipped: their
343
+ * deposits sit in the underlying vault as LP and are already counted there.
342
344
  * @param options Optional configuration for loading vaults
343
345
  * @returns Total deposited amount in USD (sum of all latest_reported_tvl values)
344
346
  */
@@ -348,6 +350,8 @@ class AugustVaults extends core_1.AugustBase {
348
350
  allVaults.forEach((vault) => {
349
351
  if (vaults_2.TVL_EXCLUDED_VAULTS.has(vault.address?.toLowerCase()))
350
352
  return;
353
+ if (vault.underlying_vault_address)
354
+ return;
351
355
  if (vault.latest_reported_tvl !== null &&
352
356
  vault.latest_reported_tvl !== undefined) {
353
357
  total += vault.latest_reported_tvl;
@@ -591,14 +595,26 @@ class AugustVaults extends core_1.AugustBase {
591
595
  });
592
596
  }
593
597
  /**
598
+ * A wallet's redemption requests on one vault, split into
599
+ * `availableRedemptions` and `pendingRedemptions`. EVM, Stellar and Solana
600
+ * vault addresses are accepted; see `AugustSDK.getVaultAvailableRedemptions`
601
+ * for what each list holds on Solana.
594
602
  *
603
+ * @param props - `vault`, the vault address; `chainId`, the EVM chain whose
604
+ * RPC to use (the active network when omitted); `wallet`, the holder,
605
+ * required for Solana, where it is base58; `verbose`, to also return the
606
+ * processed and requested withdrawal lists (always empty for Solana).
607
+ * @returns `{ availableRedemptions, pendingRedemptions }`, plus the verbose lists.
608
+ * @throws Error when unauthorized, or when `vault` is missing or not an address.
595
609
  */
596
610
  async getVaultAvailableRedemptions({ vault, chainId, wallet, verbose, }) {
597
611
  if (!this.authorized)
598
612
  throw new Error('Not authorized.');
599
613
  if (!vault)
600
614
  throw new Error('Vault input parameter is undefined.');
601
- if (!(0, ethers_1.isAddress)(vault) && !(0, utils_2.isStellarAddress)(vault))
615
+ if (!(0, ethers_1.isAddress)(vault) &&
616
+ !(0, utils_2.isStellarAddress)(vault) &&
617
+ !utils_1.SolanaUtils.isSolanaAddress(vault))
602
618
  throw new Error(`Vault input parameter is not an address: ${String(vault)}`);
603
619
  return await (0, getters_1.getVaultAvailableRedemptions)({
604
620
  vault,
@@ -1,5 +1,5 @@
1
1
  import type { Connection } from '@solana/web3.js';
2
- import type { IAddress, IEnv, IStellarNetwork, IWSMonitorHeaders } from '../../types';
2
+ import type { IAddress, IEnv, ISolanaNetwork, IStellarNetwork, IWSMonitorHeaders } from '../../types';
3
3
  /**
4
4
  * Structural interface for the Solana adapter surface used by vault operations.
5
5
  * Avoids importing the concrete SolanaAdapter class to prevent circular dependencies.
@@ -29,6 +29,19 @@ export interface ISolanaService {
29
29
  amount: string;
30
30
  decimals: number | null;
31
31
  }>;
32
+ /**
33
+ * Canonical program id for this service's network, as
34
+ * `SolanaAdapter.getProgramId`. Optional so a hand-built service keeps
35
+ * working: without it the withdrawal-queue reads are skipped, and vaults and
36
+ * positions come back without queue data.
37
+ */
38
+ getProgramId?: (type: 'vault' | 'withdrawalQueue') => string;
39
+ /**
40
+ * This service's network, as `SolanaAdapter.network`. When present, the
41
+ * withdrawal-queue reads look the queue program up in `programIds` directly
42
+ * instead of calling `getProgramId`.
43
+ */
44
+ network?: ISolanaNetwork;
32
45
  }
33
46
  /**
34
47
  * Base configuration for vault operations.
@@ -82,6 +82,14 @@ export declare function formatVaultApy(tokenizedVault: ITokenizedVault): IVault[
82
82
  * the trailing `Z` is preserved.
83
83
  */
84
84
  export declare function mapVaultFreshness(tokenizedVault: ITokenizedVault | undefined | null): IVaultFreshness | null;
85
+ /**
86
+ * Map a wrapper vault's link to the vault it wraps.
87
+ *
88
+ * @param tokenizedVault - Backend tokenized-vault payload.
89
+ * @returns The underlying vault address (casing preserved) and chain id, both
90
+ * null for a non-wrapper vault. A chain id without an address is dropped.
91
+ */
92
+ export declare function mapUnderlyingVault(tokenizedVault: ITokenizedVault | undefined | null): Pick<IVault, 'underlyingVaultAddress' | 'underlyingChainId'>;
85
93
  /**
86
94
  * Map strategists from backend subaccounts or hardcoded list.
87
95
  * Shared across all chain adapters.
@@ -7,6 +7,7 @@ exports.getIdleAssets = getIdleAssets;
7
7
  exports.getYieldLastRealizedOn = getYieldLastRealizedOn;
8
8
  exports.formatVaultApy = formatVaultApy;
9
9
  exports.mapVaultFreshness = mapVaultFreshness;
10
+ exports.mapUnderlyingVault = mapUnderlyingVault;
10
11
  exports.mapStrategists = mapStrategists;
11
12
  exports.mapComposabilityIntegrations = mapComposabilityIntegrations;
12
13
  exports.backendTvlToNormalizedBn = backendTvlToNormalizedBn;
@@ -268,6 +269,22 @@ function mapVaultFreshness(tokenizedVault) {
268
269
  cachedAt: freshness.cached_at ?? null,
269
270
  };
270
271
  }
272
+ /**
273
+ * Map a wrapper vault's link to the vault it wraps.
274
+ *
275
+ * @param tokenizedVault - Backend tokenized-vault payload.
276
+ * @returns The underlying vault address (casing preserved) and chain id, both
277
+ * null for a non-wrapper vault. A chain id without an address is dropped.
278
+ */
279
+ function mapUnderlyingVault(tokenizedVault) {
280
+ const address = tokenizedVault?.underlying_vault_address;
281
+ if (!address)
282
+ return { underlyingVaultAddress: null, underlyingChainId: null };
283
+ return {
284
+ underlyingVaultAddress: address,
285
+ underlyingChainId: tokenizedVault?.underlying_chain ?? null,
286
+ };
287
+ }
271
288
  /**
272
289
  * Map strategists from backend subaccounts or hardcoded list.
273
290
  * Shared across all chain adapters.
@@ -437,6 +454,7 @@ function buildBackendVault(tokenizedVault, overrides) {
437
454
  dailyPnlPerShare: mapDailyPnlPerShare(tokenizedVault.daily_pnl_per_share),
438
455
  enabled_historical_price_horizons: tokenizedVault.enabled_historical_price_horizons || [],
439
456
  latest_reported_tvl: tokenizedVault.latest_reported_tvl,
457
+ ...mapUnderlyingVault(tokenizedVault),
440
458
  defaultApyHorizon: tokenizedVault.default_apy_horizon,
441
459
  ...(tokenizedVault.instant_redeem_config
442
460
  ? {
@@ -659,6 +677,7 @@ async function buildFormattedVault(provider, tokenizedVault, contractCalls) {
659
677
  enabled_historical_price_horizons: tokenizedVault?.enabled_historical_price_horizons,
660
678
  defaultApyHorizon: tokenizedVault?.default_apy_horizon ?? null,
661
679
  latest_reported_tvl: tokenizedVault?.latest_reported_tvl,
680
+ ...mapUnderlyingVault(tokenizedVault),
662
681
  cachedAt: tokenizedVault?.cached_at ?? null,
663
682
  freshness: mapVaultFreshness(tokenizedVault),
664
683
  showCapFilled: tokenizedVault?.show_cap_filled ?? null,