@oydual31/more-vaults-sdk 0.4.0 → 0.4.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/README.md +859 -215
- package/dist/react/index.cjs +644 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +111 -2
- package/dist/react/index.d.ts +111 -2
- package/dist/react/index.js +638 -3
- package/dist/react/index.js.map +1 -1
- package/dist/{spokeRoutes-BIafSbQ3.d.cts → spokeRoutes-B8Lnk-t4.d.cts} +191 -2
- package/dist/{spokeRoutes-BIafSbQ3.d.ts → spokeRoutes-B8Lnk-t4.d.ts} +191 -2
- package/dist/viem/index.d.cts +4 -192
- package/dist/viem/index.d.ts +4 -192
- package/package.json +1 -1
- package/src/react/index.ts +25 -0
- package/src/react/useCuratorVaultStatus.ts +32 -0
- package/src/react/useExecuteActions.ts +23 -0
- package/src/react/useIsCurator.ts +30 -0
- package/src/react/usePendingActions.ts +33 -0
- package/src/react/useProtocolWhitelist.ts +30 -0
- package/src/react/useSubmitActions.ts +27 -0
- package/src/react/useVaultAnalysis.ts +32 -0
- package/src/react/useVaultAssetBreakdown.ts +32 -0
- package/src/react/useVetoActions.ts +23 -0
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
1
|
+
import { useQuery, useMutation } from '@tanstack/react-query';
|
|
2
2
|
import { usePublicClient, useChainId, useWalletClient } from 'wagmi';
|
|
3
|
-
import { getAddress, zeroAddress, encodeAbiParameters, createPublicClient, http, fallback } from 'viem';
|
|
3
|
+
import { 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
|
|
@@ -812,6 +812,227 @@ var OFT_ABI = [
|
|
|
812
812
|
stateMutability: "view"
|
|
813
813
|
}
|
|
814
814
|
];
|
|
815
|
+
var MULTICALL_ABI = [
|
|
816
|
+
{
|
|
817
|
+
type: "function",
|
|
818
|
+
name: "submitActions",
|
|
819
|
+
inputs: [
|
|
820
|
+
{ name: "actionsData", type: "bytes[]" }
|
|
821
|
+
],
|
|
822
|
+
outputs: [{ name: "nonce", type: "uint256" }],
|
|
823
|
+
stateMutability: "nonpayable"
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
type: "function",
|
|
827
|
+
name: "executeActions",
|
|
828
|
+
inputs: [
|
|
829
|
+
{ name: "actionsNonce", type: "uint256" }
|
|
830
|
+
],
|
|
831
|
+
outputs: [],
|
|
832
|
+
stateMutability: "nonpayable"
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
type: "function",
|
|
836
|
+
name: "getPendingActions",
|
|
837
|
+
inputs: [
|
|
838
|
+
{ name: "actionsNonce", type: "uint256" }
|
|
839
|
+
],
|
|
840
|
+
outputs: [
|
|
841
|
+
{ name: "actionsData", type: "bytes[]" },
|
|
842
|
+
{ name: "pendingUntil", type: "uint256" }
|
|
843
|
+
],
|
|
844
|
+
stateMutability: "view"
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
type: "function",
|
|
848
|
+
name: "getCurrentNonce",
|
|
849
|
+
inputs: [],
|
|
850
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
851
|
+
stateMutability: "view"
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
type: "function",
|
|
855
|
+
name: "vetoActions",
|
|
856
|
+
inputs: [
|
|
857
|
+
{ name: "actionsNonces", type: "uint256[]" }
|
|
858
|
+
],
|
|
859
|
+
outputs: [],
|
|
860
|
+
stateMutability: "nonpayable"
|
|
861
|
+
}
|
|
862
|
+
];
|
|
863
|
+
var DEX_ABI = [
|
|
864
|
+
{
|
|
865
|
+
type: "function",
|
|
866
|
+
name: "executeSwap",
|
|
867
|
+
inputs: [
|
|
868
|
+
{
|
|
869
|
+
name: "params",
|
|
870
|
+
type: "tuple",
|
|
871
|
+
components: [
|
|
872
|
+
{ name: "targetContract", type: "address" },
|
|
873
|
+
{ name: "tokenIn", type: "address" },
|
|
874
|
+
{ name: "tokenOut", type: "address" },
|
|
875
|
+
{ name: "maxAmountIn", type: "uint256" },
|
|
876
|
+
{ name: "minAmountOut", type: "uint256" },
|
|
877
|
+
{ name: "swapCallData", type: "bytes" }
|
|
878
|
+
]
|
|
879
|
+
}
|
|
880
|
+
],
|
|
881
|
+
outputs: [{ name: "amountOut", type: "uint256" }],
|
|
882
|
+
stateMutability: "nonpayable"
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
type: "function",
|
|
886
|
+
name: "executeBatchSwap",
|
|
887
|
+
inputs: [
|
|
888
|
+
{
|
|
889
|
+
name: "params",
|
|
890
|
+
type: "tuple",
|
|
891
|
+
components: [
|
|
892
|
+
{
|
|
893
|
+
name: "swaps",
|
|
894
|
+
type: "tuple[]",
|
|
895
|
+
components: [
|
|
896
|
+
{ name: "targetContract", type: "address" },
|
|
897
|
+
{ name: "tokenIn", type: "address" },
|
|
898
|
+
{ name: "tokenOut", type: "address" },
|
|
899
|
+
{ name: "maxAmountIn", type: "uint256" },
|
|
900
|
+
{ name: "minAmountOut", type: "uint256" },
|
|
901
|
+
{ name: "swapCallData", type: "bytes" }
|
|
902
|
+
]
|
|
903
|
+
}
|
|
904
|
+
]
|
|
905
|
+
}
|
|
906
|
+
],
|
|
907
|
+
outputs: [{ name: "amountsOut", type: "uint256[]" }],
|
|
908
|
+
stateMutability: "nonpayable"
|
|
909
|
+
}
|
|
910
|
+
];
|
|
911
|
+
var ERC7540_FACET_ABI = [
|
|
912
|
+
{
|
|
913
|
+
type: "function",
|
|
914
|
+
name: "erc7540RequestDeposit",
|
|
915
|
+
inputs: [
|
|
916
|
+
{ name: "vault", type: "address" },
|
|
917
|
+
{ name: "assets", type: "uint256" }
|
|
918
|
+
],
|
|
919
|
+
outputs: [{ name: "requestId", type: "uint256" }],
|
|
920
|
+
stateMutability: "nonpayable"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
type: "function",
|
|
924
|
+
name: "erc7540RequestRedeem",
|
|
925
|
+
inputs: [
|
|
926
|
+
{ name: "vault", type: "address" },
|
|
927
|
+
{ name: "shares", type: "uint256" }
|
|
928
|
+
],
|
|
929
|
+
outputs: [{ name: "requestId", type: "uint256" }],
|
|
930
|
+
stateMutability: "nonpayable"
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
type: "function",
|
|
934
|
+
name: "erc7540Deposit",
|
|
935
|
+
inputs: [
|
|
936
|
+
{ name: "vault", type: "address" },
|
|
937
|
+
{ name: "assets", type: "uint256" }
|
|
938
|
+
],
|
|
939
|
+
outputs: [{ name: "shares", type: "uint256" }],
|
|
940
|
+
stateMutability: "nonpayable"
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
type: "function",
|
|
944
|
+
name: "erc7540Redeem",
|
|
945
|
+
inputs: [
|
|
946
|
+
{ name: "vault", type: "address" },
|
|
947
|
+
{ name: "shares", type: "uint256" }
|
|
948
|
+
],
|
|
949
|
+
outputs: [{ name: "assets", type: "uint256" }],
|
|
950
|
+
stateMutability: "nonpayable"
|
|
951
|
+
}
|
|
952
|
+
];
|
|
953
|
+
var CURATOR_CONFIG_ABI = [
|
|
954
|
+
{
|
|
955
|
+
type: "function",
|
|
956
|
+
name: "curator",
|
|
957
|
+
inputs: [],
|
|
958
|
+
outputs: [{ name: "", type: "address" }],
|
|
959
|
+
stateMutability: "view"
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
type: "function",
|
|
963
|
+
name: "timeLockPeriod",
|
|
964
|
+
inputs: [],
|
|
965
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
966
|
+
stateMutability: "view"
|
|
967
|
+
},
|
|
968
|
+
{
|
|
969
|
+
type: "function",
|
|
970
|
+
name: "getAvailableAssets",
|
|
971
|
+
inputs: [],
|
|
972
|
+
outputs: [{ name: "", type: "address[]" }],
|
|
973
|
+
stateMutability: "view"
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
type: "function",
|
|
977
|
+
name: "getMaxSlippagePercent",
|
|
978
|
+
inputs: [],
|
|
979
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
980
|
+
stateMutability: "view"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
type: "function",
|
|
984
|
+
name: "getCrossChainAccountingManager",
|
|
985
|
+
inputs: [],
|
|
986
|
+
outputs: [{ name: "", type: "address" }],
|
|
987
|
+
stateMutability: "view"
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
type: "function",
|
|
991
|
+
name: "paused",
|
|
992
|
+
inputs: [],
|
|
993
|
+
outputs: [{ name: "", type: "bool" }],
|
|
994
|
+
stateMutability: "view"
|
|
995
|
+
}
|
|
996
|
+
];
|
|
997
|
+
var ERC4626_FACET_ABI = [
|
|
998
|
+
{
|
|
999
|
+
type: "function",
|
|
1000
|
+
name: "erc4626Deposit",
|
|
1001
|
+
inputs: [
|
|
1002
|
+
{ name: "vault", type: "address" },
|
|
1003
|
+
{ name: "assets", type: "uint256" }
|
|
1004
|
+
],
|
|
1005
|
+
outputs: [{ name: "shares", type: "uint256" }],
|
|
1006
|
+
stateMutability: "nonpayable"
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
type: "function",
|
|
1010
|
+
name: "erc4626Redeem",
|
|
1011
|
+
inputs: [
|
|
1012
|
+
{ name: "vault", type: "address" },
|
|
1013
|
+
{ name: "shares", type: "uint256" }
|
|
1014
|
+
],
|
|
1015
|
+
outputs: [{ name: "assets", type: "uint256" }],
|
|
1016
|
+
stateMutability: "nonpayable"
|
|
1017
|
+
}
|
|
1018
|
+
];
|
|
1019
|
+
var VAULT_ANALYSIS_ABI = [
|
|
1020
|
+
// Asset management reads
|
|
1021
|
+
{ type: "function", name: "getAvailableAssets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" },
|
|
1022
|
+
{ type: "function", name: "getDepositableAssets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" },
|
|
1023
|
+
{ type: "function", name: "isAssetAvailable", inputs: [{ name: "asset", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1024
|
+
{ type: "function", name: "isAssetDepositable", inputs: [{ name: "asset", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1025
|
+
// Deposit whitelist
|
|
1026
|
+
{ type: "function", name: "isDepositWhitelistEnabled", inputs: [], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1027
|
+
{ type: "function", name: "getAvailableToDeposit", inputs: [{ name: "depositor", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "view" },
|
|
1028
|
+
// Registry
|
|
1029
|
+
{ type: "function", name: "moreVaultsRegistry", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" }
|
|
1030
|
+
];
|
|
1031
|
+
var REGISTRY_ABI = [
|
|
1032
|
+
{ type: "function", name: "isWhitelisted", inputs: [{ name: "protocol", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1033
|
+
{ type: "function", name: "isBridgeAllowed", inputs: [{ name: "bridge", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" },
|
|
1034
|
+
{ type: "function", name: "getAllowedFacets", inputs: [], outputs: [{ type: "address[]" }], stateMutability: "view" }
|
|
1035
|
+
];
|
|
815
1036
|
|
|
816
1037
|
// src/viem/types.ts
|
|
817
1038
|
var ActionType = {
|
|
@@ -1914,6 +2135,329 @@ async function getVaultDistribution(hubClient, vault, spokeClients) {
|
|
|
1914
2135
|
oracleAccountingEnabled: hubStatus.oracleAccountingEnabled
|
|
1915
2136
|
};
|
|
1916
2137
|
}
|
|
2138
|
+
async function getCuratorVaultStatus(publicClient, vault) {
|
|
2139
|
+
const v = getAddress(vault);
|
|
2140
|
+
const [
|
|
2141
|
+
curator,
|
|
2142
|
+
timeLockPeriod,
|
|
2143
|
+
maxSlippagePercent,
|
|
2144
|
+
currentNonce,
|
|
2145
|
+
availableAssets,
|
|
2146
|
+
lzAdapter,
|
|
2147
|
+
paused
|
|
2148
|
+
] = await publicClient.multicall({
|
|
2149
|
+
contracts: [
|
|
2150
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "curator" },
|
|
2151
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "timeLockPeriod" },
|
|
2152
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "getMaxSlippagePercent" },
|
|
2153
|
+
{ address: v, abi: MULTICALL_ABI, functionName: "getCurrentNonce" },
|
|
2154
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "getAvailableAssets" },
|
|
2155
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "getCrossChainAccountingManager" },
|
|
2156
|
+
{ address: v, abi: CURATOR_CONFIG_ABI, functionName: "paused" }
|
|
2157
|
+
],
|
|
2158
|
+
allowFailure: false
|
|
2159
|
+
});
|
|
2160
|
+
return {
|
|
2161
|
+
curator: getAddress(curator),
|
|
2162
|
+
timeLockPeriod,
|
|
2163
|
+
maxSlippagePercent,
|
|
2164
|
+
currentNonce,
|
|
2165
|
+
availableAssets: availableAssets.map(getAddress),
|
|
2166
|
+
lzAdapter: getAddress(lzAdapter),
|
|
2167
|
+
paused
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
async function getPendingActions(publicClient, vault, nonce) {
|
|
2171
|
+
const v = getAddress(vault);
|
|
2172
|
+
const [actionsResult, block] = await Promise.all([
|
|
2173
|
+
publicClient.readContract({
|
|
2174
|
+
address: v,
|
|
2175
|
+
abi: MULTICALL_ABI,
|
|
2176
|
+
functionName: "getPendingActions",
|
|
2177
|
+
args: [nonce]
|
|
2178
|
+
}),
|
|
2179
|
+
publicClient.getBlock()
|
|
2180
|
+
]);
|
|
2181
|
+
const [actionsData, pendingUntil] = actionsResult;
|
|
2182
|
+
const isExecutable = pendingUntil > 0n && block.timestamp >= pendingUntil;
|
|
2183
|
+
return {
|
|
2184
|
+
nonce,
|
|
2185
|
+
actionsData,
|
|
2186
|
+
pendingUntil,
|
|
2187
|
+
isExecutable
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
async function isCurator(publicClient, vault, address) {
|
|
2191
|
+
const curatorAddress = await publicClient.readContract({
|
|
2192
|
+
address: getAddress(vault),
|
|
2193
|
+
abi: CURATOR_CONFIG_ABI,
|
|
2194
|
+
functionName: "curator"
|
|
2195
|
+
});
|
|
2196
|
+
return getAddress(curatorAddress) === getAddress(address);
|
|
2197
|
+
}
|
|
2198
|
+
async function getVaultAnalysis(publicClient, vault) {
|
|
2199
|
+
const v = getAddress(vault);
|
|
2200
|
+
const [availableRaw, depositableRaw, depositWhitelistEnabled, registryResult] = await Promise.all([
|
|
2201
|
+
publicClient.readContract({
|
|
2202
|
+
address: v,
|
|
2203
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
2204
|
+
functionName: "getAvailableAssets"
|
|
2205
|
+
}),
|
|
2206
|
+
publicClient.readContract({
|
|
2207
|
+
address: v,
|
|
2208
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
2209
|
+
functionName: "getDepositableAssets"
|
|
2210
|
+
}),
|
|
2211
|
+
publicClient.readContract({
|
|
2212
|
+
address: v,
|
|
2213
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
2214
|
+
functionName: "isDepositWhitelistEnabled"
|
|
2215
|
+
}),
|
|
2216
|
+
publicClient.readContract({
|
|
2217
|
+
address: v,
|
|
2218
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
2219
|
+
functionName: "moreVaultsRegistry"
|
|
2220
|
+
}).catch(() => null)
|
|
2221
|
+
]);
|
|
2222
|
+
const availableAddresses = availableRaw.map(getAddress);
|
|
2223
|
+
const depositableAddresses = depositableRaw.map(getAddress);
|
|
2224
|
+
const allAddresses = Array.from(/* @__PURE__ */ new Set([...availableAddresses, ...depositableAddresses]));
|
|
2225
|
+
const metadataCalls = allAddresses.flatMap((addr) => [
|
|
2226
|
+
{ address: addr, abi: METADATA_ABI, functionName: "name" },
|
|
2227
|
+
{ address: addr, abi: METADATA_ABI, functionName: "symbol" },
|
|
2228
|
+
{ address: addr, abi: METADATA_ABI, functionName: "decimals" }
|
|
2229
|
+
]);
|
|
2230
|
+
const metadataResults = allAddresses.length > 0 ? await publicClient.multicall({ contracts: metadataCalls, allowFailure: true }) : [];
|
|
2231
|
+
const assetInfoMap = /* @__PURE__ */ new Map();
|
|
2232
|
+
for (let i = 0; i < allAddresses.length; i++) {
|
|
2233
|
+
const addr = allAddresses[i];
|
|
2234
|
+
const nameResult = metadataResults[i * 3];
|
|
2235
|
+
const symbolResult = metadataResults[i * 3 + 1];
|
|
2236
|
+
const decimalsResult = metadataResults[i * 3 + 2];
|
|
2237
|
+
assetInfoMap.set(addr, {
|
|
2238
|
+
address: addr,
|
|
2239
|
+
name: nameResult?.status === "success" ? nameResult.result : "",
|
|
2240
|
+
symbol: symbolResult?.status === "success" ? symbolResult.result : "",
|
|
2241
|
+
decimals: decimalsResult?.status === "success" ? decimalsResult.result : 18
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
const registryAddress = registryResult ? getAddress(registryResult) : null;
|
|
2245
|
+
return {
|
|
2246
|
+
availableAssets: availableAddresses.map((a) => assetInfoMap.get(a)),
|
|
2247
|
+
depositableAssets: depositableAddresses.map((a) => assetInfoMap.get(a)),
|
|
2248
|
+
depositWhitelistEnabled,
|
|
2249
|
+
registryAddress
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
async function checkProtocolWhitelist(publicClient, vault, protocols) {
|
|
2253
|
+
const v = getAddress(vault);
|
|
2254
|
+
const registryRaw = await publicClient.readContract({
|
|
2255
|
+
address: v,
|
|
2256
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
2257
|
+
functionName: "moreVaultsRegistry"
|
|
2258
|
+
});
|
|
2259
|
+
const registry = getAddress(registryRaw);
|
|
2260
|
+
if (protocols.length === 0) return {};
|
|
2261
|
+
const results = await publicClient.multicall({
|
|
2262
|
+
contracts: protocols.map((protocol) => ({
|
|
2263
|
+
address: registry,
|
|
2264
|
+
abi: REGISTRY_ABI,
|
|
2265
|
+
functionName: "isWhitelisted",
|
|
2266
|
+
args: [getAddress(protocol)]
|
|
2267
|
+
})),
|
|
2268
|
+
allowFailure: true
|
|
2269
|
+
});
|
|
2270
|
+
const out = {};
|
|
2271
|
+
for (let i = 0; i < protocols.length; i++) {
|
|
2272
|
+
const r = results[i];
|
|
2273
|
+
out[getAddress(protocols[i])] = r?.status === "success" ? r.result : false;
|
|
2274
|
+
}
|
|
2275
|
+
return out;
|
|
2276
|
+
}
|
|
2277
|
+
async function getVaultAssetBreakdown(publicClient, vault) {
|
|
2278
|
+
const v = getAddress(vault);
|
|
2279
|
+
const availableRaw = await publicClient.readContract({
|
|
2280
|
+
address: v,
|
|
2281
|
+
abi: VAULT_ANALYSIS_ABI,
|
|
2282
|
+
functionName: "getAvailableAssets"
|
|
2283
|
+
});
|
|
2284
|
+
const addresses = availableRaw.map(getAddress);
|
|
2285
|
+
const results = await publicClient.multicall({
|
|
2286
|
+
contracts: [
|
|
2287
|
+
// Per-asset: balanceOf, name, symbol, decimals
|
|
2288
|
+
...addresses.flatMap((addr) => [
|
|
2289
|
+
{ address: addr, abi: ERC20_ABI, functionName: "balanceOf", args: [v] },
|
|
2290
|
+
{ address: addr, abi: METADATA_ABI, functionName: "name" },
|
|
2291
|
+
{ address: addr, abi: METADATA_ABI, functionName: "symbol" },
|
|
2292
|
+
{ address: addr, abi: METADATA_ABI, functionName: "decimals" }
|
|
2293
|
+
]),
|
|
2294
|
+
// Vault totals
|
|
2295
|
+
{ address: v, abi: VAULT_ABI, functionName: "totalAssets" },
|
|
2296
|
+
{ address: v, abi: VAULT_ABI, functionName: "totalSupply" },
|
|
2297
|
+
{ address: v, abi: METADATA_ABI, functionName: "decimals" }
|
|
2298
|
+
],
|
|
2299
|
+
allowFailure: true
|
|
2300
|
+
});
|
|
2301
|
+
const perAssetFields = 4;
|
|
2302
|
+
const assets = addresses.map((addr, i) => {
|
|
2303
|
+
const base = i * perAssetFields;
|
|
2304
|
+
const balance = results[base]?.status === "success" ? results[base].result : 0n;
|
|
2305
|
+
const name = results[base + 1]?.status === "success" ? results[base + 1].result : "";
|
|
2306
|
+
const symbol = results[base + 2]?.status === "success" ? results[base + 2].result : "";
|
|
2307
|
+
const decimals = results[base + 3]?.status === "success" ? results[base + 3].result : 18;
|
|
2308
|
+
return { address: addr, name, symbol, decimals, balance };
|
|
2309
|
+
});
|
|
2310
|
+
const totalsBase = addresses.length * perAssetFields;
|
|
2311
|
+
const totalAssets = results[totalsBase]?.status === "success" ? results[totalsBase].result : 0n;
|
|
2312
|
+
const totalSupply = results[totalsBase + 1]?.status === "success" ? results[totalsBase + 1].result : 0n;
|
|
2313
|
+
const underlyingDecimals = results[totalsBase + 2]?.status === "success" ? results[totalsBase + 2].result : 6;
|
|
2314
|
+
return { assets, totalAssets, totalSupply, underlyingDecimals };
|
|
2315
|
+
}
|
|
2316
|
+
function encodeCuratorAction(action) {
|
|
2317
|
+
switch (action.type) {
|
|
2318
|
+
case "swap":
|
|
2319
|
+
return encodeFunctionData({
|
|
2320
|
+
abi: DEX_ABI,
|
|
2321
|
+
functionName: "executeSwap",
|
|
2322
|
+
args: [
|
|
2323
|
+
{
|
|
2324
|
+
targetContract: getAddress(action.params.targetContract),
|
|
2325
|
+
tokenIn: getAddress(action.params.tokenIn),
|
|
2326
|
+
tokenOut: getAddress(action.params.tokenOut),
|
|
2327
|
+
maxAmountIn: action.params.maxAmountIn,
|
|
2328
|
+
minAmountOut: action.params.minAmountOut,
|
|
2329
|
+
swapCallData: action.params.swapCallData
|
|
2330
|
+
}
|
|
2331
|
+
]
|
|
2332
|
+
});
|
|
2333
|
+
case "batchSwap":
|
|
2334
|
+
return encodeFunctionData({
|
|
2335
|
+
abi: DEX_ABI,
|
|
2336
|
+
functionName: "executeBatchSwap",
|
|
2337
|
+
args: [
|
|
2338
|
+
{
|
|
2339
|
+
swaps: action.params.swaps.map((s) => ({
|
|
2340
|
+
targetContract: getAddress(s.targetContract),
|
|
2341
|
+
tokenIn: getAddress(s.tokenIn),
|
|
2342
|
+
tokenOut: getAddress(s.tokenOut),
|
|
2343
|
+
maxAmountIn: s.maxAmountIn,
|
|
2344
|
+
minAmountOut: s.minAmountOut,
|
|
2345
|
+
swapCallData: s.swapCallData
|
|
2346
|
+
}))
|
|
2347
|
+
}
|
|
2348
|
+
]
|
|
2349
|
+
});
|
|
2350
|
+
case "erc4626Deposit":
|
|
2351
|
+
return encodeFunctionData({
|
|
2352
|
+
abi: ERC4626_FACET_ABI,
|
|
2353
|
+
functionName: "erc4626Deposit",
|
|
2354
|
+
args: [getAddress(action.vault), action.assets]
|
|
2355
|
+
});
|
|
2356
|
+
case "erc4626Redeem":
|
|
2357
|
+
return encodeFunctionData({
|
|
2358
|
+
abi: ERC4626_FACET_ABI,
|
|
2359
|
+
functionName: "erc4626Redeem",
|
|
2360
|
+
args: [getAddress(action.vault), action.shares]
|
|
2361
|
+
});
|
|
2362
|
+
case "erc7540RequestDeposit":
|
|
2363
|
+
return encodeFunctionData({
|
|
2364
|
+
abi: ERC7540_FACET_ABI,
|
|
2365
|
+
functionName: "erc7540RequestDeposit",
|
|
2366
|
+
args: [getAddress(action.vault), action.assets]
|
|
2367
|
+
});
|
|
2368
|
+
case "erc7540Deposit":
|
|
2369
|
+
return encodeFunctionData({
|
|
2370
|
+
abi: ERC7540_FACET_ABI,
|
|
2371
|
+
functionName: "erc7540Deposit",
|
|
2372
|
+
args: [getAddress(action.vault), action.assets]
|
|
2373
|
+
});
|
|
2374
|
+
case "erc7540RequestRedeem":
|
|
2375
|
+
return encodeFunctionData({
|
|
2376
|
+
abi: ERC7540_FACET_ABI,
|
|
2377
|
+
functionName: "erc7540RequestRedeem",
|
|
2378
|
+
args: [getAddress(action.vault), action.shares]
|
|
2379
|
+
});
|
|
2380
|
+
case "erc7540Redeem":
|
|
2381
|
+
return encodeFunctionData({
|
|
2382
|
+
abi: ERC7540_FACET_ABI,
|
|
2383
|
+
functionName: "erc7540Redeem",
|
|
2384
|
+
args: [getAddress(action.vault), action.shares]
|
|
2385
|
+
});
|
|
2386
|
+
default: {
|
|
2387
|
+
const _exhaustive = action;
|
|
2388
|
+
throw new Error(`[MoreVaults] Unknown CuratorAction type: ${_exhaustive.type}`);
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
function buildCuratorBatch(actions) {
|
|
2393
|
+
return actions.map(encodeCuratorAction);
|
|
2394
|
+
}
|
|
2395
|
+
async function submitActions(walletClient, publicClient, vault, actions) {
|
|
2396
|
+
const account = walletClient.account;
|
|
2397
|
+
const v = getAddress(vault);
|
|
2398
|
+
await publicClient.simulateContract({
|
|
2399
|
+
address: v,
|
|
2400
|
+
abi: MULTICALL_ABI,
|
|
2401
|
+
functionName: "submitActions",
|
|
2402
|
+
args: [actions],
|
|
2403
|
+
account: account.address
|
|
2404
|
+
});
|
|
2405
|
+
const txHash = await walletClient.writeContract({
|
|
2406
|
+
address: v,
|
|
2407
|
+
abi: MULTICALL_ABI,
|
|
2408
|
+
functionName: "submitActions",
|
|
2409
|
+
args: [actions],
|
|
2410
|
+
account,
|
|
2411
|
+
chain: walletClient.chain
|
|
2412
|
+
});
|
|
2413
|
+
const nextNonce = await publicClient.readContract({
|
|
2414
|
+
address: v,
|
|
2415
|
+
abi: MULTICALL_ABI,
|
|
2416
|
+
functionName: "getCurrentNonce"
|
|
2417
|
+
});
|
|
2418
|
+
const nonce = nextNonce - 1n;
|
|
2419
|
+
return { txHash, nonce };
|
|
2420
|
+
}
|
|
2421
|
+
async function executeActions(walletClient, publicClient, vault, nonce) {
|
|
2422
|
+
const account = walletClient.account;
|
|
2423
|
+
const v = getAddress(vault);
|
|
2424
|
+
await publicClient.simulateContract({
|
|
2425
|
+
address: v,
|
|
2426
|
+
abi: MULTICALL_ABI,
|
|
2427
|
+
functionName: "executeActions",
|
|
2428
|
+
args: [nonce],
|
|
2429
|
+
account: account.address
|
|
2430
|
+
});
|
|
2431
|
+
const txHash = await walletClient.writeContract({
|
|
2432
|
+
address: v,
|
|
2433
|
+
abi: MULTICALL_ABI,
|
|
2434
|
+
functionName: "executeActions",
|
|
2435
|
+
args: [nonce],
|
|
2436
|
+
account,
|
|
2437
|
+
chain: walletClient.chain
|
|
2438
|
+
});
|
|
2439
|
+
return { txHash };
|
|
2440
|
+
}
|
|
2441
|
+
async function vetoActions(walletClient, publicClient, vault, nonces) {
|
|
2442
|
+
const account = walletClient.account;
|
|
2443
|
+
const v = getAddress(vault);
|
|
2444
|
+
await publicClient.simulateContract({
|
|
2445
|
+
address: v,
|
|
2446
|
+
abi: MULTICALL_ABI,
|
|
2447
|
+
functionName: "vetoActions",
|
|
2448
|
+
args: [nonces],
|
|
2449
|
+
account: account.address
|
|
2450
|
+
});
|
|
2451
|
+
const txHash = await walletClient.writeContract({
|
|
2452
|
+
address: v,
|
|
2453
|
+
abi: MULTICALL_ABI,
|
|
2454
|
+
functionName: "vetoActions",
|
|
2455
|
+
args: [nonces],
|
|
2456
|
+
account,
|
|
2457
|
+
chain: walletClient.chain
|
|
2458
|
+
});
|
|
2459
|
+
return { txHash };
|
|
2460
|
+
}
|
|
1917
2461
|
|
|
1918
2462
|
// src/viem/wagmiCompat.ts
|
|
1919
2463
|
function asSdkClient(client) {
|
|
@@ -2283,7 +2827,98 @@ function useInboundRoutes(hubChainId, vault, vaultAsset, userAddress) {
|
|
|
2283
2827
|
error: error ?? null
|
|
2284
2828
|
};
|
|
2285
2829
|
}
|
|
2830
|
+
function useCuratorVaultStatus(vault, chainId, options) {
|
|
2831
|
+
const publicClient = usePublicClient({ chainId });
|
|
2832
|
+
return useQuery({
|
|
2833
|
+
queryKey: ["curatorVaultStatus", vault, chainId],
|
|
2834
|
+
queryFn: () => getCuratorVaultStatus(asSdkClient(publicClient), vault),
|
|
2835
|
+
enabled: !!vault && !!publicClient,
|
|
2836
|
+
refetchInterval: options?.refetchInterval ?? 3e4,
|
|
2837
|
+
staleTime: 15e3
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
function useVaultAnalysis(vault, chainId, options) {
|
|
2841
|
+
const publicClient = usePublicClient({ chainId });
|
|
2842
|
+
return useQuery({
|
|
2843
|
+
queryKey: ["vaultAnalysis", vault, chainId],
|
|
2844
|
+
queryFn: () => getVaultAnalysis(asSdkClient(publicClient), vault),
|
|
2845
|
+
enabled: !!vault && !!publicClient,
|
|
2846
|
+
refetchInterval: options?.refetchInterval ?? 3e4,
|
|
2847
|
+
staleTime: 15e3
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
function useVaultAssetBreakdown(vault, chainId, options) {
|
|
2851
|
+
const publicClient = usePublicClient({ chainId });
|
|
2852
|
+
return useQuery({
|
|
2853
|
+
queryKey: ["vaultAssetBreakdown", vault, chainId],
|
|
2854
|
+
queryFn: () => getVaultAssetBreakdown(asSdkClient(publicClient), vault),
|
|
2855
|
+
enabled: !!vault && !!publicClient,
|
|
2856
|
+
refetchInterval: options?.refetchInterval ?? 3e4,
|
|
2857
|
+
staleTime: 15e3
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
function usePendingActions(vault, chainId, nonce, options) {
|
|
2861
|
+
const publicClient = usePublicClient({ chainId });
|
|
2862
|
+
return useQuery({
|
|
2863
|
+
queryKey: ["pendingActions", vault, chainId, nonce?.toString()],
|
|
2864
|
+
queryFn: () => getPendingActions(asSdkClient(publicClient), vault, nonce),
|
|
2865
|
+
enabled: !!vault && !!publicClient && nonce !== void 0,
|
|
2866
|
+
refetchInterval: options?.refetchInterval ?? 3e4,
|
|
2867
|
+
staleTime: 15e3
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2870
|
+
function useIsCurator(vault, chainId, address, options) {
|
|
2871
|
+
const publicClient = usePublicClient({ chainId });
|
|
2872
|
+
return useQuery({
|
|
2873
|
+
queryKey: ["isCurator", vault, chainId, address],
|
|
2874
|
+
queryFn: () => isCurator(asSdkClient(publicClient), vault, address),
|
|
2875
|
+
enabled: !!vault && !!publicClient && !!address,
|
|
2876
|
+
refetchInterval: options?.refetchInterval ?? 3e4,
|
|
2877
|
+
staleTime: 15e3
|
|
2878
|
+
});
|
|
2879
|
+
}
|
|
2880
|
+
function useProtocolWhitelist(vault, chainId, protocols, options) {
|
|
2881
|
+
const publicClient = usePublicClient({ chainId });
|
|
2882
|
+
return useQuery({
|
|
2883
|
+
queryKey: ["protocolWhitelist", vault, chainId, protocols],
|
|
2884
|
+
queryFn: () => checkProtocolWhitelist(asSdkClient(publicClient), vault, protocols),
|
|
2885
|
+
enabled: !!vault && !!publicClient,
|
|
2886
|
+
refetchInterval: options?.refetchInterval ?? 3e4,
|
|
2887
|
+
staleTime: 15e3
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
function useSubmitActions(vault, chainId) {
|
|
2891
|
+
const publicClient = usePublicClient({ chainId });
|
|
2892
|
+
const { data: walletClient } = useWalletClient({ chainId });
|
|
2893
|
+
return useMutation({
|
|
2894
|
+
mutationFn: async ({ actions }) => {
|
|
2895
|
+
if (!walletClient || !publicClient) throw new Error("Wallet or public client not available");
|
|
2896
|
+
const encodedActions = buildCuratorBatch(actions);
|
|
2897
|
+
return submitActions(walletClient, asSdkClient(publicClient), vault, encodedActions);
|
|
2898
|
+
}
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
function useExecuteActions(vault, chainId) {
|
|
2902
|
+
const publicClient = usePublicClient({ chainId });
|
|
2903
|
+
const { data: walletClient } = useWalletClient({ chainId });
|
|
2904
|
+
return useMutation({
|
|
2905
|
+
mutationFn: async ({ nonce }) => {
|
|
2906
|
+
if (!walletClient || !publicClient) throw new Error("Wallet or public client not available");
|
|
2907
|
+
return executeActions(walletClient, asSdkClient(publicClient), vault, nonce);
|
|
2908
|
+
}
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2911
|
+
function useVetoActions(vault, chainId) {
|
|
2912
|
+
const publicClient = usePublicClient({ chainId });
|
|
2913
|
+
const { data: walletClient } = useWalletClient({ chainId });
|
|
2914
|
+
return useMutation({
|
|
2915
|
+
mutationFn: async ({ nonces }) => {
|
|
2916
|
+
if (!walletClient || !publicClient) throw new Error("Wallet or public client not available");
|
|
2917
|
+
return vetoActions(walletClient, asSdkClient(publicClient), vault, nonces);
|
|
2918
|
+
}
|
|
2919
|
+
});
|
|
2920
|
+
}
|
|
2286
2921
|
|
|
2287
|
-
export { getRouteTokenDecimals, useAsyncRequestStatus, useDepositSimple, useInboundRoutes, useLzFee, useOmniDeposit, useOmniRedeem, useRedeemShares, useSmartDeposit, useSmartRedeem, useUserPosition, useUserPositionMultiChain, useVaultDistribution, useVaultMetadata, useVaultStatus, useVaultTopology };
|
|
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 };
|
|
2288
2923
|
//# sourceMappingURL=index.js.map
|
|
2289
2924
|
//# sourceMappingURL=index.js.map
|