augustdigital-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,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isViemWalletClient = isViemWalletClient;
|
|
4
|
+
exports.viemToEthersSigner = viemToEthersSigner;
|
|
5
|
+
exports.normalizeSigner = normalizeSigner;
|
|
6
|
+
exports.wrapSignerWithAttribution = wrapSignerWithAttribution;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const attribution_1 = require("../attribution");
|
|
9
|
+
/**
|
|
10
|
+
* Signer Compatibility Helpers
|
|
11
|
+
*
|
|
12
|
+
* Utilities for supporting both ethers and viem/wagmi signers.
|
|
13
|
+
* Provides conversion layer from viem WalletClient to ethers Signer.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a signer is from viem/wagmi
|
|
17
|
+
* @param signer The signer to check
|
|
18
|
+
* @returns True if the signer is a viem WalletClient
|
|
19
|
+
*/
|
|
20
|
+
function isViemWalletClient(signer) {
|
|
21
|
+
// Viem WalletClient has specific properties that ethers Signer doesn't
|
|
22
|
+
return !!(signer &&
|
|
23
|
+
typeof signer === 'object' &&
|
|
24
|
+
'account' in signer &&
|
|
25
|
+
'chain' in signer &&
|
|
26
|
+
'transport' in signer &&
|
|
27
|
+
typeof signer.writeContract === 'function');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Convert a viem WalletClient to an ethers-compatible Signer
|
|
31
|
+
* Uses the walletClient as a provider and wraps it for ethers compatibility
|
|
32
|
+
* @param walletClient Viem WalletClient from wagmi or viem
|
|
33
|
+
* @returns Ethers Signer that can be used with the SDK
|
|
34
|
+
*/
|
|
35
|
+
async function viemToEthersSigner(walletClient) {
|
|
36
|
+
if (!walletClient) {
|
|
37
|
+
throw new Error('WalletClient is required');
|
|
38
|
+
}
|
|
39
|
+
// Create an EIP-1193 provider from the wallet client
|
|
40
|
+
const { account, chain, transport } = walletClient;
|
|
41
|
+
if (!account) {
|
|
42
|
+
throw new Error('WalletClient must have an account');
|
|
43
|
+
}
|
|
44
|
+
// Create a custom transport that uses the walletClient
|
|
45
|
+
const provider = new ethers_1.BrowserProvider({
|
|
46
|
+
request: async ({ method, params }) => {
|
|
47
|
+
// Use the wallet client's transport for all requests
|
|
48
|
+
if (method === 'eth_sendTransaction') {
|
|
49
|
+
// For transactions, use writeContract or sendTransaction
|
|
50
|
+
const [tx] = params;
|
|
51
|
+
return walletClient.sendTransaction({
|
|
52
|
+
...tx,
|
|
53
|
+
account,
|
|
54
|
+
chain,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// For all other requests, use the transport directly
|
|
58
|
+
return transport({ chain }).request({ method, params });
|
|
59
|
+
},
|
|
60
|
+
}, chain?.id);
|
|
61
|
+
// Get the signer from the provider
|
|
62
|
+
return provider.getSigner(account.address);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Type guard to check if a signer is from ethers
|
|
66
|
+
* @param signer The signer to check
|
|
67
|
+
* @returns True if the signer is an ethers Signer or Wallet
|
|
68
|
+
*/
|
|
69
|
+
function isEthersSigner(signer) {
|
|
70
|
+
// Check for ethers Signer/Wallet properties
|
|
71
|
+
return (signer &&
|
|
72
|
+
typeof signer === 'object' &&
|
|
73
|
+
typeof signer.signMessage === 'function' &&
|
|
74
|
+
typeof signer.signTransaction === 'function' &&
|
|
75
|
+
(signer.provider !== undefined || signer._isSigner === true));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Normalize a signer to ensure it's ethers-compatible
|
|
79
|
+
* Accepts both ethers Signer and viem WalletClient
|
|
80
|
+
* @param signer Either an ethers Signer or viem WalletClient
|
|
81
|
+
* @returns Ethers-compatible Signer
|
|
82
|
+
*/
|
|
83
|
+
async function normalizeSigner(signer) {
|
|
84
|
+
// If it's already an ethers signer, return as-is
|
|
85
|
+
if (isEthersSigner(signer)) {
|
|
86
|
+
return signer;
|
|
87
|
+
}
|
|
88
|
+
// If it's a viem wallet client, convert it
|
|
89
|
+
if (isViemWalletClient(signer)) {
|
|
90
|
+
return viemToEthersSigner(signer);
|
|
91
|
+
}
|
|
92
|
+
// If we can't determine the type, throw an error
|
|
93
|
+
throw new Error('Invalid signer type. Expected ethers Signer, ethers Wallet, or viem WalletClient');
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Wrap an ethers signer so every transaction it sends carries the active
|
|
97
|
+
* ERC-8021 attribution suffix (Base Builder Codes).
|
|
98
|
+
*
|
|
99
|
+
* Every ethers write in the SDK funnels through the wrapped signer's
|
|
100
|
+
* `sendTransaction`, so this single wrap attributes all vault writes. The
|
|
101
|
+
* wrapper is a Proxy — the caller's signer object is never mutated, so a
|
|
102
|
+
* signer reused outside the SDK sends unattributed transactions. Attribution
|
|
103
|
+
* state is read at send time, not wrap time; when no attribution is
|
|
104
|
+
* configured (see `IAugustBase.attribution`) the wrapper is a pass-through.
|
|
105
|
+
*
|
|
106
|
+
* Plain value transfers (no calldata) are never attributed, and calldata
|
|
107
|
+
* already ending in the ERC-8021 marker is left untouched. When the
|
|
108
|
+
* configured `chains` list requires a chain check and the transaction does
|
|
109
|
+
* not carry a `chainId`, the signer's provider network is consulted (one
|
|
110
|
+
* cached RPC call).
|
|
111
|
+
*
|
|
112
|
+
* @param signer Normalized ethers Signer or Wallet.
|
|
113
|
+
* @returns A proxied signer with an attribution-aware `sendTransaction`.
|
|
114
|
+
*/
|
|
115
|
+
function wrapSignerWithAttribution(signer) {
|
|
116
|
+
return new Proxy(signer, {
|
|
117
|
+
get(target, prop) {
|
|
118
|
+
if (prop === 'sendTransaction') {
|
|
119
|
+
return async (tx) => {
|
|
120
|
+
if (!(0, attribution_1.getAttributionSuffix)() || typeof tx?.data !== 'string') {
|
|
121
|
+
return target.sendTransaction(tx);
|
|
122
|
+
}
|
|
123
|
+
let chainId = tx.chainId != null ? Number(tx.chainId) : undefined;
|
|
124
|
+
if (chainId === undefined && target.provider) {
|
|
125
|
+
try {
|
|
126
|
+
chainId = Number((await target.provider.getNetwork()).chainId);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Unknown chain: fall through with chainId undefined, which
|
|
130
|
+
// appends regardless of a `chains` restriction —
|
|
131
|
+
// over-attribution is harmless, under-attribution loses data.
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const data = (0, attribution_1.appendAttributionSuffix)(tx.data, chainId);
|
|
135
|
+
return target.sendTransaction(data === tx.data ? tx : { ...tx, data });
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
// `this`-bind reads to the target, not the proxy — ethers classes use
|
|
139
|
+
// private fields, which throw when methods run with a Proxy receiver.
|
|
140
|
+
const value = Reflect.get(target, prop, target);
|
|
141
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=signer.js.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { type Signer, type Wallet } from 'ethers';
|
|
2
|
+
import type { IAddress, ISwapRouterDepositResult, ISwapRouterDepositResultOptions } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the `SwapRouter` address for a chain.
|
|
5
|
+
*
|
|
6
|
+
* @param chainId - EVM chain ID.
|
|
7
|
+
* @returns The router address, or `undefined` if no SwapRouter is deployed.
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const router = getSwapRouterAddress(1);
|
|
11
|
+
* // '0xAC771209FF2b71EECfF6E85a9AD01db8Ff2618B0'
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function getSwapRouterAddress(chainId: number): IAddress | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the human-readable display name of the `SwapRouter` periphery
|
|
17
|
+
* contract for a chain.
|
|
18
|
+
*
|
|
19
|
+
* The contract exposes no name on-chain, so this reads the SDK-maintained
|
|
20
|
+
* {@link SWAP_ROUTER_NAMES} registry. Intended for UI surfaces that label the
|
|
21
|
+
* contract a swap-and-deposit routes through (e.g. a "Router" row in a
|
|
22
|
+
* transaction overview) — display metadata only, never routing logic.
|
|
23
|
+
*
|
|
24
|
+
* @param chainId - EVM chain ID.
|
|
25
|
+
* @returns The display name (e.g. `'Upshift Swap Router'`), or `undefined`
|
|
26
|
+
* when no SwapRouter is deployed on the chain — callers should omit the
|
|
27
|
+
* label rather than show an address.
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const name = getSwapRouterName(1);
|
|
31
|
+
* // 'Upshift Swap Router'
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function getSwapRouterName(chainId: number): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Whether a vault is eligible for the any-token `SwapRouter` deposit surface
|
|
37
|
+
* (the SwapRouter is `enableVault`-ed for it on-chain). Address comparison is
|
|
38
|
+
* case-insensitive.
|
|
39
|
+
*
|
|
40
|
+
* This gates the (flag-controlled) swap-router deposit UI and can fail-fast a
|
|
41
|
+
* {@link swapRouterDeposit} call. It does **not** affect {@link vaultDeposit},
|
|
42
|
+
* which is always the native/multiasset/adapter path.
|
|
43
|
+
*
|
|
44
|
+
* @param vaultAddress - August vault address.
|
|
45
|
+
* @returns `true` when the vault is in {@link SWAP_ROUTER_ELIGIBLE_VAULTS}.
|
|
46
|
+
* @deprecated Superseded by {@link getSwapRouterEligibleVaults}, which resolves
|
|
47
|
+
* eligibility from the router's on-chain `VaultEnabled` history + current
|
|
48
|
+
* `vaultInfo` registration instead of this static snapshot. Kept functional as
|
|
49
|
+
* the zero-RPC sync fallback (seed data, fail-fast checks); migrate UI gates
|
|
50
|
+
* to the async resolver.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isSwapRouterEligible(vaultAddress: IAddress): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Renamed to {@link isSwapRouterEligible} (itself now superseded by
|
|
55
|
+
* {@link getSwapRouterEligibleVaults}, the on-chain-derived resolver). The
|
|
56
|
+
* meaning also changed: it no longer implies `vaultDeposit` routes the vault
|
|
57
|
+
* through the SwapRouter (that behavior was removed) — it only reports
|
|
58
|
+
* swap-router *eligibility* for the opt-in deposit surface. Kept as an alias
|
|
59
|
+
* for one release; migrate to the async resolver.
|
|
60
|
+
*/
|
|
61
|
+
export declare const vaultUsesSwapRouter: typeof isSwapRouterEligible;
|
|
62
|
+
/**
|
|
63
|
+
* Normalize an optional origin code to the value to send on-chain.
|
|
64
|
+
*
|
|
65
|
+
* Returns the caller-supplied code when present, otherwise the default
|
|
66
|
+
* (all-zero) sentinel from {@link ORIGIN_CODES}. Validates that any
|
|
67
|
+
* supplied code is exactly 32 bytes (66 chars including the `0x` prefix);
|
|
68
|
+
* the on-chain SwapRouter reverts with `InvalidOrigin` otherwise, but
|
|
69
|
+
* surfacing the failure here as a typed SDK error gives partners a
|
|
70
|
+
* grepable Sentry event instead of a generic `execution reverted`.
|
|
71
|
+
*
|
|
72
|
+
* @param provided - Optional caller-supplied origin code.
|
|
73
|
+
* @returns The 32-byte origin code to pass to the router.
|
|
74
|
+
* @throws {@link AugustValidationError} when `provided` is not a 32-byte hex string.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolveOriginCode(provided?: `0x${string}`): `0x${string}`;
|
|
77
|
+
/**
|
|
78
|
+
* Resolves the real, post-execution outcome of a SwapRouter deposit from its
|
|
79
|
+
* mined transaction receipt. The SwapRouter contract itself emits no
|
|
80
|
+
* deposit/amount-out event — only the vault does, via its own `Deposit` event
|
|
81
|
+
* — so this decodes that log directly rather than trusting the pre-trade quote
|
|
82
|
+
* a UI shows before the user submits (the true post-swap amount depends on
|
|
83
|
+
* execution-time price and can differ from that estimate).
|
|
84
|
+
*
|
|
85
|
+
* Works for both vault generations without the caller resolving the version
|
|
86
|
+
* first: evm-1 (ERC-4626-style `Deposit(sender, owner, assets, shares)`) and
|
|
87
|
+
* evm-2 (`Deposit(assetIn, amountIn, shares, senderAddr, receiverAddr)`) have
|
|
88
|
+
* different event signatures (different topic0), so both are registered and
|
|
89
|
+
* whichever matches the vault's actual log is decoded.
|
|
90
|
+
*
|
|
91
|
+
* @param signer - ethers `Signer` or `Wallet` connected to a provider (used
|
|
92
|
+
* read-only here — no transaction is sent).
|
|
93
|
+
* @param options - {@link ISwapRouterDepositResultOptions}.
|
|
94
|
+
* @returns The decoded {@link ISwapRouterDepositResult}, or `null` if the
|
|
95
|
+
* receipt isn't found yet or carries no `Deposit` log from `vault` (e.g. the
|
|
96
|
+
* hash is wrong, or the tx hasn't mined).
|
|
97
|
+
* @throws {@link AugustValidationError} if `signer` has no connected provider.
|
|
98
|
+
* @worstCaseRpcCalls 1 — a single `getTransactionReceipt` call; decoding is
|
|
99
|
+
* local.
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const hash = await augustSdk.evm.swapRouterDeposit({ ... });
|
|
103
|
+
* const result = await augustSdk.evm.getSwapRouterDepositResult({
|
|
104
|
+
* txHash: hash,
|
|
105
|
+
* vault: '0x74ad2f789ed583dbd141bbdafc673fe1f033718b',
|
|
106
|
+
* });
|
|
107
|
+
* // result?.amountOut — actual reference-asset amount received after the swap
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function getSwapRouterDepositResult(signer: Signer | Wallet, { txHash, vault }: ISwapRouterDepositResultOptions): Promise<ISwapRouterDepositResult | null>;
|
|
111
|
+
/**
|
|
112
|
+
* Resolve the ERC-20 tokens currently whitelisted for the `SwapRouter` on a
|
|
113
|
+
* chain — the any-token set a UI can offer as swap-and-deposit inputs.
|
|
114
|
+
*
|
|
115
|
+
* The router exposes its allowlist only as `mapping(address => bool)
|
|
116
|
+
* whitelistedTokens` with **no on-chain enumeration**, so this cannot be a
|
|
117
|
+
* single view call. It runs in two stages:
|
|
118
|
+
* 1. Scan the router's `TokenEnabled(address)` event history (from the chain's
|
|
119
|
+
* {@link SWAP_ROUTER_DEPLOY_BLOCKS} floor, in `eth_getLogs` chunks sized by
|
|
120
|
+
* {@link determineBlockSkipInternal}) to reconstruct the candidate set of
|
|
121
|
+
* every token ever enabled.
|
|
122
|
+
* 2. Re-read `whitelistedTokens(token)` for each candidate — batched via
|
|
123
|
+
* Multicall3 where verified, else per-call — and keep only those the
|
|
124
|
+
* mapping currently returns `true` for. This step makes later disables (and
|
|
125
|
+
* disable-then-re-enable) correct without replaying `TokenDisabled`, and is
|
|
126
|
+
* the fail-closed source of truth: a token surfaces only on a definite
|
|
127
|
+
* on-chain `true`.
|
|
128
|
+
*
|
|
129
|
+
* The resolved list is cached per chain for 5 minutes — the allowlist changes
|
|
130
|
+
* only via an admin `enableToken`/`disableToken` transaction, so a short TTL
|
|
131
|
+
* keeps the (multi-RPC) scan off the hot path without going stale for long.
|
|
132
|
+
*
|
|
133
|
+
* @param chainId - EVM chain ID. Chains without a {@link SWAP_ROUTER_ADDRESSES}
|
|
134
|
+
* entry resolve to `[]` with no RPC.
|
|
135
|
+
* @param options - `rpcUrl` (required) must point at `chainId`'s network;
|
|
136
|
+
* `fromBlock` overrides the default deploy-block scan floor (e.g. to widen a
|
|
137
|
+
* scan on a chain missing from {@link SWAP_ROUTER_DEPLOY_BLOCKS}).
|
|
138
|
+
* @returns Checksummed addresses of the currently-whitelisted tokens, deduped.
|
|
139
|
+
* Empty when no router is deployed or none are enabled. Callers still filter
|
|
140
|
+
* out a given vault's natively-accepted assets (those deposit without a swap).
|
|
141
|
+
* @throws AugustValidationError when `rpcUrl` is missing/empty.
|
|
142
|
+
* @throws AugustSDKError when an `eth_getLogs` chunk fails — surfaced (not
|
|
143
|
+
* swallowed) so a partial scan never masquerades as a complete allowlist.
|
|
144
|
+
* @worstCaseRpcCalls On mainnet, 1 `eth_blockNumber` + ~4 `eth_getLogs` chunks
|
|
145
|
+
* (router-lifetime ÷ 50k-block window) + 1 Multicall3 `eth_call` ≈ 6; scales
|
|
146
|
+
* with the router's on-chain age, not with candidate count.
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* const tokens = await getSwapRouterWhitelistedTokens(1, {
|
|
150
|
+
* rpcUrl: 'https://eth-mainnet.example/v2/KEY',
|
|
151
|
+
* });
|
|
152
|
+
* // ['0xA0b8…', '0xdAC1…', '0xC02a…', '0x2260…'] (USDC, USDT, WETH, WBTC)
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function getSwapRouterWhitelistedTokens(chainId: number, options: {
|
|
156
|
+
rpcUrl: string;
|
|
157
|
+
fromBlock?: number;
|
|
158
|
+
}): Promise<IAddress[]>;
|
|
159
|
+
/**
|
|
160
|
+
* Resolve the vaults currently eligible for the any-token `SwapRouter` deposit
|
|
161
|
+
* surface on a chain — i.e. every vault the router has `enableVault`-ed that is
|
|
162
|
+
* still registered on-chain.
|
|
163
|
+
*
|
|
164
|
+
* The router stores registrations as `mapping(address => VaultInfo) vaultInfo`
|
|
165
|
+
* with **no on-chain enumeration**, so (exactly like
|
|
166
|
+
* {@link getSwapRouterWhitelistedTokens}) this runs in two stages:
|
|
167
|
+
* 1. Scan the router's `VaultEnabled(address)` event history (from the chain's
|
|
168
|
+
* {@link SWAP_ROUTER_DEPLOY_BLOCKS} floor, in `eth_getLogs` chunks sized by
|
|
169
|
+
* {@link determineBlockSkipInternal}) to reconstruct the candidate set of
|
|
170
|
+
* every vault ever enabled.
|
|
171
|
+
* 2. Re-read `vaultInfo(vault)` for each candidate — batched via Multicall3
|
|
172
|
+
* where verified, else per-call — and keep only those whose
|
|
173
|
+
* `referenceAsset != address(0)` (an unregistered vault reverts with
|
|
174
|
+
* `InvalidVault` at deposit time). This makes later disables correct
|
|
175
|
+
* without replaying `VaultDisabled`, and is the fail-closed source of
|
|
176
|
+
* truth: a vault surfaces only on a definite on-chain registration.
|
|
177
|
+
*
|
|
178
|
+
* This is the dynamic successor to the static
|
|
179
|
+
* {@link SWAP_ROUTER_ELIGIBLE_VAULTS} snapshot / {@link isSwapRouterEligible}.
|
|
180
|
+
* It reports **on-chain eligibility only** — app-level policy (e.g. excluding
|
|
181
|
+
* OVault-enabled vaults that have their own deposit flow) remains the caller's
|
|
182
|
+
* responsibility, as does the flag gating of the UI surface.
|
|
183
|
+
*
|
|
184
|
+
* The resolved list is cached per chain for 5 minutes — registrations change
|
|
185
|
+
* only via an admin `enableVault`/`disableVault` transaction, so a short TTL
|
|
186
|
+
* keeps the (multi-RPC) scan off the hot path without going stale for long.
|
|
187
|
+
*
|
|
188
|
+
* @param chainId - EVM chain ID. Chains without a {@link SWAP_ROUTER_ADDRESSES}
|
|
189
|
+
* entry resolve to `[]` with no RPC.
|
|
190
|
+
* @param options - `rpcUrl` (required) must point at `chainId`'s network;
|
|
191
|
+
* `fromBlock` overrides the default deploy-block scan floor.
|
|
192
|
+
* @returns Checksummed addresses of the currently-registered eligible vaults,
|
|
193
|
+
* deduped. Empty when no router is deployed or none are registered.
|
|
194
|
+
* @throws AugustValidationError when `rpcUrl` is missing/empty.
|
|
195
|
+
* @throws AugustSDKError when an `eth_getLogs` chunk fails — surfaced (not
|
|
196
|
+
* swallowed) so a partial scan never masquerades as the complete set.
|
|
197
|
+
* @worstCaseRpcCalls On mainnet, 1 `eth_blockNumber` + ~4 `eth_getLogs` chunks
|
|
198
|
+
* (router-lifetime ÷ 50k-block window) + 1 Multicall3 `eth_call` ≈ 6; scales
|
|
199
|
+
* with the router's on-chain age, not with candidate count.
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* const vaults = await getSwapRouterEligibleVaults(1, {
|
|
203
|
+
* rpcUrl: 'https://eth-mainnet.example/v2/KEY',
|
|
204
|
+
* });
|
|
205
|
+
* // ['0x74aD…718b', '0xE9B7…9D32'] (Sentora USD, Upshift Core USDC)
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export declare function getSwapRouterEligibleVaults(chainId: number, options: {
|
|
209
|
+
rpcUrl: string;
|
|
210
|
+
fromBlock?: number;
|
|
211
|
+
}): Promise<IAddress[]>;
|