@oydual31/more-vaults-sdk 0.2.5 → 0.2.7

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.
@@ -1808,12 +1808,21 @@ async function getUserPositionMultiChain(vault, user) {
1808
1808
  }
1809
1809
  const spokeClient = createChainClient(spokeChainId);
1810
1810
  if (!spokeClient) return { chainId: spokeChainId, balance: 0n };
1811
- const balance = await spokeClient.readContract({
1812
- address: spokeOft,
1813
- abi: ERC20_ABI,
1814
- functionName: "balanceOf",
1815
- args: [u]
1811
+ const [rawBalance, spokeOftDecimals] = await spokeClient.multicall({
1812
+ contracts: [
1813
+ { address: spokeOft, abi: ERC20_ABI, functionName: "balanceOf", args: [u] },
1814
+ { address: spokeOft, abi: METADATA_ABI, functionName: "decimals" }
1815
+ ],
1816
+ allowFailure: false
1816
1817
  });
1818
+ let balance;
1819
+ if (spokeOftDecimals > decimals) {
1820
+ balance = rawBalance / 10n ** BigInt(spokeOftDecimals - decimals);
1821
+ } else if (spokeOftDecimals < decimals) {
1822
+ balance = rawBalance * 10n ** BigInt(decimals - spokeOftDecimals);
1823
+ } else {
1824
+ balance = rawBalance;
1825
+ }
1817
1826
  return { chainId: spokeChainId, balance };
1818
1827
  } catch {
1819
1828
  return { chainId: spokeChainId, balance: 0n };