prepareWithdrawTxData to offer immediate redemptions. The custom hook handles transaction preparation, submission, and receipt tracking so UI components can focus on user experience.
Overview
- Fetch vault metadata (optionally cached with React Query or SWR).
- Prepare withdrawal calldata with slippage tolerance.
- Submit the transaction using wagmi’s
useWriteContract. - Surface transaction state with
useWaitForTransactionReceipt.
Prerequisites
- React 18+
- wagmi >= 2.0.0 and viem >= 2.0.0
- @paxoslabs/amplify-sdk installed and initialized (
initAmplifySDKcalled in a provider) - React Query (optional) for data fetching
- Connected wallet with vault shares to redeem
Withdrawal Hook
Component Usage
prepareWithdrawTxData throws APIError when liquidity is
unavailable or the vault is unsupported. Surface the endpoint and
statusCode fields so users understand why the operation failed.