# Mamo

[Mamo](https://mamo.bot) is an automated yield strategy platform built on Base that uses Moonwell's lending markets as its primary yield source. Each user gets their own strategy contract that holds funds and earns yield - managed by the Mamo backend but fully owned by the user.

Mamo is a good example of what can be built on top of Moonwell: a complete product with its own brand, token, and user experience, powered by Moonwell's open lending infrastructure.

## How Mamo Uses Moonwell

Mamo strategies deposit user funds into two Moonwell primitives:

| Primitive                  | How Mamo Uses It                                                                                                      |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **mTokens** (Core Markets) | User USDC is supplied to Moonwell via `mToken.mint()`, earning lending yield. The strategy holds mUSDC.               |
| **MetaMorpho Vaults**      | A configurable split can route funds to Moonwell's MetaMorpho vaults for aggregated yield across Morpho Blue markets. |
| **Reward Compounding**     | Strategies accumulate WELL and MAMO rewards, swap them to the base asset, and re-deposit into the strategy.           |

## Architecture

```
User deposits USDC
        ↓
Strategy Factory deploys a personal proxy contract
        ↓
┌─────────────────────────────────────────────┐
│         User's Strategy Contract            │
│         (UUPS upgradeable proxy)            │
│                                             │
│  ┌──────────────┐    ┌───────────────────┐  │
│  │  Moonwell     │    │  MetaMorpho       │  │
│  │  mUSDC        │    │  Vault            │  │
│  │  (core yield) │    │  (aggregated      │  │
│  │               │    │   yield)          │  │
│  └──────────────┘    └───────────────────┘  │
│                                             │
│  Accumulated rewards: WELL, MAMO         │
└─────────────────────────────────────────────┘
        ↓
Mamo backend monitors + rebalances
        ↓
Bots swap rewards → USDC via CowSwap
        ↓
Compounded back into strategy
```

## Moonwell Primitives Used

### 1. mToken Supply (Core Yield)

Each strategy contract supplies USDC to Moonwell's core lending market by calling `mToken.mint()`. The mUSDC held by the strategy earns lending interest as the exchange rate grows over time.

```solidity
// Simplified - what Mamo's strategy does under the hood
EIP20Interface(usdc).approve(address(mUSDC), amount);
uint err = MErc20(mUSDC).mint(amount);
```

The strategy can also withdraw via `mToken.redeemUnderlying()` when users request their funds back.

### 2. MetaMorpho Vault (Aggregated Yield)

Mamo can split deposits between the mToken market and a MetaMorpho vault. The split ratio is configurable - the backend adjusts it dynamically based on where yield is higher.

```solidity
// Configurable split between Moonwell core and MetaMorpho
// splitMToken + splitVault = 10000 bps (100%)
uint mTokenAmount = (depositAmount * splitMToken) / 10000;
uint vaultAmount = (depositAmount * splitVault) / 10000;
```

### 3. Reward Claiming and Compounding

Strategies accumulate reward tokens (ie WELL, MAMO). Bots periodically claim these rewards, swap them to the base asset, and re-deposit into the strategy - compounding yield automatically.

## Key Design Patterns

These patterns from Mamo's architecture are reusable for any product built on Moonwell:

**Per-user strategy contracts** - Each user gets an isolated proxy contract. This avoids pooling risk and gives users direct ownership of their position. The factory pattern (one factory deploys many proxies) makes this scalable.

**Configurable protocol splits** - Rather than committing to a single yield source, the strategy can dynamically allocate between Moonwell core markets and MetaMorpho vaults based on where yield is highest.

**Automated reward compounding** - Reward tokens (WELL, MAMO) are claimed, swapped to the base asset, and re-deposited - all without user intervention.

**Backend manages, user owns** - The Mamo backend can rebalance positions and trigger reward claims, but cannot withdraw user funds. Users retain full custody through contract ownership.

## Deployed Contracts (Base)

| Contract                     | Address                                                                                                                 |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| Strategy Registry            | [`0x46a5624C2ba92c08aBA4B206297052EDf14baa92`](https://basescan.org/address/0x46a5624C2ba92c08aBA4B206297052EDf14baa92) |
| Strategy Implementation (V2) | [`0x6C8577fa9B10807f7485f6476C2AFE0B8d61D1e7`](https://basescan.org/address/0x6C8577fa9B10807f7485f6476C2AFE0B8d61D1e7) |
| USDC Strategy Factory        | [`0x3098360e627E84Fb9dD621F01ea03E325cCEE2c6`](https://basescan.org/address/0x3098360e627E84Fb9dD621F01ea03E325cCEE2c6) |
| cbBTC Strategy Factory       | [`0xf8CFdEf5068929e022a50315983043b61E9987f8`](https://basescan.org/address/0xf8CFdEf5068929e022a50315983043b61E9987f8) |
| WETH Strategy Factory        | [`0x14bA47Ef0286B345E2B74d26243767268290eE28`](https://basescan.org/address/0x14bA47Ef0286B345E2B74d26243767268290eE28) |

## Learn More

For full Mamo developer documentation, see the [Mamo Docs](https://github.com/moonwell-fi/mamodocs).

To build a similar integration, start with the [Core Market Integration Guide](https://docs.moonwell.fi/moonwell/developers/guides/core-market-integration) and [Vault Integration Guide](https://docs.moonwell.fi/moonwell/developers/guides/vault-integration).
