@augustdigital/sdk 8.3.2 → 8.6.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 (213) hide show
  1. package/README.md +207 -117
  2. package/lib/abis/ERC20_Bytes32.d.ts +4 -0
  3. package/lib/abis/ERC20_Bytes32.js +4 -0
  4. package/lib/abis/ERC4626.d.ts +1 -0
  5. package/lib/abis/ERC4626.js +1 -0
  6. package/lib/abis/ERC721.d.ts +1 -0
  7. package/lib/abis/ERC721.js +1 -0
  8. package/lib/abis/FeeOracle.js +1 -0
  9. package/lib/abis/LendingPool.js +1 -0
  10. package/lib/abis/LendingPoolV2.js +1 -0
  11. package/lib/abis/Multicall3.js +3 -0
  12. package/lib/abis/OFT.d.ts +20 -0
  13. package/lib/abis/OFT.js +20 -0
  14. package/lib/abis/SmartAccount.d.ts +1 -0
  15. package/lib/abis/SmartAccount.js +3 -0
  16. package/lib/abis/SwapRouter.d.ts +1 -0
  17. package/lib/abis/SwapRouter.js +1 -0
  18. package/lib/abis/UniversalSignatureValidator.js +3 -0
  19. package/lib/abis/index.d.ts +5 -0
  20. package/lib/abis/index.js +5 -0
  21. package/lib/adapters/evm/getters.d.ts +17 -2
  22. package/lib/adapters/evm/getters.js +35 -3
  23. package/lib/adapters/evm/index.d.ts +266 -4
  24. package/lib/adapters/evm/index.js +270 -1
  25. package/lib/adapters/evm/utils.d.ts +6 -0
  26. package/lib/adapters/evm/utils.js +7 -0
  27. package/lib/adapters/solana/constants.d.ts +1 -1
  28. package/lib/adapters/solana/constants.js +4 -1
  29. package/lib/adapters/solana/getters.d.ts +9 -1
  30. package/lib/adapters/solana/getters.js +21 -0
  31. package/lib/adapters/solana/idl/vault-idl.js +9 -0
  32. package/lib/adapters/solana/index.d.ts +59 -4
  33. package/lib/adapters/solana/index.js +61 -0
  34. package/lib/adapters/solana/types.d.ts +1 -1
  35. package/lib/adapters/solana/utils.d.ts +31 -3
  36. package/lib/adapters/solana/utils.js +79 -4
  37. package/lib/adapters/solana/vault.actions.d.ts +23 -4
  38. package/lib/adapters/solana/vault.actions.js +47 -3
  39. package/lib/adapters/stellar/actions.d.ts +26 -1
  40. package/lib/adapters/stellar/actions.js +33 -0
  41. package/lib/adapters/stellar/constants.d.ts +26 -0
  42. package/lib/adapters/stellar/constants.js +29 -0
  43. package/lib/adapters/stellar/getters.d.ts +56 -0
  44. package/lib/adapters/stellar/getters.js +81 -0
  45. package/lib/adapters/stellar/index.d.ts +70 -0
  46. package/lib/adapters/stellar/index.js +71 -0
  47. package/lib/adapters/stellar/soroban.d.ts +21 -1
  48. package/lib/adapters/stellar/soroban.js +47 -1
  49. package/lib/adapters/stellar/submit.d.ts +29 -0
  50. package/lib/adapters/stellar/submit.js +90 -5
  51. package/lib/adapters/stellar/types.d.ts +27 -0
  52. package/lib/adapters/stellar/types.js +3 -0
  53. package/lib/adapters/stellar/utils.d.ts +10 -0
  54. package/lib/adapters/stellar/utils.js +10 -0
  55. package/lib/adapters/sui/getters.d.ts +7 -1
  56. package/lib/adapters/sui/getters.js +6 -0
  57. package/lib/adapters/sui/index.d.ts +16 -1
  58. package/lib/adapters/sui/index.js +17 -0
  59. package/lib/adapters/sui/transformer.d.ts +8 -2
  60. package/lib/adapters/sui/transformer.js +7 -0
  61. package/lib/adapters/sui/types.d.ts +1 -1
  62. package/lib/adapters/sui/utils.d.ts +6 -0
  63. package/lib/adapters/sui/utils.js +6 -0
  64. package/lib/core/analytics/chain-name.d.ts +8 -0
  65. package/lib/core/analytics/chain-name.js +8 -0
  66. package/lib/core/analytics/constants.d.ts +4 -0
  67. package/lib/core/analytics/constants.js +4 -0
  68. package/lib/core/analytics/env.d.ts +25 -0
  69. package/lib/core/analytics/env.js +26 -0
  70. package/lib/core/analytics/index.d.ts +26 -0
  71. package/lib/core/analytics/index.js +35 -0
  72. package/lib/core/analytics/instrumentation.d.ts +26 -0
  73. package/lib/core/analytics/instrumentation.js +66 -2
  74. package/lib/core/analytics/method-taxonomy.d.ts +16 -0
  75. package/lib/core/analytics/method-taxonomy.js +18 -0
  76. package/lib/core/analytics/metrics.d.ts +23 -0
  77. package/lib/core/analytics/metrics.js +40 -0
  78. package/lib/core/analytics/sanitize.d.ts +38 -0
  79. package/lib/core/analytics/sanitize.js +46 -0
  80. package/lib/core/analytics/sentry-runtime.d.ts +11 -0
  81. package/lib/core/analytics/sentry-runtime.js +20 -1
  82. package/lib/core/analytics/sentry.d.ts +47 -2
  83. package/lib/core/analytics/sentry.js +115 -2
  84. package/lib/core/analytics/types.d.ts +28 -1
  85. package/lib/core/analytics/user-identity.d.ts +36 -2
  86. package/lib/core/analytics/user-identity.js +43 -1
  87. package/lib/core/analytics/version.d.ts +6 -1
  88. package/lib/core/analytics/version.js +6 -1
  89. package/lib/core/auth/verify.js +5 -0
  90. package/lib/core/base.class.d.ts +78 -3
  91. package/lib/core/base.class.js +66 -4
  92. package/lib/core/cache.d.ts +5 -0
  93. package/lib/core/cache.js +6 -0
  94. package/lib/core/constants/adapters.d.ts +16 -1
  95. package/lib/core/constants/adapters.js +28 -8
  96. package/lib/core/constants/core.d.ts +14 -1
  97. package/lib/core/constants/core.js +18 -0
  98. package/lib/core/constants/swap-router.d.ts +83 -1
  99. package/lib/core/constants/swap-router.js +91 -1
  100. package/lib/core/constants/vaults.d.ts +57 -1
  101. package/lib/core/constants/vaults.js +66 -1
  102. package/lib/core/constants/web3.d.ts +4 -1
  103. package/lib/core/constants/web3.js +15 -5
  104. package/lib/core/errors/index.d.ts +38 -2
  105. package/lib/core/errors/index.js +38 -0
  106. package/lib/core/fetcher.d.ts +136 -2
  107. package/lib/core/fetcher.js +229 -25
  108. package/lib/core/helpers/adapters.d.ts +10 -1
  109. package/lib/core/helpers/adapters.js +11 -0
  110. package/lib/core/helpers/chain-address.d.ts +10 -0
  111. package/lib/core/helpers/chain-address.js +11 -0
  112. package/lib/core/helpers/core.d.ts +49 -4
  113. package/lib/core/helpers/core.js +74 -7
  114. package/lib/core/helpers/explorer-link.d.ts +15 -1
  115. package/lib/core/helpers/explorer-link.js +14 -0
  116. package/lib/core/helpers/signer.d.ts +27 -1
  117. package/lib/core/helpers/signer.js +39 -0
  118. package/lib/core/helpers/swap-router.d.ts +33 -1
  119. package/lib/core/helpers/swap-router.js +32 -0
  120. package/lib/core/helpers/vault-version.d.ts +2 -1
  121. package/lib/core/helpers/vault-version.js +2 -0
  122. package/lib/core/helpers/vaults.d.ts +9 -1
  123. package/lib/core/helpers/vaults.js +22 -8
  124. package/lib/core/helpers/web3.d.ts +154 -2
  125. package/lib/core/helpers/web3.js +192 -15
  126. package/lib/core/logger/index.d.ts +55 -0
  127. package/lib/core/logger/index.js +19 -0
  128. package/lib/core/logger/slack.d.ts +3 -0
  129. package/lib/core/logger/slack.js +3 -0
  130. package/lib/core/vault-metadata.d.ts +7 -1
  131. package/lib/core/vault-metadata.js +6 -0
  132. package/lib/core/version-check.d.ts +52 -0
  133. package/lib/core/version-check.js +82 -1
  134. package/lib/evm/methods/crossChainVault.d.ts +90 -0
  135. package/lib/evm/methods/crossChainVault.js +187 -2
  136. package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
  137. package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
  138. package/lib/evm/methods/index.d.ts +1 -0
  139. package/lib/evm/methods/index.js +1 -0
  140. package/lib/evm/types/crossChain.d.ts +202 -0
  141. package/lib/evm/types/crossChain.js +12 -1
  142. package/lib/index.d.ts +16 -0
  143. package/lib/index.js +19 -0
  144. package/lib/main.d.ts +289 -6
  145. package/lib/main.js +312 -0
  146. package/lib/modules/api/index.d.ts +1 -0
  147. package/lib/modules/api/index.js +6 -0
  148. package/lib/modules/api/main.d.ts +52 -0
  149. package/lib/modules/api/main.js +130 -0
  150. package/lib/modules/sub-accounts/fetcher.d.ts +17 -2
  151. package/lib/modules/sub-accounts/fetcher.js +15 -0
  152. package/lib/modules/sub-accounts/main.d.ts +35 -2
  153. package/lib/modules/sub-accounts/main.js +39 -1
  154. package/lib/modules/sub-accounts/utils.d.ts +4 -1
  155. package/lib/modules/sub-accounts/utils.js +3 -0
  156. package/lib/modules/vaults/adapter.helpers.d.ts +21 -3
  157. package/lib/modules/vaults/adapter.helpers.js +34 -0
  158. package/lib/modules/vaults/fetcher.d.ts +45 -0
  159. package/lib/modules/vaults/fetcher.js +91 -4
  160. package/lib/modules/vaults/getters.d.ts +295 -0
  161. package/lib/modules/vaults/getters.js +567 -26
  162. package/lib/modules/vaults/index.d.ts +12 -0
  163. package/lib/modules/vaults/index.js +12 -0
  164. package/lib/modules/vaults/main.d.ts +292 -4
  165. package/lib/modules/vaults/main.js +382 -8
  166. package/lib/modules/vaults/read.actions.d.ts +170 -2
  167. package/lib/modules/vaults/read.actions.js +143 -0
  168. package/lib/modules/vaults/types.d.ts +34 -0
  169. package/lib/modules/vaults/utils/call-data-decoder.d.ts +48 -1
  170. package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
  171. package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
  172. package/lib/modules/vaults/utils/date-utils.js +47 -1
  173. package/lib/modules/vaults/utils.d.ts +85 -0
  174. package/lib/modules/vaults/utils.js +139 -7
  175. package/lib/modules/vaults/write.actions.d.ts +363 -3
  176. package/lib/modules/vaults/write.actions.js +399 -3
  177. package/lib/polyfills.js +4 -2
  178. package/lib/sdk.d.ts +23847 -0
  179. package/lib/services/coingecko/fetcher.d.ts +15 -1
  180. package/lib/services/coingecko/fetcher.js +30 -9
  181. package/lib/services/debank/fetcher.d.ts +15 -1
  182. package/lib/services/debank/fetcher.js +12 -0
  183. package/lib/services/debank/utils.d.ts +1 -1
  184. package/lib/services/debank/utils.js +18 -1
  185. package/lib/services/layerzero/deposits.d.ts +12 -1
  186. package/lib/services/layerzero/deposits.js +34 -11
  187. package/lib/services/layerzero/redeems.d.ts +11 -1
  188. package/lib/services/layerzero/redeems.js +13 -0
  189. package/lib/services/layerzero/utils.d.ts +8 -0
  190. package/lib/services/layerzero/utils.js +11 -0
  191. package/lib/services/octavfi/fetcher.d.ts +8 -1
  192. package/lib/services/octavfi/fetcher.js +25 -0
  193. package/lib/services/octavfi/types.d.ts +1 -1
  194. package/lib/services/octavfi/utils.d.ts +14 -2
  195. package/lib/services/octavfi/utils.js +44 -10
  196. package/lib/services/subgraph/fetcher.js +4 -2
  197. package/lib/services/subgraph/vaults.d.ts +12 -0
  198. package/lib/services/subgraph/vaults.js +119 -2
  199. package/lib/services/swap-quotes/index.d.ts +80 -0
  200. package/lib/services/swap-quotes/index.js +27 -1
  201. package/lib/services/swap-quotes/paraswap.d.ts +25 -0
  202. package/lib/services/swap-quotes/paraswap.js +22 -0
  203. package/lib/types/pools.d.ts +5 -2
  204. package/lib/types/staking.d.ts +1 -1
  205. package/lib/types/sub-accounts.d.ts +1 -1
  206. package/lib/types/subgraph.d.ts +10 -1
  207. package/lib/types/typed-contract.d.ts +64 -0
  208. package/lib/types/vaults.d.ts +163 -2
  209. package/lib/types/vaults.js +10 -0
  210. package/lib/types/web3.d.ts +9 -1
  211. package/lib/types/web3.js +1 -0
  212. package/lib/types/webserver.d.ts +47 -2
  213. package/package.json +6 -5
