@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/README.md +23 -8
- package/dist/react/index.cjs +14 -5
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +14 -5
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +14 -5
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.js +14 -5
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/userHelpers.ts +18 -6
package/package.json
CHANGED
package/src/viem/userHelpers.ts
CHANGED
|
@@ -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
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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 }
|