# Direct Wallet & Guardrails (Mode A)

**Mode A (`Direct Wallet`)** lets you keep native **Morpho Blue `supplyShares`** directly on your own Ethereum address while optionally enabling automated yield rebalancing through the immutable **`MorfaRebalancer`** contract ([`0x2135195643CCC32513Da3baDC6394FbaB8Fb9cfA`](https://etherscan.io/address/0x2135195643CCC32513Da3baDC6394FbaB8Fb9cfA#code)).

## Existing Morpho Blue Positions

If your wallet already holds USDC supply positions on Morpho Blue, **you do not need to withdraw them**. When you connect your wallet on [`morfa.finance/portfolio`](https://morfa.finance/portfolio) and select **Direct Wallet**, Morfa automatically detects your existing Morpho Blue USDC supply positions.

:::danger[Open Morpho Blue Borrows or Collateral Warning]
Enabling Mode A automation requires granting **`Morpho.setAuthorization(rebalancer, true)`**, which is a **wallet-wide** permission inside Morpho Blue. Although `MorfaRebalancer.sol` is immutable and contains no `borrow` or `withdrawCollateral` code paths, Morfa automatically scans your address for any open Morpho Blue borrow or collateral positions and displays a prominent warning if any are found.

If you actively borrow on Morpho Blue, **use a dedicated wallet for Mode A** or deposit into **Mode B (`Morfa Vault`)**, which requires zero `setAuthorization`. Read [Morpho Authorization Scope (Mode A)](/security/authorization-scope) before opting in.
:::

## Supplying & Withdrawing Directly on Morpho Blue

Mode A gives you direct access to risk-eligible Ethereum Mainnet USDC markets on Morpho Blue:

* **Curated tags:** Markets curated for Morfa carry a curated indicator, and every market row displays live **6h Native APY**, **6h Merkl APR**, **Utilization**, **LLTV**, free liquidity, and a direct **Oracle Etherscan link**.
* **Direct execution:** Supplies and withdrawals execute via `@morpho-org/morpho-sdk` (`BlueBundlesV1`) with pre-flight `eth_call` simulation and a 1-hour plan deadline.
* **Partial or zero-dust exit:** Withdraw an exact USDC amount or withdraw 100% of your `supplyShares` from a market to leave zero dust.
* **Recommended threshold for automation:** You can manually supply any USDC amount into Morpho Blue, while **`≥ 100 USDC`** is recommended to qualify for keeper-subsidized automated rebalancing.

***

## Personal On-Chain Guardrails

Before enabling automation, you configure three strict per-wallet limits stored on-chain in `MorfaRebalancer.sol`. The keeper **cannot** execute a rebalance that violates any of these limits; the smart contract reverts the transaction on-chain.

| Parameter | Editable UI Default | On-Chain Bounds | What It Protects Against |
| --- | --- | --- | --- |
| **`maxFeeBps`** | `5 bps` (`0.05%`) | `0` to `100 bps` (`1.00%`) | Prevents any rebalance if the protocol's active rebalance fee exceeds your chosen ceiling. |
| **`cooldown`** | `21,600s` (`6 hours`) | Any `uint32` seconds | Prevents overly frequent back-and-forth rebalancing on your wallet. |
| **`periodFeeCap`** | `25 USDC` | Any `uint128` USDC (6 dec) | Caps total rebalance fees deducted from your wallet over each resetting **30-day** period (`FEE_PERIOD_DURATION`). |

:::info[Updating Guardrails Never Resets Your Spent Fee Counter]
Calling `setConfig(...)` to adjust your guardrails preserves your existing 30-day `periodFeeSpent`, `periodStart`, `lastRebalanceAt`, and `nonce`. You can raise, lower, or pause automation at any time without opening a loophole.
:::

## Enabling Automation

### EOA Wallets (`enableWithSig`: 1 Signature + 1 Transaction)

For standard EOA wallets, Morfa streamlines onboarding into a single atomic transaction:

1. Open the **Direct Wallet → Advanced** guardrails form, adjust `maxFeeBps`, `cooldown`, and `periodFeeCap` if desired, and click **Enable Automation**.
2. Sign one off-chain **EIP-712 Morpho `Authorization`** message authorizing `MorfaRebalancer` on Morpho Blue.
3. Send one **`MorfaRebalancer.enableWithSig(...)`** transaction. The contract atomically submits your authorization to Morpho Blue and saves your personal guardrail config in the same transaction.

`enableWithSig` is designed to be resilient against mempool front-running (if someone submits your Morpho authorization early, `enableWithSig` detects that you are already authorized and still completes your config update) and prevents replay after revocation by checking Morpho's live authorization nonce.

### Smart Accounts (2-Step Flow)

Because Smart Accounts use EIP-1271 signatures rather than Morpho's EOA `setAuthorizationWithSig`, Morfa automatically switches Smart Accounts to a clean two-step sequence:

1. `Morpho.setAuthorization(rebalancer, true)` (skipped automatically if already authorized).
2. `MorfaRebalancer.setConfig(true, maxFeeBps, cooldown, periodFeeCap)`.

***

## How Automated Rebalancing Works on Your Wallet

Once enabled, Morfa's keeper indexes your opt-in configuration, monitors your USDC supply positions against active whitelisted markets, and moves your largest non-optimal position into the best active market only when:

* The expected net yield improvement clears fees and a conservative safety margin after modeling post-move interest rate impact.
* Every on-chain guardrail (`maxFeeBps`, `cooldown`, 30-day `periodFeeCap`, target pre-supply TVL `≥ 100,000 USDC`, pre-supply utilization `≤ 95%`, and `≤ 2 wei` rounding tolerance) passes.
* Each move withdraws **100% of your shares** in the source market so you do not accumulate fragmented dust positions across multiple markets.

If a market holding your USDC is placed into **`WithdrawOnly`** emergency status by Admin or Sentinel, emergency evacuations out of that market incur **`0 bps` (fee-free)** and bypass your `cooldown` on-chain.

## Disabling Automation & Revoking Permissions

You retain two independent, always-available off-switches, both working **even if `MorfaRebalancer` is paused**:

1. **One-click pause (`MorfaRebalancer.disable()`):** Sets `enabled = false` and increments your on-chain `configVersion`, immediately blocking any queued keeper rebalance for your address.
2. **Protocol-level revoke (`Morpho.setAuthorization(rebalancer, false)`):** Removes `MorfaRebalancer`'s authorization directly inside immutable Morpho Blue. You can execute this from `morfa.finance`, [Morpho App](https://app.morpho.org/), or Etherscan at any time.
