@oydual31/more-vaults-sdk 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/{spokeRoutes-DK7cIW4z.d.cts → spokeRoutes-BIafSbQ3.d.cts} +13 -2
- package/dist/{spokeRoutes-DK7cIW4z.d.ts → spokeRoutes-BIafSbQ3.d.ts} +13 -2
- package/dist/viem/index.cjs +34 -28
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +1 -1
- package/dist/viem/index.d.ts +1 -1
- package/dist/viem/index.js +34 -29
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/crossChainFlows.ts +12 -22
- package/src/viem/index.ts +1 -0
- package/src/viem/preflight.ts +3 -9
- package/src/viem/redeemFlows.ts +4 -5
- package/src/viem/utils.ts +40 -0
package/dist/viem/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Address, Hash, WalletClient, PublicClient } from 'viem';
|
|
2
2
|
export { PublicClient as SdkPublicClient } from 'viem';
|
|
3
|
-
export { A as AsyncRequestFinalResult, a as AsyncRequestStatus, b as AsyncRequestStatusInfo, D as DepositBlockReason, c as DepositEligibility, I as InboundRoute, d as InboundRouteWithBalance, M as MaxWithdrawable, e as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, f as OutboundRoute, S as SpokeBalance, U as UserBalances, g as UserPosition, V as VaultDistribution, h as VaultMetadata, i as VaultMode, j as VaultStatus, k as VaultSummary, l as VaultTopology, m as canDeposit, n as
|
|
3
|
+
export { A as AsyncRequestFinalResult, a as AsyncRequestStatus, b as AsyncRequestStatusInfo, D as DepositBlockReason, c as DepositEligibility, I as InboundRoute, d as InboundRouteWithBalance, M as MaxWithdrawable, e as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, f as OutboundRoute, S as SpokeBalance, U as UserBalances, g as UserPosition, V as VaultDistribution, h as VaultMetadata, i as VaultMode, j as VaultStatus, k as VaultSummary, l as VaultTopology, m as canDeposit, n as detectStargateOft, o as discoverVaultTopology, p as ensureAllowance, q as getAllVaultChainIds, r as getAsyncRequestStatus, s as getAsyncRequestStatusLabel, t as getFullVaultTopology, u as getInboundRoutes, v as getMaxWithdrawable, w as getOutboundRoutes, x as getUserBalances, y as getUserBalancesForRoutes, z as getUserPosition, B as getUserPositionMultiChain, C as getVaultDistribution, E as getVaultDistributionWithTopology, F as getVaultMetadata, G as getVaultStatus, H as getVaultSummary, J as getVaultTopology, K as isAsyncMode, L as isOnHubChain, P as previewDeposit, Q as previewRedeem, R as quoteLzFee, T as quoteRouteDepositFee, W as waitForAsyncRequest, X as waitForTx } from '../spokeRoutes-BIafSbQ3.cjs';
|
|
4
4
|
|
|
5
5
|
/** EVM Chain IDs for chains supported by MoreVaults */
|
|
6
6
|
declare const CHAIN_IDS: {
|
package/dist/viem/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Address, Hash, WalletClient, PublicClient } from 'viem';
|
|
2
2
|
export { PublicClient as SdkPublicClient } from 'viem';
|
|
3
|
-
export { A as AsyncRequestFinalResult, a as AsyncRequestStatus, b as AsyncRequestStatusInfo, D as DepositBlockReason, c as DepositEligibility, I as InboundRoute, d as InboundRouteWithBalance, M as MaxWithdrawable, e as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, f as OutboundRoute, S as SpokeBalance, U as UserBalances, g as UserPosition, V as VaultDistribution, h as VaultMetadata, i as VaultMode, j as VaultStatus, k as VaultSummary, l as VaultTopology, m as canDeposit, n as
|
|
3
|
+
export { A as AsyncRequestFinalResult, a as AsyncRequestStatus, b as AsyncRequestStatusInfo, D as DepositBlockReason, c as DepositEligibility, I as InboundRoute, d as InboundRouteWithBalance, M as MaxWithdrawable, e as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, f as OutboundRoute, S as SpokeBalance, U as UserBalances, g as UserPosition, V as VaultDistribution, h as VaultMetadata, i as VaultMode, j as VaultStatus, k as VaultSummary, l as VaultTopology, m as canDeposit, n as detectStargateOft, o as discoverVaultTopology, p as ensureAllowance, q as getAllVaultChainIds, r as getAsyncRequestStatus, s as getAsyncRequestStatusLabel, t as getFullVaultTopology, u as getInboundRoutes, v as getMaxWithdrawable, w as getOutboundRoutes, x as getUserBalances, y as getUserBalancesForRoutes, z as getUserPosition, B as getUserPositionMultiChain, C as getVaultDistribution, E as getVaultDistributionWithTopology, F as getVaultMetadata, G as getVaultStatus, H as getVaultSummary, J as getVaultTopology, K as isAsyncMode, L as isOnHubChain, P as previewDeposit, Q as previewRedeem, R as quoteLzFee, T as quoteRouteDepositFee, W as waitForAsyncRequest, X as waitForTx } from '../spokeRoutes-BIafSbQ3.js';
|
|
4
4
|
|
|
5
5
|
/** EVM Chain IDs for chains supported by MoreVaults */
|
|
6
6
|
declare const CHAIN_IDS: {
|
package/dist/viem/index.js
CHANGED
|
@@ -1468,6 +1468,27 @@ async function waitForAsyncRequest(publicClient, vault, guid, pollInterval = 3e4
|
|
|
1468
1468
|
`[MoreVaults] Async request ${guid} did not finalize within ${timeout / 1e3}s. The request may still complete \u2014 check https://layerzeroscan.com/tx/${guid}`
|
|
1469
1469
|
);
|
|
1470
1470
|
}
|
|
1471
|
+
var STARGATE_TYPE_ABI = [
|
|
1472
|
+
{
|
|
1473
|
+
type: "function",
|
|
1474
|
+
name: "stargateType",
|
|
1475
|
+
inputs: [],
|
|
1476
|
+
outputs: [{ type: "uint8" }],
|
|
1477
|
+
stateMutability: "view"
|
|
1478
|
+
}
|
|
1479
|
+
];
|
|
1480
|
+
async function detectStargateOft(publicClient, oft) {
|
|
1481
|
+
try {
|
|
1482
|
+
await publicClient.readContract({
|
|
1483
|
+
address: getAddress(oft),
|
|
1484
|
+
abi: STARGATE_TYPE_ABI,
|
|
1485
|
+
functionName: "stargateType"
|
|
1486
|
+
});
|
|
1487
|
+
return true;
|
|
1488
|
+
} catch {
|
|
1489
|
+
return false;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1471
1492
|
var PUBLIC_RPCS = {
|
|
1472
1493
|
1: [
|
|
1473
1494
|
"https://ethereum-rpc.publicnode.com",
|
|
@@ -1866,21 +1887,11 @@ var COMPOSER_ABI = [
|
|
|
1866
1887
|
stateMutability: "view"
|
|
1867
1888
|
}
|
|
1868
1889
|
];
|
|
1869
|
-
var STARGATE_ASSETS = /* @__PURE__ */ new Set(["stgUSDC", "USDT", "WETH"]);
|
|
1870
1890
|
function buildLzComposeOption(gas, nativeValue) {
|
|
1871
1891
|
const gasHex = gas.toString(16).padStart(32, "0");
|
|
1872
1892
|
const valueHex = nativeValue.toString(16).padStart(32, "0");
|
|
1873
1893
|
return `0x00030300220000${gasHex}${valueHex}`;
|
|
1874
1894
|
}
|
|
1875
|
-
function isStargateOft(oft) {
|
|
1876
|
-
for (const [symbol, chainMap] of Object.entries(OFT_ROUTES)) {
|
|
1877
|
-
if (!STARGATE_ASSETS.has(symbol)) continue;
|
|
1878
|
-
for (const entry of Object.values(chainMap)) {
|
|
1879
|
-
if (getAddress(entry.oft) === oft) return true;
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
return false;
|
|
1883
|
-
}
|
|
1884
1895
|
async function resolveComposeNativeValue(hubClient, vault, composerAddress, spokeEid, receiverBytes32) {
|
|
1885
1896
|
const [readFeeResult, shareOftResult] = await Promise.allSettled([
|
|
1886
1897
|
hubClient.readContract({
|
|
@@ -1944,7 +1955,7 @@ async function depositFromSpoke(walletClient, publicClient, vault, spokeOFT, hub
|
|
|
1944
1955
|
if (composerAddress === zeroAddress) throw new Error(`No composer registered for vault ${vault} on hub chainId ${hubChainId}`);
|
|
1945
1956
|
const composerBytes32 = pad(composerAddress, { size: 32 });
|
|
1946
1957
|
const receiverBytes32 = pad(getAddress(receiver), { size: 32 });
|
|
1947
|
-
const isStargate =
|
|
1958
|
+
const isStargate = await detectStargateOft(publicClient, oft);
|
|
1948
1959
|
let resolvedExtraOptions;
|
|
1949
1960
|
if (extraOptions !== "0x") {
|
|
1950
1961
|
resolvedExtraOptions = extraOptions;
|
|
@@ -2041,7 +2052,7 @@ async function depositFromSpoke(walletClient, publicClient, vault, spokeOFT, hub
|
|
|
2041
2052
|
account,
|
|
2042
2053
|
chain: walletClient.chain
|
|
2043
2054
|
});
|
|
2044
|
-
const stargate =
|
|
2055
|
+
const stargate = isStargate;
|
|
2045
2056
|
let composeData;
|
|
2046
2057
|
if (stargate) {
|
|
2047
2058
|
const hubBlockStart = await hubClient.getBlockNumber();
|
|
@@ -2075,7 +2086,7 @@ async function quoteDepositFromSpokeFee(publicClient, vault, spokeOFT, hubEid, s
|
|
|
2075
2086
|
args: [getAddress(vault)]
|
|
2076
2087
|
});
|
|
2077
2088
|
const composerBytes32 = pad(composerAddress, { size: 32 });
|
|
2078
|
-
const isStargate =
|
|
2089
|
+
const isStargate = await detectStargateOft(publicClient, oft);
|
|
2079
2090
|
let resolvedExtraOptions;
|
|
2080
2091
|
if (extraOptions !== "0x") {
|
|
2081
2092
|
resolvedExtraOptions = extraOptions;
|
|
@@ -2144,13 +2155,16 @@ async function waitForCompose(hubPublicClient, composeData, receiver, pollInterv
|
|
|
2144
2155
|
const endpoint = getAddress(composeData.endpoint);
|
|
2145
2156
|
const receiverNeedle = getAddress(receiver).slice(2).toLowerCase();
|
|
2146
2157
|
const startBlock = composeData.hubBlockStart;
|
|
2147
|
-
const knownFromAddresses = [];
|
|
2148
2158
|
const hubChainId = composeData.hubChainId;
|
|
2149
|
-
|
|
2150
|
-
|
|
2159
|
+
const candidateAddresses = [];
|
|
2160
|
+
for (const chainMap of Object.values(OFT_ROUTES)) {
|
|
2151
2161
|
const entry = chainMap[hubChainId];
|
|
2152
|
-
if (entry)
|
|
2162
|
+
if (entry) candidateAddresses.push(getAddress(entry.oft));
|
|
2153
2163
|
}
|
|
2164
|
+
const stargateChecks = await Promise.all(
|
|
2165
|
+
candidateAddresses.map(async (addr) => ({ addr, isSg: await detectStargateOft(hubPublicClient, addr) }))
|
|
2166
|
+
);
|
|
2167
|
+
const knownFromAddresses = stargateChecks.filter((c) => c.isSg).map((c) => c.addr);
|
|
2154
2168
|
let attempt = 0;
|
|
2155
2169
|
let scannedUpTo = startBlock - 1n;
|
|
2156
2170
|
while (Date.now() < deadline) {
|
|
@@ -2483,14 +2497,7 @@ async function preflightSpokeDeposit(spokePublicClient, vault, spokeOFT, hubEid,
|
|
|
2483
2497
|
Have: ${spokeNativeBalance} wei`
|
|
2484
2498
|
);
|
|
2485
2499
|
}
|
|
2486
|
-
const
|
|
2487
|
-
let isStargate = false;
|
|
2488
|
-
for (const [symbol, chainMap] of Object.entries(OFT_ROUTES)) {
|
|
2489
|
-
if (!STARGATE_ASSETS3.has(symbol)) continue;
|
|
2490
|
-
for (const entry of Object.values(chainMap)) {
|
|
2491
|
-
if (getAddress(entry.oft) === oft) isStargate = true;
|
|
2492
|
-
}
|
|
2493
|
-
}
|
|
2500
|
+
const isStargate = await detectStargateOft(spokePublicClient, oft);
|
|
2494
2501
|
let hubNativeBalance = 0n;
|
|
2495
2502
|
let estimatedComposeFee = 0n;
|
|
2496
2503
|
if (isStargate) {
|
|
@@ -2992,7 +2999,6 @@ async function bridgeAssetsToSpoke(walletClient, publicClient, assetOFT, spokeCh
|
|
|
2992
2999
|
});
|
|
2993
3000
|
return { txHash };
|
|
2994
3001
|
}
|
|
2995
|
-
var STARGATE_ASSETS2 = /* @__PURE__ */ new Set(["stgUSDC", "USDT", "WETH"]);
|
|
2996
3002
|
var FACTORY_COMPOSER_ABI2 = [
|
|
2997
3003
|
{
|
|
2998
3004
|
type: "function",
|
|
@@ -3042,7 +3048,6 @@ async function resolveRedeemAddresses(hubPublicClient, vault, hubChainId, spokeC
|
|
|
3042
3048
|
const spokeShareOft = getAddress(`0x${spokeShareOftBytes32.slice(-40)}`);
|
|
3043
3049
|
let hubAssetOft = null;
|
|
3044
3050
|
let spokeAsset = null;
|
|
3045
|
-
let isStargate = false;
|
|
3046
3051
|
let symbol = "";
|
|
3047
3052
|
for (const [sym, chainMap] of Object.entries(OFT_ROUTES)) {
|
|
3048
3053
|
const hubEntry = chainMap[hubChainId];
|
|
@@ -3051,7 +3056,6 @@ async function resolveRedeemAddresses(hubPublicClient, vault, hubChainId, spokeC
|
|
|
3051
3056
|
if (getAddress(hubEntry.token) === getAddress(hubAsset)) {
|
|
3052
3057
|
hubAssetOft = getAddress(hubEntry.oft);
|
|
3053
3058
|
spokeAsset = getAddress(spokeEntry.token);
|
|
3054
|
-
isStargate = STARGATE_ASSETS2.has(sym);
|
|
3055
3059
|
symbol = sym;
|
|
3056
3060
|
break;
|
|
3057
3061
|
}
|
|
@@ -3061,6 +3065,7 @@ async function resolveRedeemAddresses(hubPublicClient, vault, hubChainId, spokeC
|
|
|
3061
3065
|
`[MoreVaults] No OFT route found for vault asset ${hubAsset} between hub chain ${hubChainId} and spoke chain ${spokeChainId}`
|
|
3062
3066
|
);
|
|
3063
3067
|
}
|
|
3068
|
+
const isStargate = await detectStargateOft(hubPublicClient, hubAssetOft);
|
|
3064
3069
|
return {
|
|
3065
3070
|
hubChainId,
|
|
3066
3071
|
spokeChainId,
|
|
@@ -3947,6 +3952,6 @@ function asSdkClient(client) {
|
|
|
3947
3952
|
return client;
|
|
3948
3953
|
}
|
|
3949
3954
|
|
|
3950
|
-
export { ActionType, BRIDGE_ABI, BRIDGE_FACET_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, DEX_ABI, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, REGISTRY_ABI, STARGATE_TAXI_CMD, UNISWAP_V3_ROUTERS, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, discoverVaultTopology, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, executeActions, executeCompose, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, quoteComposeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForAsyncRequest, waitForCompose, waitForTx, withdrawAssets };
|
|
3955
|
+
export { ActionType, BRIDGE_ABI, BRIDGE_FACET_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, DEX_ABI, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, REGISTRY_ABI, STARGATE_TAXI_CMD, UNISWAP_V3_ROUTERS, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, detectStargateOft, discoverVaultTopology, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, executeActions, executeCompose, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, quoteComposeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForAsyncRequest, waitForCompose, waitForTx, withdrawAssets };
|
|
3951
3956
|
//# sourceMappingURL=index.js.map
|
|
3952
3957
|
//# sourceMappingURL=index.js.map
|