@augustdigital/sdk 8.3.2 → 8.5.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 (204) hide show
  1. package/lib/abis/ERC20_Bytes32.d.ts +4 -0
  2. package/lib/abis/ERC20_Bytes32.js +4 -0
  3. package/lib/abis/ERC4626.d.ts +1 -0
  4. package/lib/abis/ERC4626.js +1 -0
  5. package/lib/abis/ERC721.d.ts +1 -0
  6. package/lib/abis/ERC721.js +1 -0
  7. package/lib/abis/FeeOracle.js +1 -0
  8. package/lib/abis/LendingPool.js +1 -0
  9. package/lib/abis/LendingPoolV2.js +1 -0
  10. package/lib/abis/Multicall3.js +3 -0
  11. package/lib/abis/OFT.d.ts +20 -0
  12. package/lib/abis/OFT.js +20 -0
  13. package/lib/abis/SmartAccount.d.ts +1 -0
  14. package/lib/abis/SmartAccount.js +3 -0
  15. package/lib/abis/SwapRouter.d.ts +1 -0
  16. package/lib/abis/SwapRouter.js +1 -0
  17. package/lib/abis/UniversalSignatureValidator.js +3 -0
  18. package/lib/abis/index.d.ts +5 -0
  19. package/lib/abis/index.js +5 -0
  20. package/lib/adapters/evm/getters.d.ts +17 -2
  21. package/lib/adapters/evm/getters.js +35 -3
  22. package/lib/adapters/evm/index.d.ts +262 -0
  23. package/lib/adapters/evm/index.js +268 -1
  24. package/lib/adapters/evm/utils.d.ts +6 -0
  25. package/lib/adapters/evm/utils.js +7 -0
  26. package/lib/adapters/solana/constants.js +4 -1
  27. package/lib/adapters/solana/getters.d.ts +8 -0
  28. package/lib/adapters/solana/getters.js +21 -0
  29. package/lib/adapters/solana/idl/vault-idl.js +9 -0
  30. package/lib/adapters/solana/index.d.ts +55 -0
  31. package/lib/adapters/solana/index.js +57 -0
  32. package/lib/adapters/solana/utils.d.ts +28 -0
  33. package/lib/adapters/solana/utils.js +79 -4
  34. package/lib/adapters/solana/vault.actions.d.ts +19 -0
  35. package/lib/adapters/solana/vault.actions.js +47 -3
  36. package/lib/adapters/stellar/actions.d.ts +25 -0
  37. package/lib/adapters/stellar/actions.js +33 -0
  38. package/lib/adapters/stellar/constants.d.ts +26 -0
  39. package/lib/adapters/stellar/constants.js +29 -0
  40. package/lib/adapters/stellar/getters.d.ts +56 -0
  41. package/lib/adapters/stellar/getters.js +81 -0
  42. package/lib/adapters/stellar/index.d.ts +48 -0
  43. package/lib/adapters/stellar/index.js +48 -0
  44. package/lib/adapters/stellar/soroban.d.ts +20 -0
  45. package/lib/adapters/stellar/soroban.js +46 -0
  46. package/lib/adapters/stellar/submit.d.ts +12 -0
  47. package/lib/adapters/stellar/submit.js +19 -0
  48. package/lib/adapters/stellar/types.d.ts +27 -0
  49. package/lib/adapters/stellar/types.js +3 -0
  50. package/lib/adapters/stellar/utils.d.ts +10 -0
  51. package/lib/adapters/stellar/utils.js +10 -0
  52. package/lib/adapters/sui/getters.d.ts +6 -0
  53. package/lib/adapters/sui/getters.js +6 -0
  54. package/lib/adapters/sui/index.d.ts +15 -0
  55. package/lib/adapters/sui/index.js +15 -0
  56. package/lib/adapters/sui/transformer.d.ts +6 -0
  57. package/lib/adapters/sui/transformer.js +6 -0
  58. package/lib/adapters/sui/utils.d.ts +6 -0
  59. package/lib/adapters/sui/utils.js +6 -0
  60. package/lib/core/analytics/chain-name.d.ts +8 -0
  61. package/lib/core/analytics/chain-name.js +8 -0
  62. package/lib/core/analytics/constants.d.ts +4 -0
  63. package/lib/core/analytics/constants.js +4 -0
  64. package/lib/core/analytics/env.d.ts +25 -0
  65. package/lib/core/analytics/env.js +26 -0
  66. package/lib/core/analytics/index.d.ts +26 -0
  67. package/lib/core/analytics/index.js +35 -0
  68. package/lib/core/analytics/instrumentation.d.ts +26 -0
  69. package/lib/core/analytics/instrumentation.js +66 -2
  70. package/lib/core/analytics/method-taxonomy.d.ts +16 -0
  71. package/lib/core/analytics/method-taxonomy.js +18 -0
  72. package/lib/core/analytics/metrics.d.ts +23 -0
  73. package/lib/core/analytics/metrics.js +40 -0
  74. package/lib/core/analytics/sanitize.d.ts +38 -0
  75. package/lib/core/analytics/sanitize.js +46 -0
  76. package/lib/core/analytics/sentry-runtime.d.ts +11 -0
  77. package/lib/core/analytics/sentry-runtime.js +19 -0
  78. package/lib/core/analytics/sentry.d.ts +45 -0
  79. package/lib/core/analytics/sentry.js +115 -2
  80. package/lib/core/analytics/types.d.ts +27 -0
  81. package/lib/core/analytics/user-identity.d.ts +34 -0
  82. package/lib/core/analytics/user-identity.js +42 -0
  83. package/lib/core/analytics/version.d.ts +6 -1
  84. package/lib/core/analytics/version.js +6 -1
  85. package/lib/core/auth/verify.js +5 -0
  86. package/lib/core/base.class.d.ts +75 -0
  87. package/lib/core/base.class.js +56 -0
  88. package/lib/core/cache.d.ts +5 -0
  89. package/lib/core/cache.js +6 -0
  90. package/lib/core/constants/adapters.d.ts +15 -0
  91. package/lib/core/constants/adapters.js +28 -8
  92. package/lib/core/constants/core.d.ts +12 -1
  93. package/lib/core/constants/core.js +12 -0
  94. package/lib/core/constants/swap-router.d.ts +46 -0
  95. package/lib/core/constants/swap-router.js +50 -0
  96. package/lib/core/constants/vaults.d.ts +56 -0
  97. package/lib/core/constants/vaults.js +66 -1
  98. package/lib/core/constants/web3.d.ts +3 -0
  99. package/lib/core/constants/web3.js +18 -5
  100. package/lib/core/errors/index.d.ts +36 -0
  101. package/lib/core/errors/index.js +29 -0
  102. package/lib/core/fetcher.d.ts +134 -0
  103. package/lib/core/fetcher.js +191 -5
  104. package/lib/core/helpers/adapters.d.ts +9 -0
  105. package/lib/core/helpers/adapters.js +11 -0
  106. package/lib/core/helpers/chain-address.d.ts +10 -0
  107. package/lib/core/helpers/chain-address.js +11 -0
  108. package/lib/core/helpers/core.d.ts +42 -0
  109. package/lib/core/helpers/core.js +66 -1
  110. package/lib/core/helpers/explorer-link.d.ts +14 -0
  111. package/lib/core/helpers/explorer-link.js +14 -0
  112. package/lib/core/helpers/signer.d.ts +26 -0
  113. package/lib/core/helpers/signer.js +39 -0
  114. package/lib/core/helpers/swap-router.d.ts +32 -0
  115. package/lib/core/helpers/swap-router.js +32 -0
  116. package/lib/core/helpers/vault-version.d.ts +1 -0
  117. package/lib/core/helpers/vault-version.js +2 -0
  118. package/lib/core/helpers/vaults.d.ts +8 -0
  119. package/lib/core/helpers/vaults.js +22 -8
  120. package/lib/core/helpers/web3.d.ts +152 -0
  121. package/lib/core/helpers/web3.js +183 -6
  122. package/lib/core/logger/index.d.ts +55 -0
  123. package/lib/core/logger/index.js +19 -0
  124. package/lib/core/logger/slack.d.ts +3 -0
  125. package/lib/core/logger/slack.js +3 -0
  126. package/lib/core/vault-metadata.d.ts +6 -0
  127. package/lib/core/vault-metadata.js +6 -0
  128. package/lib/core/version-check.d.ts +52 -0
  129. package/lib/core/version-check.js +81 -0
  130. package/lib/evm/methods/crossChainVault.d.ts +90 -0
  131. package/lib/evm/methods/crossChainVault.js +186 -1
  132. package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
  133. package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
  134. package/lib/evm/methods/index.d.ts +1 -0
  135. package/lib/evm/methods/index.js +1 -0
  136. package/lib/evm/types/crossChain.d.ts +202 -0
  137. package/lib/evm/types/crossChain.js +11 -0
  138. package/lib/index.d.ts +16 -0
  139. package/lib/index.js +19 -0
  140. package/lib/main.d.ts +288 -5
  141. package/lib/main.js +305 -0
  142. package/lib/modules/api/index.d.ts +1 -0
  143. package/lib/modules/api/index.js +6 -0
  144. package/lib/modules/api/main.d.ts +52 -0
  145. package/lib/modules/api/main.js +130 -0
  146. package/lib/modules/sub-accounts/fetcher.d.ts +15 -0
  147. package/lib/modules/sub-accounts/fetcher.js +15 -0
  148. package/lib/modules/sub-accounts/main.d.ts +33 -0
  149. package/lib/modules/sub-accounts/main.js +38 -0
  150. package/lib/modules/sub-accounts/utils.d.ts +3 -0
  151. package/lib/modules/sub-accounts/utils.js +3 -0
  152. package/lib/modules/vaults/adapter.helpers.d.ts +18 -0
  153. package/lib/modules/vaults/adapter.helpers.js +34 -0
  154. package/lib/modules/vaults/fetcher.d.ts +20 -0
  155. package/lib/modules/vaults/fetcher.js +40 -3
  156. package/lib/modules/vaults/getters.d.ts +295 -0
  157. package/lib/modules/vaults/getters.js +552 -12
  158. package/lib/modules/vaults/index.d.ts +12 -0
  159. package/lib/modules/vaults/index.js +12 -0
  160. package/lib/modules/vaults/main.d.ts +292 -4
  161. package/lib/modules/vaults/main.js +379 -7
  162. package/lib/modules/vaults/read.actions.d.ts +168 -0
  163. package/lib/modules/vaults/read.actions.js +143 -0
  164. package/lib/modules/vaults/types.d.ts +34 -0
  165. package/lib/modules/vaults/utils/call-data-decoder.d.ts +47 -0
  166. package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
  167. package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
  168. package/lib/modules/vaults/utils/date-utils.js +47 -1
  169. package/lib/modules/vaults/utils.d.ts +69 -0
  170. package/lib/modules/vaults/utils.js +104 -5
  171. package/lib/modules/vaults/write.actions.d.ts +363 -3
  172. package/lib/modules/vaults/write.actions.js +364 -2
  173. package/lib/polyfills.js +2 -0
  174. package/lib/sdk.d.ts +23705 -0
  175. package/lib/services/coingecko/fetcher.d.ts +13 -0
  176. package/lib/services/coingecko/fetcher.js +17 -0
  177. package/lib/services/debank/fetcher.d.ts +14 -0
  178. package/lib/services/debank/fetcher.js +12 -0
  179. package/lib/services/debank/utils.js +17 -0
  180. package/lib/services/layerzero/deposits.d.ts +11 -0
  181. package/lib/services/layerzero/deposits.js +34 -11
  182. package/lib/services/layerzero/redeems.d.ts +10 -0
  183. package/lib/services/layerzero/redeems.js +13 -0
  184. package/lib/services/layerzero/utils.d.ts +8 -0
  185. package/lib/services/layerzero/utils.js +11 -0
  186. package/lib/services/octavfi/fetcher.d.ts +7 -0
  187. package/lib/services/octavfi/fetcher.js +25 -0
  188. package/lib/services/octavfi/utils.d.ts +12 -0
  189. package/lib/services/octavfi/utils.js +44 -10
  190. package/lib/services/subgraph/fetcher.js +4 -2
  191. package/lib/services/subgraph/vaults.d.ts +12 -0
  192. package/lib/services/subgraph/vaults.js +43 -2
  193. package/lib/services/swap-quotes/index.d.ts +71 -0
  194. package/lib/services/swap-quotes/index.js +25 -0
  195. package/lib/services/swap-quotes/paraswap.d.ts +17 -0
  196. package/lib/services/swap-quotes/paraswap.js +14 -0
  197. package/lib/types/pools.d.ts +3 -0
  198. package/lib/types/typed-contract.d.ts +64 -0
  199. package/lib/types/vaults.d.ts +137 -2
  200. package/lib/types/vaults.js +10 -0
  201. package/lib/types/web3.d.ts +8 -0
  202. package/lib/types/web3.js +1 -0
  203. package/lib/types/webserver.d.ts +45 -0
  204. package/package.json +6 -5
