Skip to main content
Any balance the execution proxy still holds when the flow ends stays there unless the flow moves it. Ops that deliver to a recipient move their own output. The flow epilogue, or its shorthand run.sweepTo, moves the rest.

Terminal resources

A resource is terminal when no op in the flow consumes it; see Resource Model. Every terminal appears in the response’s outputs with role: "terminal", an owner and a delivery. An unspent resource input is reported under the key input.<name>.

The flow epilogue

The epilogue is an optional top-level Flow field. Its transfers run after the last node:
  • Named forwards. Each entry in forwards moves the proxy’s whole balance of one resource to its to address, and the response reports the amount the simulation measured. Name each resource at most once; it must be on the flow’s chain, and the native coin is { "kind": "native", "chainId": … }.
  • Remainder. remainder moves the whole proxy balance of every other token that is a proxy-held terminal of this flow. It does not touch tokens the flow never produced as a terminal, and a remainder with nothing to move does nothing.
  • Targets. to and remainder take a literal address or { "$ref": "context.sender" }. No other ref is accepted.
An epilogue needs forwards, remainder, or both. It never moves terminals delivered to a recipient or terminals that arrive later.

Set the epilogue from the SDK

The flow builder has no epilogue method. Build the request with sdk.request, add epilogue to the flow document, and send it with sdk.client.compile:
The swap’s WETH goes to 0x2222…2222. Any USDC the swap left unspent (its unspentIn output) goes back to the signer through the remainder.

sweepTo

run.sweepTo on the compile request is shorthand for epilogue.remainder. It takes the same targets:
  • builder.context.sender. Sweep to the transaction signer, as most flows do. On the wire it is { "$ref": "context.sender" }.
  • A literal address. Sweep to that address.
  • Omitted. No sweep. Terminal resources stay on the per-signer execution proxy, for example to accumulate a balance across several submissions.
A request with both run.sweepTo and flow.epilogue is rejected with a validation_error at run.sweepTo. To deliver one token to a third party, use an op’s recipient or a named epilogue forward instead of sweeping everything there. The sweep moves every proxy-held terminal that is available now. It does not move resources another op consumes, terminals delivered to a recipient, terminals that arrive later, or handles. An op that does not spend all of its input reports the rest as its own output, for example lifi.swap’s unspentIn, and the sweep moves it if nothing binds it. A core.split relies on this to keep part of an input: with config: { bps: 8000 }, bind only its a handle to a swap, and the sweep returns the unbound 20% (b) to the sender in the same transaction.

Non-transferable terminal resources

The remainder moves the whole balance of each terminal token on the proxy, and some balances cannot be transferred. The common case is aTokens or other collateral receipts that back an open debt: Aave reverts a transfer that would leave the position under-collateralised, so a remainder or sweepTo over such a balance makes the whole transaction revert.
When a flow deliberately leaves a position on the proxy, for example a borrow or leverage flow that keeps collateral in place, do not set a remainder or sweepTo. Move only the loose tokens: name them in epilogue.forwards, or read each with core.balanceOf (the owner defaults to the proxy) and move it with core.transfer:
core.transfer moves the whole amount it is bound to, and the recipient owns its transferred output.

Supplying input amounts

A resource input’s value in run.inputs is either a materialiser or a plain integer. A materialiser funds or measures the amount when the transaction runs: directDeposit pulls it from the signer, while balanceOf and call measure an amount that is already there or that a call produces. A plain integer says the proxy already holds that amount; nothing is pulled from the signer. See Wire runtime values and the materialisers catalog. Amounts that depend on an earlier step, such as the shares a vault deposit mints, are read onchain during the transaction. The only amounts fixed at compile time are provider quotes.

Amounts on the response

Every token output port has an entry in outputs, keyed <nodeId>.<port>, plus input.<name> for unspent inputs. The SDK decodes amounts to bigint. The compile response lists every response field; each outputs entry carries:
  • role: consumed (a later node, named in consumedBy, spends it) or terminal.
  • owner (terminal only): who holds the output after the flow. With sweepTo set to the signer, proxy-held terminals report the signer.
  • delivery (terminal only): { when: "now" }, or { when: "future", etaSeconds?, provider?, trackingId? } for an output that arrives later. See Future resources.
  • amount.estimate: the expected amount. basis: "simulated" when the simulation measured it, basis: "quoted" when it comes from a provider quote. Display it as “you will receive ≈ X”.
  • amount.minimum: the guaranteed floor, enforced onchain. basis says where it comes from: guard (a guard floor), op (the op’s own minimum, such as a swap’s minOut), input (an unspent input’s bound amount), or declared (a providesMinimum port’s estimate, used when no other floor exists). Display it as “you will receive at least X”.
An absent minimum means no floor exists. There is no zero placeholder: an unguarded split output reports only an estimate. When a guard floor and an op floor both exist, the larger wins; see Guaranteed minimums. On a 206 (allow-revert) response nothing was measured, so estimates are quoted and floors come only from ops and inputs. For a continuation.settle output, minimum is the minimum received, which the settlement contract checks onchain, and estimate is an expected outcome that is never enforced; see Cross-chain flows. The epilogue block on a 200 response reports each named forward with its resource, to and measured amount, and the resolved remainder address. The remainder itself is not measured; it shows up in outputs only as the new owner.

See also