@augustdigital/sdk 8.7.2 → 8.9.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.
@@ -7,8 +7,20 @@ exports.AugustSubAccounts = void 0;
7
7
  * @module AugustSubAccounts
8
8
  */
9
9
  const fetcher_1 = require("./fetcher");
10
+ const ethers_1 = require("ethers");
10
11
  const utils_1 = require("./utils");
11
12
  const core_1 = require("../../core");
13
+ /**
14
+ * Validates that a subaccount address is a well-formed EVM address, throwing a
15
+ * typed {@link AugustValidationError} if not. August subaccounts are EVM
16
+ * smart-contract wallets, so an invalid value should fail fast in the SDK
17
+ * rather than reaching the backend.
18
+ */
19
+ function assertSubaccountAddress(address, method) {
20
+ if (typeof address !== 'string' || !(0, ethers_1.isAddress)(address)) {
21
+ throw new core_1.AugustValidationError('INVALID_ADDRESS', `${method}: "${address}" is not a valid subaccount address — pass the subaccount's EVM (0x…) address.`);
22
+ }
23
+ }
12
24
  /**
13
25
  * Subaccount operation class interacting with August Subaccounts
14
26
  * Subaccount is a smart contract wallet that serves as the fundamental infrastructure for August's platform.
@@ -24,6 +36,38 @@ class AugustSubAccounts extends core_1.AugustBase {
24
36
  'x-user-id': this.monitoring?.['x-user-id'],
25
37
  };
26
38
  }
39
+ /**
40
+ * Retrieves one page of the directory of all August subaccounts.
41
+ *
42
+ * Backed by the admin-only `GET /subaccount` backend endpoint, so the
43
+ * August API key configured on the SDK must belong to an admin user —
44
+ * non-admin keys are rejected with an auth error by the backend. Makes
45
+ * exactly one HTTP request and no RPC calls.
46
+ *
47
+ * @param options - Pagination window over the subaccount directory
48
+ * @param options.offset - Number of records to skip. Defaults to 0; must be a non-negative integer.
49
+ * @param options.limit - Page size. Defaults to 100; must be an integer between 1 and 1000 (backend maximum).
50
+ * @returns The page of subaccount records (address, internal/friendly names, status, type, linked chains, risk metadata). An empty array means the offset is past the end of the directory.
51
+ * @throws AugustValidationError when `offset` or `limit` is out of range
52
+ * @throws AugustAuthError when the API key is missing or not admin-scoped
53
+ * @example
54
+ * const page = await augustSdk.subAccountsModule.getAllSubaccounts({
55
+ * offset: 0,
56
+ * limit: 200,
57
+ * });
58
+ * console.log(page.map((s) => `${s.internal_name}: ${s.address}`));
59
+ */
60
+ async getAllSubaccounts(options = {}) {
61
+ const offset = options.offset ?? 0;
62
+ const limit = options.limit ?? 100;
63
+ if (!Number.isInteger(offset) || offset < 0) {
64
+ throw new core_1.AugustValidationError('INVALID_INPUT', `getAllSubaccounts: offset must be a non-negative integer, got ${offset}`);
65
+ }
66
+ if (!Number.isInteger(limit) || limit < 1 || limit > 1000) {
67
+ throw new core_1.AugustValidationError('INVALID_INPUT', `getAllSubaccounts: limit must be an integer between 1 and 1000, got ${limit}`);
68
+ }
69
+ return (0, fetcher_1.fetchAllSubaccounts)({ offset, limit }, this.keys.august, this.headers);
70
+ }
27
71
  /**
28
72
  * Retrieves the health factor for a subaccount.
29
73
  * @param subaccountAddress - The address of the subaccount to query
@@ -77,6 +121,85 @@ class AugustSubAccounts extends core_1.AugustBase {
77
121
  const response = await (0, fetcher_1.fetchSubaccountSummary)(subaccountAddress, this.keys.august, this.headers);
78
122
  return (0, utils_1.transformSubaccountSummary)(response);
79
123
  }
124
+ /**
125
+ * Retrieves a subaccount's on-chain transaction history, newest first,
126
+ * optionally windowed by a time range.
127
+ *
128
+ * Backed by the authenticated `GET /transactions/v2` backend endpoint,
129
+ * which resolves and authorizes the subaccount, so the configured August
130
+ * API key must be authorized for it (an admin-scoped key always is). Makes
131
+ * exactly one HTTP request and no RPC calls.
132
+ *
133
+ * @param subaccountAddress - The address of the subaccount to query
134
+ * @param options - Optional time window
135
+ * @param options.startTime - ISO-8601 datetime lower bound (inclusive); omit for no lower bound
136
+ * @param options.endTime - ISO-8601 datetime upper bound (inclusive); omit for no upper bound
137
+ * @returns The subaccount's transactions with decoded logs, transfers, and function names
138
+ * @throws AugustValidationError When `subaccountAddress` is not a valid EVM address
139
+ * @throws AugustAuthError When the API key is missing or not authorized for the subaccount
140
+ * @throws AugustServerError When the API responds with a non-2xx status
141
+ * @example
142
+ * const txs = await augustSdk.subAccountsModule.getSubaccountTransactions(
143
+ * '0xabc…',
144
+ * { startTime: '2026-01-01T00:00:00Z' },
145
+ * );
146
+ */
147
+ async getSubaccountTransactions(subaccountAddress, options = {}) {
148
+ assertSubaccountAddress(subaccountAddress, 'getSubaccountTransactions');
149
+ return (0, fetcher_1.fetchSubaccountTransactions)({
150
+ address: subaccountAddress,
151
+ startTime: options.startTime,
152
+ endTime: options.endTime,
153
+ }, this.keys.august, this.headers);
154
+ }
155
+ /**
156
+ * Retrieves the full loan-book detail for a single loan by its address and
157
+ * chain.
158
+ *
159
+ * Backed by the admin-only `GET /subaccount/loans/{loan_address}` backend
160
+ * endpoint (60-second server-side cache), so the configured August API key
161
+ * must belong to an admin user. Makes exactly one HTTP request and no RPC
162
+ * calls.
163
+ *
164
+ * @param loanAddress - The loan contract address
165
+ * @param chainId - Numeric August chain id the loan lives on (e.g. `1` for Ethereum mainnet)
166
+ * @returns The loan's {@link ILoanBookInfo} detail
167
+ * @throws AugustValidationError When `chainId` is not an integer
168
+ * @throws AugustAuthError When the API key is missing or not admin-scoped
169
+ * @throws AugustServerError When the loan or chain is not found, or the API otherwise responds non-2xx
170
+ * @example
171
+ * const loan = await augustSdk.subAccountsModule.getSubaccountLoanByAddress(
172
+ * '0xloan…',
173
+ * 1,
174
+ * );
175
+ */
176
+ async getSubaccountLoanByAddress(loanAddress, chainId) {
177
+ if (!Number.isInteger(chainId)) {
178
+ throw new core_1.AugustValidationError('INVALID_CHAIN', `getSubaccountLoanByAddress: chainId must be an integer August chain id, got ${chainId}.`);
179
+ }
180
+ return (0, fetcher_1.fetchSubaccountLoanByAddress)(loanAddress, chainId, this.keys.august, this.headers);
181
+ }
182
+ /**
183
+ * Retrieves cross-chain DeBank protocol positions and token balances for a
184
+ * subaccount and its associated strategies.
185
+ *
186
+ * Backed by `GET /subaccount/{subaccount_address}/debank` (300-second
187
+ * server-side cache). This is a slow endpoint — it fans out to DeBank
188
+ * across every supported chain — so expect higher latency than other
189
+ * subaccount reads. Makes exactly one HTTP request and no RPC calls.
190
+ *
191
+ * @param subaccountAddress - The address of the subaccount to query
192
+ * @returns The subaccount's DeBank positions/tokens plus per-strategy breakdowns
193
+ * @throws AugustValidationError When `subaccountAddress` is not a valid EVM address
194
+ * @throws AugustServerError When the API responds with a non-2xx status
195
+ * @example
196
+ * const debank = await augustSdk.subAccountsModule.getSubaccountDebank('0xabc…');
197
+ * console.log(debank.subaccount.positions.length);
198
+ */
199
+ async getSubaccountDebank(subaccountAddress) {
200
+ assertSubaccountAddress(subaccountAddress, 'getSubaccountDebank');
201
+ return (0, fetcher_1.fetchSubaccountDebank)(subaccountAddress, this.keys.august, this.headers);
202
+ }
80
203
  }
81
204
  exports.AugustSubAccounts = AugustSubAccounts;
82
205
  //# sourceMappingURL=main.js.map