@@ -4,21 +4,222 @@ import { IPreviewDepositOptions, IPreviewRedeemOptions, IAllowanceOptions, IBala
4
4
  import { CompatibleSigner } from '../../core/helpers/signer';
5
5
  import { IAddress } from '../../types';
6
6
  export * from './getters';
7
+ /**
8
+ * EVM Adapter for August SDK
9
+ * Supports both ethers Signer/Wallet and wagmi/viem WalletClient
10
+ *
11
+ * @example
12
+ * To access the EVM adapter instance
13
+ * ```
14
+ * const sdk = new AugustSDK()
15
+ * sdk.evm.vaultRedeem()
16
+ * ```
17
+ */
7
18
  declare class EVMAdapter {
8
19
  private signer?;
9
20
  private rawSigner?;
10
21
  constructor(signer?: CompatibleSigner);
22
+ /**
23
+ * Set a new signer (supports both ethers and viem/wagmi)
24
+ * @param signer - Either an ethers Signer/Wallet or viem WalletClient
25
+ */
11
26
  setSigner(signer: CompatibleSigner): void;
27
+ /**
28
+ * Get the normalized ethers-compatible signer
29
+ * Converts viem WalletClient to ethers Signer if needed
30
+ */
12
31
  private getSigner;
13
32
  vaultApprove(options: IContractWriteOptions): Promise<string>;
33
+ /**
34
+ * Approve a vault to spend a deposit token, returning a discriminated
35
+ * {@link ApproveResult} so callers can tell `sent` from `sufficient`
36
+ * (existing allowance covers) and `native` (no allowance applies).
37
+ * Prefer this over {@link vaultApprove} for new integrations.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const r = await augustSdk.evm.approve({
42
+ * target: vaultAddress,
43
+ * wallet: walletAddress,
44
+ * amount: '100',
45
+ * wait: true,
46
+ * });
47
+ * if (r.kind === 'sent') console.log('approve tx', r.hash);
48
+ * ```
49
+ */
14
50
  approve(options: IContractWriteOptions): Promise<ApproveResult>;
51
+ /**
52
+ * Read the ERC-20 allowance the wallet has granted the vault to spend its
53
+ * underlying asset, returned as a normalized number. For the newer typed
54
+ * read that returns a raw `bigint` and accepts an explicit `asset` override,
55
+ * use {@link EVMAdapter.allowance}.
56
+ *
57
+ * Only `target` (vault address) and `wallet` are read from `options`; the
58
+ * remaining {@link IContractWriteOptions} fields are ignored.
59
+ *
60
+ * @param options - `{ target, wallet }` (other fields ignored).
61
+ * @returns Normalized allowance (`{ raw, normalized }`), or `undefined` when
62
+ * `target` / `wallet` fail address validation.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const a = await augustSdk.evm.vaultAllowance({
67
+ * target: vaultAddress,
68
+ * wallet: walletAddress,
69
+ * });
70
+ * console.log(a?.normalized);
71
+ * ```
72
+ */
15
73
  vaultAllowance(options: IContractWriteOptions): Promise<import("../../types").INormalizedNumber>;
74
+ /**
75
+ * Deposit into an August vault. Routes automatically: V1 single-asset vaults
76
+ * deposit the underlying directly; V2 multi-asset vaults route through the
77
+ * adapter for non-underlying `depositAsset`. If allowance is insufficient
78
+ * the method submits an approve transaction first (the approve step always
79
+ * waits for confirmation to close a race window, regardless of `wait`).
80
+ *
81
+ * @param options - {@link IContractWriteOptions}. `target` and `wallet` are
82
+ * required; pass `amount`, `depositAsset` (defaults to the vault's
83
+ * underlying), `chainId`, `poolName`, `wait`, and `isDepositWithPermit`
84
+ * as needed.
85
+ * @returns The deposit `TransactionResponse`, or `undefined` if an
86
+ * approval-only path was taken and no deposit transaction was sent.
87
+ * @throws AugustValidationError on invalid inputs (bad address, bad amount).
88
+ * @throws AugustSDKError on RPC / contract revert during the deposit.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const tx = await augustSdk.evm.vaultDeposit({
93
+ * target: vaultAddress,
94
+ * wallet: walletAddress,
95
+ * amount: '100',
96
+ * wait: true,
97
+ * });
98
+ * ```
99
+ */
16
100
  vaultDeposit(options: IContractWriteOptions): Promise<string>;
101
+ /**
102
+ * Submit a redemption request against a vault. Shares are escrowed and the
103
+ * underlying assets are released asynchronously by the protocol; callers
104
+ * collect the matured assets via {@link EVMAdapter.vaultRedeem}, or use the
105
+ * instant-redeem variant by setting `isInstantRedeem: true`.
106
+ *
107
+ * @param options - {@link IContractWriteOptions}. `target`, `wallet`, and
108
+ * `amount` (in shares) are required. Set `isInstantRedeem: true` to take
109
+ * the instant-redeem path when the vault supports it.
110
+ * @returns The request `TransactionResponse`, or `undefined` if the request
111
+ * could not be built (validation failure).
112
+ * @throws AugustValidationError on invalid inputs.
113
+ * @throws AugustSDKError on RPC / contract revert.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const tx = await augustSdk.evm.vaultRequestRedeem({
118
+ * target: vaultAddress,
119
+ * wallet: walletAddress,
120
+ * amount: shareAmount,
121
+ * wait: true,
122
+ * });
123
+ * ```
124
+ */
17
125
  vaultRequestRedeem(options: IContractWriteOptions): Promise<string>;
126
+ /**
127
+ * Deposit the chain's native asset (ETH / AVAX / etc.) into a vault by
128
+ * routing through the `MultiAssetNativeDepositWrapper`. The wrapper handles
129
+ * native-to-wrapped conversion and the subsequent vault deposit in a single
130
+ * transaction.
131
+ *
132
+ * @param options - {@link INativeDepositOptions}: `wrapperAddress`, `amount`
133
+ * (native, scaled by the chain's native decimals), optional `receiver`
134
+ * (defaults to the signer), and optional `wait`.
135
+ * @returns The deposit `TransactionResponse`.
136
+ * @throws AugustValidationError on invalid inputs.
137
+ * @throws AugustSDKError on RPC / contract revert.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const tx = await augustSdk.evm.depositNative({
142
+ * wrapperAddress: nativeWrapperAddress,
143
+ * amount: parseEther('1'),
144
+ * wait: true,
145
+ * });
146
+ * ```
147
+ */
18
148
  depositNative(options: INativeDepositOptions): Promise<string>;
149
+ /**
150
+ * Swap one or more whitelisted ERC-20s into a vault's reference asset via
151
+ * the on-chain `SwapRouter` and deposit the proceeds. The router handles
152
+ * fee accrual, slippage protection, and the v1/v3 vs v2 deposit-interface
153
+ * branching. Approval is sent automatically for each `swaps[i].tokenIn`
154
+ * when the caller's allowance against the SwapRouter is below `amountIn`.
155
+ *
156
+ * @param options - {@link ISwapAndDepositOptions}.
157
+ * @returns The transaction hash of the `swapAndDeposit` call.
158
+ * @throws AugustValidationError on invalid inputs (bad chain, empty swaps).
159
+ * @throws AugustSDKError on RPC / contract revert.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * const quote = await fetchSwapQuote({
164
+ * chainId: 1, srcToken: WBTC, srcDecimals: 8,
165
+ * destToken: USDC, destDecimals: 6, amount: 100_000_000n,
166
+ * receiver: SWAP_ROUTER_ADDRESSES[1]!,
167
+ * });
168
+ * const hash = await augustSdk.evm.swapAndDeposit({
169
+ * chainId: 1, vault, receiver: wallet,
170
+ * swaps: [{ tokenIn: WBTC, tokenOut: USDC, amountIn: 100_000_000n,
171
+ * minAmountOut: quote.minAmountOut, router: quote.router, payload: quote.payload }],
172
+ * });
173
+ * ```
174
+ */
19
175
  swapAndDeposit(options: ISwapAndDepositOptions): Promise<string>;
176
+ /**
177
+ * Deposit a vault's reference asset through the SwapRouter — no swap.
178
+ * Use this when the caller already holds the reference asset but wants
179
+ * the origin/referral fee accounting that the SwapRouter path provides.
180
+ *
181
+ * @param options - {@link ISwapRouterDirectDepositOptions}.
182
+ * @returns The transaction hash of the `deposit` call.
183
+ */
20
184
  depositViaSwapRouter(options: ISwapRouterDirectDepositOptions): Promise<string>;
185
+ /**
186
+ * Deposit native ETH (or chain-native equivalent) into a vault via the
187
+ * SwapRouter. Only valid when the vault's reference asset is the chain's
188
+ * wrapped-native token — the SwapRouter wraps `amount` and deposits.
189
+ *
190
+ * @param options - {@link ISwapRouterNativeDepositOptions}.
191
+ * @returns The transaction hash of the `depositNativeToken` call.
192
+ */
21
193
  depositNativeViaSwapRouter(options: ISwapRouterNativeDepositOptions): Promise<string>;
194
+ /**
195
+ * Claim assets from a matured redemption request on a dated-redemption
196
+ * (RWA-style) vault. The `year`, `month`, `day`, and `receiverIndex` tuple
197
+ * identifies which batch of the user's matured requests to redeem from —
198
+ * these are emitted at request-time and indexed by the subgraph.
199
+ *
200
+ * For non-dated vaults that complete their redemption via `instantRedeem`,
201
+ * see {@link EVMAdapter.vaultRequestRedeem} with `isInstantRedeem: true`.
202
+ *
203
+ * @param options - {@link IContractWriteOptions} plus `year` / `month` /
204
+ * `day` / `receiverIndex` identifying the matured batch to claim.
205
+ * @returns The redeem `TransactionResponse`.
206
+ * @throws AugustValidationError on invalid inputs.
207
+ * @throws AugustSDKError on RPC / contract revert.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * const tx = await augustSdk.evm.vaultRedeem({
212
+ * target: vaultAddress,
213
+ * wallet: walletAddress,
214
+ * amount: shareAmount,
215
+ * year: '2026',
216
+ * month: '06',
217
+ * day: '02',
218
+ * receiverIndex: '0',
219
+ * wait: true,
220
+ * });
221
+ * ```
222
+ */
22
223
  vaultRedeem(options: IContractWriteOptions & {
23
224
  year: string;
24
225
  month: string;
@@ -43,10 +244,71 @@ declare class EVMAdapter {
43
244
  vault: IAddress;
44
245
  depositCapAmount?: bigint;
45
246
  }): Promise<import("../../types").INormalizedNumber>;
247
+ /**
248
+ * Preview the share output of a deposit without broadcasting a transaction.
249
+ * See {@link readPreviewDeposit} for the routing details (EVM-1 vs EVM-2
250
+ * multi-asset vaults).
251
+ *
252
+ * @returns Shares minted in raw on-chain units (share-token decimals).
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * const shares = await augustSdk.evm.previewDeposit({
257
+ * vault: '0x...',
258
+ * amount: 1_000_000n,
259
+ * });
260
+ * ```
261
+ */
46
262
  previewDeposit(options: IPreviewDepositOptions): Promise<bigint>;
263
+ /**
264
+ * Preview the assets returned by redeeming a number of shares, without
265
+ * broadcasting a transaction.
266
+ *
267
+ * @returns Assets returned in raw on-chain units (asset decimals).
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * const assets = await augustSdk.evm.previewRedeem({
272
+ * vault: '0x...',
273
+ * shares: 1_000_000_000_000_000_000n,
274
+ * });
275
+ * ```
276
+ */
47
277
  previewRedeem(options: IPreviewRedeemOptions): Promise<bigint>;
278
+ /**
279
+ * Read the ERC-20 allowance an owner has granted the vault. Defaults to the
280
+ * vault's underlying asset; pass `asset` to override.
281
+ *
282
+ * @returns Allowance as a raw `bigint`.
283
+ *
284
+ * @example
285
+ * ```ts
286
+ * const raw = await augustSdk.evm.allowance({ vault, owner });
287
+ * ```
288
+ */
48
289
  allowance(options: IAllowanceOptions): Promise<bigint>;
290
+ /**
291
+ * Read an ERC-20 token balance.
292
+ *
293
+ * @returns Balance as a raw `bigint`.
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * const raw = await augustSdk.evm.balanceOf({ asset: usdcAddress, owner });
298
+ * ```
299
+ */
49
300
  balanceOf(options: IBalanceOfOptions): Promise<bigint>;
301
+ /**
302
+ * Read the maximum deposit accepted by the vault for the supplied
303
+ * receiver. Useful for "vault is full" gates.
304
+ *
305
+ * @returns Max deposit as a raw `bigint`.
306
+ *
307
+ * @example
308
+ * ```ts
309
+ * const cap = await augustSdk.evm.maxDeposit({ vault });
310
+ * ```
311
+ */
50
312
  maxDeposit(options: IMaxDepositOptions): Promise<bigint>;
51
313
  }
52
314
  export default EVMAdapter;
@@ -18,60 +18,266 @@ const write_actions_1 = require("../../modules/vaults/write.actions");
18
18
  const read_actions_1 = require("../../modules/vaults/read.actions");
19
19
  const signer_1 = require("../../core/helpers/signer");
20
20
  __exportStar(require("./getters"), exports);
21
+ /**
22
+ * EVM Adapter for August SDK
23
+ * Supports both ethers Signer/Wallet and wagmi/viem WalletClient
24
+ *
25
+ * @example
26
+ * To access the EVM adapter instance
27
+ * ```
28
+ * const sdk = new AugustSDK()
29
+ * sdk.evm.vaultRedeem()
30
+ * ```
31
+ */
21
32
  class EVMAdapter {
22
33
  constructor(signer) {
23
34
  this.rawSigner = signer;
35
+ // Don't normalize in constructor - do it lazily when needed
24
36
  }
37
+ /**
38
+ * Set a new signer (supports both ethers and viem/wagmi)
39
+ * @param signer - Either an ethers Signer/Wallet or viem WalletClient
40
+ */
25
41
  setSigner(signer) {
26
42
  this.rawSigner = signer;
27
- this.signer = undefined;
43
+ this.signer = undefined; // Reset normalized signer
28
44
  }
45
+ /**
46
+ * Get the normalized ethers-compatible signer
47
+ * Converts viem WalletClient to ethers Signer if needed
48
+ */
29
49
  async getSigner() {
30
50
  if (!this.rawSigner) {
31
51
  throw new Error('No signer provided');
32
52
  }
53
+ // If we already have a normalized signer, return it
33
54
  if (this.signer) {
34
55
  return this.signer;
35
56
  }
57
+ // Normalize and cache the signer
36
58
  this.signer = await (0, signer_1.normalizeSigner)(this.rawSigner);
37
59
  return this.signer;
38
60
  }
61
+ // Core EVM operations
39
62
  async vaultApprove(options) {
40
63
  const signer = await this.getSigner();
41
64
  return (0, write_actions_1.vaultApprove)(signer, options);
42
65
  }
66
+ /**
67
+ * Approve a vault to spend a deposit token, returning a discriminated
68
+ * {@link ApproveResult} so callers can tell `sent` from `sufficient`
69
+ * (existing allowance covers) and `native` (no allowance applies).
70
+ * Prefer this over {@link vaultApprove} for new integrations.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const r = await augustSdk.evm.approve({
75
+ * target: vaultAddress,
76
+ * wallet: walletAddress,
77
+ * amount: '100',
78
+ * wait: true,
79
+ * });
80
+ * if (r.kind === 'sent') console.log('approve tx', r.hash);
81
+ * ```
82
+ */
43
83
  async approve(options) {
44
84
  const signer = await this.getSigner();
45
85
  return (0, write_actions_1.approve)(signer, options);
46
86
  }
87
+ /**
88
+ * Read the ERC-20 allowance the wallet has granted the vault to spend its
89
+ * underlying asset, returned as a normalized number. For the newer typed
90
+ * read that returns a raw `bigint` and accepts an explicit `asset` override,
91
+ * use {@link EVMAdapter.allowance}.
92
+ *
93
+ * Only `target` (vault address) and `wallet` are read from `options`; the
94
+ * remaining {@link IContractWriteOptions} fields are ignored.
95
+ *
96
+ * @param options - `{ target, wallet }` (other fields ignored).
97
+ * @returns Normalized allowance (`{ raw, normalized }`), or `undefined` when
98
+ * `target` / `wallet` fail address validation.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const a = await augustSdk.evm.vaultAllowance({
103
+ * target: vaultAddress,
104
+ * wallet: walletAddress,
105
+ * });
106
+ * console.log(a?.normalized);
107
+ * ```
108
+ */
47
109
  async vaultAllowance(options) {
48
110
  const signer = await this.getSigner();
49
111
  return (0, read_actions_1.vaultAllowance)(signer, options);
50
112
  }
113
+ // Vault operations (delegate to modules)
114
+ /**
115
+ * Deposit into an August vault. Routes automatically: V1 single-asset vaults
116
+ * deposit the underlying directly; V2 multi-asset vaults route through the
117
+ * adapter for non-underlying `depositAsset`. If allowance is insufficient
118
+ * the method submits an approve transaction first (the approve step always
119
+ * waits for confirmation to close a race window, regardless of `wait`).
120
+ *
121
+ * @param options - {@link IContractWriteOptions}. `target` and `wallet` are
122
+ * required; pass `amount`, `depositAsset` (defaults to the vault's
123
+ * underlying), `chainId`, `poolName`, `wait`, and `isDepositWithPermit`
124
+ * as needed.
125
+ * @returns The deposit `TransactionResponse`, or `undefined` if an
126
+ * approval-only path was taken and no deposit transaction was sent.
127
+ * @throws AugustValidationError on invalid inputs (bad address, bad amount).
128
+ * @throws AugustSDKError on RPC / contract revert during the deposit.
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * const tx = await augustSdk.evm.vaultDeposit({
133
+ * target: vaultAddress,
134
+ * wallet: walletAddress,
135
+ * amount: '100',
136
+ * wait: true,
137
+ * });
138
+ * ```
139
+ */
51
140
  async vaultDeposit(options) {
52
141
  const signer = await this.getSigner();
53
142
  return (0, write_actions_1.vaultDeposit)(signer, options);
54
143
  }
144
+ /**
145
+ * Submit a redemption request against a vault. Shares are escrowed and the
146
+ * underlying assets are released asynchronously by the protocol; callers
147
+ * collect the matured assets via {@link EVMAdapter.vaultRedeem}, or use the
148
+ * instant-redeem variant by setting `isInstantRedeem: true`.
149
+ *
150
+ * @param options - {@link IContractWriteOptions}. `target`, `wallet`, and
151
+ * `amount` (in shares) are required. Set `isInstantRedeem: true` to take
152
+ * the instant-redeem path when the vault supports it.
153
+ * @returns The request `TransactionResponse`, or `undefined` if the request
154
+ * could not be built (validation failure).
155
+ * @throws AugustValidationError on invalid inputs.
156
+ * @throws AugustSDKError on RPC / contract revert.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * const tx = await augustSdk.evm.vaultRequestRedeem({
161
+ * target: vaultAddress,
162
+ * wallet: walletAddress,
163
+ * amount: shareAmount,
164
+ * wait: true,
165
+ * });
166
+ * ```
167
+ */
55
168
  async vaultRequestRedeem(options) {
56
169
  const signer = await this.getSigner();
57
170
  return (0, write_actions_1.vaultRequestRedeem)(signer, options);
58
171
  }
172
+ /**
173
+ * Deposit the chain's native asset (ETH / AVAX / etc.) into a vault by
174
+ * routing through the `MultiAssetNativeDepositWrapper`. The wrapper handles
175
+ * native-to-wrapped conversion and the subsequent vault deposit in a single
176
+ * transaction.
177
+ *
178
+ * @param options - {@link INativeDepositOptions}: `wrapperAddress`, `amount`
179
+ * (native, scaled by the chain's native decimals), optional `receiver`
180
+ * (defaults to the signer), and optional `wait`.
181
+ * @returns The deposit `TransactionResponse`.
182
+ * @throws AugustValidationError on invalid inputs.
183
+ * @throws AugustSDKError on RPC / contract revert.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * const tx = await augustSdk.evm.depositNative({
188
+ * wrapperAddress: nativeWrapperAddress,
189
+ * amount: parseEther('1'),
190
+ * wait: true,
191
+ * });
192
+ * ```
193
+ */
59
194
  async depositNative(options) {
60
195
  const signer = await this.getSigner();
61
196
  return (0, write_actions_1.depositNative)(signer, options);
62
197
  }
198
+ /**
199
+ * Swap one or more whitelisted ERC-20s into a vault's reference asset via
200
+ * the on-chain `SwapRouter` and deposit the proceeds. The router handles
201
+ * fee accrual, slippage protection, and the v1/v3 vs v2 deposit-interface
202
+ * branching. Approval is sent automatically for each `swaps[i].tokenIn`
203
+ * when the caller's allowance against the SwapRouter is below `amountIn`.
204
+ *
205
+ * @param options - {@link ISwapAndDepositOptions}.
206
+ * @returns The transaction hash of the `swapAndDeposit` call.
207
+ * @throws AugustValidationError on invalid inputs (bad chain, empty swaps).
208
+ * @throws AugustSDKError on RPC / contract revert.
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * const quote = await fetchSwapQuote({
213
+ * chainId: 1, srcToken: WBTC, srcDecimals: 8,
214
+ * destToken: USDC, destDecimals: 6, amount: 100_000_000n,
215
+ * receiver: SWAP_ROUTER_ADDRESSES[1]!,
216
+ * });
217
+ * const hash = await augustSdk.evm.swapAndDeposit({
218
+ * chainId: 1, vault, receiver: wallet,
219
+ * swaps: [{ tokenIn: WBTC, tokenOut: USDC, amountIn: 100_000_000n,
220
+ * minAmountOut: quote.minAmountOut, router: quote.router, payload: quote.payload }],
221
+ * });
222
+ * ```
223
+ */
63
224
  async swapAndDeposit(options) {
64
225
  const signer = await this.getSigner();
65
226
  return (0, write_actions_1.swapAndDeposit)(signer, options);
66
227
  }
228
+ /**
229
+ * Deposit a vault's reference asset through the SwapRouter — no swap.
230
+ * Use this when the caller already holds the reference asset but wants
231
+ * the origin/referral fee accounting that the SwapRouter path provides.
232
+ *
233
+ * @param options - {@link ISwapRouterDirectDepositOptions}.
234
+ * @returns The transaction hash of the `deposit` call.
235
+ */
67
236
  async depositViaSwapRouter(options) {
68
237
  const signer = await this.getSigner();
69
238
  return (0, write_actions_1.depositViaSwapRouter)(signer, options);
70
239
  }
240
+ /**
241
+ * Deposit native ETH (or chain-native equivalent) into a vault via the
242
+ * SwapRouter. Only valid when the vault's reference asset is the chain's
243
+ * wrapped-native token — the SwapRouter wraps `amount` and deposits.
244
+ *
245
+ * @param options - {@link ISwapRouterNativeDepositOptions}.
246
+ * @returns The transaction hash of the `depositNativeToken` call.
247
+ */
71
248
  async depositNativeViaSwapRouter(options) {
72
249
  const signer = await this.getSigner();
73
250
  return (0, write_actions_1.depositNativeViaSwapRouter)(signer, options);
74
251
  }
252
+ /**
253
+ * Claim assets from a matured redemption request on a dated-redemption
254
+ * (RWA-style) vault. The `year`, `month`, `day`, and `receiverIndex` tuple
255
+ * identifies which batch of the user's matured requests to redeem from —
256
+ * these are emitted at request-time and indexed by the subgraph.
257
+ *
258
+ * For non-dated vaults that complete their redemption via `instantRedeem`,
259
+ * see {@link EVMAdapter.vaultRequestRedeem} with `isInstantRedeem: true`.
260
+ *
261
+ * @param options - {@link IContractWriteOptions} plus `year` / `month` /
262
+ * `day` / `receiverIndex` identifying the matured batch to claim.
263
+ * @returns The redeem `TransactionResponse`.
264
+ * @throws AugustValidationError on invalid inputs.
265
+ * @throws AugustSDKError on RPC / contract revert.
266
+ *
267
+ * @example
268
+ * ```ts
269
+ * const tx = await augustSdk.evm.vaultRedeem({
270
+ * target: vaultAddress,
271
+ * wallet: walletAddress,
272
+ * amount: shareAmount,
273
+ * year: '2026',
274
+ * month: '06',
275
+ * day: '02',
276
+ * receiverIndex: '0',
277
+ * wait: true,
278
+ * });
279
+ * ```
280
+ */
75
281
  async vaultRedeem(options) {
76
282
  const signer = await this.getSigner();
77
283
  return (0, write_actions_1.vaultRedeem)(signer, options);
@@ -92,22 +298,83 @@ class EVMAdapter {
92
298
  const signer = await this.getSigner();
93
299
  return (0, read_actions_1.getRemainingAllocations)(signer, options);
94
300
  }
301
+ /**
302
+ * Preview the share output of a deposit without broadcasting a transaction.
303
+ * See {@link readPreviewDeposit} for the routing details (EVM-1 vs EVM-2
304
+ * multi-asset vaults).
305
+ *
306
+ * @returns Shares minted in raw on-chain units (share-token decimals).
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * const shares = await augustSdk.evm.previewDeposit({
311
+ * vault: '0x...',
312
+ * amount: 1_000_000n,
313
+ * });
314
+ * ```
315
+ */
95
316
  async previewDeposit(options) {
96
317
  const signer = await this.getSigner();
97
318
  return (0, read_actions_1.previewDeposit)(signer, options);
98
319
  }
320
+ /**
321
+ * Preview the assets returned by redeeming a number of shares, without
322
+ * broadcasting a transaction.
323
+ *
324
+ * @returns Assets returned in raw on-chain units (asset decimals).
325
+ *
326
+ * @example
327
+ * ```ts
328
+ * const assets = await augustSdk.evm.previewRedeem({
329
+ * vault: '0x...',
330
+ * shares: 1_000_000_000_000_000_000n,
331
+ * });
332
+ * ```
333
+ */
99
334
  async previewRedeem(options) {
100
335
  const signer = await this.getSigner();
101
336
  return (0, read_actions_1.previewRedeem)(signer, options);
102
337
  }
338
+ /**
339
+ * Read the ERC-20 allowance an owner has granted the vault. Defaults to the
340
+ * vault's underlying asset; pass `asset` to override.
341
+ *
342
+ * @returns Allowance as a raw `bigint`.
343
+ *
344
+ * @example
345
+ * ```ts
346
+ * const raw = await augustSdk.evm.allowance({ vault, owner });
347
+ * ```
348
+ */
103
349
  async allowance(options) {
104
350
  const signer = await this.getSigner();
105
351
  return (0, read_actions_1.allowance)(signer, options);
106
352
  }
353
+ /**
354
+ * Read an ERC-20 token balance.
355
+ *
356
+ * @returns Balance as a raw `bigint`.
357
+ *
358
+ * @example
359
+ * ```ts
360
+ * const raw = await augustSdk.evm.balanceOf({ asset: usdcAddress, owner });
361
+ * ```
362
+ */
107
363
  async balanceOf(options) {
108
364
  const signer = await this.getSigner();
109
365
  return (0, read_actions_1.balanceOf)(signer, options);
110
366
  }
367
+ /**
368
+ * Read the maximum deposit accepted by the vault for the supplied
369
+ * receiver. Useful for "vault is full" gates.
370
+ *
371
+ * @returns Max deposit as a raw `bigint`.
372
+ *
373
+ * @example
374
+ * ```ts
375
+ * const cap = await augustSdk.evm.maxDeposit({ vault });
376
+ * ```
377
+ */
111
378
  async maxDeposit(options) {
112
379
  const signer = await this.getSigner();
113
380
  return (0, read_actions_1.maxDeposit)(signer, options);
@@ -1,2 +1,8 @@
1
+ /**
2
+ * @todo
3
+ */
1
4
  export declare const functionsToCallMapping: (provider: any, contract: any, functionCalls: any[]) => any[];
5
+ /**
6
+ * @todo
7
+ */
2
8
  export declare const functionsToCallReduction: (acc: any, curr: any, i: number, functionCalls: any[], contractCalls: any[]) => any;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.functionsToCallReduction = exports.functionsToCallMapping = void 0;
4
4
  const core_1 = require("../../core");
5
+ /**
6
+ * @todo
7
+ */
5
8
  const functionsToCallMapping = (provider, contract, functionCalls) => {
6
9
  return functionCalls.map((f) => {
7
10
  if (f === 'symbol') {
@@ -14,6 +17,9 @@ const functionsToCallMapping = (provider, contract, functionCalls) => {
14
17
  });
15
18
  };
16
19
  exports.functionsToCallMapping = functionsToCallMapping;
20
+ /**
21
+ * @todo
22
+ */
17
23
  const functionsToCallReduction = (acc, curr, i, functionCalls, contractCalls) => {
18
24
  let val;
19
25
  if (functionCalls[i] === 'totalSupply' ||
@@ -33,6 +39,7 @@ const functionsToCallReduction = (acc, curr, i, functionCalls, contractCalls) =>
33
39
  val = Number(curr.toString());
34
40
  }
35
41
  else if (functionCalls[i] === 'loansOperator') {
42
+ // TODO: hardcoded as we cannot pull the real strategist
36
43
  val = '0x4DCb388488622e47683EAd1a147947140a31e485';
37
44
  }
38
45
  else {