@oydual31/more-vaults-sdk 0.3.1 → 0.3.2
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/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +163 -0
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +128 -1
- package/dist/viem/index.d.ts +128 -1
- package/dist/viem/index.js +160 -1
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/chains.ts +17 -0
- package/src/viem/curatorStatus.ts +66 -2
- package/src/viem/curatorSwaps.ts +239 -0
- package/src/viem/index.ts +8 -1
- package/src/viem/types.ts +16 -0
package/dist/viem/index.d.cts
CHANGED
|
@@ -402,6 +402,16 @@ declare const LZ_TIMEOUTS: {
|
|
|
402
402
|
/** Full spoke→hub→spoke redeem (all steps combined) */
|
|
403
403
|
readonly FULL_SPOKE_REDEEM: 3600000;
|
|
404
404
|
};
|
|
405
|
+
/**
|
|
406
|
+
* Uniswap V3 SwapRouter addresses per chain.
|
|
407
|
+
* Used by curator swap helpers to build calldata for on-chain swaps.
|
|
408
|
+
*
|
|
409
|
+
* Note on struct differences:
|
|
410
|
+
* - SwapRouter (Eth/Arb/Op, 0xE592...): exactInputSingle struct includes `deadline`
|
|
411
|
+
* - SwapRouter02 (Base, 0x2626...): exactInputSingle struct does NOT include `deadline`
|
|
412
|
+
* - FlowSwap V3 (Flow EVM, 0xeEDC...): derived from original UniV3, includes `deadline`
|
|
413
|
+
*/
|
|
414
|
+
declare const UNISWAP_V3_ROUTERS: Record<number, `0x${string}`>;
|
|
405
415
|
/** @deprecated Use OFT_ROUTES.stgUSDC instead */
|
|
406
416
|
declare const USDC_STARGATE_OFT: Partial<Record<number, `0x${string}`>>;
|
|
407
417
|
/** @deprecated Use OFT_ROUTES.stgUSDC[chainId].token instead */
|
|
@@ -1777,6 +1787,20 @@ interface VaultAnalysis {
|
|
|
1777
1787
|
/** Registry address for global protocol whitelist checks */
|
|
1778
1788
|
registryAddress: Address | null;
|
|
1779
1789
|
}
|
|
1790
|
+
interface AssetBalance extends AssetInfo {
|
|
1791
|
+
/** Raw balance held by the vault */
|
|
1792
|
+
balance: bigint;
|
|
1793
|
+
}
|
|
1794
|
+
interface VaultAssetBreakdown {
|
|
1795
|
+
/** Per-asset balances held by the vault on the hub chain */
|
|
1796
|
+
assets: AssetBalance[];
|
|
1797
|
+
/** totalAssets() as reported by the vault (all positions converted to underlying) */
|
|
1798
|
+
totalAssets: bigint;
|
|
1799
|
+
/** totalSupply() of vault shares */
|
|
1800
|
+
totalSupply: bigint;
|
|
1801
|
+
/** Vault underlying token decimals */
|
|
1802
|
+
underlyingDecimals: number;
|
|
1803
|
+
}
|
|
1780
1804
|
|
|
1781
1805
|
/**
|
|
1782
1806
|
* Typed error classes for the MoreVaults SDK.
|
|
@@ -2469,6 +2493,18 @@ declare function getVaultAnalysis(publicClient: PublicClient, vault: Address): P
|
|
|
2469
2493
|
* @returns Record mapping address → whitelisted boolean
|
|
2470
2494
|
*/
|
|
2471
2495
|
declare function checkProtocolWhitelist(publicClient: PublicClient, vault: Address, protocols: Address[]): Promise<Record<string, boolean>>;
|
|
2496
|
+
/**
|
|
2497
|
+
* Get the vault's per-asset balance breakdown on the hub chain.
|
|
2498
|
+
*
|
|
2499
|
+
* Returns the balance of every available asset held by the vault, plus
|
|
2500
|
+
* totalAssets and totalSupply for context. Useful for portfolio views
|
|
2501
|
+
* that need to show individual holdings rather than a single USD-denominated total.
|
|
2502
|
+
*
|
|
2503
|
+
* @param publicClient Viem public client (must be on the vault's hub chain)
|
|
2504
|
+
* @param vault Vault address (diamond proxy)
|
|
2505
|
+
* @returns VaultAssetBreakdown with per-asset balances
|
|
2506
|
+
*/
|
|
2507
|
+
declare function getVaultAssetBreakdown(publicClient: PublicClient, vault: Address): Promise<VaultAssetBreakdown>;
|
|
2472
2508
|
|
|
2473
2509
|
/**
|
|
2474
2510
|
* Curator MulticallFacet write operations for the MoreVaults SDK.
|
|
@@ -2564,6 +2600,97 @@ declare function vetoActions(walletClient: WalletClient, publicClient: PublicCli
|
|
|
2564
2600
|
txHash: `0x${string}`;
|
|
2565
2601
|
}>;
|
|
2566
2602
|
|
|
2603
|
+
/**
|
|
2604
|
+
* Curator swap helpers for Uniswap V3-compatible DEXes.
|
|
2605
|
+
*
|
|
2606
|
+
* Provides typed helpers to build CuratorAction objects and raw calldata for
|
|
2607
|
+
* Uniswap V3 exactInputSingle swaps, automatically resolving the correct router
|
|
2608
|
+
* and ABI variant (SwapRouter vs SwapRouter02) per chain.
|
|
2609
|
+
*
|
|
2610
|
+
* Supported chains and routers:
|
|
2611
|
+
* - Base (8453): SwapRouter02 0x2626... — NO deadline field
|
|
2612
|
+
* - Ethereum (1): SwapRouter 0xE592... — HAS deadline field
|
|
2613
|
+
* - Arbitrum (42161): SwapRouter 0xE592... — HAS deadline field
|
|
2614
|
+
* - Optimism (10): SwapRouter 0xE592... — HAS deadline field
|
|
2615
|
+
* - Flow EVM (747): FlowSwap V3 0xeEDC... — HAS deadline field
|
|
2616
|
+
*
|
|
2617
|
+
* @module curatorSwaps
|
|
2618
|
+
*/
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* Encode Uniswap V3 exactInputSingle calldata directly.
|
|
2622
|
+
* For curators who want raw calldata without the CuratorAction wrapper.
|
|
2623
|
+
*
|
|
2624
|
+
* Automatically selects the correct ABI variant (SwapRouter vs SwapRouter02)
|
|
2625
|
+
* based on the chainId. The deadline (for SwapRouter chains) is set to
|
|
2626
|
+
* `now + 20 minutes` to prevent stale transactions from executing.
|
|
2627
|
+
*
|
|
2628
|
+
* @param params.chainId EVM chain ID — must be present in UNISWAP_V3_ROUTERS
|
|
2629
|
+
* @param params.tokenIn Input token address
|
|
2630
|
+
* @param params.tokenOut Output token address
|
|
2631
|
+
* @param params.fee Pool fee tier: 100, 500, 3000, or 10000
|
|
2632
|
+
* @param params.amountIn Exact input amount (in tokenIn units)
|
|
2633
|
+
* @param params.minAmountOut Minimum acceptable output (slippage protection)
|
|
2634
|
+
* @param params.recipient Address to receive the output tokens (usually the vault)
|
|
2635
|
+
* @returns The router contract address and ABI-encoded calldata
|
|
2636
|
+
* @throws If no router is configured for the given chainId
|
|
2637
|
+
*/
|
|
2638
|
+
declare function encodeUniswapV3SwapCalldata(params: {
|
|
2639
|
+
chainId: number;
|
|
2640
|
+
tokenIn: Address;
|
|
2641
|
+
tokenOut: Address;
|
|
2642
|
+
fee: number;
|
|
2643
|
+
amountIn: bigint;
|
|
2644
|
+
minAmountOut: bigint;
|
|
2645
|
+
recipient: Address;
|
|
2646
|
+
}): {
|
|
2647
|
+
targetContract: Address;
|
|
2648
|
+
swapCallData: `0x${string}`;
|
|
2649
|
+
};
|
|
2650
|
+
/**
|
|
2651
|
+
* Build a CuratorAction for a Uniswap V3 exactInputSingle swap.
|
|
2652
|
+
*
|
|
2653
|
+
* Automatically resolves the router address from UNISWAP_V3_ROUTERS and
|
|
2654
|
+
* selects the correct ABI struct (with or without deadline) based on chainId.
|
|
2655
|
+
*
|
|
2656
|
+
* The returned action is a `swap` variant ready to be passed to
|
|
2657
|
+
* `buildCuratorBatch` and then `submitActions`.
|
|
2658
|
+
*
|
|
2659
|
+
* @param params.chainId EVM chain ID — must be present in UNISWAP_V3_ROUTERS
|
|
2660
|
+
* @param params.tokenIn Input token address
|
|
2661
|
+
* @param params.tokenOut Output token address
|
|
2662
|
+
* @param params.fee Pool fee tier: 100, 500, 3000, or 10000
|
|
2663
|
+
* @param params.amountIn Exact input amount (in tokenIn units)
|
|
2664
|
+
* @param params.minAmountOut Minimum acceptable output (slippage protection)
|
|
2665
|
+
* @param params.recipient Address to receive output tokens (usually the vault)
|
|
2666
|
+
* @returns A typed CuratorAction ready for buildCuratorBatch
|
|
2667
|
+
* @throws If no router is configured for the given chainId
|
|
2668
|
+
*
|
|
2669
|
+
* @example
|
|
2670
|
+
* ```typescript
|
|
2671
|
+
* const action = buildUniswapV3Swap({
|
|
2672
|
+
* chainId: 8453,
|
|
2673
|
+
* tokenIn: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC
|
|
2674
|
+
* tokenOut: '0x4200000000000000000000000000000000000006', // WETH
|
|
2675
|
+
* fee: 500, // 0.05% pool
|
|
2676
|
+
* amountIn: 150_000n, // 0.15 USDC (6 decimals)
|
|
2677
|
+
* minAmountOut: 1n, // accept any amount (set properly in production)
|
|
2678
|
+
* recipient: VAULT,
|
|
2679
|
+
* })
|
|
2680
|
+
* const batch = buildCuratorBatch([action])
|
|
2681
|
+
* await submitActions(walletClient, publicClient, vault, batch)
|
|
2682
|
+
* ```
|
|
2683
|
+
*/
|
|
2684
|
+
declare function buildUniswapV3Swap(params: {
|
|
2685
|
+
chainId: number;
|
|
2686
|
+
tokenIn: Address;
|
|
2687
|
+
tokenOut: Address;
|
|
2688
|
+
fee: number;
|
|
2689
|
+
amountIn: bigint;
|
|
2690
|
+
minAmountOut: bigint;
|
|
2691
|
+
recipient: Address;
|
|
2692
|
+
}): CuratorAction;
|
|
2693
|
+
|
|
2567
2694
|
/**
|
|
2568
2695
|
* Cast a wagmi PublicClient to the SDK's expected type.
|
|
2569
2696
|
* Use this in React components to avoid `as any` casts:
|
|
@@ -2578,4 +2705,4 @@ declare function vetoActions(walletClient: WalletClient, publicClient: PublicCli
|
|
|
2578
2705
|
*/
|
|
2579
2706
|
declare function asSdkClient(client: unknown): PublicClient;
|
|
2580
2707
|
|
|
2581
|
-
export { ActionType, type ActionTypeValue, type AssetInfo, type AsyncRequestResult, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, type ComposeData, type CrossChainRequestInfo, type CuratorAction, type CuratorVaultStatus, DEX_ABI, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, type PendingAction, REGISTRY_ABI, type RedeemResult, STARGATE_TAXI_CMD, type SpokeDepositResult, type SpokeRedeemRoute, type SubmitActionsResult, type SwapParams, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, encodeCuratorAction, executeActions, executeCompose, getCuratorVaultStatus, getPendingActions, getVaultAnalysis, getWithdrawalRequest, isCurator, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, quoteComposeFee, quoteDepositFromSpokeFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForCompose, withdrawAssets };
|
|
2708
|
+
export { ActionType, type ActionTypeValue, type AssetBalance, type AssetInfo, type AsyncRequestResult, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, type ComposeData, type CrossChainRequestInfo, type CuratorAction, type CuratorVaultStatus, DEX_ABI, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, type PendingAction, REGISTRY_ABI, type RedeemResult, STARGATE_TAXI_CMD, type SpokeDepositResult, type SpokeRedeemRoute, type SubmitActionsResult, type SwapParams, UNISWAP_V3_ROUTERS, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, type VaultAssetBreakdown, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, encodeCuratorAction, encodeUniswapV3SwapCalldata, executeActions, executeCompose, getCuratorVaultStatus, getPendingActions, getVaultAnalysis, getVaultAssetBreakdown, getWithdrawalRequest, isCurator, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, quoteComposeFee, quoteDepositFromSpokeFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForCompose, withdrawAssets };
|
package/dist/viem/index.d.ts
CHANGED
|
@@ -402,6 +402,16 @@ declare const LZ_TIMEOUTS: {
|
|
|
402
402
|
/** Full spoke→hub→spoke redeem (all steps combined) */
|
|
403
403
|
readonly FULL_SPOKE_REDEEM: 3600000;
|
|
404
404
|
};
|
|
405
|
+
/**
|
|
406
|
+
* Uniswap V3 SwapRouter addresses per chain.
|
|
407
|
+
* Used by curator swap helpers to build calldata for on-chain swaps.
|
|
408
|
+
*
|
|
409
|
+
* Note on struct differences:
|
|
410
|
+
* - SwapRouter (Eth/Arb/Op, 0xE592...): exactInputSingle struct includes `deadline`
|
|
411
|
+
* - SwapRouter02 (Base, 0x2626...): exactInputSingle struct does NOT include `deadline`
|
|
412
|
+
* - FlowSwap V3 (Flow EVM, 0xeEDC...): derived from original UniV3, includes `deadline`
|
|
413
|
+
*/
|
|
414
|
+
declare const UNISWAP_V3_ROUTERS: Record<number, `0x${string}`>;
|
|
405
415
|
/** @deprecated Use OFT_ROUTES.stgUSDC instead */
|
|
406
416
|
declare const USDC_STARGATE_OFT: Partial<Record<number, `0x${string}`>>;
|
|
407
417
|
/** @deprecated Use OFT_ROUTES.stgUSDC[chainId].token instead */
|
|
@@ -1777,6 +1787,20 @@ interface VaultAnalysis {
|
|
|
1777
1787
|
/** Registry address for global protocol whitelist checks */
|
|
1778
1788
|
registryAddress: Address | null;
|
|
1779
1789
|
}
|
|
1790
|
+
interface AssetBalance extends AssetInfo {
|
|
1791
|
+
/** Raw balance held by the vault */
|
|
1792
|
+
balance: bigint;
|
|
1793
|
+
}
|
|
1794
|
+
interface VaultAssetBreakdown {
|
|
1795
|
+
/** Per-asset balances held by the vault on the hub chain */
|
|
1796
|
+
assets: AssetBalance[];
|
|
1797
|
+
/** totalAssets() as reported by the vault (all positions converted to underlying) */
|
|
1798
|
+
totalAssets: bigint;
|
|
1799
|
+
/** totalSupply() of vault shares */
|
|
1800
|
+
totalSupply: bigint;
|
|
1801
|
+
/** Vault underlying token decimals */
|
|
1802
|
+
underlyingDecimals: number;
|
|
1803
|
+
}
|
|
1780
1804
|
|
|
1781
1805
|
/**
|
|
1782
1806
|
* Typed error classes for the MoreVaults SDK.
|
|
@@ -2469,6 +2493,18 @@ declare function getVaultAnalysis(publicClient: PublicClient, vault: Address): P
|
|
|
2469
2493
|
* @returns Record mapping address → whitelisted boolean
|
|
2470
2494
|
*/
|
|
2471
2495
|
declare function checkProtocolWhitelist(publicClient: PublicClient, vault: Address, protocols: Address[]): Promise<Record<string, boolean>>;
|
|
2496
|
+
/**
|
|
2497
|
+
* Get the vault's per-asset balance breakdown on the hub chain.
|
|
2498
|
+
*
|
|
2499
|
+
* Returns the balance of every available asset held by the vault, plus
|
|
2500
|
+
* totalAssets and totalSupply for context. Useful for portfolio views
|
|
2501
|
+
* that need to show individual holdings rather than a single USD-denominated total.
|
|
2502
|
+
*
|
|
2503
|
+
* @param publicClient Viem public client (must be on the vault's hub chain)
|
|
2504
|
+
* @param vault Vault address (diamond proxy)
|
|
2505
|
+
* @returns VaultAssetBreakdown with per-asset balances
|
|
2506
|
+
*/
|
|
2507
|
+
declare function getVaultAssetBreakdown(publicClient: PublicClient, vault: Address): Promise<VaultAssetBreakdown>;
|
|
2472
2508
|
|
|
2473
2509
|
/**
|
|
2474
2510
|
* Curator MulticallFacet write operations for the MoreVaults SDK.
|
|
@@ -2564,6 +2600,97 @@ declare function vetoActions(walletClient: WalletClient, publicClient: PublicCli
|
|
|
2564
2600
|
txHash: `0x${string}`;
|
|
2565
2601
|
}>;
|
|
2566
2602
|
|
|
2603
|
+
/**
|
|
2604
|
+
* Curator swap helpers for Uniswap V3-compatible DEXes.
|
|
2605
|
+
*
|
|
2606
|
+
* Provides typed helpers to build CuratorAction objects and raw calldata for
|
|
2607
|
+
* Uniswap V3 exactInputSingle swaps, automatically resolving the correct router
|
|
2608
|
+
* and ABI variant (SwapRouter vs SwapRouter02) per chain.
|
|
2609
|
+
*
|
|
2610
|
+
* Supported chains and routers:
|
|
2611
|
+
* - Base (8453): SwapRouter02 0x2626... — NO deadline field
|
|
2612
|
+
* - Ethereum (1): SwapRouter 0xE592... — HAS deadline field
|
|
2613
|
+
* - Arbitrum (42161): SwapRouter 0xE592... — HAS deadline field
|
|
2614
|
+
* - Optimism (10): SwapRouter 0xE592... — HAS deadline field
|
|
2615
|
+
* - Flow EVM (747): FlowSwap V3 0xeEDC... — HAS deadline field
|
|
2616
|
+
*
|
|
2617
|
+
* @module curatorSwaps
|
|
2618
|
+
*/
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* Encode Uniswap V3 exactInputSingle calldata directly.
|
|
2622
|
+
* For curators who want raw calldata without the CuratorAction wrapper.
|
|
2623
|
+
*
|
|
2624
|
+
* Automatically selects the correct ABI variant (SwapRouter vs SwapRouter02)
|
|
2625
|
+
* based on the chainId. The deadline (for SwapRouter chains) is set to
|
|
2626
|
+
* `now + 20 minutes` to prevent stale transactions from executing.
|
|
2627
|
+
*
|
|
2628
|
+
* @param params.chainId EVM chain ID — must be present in UNISWAP_V3_ROUTERS
|
|
2629
|
+
* @param params.tokenIn Input token address
|
|
2630
|
+
* @param params.tokenOut Output token address
|
|
2631
|
+
* @param params.fee Pool fee tier: 100, 500, 3000, or 10000
|
|
2632
|
+
* @param params.amountIn Exact input amount (in tokenIn units)
|
|
2633
|
+
* @param params.minAmountOut Minimum acceptable output (slippage protection)
|
|
2634
|
+
* @param params.recipient Address to receive the output tokens (usually the vault)
|
|
2635
|
+
* @returns The router contract address and ABI-encoded calldata
|
|
2636
|
+
* @throws If no router is configured for the given chainId
|
|
2637
|
+
*/
|
|
2638
|
+
declare function encodeUniswapV3SwapCalldata(params: {
|
|
2639
|
+
chainId: number;
|
|
2640
|
+
tokenIn: Address;
|
|
2641
|
+
tokenOut: Address;
|
|
2642
|
+
fee: number;
|
|
2643
|
+
amountIn: bigint;
|
|
2644
|
+
minAmountOut: bigint;
|
|
2645
|
+
recipient: Address;
|
|
2646
|
+
}): {
|
|
2647
|
+
targetContract: Address;
|
|
2648
|
+
swapCallData: `0x${string}`;
|
|
2649
|
+
};
|
|
2650
|
+
/**
|
|
2651
|
+
* Build a CuratorAction for a Uniswap V3 exactInputSingle swap.
|
|
2652
|
+
*
|
|
2653
|
+
* Automatically resolves the router address from UNISWAP_V3_ROUTERS and
|
|
2654
|
+
* selects the correct ABI struct (with or without deadline) based on chainId.
|
|
2655
|
+
*
|
|
2656
|
+
* The returned action is a `swap` variant ready to be passed to
|
|
2657
|
+
* `buildCuratorBatch` and then `submitActions`.
|
|
2658
|
+
*
|
|
2659
|
+
* @param params.chainId EVM chain ID — must be present in UNISWAP_V3_ROUTERS
|
|
2660
|
+
* @param params.tokenIn Input token address
|
|
2661
|
+
* @param params.tokenOut Output token address
|
|
2662
|
+
* @param params.fee Pool fee tier: 100, 500, 3000, or 10000
|
|
2663
|
+
* @param params.amountIn Exact input amount (in tokenIn units)
|
|
2664
|
+
* @param params.minAmountOut Minimum acceptable output (slippage protection)
|
|
2665
|
+
* @param params.recipient Address to receive output tokens (usually the vault)
|
|
2666
|
+
* @returns A typed CuratorAction ready for buildCuratorBatch
|
|
2667
|
+
* @throws If no router is configured for the given chainId
|
|
2668
|
+
*
|
|
2669
|
+
* @example
|
|
2670
|
+
* ```typescript
|
|
2671
|
+
* const action = buildUniswapV3Swap({
|
|
2672
|
+
* chainId: 8453,
|
|
2673
|
+
* tokenIn: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC
|
|
2674
|
+
* tokenOut: '0x4200000000000000000000000000000000000006', // WETH
|
|
2675
|
+
* fee: 500, // 0.05% pool
|
|
2676
|
+
* amountIn: 150_000n, // 0.15 USDC (6 decimals)
|
|
2677
|
+
* minAmountOut: 1n, // accept any amount (set properly in production)
|
|
2678
|
+
* recipient: VAULT,
|
|
2679
|
+
* })
|
|
2680
|
+
* const batch = buildCuratorBatch([action])
|
|
2681
|
+
* await submitActions(walletClient, publicClient, vault, batch)
|
|
2682
|
+
* ```
|
|
2683
|
+
*/
|
|
2684
|
+
declare function buildUniswapV3Swap(params: {
|
|
2685
|
+
chainId: number;
|
|
2686
|
+
tokenIn: Address;
|
|
2687
|
+
tokenOut: Address;
|
|
2688
|
+
fee: number;
|
|
2689
|
+
amountIn: bigint;
|
|
2690
|
+
minAmountOut: bigint;
|
|
2691
|
+
recipient: Address;
|
|
2692
|
+
}): CuratorAction;
|
|
2693
|
+
|
|
2567
2694
|
/**
|
|
2568
2695
|
* Cast a wagmi PublicClient to the SDK's expected type.
|
|
2569
2696
|
* Use this in React components to avoid `as any` casts:
|
|
@@ -2578,4 +2705,4 @@ declare function vetoActions(walletClient: WalletClient, publicClient: PublicCli
|
|
|
2578
2705
|
*/
|
|
2579
2706
|
declare function asSdkClient(client: unknown): PublicClient;
|
|
2580
2707
|
|
|
2581
|
-
export { ActionType, type ActionTypeValue, type AssetInfo, type AsyncRequestResult, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, type ComposeData, type CrossChainRequestInfo, type CuratorAction, type CuratorVaultStatus, DEX_ABI, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, type PendingAction, REGISTRY_ABI, type RedeemResult, STARGATE_TAXI_CMD, type SpokeDepositResult, type SpokeRedeemRoute, type SubmitActionsResult, type SwapParams, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, encodeCuratorAction, executeActions, executeCompose, getCuratorVaultStatus, getPendingActions, getVaultAnalysis, getWithdrawalRequest, isCurator, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, quoteComposeFee, quoteDepositFromSpokeFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForCompose, withdrawAssets };
|
|
2708
|
+
export { ActionType, type ActionTypeValue, type AssetBalance, type AssetInfo, type AsyncRequestResult, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, type ComposeData, type CrossChainRequestInfo, type CuratorAction, type CuratorVaultStatus, DEX_ABI, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, type PendingAction, REGISTRY_ABI, type RedeemResult, STARGATE_TAXI_CMD, type SpokeDepositResult, type SpokeRedeemRoute, type SubmitActionsResult, type SwapParams, UNISWAP_V3_ROUTERS, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, type VaultAssetBreakdown, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, encodeCuratorAction, encodeUniswapV3SwapCalldata, executeActions, executeCompose, getCuratorVaultStatus, getPendingActions, getVaultAnalysis, getVaultAssetBreakdown, getWithdrawalRequest, isCurator, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, quoteComposeFee, quoteDepositFromSpokeFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForCompose, withdrawAssets };
|
package/dist/viem/index.js
CHANGED
|
@@ -385,6 +385,18 @@ var LZ_TIMEOUTS = {
|
|
|
385
385
|
FULL_SPOKE_REDEEM: 36e5
|
|
386
386
|
// 60 min
|
|
387
387
|
};
|
|
388
|
+
var UNISWAP_V3_ROUTERS = {
|
|
389
|
+
[8453]: "0x2626664c2603336E57B271c5C0b26F421741e481",
|
|
390
|
+
// Base — SwapRouter02 (no deadline)
|
|
391
|
+
[1]: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
|
|
392
|
+
// Ethereum — SwapRouter
|
|
393
|
+
[42161]: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
|
|
394
|
+
// Arbitrum — SwapRouter
|
|
395
|
+
[10]: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
|
|
396
|
+
// Optimism — SwapRouter
|
|
397
|
+
[747]: "0xeEDC6Ff75e1b10B903D9013c358e446a73d35341"
|
|
398
|
+
// Flow EVM — FlowSwap V3 SwapRouter
|
|
399
|
+
};
|
|
388
400
|
var USDC_STARGATE_OFT = Object.fromEntries(
|
|
389
401
|
Object.entries(OFT_ROUTES.stgUSDC).map(([k, v]) => [k, v.oft])
|
|
390
402
|
);
|
|
@@ -3636,6 +3648,45 @@ async function checkProtocolWhitelist(publicClient, vault, protocols) {
|
|
|
3636
3648
|
}
|
|
3637
3649
|
return out;
|
|
3638
3650
|
}
|
|
3651
|
+
async function getVaultAssetBreakdown(publicClient, vault) {
|
|
3652
|
+
const v = getAddress(vault);
|
|
3653
|
+
const availableRaw = await publicClient.readContract({
|
|
3654
|
+
address: v,
|
|
3655
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
3656
|
+
functionName: "getAvailableAssets"
|
|
3657
|
+
});
|
|
3658
|
+
const addresses = availableRaw.map(getAddress);
|
|
3659
|
+
const results = await publicClient.multicall({
|
|
3660
|
+
contracts: [
|
|
3661
|
+
// Per-asset: balanceOf, name, symbol, decimals
|
|
3662
|
+
...addresses.flatMap((addr) => [
|
|
3663
|
+
{ address: addr, abi: ERC20_ABI, functionName: "balanceOf", args: [v] },
|
|
3664
|
+
{ address: addr, abi: METADATA_ABI, functionName: "name" },
|
|
3665
|
+
{ address: addr, abi: METADATA_ABI, functionName: "symbol" },
|
|
3666
|
+
{ address: addr, abi: METADATA_ABI, functionName: "decimals" }
|
|
3667
|
+
]),
|
|
3668
|
+
// Vault totals
|
|
3669
|
+
{ address: v, abi: VAULT_ABI, functionName: "totalAssets" },
|
|
3670
|
+
{ address: v, abi: VAULT_ABI, functionName: "totalSupply" },
|
|
3671
|
+
{ address: v, abi: METADATA_ABI, functionName: "decimals" }
|
|
3672
|
+
],
|
|
3673
|
+
allowFailure: true
|
|
3674
|
+
});
|
|
3675
|
+
const perAssetFields = 4;
|
|
3676
|
+
const assets = addresses.map((addr, i) => {
|
|
3677
|
+
const base = i * perAssetFields;
|
|
3678
|
+
const balance = results[base]?.status === "success" ? results[base].result : 0n;
|
|
3679
|
+
const name = results[base + 1]?.status === "success" ? results[base + 1].result : "";
|
|
3680
|
+
const symbol = results[base + 2]?.status === "success" ? results[base + 2].result : "";
|
|
3681
|
+
const decimals = results[base + 3]?.status === "success" ? results[base + 3].result : 18;
|
|
3682
|
+
return { address: addr, name, symbol, decimals, balance };
|
|
3683
|
+
});
|
|
3684
|
+
const totalsBase = addresses.length * perAssetFields;
|
|
3685
|
+
const totalAssets = results[totalsBase]?.status === "success" ? results[totalsBase].result : 0n;
|
|
3686
|
+
const totalSupply = results[totalsBase + 1]?.status === "success" ? results[totalsBase + 1].result : 0n;
|
|
3687
|
+
const underlyingDecimals = results[totalsBase + 2]?.status === "success" ? results[totalsBase + 2].result : 6;
|
|
3688
|
+
return { assets, totalAssets, totalSupply, underlyingDecimals };
|
|
3689
|
+
}
|
|
3639
3690
|
function encodeCuratorAction(action) {
|
|
3640
3691
|
switch (action.type) {
|
|
3641
3692
|
case "swap":
|
|
@@ -3781,6 +3832,114 @@ async function vetoActions(walletClient, publicClient, vault, nonces) {
|
|
|
3781
3832
|
});
|
|
3782
3833
|
return { txHash };
|
|
3783
3834
|
}
|
|
3835
|
+
var UNISWAP_V3_SWAP_ROUTER_ABI = [
|
|
3836
|
+
{
|
|
3837
|
+
type: "function",
|
|
3838
|
+
name: "exactInputSingle",
|
|
3839
|
+
inputs: [
|
|
3840
|
+
{
|
|
3841
|
+
type: "tuple",
|
|
3842
|
+
name: "params",
|
|
3843
|
+
components: [
|
|
3844
|
+
{ name: "tokenIn", type: "address" },
|
|
3845
|
+
{ name: "tokenOut", type: "address" },
|
|
3846
|
+
{ name: "fee", type: "uint24" },
|
|
3847
|
+
{ name: "recipient", type: "address" },
|
|
3848
|
+
{ name: "deadline", type: "uint256" },
|
|
3849
|
+
{ name: "amountIn", type: "uint256" },
|
|
3850
|
+
{ name: "amountOutMinimum", type: "uint256" },
|
|
3851
|
+
{ name: "sqrtPriceLimitX96", type: "uint160" }
|
|
3852
|
+
]
|
|
3853
|
+
}
|
|
3854
|
+
],
|
|
3855
|
+
outputs: [{ name: "amountOut", type: "uint256" }],
|
|
3856
|
+
stateMutability: "payable"
|
|
3857
|
+
}
|
|
3858
|
+
];
|
|
3859
|
+
var UNISWAP_V3_SWAP_ROUTER02_ABI = [
|
|
3860
|
+
{
|
|
3861
|
+
type: "function",
|
|
3862
|
+
name: "exactInputSingle",
|
|
3863
|
+
inputs: [
|
|
3864
|
+
{
|
|
3865
|
+
type: "tuple",
|
|
3866
|
+
name: "params",
|
|
3867
|
+
components: [
|
|
3868
|
+
{ name: "tokenIn", type: "address" },
|
|
3869
|
+
{ name: "tokenOut", type: "address" },
|
|
3870
|
+
{ name: "fee", type: "uint24" },
|
|
3871
|
+
{ name: "recipient", type: "address" },
|
|
3872
|
+
{ name: "amountIn", type: "uint256" },
|
|
3873
|
+
{ name: "amountOutMinimum", type: "uint256" },
|
|
3874
|
+
{ name: "sqrtPriceLimitX96", type: "uint160" }
|
|
3875
|
+
]
|
|
3876
|
+
}
|
|
3877
|
+
],
|
|
3878
|
+
outputs: [{ name: "amountOut", type: "uint256" }],
|
|
3879
|
+
stateMutability: "payable"
|
|
3880
|
+
}
|
|
3881
|
+
];
|
|
3882
|
+
var SWAP_ROUTER02_CHAINS = /* @__PURE__ */ new Set([8453]);
|
|
3883
|
+
function encodeUniswapV3SwapCalldata(params) {
|
|
3884
|
+
const { chainId, tokenIn, tokenOut, fee, amountIn, minAmountOut, recipient } = params;
|
|
3885
|
+
const router = UNISWAP_V3_ROUTERS[chainId];
|
|
3886
|
+
if (!router) {
|
|
3887
|
+
throw new Error(
|
|
3888
|
+
`[MoreVaults] No Uniswap V3 router configured for chainId ${chainId}. Supported chains: ${Object.keys(UNISWAP_V3_ROUTERS).join(", ")}`
|
|
3889
|
+
);
|
|
3890
|
+
}
|
|
3891
|
+
let swapCallData;
|
|
3892
|
+
if (SWAP_ROUTER02_CHAINS.has(chainId)) {
|
|
3893
|
+
swapCallData = encodeFunctionData({
|
|
3894
|
+
abi: UNISWAP_V3_SWAP_ROUTER02_ABI,
|
|
3895
|
+
functionName: "exactInputSingle",
|
|
3896
|
+
args: [
|
|
3897
|
+
{
|
|
3898
|
+
tokenIn,
|
|
3899
|
+
tokenOut,
|
|
3900
|
+
fee,
|
|
3901
|
+
recipient,
|
|
3902
|
+
amountIn,
|
|
3903
|
+
amountOutMinimum: minAmountOut,
|
|
3904
|
+
sqrtPriceLimitX96: 0n
|
|
3905
|
+
}
|
|
3906
|
+
]
|
|
3907
|
+
});
|
|
3908
|
+
} else {
|
|
3909
|
+
const deadline = BigInt(Math.floor(Date.now() / 1e3) + 1200);
|
|
3910
|
+
swapCallData = encodeFunctionData({
|
|
3911
|
+
abi: UNISWAP_V3_SWAP_ROUTER_ABI,
|
|
3912
|
+
functionName: "exactInputSingle",
|
|
3913
|
+
args: [
|
|
3914
|
+
{
|
|
3915
|
+
tokenIn,
|
|
3916
|
+
tokenOut,
|
|
3917
|
+
fee,
|
|
3918
|
+
recipient,
|
|
3919
|
+
deadline,
|
|
3920
|
+
amountIn,
|
|
3921
|
+
amountOutMinimum: minAmountOut,
|
|
3922
|
+
sqrtPriceLimitX96: 0n
|
|
3923
|
+
}
|
|
3924
|
+
]
|
|
3925
|
+
});
|
|
3926
|
+
}
|
|
3927
|
+
return { targetContract: router, swapCallData };
|
|
3928
|
+
}
|
|
3929
|
+
function buildUniswapV3Swap(params) {
|
|
3930
|
+
const { targetContract, swapCallData } = encodeUniswapV3SwapCalldata(params);
|
|
3931
|
+
return {
|
|
3932
|
+
type: "swap",
|
|
3933
|
+
params: {
|
|
3934
|
+
targetContract,
|
|
3935
|
+
tokenIn: params.tokenIn,
|
|
3936
|
+
tokenOut: params.tokenOut,
|
|
3937
|
+
maxAmountIn: params.amountIn,
|
|
3938
|
+
minAmountOut: params.minAmountOut,
|
|
3939
|
+
swapCallData
|
|
3940
|
+
}
|
|
3941
|
+
};
|
|
3942
|
+
}
|
|
3784
3943
|
|
|
3785
3944
|
// src/viem/wagmiCompat.ts
|
|
3786
3945
|
function asSdkClient(client) {
|
|
@@ -3788,6 +3947,6 @@ function asSdkClient(client) {
|
|
|
3788
3947
|
return client;
|
|
3789
3948
|
}
|
|
3790
3949
|
|
|
3791
|
-
export { ActionType, BRIDGE_ABI, BRIDGE_FACET_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, DEX_ABI, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, REGISTRY_ABI, STARGATE_TAXI_CMD, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, canDeposit, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, discoverVaultTopology, encodeCuratorAction, ensureAllowance, executeActions, executeCompose, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, quoteComposeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForAsyncRequest, waitForCompose, waitForTx, withdrawAssets };
|
|
3950
|
+
export { ActionType, BRIDGE_ABI, BRIDGE_FACET_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, DEX_ABI, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, REGISTRY_ABI, STARGATE_TAXI_CMD, UNISWAP_V3_ROUTERS, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, discoverVaultTopology, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, executeActions, executeCompose, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, quoteComposeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForAsyncRequest, waitForCompose, waitForTx, withdrawAssets };
|
|
3792
3951
|
//# sourceMappingURL=index.js.map
|
|
3793
3952
|
//# sourceMappingURL=index.js.map
|