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