Plan a position from ETH or USDG, in one transaction
plan_buildPlans one transaction (two when paying in USDG: its approval first) from ETH or USDG to a ladder in a v4 pool of the token against the quote, and returns it unsigned. The sides the wallet's asset is not are bought in the chain's own pools inside the transaction, the ladder is built for the owner, and when the pair has no pool on LoomDesk's hook one is opened on the way. Use whenever the caller pays in ETH or USDG; it replaces plan_swap, plan_open_pool and plan_ladder together. Not for assets the wallet already holds (plan_ladder) or for an order at one price (plan_limit_order). Returns: transactions[] (to, data, value in wei, gas), check (simulated, ok, failedStep, reason, ethNeeded, ethHeld), sendWithin, ifItReverts, slippagePct, pool (which, or that it opens), priceNow, band, rungs, bought[] (each side, expected, atLeast, via), paid, fees, recentMovePct. Behavior: read-only on our side; nothing is signed or sent. The plan is laid out from the chain at this block and simulated from the owner; send it within check.sendWithin, and plan again rather than resend one that reverted. Costs quota units (agent_quota). Errors: refused when the amount does not cover the opening fee, the token has no pool against ETH or USDG to buy a side in, or the quote has no exit.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pool | No | A v4 pool id from ladder_pools to build in, on the hook or not; the quote is then that pool's. Left out: the token's pool against the quote, opened if none. | |
| owner | Yes | The wallet that signs, sends, and owns the ladder. | |
| payIn | Yes | What the wallet pays with. | |
| quote | Yes | What the token trades against: ETH, USDG, or the quote token's address. | |
| rungs | No | How many rungs across the band, 1 to 40; default 20. | |
| shape | No | Where the band puts the most: spot, curve, bidask, hybrid, or custom with weights. Default bidask. | |
| token | Yes | The token's address. | |
| amount | Yes | How much is paid, as a decimal string (for example "0.05"). | |
| copyOf | No | The id of a ladder on the current contract this one copies: its owner is paid 0.1% while it stays open in the same pair. | |
| feePct | No | The swap fee for a pool that has to be opened: 0.1, 0.5, or 1 to 5 (percent). Ignored when the pair already has a pool on the hook. | |
| lowPct | No | The band's bottom, percent from the price (negative). Needed unless fullRange. | |
| highPct | No | The band's top, percent from the price. Needed unless fullRange. | |
| weights | No | shape custom only: a relative height per rung, low price to high, any scale; stretched over the rungs built. | |
| referrer | No | The wallet that referred the owner: paid 0.1% of what goes in, out of the opening fee. | |
| fullRange | No | One position across every price instead of a band; lowPct and highPct are ignored. | |
| slippagePct | No | Room for the price to move, in percent. Left out: 1.5% on a calm token, more on one that has been moving, at most 10%. |