@upshiftfinance/sdk 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +408 -2
- 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 +953 -0
- package/lib/abis/SwapRouter.js +1228 -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 +249 -0
- package/lib/adapters/evm/index.d.ts +539 -0
- package/lib/adapters/evm/index.js +656 -0
- package/lib/adapters/evm/utils.d.ts +8 -0
- package/lib/adapters/evm/utils.js +51 -0
- package/lib/adapters/solana/confirm.d.ts +88 -0
- package/lib/adapters/solana/confirm.js +291 -0
- package/lib/adapters/solana/constants.d.ts +42 -0
- package/lib/adapters/solana/constants.js +59 -0
- package/lib/adapters/solana/getters.d.ts +42 -0
- package/lib/adapters/solana/getters.js +275 -0
- package/lib/adapters/solana/idl/vault-idl.d.ts +700 -0
- package/lib/adapters/solana/idl/vault-idl.js +2101 -0
- package/lib/adapters/solana/idl/withdrawal-queue-idl.d.ts +795 -0
- package/lib/adapters/solana/idl/withdrawal-queue-idl.js +1864 -0
- package/lib/adapters/solana/index.d.ts +372 -0
- package/lib/adapters/solana/index.js +459 -0
- package/lib/adapters/solana/pricing.d.ts +184 -0
- package/lib/adapters/solana/pricing.js +239 -0
- package/lib/adapters/solana/queue-hints.d.ts +29 -0
- package/lib/adapters/solana/queue-hints.js +59 -0
- package/lib/adapters/solana/queue.actions.d.ts +97 -0
- package/lib/adapters/solana/queue.actions.js +468 -0
- package/lib/adapters/solana/token-reads.d.ts +108 -0
- package/lib/adapters/solana/token-reads.js +145 -0
- package/lib/adapters/solana/types.d.ts +325 -0
- package/lib/adapters/solana/types.js +3 -0
- package/lib/adapters/solana/utils.d.ts +229 -0
- package/lib/adapters/solana/utils.js +773 -0
- package/lib/adapters/solana/vault.actions.d.ts +140 -0
- package/lib/adapters/solana/vault.actions.js +657 -0
- package/lib/adapters/solana/withdrawal-queue.d.ts +125 -0
- package/lib/adapters/solana/withdrawal-queue.js +301 -0
- package/lib/adapters/stellar/actions.d.ts +41 -0
- package/lib/adapters/stellar/actions.js +126 -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 +126 -0
- package/lib/adapters/stellar/index.js +187 -0
- package/lib/adapters/stellar/invocation.d.ts +55 -0
- package/lib/adapters/stellar/invocation.js +92 -0
- package/lib/adapters/stellar/soroban.d.ts +131 -0
- package/lib/adapters/stellar/soroban.js +617 -0
- package/lib/adapters/stellar/submit.d.ts +42 -0
- package/lib/adapters/stellar/submit.js +195 -0
- package/lib/adapters/stellar/types.d.ts +57 -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/client.d.ts +83 -0
- package/lib/adapters/sui/client.js +216 -0
- package/lib/adapters/sui/constants.d.ts +33 -0
- package/lib/adapters/sui/constants.js +31 -0
- package/lib/adapters/sui/index.d.ts +57 -0
- package/lib/adapters/sui/index.js +100 -0
- package/lib/adapters/sui/targets.d.ts +171 -0
- package/lib/adapters/sui/targets.js +225 -0
- package/lib/adapters/sui/utils.d.ts +8 -0
- package/lib/adapters/sui/utils.js +17 -0
- package/lib/core/analytics/app-name.d.ts +27 -0
- package/lib/core/analytics/app-name.js +48 -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 +15 -0
- package/lib/core/analytics/constants.js +28 -0
- package/lib/core/analytics/env.d.ts +46 -0
- package/lib/core/analytics/env.js +147 -0
- package/lib/core/analytics/index.d.ts +39 -0
- package/lib/core/analytics/index.js +83 -0
- package/lib/core/analytics/instrumentation.d.ts +29 -0
- package/lib/core/analytics/instrumentation.js +292 -0
- package/lib/core/analytics/method-taxonomy.d.ts +19 -0
- package/lib/core/analytics/method-taxonomy.js +156 -0
- package/lib/core/analytics/metrics.d.ts +48 -0
- package/lib/core/analytics/metrics.js +142 -0
- package/lib/core/analytics/sanitize.d.ts +57 -0
- package/lib/core/analytics/sanitize.js +272 -0
- package/lib/core/analytics/sentry-runtime.d.ts +15 -0
- package/lib/core/analytics/sentry-runtime.js +131 -0
- package/lib/core/analytics/sentry.d.ts +100 -0
- package/lib/core/analytics/sentry.js +696 -0
- package/lib/core/analytics/types.d.ts +55 -0
- package/lib/core/analytics/types.js +3 -0
- package/lib/core/analytics/user-identity.d.ts +55 -0
- package/lib/core/analytics/user-identity.js +218 -0
- package/lib/core/analytics/version.d.ts +6 -0
- package/lib/core/analytics/version.js +10 -0
- package/lib/core/attribution.d.ts +159 -0
- package/lib/core/attribution.js +194 -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 +35 -0
- package/lib/core/base.class.d.ts +193 -0
- package/lib/core/base.class.js +163 -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 +162 -0
- package/lib/core/constants/core.js +281 -0
- package/lib/core/constants/swap-router.d.ts +180 -0
- package/lib/core/constants/swap-router.js +203 -0
- package/lib/core/constants/vaults.d.ts +93 -0
- package/lib/core/constants/vaults.js +277 -0
- package/lib/core/constants/web3.d.ts +106 -0
- package/lib/core/constants/web3.js +251 -0
- package/lib/core/errors/index.d.ts +177 -0
- package/lib/core/errors/index.js +257 -0
- package/lib/core/fetcher.d.ts +237 -0
- package/lib/core/fetcher.js +1103 -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 +697 -0
- package/lib/core/helpers/chain-support.d.ts +98 -0
- package/lib/core/helpers/chain-support.js +139 -0
- package/lib/core/helpers/concurrency.d.ts +51 -0
- package/lib/core/helpers/concurrency.js +79 -0
- package/lib/core/helpers/core.d.ts +92 -0
- package/lib/core/helpers/core.js +368 -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 +61 -0
- package/lib/core/helpers/signer.js +184 -0
- package/lib/core/helpers/swap-router.d.ts +269 -0
- package/lib/core/helpers/swap-router.js +542 -0
- package/lib/core/helpers/vault-version.d.ts +24 -0
- package/lib/core/helpers/vault-version.js +83 -0
- package/lib/core/helpers/vaults.d.ts +89 -0
- package/lib/core/helpers/vaults.js +241 -0
- package/lib/core/helpers/web3.d.ts +366 -0
- package/lib/core/helpers/web3.js +1034 -0
- package/lib/core/index.d.ts +23 -0
- package/lib/core/index.js +40 -0
- package/lib/core/logger/curator-alert.d.ts +217 -0
- package/lib/core/logger/curator-alert.js +276 -0
- package/lib/core/logger/index.d.ts +99 -0
- package/lib/core/logger/index.js +163 -0
- package/lib/core/logger/slack.d.ts +49 -0
- package/lib/core/logger/slack.js +111 -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 +132 -0
- package/lib/evm/methods/crossChainVault.js +857 -0
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +92 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +239 -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 +596 -0
- package/lib/main.js +681 -0
- package/lib/modules/api/fetcher.d.ts +108 -0
- package/lib/modules/api/fetcher.js +187 -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 +587 -0
- package/lib/modules/api/main.js +911 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
- package/lib/modules/sub-accounts/fetcher.js +96 -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 +249 -0
- package/lib/modules/sub-accounts/main.js +211 -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 +84 -0
- package/lib/modules/vaults/adapter.helpers.js +202 -0
- package/lib/modules/vaults/fetcher.d.ts +147 -0
- package/lib/modules/vaults/fetcher.js +357 -0
- package/lib/modules/vaults/getters.d.ts +1060 -0
- package/lib/modules/vaults/getters.js +4079 -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 +607 -0
- package/lib/modules/vaults/main.js +1687 -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 +406 -0
- package/lib/modules/vaults/read.actions.js +891 -0
- package/lib/modules/vaults/types.d.ts +149 -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 +153 -0
- package/lib/modules/vaults/utils.js +818 -0
- package/lib/modules/vaults/write.actions.d.ts +812 -0
- package/lib/modules/vaults/write.actions.js +2377 -0
- package/lib/polyfills.d.ts +1 -0
- package/lib/polyfills.js +12 -0
- package/lib/sdk.d.ts +30173 -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 +50 -0
- package/lib/services/debank/utils.js +325 -0
- package/lib/services/layerzero/deposits.d.ts +55 -0
- package/lib/services/layerzero/deposits.js +174 -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 +33 -0
- package/lib/services/octavfi/fetcher.js +39 -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 +244 -0
- package/lib/services/subgraph/fetcher.d.ts +2 -0
- package/lib/services/subgraph/fetcher.js +66 -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 +48 -0
- package/lib/services/subgraph/schema.js +87 -0
- package/lib/services/subgraph/vaults.d.ts +83 -0
- package/lib/services/subgraph/vaults.js +1282 -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/services/untangled/fetcher.d.ts +40 -0
- package/lib/services/untangled/fetcher.js +110 -0
- package/lib/services/untangled/index.d.ts +3 -0
- package/lib/services/untangled/index.js +20 -0
- package/lib/services/untangled/types.d.ts +83 -0
- package/lib/services/untangled/types.js +10 -0
- package/lib/services/untangled/utils.d.ts +91 -0
- package/lib/services/untangled/utils.js +339 -0
- package/lib/types/api.d.ts +498 -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 +150 -0
- package/lib/types/sub-accounts.js +3 -0
- package/lib/types/subgraph.d.ts +84 -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 +886 -0
- package/lib/types/vaults.js +30 -0
- package/lib/types/web3.d.ts +100 -0
- package/lib/types/web3.js +14 -0
- package/lib/types/webserver.d.ts +730 -0
- package/lib/types/webserver.js +3 -0
- package/package.json +79 -3
|
@@ -0,0 +1,275 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getSolanaVault = void 0;
|
|
37
|
+
exports.getSolanaVaultAumUsd = getSolanaVaultAumUsd;
|
|
38
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
39
|
+
const utils_1 = require("./utils");
|
|
40
|
+
const SolanaConstants = __importStar(require("./constants"));
|
|
41
|
+
const core_1 = require("../../core");
|
|
42
|
+
const utils_2 = require("../../modules/vaults/utils");
|
|
43
|
+
const withdrawal_queue_1 = require("./withdrawal-queue");
|
|
44
|
+
/**
|
|
45
|
+
* Fetch Solana vault data from on-chain program state.
|
|
46
|
+
* Falls back to backend-only data when Solana RPC is unavailable,
|
|
47
|
+
* ensuring vaults always appear in the list even without on-chain access.
|
|
48
|
+
*
|
|
49
|
+
* When the vault has a withdrawal queue, `withdrawalQueue` carries its live
|
|
50
|
+
* summary, at the cost of one extra `getMultipleAccountsInfo` (the queue and a
|
|
51
|
+
* fresh read of the vault state, for `enabled`). A failed queue read is
|
|
52
|
+
* logged and leaves the field out rather than failing the vault.
|
|
53
|
+
* @param tokenizedVault Vault metadata from backend
|
|
54
|
+
* @param options RPC configuration with Solana service
|
|
55
|
+
* @returns Formatted vault object with Solana-specific fields
|
|
56
|
+
*/
|
|
57
|
+
const getSolanaVault = async (tokenizedVault, options) => {
|
|
58
|
+
// `options.rpcUrl` is resolved upstream as `providers[vault.chain]`, and that
|
|
59
|
+
// map is keyed by EVM chain id — Solana's synthetic id is never in it, so the
|
|
60
|
+
// field arrives undefined for every Solana vault however well the app has
|
|
61
|
+
// configured its Solana RPC. The connection built from that RPC *is* passed
|
|
62
|
+
// (`solanaService`), so take the endpoint off it rather than fetching against
|
|
63
|
+
// `undefined`.
|
|
64
|
+
const solanaRpcUrl = (options.rpcUrl ??
|
|
65
|
+
options.solanaService?.connection?.rpcEndpoint);
|
|
66
|
+
const solanaMetadata = tokenizedVault.solana_vault_metadata;
|
|
67
|
+
const programId = utils_1.SolanaUtils.resolveProgramId(tokenizedVault.address, solanaMetadata);
|
|
68
|
+
// Fallback decimals: prefer backend metadata, then the application default
|
|
69
|
+
const fallbackDecimals = solanaMetadata?.deposit_token_decimals ?? SolanaConstants.fallbackDecimals;
|
|
70
|
+
let vaultState = null;
|
|
71
|
+
let depositMint = null;
|
|
72
|
+
let onChainAvailable = false;
|
|
73
|
+
// Attempt to fetch on-chain data; gracefully degrade if RPC is unavailable
|
|
74
|
+
try {
|
|
75
|
+
vaultState = await utils_1.SolanaUtils.getVaultStateReadOnly({
|
|
76
|
+
idl: SolanaConstants.vaultIdl,
|
|
77
|
+
vaultProgramId: programId,
|
|
78
|
+
vaultAddress: solanaMetadata?.vault_state_pda ?? undefined,
|
|
79
|
+
endpoint: solanaRpcUrl,
|
|
80
|
+
connection: options?.solanaService?.connection,
|
|
81
|
+
});
|
|
82
|
+
// `getVaultStateReadOnly` swallows RPC and decode failures and resolves
|
|
83
|
+
// `{ vaultState: null }` rather than throwing, so a resolved call is not
|
|
84
|
+
// proof the chain was reachable. Only a decoded state counts; otherwise
|
|
85
|
+
// `totalAssets` must come from the backend's `latest_reported_tvl`
|
|
86
|
+
// instead of being computed as 0 from a missing `localAum`/`deployedAum`.
|
|
87
|
+
onChainAvailable = vaultState?.vaultState != null;
|
|
88
|
+
if (vaultState?.vaultState?.depositMint) {
|
|
89
|
+
try {
|
|
90
|
+
depositMint = await utils_1.SolanaUtils.getToken({
|
|
91
|
+
mintAddress: vaultState.vaultState.depositMint,
|
|
92
|
+
endpoint: solanaRpcUrl,
|
|
93
|
+
connection: options?.solanaService?.connection,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (tokenError) {
|
|
97
|
+
core_1.Logger.log.warn('getSolanaVault', 'Token fetch failed, using backend metadata', { vault: tokenizedVault.address, error: tokenError });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
// Only degrade gracefully for network/RPC issues; re-throw everything else
|
|
103
|
+
const isNetworkError = error instanceof Error &&
|
|
104
|
+
(/fetch failed|ETIMEDOUT|timeout|ECONNREFUSED|403|503|network/i.test(error.message) ||
|
|
105
|
+
error.name === 'AbortError');
|
|
106
|
+
if (!isNetworkError) {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
core_1.Logger.log.warn('getSolanaVault', 'RPC unavailable, using backend-only data', { vault: tokenizedVault.address, error });
|
|
110
|
+
}
|
|
111
|
+
const decimals = vaultState?.depositMintDecimals ?? fallbackDecimals;
|
|
112
|
+
// Fetch share mint supply to get totalSupply.
|
|
113
|
+
// Prefer vaultState.shareMint (correct for multi-vault programs like jitoSOL);
|
|
114
|
+
// fall back to deriveShareMintPda(programId) for legacy single-vault programs.
|
|
115
|
+
let totalSupply = (0, core_1.toNormalizedBn)(0, decimals);
|
|
116
|
+
let shareDecimals = decimals;
|
|
117
|
+
if (onChainAvailable) {
|
|
118
|
+
try {
|
|
119
|
+
const shareMintFromState = vaultState?.vaultState?.shareMint;
|
|
120
|
+
const shareMintKey = shareMintFromState
|
|
121
|
+
? new web3_js_1.PublicKey(String(shareMintFromState))
|
|
122
|
+
: utils_1.SolanaUtils.deriveShareMintPda(programId);
|
|
123
|
+
const shareMintAccountInfo = await options.solanaService?.connection.getParsedAccountInfo(shareMintKey);
|
|
124
|
+
if (shareMintAccountInfo?.value) {
|
|
125
|
+
const parsedData = shareMintAccountInfo.value.data;
|
|
126
|
+
const { supply, decimals: mintDecimals } = parsedData.parsed.info;
|
|
127
|
+
totalSupply = (0, core_1.toNormalizedBn)(BigInt(supply), mintDecimals);
|
|
128
|
+
shareDecimals = mintDecimals;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
core_1.Logger.log.warn('getSolanaVault', 'Error fetching share mint info', {
|
|
133
|
+
vault: tokenizedVault.address,
|
|
134
|
+
error,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Total assets must mirror the on-chain `VaultState::total_assets()` which
|
|
139
|
+
// is `local_aum + deployed_aum` (see solana-vaults/programs/august-vault/
|
|
140
|
+
// src/state/vault.rs). Reading deployed_aum alone makes the displayed share
|
|
141
|
+
// price drop below 1.0 the instant the operator deploys part of the vault,
|
|
142
|
+
// even though the vault has had no PnL.
|
|
143
|
+
let totalAssets;
|
|
144
|
+
// `local_aum` is what the vault program itself holds — the idle buffer the
|
|
145
|
+
// operators' portfolios (Octav) never see.
|
|
146
|
+
let idleAssets;
|
|
147
|
+
if (onChainAvailable) {
|
|
148
|
+
const localAumRaw = vaultState?.vaultState?.localAum;
|
|
149
|
+
const deployedAumRaw = vaultState?.vaultState?.deployedAum;
|
|
150
|
+
const localAum = localAumRaw !== null && localAumRaw !== undefined
|
|
151
|
+
? BigInt(localAumRaw.toString())
|
|
152
|
+
: BigInt(0);
|
|
153
|
+
const deployedAum = deployedAumRaw !== null && deployedAumRaw !== undefined
|
|
154
|
+
? BigInt(deployedAumRaw.toString())
|
|
155
|
+
: BigInt(0);
|
|
156
|
+
totalAssets = (0, core_1.toNormalizedBn)(localAum + deployedAum, decimals);
|
|
157
|
+
idleAssets = (0, core_1.toNormalizedBn)(localAum, decimals);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
totalAssets = (0, utils_2.backendTvlToNormalizedBn)(tokenizedVault.latest_reported_tvl, decimals);
|
|
161
|
+
}
|
|
162
|
+
// Deposit asset: use on-chain data if available, otherwise backend metadata
|
|
163
|
+
const depositAsset = {
|
|
164
|
+
address: depositMint?.address ?? solanaMetadata?.deposit_mint,
|
|
165
|
+
symbol: depositMint?.symbol ?? solanaMetadata?.deposit_token_symbol,
|
|
166
|
+
decimals: depositMint?.decimals ?? fallbackDecimals,
|
|
167
|
+
};
|
|
168
|
+
if (!depositAsset.address) {
|
|
169
|
+
core_1.Logger.log.warn('getSolanaVault', 'Missing deposit asset address', {
|
|
170
|
+
vault: tokenizedVault.address,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
let withdrawalQueue;
|
|
174
|
+
const solanaService = options.solanaService;
|
|
175
|
+
if (onChainAvailable && vaultState?.vaultState && solanaService) {
|
|
176
|
+
try {
|
|
177
|
+
const queueProgramId = (0, withdrawal_queue_1.resolveQueueProgramId)(solanaService);
|
|
178
|
+
withdrawalQueue = queueProgramId
|
|
179
|
+
? await (0, withdrawal_queue_1.getSolanaWithdrawalQueueSummary)({
|
|
180
|
+
connection: solanaService.connection,
|
|
181
|
+
queueProgramId,
|
|
182
|
+
vaultState: solanaMetadata?.vault_state_pda
|
|
183
|
+
? new web3_js_1.PublicKey(solanaMetadata.vault_state_pda)
|
|
184
|
+
: utils_1.SolanaUtils.deriveVaultStatePda(programId),
|
|
185
|
+
shareDecimals,
|
|
186
|
+
})
|
|
187
|
+
: undefined;
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
core_1.Logger.log.warn('getSolanaVault', 'Withdrawal queue read failed', {
|
|
191
|
+
vault: tokenizedVault.address,
|
|
192
|
+
error,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Build unified vault object combining on-chain and backend data
|
|
197
|
+
const vault = (0, utils_2.buildBackendVault)(tokenizedVault, {
|
|
198
|
+
chainId: core_1.SPECIAL_CHAINS.solana.chainId,
|
|
199
|
+
version: 'sol-0',
|
|
200
|
+
name: tokenizedVault.vault_name || 'Solana Program',
|
|
201
|
+
totalAssets,
|
|
202
|
+
totalSupply,
|
|
203
|
+
depositAssets: [depositAsset],
|
|
204
|
+
receipt: {
|
|
205
|
+
address: tokenizedVault.address,
|
|
206
|
+
symbol: tokenizedVault.receipt_token_symbol || 'upSOL',
|
|
207
|
+
decimals: decimals,
|
|
208
|
+
},
|
|
209
|
+
programId,
|
|
210
|
+
});
|
|
211
|
+
if (idleAssets)
|
|
212
|
+
vault.idleAssets = idleAssets;
|
|
213
|
+
if (tokenizedVault.eoa_operators?.length) {
|
|
214
|
+
vault.eoa_operators = tokenizedVault.eoa_operators;
|
|
215
|
+
}
|
|
216
|
+
if (withdrawalQueue)
|
|
217
|
+
vault.withdrawalQueue = withdrawalQueue;
|
|
218
|
+
return vault;
|
|
219
|
+
};
|
|
220
|
+
exports.getSolanaVault = getSolanaVault;
|
|
221
|
+
/**
|
|
222
|
+
* Read a Solana vault's AUM in USD fresh from its state account.
|
|
223
|
+
*
|
|
224
|
+
* For comparing the vault with live portfolio data: the state cache behind
|
|
225
|
+
* {@link getSolanaVault} can be up to 24h old, which would show yield accrued
|
|
226
|
+
* since as unattributed. Costs one uncached vault-state read (plus the deposit
|
|
227
|
+
* mint's decimals), then one cached price lookup.
|
|
228
|
+
*
|
|
229
|
+
* Never rejects. A failed read, a missing state account or symbol, or a
|
|
230
|
+
* non-positive price returns `null`, so the caller can drop the comparison
|
|
231
|
+
* without losing the rest of its result.
|
|
232
|
+
*
|
|
233
|
+
* @param tokenizedVault - Backend row of the Solana vault
|
|
234
|
+
* @param options - Must carry `solanaService` for the RPC connection
|
|
235
|
+
* @returns The vault's deployed and idle AUM in USD, or `null`
|
|
236
|
+
*/
|
|
237
|
+
async function getSolanaVaultAumUsd(tokenizedVault, options) {
|
|
238
|
+
const metadata = tokenizedVault.solana_vault_metadata;
|
|
239
|
+
const symbol = metadata?.deposit_token_symbol;
|
|
240
|
+
try {
|
|
241
|
+
if (!symbol)
|
|
242
|
+
throw new Error('no deposit_token_symbol in vault metadata');
|
|
243
|
+
const state = await utils_1.SolanaUtils.getVaultStateReadOnly({
|
|
244
|
+
idl: SolanaConstants.vaultIdl,
|
|
245
|
+
vaultProgramId: utils_1.SolanaUtils.resolveProgramId(tokenizedVault.address, metadata),
|
|
246
|
+
vaultAddress: metadata?.vault_state_pda ?? undefined,
|
|
247
|
+
connection: options?.solanaService?.connection,
|
|
248
|
+
fresh: true,
|
|
249
|
+
});
|
|
250
|
+
const vaultState = state?.vaultState;
|
|
251
|
+
// Checked before pricing so an unreachable RPC costs no price request.
|
|
252
|
+
if (!vaultState)
|
|
253
|
+
throw new Error('vault state unavailable');
|
|
254
|
+
const price = await (0, core_1.fetchTokenPrice)(symbol, undefined, undefined, options?.headers);
|
|
255
|
+
if (!(price > 0))
|
|
256
|
+
throw new Error(`${symbol} priced at ${price}`);
|
|
257
|
+
const decimals = state.depositMintDecimals ??
|
|
258
|
+
metadata?.deposit_token_decimals ??
|
|
259
|
+
SolanaConstants.fallbackDecimals;
|
|
260
|
+
const toUsd = (raw) => Number((0, core_1.toNormalizedBn)(BigInt(String(raw ?? 0)), decimals).normalized) *
|
|
261
|
+
price;
|
|
262
|
+
return {
|
|
263
|
+
deployedUsd: toUsd(vaultState.deployedAum),
|
|
264
|
+
idleUsd: toUsd(vaultState.localAum),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
core_1.Logger.log.warn('getSolanaVaultAumUsd', 'AUM read failed', {
|
|
269
|
+
vault: tokenizedVault.address,
|
|
270
|
+
error,
|
|
271
|
+
});
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=getters.js.map
|