@augustdigital/sdk 7.0.0 → 8.0.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/adapters/stellar/types.d.ts +0 -1
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/base.class.d.ts +0 -1
- package/lib/core/helpers/explorer-link.d.ts +1 -1
- package/lib/core/helpers/explorer-link.js +4 -3
- package/lib/main.d.ts +2 -1
- package/lib/main.js +1 -1
- package/lib/modules/vaults/fetcher.js +2 -2
- package/lib/modules/vaults/getters.d.ts +5 -14
- package/lib/modules/vaults/getters.js +54 -13
- package/lib/modules/vaults/main.d.ts +1 -1
- package/lib/modules/vaults/main.js +3 -1
- package/lib/services/coingecko/fetcher.js +15 -5
- package/lib/services/debank/fetcher.js +6 -3
- package/lib/services/debank/utils.js +7 -6
- package/lib/services/octavfi/fetcher.js +10 -5
- package/lib/services/subgraph/vaults.js +6 -6
- package/lib/types/vaults.d.ts +11 -0
- package/lib/types/web3.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "8.0.0";
|
package/lib/core/base.class.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IAddress, IChainId, IExplorerType } from '../../types';
|
|
2
|
-
export declare const explorerLink: (hex: IAddress, chain: IChainId, type: IExplorerType) => string
|
|
2
|
+
export declare const explorerLink: (hex: IAddress, chain: IChainId, type: IExplorerType) => string;
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.explorerLink = void 0;
|
|
4
4
|
const web3_1 = require("../constants/web3");
|
|
5
5
|
const explorerLink = (hex, chain, type) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const network = chain ? web3_1.NETWORKS[chain] : undefined;
|
|
7
|
+
if (!network)
|
|
8
|
+
return '';
|
|
9
|
+
return `${network.explorer}/${type}/${hex}`;
|
|
9
10
|
};
|
|
10
11
|
exports.explorerLink = explorerLink;
|
|
11
12
|
//# sourceMappingURL=explorer-link.js.map
|
package/lib/main.d.ts
CHANGED
|
@@ -138,7 +138,8 @@ export declare class AugustSDK extends AugustBase {
|
|
|
138
138
|
}): Promise<import("./types").IActiveStakingPosition[]>;
|
|
139
139
|
getVaultBorrowerHealthFactor(props?: {
|
|
140
140
|
chainId?: IChainId;
|
|
141
|
-
|
|
141
|
+
vault?: IAddress;
|
|
142
|
+
}): Promise<Record<string, import("./types").IVaultBorrowerHealthFactor[]> | Record<string, import("./types").IVaultBorrowerHealthFactor[]>[]>;
|
|
142
143
|
getUserPoints(userAddress: IAddress): Promise<any>;
|
|
143
144
|
registerUserForPoints(userAddress: IAddress, referrerAddress: IAddress | undefined, chainId: number, signature: string, nonce: string, expiry: number): Promise<Response>;
|
|
144
145
|
fetchPointsLeaderboard(params?: {
|
package/lib/main.js
CHANGED
|
@@ -170,7 +170,7 @@ class AugustSDK extends core_1.AugustBase {
|
|
|
170
170
|
return await this.vaults.getStakingPositions(props.wallet, props.chainId);
|
|
171
171
|
}
|
|
172
172
|
async getVaultBorrowerHealthFactor(props) {
|
|
173
|
-
return await this.vaults.getVaultBorrowerHealthFactor(props?.chainId);
|
|
173
|
+
return await this.vaults.getVaultBorrowerHealthFactor(props?.chainId, props?.vault);
|
|
174
174
|
}
|
|
175
175
|
async getUserPoints(userAddress) {
|
|
176
176
|
return await this.vaults.getUserPoints(userAddress);
|
|
@@ -54,7 +54,7 @@ async function fetchVaultsBatch(vaults, options = {}) {
|
|
|
54
54
|
maxRetries,
|
|
55
55
|
baseDelay,
|
|
56
56
|
});
|
|
57
|
-
if (result.success
|
|
57
|
+
if (result.success) {
|
|
58
58
|
successful.push({
|
|
59
59
|
index: globalIndex,
|
|
60
60
|
data: result.data,
|
|
@@ -64,7 +64,7 @@ async function fetchVaultsBatch(vaults, options = {}) {
|
|
|
64
64
|
else {
|
|
65
65
|
failed.push({
|
|
66
66
|
index: globalIndex,
|
|
67
|
-
error: result.error
|
|
67
|
+
error: result.error ?? new Error('Unknown failure'),
|
|
68
68
|
address: vault.address,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAddress, IHistoricalTimeseriesResponse, INormalizedNumber, ISubgraphWithdrawProccessed, IVault, IVaultAllocations, IVaultAnnualizedApy, IVaultAvailableRedemption, IVaultLoan, IVaultPosition, IVaultRedemptionHistoryItem, IVaultSummary, IVaultWithdrawals, IVaultPendingRedemptions, IActiveStakingPosition, IVaultHistoricalParams, IVaultUserLifetimePnl, IVaultPnl, VaultAddress } from '../../types';
|
|
1
|
+
import { IAddress, IHistoricalTimeseriesResponse, INormalizedNumber, ISubgraphWithdrawProccessed, IVault, IVaultAllocations, IVaultAnnualizedApy, IVaultAvailableRedemption, IVaultLoan, IVaultPosition, IVaultRedemptionHistoryItem, IVaultSummary, IVaultWithdrawals, IVaultPendingRedemptions, IActiveStakingPosition, IVaultHistoricalParams, IVaultUserLifetimePnl, IVaultBorrowerHealthFactor, IVaultPnl, VaultAddress } from '../../types';
|
|
2
2
|
import { IVaultBaseOptions } from './types';
|
|
3
3
|
export declare function getVault({ vault, loans, allocations, options, loadSubaccounts, loadSnapshots, }: {
|
|
4
4
|
vault: IAddress;
|
|
@@ -60,20 +60,11 @@ export declare function getVaultTvl({ vault, options, historical, }: {
|
|
|
60
60
|
export declare function getVaultBorrowerHealthFactor({ vault, options, }: {
|
|
61
61
|
vault: IAddress;
|
|
62
62
|
options: IVaultBaseOptions;
|
|
63
|
-
}): Promise<
|
|
64
|
-
|
|
65
|
-
loan: IAddress;
|
|
66
|
-
health_factor?: {
|
|
67
|
-
datetime: string;
|
|
68
|
-
health_factor: number;
|
|
69
|
-
id: string;
|
|
70
|
-
total_collateral_value: number;
|
|
71
|
-
total_loan_value: number;
|
|
72
|
-
};
|
|
73
|
-
}[]>;
|
|
74
|
-
export declare function getHealthFactorOfBorrowersByVault({ options, }: {
|
|
63
|
+
}): Promise<IVaultBorrowerHealthFactor[]>;
|
|
64
|
+
export declare function getHealthFactorOfBorrowersByVault({ options, vault, }: {
|
|
75
65
|
options: IVaultBaseOptions;
|
|
76
|
-
|
|
66
|
+
vault?: IAddress;
|
|
67
|
+
}): Promise<Record<string, IVaultBorrowerHealthFactor[]>>;
|
|
77
68
|
export declare function getUserPoints({ userAddress, options, }: {
|
|
78
69
|
userAddress: IAddress;
|
|
79
70
|
options?: IVaultBaseOptions;
|
|
@@ -1281,7 +1281,7 @@ async function getVaultTvl({ vault, options, historical, }) {
|
|
|
1281
1281
|
async function getVaultBorrowerHealthFactor({ vault, options, }) {
|
|
1282
1282
|
const provider = (0, core_1.createProvider)(options.rpcUrl);
|
|
1283
1283
|
const loans = await getVaultLoans(vault, options);
|
|
1284
|
-
const
|
|
1284
|
+
const activeLoanResults = await Promise.allSettled(loans.map(async (l) => {
|
|
1285
1285
|
const loanContract = (0, core_1.createContract)({
|
|
1286
1286
|
provider,
|
|
1287
1287
|
address: l.address,
|
|
@@ -1289,10 +1289,21 @@ async function getVaultBorrowerHealthFactor({ vault, options, }) {
|
|
|
1289
1289
|
});
|
|
1290
1290
|
const loanState = await loanContract.loanState();
|
|
1291
1291
|
if ((0, core_1.loanStateToReadable)(loanState) !== 'ACTIVE')
|
|
1292
|
-
return;
|
|
1292
|
+
return undefined;
|
|
1293
1293
|
return l.address;
|
|
1294
|
-
}))
|
|
1295
|
-
const
|
|
1294
|
+
}));
|
|
1295
|
+
const activeLoans = activeLoanResults
|
|
1296
|
+
.map((r, i) => {
|
|
1297
|
+
if (r.status === 'fulfilled')
|
|
1298
|
+
return r.value;
|
|
1299
|
+
core_1.Logger.log.warn('getVaultBorrowerHealthFactor:loanState', r.reason, {
|
|
1300
|
+
vault,
|
|
1301
|
+
loan: loans[i]?.address,
|
|
1302
|
+
});
|
|
1303
|
+
return undefined;
|
|
1304
|
+
})
|
|
1305
|
+
.filter((l) => l !== undefined);
|
|
1306
|
+
const formattedSettled = await Promise.allSettled(activeLoans.map(async (l) => {
|
|
1296
1307
|
const loanContract = (0, core_1.createContract)({
|
|
1297
1308
|
provider,
|
|
1298
1309
|
address: l,
|
|
@@ -1303,32 +1314,62 @@ async function getVaultBorrowerHealthFactor({ vault, options, }) {
|
|
|
1303
1314
|
loan: l,
|
|
1304
1315
|
};
|
|
1305
1316
|
}));
|
|
1317
|
+
const formattedLoansArray = formattedSettled
|
|
1318
|
+
.map((r, i) => {
|
|
1319
|
+
if (r.status === 'fulfilled')
|
|
1320
|
+
return r.value;
|
|
1321
|
+
core_1.Logger.log.warn('getVaultBorrowerHealthFactor:borrower', r.reason, {
|
|
1322
|
+
vault,
|
|
1323
|
+
loan: activeLoans[i],
|
|
1324
|
+
});
|
|
1325
|
+
return undefined;
|
|
1326
|
+
})
|
|
1327
|
+
.filter((entry) => entry !== undefined);
|
|
1306
1328
|
const uniqueBorrowers = [
|
|
1307
1329
|
...new Set(formattedLoansArray.map((l) => l.borrower)),
|
|
1308
1330
|
];
|
|
1309
1331
|
const borrowerResponses = {};
|
|
1310
1332
|
for (const b of uniqueBorrowers) {
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1333
|
+
try {
|
|
1334
|
+
const response = await (0, core_1.fetchAugustWithKey)(options.augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.health_factor(b));
|
|
1335
|
+
if (response.status === 200) {
|
|
1336
|
+
borrowerResponses[b] = await response.json();
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
catch (err) {
|
|
1340
|
+
core_1.Logger.log.warn('getVaultBorrowerHealthFactor:health_factor', err, {
|
|
1341
|
+
vault,
|
|
1342
|
+
borrower: b,
|
|
1343
|
+
});
|
|
1314
1344
|
}
|
|
1315
1345
|
}
|
|
1316
|
-
formattedLoansArray
|
|
1346
|
+
formattedLoansArray.forEach((loan) => {
|
|
1317
1347
|
loan.health_factor = borrowerResponses[loan.borrower];
|
|
1318
1348
|
});
|
|
1319
1349
|
return formattedLoansArray;
|
|
1320
1350
|
}
|
|
1321
|
-
async function getHealthFactorOfBorrowersByVault({ options, }) {
|
|
1322
|
-
const vaults =
|
|
1323
|
-
|
|
1351
|
+
async function getHealthFactorOfBorrowersByVault({ options, vault, }) {
|
|
1352
|
+
const vaults = vault
|
|
1353
|
+
? ((await (0, core_1.fetchTokenizedVault)(vault, options?.headers)) ?? [])
|
|
1354
|
+
: await (0, core_1.fetchTokenizedVaults)(undefined, options?.headers, false, false);
|
|
1355
|
+
const healthFactorResults = await Promise.allSettled(vaults.map(async (v) => {
|
|
1324
1356
|
return getVaultBorrowerHealthFactor({
|
|
1325
1357
|
vault: v.address,
|
|
1326
1358
|
options,
|
|
1327
1359
|
});
|
|
1328
1360
|
}));
|
|
1329
1361
|
const healthFactorsByPool = {};
|
|
1330
|
-
vaults.
|
|
1331
|
-
|
|
1362
|
+
vaults.forEach((pool, index) => {
|
|
1363
|
+
const result = healthFactorResults[index];
|
|
1364
|
+
const key = pool.address.toLowerCase();
|
|
1365
|
+
if (result?.status === 'fulfilled') {
|
|
1366
|
+
healthFactorsByPool[key] = result.value;
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
core_1.Logger.log.warn('getHealthFactorOfBorrowersByVault:vault', result?.reason, {
|
|
1370
|
+
vault: pool.address,
|
|
1371
|
+
});
|
|
1372
|
+
healthFactorsByPool[key] = [];
|
|
1332
1373
|
});
|
|
1333
1374
|
return healthFactorsByPool;
|
|
1334
1375
|
}
|
|
@@ -125,7 +125,7 @@ export declare class AugustVaults extends AugustBase {
|
|
|
125
125
|
vault: IAddress;
|
|
126
126
|
chainId?: IChainId;
|
|
127
127
|
}): Promise<number>;
|
|
128
|
-
getVaultBorrowerHealthFactor(chainId?: IChainId): Promise<
|
|
128
|
+
getVaultBorrowerHealthFactor(chainId?: IChainId, vault?: IAddress): Promise<Record<string, import("../../types").IVaultBorrowerHealthFactor[]> | Record<string, import("../../types").IVaultBorrowerHealthFactor[]>[]>;
|
|
129
129
|
getUserPoints(userAddress: IAddress): Promise<any>;
|
|
130
130
|
registerUserForPoints(userAddress: IAddress, referrerAddress: IAddress | undefined, chainId: number, signature: string, nonce: string, expiry: number): Promise<Response>;
|
|
131
131
|
fetchPointsLeaderboard(params?: {
|
|
@@ -740,7 +740,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
740
740
|
},
|
|
741
741
|
});
|
|
742
742
|
}
|
|
743
|
-
async getVaultBorrowerHealthFactor(chainId) {
|
|
743
|
+
async getVaultBorrowerHealthFactor(chainId, vault) {
|
|
744
744
|
if (chainId) {
|
|
745
745
|
const health_factors = await (0, getters_1.getHealthFactorOfBorrowersByVault)({
|
|
746
746
|
options: {
|
|
@@ -748,6 +748,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
748
748
|
env: this.monitoring?.env,
|
|
749
749
|
augustKey: this.keys?.august,
|
|
750
750
|
},
|
|
751
|
+
vault,
|
|
751
752
|
});
|
|
752
753
|
return health_factors;
|
|
753
754
|
}
|
|
@@ -763,6 +764,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
763
764
|
subgraphKey: this.keys?.graph,
|
|
764
765
|
headers: this.headers,
|
|
765
766
|
},
|
|
767
|
+
vault,
|
|
766
768
|
});
|
|
767
769
|
}));
|
|
768
770
|
return health_factors.flat();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchTokenPricesFromCoinGecko = fetchTokenPricesFromCoinGecko;
|
|
4
|
+
const logger_1 = require("../../core/logger");
|
|
4
5
|
const utils_1 = require("./utils");
|
|
5
6
|
async function fetchTokenPricesFromCoinGecko(symbol, coinGeckoKey) {
|
|
6
7
|
const coinId = utils_1.COINGECKO_COIN_ID_MAP[symbol.toLowerCase()];
|
|
@@ -19,17 +20,26 @@ async function fetchTokenPricesFromCoinGecko(symbol, coinGeckoKey) {
|
|
|
19
20
|
},
|
|
20
21
|
});
|
|
21
22
|
if (!response.ok) {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
const err = new Error(`CoinGecko API error: ${response.status} ${response.statusText}`);
|
|
24
|
+
logger_1.Logger.log.error('fetchTokenPricesFromCoinGecko', err, {
|
|
25
|
+
status: response.status,
|
|
26
|
+
statusText: response.statusText,
|
|
27
|
+
coinId,
|
|
28
|
+
symbol,
|
|
29
|
+
});
|
|
30
|
+
throw err;
|
|
24
31
|
}
|
|
25
32
|
const data = (await response.json());
|
|
26
|
-
if (data
|
|
27
|
-
return data.prices[data.length - 1][1];
|
|
33
|
+
if (data?.prices?.length) {
|
|
34
|
+
return data.prices[data.prices.length - 1][1];
|
|
28
35
|
}
|
|
29
36
|
return null;
|
|
30
37
|
}
|
|
31
38
|
catch (error) {
|
|
32
|
-
|
|
39
|
+
logger_1.Logger.log.error('fetchTokenPricesFromCoinGecko', error, {
|
|
40
|
+
coinId,
|
|
41
|
+
symbol,
|
|
42
|
+
});
|
|
33
43
|
return null;
|
|
34
44
|
}
|
|
35
45
|
}
|
|
@@ -10,18 +10,21 @@ async function fetchVaultDebankResponse(vaultAddress, headers) {
|
|
|
10
10
|
const data = (await response.json());
|
|
11
11
|
return data;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
core_1.Logger.log.error('fetchVaultDebankResponse', new Error(`HTTP ${response.status} ${response.statusText}`), { status: response.status, statusText: response.statusText });
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
catch (e) {
|
|
17
|
-
|
|
17
|
+
core_1.Logger.log.error('fetchVaultDebankResponse', e);
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
async function fetchDebankResponse(address, headers) {
|
|
22
22
|
const debankResponse = await (0, core_1.fetchAugustWithKey)(undefined, core_1.WEBSERVER_ENDPOINTS.subaccount.debank(address), { override: true, headers: headers });
|
|
23
23
|
if (debankResponse.status !== 200) {
|
|
24
|
-
|
|
24
|
+
core_1.Logger.log.error('fetchDebankResponse', new Error(`HTTP ${debankResponse.status} ${debankResponse.statusText}`), {
|
|
25
|
+
status: debankResponse.status,
|
|
26
|
+
statusText: debankResponse.statusText,
|
|
27
|
+
});
|
|
25
28
|
return false;
|
|
26
29
|
}
|
|
27
30
|
else if (debankResponse.status === 200) {
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseVaultLevelDebank = parseVaultLevelDebank;
|
|
4
4
|
exports.getVaultExposure = getVaultExposure;
|
|
5
5
|
exports.parseLoanLevelDebank = parseLoanLevelDebank;
|
|
6
|
-
const core_1 = require("../../core
|
|
6
|
+
const core_1 = require("../../core");
|
|
7
|
+
const core_2 = require("../../core/helpers/core");
|
|
7
8
|
function addToTokenExposure(token, tokenExposure, exposureType, protocol, exposurePerCategory, netValue, borrower) {
|
|
8
9
|
const usdAmount = Number(token?.price || 0) * Number(token?.amount);
|
|
9
10
|
if (exposureType === 'wallet'
|
|
10
|
-
? !(0,
|
|
11
|
-
: !(0,
|
|
11
|
+
? !(0, core_2.filterOutBySize)(usdAmount)
|
|
12
|
+
: !(0, core_2.filterOutBySize)(usdAmount))
|
|
12
13
|
return;
|
|
13
14
|
if (exposureType === 'borrow') {
|
|
14
15
|
netValue.value -= usdAmount;
|
|
@@ -73,7 +74,7 @@ function parseVaultLevelDebank(debankRes, protocolExposure, tokenExposure, borro
|
|
|
73
74
|
});
|
|
74
75
|
const foundExistingProtocolExposure = protocolExposure.find((exp) => exp.id === pos.id);
|
|
75
76
|
if (!foundExistingProtocolExposure &&
|
|
76
|
-
(0,
|
|
77
|
+
(0, core_2.filterOutBySize)(protoReturnObj.netUsdValue)) {
|
|
77
78
|
protocolExposure.push(protoReturnObj);
|
|
78
79
|
}
|
|
79
80
|
else if (foundExistingProtocolExposure) {
|
|
@@ -126,7 +127,7 @@ function parseVaultLevelDebank(debankRes, protocolExposure, tokenExposure, borro
|
|
|
126
127
|
});
|
|
127
128
|
const foundExistingProtocolExposure = protocolExposure.find((exp) => exp.id === pos.id);
|
|
128
129
|
if (!foundExistingProtocolExposure &&
|
|
129
|
-
(0,
|
|
130
|
+
(0, core_2.filterOutBySize)(protoReturnObj.netUsdValue)) {
|
|
130
131
|
protocolExposure.push(protoReturnObj);
|
|
131
132
|
}
|
|
132
133
|
else if (foundExistingProtocolExposure) {
|
|
@@ -272,7 +273,7 @@ function parseLoanLevelDebank(debankRes) {
|
|
|
272
273
|
exposure = uniqueExposure;
|
|
273
274
|
}
|
|
274
275
|
catch (err) {
|
|
275
|
-
|
|
276
|
+
core_1.Logger.log.error('getPoolLoansData.strategies', err);
|
|
276
277
|
}
|
|
277
278
|
return { exposure, positions };
|
|
278
279
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchOctavfiPortfolios = fetchOctavfiPortfolios;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
5
|
const utils_1 = require("../../adapters/solana/utils");
|
|
6
|
+
const core_1 = require("../../core");
|
|
6
7
|
const BASE_URL = 'https://api.octav.fi';
|
|
7
8
|
const OCTAVFI_API_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWRlZmF1bHQtcm9sZSI6InVzZXIiLCJ4LWhhc3VyYS1hbGxvd2VkLXJvbGVzIjpbInVzZXIiXSwieC1oYXN1cmEtdXNlci1pZCI6ImF1Z3VzdDEyMjM0In19.zaMUtrtdC82uaDh6XSZrsneEcKO3PFOE6FyX3G-MR6c';
|
|
8
9
|
function filterEvmAndSolanaAddresses(addresses) {
|
|
@@ -15,7 +16,7 @@ function filterEvmAndSolanaAddresses(addresses) {
|
|
|
15
16
|
if (utils_1.SolanaUtils.isSolanaAddress(address)) {
|
|
16
17
|
return true;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
core_1.Logger.log.info('filterEvmAndSolanaAddresses.excluded', { address });
|
|
19
20
|
return false;
|
|
20
21
|
});
|
|
21
22
|
}
|
|
@@ -30,16 +31,20 @@ async function fetchSinglePortfolio(address) {
|
|
|
30
31
|
});
|
|
31
32
|
if (!response.ok) {
|
|
32
33
|
const errorText = await response.text();
|
|
33
|
-
|
|
34
|
+
core_1.Logger.log.error('fetchSinglePortfolio', new Error(`HTTP ${response.status} ${response.statusText}: ${errorText}`), {
|
|
35
|
+
address,
|
|
36
|
+
status: response.status,
|
|
37
|
+
statusText: response.statusText,
|
|
38
|
+
});
|
|
34
39
|
return null;
|
|
35
40
|
}
|
|
36
41
|
const data = await response.json();
|
|
37
42
|
if (!data || typeof data !== 'object') {
|
|
38
|
-
|
|
43
|
+
core_1.Logger.log.error('fetchSinglePortfolio.unexpected-type', new Error(`unexpected response type: ${typeof data}`), { address });
|
|
39
44
|
return null;
|
|
40
45
|
}
|
|
41
46
|
if (data.error) {
|
|
42
|
-
|
|
47
|
+
core_1.Logger.log.error('fetchSinglePortfolio.api-error', new Error(String(data.error)), { address });
|
|
43
48
|
return null;
|
|
44
49
|
}
|
|
45
50
|
let portfolio = data;
|
|
@@ -57,7 +62,7 @@ async function fetchSinglePortfolio(address) {
|
|
|
57
62
|
return portfolio;
|
|
58
63
|
}
|
|
59
64
|
catch (error) {
|
|
60
|
-
|
|
65
|
+
core_1.Logger.log.error('fetchSinglePortfolio', error, { address });
|
|
61
66
|
return null;
|
|
62
67
|
}
|
|
63
68
|
}
|
|
@@ -297,7 +297,7 @@ async function getSubgraphWithdrawProccessed(pool, provider, slackWebookUrl = sl
|
|
|
297
297
|
const requests = [];
|
|
298
298
|
if (!goldskyUrl) {
|
|
299
299
|
const chainId = await (0, core_1.getChainId)(provider);
|
|
300
|
-
|
|
300
|
+
core_1.Logger.log.error('getSubgraphWithdrawProccessed.missing-subgraph-url', new Error('goldsky url is undefined'), { chainId, vaultSymbol, pool });
|
|
301
301
|
slack_1.SLACK.error({
|
|
302
302
|
title: 'Missing Subgraph',
|
|
303
303
|
error: '#getSubgraphWithdrawProccessed: goldsky url is undefined',
|
|
@@ -326,7 +326,7 @@ async function getSubgraphWithdrawProccessed(pool, provider, slackWebookUrl = sl
|
|
|
326
326
|
}
|
|
327
327
|
}`, GOLDSKY_API_KEY);
|
|
328
328
|
if (result.status !== 200) {
|
|
329
|
-
|
|
329
|
+
core_1.Logger.log.error('getSubgraphWithdrawProccessed', new Error(`HTTP ${result.status} ${result.statusText}`), { status: result.status, statusText: result.statusText, pool });
|
|
330
330
|
return [];
|
|
331
331
|
}
|
|
332
332
|
const json = (await result.json());
|
|
@@ -334,7 +334,7 @@ async function getSubgraphWithdrawProccessed(pool, provider, slackWebookUrl = sl
|
|
|
334
334
|
return requests;
|
|
335
335
|
}
|
|
336
336
|
catch (e) {
|
|
337
|
-
|
|
337
|
+
core_1.Logger.log.error('getSubgraphWithdrawProccessed', e, { pool });
|
|
338
338
|
return [];
|
|
339
339
|
}
|
|
340
340
|
}
|
|
@@ -638,7 +638,7 @@ async function getSubgraphVaultHistory(provider, pool, slackWebookUrl = slack_1.
|
|
|
638
638
|
}
|
|
639
639
|
}`, GOLDSKY_API_KEY);
|
|
640
640
|
if (result.status !== 200) {
|
|
641
|
-
|
|
641
|
+
core_1.Logger.log.error('getSubgraphVaultHistory', new Error(`HTTP ${result.status} ${result.statusText}`), { status: result.status, statusText: result.statusText });
|
|
642
642
|
return requests;
|
|
643
643
|
}
|
|
644
644
|
const json = (await result.json());
|
|
@@ -648,7 +648,7 @@ async function getSubgraphVaultHistory(provider, pool, slackWebookUrl = slack_1.
|
|
|
648
648
|
return formattedRequests;
|
|
649
649
|
}
|
|
650
650
|
catch (e) {
|
|
651
|
-
|
|
651
|
+
core_1.Logger.log.error('getSubgraphVaultHistory', e, { pool });
|
|
652
652
|
return [];
|
|
653
653
|
}
|
|
654
654
|
}
|
|
@@ -740,7 +740,7 @@ async function getSubgraphUserTransfers(user, provider, pool, slackWebookUrl = s
|
|
|
740
740
|
return userTransfers;
|
|
741
741
|
}
|
|
742
742
|
catch (e) {
|
|
743
|
-
|
|
743
|
+
core_1.Logger.log.error('getSubgraphUserTransfers', e, { pool });
|
|
744
744
|
return [];
|
|
745
745
|
}
|
|
746
746
|
}
|
package/lib/types/vaults.d.ts
CHANGED
|
@@ -22,6 +22,17 @@ export interface IVaultLoan {
|
|
|
22
22
|
isIdleCapital: boolean;
|
|
23
23
|
allocation: number;
|
|
24
24
|
}
|
|
25
|
+
export interface IVaultBorrowerHealthFactor {
|
|
26
|
+
borrower: IAddress;
|
|
27
|
+
loan: IAddress;
|
|
28
|
+
health_factor?: {
|
|
29
|
+
datetime: string;
|
|
30
|
+
health_factor: number;
|
|
31
|
+
id: string;
|
|
32
|
+
total_collateral_value: number;
|
|
33
|
+
total_loan_value: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
25
36
|
export type IVaultUserHistoryItem = {
|
|
26
37
|
timestamp: number;
|
|
27
38
|
address: IAddress;
|
package/lib/types/web3.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ export type IInfuraOptions = {
|
|
|
22
22
|
};
|
|
23
23
|
export type ISolanaNetwork = 'devnet' | 'mainnet-beta' | 'testnet' | 'localnet';
|
|
24
24
|
export type IStellarNetwork = 'mainnet' | 'testnet';
|
|
25
|
-
export type StellarNetwork = IStellarNetwork;
|
|
26
25
|
export interface ISolanaConfig {
|
|
27
26
|
rpcUrl: string;
|
|
28
27
|
network: ISolanaNetwork;
|