@augustdigital/sdk 8.3.2 → 8.5.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/abis/ERC20_Bytes32.d.ts +4 -0
- package/lib/abis/ERC20_Bytes32.js +4 -0
- package/lib/abis/ERC4626.d.ts +1 -0
- package/lib/abis/ERC4626.js +1 -0
- package/lib/abis/ERC721.d.ts +1 -0
- package/lib/abis/ERC721.js +1 -0
- package/lib/abis/FeeOracle.js +1 -0
- package/lib/abis/LendingPool.js +1 -0
- package/lib/abis/LendingPoolV2.js +1 -0
- package/lib/abis/Multicall3.js +3 -0
- package/lib/abis/OFT.d.ts +20 -0
- package/lib/abis/OFT.js +20 -0
- package/lib/abis/SmartAccount.d.ts +1 -0
- package/lib/abis/SmartAccount.js +3 -0
- package/lib/abis/SwapRouter.d.ts +1 -0
- package/lib/abis/SwapRouter.js +1 -0
- package/lib/abis/UniversalSignatureValidator.js +3 -0
- package/lib/abis/index.d.ts +5 -0
- package/lib/abis/index.js +5 -0
- package/lib/adapters/evm/getters.d.ts +17 -2
- package/lib/adapters/evm/getters.js +35 -3
- package/lib/adapters/evm/index.d.ts +262 -0
- package/lib/adapters/evm/index.js +268 -1
- package/lib/adapters/evm/utils.d.ts +6 -0
- package/lib/adapters/evm/utils.js +7 -0
- package/lib/adapters/solana/constants.js +4 -1
- package/lib/adapters/solana/getters.d.ts +8 -0
- package/lib/adapters/solana/getters.js +21 -0
- package/lib/adapters/solana/idl/vault-idl.js +9 -0
- package/lib/adapters/solana/index.d.ts +55 -0
- package/lib/adapters/solana/index.js +57 -0
- package/lib/adapters/solana/utils.d.ts +28 -0
- package/lib/adapters/solana/utils.js +79 -4
- package/lib/adapters/solana/vault.actions.d.ts +19 -0
- package/lib/adapters/solana/vault.actions.js +47 -3
- package/lib/adapters/stellar/actions.d.ts +25 -0
- package/lib/adapters/stellar/actions.js +33 -0
- package/lib/adapters/stellar/constants.d.ts +26 -0
- package/lib/adapters/stellar/constants.js +29 -0
- package/lib/adapters/stellar/getters.d.ts +56 -0
- package/lib/adapters/stellar/getters.js +81 -0
- package/lib/adapters/stellar/index.d.ts +48 -0
- package/lib/adapters/stellar/index.js +48 -0
- package/lib/adapters/stellar/soroban.d.ts +20 -0
- package/lib/adapters/stellar/soroban.js +46 -0
- package/lib/adapters/stellar/submit.d.ts +12 -0
- package/lib/adapters/stellar/submit.js +19 -0
- package/lib/adapters/stellar/types.d.ts +27 -0
- package/lib/adapters/stellar/types.js +3 -0
- package/lib/adapters/stellar/utils.d.ts +10 -0
- package/lib/adapters/stellar/utils.js +10 -0
- package/lib/adapters/sui/getters.d.ts +6 -0
- package/lib/adapters/sui/getters.js +6 -0
- package/lib/adapters/sui/index.d.ts +15 -0
- package/lib/adapters/sui/index.js +15 -0
- package/lib/adapters/sui/transformer.d.ts +6 -0
- package/lib/adapters/sui/transformer.js +6 -0
- package/lib/adapters/sui/utils.d.ts +6 -0
- package/lib/adapters/sui/utils.js +6 -0
- package/lib/core/analytics/chain-name.d.ts +8 -0
- package/lib/core/analytics/chain-name.js +8 -0
- package/lib/core/analytics/constants.d.ts +4 -0
- package/lib/core/analytics/constants.js +4 -0
- package/lib/core/analytics/env.d.ts +25 -0
- package/lib/core/analytics/env.js +26 -0
- package/lib/core/analytics/index.d.ts +26 -0
- package/lib/core/analytics/index.js +35 -0
- package/lib/core/analytics/instrumentation.d.ts +26 -0
- package/lib/core/analytics/instrumentation.js +66 -2
- package/lib/core/analytics/method-taxonomy.d.ts +16 -0
- package/lib/core/analytics/method-taxonomy.js +18 -0
- package/lib/core/analytics/metrics.d.ts +23 -0
- package/lib/core/analytics/metrics.js +40 -0
- package/lib/core/analytics/sanitize.d.ts +38 -0
- package/lib/core/analytics/sanitize.js +46 -0
- package/lib/core/analytics/sentry-runtime.d.ts +11 -0
- package/lib/core/analytics/sentry-runtime.js +19 -0
- package/lib/core/analytics/sentry.d.ts +45 -0
- package/lib/core/analytics/sentry.js +115 -2
- package/lib/core/analytics/types.d.ts +27 -0
- package/lib/core/analytics/user-identity.d.ts +34 -0
- package/lib/core/analytics/user-identity.js +42 -0
- package/lib/core/analytics/version.d.ts +6 -1
- package/lib/core/analytics/version.js +6 -1
- package/lib/core/auth/verify.js +5 -0
- package/lib/core/base.class.d.ts +75 -0
- package/lib/core/base.class.js +56 -0
- package/lib/core/cache.d.ts +5 -0
- package/lib/core/cache.js +6 -0
- package/lib/core/constants/adapters.d.ts +15 -0
- package/lib/core/constants/adapters.js +28 -8
- package/lib/core/constants/core.d.ts +12 -1
- package/lib/core/constants/core.js +12 -0
- package/lib/core/constants/swap-router.d.ts +46 -0
- package/lib/core/constants/swap-router.js +50 -0
- package/lib/core/constants/vaults.d.ts +56 -0
- package/lib/core/constants/vaults.js +66 -1
- package/lib/core/constants/web3.d.ts +3 -0
- package/lib/core/constants/web3.js +18 -5
- package/lib/core/errors/index.d.ts +36 -0
- package/lib/core/errors/index.js +29 -0
- package/lib/core/fetcher.d.ts +134 -0
- package/lib/core/fetcher.js +191 -5
- package/lib/core/helpers/adapters.d.ts +9 -0
- package/lib/core/helpers/adapters.js +11 -0
- package/lib/core/helpers/chain-address.d.ts +10 -0
- package/lib/core/helpers/chain-address.js +11 -0
- package/lib/core/helpers/core.d.ts +42 -0
- package/lib/core/helpers/core.js +66 -1
- package/lib/core/helpers/explorer-link.d.ts +14 -0
- package/lib/core/helpers/explorer-link.js +14 -0
- package/lib/core/helpers/signer.d.ts +26 -0
- package/lib/core/helpers/signer.js +39 -0
- package/lib/core/helpers/swap-router.d.ts +32 -0
- package/lib/core/helpers/swap-router.js +32 -0
- package/lib/core/helpers/vault-version.d.ts +1 -0
- package/lib/core/helpers/vault-version.js +2 -0
- package/lib/core/helpers/vaults.d.ts +8 -0
- package/lib/core/helpers/vaults.js +22 -8
- package/lib/core/helpers/web3.d.ts +152 -0
- package/lib/core/helpers/web3.js +183 -6
- package/lib/core/logger/index.d.ts +55 -0
- package/lib/core/logger/index.js +19 -0
- package/lib/core/logger/slack.d.ts +3 -0
- package/lib/core/logger/slack.js +3 -0
- package/lib/core/vault-metadata.d.ts +6 -0
- package/lib/core/vault-metadata.js +6 -0
- package/lib/core/version-check.d.ts +52 -0
- package/lib/core/version-check.js +81 -0
- package/lib/evm/methods/crossChainVault.d.ts +90 -0
- package/lib/evm/methods/crossChainVault.js +186 -1
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
- package/lib/evm/methods/index.d.ts +1 -0
- package/lib/evm/methods/index.js +1 -0
- package/lib/evm/types/crossChain.d.ts +202 -0
- package/lib/evm/types/crossChain.js +11 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +19 -0
- package/lib/main.d.ts +288 -5
- package/lib/main.js +305 -0
- package/lib/modules/api/index.d.ts +1 -0
- package/lib/modules/api/index.js +6 -0
- package/lib/modules/api/main.d.ts +52 -0
- package/lib/modules/api/main.js +130 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +15 -0
- package/lib/modules/sub-accounts/fetcher.js +15 -0
- package/lib/modules/sub-accounts/main.d.ts +33 -0
- package/lib/modules/sub-accounts/main.js +38 -0
- package/lib/modules/sub-accounts/utils.d.ts +3 -0
- package/lib/modules/sub-accounts/utils.js +3 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +18 -0
- package/lib/modules/vaults/adapter.helpers.js +34 -0
- package/lib/modules/vaults/fetcher.d.ts +20 -0
- package/lib/modules/vaults/fetcher.js +40 -3
- package/lib/modules/vaults/getters.d.ts +295 -0
- package/lib/modules/vaults/getters.js +552 -12
- package/lib/modules/vaults/index.d.ts +12 -0
- package/lib/modules/vaults/index.js +12 -0
- package/lib/modules/vaults/main.d.ts +292 -4
- package/lib/modules/vaults/main.js +379 -7
- package/lib/modules/vaults/read.actions.d.ts +168 -0
- package/lib/modules/vaults/read.actions.js +143 -0
- package/lib/modules/vaults/types.d.ts +34 -0
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +47 -0
- package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
- package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
- package/lib/modules/vaults/utils/date-utils.js +47 -1
- package/lib/modules/vaults/utils.d.ts +69 -0
- package/lib/modules/vaults/utils.js +104 -5
- package/lib/modules/vaults/write.actions.d.ts +363 -3
- package/lib/modules/vaults/write.actions.js +364 -2
- package/lib/polyfills.js +2 -0
- package/lib/sdk.d.ts +23705 -0
- package/lib/services/coingecko/fetcher.d.ts +13 -0
- package/lib/services/coingecko/fetcher.js +17 -0
- package/lib/services/debank/fetcher.d.ts +14 -0
- package/lib/services/debank/fetcher.js +12 -0
- package/lib/services/debank/utils.js +17 -0
- package/lib/services/layerzero/deposits.d.ts +11 -0
- package/lib/services/layerzero/deposits.js +34 -11
- package/lib/services/layerzero/redeems.d.ts +10 -0
- package/lib/services/layerzero/redeems.js +13 -0
- package/lib/services/layerzero/utils.d.ts +8 -0
- package/lib/services/layerzero/utils.js +11 -0
- package/lib/services/octavfi/fetcher.d.ts +7 -0
- package/lib/services/octavfi/fetcher.js +25 -0
- package/lib/services/octavfi/utils.d.ts +12 -0
- package/lib/services/octavfi/utils.js +44 -10
- package/lib/services/subgraph/fetcher.js +4 -2
- package/lib/services/subgraph/vaults.d.ts +12 -0
- package/lib/services/subgraph/vaults.js +43 -2
- package/lib/services/swap-quotes/index.d.ts +71 -0
- package/lib/services/swap-quotes/index.js +25 -0
- package/lib/services/swap-quotes/paraswap.d.ts +17 -0
- package/lib/services/swap-quotes/paraswap.js +14 -0
- package/lib/types/pools.d.ts +3 -0
- package/lib/types/typed-contract.d.ts +64 -0
- package/lib/types/vaults.d.ts +137 -2
- package/lib/types/vaults.js +10 -0
- package/lib/types/web3.d.ts +8 -0
- package/lib/types/web3.js +1 -0
- package/lib/types/webserver.d.ts +45 -0
- package/package.json +6 -5
|
@@ -1 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch the latest USD price for a token symbol from CoinGecko's
|
|
3
|
+
* `/market_chart/range` endpoint, mapped through `COINGECKO_COIN_ID_MAP`.
|
|
4
|
+
*
|
|
5
|
+
* @param symbol Token symbol (case-insensitive). Must be present in
|
|
6
|
+
* `COINGECKO_COIN_ID_MAP`; unmapped symbols still hit the network and
|
|
7
|
+
* 404 today (see todo/32-coingecko-fetcher-defects.md).
|
|
8
|
+
* @param coinGeckoKey CoinGecko Pro API key passed as `x-cg-pro-api-key`.
|
|
9
|
+
* @returns The latest price in USD on success; `null` on any failure
|
|
10
|
+
* (non-2xx response, network error, JSON parse error, or missing
|
|
11
|
+
* `prices` array). The `musd` short-circuit returns a tuple literal
|
|
12
|
+
* for back-compat — see todo/32 for the cleanup.
|
|
13
|
+
*/
|
|
1
14
|
export declare function fetchTokenPricesFromCoinGecko(symbol: string, coinGeckoKey: string): Promise<any>;
|
|
@@ -3,11 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchTokenPricesFromCoinGecko = fetchTokenPricesFromCoinGecko;
|
|
4
4
|
const logger_1 = require("../../core/logger");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
+
/**
|
|
7
|
+
* Fetch the latest USD price for a token symbol from CoinGecko's
|
|
8
|
+
* `/market_chart/range` endpoint, mapped through `COINGECKO_COIN_ID_MAP`.
|
|
9
|
+
*
|
|
10
|
+
* @param symbol Token symbol (case-insensitive). Must be present in
|
|
11
|
+
* `COINGECKO_COIN_ID_MAP`; unmapped symbols still hit the network and
|
|
12
|
+
* 404 today (see todo/32-coingecko-fetcher-defects.md).
|
|
13
|
+
* @param coinGeckoKey CoinGecko Pro API key passed as `x-cg-pro-api-key`.
|
|
14
|
+
* @returns The latest price in USD on success; `null` on any failure
|
|
15
|
+
* (non-2xx response, network error, JSON parse error, or missing
|
|
16
|
+
* `prices` array). The `musd` short-circuit returns a tuple literal
|
|
17
|
+
* for back-compat — see todo/32 for the cleanup.
|
|
18
|
+
*/
|
|
6
19
|
async function fetchTokenPricesFromCoinGecko(symbol, coinGeckoKey) {
|
|
7
20
|
const coinId = utils_1.COINGECKO_COIN_ID_MAP[symbol.toLowerCase()];
|
|
8
21
|
if (coinId === 'mezo-usd') {
|
|
9
22
|
return [['175394880000', 1]];
|
|
10
23
|
}
|
|
24
|
+
// this is what we do in FE - not sure if we really need 7d worth of data since we just want something but it'll do for now
|
|
11
25
|
const sevendDaysInS = 7 * 24 * 60 * 60;
|
|
12
26
|
const from = Date.now() / 1000 - sevendDaysInS;
|
|
13
27
|
const url = `https://pro-api.coingecko.com/api/v3/coins/${coinId}/market_chart/range?vs_currency=usd&from=${from}&to=${Math.floor(Date.now() / 1000)}&interval=daily`;
|
|
@@ -30,6 +44,9 @@ async function fetchTokenPricesFromCoinGecko(symbol, coinGeckoKey) {
|
|
|
30
44
|
throw err;
|
|
31
45
|
}
|
|
32
46
|
const data = (await response.json());
|
|
47
|
+
// `/market_chart/range` returns `{ prices, market_caps, total_volumes }` —
|
|
48
|
+
// an object. The previous `data.length` check was always falsy on the
|
|
49
|
+
// success path and silently collapsed every valid response to `null`.
|
|
33
50
|
if (data?.prices?.length) {
|
|
34
51
|
return data.prices[data.prices.length - 1][1];
|
|
35
52
|
}
|
|
@@ -107,6 +107,20 @@ export interface IDebankAccountData {
|
|
|
107
107
|
export interface IDebankAccountDataError {
|
|
108
108
|
error: string;
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Response type for vault-level DeBank data.
|
|
112
|
+
* Keys are subaccount addresses, values are either DeBank data or error objects.
|
|
113
|
+
*/
|
|
110
114
|
export type IVaultDebankResponse = Record<string, IDebankAccountData | IDebankAccountDataError>;
|
|
115
|
+
/**
|
|
116
|
+
* Fetch DeBank data for all subaccounts of a vault in a single request.
|
|
117
|
+
* @param vaultAddress The vault contract address
|
|
118
|
+
* @param headers Optional monitoring headers
|
|
119
|
+
* @returns Dictionary of subaccount addresses to DeBank data, or false on error
|
|
120
|
+
*/
|
|
111
121
|
export declare function fetchVaultDebankResponse(vaultAddress: IAddress, headers?: IWSMonitorHeaders): Promise<IVaultDebankResponse | false>;
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated Use fetchVaultDebankResponse for vault-level queries.
|
|
124
|
+
* Fetch DeBank data for a single subaccount address.
|
|
125
|
+
*/
|
|
112
126
|
export declare function fetchDebankResponse(address: IAddress, headers?: IWSMonitorHeaders): Promise<any>;
|
|
@@ -3,9 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchVaultDebankResponse = fetchVaultDebankResponse;
|
|
4
4
|
exports.fetchDebankResponse = fetchDebankResponse;
|
|
5
5
|
const core_1 = require("../../core");
|
|
6
|
+
/**
|
|
7
|
+
* Fetch DeBank data for all subaccounts of a vault in a single request.
|
|
8
|
+
* @param vaultAddress The vault contract address
|
|
9
|
+
* @param headers Optional monitoring headers
|
|
10
|
+
* @returns Dictionary of subaccount addresses to DeBank data, or false on error
|
|
11
|
+
*/
|
|
6
12
|
async function fetchVaultDebankResponse(vaultAddress, headers) {
|
|
7
13
|
try {
|
|
8
14
|
const response = await (0, core_1.fetchAugustPublic)(core_1.WEBSERVER_ENDPOINTS.public.tokenizedVault.debank(vaultAddress), { headers: headers });
|
|
15
|
+
// 200 = success, 207 = partial success (some subaccounts failed)
|
|
9
16
|
if (response.status === 200 || response.status === 207) {
|
|
10
17
|
const data = (await response.json());
|
|
11
18
|
return data;
|
|
@@ -18,7 +25,12 @@ async function fetchVaultDebankResponse(vaultAddress, headers) {
|
|
|
18
25
|
return false;
|
|
19
26
|
}
|
|
20
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use fetchVaultDebankResponse for vault-level queries.
|
|
30
|
+
* Fetch DeBank data for a single subaccount address.
|
|
31
|
+
*/
|
|
21
32
|
async function fetchDebankResponse(address, headers) {
|
|
33
|
+
// filter out hyperevm since debank does not yet support hyperevm
|
|
22
34
|
const debankResponse = await (0, core_1.fetchAugustWithKey)(undefined, core_1.WEBSERVER_ENDPOINTS.subaccount.debank(address), { override: true, headers: headers });
|
|
23
35
|
if (debankResponse.status !== 200) {
|
|
24
36
|
core_1.Logger.log.error('fetchDebankResponse', new Error(`HTTP ${debankResponse.status} ${debankResponse.statusText}`), {
|
|
@@ -47,12 +47,14 @@ function addToTokenExposure(token, tokenExposure, exposureType, protocol, exposu
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
function parseVaultLevelDebank(debankRes, protocolExposure, tokenExposure, borrower, exposurePerCategory, netValue) {
|
|
50
|
+
// new mapping to grab vault-level token and protocol exposure per
|
|
50
51
|
const tokenMap = {};
|
|
51
52
|
const protocolTokenMap = {};
|
|
52
53
|
const protocolExposures = debankRes?.subaccount?.positions || [];
|
|
53
54
|
const appProtocolExposures = debankRes?.subaccount?.app_positions || [];
|
|
54
55
|
const tokenExposures = debankRes?.subaccount?.tokens || [];
|
|
55
56
|
protocolExposures.forEach((pos) => {
|
|
57
|
+
// protocol-level data fetching
|
|
56
58
|
const protoReturnObj = {
|
|
57
59
|
id: pos?.id,
|
|
58
60
|
chain: pos?.chain,
|
|
@@ -68,6 +70,7 @@ function parseVaultLevelDebank(debankRes, protocolExposure, tokenExposure, borro
|
|
|
68
70
|
address: borrower,
|
|
69
71
|
};
|
|
70
72
|
pos?.portfolio_item_list?.forEach((item) => {
|
|
73
|
+
// initialize protocol exposure
|
|
71
74
|
protoReturnObj.assetUsdValue += item?.stats?.asset_usd_value || 0;
|
|
72
75
|
protoReturnObj.debtUsdValue += item?.stats?.debt_usd_value || 0;
|
|
73
76
|
protoReturnObj.netUsdValue += item?.stats?.net_usd_value || 0;
|
|
@@ -83,21 +86,27 @@ function parseVaultLevelDebank(debankRes, protocolExposure, tokenExposure, borro
|
|
|
83
86
|
foundExistingProtocolExposure.assetUsdValue +=
|
|
84
87
|
protoReturnObj.assetUsdValue;
|
|
85
88
|
}
|
|
89
|
+
// go through the debank portfolio
|
|
86
90
|
pos.portfolio_item_list.forEach((item) => {
|
|
87
91
|
item.detail.supply_token_list.forEach((sup) => {
|
|
92
|
+
// add protocol id for vault-level "protocol exposure"
|
|
88
93
|
if (sup?.protocol_id) {
|
|
89
94
|
const existingArray = protocolTokenMap[sup.protocol_id] || [];
|
|
90
95
|
if (!existingArray.includes(sup.symbol))
|
|
91
96
|
existingArray.push(sup.symbol);
|
|
92
97
|
}
|
|
98
|
+
// add token to vault "token exposure"
|
|
93
99
|
addToTokenExposure(sup, tokenExposure, 'supply', pos.id, exposurePerCategory, netValue, borrower);
|
|
100
|
+
// add token image url to token mapping for display
|
|
94
101
|
if (sup?.symbol && sup?.logo_url) {
|
|
95
102
|
tokenMap[sup.symbol] = sup.logo_url;
|
|
96
103
|
}
|
|
97
104
|
tokenMap[sup.supplying_exposure] = 'true';
|
|
98
105
|
});
|
|
99
106
|
item.detail.borrow_token_list.forEach((bor) => {
|
|
107
|
+
// add token to vault "token exposure"
|
|
100
108
|
addToTokenExposure(bor, tokenExposure, 'borrow', pos.id, exposurePerCategory, netValue, borrower);
|
|
109
|
+
// add token image url to token mapping for display
|
|
101
110
|
if (bor?.symbol && bor?.logo_url) {
|
|
102
111
|
tokenMap[bor.symbol] = bor.logo_url;
|
|
103
112
|
}
|
|
@@ -105,6 +114,8 @@ function parseVaultLevelDebank(debankRes, protocolExposure, tokenExposure, borro
|
|
|
105
114
|
});
|
|
106
115
|
});
|
|
107
116
|
});
|
|
117
|
+
// Process non-EVM app protocols (e.g. Hyperliquid, Lighter).
|
|
118
|
+
// These lack chain and protocol_id fields unlike EVM-based positions.
|
|
108
119
|
appProtocolExposures.forEach((pos) => {
|
|
109
120
|
const protoReturnObj = {
|
|
110
121
|
id: pos?.id,
|
|
@@ -202,6 +213,8 @@ function getVaultExposure(debankResponse) {
|
|
|
202
213
|
!token.is_suspicious &&
|
|
203
214
|
!token.is_scam &&
|
|
204
215
|
token?.is_core) {
|
|
216
|
+
// Not sure what isWallet is, but I'm guessing is that this field means that it should be in wallet exposure...
|
|
217
|
+
// fwiw I have seen this double counted in supplyTokens AND tokens
|
|
205
218
|
if (!token.is_wallet) {
|
|
206
219
|
supplying_exposure.push({
|
|
207
220
|
symbol: token.symbol,
|
|
@@ -219,10 +232,12 @@ function parseLoanLevelDebank(debankRes) {
|
|
|
219
232
|
let positions = [];
|
|
220
233
|
let exposure = [];
|
|
221
234
|
try {
|
|
235
|
+
// new mapping to grab token and protocol exposure
|
|
222
236
|
const protocolExposures = [
|
|
223
237
|
...(debankRes?.subaccount?.positions || []),
|
|
224
238
|
...(debankRes?.subaccount?.app_positions || []),
|
|
225
239
|
];
|
|
240
|
+
// Old mapping to grab token and protocol exposure
|
|
226
241
|
positions = protocolExposures?.map((p) => ({
|
|
227
242
|
value: p.logo_url,
|
|
228
243
|
label: p.name,
|
|
@@ -243,6 +258,8 @@ function parseLoanLevelDebank(debankRes) {
|
|
|
243
258
|
}
|
|
244
259
|
return extra;
|
|
245
260
|
}));
|
|
261
|
+
// this is a request where if there is no protocol exposure then show any spots
|
|
262
|
+
// over 10k in collateral exposure
|
|
246
263
|
if (protocolExposures.length === 0) {
|
|
247
264
|
if (debankRes?.subaccount?.tokens) {
|
|
248
265
|
debankRes.subaccount.tokens.forEach((t) => {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LayerZero Deposits Service
|
|
3
|
+
* Handles querying LayerZero USDC deposits from subgraphs
|
|
4
|
+
*/
|
|
1
5
|
import { IAddress } from '../../types';
|
|
2
6
|
export declare const LAYERZERO_VAULTS: {
|
|
3
7
|
coreUSDC: {
|
|
@@ -34,5 +38,12 @@ export interface ILayerZeroDeposit {
|
|
|
34
38
|
transactionHash_: string;
|
|
35
39
|
timestamp_: string;
|
|
36
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Check if a vault address or symbol is a LayerZero vault
|
|
43
|
+
*/
|
|
37
44
|
export declare function isLayerZeroVault(vaultAddressOrSymbol: string): keyof typeof LAYERZERO_VAULTS | null;
|
|
45
|
+
/**
|
|
46
|
+
* Query LayerZero deposits from the appropriate subgraph
|
|
47
|
+
* @throws Error if the GraphQL request fails or returns invalid data
|
|
48
|
+
*/
|
|
38
49
|
export declare function queryLayerZeroDeposits(vaultKey: keyof typeof LAYERZERO_VAULTS, wallet?: IAddress): Promise<ILayerZeroDeposit[]>;
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LayerZero Deposits Service
|
|
4
|
+
* Handles querying LayerZero USDC deposits from subgraphs
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.LAYERZERO_VAULTS = void 0;
|
|
4
8
|
exports.isLayerZeroVault = isLayerZeroVault;
|
|
5
9
|
exports.queryLayerZeroDeposits = queryLayerZeroDeposits;
|
|
6
10
|
const fetcher_1 = require("../subgraph/fetcher");
|
|
7
11
|
const utils_1 = require("./utils");
|
|
12
|
+
// LayerZero vault addresses and their corresponding receipt tokens
|
|
13
|
+
// spokeChains maps chainId -> shareOFT address (receipt token on that chain)
|
|
8
14
|
exports.LAYERZERO_VAULTS = {
|
|
9
15
|
coreUSDC: {
|
|
10
16
|
address: '0xE9B725010A9E419412ed67d0fA5f3A5f40159D32',
|
|
11
17
|
receiptToken: 'coreusdc',
|
|
12
|
-
decimals: 6,
|
|
18
|
+
decimals: 6, // USDC decimals
|
|
13
19
|
hubChainId: 1,
|
|
14
20
|
spokeChains: {
|
|
15
|
-
42161: '0x50a31ff4d57841681011837c17aa201c6a34203c',
|
|
16
|
-
43114: '0x1FA931Bf85248aD2eDf0004DD9A284698358e708',
|
|
17
|
-
8453: '0x1fa931bf85248ad2edf0004dd9a284698358e708',
|
|
18
|
-
146: '0x4bdd224fe59a3ae0b249125ad4c5b3126074c71b',
|
|
21
|
+
42161: '0x50a31ff4d57841681011837c17aa201c6a34203c', // Arbitrum
|
|
22
|
+
43114: '0x1FA931Bf85248aD2eDf0004DD9A284698358e708', // Avalanche
|
|
23
|
+
8453: '0x1fa931bf85248ad2edf0004dd9a284698358e708', // Base
|
|
24
|
+
146: '0x4bdd224fe59a3ae0b249125ad4c5b3126074c71b', // Sonic
|
|
19
25
|
},
|
|
20
26
|
subgraphEndpoints: [
|
|
21
27
|
'https://api.goldsky.com/api/public/project_cm9g0xy3o4j6v01vd34r3hvv9/subgraphs/august-layerzero-coreusdc/1.0.0/gn',
|
|
@@ -24,13 +30,13 @@ exports.LAYERZERO_VAULTS = {
|
|
|
24
30
|
upUSDC: {
|
|
25
31
|
address: '0x80E1048eDE66ec4c364b4F22C8768fc657FF6A42',
|
|
26
32
|
receiptToken: 'upusdc',
|
|
27
|
-
decimals: 6,
|
|
33
|
+
decimals: 6, // USDC decimals
|
|
28
34
|
hubChainId: 1,
|
|
29
35
|
spokeChains: {
|
|
30
|
-
42161: '0x81971a3c359cfe74259cff1b46fb5f2112ddde34',
|
|
31
|
-
43114: '0x81971A3C359cFE74259CfF1b46FB5f2112ddDE34',
|
|
32
|
-
8453: '0x81971a3c359cfe74259cff1b46fb5f2112ddde34',
|
|
33
|
-
146: '0x81971a3c359cfe74259cff1b46fb5f2112ddde34',
|
|
36
|
+
42161: '0x81971a3c359cfe74259cff1b46fb5f2112ddde34', // Arbitrum
|
|
37
|
+
43114: '0x81971A3C359cFE74259CfF1b46FB5f2112ddDE34', // Avalanche
|
|
38
|
+
8453: '0x81971a3c359cfe74259cff1b46fb5f2112ddde34', // Base
|
|
39
|
+
146: '0x81971a3c359cfe74259cff1b46fb5f2112ddde34', // Sonic
|
|
34
40
|
},
|
|
35
41
|
subgraphEndpoints: [
|
|
36
42
|
'https://api.goldsky.com/api/public/project_cm9g0xy3o4j6v01vd34r3hvv9/subgraphs/august-layerzero-upusdc/1.0.0/gn',
|
|
@@ -42,7 +48,7 @@ exports.LAYERZERO_VAULTS = {
|
|
|
42
48
|
decimals: 6,
|
|
43
49
|
hubChainId: 143,
|
|
44
50
|
spokeChains: {
|
|
45
|
-
1: '0xa6916b65c5e3fEdf46c0a2F59bff776e872C8992',
|
|
51
|
+
1: '0xa6916b65c5e3fEdf46c0a2F59bff776e872C8992', // Ethereum
|
|
46
52
|
},
|
|
47
53
|
subgraphEndpoints: [
|
|
48
54
|
'https://api.goldsky.com/api/public/project_cm9g0xy3o4j6v01vd34r3hvv9/subgraphs/august-layerzero-earnAUSD/1.0.0/gn',
|
|
@@ -50,8 +56,12 @@ exports.LAYERZERO_VAULTS = {
|
|
|
50
56
|
],
|
|
51
57
|
},
|
|
52
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Check if a vault address or symbol is a LayerZero vault
|
|
61
|
+
*/
|
|
53
62
|
function isLayerZeroVault(vaultAddressOrSymbol) {
|
|
54
63
|
const normalized = vaultAddressOrSymbol.toLowerCase();
|
|
64
|
+
// Check by address
|
|
55
65
|
if (normalized === exports.LAYERZERO_VAULTS.coreUSDC.address.toLowerCase() ||
|
|
56
66
|
normalized === 'coreusdc') {
|
|
57
67
|
return 'coreUSDC';
|
|
@@ -66,6 +76,9 @@ function isLayerZeroVault(vaultAddressOrSymbol) {
|
|
|
66
76
|
}
|
|
67
77
|
return null;
|
|
68
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Validate GraphQL response structure
|
|
81
|
+
*/
|
|
69
82
|
function validateDepositResponse(result) {
|
|
70
83
|
if (!result || typeof result !== 'object') {
|
|
71
84
|
return false;
|
|
@@ -80,8 +93,13 @@ function validateDepositResponse(result) {
|
|
|
80
93
|
}
|
|
81
94
|
return true;
|
|
82
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Query LayerZero deposits from the appropriate subgraph
|
|
98
|
+
* @throws Error if the GraphQL request fails or returns invalid data
|
|
99
|
+
*/
|
|
83
100
|
async function queryLayerZeroDeposits(vaultKey, wallet) {
|
|
84
101
|
const vaultConfig = exports.LAYERZERO_VAULTS[vaultKey];
|
|
102
|
+
// Build GraphQL query (fetchSubgraph prepends "query " automatically)
|
|
85
103
|
let query = `GetDeposits {
|
|
86
104
|
depositeds(first: 1000) {
|
|
87
105
|
assetAmt
|
|
@@ -93,6 +111,7 @@ async function queryLayerZeroDeposits(vaultKey, wallet) {
|
|
|
93
111
|
timestamp_
|
|
94
112
|
}
|
|
95
113
|
}`;
|
|
114
|
+
// If wallet is provided, filter by sender
|
|
96
115
|
if (wallet) {
|
|
97
116
|
const senderBytes32 = (0, utils_1.addressToBytes32)(wallet);
|
|
98
117
|
query = `GetDeposits {
|
|
@@ -112,6 +131,7 @@ async function queryLayerZeroDeposits(vaultKey, wallet) {
|
|
|
112
131
|
for (let i = 0; i < endpoints.length; i++) {
|
|
113
132
|
try {
|
|
114
133
|
const response = await (0, fetcher_1.fetchSubgraph)(endpoints[i], query);
|
|
134
|
+
// Only fall through to next endpoint on 404 (wrong URL casing)
|
|
115
135
|
if (response.status === 404 && i < endpoints.length - 1) {
|
|
116
136
|
continue;
|
|
117
137
|
}
|
|
@@ -122,6 +142,7 @@ async function queryLayerZeroDeposits(vaultKey, wallet) {
|
|
|
122
142
|
if (result.errors) {
|
|
123
143
|
throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`);
|
|
124
144
|
}
|
|
145
|
+
// Validate response structure
|
|
125
146
|
if (!validateDepositResponse(result)) {
|
|
126
147
|
throw new Error(`Invalid response structure from LayerZero subgraph. Expected data.depositeds array, got: ${JSON.stringify(result)}`);
|
|
127
148
|
}
|
|
@@ -129,10 +150,12 @@ async function queryLayerZeroDeposits(vaultKey, wallet) {
|
|
|
129
150
|
}
|
|
130
151
|
catch (error) {
|
|
131
152
|
lastError = error;
|
|
153
|
+
// Only continue to next endpoint on network-level failures; re-throw application errors immediately
|
|
132
154
|
if (i >= endpoints.length - 1)
|
|
133
155
|
break;
|
|
134
156
|
}
|
|
135
157
|
}
|
|
158
|
+
// All endpoints failed — throw the last error with context
|
|
136
159
|
if (lastError instanceof Error) {
|
|
137
160
|
const enhancedError = new Error(`Failed to fetch LayerZero deposits for ${vaultKey}: ${lastError.message}`);
|
|
138
161
|
enhancedError.stack = lastError.stack;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LayerZero Redeems Service
|
|
3
|
+
* Handles querying LayerZero earnAUSD redeems from subgraphs
|
|
4
|
+
*/
|
|
1
5
|
import { IAddress } from '../../types';
|
|
2
6
|
export interface ILayerZeroRedeem {
|
|
3
7
|
id: string;
|
|
@@ -7,4 +11,10 @@ export interface ILayerZeroRedeem {
|
|
|
7
11
|
transactionHash_: string;
|
|
8
12
|
timestamp_: string;
|
|
9
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Query LayerZero redeems for earnAUSD from the subgraph.
|
|
16
|
+
* Uses the same earnAUSD subgraph endpoints as deposits — the subgraph indexes
|
|
17
|
+
* both Deposited and Redeemed events from the same contract.
|
|
18
|
+
* @throws Error if the GraphQL request fails or returns invalid data
|
|
19
|
+
*/
|
|
10
20
|
export declare function queryLayerZeroRedeems(wallet?: IAddress): Promise<ILayerZeroRedeem[]>;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LayerZero Redeems Service
|
|
4
|
+
* Handles querying LayerZero earnAUSD redeems from subgraphs
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.queryLayerZeroRedeems = queryLayerZeroRedeems;
|
|
4
8
|
const fetcher_1 = require("../subgraph/fetcher");
|
|
5
9
|
const deposits_1 = require("./deposits");
|
|
6
10
|
const utils_1 = require("./utils");
|
|
11
|
+
/**
|
|
12
|
+
* Validate GraphQL response structure for redeems
|
|
13
|
+
*/
|
|
7
14
|
function validateRedeemResponse(result) {
|
|
8
15
|
if (!result || typeof result !== 'object') {
|
|
9
16
|
return false;
|
|
@@ -18,6 +25,12 @@ function validateRedeemResponse(result) {
|
|
|
18
25
|
}
|
|
19
26
|
return true;
|
|
20
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Query LayerZero redeems for earnAUSD from the subgraph.
|
|
30
|
+
* Uses the same earnAUSD subgraph endpoints as deposits — the subgraph indexes
|
|
31
|
+
* both Deposited and Redeemed events from the same contract.
|
|
32
|
+
* @throws Error if the GraphQL request fails or returns invalid data
|
|
33
|
+
*/
|
|
21
34
|
async function queryLayerZeroRedeems(wallet) {
|
|
22
35
|
const vaultConfig = deposits_1.LAYERZERO_VAULTS.earnAUSD;
|
|
23
36
|
let query = `GetRedeems {
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared LayerZero utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Convert Ethereum address to bytes32 format (left-padded with zeros)
|
|
6
|
+
* Used by LayerZero subgraph queries where addresses are stored in bytes32 format.
|
|
7
|
+
* @throws {Error} If address format is invalid
|
|
8
|
+
*/
|
|
1
9
|
export declare function addressToBytes32(address: string): string;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared LayerZero utilities
|
|
4
|
+
*/
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.addressToBytes32 = addressToBytes32;
|
|
7
|
+
/**
|
|
8
|
+
* Convert Ethereum address to bytes32 format (left-padded with zeros)
|
|
9
|
+
* Used by LayerZero subgraph queries where addresses are stored in bytes32 format.
|
|
10
|
+
* @throws {Error} If address format is invalid
|
|
11
|
+
*/
|
|
4
12
|
function addressToBytes32(address) {
|
|
13
|
+
// Validate address format
|
|
5
14
|
if (!address.match(/^0x[a-fA-F0-9]{40}$/)) {
|
|
6
15
|
throw new Error(`Invalid Ethereum address format: ${address}. Expected format: 0x followed by 40 hexadecimal characters.`);
|
|
7
16
|
}
|
|
17
|
+
// Remove 0x prefix and convert to lowercase
|
|
8
18
|
const cleanAddress = address.replace(/^0x/i, '').toLowerCase();
|
|
19
|
+
// Pad with 24 zeros (12 bytes) to make it 32 bytes total
|
|
9
20
|
return '0x' + '0'.repeat(24) + cleanAddress;
|
|
10
21
|
}
|
|
11
22
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { IOctavfiPortfolio } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches portfolio data from Octavfi API.
|
|
4
|
+
* Note: The API currently doesn't support multiple addresses in a single request,
|
|
5
|
+
* so individual requests are made for each address.
|
|
6
|
+
* @param addresses - Array of addresses to fetch data for.
|
|
7
|
+
* @returns Array of portfolio data (may be empty if all requests fail).
|
|
8
|
+
*/
|
|
2
9
|
export declare function fetchOctavfiPortfolios(addresses: string[]): Promise<IOctavfiPortfolio[]>;
|
|
@@ -6,6 +6,13 @@ const utils_1 = require("../../adapters/solana/utils");
|
|
|
6
6
|
const core_1 = require("../../core");
|
|
7
7
|
const BASE_URL = 'https://api.octav.fi';
|
|
8
8
|
const OCTAVFI_API_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWRlZmF1bHQtcm9sZSI6InVzZXIiLCJ4LWhhc3VyYS1hbGxvd2VkLXJvbGVzIjpbInVzZXIiXSwieC1oYXN1cmEtdXNlci1pZCI6ImF1Z3VzdDEyMjM0In19.zaMUtrtdC82uaDh6XSZrsneEcKO3PFOE6FyX3G-MR6c';
|
|
9
|
+
/**
|
|
10
|
+
* Filters addresses to only include EVM and Solana wallet addresses.
|
|
11
|
+
* Excludes Sui addresses and other non-supported address formats.
|
|
12
|
+
*
|
|
13
|
+
* @param addresses - Array of addresses to filter
|
|
14
|
+
* @returns Array containing only EVM and Solana addresses
|
|
15
|
+
*/
|
|
9
16
|
function filterEvmAndSolanaAddresses(addresses) {
|
|
10
17
|
return addresses.filter((address) => {
|
|
11
18
|
if (!address || typeof address !== 'string')
|
|
@@ -20,6 +27,11 @@ function filterEvmAndSolanaAddresses(addresses) {
|
|
|
20
27
|
return false;
|
|
21
28
|
});
|
|
22
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Fetches portfolio data for a single address from Octavfi API.
|
|
32
|
+
* @param address - Single address to fetch data for.
|
|
33
|
+
* @returns Portfolio data or null if request fails.
|
|
34
|
+
*/
|
|
23
35
|
async function fetchSinglePortfolio(address) {
|
|
24
36
|
try {
|
|
25
37
|
const response = await fetch(`${BASE_URL}/v1/portfolio?addresses=${address}`, {
|
|
@@ -47,18 +59,22 @@ async function fetchSinglePortfolio(address) {
|
|
|
47
59
|
core_1.Logger.log.error('fetchSinglePortfolio.api-error', new Error(String(data.error)), { address });
|
|
48
60
|
return null;
|
|
49
61
|
}
|
|
62
|
+
// Handle nested array response: [[portfolio]] or [portfolio] or portfolio
|
|
50
63
|
let portfolio = data;
|
|
51
64
|
if (Array.isArray(data)) {
|
|
52
65
|
if (data.length > 0 && Array.isArray(data[0])) {
|
|
66
|
+
// Nested array: [[portfolio]]
|
|
53
67
|
portfolio = data[0][0];
|
|
54
68
|
}
|
|
55
69
|
else if (data.length > 0) {
|
|
70
|
+
// Single array: [portfolio]
|
|
56
71
|
portfolio = data[0];
|
|
57
72
|
}
|
|
58
73
|
else {
|
|
59
74
|
return null;
|
|
60
75
|
}
|
|
61
76
|
}
|
|
77
|
+
// Return raw Octavfi data (transformation should happen separately when needed)
|
|
62
78
|
return portfolio;
|
|
63
79
|
}
|
|
64
80
|
catch (error) {
|
|
@@ -66,13 +82,22 @@ async function fetchSinglePortfolio(address) {
|
|
|
66
82
|
return null;
|
|
67
83
|
}
|
|
68
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Fetches portfolio data from Octavfi API.
|
|
87
|
+
* Note: The API currently doesn't support multiple addresses in a single request,
|
|
88
|
+
* so individual requests are made for each address.
|
|
89
|
+
* @param addresses - Array of addresses to fetch data for.
|
|
90
|
+
* @returns Array of portfolio data (may be empty if all requests fail).
|
|
91
|
+
*/
|
|
69
92
|
async function fetchOctavfiPortfolios(addresses) {
|
|
70
93
|
const filteredAddresses = filterEvmAndSolanaAddresses(addresses);
|
|
71
94
|
if (filteredAddresses.length === 0) {
|
|
72
95
|
return [];
|
|
73
96
|
}
|
|
97
|
+
// Fetch portfolios for each address in parallel
|
|
74
98
|
const portfolioPromises = filteredAddresses.map((address) => fetchSinglePortfolio(address));
|
|
75
99
|
const portfolios = await Promise.all(portfolioPromises);
|
|
100
|
+
// Filter out null results (failed requests)
|
|
76
101
|
return portfolios.filter((portfolio) => portfolio !== null);
|
|
77
102
|
}
|
|
78
103
|
//# sourceMappingURL=fetcher.js.map
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { IOctavfiPortfolio } from './types';
|
|
2
2
|
import { IDebankNormalizedResponse } from '../debank/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms Octavfi portfolio response to DeBank-compatible format.
|
|
5
|
+
* This allows Solana addresses to use Octavfi data while maintaining
|
|
6
|
+
* compatibility with existing DeBank parsing functions.
|
|
7
|
+
*
|
|
8
|
+
* @param octavfiPortfolio - Octavfi portfolio response
|
|
9
|
+
* @returns DeBank-compatible response structure
|
|
10
|
+
*/
|
|
3
11
|
export declare function transformOctavfiToDebank(octavfiPortfolio: IOctavfiPortfolio | null | undefined): IDebankNormalizedResponse;
|
|
12
|
+
/**
|
|
13
|
+
* Transforms multiple Octavfi portfolios to DeBank format.
|
|
14
|
+
* Used when fetching multiple addresses.
|
|
15
|
+
*/
|
|
4
16
|
export declare function transformOctavfiPortfoliosToDebank(portfolios: IOctavfiPortfolio[]): any[];
|