Build an Earn transaction
earn_buildBuild an Earn action for the key's wallet to sign: deposit, withdraw (USDG lent), borrow, repay, addCollateral, withdrawCollateral, revoke, multiply (leverage on a Stock Token in one transaction), repayWithCollateral (sell part of the collateral to repay, max to repay it all), vaultDeposit, vaultWithdraw. Same checks as trnch.fun/earn: listed markets and vaults only, Trnch max LTV, exact approvals, receiver is always the wallet. The Trnch fee (borrow, repay, Multiply) and the swap fee are in preview. Returns { calls, preview, chainId, from }: send calls in order from the key's wallet (chainId 4663); each was simulated on chain before being returned. Nothing is sent by Trnch. multiply and repayWithCollateral: send the calls as one atomic batch (EIP-5792) or, one by one, ALWAYS send the last call (it removes an approval), even if an earlier one failed. Requires an API key (created by wallet signature), sent as Authorization: Bearer .
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>"
},
"name": "earn_build"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault | No | Vault address, from earn_markets (vaults). | |
| action | Yes | ||
| amount | No | Amount in token units, or max; borrow also takes ltv:20|35|50|max. repayWithCollateral: collateral to sell. | |
| leverage | No | multiply: target leverage, 1.2 up to the Trnch cap, or max. | |
| marketId | No | Morpho market id, from earn_markets (marketId). | |
| collateral | No | borrow and multiply: collateral to supply, or wallet for the whole balance. |