@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,229 @@
|
|
|
1
|
+
import { AnchorProvider, BN, Program, type web3 } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, type ParsedAccountData, type Transaction } from '@solana/web3.js';
|
|
3
|
+
import type { ISolanaConnectionOptions, ISolanaVaultState } from './types';
|
|
4
|
+
import { BlockhashConfirmingProvider } from './confirm';
|
|
5
|
+
import type { ISolanaProgramIds } from './constants';
|
|
6
|
+
declare function getExplorerLink({ signature, type, network, }: {
|
|
7
|
+
signature: string;
|
|
8
|
+
type: 'tx' | 'address' | 'token';
|
|
9
|
+
} & ISolanaConnectionOptions): string;
|
|
10
|
+
import { isSolanaAddress } from '../../core/helpers/chain-address';
|
|
11
|
+
export { isSolanaAddress };
|
|
12
|
+
declare function isSolana(signature: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Throws unless `type` is a program type `programNames` maps. Checked at
|
|
15
|
+
* runtime for untyped callers: a typo would otherwise read as an undeployed
|
|
16
|
+
* program, and a prototype key like `toString` as a program id.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function assertSolanaProgramType(type: unknown): asserts type is keyof ISolanaProgramIds;
|
|
20
|
+
/**
|
|
21
|
+
* Error text for `program` having no canonical deployment on `network`, naming
|
|
22
|
+
* the networks it is deployed on.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare function undeployedProgramMessage(program: keyof ISolanaProgramIds, network: string): string;
|
|
26
|
+
declare function getProgram({ provider, idl, programId, network, }: {
|
|
27
|
+
idl?: any;
|
|
28
|
+
programId?: string;
|
|
29
|
+
} & ISolanaConnectionOptions): Program<any>;
|
|
30
|
+
declare function getBestRpcEndpoint({ endpoint, network, connection, }: ISolanaConnectionOptions): Promise<"http://127.0.0.1:8899" | `https://${string}`>;
|
|
31
|
+
declare function getProvider({ connection, publicKey, signTransaction, }: {
|
|
32
|
+
publicKey: PublicKey;
|
|
33
|
+
signTransaction: (<T extends Transaction | web3.VersionedTransaction>(transaction: T) => Promise<T>) | undefined;
|
|
34
|
+
} & ISolanaConnectionOptions): BlockhashConfirmingProvider;
|
|
35
|
+
declare function getReadOnlyProvider({ connection }: ISolanaConnectionOptions): AnchorProvider;
|
|
36
|
+
declare function deriveVaultStatePda(vaultProgramId: PublicKey | string): web3.PublicKey;
|
|
37
|
+
declare function deriveShareMintPda(vaultProgramId: PublicKey | string): web3.PublicKey;
|
|
38
|
+
declare function deriveVaultTokenAtaPda(vaultProgramId: PublicKey | string, depositMint: PublicKey, vaultVersion?: number): web3.PublicKey;
|
|
39
|
+
declare function getVaultState({ provider, connection, vaultProgramId, vaultAddress, idl, }: {
|
|
40
|
+
vaultProgramId: PublicKey | string;
|
|
41
|
+
vaultAddress?: PublicKey | string;
|
|
42
|
+
idl: any;
|
|
43
|
+
} & ISolanaConnectionOptions): Promise<{
|
|
44
|
+
vaultState: unknown | null;
|
|
45
|
+
depositMintDecimals: number | null;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Read-only version of `getVaultState` that works without a wallet connection.
|
|
49
|
+
*
|
|
50
|
+
* Makes one `getAccountInfo` for the vault state PDA and decodes the bytes
|
|
51
|
+
* with the program's account coder (no second fetch through
|
|
52
|
+
* `program.account.vaultState.fetch`), plus one `getParsedAccountInfo` for the
|
|
53
|
+
* deposit mint's decimals. Worst case: 2 RPC calls per cache miss; a hit costs
|
|
54
|
+
* none. The decoded state is cached for {@link VAULT_STATE_CACHE_TTL_MS}.
|
|
55
|
+
*
|
|
56
|
+
* Resolves `{ vaultState: null, depositMintDecimals: null }` — and caches
|
|
57
|
+
* nothing — when the account is missing, the RPC fails, or the bytes do not
|
|
58
|
+
* decode. Callers (`getSolanaVault`) treat a `null` state as "on-chain data
|
|
59
|
+
* unavailable" and fall back to backend data.
|
|
60
|
+
*
|
|
61
|
+
* Served from the cache unless `fresh` is set. A fresh read skips the cached
|
|
62
|
+
* value and refreshes it, for callers comparing the vault's AUM with live data
|
|
63
|
+
* such as an operator's current portfolio.
|
|
64
|
+
*/
|
|
65
|
+
declare function getVaultStateReadOnly({ vaultProgramId, vaultAddress, connection, idl, fresh, }: {
|
|
66
|
+
vaultProgramId: PublicKey | string;
|
|
67
|
+
vaultAddress?: PublicKey | string;
|
|
68
|
+
idl: any;
|
|
69
|
+
fresh?: boolean;
|
|
70
|
+
} & ISolanaConnectionOptions): Promise<{
|
|
71
|
+
vaultState: ISolanaVaultState | null;
|
|
72
|
+
depositMintDecimals: number | null;
|
|
73
|
+
}>;
|
|
74
|
+
declare function getVaultMints({ vaultProgramId, vaultAddress, connection, idl, }: {
|
|
75
|
+
vaultProgramId: PublicKey | string;
|
|
76
|
+
vaultAddress?: PublicKey | string;
|
|
77
|
+
idl: any;
|
|
78
|
+
} & ISolanaConnectionOptions): Promise<{
|
|
79
|
+
depositMint: string;
|
|
80
|
+
shareMint: string;
|
|
81
|
+
vaultVersion: number | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
declare function getToken({ mintAddress, endpoint, connection, }: {
|
|
84
|
+
mintAddress: string | PublicKey;
|
|
85
|
+
} & ISolanaConnectionOptions): Promise<{
|
|
86
|
+
address: string;
|
|
87
|
+
symbol: string;
|
|
88
|
+
decimals: number;
|
|
89
|
+
name: string;
|
|
90
|
+
image: string;
|
|
91
|
+
} | null>;
|
|
92
|
+
declare function getTokenSymbol({ endpoint, mintAddress, }: {
|
|
93
|
+
mintAddress: string | PublicKey;
|
|
94
|
+
} & ISolanaConnectionOptions): Promise<string | null>;
|
|
95
|
+
/**
|
|
96
|
+
* A wallet's token account of record for one mint: the account holding the
|
|
97
|
+
* largest balance.
|
|
98
|
+
*
|
|
99
|
+
* **This is the single selection rule for the whole Solana adapter.** Reads
|
|
100
|
+
* (balances shown in a UI) and writes (the account a transfer actually names)
|
|
101
|
+
* must agree on which account represents the user, or the two describe
|
|
102
|
+
* different money: a balance read from account A while a deposit mints into
|
|
103
|
+
* account B looks, to the user, like a successful transaction that never
|
|
104
|
+
* arrived. Every reader in this file and both vault handlers call this, so the
|
|
105
|
+
* rule cannot drift.
|
|
106
|
+
*
|
|
107
|
+
* Largest-balance rather than "the first account the RPC returned":
|
|
108
|
+
* `getParsedTokenAccountsByOwner` guarantees no ordering, so taking `[0]` can
|
|
109
|
+
* select an empty leftover while the user's funds sit in a sibling account —
|
|
110
|
+
* which fails on-chain as an insufficient-funds revert *after* they sign.
|
|
111
|
+
*
|
|
112
|
+
* **Spendable accounts win over frozen ones**, regardless of balance: a token
|
|
113
|
+
* issuer can freeze an account, and neither a transfer out of nor a transfer
|
|
114
|
+
* into a frozen account can succeed. Picking the richest account outright would
|
|
115
|
+
* hand a frozen one to the program and revert with SPL `0x11` after the user
|
|
116
|
+
* signs, while a perfectly usable sibling sat next to it. When *every* account
|
|
117
|
+
* is frozen the richest frozen one is still returned, flagged — a reader should
|
|
118
|
+
* show that balance, because the user does own it, and a writer should refuse
|
|
119
|
+
* before asking for a signature.
|
|
120
|
+
*
|
|
121
|
+
* Internal to the adapter: exported for `vault.actions.ts`, deliberately not
|
|
122
|
+
* re-exported on `SolanaUtils`. It takes a raw RPC response shape, which is not
|
|
123
|
+
* a contract worth freezing on the public surface.
|
|
124
|
+
*
|
|
125
|
+
* @param accounts - The `.value` array from `getParsedTokenAccountsByOwner`.
|
|
126
|
+
* @returns The selected account with its raw balance, decimals, the RPC's own
|
|
127
|
+
* `uiAmount`, and whether it is frozen — or `undefined` when the wallet owns
|
|
128
|
+
* no account for the mint.
|
|
129
|
+
* @throws UpshiftSDKError when an account's balance cannot be read. An
|
|
130
|
+
* unreadable balance is *unknown*, not zero — scoring it zero would silently
|
|
131
|
+
* demote a funded account below a dust one and reinstate the `[0]` behaviour
|
|
132
|
+
* this function exists to prevent.
|
|
133
|
+
*/
|
|
134
|
+
export declare function selectRichestTokenAccount(accounts: {
|
|
135
|
+
pubkey: PublicKey;
|
|
136
|
+
account: {
|
|
137
|
+
data: ParsedAccountData | Buffer;
|
|
138
|
+
};
|
|
139
|
+
}[]): {
|
|
140
|
+
pubkey: PublicKey;
|
|
141
|
+
amount: bigint;
|
|
142
|
+
decimals: number | null;
|
|
143
|
+
uiAmount: number | null;
|
|
144
|
+
frozen: boolean;
|
|
145
|
+
} | undefined;
|
|
146
|
+
declare function fetchUserTokenBalance({ connection, publicKey, depositMint, }: {
|
|
147
|
+
publicKey: PublicKey | string;
|
|
148
|
+
depositMint?: PublicKey | string;
|
|
149
|
+
} & ISolanaConnectionOptions): Promise<string>;
|
|
150
|
+
declare function fetchUserShareBalance({ connection, publicKey, shareMint, }: {
|
|
151
|
+
publicKey: PublicKey | string;
|
|
152
|
+
shareMint?: PublicKey | string;
|
|
153
|
+
} & ISolanaConnectionOptions): Promise<number>;
|
|
154
|
+
/**
|
|
155
|
+
* Same on-chain lookup as `fetchUserShareBalance`, but returns the raw u64
|
|
156
|
+
* `amount` string and the mint's `decimals` — or `null` when the scale can't
|
|
157
|
+
* be determined (see Return shape) — instead of the floating-point `uiAmount`.
|
|
158
|
+
* Callers that feed the result into BigInt math (positions, redemptions,
|
|
159
|
+
* allowances) must use this — `uiAmount` is lossy and silently encodes with
|
|
160
|
+
* the wrong scale when passed back through `toNormalizedBn` without an
|
|
161
|
+
* explicit decimals argument.
|
|
162
|
+
*
|
|
163
|
+
* Return shape:
|
|
164
|
+
* `{ amount: '<u64>', decimals: number }` — token account exists.
|
|
165
|
+
* `{ amount: '0', decimals: null }` — no token account, missing
|
|
166
|
+
* tokenAmount in the parsed response, missing args, or the RPC threw.
|
|
167
|
+
*
|
|
168
|
+
* `decimals === null` is the "scale unknown" signal — callers that need a
|
|
169
|
+
* normalized `INormalizedNumber` must substitute a known decimals value
|
|
170
|
+
* (typically the deposit mint's decimals from backend metadata) before
|
|
171
|
+
* normalizing. Never throws.
|
|
172
|
+
*
|
|
173
|
+
* RPC cost: 1 × `getParsedTokenAccountsByOwner`. Independent of how many
|
|
174
|
+
* other accounts the wallet owns (filter is mint-scoped).
|
|
175
|
+
*/
|
|
176
|
+
declare function fetchUserShareBalanceRaw({ connection, publicKey, shareMint, }: {
|
|
177
|
+
publicKey: PublicKey | string;
|
|
178
|
+
shareMint?: PublicKey | string;
|
|
179
|
+
} & ISolanaConnectionOptions): Promise<{
|
|
180
|
+
amount: string;
|
|
181
|
+
decimals: number | null;
|
|
182
|
+
}>;
|
|
183
|
+
/**
|
|
184
|
+
* Resolve the on-chain program ID for a Solana vault.
|
|
185
|
+
* Prefers the explicit `program_id` from metadata; falls back to the vault address
|
|
186
|
+
* (for legacy vaults where address == program ID).
|
|
187
|
+
*/
|
|
188
|
+
declare function resolveProgramId(vaultAddress: string, solanaMetadata?: {
|
|
189
|
+
program_id?: string;
|
|
190
|
+
} | null): string;
|
|
191
|
+
/** @internal */
|
|
192
|
+
export declare function uiAmountToRawBn(uiAmount: number, decimals: number): BN;
|
|
193
|
+
export declare const SolanaUtils: {
|
|
194
|
+
getExplorerLink: typeof getExplorerLink;
|
|
195
|
+
isSolanaAddress: typeof isSolanaAddress;
|
|
196
|
+
isSolana: typeof isSolana;
|
|
197
|
+
getProgram: typeof getProgram;
|
|
198
|
+
getProvider: typeof getProvider;
|
|
199
|
+
getReadOnlyProvider: typeof getReadOnlyProvider;
|
|
200
|
+
deriveShareMintPda: typeof deriveShareMintPda;
|
|
201
|
+
deriveVaultStatePda: typeof deriveVaultStatePda;
|
|
202
|
+
deriveVaultTokenAtaPda: typeof deriveVaultTokenAtaPda;
|
|
203
|
+
getVaultState: typeof getVaultState;
|
|
204
|
+
getVaultStateReadOnly: typeof getVaultStateReadOnly;
|
|
205
|
+
getToken: typeof getToken;
|
|
206
|
+
getTokenSymbol: typeof getTokenSymbol;
|
|
207
|
+
fetchUserTokenBalance: typeof fetchUserTokenBalance;
|
|
208
|
+
fetchUserShareBalance: typeof fetchUserShareBalance;
|
|
209
|
+
fetchUserShareBalanceRaw: typeof fetchUserShareBalanceRaw;
|
|
210
|
+
getBestRpcEndpoint: typeof getBestRpcEndpoint;
|
|
211
|
+
fallbackDecimals: number;
|
|
212
|
+
fallbackNetwork: import("../..").ISolanaNetwork;
|
|
213
|
+
programIds: {
|
|
214
|
+
devnet: {
|
|
215
|
+
vault: string;
|
|
216
|
+
withdrawalQueue: string;
|
|
217
|
+
};
|
|
218
|
+
"mainnet-beta": {
|
|
219
|
+
vault: string;
|
|
220
|
+
withdrawalQueue: string;
|
|
221
|
+
};
|
|
222
|
+
localnet: {
|
|
223
|
+
vault: string;
|
|
224
|
+
withdrawalQueue: string;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
getVaultMints: typeof getVaultMints;
|
|
228
|
+
resolveProgramId: typeof resolveProgramId;
|
|
229
|
+
};
|