@augustdigital/sdk 8.8.0 → 8.10.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.
- package/lib/core/analytics/method-taxonomy.js +16 -0
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/constants/core.d.ts +32 -0
- package/lib/core/constants/core.js +72 -0
- package/lib/core/constants/vaults.d.ts +5 -0
- package/lib/core/constants/vaults.js +7 -0
- package/lib/core/helpers/chain-error.d.ts +1 -0
- package/lib/core/helpers/chain-error.js +96 -0
- package/lib/main.js +1 -1
- package/lib/modules/api/fetcher.d.ts +82 -0
- package/lib/modules/api/fetcher.js +150 -0
- package/lib/modules/api/main.d.ts +263 -2
- package/lib/modules/api/main.js +353 -4
- package/lib/modules/sub-accounts/fetcher.d.ts +28 -1
- package/lib/modules/sub-accounts/fetcher.js +51 -1
- package/lib/modules/sub-accounts/main.d.ts +93 -1
- package/lib/modules/sub-accounts/main.js +123 -0
- package/lib/modules/vaults/write.actions.js +76 -6
- package/lib/sdk.d.ts +759 -1
- package/lib/types/api.d.ts +280 -0
- package/lib/types/api.js +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/sub-accounts.d.ts +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { IAddress } from './web3';
|
|
2
|
+
/**
|
|
3
|
+
* A whitelisted token as embedded in loan-book records by the backend
|
|
4
|
+
* `WhitelistedTokenModel` schema. `chain` is the numeric August chain id
|
|
5
|
+
* (backend `Chain` IntEnum value, e.g. `1` for Ethereum mainnet).
|
|
6
|
+
*/
|
|
7
|
+
export interface IWhitelistedToken {
|
|
8
|
+
chain: number;
|
|
9
|
+
name: string;
|
|
10
|
+
token_type: string;
|
|
11
|
+
address: IAddress;
|
|
12
|
+
decimals: number;
|
|
13
|
+
symbol: string;
|
|
14
|
+
discount_factor: number;
|
|
15
|
+
img_url: string | null;
|
|
16
|
+
price: number | null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The amount and due date of a loan's next scheduled payment, as serialized
|
|
20
|
+
* by the backend `UpcomingPayment` schema. `due_date` is an ISO-8601 datetime
|
|
21
|
+
* string.
|
|
22
|
+
*/
|
|
23
|
+
export interface ILoanUpcomingPayment {
|
|
24
|
+
amount: number;
|
|
25
|
+
due_date: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One loan-book entry from the admin loan-book endpoints (backend
|
|
29
|
+
* `LoanBookInfo` schema). Amounts are decimal-adjusted floats; monetary
|
|
30
|
+
* fields are denominated in the loan's principal token. `deployed_date` is an
|
|
31
|
+
* ISO-8601 datetime string; `state` is the backend `LoanStateStr` value
|
|
32
|
+
* (e.g. `"ACTIVE"`).
|
|
33
|
+
*/
|
|
34
|
+
export interface ILoanBookInfo {
|
|
35
|
+
address: IAddress;
|
|
36
|
+
lender: IAddress;
|
|
37
|
+
borrower: IAddress;
|
|
38
|
+
state: string;
|
|
39
|
+
total_repaid: number;
|
|
40
|
+
principal_token: IWhitelistedToken;
|
|
41
|
+
principal_amount: number;
|
|
42
|
+
interest_amount: number;
|
|
43
|
+
upcoming_payment: ILoanUpcomingPayment;
|
|
44
|
+
apr: number;
|
|
45
|
+
initial_principal_amount: number;
|
|
46
|
+
deployed_date: string;
|
|
47
|
+
payment_interval: number;
|
|
48
|
+
total_interest_payment_fees: number;
|
|
49
|
+
lender_apr: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A token's discount-factor ladder from `GET /risk/discount_factors`
|
|
53
|
+
* (backend `DiscountFactorRead` schema). `steps` are ascending notional
|
|
54
|
+
* thresholds (in the token's smallest unit) and `factors` the corresponding
|
|
55
|
+
* ascending haircut multipliers in `[0, 1]`; the two arrays are equal length.
|
|
56
|
+
* `chain` is the numeric August chain id.
|
|
57
|
+
*/
|
|
58
|
+
export interface IDiscountFactorLadder {
|
|
59
|
+
steps: number[] | null;
|
|
60
|
+
factors: number[] | null;
|
|
61
|
+
address: IAddress;
|
|
62
|
+
chain: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Result of `GET /risk/collateral_excess_or_deficit` (backend
|
|
66
|
+
* `CollateralExcessOrDeficit` schema). A positive value is excess collateral
|
|
67
|
+
* that could be withdrawn; a negative value is the shortfall that must be
|
|
68
|
+
* deposited to reach the target health factor.
|
|
69
|
+
*/
|
|
70
|
+
export interface ICollateralExcessOrDeficit {
|
|
71
|
+
amount_usd: number;
|
|
72
|
+
amount_token: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Request body for `POST /risk/collateral_simulation` (backend
|
|
76
|
+
* `CollateralSimulation` schema). Chain fields are numeric August chain ids.
|
|
77
|
+
* `collateral_tokens` is a list of `[chain, address]` pairs and
|
|
78
|
+
* `collateral_token_allocation` the matching per-token weights (normalized
|
|
79
|
+
* server-side, so relative magnitudes are what matter). When `on_platform`
|
|
80
|
+
* is `true`, both `loan_redeployed_token_*` fields are required by the
|
|
81
|
+
* backend.
|
|
82
|
+
*/
|
|
83
|
+
export interface ICollateralSimulationInput {
|
|
84
|
+
loan_token_chain: number;
|
|
85
|
+
loan_token_address: IAddress;
|
|
86
|
+
loan_amount: number;
|
|
87
|
+
on_platform?: boolean;
|
|
88
|
+
loan_redeployed_token_chain?: number | null;
|
|
89
|
+
loan_redeployed_token_address?: IAddress | null;
|
|
90
|
+
collateral_tokens: [number, IAddress][];
|
|
91
|
+
collateral_token_allocation: number[];
|
|
92
|
+
target_health_factor?: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Per-collateral-token breakdown within a collateral simulation (backend
|
|
96
|
+
* `CollateralDetailsResult` schema). `chain` is the numeric August chain id.
|
|
97
|
+
*/
|
|
98
|
+
export interface ICollateralDetailsResult {
|
|
99
|
+
chain: number;
|
|
100
|
+
token_address: IAddress;
|
|
101
|
+
price: number;
|
|
102
|
+
allocation: number;
|
|
103
|
+
collateral_value_from_redeployed_loan_usd: number;
|
|
104
|
+
collateral_value_usd: number;
|
|
105
|
+
amount_usd: number;
|
|
106
|
+
amount_token: number;
|
|
107
|
+
effective_discount_factor: number;
|
|
108
|
+
is_top_up: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Result of `POST /risk/collateral_simulation` (backend
|
|
112
|
+
* `CollateralSimulationResults` schema). `collateral_details` is keyed by
|
|
113
|
+
* `"<symbol>_<chainName>"`.
|
|
114
|
+
*/
|
|
115
|
+
export interface ICollateralSimulationResults {
|
|
116
|
+
total_debt_usd: number;
|
|
117
|
+
total_required_collateral_usd: number;
|
|
118
|
+
total_collateral_value_from_redeployed_loan_usd: number;
|
|
119
|
+
health_factor: number;
|
|
120
|
+
collateral_details: Record<string, ICollateralDetailsResult>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Result of the public `GET /revert_reason` endpoint (backend `RevertResponse`
|
|
124
|
+
* schema) — the decoded failure reasons for a reverted transaction, collected
|
|
125
|
+
* from a `debug_traceTransaction` call tree. All three arrays are empty when
|
|
126
|
+
* no matching signal was found in the trace.
|
|
127
|
+
*/
|
|
128
|
+
export interface IRevertReason {
|
|
129
|
+
error_messages: string[];
|
|
130
|
+
revert_reasons: string[];
|
|
131
|
+
universal_subaccount_errors: string[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* One transaction record from `GET /transactions/v2` (backend
|
|
135
|
+
* `TransactionAPIRead` schema). `chain` is the numeric August chain id;
|
|
136
|
+
* `value` is decimal-adjusted; `timestamp` is a Unix epoch (seconds).
|
|
137
|
+
* `from_` mirrors the backend field name (`from` is reserved). Nested
|
|
138
|
+
* `logs` / `transfers` / `function_signature` / `otc_cashflow` are passed
|
|
139
|
+
* through as-is. `transaction_name` is the resolved function name (or the raw
|
|
140
|
+
* selector when unknown).
|
|
141
|
+
*/
|
|
142
|
+
export interface ISubaccountTransaction {
|
|
143
|
+
id: string;
|
|
144
|
+
tx_hash: string;
|
|
145
|
+
chain: number;
|
|
146
|
+
from_: IAddress;
|
|
147
|
+
to: IAddress;
|
|
148
|
+
value: number;
|
|
149
|
+
block_number: number;
|
|
150
|
+
timestamp: number;
|
|
151
|
+
selector: string | null;
|
|
152
|
+
logs: unknown[];
|
|
153
|
+
transfers: unknown[];
|
|
154
|
+
function_signature: Record<string, unknown> | null;
|
|
155
|
+
otc_cashflow: Record<string, unknown> | null;
|
|
156
|
+
transaction_name: string | null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* DeBank positions and tokens for a single account (backend
|
|
160
|
+
* `DebankAccountData` schema). `positions`, `app_positions`, and `tokens`
|
|
161
|
+
* are passed through as raw DeBank objects.
|
|
162
|
+
*/
|
|
163
|
+
export interface ISubaccountDebankData {
|
|
164
|
+
positions: unknown[];
|
|
165
|
+
app_positions: unknown[];
|
|
166
|
+
tokens: unknown[];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Cross-chain DeBank protocol positions for a subaccount and its associated
|
|
170
|
+
* strategies (backend `SubaccountDebankAccountData` schema). `strategies` is
|
|
171
|
+
* keyed by strategy address. This endpoint is slow (300-second server-side
|
|
172
|
+
* cache) as it fans out across every supported chain.
|
|
173
|
+
*/
|
|
174
|
+
export interface ISubaccountDebank {
|
|
175
|
+
subaccount: ISubaccountDebankData;
|
|
176
|
+
strategies: Record<string, ISubaccountDebankData>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* A tracked position from `GET /otc/position` (backend `IPositionRead`
|
|
180
|
+
* schema). `configs` is a free-form JSON object of position-specific
|
|
181
|
+
* settings; `category` is the position category (e.g. `"otc"`).
|
|
182
|
+
*/
|
|
183
|
+
export interface IOtcPositionRead {
|
|
184
|
+
id: string;
|
|
185
|
+
slug: string;
|
|
186
|
+
position_class: string | null;
|
|
187
|
+
configs: Record<string, unknown> | null;
|
|
188
|
+
category: string | null;
|
|
189
|
+
position_discount_factor: number | null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* An OTC margin requirement from `GET /otc/margin_requirement` (backend
|
|
193
|
+
* `IOTCMarginRequirementRead` schema) — the margin the `payer` must post to
|
|
194
|
+
* the given counterparty.
|
|
195
|
+
*/
|
|
196
|
+
export interface IOtcMarginRequirement {
|
|
197
|
+
otc_counter_party_id: string;
|
|
198
|
+
margin_requirement: number;
|
|
199
|
+
payer: IAddress;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* On-chain whitelist status of one subaccount linked to a vault, from
|
|
203
|
+
* `GET /curator/vaults/{vault_address}/whitelist` (backend
|
|
204
|
+
* `WhitelistStatusResponse` schema). EVM vaults only.
|
|
205
|
+
*/
|
|
206
|
+
export interface ICuratorWhitelistStatus {
|
|
207
|
+
address: IAddress;
|
|
208
|
+
is_whitelisted: boolean;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* One timelock request from `GET /timelock-requests` (backend
|
|
212
|
+
* `ITimelockRequestRead` schema). `chain_id` is the numeric chain id;
|
|
213
|
+
* `status` is one of `"scheduled" | "executed" | "cancelled"`; `params` is a
|
|
214
|
+
* free-form JSON object; datetime fields are ISO-8601 strings.
|
|
215
|
+
*/
|
|
216
|
+
export interface ITimelockRequest {
|
|
217
|
+
id: string;
|
|
218
|
+
hash: string;
|
|
219
|
+
vault_address: IAddress;
|
|
220
|
+
timelock_address: IAddress;
|
|
221
|
+
chain_id: number;
|
|
222
|
+
action_id: string;
|
|
223
|
+
params: Record<string, unknown>;
|
|
224
|
+
status: string;
|
|
225
|
+
schedule_tx_hash: string;
|
|
226
|
+
execute_tx_hash: string | null;
|
|
227
|
+
cancel_tx_hash: string | null;
|
|
228
|
+
submitted_by: string | null;
|
|
229
|
+
scheduled_at: string;
|
|
230
|
+
resolved_at: string | null;
|
|
231
|
+
created_at: string | null;
|
|
232
|
+
updated_at: string | null;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Performance-fee computation for a vault from
|
|
236
|
+
* `GET /metrics/vault_performance_fees` (backend `UpshiftVaultPerformanceFees`
|
|
237
|
+
* schema). High/low water marks are share-price levels; `*_datetime` fields
|
|
238
|
+
* are ISO-8601 strings. `calculation_period` is `"YearToDate"` /
|
|
239
|
+
* `"MonthToDate"` (null when a custom date range was supplied).
|
|
240
|
+
*/
|
|
241
|
+
export interface IVaultPerformanceFees {
|
|
242
|
+
previous_water_mark: number;
|
|
243
|
+
previous_water_mark_datetime: string;
|
|
244
|
+
last_water_mark: number;
|
|
245
|
+
last_water_mark_datetime: string;
|
|
246
|
+
is_in_drawdown: boolean;
|
|
247
|
+
asset_symbol: string | null;
|
|
248
|
+
total_pnl_in_asset: number;
|
|
249
|
+
total_perf_fees_asset: number;
|
|
250
|
+
calculation_period: string | null;
|
|
251
|
+
annualized_fees_pct: number;
|
|
252
|
+
underlying_asset_vs_native_perf: number | null;
|
|
253
|
+
native_token_symbol: string | null;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* One row of a vault's NAV-oracle classification table (backend
|
|
257
|
+
* `OracleClassificationRow` schema) — how a single position/token is priced
|
|
258
|
+
* and its USD value.
|
|
259
|
+
*/
|
|
260
|
+
export interface IOracleClassificationRow {
|
|
261
|
+
position: string;
|
|
262
|
+
type: string;
|
|
263
|
+
oracle_source: string;
|
|
264
|
+
usd_value: number;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* A vault's NAV-oracle classification from the public
|
|
268
|
+
* `GET /upshift/oracle_classification/{vault_address}` endpoint (backend
|
|
269
|
+
* `OracleClassificationResponse` schema). `warnings` lists tokens that could
|
|
270
|
+
* not be resolved (`"unresolved:<symbol>"`). `snapshot_at` is an ISO-8601
|
|
271
|
+
* datetime string.
|
|
272
|
+
*/
|
|
273
|
+
export interface IOracleClassification {
|
|
274
|
+
vault_address: IAddress;
|
|
275
|
+
chain_id: number;
|
|
276
|
+
snapshot_at: string;
|
|
277
|
+
methodology: string;
|
|
278
|
+
rows: IOracleClassificationRow[];
|
|
279
|
+
warnings: string[];
|
|
280
|
+
}
|
package/lib/types/api.js
ADDED
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -24,4 +24,5 @@ __exportStar(require("./subgraph"), exports);
|
|
|
24
24
|
__exportStar(require("./vaults"), exports);
|
|
25
25
|
__exportStar(require("./points"), exports);
|
|
26
26
|
__exportStar(require("./sub-accounts"), exports);
|
|
27
|
+
__exportStar(require("./api"), exports);
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
import type { IAddress } from './web3';
|
|
2
|
+
/**
|
|
3
|
+
* Chain record attached to a subaccount directory entry, as serialized by the
|
|
4
|
+
* backend `IChainRead` schema.
|
|
5
|
+
*/
|
|
6
|
+
export interface IWSSubaccountListChain {
|
|
7
|
+
id: string;
|
|
8
|
+
chain_id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* One subaccount record from the admin-only `GET /subaccount` directory
|
|
13
|
+
* endpoint (backend `ISubaccountRead` schema). Nullable fields are optional
|
|
14
|
+
* metadata the operations team may not have filled in.
|
|
15
|
+
*/
|
|
16
|
+
export interface IWSSubaccountListItem {
|
|
17
|
+
id: string;
|
|
18
|
+
user_id: string | null;
|
|
19
|
+
internal_name: string;
|
|
20
|
+
friendly_name: string | null;
|
|
21
|
+
address: IAddress;
|
|
22
|
+
status: string | null;
|
|
23
|
+
subaccount_type: string | null;
|
|
24
|
+
min_health_factor: number | null;
|
|
25
|
+
estimated_apr: number | null;
|
|
26
|
+
notes: string | null;
|
|
27
|
+
proxy_salt: string | null;
|
|
28
|
+
admin_salt: string | null;
|
|
29
|
+
disable_discount_factor: boolean | null;
|
|
30
|
+
turnkey_address: IAddress | null;
|
|
31
|
+
autopay_frequency: string | null;
|
|
32
|
+
implementation: string | null;
|
|
33
|
+
variant: string | null;
|
|
34
|
+
default_fee_rate_in_bips: number | null;
|
|
35
|
+
wallet_role: string | null;
|
|
36
|
+
chains: IWSSubaccountListChain[];
|
|
37
|
+
}
|
|
2
38
|
export interface IWSSubAccountHealthFactor {
|
|
3
39
|
id: IAddress;
|
|
4
40
|
datetime: string;
|