@oydual31/more-vaults-sdk 0.2.1 → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  import { Hash, Address, WalletClient, PublicClient } from 'viem';
2
2
  export { PublicClient as SdkPublicClient } from 'viem';
3
- export { A as AsyncRequestStatus, a as AsyncRequestStatusInfo, D as DepositBlockReason, b as DepositEligibility, I as InboundRoute, c as InboundRouteWithBalance, M as MaxWithdrawable, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, d as OutboundRoute, S as SpokeBalance, U as UserBalances, e as UserPosition, V as VaultDistribution, f as VaultMetadata, g as VaultMode, h as VaultStatus, i as VaultSummary, j as VaultTopology, k as canDeposit, l as ensureAllowance, m as getAllVaultChainIds, n as getAsyncRequestStatus, o as getAsyncRequestStatusLabel, p as getFullVaultTopology, q as getInboundRoutes, r as getMaxWithdrawable, s as getOutboundRoutes, t as getUserBalances, u as getUserBalancesForRoutes, v as getUserPosition, w as getVaultDistribution, x as getVaultDistributionWithTopology, y as getVaultMetadata, z as getVaultStatus, B as getVaultSummary, C as getVaultTopology, E as isAsyncMode, F as isOnHubChain, G as previewDeposit, H as previewRedeem, J as quoteLzFee, K as quoteRouteDepositFee, L as waitForTx } from '../spokeRoutes-BFI1m_zk.cjs';
3
+ export { A as AsyncRequestStatus, a as AsyncRequestStatusInfo, D as DepositBlockReason, b as DepositEligibility, I as InboundRoute, c as InboundRouteWithBalance, M as MaxWithdrawable, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, d as OutboundRoute, S as SpokeBalance, U as UserBalances, e as UserPosition, V as VaultDistribution, f as VaultMetadata, g as VaultMode, h as VaultStatus, i as VaultSummary, j as VaultTopology, k as canDeposit, l as discoverVaultTopology, m as ensureAllowance, n as getAllVaultChainIds, o as getAsyncRequestStatus, p as getAsyncRequestStatusLabel, q as getFullVaultTopology, r as getInboundRoutes, s as getMaxWithdrawable, t as getOutboundRoutes, u as getUserBalances, v as getUserBalancesForRoutes, w as getUserPosition, x as getVaultDistribution, y as getVaultDistributionWithTopology, z as getVaultMetadata, B as getVaultStatus, C as getVaultSummary, E as getVaultTopology, F as isAsyncMode, G as isOnHubChain, H as previewDeposit, J as previewRedeem, K as quoteLzFee, L as quoteRouteDepositFee, P as waitForTx } from '../spokeRoutes-CK5NSOOF.cjs';
4
4
 
5
5
  /** EVM Chain IDs for chains supported by MoreVaults */
