upshift-finance 1.0.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 +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,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* Functions to support deposits with alternative tokens through swap adapters,
|
|
5
|
+
* wrapper contracts, and Paraswap integration.
|
|
6
|
+
*/
|
|
7
|
+
import type { BaseContract, Signer, Wallet } from 'ethers';
|
|
8
|
+
import type { IAddress } from '../../types';
|
|
9
|
+
import type { IVaultAdapterConfig } from '../../types/vaults';
|
|
10
|
+
/**
|
|
11
|
+
* Get quote from Paraswap for token swap
|
|
12
|
+
*/
|
|
13
|
+
export declare function getParaswapQuote({ srcToken, destToken, amount, network, srcDecimals, destDecimals, }: {
|
|
14
|
+
srcToken: string;
|
|
15
|
+
destToken: string;
|
|
16
|
+
amount: string;
|
|
17
|
+
network: string;
|
|
18
|
+
srcDecimals: number;
|
|
19
|
+
destDecimals: number;
|
|
20
|
+
}): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Build swap and deposit transaction for Paraswap bridge
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildSwapAndDepositTransaction({ signer, srcToken, srcDecimals, destToken, destDecimals, amount, network, adapterConfig, userAddress, }: {
|
|
25
|
+
signer: Signer | Wallet;
|
|
26
|
+
srcToken: IAddress;
|
|
27
|
+
srcDecimals: number;
|
|
28
|
+
destToken: IAddress;
|
|
29
|
+
destDecimals: number;
|
|
30
|
+
amount: string;
|
|
31
|
+
network: string;
|
|
32
|
+
adapterConfig: IVaultAdapterConfig;
|
|
33
|
+
userAddress: IAddress;
|
|
34
|
+
}): Promise<BaseContract>;
|
|
35
|
+
/**
|
|
36
|
+
* Build native/wrapped token deposit transaction
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildNativeDepositTransaction({ signer, srcToken, amount, poolName, adapterConfig, userAddress, }: {
|
|
39
|
+
signer: Signer | Wallet;
|
|
40
|
+
srcToken: IAddress;
|
|
41
|
+
amount: string;
|
|
42
|
+
poolName?: string;
|
|
43
|
+
adapterConfig: IVaultAdapterConfig;
|
|
44
|
+
userAddress: IAddress;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
contract: BaseContract;
|
|
47
|
+
functionName: string;
|
|
48
|
+
args: any[];
|
|
49
|
+
value?: bigint;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Preview adapter deposit output
|
|
53
|
+
*/
|
|
54
|
+
export declare function previewAdapterDeposit({ signer, vaultAddress, srcToken, srcAmount, srcDecimals, destToken, destDecimals, adapterConfig, chainId, }: {
|
|
55
|
+
signer: Signer | Wallet;
|
|
56
|
+
vaultAddress: IAddress;
|
|
57
|
+
srcToken: IAddress;
|
|
58
|
+
srcAmount: string;
|
|
59
|
+
srcDecimals: number;
|
|
60
|
+
destToken: IAddress;
|
|
61
|
+
destDecimals: number;
|
|
62
|
+
adapterConfig: IVaultAdapterConfig;
|
|
63
|
+
chainId: number;
|
|
64
|
+
}): Promise<bigint>;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Adapter Helper Functions
|
|
4
|
+
*
|
|
5
|
+
* Functions to support deposits with alternative tokens through swap adapters,
|
|
6
|
+
* wrapper contracts, and Paraswap integration.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getParaswapQuote = getParaswapQuote;
|
|
10
|
+
exports.buildSwapAndDepositTransaction = buildSwapAndDepositTransaction;
|
|
11
|
+
exports.buildNativeDepositTransaction = buildNativeDepositTransaction;
|
|
12
|
+
exports.previewAdapterDeposit = previewAdapterDeposit;
|
|
13
|
+
const adapters_1 = require("../../core/constants/adapters");
|
|
14
|
+
const abis_1 = require("../../abis");
|
|
15
|
+
const core_1 = require("../../core");
|
|
16
|
+
/**
|
|
17
|
+
* Paraswap API endpoints
|
|
18
|
+
*/
|
|
19
|
+
const PARASWAP_PRICES_API = 'https://api.paraswap.io/prices';
|
|
20
|
+
/**
|
|
21
|
+
* Paraswap partner configuration
|
|
22
|
+
*/
|
|
23
|
+
const PARASWAP_PARTNER = 'august';
|
|
24
|
+
const PARASWAP_PARTNER_ADDRESS = '0xb60ee0FA5B6bA917255A03e744967E0Bda531dD0';
|
|
25
|
+
const PARASWAP_VERSION = '6.2';
|
|
26
|
+
/**
|
|
27
|
+
* Get quote from Paraswap for token swap
|
|
28
|
+
*/
|
|
29
|
+
async function getParaswapQuote({ srcToken, destToken, amount, network, srcDecimals, destDecimals, }) {
|
|
30
|
+
const params = new URLSearchParams();
|
|
31
|
+
params.append('network', network);
|
|
32
|
+
params.append('srcToken', srcToken);
|
|
33
|
+
params.append('srcDecimals', srcDecimals.toString());
|
|
34
|
+
params.append('destToken', destToken);
|
|
35
|
+
params.append('destDecimals', destDecimals.toString());
|
|
36
|
+
params.append('amount', amount);
|
|
37
|
+
params.append('partner', PARASWAP_PARTNER);
|
|
38
|
+
params.append('partnerAddress', PARASWAP_PARTNER_ADDRESS);
|
|
39
|
+
params.append('version', PARASWAP_VERSION);
|
|
40
|
+
const priceUrl = `${PARASWAP_PRICES_API}?${params.toString()}`;
|
|
41
|
+
const response = await fetch(priceUrl, {
|
|
42
|
+
method: 'GET',
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const data = await response.json();
|
|
48
|
+
return data?.priceRoute || {};
|
|
49
|
+
}
|
|
50
|
+
// Note: buildParaswapTransaction is kept for potential future use
|
|
51
|
+
// Currently transaction building is handled directly in buildSwapAndDepositTransaction
|
|
52
|
+
/**
|
|
53
|
+
* Build swap and deposit transaction for Paraswap bridge
|
|
54
|
+
*/
|
|
55
|
+
async function buildSwapAndDepositTransaction({ signer, srcToken, srcDecimals, destToken, destDecimals, amount, network, adapterConfig, userAddress, }) {
|
|
56
|
+
// Get price quote from Paraswap
|
|
57
|
+
const priceRoute = await getParaswapQuote({
|
|
58
|
+
srcToken,
|
|
59
|
+
destToken,
|
|
60
|
+
amount,
|
|
61
|
+
network,
|
|
62
|
+
srcDecimals,
|
|
63
|
+
destDecimals,
|
|
64
|
+
});
|
|
65
|
+
if (!priceRoute || !priceRoute.destAmount) {
|
|
66
|
+
throw new Error('No price route found from Paraswap');
|
|
67
|
+
}
|
|
68
|
+
// Create adapter contract
|
|
69
|
+
// Note: Transaction data will be built in the calling code
|
|
70
|
+
const adapterContract = (0, core_1.createContract)({
|
|
71
|
+
address: adapterConfig.wrapperAddress,
|
|
72
|
+
provider: signer,
|
|
73
|
+
abi: abis_1.ABI_POOL_ADAPTER,
|
|
74
|
+
});
|
|
75
|
+
return adapterContract;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Build native/wrapped token deposit transaction
|
|
79
|
+
*/
|
|
80
|
+
async function buildNativeDepositTransaction({ signer, srcToken, amount, poolName, adapterConfig, userAddress, }) {
|
|
81
|
+
const isNative = srcToken === '0x0000000000000000000000000000000000000000';
|
|
82
|
+
const wrapperContract = (0, core_1.createContract)({
|
|
83
|
+
address: adapterConfig.wrapperAddress,
|
|
84
|
+
provider: signer,
|
|
85
|
+
abi: (adapterConfig.abi ||
|
|
86
|
+
abis_1.ABI_WRAPPER_ADAPTER),
|
|
87
|
+
});
|
|
88
|
+
// Handle different pool types
|
|
89
|
+
if (poolName === adapters_1.POOL_NAMES.ETH_TREEHOUSE_GROWTH) {
|
|
90
|
+
if (isNative) {
|
|
91
|
+
return {
|
|
92
|
+
contract: wrapperContract,
|
|
93
|
+
functionName: 'depositETH',
|
|
94
|
+
args: [adapterConfig.referralId],
|
|
95
|
+
value: BigInt(amount),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
contract: wrapperContract,
|
|
100
|
+
functionName: 'depositWETH',
|
|
101
|
+
args: [BigInt(amount), adapterConfig.referralId],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (poolName === adapters_1.POOL_NAMES.AVAX_AVAX) {
|
|
105
|
+
return {
|
|
106
|
+
contract: wrapperContract,
|
|
107
|
+
functionName: 'depositETH',
|
|
108
|
+
args: [],
|
|
109
|
+
value: BigInt(amount),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (poolName === adapters_1.POOL_NAMES.ETH_KELP_TAC_RSETH) {
|
|
113
|
+
if (isNative) {
|
|
114
|
+
return {
|
|
115
|
+
contract: wrapperContract,
|
|
116
|
+
functionName: 'getRSETHWithETH',
|
|
117
|
+
args: [adapterConfig.referralId],
|
|
118
|
+
value: BigInt(amount),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
contract: wrapperContract,
|
|
123
|
+
functionName: 'getRSETHWithERC20',
|
|
124
|
+
args: [
|
|
125
|
+
adapterConfig.wrappedTokenAddress,
|
|
126
|
+
BigInt(amount),
|
|
127
|
+
adapterConfig.referralId,
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// Default native deposit
|
|
132
|
+
if (isNative && adapterConfig.isNativeTokenDeposit) {
|
|
133
|
+
return {
|
|
134
|
+
contract: wrapperContract,
|
|
135
|
+
functionName: 'depositETH',
|
|
136
|
+
args: adapterConfig.referralId ? [adapterConfig.referralId] : [],
|
|
137
|
+
value: BigInt(amount),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
throw new Error('Unsupported deposit configuration');
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Preview adapter deposit output
|
|
144
|
+
*/
|
|
145
|
+
async function previewAdapterDeposit({ signer, vaultAddress, srcToken, srcAmount, srcDecimals, destToken, destDecimals, adapterConfig, chainId, }) {
|
|
146
|
+
// If using Paraswap bridge, get quote
|
|
147
|
+
if (adapterConfig.bridgeId === 2) {
|
|
148
|
+
const quote = await getParaswapQuote({
|
|
149
|
+
srcToken,
|
|
150
|
+
destToken,
|
|
151
|
+
amount: srcAmount,
|
|
152
|
+
network: chainId.toString(),
|
|
153
|
+
srcDecimals,
|
|
154
|
+
destDecimals,
|
|
155
|
+
});
|
|
156
|
+
return BigInt(quote.destAmount || 0);
|
|
157
|
+
}
|
|
158
|
+
// If view adapter is available, use it
|
|
159
|
+
if (adapterConfig.viewAdapter) {
|
|
160
|
+
const viewContract = (0, core_1.createContract)({
|
|
161
|
+
address: adapterConfig.viewAdapter,
|
|
162
|
+
provider: signer,
|
|
163
|
+
abi: [
|
|
164
|
+
{
|
|
165
|
+
inputs: [
|
|
166
|
+
{ internalType: 'address', name: 'asset', type: 'address' },
|
|
167
|
+
{ internalType: 'uint256', name: 'depositAmount', type: 'uint256' },
|
|
168
|
+
],
|
|
169
|
+
name: 'getRsETHAmountToMint',
|
|
170
|
+
outputs: [
|
|
171
|
+
{ internalType: 'uint256', name: 'rsETHAmount', type: 'uint256' },
|
|
172
|
+
],
|
|
173
|
+
stateMutability: 'view',
|
|
174
|
+
type: 'function',
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
});
|
|
178
|
+
const output = await viewContract.getRsETHAmountToMint(srcToken, BigInt(srcAmount));
|
|
179
|
+
return BigInt(output);
|
|
180
|
+
}
|
|
181
|
+
// Default: assume 1:1 ratio
|
|
182
|
+
return BigInt(srcAmount);
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=adapter.helpers.js.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { IAddress } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch the set of vaults whose deposit/withdraw history is served from the
|
|
4
|
+
* backend Mongo snapshot (`/upshift/vault_history`) rather than their (retired)
|
|
5
|
+
* Goldsky subgraph.
|
|
6
|
+
*
|
|
7
|
+
* This is the routing source of truth: a vault appears here only once its
|
|
8
|
+
* history has been backfilled, so the SDK can never reroute a vault to empty
|
|
9
|
+
* snapshot data ahead of its backfill. Result is cached for 10 minutes.
|
|
10
|
+
*
|
|
11
|
+
* Side effects: one HTTP GET to the public API (cached).
|
|
12
|
+
*
|
|
13
|
+
* @returns A set of lowercased vault addresses. Empty on any error — callers
|
|
14
|
+
* then fall back to the subgraph path, which is the safe default while
|
|
15
|
+
* subgraphs still exist.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fetchArchivedVaults(): Promise<Set<string>>;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a vault's history should be served from the backend snapshot rather
|
|
20
|
+
* than its subgraph. Backed by {@link fetchArchivedVaults} (cached).
|
|
21
|
+
*
|
|
22
|
+
* @param vaultAddress - The vault contract address (any casing).
|
|
23
|
+
* @returns `true` if the vault has a backfilled history snapshot.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isArchivedVault(vaultAddress: IAddress): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Specialized vault fetching with enhanced retry logic and fallback strategies
|
|
28
|
+
* This function attempts to fetch vault data with multiple fallback approaches
|
|
29
|
+
*
|
|
30
|
+
* The return shape is "success flag wins": when `success === true`, `data` is
|
|
31
|
+
* the resolved value (which may legitimately be falsy — `0`, `''`, `0n`,
|
|
32
|
+
* `null`); when `success === false`, `error` is populated. Callers must branch
|
|
33
|
+
* on `success`, not on the truthiness of `data`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function fetchVaultWithFallback<T>(vaultAddress: string, fetchFn: () => Promise<T>, options?: {
|
|
36
|
+
maxRetries?: number;
|
|
37
|
+
baseDelay?: number;
|
|
38
|
+
fallbackStrategies?: Array<() => Promise<T>>;
|
|
39
|
+
timeout?: number;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
success: boolean;
|
|
42
|
+
data?: T;
|
|
43
|
+
error?: Error;
|
|
44
|
+
strategy: string;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Batch vault fetching with intelligent retry and fallback
|
|
48
|
+
* Ensures maximum vault coverage by trying multiple strategies
|
|
49
|
+
*/
|
|
50
|
+
export declare function fetchVaultsBatch<T>(vaults: Array<{
|
|
51
|
+
address: string;
|
|
52
|
+
fetchFn: () => Promise<T>;
|
|
53
|
+
}>, options?: {
|
|
54
|
+
maxRetries?: number;
|
|
55
|
+
baseDelay?: number;
|
|
56
|
+
batchSize?: number;
|
|
57
|
+
parallelLimit?: number;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
successful: Array<{
|
|
60
|
+
index: number;
|
|
61
|
+
data: T;
|
|
62
|
+
strategy: string;
|
|
63
|
+
}>;
|
|
64
|
+
failed: Array<{
|
|
65
|
+
index: number;
|
|
66
|
+
error: Error;
|
|
67
|
+
address: string;
|
|
68
|
+
}>;
|
|
69
|
+
totalAttempted: number;
|
|
70
|
+
successRate: number;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Comprehensive vault fetching that handles all failure points
|
|
74
|
+
* This function ensures maximum vault coverage by implementing multiple strategies
|
|
75
|
+
*/
|
|
76
|
+
export declare function fetchVaultsComprehensive<T>(vaults: Array<{
|
|
77
|
+
address: string;
|
|
78
|
+
chain: number;
|
|
79
|
+
}>, fetchFn: (vault: {
|
|
80
|
+
address: string;
|
|
81
|
+
chain: number;
|
|
82
|
+
fallbackRpc?: string;
|
|
83
|
+
minimal?: boolean;
|
|
84
|
+
}) => Promise<T>, options?: {
|
|
85
|
+
maxRetries?: number;
|
|
86
|
+
baseDelay?: number;
|
|
87
|
+
batchSize?: number;
|
|
88
|
+
parallelLimit?: number;
|
|
89
|
+
includeClosed?: boolean;
|
|
90
|
+
includeInvisible?: boolean;
|
|
91
|
+
fallbackRpcUrls?: Record<number, string[]>;
|
|
92
|
+
timeout?: number;
|
|
93
|
+
}): Promise<{
|
|
94
|
+
successful: Array<{
|
|
95
|
+
index: number;
|
|
96
|
+
data: T;
|
|
97
|
+
strategy: string;
|
|
98
|
+
attempts: number;
|
|
99
|
+
}>;
|
|
100
|
+
failed: Array<{
|
|
101
|
+
index: number;
|
|
102
|
+
error: Error;
|
|
103
|
+
address: string;
|
|
104
|
+
chain: number;
|
|
105
|
+
attempts: number;
|
|
106
|
+
}>;
|
|
107
|
+
totalAttempted: number;
|
|
108
|
+
successRate: number;
|
|
109
|
+
coverageReport: {
|
|
110
|
+
totalVaults: number;
|
|
111
|
+
successfulVaults: number;
|
|
112
|
+
failedVaults: number;
|
|
113
|
+
closedVaults: number;
|
|
114
|
+
invisibleVaults: number;
|
|
115
|
+
rpcFailures: Record<number, number>;
|
|
116
|
+
};
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Enhanced vault filtering that preserves more vaults while maintaining quality
|
|
120
|
+
*/
|
|
121
|
+
export declare function filterVaultsIntelligently<T extends {
|
|
122
|
+
status?: string;
|
|
123
|
+
isVisible?: boolean;
|
|
124
|
+
is_visible?: boolean;
|
|
125
|
+
}>(vaults: (T | null)[], options?: {
|
|
126
|
+
includeClosed?: boolean;
|
|
127
|
+
includeInvisible?: boolean;
|
|
128
|
+
includeNull?: boolean;
|
|
129
|
+
minStatus?: string[];
|
|
130
|
+
}): {
|
|
131
|
+
active: T[];
|
|
132
|
+
closed: T[];
|
|
133
|
+
invisible: T[];
|
|
134
|
+
failed: Array<{
|
|
135
|
+
index: number;
|
|
136
|
+
reason: string;
|
|
137
|
+
}>;
|
|
138
|
+
summary: {
|
|
139
|
+
total: number;
|
|
140
|
+
active: number;
|
|
141
|
+
closed: number;
|
|
142
|
+
invisible: number;
|
|
143
|
+
failed: number;
|
|
144
|
+
successRate: number;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export { fetchVaultMetadata } from '../../core/vault-metadata';
|