> ## Documentation Index
> Fetch the complete documentation index at: https://pessoal-86816071.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Off-chain Architecture

> How the solver, adapters, Ranger runtime, manifests, and operator CLIs work together.

# Off-chain Architecture

The off-chain stack is where most of the operational intelligence lives.

## Shared layer

`services/shared/` provides:

* domain types
* sample registry and live snapshot config
* math helpers
* deterministic hashing
* `.env` loading
* execution step helpers

This layer keeps solver, adapters, and Ranger aligned on a single type system.

## Adapters

`services/adapters/` exposes a common `StrategyAdapter` interface for all strategies.

### Current adapter types

* `DriftStrategyAdapter`
* `KaminoStrategyAdapter`
* `ManifestStrategyAdapter`
* `StaticStrategyAdapter`

### Why adapters matter

The solver should not care whether a strategy uses:

* direct SDK instructions
* pre-authored instruction manifests
* static placeholders during development

Adapters normalize all of those into `ExecutionStep` objects.

## Solver

`services/solver/` builds a deterministic rebalance plan.

The solver:

* consumes snapshots and policy constraints
* computes expected net APY and haircuts
* ranks strategies
* assigns target weights within limits
* builds execution steps using the adapter catalog
* hashes the plan, target weights, and transaction bundle

## Ranger

`services/ranger/` is the execution runtime.

It is responsible for:

* loading signers
* building Solana connections
* preparing vault instructions
* sending protocol instruction bundles
* persisting rebalance proofs through the vault program client

## Manifest path for partially integrated protocols

`MarginFi` and `Perena` use a bridge layer:

* if a manifest exists, Ranger can execute the provided raw envelopes
* if no manifest exists, the adapter falls back to a static placeholder step

This lets the system evolve incrementally without changing the solver contract.

## Operator CLIs

The repo includes CLIs for:

* diagnostics
* protocol smoke tests
* direct Drift send
* vault bootstrap
* vault administration
* vault user actions
* vault state inspection
