@oydual31/more-vaults-sdk 0.1.10 → 0.1.12
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 +58 -27
- 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 +59 -28
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +60 -23
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.js +61 -24
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/react/useVaultDistribution.ts +7 -20
- package/src/viem/spokeRoutes.ts +69 -28
package/dist/react/index.cjs
CHANGED
|
@@ -1384,15 +1384,57 @@ async function getVaultDistribution(hubClient, vault, spokeClients) {
|
|
|
1384
1384
|
oracleAccountingEnabled: hubStatus.oracleAccountingEnabled
|
|
1385
1385
|
};
|
|
1386
1386
|
}
|
|
1387
|
-
var
|
|
1388
|
-
1:
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1387
|
+
var PUBLIC_RPCS = {
|
|
1388
|
+
1: [
|
|
1389
|
+
"https://ethereum-rpc.publicnode.com",
|
|
1390
|
+
"https://ethereum.publicnode.com",
|
|
1391
|
+
"https://eth.drpc.org",
|
|
1392
|
+
"https://eth-mainnet.public.blastapi.io",
|
|
1393
|
+
"https://0xrpc.io/eth",
|
|
1394
|
+
"https://eth.llamarpc.com"
|
|
1395
|
+
],
|
|
1396
|
+
10: [
|
|
1397
|
+
"https://mainnet.optimism.io",
|
|
1398
|
+
"https://optimism-rpc.publicnode.com",
|
|
1399
|
+
"https://op.drpc.org"
|
|
1400
|
+
],
|
|
1401
|
+
42161: [
|
|
1402
|
+
"https://arbitrum-one-rpc.publicnode.com",
|
|
1403
|
+
"https://arbitrum.publicnode.com",
|
|
1404
|
+
"https://arbitrum.public.blockpi.network/v1/rpc/public",
|
|
1405
|
+
"https://public-arb-mainnet.fastnode.io"
|
|
1406
|
+
],
|
|
1407
|
+
8453: [
|
|
1408
|
+
"https://base-rpc.publicnode.com",
|
|
1409
|
+
"https://base.llamarpc.com",
|
|
1410
|
+
"https://base.drpc.org",
|
|
1411
|
+
"https://mainnet.base.org",
|
|
1412
|
+
"https://1rpc.io/base",
|
|
1413
|
+
"https://base.rpc.subquery.network/public"
|
|
1414
|
+
],
|
|
1415
|
+
747: [
|
|
1416
|
+
"https://mainnet.evm.nodes.onflow.org"
|
|
1417
|
+
],
|
|
1418
|
+
146: [
|
|
1419
|
+
"https://rpc.soniclabs.com",
|
|
1420
|
+
"https://sonic.drpc.org"
|
|
1421
|
+
],
|
|
1422
|
+
56: [
|
|
1423
|
+
"https://bsc-dataseed1.binance.org",
|
|
1424
|
+
"https://bsc-dataseed2.binance.org",
|
|
1425
|
+
"https://bsc-rpc.publicnode.com"
|
|
1426
|
+
]
|
|
1395
1427
|
};
|
|
1428
|
+
function createChainClient(chainId) {
|
|
1429
|
+
const rpcs = PUBLIC_RPCS[chainId];
|
|
1430
|
+
if (!rpcs?.length) return null;
|
|
1431
|
+
return viem.createPublicClient({
|
|
1432
|
+
transport: rpcs.length === 1 ? viem.http(rpcs[0]) : viem.fallback(rpcs.map((url) => viem.http(url)))
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
Object.fromEntries(
|
|
1436
|
+
Object.entries(PUBLIC_RPCS).map(([k, v]) => [k, v[0]])
|
|
1437
|
+
);
|
|
1396
1438
|
var NATIVE_SYMBOL = {
|
|
1397
1439
|
1: "ETH",
|
|
1398
1440
|
10: "ETH",
|
|
@@ -1405,9 +1447,8 @@ var NATIVE_SYMBOL = {
|
|
|
1405
1447
|
async function getInboundRoutes(hubChainId, vault, vaultAsset, userAddress) {
|
|
1406
1448
|
const hubEid = CHAIN_ID_TO_EID[hubChainId];
|
|
1407
1449
|
if (!hubEid) throw new Error(`No LZ EID for hub chainId ${hubChainId}`);
|
|
1408
|
-
const
|
|
1409
|
-
if (!
|
|
1410
|
-
const hubClient = viem.createPublicClient({ transport: viem.http(hubRpc) });
|
|
1450
|
+
const hubClient = createChainClient(hubChainId);
|
|
1451
|
+
if (!hubClient) throw new Error(`No public RPC for hub chainId ${hubChainId}`);
|
|
1411
1452
|
const topology = await getVaultTopology(hubClient, vault);
|
|
1412
1453
|
const registeredSpokes = new Set(topology.spokeChainIds);
|
|
1413
1454
|
const results = [];
|
|
@@ -1422,9 +1463,8 @@ async function getInboundRoutes(hubChainId, vault, vaultAsset, userAddress) {
|
|
|
1422
1463
|
spokesToCheck.map(async (spokeChainId) => {
|
|
1423
1464
|
const spokeEntry = chainMap[spokeChainId];
|
|
1424
1465
|
if (!spokeEntry) return;
|
|
1425
|
-
const
|
|
1426
|
-
if (!
|
|
1427
|
-
const client = viem.createPublicClient({ transport: viem.http(rpc) });
|
|
1466
|
+
const client = createChainClient(spokeChainId);
|
|
1467
|
+
if (!client) return;
|
|
1428
1468
|
try {
|
|
1429
1469
|
const receiverBytes32 = `0x${viem.getAddress(userAddress).slice(2).padStart(64, "0")}`;
|
|
1430
1470
|
const fee = await client.readContract({
|
|
@@ -1479,9 +1519,8 @@ async function getInboundRoutes(hubChainId, vault, vaultAsset, userAddress) {
|
|
|
1479
1519
|
async function getUserBalancesForRoutes(routes, userAddress) {
|
|
1480
1520
|
return Promise.all(
|
|
1481
1521
|
routes.map(async (route) => {
|
|
1482
|
-
const
|
|
1483
|
-
if (!
|
|
1484
|
-
const client = viem.createPublicClient({ transport: viem.http(rpc) });
|
|
1522
|
+
const client = createChainClient(route.spokeChainId);
|
|
1523
|
+
if (!client) return { ...route, userBalance: 0n };
|
|
1485
1524
|
try {
|
|
1486
1525
|
let userBalance;
|
|
1487
1526
|
if (route.spokeToken === viem.zeroAddress) {
|
|
@@ -1758,10 +1797,6 @@ function useRedeemShares(vault, chainId) {
|
|
|
1758
1797
|
reset
|
|
1759
1798
|
};
|
|
1760
1799
|
}
|
|
1761
|
-
var SPOKE_RPCS = {
|
|
1762
|
-
1: "https://eth.llamarpc.com",
|
|
1763
|
-
42161: "https://arbitrum.public.blockpi.network/v1/rpc/public"
|
|
1764
|
-
};
|
|
1765
1800
|
function useVaultDistribution(vault) {
|
|
1766
1801
|
const chainId = wagmi.useChainId();
|
|
1767
1802
|
const publicClient = wagmi.usePublicClient();
|
|
@@ -1770,12 +1805,8 @@ function useVaultDistribution(vault) {
|
|
|
1770
1805
|
if (!topology) return {};
|
|
1771
1806
|
const clients = {};
|
|
1772
1807
|
for (const spokeChainId of topology.spokeChainIds) {
|
|
1773
|
-
const
|
|
1774
|
-
if (
|
|
1775
|
-
clients[spokeChainId] = viem.createPublicClient({
|
|
1776
|
-
transport: viem.http(rpcUrl)
|
|
1777
|
-
});
|
|
1778
|
-
}
|
|
1808
|
+
const client = createChainClient(spokeChainId);
|
|
1809
|
+
if (client) clients[spokeChainId] = client;
|
|
1779
1810
|
}
|
|
1780
1811
|
return clients;
|
|
1781
1812
|
}, [topology]);
|