augustdigital-sdk 8.20.1
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/LICENSE +21 -0
- package/README.md +349 -0
- package/lib/abis/AddressResolver.d.ts +28 -0
- package/lib/abis/AddressResolver.js +23 -0
- package/lib/abis/ChainlinkV3.d.ts +87 -0
- package/lib/abis/ChainlinkV3.js +117 -0
- package/lib/abis/ERC20.d.ts +168 -0
- package/lib/abis/ERC20.js +226 -0
- package/lib/abis/ERC20_Bytes32.d.ts +139 -0
- package/lib/abis/ERC20_Bytes32.js +196 -0
- package/lib/abis/ERC4626.d.ts +364 -0
- package/lib/abis/ERC4626.js +507 -0
- package/lib/abis/ERC721.d.ts +231 -0
- package/lib/abis/ERC721.js +321 -0
- package/lib/abis/FeeOracle.d.ts +120 -0
- package/lib/abis/FeeOracle.js +162 -0
- package/lib/abis/LendingPool.d.ts +1393 -0
- package/lib/abis/LendingPool.js +1807 -0
- package/lib/abis/LendingPoolV2.d.ts +1413 -0
- package/lib/abis/LendingPoolV2.js +1833 -0
- package/lib/abis/LendingPoolV3.d.ts +1677 -0
- package/lib/abis/LendingPoolV3.js +1160 -0
- package/lib/abis/Loan.d.ts +837 -0
- package/lib/abis/Loan.js +1080 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
- package/lib/abis/Multicall3.d.ts +30 -0
- package/lib/abis/Multicall3.js +97 -0
- package/lib/abis/OFT.d.ts +116 -0
- package/lib/abis/OFT.js +85 -0
- package/lib/abis/PoolAdapter.d.ts +36 -0
- package/lib/abis/PoolAdapter.js +51 -0
- package/lib/abis/RewardDistributor.d.ts +267 -0
- package/lib/abis/RewardDistributor.js +352 -0
- package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
- package/lib/abis/RwaRedeemSubaccount.js +548 -0
- package/lib/abis/SmartAccount.d.ts +17 -0
- package/lib/abis/SmartAccount.js +19 -0
- package/lib/abis/SwapRouter.d.ts +1043 -0
- package/lib/abis/SwapRouter.js +740 -0
- package/lib/abis/TextResolver.d.ts +16 -0
- package/lib/abis/TextResolver.js +16 -0
- package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
- package/lib/abis/TokenizedVaultV2.js +1041 -0
- package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
- package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
- package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
- package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
- package/lib/abis/UniversalResolverResolve.d.ts +69 -0
- package/lib/abis/UniversalResolverResolve.js +35 -0
- package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
- package/lib/abis/UniversalSignatureValidator.js +30 -0
- package/lib/abis/WrapperAdapter.d.ts +71 -0
- package/lib/abis/WrapperAdapter.js +77 -0
- package/lib/abis/index.d.ts +34 -0
- package/lib/abis/index.js +51 -0
- package/lib/adapters/evm/getters.d.ts +19 -0
- package/lib/adapters/evm/getters.js +209 -0
- package/lib/adapters/evm/index.d.ts +353 -0
- package/lib/adapters/evm/index.js +434 -0
- package/lib/adapters/evm/utils.d.ts +8 -0
- package/lib/adapters/evm/utils.js +51 -0
- package/lib/adapters/solana/constants.d.ts +33 -0
- package/lib/adapters/solana/constants.js +52 -0
- package/lib/adapters/solana/getters.d.ts +11 -0
- package/lib/adapters/solana/getters.js +165 -0
- package/lib/adapters/solana/idl/vault-idl.d.ts +272 -0
- package/lib/adapters/solana/idl/vault-idl.js +1084 -0
- package/lib/adapters/solana/index.d.ts +233 -0
- package/lib/adapters/solana/index.js +291 -0
- package/lib/adapters/solana/types.d.ts +67 -0
- package/lib/adapters/solana/types.js +3 -0
- package/lib/adapters/solana/utils.d.ts +141 -0
- package/lib/adapters/solana/utils.js +595 -0
- package/lib/adapters/solana/vault.actions.d.ts +57 -0
- package/lib/adapters/solana/vault.actions.js +379 -0
- package/lib/adapters/stellar/actions.d.ts +28 -0
- package/lib/adapters/stellar/actions.js +77 -0
- package/lib/adapters/stellar/constants.d.ts +43 -0
- package/lib/adapters/stellar/constants.js +53 -0
- package/lib/adapters/stellar/getters.d.ts +68 -0
- package/lib/adapters/stellar/getters.js +290 -0
- package/lib/adapters/stellar/index.d.ts +114 -0
- package/lib/adapters/stellar/index.js +175 -0
- package/lib/adapters/stellar/soroban.d.ts +123 -0
- package/lib/adapters/stellar/soroban.js +613 -0
- package/lib/adapters/stellar/submit.d.ts +34 -0
- package/lib/adapters/stellar/submit.js +149 -0
- package/lib/adapters/stellar/types.d.ts +58 -0
- package/lib/adapters/stellar/types.js +6 -0
- package/lib/adapters/stellar/utils.d.ts +24 -0
- package/lib/adapters/stellar/utils.js +34 -0
- package/lib/adapters/sui/constants.d.ts +14 -0
- package/lib/adapters/sui/constants.js +29 -0
- package/lib/adapters/sui/getters.d.ts +9 -0
- package/lib/adapters/sui/getters.js +60 -0
- package/lib/adapters/sui/index.d.ts +45 -0
- package/lib/adapters/sui/index.js +101 -0
- package/lib/adapters/sui/transformer.d.ts +10 -0
- package/lib/adapters/sui/transformer.js +107 -0
- package/lib/adapters/sui/types.d.ts +66 -0
- package/lib/adapters/sui/types.js +3 -0
- package/lib/adapters/sui/utils.d.ts +10 -0
- package/lib/adapters/sui/utils.js +29 -0
- package/lib/core/analytics/chain-name.d.ts +9 -0
- package/lib/core/analytics/chain-name.js +34 -0
- package/lib/core/analytics/constants.d.ts +5 -0
- package/lib/core/analytics/constants.js +9 -0
- package/lib/core/analytics/env.d.ts +29 -0
- package/lib/core/analytics/env.js +59 -0
- package/lib/core/analytics/index.d.ts +36 -0
- package/lib/core/analytics/index.js +79 -0
- package/lib/core/analytics/instrumentation.d.ts +29 -0
- package/lib/core/analytics/instrumentation.js +277 -0
- package/lib/core/analytics/method-taxonomy.d.ts +19 -0
- package/lib/core/analytics/method-taxonomy.js +128 -0
- package/lib/core/analytics/metrics.d.ts +33 -0
- package/lib/core/analytics/metrics.js +116 -0
- package/lib/core/analytics/sanitize.d.ts +44 -0
- package/lib/core/analytics/sanitize.js +260 -0
- package/lib/core/analytics/sentry-runtime.d.ts +15 -0
- package/lib/core/analytics/sentry-runtime.js +97 -0
- package/lib/core/analytics/sentry.d.ts +67 -0
- package/lib/core/analytics/sentry.js +613 -0
- package/lib/core/analytics/types.d.ts +48 -0
- package/lib/core/analytics/types.js +3 -0
- package/lib/core/analytics/user-identity.d.ts +41 -0
- package/lib/core/analytics/user-identity.js +141 -0
- package/lib/core/analytics/version.d.ts +6 -0
- package/lib/core/analytics/version.js +10 -0
- package/lib/core/attribution.d.ts +111 -0
- package/lib/core/attribution.js +142 -0
- package/lib/core/auth/index.d.ts +1 -0
- package/lib/core/auth/index.js +18 -0
- package/lib/core/auth/verify.d.ts +2 -0
- package/lib/core/auth/verify.js +31 -0
- package/lib/core/base.class.d.ts +152 -0
- package/lib/core/base.class.js +172 -0
- package/lib/core/cache.d.ts +9 -0
- package/lib/core/cache.js +31 -0
- package/lib/core/constants/adapters.d.ts +103 -0
- package/lib/core/constants/adapters.js +180 -0
- package/lib/core/constants/core.d.ts +133 -0
- package/lib/core/constants/core.js +209 -0
- package/lib/core/constants/swap-router.d.ts +150 -0
- package/lib/core/constants/swap-router.js +169 -0
- package/lib/core/constants/vaults.d.ts +93 -0
- package/lib/core/constants/vaults.js +273 -0
- package/lib/core/constants/web3.d.ts +91 -0
- package/lib/core/constants/web3.js +229 -0
- package/lib/core/errors/index.d.ts +114 -0
- package/lib/core/errors/index.js +183 -0
- package/lib/core/fetcher.d.ts +198 -0
- package/lib/core/fetcher.js +903 -0
- package/lib/core/helpers/adapters.d.ts +13 -0
- package/lib/core/helpers/adapters.js +39 -0
- package/lib/core/helpers/chain-address.d.ts +13 -0
- package/lib/core/helpers/chain-address.js +47 -0
- package/lib/core/helpers/chain-error.d.ts +207 -0
- package/lib/core/helpers/chain-error.js +682 -0
- package/lib/core/helpers/chain-support.d.ts +80 -0
- package/lib/core/helpers/chain-support.js +115 -0
- package/lib/core/helpers/core.d.ts +68 -0
- package/lib/core/helpers/core.js +285 -0
- package/lib/core/helpers/explorer-link.d.ts +16 -0
- package/lib/core/helpers/explorer-link.js +26 -0
- package/lib/core/helpers/multicall.d.ts +68 -0
- package/lib/core/helpers/multicall.js +103 -0
- package/lib/core/helpers/revert-decode.d.ts +248 -0
- package/lib/core/helpers/revert-decode.js +515 -0
- package/lib/core/helpers/signer.d.ts +52 -0
- package/lib/core/helpers/signer.js +145 -0
- package/lib/core/helpers/swap-router.d.ts +211 -0
- package/lib/core/helpers/swap-router.js +480 -0
- package/lib/core/helpers/vault-version.d.ts +23 -0
- package/lib/core/helpers/vault-version.js +75 -0
- package/lib/core/helpers/vaults.d.ts +89 -0
- package/lib/core/helpers/vaults.js +235 -0
- package/lib/core/helpers/web3.d.ts +353 -0
- package/lib/core/helpers/web3.js +992 -0
- package/lib/core/index.d.ts +23 -0
- package/lib/core/index.js +40 -0
- package/lib/core/logger/index.d.ts +98 -0
- package/lib/core/logger/index.js +144 -0
- package/lib/core/logger/slack.d.ts +16 -0
- package/lib/core/logger/slack.js +57 -0
- package/lib/core/vault-metadata.d.ts +12 -0
- package/lib/core/vault-metadata.js +42 -0
- package/lib/core/version-check.d.ts +58 -0
- package/lib/core/version-check.js +182 -0
- package/lib/evm/index.d.ts +2 -0
- package/lib/evm/index.js +19 -0
- package/lib/evm/methods/crossChainVault.d.ts +128 -0
- package/lib/evm/methods/crossChainVault.js +853 -0
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
- package/lib/evm/methods/index.d.ts +2 -0
- package/lib/evm/methods/index.js +19 -0
- package/lib/evm/types/crossChain.d.ts +363 -0
- package/lib/evm/types/crossChain.js +20 -0
- package/lib/evm/types/index.d.ts +1 -0
- package/lib/evm/types/index.js +18 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +52 -0
- package/lib/main.d.ts +527 -0
- package/lib/main.js +601 -0
- package/lib/modules/api/fetcher.d.ts +82 -0
- package/lib/modules/api/fetcher.js +150 -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 +313 -0
- package/lib/modules/api/main.js +479 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
- package/lib/modules/sub-accounts/fetcher.js +120 -0
- package/lib/modules/sub-accounts/index.d.ts +2 -0
- package/lib/modules/sub-accounts/index.js +19 -0
- package/lib/modules/sub-accounts/main.d.ts +243 -0
- package/lib/modules/sub-accounts/main.js +205 -0
- package/lib/modules/sub-accounts/utils.d.ts +106 -0
- package/lib/modules/sub-accounts/utils.js +112 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +64 -0
- package/lib/modules/vaults/adapter.helpers.js +184 -0
- package/lib/modules/vaults/fetcher.d.ts +147 -0
- package/lib/modules/vaults/fetcher.js +368 -0
- package/lib/modules/vaults/getters.d.ts +570 -0
- package/lib/modules/vaults/getters.js +3051 -0
- package/lib/modules/vaults/index.d.ts +20 -0
- package/lib/modules/vaults/index.js +44 -0
- package/lib/modules/vaults/main.d.ts +601 -0
- package/lib/modules/vaults/main.js +1623 -0
- package/lib/modules/vaults/prefetch.d.ts +65 -0
- package/lib/modules/vaults/prefetch.js +120 -0
- package/lib/modules/vaults/read.actions.d.ts +225 -0
- package/lib/modules/vaults/read.actions.js +596 -0
- package/lib/modules/vaults/types.d.ts +71 -0
- package/lib/modules/vaults/types.js +3 -0
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
- package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
- package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
- package/lib/modules/vaults/utils/date-utils.js +84 -0
- package/lib/modules/vaults/utils.d.ts +140 -0
- package/lib/modules/vaults/utils.js +799 -0
- package/lib/modules/vaults/write.actions.d.ts +529 -0
- package/lib/modules/vaults/write.actions.js +1749 -0
- package/lib/polyfills.d.ts +1 -0
- package/lib/polyfills.js +12 -0
- package/lib/sdk.d.ts +26721 -0
- package/lib/services/coingecko/fetcher.d.ts +15 -0
- package/lib/services/coingecko/fetcher.js +67 -0
- package/lib/services/coingecko/index.d.ts +2 -0
- package/lib/services/coingecko/index.js +19 -0
- package/lib/services/coingecko/utils.d.ts +1 -0
- package/lib/services/coingecko/utils.js +24 -0
- package/lib/services/debank/fetcher.d.ts +126 -0
- package/lib/services/debank/fetcher.js +47 -0
- package/lib/services/debank/index.d.ts +2 -0
- package/lib/services/debank/index.js +19 -0
- package/lib/services/debank/utils.d.ts +38 -0
- package/lib/services/debank/utils.js +297 -0
- package/lib/services/layerzero/deposits.d.ts +49 -0
- package/lib/services/layerzero/deposits.js +166 -0
- package/lib/services/layerzero/redeems.d.ts +20 -0
- package/lib/services/layerzero/redeems.js +92 -0
- package/lib/services/layerzero/utils.d.ts +9 -0
- package/lib/services/layerzero/utils.js +22 -0
- package/lib/services/octavfi/fetcher.d.ts +9 -0
- package/lib/services/octavfi/fetcher.js +103 -0
- package/lib/services/octavfi/index.d.ts +3 -0
- package/lib/services/octavfi/index.js +20 -0
- package/lib/services/octavfi/types.d.ts +34 -0
- package/lib/services/octavfi/types.js +3 -0
- package/lib/services/octavfi/utils.d.ts +16 -0
- package/lib/services/octavfi/utils.js +212 -0
- package/lib/services/subgraph/fetcher.d.ts +2 -0
- package/lib/services/subgraph/fetcher.js +61 -0
- package/lib/services/subgraph/index.d.ts +2 -0
- package/lib/services/subgraph/index.js +19 -0
- package/lib/services/subgraph/schema.d.ts +45 -0
- package/lib/services/subgraph/schema.js +75 -0
- package/lib/services/subgraph/vaults.d.ts +25 -0
- package/lib/services/subgraph/vaults.js +1106 -0
- package/lib/services/swap-quotes/index.d.ts +105 -0
- package/lib/services/swap-quotes/index.js +77 -0
- package/lib/services/swap-quotes/paraswap.d.ts +51 -0
- package/lib/services/swap-quotes/paraswap.js +138 -0
- package/lib/types/api.d.ts +280 -0
- package/lib/types/api.js +3 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.js +28 -0
- package/lib/types/points.d.ts +28 -0
- package/lib/types/points.js +3 -0
- package/lib/types/pools.d.ts +144 -0
- package/lib/types/pools.js +3 -0
- package/lib/types/staking.d.ts +28 -0
- package/lib/types/staking.js +3 -0
- package/lib/types/sub-accounts.d.ts +140 -0
- package/lib/types/sub-accounts.js +3 -0
- package/lib/types/subgraph.d.ts +74 -0
- package/lib/types/subgraph.js +3 -0
- package/lib/types/typed-contract.d.ts +102 -0
- package/lib/types/typed-contract.js +3 -0
- package/lib/types/user.d.ts +1 -0
- package/lib/types/user.js +3 -0
- package/lib/types/vaults.d.ts +714 -0
- package/lib/types/vaults.js +24 -0
- package/lib/types/web3.d.ts +51 -0
- package/lib/types/web3.js +14 -0
- package/lib/types/webserver.d.ts +698 -0
- package/lib/types/webserver.js +3 -0
- package/package.json +78 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformOctavfiToDebank = transformOctavfiToDebank;
|
|
4
|
+
exports.transformOctavfiPortfoliosToDebank = transformOctavfiPortfoliosToDebank;
|
|
5
|
+
/**
|
|
6
|
+
* Transforms Octavfi portfolio response to DeBank-compatible format.
|
|
7
|
+
* This allows Solana addresses to use Octavfi data while maintaining
|
|
8
|
+
* compatibility with existing DeBank parsing functions.
|
|
9
|
+
*
|
|
10
|
+
* @param octavfiPortfolio - Octavfi portfolio response
|
|
11
|
+
* @returns DeBank-compatible response structure
|
|
12
|
+
*/
|
|
13
|
+
function transformOctavfiToDebank(octavfiPortfolio) {
|
|
14
|
+
if (!octavfiPortfolio) {
|
|
15
|
+
return {
|
|
16
|
+
subaccount: {
|
|
17
|
+
positions: [],
|
|
18
|
+
tokens: [],
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const positions = [];
|
|
23
|
+
const tokens = [];
|
|
24
|
+
// Transform protocols (assetByProtocols) into DeBank positions format
|
|
25
|
+
const assetByProtocols = octavfiPortfolio.assetByProtocols || {};
|
|
26
|
+
Object.entries(assetByProtocols).forEach(([protocolKey, protocol]) => {
|
|
27
|
+
// Skip wallet protocol - we'll handle it separately in tokens
|
|
28
|
+
if (protocolKey === 'wallet') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Extract all assets from nested structure: chains -> protocolPositions -> assets
|
|
32
|
+
const allAssets = [];
|
|
33
|
+
if (protocol.chains) {
|
|
34
|
+
Object.values(protocol.chains).forEach((chain) => {
|
|
35
|
+
if (chain.protocolPositions) {
|
|
36
|
+
Object.values(chain.protocolPositions).forEach((protocolPosition) => {
|
|
37
|
+
// Direct assets
|
|
38
|
+
if (protocolPosition.assets &&
|
|
39
|
+
Array.isArray(protocolPosition.assets)) {
|
|
40
|
+
allAssets.push(...protocolPosition.assets);
|
|
41
|
+
}
|
|
42
|
+
// Nested protocolPositions (like in Kamino)
|
|
43
|
+
if (protocolPosition.protocolPositions &&
|
|
44
|
+
Array.isArray(protocolPosition.protocolPositions)) {
|
|
45
|
+
protocolPosition.protocolPositions.forEach((nestedPos) => {
|
|
46
|
+
if (nestedPos.assets && Array.isArray(nestedPos.assets)) {
|
|
47
|
+
allAssets.push(...nestedPos.assets);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// Create position structure matching DeBank format
|
|
56
|
+
const position = {
|
|
57
|
+
id: protocolKey,
|
|
58
|
+
chain: getChainFromProtocol(protocol, octavfiPortfolio),
|
|
59
|
+
name: protocol.name || protocolKey,
|
|
60
|
+
logo_url: '', // Octavfi doesn't provide protocol logos
|
|
61
|
+
site_url: '', // Octavfi doesn't provide protocol URLs
|
|
62
|
+
portfolio_item_list: [
|
|
63
|
+
{
|
|
64
|
+
name: protocol.name || protocolKey,
|
|
65
|
+
stats: {
|
|
66
|
+
asset_usd_value: parseFloat(protocol.value || '0') || 0,
|
|
67
|
+
debt_usd_value: 0, // Octavfi doesn't distinguish debt, default to 0
|
|
68
|
+
net_usd_value: parseFloat(protocol.value || '0') || 0,
|
|
69
|
+
},
|
|
70
|
+
detail: {
|
|
71
|
+
supply_token_list: allAssets
|
|
72
|
+
.map((asset) => transformAssetToDebankToken(asset, 'supply'))
|
|
73
|
+
.filter((token) => token !== null),
|
|
74
|
+
borrow_token_list: [], // Octavfi doesn't provide borrow data
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
positions.push(position);
|
|
80
|
+
});
|
|
81
|
+
// Transform wallet assets to tokens array
|
|
82
|
+
const walletProtocol = assetByProtocols['wallet'];
|
|
83
|
+
if (walletProtocol && walletProtocol.chains) {
|
|
84
|
+
// Extract assets from nested structure: chains -> protocolPositions -> assets
|
|
85
|
+
Object.values(walletProtocol.chains).forEach((chain) => {
|
|
86
|
+
if (chain.protocolPositions) {
|
|
87
|
+
Object.values(chain.protocolPositions).forEach((protocolPosition) => {
|
|
88
|
+
if (protocolPosition.assets &&
|
|
89
|
+
Array.isArray(protocolPosition.assets)) {
|
|
90
|
+
protocolPosition.assets.forEach((asset) => {
|
|
91
|
+
tokens.push({
|
|
92
|
+
...transformAssetToDebankToken(asset, 'wallet'),
|
|
93
|
+
is_wallet: true,
|
|
94
|
+
is_core: true, // Assume wallet tokens are core tokens
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// Also add protocol assets as tokens (non-wallet)
|
|
103
|
+
Object.entries(assetByProtocols).forEach(([protocolKey, protocol]) => {
|
|
104
|
+
if (protocolKey === 'wallet')
|
|
105
|
+
return;
|
|
106
|
+
if (!protocol || !protocol.chains)
|
|
107
|
+
return;
|
|
108
|
+
// Extract assets from nested structure
|
|
109
|
+
Object.values(protocol.chains).forEach((chain) => {
|
|
110
|
+
if (chain.protocolPositions) {
|
|
111
|
+
Object.values(chain.protocolPositions).forEach((protocolPosition) => {
|
|
112
|
+
// Direct assets
|
|
113
|
+
if (protocolPosition.assets &&
|
|
114
|
+
Array.isArray(protocolPosition.assets)) {
|
|
115
|
+
protocolPosition.assets.forEach((asset) => {
|
|
116
|
+
// Check if token already exists (from wallet)
|
|
117
|
+
const existingToken = tokens.find((t) => t.symbol === asset.symbol &&
|
|
118
|
+
t.chain === (asset.chainKey || asset.chain));
|
|
119
|
+
if (!existingToken) {
|
|
120
|
+
tokens.push({
|
|
121
|
+
...transformAssetToDebankToken(asset, 'supply'),
|
|
122
|
+
is_wallet: false,
|
|
123
|
+
is_core: true, // Assume protocol tokens are core
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
// Nested protocolPositions (like in Kamino)
|
|
129
|
+
if (protocolPosition.protocolPositions &&
|
|
130
|
+
Array.isArray(protocolPosition.protocolPositions)) {
|
|
131
|
+
protocolPosition.protocolPositions.forEach((nestedPos) => {
|
|
132
|
+
if (nestedPos.assets && Array.isArray(nestedPos.assets)) {
|
|
133
|
+
nestedPos.assets.forEach((asset) => {
|
|
134
|
+
const existingToken = tokens.find((t) => t.symbol === asset.symbol &&
|
|
135
|
+
t.chain === (asset.chainKey || asset.chain));
|
|
136
|
+
if (!existingToken) {
|
|
137
|
+
tokens.push({
|
|
138
|
+
...transformAssetToDebankToken(asset, 'supply'),
|
|
139
|
+
is_wallet: false,
|
|
140
|
+
is_core: true,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
subaccount: {
|
|
153
|
+
positions,
|
|
154
|
+
tokens,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Transforms Octavfi asset to DeBank token format
|
|
160
|
+
*/
|
|
161
|
+
function transformAssetToDebankToken(asset, // Using any since the actual structure differs from IOctavfiAsset
|
|
162
|
+
exposureType) {
|
|
163
|
+
if (!asset) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const balance = parseFloat(asset.balance || '0') || 0;
|
|
167
|
+
const price = parseFloat(asset.price || '0') || 0;
|
|
168
|
+
const amount = balance;
|
|
169
|
+
const chain = asset.chainKey || asset.chain || 'unknown';
|
|
170
|
+
const contract = asset.contract || asset.chainContract || asset.contractAddress;
|
|
171
|
+
const decimals = parseInt(asset.decimal || asset.decimals || '18', 10);
|
|
172
|
+
return {
|
|
173
|
+
id: contract || asset.symbol || 'unknown', // Use contract address if available, fallback to symbol
|
|
174
|
+
chain: chain,
|
|
175
|
+
name: asset.name || asset.symbol || 'Unknown',
|
|
176
|
+
symbol: asset.symbol || 'UNKNOWN',
|
|
177
|
+
optimized_symbol: asset.symbol || 'UNKNOWN',
|
|
178
|
+
decimals: decimals,
|
|
179
|
+
logo_url: '', // Octavfi doesn't provide token logos
|
|
180
|
+
amount,
|
|
181
|
+
price,
|
|
182
|
+
protocol_id: '', // Will be set by the calling context
|
|
183
|
+
supplying_exposure: exposureType === 'supply' ? 'true' : undefined,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Determines the chain from protocol data or portfolio chains
|
|
188
|
+
*/
|
|
189
|
+
function getChainFromProtocol(protocol, portfolio) {
|
|
190
|
+
// Try to get chain from protocol.chains structure
|
|
191
|
+
if (protocol.chains) {
|
|
192
|
+
const chainKeys = Object.keys(protocol.chains);
|
|
193
|
+
if (chainKeys.length > 0) {
|
|
194
|
+
return chainKeys[0];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Fallback to first chain in portfolio
|
|
198
|
+
const chains = portfolio.chains || {};
|
|
199
|
+
const chainKeys = Object.keys(chains);
|
|
200
|
+
if (chainKeys.length > 0) {
|
|
201
|
+
return chainKeys[0];
|
|
202
|
+
}
|
|
203
|
+
return 'unknown';
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Transforms multiple Octavfi portfolios to DeBank format.
|
|
207
|
+
* Used when fetching multiple addresses.
|
|
208
|
+
*/
|
|
209
|
+
function transformOctavfiPortfoliosToDebank(portfolios) {
|
|
210
|
+
return portfolios.map(transformOctavfiToDebank);
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchSubgraph = fetchSubgraph;
|
|
4
|
+
exports.fetchSubgraphWithRetry = fetchSubgraphWithRetry;
|
|
5
|
+
const core_1 = require("../../core");
|
|
6
|
+
async function fetchSubgraph(graphUrl, query, apiKey) {
|
|
7
|
+
return fetchSubgraphWithRetry(graphUrl, query, apiKey);
|
|
8
|
+
}
|
|
9
|
+
async function fetchSubgraphWithRetry(graphUrl, query, apiKey, maxRetries = 3, baseDelay = 1000) {
|
|
10
|
+
if (!graphUrl) {
|
|
11
|
+
throw new Error('#fetchSubgraph: URL is not defined');
|
|
12
|
+
}
|
|
13
|
+
let lastError;
|
|
14
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
15
|
+
try {
|
|
16
|
+
const controller = new AbortController();
|
|
17
|
+
const timeoutId = setTimeout(() => controller.abort(), core_1.REQUEST_TIMEOUT_MS / 3); // 30 second timeout
|
|
18
|
+
try {
|
|
19
|
+
const headers = {
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
};
|
|
22
|
+
if (apiKey) {
|
|
23
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
24
|
+
}
|
|
25
|
+
const response = await fetch(graphUrl, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
headers,
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
query: `query ${query}`,
|
|
30
|
+
}),
|
|
31
|
+
signal: controller.signal,
|
|
32
|
+
});
|
|
33
|
+
clearTimeout(timeoutId);
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
catch (fetchError) {
|
|
37
|
+
clearTimeout(timeoutId);
|
|
38
|
+
throw fetchError;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
lastError = error;
|
|
43
|
+
// If it's a timeout error, abort error, or network error and we have retries left
|
|
44
|
+
if (attempt < maxRetries &&
|
|
45
|
+
((error instanceof TypeError &&
|
|
46
|
+
error.message.includes('fetch failed')) ||
|
|
47
|
+
error.name === 'AbortError' ||
|
|
48
|
+
error.message.includes('ETIMEDOUT') ||
|
|
49
|
+
error.message.includes('timeout'))) {
|
|
50
|
+
const delay = baseDelay * 2 ** attempt; // Exponential backoff
|
|
51
|
+
core_1.Logger.log.warn(`fetchSubgraph`, `${graphUrl?.includes('/subgraphs') ? graphUrl?.split('/subgraphs/')?.[1]?.split('/')?.[0] : graphUrl}: Attempt ${attempt + 1} failed, retrying in ${delay}ms`);
|
|
52
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
// If it's not a retryable error or we're out of retries, throw
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
throw lastError;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=fetcher.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./vaults"), exports);
|
|
18
|
+
__exportStar(require("./fetcher"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which field-naming schema a deployed August vault subgraph uses:
|
|
3
|
+
* - `'old'` — snake_case fields (`block_number`, `timestamp_`, `transactionHash_`).
|
|
4
|
+
* - `'new'` — camelCase fields (`blockNumber`, `blockTimestamp`, `transactionHash`).
|
|
5
|
+
*
|
|
6
|
+
* The two templates are otherwise equivalent; the SDK aliases new-schema fields
|
|
7
|
+
* back to the old internal names when querying, so the rest of the code only ever
|
|
8
|
+
* sees the old (snake_case) shape.
|
|
9
|
+
*/
|
|
10
|
+
export type SubgraphSchema = 'old' | 'new';
|
|
11
|
+
/**
|
|
12
|
+
* True when a GraphQL error array reports an unknown field on the queried type
|
|
13
|
+
* (message contains "has no field") — the signature of a schema mismatch.
|
|
14
|
+
*
|
|
15
|
+
* @param errors - GraphQL `errors` array from a subgraph response (may be undefined).
|
|
16
|
+
* @returns `true` if any error message indicates an unknown field, else `false`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isSubgraphSchemaFieldError(errors: {
|
|
19
|
+
message?: string;
|
|
20
|
+
}[] | undefined): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Detects whether a deployed subgraph uses the old or new field schema by probing
|
|
23
|
+
* a single field (`blockTimestamp`) that exists only on the new template.
|
|
24
|
+
*
|
|
25
|
+
* This replaces the previous heuristic — "vault symbol present in the deprecated
|
|
26
|
+
* `SUBGRAPH_VAULT_URLS` map ⇒ old schema, else new" — which mis-guessed any
|
|
27
|
+
* newly-added vault whose subgraph shipped on the old template (e.g.
|
|
28
|
+
* `august-citrea-earn-ctusd`). A wrong guess made every subgraph read query
|
|
29
|
+
* non-existent field names, so the subgraph returned GraphQL errors with no
|
|
30
|
+
* `data` and the SDK silently returned empty sets — emptying the Pending
|
|
31
|
+
* Withdrawals and History tabs for that vault (AUGUST-6568).
|
|
32
|
+
*
|
|
33
|
+
* Because the schema is immutable for a fixed subgraph deployment, the result is
|
|
34
|
+
* cached per URL ({@link SCHEMA_TTL_MS}); across a page's positions/history/
|
|
35
|
+
* withdrawals reads this amounts to a single extra lightweight query per subgraph.
|
|
36
|
+
*
|
|
37
|
+
* Side effects: at most one HTTP POST to the subgraph per URL per TTL window.
|
|
38
|
+
*
|
|
39
|
+
* @param goldskyUrl - Fully-qualified subgraph GraphQL endpoint.
|
|
40
|
+
* @param apiKey - Optional Goldsky API key sent as a Bearer token.
|
|
41
|
+
* @returns `'old'` or `'new'`. Defaults to `'new'` when the URL is empty or the
|
|
42
|
+
* probe is inconclusive (network error / unexpected response) — the schema the
|
|
43
|
+
* majority of current vaults use.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveSubgraphSchema(goldskyUrl: string, apiKey?: string): Promise<SubgraphSchema>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSubgraphSchemaFieldError = isSubgraphSchemaFieldError;
|
|
4
|
+
exports.resolveSubgraphSchema = resolveSubgraphSchema;
|
|
5
|
+
const core_1 = require("../../core");
|
|
6
|
+
const fetcher_1 = require("./fetcher");
|
|
7
|
+
const SCHEMA_CACHE_PREFIX = 'subgraph-schema-';
|
|
8
|
+
// A subgraph's schema is fixed for a given deployment/version, so one probe can
|
|
9
|
+
// serve every subsequent read for a long time. Cache generously.
|
|
10
|
+
const SCHEMA_TTL_MS = 60 * 60 * 1000; // 1 hour
|
|
11
|
+
/**
|
|
12
|
+
* True when a GraphQL error array reports an unknown field on the queried type
|
|
13
|
+
* (message contains "has no field") — the signature of a schema mismatch.
|
|
14
|
+
*
|
|
15
|
+
* @param errors - GraphQL `errors` array from a subgraph response (may be undefined).
|
|
16
|
+
* @returns `true` if any error message indicates an unknown field, else `false`.
|
|
17
|
+
*/
|
|
18
|
+
function isSubgraphSchemaFieldError(errors) {
|
|
19
|
+
return Boolean(errors?.some((e) => e?.message?.includes('has no field')));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Detects whether a deployed subgraph uses the old or new field schema by probing
|
|
23
|
+
* a single field (`blockTimestamp`) that exists only on the new template.
|
|
24
|
+
*
|
|
25
|
+
* This replaces the previous heuristic — "vault symbol present in the deprecated
|
|
26
|
+
* `SUBGRAPH_VAULT_URLS` map ⇒ old schema, else new" — which mis-guessed any
|
|
27
|
+
* newly-added vault whose subgraph shipped on the old template (e.g.
|
|
28
|
+
* `august-citrea-earn-ctusd`). A wrong guess made every subgraph read query
|
|
29
|
+
* non-existent field names, so the subgraph returned GraphQL errors with no
|
|
30
|
+
* `data` and the SDK silently returned empty sets — emptying the Pending
|
|
31
|
+
* Withdrawals and History tabs for that vault (AUGUST-6568).
|
|
32
|
+
*
|
|
33
|
+
* Because the schema is immutable for a fixed subgraph deployment, the result is
|
|
34
|
+
* cached per URL ({@link SCHEMA_TTL_MS}); across a page's positions/history/
|
|
35
|
+
* withdrawals reads this amounts to a single extra lightweight query per subgraph.
|
|
36
|
+
*
|
|
37
|
+
* Side effects: at most one HTTP POST to the subgraph per URL per TTL window.
|
|
38
|
+
*
|
|
39
|
+
* @param goldskyUrl - Fully-qualified subgraph GraphQL endpoint.
|
|
40
|
+
* @param apiKey - Optional Goldsky API key sent as a Bearer token.
|
|
41
|
+
* @returns `'old'` or `'new'`. Defaults to `'new'` when the URL is empty or the
|
|
42
|
+
* probe is inconclusive (network error / unexpected response) — the schema the
|
|
43
|
+
* majority of current vaults use.
|
|
44
|
+
*/
|
|
45
|
+
async function resolveSubgraphSchema(goldskyUrl, apiKey) {
|
|
46
|
+
if (!goldskyUrl)
|
|
47
|
+
return 'new';
|
|
48
|
+
const key = `${SCHEMA_CACHE_PREFIX}${goldskyUrl}`;
|
|
49
|
+
const cached = core_1.CACHE.get(key);
|
|
50
|
+
if (cached)
|
|
51
|
+
return cached;
|
|
52
|
+
try {
|
|
53
|
+
// `blockTimestamp` is a new-schema-only field. If the subgraph rejects it
|
|
54
|
+
// with an unknown-field error, the deployment is old-schema. Schema
|
|
55
|
+
// validation is static, so this is authoritative even when the entity has
|
|
56
|
+
// zero rows.
|
|
57
|
+
const result = await (0, fetcher_1.fetchSubgraph)(goldskyUrl, `{ withdrawalRequesteds(first: 1) { blockTimestamp } }`, apiKey);
|
|
58
|
+
let schema = 'new';
|
|
59
|
+
if (result.status === 200) {
|
|
60
|
+
const json = (await result.json());
|
|
61
|
+
if (isSubgraphSchemaFieldError(json?.errors)) {
|
|
62
|
+
schema = 'old';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
core_1.CACHE.set(key, schema, { ttl: SCHEMA_TTL_MS });
|
|
66
|
+
return schema;
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
// Don't cache an inconclusive probe — let the next call retry. Default to
|
|
70
|
+
// 'new' so freshly-deployed vaults keep working when the probe is flaky.
|
|
71
|
+
core_1.Logger.log.warn('resolveSubgraphSchema', `probe failed for ${goldskyUrl}, defaulting to new schema: ${e instanceof Error ? e.message : 'unknown error'}`);
|
|
72
|
+
return 'new';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IAddress, IContractRunner, ISubgraphTransfer, ISubgraphUserHistoryItem, ISubgraphWithdrawProccessed, ISubgraphWithdrawRequest } from '../../types';
|
|
2
|
+
export declare function isOldSubgraphSchema(vaultSymbol: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param pool
|
|
6
|
+
* @param provider
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSubgraphWithdrawRequests(pool: IAddress, provider: IContractRunner, slackWebookUrl?: string): Promise<ISubgraphWithdrawRequest[]>;
|
|
10
|
+
export declare function getSubgraphWithdrawProccessed(pool: IAddress, provider: IContractRunner, slackWebookUrl?: string): Promise<ISubgraphWithdrawProccessed[]>;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param pool
|
|
14
|
+
* @param provider
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSubgraphAllWithdrawals(pool: IAddress, provider: IContractRunner, slackWebookUrl?: string): Promise<{
|
|
18
|
+
withdrawalRequesteds: ISubgraphWithdrawRequest[];
|
|
19
|
+
withdrawalProcesseds: ISubgraphWithdrawProccessed[];
|
|
20
|
+
}>;
|
|
21
|
+
export declare function getSubgraphUserHistory(user: IAddress, provider: IContractRunner, pool: IAddress, slackWebookUrl?: string): Promise<ISubgraphUserHistoryItem[]>;
|
|
22
|
+
export declare function getSubgraphVaultHistory(provider: IContractRunner, pool: IAddress, slackWebookUrl?: string, opts?: {
|
|
23
|
+
sinceTs?: number;
|
|
24
|
+
}): Promise<ISubgraphUserHistoryItem[]>;
|
|
25
|
+
export declare function getSubgraphUserTransfers(user: IAddress, provider: IContractRunner, pool: IAddress, slackWebookUrl?: string): Promise<ISubgraphTransfer[]>;
|