> For the complete documentation index, see [llms.txt](https://gremlix.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gremlix.gitbook.io/docs/protocol/contracts/strategy.md).

# Strategy

## Overview

The `Strategy` contract is the bridge between the Gremlix vault and the external Contracts / Hot Wallets. Each vault can have one or more strategy contracts.

## Responsibilities

1. **Hold deployed capital** — Assets allocated by the vault are held by the strategy contract
2. **Report current value** — The strategy tracks `totalTrackedAssets()`, the current real value of all deployed capital including unrealized PnL
3. **Accept deposits from vault** — `deposit(amount)` is called by the Keeper when allocating
4. **Return assets to vault** — `withdraw(amount)` is called by the Keeper when deallocating
5. **Allow keeper value updates** — `updateTotalTrackedAssets(newValue)` lets the Keeper report real-world PnL from off-chain strategy positions

## Interface

```solidity
interface IStrategy {
    // Current total value of strategy assets (including off-chain PnL)
    function totalTrackedAssets() external view returns (uint256);

    // Receive assets from vault (called on allocation)
    function deposit(uint256 amount) external;

    // Send assets back to vault (called on deallocation)
    function withdraw(uint256 amount) external;

    // Keeper updates the tracked value after reconciliation
    function updateTotalTrackedAssets(uint256 newValue) external;

    // Underlying asset address
    function asset() external view returns (address);

    // Associated vault address
    function vault() external view returns (address);
}
```

## Staleness Protection

Each strategy tracks the timestamp of the last value update. If the vault's `harvestStalenessWindow` has passed since the last update, the harvest will revert — preventing recognition of stale yield that hasn't been recently verified.

```
lastUpdated = timestamp of last updateTotalTrackedAssets() call
harvestStalenessWindow = max allowed gap (e.g., 24 hours)

if (block.timestamp - lastUpdated > harvestStalenessWindow):
    revert("stale strategy value")
```

## Multiple Strategies per Vault

A vault can deploy capital across multiple strategy contracts. Each strategy is tracked independently, and harvest is called per-strategy. This allows:

* Running strategies on multiple DEXs simultaneously
* Different risk profiles per strategy
* Gradual capital migration between strategies

## Strategy Deployment

Strategies are deployed by the protocol team and registered with the vault via the Keeper. Users interact only with the vault — strategy details are abstracted away.
