@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,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Upshift
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_FETCH_OPTIONS = exports.WEBSERVER_ENDPOINTS = exports.WEBSERVER_URL = exports.PRICE_SERVER_URL = exports.REQUEST_TIMEOUT_MS = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
/**
|
|
9
|
+
* Build the path segment for a subaccount identifier.
|
|
10
|
+
*
|
|
11
|
+
* Why this exists: subaccounts are not EVM-only. Vault operators and loan
|
|
12
|
+
* borrowers can be Solana base58 keys or Stellar `G…`/`C…` addresses, and the
|
|
13
|
+
* backend keys those records by their native string form. Calling ethers'
|
|
14
|
+
* `getAddress()` on them throws `INVALID_ARGUMENT` before the request is ever
|
|
15
|
+
* made — which is how a Solana borrower turned every
|
|
16
|
+
* `getVaultAllocations` call for a mixed-chain vault into a
|
|
17
|
+
* `TypeError: invalid address` (see `getVaultAllocations:cefi` /
|
|
18
|
+
* `:otc` in Sentry).
|
|
19
|
+
*
|
|
20
|
+
* EVM addresses are still checksummed, because the backend expects the
|
|
21
|
+
* checksummed form for those and case-normalising avoids cache misses.
|
|
22
|
+
* Everything else is passed through URL-encoded so a malformed value can never
|
|
23
|
+
* inject extra path segments.
|
|
24
|
+
*
|
|
25
|
+
* @param subaccount - Subaccount identifier: EVM hex address, Solana base58
|
|
26
|
+
* public key, or Stellar strkey. Not validated beyond the EVM branch — the
|
|
27
|
+
* backend is the authority on whether a non-EVM identifier exists.
|
|
28
|
+
* @returns A single URL path segment safe to interpolate into an endpoint.
|
|
29
|
+
*/
|
|
30
|
+
function subaccountSegment(subaccount) {
|
|
31
|
+
return (0, ethers_1.isAddress)(subaccount)
|
|
32
|
+
? (0, ethers_1.getAddress)(subaccount)
|
|
33
|
+
: encodeURIComponent(subaccount);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Default per-request timeout, in milliseconds, for every Upshift HTTP fetcher
|
|
37
|
+
* (`fetchUpshiftPublic`, `fetchUpshiftWithKey`, `fetchUpshiftWithBearer`).
|
|
38
|
+
*
|
|
39
|
+
* Previously 90s. That was longer than any realistic caller was willing to
|
|
40
|
+
* wait: server-rendered integrations run inside serverless functions whose own
|
|
41
|
+
* execution budget is well under 90s, so the request had already been abandoned
|
|
42
|
+
* upstream by the time the abort fired — the timeout only ever garbage-collected
|
|
43
|
+
* a dead request, while the socket stayed open holding backend capacity and
|
|
44
|
+
* amplifying the stall for every concurrent caller.
|
|
45
|
+
*
|
|
46
|
+
* 15s is above the p99 of a healthy Upshift API response and below every common
|
|
47
|
+
* upstream budget (Vercel/Lambda defaults, browser patience, upstream gateway
|
|
48
|
+
* timeouts), so a stalled request now fails fast and frees its connection.
|
|
49
|
+
*
|
|
50
|
+
* Callers that genuinely need longer override per-request via
|
|
51
|
+
* `IFetchUpshiftOptions.timeoutMs`, or process-wide via `setSdkRequestTimeout`.
|
|
52
|
+
*/
|
|
53
|
+
exports.REQUEST_TIMEOUT_MS = 15000;
|
|
54
|
+
exports.PRICE_SERVER_URL = 'https://prices.augustdigital.io';
|
|
55
|
+
exports.WEBSERVER_URL = {
|
|
56
|
+
production: 'https://backend.fractalprotocol.org',
|
|
57
|
+
staging: 'https://backend.staging.fractalprotocol.org',
|
|
58
|
+
development: 'https://backend-dev.augustdigital.io',
|
|
59
|
+
localhost: 'http://127.0.0.1:8000',
|
|
60
|
+
qa: 'https://backend-qa.augustdigital.io',
|
|
61
|
+
public: 'https://api.augustdigital.io/api/v1',
|
|
62
|
+
upshift: 'https://app.upshift.finance',
|
|
63
|
+
};
|
|
64
|
+
exports.WEBSERVER_ENDPOINTS = {
|
|
65
|
+
default: {
|
|
66
|
+
/** @deprecated No backend route. Removed in the next major release. */
|
|
67
|
+
hello: '/hello',
|
|
68
|
+
protected: '/protected',
|
|
69
|
+
},
|
|
70
|
+
auth: {
|
|
71
|
+
verify: '/auth/secret',
|
|
72
|
+
sign: '/auth/sign',
|
|
73
|
+
login: '/auth/login',
|
|
74
|
+
nonce: '/auth/nonce',
|
|
75
|
+
refresh: '/auth/refresh',
|
|
76
|
+
},
|
|
77
|
+
subaccount: {
|
|
78
|
+
list: (offset = 0, limit = 100) => `/subaccount?offset=${offset}&limit=${limit}`,
|
|
79
|
+
/** @deprecated No backend route. Removed in the next major release. */
|
|
80
|
+
rewards: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/rewards`,
|
|
81
|
+
tokens: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/tokens`,
|
|
82
|
+
twap: {
|
|
83
|
+
create: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/twap`,
|
|
84
|
+
stop: (subaccount, id) => `/subaccount/${subaccountSegment(subaccount)}/twap/${id}/stop`,
|
|
85
|
+
fills: (subaccount, id) => `/subaccount/${subaccountSegment(subaccount)}/twap/${id}/fills`,
|
|
86
|
+
},
|
|
87
|
+
debank: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/debank`,
|
|
88
|
+
health_factor: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/health_factor`,
|
|
89
|
+
summary: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/summary`,
|
|
90
|
+
/** @deprecated No backend route. Removed in the next major release. */
|
|
91
|
+
batch: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/tx_batcher_integrations`,
|
|
92
|
+
loans: (subaccount, side = 'BOTH', active = true) => `/subaccount/${subaccountSegment(subaccount)}/loans?side=${side}&active=${active}`,
|
|
93
|
+
cefi: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/cefi_position`,
|
|
94
|
+
otc_positions: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/otc_positions`,
|
|
95
|
+
loanByAddress: (loanAddress, chainId) => `/subaccount/loans/${encodeURIComponent(loanAddress)}?chain_id=${chainId}`,
|
|
96
|
+
_: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}`,
|
|
97
|
+
},
|
|
98
|
+
transactions: {
|
|
99
|
+
v2: (subaccount, startTime, endTime) => {
|
|
100
|
+
const params = new URLSearchParams({ address: subaccount });
|
|
101
|
+
if (startTime !== undefined)
|
|
102
|
+
params.set('start_time', startTime);
|
|
103
|
+
if (endTime !== undefined)
|
|
104
|
+
params.set('end_time', endTime);
|
|
105
|
+
return `/transactions/v2?${params.toString()}`;
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
otc: {
|
|
109
|
+
positions: '/otc/position',
|
|
110
|
+
marginRequirements: (otcCounterpartyId, payer) => {
|
|
111
|
+
const params = new URLSearchParams();
|
|
112
|
+
if (otcCounterpartyId !== undefined)
|
|
113
|
+
params.set('otc_counter_party_id', otcCounterpartyId);
|
|
114
|
+
if (payer !== undefined)
|
|
115
|
+
params.set('payer', payer);
|
|
116
|
+
const query = params.toString();
|
|
117
|
+
return `/otc/margin_requirement${query ? `?${query}` : ''}`;
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
curator: {
|
|
121
|
+
vaultSubaccounts: (vaultAddress) => `/curator/vaults/${encodeURIComponent(vaultAddress)}/subaccounts`,
|
|
122
|
+
vaultWhitelist: (vaultAddress) => `/curator/vaults/${encodeURIComponent(vaultAddress)}/whitelist`,
|
|
123
|
+
},
|
|
124
|
+
timelockRequests: (vaultAddress, chainId, status) => {
|
|
125
|
+
const params = new URLSearchParams({
|
|
126
|
+
vaultAddress,
|
|
127
|
+
chainId: String(chainId),
|
|
128
|
+
});
|
|
129
|
+
if (status !== undefined)
|
|
130
|
+
params.set('status', status);
|
|
131
|
+
return `/timelock-requests?${params.toString()}`;
|
|
132
|
+
},
|
|
133
|
+
users: {
|
|
134
|
+
get: '/users',
|
|
135
|
+
},
|
|
136
|
+
dashboard: {
|
|
137
|
+
loans: '/dashboard/loans',
|
|
138
|
+
},
|
|
139
|
+
risk: {
|
|
140
|
+
discountFactors: '/risk/discount_factors',
|
|
141
|
+
collateralExcessOrDeficit: (subaccount, tokenAddress, tokenChain, targetHealthFactor) => {
|
|
142
|
+
const params = new URLSearchParams({
|
|
143
|
+
address: subaccount,
|
|
144
|
+
token_address: tokenAddress,
|
|
145
|
+
token_chain: String(tokenChain),
|
|
146
|
+
});
|
|
147
|
+
if (targetHealthFactor !== undefined)
|
|
148
|
+
params.set('target_health_factor', String(targetHealthFactor));
|
|
149
|
+
return `/risk/collateral_excess_or_deficit?${params.toString()}`;
|
|
150
|
+
},
|
|
151
|
+
collateralSimulation: '/risk/collateral_simulation',
|
|
152
|
+
},
|
|
153
|
+
prices: (symbol) => `/prices/${symbol}`,
|
|
154
|
+
metrics: {
|
|
155
|
+
pnl: (subaccount, startTime, endTime) => `/metrics/pnl?subaccount_address=${subaccountSegment(subaccount)}${startTime && endTime ? `&start=${startTime}&end=${endTime}` : ''}`,
|
|
156
|
+
vaultPerformanceFees: (params) => {
|
|
157
|
+
const q = new URLSearchParams({
|
|
158
|
+
vault_address: params.vaultAddress,
|
|
159
|
+
annualized_fees_pct: String(params.annualizedFeesPct),
|
|
160
|
+
native_denominated: String(params.nativeDenominated),
|
|
161
|
+
calculation_period: params.calculationPeriod,
|
|
162
|
+
});
|
|
163
|
+
if (params.startDate !== undefined)
|
|
164
|
+
q.set('start_date', params.startDate);
|
|
165
|
+
if (params.endDate !== undefined)
|
|
166
|
+
q.set('end_date', params.endDate);
|
|
167
|
+
return `/metrics/vault_performance_fees?${q.toString()}`;
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
public: {
|
|
171
|
+
integrations: {
|
|
172
|
+
morpho: {
|
|
173
|
+
apy: (subaccount, vaultAddress) => `/integrations/morpho/apy?subaccount_address=${subaccountSegment(subaccount)}&vault_address=${(0, ethers_1.getAddress)(vaultAddress)}`,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
tokenizedVault: {
|
|
177
|
+
loans: (vaultAddress, chainId, active) => `/upshift/lending_pool/loanbook?address=${vaultAddress}&chain=${chainId}&active=${active}`,
|
|
178
|
+
subaccountLoans: (vaultAddress, chainId, active) => `/upshift/lending_pool/subaccounts_loanbook?address=${vaultAddress}&chain=${chainId}&active=${active}`,
|
|
179
|
+
list: '/tokenized_vault',
|
|
180
|
+
byVaultAddress: (vaultAddress) => `/tokenized_vault/${vaultAddress}`,
|
|
181
|
+
historicalApy: (vaultAddress) => `/upshift/historical_apy/chart?vault_address=${vaultAddress}`,
|
|
182
|
+
historicalTimeseries: (vaultAddress, nDays) => `/tokenized_vault/${vaultAddress}/historical-timeseries${nDays ? `?n_days=${nDays}` : ''}`,
|
|
183
|
+
annualizedApy: (vaultAddress) => `/tokenized_vault/annualized_apy/${(0, ethers_1.getAddress)(vaultAddress)}`,
|
|
184
|
+
summary: (vaultAddress) => `/tokenized_vault/vault_summary/${(0, ethers_1.getAddress)(vaultAddress)}`,
|
|
185
|
+
withdrawals: (chain, vaultAddress) => `/withdrawals/${chain}/${(0, ethers_1.getAddress)(vaultAddress)}`,
|
|
186
|
+
debank: (vaultAddress) => `/tokenized_vault/${(0, ethers_1.getAddress)(vaultAddress)}/debank`,
|
|
187
|
+
octav: (vaultAddress) => `/tokenized_vault/${subaccountSegment(vaultAddress)}/octav`,
|
|
188
|
+
// Mongo-backed deposit/withdraw history for archived vaults whose
|
|
189
|
+
// subgraph has been (or will be) retired. See fetchArchivedVaults.
|
|
190
|
+
userHistory: (vaultAddress, wallet) => `/upshift/vault_history/${(0, ethers_1.getAddress)(vaultAddress)}?wallet=${(0, ethers_1.getAddress)(wallet)}`,
|
|
191
|
+
// Vaults whose history is served from the snapshot (source of truth for
|
|
192
|
+
// routing — a vault appears only after its backfill completes).
|
|
193
|
+
archivedVaults: '/upshift/vault_history/archived',
|
|
194
|
+
},
|
|
195
|
+
points: {
|
|
196
|
+
byUserAddress: (userAddress) => `/upshift/points/${(0, ethers_1.getAddress)(userAddress)}`,
|
|
197
|
+
register: '/upshift/points/register',
|
|
198
|
+
leaderboard: '/upshift/points/leaderboard',
|
|
199
|
+
},
|
|
200
|
+
vaults: {
|
|
201
|
+
pendingRedemptions: (vaultAddress) => `/vaults/${vaultAddress}/pending-redemptions`,
|
|
202
|
+
},
|
|
203
|
+
pnl: {
|
|
204
|
+
unrealizedHistory: (vaultAddress, limit) => `/upshift/unrealized_pnl?vault_address=${vaultAddress}${limit !== undefined ? `&limit=${limit}` : ''}`,
|
|
205
|
+
unrealizedLatest: '/upshift/unrealized_pnl/latest',
|
|
206
|
+
},
|
|
207
|
+
revertReason: (txHash, chain) => `/revert_reason?${new URLSearchParams({
|
|
208
|
+
tx_hash: txHash,
|
|
209
|
+
chain: String(chain),
|
|
210
|
+
}).toString()}`,
|
|
211
|
+
oracleClassification: (vaultAddress, chainId) => `/upshift/oracle_classification/${encodeURIComponent(vaultAddress)}?chain_id=${chainId}`,
|
|
212
|
+
// Transparency dashboard endpoints (all public, snapshot-backed).
|
|
213
|
+
transparency: {
|
|
214
|
+
positions: (vaultAddress, chainId) => `/upshift/positions/${encodeURIComponent(vaultAddress)}?chain_id=${chainId}`,
|
|
215
|
+
historicalAllocations: (vaultAddress, chainId, startDate, endDate) => {
|
|
216
|
+
const q = new URLSearchParams({ chain_id: String(chainId) });
|
|
217
|
+
if (startDate)
|
|
218
|
+
q.set('start_date', startDate);
|
|
219
|
+
// The backend compares `<= end_date` as a datetime, so a bare date
|
|
220
|
+
// would exclude the whole last day; widen to end-of-day for the
|
|
221
|
+
// documented inclusive semantics.
|
|
222
|
+
if (endDate)
|
|
223
|
+
q.set('end_date', `${endDate}T23:59:59.999`);
|
|
224
|
+
return `/upshift/historical_allocations/${encodeURIComponent(vaultAddress)}?${q.toString()}`;
|
|
225
|
+
},
|
|
226
|
+
fees: (vaultAddress, chainId) => `/upshift/fees/${encodeURIComponent(vaultAddress)}?chain_id=${chainId}`,
|
|
227
|
+
ratioSeries: (vaultAddress, startDate, endDate, limit) => {
|
|
228
|
+
const q = new URLSearchParams({
|
|
229
|
+
vault_address: vaultAddress,
|
|
230
|
+
fields: 'ratio',
|
|
231
|
+
});
|
|
232
|
+
if (startDate)
|
|
233
|
+
q.set('start_date', startDate);
|
|
234
|
+
// See historicalAllocations: widen to end-of-day for inclusive semantics.
|
|
235
|
+
if (endDate)
|
|
236
|
+
q.set('end_date', `${endDate}T23:59:59.999`);
|
|
237
|
+
if (limit !== undefined)
|
|
238
|
+
q.set('limit', String(limit));
|
|
239
|
+
return `/upshift/unrealized_pnl?${q.toString()}`;
|
|
240
|
+
},
|
|
241
|
+
smoothedApy: (vaultAddress, daysAgo, averagingPeriodDays, applySmoothing) => `/upshift/historical_apy/chart?${new URLSearchParams({
|
|
242
|
+
vault_address: vaultAddress,
|
|
243
|
+
days_ago: String(daysAgo),
|
|
244
|
+
averaging_period_in_days: String(averagingPeriodDays),
|
|
245
|
+
apply_smoothing: String(applySmoothing),
|
|
246
|
+
}).toString()}`,
|
|
247
|
+
governanceRoles: (vaultAddress, chainId) => `/upshift/governance/${encodeURIComponent(vaultAddress)}/roles?chain_id=${chainId}`,
|
|
248
|
+
governancePermissions: (vaultAddress, chainId) => `/upshift/governance/${encodeURIComponent(vaultAddress)}/permissions?chain_id=${chainId}`,
|
|
249
|
+
governanceTimelocks: (vaultAddress, chainId, status) => {
|
|
250
|
+
const q = new URLSearchParams({ chain_id: String(chainId) });
|
|
251
|
+
if (status)
|
|
252
|
+
q.set('status', status);
|
|
253
|
+
return `/upshift/governance/${encodeURIComponent(vaultAddress)}/timelocks?${q.toString()}`;
|
|
254
|
+
},
|
|
255
|
+
governanceAuditLog: (vaultAddress, chainId, category, before, limit) => {
|
|
256
|
+
const q = new URLSearchParams({ chain_id: String(chainId) });
|
|
257
|
+
if (category)
|
|
258
|
+
q.set('category', category);
|
|
259
|
+
if (before)
|
|
260
|
+
q.set('before', before);
|
|
261
|
+
if (limit !== undefined)
|
|
262
|
+
q.set('limit', String(limit));
|
|
263
|
+
return `/upshift/governance/${encodeURIComponent(vaultAddress)}/audit_log?${q.toString()}`;
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
upshift: {
|
|
268
|
+
vaults: {
|
|
269
|
+
metadata: `/api/sdk/vaults-metadata`,
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
// TODO: add remaining endpoints
|
|
273
|
+
};
|
|
274
|
+
exports.DEFAULT_FETCH_OPTIONS = {
|
|
275
|
+
method: 'GET',
|
|
276
|
+
headers: {
|
|
277
|
+
Accept: 'application/json',
|
|
278
|
+
'Content-Type': 'application/json',
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { IAddress } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Address of the `SwapRouter` periphery contract on each supported chain.
|
|
4
|
+
*
|
|
5
|
+
* Missing keys mean no SwapRouter is deployed on that chain — callers
|
|
6
|
+
* should fall back to legacy adapter paths.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link getSwapRouterAddress} for the typed lookup helper.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SWAP_ROUTER_ADDRESSES: Readonly<Record<number, IAddress>>;
|
|
11
|
+
/**
|
|
12
|
+
* Human-readable display name of the `SwapRouter` periphery contract on each
|
|
13
|
+
* supported chain.
|
|
14
|
+
*
|
|
15
|
+
* The contract exposes no on-chain name (no `@title` accessor), so UIs that
|
|
16
|
+
* want to show *which contract* performed the swap-and-deposit — rather than a
|
|
17
|
+
* bare address — read it from here. Display metadata only: never derive
|
|
18
|
+
* routing or eligibility logic from it.
|
|
19
|
+
*
|
|
20
|
+
* Missing keys mean no SwapRouter is deployed on that chain.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link getSwapRouterName} for the typed lookup helper.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SWAP_ROUTER_NAMES: Readonly<Record<number, string>>;
|
|
25
|
+
/**
|
|
26
|
+
* Vaults whose UI **may offer the any-token SwapRouter deposit surface**
|
|
27
|
+
* (swap tokens).
|
|
28
|
+
*
|
|
29
|
+
* This is *eligibility metadata only*. It is consumed by:
|
|
30
|
+
* - the app UI, to decide whether to render the (flag-gated) swap-router
|
|
31
|
+
* deposit surface for a vault; and
|
|
32
|
+
* - {@link swapRouterDeposit}, optionally, as a fail-fast eligibility check.
|
|
33
|
+
*
|
|
34
|
+
* It is deliberately **NOT** read by {@link vaultDeposit}: `vaultDeposit` never
|
|
35
|
+
* swaps, and uses the SwapRouter only for a direct deposit of an asset the
|
|
36
|
+
* vault accepts (see `getDepositRoute`). That separation is what
|
|
37
|
+
* stops a natively-accepted asset from being silently swapped — the
|
|
38
|
+
* regression that implicit auto-routing caused. Any-token swap
|
|
39
|
+
* deposits are the explicit, opt-in job of {@link swapRouterDeposit}.
|
|
40
|
+
*
|
|
41
|
+
* A listed vault's natively-accepted assets
|
|
42
|
+
* (for a multi-asset vault, its whole deposit-asset set) still deposit via
|
|
43
|
+
* `vaultDeposit`; only tokens OUTSIDE that set go through `swapRouterDeposit`.
|
|
44
|
+
*
|
|
45
|
+
* Lowercase comparison is required when checking — use
|
|
46
|
+
* {@link isSwapRouterEligible} rather than reading this set directly.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Superseded by {@link getSwapRouterEligibleVaults}, which reads
|
|
49
|
+
* the backend `swaps_enabled` flag — so new vaults surface without an SDK
|
|
50
|
+
* release. This static set stays
|
|
51
|
+
* functional as the zero-RPC fallback seed (e.g. TanStack Query `initialData`)
|
|
52
|
+
* and for SDK-internal sync consumers.
|
|
53
|
+
*/
|
|
54
|
+
export declare const SWAP_ROUTER_ELIGIBLE_VAULTS: ReadonlySet<string>;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Renamed to {@link SWAP_ROUTER_ELIGIBLE_VAULTS} (itself now
|
|
57
|
+
* superseded by {@link getSwapRouterEligibleVaults}, the `swaps_enabled`
|
|
58
|
+
* resolver), and the semantics changed: this set no longer drives
|
|
59
|
+
* `vaultDeposit` auto-routing (that branch was removed) — it only marks vaults
|
|
60
|
+
* whose UI may offer the swap-router deposit surface. Kept as an alias for one
|
|
61
|
+
* release; migrate to the async resolver.
|
|
62
|
+
*/
|
|
63
|
+
export declare const VAULTS_USING_SWAP_ROUTER: ReadonlySet<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Block at which each chain's `SwapRouter` was deployed/configured — the safe
|
|
66
|
+
* lower bound for scanning its `TokenEnabled` log history.
|
|
67
|
+
*
|
|
68
|
+
* The router stores its allowlist as `mapping(address => bool) whitelistedTokens`
|
|
69
|
+
* with no on-chain enumeration, so {@link getSwapRouterWhitelistedTokens} must
|
|
70
|
+
* reconstruct the candidate set from `TokenEnabled` events before verifying each
|
|
71
|
+
* against the current mapping. Starting the `eth_getLogs` scan here (rather than
|
|
72
|
+
* from genesis) bounds it to the router's own lifetime — a few chunks — instead
|
|
73
|
+
* of the whole chain.
|
|
74
|
+
*
|
|
75
|
+
* Each value is the router's deployment block (its first emitted event, the
|
|
76
|
+
* constructor `OwnershipTransferred`). A too-low value only costs extra empty
|
|
77
|
+
* log ranges; a value ABOVE the first `TokenEnabled` would silently miss tokens,
|
|
78
|
+
* so err on the side of earlier.
|
|
79
|
+
*/
|
|
80
|
+
export declare const SWAP_ROUTER_DEPLOY_BLOCKS: Readonly<Record<number, number>>;
|
|
81
|
+
/**
|
|
82
|
+
* 32-byte origin codes registered on the `SwapRouter` via `addOrigin`.
|
|
83
|
+
* Drives origin/referral-fee accrual. The on-chain admin must register a
|
|
84
|
+
* code before it can be used — calls with an unknown code revert with
|
|
85
|
+
* `InvalidOrigin`.
|
|
86
|
+
*
|
|
87
|
+
* `default` is the all-zero sentinel — the SwapRouter treats it as "no
|
|
88
|
+
* origin fee" and skips the origin-fee transfer.
|
|
89
|
+
*/
|
|
90
|
+
export declare const ORIGIN_CODES: {
|
|
91
|
+
/** All-zero sentinel — no origin fee. */
|
|
92
|
+
readonly default: `0x${string}`;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Shape of a SwapRouter origin code: `0x` followed by exactly 64 hex chars
|
|
96
|
+
* (a `bytes32`). Shared by every origin-code entry point so the constructor
|
|
97
|
+
* option, the per-call override and the registration read validate the same
|
|
98
|
+
* way.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
export declare const ORIGIN_CODE_PATTERN: RegExp;
|
|
102
|
+
/**
|
|
103
|
+
* Chains on which the SDK sends the instance origin code
|
|
104
|
+
* (`attribution.originCode`). Ethereum mainnet only: it is the one SwapRouter
|
|
105
|
+
* deployment whose origin registry has been verified. On any other chain the
|
|
106
|
+
* instance code is never sent, even where a SwapRouter is configured; an
|
|
107
|
+
* `originCode` passed to a call is still sent.
|
|
108
|
+
*/
|
|
109
|
+
export declare const ORIGIN_ATTRIBUTION_CHAINS: readonly number[];
|
|
110
|
+
/**
|
|
111
|
+
* Maximum number of swap legs the contract accepts in a single
|
|
112
|
+
* `swapAndDeposit` call. Mirrors the on-chain `MAX_SWAPS` constant; reading
|
|
113
|
+
* the on-chain value at call time would add an RPC for no gain.
|
|
114
|
+
*
|
|
115
|
+
* Kept here so the SDK can reject oversize inputs at the boundary rather
|
|
116
|
+
* than wait for the on-chain `TooManySwaps` revert.
|
|
117
|
+
*/
|
|
118
|
+
export declare const SWAP_ROUTER_MAX_SWAPS = 9;
|
|
119
|
+
/**
|
|
120
|
+
* Wrapped-native ERC-20 per chain that has a SwapRouter deployment. Mirrors
|
|
121
|
+
* the on-chain `wrappedNativeTokenAddress()` view to avoid an extra RPC on
|
|
122
|
+
* every dispatch. Used to validate that native-token deposits target a
|
|
123
|
+
* vault whose reference asset is the wrapped native — the only configuration
|
|
124
|
+
* the contract's `depositNativeToken` / `swapAndDepositNativeToken` accept.
|
|
125
|
+
*
|
|
126
|
+
* **Wrap-only, WETH-vaults-only limitation.** Both payable entry points on the
|
|
127
|
+
* deployed router (`depositNativeToken` and `swapAndDepositNativeToken`) only
|
|
128
|
+
* wrap native ETH to this address and deposit — neither has an ETH→other-asset
|
|
129
|
+
* swap leg. `swapAndDepositNativeToken`'s ABI takes no swap payload, so a DEX
|
|
130
|
+
* swap is structurally impossible on that path too; its only difference from
|
|
131
|
+
* `depositNativeToken` is applying the vault swap fee on the pure wrap. The
|
|
132
|
+
* practical consequence: **native ETH can only be deposited into a vault whose
|
|
133
|
+
* reference asset is this wrapped-native token** (e.g. a WETH-reference
|
|
134
|
+
* vault). There is no atomic native-ETH deposit into a non-WETH-reference
|
|
135
|
+
* vault (e.g. a USDC vault) — deposit the wrapped native token instead
|
|
136
|
+
* (already whitelisted, and it routes through the swap leg for a vault whose
|
|
137
|
+
* reference asset differs). True atomic ETH→any-asset support would require a
|
|
138
|
+
* contract change (a payable `swapAndDeposit` variant), which is out of scope
|
|
139
|
+
* for this SDK. Use {@link isNativeSwapRouterDepositSupported} to check a
|
|
140
|
+
* vault's eligibility for the native path before offering it in a UI.
|
|
141
|
+
*/
|
|
142
|
+
export declare const SWAP_ROUTER_WRAPPED_NATIVE: Readonly<Record<number, IAddress>>;
|
|
143
|
+
/**
|
|
144
|
+
* The DEX aggregator whitelisted on each chain's `SwapRouter` via
|
|
145
|
+
* `enableRouter`, plus the single aggregator contract method every swap leg is
|
|
146
|
+
* pinned to and that method's 4-byte selector.
|
|
147
|
+
*
|
|
148
|
+
* This is the single source of truth tying the off-chain swap-leg builder to
|
|
149
|
+
* the on-chain router whitelist. The two MUST agree or `swapAndDeposit` reverts
|
|
150
|
+
* with `InvalidRouter()` (router not whitelisted) or `InvalidNotWhitelisted()`
|
|
151
|
+
* (selector not authorized). It is consumed in three places:
|
|
152
|
+
*
|
|
153
|
+
* - `dispatchViaSwapRouter` asks {@link fetchSwapQuote} to pin the aggregator to
|
|
154
|
+
* `contractMethod`, then asserts the returned quote's `router` and payload
|
|
155
|
+
* selector match this entry before broadcasting — failing closed rather than
|
|
156
|
+
* letting the user pay gas for a transaction the contract will reject.
|
|
157
|
+
* - The CI check `scripts/verify-swap-router-aggregator.mjs` asserts the
|
|
158
|
+
* deployed `SwapRouter` actually has `tokenTransferProxies[router] != 0` and
|
|
159
|
+
* `isAuthorizedSelector(router, selector) == true` for every entry here, so
|
|
160
|
+
* config drift is caught at release time, not by a user's failed deposit.
|
|
161
|
+
*
|
|
162
|
+
* Pinning to one generic method matters: the aggregator otherwise picks a route
|
|
163
|
+
* method per quote (e.g. a direct `swapExactAmountInOnUniswapV3`) that varies
|
|
164
|
+
* with market conditions, producing a different selector each time. Pinning
|
|
165
|
+
* collapses that to one stable selector so the on-chain whitelist needs only
|
|
166
|
+
* that selector and never drifts as routing changes.
|
|
167
|
+
*
|
|
168
|
+
* `router` is the address the aggregator's calldata targets (ParaSwap v6.2
|
|
169
|
+
* pulls tokens to the Augustus contract itself, so the SwapRouter's
|
|
170
|
+
* `tokenTransferProxies[router]` is the router address). `selector` is
|
|
171
|
+
* `bytes4(keccak256("<contractMethod>(...)"))`. Verify both against the
|
|
172
|
+
* deployed router before adding a chain — a wrong value reverts at deposit time.
|
|
173
|
+
*/
|
|
174
|
+
export declare const SWAP_ROUTER_DEX_AGGREGATOR: Readonly<Record<number, {
|
|
175
|
+
router: IAddress;
|
|
176
|
+
contractMethod: string;
|
|
177
|
+
selector: `0x${string}`;
|
|
178
|
+
/** Human-readable aggregator name — for display; never derive routing logic from it. */
|
|
179
|
+
name: string;
|
|
180
|
+
}>>;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SWAP_ROUTER_DEX_AGGREGATOR = exports.SWAP_ROUTER_WRAPPED_NATIVE = exports.SWAP_ROUTER_MAX_SWAPS = exports.ORIGIN_ATTRIBUTION_CHAINS = exports.ORIGIN_CODE_PATTERN = exports.ORIGIN_CODES = exports.SWAP_ROUTER_DEPLOY_BLOCKS = exports.VAULTS_USING_SWAP_ROUTER = exports.SWAP_ROUTER_ELIGIBLE_VAULTS = exports.SWAP_ROUTER_NAMES = exports.SWAP_ROUTER_ADDRESSES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Address of the `SwapRouter` periphery contract on each supported chain.
|
|
6
|
+
*
|
|
7
|
+
* Missing keys mean no SwapRouter is deployed on that chain — callers
|
|
8
|
+
* should fall back to legacy adapter paths.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link getSwapRouterAddress} for the typed lookup helper.
|
|
11
|
+
*/
|
|
12
|
+
exports.SWAP_ROUTER_ADDRESSES = {
|
|
13
|
+
1: '0xC11c6d8fD8FfFB2045d57b149125C44414d8160B',
|
|
14
|
+
999: '0x1766f1F4C80756c0985ae93E3cf5cA5024bdAE6F',
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Human-readable display name of the `SwapRouter` periphery contract on each
|
|
18
|
+
* supported chain.
|
|
19
|
+
*
|
|
20
|
+
* The contract exposes no on-chain name (no `@title` accessor), so UIs that
|
|
21
|
+
* want to show *which contract* performed the swap-and-deposit — rather than a
|
|
22
|
+
* bare address — read it from here. Display metadata only: never derive
|
|
23
|
+
* routing or eligibility logic from it.
|
|
24
|
+
*
|
|
25
|
+
* Missing keys mean no SwapRouter is deployed on that chain.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link getSwapRouterName} for the typed lookup helper.
|
|
28
|
+
*/
|
|
29
|
+
exports.SWAP_ROUTER_NAMES = {
|
|
30
|
+
1: 'Upshift Swap Router',
|
|
31
|
+
999: 'Upshift Swap Router',
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Vaults whose UI **may offer the any-token SwapRouter deposit surface**
|
|
35
|
+
* (swap tokens).
|
|
36
|
+
*
|
|
37
|
+
* This is *eligibility metadata only*. It is consumed by:
|
|
38
|
+
* - the app UI, to decide whether to render the (flag-gated) swap-router
|
|
39
|
+
* deposit surface for a vault; and
|
|
40
|
+
* - {@link swapRouterDeposit}, optionally, as a fail-fast eligibility check.
|
|
41
|
+
*
|
|
42
|
+
* It is deliberately **NOT** read by {@link vaultDeposit}: `vaultDeposit` never
|
|
43
|
+
* swaps, and uses the SwapRouter only for a direct deposit of an asset the
|
|
44
|
+
* vault accepts (see `getDepositRoute`). That separation is what
|
|
45
|
+
* stops a natively-accepted asset from being silently swapped — the
|
|
46
|
+
* regression that implicit auto-routing caused. Any-token swap
|
|
47
|
+
* deposits are the explicit, opt-in job of {@link swapRouterDeposit}.
|
|
48
|
+
*
|
|
49
|
+
* A listed vault's natively-accepted assets
|
|
50
|
+
* (for a multi-asset vault, its whole deposit-asset set) still deposit via
|
|
51
|
+
* `vaultDeposit`; only tokens OUTSIDE that set go through `swapRouterDeposit`.
|
|
52
|
+
*
|
|
53
|
+
* Lowercase comparison is required when checking — use
|
|
54
|
+
* {@link isSwapRouterEligible} rather than reading this set directly.
|
|
55
|
+
*
|
|
56
|
+
* @deprecated Superseded by {@link getSwapRouterEligibleVaults}, which reads
|
|
57
|
+
* the backend `swaps_enabled` flag — so new vaults surface without an SDK
|
|
58
|
+
* release. This static set stays
|
|
59
|
+
* functional as the zero-RPC fallback seed (e.g. TanStack Query `initialData`)
|
|
60
|
+
* and for SDK-internal sync consumers.
|
|
61
|
+
*/
|
|
62
|
+
exports.SWAP_ROUTER_ELIGIBLE_VAULTS = new Set([
|
|
63
|
+
// Sentora USD — native multi-asset Tokenized Vault V2 (reference asset
|
|
64
|
+
// USDC). Its native assets (USDC/RLUSD/PYUSD/USDT) deposit via vaultDeposit;
|
|
65
|
+
// the swap-router surface adds deposits of tokens outside that set.
|
|
66
|
+
'0x74ad2f789ed583dbd141bbdafc673fe1f033718b',
|
|
67
|
+
]);
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Renamed to {@link SWAP_ROUTER_ELIGIBLE_VAULTS} (itself now
|
|
70
|
+
* superseded by {@link getSwapRouterEligibleVaults}, the `swaps_enabled`
|
|
71
|
+
* resolver), and the semantics changed: this set no longer drives
|
|
72
|
+
* `vaultDeposit` auto-routing (that branch was removed) — it only marks vaults
|
|
73
|
+
* whose UI may offer the swap-router deposit surface. Kept as an alias for one
|
|
74
|
+
* release; migrate to the async resolver.
|
|
75
|
+
*/
|
|
76
|
+
exports.VAULTS_USING_SWAP_ROUTER = exports.SWAP_ROUTER_ELIGIBLE_VAULTS;
|
|
77
|
+
/**
|
|
78
|
+
* Block at which each chain's `SwapRouter` was deployed/configured — the safe
|
|
79
|
+
* lower bound for scanning its `TokenEnabled` log history.
|
|
80
|
+
*
|
|
81
|
+
* The router stores its allowlist as `mapping(address => bool) whitelistedTokens`
|
|
82
|
+
* with no on-chain enumeration, so {@link getSwapRouterWhitelistedTokens} must
|
|
83
|
+
* reconstruct the candidate set from `TokenEnabled` events before verifying each
|
|
84
|
+
* against the current mapping. Starting the `eth_getLogs` scan here (rather than
|
|
85
|
+
* from genesis) bounds it to the router's own lifetime — a few chunks — instead
|
|
86
|
+
* of the whole chain.
|
|
87
|
+
*
|
|
88
|
+
* Each value is the router's deployment block (its first emitted event, the
|
|
89
|
+
* constructor `OwnershipTransferred`). A too-low value only costs extra empty
|
|
90
|
+
* log ranges; a value ABOVE the first `TokenEnabled` would silently miss tokens,
|
|
91
|
+
* so err on the side of earlier.
|
|
92
|
+
*/
|
|
93
|
+
exports.SWAP_ROUTER_DEPLOY_BLOCKS = {
|
|
94
|
+
1: 26248966,
|
|
95
|
+
999: 49232457,
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* 32-byte origin codes registered on the `SwapRouter` via `addOrigin`.
|
|
99
|
+
* Drives origin/referral-fee accrual. The on-chain admin must register a
|
|
100
|
+
* code before it can be used — calls with an unknown code revert with
|
|
101
|
+
* `InvalidOrigin`.
|
|
102
|
+
*
|
|
103
|
+
* `default` is the all-zero sentinel — the SwapRouter treats it as "no
|
|
104
|
+
* origin fee" and skips the origin-fee transfer.
|
|
105
|
+
*/
|
|
106
|
+
exports.ORIGIN_CODES = {
|
|
107
|
+
/** All-zero sentinel — no origin fee. */
|
|
108
|
+
default: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Shape of a SwapRouter origin code: `0x` followed by exactly 64 hex chars
|
|
112
|
+
* (a `bytes32`). Shared by every origin-code entry point so the constructor
|
|
113
|
+
* option, the per-call override and the registration read validate the same
|
|
114
|
+
* way.
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
exports.ORIGIN_CODE_PATTERN = /^0x[0-9a-fA-F]{64}$/;
|
|
118
|
+
/**
|
|
119
|
+
* Chains on which the SDK sends the instance origin code
|
|
120
|
+
* (`attribution.originCode`). Ethereum mainnet only: it is the one SwapRouter
|
|
121
|
+
* deployment whose origin registry has been verified. On any other chain the
|
|
122
|
+
* instance code is never sent, even where a SwapRouter is configured; an
|
|
123
|
+
* `originCode` passed to a call is still sent.
|
|
124
|
+
*/
|
|
125
|
+
exports.ORIGIN_ATTRIBUTION_CHAINS = [1];
|
|
126
|
+
/**
|
|
127
|
+
* Maximum number of swap legs the contract accepts in a single
|
|
128
|
+
* `swapAndDeposit` call. Mirrors the on-chain `MAX_SWAPS` constant; reading
|
|
129
|
+
* the on-chain value at call time would add an RPC for no gain.
|
|
130
|
+
*
|
|
131
|
+
* Kept here so the SDK can reject oversize inputs at the boundary rather
|
|
132
|
+
* than wait for the on-chain `TooManySwaps` revert.
|
|
133
|
+
*/
|
|
134
|
+
exports.SWAP_ROUTER_MAX_SWAPS = 9;
|
|
135
|
+
/**
|
|
136
|
+
* Wrapped-native ERC-20 per chain that has a SwapRouter deployment. Mirrors
|
|
137
|
+
* the on-chain `wrappedNativeTokenAddress()` view to avoid an extra RPC on
|
|
138
|
+
* every dispatch. Used to validate that native-token deposits target a
|
|
139
|
+
* vault whose reference asset is the wrapped native — the only configuration
|
|
140
|
+
* the contract's `depositNativeToken` / `swapAndDepositNativeToken` accept.
|
|
141
|
+
*
|
|
142
|
+
* **Wrap-only, WETH-vaults-only limitation.** Both payable entry points on the
|
|
143
|
+
* deployed router (`depositNativeToken` and `swapAndDepositNativeToken`) only
|
|
144
|
+
* wrap native ETH to this address and deposit — neither has an ETH→other-asset
|
|
145
|
+
* swap leg. `swapAndDepositNativeToken`'s ABI takes no swap payload, so a DEX
|
|
146
|
+
* swap is structurally impossible on that path too; its only difference from
|
|
147
|
+
* `depositNativeToken` is applying the vault swap fee on the pure wrap. The
|
|
148
|
+
* practical consequence: **native ETH can only be deposited into a vault whose
|
|
149
|
+
* reference asset is this wrapped-native token** (e.g. a WETH-reference
|
|
150
|
+
* vault). There is no atomic native-ETH deposit into a non-WETH-reference
|
|
151
|
+
* vault (e.g. a USDC vault) — deposit the wrapped native token instead
|
|
152
|
+
* (already whitelisted, and it routes through the swap leg for a vault whose
|
|
153
|
+
* reference asset differs). True atomic ETH→any-asset support would require a
|
|
154
|
+
* contract change (a payable `swapAndDeposit` variant), which is out of scope
|
|
155
|
+
* for this SDK. Use {@link isNativeSwapRouterDepositSupported} to check a
|
|
156
|
+
* vault's eligibility for the native path before offering it in a UI.
|
|
157
|
+
*/
|
|
158
|
+
exports.SWAP_ROUTER_WRAPPED_NATIVE = {
|
|
159
|
+
1: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
160
|
+
999: '0x5555555555555555555555555555555555555555',
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* The DEX aggregator whitelisted on each chain's `SwapRouter` via
|
|
164
|
+
* `enableRouter`, plus the single aggregator contract method every swap leg is
|
|
165
|
+
* pinned to and that method's 4-byte selector.
|
|
166
|
+
*
|
|
167
|
+
* This is the single source of truth tying the off-chain swap-leg builder to
|
|
168
|
+
* the on-chain router whitelist. The two MUST agree or `swapAndDeposit` reverts
|
|
169
|
+
* with `InvalidRouter()` (router not whitelisted) or `InvalidNotWhitelisted()`
|
|
170
|
+
* (selector not authorized). It is consumed in three places:
|
|
171
|
+
*
|
|
172
|
+
* - `dispatchViaSwapRouter` asks {@link fetchSwapQuote} to pin the aggregator to
|
|
173
|
+
* `contractMethod`, then asserts the returned quote's `router` and payload
|
|
174
|
+
* selector match this entry before broadcasting — failing closed rather than
|
|
175
|
+
* letting the user pay gas for a transaction the contract will reject.
|
|
176
|
+
* - The CI check `scripts/verify-swap-router-aggregator.mjs` asserts the
|
|
177
|
+
* deployed `SwapRouter` actually has `tokenTransferProxies[router] != 0` and
|
|
178
|
+
* `isAuthorizedSelector(router, selector) == true` for every entry here, so
|
|
179
|
+
* config drift is caught at release time, not by a user's failed deposit.
|
|
180
|
+
*
|
|
181
|
+
* Pinning to one generic method matters: the aggregator otherwise picks a route
|
|
182
|
+
* method per quote (e.g. a direct `swapExactAmountInOnUniswapV3`) that varies
|
|
183
|
+
* with market conditions, producing a different selector each time. Pinning
|
|
184
|
+
* collapses that to one stable selector so the on-chain whitelist needs only
|
|
185
|
+
* that selector and never drifts as routing changes.
|
|
186
|
+
*
|
|
187
|
+
* `router` is the address the aggregator's calldata targets (ParaSwap v6.2
|
|
188
|
+
* pulls tokens to the Augustus contract itself, so the SwapRouter's
|
|
189
|
+
* `tokenTransferProxies[router]` is the router address). `selector` is
|
|
190
|
+
* `bytes4(keccak256("<contractMethod>(...)"))`. Verify both against the
|
|
191
|
+
* deployed router before adding a chain — a wrong value reverts at deposit time.
|
|
192
|
+
*/
|
|
193
|
+
exports.SWAP_ROUTER_DEX_AGGREGATOR = {
|
|
194
|
+
// ParaSwap AugustusV6.2 (Velora). `swapExactAmountIn` is the generic
|
|
195
|
+
// executor method; its selector is 0xe3ead59e.
|
|
196
|
+
1: {
|
|
197
|
+
router: '0x6A000F20005980200259B80c5102003040001068',
|
|
198
|
+
contractMethod: 'swapExactAmountIn',
|
|
199
|
+
selector: '0xe3ead59e',
|
|
200
|
+
name: 'ParaSwap',
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=swap-router.js.map
|