Get solution

Get solution on Plug

Ethereum
Ethereum
Base
Base

Acts onchain

Ready to run on Base

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.

Plug lets you combine onchain actions like this one into a single transaction, without writing a smart contract. Use in App opens a new plug with this action already in it.

Takes nothing — it reads the caller's own position.

Rebalance Holdings to Target

plug
values
evm
23actions
  1. 1·Take

    Take opens by declaring holder_wallet as a caller parameter, the address whose token balances this run reads and transfers from.

  2. 2·Take

    Next, count is declared as a caller parameter, the number of registered tokens the two loops iterate over.

  3. 3·Use

    Composing the Get Total Holdings Value plug pulls in its valuation logic, computing the wallet's aggregate holdings across the token set.

  4. 4·Get address

    The Solver is held here as a named value, standing ready as the destination for the transfers that follow.

  5. 5·Set

    Setting index to 0 initializes the loop counter for the first pass.

  6. 6·Predicate

    A for loop opens, running while index is less than count so it visits every registered token once.

  7. 7·Read map value

    Reading the map value at index in the tokens map of socket storage pulls the token registered at that slot.

  8. 8·Set

    That looked-up token is written into the variable token so the next steps reference it by name.

  9. 9·Get token balance

    Using token, the balance held by holder_wallet is read, capturing what the wallet holds of this token.

  10. 10·Transfer tokens

    Transferring that read balance of token to the solver moves the wallet's holding out for routing.

  11. 11·Calculate

    Adding 1 to index advances the loop counter.

  12. 12·Set

    The incremented value is written back into index, closing the loop step.

  13. 13·End block

    Closing the innermost open block ends the transfer loop.

  14. 14·Get solution

    Handing the transferred tokens to the solver runs the routing and verifies the outcome.

  15. 15·Set

    Resetting index to 0 prepares the counter for the verification pass.

  16. 16·Predicate

    A second for loop opens, running while index is less than count so it checks every token again.

  17. 17·Use

    Composing the Get Token Target plug returns the token at this index alongside its target amount.

  18. 18·Get token balance

    Using that returned token, the balance held by holder_wallet is read after routing.

  19. 19·Predicate

    Requiring the post-routing balance be greater than or equal to the token's target enforces that each holding reached its goal.

  20. 20·Calculate

    Adding 1 to index advances the verification counter.

  21. 21·Set

    The incremented value is written back into index.

  22. 22·End block

    Closing the innermost open block ends the verification loop.

  23. 23·End block

    Closing the remaining open block completes the composed rebalance transaction.

Take
Take
Use where
holder_walletis
countis
Get
Set to
Read map value of in in
Set to
Get balance of held by
Transfer to
Calculate
Set to
End block
Get solution
Set to
Use where
indexis
total_valueis
Get balance of held by
Calculate
Set to
End block
End block

More plugs on Base

Borrow on Base · 7 plugs

Earn yield on Base · 12 plugs

Stake on Base · 9 plugs

Provide liquidity on Base · 6 plugs

Dollar-cost average on Base · 4 plugs

Posts · 4

More on Plug · 6