@@ -7,9 +7,24 @@ export interface IParaswapQuoteInput {
7
7
  destDecimals: number;
8
8
  amount: bigint;
9
9
  receiver: IAddress;
10
+ /**
11
+ * Slippage tolerance in bps (1 bp = 0.01%). Used to derive the
12
+ * `destAmount` minimum baked into the resulting Paraswap calldata, so the
13
+ * on-chain DEX leg enforces the same tolerance the SwapRouter does
14
+ * (otherwise the leg reverts at the aggregator's exact-out check before
15
+ * the SwapRouter's `minAmountOut` is ever evaluated).
16
+ */
10
17
  slippageBps: number;
11
18
  partner: string;
12
19
  partnerAddress: IAddress;
20
+ /**
21
+ * Optional `includeContractMethods` value passed to Paraswap's `/prices`. When
22
+ * set, Paraswap is restricted to this single contract method so the resulting
23
+ * calldata's leading selector is deterministic and matches the one the
24
+ * SwapRouter authorizes for this router. When omitted, Paraswap is free to
25
+ * pick whichever method is optimal for the route.
26
+ */
27
+ contractMethod?: string;
13
28
  fetchImpl: typeof fetch;
14
29
  signal?: AbortSignal;
15
30
  }
@@ -19,6 +34,16 @@ export interface IParaswapQuoteOutput {
19
34
  expectedAmountOut: bigint;
20
35
  fetchedAt: number;
21
36
  }
