@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.
- 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/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/sdk.d.ts +757 -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
|
@@ -24,6 +24,18 @@ exports.METHOD_CATEGORIES = {
|
|
|
24
24
|
getVaultPnl: 'read.vault',
|
|
25
25
|
getVaultUnrealizedPnlHistory: 'read.vault',
|
|
26
26
|
getLatestUnrealizedPnl: 'read.vault',
|
|
27
|
+
getDashboardLoans: 'read.vault',
|
|
28
|
+
getDiscountFactors: 'read.vault',
|
|
29
|
+
getCollateralExcessOrDeficit: 'read.vault',
|
|
30
|
+
simulateCollateral: 'read.vault',
|
|
31
|
+
getRevertReason: 'read.vault',
|
|
32
|
+
getOtcPositions: 'read.vault',
|
|
33
|
+
getOtcMarginRequirements: 'read.vault',
|
|
34
|
+
getCuratorVaultSubaccounts: 'read.vault',
|
|
35
|
+
getCuratorVaultWhitelist: 'read.vault',
|
|
36
|
+
getTimelockRequests: 'read.vault',
|
|
37
|
+
getVaultPerformanceFees: 'read.vault',
|
|
38
|
+
getVaultOracleClassification: 'read.vault',
|
|
27
39
|
getVaultBorrowerHealthFactor: 'read.vault',
|
|
28
40
|
getYieldLastRealizedOn: 'read.vault',
|
|
29
41
|
getVaultActivity: 'read.vault',
|
|
@@ -42,11 +54,15 @@ exports.METHOD_CATEGORIES = {
|
|
|
42
54
|
getPrice: 'read.price',
|
|
43
55
|
getUserPoints: 'read.points',
|
|
44
56
|
fetchPointsLeaderboard: 'read.points',
|
|
57
|
+
getAllSubaccounts: 'read.subaccount',
|
|
45
58
|
getSubaccountHealthFactor: 'read.subaccount',
|
|
46
59
|
getSubaccountLoans: 'read.subaccount',
|
|
47
60
|
getSubaccountCefiPositions: 'read.subaccount',
|
|
48
61
|
getSubaccountOtcPositions: 'read.subaccount',
|
|
49
62
|
getSubaccountSummary: 'read.subaccount',
|
|
63
|
+
getSubaccountTransactions: 'read.subaccount',
|
|
64
|
+
getSubaccountLoanByAddress: 'read.subaccount',
|
|
65
|
+
getSubaccountDebank: 'read.subaccount',
|
|
50
66
|
getStakingPositions: 'read.staking',
|
|
51
67
|
getVaultStakingPositions: 'read.staking',
|
|
52
68
|
getLayerZeroDeposits: 'read.layerzero',
|
|
@@ -30,6 +30,7 @@ export declare const WEBSERVER_ENDPOINTS: {
|
|
|
30
30
|
refresh: string;
|
|
31
31
|
};
|
|
32
32
|
subaccount: {
|
|
33
|
+
list: (offset?: number, limit?: number) => string;
|
|
33
34
|
rewards: (subaccount: IAddress) => string;
|
|
34
35
|
tokens: (subaccount: IAddress) => string;
|
|
35
36
|
twap: {
|
|
@@ -44,14 +45,43 @@ export declare const WEBSERVER_ENDPOINTS: {
|
|
|
44
45
|
loans: (subaccount: IAddress, side?: "BORROWER" | "LENDER" | "BOTH", active?: boolean) => string;
|
|
45
46
|
cefi: (subaccount: IAddress) => string;
|
|
46
47
|
otc_positions: (subaccount: IAddress) => string;
|
|
48
|
+
loanByAddress: (loanAddress: string, chainId: number) => string;
|
|
47
49
|
_: (subaccount: IAddress) => string;
|
|
48
50
|
};
|
|
51
|
+
transactions: {
|
|
52
|
+
v2: (subaccount: string, startTime?: string, endTime?: string) => string;
|
|
53
|
+
};
|
|
54
|
+
otc: {
|
|
55
|
+
positions: string;
|
|
56
|
+
marginRequirements: (otcCounterpartyId?: string, payer?: string) => string;
|
|
57
|
+
};
|
|
58
|
+
curator: {
|
|
59
|
+
vaultSubaccounts: (vaultAddress: string) => string;
|
|
60
|
+
vaultWhitelist: (vaultAddress: string) => string;
|
|
61
|
+
};
|
|
62
|
+
timelockRequests: (vaultAddress: string, chainId: number, status?: string) => string;
|
|
49
63
|
users: {
|
|
50
64
|
get: string;
|
|
51
65
|
};
|
|
66
|
+
dashboard: {
|
|
67
|
+
loans: string;
|
|
68
|
+
};
|
|
69
|
+
risk: {
|
|
70
|
+
discountFactors: string;
|
|
71
|
+
collateralExcessOrDeficit: (subaccount: string, tokenAddress: string, tokenChain: number, targetHealthFactor?: number) => string;
|
|
72
|
+
collateralSimulation: string;
|
|
73
|
+
};
|
|
52
74
|
prices: (symbol: string) => string;
|
|
53
75
|
metrics: {
|
|
54
76
|
pnl: (subaccount: IAddress, startTime?: string, endTime?: string) => string;
|
|
77
|
+
vaultPerformanceFees: (params: {
|
|
78
|
+
vaultAddress: string;
|
|
79
|
+
annualizedFeesPct: number;
|
|
80
|
+
nativeDenominated: boolean;
|
|
81
|
+
calculationPeriod: string;
|
|
82
|
+
startDate?: string;
|
|
83
|
+
endDate?: string;
|
|
84
|
+
}) => string;
|
|
55
85
|
};
|
|
56
86
|
public: {
|
|
57
87
|
integrations: {
|
|
@@ -85,6 +115,8 @@ export declare const WEBSERVER_ENDPOINTS: {
|
|
|
85
115
|
unrealizedHistory: (vaultAddress: VaultAddress, limit?: number) => string;
|
|
86
116
|
unrealizedLatest: string;
|
|
87
117
|
};
|
|
118
|
+
revertReason: (txHash: string, chain: number) => string;
|
|
119
|
+
oracleClassification: (vaultAddress: string, chainId: number) => string;
|
|
88
120
|
};
|
|
89
121
|
upshift: {
|
|
90
122
|
vaults: {
|
|
@@ -33,6 +33,7 @@ exports.WEBSERVER_ENDPOINTS = {
|
|
|
33
33
|
refresh: '/auth/refresh',
|
|
34
34
|
},
|
|
35
35
|
subaccount: {
|
|
36
|
+
list: (offset = 0, limit = 100) => `/subaccount?offset=${offset}&limit=${limit}`,
|
|
36
37
|
rewards: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/rewards`,
|
|
37
38
|
tokens: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/tokens`,
|
|
38
39
|
twap: {
|
|
@@ -47,14 +48,80 @@ exports.WEBSERVER_ENDPOINTS = {
|
|
|
47
48
|
loans: (subaccount, side = 'BOTH', active = true) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/loans?side=${side}&active=${active}`,
|
|
48
49
|
cefi: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/cefi_position`,
|
|
49
50
|
otc_positions: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}/otc_positions`,
|
|
51
|
+
loanByAddress: (loanAddress, chainId) => `/subaccount/loans/${encodeURIComponent(loanAddress)}?chain_id=${chainId}`,
|
|
50
52
|
_: (subaccount) => `/subaccount/${(0, ethers_1.getAddress)(subaccount)}`,
|
|
51
53
|
},
|
|
54
|
+
transactions: {
|
|
55
|
+
v2: (subaccount, startTime, endTime) => {
|
|
56
|
+
const params = new URLSearchParams({ address: subaccount });
|
|
57
|
+
if (startTime !== undefined)
|
|
58
|
+
params.set('start_time', startTime);
|
|
59
|
+
if (endTime !== undefined)
|
|
60
|
+
params.set('end_time', endTime);
|
|
61
|
+
return `/transactions/v2?${params.toString()}`;
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
otc: {
|
|
65
|
+
positions: '/otc/position',
|
|
66
|
+
marginRequirements: (otcCounterpartyId, payer) => {
|
|
67
|
+
const params = new URLSearchParams();
|
|
68
|
+
if (otcCounterpartyId !== undefined)
|
|
69
|
+
params.set('otc_counter_party_id', otcCounterpartyId);
|
|
70
|
+
if (payer !== undefined)
|
|
71
|
+
params.set('payer', payer);
|
|
72
|
+
const query = params.toString();
|
|
73
|
+
return `/otc/margin_requirement${query ? `?${query}` : ''}`;
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
curator: {
|
|
77
|
+
vaultSubaccounts: (vaultAddress) => `/curator/vaults/${encodeURIComponent(vaultAddress)}/subaccounts`,
|
|
78
|
+
vaultWhitelist: (vaultAddress) => `/curator/vaults/${encodeURIComponent(vaultAddress)}/whitelist`,
|
|
79
|
+
},
|
|
80
|
+
timelockRequests: (vaultAddress, chainId, status) => {
|
|
81
|
+
const params = new URLSearchParams({
|
|
82
|
+
vaultAddress,
|
|
83
|
+
chainId: String(chainId),
|
|
84
|
+
});
|
|
85
|
+
if (status !== undefined)
|
|
86
|
+
params.set('status', status);
|
|
87
|
+
return `/timelock-requests?${params.toString()}`;
|
|
88
|
+
},
|
|
52
89
|
users: {
|
|
53
90
|
get: '/users',
|
|
54
91
|
},
|
|
92
|
+
dashboard: {
|
|
93
|
+
loans: '/dashboard/loans',
|
|
94
|
+
},
|
|
95
|
+
risk: {
|
|
96
|
+
discountFactors: '/risk/discount_factors',
|
|
97
|
+
collateralExcessOrDeficit: (subaccount, tokenAddress, tokenChain, targetHealthFactor) => {
|
|
98
|
+
const params = new URLSearchParams({
|
|
99
|
+
address: subaccount,
|
|
100
|
+
token_address: tokenAddress,
|
|
101
|
+
token_chain: String(tokenChain),
|
|
102
|
+
});
|
|
103
|
+
if (targetHealthFactor !== undefined)
|
|
104
|
+
params.set('target_health_factor', String(targetHealthFactor));
|
|
105
|
+
return `/risk/collateral_excess_or_deficit?${params.toString()}`;
|
|
106
|
+
},
|
|
107
|
+
collateralSimulation: '/risk/collateral_simulation',
|
|
108
|
+
},
|
|
55
109
|
prices: (symbol) => `/prices/${symbol}`,
|
|
56
110
|
metrics: {
|
|
57
111
|
pnl: (subaccount, startTime, endTime) => `/metrics/pnl?subaccount_address=${(0, ethers_1.getAddress)(subaccount)}${startTime && endTime ? `&start=${startTime}&end=${endTime}` : ''}`,
|
|
112
|
+
vaultPerformanceFees: (params) => {
|
|
113
|
+
const q = new URLSearchParams({
|
|
114
|
+
vault_address: params.vaultAddress,
|
|
115
|
+
annualized_fees_pct: String(params.annualizedFeesPct),
|
|
116
|
+
native_denominated: String(params.nativeDenominated),
|
|
117
|
+
calculation_period: params.calculationPeriod,
|
|
118
|
+
});
|
|
119
|
+
if (params.startDate !== undefined)
|
|
120
|
+
q.set('start_date', params.startDate);
|
|
121
|
+
if (params.endDate !== undefined)
|
|
122
|
+
q.set('end_date', params.endDate);
|
|
123
|
+
return `/metrics/vault_performance_fees?${q.toString()}`;
|
|
124
|
+
},
|
|
58
125
|
},
|
|
59
126
|
public: {
|
|
60
127
|
integrations: {
|
|
@@ -92,6 +159,11 @@ exports.WEBSERVER_ENDPOINTS = {
|
|
|
92
159
|
unrealizedHistory: (vaultAddress, limit) => `/upshift/unrealized_pnl?vault_address=${vaultAddress}${limit !== undefined ? `&limit=${limit}` : ''}`,
|
|
93
160
|
unrealizedLatest: '/upshift/unrealized_pnl/latest',
|
|
94
161
|
},
|
|
162
|
+
revertReason: (txHash, chain) => `/revert_reason?${new URLSearchParams({
|
|
163
|
+
tx_hash: txHash,
|
|
164
|
+
chain: String(chain),
|
|
165
|
+
}).toString()}`,
|
|
166
|
+
oracleClassification: (vaultAddress, chainId) => `/upshift/oracle_classification/${encodeURIComponent(vaultAddress)}?chain_id=${chainId}`,
|
|
95
167
|
},
|
|
96
168
|
upshift: {
|
|
97
169
|
vaults: {
|
|
@@ -20,6 +20,11 @@ export declare const VAULT_ALLOCATION_SUBACCOUNTS: {
|
|
|
20
20
|
subaccount: IAddress;
|
|
21
21
|
useDebank: boolean;
|
|
22
22
|
};
|
|
23
|
+
MonarqXRP: {
|
|
24
|
+
address: IAddress;
|
|
25
|
+
subaccount: IAddress;
|
|
26
|
+
useDebank: boolean;
|
|
27
|
+
};
|
|
23
28
|
};
|
|
24
29
|
/**
|
|
25
30
|
* @deprecated use the backend responses /tokenized_vault internal_type field to determine if the vault is an old lending pool
|
|
@@ -26,6 +26,13 @@ exports.VAULT_ALLOCATION_SUBACCOUNTS = {
|
|
|
26
26
|
subaccount: (0, ethers_1.getAddress)('0xC8c0Ffb8Ff3BDA26321224e800B3B38AEaB48799'),
|
|
27
27
|
useDebank: true,
|
|
28
28
|
},
|
|
29
|
+
// For the Monarq XRP Yield Vault (Flare), surface the borrower subaccount and
|
|
30
|
+
// keep vault-level Debank exposure (mirrors earnAUSD).
|
|
31
|
+
MonarqXRP: {
|
|
32
|
+
address: (0, ethers_1.getAddress)('0x2439D4bb753A0f3777d4C9011AFacc475ba6B951'),
|
|
33
|
+
subaccount: (0, ethers_1.getAddress)('0xF755B2244C1C1f20cA03C3Bb472175C9a4E250f2'),
|
|
34
|
+
useDebank: true,
|
|
35
|
+
},
|
|
29
36
|
};
|
|
30
37
|
/**
|
|
31
38
|
* @deprecated use the backend responses /tokenized_vault internal_type field to determine if the vault is an old lending pool
|
package/lib/main.js
CHANGED
|
@@ -111,7 +111,7 @@ class AugustSDK extends core_1.AugustBase {
|
|
|
111
111
|
this.stellar = new stellar_1.default();
|
|
112
112
|
this.vaults = new vaults_1.AugustVaults(baseConfig, this.solana, this.sui);
|
|
113
113
|
this.subaccounts = new sub_accounts_1.AugustSubAccounts(baseConfig);
|
|
114
|
-
this.api = new api_1.AugustApi();
|
|
114
|
+
this.api = new api_1.AugustApi(baseConfig);
|
|
115
115
|
// Instrument all SDK methods for analytics tracking
|
|
116
116
|
(0, analytics_1.instrumentClass)(this, () => this.activeNetwork?.chainId);
|
|
117
117
|
(0, analytics_1.instrumentClass)(this.evm, () => this.activeNetwork?.chainId);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type IFetchAugustOptions } from '../../core';
|
|
2
|
+
import type { ICollateralExcessOrDeficit, ICollateralSimulationInput, ICollateralSimulationResults, ICuratorWhitelistStatus, IDiscountFactorLadder, ILoanBookInfo, IOracleClassification, IOtcMarginRequirement, IOtcPositionRead, IRevertReason, ITimelockRequest, IVaultPerformanceFees, IWSSubaccountListItem } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Fetch the global loan-book aggregate (admin-only `GET /dashboard/loans`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const fetchDashboardLoans: (augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ILoanBookInfo[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetch every token discount-factor ladder (`GET /risk/discount_factors`).
|
|
9
|
+
*/
|
|
10
|
+
export declare const fetchDiscountFactors: (augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IDiscountFactorLadder[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Fetch a subaccount's collateral excess/deficit for one token
|
|
13
|
+
* (`GET /risk/collateral_excess_or_deficit`).
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchCollateralExcessOrDeficit: (params: {
|
|
16
|
+
subaccount: string;
|
|
17
|
+
tokenAddress: string;
|
|
18
|
+
tokenChain: number;
|
|
19
|
+
targetHealthFactor?: number;
|
|
20
|
+
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ICollateralExcessOrDeficit>;
|
|
21
|
+
/**
|
|
22
|
+
* Run a collateral simulation (`POST /risk/collateral_simulation`). This is a
|
|
23
|
+
* pure, read-only simulation — the backend computes required collateral for a
|
|
24
|
+
* hypothetical loan and changes no state.
|
|
25
|
+
*/
|
|
26
|
+
export declare const fetchCollateralSimulation: (body: ICollateralSimulationInput, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ICollateralSimulationResults>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch the decoded revert reason(s) for a transaction from the public
|
|
29
|
+
* `GET /revert_reason` endpoint. No API key required.
|
|
30
|
+
*/
|
|
31
|
+
export declare const fetchRevertReason: (txHash: string, chain: number, headers?: IFetchAugustOptions["headers"]) => Promise<IRevertReason>;
|
|
32
|
+
/**
|
|
33
|
+
* Fetch all OTC positions (admin-only `GET /otc/position`).
|
|
34
|
+
*/
|
|
35
|
+
export declare const fetchOtcPositions: (augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IOtcPositionRead[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch OTC margin requirements (admin-only `GET /otc/margin_requirement`),
|
|
38
|
+
* optionally filtered by counterparty id and/or payer.
|
|
39
|
+
*/
|
|
40
|
+
export declare const fetchOtcMarginRequirements: (filters: {
|
|
41
|
+
otcCounterpartyId?: string;
|
|
42
|
+
payer?: string;
|
|
43
|
+
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IOtcMarginRequirement[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Fetch the subaccounts linked to a vault (curator-or-admin
|
|
46
|
+
* `GET /curator/vaults/{vault_address}/subaccounts`).
|
|
47
|
+
*/
|
|
48
|
+
export declare const fetchCuratorVaultSubaccounts: (vaultAddress: string, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountListItem[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Fetch on-chain whitelist status for a vault's subaccounts (curator-or-admin
|
|
51
|
+
* `GET /curator/vaults/{vault_address}/whitelist`). EVM vaults only — the
|
|
52
|
+
* backend 400s for non-EVM vaults.
|
|
53
|
+
*/
|
|
54
|
+
export declare const fetchCuratorVaultWhitelist: (vaultAddress: string, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ICuratorWhitelistStatus[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Fetch timelock requests for a vault on a chain (`GET /timelock-requests`),
|
|
57
|
+
* optionally filtered by status.
|
|
58
|
+
*/
|
|
59
|
+
export declare const fetchTimelockRequests: (params: {
|
|
60
|
+
vaultAddress: string;
|
|
61
|
+
chainId: number;
|
|
62
|
+
status?: string;
|
|
63
|
+
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ITimelockRequest[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Fetch a vault's performance-fee computation
|
|
66
|
+
* (`GET /metrics/vault_performance_fees`). Slow first call (pandas over full
|
|
67
|
+
* snapshot history); 20-minute server-side cache.
|
|
68
|
+
*/
|
|
69
|
+
export declare const fetchVaultPerformanceFees: (params: {
|
|
70
|
+
vaultAddress: string;
|
|
71
|
+
annualizedFeesPct: number;
|
|
72
|
+
nativeDenominated: boolean;
|
|
73
|
+
calculationPeriod: string;
|
|
74
|
+
startDate?: string;
|
|
75
|
+
endDate?: string;
|
|
76
|
+
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IVaultPerformanceFees>;
|
|
77
|
+
/**
|
|
78
|
+
* Fetch a vault's NAV-oracle classification table from the public
|
|
79
|
+
* `GET /upshift/oracle_classification/{vault_address}` endpoint. No API key
|
|
80
|
+
* required.
|
|
81
|
+
*/
|
|
82
|
+
export declare const fetchVaultOracleClassification: (vaultAddress: string, chainId: number, headers?: IFetchAugustOptions["headers"]) => Promise<IOracleClassification>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchVaultOracleClassification = exports.fetchVaultPerformanceFees = exports.fetchTimelockRequests = exports.fetchCuratorVaultWhitelist = exports.fetchCuratorVaultSubaccounts = exports.fetchOtcMarginRequirements = exports.fetchOtcPositions = exports.fetchRevertReason = exports.fetchCollateralSimulation = exports.fetchCollateralExcessOrDeficit = exports.fetchDiscountFactors = exports.fetchDashboardLoans = void 0;
|
|
4
|
+
const core_1 = require("../../core");
|
|
5
|
+
/**
|
|
6
|
+
* Fetch the global loan-book aggregate (admin-only `GET /dashboard/loans`).
|
|
7
|
+
*/
|
|
8
|
+
const fetchDashboardLoans = async (augustKey, headers) => {
|
|
9
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.dashboard.loans, { headers });
|
|
10
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
11
|
+
throw new Error(`Failed to fetch dashboard loans: ${response.statusText || 'Unknown error'}`);
|
|
12
|
+
}
|
|
13
|
+
return response.json();
|
|
14
|
+
};
|
|
15
|
+
exports.fetchDashboardLoans = fetchDashboardLoans;
|
|
16
|
+
/**
|
|
17
|
+
* Fetch every token discount-factor ladder (`GET /risk/discount_factors`).
|
|
18
|
+
*/
|
|
19
|
+
const fetchDiscountFactors = async (augustKey, headers) => {
|
|
20
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.risk.discountFactors, { headers });
|
|
21
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
22
|
+
throw new Error(`Failed to fetch discount factors: ${response.statusText || 'Unknown error'}`);
|
|
23
|
+
}
|
|
24
|
+
return response.json();
|
|
25
|
+
};
|
|
26
|
+
exports.fetchDiscountFactors = fetchDiscountFactors;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch a subaccount's collateral excess/deficit for one token
|
|
29
|
+
* (`GET /risk/collateral_excess_or_deficit`).
|
|
30
|
+
*/
|
|
31
|
+
const fetchCollateralExcessOrDeficit = async (params, augustKey, headers) => {
|
|
32
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.risk.collateralExcessOrDeficit(params.subaccount, params.tokenAddress, params.tokenChain, params.targetHealthFactor), { headers });
|
|
33
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
34
|
+
throw new Error(`Failed to fetch collateral excess or deficit: ${response.statusText || 'Unknown error'}`);
|
|
35
|
+
}
|
|
36
|
+
return response.json();
|
|
37
|
+
};
|
|
38
|
+
exports.fetchCollateralExcessOrDeficit = fetchCollateralExcessOrDeficit;
|
|
39
|
+
/**
|
|
40
|
+
* Run a collateral simulation (`POST /risk/collateral_simulation`). This is a
|
|
41
|
+
* pure, read-only simulation — the backend computes required collateral for a
|
|
42
|
+
* hypothetical loan and changes no state.
|
|
43
|
+
*/
|
|
44
|
+
const fetchCollateralSimulation = async (body, augustKey, headers) => {
|
|
45
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.risk.collateralSimulation, { method: 'post', data: body, headers });
|
|
46
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
47
|
+
throw new Error(`Failed to run collateral simulation: ${response.statusText || 'Unknown error'}`);
|
|
48
|
+
}
|
|
49
|
+
return response.json();
|
|
50
|
+
};
|
|
51
|
+
exports.fetchCollateralSimulation = fetchCollateralSimulation;
|
|
52
|
+
/**
|
|
53
|
+
* Fetch the decoded revert reason(s) for a transaction from the public
|
|
54
|
+
* `GET /revert_reason` endpoint. No API key required.
|
|
55
|
+
*/
|
|
56
|
+
const fetchRevertReason = async (txHash, chain, headers) => {
|
|
57
|
+
const response = await (0, core_1.fetchAugustPublic)(core_1.WEBSERVER_ENDPOINTS.public.revertReason(txHash, chain), { headers });
|
|
58
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
59
|
+
throw new Error(`Failed to fetch revert reason: ${response.statusText || 'Unknown error'}`);
|
|
60
|
+
}
|
|
61
|
+
return response.json();
|
|
62
|
+
};
|
|
63
|
+
exports.fetchRevertReason = fetchRevertReason;
|
|
64
|
+
/**
|
|
65
|
+
* Fetch all OTC positions (admin-only `GET /otc/position`).
|
|
66
|
+
*/
|
|
67
|
+
const fetchOtcPositions = async (augustKey, headers) => {
|
|
68
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.otc.positions, { headers });
|
|
69
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
70
|
+
throw new Error(`Failed to fetch OTC positions: ${response.statusText || 'Unknown error'}`);
|
|
71
|
+
}
|
|
72
|
+
return response.json();
|
|
73
|
+
};
|
|
74
|
+
exports.fetchOtcPositions = fetchOtcPositions;
|
|
75
|
+
/**
|
|
76
|
+
* Fetch OTC margin requirements (admin-only `GET /otc/margin_requirement`),
|
|
77
|
+
* optionally filtered by counterparty id and/or payer.
|
|
78
|
+
*/
|
|
79
|
+
const fetchOtcMarginRequirements = async (filters, augustKey, headers) => {
|
|
80
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.otc.marginRequirements(filters.otcCounterpartyId, filters.payer), { headers });
|
|
81
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
82
|
+
throw new Error(`Failed to fetch OTC margin requirements: ${response.statusText || 'Unknown error'}`);
|
|
83
|
+
}
|
|
84
|
+
return response.json();
|
|
85
|
+
};
|
|
86
|
+
exports.fetchOtcMarginRequirements = fetchOtcMarginRequirements;
|
|
87
|
+
/**
|
|
88
|
+
* Fetch the subaccounts linked to a vault (curator-or-admin
|
|
89
|
+
* `GET /curator/vaults/{vault_address}/subaccounts`).
|
|
90
|
+
*/
|
|
91
|
+
const fetchCuratorVaultSubaccounts = async (vaultAddress, augustKey, headers) => {
|
|
92
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.curator.vaultSubaccounts(vaultAddress), { headers });
|
|
93
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
94
|
+
throw new Error(`Failed to fetch curator vault subaccounts: ${response.statusText || 'Unknown error'}`);
|
|
95
|
+
}
|
|
96
|
+
return response.json();
|
|
97
|
+
};
|
|
98
|
+
exports.fetchCuratorVaultSubaccounts = fetchCuratorVaultSubaccounts;
|
|
99
|
+
/**
|
|
100
|
+
* Fetch on-chain whitelist status for a vault's subaccounts (curator-or-admin
|
|
101
|
+
* `GET /curator/vaults/{vault_address}/whitelist`). EVM vaults only — the
|
|
102
|
+
* backend 400s for non-EVM vaults.
|
|
103
|
+
*/
|
|
104
|
+
const fetchCuratorVaultWhitelist = async (vaultAddress, augustKey, headers) => {
|
|
105
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.curator.vaultWhitelist(vaultAddress), { headers });
|
|
106
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
107
|
+
throw new Error(`Failed to fetch curator vault whitelist: ${response.statusText || 'Unknown error'}`);
|
|
108
|
+
}
|
|
109
|
+
return response.json();
|
|
110
|
+
};
|
|
111
|
+
exports.fetchCuratorVaultWhitelist = fetchCuratorVaultWhitelist;
|
|
112
|
+
/**
|
|
113
|
+
* Fetch timelock requests for a vault on a chain (`GET /timelock-requests`),
|
|
114
|
+
* optionally filtered by status.
|
|
115
|
+
*/
|
|
116
|
+
const fetchTimelockRequests = async (params, augustKey, headers) => {
|
|
117
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.timelockRequests(params.vaultAddress, params.chainId, params.status), { headers });
|
|
118
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
119
|
+
throw new Error(`Failed to fetch timelock requests: ${response.statusText || 'Unknown error'}`);
|
|
120
|
+
}
|
|
121
|
+
return response.json();
|
|
122
|
+
};
|
|
123
|
+
exports.fetchTimelockRequests = fetchTimelockRequests;
|
|
124
|
+
/**
|
|
125
|
+
* Fetch a vault's performance-fee computation
|
|
126
|
+
* (`GET /metrics/vault_performance_fees`). Slow first call (pandas over full
|
|
127
|
+
* snapshot history); 20-minute server-side cache.
|
|
128
|
+
*/
|
|
129
|
+
const fetchVaultPerformanceFees = async (params, augustKey, headers) => {
|
|
130
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.metrics.vaultPerformanceFees(params), { headers });
|
|
131
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
132
|
+
throw new Error(`Failed to fetch vault performance fees: ${response.statusText || 'Unknown error'}`);
|
|
133
|
+
}
|
|
134
|
+
return response.json();
|
|
135
|
+
};
|
|
136
|
+
exports.fetchVaultPerformanceFees = fetchVaultPerformanceFees;
|
|
137
|
+
/**
|
|
138
|
+
* Fetch a vault's NAV-oracle classification table from the public
|
|
139
|
+
* `GET /upshift/oracle_classification/{vault_address}` endpoint. No API key
|
|
140
|
+
* required.
|
|
141
|
+
*/
|
|
142
|
+
const fetchVaultOracleClassification = async (vaultAddress, chainId, headers) => {
|
|
143
|
+
const response = await (0, core_1.fetchAugustPublic)(core_1.WEBSERVER_ENDPOINTS.public.oracleClassification(vaultAddress, chainId), { headers });
|
|
144
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
145
|
+
throw new Error(`Failed to fetch vault oracle classification: ${response.statusText || 'Unknown error'}`);
|
|
146
|
+
}
|
|
147
|
+
return response.json();
|
|
148
|
+
};
|
|
149
|
+
exports.fetchVaultOracleClassification = fetchVaultOracleClassification;
|
|
150
|
+
//# sourceMappingURL=fetcher.js.map
|