upshift-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,13 @@
|
|
|
1
|
+
import type { IAddress, IVaultAdapterConfig } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get adapter configuration for a vault
|
|
4
|
+
*/
|
|
5
|
+
export declare function getVaultAdapterConfig(vaultAddress: IAddress): IVaultAdapterConfig | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Check if vault has adapter support
|
|
8
|
+
*/
|
|
9
|
+
export declare function vaultHasAdapter(vaultAddress: IAddress): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Get deposit tokens for a vault (includes underlying + adapter tokens)
|
|
12
|
+
*/
|
|
13
|
+
export declare function getVaultDepositTokens(vaultAddress: IAddress, underlyingToken: IAddress): IAddress[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVaultAdapterConfig = getVaultAdapterConfig;
|
|
4
|
+
exports.vaultHasAdapter = vaultHasAdapter;
|
|
5
|
+
exports.getVaultDepositTokens = getVaultDepositTokens;
|
|
6
|
+
const adapters_1 = require("../constants/adapters");
|
|
7
|
+
/**
|
|
8
|
+
* Get adapter configuration for a vault
|
|
9
|
+
*/
|
|
10
|
+
function getVaultAdapterConfig(vaultAddress) {
|
|
11
|
+
return adapters_1.VAULT_ADAPTER_CONFIGS[vaultAddress];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Check if vault has adapter support
|
|
15
|
+
*/
|
|
16
|
+
function vaultHasAdapter(vaultAddress) {
|
|
17
|
+
return !!adapters_1.VAULT_ADAPTER_CONFIGS[vaultAddress];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get deposit tokens for a vault (includes underlying + adapter tokens)
|
|
21
|
+
*/
|
|
22
|
+
function getVaultDepositTokens(vaultAddress, underlyingToken) {
|
|
23
|
+
const adapterConfig = getVaultAdapterConfig(vaultAddress);
|
|
24
|
+
if (!adapterConfig) {
|
|
25
|
+
return [underlyingToken];
|
|
26
|
+
}
|
|
27
|
+
// Return all tokens including the underlying
|
|
28
|
+
const allTokens = [underlyingToken];
|
|
29
|
+
if (adapterConfig.tokens && adapterConfig.tokens.length > 0) {
|
|
30
|
+
// Use configured tokens list
|
|
31
|
+
adapterConfig.tokens.forEach((token) => {
|
|
32
|
+
if (!allTokens.includes(token)) {
|
|
33
|
+
allTokens.push(token);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return allTokens;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a string is a valid Solana base58 address (including PDAs).
|
|
3
|
+
* Returns `false` for EVM hex addresses.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isSolanaAddress(address: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Check if a string is a valid Stellar address.
|
|
8
|
+
* Muxed accounts (M prefix, per SEP-0023) are intentionally excluded — they are
|
|
9
|
+
* not valid vault or contract addresses.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isStellarAddress(address: string): boolean;
|
|
12
|
+
/** Check if a string is a valid Sui address (0x + 64 hex chars). */
|
|
13
|
+
export declare function isSuiAddress(address: string): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSolanaAddress = isSolanaAddress;
|
|
4
|
+
exports.isStellarAddress = isStellarAddress;
|
|
5
|
+
exports.isSuiAddress = isSuiAddress;
|
|
6
|
+
const ethers_1 = require("ethers");
|
|
7
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
+
/** Stellar uses RFC 4648 base32; 56 chars, prefixed by G (public key) or C (contract/Soroban). */
|
|
9
|
+
const STELLAR_ADDRESS_RE = /^[A-Z2-7]{56}$/;
|
|
10
|
+
/**
|
|
11
|
+
* Check if a string is a valid Solana base58 address (including PDAs).
|
|
12
|
+
* Returns `false` for EVM hex addresses.
|
|
13
|
+
*/
|
|
14
|
+
function isSolanaAddress(address) {
|
|
15
|
+
if (!address)
|
|
16
|
+
return false;
|
|
17
|
+
if ((0, ethers_1.isAddress)(address))
|
|
18
|
+
return false;
|
|
19
|
+
try {
|
|
20
|
+
new web3_js_1.PublicKey(address);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if a string is a valid Stellar address.
|
|
29
|
+
* Muxed accounts (M prefix, per SEP-0023) are intentionally excluded — they are
|
|
30
|
+
* not valid vault or contract addresses.
|
|
31
|
+
*/
|
|
32
|
+
function isStellarAddress(address) {
|
|
33
|
+
if (!address || typeof address !== 'string')
|
|
34
|
+
return false;
|
|
35
|
+
if (address.length !== 56)
|
|
36
|
+
return false;
|
|
37
|
+
if (address[0] !== 'G' && address[0] !== 'C')
|
|
38
|
+
return false;
|
|
39
|
+
return STELLAR_ADDRESS_RE.test(address);
|
|
40
|
+
}
|
|
41
|
+
/** Check if a string is a valid Sui address (0x + 64 hex chars). */
|
|
42
|
+
function isSuiAddress(address) {
|
|
43
|
+
if (!address || typeof address !== 'string')
|
|
44
|
+
return false;
|
|
45
|
+
return /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=chain-address.js.map
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Is this error a wallet/user rejection of a transaction or signature request?
|
|
3
|
+
*
|
|
4
|
+
* Detects ethers v6's `ACTION_REJECTED` code, the EIP-1193 `4001`
|
|
5
|
+
* ("User rejected the request") code (top-level or nested), and the common
|
|
6
|
+
* human-readable phrasings as a fallback for providers that omit a code.
|
|
7
|
+
*
|
|
8
|
+
* @param error - The caught value, of unknown type.
|
|
9
|
+
* @returns `true` when the failure was the user declining in their wallet.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* try { await vault.deposit(...); }
|
|
14
|
+
* catch (e) {
|
|
15
|
+
* if (isUserRejectionError(e)) return; // user cancelled — not an error
|
|
16
|
+
* throw e;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function isUserRejectionError(error: unknown): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Is this error a routine on-chain read revert rather than a real failure?
|
|
23
|
+
*
|
|
24
|
+
* Reading a function a contract doesn't implement, or an address that holds no
|
|
25
|
+
* (or incompatible) bytecode, reverts — a normal outcome when the SDK probes
|
|
26
|
+
* heterogeneous vaults. Matches ethers' `CALL_EXCEPTION` code and the
|
|
27
|
+
* message variants emitted by ethers and viem (`missing revert data`,
|
|
28
|
+
* `execution reverted`, `call revert exception`, and the bare `reverted`
|
|
29
|
+
* phrasing such as `the contract function "totalAssets" reverted`).
|
|
30
|
+
*
|
|
31
|
+
* Scope note: callers apply this on **read** paths only. A reverted *write*
|
|
32
|
+
* (a tx that failed on-chain) is a genuine error and is intentionally not
|
|
33
|
+
* demoted by this predicate's use in `write.actions`.
|
|
34
|
+
*
|
|
35
|
+
* @param error - The caught value, of unknown type.
|
|
36
|
+
* @returns `true` when the failure is an expected/benign contract revert.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* try { return await vaultContract.maxDepositAmount(); }
|
|
41
|
+
* catch (e) {
|
|
42
|
+
* logChainError('maxDeposit', e, isExpectedRevertError(e));
|
|
43
|
+
* throw e;
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function isExpectedRevertError(error: unknown): boolean;
|
|
48
|
+
export declare function isInsufficientFundsError(error: unknown): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Is this error a transient RPC **transport** failure that is safe to retry,
|
|
51
|
+
* rather than a decision the chain made?
|
|
52
|
+
*
|
|
53
|
+
* Why this exists: the SDK's write paths poll `eth_getTransactionReceipt` to
|
|
54
|
+
* confirm a broadcast transaction. When the provider hiccups mid-poll, ethers
|
|
55
|
+
* surfaces `could not coalesce error (error={ "code": -32603, … "method":
|
|
56
|
+
* "eth_getTransactionReceipt" … })`. Historically that propagated out of
|
|
57
|
+
* `safeWaitForTx` and the SDK reported the write as **failed** — even though
|
|
58
|
+
* the transaction was broadcast, its hash was known, and it mined fine. Users
|
|
59
|
+
* then retried and hit `ERC20InsufficientBalance` because the first attempt had
|
|
60
|
+
* in fact succeeded. Classifying the failure as transport-level lets callers
|
|
61
|
+
* re-poll instead of lying to the user.
|
|
62
|
+
*
|
|
63
|
+
* Matches, in order of precedence:
|
|
64
|
+
* 1. **Veto** — anything with revert evidence ({@link hasRevertEvidence}:
|
|
65
|
+
* `CALL_EXCEPTION` carrying revert `data`, an `execution reverted` message,
|
|
66
|
+
* or an attached `receipt.status === 0`) returns `false`. Nodes reuse
|
|
67
|
+
* `-32603`/`-32000` for real reverts, so the veto must come first.
|
|
68
|
+
* 2. JSON-RPC / ethers transport codes — see `RETRYABLE_RPC_CODES`.
|
|
69
|
+
* 3. HTTP `429` and any `5xx` carried on the error.
|
|
70
|
+
* 4. Transport message fragments — see `RETRYABLE_RPC_PHRASES`.
|
|
71
|
+
*
|
|
72
|
+
* Retrying is only safe for **idempotent** work: re-reading an immutable value
|
|
73
|
+
* (`decimals()`) or re-polling a receipt for a hash that is already on the
|
|
74
|
+
* wire. Never use this to re-send a transaction.
|
|
75
|
+
*
|
|
76
|
+
* @param error - The caught value, of unknown type.
|
|
77
|
+
* @returns `true` when the failure is a transient transport fault worth
|
|
78
|
+
* retrying with backoff; `false` for chain-level decisions (reverts) and for
|
|
79
|
+
* anything unrecognised — the safe default is to surface the error.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* try {
|
|
84
|
+
* return await provider.waitForTransaction(hash, 1, 120_000);
|
|
85
|
+
* } catch (e) {
|
|
86
|
+
* if (!isRetryableRpcError(e)) throw e; // real revert — surface it
|
|
87
|
+
* await sleep(250);
|
|
88
|
+
* return await provider.waitForTransaction(hash, 1, 120_000);
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function isRetryableRpcError(error: unknown): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* `lpTokenAddress()` — `keccak256("lpTokenAddress()")[0..4]`. The August `evm-2`
|
|
95
|
+
* tokenized vault's receipt-token getter, exported so the readers that invoke it
|
|
96
|
+
* can scope {@link isEmptyViewResponse} to exactly this call instead of
|
|
97
|
+
* duplicating the literal.
|
|
98
|
+
*/
|
|
99
|
+
export declare const LP_TOKEN_ADDRESS_SELECTOR = "0xf5ae497a";
|
|
100
|
+
/**
|
|
101
|
+
* Is this error an **empty RPC response to an argument-free view call** —
|
|
102
|
+
* i.e. a transport artefact wearing a revert's clothes?
|
|
103
|
+
*
|
|
104
|
+
* Why this is separate from {@link isRetryableRpcError}: when a provider
|
|
105
|
+
* truncates or 500s a response to `eth_call`, ethers reports
|
|
106
|
+
* `missing revert data (action="call", data="0x313ce567", …)` with a `null`
|
|
107
|
+
* `data` field. That is byte-for-byte the shape of a genuine revert with no
|
|
108
|
+
* reason string, so a general "transport" predicate cannot safely claim it —
|
|
109
|
+
* doing so would retry every data-less `CALL_EXCEPTION` in the SDK. This
|
|
110
|
+
* predicate narrows the claim to the one case where the ambiguity resolves:
|
|
111
|
+
* a **deployed ERC-20's `decimals()`/`symbol()`/`name()`/`totalSupply()` cannot
|
|
112
|
+
* legitimately revert**, because it takes no arguments and returns state fixed
|
|
113
|
+
* at deployment. An empty response there is the provider's fault, full stop.
|
|
114
|
+
*
|
|
115
|
+
* A match requires all of:
|
|
116
|
+
* 1. no revert evidence ({@link hasRevertEvidence}) — anything carrying real
|
|
117
|
+
* revert `data`, an `execution reverted` message, or a failed receipt is out;
|
|
118
|
+
* 2. a `missing revert data` message;
|
|
119
|
+
* 3. an `action` of `call` or `staticCall` — a read, never a state change;
|
|
120
|
+
* 4. **when a selector is derivable** from the error, that it is
|
|
121
|
+
* `expectedSelector` (if given) or one of
|
|
122
|
+
* {@link ARGUMENT_FREE_VIEW_SELECTORS}. When no selector can be recovered,
|
|
123
|
+
* conditions 1–3 stand on their own.
|
|
124
|
+
*
|
|
125
|
+
* Note the cost of a false positive is bounded and small: the caller retries an
|
|
126
|
+
* idempotent read a couple of times before surfacing the same error. The cost
|
|
127
|
+
* of a false negative is the production flood this predicate exists to stop.
|
|
128
|
+
*
|
|
129
|
+
* @param error - The caught value, of unknown type.
|
|
130
|
+
* @param expectedSelector - Optional `0x`-prefixed 4-byte selector the caller
|
|
131
|
+
* knows it invoked (e.g. `'0x313ce567'` for `decimals()`). When supplied, the
|
|
132
|
+
* error's own selector must match it — this stops a `decimals()` retry from
|
|
133
|
+
* firing on an unrelated view call that happened to fail the same way.
|
|
134
|
+
* @returns `true` when the failure is an empty provider response to a view call
|
|
135
|
+
* that cannot revert, and is therefore safe to retry.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* try { return Number(await erc20.decimals()); }
|
|
140
|
+
* catch (e) {
|
|
141
|
+
* if (!isEmptyViewResponse(e, '0x313ce567')) throw e; // real problem
|
|
142
|
+
* return Number(await erc20.decimals()); // provider blip
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function isEmptyViewResponse(error: unknown, expectedSelector?: string): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Run an **idempotent** RPC read, retrying with exponential backoff while the
|
|
149
|
+
* failure classifies as a transient transport fault
|
|
150
|
+
* ({@link isRetryableRpcError}).
|
|
151
|
+
*
|
|
152
|
+
* Lives next to the classifiers it consumes so there is exactly one retry
|
|
153
|
+
* implementation in the SDK: both the receipt-poll fallback in the vault write
|
|
154
|
+
* paths and the cached `decimals()` reader in `core/helpers/web3.ts` call this.
|
|
155
|
+
*
|
|
156
|
+
* Only safe for operations that can be repeated without side effects: polling
|
|
157
|
+
* `eth_getTransactionReceipt` for an already-broadcast hash, or re-reading an
|
|
158
|
+
* immutable value such as `decimals()`. **Never wrap a transaction send in
|
|
159
|
+
* this.**
|
|
160
|
+
*
|
|
161
|
+
* Anything that is not a transport fault (a genuine revert, a user rejection,
|
|
162
|
+
* an insufficient-funds rejection) is rethrown on the first attempt with no
|
|
163
|
+
* delay, so real failures still fail fast.
|
|
164
|
+
*
|
|
165
|
+
* @param tag - Low-cardinality log label for the retry breadcrumb.
|
|
166
|
+
* @param operation - The idempotent async read to run.
|
|
167
|
+
* @param context - Extra structured context for the retry breadcrumb (e.g.
|
|
168
|
+
* `{ hash }`). Sanitized by the logger before transport.
|
|
169
|
+
* @param isRetryable - Predicate deciding whether a caught error warrants
|
|
170
|
+
* another attempt. Defaults to the strict transport definition
|
|
171
|
+
* ({@link isRetryableRpcError}); pass a wider one only where the call site
|
|
172
|
+
* can prove the extra shape is also a provider artefact — the only such case
|
|
173
|
+
* today is the selector-scoped {@link isEmptyViewResponse} used by
|
|
174
|
+
* `getDecimalsOrThrow`.
|
|
175
|
+
* @returns Whatever `operation` resolves to on the first successful attempt.
|
|
176
|
+
* @throws The last error thrown by `operation` once retries are exhausted, or
|
|
177
|
+
* immediately when the error is not retryable.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* const receipt = await retryOnTransientRpc(
|
|
182
|
+
* 'safeWaitForTx:transport-retry',
|
|
183
|
+
* () => provider.waitForTransaction(hash, 1, 120_000),
|
|
184
|
+
* { hash },
|
|
185
|
+
* );
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export declare function retryOnTransientRpc<T>(tag: string, operation: () => Promise<T>, context?: Record<string, unknown>, isRetryable?: (error: unknown) => boolean): Promise<T>;
|
|
189
|
+
/**
|
|
190
|
+
* Log a caught chain error at the severity its category warrants, without
|
|
191
|
+
* swallowing it. When `isBenign` is `true` the failure is recorded as a `warn`
|
|
192
|
+
* (a Sentry breadcrumb that rides along with the next real issue, not a billed
|
|
193
|
+
* standalone issue); otherwise it is logged at `error` (a Sentry issue). The
|
|
194
|
+
* caller is still responsible for re-throwing — this only routes telemetry.
|
|
195
|
+
*
|
|
196
|
+
* Pass the benign decision explicitly (via {@link isUserRejectionError} or
|
|
197
|
+
* {@link isExpectedRevertError}) so the call site documents *why* the demotion
|
|
198
|
+
* is safe and each path opts into only the category that applies to it.
|
|
199
|
+
*
|
|
200
|
+
* @param tag - Low-cardinality call-site label (e.g. `'deposit'`), used as the
|
|
201
|
+
* Sentry breadcrumb/issue grouping key.
|
|
202
|
+
* @param error - The caught value, of unknown type.
|
|
203
|
+
* @param isBenign - `true` to demote to `warn`; `false` to keep at `error`.
|
|
204
|
+
* @param context - Optional structured context attached to the log entry. It is
|
|
205
|
+
* sanitized by the logger before transport.
|
|
206
|
+
*/
|
|
207
|
+
export declare function logChainError(tag: string, error: unknown, isBenign: boolean, context?: Record<string, unknown>): void;
|