37
+ /**
38
+ * Fetch a Paraswap quote and the calldata to execute it on behalf of the
39
+ * SwapRouter. Throws `AugustNetworkError` on fetch-layer failure and
40
+ * `AugustServerError` on Paraswap-side error responses or malformed bodies.
41
+ *
42
+ * `fetchedAt` is the wall-clock timestamp captured *after* the calldata
43
+ * response — callers downstream can use it to decide whether the leg is
44
+ * fresh enough to broadcast (DEX pool state moves; stale calldata may
45
+ * silently revert at the on-chain slippage check).
46
+ */
22
47
  export declare function fetchParaswapQuote(input: IParaswapQuoteInput): Promise<IParaswapQuoteOutput>;
23
48
  export declare const PARASWAP_DEFAULTS: {
24
49
  readonly partner: "august";
@@ -10,6 +10,16 @@ const DEFAULT_PARTNER = 'august';
10
10
  const DEFAULT_PARTNER_ADDRESS = '0xb60ee0FA5B6bA917255A03e744967E0Bda531dD0';
11
11
  const PARASWAP_VERSION = '6.2';
12
12
  const BPS_DENOMINATOR = 10000n;
13
+ /**
14
+ * Fetch a Paraswap quote and the calldata to execute it on behalf of the
15
+ * SwapRouter. Throws `AugustNetworkError` on fetch-layer failure and
16
+ * `AugustServerError` on Paraswap-side error responses or malformed bodies.
17
+ *
18
+ * `fetchedAt` is the wall-clock timestamp captured *after* the calldata
19
+ * response — callers downstream can use it to decide whether the leg is
20
+ * fresh enough to broadcast (DEX pool state moves; stale calldata may
21
+ * silently revert at the on-chain slippage check).
22
+ */
13
23
  async function fetchParaswapQuote(input) {
14
24
  const priceRoute = await getPriceRoute(input);
15
25
  const destAmountRaw = priceRoute.destAmount;
@@ -32,6 +42,14 @@ async function getPriceRoute(input) {
32
42
  partnerAddress: input.partnerAddress,
33
43
  version: PARASWAP_VERSION,
34
44
  });
45
+ // Restrict the route to a single contract method when the caller pins one,
46
+ // so the calldata's selector is deterministic and matches the SwapRouter's
47
+ // per-router authorized selector. Without this the aggregator may return a
48
+ // route-optimized method (e.g. swapExactAmountInOnUniswapV3) whose selector
49
+ // the SwapRouter has not whitelisted, reverting with InvalidNotWhitelisted().
50
+ if (input.contractMethod) {
51
+ params.append('includeContractMethods', input.contractMethod);
52
+ }
35
53
  const url = `${PARASWAP_PRICES_URL}?${params.toString()}`;
36
54
  let response;
37
55
  try {
@@ -58,6 +76,10 @@ async function getPriceRoute(input) {
58
76
  }
59
77
  async function getTransactionData(input, priceRoute) {
60
78
  const url = `${PARASWAP_TRANSACTIONS_BASE_URL}/${input.chainId}/?ignoreChecks=true&ignoreGasEstimate=true&onlyParams=false`;
79
+ // Bake slippage into the destAmount Paraswap embeds as the aggregator's
80
+ // own min-out, so the DEX leg enforces the same lower bound the
81
+ // SwapRouter will check. Without this the aggregator uses the exact
82
+ // priceRoute quote (0% tolerance) and reverts on any adverse movement.
61
83
  const expectedDestAmount = BigInt(priceRoute.destAmount);
62
84
  const minDestAmount = (expectedDestAmount * (BPS_DENOMINATOR - BigInt(input.slippageBps))) /
63
85
  BPS_DENOMINATOR;
@@ -1,5 +1,8 @@
1
- import { IAddress, INormalizedNumber } from './web3';
2
- import { IDebankProtocolExposure, IDebankTokenExposure, ITokenizedVaultStrategist, IWSSubaccountCefi } from './webserver';
1
+ /**
2
+ * @deprecated
3
+ */
4
+ import type { IAddress, INormalizedNumber } from './web3';
5
+ import type { IDebankProtocolExposure, IDebankTokenExposure, ITokenizedVaultStrategist, IWSSubaccountCefi } from './webserver';
3
6
  type ILabelValue = {
4
7
  label: string;
5
8
  value: string;
@@ -1,4 +1,4 @@
1
- import { IAddress, INormalizedNumber } from './web3';
1
+ import type { IAddress, INormalizedNumber } from './web3';
2
2
  export type IActiveStakingPosition = {
3
3
  stakingToken: {
4
4
  decimals: number;
@@ -1,4 +1,4 @@
1
- import { IAddress } from './web3';
1
+ import type { IAddress } from './web3';
2
2
  export interface IWSSubAccountHealthFactor {
3
3
  id: IAddress;
4
4
  datetime: string;
@@ -1,4 +1,4 @@
1
- import { IAddress } from './web3';
1
+ import type { IAddress } from './web3';
2
2
  export interface ISubgraphBase {
3
3
  id: string;
4
4
  contractId_: IAddress;
@@ -12,6 +12,15 @@ export interface ISubgraphUserHistoryItem extends ISubgraphBase {
12
12
  type: 'withdraw-request' | 'deposit' | 'withdraw-processed';
13
13
  decimals?: number;
14
14
  isInstant?: boolean;
15
+ /**
16
+ * Deposit asset token address, when known. Pre-deposit vaults accept
17
+ * multiple deposit assets with differing decimals (e.g. USDS at 18,
18
+ * USDC at 6), so `amount` cannot be normalized with the vault's own
19
+ * decimals alone — consumers (notably lifetime PnL) key off this address
20
+ * to resolve the correct per-asset decimals and USD price. Absent for
21
+ * single-asset vaults, where the vault `decimals` is correct.
22
+ */
23
+ assetIn?: IAddress;
15
24
  }
16
25
  export interface ISubgraphWithdrawProccessed extends ISubgraphBase {
17
26
  processedOn: string;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * TypedContract type definitions for ethers v6 with abitype.
3
+ *
4
+ * This is a local copy of types from ethers-abitype to avoid the global
5
+ * abitype module augmentation that pollutes AddressType with `string | Addressable`,
6
+ * which breaks viem type compatibility.
7
+ *
8
+ * @see https://github.com/ethers-io/ethers.js/issues/4475
9
+ */
1
10
  import type { BaseContract, ContractTransaction, ContractTransactionResponse, DeferredTopicFilter, EventFragment, FunctionFragment, Result, Overrides } from 'ethers';
2
11
  import type { Abi, AbiParametersToPrimitiveTypes, ExtractAbiEvent, ExtractAbiEventNames, ExtractAbiEvents, ExtractAbiFunction, ExtractAbiFunctionNames, ExtractAbiFunctions } from 'abitype';
3
12
  type AsArray<T> = T extends readonly unknown[] ? T : never;
@@ -11,26 +20,81 @@ export type TypedFragment<TAbi extends Abi, TFunctionName extends string, TFunct
11
20
  };
12
21
  export interface TypedContractFunction<TAbi extends Abi, TFunctionName extends string, TFunction extends ExtractAbiFunctions<TAbi> = ExtractAbiFunction<TAbi, TFunctionName>, TInputArgs extends readonly unknown[] = AsArray<AbiParametersToPrimitiveTypes<TFunction['inputs']>>, TResult = TypedContractFunctionResult<TAbi, TFunctionName>, TFragment = TypedFragment<TAbi, TFunctionName>> {
13
22
  (...args: [...TInputArgs, overrides?: Overrides]): Promise<TFunction['stateMutability'] extends 'view' | 'pure' ? TResult : ContractTransactionResponse>;
23
+ /**
24
+ * The name of the Contract method.
25
+ */
14
26
  name: TFunctionName;
27
+ /**
28
+ * The fragment of the Contract method. This will throw on ambiguous
29
+ * method names.
30
+ */
15
31
  fragment: TFragment;
32
+ /**
33
+ * Returns the fragment constrained by %%args%%. This can be used to
34
+ * resolve ambiguous method names.
35
+ */
16
36
  getFragment(...args: [...TInputArgs]): TFragment;
37
+ /**
38
+ * Returns a populated transaction that can be used to perform the
39
+ * contract method with %%args%%.
40
+ */
17
41
  populateTransaction(...args: [...TInputArgs, overrides?: Overrides]): Promise<ContractTransaction>;
42
+ /**
43
+ * Call the contract method with %%args%% and return the value.
44
+ *
45
+ * If the return value is a single type, it will be dereferenced and
46
+ * returned directly, otherwise the full Result will be returned.
47
+ */
18
48
  staticCall(...args: [...TInputArgs, overrides?: Overrides]): Promise<TResult>;
49
+ /**
50
+ * Send a transaction for the contract method with %%args%%.
51
+ */
19
52
  send(...args: [...TInputArgs, overrides?: Overrides]): Promise<ContractTransactionResponse>;
53
+ /**
54
+ * Estimate the gas to send the contract method with %%args%%.
55
+ */
20
56
  estimateGas(...args: [...TInputArgs, overrides?: Overrides]): Promise<bigint>;
57
+ /**
58
+ * Call the contract method with %%args%% and return the Result
59
+ * without any dereferencing.
60
+ */
21
61
  staticCallResult(...args: [...TInputArgs, overrides?: Overrides]): Promise<Result>;
22
62
  }
23
63
  export interface TypedContractEvent<TAbi extends Abi, TEventName extends string, TEvent extends ExtractAbiEvents<TAbi> = ExtractAbiEvent<TAbi, TEventName>, TEventArgs extends readonly unknown[] = AsArray<Partial<AbiParametersToPrimitiveTypes<TEvent['inputs']>>>> {
24
64
  (...args: [...TEventArgs]): DeferredTopicFilter;
65
+ /**
66
+ * The name of the Contract event.
67
+ */
25
68
  name: TEventName;
69
+ /**
70
+ * The fragment of the Contract event. This will throw on ambiguous
71
+ * method names.
72
+ */
26
73
  fragment: EventFragment;
74
+ /**
75
+ * Returns the fragment constrained by %%args%%. This can be used to
76
+ * resolve ambiguous event names.
77
+ */
27
78
  getFragment(...args: [...TEventArgs]): EventFragment;
28
79
  }
29
80
  export type TypedContract<TAbi extends Abi> = Omit<BaseContract, 'getFunction' | 'getEvent'> & {
30
81
  [Method in ExtractAbiFunctionNames<TAbi>]: TypedContractFunction<TAbi, Method>;
31
82
  } & {
83
+ /**
84
+ * Return the function for a given name. This is useful when a contract
85
+ * method name conflicts with a JavaScript name such as ``prototype`` or
86
+ * when using a Contract programatically.
87
+ */
32
88
  getFunction<T extends ExtractAbiFunctionNames<TAbi>>(key: T | TypedFragment<TAbi, T>): TypedContractFunction<TAbi, T>;
89
+ /**
90
+ * Return the event for a given name. This is useful when a contract
91
+ * event name conflicts with a JavaScript name such as ``prototype`` or
92
+ * when using a Contract programatically.
93
+ */
33
94
  getEvent<T extends ExtractAbiEventNames<TAbi>>(key: T | EventFragment): TypedContractEvent<TAbi, T>;
95
+ /**
96
+ * All the Events available on this contract.
97
+ */
34
98
  filters: {
35
99
  [EventName in ExtractAbiEventNames<TAbi>]: TypedContractEvent<TAbi, EventName>;
36
100
  };
@@ -1,5 +1,5 @@
1
- import { IAddress, INormalizedNumber, VaultAddress } from './web3';
2
- import { IDebankProtocolExposure, IDebankTokenExposure, IOTCPosition, IWSSubaccountCefi, IWSSubaccountLoan, IWSTokenEntry, ITokenizedVaultOperator, ITokenizedVaultEoaOperator, IHIstoricalSnapshot, IApyOverride } from './webserver';
1
+ import type { IAddress, INormalizedNumber, VaultAddress } from './web3';
2
+ import type { IDebankProtocolExposure, IDebankTokenExposure, IOTCPosition, IWSSubaccountCefi, IWSSubaccountLoan, IWSTokenEntry, ITokenizedVaultOperator, ITokenizedVaultEoaOperator, IHIstoricalSnapshot, IApyOverride } from './webserver';
3
3
  import type { InterfaceAbi } from 'ethers';
4
4
  export interface IVaultLoan {
5
5
  vault: VaultAddress;
@@ -22,6 +22,13 @@ export interface IVaultLoan {
22
22
  isIdleCapital: boolean;
23
23
  allocation: number;
24
24
  }
25
+ /**
26
+ * One row of borrower-health-factor data for a vault. `health_factor` is
27
+ * absent when the upstream August backend has no record for `borrower`
28
+ * (e.g. test loans whose borrower is not a registered subaccount), or when
29
+ * the per-borrower fetch failed — callers must handle the undefined case
30
+ * rather than assume a numeric value is present.
31
+ */
25
32
  export interface IVaultBorrowerHealthFactor {
26
33
  borrower: IAddress;
27
34
  loan: IAddress;
@@ -42,6 +49,26 @@ export type IVaultUserHistoryItem = {
42
49
  type: 'withdraw-request' | 'deposit' | 'withdraw-processed' | 'redeem';
43
50
  transactionHash: IAddress;
44
51
  };
52
+ /**
53
+ * A single reward paired with its backend-provided logo.
54
+ *
55
+ * `id` is the reward's stable backend identifier ({@link ITokenizedVaultReward.id})
56
+ * and is the key consumers should join on — it is unique even when two rewards
57
+ * share a multiplier and text. `label` is display-only: it mirrors the
58
+ * corresponding {@link IVaultRewards.additionalPoints} string (and so carries a
59
+ * leading space when `multiplier === 1`, e.g. `" Cores"`), so it is fine to
60
+ * print but must not be treated as a unique key.
61
+ *
62
+ * `imgUrl` is `null` when the backend has no logo for the reward, in which
63
+ * case consumers fall back to a bundled asset.
64
+ */
65
+ export type IVaultRewardDetail = {
66
+ id: string;
67
+ label: string;
68
+ text: string;
69
+ imgUrl: string | null;
70
+ multiplier: number;
71
+ };
45
72
  export type IVaultRewards = {
46
73
  points: string;
47
74
  multiplier: number;
@@ -50,6 +77,12 @@ export type IVaultRewards = {
50
77
  timestamp: number;
51
78
  }[];
52
79
  additionalPoints: string[];
80
+ /**
81
+ * Optional so this addition is non-breaking for external code that
82
+ * constructs an {@link IVaultRewards}. `getVaultRewards` always populates it;
83
+ * readers should treat an absent value as an empty list.
84
+ */
85
+ additionalPointsDetailed?: IVaultRewardDetail[];
53
86
  };
54
87
  export type IVaultExposureItem = {
55
88
  amount: number;
@@ -72,6 +105,22 @@ export type IExposurePerCategory = {
72
105
  walletBalance: number;
73
106
  loanBalance: number;
74
107
  };
108
+ /**
109
+ * @todo clean up to minimize data transfer
110
+ * ```typescript
111
+ * {
112
+ * defi: IOctavfiPortfolio[]
113
+ * cefi: IWSSubaccountCefi[]
114
+ * otc: Record<string, IOTCPosition>
115
+ * breakdown: { // this will be total net values
116
+ * defi: number;
117
+ * cefi: number;
118
+ * otc: number;
119
+ * total: number;
120
+ * }
121
+ * }
122
+ * ```
123
+ */
75
124
  export interface IVaultAllocations {
76
125
  defi: IDebankProtocolExposure[];
77
126
  tokens: IDebankTokenExposure[];
@@ -104,6 +153,9 @@ export interface IVaultStrategist {
104
153
  }
105
154
  export type IVaultVersion = 'evm-0' | 'evm-1' | 'evm-2' | 'sol-0' | 'sui-0' | 'stellar-0';
106
155
  export type { ChainType } from './web3';
156
+ /**
157
+ * Adapter configuration for vaults that support deposits with alternative tokens
158
+ */
107
159
  export interface IVaultAdapterConfig {
108
160
  lpTokenAddress?: IAddress;
109
161
  isNativeTokenDeposit: boolean;
@@ -119,9 +171,14 @@ export interface IVaultAdapterConfig {
119
171
  export interface IVault {
120
172
  max_drawdown?: number | null;
121
173
  historical_apy?: Record<number, number> | null;
174
+ /** @deprecated Use getVaultHistoricalTimeseries instead */
122
175
  historical_snapshots?: IHIstoricalSnapshot[];
123
176
  depositCap?: INormalizedNumber;
124
177
  maxDepositAmount?: INormalizedNumber;
178
+ /**
179
+ * Vault contract address. May be an EVM hex address, Solana base58 address,
180
+ * or Stellar base32 address depending on the vault's chain.
181
+ */
125
182
  address: VaultAddress;
126
183
  chainId: number;
127
184
  name: string;
@@ -195,8 +252,10 @@ export interface IVault {
195
252
  latest_reported_tvl?: number | null;
196
253
  cachedAt?: string | null;
197
254
  showCapFilled?: boolean | null;
255
+ /** Controls how the vault's APY is displayed; null when the backend has not set an override. */
198
256
  apyOverride?: IApyOverride | null;
199
257
  programId?: string;
258
+ /** Instant redemption config, populated from backend instant_redeem_config */
200
259
  instant_redeem_config?: {
201
260
  subaccountAddress: IAddress;
202
261
  outputAssetSymbol: string;
@@ -265,15 +324,29 @@ export interface IVaultPnl {
265
324
  totalPnl: INormalizedNumber;
266
325
  pnlUsd: number;
267
326
  }
327
+ /**
328
+ * Response for GET /tokenized_vault/annualized_apy/{vault_address}
329
+ *
330
+ * Supported Vaults: cUSDO, tETH, wstETH, rsETH
331
+ *
332
+ * @deprecated The `hgETH30dLiquidAPY` and `hgETH7dLiquidAPY` fields are deprecated.
333
+ * These fields will be removed on 2026-01-01.
334
+ * Use `liquidAPY30Day` and `liquidAPY7Day` fields instead.
335
+ */
268
336
  export interface IVaultAnnualizedApy {
269
337
  vaultAddress: IAddress;
270
338
  liquidityApy: number;
271
339
  annualizedApy: number;
340
+ /** @deprecated Use `liquidAPY7Day` instead. Will be removed on 2026-01-01. */
272
341
  hgETH7dLiquidAPY?: number;
342
+ /** @deprecated Use `liquidAPY30Day` instead. Will be removed on 2026-01-01. */
273
343
  hgETH30dLiquidAPY?: number;
274
344
  liquidAPY7Day?: number;
275
345
  liquidAPY30Day?: number;
276
346
  }
347
+ /**
348
+ * Response for GET /tokenized_vault/vault_summary/{vault_address}
349
+ */
277
350
  export interface IVaultSummary {
278
351
  vaultAddress: IAddress;
279
352
  name: string;
@@ -285,6 +358,9 @@ export interface IVaultSummary {
285
358
  month: number;
286
359
  };
287
360
  }
361
+ /**
362
+ * Response for GET /withdrawals/{chain}/{vault_address}
363
+ */
288
364
  export interface IVaultWithdrawals {
289
365
  vaultAddress: IAddress;
290
366
  chain: string;
@@ -297,6 +373,9 @@ export interface IVaultWithdrawals {
297
373
  receiver: IAddress;
298
374
  }>;
299
375
  }
376
+ /**
377
+ * Response for GET /vaults/\{vault_addr\}/pending-redemptions
378
+ */
300
379
  export interface IVaultPendingRedemptions {
301
380
  vault: {
302
381
  address: string;
@@ -328,38 +407,120 @@ export interface IVaultPendingRedemptions {
328
407
  isOverdue: boolean;
329
408
  }>;
330
409
  }
410
+ /**
411
+ * One unrealized-PnL snapshot for a vault, computed by the August backend
412
+ * from periodic vault state. `timestamp` is an ISO-8601 datetime; monetary
413
+ * fields are denominated in the vault's reference asset
414
+ * (`referenceAsset`) except `assetPrice`, which is the asset's USD price.
415
+ */
416
+ export type IUnrealizedPnlSnapshot = {
417
+ timestamp: string;
418
+ vaultName: string;
419
+ vaultAddress: string;
420
+ strategistName: string | null;
421
+ referenceAsset: string;
422
+ assetPrice: number;
423
+ tvlOnVault: number;
424
+ currentRedeemRatio: number;
425
+ actualTvl: number;
426
+ adjustedRedeemRatio: number;
427
+ unrealizedPnl: number;
428
+ unrealizedPnlInAsset: number;
429
+ };
430
+ /**
431
+ * Vault metadata item from upshift API
432
+ */
331
433
  export interface IVaultMetadataItem {
332
434
  symbol: string;
333
435
  subgraph: string;
334
436
  address: string;
335
437
  }
438
+ /**
439
+ * Response type for getVaultMetadata
440
+ * Keys are lowercase of the symbol value
441
+ */
336
442
  export type IVaultMetadata = Record<string, IVaultMetadataItem>;
443
+ /**
444
+ * Numeric vault-type tag used by the on-chain `SwapRouter` to branch between
445
+ * the ERC-4626 (`deposit(uint256, address)`) and multi-asset
446
+ * (`deposit(address, uint256, address)`) deposit interfaces.
447
+ *
448
+ * Values match the contract's `VAULT_TYPE_ERC4626` / `VAULT_TYPE_TOKENIZED_VAULT_V2`
449
+ * constants exactly. Set by an admin per-vault via `enableVault` and looked
450
+ * up via `vaultInfo(vaultAddr).vaultType`. SDK callers normally do not pass
451
+ * this — the router resolves it internally.
452
+ */
337
453
  export declare enum SwapRouterVaultType {
338
454
  ERC4626 = 1,
339
455
  TokenizedVaultV2 = 2
340
456
  }
457
+ /**
458
+ * One swap leg passed to `SwapRouter.swapAndDeposit`.
459
+ *
460
+ * The router pulls `amountIn` of `tokenIn` from the caller, approves the
461
+ * configured `tokenTransferProxies[router]` address, and calls `router` with
462
+ * `payload`. Output is measured by balance-diff and must clear `minAmountOut`
463
+ * or the call reverts with `SlippageError`.
464
+ *
465
+ * For a single-hop swap, `tokenOut` is typically the vault's reference asset.
466
+ * For multi-hop, intermediate legs use any whitelisted token.
467
+ */
341
468
  export interface ISwapParams {
469
+ /** ERC-20 address pulled from the caller. Must be whitelisted via `whitelistedTokens`. */
342
470
  tokenIn: IAddress;
471
+ /** ERC-20 address the router is expected to produce. */
343
472
  tokenOut: IAddress;
473
+ /** Input amount in `tokenIn`'s smallest unit (no decimals). */
344
474
  amountIn: bigint;
475
+ /** Minimum acceptable `tokenOut` output. Below this the call reverts. */
345
476
  minAmountOut: bigint;
477
+ /** Whitelisted DEX router target (enabled via `enableRouter`). */
346
478
  router: IAddress;
479
+ /** ABI-encoded calldata to invoke on `router`. */
347
480
  payload: `0x${string}`;
348
481
  }
482
+ /**
483
+ * Common options shared by every public SwapRouter SDK method.
484
+ */
349
485
  export interface ISwapRouterBaseOptions {
486
+ /** EVM chain ID — must have an entry in `SWAP_ROUTER_ADDRESSES`. */
350
487
  chainId: number;
488
+ /** August vault address. Must be registered via `enableVault` on the router. */
351
489
  vault: IAddress;
490
+ /** Address that receives the minted vault shares. */
352
491
  receiver: IAddress;
492
+ /**
493
+ * 32-byte origin/referral code registered via `addOrigin`. Drives the
494
+ * origin-fee accrual. Defaults to {@link ORIGIN_CODES.default} when omitted.
495
+ */
353
496
  originCode?: `0x${string}`;
497
+ /** When `true`, the helper awaits a single confirmation before returning. */
354
498
  wait?: boolean;
355
499
  }
500
+ /**
501
+ * Options for `swapAndDeposit` — ERC-20 in, vault reference asset out.
502
+ */
356
503
  export interface ISwapAndDepositOptions extends ISwapRouterBaseOptions {
504
+ /** One or more swap legs. Capped by the contract's `MAX_SWAPS`. */
357
505
  swaps: ISwapParams[];
358
506
  }
507
+ /**
508
+ * Options for `depositViaSwapRouter` — direct deposit (no swap) of an
509
+ * already-held asset, routed through the SwapRouter so origin/swap-fee
510
+ * accounting still applies.
511
+ */
359
512
  export interface ISwapRouterDirectDepositOptions extends ISwapRouterBaseOptions {
513
+ /** Deposited ERC-20 asset. For ERC-4626 vaults this must equal the reference asset. */
360
514
  asset: IAddress;
515
+ /** Amount in `asset`'s smallest unit. */
361
516
  amount: bigint;
362
517
  }
518
+ /**
519
+ * Options for `depositNativeViaSwapRouter` — wraps `msg.value` to the
520
+ * chain's wrapped-native token and deposits. Only valid when the vault's
521
+ * reference asset equals `wrappedNativeTokenAddress`.
522
+ */
363
523
  export interface ISwapRouterNativeDepositOptions extends ISwapRouterBaseOptions {
524
+ /** Native token amount in wei. Sent as `msg.value`. */
364
525
  amount: bigint;
365
526
  }
@@ -6,6 +6,16 @@ var VaultRedemptionStatus;
6
6
  VaultRedemptionStatus["AWAITING_COOLDOWN"] = "awaiting_cooldown";
7
7
  VaultRedemptionStatus["READY_TO_CLAIM"] = "ready_to_claim";
8
8
  })(VaultRedemptionStatus || (exports.VaultRedemptionStatus = VaultRedemptionStatus = {}));
9
+ /**
10
+ * Numeric vault-type tag used by the on-chain `SwapRouter` to branch between
11
+ * the ERC-4626 (`deposit(uint256, address)`) and multi-asset
12
+ * (`deposit(address, uint256, address)`) deposit interfaces.
13
+ *
14
+ * Values match the contract's `VAULT_TYPE_ERC4626` / `VAULT_TYPE_TOKENIZED_VAULT_V2`
15
+ * constants exactly. Set by an admin per-vault via `enableVault` and looked
16
+ * up via `vaultInfo(vaultAddr).vaultType`. SDK callers normally do not pass
17
+ * this — the router resolves it internally.
18
+ */
9
19
  var SwapRouterVaultType;
10
20
  (function (SwapRouterVaultType) {
11
21
  SwapRouterVaultType[SwapRouterVaultType["ERC4626"] = 1] = "ERC4626";
@@ -1,8 +1,16 @@
1
- import { Signer, Provider } from 'ethers';
1
+ import type { Signer, Provider } from 'ethers';
2
2
  export type IAddress = `0x${string}`;
3
+ /**
4
+ * Address type for vault contracts across all supported chains.
5
+ * EVM vaults use `0x`-prefixed hex addresses, Solana vaults use base58,
6
+ * and Stellar vaults use 56-character base32 addresses (G/C prefix).
7
+ *
8
+ * Use this instead of `IAddress` when the address may belong to any chain.
9
+ */
3
10
  export type VaultAddress = string;
4
11
  export type IChainId = number;
5
12
  export type ChainType = 'evm' | 'solana' | 'sui' | 'stellar';
13
+ /** Runtime type guard for ChainType values (e.g. at API deserialization boundaries). */
6
14
  export declare function isChainType(value: unknown): value is ChainType;
7
15
  export type IChainObj = {
8
16
  chainId: number;
package/lib/types/web3.js CHANGED
@@ -7,6 +7,7 @@ const VALID_CHAIN_TYPES = new Set([
7
7
  'sui',
8
8
  'stellar',
9
9
  ]);
10
+ /** Runtime type guard for ChainType values (e.g. at API deserialization boundaries). */
10
11
  function isChainType(value) {
11
12
  return typeof value === 'string' && VALID_CHAIN_TYPES.has(value);
12
13
  }
@@ -1,5 +1,15 @@
1
- import { IUserRoles } from './user';
2
- import { IAddress, type ChainType, type IStellarNetwork } from './web3';
1
+ import type { IUserRoles } from './user';
2
+ import type { IAddress, ChainType, IStellarNetwork } from './web3';
3
+ /**
4
+ * Table of Contents
5
+ * 1) Subaccounts
6
+ * 2) Metrics
7
+ * 3) Tokens
8
+ * 4) Users
9
+ * 5) Statuses
10
+ * 6) Integrations
11
+ * 7) Lending Pools
12
+ */
3
13
  export type IHIstoricalSnapshot = {
4
14
  total_assets: number;
5
15
  total_shares: number;
@@ -14,6 +24,9 @@ export interface IWSMonitorHeaders {
14
24
  'x-user-id'?: string;
15
25
  'x-environment'?: string;
16
26
  }
27
+ /**
28
+ * Subaccounts
29
+ */
17
30
  export type IWSSubaccountPermission = {
18
31
  name: string;
19
32
  chain: number;
@@ -117,6 +130,9 @@ export interface IWSSubaccountLoan {
117
130
  payment_interval: number;
118
131
  lender_apr: number;
119
132
  }
133
+ /**
134
+ * Metrics
135
+ */
120
136
  export type IWSMetricsPnlAttributes = {
121
137
  pnl: number;
122
138
  percent_return: number;
@@ -289,6 +305,9 @@ export type IWSMetricsTimeseries = {
289
305
  total_pnl_7d: number | null;
290
306
  total_pnl_30d: number | null;
291
307
  };
308
+ /**
309
+ * Tokens
310
+ */
292
311
  export type IWSTokenEntry = {
293
312
  symbol: string;
294
313
  address: `0x${string}`;
@@ -306,6 +325,9 @@ export type IWSTokenPrice = {
306
325
  price: number;
307
326
  dt: string;
308
327
  };
328
+ /**
329
+ * Users
330
+ */
309
331
  export type IWSUserSubaccount = {
310
332
  internal_name: string;
311
333
  friendly_name: string;
@@ -332,12 +354,21 @@ export type IWSUser = {
332
354
  disabled: boolean;
333
355
  id: string;
334
356
  };
357
+ /**
358
+ * Statuses
359
+ */
335
360
  export type IWSFireblocksTxStatus = 'SUBMITTED' | 'PENDING_AML_SCREENING' | 'PENDING_AUTHORIZATION' | 'QUEUED' | 'PENDING_SIGNATURE' | 'PENDING_3RD_PARTY_MANUAL_APPROVAL' | 'PENDING_3RD_PARTY' | 'BROADCASTING' | 'CONFIRMING' | 'COMPLETED' | 'CANCELLING' | 'BLOCKED' | 'REJECTED' | 'FAILED';
361
+ /**
362
+ * Integrations
363
+ */
336
364
  export interface IWSIntegrationMorphoApy {
337
365
  apy: number;
338
366
  vault_positions: any[];
339
367
  token: IWSTokenEntry;
340
368
  }
369
+ /**
370
+ * Lending Pools
371
+ */
341
372
  export interface IWSVaultLoan {
342
373
  address: IAddress;
343
374
  lender: IAddress;
@@ -392,14 +423,23 @@ export interface ITokenizedVaultEoaOperator {
392
423
  id: string;
393
424
  name: string;
394
425
  }
426
+ /**
427
+ * Controls how the vault's APY is displayed in the UI.
428
+ * When `is_show_target_apy` is true, the UI should show a target/projected APY.
429
+ * When `is_show_hardcoded_apy` is true, `hardcoded_apy` overrides the computed APY.
430
+ */
395
431
  export interface IApyOverride {
432
+ /** Whether to display a target APY rather than historical performance. */
396
433
  is_show_target_apy: boolean;
434
+ /** Whether to display `hardcoded_apy` in place of the computed APY. */
397
435
  is_show_hardcoded_apy: boolean;
436
+ /** The fixed APY value to display when `is_show_hardcoded_apy` is true, or null. */
398
437
  hardcoded_apy: number | null;
399
438
  }
400
439
  export interface ITokenizedVaultStrategist {
401
440
  strategist_name: string;
402
441
  strategist_logo: string;
442
+ /** URL of the strategist's website, or null if not provided. */
403
443
  website_url: string | null;
404
444
  id: string;
405
445
  }
@@ -534,6 +574,7 @@ export interface ITokenizedVault {
534
574
  stellar_vault_metadata?: IStellarVaultMetadata | null;
535
575
  lagDuration: number;
536
576
  historical_apy: Record<number, number> | null;
577
+ /** @deprecated Use getVaultHistoricalTimeseries instead */
537
578
  historical_snapshots?: IHIstoricalSnapshot[];
538
579
  max_drawdown: number | null;
539
580
  daily_pnl_per_share: Record<string, number>;
@@ -552,8 +593,12 @@ export interface ITokenizedVault {
552
593
  }>;
553
594
  };
554
595
  show_cap_filled: boolean | null;
596
+ /** Controls APY display behaviour in the UI; null when the server has not set an override. */
555
597
  apy_override: IApyOverride | null;
556
598
  }
599
+ /**
600
+ * @deprecated
601
+ */
557
602
  export interface IWSVaultHistoricalApy {
558
603
  data: {
559
604
  labels: string[];