@oydual31/more-vaults-sdk 0.2.6 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oydual31/more-vaults-sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "TypeScript SDK for MoreVaults protocol — viem/wagmi and ethers.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -625,17 +625,29 @@ export async function getUserPositionMultiChain(
625
625
  return { chainId: spokeChainId, balance: 0n }
626
626
  }
627
627
 
628
- // Read balance on spoke chain
628
+ // Read balance + decimals on spoke chain
629
629
  const spokeClient = createChainClient(spokeChainId)
630
630
  if (!spokeClient) return { chainId: spokeChainId, balance: 0n }
631
631
 
632
- const balance = await (spokeClient as PublicClient).readContract({
633
- address: spokeOft,
634
- abi: ERC20_ABI,
635
- functionName: 'balanceOf',
636
- args: [u],
632
+ const [rawBalance, spokeOftDecimals] = await (spokeClient as PublicClient).multicall({
633
+ contracts: [
634
+ { address: spokeOft, abi: ERC20_ABI, functionName: 'balanceOf', args: [u] },
635
+ { address: spokeOft, abi: METADATA_ABI, functionName: 'decimals' },
636
+ ],
637
+ allowFailure: false,
637
638
  })
638
639
 
640
+ // Normalize SHARE_OFT balance to vault decimals
641
+ // Spoke OFTs may use different decimals (e.g. 18) than the vault shares (e.g. 8)
642
+ let balance: bigint
643
+ if (spokeOftDecimals > decimals) {
644
+ balance = rawBalance / (10n ** BigInt(spokeOftDecimals - decimals))
645
+ } else if (spokeOftDecimals < decimals) {
646
+ balance = rawBalance * (10n ** BigInt(decimals - spokeOftDecimals))
647
+ } else {
648
+ balance = rawBalance
649
+ }
650
+
639
651
  return { chainId: spokeChainId, balance }
640
652
  } catch {
641
653
  return { chainId: spokeChainId, balance: 0n }