@augustdigital/sdk 8.8.0 → 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.
@@ -1,5 +1,32 @@
1
1
  import { type IFetchAugustOptions } from '../../core';
2
- import type { IAddress, IOTCPosition, IWSSubaccountCefi, IWSSubAccountHealthFactor, IWSSubaccountLoan, IWSSubaccountSummary } from '../../types';
2
+ import type { IAddress, ILoanBookInfo, IOTCPosition, ISubaccountDebank, ISubaccountTransaction, IWSSubaccountCefi, IWSSubAccountHealthFactor, IWSSubaccountListItem, IWSSubaccountLoan, IWSSubaccountSummary } from '../../types';
3
+ /**
4
+ * Fetch one page of the subaccount directory (admin-only backend endpoint)
5
+ */
6
+ export declare const fetchAllSubaccounts: (pagination: {
7
+ offset?: number;
8
+ limit?: number;
9
+ }, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountListItem[]>;
10
+ /**
11
+ * Fetch a subaccount's transaction history (authenticated `GET
12
+ * /transactions/v2`), optionally windowed by ISO-8601 start/end datetimes.
13
+ */
14
+ export declare const fetchSubaccountTransactions: (payload: {
15
+ address: IAddress;
16
+ startTime?: string;
17
+ endTime?: string;
18
+ }, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ISubaccountTransaction[]>;
19
+ /**
20
+ * Fetch a single loan's loan-book detail by loan address + chain
21
+ * (admin-only `GET /subaccount/loans/{loan_address}`).
22
+ */
23
+ export declare const fetchSubaccountLoanByAddress: (loanAddress: string, chainId: number, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ILoanBookInfo>;
24
+ /**
25
+ * Fetch cross-chain DeBank positions for a subaccount (`GET
26
+ * /subaccount/{subaccount_address}/debank`). Slow endpoint (300-second
27
+ * server-side cache) — it fans out across every supported chain.
28
+ */
29
+ export declare const fetchSubaccountDebank: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ISubaccountDebank>;
3
30
  /**
4
31
  * Fetch subaccount health factor for a given subaccount address
5
32
  */
@@ -1,7 +1,57 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchSubaccountSummary = exports.fetchSubaccountOtcPositions = exports.fetchSubaccountCefiPositions = exports.fetchSubaccountLoans = exports.fetchSubaccountHeathFactor = void 0;
3
+ exports.fetchSubaccountSummary = exports.fetchSubaccountOtcPositions = exports.fetchSubaccountCefiPositions = exports.fetchSubaccountLoans = exports.fetchSubaccountHeathFactor = exports.fetchSubaccountDebank = exports.fetchSubaccountLoanByAddress = exports.fetchSubaccountTransactions = exports.fetchAllSubaccounts = void 0;
4
4
  const core_1 = require("../../core");
5
+ /**
6
+ * Fetch one page of the subaccount directory (admin-only backend endpoint)
7
+ */
8
+ const fetchAllSubaccounts = async (pagination, augustKey, headers) => {
9
+ const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.list(pagination.offset, pagination.limit), {
10
+ headers,
11
+ });
12
+ if (!response.ok || typeof response.json !== 'function') {
13
+ throw new Error(`Failed to fetch subaccounts: ${response.statusText || 'Unknown error'}`);
14
+ }
15
+ return response.json();
16
+ };
17
+ exports.fetchAllSubaccounts = fetchAllSubaccounts;
18
+ /**
19
+ * Fetch a subaccount's transaction history (authenticated `GET
20
+ * /transactions/v2`), optionally windowed by ISO-8601 start/end datetimes.
21
+ */
22
+ const fetchSubaccountTransactions = async (payload, augustKey, headers) => {
23
+ const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.transactions.v2(payload.address, payload.startTime, payload.endTime), { headers });
24
+ if (!response.ok || typeof response.json !== 'function') {
25
+ throw new Error(`Failed to fetch subaccount transactions: ${response.statusText || 'Unknown error'}`);
26
+ }
27
+ return response.json();
28
+ };
29
+ exports.fetchSubaccountTransactions = fetchSubaccountTransactions;
30
+ /**
31
+ * Fetch a single loan's loan-book detail by loan address + chain
32
+ * (admin-only `GET /subaccount/loans/{loan_address}`).
33
+ */
34
+ const fetchSubaccountLoanByAddress = async (loanAddress, chainId, augustKey, headers) => {
35
+ const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.loanByAddress(loanAddress, chainId), { headers });
36
+ if (!response.ok || typeof response.json !== 'function') {
37
+ throw new Error(`Failed to fetch loan by address: ${response.statusText || 'Unknown error'}`);
38
+ }
39
+ return response.json();
40
+ };
41
+ exports.fetchSubaccountLoanByAddress = fetchSubaccountLoanByAddress;
42
+ /**
43
+ * Fetch cross-chain DeBank positions for a subaccount (`GET
44
+ * /subaccount/{subaccount_address}/debank`). Slow endpoint (300-second
45
+ * server-side cache) — it fans out across every supported chain.
46
+ */
47
+ const fetchSubaccountDebank = async (address, augustKey, headers) => {
48
+ const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.debank(address), { headers });
49
+ if (!response.ok || typeof response.json !== 'function') {
50
+ throw new Error(`Failed to fetch subaccount debank: ${response.statusText || 'Unknown error'}`);
51
+ }
52
+ return response.json();
53
+ };
54
+ exports.fetchSubaccountDebank = fetchSubaccountDebank;
5
55
  /**
6
56
  * Fetch subaccount health factor for a given subaccount address
7
57
  */
