> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mystacks.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Execution and rebalancing

> How MyStacks connects portfolio decisions to authorised trades in each user's account.

The initial execution model uses direct swaps from each user's smart account.
MyStacks coordinates the transaction for that account.
The assets and swap proceeds remain associated with the user portfolio.

## From a portfolio decision to a trade

<Steps>
  <Step title="Prepare the rebalance">
    The intended workflow uses the manager's saved allocation at the next
    applicable schedule boundary. MyStacks determines the trades needed for each
    user's holdings. This portfolio planning layer is still being built.
  </Step>

  <Step title="Request a swap quote">
    The routing layer obtains a quote through a supported swap aggregator. The
    quote supplies the transaction data needed to perform the swap.
  </Step>

  <Step title="Prepare the account calls">
    MyStacks prepares the approval and swap calls for the user's account. The
    execution must fit the account's delegated permission.
  </Step>

  <Step title="Sign and submit the execution">
    KMS signs the request using the session signing key. The MyStacks execution
    layer coordinates the authorised account calls. The selected execution path
    supports sponsored transactions.
  </Step>

  <Step title="Observe the result">
    The execution result and onchain receipts show whether the trade settled. A
    successful quote or submission alone does not mean the portfolio has
    changed.
  </Step>
</Steps>

## Routing and execution have different jobs

| Component                | Role in MyStacks                                                   |
| ------------------------ | ------------------------------------------------------------------ |
| Liquidity routing        | Sources swap quotes and route data.                                |
| MyStacks backend         | Prepares the requested execution and coordinates signing.          |
| Session signer           | Signs on behalf of the delegated session.                          |
| Execution layer          | Coordinates execution of the prepared account calls.               |
| User-owned smart account | Holds the assets and governs execution under the user's authority. |

The routing layer obtains quotes through supported swap aggregators.
The execution layer carries out the authorised trades in each user's account.

## What is still open?

The production rebalance service still needs its scheduling and operation lifecycle.
Detailed execution controls and the final account permissions remain under design.
The pricing and fee model for sponsored execution is still being defined.

The initial scope is individual account execution.
Shared settlement and internal trade netting are outside that scope.
This draft makes no guarantee that an entire portfolio rebalance is atomic.
