Prepare enable/disable collateral
prepare_set_collateralBuild an unsigned transaction to change whether a supplied asset is used as collateral (v3 or v4). On v4 'enable' sets the state; on v3 it toggles the current state, and a toggle that would invert a stated 'enable' is refused. The wallet must already hold a supply in that reserve: this sets a flag on it, nothing moves. Disabling can leave a position liquidatable, so it is simulated first: a health factor under 1 after is refused, just above 1 carries a warning to relay, and a build whose simulation could not run says so under 'warnings'. Enabling needs no check. Non-custodial.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | No | v3 only: underlying token address. | |
| enable | No | v4: true to enable, false to disable (default true). v3 toggles the current state; send it on v3 as the intended end state, and a toggle that would produce the opposite is refused. | |
| market | No | v3 only: market pool address. | |
| 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. |