Plan a limit buy or a limit sell
plan_limit_orderPlans an order at a price and returns the unsigned transactions. A limit sell holds the token in rungs over the price and sells as the price rises through them; a limit buy holds the quote under the price and buys as it falls. Use when the wallet wants to buy or sell at a price, not now; for a band around the price use plan_ladder or plan_build. Nothing is swapped at placing; the order earns the pool's fee while it fills; a part fill is not final (the rungs trade back if the price turns); by default the keeper closes it once the price has passed all the way through and pays what it holds. Returns: transactions[] (to, data, value in wei, gas), check (simulated, ok, failedStep, reason, ethNeeded, ethHeld), sendWithin, ifItReverts, slippagePct, the built prices, then (how to set the fill rule). 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 price is on the wrong side of the market, or when the pool's steps move the prices by more than 1% (the built prices are returned; ask for them, or set acceptBuilt).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pool | No | A pool id from ladder_pools. Left out: the token's default pool. | |
| side | Yes | sell: hold the token over the price and sell as it rises. buy: hold the quote under the price and buy as it falls. | |
| unit | No | What price and priceTo are in: usd (default) or quote (the pool's quote asset a token). | |
| owner | Yes | The wallet that signs, sends, and owns the order. | |
| price | Yes | The limit price: dollars a token, or the pool's quote asset a token when unit is "quote". A sell's lies over the price now, a buy's under it. | |
| rungs | No | A range (priceTo given) only: how many rungs, 1 to 40; default 5. | |
| shape | No | A range only: spot (even), curve (more where the order starts), bidask (more where it is complete). | |
| token | Yes | The token's address. | |
| amount | Yes | How much of the asset the order holds, as a decimal string: the token for a sell, the quote for a buy. | |
| copyOf | No | The id of a ladder on the current contract this order copies: its owner is paid 0.1% while it stays open in the same pair. | |
| priceTo | No | Where the order is complete, further from the market than price. Left out: one rung, the narrowest the pool has. | |
| referrer | No | The wallet that referred the owner: paid 0.1% of what goes in, out of the opening fee. | |
| payWithEth | No | A limit buy in a pool quoted in WETH: pay in plain ETH, wrapped inside the same transaction. Default: whenever the wallet holds less WETH than amount. | |
| acceptBuilt | No | Place it at the prices the pool can hold even when they lie more than 1% from the prices asked for. | |
| closeOnceFilled | No | Default true: the keeper closes the order once it is filled all the way through. The plan's `then` says how to set the rule once the order is placed. |