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 'reserve'; v3 takes 'market' + 'token' + 'chainId'; 'max' is for withdraw and repay; 'native' works on both; 'enableCollateral' is v4 only. What comes back differs by version, because the two protocols offer different amounts of it: v4 returns the resulting health factor, net APY, borrowing power and rewards; v3 returns the health factor before and after, 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-prefixed (40 hex chars). | |
| chainId | No | v3 only: chain id (positive integer). | |
| reserve | 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. 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. | |
| version | No | Optional: inferred from the reserve selector ('reserve' means v3 is not being used, 'market'+'token'+'chainId' means v4 is not). Send it to be explicit, or if you somehow set both. | |
| enableCollateral | No | v4 supply only: also enable as collateral. |