@oydual31/more-vaults-sdk 0.4.2 → 0.6.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 +94 -0
- package/dist/{spokeRoutes-B8Lnk-t4.d.cts → curatorBridge-CNs59kT9.d.cts} +222 -1
- package/dist/{spokeRoutes-B8Lnk-t4.d.ts → curatorBridge-CNs59kT9.d.ts} +222 -1
- package/dist/ethers/index.cjs +328 -3
- package/dist/ethers/index.cjs.map +1 -1
- package/dist/ethers/index.d.cts +279 -1
- package/dist/ethers/index.d.ts +279 -1
- package/dist/ethers/index.js +318 -5
- package/dist/ethers/index.js.map +1 -1
- package/dist/react/index.cjs +375 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +266 -2
- package/dist/react/index.d.ts +266 -2
- package/dist/react/index.js +372 -2
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +377 -0
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +261 -3
- package/dist/viem/index.d.ts +261 -3
- package/dist/viem/index.js +367 -2
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ethers/abis.ts +24 -0
- package/src/ethers/curatorBridge.ts +235 -0
- package/src/ethers/curatorSubVaults.ts +443 -0
- package/src/ethers/index.ts +26 -0
- package/src/ethers/types.ts +99 -0
- package/src/react/index.ts +14 -0
- package/src/react/useCuratorBridgeQuote.ts +43 -0
- package/src/react/useERC7540RequestStatus.ts +43 -0
- package/src/react/useExecuteBridge.ts +50 -0
- package/src/react/useSubVaultPositions.ts +35 -0
- package/src/react/useVaultPortfolio.ts +35 -0
- package/src/viem/abis.ts +24 -0
- package/src/viem/curatorBridge.ts +288 -0
- package/src/viem/curatorSubVaults.ts +514 -0
- package/src/viem/index.ts +23 -0
- package/src/viem/types.ts +100 -0
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery, useMutation } from '@tanstack/react-query';
|
|
2
2
|
import { usePublicClient, useChainId, useWalletClient } from 'wagmi';
|
|
3
|
-
import { getAddress, zeroAddress, encodeAbiParameters, createPublicClient, http, fallback, encodeFunctionData } from 'viem';
|
|
3
|
+
import { keccak256, toHex, getAddress, zeroAddress, encodeAbiParameters, createPublicClient, http, fallback, encodeFunctionData } from 'viem';
|
|
4
4
|
import { useState, useCallback, useMemo } from 'react';
|
|
5
5
|
|
|
6
6
|
// src/react/useVaultStatus.ts
|
|
@@ -908,6 +908,41 @@ var DEX_ABI = [
|
|
|
908
908
|
stateMutability: "nonpayable"
|
|
909
909
|
}
|
|
910
910
|
];
|
|
911
|
+
var BRIDGE_FACET_ABI = [
|
|
912
|
+
{
|
|
913
|
+
type: "function",
|
|
914
|
+
name: "executeBridging",
|
|
915
|
+
inputs: [
|
|
916
|
+
{ name: "adapter", type: "address" },
|
|
917
|
+
{ name: "token", type: "address" },
|
|
918
|
+
{ name: "amount", type: "uint256" },
|
|
919
|
+
{ name: "bridgeSpecificParams", type: "bytes" }
|
|
920
|
+
],
|
|
921
|
+
outputs: [],
|
|
922
|
+
stateMutability: "payable"
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
type: "function",
|
|
926
|
+
name: "initVaultActionRequest",
|
|
927
|
+
inputs: [
|
|
928
|
+
{ name: "actionType", type: "uint8" },
|
|
929
|
+
{ name: "actionCallData", type: "bytes" },
|
|
930
|
+
{ name: "amountLimit", type: "uint256" },
|
|
931
|
+
{ name: "extraOptions", type: "bytes" }
|
|
932
|
+
],
|
|
933
|
+
outputs: [{ name: "guid", type: "bytes32" }],
|
|
934
|
+
stateMutability: "payable"
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
type: "function",
|
|
938
|
+
name: "executeRequest",
|
|
939
|
+
inputs: [
|
|
940
|
+
{ name: "guid", type: "bytes32" }
|
|
941
|
+
],
|
|
942
|
+
outputs: [],
|
|
943
|
+
stateMutability: "nonpayable"
|
|
944
|
+
}
|
|
945
|
+
];
|
|
911
946
|
var ERC7540_FACET_ABI = [
|
|
912
947
|
{
|
|
913
948
|
type: "function",
|
|
@@ -994,6 +1029,37 @@ var CURATOR_CONFIG_ABI = [
|
|
|
994
1029
|
stateMutability: "view"
|
|
995
1030
|
}
|
|
996
1031
|
];
|
|
1032
|
+
var LZ_ADAPTER_ABI = [
|
|
1033
|
+
{
|
|
1034
|
+
type: "function",
|
|
1035
|
+
name: "quoteBridgeFee",
|
|
1036
|
+
inputs: [
|
|
1037
|
+
{ name: "bridgeSpecificParams", type: "bytes" }
|
|
1038
|
+
],
|
|
1039
|
+
outputs: [{ name: "nativeFee", type: "uint256" }],
|
|
1040
|
+
stateMutability: "view"
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
type: "function",
|
|
1044
|
+
name: "quoteReadFee",
|
|
1045
|
+
inputs: [
|
|
1046
|
+
{ name: "vaults", type: "address[]" },
|
|
1047
|
+
{ name: "eids", type: "uint32[]" },
|
|
1048
|
+
{ name: "_extraOptions", type: "bytes" }
|
|
1049
|
+
],
|
|
1050
|
+
outputs: [
|
|
1051
|
+
{
|
|
1052
|
+
name: "fee",
|
|
1053
|
+
type: "tuple",
|
|
1054
|
+
components: [
|
|
1055
|
+
{ name: "nativeFee", type: "uint256" },
|
|
1056
|
+
{ name: "lzTokenFee", type: "uint256" }
|
|
1057
|
+
]
|
|
1058
|
+
}
|
|
1059
|
+
],
|
|
1060
|
+
stateMutability: "view"
|
|
1061
|
+
}
|
|
1062
|
+
];
|
|
997
1063
|
var ERC4626_FACET_ABI = [
|
|
998
1064
|
{
|
|
999
1065
|
type: "function",
|
|
@@ -1033,6 +1099,23 @@ var REGISTRY_ABI = [
|
|
|
1033
1099
|
{ type: "function", name: "isBridgeAllowed", inputs: [{ name: "bridge", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1034
1100
|
{ type: "function", name: "getAllowedFacets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" }
|
|
1035
1101
|
];
|
|
1102
|
+
var SUB_VAULT_ABI = [
|
|
1103
|
+
// ConfigurationFacet reads — called on the MoreVaults diamond proxy
|
|
1104
|
+
{ type: "function", name: "tokensHeld", inputs: [{ name: "id", type: "bytes32" }], outputs: [{ name: "", type: "address[]" }], stateMutability: "view" },
|
|
1105
|
+
{ type: "function", name: "lockedTokensAmountOfAsset", inputs: [{ name: "asset", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1106
|
+
// ERC4626 standard reads — called on the sub-vault contract
|
|
1107
|
+
{ type: "function", name: "convertToAssets", inputs: [{ name: "shares", type: "uint256" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1108
|
+
{ type: "function", name: "convertToShares", inputs: [{ name: "assets", type: "uint256" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1109
|
+
{ type: "function", name: "previewDeposit", inputs: [{ name: "assets", type: "uint256" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1110
|
+
{ type: "function", name: "previewRedeem", inputs: [{ name: "shares", type: "uint256" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1111
|
+
{ type: "function", name: "maxDeposit", inputs: [{ name: "receiver", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1112
|
+
{ type: "function", name: "maxRedeem", inputs: [{ name: "owner", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1113
|
+
// ERC7540 async reads — called on the sub-vault contract
|
|
1114
|
+
{ type: "function", name: "pendingDepositRequest", inputs: [{ name: "requestId", type: "uint256" }, { name: "controller", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1115
|
+
{ type: "function", name: "claimableDepositRequest", inputs: [{ name: "requestId", type: "uint256" }, { name: "controller", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1116
|
+
{ type: "function", name: "pendingRedeemRequest", inputs: [{ name: "requestId", type: "uint256" }, { name: "controller", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" },
|
|
1117
|
+
{ type: "function", name: "claimableRedeemRequest", inputs: [{ name: "requestId", type: "uint256" }, { name: "controller", type: "address" }], outputs: [{ name: "", type: "uint256" }], stateMutability: "view" }
|
|
1118
|
+
];
|
|
1036
1119
|
|
|
1037
1120
|
// src/viem/types.ts
|
|
1038
1121
|
var ActionType = {
|
|
@@ -2458,6 +2541,237 @@ async function vetoActions(walletClient, publicClient, vault, nonces) {
|
|
|
2458
2541
|
});
|
|
2459
2542
|
return { txHash };
|
|
2460
2543
|
}
|
|
2544
|
+
function encodeBridgeParams(params) {
|
|
2545
|
+
return encodeAbiParameters(
|
|
2546
|
+
[
|
|
2547
|
+
{ type: "address" },
|
|
2548
|
+
{ type: "uint32" },
|
|
2549
|
+
{ type: "uint256" },
|
|
2550
|
+
{ type: "address" },
|
|
2551
|
+
{ type: "address" }
|
|
2552
|
+
],
|
|
2553
|
+
[
|
|
2554
|
+
getAddress(params.oftToken),
|
|
2555
|
+
params.dstEid,
|
|
2556
|
+
params.amount,
|
|
2557
|
+
getAddress(params.dstVault),
|
|
2558
|
+
getAddress(params.refundAddress)
|
|
2559
|
+
]
|
|
2560
|
+
);
|
|
2561
|
+
}
|
|
2562
|
+
function encodeBridgeParamsForQuote(params) {
|
|
2563
|
+
return encodeAbiParameters(
|
|
2564
|
+
[
|
|
2565
|
+
{ type: "address" },
|
|
2566
|
+
{ type: "uint32" },
|
|
2567
|
+
{ type: "uint256" },
|
|
2568
|
+
{ type: "address" }
|
|
2569
|
+
],
|
|
2570
|
+
[
|
|
2571
|
+
getAddress(params.oftToken),
|
|
2572
|
+
params.dstEid,
|
|
2573
|
+
params.amount,
|
|
2574
|
+
getAddress(params.dstVault)
|
|
2575
|
+
]
|
|
2576
|
+
);
|
|
2577
|
+
}
|
|
2578
|
+
async function quoteCuratorBridgeFee(publicClient, vault, params) {
|
|
2579
|
+
const status = await getCuratorVaultStatus(publicClient, vault);
|
|
2580
|
+
const lzAdapter = status.lzAdapter;
|
|
2581
|
+
const bridgeSpecificParams = encodeBridgeParamsForQuote(params);
|
|
2582
|
+
const nativeFee = await publicClient.readContract({
|
|
2583
|
+
address: lzAdapter,
|
|
2584
|
+
abi: LZ_ADAPTER_ABI,
|
|
2585
|
+
functionName: "quoteBridgeFee",
|
|
2586
|
+
args: [bridgeSpecificParams]
|
|
2587
|
+
});
|
|
2588
|
+
return nativeFee;
|
|
2589
|
+
}
|
|
2590
|
+
async function executeCuratorBridge(walletClient, publicClient, vault, token, params) {
|
|
2591
|
+
const account = walletClient.account;
|
|
2592
|
+
const v = getAddress(vault);
|
|
2593
|
+
const status = await getCuratorVaultStatus(publicClient, vault);
|
|
2594
|
+
const lzAdapter = status.lzAdapter;
|
|
2595
|
+
const fee = await quoteCuratorBridgeFee(publicClient, vault, params);
|
|
2596
|
+
const bridgeSpecificParams = encodeBridgeParams(params);
|
|
2597
|
+
const txHash = await walletClient.writeContract({
|
|
2598
|
+
address: v,
|
|
2599
|
+
abi: BRIDGE_FACET_ABI,
|
|
2600
|
+
functionName: "executeBridging",
|
|
2601
|
+
args: [
|
|
2602
|
+
lzAdapter,
|
|
2603
|
+
getAddress(token),
|
|
2604
|
+
params.amount,
|
|
2605
|
+
bridgeSpecificParams
|
|
2606
|
+
],
|
|
2607
|
+
value: fee,
|
|
2608
|
+
account,
|
|
2609
|
+
chain: walletClient.chain
|
|
2610
|
+
});
|
|
2611
|
+
return txHash;
|
|
2612
|
+
}
|
|
2613
|
+
var ERC4626_ID = keccak256(toHex("ERC4626_ID"));
|
|
2614
|
+
var ERC7540_ID = keccak256(toHex("ERC7540_ID"));
|
|
2615
|
+
async function getSubVaultPositions(publicClient, vault) {
|
|
2616
|
+
const v = getAddress(vault);
|
|
2617
|
+
const [erc4626Raw, erc7540Raw] = await Promise.all([
|
|
2618
|
+
publicClient.readContract({
|
|
2619
|
+
address: v,
|
|
2620
|
+
abi: SUB_VAULT_ABI,
|
|
2621
|
+
functionName: "tokensHeld",
|
|
2622
|
+
args: [ERC4626_ID]
|
|
2623
|
+
}).catch(() => []),
|
|
2624
|
+
publicClient.readContract({
|
|
2625
|
+
address: v,
|
|
2626
|
+
abi: SUB_VAULT_ABI,
|
|
2627
|
+
functionName: "tokensHeld",
|
|
2628
|
+
args: [ERC7540_ID]
|
|
2629
|
+
}).catch(() => [])
|
|
2630
|
+
]);
|
|
2631
|
+
const erc4626Vaults = erc4626Raw.map(getAddress);
|
|
2632
|
+
const erc7540Vaults = erc7540Raw.map(getAddress);
|
|
2633
|
+
const allSubVaults = [
|
|
2634
|
+
...erc4626Vaults.map((a) => ({ address: a, type: "erc4626" })),
|
|
2635
|
+
...erc7540Vaults.map((a) => ({ address: a, type: "erc7540" }))
|
|
2636
|
+
];
|
|
2637
|
+
if (allSubVaults.length === 0) return [];
|
|
2638
|
+
const PER_SV = 5;
|
|
2639
|
+
const subVaultCalls = allSubVaults.flatMap(({ address: sv }) => [
|
|
2640
|
+
{ address: sv, abi: ERC20_ABI, functionName: "balanceOf", args: [v] },
|
|
2641
|
+
{ address: sv, abi: VAULT_ABI, functionName: "asset" },
|
|
2642
|
+
{ address: sv, abi: METADATA_ABI, functionName: "name" },
|
|
2643
|
+
{ address: sv, abi: METADATA_ABI, functionName: "symbol" },
|
|
2644
|
+
{ address: sv, abi: METADATA_ABI, functionName: "decimals" }
|
|
2645
|
+
]);
|
|
2646
|
+
const subVaultResults = await publicClient.multicall({
|
|
2647
|
+
contracts: subVaultCalls,
|
|
2648
|
+
allowFailure: true
|
|
2649
|
+
});
|
|
2650
|
+
const partials = allSubVaults.map(({ address: sv, type }, i) => {
|
|
2651
|
+
const base = i * PER_SV;
|
|
2652
|
+
const sharesBalance = subVaultResults[base]?.status === "success" ? subVaultResults[base].result : 0n;
|
|
2653
|
+
const underlyingAsset = subVaultResults[base + 1]?.status === "success" ? getAddress(subVaultResults[base + 1].result) : zeroAddress;
|
|
2654
|
+
const name = subVaultResults[base + 2]?.status === "success" ? subVaultResults[base + 2].result : "";
|
|
2655
|
+
const symbol = subVaultResults[base + 3]?.status === "success" ? subVaultResults[base + 3].result : "";
|
|
2656
|
+
const decimals = subVaultResults[base + 4]?.status === "success" ? subVaultResults[base + 4].result : 18;
|
|
2657
|
+
return { address: sv, type, sharesBalance, underlyingAsset, name, symbol, decimals };
|
|
2658
|
+
});
|
|
2659
|
+
const active = partials.filter((p) => p.sharesBalance > 0n);
|
|
2660
|
+
if (active.length === 0) return [];
|
|
2661
|
+
const PER_ACTIVE = 4;
|
|
2662
|
+
const activeCalls = active.flatMap(({ address: sv, sharesBalance, underlyingAsset }) => [
|
|
2663
|
+
{ address: sv, abi: SUB_VAULT_ABI, functionName: "convertToAssets", args: [sharesBalance] },
|
|
2664
|
+
{ address: underlyingAsset, abi: METADATA_ABI, functionName: "name" },
|
|
2665
|
+
{ address: underlyingAsset, abi: METADATA_ABI, functionName: "symbol" },
|
|
2666
|
+
{ address: underlyingAsset, abi: METADATA_ABI, functionName: "decimals" }
|
|
2667
|
+
]);
|
|
2668
|
+
const activeResults = await publicClient.multicall({
|
|
2669
|
+
contracts: activeCalls,
|
|
2670
|
+
allowFailure: true
|
|
2671
|
+
});
|
|
2672
|
+
return active.map((p, i) => {
|
|
2673
|
+
const base = i * PER_ACTIVE;
|
|
2674
|
+
const underlyingValue = activeResults[base]?.status === "success" ? activeResults[base].result : 0n;
|
|
2675
|
+
const underlyingSymbol = activeResults[base + 2]?.status === "success" ? activeResults[base + 2].result : "";
|
|
2676
|
+
const underlyingDecimals = activeResults[base + 3]?.status === "success" ? activeResults[base + 3].result : 18;
|
|
2677
|
+
return {
|
|
2678
|
+
address: p.address,
|
|
2679
|
+
type: p.type,
|
|
2680
|
+
name: p.name,
|
|
2681
|
+
symbol: p.symbol,
|
|
2682
|
+
decimals: p.decimals,
|
|
2683
|
+
sharesBalance: p.sharesBalance,
|
|
2684
|
+
underlyingValue,
|
|
2685
|
+
underlyingAsset: p.underlyingAsset,
|
|
2686
|
+
underlyingSymbol,
|
|
2687
|
+
underlyingDecimals
|
|
2688
|
+
};
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
async function getERC7540RequestStatus(publicClient, vault, subVault) {
|
|
2692
|
+
const v = getAddress(vault);
|
|
2693
|
+
const sv = getAddress(subVault);
|
|
2694
|
+
const results = await publicClient.multicall({
|
|
2695
|
+
contracts: [
|
|
2696
|
+
{ address: sv, abi: SUB_VAULT_ABI, functionName: "pendingDepositRequest", args: [0n, v] },
|
|
2697
|
+
{ address: sv, abi: SUB_VAULT_ABI, functionName: "claimableDepositRequest", args: [0n, v] },
|
|
2698
|
+
{ address: sv, abi: SUB_VAULT_ABI, functionName: "pendingRedeemRequest", args: [0n, v] },
|
|
2699
|
+
{ address: sv, abi: SUB_VAULT_ABI, functionName: "claimableRedeemRequest", args: [0n, v] }
|
|
2700
|
+
],
|
|
2701
|
+
allowFailure: true
|
|
2702
|
+
});
|
|
2703
|
+
const pendingDeposit = results[0]?.status === "success" ? results[0].result : 0n;
|
|
2704
|
+
const claimableDeposit = results[1]?.status === "success" ? results[1].result : 0n;
|
|
2705
|
+
const pendingRedeem = results[2]?.status === "success" ? results[2].result : 0n;
|
|
2706
|
+
const claimableRedeem = results[3]?.status === "success" ? results[3].result : 0n;
|
|
2707
|
+
return {
|
|
2708
|
+
subVault: sv,
|
|
2709
|
+
pendingDeposit,
|
|
2710
|
+
claimableDeposit,
|
|
2711
|
+
pendingRedeem,
|
|
2712
|
+
claimableRedeem,
|
|
2713
|
+
canFinalizeDeposit: claimableDeposit > 0n,
|
|
2714
|
+
canFinalizeRedeem: claimableRedeem > 0n
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2717
|
+
async function getVaultPortfolio(publicClient, vault) {
|
|
2718
|
+
const v = getAddress(vault);
|
|
2719
|
+
const [availableRaw, subVaultPositions, vaultTotals] = await Promise.all([
|
|
2720
|
+
publicClient.readContract({ address: v, abi: VAULT_ANALYSIS_ABI, functionName: "getAvailableAssets" }).catch(() => []),
|
|
2721
|
+
getSubVaultPositions(publicClient, v),
|
|
2722
|
+
publicClient.multicall({
|
|
2723
|
+
contracts: [
|
|
2724
|
+
{ address: v, abi: VAULT_ABI, functionName: "totalAssets" },
|
|
2725
|
+
{ address: v, abi: VAULT_ABI, functionName: "totalSupply" },
|
|
2726
|
+
{ address: v, abi: VAULT_ABI, functionName: "asset" }
|
|
2727
|
+
],
|
|
2728
|
+
allowFailure: true
|
|
2729
|
+
})
|
|
2730
|
+
]);
|
|
2731
|
+
const totalAssets = vaultTotals[0]?.status === "success" ? vaultTotals[0].result : 0n;
|
|
2732
|
+
const totalSupply = vaultTotals[1]?.status === "success" ? vaultTotals[1].result : 0n;
|
|
2733
|
+
const underlyingAsset = vaultTotals[2]?.status === "success" ? getAddress(vaultTotals[2].result) : zeroAddress;
|
|
2734
|
+
const availableAddresses = availableRaw.map(getAddress);
|
|
2735
|
+
const subVaultAddressSet = new Set(subVaultPositions.map((p) => p.address.toLowerCase()));
|
|
2736
|
+
const liquidAddresses = availableAddresses.filter(
|
|
2737
|
+
(addr) => !subVaultAddressSet.has(addr.toLowerCase())
|
|
2738
|
+
);
|
|
2739
|
+
const PER_ASSET = 4;
|
|
2740
|
+
const liquidCalls = liquidAddresses.flatMap((addr) => [
|
|
2741
|
+
{ address: addr, abi: ERC20_ABI, functionName: "balanceOf", args: [v] },
|
|
2742
|
+
{ address: addr, abi: METADATA_ABI, functionName: "name" },
|
|
2743
|
+
{ address: addr, abi: METADATA_ABI, functionName: "symbol" },
|
|
2744
|
+
{ address: addr, abi: METADATA_ABI, functionName: "decimals" }
|
|
2745
|
+
]);
|
|
2746
|
+
const liquidResults = liquidAddresses.length > 0 ? await publicClient.multicall({ contracts: liquidCalls, allowFailure: true }) : [];
|
|
2747
|
+
const liquidAssets = liquidAddresses.map((addr, i) => {
|
|
2748
|
+
const base = i * PER_ASSET;
|
|
2749
|
+
const balance = liquidResults[base]?.status === "success" ? liquidResults[base].result : 0n;
|
|
2750
|
+
const name = liquidResults[base + 1]?.status === "success" ? liquidResults[base + 1].result : "";
|
|
2751
|
+
const symbol = liquidResults[base + 2]?.status === "success" ? liquidResults[base + 2].result : "";
|
|
2752
|
+
const decimals = liquidResults[base + 3]?.status === "success" ? liquidResults[base + 3].result : 18;
|
|
2753
|
+
return { address: addr, name, symbol, decimals, balance };
|
|
2754
|
+
});
|
|
2755
|
+
const lockedAssets = await publicClient.readContract({
|
|
2756
|
+
address: v,
|
|
2757
|
+
abi: SUB_VAULT_ABI,
|
|
2758
|
+
functionName: "lockedTokensAmountOfAsset",
|
|
2759
|
+
args: [underlyingAsset]
|
|
2760
|
+
}).catch(() => 0n);
|
|
2761
|
+
const subVaultTotal = subVaultPositions.reduce((sum, p) => sum + p.underlyingValue, 0n);
|
|
2762
|
+
const underlyingBalance = liquidAssets.find(
|
|
2763
|
+
(a) => a.address.toLowerCase() === underlyingAsset.toLowerCase()
|
|
2764
|
+
)?.balance ?? 0n;
|
|
2765
|
+
const totalValue = underlyingBalance + subVaultTotal;
|
|
2766
|
+
return {
|
|
2767
|
+
liquidAssets,
|
|
2768
|
+
subVaultPositions,
|
|
2769
|
+
totalValue,
|
|
2770
|
+
totalAssets,
|
|
2771
|
+
totalSupply,
|
|
2772
|
+
lockedAssets
|
|
2773
|
+
};
|
|
2774
|
+
}
|
|
2461
2775
|
|
|
2462
2776
|
// src/viem/wagmiCompat.ts
|
|
2463
2777
|
function asSdkClient(client) {
|
|
@@ -2918,7 +3232,63 @@ function useVetoActions(vault, chainId) {
|
|
|
2918
3232
|
}
|
|
2919
3233
|
});
|
|
2920
3234
|
}
|
|
3235
|
+
function useCuratorBridgeQuote(vault, chainId, params) {
|
|
3236
|
+
const publicClient = usePublicClient({ chainId });
|
|
3237
|
+
const query = useQuery({
|
|
3238
|
+
queryKey: ["curatorBridgeQuote", vault, chainId, params],
|
|
3239
|
+
queryFn: () => quoteCuratorBridgeFee(asSdkClient(publicClient), vault, params),
|
|
3240
|
+
enabled: !!vault && !!publicClient && !!params,
|
|
3241
|
+
refetchInterval: 6e4,
|
|
3242
|
+
staleTime: 3e4
|
|
3243
|
+
});
|
|
3244
|
+
return {
|
|
3245
|
+
...query,
|
|
3246
|
+
fee: query.data
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3249
|
+
function useExecuteBridge(vault, token, chainId) {
|
|
3250
|
+
const publicClient = usePublicClient({ chainId });
|
|
3251
|
+
const { data: walletClient } = useWalletClient({ chainId });
|
|
3252
|
+
return useMutation({
|
|
3253
|
+
mutationFn: async (params) => {
|
|
3254
|
+
if (!walletClient || !publicClient) {
|
|
3255
|
+
throw new Error("Wallet or public client not available");
|
|
3256
|
+
}
|
|
3257
|
+
return executeCuratorBridge(walletClient, asSdkClient(publicClient), vault, token, params);
|
|
3258
|
+
}
|
|
3259
|
+
});
|
|
3260
|
+
}
|
|
3261
|
+
function useSubVaultPositions(vault, chainId, options) {
|
|
3262
|
+
const publicClient = usePublicClient({ chainId });
|
|
3263
|
+
return useQuery({
|
|
3264
|
+
queryKey: ["subVaultPositions", vault, chainId],
|
|
3265
|
+
queryFn: () => getSubVaultPositions(asSdkClient(publicClient), vault),
|
|
3266
|
+
enabled: !!vault && !!publicClient,
|
|
3267
|
+
refetchInterval: options?.refetchInterval ?? 3e4,
|
|
3268
|
+
staleTime: 15e3
|
|
3269
|
+
});
|
|
3270
|
+
}
|
|
3271
|
+
function useVaultPortfolio(vault, chainId, options) {
|
|
3272
|
+
const publicClient = usePublicClient({ chainId });
|
|
3273
|
+
return useQuery({
|
|
3274
|
+
queryKey: ["vaultPortfolio", vault, chainId],
|
|
3275
|
+
queryFn: () => getVaultPortfolio(asSdkClient(publicClient), vault),
|
|
3276
|
+
enabled: !!vault && !!publicClient,
|
|
3277
|
+
refetchInterval: options?.refetchInterval ?? 3e4,
|
|
3278
|
+
staleTime: 15e3
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
function useERC7540RequestStatus(vault, chainId, subVault, options) {
|
|
3282
|
+
const publicClient = usePublicClient({ chainId });
|
|
3283
|
+
return useQuery({
|
|
3284
|
+
queryKey: ["erc7540RequestStatus", vault, chainId, subVault],
|
|
3285
|
+
queryFn: () => getERC7540RequestStatus(asSdkClient(publicClient), vault, subVault),
|
|
3286
|
+
enabled: !!vault && !!publicClient && !!subVault,
|
|
3287
|
+
refetchInterval: options?.refetchInterval ?? 15e3,
|
|
3288
|
+
staleTime: 1e4
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
2921
3291
|
|
|
2922
|
-
export { getRouteTokenDecimals, useAsyncRequestStatus, useCuratorVaultStatus, useDepositSimple, useExecuteActions, useInboundRoutes, useIsCurator, useLzFee, useOmniDeposit, useOmniRedeem, usePendingActions, useProtocolWhitelist, useRedeemShares, useSmartDeposit, useSmartRedeem, useSubmitActions, useUserPosition, useUserPositionMultiChain, useVaultAnalysis, useVaultAssetBreakdown, useVaultDistribution, useVaultMetadata, useVaultStatus, useVaultTopology, useVetoActions };
|
|
3292
|
+
export { getRouteTokenDecimals, useAsyncRequestStatus, useCuratorBridgeQuote, useCuratorVaultStatus, useDepositSimple, useERC7540RequestStatus, useExecuteActions, useExecuteBridge, useInboundRoutes, useIsCurator, useLzFee, useOmniDeposit, useOmniRedeem, usePendingActions, useProtocolWhitelist, useRedeemShares, useSmartDeposit, useSmartRedeem, useSubVaultPositions, useSubmitActions, useUserPosition, useUserPositionMultiChain, useVaultAnalysis, useVaultAssetBreakdown, useVaultDistribution, useVaultMetadata, useVaultPortfolio, useVaultStatus, useVaultTopology, useVetoActions };
|
|
2923
3293
|
//# sourceMappingURL=index.js.map
|
|
2924
3294
|
//# sourceMappingURL=index.js.map
|