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