@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.
- 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 +27 -6
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +1 -13
- package/dist/viem/index.d.ts +1 -13
- package/dist/viem/index.js +27 -6
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/crossChainFlows.ts +24 -2
- package/src/viem/userHelpers.ts +18 -6
package/package.json
CHANGED
|
@@ -766,12 +766,18 @@ export async function quoteComposeFee(
|
|
|
766
766
|
* @param fee ETH to send (from quoteComposeFee). Covers readFee for D7.
|
|
767
767
|
* @returns Transaction hash of the compose execution
|
|
768
768
|
*/
|
|
769
|
+
/**
|
|
770
|
+
* Event topic0 emitted by the escrow when initVaultActionRequest creates a new request.
|
|
771
|
+
* topic1 = GUID (bytes32). Used to extract the async request GUID from executeCompose receipts.
|
|
772
|
+
*/
|
|
773
|
+
const ESCROW_REQUEST_TOPIC = '0x304ac8b57de34b9e6118fb049ba362689cfcfab98c30c9d78e3e2e14be7e0972' as const
|
|
774
|
+
|
|
769
775
|
export async function executeCompose(
|
|
770
776
|
walletClient: WalletClient,
|
|
771
777
|
hubPublicClient: PublicClient,
|
|
772
778
|
composeData: ComposeData,
|
|
773
779
|
fee: bigint,
|
|
774
|
-
): Promise<{ txHash: Hash }> {
|
|
780
|
+
): Promise<{ txHash: Hash; guid?: `0x${string}` }> {
|
|
775
781
|
const account = walletClient.account!
|
|
776
782
|
const endpoint = getAddress(composeData.endpoint)
|
|
777
783
|
|
|
@@ -811,5 +817,21 @@ export async function executeCompose(
|
|
|
811
817
|
gas: 5_000_000n, // initVaultActionRequest + LZ Read is gas-heavy
|
|
812
818
|
})
|
|
813
819
|
|
|
814
|
-
|
|
820
|
+
// Parse the GUID from the escrow's event in the TX receipt.
|
|
821
|
+
// The composer calls initVaultActionRequest internally, which emits an event
|
|
822
|
+
// with topic1 = GUID. We need this GUID to poll finalization via waitForAsyncRequest.
|
|
823
|
+
let guid: `0x${string}` | undefined
|
|
824
|
+
try {
|
|
825
|
+
const receipt = await hubPublicClient.waitForTransactionReceipt({ hash: txHash, timeout: 60_000 })
|
|
826
|
+
for (const log of receipt.logs) {
|
|
827
|
+
if (log.topics[0] === ESCROW_REQUEST_TOPIC && log.topics[1]) {
|
|
828
|
+
guid = log.topics[1] as `0x${string}`
|
|
829
|
+
break
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
} catch {
|
|
833
|
+
// Receipt timeout — guid will be undefined, caller can still poll by balance
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
return { txHash, guid }
|
|
815
837
|
}
|
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 }
|