@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
@@ -18,60 +18,268 @@ 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 {
33
+ signer;
34
+ rawSigner;
22
35
  constructor(signer) {
23
36
  this.rawSigner = signer;
37
+ // Don't normalize in constructor - do it lazily when needed
24
38
  }
39
+ /**
40
+ * Set a new signer (supports both ethers and viem/wagmi)
41
+ * @param signer - Either an ethers Signer/Wallet or viem WalletClient
42
+ */
25
43
  setSigner(signer) {
26
44
  this.rawSigner = signer;
27
- this.signer = undefined;
45
+ this.signer = undefined; // Reset normalized signer
28
46
  }
47
+ /**
48
+ * Get the normalized ethers-compatible signer
49
+ * Converts viem WalletClient to ethers Signer if needed
50
+ */
29
51
  async getSigner() {
30
52
  if (!this.rawSigner) {
31
53
  throw new Error('No signer provided');
32
54
  }
55
+ // If we already have a normalized signer, return it
33
56
  if (this.signer) {
34
57
  return this.signer;
35
58
  }
59
+ // Normalize and cache the signer
36
60
  this.signer = await (0, signer_1.normalizeSigner)(this.rawSigner);
37
61
  return this.signer;
38
62
  }
63
+ // Core EVM operations
39
64
  async vaultApprove(options) {
40
65
  const signer = await this.getSigner();
41
66
  return (0, write_actions_1.vaultApprove)(signer, options);
42
67
  }
68
+ /**
69
+ * Approve a vault to spend a deposit token, returning a discriminated
70
+ * {@link ApproveResult} so callers can tell `sent` from `sufficient`
71
+ * (existing allowance covers) and `native` (no allowance applies).
72
+ * Prefer this over {@link vaultApprove} for new integrations.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const r = await augustSdk.evm.approve({
77
+ * target: vaultAddress,
78
+ * wallet: walletAddress,
79
+ * amount: '100',
80
+ * wait: true,
81
+ * });
82
+ * if (r.kind === 'sent') console.log('approve tx', r.hash);
83
+ * ```
84
+ */
43
85
  async approve(options) {
44
86
  const signer = await this.getSigner();
45
87
  return (0, write_actions_1.approve)(signer, options);
46
88
  }
89
+ /**
90
+ * Read the ERC-20 allowance the wallet has granted the vault to spend its
91
+ * underlying asset, returned as a normalized number. For the newer typed
92
+ * read that returns a raw `bigint` and accepts an explicit `asset` override,
93
+ * use {@link EVMAdapter.allowance}.
94
+ *
95
+ * Only `target` (vault address) and `wallet` are read from `options`; the
96
+ * remaining {@link IContractWriteOptions} fields are ignored.
97
+ *
98
+ * @param options - `{ target, wallet }` (other fields ignored).
99
+ * @returns Normalized allowance (`{ raw, normalized }`), or `undefined` when
100
+ * `target` / `wallet` fail address validation.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const a = await augustSdk.evm.vaultAllowance({
105
+ * target: vaultAddress,
106
+ * wallet: walletAddress,
107
+ * });
108
+ * console.log(a?.normalized);
109
+ * ```
110
+ */
47
111
  async vaultAllowance(options) {
48
112
  const signer = await this.getSigner();
49
113
  return (0, read_actions_1.vaultAllowance)(signer, options);
50
114
  }
115
+ // Vault operations (delegate to modules)
116
+ /**
117
+ * Deposit into an August vault. Routes automatically: V1 single-asset vaults
118
+ * deposit the underlying directly; V2 multi-asset vaults route through the
119
+ * adapter for non-underlying `depositAsset`. If allowance is insufficient
120
+ * the method submits an approve transaction first (the approve step always
121
+ * waits for confirmation to close a race window, regardless of `wait`).
122
+ *
123
+ * @param options - {@link IContractWriteOptions}. `target` and `wallet` are
124
+ * required; pass `amount`, `depositAsset` (defaults to the vault's
125
+ * underlying), `chainId`, `poolName`, `wait`, and `isDepositWithPermit`
126
+ * as needed.
127
+ * @returns The deposit `TransactionResponse`, or `undefined` if an
128
+ * approval-only path was taken and no deposit transaction was sent.
129
+ * @throws AugustValidationError on invalid inputs (bad address, bad amount).
130
+ * @throws AugustSDKError on RPC / contract revert during the deposit.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * const tx = await augustSdk.evm.vaultDeposit({
135
+ * target: vaultAddress,
136
+ * wallet: walletAddress,
137
+ * amount: '100',
138
+ * wait: true,
139
+ * });
140
+ * ```
141
+ */
51
142
  async vaultDeposit(options) {
52
143
  const signer = await this.getSigner();
53
144
  return (0, write_actions_1.vaultDeposit)(signer, options);
54
145
  }
146
+ /**
147
+ * Submit a redemption request against a vault. Shares are escrowed and the
148
+ * underlying assets are released asynchronously by the protocol; callers
149
+ * collect the matured assets via {@link EVMAdapter.vaultRedeem}, or use the
150
+ * instant-redeem variant by setting `isInstantRedeem: true`.
151
+ *
152
+ * @param options - {@link IContractWriteOptions}. `target`, `wallet`, and
153
+ * `amount` (in shares) are required. Set `isInstantRedeem: true` to take
154
+ * the instant-redeem path when the vault supports it.
155
+ * @returns The request `TransactionResponse`, or `undefined` if the request
156
+ * could not be built (validation failure).
157
+ * @throws AugustValidationError on invalid inputs.
158
+ * @throws AugustSDKError on RPC / contract revert.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * const tx = await augustSdk.evm.vaultRequestRedeem({
163
+ * target: vaultAddress,
164
+ * wallet: walletAddress,
165
+ * amount: shareAmount,
166
+ * wait: true,
167
+ * });
168
+ * ```
169
+ */
55
170
  async vaultRequestRedeem(options) {
56
171
  const signer = await this.getSigner();
57
172
  return (0, write_actions_1.vaultRequestRedeem)(signer, options);
58
173
  }
174
+ /**
175
+ * Deposit the chain's native asset (ETH / AVAX / etc.) into a vault by
176
+ * routing through the `MultiAssetNativeDepositWrapper`. The wrapper handles
177
+ * native-to-wrapped conversion and the subsequent vault deposit in a single
178
+ * transaction.
179
+ *
180
+ * @param options - {@link INativeDepositOptions}: `wrapperAddress`, `amount`
181
+ * (native, scaled by the chain's native decimals), optional `receiver`
182
+ * (defaults to the signer), and optional `wait`.
183
+ * @returns The deposit `TransactionResponse`.
184
+ * @throws AugustValidationError on invalid inputs.
185
+ * @throws AugustSDKError on RPC / contract revert.
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * const tx = await augustSdk.evm.depositNative({
190
+ * wrapperAddress: nativeWrapperAddress,
191
+ * amount: parseEther('1'),
192
+ * wait: true,
193
+ * });
194
+ * ```
195
+ */
59
196
  async depositNative(options) {
60
197
  const signer = await this.getSigner();
61
198
  return (0, write_actions_1.depositNative)(signer, options);
62
199
  }
200
+ /**
201
+ * Swap one or more whitelisted ERC-20s into a vault's reference asset via
202
+ * the on-chain `SwapRouter` and deposit the proceeds. The router handles
203
+ * fee accrual, slippage protection, and the v1/v3 vs v2 deposit-interface
204
+ * branching. Approval is sent automatically for each `swaps[i].tokenIn`
205
+ * when the caller's allowance against the SwapRouter is below `amountIn`.
206
+ *
207
+ * @param options - {@link ISwapAndDepositOptions}.
208
+ * @returns The transaction hash of the `swapAndDeposit` call.
209
+ * @throws AugustValidationError on invalid inputs (bad chain, empty swaps).
210
+ * @throws AugustSDKError on RPC / contract revert.
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * const quote = await fetchSwapQuote({
215
+ * chainId: 1, srcToken: WBTC, srcDecimals: 8,
216
+ * destToken: USDC, destDecimals: 6, amount: 100_000_000n,
217
+ * receiver: SWAP_ROUTER_ADDRESSES[1]!,
218
+ * });
219
+ * const hash = await augustSdk.evm.swapAndDeposit({
220
+ * chainId: 1, vault, receiver: wallet,
221
+ * swaps: [{ tokenIn: WBTC, tokenOut: USDC, amountIn: 100_000_000n,
222
+ * minAmountOut: quote.minAmountOut, router: quote.router, payload: quote.payload }],
223
+ * });
224
+ * ```
225
+ */
63
226
  async swapAndDeposit(options) {
64
227
  const signer = await this.getSigner();
65
228
  return (0, write_actions_1.swapAndDeposit)(signer, options);
66
229
  }
230
+ /**
231
+ * Deposit a vault's reference asset through the SwapRouter — no swap.
232
+ * Use this when the caller already holds the reference asset but wants
233
+ * the origin/referral fee accounting that the SwapRouter path provides.
234
+ *
235
+ * @param options - {@link ISwapRouterDirectDepositOptions}.
236
+ * @returns The transaction hash of the `deposit` call.
237
+ */
67
238
  async depositViaSwapRouter(options) {
68
239
  const signer = await this.getSigner();
69
240
  return (0, write_actions_1.depositViaSwapRouter)(signer, options);
70
241
  }
242
+ /**
243
+ * Deposit native ETH (or chain-native equivalent) into a vault via the
244
+ * SwapRouter. Only valid when the vault's reference asset is the chain's
245
+ * wrapped-native token — the SwapRouter wraps `amount` and deposits.
246
+ *
247
+ * @param options - {@link ISwapRouterNativeDepositOptions}.
248
+ * @returns The transaction hash of the `depositNativeToken` call.
249
+ */
71
250
  async depositNativeViaSwapRouter(options) {
72
251
  const signer = await this.getSigner();
73
252
  return (0, write_actions_1.depositNativeViaSwapRouter)(signer, options);
74
253
  }
254
+ /**
255
+ * Claim assets from a matured redemption request on a dated-redemption
256
+ * (RWA-style) vault. The `year`, `month`, `day`, and `receiverIndex` tuple
257
+ * identifies which batch of the user's matured requests to redeem from —
258
+ * these are emitted at request-time and indexed by the subgraph.
259
+ *
260
+ * For non-dated vaults that complete their redemption via `instantRedeem`,
261
+ * see {@link EVMAdapter.vaultRequestRedeem} with `isInstantRedeem: true`.
262
+ *
263
+ * @param options - {@link IContractWriteOptions} plus `year` / `month` /
264
+ * `day` / `receiverIndex` identifying the matured batch to claim.
265
+ * @returns The redeem `TransactionResponse`.
266
+ * @throws AugustValidationError on invalid inputs.
267
+ * @throws AugustSDKError on RPC / contract revert.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * const tx = await augustSdk.evm.vaultRedeem({
272
+ * target: vaultAddress,
273
+ * wallet: walletAddress,
274
+ * amount: shareAmount,
275
+ * year: '2026',
276
+ * month: '06',
277
+ * day: '02',
278
+ * receiverIndex: '0',
279
+ * wait: true,
280
+ * });
281
+ * ```
282
+ */
75
283
  async vaultRedeem(options) {
76
284
  const signer = await this.getSigner();
77
285
  return (0, write_actions_1.vaultRedeem)(signer, options);
@@ -92,22 +300,83 @@ class EVMAdapter {
92
300
  const signer = await this.getSigner();
93
301
  return (0, read_actions_1.getRemainingAllocations)(signer, options);
94
302
  }
303
+ /**
304
+ * Preview the share output of a deposit without broadcasting a transaction.
305
+ * See {@link readPreviewDeposit} for the routing details (EVM-1 vs EVM-2
306
+ * multi-asset vaults).
307
+ *
308
+ * @returns Shares minted in raw on-chain units (share-token decimals).
309
+ *
310
+ * @example
311
+ * ```ts
312
+ * const shares = await augustSdk.evm.previewDeposit({
313
+ * vault: '0x...',
314
+ * amount: 1_000_000n,
315
+ * });
316
+ * ```
317
+ */
95
318
  async previewDeposit(options) {
96
319
  const signer = await this.getSigner();
97
320
  return (0, read_actions_1.previewDeposit)(signer, options);
98
321
  }
322
+ /**
323
+ * Preview the assets returned by redeeming a number of shares, without
324
+ * broadcasting a transaction.
325
+ *
326
+ * @returns Assets returned in raw on-chain units (asset decimals).
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * const assets = await augustSdk.evm.previewRedeem({
331
+ * vault: '0x...',
332
+ * shares: 1_000_000_000_000_000_000n,
333
+ * });
334
+ * ```
335
+ */
99
336
  async previewRedeem(options) {
100
337
  const signer = await this.getSigner();
101
338
  return (0, read_actions_1.previewRedeem)(signer, options);
102
339
  }
340
+ /**
341
+ * Read the ERC-20 allowance an owner has granted the vault. Defaults to the
342
+ * vault's underlying asset; pass `asset` to override.
343
+ *
344
+ * @returns Allowance as a raw `bigint`.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * const raw = await augustSdk.evm.allowance({ vault, owner });
349
+ * ```
350
+ */
103
351
  async allowance(options) {
104
352
  const signer = await this.getSigner();
105
353
  return (0, read_actions_1.allowance)(signer, options);
106
354
  }
355
+ /**
356
+ * Read an ERC-20 token balance.
357
+ *
358
+ * @returns Balance as a raw `bigint`.
359
+ *
360
+ * @example
361
+ * ```ts
362
+ * const raw = await augustSdk.evm.balanceOf({ asset: usdcAddress, owner });
363
+ * ```
364
+ */
107
365
  async balanceOf(options) {
108
366
  const signer = await this.getSigner();
109
367
  return (0, read_actions_1.balanceOf)(signer, options);
110
368
  }
369
+ /**
370
+ * Read the maximum deposit accepted by the vault for the supplied
371
+ * receiver. Useful for "vault is full" gates.
372
+ *
373
+ * @returns Max deposit as a raw `bigint`.
374
+ *
375
+ * @example
376
+ * ```ts
377
+ * const cap = await augustSdk.evm.maxDeposit({ vault });
378
+ * ```
379
+ */
111
380
  async maxDeposit(options) {
112
381
  const signer = await this.getSigner();
113
382
  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 {
@@ -1,4 +1,4 @@
1
- import { ISolanaNetwork } from '../../types';
1
+ import type { ISolanaNetwork } from '../../types';
2
2
  import { vaultIdl } from './idl/vault-idl';
3
3
  declare const fallbackDecimals = 8;
4
4
  declare const fallbackNetwork: ISolanaNetwork;
@@ -7,6 +7,9 @@ const fallbackDecimals = 8;
7
7
  exports.fallbackDecimals = fallbackDecimals;
8
8
  const fallbackNetwork = 'mainnet-beta';
9
9
  exports.fallbackNetwork = fallbackNetwork;
10
+ // ============================================================================
11
+ // SOLANA CONFIGURATION
12
+ // ============================================================================
10
13
  const fallbackRpcEndpoints = {
11
14
  devnet: 'https://api.devnet.solana.com',
12
15
  mainnet: 'https://api.mainnet-beta.solana.com',
@@ -19,7 +22,7 @@ const programIds = {
19
22
  vault: '7B8n9vL51b6ibqRAd1adZsi3x3kxtq5NZaondh22Vkyq',
20
23
  },
21
24
  ['mainnet-beta']: {
22
- vault: '7B8n9vL51b6ibqRAd1adZsi3x3kxtq5NZaondh22Vkyq',
25
+ vault: '7B8n9vL51b6ibqRAd1adZsi3x3kxtq5NZaondh22Vkyq', // BTCsyrup vault
23
26
  },
24
27
  testnet: {
25
28
  vault: '7B8n9vL51b6ibqRAd1adZsi3x3kxtq5NZaondh22Vkyq',
@@ -1,3 +1,11 @@
1
- import { ITokenizedVault } from '../../types';
1
+ import type { ITokenizedVault } from '../../types';
2
2
  import type { IVaultBaseOptions } from '../../modules/vaults/types';
3
+ /**
4
+ * Fetch Solana vault data from on-chain program state.
5
+ * Falls back to backend-only data when Solana RPC is unavailable,
6
+ * ensuring vaults always appear in the list even without on-chain access.
7
+ * @param tokenizedVault Vault metadata from backend
8
+ * @param options RPC configuration with Solana service
9
+ * @returns Formatted vault object with Solana-specific fields
10
+ */
3
11
  export declare const getSolanaVault: (tokenizedVault: ITokenizedVault, options: IVaultBaseOptions) => Promise<import("../../types").IVault>;
@@ -39,14 +39,24 @@ const utils_1 = require("./utils");
39
39
  const SolanaConstants = __importStar(require("./constants"));
40
40
  const core_1 = require("../../core");
41
41
  const utils_2 = require("../../modules/vaults/utils");
42
+ /**
43
+ * Fetch Solana vault data from on-chain program state.
44
+ * Falls back to backend-only data when Solana RPC is unavailable,
45
+ * ensuring vaults always appear in the list even without on-chain access.
46
+ * @param tokenizedVault Vault metadata from backend
47
+ * @param options RPC configuration with Solana service
48
+ * @returns Formatted vault object with Solana-specific fields
49
+ */
42
50
  const getSolanaVault = async (tokenizedVault, options) => {
43
51
  const solanaRpcUrl = options.rpcUrl;
44
52
  const solanaMetadata = tokenizedVault.solana_vault_metadata;
45
53
  const programId = utils_1.SolanaUtils.resolveProgramId(tokenizedVault.address, solanaMetadata);
54
+ // Fallback decimals: prefer backend metadata, then the application default
46
55
  const fallbackDecimals = solanaMetadata?.deposit_token_decimals ?? SolanaConstants.fallbackDecimals;
47
56
  let vaultState = null;
48
57
  let depositMint = null;
49
58
  let onChainAvailable = false;
59
+ // Attempt to fetch on-chain data; gracefully degrade if RPC is unavailable
50
60
  try {
51
61
  vaultState = await utils_1.SolanaUtils.getVaultStateReadOnly({
52
62
  idl: SolanaConstants.vaultIdl,
@@ -70,6 +80,7 @@ const getSolanaVault = async (tokenizedVault, options) => {
70
80
  }
71
81
  }
72
82
  catch (error) {
83
+ // Only degrade gracefully for network/RPC issues; re-throw everything else
73
84
  const isNetworkError = error instanceof Error &&
74
85
  (/fetch failed|ETIMEDOUT|timeout|ECONNREFUSED|403|503|network/i.test(error.message) ||
75
86
  error.name === 'AbortError');
@@ -79,6 +90,9 @@ const getSolanaVault = async (tokenizedVault, options) => {
79
90
  core_1.Logger.log.warn('getSolanaVault', 'RPC unavailable, using backend-only data', { vault: tokenizedVault.address, error });
80
91
  }
81
92
  const decimals = vaultState?.depositMintDecimals ?? fallbackDecimals;
93
+ // Fetch share mint supply to get totalSupply.
94
+ // Prefer vaultState.shareMint (correct for multi-vault programs like jitoSOL);
95
+ // fall back to deriveShareMintPda(programId) for legacy single-vault programs.
82
96
  let totalSupply = (0, core_1.toNormalizedBn)(0, decimals);
83
97
  if (onChainAvailable) {
84
98
  try {
@@ -100,6 +114,11 @@ const getSolanaVault = async (tokenizedVault, options) => {
100
114
  });
101
115
  }
102
116
  }
117
+ // Total assets must mirror the on-chain `VaultState::total_assets()` which
118
+ // is `local_aum + deployed_aum` (see solana-vaults/programs/august-vault/
119
+ // src/state/vault.rs). Reading deployed_aum alone makes the displayed share
120
+ // price drop below 1.0 the instant the operator deploys part of the vault,
121
+ // even though the vault has had no PnL.
103
122
  let totalAssets;
104
123
  if (onChainAvailable) {
105
124
  const localAumRaw = vaultState?.vaultState?.localAum;
@@ -115,6 +134,7 @@ const getSolanaVault = async (tokenizedVault, options) => {
115
134
  else {
116
135
  totalAssets = (0, utils_2.backendTvlToNormalizedBn)(tokenizedVault.latest_reported_tvl, decimals);
117
136
  }
137
+ // Deposit asset: use on-chain data if available, otherwise backend metadata
118
138
  const depositAsset = {
119
139
  address: depositMint?.address ?? solanaMetadata?.deposit_mint,
120
140
  symbol: depositMint?.symbol ?? solanaMetadata?.deposit_token_symbol,
@@ -125,6 +145,7 @@ const getSolanaVault = async (tokenizedVault, options) => {
125
145
  vault: tokenizedVault.address,
126
146
  });
127
147
  }
148
+ // Build unified vault object combining on-chain and backend data
128
149
  return (0, utils_2.buildBackendVault)(tokenizedVault, {
129
150
  chainId: core_1.SPECIAL_CHAINS.solana.chainId,
130
151
  version: 'sol-0',
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vaultIdl = void 0;
4
+ // /**
5
+ // * Program IDL in camelCase format in order to be used in JS/TS.
6
+ // *
7
+ // * Note that this is only a type helper and is not the actual IDL. The original
8
+ // * IDL can be found at `target/idl/august_vault.json`.
9
+ // */
4
10
  exports.vaultIdl = {
5
11
  address: '7B8n9vL51b6ibqRAd1adZsi3x3kxtq5NZaondh22Vkyq',
6
12
  metadata: {
@@ -990,6 +996,9 @@ exports.vaultIdl = {
990
996
  name: 'VaultState',
991
997
  type: {
992
998
  kind: 'struct',
999
+ // Field order MUST match programs/august-vault/src/state/vault.rs:36
1000
+ // exactly. Borsh deserialization is positional; any reorder, addition,
1001
+ // or omission silently corrupts every field after the drift point.
993
1002
  fields: [
994
1003
  {
995
1004
  name: 'operator',
@@ -1,10 +1,15 @@
1
+ /**
2
+ * Solana Adapter for August SDK
3
+ *
4
+ * @module SolanaAdapter
5
+ */
1
6
  import * as SolanaConstants from './constants';
2
7
  import * as SolanaGetters from './getters';
3
8
  import * as SolanaActions from './vault.actions';
4
- import { AnchorProvider, web3 } from '@coral-xyz/anchor';
5
- import { Connection, PublicKey, Transaction } from '@solana/web3.js';
6
- import { ISolanaNetwork, ISolanaRpcEndpoint } from './types';
7
- import { SendTransactionOptions } from '@solana/wallet-adapter-base';
9
+ import type { AnchorProvider, web3 } from '@coral-xyz/anchor';
10
+ import { Connection, PublicKey, type Transaction } from '@solana/web3.js';
11
+ import type { ISolanaNetwork, ISolanaRpcEndpoint } from './types';
12
+ import type { SendTransactionOptions } from '@solana/wallet-adapter-base';
8
13
  export declare const Solana: {
9
14
  utils: {
10
15
  getExplorerLink: ({ signature, type, network, }: {
@@ -102,6 +107,16 @@ export declare const Solana: {
102
107
  actions: typeof SolanaActions;
103
108
  getters: typeof SolanaGetters;
104
109
  };
110
+ /**
111
+ * Solana Adapter for August SDK
112
+ *
113
+ * @example
114
+ * To access the Solana adapter instance
115
+ * ```
116
+ * const sdk = new AugustSDK()
117
+ * sdk.solana.getVaultState()
118
+ * ```
119
+ */
105
120
  declare class SolanaAdapter {
106
121
  private _endpoint;
107
122
  private _network;
@@ -132,11 +147,51 @@ declare class SolanaAdapter {
132
147
  getTokenSymbol(mintAddress: string | PublicKey): Promise<string>;
133
148
  fetchUserTokenBalance(publicKey: PublicKey | string, depositMint: PublicKey | string): Promise<any>;
134
149
  fetchUserShareBalance(publicKey: PublicKey | string, shareMint: PublicKey | string): Promise<any>;
150
+ /**
151
+ * BigInt-safe variant of {@link fetchUserShareBalance}. Returns the raw u64
152
+ * `amount` (as a base-units string) plus the mint's `decimals` (or `null`
153
+ * when the scale can't be determined — see Returns), so the caller can
154
+ * produce a correct `INormalizedNumber` without losing precision.
155
+ *
156
+ * Prefer this anywhere the result feeds BigInt math — positions, max-
157
+ * actions, redemption sizing, allowance checks. `fetchUserShareBalance`
158
+ * returns a JS-number `uiAmount` which silently encodes against 18 decimals
159
+ * when passed through `toNormalizedBn(value)` without an explicit decimals
160
+ * argument; that's exactly how the jitoSOL "missing position" regression
161
+ * manifested.
162
+ *
163
+ * RPC cost: 1 `getParsedTokenAccountsByOwner` call. Worst case ~150ms on a
164
+ * healthy mainnet endpoint.
165
+ *
166
+ * @param publicKey Wallet owner (PublicKey or base58 string).
167
+ * @param shareMint The vault's share-token mint (PublicKey or base58).
168
+ * @returns
169
+ * `{ amount, decimals }`. Three observable shapes:
170
+ * - `{ amount: '<u64>', decimals: <number> }` — token account exists.
171
+ * - `{ amount: '0', decimals: null }` — no token account for this mint
172
+ * under this wallet, OR `tokenAmount` was missing from the response,
173
+ * OR `publicKey`/`shareMint` was not supplied. Distinguishable from a
174
+ * genuine zero-balance account (`decimals` would be set there).
175
+ * - `{ amount: '0', decimals: null }` — RPC threw (error is logged).
176
+ *
177
+ * `decimals === null` means "we could not determine the scale" — callers
178
+ * that need an `INormalizedNumber` must fall back to a known decimals
179
+ * value (typically the deposit mint's decimals from backend metadata)
180
+ * before normalizing. Never throws.
181
+ */
135
182
  fetchUserShareBalanceRaw(publicKey: PublicKey | string, shareMint: PublicKey | string): Promise<{
136
183
  amount: string;
137
184
  decimals: number | null;
138
185
  }>;
186
+ /**
187
+ * Deposit funds into a Solana August vault.
188
+ * @param depositAmount `bigint` (raw on-chain units) or `number` (UI amount).
189
+ */
139
190
  vaultDeposit(vaultProgramId: PublicKey | string, idl: any, publicKey: PublicKey | string, depositAmount: number | bigint, sendTransaction: (transaction: Transaction | web3.VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<web3.TransactionSignature>, vaultAddress?: PublicKey | string): Promise<any>;
191
+ /**
192
+ * Redeem vault shares from a Solana August vault.
193
+ * @param redeemShares `bigint` (raw share units) or `number` (UI amount).
194
+ */
140
195
  vaultRedeem(vaultProgramId: PublicKey | string, idl: any, publicKey: PublicKey | string, redeemShares: number | bigint, sendTransaction: (transaction: Transaction | web3.VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<web3.TransactionSignature>, vaultAddress?: PublicKey | string): Promise<any>;
141
196
  getProgramId(type: 'vault'): string;
142
197
  }