6
6
  declare const CHAIN_IDS: {
@@ -1,6 +1,6 @@
1
1
  import { Hash, Address, WalletClient, PublicClient } from 'viem';
2
2
  export { PublicClient as SdkPublicClient } from 'viem';
3
- export { A as AsyncRequestStatus, a as AsyncRequestStatusInfo, D as DepositBlockReason, b as DepositEligibility, I as InboundRoute, c as InboundRouteWithBalance, M as MaxWithdrawable, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, d as OutboundRoute, S as SpokeBalance, U as UserBalances, e as UserPosition, V as VaultDistribution, f as VaultMetadata, g as VaultMode, h as VaultStatus, i as VaultSummary, j as VaultTopology, k as canDeposit, l as ensureAllowance, m as getAllVaultChainIds, n as getAsyncRequestStatus, o as getAsyncRequestStatusLabel, p as getFullVaultTopology, q as getInboundRoutes, r as getMaxWithdrawable, s as getOutboundRoutes, t as getUserBalances, u as getUserBalancesForRoutes, v as getUserPosition, w as getVaultDistribution, x as getVaultDistributionWithTopology, y as getVaultMetadata, z as getVaultStatus, B as getVaultSummary, C as getVaultTopology, E as isAsyncMode, F as isOnHubChain, G as previewDeposit, H as previewRedeem, J as quoteLzFee, K as quoteRouteDepositFee, L as waitForTx } from '../spokeRoutes-BFI1m_zk.js';
3
+ export { A as AsyncRequestStatus, a as AsyncRequestStatusInfo, D as DepositBlockReason, b as DepositEligibility, I as InboundRoute, c as InboundRouteWithBalance, M as MaxWithdrawable, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, d as OutboundRoute, S as SpokeBalance, U as UserBalances, e as UserPosition, V as VaultDistribution, f as VaultMetadata, g as VaultMode, h as VaultStatus, i as VaultSummary, j as VaultTopology, k as canDeposit, l as discoverVaultTopology, m as ensureAllowance, n as getAllVaultChainIds, o as getAsyncRequestStatus, p as getAsyncRequestStatusLabel, q as getFullVaultTopology, r as getInboundRoutes, s as getMaxWithdrawable, t as getOutboundRoutes, u as getUserBalances, v as getUserBalancesForRoutes, w as getUserPosition, x as getVaultDistribution, y as getVaultDistributionWithTopology, z as getVaultMetadata, B as getVaultStatus, C as getVaultSummary, E as getVaultTopology, F as isAsyncMode, G as isOnHubChain, H as previewDeposit, J as previewRedeem, K as quoteLzFee, L as quoteRouteDepositFee, P as waitForTx } from '../spokeRoutes-CK5NSOOF.js';
4
4
 
5
5
  /** EVM Chain IDs for chains supported by MoreVaults */
6
6
  declare const CHAIN_IDS: {
@@ -1132,93 +1132,6 @@ async function getAsyncRequestStatus(publicClient, vault, guid) {
1132
1132
  result: finalizationResult
1133
1133
  };
1134
1134
  }
1135
- var OMNI_FACTORY_ADDRESS = "0x7bDB8B17604b03125eFAED33cA0c55FBf856BB0C";
1136
- var FACTORY_ABI = [
1137
- {
1138
- name: "localEid",
1139
- type: "function",
1140
- inputs: [],
1141
- outputs: [{ type: "uint32" }],
1142
- stateMutability: "view"
1143
- },
1144
- {
1145
- name: "isCrossChainVault",
1146
- type: "function",
1147
- inputs: [{ name: "__eid", type: "uint32" }, { name: "_vault", type: "address" }],
1148
- outputs: [{ type: "bool" }],
1149
- stateMutability: "view"
1150
- },
1151
- {
1152
- name: "hubToSpokes",
1153
- type: "function",
1154
- inputs: [{ name: "__eid", type: "uint32" }, { name: "_hubVault", type: "address" }],
1155
- outputs: [{ name: "eids", type: "uint32[]" }, { name: "vaults", type: "address[]" }],
1156
- stateMutability: "view"
1157
- },
1158
- {
1159
- name: "spokeToHub",
1160
- type: "function",
1161
- inputs: [{ name: "__eid", type: "uint32" }, { name: "_spokeVault", type: "address" }],
1162
- outputs: [{ name: "eid", type: "uint32" }, { name: "vault", type: "address" }],
1163
- stateMutability: "view"
1164
- }
1165
- ];
1166
- async function getVaultTopology(publicClient, vault, factoryAddress = OMNI_FACTORY_ADDRESS) {
1167
- const v = getAddress(vault);
1168
- const f = getAddress(factoryAddress);
1169
- const localEid = await publicClient.readContract({
1170
- address: f,
1171
- abi: FACTORY_ABI,
1172
- functionName: "localEid"
1173
- });
1174
- const isHub = await publicClient.readContract({
1175
- address: f,
1176
- abi: FACTORY_ABI,
1177
- functionName: "isCrossChainVault",
1178
- args: [localEid, v]
1179
- });
1180
- if (isHub) {
1181
- const [spokeEids] = await publicClient.readContract({
1182
- address: f,
1183
- abi: FACTORY_ABI,
1184
- functionName: "hubToSpokes",
1185
- args: [localEid, v]
1186
- });
1187
- const localChainId2 = EID_TO_CHAIN_ID[localEid] ?? Number(publicClient.chain?.id ?? 0);
1188
- const spokeChainIds = spokeEids.map((eid) => EID_TO_CHAIN_ID[eid]).filter((id) => id !== void 0);
1189
- return { role: "hub", hubChainId: localChainId2, spokeChainIds };
1190
- }
1191
- const [hubEid, hubVault] = await publicClient.readContract({
1192
- address: f,
1193
- abi: FACTORY_ABI,
1194
- functionName: "spokeToHub",
1195
- args: [localEid, v]
1196
- });
1197
- if (hubEid !== 0 && hubVault !== "0x0000000000000000000000000000000000000000") {
1198
- const hubChainId = EID_TO_CHAIN_ID[hubEid] ?? 0;
1199
- const spokeChainIds = [];
1200
- const localChainId2 = EID_TO_CHAIN_ID[localEid];
1201
- if (localChainId2 !== void 0) spokeChainIds.push(localChainId2);
1202
- return { role: "spoke", hubChainId, spokeChainIds };
1203
- }
1204
- const localChainId = EID_TO_CHAIN_ID[localEid] ?? Number(publicClient.chain?.id ?? 0);
1205
- return { role: "local", hubChainId: localChainId, spokeChainIds: [] };
1206
- }
1207
- async function getFullVaultTopology(hubChainClient, vault, factoryAddress = OMNI_FACTORY_ADDRESS) {
1208
- const topo = await getVaultTopology(hubChainClient, vault, factoryAddress);
1209
- if (topo.role !== "hub") {
1210
- throw new Error(
1211
- `getFullVaultTopology: client must be connected to the hub chain (${topo.hubChainId}), but got role="${topo.role}". Connect to chainId ${topo.hubChainId} instead.`
1212
- );
1213
- }
1214
- return topo;
1215
- }
1216
- function isOnHubChain(currentChainId, topology) {
1217
- return currentChainId === topology.hubChainId;
1218
- }
1219
- function getAllVaultChainIds(topology) {
1220
- return [topology.hubChainId, ...topology.spokeChainIds];
1221
- }
1222
1135
  var PUBLIC_RPCS = {
1223
1136
  1: [
1224
1137
  "https://ethereum-rpc.publicnode.com",
@@ -1459,6 +1372,144 @@ async function quoteRouteDepositFee(route, hubChainId, amount, userAddress) {
1459
1372
  return fee.nativeFee;
1460
1373
  }
1461
1374
 
1375
+ // src/viem/topology.ts
1376
+ var OMNI_FACTORY_ADDRESS = "0x7bDB8B17604b03125eFAED33cA0c55FBf856BB0C";
1377
+ var FACTORY_ABI = [
1378
+ {
1379
+ name: "localEid",
1380
+ type: "function",
1381
+ inputs: [],
1382
+ outputs: [{ type: "uint32" }],
1383
+ stateMutability: "view"
1384
+ },
1385
+ {
1386
+ name: "isCrossChainVault",
1387
+ type: "function",
1388
+ inputs: [{ name: "__eid", type: "uint32" }, { name: "_vault", type: "address" }],
1389
+ outputs: [{ type: "bool" }],
1390
+ stateMutability: "view"
1391
+ },
1392
+ {
1393
+ name: "hubToSpokes",
1394
+ type: "function",
1395
+ inputs: [{ name: "__eid", type: "uint32" }, { name: "_hubVault", type: "address" }],
1396
+ outputs: [{ name: "eids", type: "uint32[]" }, { name: "vaults", type: "address[]" }],
1397
+ stateMutability: "view"
1398
+ },
1399
+ {
1400
+ name: "spokeToHub",
1401
+ type: "function",
1402
+ inputs: [{ name: "__eid", type: "uint32" }, { name: "_spokeVault", type: "address" }],
1403
+ outputs: [{ name: "eid", type: "uint32" }, { name: "vault", type: "address" }],
1404
+ stateMutability: "view"
1405
+ }
1406
+ ];
1407
+ async function getVaultTopology(publicClient, vault, factoryAddress = OMNI_FACTORY_ADDRESS) {
1408
+ const v = getAddress(vault);
1409
+ const f = getAddress(factoryAddress);
1410
+ const localEid = await publicClient.readContract({
1411
+ address: f,
1412
+ abi: FACTORY_ABI,
1413
+ functionName: "localEid"
1414
+ });
1415
+ const isHub = await publicClient.readContract({
1416
+ address: f,
1417
+ abi: FACTORY_ABI,
1418
+ functionName: "isCrossChainVault",
1419
+ args: [localEid, v]
1420
+ });
1421
+ if (isHub) {
1422
+ const [spokeEids] = await publicClient.readContract({
1423
+ address: f,
1424
+ abi: FACTORY_ABI,
1425
+ functionName: "hubToSpokes",
1426
+ args: [localEid, v]
1427
+ });
1428
+ const localChainId2 = EID_TO_CHAIN_ID[localEid] ?? Number(publicClient.chain?.id ?? 0);
1429
+ const spokeChainIds = spokeEids.map((eid) => EID_TO_CHAIN_ID[eid]).filter((id) => id !== void 0);
1430
+ return { role: "hub", hubChainId: localChainId2, spokeChainIds };
1431
+ }
1432
+ const [hubEid, hubVault] = await publicClient.readContract({
1433
+ address: f,
1434
+ abi: FACTORY_ABI,
1435
+ functionName: "spokeToHub",
1436
+ args: [localEid, v]
1437
+ });
1438
+ if (hubEid !== 0 && hubVault !== "0x0000000000000000000000000000000000000000") {
1439
+ const hubChainId = EID_TO_CHAIN_ID[hubEid] ?? 0;
1440
+ const spokeChainIds = [];
1441
+ const localChainId2 = EID_TO_CHAIN_ID[localEid];
1442
+ if (localChainId2 !== void 0) spokeChainIds.push(localChainId2);
1443
+ return { role: "spoke", hubChainId, spokeChainIds };
1444
+ }
1445
+ const localChainId = EID_TO_CHAIN_ID[localEid] ?? Number(publicClient.chain?.id ?? 0);
1446
+ return { role: "local", hubChainId: localChainId, spokeChainIds: [] };
1447
+ }
1448
+ async function getFullVaultTopology(hubChainClient, vault, factoryAddress = OMNI_FACTORY_ADDRESS) {
1449
+ const topo = await getVaultTopology(hubChainClient, vault, factoryAddress);
1450
+ if (topo.role !== "hub") {
1451
+ throw new Error(
1452
+ `getFullVaultTopology: client must be connected to the hub chain (${topo.hubChainId}), but got role="${topo.role}". Connect to chainId ${topo.hubChainId} instead.`
1453
+ );
1454
+ }
1455
+ return topo;
1456
+ }
1457
+ var DISCOVERY_CHAIN_IDS = Object.values(CHAIN_IDS).filter(
1458
+ (id) => id !== 545
1459
+ // exclude testnet
1460
+ );
1461
+ async function discoverVaultTopology(vault, publicClient, factoryAddress = OMNI_FACTORY_ADDRESS) {
1462
+ const v = getAddress(vault);
1463
+ let triedChainId;
1464
+ if (publicClient) {
1465
+ try {
1466
+ const topo = await getVaultTopology(publicClient, v, factoryAddress);
1467
+ if (topo.role !== "local") {
1468
+ if (topo.role === "spoke") {
1469
+ const hubClient = createChainClient(topo.hubChainId);
1470
+ if (hubClient) {
1471
+ try {
1472
+ return await getFullVaultTopology(hubClient, v, factoryAddress);
1473
+ } catch {
1474
+ }
1475
+ }
1476
+ }
1477
+ return topo;
1478
+ }
1479
+ triedChainId = publicClient.chain?.id;
1480
+ } catch {
1481
+ }
1482
+ }
1483
+ for (const chainId of DISCOVERY_CHAIN_IDS) {
1484
+ if (chainId === triedChainId) continue;
1485
+ const client = createChainClient(chainId);
1486
+ if (!client) continue;
1487
+ try {
1488
+ const topo = await getVaultTopology(client, v, factoryAddress);
1489
+ if (topo.role === "hub") return topo;
1490
+ if (topo.role === "spoke") {
1491
+ const hubClient = createChainClient(topo.hubChainId);
1492
+ if (hubClient) {
1493
+ try {
1494
+ return await getFullVaultTopology(hubClient, v, factoryAddress);
1495
+ } catch {
1496
+ return topo;
1497
+ }
1498
+ }
1499
+ return topo;
1500
+ }
1501
+ } catch {
1502
+ }
1503
+ }
1504
+ return { role: "local", hubChainId: 0, spokeChainIds: [] };
1505
+ }
1506
+ function isOnHubChain(currentChainId, topology) {
1507
+ return currentChainId === topology.hubChainId;
1508
+ }
1509
+ function getAllVaultChainIds(topology) {
1510
+ return [topology.hubChainId, ...topology.spokeChainIds];
1511
+ }
1512
+
1462
1513
  // src/viem/crossChainFlows.ts
1463
1514
  var LZ_ENDPOINT = "0x1a44076050125825900e736c501f859c50fe728c";
1464
1515
  var FACTORY_COMPOSER_ABI = [
@@ -2967,6 +3018,6 @@ function asSdkClient(client) {
2967
3018
  return client;
2968
3019
  }
2969
3020
 
2970
- export { ActionType, BRIDGE_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CapacityFullError, EID_TO_CHAIN_ID, ERC20_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, STARGATE_TAXI_CMD, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, canDeposit, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, ensureAllowance, executeCompose, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getUserBalances, getUserBalancesForRoutes, getUserPosition, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isOnHubChain, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, quoteComposeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, waitForCompose, waitForTx, withdrawAssets };
3021
+ export { ActionType, BRIDGE_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CapacityFullError, EID_TO_CHAIN_ID, ERC20_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, STARGATE_TAXI_CMD, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, canDeposit, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, discoverVaultTopology, ensureAllowance, executeCompose, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getUserBalances, getUserBalancesForRoutes, getUserPosition, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isOnHubChain, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, quoteComposeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, waitForCompose, waitForTx, withdrawAssets };
2971
3022
  //# sourceMappingURL=index.js.map
2972
3023
  //# sourceMappingURL=index.js.map