upshift-sdk 8.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +349 -0
- package/lib/abis/AddressResolver.d.ts +28 -0
- package/lib/abis/AddressResolver.js +23 -0
- package/lib/abis/ChainlinkV3.d.ts +87 -0
- package/lib/abis/ChainlinkV3.js +117 -0
- package/lib/abis/ERC20.d.ts +168 -0
- package/lib/abis/ERC20.js +226 -0
- package/lib/abis/ERC20_Bytes32.d.ts +139 -0
- package/lib/abis/ERC20_Bytes32.js +196 -0
- package/lib/abis/ERC4626.d.ts +364 -0
- package/lib/abis/ERC4626.js +507 -0
- package/lib/abis/ERC721.d.ts +231 -0
- package/lib/abis/ERC721.js +321 -0
- package/lib/abis/FeeOracle.d.ts +120 -0
- package/lib/abis/FeeOracle.js +162 -0
- package/lib/abis/LendingPool.d.ts +1393 -0
- package/lib/abis/LendingPool.js +1807 -0
- package/lib/abis/LendingPoolV2.d.ts +1413 -0
- package/lib/abis/LendingPoolV2.js +1833 -0
- package/lib/abis/LendingPoolV3.d.ts +1677 -0
- package/lib/abis/LendingPoolV3.js +1160 -0
- package/lib/abis/Loan.d.ts +837 -0
- package/lib/abis/Loan.js +1080 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
- package/lib/abis/Multicall3.d.ts +30 -0
- package/lib/abis/Multicall3.js +97 -0
- package/lib/abis/OFT.d.ts +116 -0
- package/lib/abis/OFT.js +85 -0
- package/lib/abis/PoolAdapter.d.ts +36 -0
- package/lib/abis/PoolAdapter.js +51 -0
- package/lib/abis/RewardDistributor.d.ts +267 -0
- package/lib/abis/RewardDistributor.js +352 -0
- package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
- package/lib/abis/RwaRedeemSubaccount.js +548 -0
- package/lib/abis/SmartAccount.d.ts +17 -0
- package/lib/abis/SmartAccount.js +19 -0
- package/lib/abis/SwapRouter.d.ts +1043 -0
- package/lib/abis/SwapRouter.js +740 -0
- package/lib/abis/TextResolver.d.ts +16 -0
- package/lib/abis/TextResolver.js +16 -0
- package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
- package/lib/abis/TokenizedVaultV2.js +1041 -0
- package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
- package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
- package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
- package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
- package/lib/abis/UniversalResolverResolve.d.ts +69 -0
- package/lib/abis/UniversalResolverResolve.js +35 -0
- package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
- package/lib/abis/UniversalSignatureValidator.js +30 -0
- package/lib/abis/WrapperAdapter.d.ts +71 -0
- package/lib/abis/WrapperAdapter.js +77 -0
- package/lib/abis/index.d.ts +34 -0
- package/lib/abis/index.js +51 -0
- package/lib/adapters/evm/getters.d.ts +19 -0
- package/lib/adapters/evm/getters.js +209 -0
- package/lib/adapters/evm/index.d.ts +353 -0
- package/lib/adapters/evm/index.js +434 -0
- package/lib/adapters/evm/utils.d.ts +8 -0
- package/lib/adapters/evm/utils.js +51 -0
- package/lib/adapters/solana/constants.d.ts +33 -0
- package/lib/adapters/solana/constants.js +52 -0
- package/lib/adapters/solana/getters.d.ts +11 -0
- package/lib/adapters/solana/getters.js +165 -0
- package/lib/adapters/solana/idl/vault-idl.d.ts +272 -0
- package/lib/adapters/solana/idl/vault-idl.js +1084 -0
- package/lib/adapters/solana/index.d.ts +233 -0
- package/lib/adapters/solana/index.js +291 -0
- package/lib/adapters/solana/types.d.ts +67 -0
- package/lib/adapters/solana/types.js +3 -0
- package/lib/adapters/solana/utils.d.ts +141 -0
- package/lib/adapters/solana/utils.js +595 -0
- package/lib/adapters/solana/vault.actions.d.ts +57 -0
- package/lib/adapters/solana/vault.actions.js +379 -0
- package/lib/adapters/stellar/actions.d.ts +28 -0
- package/lib/adapters/stellar/actions.js +77 -0
- package/lib/adapters/stellar/constants.d.ts +43 -0
- package/lib/adapters/stellar/constants.js +53 -0
- package/lib/adapters/stellar/getters.d.ts +68 -0
- package/lib/adapters/stellar/getters.js +290 -0
- package/lib/adapters/stellar/index.d.ts +114 -0
- package/lib/adapters/stellar/index.js +175 -0
- package/lib/adapters/stellar/soroban.d.ts +123 -0
- package/lib/adapters/stellar/soroban.js +613 -0
- package/lib/adapters/stellar/submit.d.ts +34 -0
- package/lib/adapters/stellar/submit.js +149 -0
- package/lib/adapters/stellar/types.d.ts +58 -0
- package/lib/adapters/stellar/types.js +6 -0
- package/lib/adapters/stellar/utils.d.ts +24 -0
- package/lib/adapters/stellar/utils.js +34 -0
- package/lib/adapters/sui/constants.d.ts +14 -0
- package/lib/adapters/sui/constants.js +29 -0
- package/lib/adapters/sui/getters.d.ts +9 -0
- package/lib/adapters/sui/getters.js +60 -0
- package/lib/adapters/sui/index.d.ts +45 -0
- package/lib/adapters/sui/index.js +101 -0
- package/lib/adapters/sui/transformer.d.ts +10 -0
- package/lib/adapters/sui/transformer.js +107 -0
- package/lib/adapters/sui/types.d.ts +66 -0
- package/lib/adapters/sui/types.js +3 -0
- package/lib/adapters/sui/utils.d.ts +10 -0
- package/lib/adapters/sui/utils.js +29 -0
- package/lib/core/analytics/chain-name.d.ts +9 -0
- package/lib/core/analytics/chain-name.js +34 -0
- package/lib/core/analytics/constants.d.ts +5 -0
- package/lib/core/analytics/constants.js +9 -0
- package/lib/core/analytics/env.d.ts +29 -0
- package/lib/core/analytics/env.js +59 -0
- package/lib/core/analytics/index.d.ts +36 -0
- package/lib/core/analytics/index.js +79 -0
- package/lib/core/analytics/instrumentation.d.ts +29 -0
- package/lib/core/analytics/instrumentation.js +277 -0
- package/lib/core/analytics/method-taxonomy.d.ts +19 -0
- package/lib/core/analytics/method-taxonomy.js +128 -0
- package/lib/core/analytics/metrics.d.ts +33 -0
- package/lib/core/analytics/metrics.js +116 -0
- package/lib/core/analytics/sanitize.d.ts +44 -0
- package/lib/core/analytics/sanitize.js +260 -0
- package/lib/core/analytics/sentry-runtime.d.ts +15 -0
- package/lib/core/analytics/sentry-runtime.js +97 -0
- package/lib/core/analytics/sentry.d.ts +67 -0
- package/lib/core/analytics/sentry.js +613 -0
- package/lib/core/analytics/types.d.ts +48 -0
- package/lib/core/analytics/types.js +3 -0
- package/lib/core/analytics/user-identity.d.ts +41 -0
- package/lib/core/analytics/user-identity.js +141 -0
- package/lib/core/analytics/version.d.ts +6 -0
- package/lib/core/analytics/version.js +10 -0
- package/lib/core/attribution.d.ts +111 -0
- package/lib/core/attribution.js +142 -0
- package/lib/core/auth/index.d.ts +1 -0
- package/lib/core/auth/index.js +18 -0
- package/lib/core/auth/verify.d.ts +2 -0
- package/lib/core/auth/verify.js +31 -0
- package/lib/core/base.class.d.ts +152 -0
- package/lib/core/base.class.js +172 -0
- package/lib/core/cache.d.ts +9 -0
- package/lib/core/cache.js +31 -0
- package/lib/core/constants/adapters.d.ts +103 -0
- package/lib/core/constants/adapters.js +180 -0
- package/lib/core/constants/core.d.ts +133 -0
- package/lib/core/constants/core.js +209 -0
- package/lib/core/constants/swap-router.d.ts +150 -0
- package/lib/core/constants/swap-router.js +169 -0
- package/lib/core/constants/vaults.d.ts +93 -0
- package/lib/core/constants/vaults.js +273 -0
- package/lib/core/constants/web3.d.ts +91 -0
- package/lib/core/constants/web3.js +229 -0
- package/lib/core/errors/index.d.ts +114 -0
- package/lib/core/errors/index.js +183 -0
- package/lib/core/fetcher.d.ts +198 -0
- package/lib/core/fetcher.js +903 -0
- package/lib/core/helpers/adapters.d.ts +13 -0
- package/lib/core/helpers/adapters.js +39 -0
- package/lib/core/helpers/chain-address.d.ts +13 -0
- package/lib/core/helpers/chain-address.js +47 -0
- package/lib/core/helpers/chain-error.d.ts +207 -0
- package/lib/core/helpers/chain-error.js +682 -0
- package/lib/core/helpers/chain-support.d.ts +80 -0
- package/lib/core/helpers/chain-support.js +115 -0
- package/lib/core/helpers/core.d.ts +68 -0
- package/lib/core/helpers/core.js +285 -0
- package/lib/core/helpers/explorer-link.d.ts +16 -0
- package/lib/core/helpers/explorer-link.js +26 -0
- package/lib/core/helpers/multicall.d.ts +68 -0
- package/lib/core/helpers/multicall.js +103 -0
- package/lib/core/helpers/revert-decode.d.ts +248 -0
- package/lib/core/helpers/revert-decode.js +515 -0
- package/lib/core/helpers/signer.d.ts +52 -0
- package/lib/core/helpers/signer.js +145 -0
- package/lib/core/helpers/swap-router.d.ts +211 -0
- package/lib/core/helpers/swap-router.js +480 -0
- package/lib/core/helpers/vault-version.d.ts +23 -0
- package/lib/core/helpers/vault-version.js +75 -0
- package/lib/core/helpers/vaults.d.ts +89 -0
- package/lib/core/helpers/vaults.js +235 -0
- package/lib/core/helpers/web3.d.ts +353 -0
- package/lib/core/helpers/web3.js +992 -0
- package/lib/core/index.d.ts +23 -0
- package/lib/core/index.js +40 -0
- package/lib/core/logger/index.d.ts +98 -0
- package/lib/core/logger/index.js +144 -0
- package/lib/core/logger/slack.d.ts +16 -0
- package/lib/core/logger/slack.js +57 -0
- package/lib/core/vault-metadata.d.ts +12 -0
- package/lib/core/vault-metadata.js +42 -0
- package/lib/core/version-check.d.ts +58 -0
- package/lib/core/version-check.js +182 -0
- package/lib/evm/index.d.ts +2 -0
- package/lib/evm/index.js +19 -0
- package/lib/evm/methods/crossChainVault.d.ts +128 -0
- package/lib/evm/methods/crossChainVault.js +853 -0
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
- package/lib/evm/methods/index.d.ts +2 -0
- package/lib/evm/methods/index.js +19 -0
- package/lib/evm/types/crossChain.d.ts +363 -0
- package/lib/evm/types/crossChain.js +20 -0
- package/lib/evm/types/index.d.ts +1 -0
- package/lib/evm/types/index.js +18 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +52 -0
- package/lib/main.d.ts +527 -0
- package/lib/main.js +601 -0
- package/lib/modules/api/fetcher.d.ts +82 -0
- package/lib/modules/api/fetcher.js +150 -0
- package/lib/modules/api/index.d.ts +1 -0
- package/lib/modules/api/index.js +6 -0
- package/lib/modules/api/main.d.ts +313 -0
- package/lib/modules/api/main.js +479 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
- package/lib/modules/sub-accounts/fetcher.js +120 -0
- package/lib/modules/sub-accounts/index.d.ts +2 -0
- package/lib/modules/sub-accounts/index.js +19 -0
- package/lib/modules/sub-accounts/main.d.ts +243 -0
- package/lib/modules/sub-accounts/main.js +205 -0
- package/lib/modules/sub-accounts/utils.d.ts +106 -0
- package/lib/modules/sub-accounts/utils.js +112 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +64 -0
- package/lib/modules/vaults/adapter.helpers.js +184 -0
- package/lib/modules/vaults/fetcher.d.ts +147 -0
- package/lib/modules/vaults/fetcher.js +368 -0
- package/lib/modules/vaults/getters.d.ts +570 -0
- package/lib/modules/vaults/getters.js +3051 -0
- package/lib/modules/vaults/index.d.ts +20 -0
- package/lib/modules/vaults/index.js +44 -0
- package/lib/modules/vaults/main.d.ts +601 -0
- package/lib/modules/vaults/main.js +1623 -0
- package/lib/modules/vaults/prefetch.d.ts +65 -0
- package/lib/modules/vaults/prefetch.js +120 -0
- package/lib/modules/vaults/read.actions.d.ts +225 -0
- package/lib/modules/vaults/read.actions.js +596 -0
- package/lib/modules/vaults/types.d.ts +71 -0
- package/lib/modules/vaults/types.js +3 -0
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
- package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
- package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
- package/lib/modules/vaults/utils/date-utils.js +84 -0
- package/lib/modules/vaults/utils.d.ts +140 -0
- package/lib/modules/vaults/utils.js +799 -0
- package/lib/modules/vaults/write.actions.d.ts +529 -0
- package/lib/modules/vaults/write.actions.js +1749 -0
- package/lib/polyfills.d.ts +1 -0
- package/lib/polyfills.js +12 -0
- package/lib/sdk.d.ts +26721 -0
- package/lib/services/coingecko/fetcher.d.ts +15 -0
- package/lib/services/coingecko/fetcher.js +67 -0
- package/lib/services/coingecko/index.d.ts +2 -0
- package/lib/services/coingecko/index.js +19 -0
- package/lib/services/coingecko/utils.d.ts +1 -0
- package/lib/services/coingecko/utils.js +24 -0
- package/lib/services/debank/fetcher.d.ts +126 -0
- package/lib/services/debank/fetcher.js +47 -0
- package/lib/services/debank/index.d.ts +2 -0
- package/lib/services/debank/index.js +19 -0
- package/lib/services/debank/utils.d.ts +38 -0
- package/lib/services/debank/utils.js +297 -0
- package/lib/services/layerzero/deposits.d.ts +49 -0
- package/lib/services/layerzero/deposits.js +166 -0
- package/lib/services/layerzero/redeems.d.ts +20 -0
- package/lib/services/layerzero/redeems.js +92 -0
- package/lib/services/layerzero/utils.d.ts +9 -0
- package/lib/services/layerzero/utils.js +22 -0
- package/lib/services/octavfi/fetcher.d.ts +9 -0
- package/lib/services/octavfi/fetcher.js +103 -0
- package/lib/services/octavfi/index.d.ts +3 -0
- package/lib/services/octavfi/index.js +20 -0
- package/lib/services/octavfi/types.d.ts +34 -0
- package/lib/services/octavfi/types.js +3 -0
- package/lib/services/octavfi/utils.d.ts +16 -0
- package/lib/services/octavfi/utils.js +212 -0
- package/lib/services/subgraph/fetcher.d.ts +2 -0
- package/lib/services/subgraph/fetcher.js +61 -0
- package/lib/services/subgraph/index.d.ts +2 -0
- package/lib/services/subgraph/index.js +19 -0
- package/lib/services/subgraph/schema.d.ts +45 -0
- package/lib/services/subgraph/schema.js +75 -0
- package/lib/services/subgraph/vaults.d.ts +25 -0
- package/lib/services/subgraph/vaults.js +1106 -0
- package/lib/services/swap-quotes/index.d.ts +105 -0
- package/lib/services/swap-quotes/index.js +77 -0
- package/lib/services/swap-quotes/paraswap.d.ts +51 -0
- package/lib/services/swap-quotes/paraswap.js +138 -0
- package/lib/types/api.d.ts +280 -0
- package/lib/types/api.js +3 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.js +28 -0
- package/lib/types/points.d.ts +28 -0
- package/lib/types/points.js +3 -0
- package/lib/types/pools.d.ts +144 -0
- package/lib/types/pools.js +3 -0
- package/lib/types/staking.d.ts +28 -0
- package/lib/types/staking.js +3 -0
- package/lib/types/sub-accounts.d.ts +140 -0
- package/lib/types/sub-accounts.js +3 -0
- package/lib/types/subgraph.d.ts +74 -0
- package/lib/types/subgraph.js +3 -0
- package/lib/types/typed-contract.d.ts +102 -0
- package/lib/types/typed-contract.js +3 -0
- package/lib/types/user.d.ts +1 -0
- package/lib/types/user.js +3 -0
- package/lib/types/vaults.d.ts +714 -0
- package/lib/types/vaults.js +24 -0
- package/lib/types/web3.d.ts +51 -0
- package/lib/types/web3.js +14 -0
- package/lib/types/webserver.d.ts +698 -0
- package/lib/types/webserver.js +3 -0
- package/package.json +78 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* August Digital
|
|
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
|
+
* Request timeout in milliseconds.
|
|
37
|
+
* Set to 90 seconds to accommodate slow API responses.
|
|
38
|
+
*/
|
|
39
|
+
exports.REQUEST_TIMEOUT_MS = 90000;
|
|
40
|
+
exports.PRICE_SERVER_URL = 'https://prices.augustdigital.io';
|
|
41
|
+
exports.WEBSERVER_URL = {
|
|
42
|
+
production: 'https://backend.fractalprotocol.org',
|
|
43
|
+
staging: 'https://backend.staging.fractalprotocol.org',
|
|
44
|
+
development: 'https://backend-dev.augustdigital.io',
|
|
45
|
+
localhost: 'http://127.0.0.1:8000',
|
|
46
|
+
qa: 'https://backend-qa.augustdigital.io',
|
|
47
|
+
public: 'https://api.augustdigital.io/api/v1',
|
|
48
|
+
upshift: 'https://app.upshift.finance',
|
|
49
|
+
};
|
|
50
|
+
exports.WEBSERVER_ENDPOINTS = {
|
|
51
|
+
default: {
|
|
52
|
+
hello: '/hello',
|
|
53
|
+
protected: '/protected',
|
|
54
|
+
},
|
|
55
|
+
auth: {
|
|
56
|
+
verify: '/auth/secret',
|
|
57
|
+
sign: '/auth/sign',
|
|
58
|
+
login: '/auth/login',
|
|
59
|
+
nonce: '/auth/nonce',
|
|
60
|
+
refresh: '/auth/refresh',
|
|
61
|
+
},
|
|
62
|
+
subaccount: {
|
|
63
|
+
list: (offset = 0, limit = 100) => `/subaccount?offset=${offset}&limit=${limit}`,
|
|
64
|
+
rewards: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/rewards`,
|
|
65
|
+
tokens: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/tokens`,
|
|
66
|
+
twap: {
|
|
67
|
+
create: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/twap`,
|
|
68
|
+
stop: (subaccount, id) => `/subaccount/${subaccountSegment(subaccount)}/twap/${id}/stop`,
|
|
69
|
+
fills: (subaccount, id) => `/subaccount/${subaccountSegment(subaccount)}/twap/${id}/fills`,
|
|
70
|
+
},
|
|
71
|
+
debank: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/debank`,
|
|
72
|
+
health_factor: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/health_factor`,
|
|
73
|
+
summary: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/summary`,
|
|
74
|
+
batch: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/tx_batcher_integrations`,
|
|
75
|
+
loans: (subaccount, side = 'BOTH', active = true) => `/subaccount/${subaccountSegment(subaccount)}/loans?side=${side}&active=${active}`,
|
|
76
|
+
cefi: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/cefi_position`,
|
|
77
|
+
otc_positions: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}/otc_positions`,
|
|
78
|
+
loanByAddress: (loanAddress, chainId) => `/subaccount/loans/${encodeURIComponent(loanAddress)}?chain_id=${chainId}`,
|
|
79
|
+
_: (subaccount) => `/subaccount/${subaccountSegment(subaccount)}`,
|
|
80
|
+
},
|
|
81
|
+
transactions: {
|
|
82
|
+
v2: (subaccount, startTime, endTime) => {
|
|
83
|
+
const params = new URLSearchParams({ address: subaccount });
|
|
84
|
+
if (startTime !== undefined)
|
|
85
|
+
params.set('start_time', startTime);
|
|
86
|
+
if (endTime !== undefined)
|
|
87
|
+
params.set('end_time', endTime);
|
|
88
|
+
return `/transactions/v2?${params.toString()}`;
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
otc: {
|
|
92
|
+
positions: '/otc/position',
|
|
93
|
+
marginRequirements: (otcCounterpartyId, payer) => {
|
|
94
|
+
const params = new URLSearchParams();
|
|
95
|
+
if (otcCounterpartyId !== undefined)
|
|
96
|
+
params.set('otc_counter_party_id', otcCounterpartyId);
|
|
97
|
+
if (payer !== undefined)
|
|
98
|
+
params.set('payer', payer);
|
|
99
|
+
const query = params.toString();
|
|
100
|
+
return `/otc/margin_requirement${query ? `?${query}` : ''}`;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
curator: {
|
|
104
|
+
vaultSubaccounts: (vaultAddress) => `/curator/vaults/${encodeURIComponent(vaultAddress)}/subaccounts`,
|
|
105
|
+
vaultWhitelist: (vaultAddress) => `/curator/vaults/${encodeURIComponent(vaultAddress)}/whitelist`,
|
|
106
|
+
},
|
|
107
|
+
timelockRequests: (vaultAddress, chainId, status) => {
|
|
108
|
+
const params = new URLSearchParams({
|
|
109
|
+
vaultAddress,
|
|
110
|
+
chainId: String(chainId),
|
|
111
|
+
});
|
|
112
|
+
if (status !== undefined)
|
|
113
|
+
params.set('status', status);
|
|
114
|
+
return `/timelock-requests?${params.toString()}`;
|
|
115
|
+
},
|
|
116
|
+
users: {
|
|
117
|
+
get: '/users',
|
|
118
|
+
},
|
|
119
|
+
dashboard: {
|
|
120
|
+
loans: '/dashboard/loans',
|
|
121
|
+
},
|
|
122
|
+
risk: {
|
|
123
|
+
discountFactors: '/risk/discount_factors',
|
|
124
|
+
collateralExcessOrDeficit: (subaccount, tokenAddress, tokenChain, targetHealthFactor) => {
|
|
125
|
+
const params = new URLSearchParams({
|
|
126
|
+
address: subaccount,
|
|
127
|
+
token_address: tokenAddress,
|
|
128
|
+
token_chain: String(tokenChain),
|
|
129
|
+
});
|
|
130
|
+
if (targetHealthFactor !== undefined)
|
|
131
|
+
params.set('target_health_factor', String(targetHealthFactor));
|
|
132
|
+
return `/risk/collateral_excess_or_deficit?${params.toString()}`;
|
|
133
|
+
},
|
|
134
|
+
collateralSimulation: '/risk/collateral_simulation',
|
|
135
|
+
},
|
|
136
|
+
prices: (symbol) => `/prices/${symbol}`,
|
|
137
|
+
metrics: {
|
|
138
|
+
pnl: (subaccount, startTime, endTime) => `/metrics/pnl?subaccount_address=${subaccountSegment(subaccount)}${startTime && endTime ? `&start=${startTime}&end=${endTime}` : ''}`,
|
|
139
|
+
vaultPerformanceFees: (params) => {
|
|
140
|
+
const q = new URLSearchParams({
|
|
141
|
+
vault_address: params.vaultAddress,
|
|
142
|
+
annualized_fees_pct: String(params.annualizedFeesPct),
|
|
143
|
+
native_denominated: String(params.nativeDenominated),
|
|
144
|
+
calculation_period: params.calculationPeriod,
|
|
145
|
+
});
|
|
146
|
+
if (params.startDate !== undefined)
|
|
147
|
+
q.set('start_date', params.startDate);
|
|
148
|
+
if (params.endDate !== undefined)
|
|
149
|
+
q.set('end_date', params.endDate);
|
|
150
|
+
return `/metrics/vault_performance_fees?${q.toString()}`;
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
public: {
|
|
154
|
+
integrations: {
|
|
155
|
+
morpho: {
|
|
156
|
+
apy: (subaccount, vaultAddress) => `/integrations/morpho/apy?subaccount_address=${subaccountSegment(subaccount)}&vault_address=${(0, ethers_1.getAddress)(vaultAddress)}`,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
tokenizedVault: {
|
|
160
|
+
loans: (vaultAddress, chainId, active) => `/upshift/lending_pool/loanbook?address=${vaultAddress}&chain=${chainId}&active=${active}`,
|
|
161
|
+
subaccountLoans: (vaultAddress, chainId, active) => `/upshift/lending_pool/subaccounts_loanbook?address=${vaultAddress}&chain=${chainId}&active=${active}`,
|
|
162
|
+
list: '/tokenized_vault',
|
|
163
|
+
byVaultAddress: (vaultAddress) => `/tokenized_vault/${vaultAddress}`,
|
|
164
|
+
historicalApy: (vaultAddress) => `/upshift/historical_apy/chart?vault_address=${vaultAddress}`,
|
|
165
|
+
historicalTimeseries: (vaultAddress, nDays) => `/tokenized_vault/${vaultAddress}/historical-timeseries${nDays ? `?n_days=${nDays}` : ''}`,
|
|
166
|
+
annualizedApy: (vaultAddress) => `/tokenized_vault/annualized_apy/${(0, ethers_1.getAddress)(vaultAddress)}`,
|
|
167
|
+
summary: (vaultAddress) => `/tokenized_vault/vault_summary/${(0, ethers_1.getAddress)(vaultAddress)}`,
|
|
168
|
+
withdrawals: (chain, vaultAddress) => `/withdrawals/${chain}/${(0, ethers_1.getAddress)(vaultAddress)}`,
|
|
169
|
+
debank: (vaultAddress) => `/tokenized_vault/${(0, ethers_1.getAddress)(vaultAddress)}/debank`,
|
|
170
|
+
// Mongo-backed deposit/withdraw history for archived vaults whose
|
|
171
|
+
// subgraph has been (or will be) retired. See fetchArchivedVaults.
|
|
172
|
+
userHistory: (vaultAddress, wallet) => `/upshift/vault_history/${(0, ethers_1.getAddress)(vaultAddress)}?wallet=${(0, ethers_1.getAddress)(wallet)}`,
|
|
173
|
+
// Vaults whose history is served from the snapshot (source of truth for
|
|
174
|
+
// routing — a vault appears only after its backfill completes).
|
|
175
|
+
archivedVaults: '/upshift/vault_history/archived',
|
|
176
|
+
},
|
|
177
|
+
points: {
|
|
178
|
+
byUserAddress: (userAddress) => `/upshift/points/${(0, ethers_1.getAddress)(userAddress)}`,
|
|
179
|
+
register: '/upshift/points/register',
|
|
180
|
+
leaderboard: '/upshift/points/leaderboard',
|
|
181
|
+
},
|
|
182
|
+
vaults: {
|
|
183
|
+
pendingRedemptions: (vaultAddress) => `/vaults/${vaultAddress}/pending-redemptions`,
|
|
184
|
+
},
|
|
185
|
+
pnl: {
|
|
186
|
+
unrealizedHistory: (vaultAddress, limit) => `/upshift/unrealized_pnl?vault_address=${vaultAddress}${limit !== undefined ? `&limit=${limit}` : ''}`,
|
|
187
|
+
unrealizedLatest: '/upshift/unrealized_pnl/latest',
|
|
188
|
+
},
|
|
189
|
+
revertReason: (txHash, chain) => `/revert_reason?${new URLSearchParams({
|
|
190
|
+
tx_hash: txHash,
|
|
191
|
+
chain: String(chain),
|
|
192
|
+
}).toString()}`,
|
|
193
|
+
oracleClassification: (vaultAddress, chainId) => `/upshift/oracle_classification/${encodeURIComponent(vaultAddress)}?chain_id=${chainId}`,
|
|
194
|
+
},
|
|
195
|
+
upshift: {
|
|
196
|
+
vaults: {
|
|
197
|
+
metadata: `/api/sdk/vaults-metadata`,
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
// TODO: add remaining endpoints
|
|
201
|
+
};
|
|
202
|
+
exports.DEFAULT_FETCH_OPTIONS = {
|
|
203
|
+
method: 'GET',
|
|
204
|
+
headers: {
|
|
205
|
+
Accept: 'application/json',
|
|
206
|
+
'Content-Type': 'application/json',
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
* i.e. the SwapRouter is `enableVault`-ed for them on-chain.
|
|
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` is the
|
|
35
|
+
* native/multiasset/adapter path and never routes through the SwapRouter. That
|
|
36
|
+
* separation is what stops a natively-accepted asset from being silently
|
|
37
|
+
* swapped — the regression that implicit auto-routing caused. Any-token swap
|
|
38
|
+
* deposits are the explicit, opt-in job of {@link swapRouterDeposit}.
|
|
39
|
+
*
|
|
40
|
+
* Membership requires the vault to be registered on-chain
|
|
41
|
+
* (`vaultInfo[addr].referenceAsset != 0`) — an unregistered vault reverts with
|
|
42
|
+
* `InvalidVault` at deposit time. A listed vault's natively-accepted assets
|
|
43
|
+
* (for a multi-asset vault, its whole deposit-asset set) still deposit via
|
|
44
|
+
* `vaultDeposit`; only tokens OUTSIDE that set go through `swapRouterDeposit`.
|
|
45
|
+
*
|
|
46
|
+
* Lowercase comparison is required when checking — use
|
|
47
|
+
* {@link isSwapRouterEligible} rather than reading this set directly.
|
|
48
|
+
*
|
|
49
|
+
* @deprecated Superseded by {@link getSwapRouterEligibleVaults}, which derives
|
|
50
|
+
* the eligible set from the router's on-chain `VaultEnabled` history and
|
|
51
|
+
* verifies each vault's current registration (`vaultInfo.referenceAsset != 0`)
|
|
52
|
+
* — so new enablements surface without an SDK release. This static set stays
|
|
53
|
+
* functional as the zero-RPC fallback seed (e.g. TanStack Query `initialData`)
|
|
54
|
+
* and for SDK-internal sync consumers.
|
|
55
|
+
*/
|
|
56
|
+
export declare const SWAP_ROUTER_ELIGIBLE_VAULTS: ReadonlySet<string>;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Renamed to {@link SWAP_ROUTER_ELIGIBLE_VAULTS} (itself now
|
|
59
|
+
* superseded by {@link getSwapRouterEligibleVaults}, the on-chain-derived
|
|
60
|
+
* resolver), and the semantics changed: this set no longer drives
|
|
61
|
+
* `vaultDeposit` auto-routing (that branch was removed) — it only marks vaults
|
|
62
|
+
* whose UI may offer the swap-router deposit surface. Kept as an alias for one
|
|
63
|
+
* release; migrate to the async resolver.
|
|
64
|
+
*/
|
|
65
|
+
export declare const VAULTS_USING_SWAP_ROUTER: ReadonlySet<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Block at which each chain's `SwapRouter` was deployed/configured — the safe
|
|
68
|
+
* lower bound for scanning its `TokenEnabled` / `VaultEnabled` log history.
|
|
69
|
+
*
|
|
70
|
+
* The router stores its allowlist as `mapping(address => bool) whitelistedTokens`
|
|
71
|
+
* with no on-chain enumeration, so {@link getSwapRouterWhitelistedTokens} must
|
|
72
|
+
* reconstruct the candidate set from `TokenEnabled` events before verifying each
|
|
73
|
+
* against the current mapping. Starting the `eth_getLogs` scan here (rather than
|
|
74
|
+
* from genesis) bounds it to the router's own lifetime — a few chunks — instead
|
|
75
|
+
* of the whole chain.
|
|
76
|
+
*
|
|
77
|
+
* Mainnet value is the router's deployment block (its first emitted event, the
|
|
78
|
+
* constructor `OwnershipTransferred`). A too-low value only costs extra empty
|
|
79
|
+
* log ranges; a value ABOVE the first `TokenEnabled` would silently miss tokens,
|
|
80
|
+
* so err on the side of earlier.
|
|
81
|
+
*/
|
|
82
|
+
export declare const SWAP_ROUTER_DEPLOY_BLOCKS: Readonly<Record<number, number>>;
|
|
83
|
+
/**
|
|
84
|
+
* 32-byte origin codes registered on the `SwapRouter` via `addOrigin`.
|
|
85
|
+
* Drives origin/referral-fee accrual. The on-chain admin must register a
|
|
86
|
+
* code before it can be used — calls with an unknown code revert with
|
|
87
|
+
* `InvalidOrigin`.
|
|
88
|
+
*
|
|
89
|
+
* `default` is the all-zero sentinel — the SwapRouter treats it as "no
|
|
90
|
+
* origin fee" and skips the origin-fee transfer.
|
|
91
|
+
*/
|
|
92
|
+
export declare const ORIGIN_CODES: {
|
|
93
|
+
/** All-zero sentinel — no origin fee. */
|
|
94
|
+
readonly default: `0x${string}`;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Maximum number of swap legs the contract accepts in a single
|
|
98
|
+
* `swapAndDeposit` call. Mirrors the on-chain `MAX_SWAPS` constant; reading
|
|
99
|
+
* the on-chain value at call time would add an RPC for no gain.
|
|
100
|
+
*
|
|
101
|
+
* Kept here so the SDK can reject oversize inputs at the boundary rather
|
|
102
|
+
* than wait for the on-chain `TooManySwaps` revert.
|
|
103
|
+
*/
|
|
104
|
+
export declare const SWAP_ROUTER_MAX_SWAPS = 9;
|
|
105
|
+
/**
|
|
106
|
+
* Wrapped-native ERC-20 per chain that has a SwapRouter deployment. Mirrors
|
|
107
|
+
* the on-chain `wrappedNativeTokenAddress()` view to avoid an extra RPC on
|
|
108
|
+
* every dispatch. Used to validate that native-token deposits target a
|
|
109
|
+
* vault whose reference asset is the wrapped native — the only configuration
|
|
110
|
+
* the contract's `depositNativeToken` / `swapAndDepositNativeToken` accept.
|
|
111
|
+
*/
|
|
112
|
+
export declare const SWAP_ROUTER_WRAPPED_NATIVE: Readonly<Record<number, IAddress>>;
|
|
113
|
+
/**
|
|
114
|
+
* The DEX aggregator whitelisted on each chain's `SwapRouter` via
|
|
115
|
+
* `enableRouter`, plus the single aggregator contract method every swap leg is
|
|
116
|
+
* pinned to and that method's 4-byte selector.
|
|
117
|
+
*
|
|
118
|
+
* This is the single source of truth tying the off-chain swap-leg builder to
|
|
119
|
+
* the on-chain router whitelist. The two MUST agree or `swapAndDeposit` reverts
|
|
120
|
+
* with `InvalidRouter()` (router not whitelisted) or `InvalidNotWhitelisted()`
|
|
121
|
+
* (selector not authorized). It is consumed in three places:
|
|
122
|
+
*
|
|
123
|
+
* - `dispatchViaSwapRouter` asks {@link fetchSwapQuote} to pin the aggregator to
|
|
124
|
+
* `contractMethod`, then asserts the returned quote's `router` and payload
|
|
125
|
+
* selector match this entry before broadcasting — failing closed rather than
|
|
126
|
+
* letting the user pay gas for a transaction the contract will reject.
|
|
127
|
+
* - The CI check `scripts/verify-swap-router-aggregator.mjs` asserts the
|
|
128
|
+
* deployed `SwapRouter` actually has `tokenTransferProxies[router] != 0` and
|
|
129
|
+
* `isAuthorizedSelector(router, selector) == true` for every entry here, so
|
|
130
|
+
* config drift is caught at release time, not by a user's failed deposit.
|
|
131
|
+
*
|
|
132
|
+
* Pinning to one generic method matters: the aggregator otherwise picks a route
|
|
133
|
+
* method per quote (e.g. a direct `swapExactAmountInOnUniswapV3`) that varies
|
|
134
|
+
* with market conditions, producing a different selector each time. Pinning
|
|
135
|
+
* collapses that to one stable selector so the on-chain whitelist needs only
|
|
136
|
+
* that selector and never drifts as routing changes.
|
|
137
|
+
*
|
|
138
|
+
* `router` is the address the aggregator's calldata targets (ParaSwap v6.2
|
|
139
|
+
* pulls tokens to the Augustus contract itself, so the SwapRouter's
|
|
140
|
+
* `tokenTransferProxies[router]` is the router address). `selector` is
|
|
141
|
+
* `bytes4(keccak256("<contractMethod>(...)"))`. Verify both against the
|
|
142
|
+
* deployed router before adding a chain — a wrong value reverts at deposit time.
|
|
143
|
+
*/
|
|
144
|
+
export declare const SWAP_ROUTER_DEX_AGGREGATOR: Readonly<Record<number, {
|
|
145
|
+
router: IAddress;
|
|
146
|
+
contractMethod: string;
|
|
147
|
+
selector: `0x${string}`;
|
|
148
|
+
/** Human-readable aggregator name — for display; never derive routing logic from it. */
|
|
149
|
+
name: string;
|
|
150
|
+
}>>;
|
|
@@ -0,0 +1,169 @@
|
|
|
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_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: '0xAC771209FF2b71EECfF6E85a9AD01db8Ff2618B0',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Human-readable display name of the `SwapRouter` periphery contract on each
|
|
17
|
+
* supported chain.
|
|
18
|
+
*
|
|
19
|
+
* The contract exposes no on-chain name (no `@title` accessor), so UIs that
|
|
20
|
+
* want to show *which contract* performed the swap-and-deposit — rather than a
|
|
21
|
+
* bare address — read it from here. Display metadata only: never derive
|
|
22
|
+
* routing or eligibility logic from it.
|
|
23
|
+
*
|
|
24
|
+
* Missing keys mean no SwapRouter is deployed on that chain.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link getSwapRouterName} for the typed lookup helper.
|
|
27
|
+
*/
|
|
28
|
+
exports.SWAP_ROUTER_NAMES = {
|
|
29
|
+
1: 'Upshift Swap Router',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Vaults whose UI **may offer the any-token SwapRouter deposit surface** —
|
|
33
|
+
* i.e. the SwapRouter is `enableVault`-ed for them on-chain.
|
|
34
|
+
*
|
|
35
|
+
* This is *eligibility metadata only*. It is consumed by:
|
|
36
|
+
* - the app UI, to decide whether to render the (flag-gated) swap-router
|
|
37
|
+
* deposit surface for a vault; and
|
|
38
|
+
* - {@link swapRouterDeposit}, optionally, as a fail-fast eligibility check.
|
|
39
|
+
*
|
|
40
|
+
* It is deliberately **NOT** read by {@link vaultDeposit}: `vaultDeposit` is the
|
|
41
|
+
* native/multiasset/adapter path and never routes through the SwapRouter. That
|
|
42
|
+
* separation is what stops a natively-accepted asset from being silently
|
|
43
|
+
* swapped — the regression that implicit auto-routing caused. Any-token swap
|
|
44
|
+
* deposits are the explicit, opt-in job of {@link swapRouterDeposit}.
|
|
45
|
+
*
|
|
46
|
+
* Membership requires the vault to be registered on-chain
|
|
47
|
+
* (`vaultInfo[addr].referenceAsset != 0`) — an unregistered vault reverts with
|
|
48
|
+
* `InvalidVault` at deposit time. A listed vault's natively-accepted assets
|
|
49
|
+
* (for a multi-asset vault, its whole deposit-asset set) still deposit via
|
|
50
|
+
* `vaultDeposit`; only tokens OUTSIDE that set go through `swapRouterDeposit`.
|
|
51
|
+
*
|
|
52
|
+
* Lowercase comparison is required when checking — use
|
|
53
|
+
* {@link isSwapRouterEligible} rather than reading this set directly.
|
|
54
|
+
*
|
|
55
|
+
* @deprecated Superseded by {@link getSwapRouterEligibleVaults}, which derives
|
|
56
|
+
* the eligible set from the router's on-chain `VaultEnabled` history and
|
|
57
|
+
* verifies each vault's current registration (`vaultInfo.referenceAsset != 0`)
|
|
58
|
+
* — so new enablements surface without an SDK 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 on-chain-derived
|
|
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` / `VaultEnabled` 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
|
+
* Mainnet 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: 25237804,
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* 32-byte origin codes registered on the `SwapRouter` via `addOrigin`.
|
|
98
|
+
* Drives origin/referral-fee accrual. The on-chain admin must register a
|
|
99
|
+
* code before it can be used — calls with an unknown code revert with
|
|
100
|
+
* `InvalidOrigin`.
|
|
101
|
+
*
|
|
102
|
+
* `default` is the all-zero sentinel — the SwapRouter treats it as "no
|
|
103
|
+
* origin fee" and skips the origin-fee transfer.
|
|
104
|
+
*/
|
|
105
|
+
exports.ORIGIN_CODES = {
|
|
106
|
+
/** All-zero sentinel — no origin fee. */
|
|
107
|
+
default: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Maximum number of swap legs the contract accepts in a single
|
|
111
|
+
* `swapAndDeposit` call. Mirrors the on-chain `MAX_SWAPS` constant; reading
|
|
112
|
+
* the on-chain value at call time would add an RPC for no gain.
|
|
113
|
+
*
|
|
114
|
+
* Kept here so the SDK can reject oversize inputs at the boundary rather
|
|
115
|
+
* than wait for the on-chain `TooManySwaps` revert.
|
|
116
|
+
*/
|
|
117
|
+
exports.SWAP_ROUTER_MAX_SWAPS = 9;
|
|
118
|
+
/**
|
|
119
|
+
* Wrapped-native ERC-20 per chain that has a SwapRouter deployment. Mirrors
|
|
120
|
+
* the on-chain `wrappedNativeTokenAddress()` view to avoid an extra RPC on
|
|
121
|
+
* every dispatch. Used to validate that native-token deposits target a
|
|
122
|
+
* vault whose reference asset is the wrapped native — the only configuration
|
|
123
|
+
* the contract's `depositNativeToken` / `swapAndDepositNativeToken` accept.
|
|
124
|
+
*/
|
|
125
|
+
exports.SWAP_ROUTER_WRAPPED_NATIVE = {
|
|
126
|
+
1: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* The DEX aggregator whitelisted on each chain's `SwapRouter` via
|
|
130
|
+
* `enableRouter`, plus the single aggregator contract method every swap leg is
|
|
131
|
+
* pinned to and that method's 4-byte selector.
|
|
132
|
+
*
|
|
133
|
+
* This is the single source of truth tying the off-chain swap-leg builder to
|
|
134
|
+
* the on-chain router whitelist. The two MUST agree or `swapAndDeposit` reverts
|
|
135
|
+
* with `InvalidRouter()` (router not whitelisted) or `InvalidNotWhitelisted()`
|
|
136
|
+
* (selector not authorized). It is consumed in three places:
|
|
137
|
+
*
|
|
138
|
+
* - `dispatchViaSwapRouter` asks {@link fetchSwapQuote} to pin the aggregator to
|
|
139
|
+
* `contractMethod`, then asserts the returned quote's `router` and payload
|
|
140
|
+
* selector match this entry before broadcasting — failing closed rather than
|
|
141
|
+
* letting the user pay gas for a transaction the contract will reject.
|
|
142
|
+
* - The CI check `scripts/verify-swap-router-aggregator.mjs` asserts the
|
|
143
|
+
* deployed `SwapRouter` actually has `tokenTransferProxies[router] != 0` and
|
|
144
|
+
* `isAuthorizedSelector(router, selector) == true` for every entry here, so
|
|
145
|
+
* config drift is caught at release time, not by a user's failed deposit.
|
|
146
|
+
*
|
|
147
|
+
* Pinning to one generic method matters: the aggregator otherwise picks a route
|
|
148
|
+
* method per quote (e.g. a direct `swapExactAmountInOnUniswapV3`) that varies
|
|
149
|
+
* with market conditions, producing a different selector each time. Pinning
|
|
150
|
+
* collapses that to one stable selector so the on-chain whitelist needs only
|
|
151
|
+
* that selector and never drifts as routing changes.
|
|
152
|
+
*
|
|
153
|
+
* `router` is the address the aggregator's calldata targets (ParaSwap v6.2
|
|
154
|
+
* pulls tokens to the Augustus contract itself, so the SwapRouter's
|
|
155
|
+
* `tokenTransferProxies[router]` is the router address). `selector` is
|
|
156
|
+
* `bytes4(keccak256("<contractMethod>(...)"))`. Verify both against the
|
|
157
|
+
* deployed router before adding a chain — a wrong value reverts at deposit time.
|
|
158
|
+
*/
|
|
159
|
+
exports.SWAP_ROUTER_DEX_AGGREGATOR = {
|
|
160
|
+
// ParaSwap AugustusV6.2 (Velora). `swapExactAmountIn` is the generic
|
|
161
|
+
// executor method; its selector is 0xe3ead59e.
|
|
162
|
+
1: {
|
|
163
|
+
router: '0x6A000F20005980200259B80c5102003040001068',
|
|
164
|
+
contractMethod: 'swapExactAmountIn',
|
|
165
|
+
selector: '0xe3ead59e',
|
|
166
|
+
name: 'ParaSwap',
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=swap-router.js.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { IAddress, IPoolFunctions } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Table of Contents
|
|
4
|
+
* - Hardcoded Addresses
|
|
5
|
+
* - Vault Functions to Call
|
|
6
|
+
* - Subgraph URLs
|
|
7
|
+
* - Vault Receipt Symbol Mapping
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Hardcoded subaccount addresses for specific vaults allocations
|
|
11
|
+
*/
|
|
12
|
+
export declare const VAULT_ALLOCATION_SUBACCOUNTS: {
|
|
13
|
+
AgoraAUSD: {
|
|
14
|
+
address: IAddress;
|
|
15
|
+
subaccount: IAddress;
|
|
16
|
+
useDebank: boolean;
|
|
17
|
+
};
|
|
18
|
+
earnAUSD: {
|
|
19
|
+
address: IAddress;
|
|
20
|
+
subaccount: IAddress;
|
|
21
|
+
useDebank: boolean;
|
|
22
|
+
};
|
|
23
|
+
MonarqXRP: {
|
|
24
|
+
address: IAddress;
|
|
25
|
+
subaccount: IAddress;
|
|
26
|
+
useDebank: boolean;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated use the backend responses /tokenized_vault internal_type field to determine if the vault is an old lending pool
|
|
31
|
+
* @todo use the backend responses /tokenized_vault internal_type field to determine if the vault is an old lending pool
|
|
32
|
+
*/
|
|
33
|
+
export declare const MULTI_ASSET_VAULTS: `0x${string}`[];
|
|
34
|
+
export declare const WRAPPER_ADAPTOR: {
|
|
35
|
+
43114: IAddress;
|
|
36
|
+
1: IAddress;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated use the backend responses /tokenized_vault internal_type field to determine if the vault is an old lending pool
|
|
40
|
+
* @todo use the backend responses /tokenized_vault internal_type field to determine if the vault is an old lending pool
|
|
41
|
+
*/
|
|
42
|
+
export declare const OLD_LENDING_POOLS: `0x${string}`[];
|
|
43
|
+
export declare const IDLE_CAPITAL_BORROWER_ADDRESS: `0x${string}`[];
|
|
44
|
+
/**
|
|
45
|
+
* Vault addresses to exclude from `getTotalDeposited` TVL aggregation.
|
|
46
|
+
* Addresses are lowercased so EVM, Solana, Sui and Stellar vaults can be
|
|
47
|
+
* checked uniformly (don't wrap them with `getAddress` — non-EVM addresses
|
|
48
|
+
* would throw). Add an address here to drop its `latest_reported_tvl` from
|
|
49
|
+
* the headline number — e.g. closed pre-deposit vaults, test vaults, or
|
|
50
|
+
* migrated v1 pools that are double-counted by a v2 successor.
|
|
51
|
+
*/
|
|
52
|
+
export declare const TVL_EXCLUDED_VAULTS: ReadonlySet<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Vault Functions to Call
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* The functions to call on the vault contract
|
|
58
|
+
* @returns The functions to call
|
|
59
|
+
*/
|
|
60
|
+
export declare const VAULT_FUNCTIONS_V1: IPoolFunctions[];
|
|
61
|
+
export declare const VAULT_FUNCTIONS_V2: IPoolFunctions[];
|
|
62
|
+
export declare const VAULT_FUNCTIONS_V2_RECEIPT: IPoolFunctions[];
|
|
63
|
+
export declare const VAULT_FUNCTIONS_V2_WHITELISTED_ASSETS: IPoolFunctions[];
|
|
64
|
+
/**
|
|
65
|
+
* NEMO ETH Yield vault address (lowercase for comparisons)
|
|
66
|
+
*/
|
|
67
|
+
export declare const NEMO_VAULT_ADDRESS = "0xa422c3018c46ba90a14acd14f96cb60616f5c91b";
|
|
68
|
+
/**
|
|
69
|
+
* Subgraph base URL
|
|
70
|
+
* @deprecated use getVaultMetadata to fetch subgraph URLs from the backend
|
|
71
|
+
*/
|
|
72
|
+
export declare const GOLDSKY_BASE_URL = "https://api.goldsky.com/api/private/project_cm9g0xy3o4j6v01vd34r3hvv9/subgraphs";
|
|
73
|
+
/**
|
|
74
|
+
* Subgraph URLs
|
|
75
|
+
* @deprecated use getVaultMetadata to fetch subgraph URLs from the backend
|
|
76
|
+
*/
|
|
77
|
+
export declare const SUBGRAPH_VAULT_URLS: Record<VaultSymbols, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Vault Receipt Symbol Mapping
|
|
80
|
+
* @deprecated use getVaultMetadata to fetch vault symbols from the backend
|
|
81
|
+
*/
|
|
82
|
+
type VaultSymbols = 'predlp' | 'sentusd' | 'pregrid' | 'repouscc' | 'earnxrp' | 'tivkbtc' | 'tivusdt0' | 'supermon' | 'earnmon' | 'k3europ' | 'wmon/ausd' | 'wbtc/ausd' | 'earnausd_monad' | 'sausd' | 'farmbold' | 'sentuscc' | 'sentbtc' | 'svusdc' | 'apusdc' | 'testwethtsa' | 'tacusr' | 'upinjusdt' | 'tac-teth' | 'upausd' | 'taccbbtc' | 'xupusdc' | 'uptbtc' | 'gteth' | 'ageth' | 'upusdc' | 'hgeth' | 'upssylva' | 'hbbtc' | 'hbhype' | 'upazt' | 'susdt' | 'upedge' | 'coreusdc' | 'upcusdo' | 'shifteth' | 'upsusde' | 'uplbtc' | 'upavax' | 'tacrseth' | 'musd' | 'earnausd' | 'alpineusdcflagship' | 'alpinecoinshiftusdc' | 'upbtc' | 'upstrbtc' | 'maxiusr' | 'upgammausdc' | 'xhype' | 'wildusd' | 'alpinebtc' | 'prenusd' | 'upyzusd' | 'upnusd' | 'hlpe' | 'nemo eth yield';
|
|
83
|
+
/**
|
|
84
|
+
* Vault Symbols Mapping
|
|
85
|
+
* @deprecated use getVaultMetadata to fetch vault symbols from the backend
|
|
86
|
+
*/
|
|
87
|
+
export declare const VAULT_SYMBOLS: Record<IAddress, string>;
|
|
88
|
+
/**
|
|
89
|
+
* Vault Symbols Reverse Mapping
|
|
90
|
+
* @deprecated use getVaultMetadata to fetch vault symbols from the backend
|
|
91
|
+
*/
|
|
92
|
+
export declare const VAULT_SYMBOLS_REVERSE: Record<VaultSymbols, IAddress>;
|
|
93
|
+
export {};
|