@@ -1,5 +1,5 @@
1
1
  import { AugustBase, type IAugustBase } from '../../core';
2
- import type { IAddress } from '../../types';
2
+ import type { IAddress, ILoanBookInfo, ISubaccountDebank, ISubaccountTransaction, IWSSubaccountListItem } from '../../types';
3
3
  /**
4
4
  * Subaccount operation class interacting with August Subaccounts
5
5
  * Subaccount is a smart contract wallet that serves as the fundamental infrastructure for August's platform.
@@ -9,6 +9,31 @@ import type { IAddress } from '../../types';
9
9
  export declare class AugustSubAccounts extends AugustBase {
10
10
  private headers;
11
11
  constructor(baseConfig: IAugustBase);
12
+ /**
13
+ * Retrieves one page of the directory of all August subaccounts.
14
+ *
15
+ * Backed by the admin-only `GET /subaccount` backend endpoint, so the
16
+ * August API key configured on the SDK must belong to an admin user —
17
+ * non-admin keys are rejected with an auth error by the backend. Makes
18
+ * exactly one HTTP request and no RPC calls.
19
+ *
20
+ * @param options - Pagination window over the subaccount directory
21
+ * @param options.offset - Number of records to skip. Defaults to 0; must be a non-negative integer.
22
+ * @param options.limit - Page size. Defaults to 100; must be an integer between 1 and 1000 (backend maximum).
23
+ * @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.
24
+ * @throws AugustValidationError when `offset` or `limit` is out of range
25
+ * @throws AugustAuthError when the API key is missing or not admin-scoped
26
+ * @example
27
+ * const page = await augustSdk.subAccountsModule.getAllSubaccounts({
28
+ * offset: 0,
29
+ * limit: 200,
30
+ * });
31
+ * console.log(page.map((s) => `${s.internal_name}: ${s.address}`));
32
+ */
33
+ getAllSubaccounts(options?: {
34
+ offset?: number;
35
+ limit?: number;
36
+ }): Promise<IWSSubaccountListItem[]>;
12
37
  /**
13
38
  * Retrieves the health factor for a subaccount.
14
39
  * @param subaccountAddress - The address of the subaccount to query
@@ -148,4 +173,71 @@ export declare class AugustSubAccounts extends AugustBase {
148
173
  netAccountValue: number;
149
174
  totalEquityValue: number;
150
175
  }>;
176
+ /**
177
+ * Retrieves a subaccount's on-chain transaction history, newest first,
178
+ * optionally windowed by a time range.
179
+ *
180
+ * Backed by the authenticated `GET /transactions/v2` backend endpoint,
181
+ * which resolves and authorizes the subaccount, so the configured August
182
+ * API key must be authorized for it (an admin-scoped key always is). Makes
183
+ * exactly one HTTP request and no RPC calls.
184
+ *
185
+ * @param subaccountAddress - The address of the subaccount to query
186
+ * @param options - Optional time window
187
+ * @param options.startTime - ISO-8601 datetime lower bound (inclusive); omit for no lower bound
188
+ * @param options.endTime - ISO-8601 datetime upper bound (inclusive); omit for no upper bound
189
+ * @returns The subaccount's transactions with decoded logs, transfers, and function names
190
+ * @throws AugustValidationError When `subaccountAddress` is not a valid EVM address
191
+ * @throws AugustAuthError When the API key is missing or not authorized for the subaccount
192
+ * @throws AugustServerError When the API responds with a non-2xx status
193
+ * @example
194
+ * const txs = await augustSdk.subAccountsModule.getSubaccountTransactions(
195
+ * '0xabc…',
196
+ * { startTime: '2026-01-01T00:00:00Z' },
197
+ * );
198
+ */
199
+ getSubaccountTransactions(subaccountAddress: IAddress, options?: {
200
+ startTime?: string;
201
+ endTime?: string;
202
+ }): Promise<ISubaccountTransaction[]>;
203
+ /**
204
+ * Retrieves the full loan-book detail for a single loan by its address and
205
+ * chain.
206
+ *
207
+ * Backed by the admin-only `GET /subaccount/loans/{loan_address}` backend
208
+ * endpoint (60-second server-side cache), so the configured August API key
209
+ * must belong to an admin user. Makes exactly one HTTP request and no RPC
210
+ * calls.
211
+ *
212
+ * @param loanAddress - The loan contract address
213
+ * @param chainId - Numeric August chain id the loan lives on (e.g. `1` for Ethereum mainnet)
214
+ * @returns The loan's {@link ILoanBookInfo} detail
215
+ * @throws AugustValidationError When `chainId` is not an integer
216
+ * @throws AugustAuthError When the API key is missing or not admin-scoped
217
+ * @throws AugustServerError When the loan or chain is not found, or the API otherwise responds non-2xx
218
+ * @example
219
+ * const loan = await augustSdk.subAccountsModule.getSubaccountLoanByAddress(
220
+ * '0xloan…',
221
+ * 1,
222
+ * );
223
+ */
224
+ getSubaccountLoanByAddress(loanAddress: string, chainId: number): Promise<ILoanBookInfo>;
225
+ /**
226
+ * Retrieves cross-chain DeBank protocol positions and token balances for a
227
+ * subaccount and its associated strategies.
228
+ *
229
+ * Backed by `GET /subaccount/{subaccount_address}/debank` (300-second
230
+ * server-side cache). This is a slow endpoint — it fans out to DeBank
231
+ * across every supported chain — so expect higher latency than other
232
+ * subaccount reads. Makes exactly one HTTP request and no RPC calls.
233
+ *
234
+ * @param subaccountAddress - The address of the subaccount to query
235
+ * @returns The subaccount's DeBank positions/tokens plus per-strategy breakdowns
236
+ * @throws AugustValidationError When `subaccountAddress` is not a valid EVM address
237
+ * @throws AugustServerError When the API responds with a non-2xx status
238
+ * @example
239
+ * const debank = await augustSdk.subAccountsModule.getSubaccountDebank('0xabc…');
240
+ * console.log(debank.subaccount.positions.length);
241
+ */
242
+ getSubaccountDebank(subaccountAddress: IAddress): Promise<ISubaccountDebank>;
151
243
  }
@@ -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