@upshiftfinance/sdk 0.0.0-stage → 0.1.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/constants.d.ts +1 -0
- package/lib/adapters/sui/constants.js +9 -0
- package/lib/adapters/sui/getters.d.ts +24 -0
- package/lib/adapters/sui/getters.js +134 -0
- package/lib/adapters/sui/index.d.ts +53 -0
- package/lib/adapters/sui/index.js +96 -0
- package/lib/adapters/sui/transformer.d.ts +10 -0
- package/lib/adapters/sui/transformer.js +115 -0
- package/lib/adapters/sui/types.d.ts +70 -0
- package/lib/adapters/sui/types.js +3 -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 +30154 -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 +81 -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 +78 -3
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { IAddress, IContractRunner, IHistoricalTimeseriesResponse, ITokenizedVault, IWSMonitorHeaders, IWSVaultLoan, VaultAddress } from '../types';
|
|
2
|
+
import { WEBSERVER_URL } from './constants/core';
|
|
3
|
+
/**
|
|
4
|
+
* API Fetching and Data Utilities
|
|
5
|
+
*
|
|
6
|
+
* Core fetching functions for Upshift backend services:
|
|
7
|
+
* - Authentication: fetchUpshiftWithKey, fetchUpshiftWithBearer, fetchUpshiftPublic
|
|
8
|
+
* - Retry Logic: withRetry, isRetryableError, promiseSettle
|
|
9
|
+
* - Vault Data: fetchTokenizedVaults, fetchTokenizedVaultLoans
|
|
10
|
+
* - Pricing: fetchTokenPrice (with CoinGecko fallback)
|
|
11
|
+
* - Caching: LRU cache for API responses
|
|
12
|
+
*/
|
|
13
|
+
export type IFetchUpshiftMethods = 'get' | 'post' | 'put';
|
|
14
|
+
export type IFetchUpshiftOptions = {
|
|
15
|
+
method?: IFetchUpshiftMethods;
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
data?: unknown;
|
|
18
|
+
server?: keyof typeof WEBSERVER_URL;
|
|
19
|
+
/** Caller-supplied AbortSignal; combined with the default timeout. */
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
/** Per-request timeout in ms. Defaults to `REQUEST_TIMEOUT_MS`. */
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated No longer has any effect: an absent `apiKey` already sends an
|
|
25
|
+
* anonymous request. Will be removed in a future major version; drop it.
|
|
26
|
+
*/
|
|
27
|
+
override?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Override the default request timeout used by every Upshift fetcher helper
|
|
31
|
+
* when the caller doesn't supply a per-call `timeoutMs`. Pass `null` (or
|
|
32
|
+
* call with no arguments) to clear the override and fall back to the
|
|
33
|
+
* compiled-in `REQUEST_TIMEOUT_MS`.
|
|
34
|
+
*
|
|
35
|
+
* @param ms - Positive number of milliseconds to wait before aborting, or
|
|
36
|
+
* `null` to clear.
|
|
37
|
+
*/
|
|
38
|
+
export declare function setSdkRequestTimeout(ms?: number | null): void;
|
|
39
|
+
/**
|
|
40
|
+
* Read the active default request timeout — the SDK-level override if set,
|
|
41
|
+
* otherwise the compiled-in `REQUEST_TIMEOUT_MS`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getSdkRequestTimeout(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Record the consuming application's `appName` so every request to the
|
|
46
|
+
* Upshift backend carries it as `x-august-app`, next to
|
|
47
|
+
* `x-august-sdk-version`. This gives the backend per-integrator request
|
|
48
|
+
* counts that do not depend on Sentry sampling.
|
|
49
|
+
*
|
|
50
|
+
* Process-global, last writer wins — the same contract as
|
|
51
|
+
* `setSdkRequestTimeout` and `setPublicApiBaseUrl`. The `UpshiftSDK`
|
|
52
|
+
* constructor calls this with its validated `appName`.
|
|
53
|
+
*
|
|
54
|
+
* @param appName - Validated app-name slug, or `null` to stop sending it.
|
|
55
|
+
*/
|
|
56
|
+
export declare function setSdkAppName(appName?: string | null): void;
|
|
57
|
+
/**
|
|
58
|
+
* Override the base URL used for `WEBSERVER_URL.public` requests — the
|
|
59
|
+
* unauthenticated vault-catalog API that `getVault` / `fetchTokenizedVault`
|
|
60
|
+
* (and the other `fetchUpshiftPublic` callers) read from. Defaults to the
|
|
61
|
+
* compiled-in prod base (`https://api.augustdigital.io/api/v1`); pass `null`
|
|
62
|
+
* (or call with no arguments) to clear.
|
|
63
|
+
*
|
|
64
|
+
* Intended for non-prod deployments that run against an ISOLATED backend
|
|
65
|
+
* (e.g. a staging API): set it once at construction via
|
|
66
|
+
* `IUpshiftBase.publicApiBaseUrl` so a staging-only vault resolves. Production
|
|
67
|
+
* leaves it unset, so behaviour is unchanged.
|
|
68
|
+
*
|
|
69
|
+
* This is a process-global override on the fetcher helpers. The SDK constructor
|
|
70
|
+
* calls it on EVERY instantiation (with `null` when `publicApiBaseUrl` is
|
|
71
|
+
* omitted), so the last `UpshiftSDK` instantiated is authoritative — a prod
|
|
72
|
+
* instance resets it to the default even after a prior staging instance set it.
|
|
73
|
+
* An invalid or non-http(s) URL is treated as "no override": it RESETS to the
|
|
74
|
+
* compiled-in default (warned) rather than retaining a prior value, so a bad env
|
|
75
|
+
* value can neither break fetches nor silently leave a previous instance's base
|
|
76
|
+
* in place.
|
|
77
|
+
*
|
|
78
|
+
* Whenever the effective base CHANGES, the shared public-response cache is
|
|
79
|
+
* cleared, so catalog data fetched from the previous backend is never served for
|
|
80
|
+
* the new one (e.g. a prod-cached vault leaking into a staging instance). Base
|
|
81
|
+
* changes happen at construction, when the cache is cold, so this is ~free.
|
|
82
|
+
*
|
|
83
|
+
* @param url - Absolute http(s) base URL (trailing slash is trimmed). `null`, or
|
|
84
|
+
* an invalid / non-http(s) value, resets to the compiled-in public base.
|
|
85
|
+
*/
|
|
86
|
+
export declare function setPublicApiBaseUrl(url?: string | null): void;
|
|
87
|
+
/**
|
|
88
|
+
* Read the active base for the `public` server — the SDK-level override if set,
|
|
89
|
+
* otherwise the compiled-in `WEBSERVER_URL.public`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function getPublicApiBaseUrl(): string;
|
|
92
|
+
import { CACHE, getSafeCache, setSafeCache } from './cache';
|
|
93
|
+
export { CACHE, getSafeCache, setSafeCache };
|
|
94
|
+
/**
|
|
95
|
+
* Make requests to Upshift backend services, sending an API key when one is
|
|
96
|
+
* configured. Many backend routes — vault-linked sub-account reads, the two
|
|
97
|
+
* collateral risk routes, timelock requests — answer anonymous callers, so a
|
|
98
|
+
* missing key is not an error here: the request goes out without the
|
|
99
|
+
* `x-api-key` header and the backend decides. Routes that do require a key
|
|
100
|
+
* answer `401`, which surfaces as an `UpshiftAuthError` with code
|
|
101
|
+
* `AUTH_UNAUTHORIZED`.
|
|
102
|
+
* Automatically logs errors with correlation IDs for debugging.
|
|
103
|
+
* @param apiKey - Upshift API key, or `undefined` for an anonymous request
|
|
104
|
+
* @param relativeUrl - Endpoint path relative to base URL
|
|
105
|
+
* @param options - Request configuration including method and headers
|
|
106
|
+
* @returns Response object if successful
|
|
107
|
+
* @throws Error with correlation ID if request fails
|
|
108
|
+
*/
|
|
109
|
+
export declare function fetchUpshiftWithKey(apiKey: string | undefined, relativeUrl: string, options?: IFetchUpshiftOptions): Promise<Response>;
|
|
110
|
+
/**
|
|
111
|
+
* Make unauthenticated requests to Upshift public API endpoints.
|
|
112
|
+
* Used for fetching vault metadata and public market data.
|
|
113
|
+
* @param relativeUrl - Endpoint path relative to public API base URL
|
|
114
|
+
* @param options - Request configuration including method and headers
|
|
115
|
+
* @returns Response object if successful
|
|
116
|
+
* @throws Error with correlation ID if request fails
|
|
117
|
+
*/
|
|
118
|
+
export declare function fetchUpshiftPublic(relativeUrl: string, options?: IFetchUpshiftOptions): Promise<Response>;
|
|
119
|
+
/**
|
|
120
|
+
* Make authenticated requests using Bearer token authentication.
|
|
121
|
+
* Typically used for user-specific operations requiring OAuth tokens.
|
|
122
|
+
* @param bearerToken - OAuth bearer token
|
|
123
|
+
* @param relativeUrl - Endpoint path relative to base URL
|
|
124
|
+
* @param options - Request configuration including method and headers
|
|
125
|
+
* @returns Response object if successful
|
|
126
|
+
* @throws Error with correlation ID if request fails
|
|
127
|
+
*/
|
|
128
|
+
export declare function fetchUpshiftWithBearer(bearerToken: string, relativeUrl: string, options?: IFetchUpshiftOptions): Promise<Response>;
|
|
129
|
+
/**
|
|
130
|
+
* Check if an error is network-related and suitable for retry.
|
|
131
|
+
* Identifies timeouts, connection resets, and fetch failures.
|
|
132
|
+
*/
|
|
133
|
+
export declare function isRetryableError(error: Error): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Wrap async operations with exponential backoff retry logic.
|
|
136
|
+
* Retries on network errors with increasing delays between attempts.
|
|
137
|
+
* @param fn - Async function to execute with retry logic
|
|
138
|
+
* @param maxRetries - Maximum number of retry attempts
|
|
139
|
+
* @param baseDelay - Initial delay in milliseconds (doubles each retry)
|
|
140
|
+
* @param shouldRetry - Custom function to determine if error is retryable
|
|
141
|
+
* @returns Result of successful function execution
|
|
142
|
+
* @throws Last error if all retries exhausted
|
|
143
|
+
*/
|
|
144
|
+
export declare function withRetry<T>(fn: () => Promise<T>, maxRetries?: number, baseDelay?: number, shouldRetry?: (error: Error) => boolean): Promise<T>;
|
|
145
|
+
/**
|
|
146
|
+
* Fetch tokenized vault configurations from backend API.
|
|
147
|
+
* Results are cached to reduce API calls. Optionally filter by specific vault address.
|
|
148
|
+
* @param pool - Optional vault address to filter results
|
|
149
|
+
* @param headers - Monitoring headers for request tracking
|
|
150
|
+
* @returns Array of tokenized vault configurations
|
|
151
|
+
*/
|
|
152
|
+
export declare function fetchTokenizedVault(pool: VaultAddress, headers?: IWSMonitorHeaders, loadSubaccounts?: boolean, loadSnapshots?: boolean): Promise<ITokenizedVault[]>;
|
|
153
|
+
/**
|
|
154
|
+
* Fetch tokenized vault configurations from backend API.
|
|
155
|
+
* Results are cached to reduce API calls. Optionally filter by specific vault address.
|
|
156
|
+
* @param pool - Optional vault address to filter results
|
|
157
|
+
* @param headers - Monitoring headers for request tracking
|
|
158
|
+
* @param loadSubaccounts - Optional flag to load subaccounts and EOA operators (defaults to true on API)
|
|
159
|
+
* @returns Array of tokenized vault configurations
|
|
160
|
+
*/
|
|
161
|
+
export declare function fetchTokenizedVaults(pool?: IAddress, headers?: IWSMonitorHeaders, loadSubaccounts?: boolean, loadSnapshots?: boolean): Promise<ITokenizedVault[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Fetch current USD price for a token symbol or vault LP token.
|
|
164
|
+
* For vault LP tokens, calculates share price using totalAssets/totalSupply ratio.
|
|
165
|
+
* Falls back to CoinGecko if primary source fails.
|
|
166
|
+
* @param symbol - Token symbol or contract address
|
|
167
|
+
* @param provider - Optional web3 provider for on-chain price calculations
|
|
168
|
+
* @param coinGeckoKey - Optional CoinGecko API key for fallback pricing
|
|
169
|
+
* @param headers - Monitoring headers for request tracking
|
|
170
|
+
* @returns Token price in USD
|
|
171
|
+
*/
|
|
172
|
+
export declare function fetchTokenPrice(symbol: string, provider?: IContractRunner, coinGeckoKey?: string, headers?: IWSMonitorHeaders): Promise<number>;
|
|
173
|
+
/**
|
|
174
|
+
* Fetch token price by contract address and chain ID from Upshift price server.
|
|
175
|
+
* @param address - Token contract address
|
|
176
|
+
* @param chainId - Network chain ID
|
|
177
|
+
* @param headers - Optional monitoring headers for request tracking
|
|
178
|
+
* @returns Token price in USD, or 0 if not found
|
|
179
|
+
*/
|
|
180
|
+
export declare function fetchTokenPriceByAddress(address: VaultAddress, chainId: number, headers?: IWSMonitorHeaders): Promise<number>;
|
|
181
|
+
/**
|
|
182
|
+
* Fetch active loans for a specific vault from backend API.
|
|
183
|
+
* Results are cached per vault and chain to reduce API calls.
|
|
184
|
+
* @param pool - Vault address
|
|
185
|
+
* @param chainId - Network chain ID
|
|
186
|
+
* @param headers - Monitoring headers for request tracking
|
|
187
|
+
* @returns Array of active loan objects
|
|
188
|
+
*/
|
|
189
|
+
export declare function fetchTokenizedVaultLoans(pool: VaultAddress, chainId: number, headers?: IWSMonitorHeaders): Promise<IWSVaultLoan[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Fetch subaccount loans for a specific tokenized vault (lending pool).
|
|
192
|
+
* Retrieves all active subaccount loan data from the backend.
|
|
193
|
+
* @param pool - Vault address
|
|
194
|
+
* @param chainId - Network chain ID
|
|
195
|
+
* @param headers - Monitoring headers for request tracking
|
|
196
|
+
* @returns Array of active subaccount loan objects
|
|
197
|
+
*/
|
|
198
|
+
export declare function fetchTokenizedVaultSubaccountLoans(pool: VaultAddress, chainId: number, headers?: IWSMonitorHeaders): Promise<IWSVaultLoan[]>;
|
|
199
|
+
/**
|
|
200
|
+
* Fetch historical timeseries data for a specific vault.
|
|
201
|
+
* Returns TVL, APY, PnL, and share price data over time.
|
|
202
|
+
* @param vaultAddress - Vault contract address
|
|
203
|
+
* @param nDays - Number of days of historical data to fetch (default 30, min 1)
|
|
204
|
+
* @param headers - Monitoring headers for request tracking
|
|
205
|
+
* @returns Historical timeseries data with date keys
|
|
206
|
+
*/
|
|
207
|
+
export declare function fetchVaultHistoricalTimeseries(vaultAddress: IAddress, nDays?: number, headers?: IWSMonitorHeaders): Promise<IHistoricalTimeseriesResponse>;
|
|
208
|
+
/**
|
|
209
|
+
* Settle a batch of async tasks, allowing partial failure.
|
|
210
|
+
*
|
|
211
|
+
* Unlike `Promise.all`, a failing task does not reject the batch: its slot in
|
|
212
|
+
* the result array is `null`, so results stay index-aligned with the input.
|
|
213
|
+
*
|
|
214
|
+
* Retries only apply to **thunks** (`() => Promise<T>`): a thunk is invoked
|
|
215
|
+
* again on each attempt via {@link withRetry} (exponential backoff from
|
|
216
|
+
* `baseDelay`, retryable network errors only). A **bare promise** is already
|
|
217
|
+
* in flight and cannot be re-executed — re-awaiting it just yields the same
|
|
218
|
+
* rejection — so bare promises are settled exactly once, with no retry and
|
|
219
|
+
* no backoff sleep. Pass thunks when a retry is actually wanted.
|
|
220
|
+
*
|
|
221
|
+
* @param tasks - Promises and/or thunks to settle. Mixed arrays are allowed.
|
|
222
|
+
* An empty array resolves to `[]`.
|
|
223
|
+
* @param maxRetries - Maximum retry attempts per **thunk** (ignored for bare
|
|
224
|
+
* promises). Default `3`.
|
|
225
|
+
* @param baseDelay - Initial backoff delay in milliseconds for thunk retries
|
|
226
|
+
* (ignored for bare promises). Default `1000`.
|
|
227
|
+
* @returns Results in input order; `null` in the slot of any task that
|
|
228
|
+
* ultimately failed. Never rejects.
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* // Bare promises: settle once, failures become null.
|
|
232
|
+
* const [a, b] = await promiseSettle([getA(), getB()]);
|
|
233
|
+
* // Thunks: each failing call is retried up to 3 times with backoff.
|
|
234
|
+
* const [c, d] = await promiseSettle([() => getC(), () => getD()]);
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export declare function promiseSettle<T>(tasks: Array<Promise<T> | (() => Promise<T>)>, maxRetries?: number, baseDelay?: number): Promise<T[]>;
|