
Plug · Acts onchain
Hands tokens already transferred to the solver over for routing, then verifies the outcome. The action opens a block. The solver's route settles inside it, and the steps between this and its End block are the acceptance checks: read balances, compare against your targets, and require the outcome you signed for. The transaction only completes when every check passes. Reach for it when the swap action's fixed shape does not fit, such as multi-token inputs or custom acceptance logic, and you want the solver's execution bounded by your own reads.
Takes nothing — it reads the caller's own position.
Rebalance Holdings to Target



1·Take
The caller supplies holder_wallet, a named parameter naming the wallet whose holdings this plug rebalances at execution time.
2·Take
Next count is declared as a caller parameter, setting how many tokens the loops iterate over.
3·Use
Composing the Get Total Holdings Value plug pulls its valuation logic into this transaction.
4·Get address
The Solver is held here as a named value, standing ready as the destination for the transfers that follow.
5·Set
Setting index to 0 initializes the loop counter for the first pass.
6·Predicate
A loop opens while index is less than count, iterating once per token in the set.
7·Read map value
Reading the map value at index in the tokens map of socket storage pulls the token registered at this position.
8·Set
That map value is written into the variable token, so the balance and transfer steps reference this entry by name.
9·Get token balance
Using token, the balance held by holder_wallet is read, capturing what the wallet holds of this token.
10·Transfer tokens
Transferring that read balance of token to the solver moves the full holding out for routing.
11·Calculate
Adding 1 to index advances the counter.
12·Set
Writing that sum back into index sets up the next iteration.
13·End block
Ending the loop block closes the first pass over the token set.
14·Get solution
Handing the transferred tokens to the solver runs the routing and verifies the outcome.
15·Set
Resetting index to 0 restarts the counter for a second pass.
16·Predicate
A loop opens again while index is less than count, iterating once per token to check targets.
17·Use
Composing the Get Token Target plug resolves the target for the token at this index.
18·Get token balance
Using the token from the target result, the balance held by holder_wallet is read after routing.
19·Predicate
A require enforces that the post-routing balance is greater than or equal to the token's target, reverting otherwise.
20·Calculate
Adding 1 to index advances the counter.
21·Set
Writing that sum back into index sets up the next check.
22·End block
Ending the inner loop block closes the target-verification pass.
23·End block
Closing the remaining open block completes the composed rebalance transaction.