@augustdigital/sdk 9.5.0 → 9.7.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/README.md +1 -1
- package/lib/adapters/evm/index.d.ts +1 -1
- package/lib/adapters/evm/index.js +29 -29
- package/lib/adapters/solana/types.d.ts +8 -0
- package/lib/adapters/solana/vault.actions.d.ts +6 -1
- package/lib/adapters/solana/vault.actions.js +99 -21
- package/lib/core/analytics/app-name.js +1 -1
- package/lib/core/analytics/constants.d.ts +10 -0
- package/lib/core/analytics/constants.js +17 -1
- package/lib/core/analytics/index.d.ts +7 -4
- package/lib/core/analytics/index.js +8 -4
- package/lib/core/analytics/instrumentation.js +8 -4
- package/lib/core/analytics/method-taxonomy.js +13 -0
- package/lib/core/analytics/metrics.d.ts +25 -10
- package/lib/core/analytics/metrics.js +41 -15
- package/lib/core/analytics/sentry.d.ts +24 -3
- package/lib/core/analytics/sentry.js +49 -18
- package/lib/core/analytics/types.d.ts +11 -4
- package/lib/core/analytics/user-identity.d.ts +19 -5
- package/lib/core/analytics/user-identity.js +35 -21
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/auth/verify.js +7 -3
- package/lib/core/base.class.d.ts +8 -1
- package/lib/core/base.class.js +7 -1
- package/lib/core/constants/core.d.ts +3 -0
- package/lib/core/constants/core.js +3 -0
- package/lib/core/constants/swap-router.d.ts +16 -0
- package/lib/core/constants/swap-router.js +16 -0
- package/lib/core/errors/index.d.ts +36 -1
- package/lib/core/errors/index.js +40 -1
- package/lib/core/fetcher.d.ts +24 -5
- package/lib/core/fetcher.js +43 -7
- package/lib/main.d.ts +6 -0
- package/lib/main.js +6 -0
- package/lib/modules/api/main.d.ts +6 -6
- package/lib/modules/api/main.js +6 -6
- package/lib/modules/sub-accounts/main.d.ts +7 -1
- package/lib/modules/sub-accounts/main.js +7 -1
- package/lib/modules/vaults/getters.d.ts +151 -10
- package/lib/modules/vaults/getters.js +226 -30
- package/lib/modules/vaults/main.d.ts +5 -0
- package/lib/modules/vaults/main.js +5 -0
- package/lib/modules/vaults/write.actions.d.ts +57 -1
- package/lib/modules/vaults/write.actions.js +86 -2
- package/lib/sdk.d.ts +13171 -12810
- package/lib/services/debank/fetcher.js +1 -1
- package/lib/services/subgraph/vaults.d.ts +18 -1
- package/lib/services/subgraph/vaults.js +19 -3
- package/lib/types/vaults.d.ts +5 -0
- package/package.json +2 -2
|
@@ -19,6 +19,7 @@ exports.rwaRedeemAsset = rwaRedeemAsset;
|
|
|
19
19
|
exports.swapAndDeposit = swapAndDeposit;
|
|
20
20
|
exports.depositViaSwapRouter = depositViaSwapRouter;
|
|
21
21
|
exports.depositNativeViaSwapRouter = depositNativeViaSwapRouter;
|
|
22
|
+
exports.isNativeSwapRouterDepositSupported = isNativeSwapRouterDepositSupported;
|
|
22
23
|
exports.swapRouterDeposit = swapRouterDeposit;
|
|
23
24
|
const ethers_1 = require("ethers");
|
|
24
25
|
const abis_1 = require("../../abis");
|
|
@@ -1407,7 +1408,7 @@ async function dispatchViaSwapRouter(args) {
|
|
|
1407
1408
|
const wrappedNative = core_1.SWAP_ROUTER_WRAPPED_NATIVE[args.chainId];
|
|
1408
1409
|
if (!wrappedNative ||
|
|
1409
1410
|
args.underlyingAsset.toLowerCase() !== wrappedNative.toLowerCase()) {
|
|
1410
|
-
throw new core_1.AugustValidationError('INVALID_INPUT', `vaultDeposit (SwapRouter): native deposit is only supported when the vault's reference asset is the chain's wrapped-native token. Vault ${args.target} underlying ${args.underlyingAsset} is not. Wrap to ${wrappedNative ?? 'WETH'} first and call again with depositAsset = the wrapped token.`, {
|
|
1411
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `vaultDeposit (SwapRouter): native deposit is only supported when the vault's reference asset is the chain's wrapped-native token. Vault ${args.target} underlying ${args.underlyingAsset} is not. Wrap to ${wrappedNative ?? 'WETH'} first and call again with depositAsset = the wrapped token. Check isNativeSwapRouterDepositSupported(chainId, vault, options) before offering this path to avoid hitting this error.`, {
|
|
1411
1412
|
context: {
|
|
1412
1413
|
vault: args.target,
|
|
1413
1414
|
underlying: args.underlyingAsset,
|
|
@@ -1694,6 +1695,14 @@ async function depositViaSwapRouter(signer, options) {
|
|
|
1694
1695
|
* before depositing — only valid when the vault's reference asset equals
|
|
1695
1696
|
* the wrapped-native token.
|
|
1696
1697
|
*
|
|
1698
|
+
* **Wrap-only limitation**: the on-chain SwapRouter has no ETH→other-asset
|
|
1699
|
+
* swap leg, so this only ever reaches a WETH-accepting vault (see
|
|
1700
|
+
* {@link SWAP_ROUTER_WRAPPED_NATIVE}). There is no atomic native-ETH deposit
|
|
1701
|
+
* into a non-WETH-reference vault (e.g. a USDC vault) — deposit the wrapped
|
|
1702
|
+
* native token instead (already whitelisted, routes through the swap leg for
|
|
1703
|
+
* a non-reference-asset vault). Use {@link isNativeSwapRouterDepositSupported}
|
|
1704
|
+
* to check eligibility before offering this path in a UI.
|
|
1705
|
+
*
|
|
1697
1706
|
* No ERC-20 approval is needed; `amount` travels as `msg.value`.
|
|
1698
1707
|
*
|
|
1699
1708
|
* @param signer - ethers `Signer` or `Wallet`.
|
|
@@ -1727,6 +1736,78 @@ async function depositNativeViaSwapRouter(signer, options) {
|
|
|
1727
1736
|
core_1.Logger.log.info('depositNativeViaSwapRouter:tx_hash', hash);
|
|
1728
1737
|
return hash;
|
|
1729
1738
|
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Whether a vault can take a native-ETH (chain-native token) SwapRouter
|
|
1741
|
+
* deposit — the pre-flight check for {@link depositNativeViaSwapRouter} and
|
|
1742
|
+
* {@link swapRouterDeposit} with a zero-address `depositAsset`.
|
|
1743
|
+
*
|
|
1744
|
+
* The on-chain SwapRouter only wraps native ETH to the chain's wrapped-native
|
|
1745
|
+
* token and deposits that — it has no ETH→other-asset swap leg (see
|
|
1746
|
+
* {@link SWAP_ROUTER_WRAPPED_NATIVE}). So a native deposit needs all three: a
|
|
1747
|
+
* SwapRouter deployed on `chainId`, the vault registered on that router with
|
|
1748
|
+
* the wrapped-native token as its `vaultInfo(vault).referenceAsset` (a
|
|
1749
|
+
* deposit into an unregistered vault reverts with `InvalidVault`), and the
|
|
1750
|
+
* vault's own on-chain `asset()` equal to that same token. Use this to gate a
|
|
1751
|
+
* "deposit ETH" UI option before the user picks it, instead of discovering
|
|
1752
|
+
* the answer via a thrown {@link AugustValidationError} or an on-chain revert.
|
|
1753
|
+
*
|
|
1754
|
+
* It checks configuration only — a deposit that passes this check can still
|
|
1755
|
+
* fail on balance, gas, a paused vault, or a deposit cap.
|
|
1756
|
+
*
|
|
1757
|
+
* Read-only and provider-agnostic (no signer required) — safe to call before
|
|
1758
|
+
* a wallet is connected. Makes no backend call.
|
|
1759
|
+
*
|
|
1760
|
+
* @param chainId - EVM chain ID the vault is deployed on.
|
|
1761
|
+
* @param vault - August vault address to check.
|
|
1762
|
+
* @param options - `rpcUrl` for `chainId`, passed to `createProvider`.
|
|
1763
|
+
* @returns `true` iff a SwapRouter exists on `chainId`, the vault is
|
|
1764
|
+
* registered on it with the wrapped-native reference asset, and the vault's
|
|
1765
|
+
* `asset()` is that token. `false` — never throws — for a chain with no
|
|
1766
|
+
* SwapRouter deployment, a missing/invalid `rpcUrl`, an unreadable vault or
|
|
1767
|
+
* router, an unregistered vault, or a vault whose reference asset isn't the
|
|
1768
|
+
* wrapped-native token.
|
|
1769
|
+
* @worstCaseRpcCalls 2 — the vault's `asset()` and the router's
|
|
1770
|
+
* `vaultInfo(vault)`, read in parallel. None on a chain with no SwapRouter.
|
|
1771
|
+
* @example
|
|
1772
|
+
* ```ts
|
|
1773
|
+
* const canDepositEth = await isNativeSwapRouterDepositSupported(
|
|
1774
|
+
* 1,
|
|
1775
|
+
* '0x1234000000000000000000000000000000005678',
|
|
1776
|
+
* { rpcUrl: 'https://eth-mainnet.example/v2/KEY' },
|
|
1777
|
+
* );
|
|
1778
|
+
* // true only if that vault is a router-registered WETH vault on mainnet
|
|
1779
|
+
* ```
|
|
1780
|
+
*/
|
|
1781
|
+
async function isNativeSwapRouterDepositSupported(chainId, vault, options) {
|
|
1782
|
+
const wrappedNative = core_1.SWAP_ROUTER_WRAPPED_NATIVE[chainId];
|
|
1783
|
+
const routerAddress = (0, core_1.getSwapRouterAddress)(chainId);
|
|
1784
|
+
if (!wrappedNative || !routerAddress)
|
|
1785
|
+
return false;
|
|
1786
|
+
try {
|
|
1787
|
+
const provider = (0, core_1.createProvider)(options.rpcUrl, chainId);
|
|
1788
|
+
const vaultContract = (0, core_1.createContract)({
|
|
1789
|
+
address: vault,
|
|
1790
|
+
provider,
|
|
1791
|
+
abi: abis_1.ABI_TOKENIZED_VAULT_V2,
|
|
1792
|
+
});
|
|
1793
|
+
const routerContract = (0, core_1.createContract)({
|
|
1794
|
+
address: routerAddress,
|
|
1795
|
+
provider,
|
|
1796
|
+
abi: abis_1.ABI_SWAP_ROUTER,
|
|
1797
|
+
});
|
|
1798
|
+
const [asset, info] = await Promise.all([
|
|
1799
|
+
vaultContract.asset(),
|
|
1800
|
+
routerContract.vaultInfo(vault),
|
|
1801
|
+
]);
|
|
1802
|
+
const wrapped = wrappedNative.toLowerCase();
|
|
1803
|
+
return (asset.toLowerCase() === wrapped &&
|
|
1804
|
+
info?.referenceAsset?.toLowerCase() === wrapped);
|
|
1805
|
+
}
|
|
1806
|
+
catch (error) {
|
|
1807
|
+
core_1.Logger.log.warn('isNativeSwapRouterDepositSupported', 'vault or router read failed — treating as unsupported', { vault, chainId, error });
|
|
1808
|
+
return false;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1730
1811
|
/**
|
|
1731
1812
|
* Deposit into an August vault through the on-chain `SwapRouter`, selecting the
|
|
1732
1813
|
* correct router path from the deposit asset. This is the high-level, explicit
|
|
@@ -1746,7 +1827,10 @@ async function depositNativeViaSwapRouter(signer, options) {
|
|
|
1746
1827
|
* - equals the reference asset → direct router deposit, no swap
|
|
1747
1828
|
* ({@link depositViaSwapRouter});
|
|
1748
1829
|
* - the zero address → native-token deposit ({@link depositNativeViaSwapRouter}),
|
|
1749
|
-
* valid only when the reference asset is the chain's wrapped-native token
|
|
1830
|
+
* valid only when the reference asset is the chain's wrapped-native token —
|
|
1831
|
+
* the router only wraps ETH, it never swaps it, so this throws for any
|
|
1832
|
+
* other reference asset (see {@link SWAP_ROUTER_WRAPPED_NATIVE} for why, and
|
|
1833
|
+
* {@link isNativeSwapRouterDepositSupported} to check first);
|
|
1750
1834
|
* - any other ERC-20 → a swap to the reference asset (Paraswap quote pinned to
|
|
1751
1835
|
* the chain's whitelisted aggregator, fail-closed on router/selector drift)
|
|
1752
1836
|
* bundled into {@link swapAndDeposit}.
|