@oydual31/more-vaults-sdk 1.1.10 → 1.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 +53 -41
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +53 -41
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +67 -63
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.js +67 -63
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/crossChainFlows.ts +11 -2
- package/src/viem/redeemFlows.ts +9 -17
- package/src/viem/topology.ts +66 -0
- package/src/viem/userHelpers.ts +8 -29
package/dist/react/index.cjs
CHANGED
|
@@ -1771,6 +1771,54 @@ var FACTORY_ABI = [
|
|
|
1771
1771
|
stateMutability: "view"
|
|
1772
1772
|
}
|
|
1773
1773
|
];
|
|
1774
|
+
var OFT_FACTORY_ABI = [
|
|
1775
|
+
{
|
|
1776
|
+
name: "MoreVaultsOftAdapterFactory",
|
|
1777
|
+
type: "function",
|
|
1778
|
+
inputs: [],
|
|
1779
|
+
outputs: [{ type: "address" }],
|
|
1780
|
+
stateMutability: "view"
|
|
1781
|
+
},
|
|
1782
|
+
{
|
|
1783
|
+
name: "MoreVaultsOftFactory",
|
|
1784
|
+
type: "function",
|
|
1785
|
+
inputs: [],
|
|
1786
|
+
outputs: [{ type: "address" }],
|
|
1787
|
+
stateMutability: "view"
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
name: "OFTs",
|
|
1791
|
+
type: "function",
|
|
1792
|
+
inputs: [{ name: "vault", type: "address" }],
|
|
1793
|
+
outputs: [{ type: "address" }],
|
|
1794
|
+
stateMutability: "view"
|
|
1795
|
+
}
|
|
1796
|
+
];
|
|
1797
|
+
async function _getOftFromFactory(publicClient, vault, factoryFn) {
|
|
1798
|
+
try {
|
|
1799
|
+
const subFactoryAddr = await publicClient.readContract({
|
|
1800
|
+
address: OMNI_FACTORY_ADDRESS,
|
|
1801
|
+
abi: OFT_FACTORY_ABI,
|
|
1802
|
+
functionName: factoryFn
|
|
1803
|
+
});
|
|
1804
|
+
const oft = await publicClient.readContract({
|
|
1805
|
+
address: subFactoryAddr,
|
|
1806
|
+
abi: OFT_FACTORY_ABI,
|
|
1807
|
+
functionName: "OFTs",
|
|
1808
|
+
args: [vault]
|
|
1809
|
+
});
|
|
1810
|
+
if (oft === "0x0000000000000000000000000000000000000000") return null;
|
|
1811
|
+
return viem.getAddress(oft);
|
|
1812
|
+
} catch {
|
|
1813
|
+
return null;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
function getHubShareOft(publicClient, vault) {
|
|
1817
|
+
return _getOftFromFactory(publicClient, vault, "MoreVaultsOftAdapterFactory");
|
|
1818
|
+
}
|
|
1819
|
+
function getSpokeShareOft(publicClient, vault) {
|
|
1820
|
+
return _getOftFromFactory(publicClient, vault, "MoreVaultsOftFactory");
|
|
1821
|
+
}
|
|
1774
1822
|
async function getVaultTopology(publicClient, vault, factoryAddress = OMNI_FACTORY_ADDRESS) {
|
|
1775
1823
|
try {
|
|
1776
1824
|
const v = viem.getAddress(vault);
|
|
@@ -2350,24 +2398,6 @@ async function getAsyncRequestStatusLabel(publicClient, vault, guid) {
|
|
|
2350
2398
|
result: 0n
|
|
2351
2399
|
};
|
|
2352
2400
|
}
|
|
2353
|
-
var FACTORY_COMPOSER_ABI = [
|
|
2354
|
-
{
|
|
2355
|
-
type: "function",
|
|
2356
|
-
name: "vaultComposer",
|
|
2357
|
-
inputs: [{ name: "_vault", type: "address" }],
|
|
2358
|
-
outputs: [{ name: "", type: "address" }],
|
|
2359
|
-
stateMutability: "view"
|
|
2360
|
-
}
|
|
2361
|
-
];
|
|
2362
|
-
var COMPOSER_SHARE_OFT_ABI = [
|
|
2363
|
-
{
|
|
2364
|
-
type: "function",
|
|
2365
|
-
name: "SHARE_OFT",
|
|
2366
|
-
inputs: [],
|
|
2367
|
-
outputs: [{ name: "", type: "address" }],
|
|
2368
|
-
stateMutability: "view"
|
|
2369
|
-
}
|
|
2370
|
-
];
|
|
2371
2401
|
async function getUserPositionMultiChain(vault, user) {
|
|
2372
2402
|
const v = viem.getAddress(vault);
|
|
2373
2403
|
const u = viem.getAddress(user);
|
|
@@ -2391,19 +2421,7 @@ async function getUserPositionMultiChain(vault, user) {
|
|
|
2391
2421
|
if (topo.spokeChainIds.length > 0) {
|
|
2392
2422
|
let hubShareOft = null;
|
|
2393
2423
|
try {
|
|
2394
|
-
|
|
2395
|
-
address: OMNI_FACTORY_ADDRESS,
|
|
2396
|
-
abi: FACTORY_COMPOSER_ABI,
|
|
2397
|
-
functionName: "vaultComposer",
|
|
2398
|
-
args: [v]
|
|
2399
|
-
});
|
|
2400
|
-
if (composerAddress !== "0x0000000000000000000000000000000000000000") {
|
|
2401
|
-
hubShareOft = await hubClient.readContract({
|
|
2402
|
-
address: composerAddress,
|
|
2403
|
-
abi: COMPOSER_SHARE_OFT_ABI,
|
|
2404
|
-
functionName: "SHARE_OFT"
|
|
2405
|
-
});
|
|
2406
|
-
}
|
|
2424
|
+
hubShareOft = await getHubShareOft(hubClient, v);
|
|
2407
2425
|
} catch {
|
|
2408
2426
|
}
|
|
2409
2427
|
if (hubShareOft) {
|
|
@@ -2411,18 +2429,12 @@ async function getUserPositionMultiChain(vault, user) {
|
|
|
2411
2429
|
try {
|
|
2412
2430
|
const spokeEid = CHAIN_ID_TO_EID[spokeChainId];
|
|
2413
2431
|
if (!spokeEid) return { chainId: spokeChainId, balance: 0n, rawBalance: 0n };
|
|
2414
|
-
const spokeOftBytes32 = await hubClient.readContract({
|
|
2415
|
-
address: hubShareOft,
|
|
2416
|
-
abi: OFT_ABI,
|
|
2417
|
-
functionName: "peers",
|
|
2418
|
-
args: [spokeEid]
|
|
2419
|
-
});
|
|
2420
|
-
const spokeOft = viem.getAddress(`0x${spokeOftBytes32.slice(-40)}`);
|
|
2421
|
-
if (spokeOft === "0x0000000000000000000000000000000000000000") {
|
|
2422
|
-
return { chainId: spokeChainId, balance: 0n, rawBalance: 0n };
|
|
2423
|
-
}
|
|
2424
2432
|
const spokeClient = createChainClient(spokeChainId);
|
|
2425
2433
|
if (!spokeClient) return { chainId: spokeChainId, balance: 0n, rawBalance: 0n };
|
|
2434
|
+
const spokeOft = await getSpokeShareOft(spokeClient, v);
|
|
2435
|
+
if (!spokeOft) {
|
|
2436
|
+
return { chainId: spokeChainId, balance: 0n, rawBalance: 0n };
|
|
2437
|
+
}
|
|
2426
2438
|
const [rawBalance, spokeOftDecimals] = await spokeClient.multicall({
|
|
2427
2439
|
contracts: [
|
|
2428
2440
|
{ address: spokeOft, abi: ERC20_ABI, functionName: "balanceOf", args: [u] },
|