Prepare supply / borrow / withdraw / repay
prepare_actionBuild an unsigned transaction to supply, borrow, withdraw, or repay on Aave (v3 or v4). Returns an execution plan (a transaction to sign, or an approval step first). Non-custodial: the user's wallet signs and submits; nothing is sent here, so building one is free and commits the user to nothing. Choose sensible values, build it, and say what you chose - do not stop to ask the user first, because they see the transaction before they sign it. Send only the arguments that apply and leave every other one out: v4 takes 'reserve'; v3 takes 'market' + 'token' + 'chainId'; 'max' is for withdraw and repay; 'enableCollateral' is for supply. Never send 'permitSignature' or 'permitDeadline' on a first call: they exist only to re-issue a call after an approval step handed you a permit to sign under 'bySignature', so if you have not been handed one, leave both out. Two things that catch callers out: a supply does NOT become collateral unless you pass enableCollateral:true, and without collateral the borrowing power is zero so any later borrow is refused; and collateral pinned by an open borrow cannot be withdrawn, so a withdraw has to repay first. After sending any transaction, poll get_transaction_processed before building the dependent next one.
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 | Which action to build. | |
| 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. | |
| 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 | Yes | Protocol version (v3 or v4; required, no 'all' for actions). | |
| permitDeadline | No | Unix seconds, the 'deadline' from the permit message that was signed. Required with permitSignature. | |
| permitSignature | No | Send this only to replay a call after an approval handed you a permit to sign: the user's signature (0x...) over the PermitTypedData that approval carried under 'bySignature', on either version. It replaces the approval transaction, so the action comes back in one step. Requires permitDeadline. | |
| enableCollateral | No | supply only: also enable the asset as collateral (default false). Leave it off and the supply earns yield but backs no borrowing, so a following borrow fails for exceeding a borrowing power of zero. Pass true whenever the plan is to borrow against it. |