Preview an action (simulate before executing)
preview_actionSimulate a supply/borrow/withdraw/repay against a wallet's position WITHOUT executing, on v3 or v4. Always do this before a borrow or a withdraw. Send only the arguments that apply: v4 takes 'reserveId'; v3 takes 'market' + 'token' + 'chainId'; 'max' is for withdraw and repay; 'native' works on both; 'enableCollateral' is v4 only. Both versions answer with 'healthFactorBefore' and 'healthFactorAfter'; v4 also returns net APY, risk premium, net collateral, net balance, projected earnings and both borrowing-power figures, each as a matching Before/After pair, plus 'rewardsAcquired' / 'rewardsAbandoned' when the action changes rewards. v3 has the two health factors and nothing else. Either version also returns 'warnings' when the action would not actually succeed - an error level there means the prepare step will refuse it, so fix the inputs rather than building it. Simulate first even when you intend to build immediately: this is the cheapest way to find out that an action cannot succeed, and it commits nothing. It reports the position's own limits and not token allowances, so a clean simulation says the position allows this, not that no approval step remains.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max | No | Withdraw/repay only: use the entire balance/debt. | |
| token | No | v3 only: underlying token address. | |
| action | Yes | Action to simulate. | |
| amount | No | Amount in MAIN units (e.g. '10.5'), never base units: 100000 base units of a 6-decimal token is '0.1', not '100'. Convert before sending if the user stated base units. Omit only if max=true. | |
| market | No | v3 only: market pool address, from a get_markets row in this session. It cannot be recalled: an Aave pool address you already recognise belongs to another deployment (v2, or another chain) and is rejected. | |
| native | No | Use the chain's native gas token instead of an ERC-20, on either version. Pass it whenever the action is in the native token, or the balance check below reads the wrapped ERC-20 balance and can refuse a supply that would work. | |
| sender | Yes | Sender wallet address (0x, 40 hex): the wallet that will sign, as the user named it in this session. If no wallet has been named, ask for it; never substitute a placeholder, which is rejected. | |
| chainId | No | v3 only: chain id (positive integer). | |
| version | No | Optional: inferred from the reserve selector ('reserveId' is v4, 'market'+'token'+'chainId' is v3). Send it to be explicit, or if you somehow set both. | |
| reserveId | No | v4 only: the opaque reserveId, copied verbatim from a get_markets row or a get_position_items item in this session (e.g. 'MTo6MHg5NGU3...Ojo1') - it cannot be constructed or recalled, so fetch one before the first call rather than after a refusal. For a withdraw or a repay take it from get_position_items for the position being acted on, not from get_markets: the same asset exists on several spokes, and the one this wallet supplied is the only one it can exit. The 'spokeId' from get_user_positions is NOT this: it is the same encoding one segment short, names the spoke rather than a reserve inside it, and is rejected. A token symbol such as 'USDC' is rejected too. | |
| enableCollateral | No | v4 supply only: also enable as collateral. |