# Overview

The Yieldex architecture is divided into three key modules:

1. Data Collection Module
2. Decision Making / Analytics Module
3. On-chain Interaction Module

<figure><img src="https://2052186243-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyOaUNxV79ihuG5umtWrZ%2Fuploads%2FElCSQAswKJK6pMv0lJTQ%2FYield%20pools.png?alt=media&#x26;token=1a923063-d4bd-4c80-a8f7-7013e26b803d" alt=""><figcaption></figcaption></figure>

### Data Collection Module

* Collects information about current APY/APR, TVL, availability, etc. from the protocols in different networks.&#x20;
* Store results in a database and periodically update (e.g., every 10 minutes).&#x20;

### Decision Making (Analytics) Module

* Receives grouped data on returns
* Calculates whether it makes financial sense to transfer funds: for example, from AAVE USDT (APY \~5%) to Compound USDT (APY \~8%).&#x20;
* Generates a "call to action" — a structure that specifies the network, protocol, token (USDT, USDC, etc.), quantity, and target return.&#x20;

### On-chain Interaction Module

* Accepts "call to action" and initiates transactions on users' smart wallets
* Uses ERC-4337 mechanics to securely aggregate transactions within a single "UserOperation".&#x20;
* Sets signing parameters, and uses session keys for limited actions (deposit/withdraw/borrow/repay).

### Sequence from Deposit to Rebalance

{% @mermaid/diagram content="sequenceDiagram
participant User as User (EOA)
participant SAcc as SmartAccount (ERC-4337)
participant DCM as DataCollection
participant DMM as DecisionMaking
participant OIM as OnChainInteraction
participant Protocol as Onchain Protocol
Note over User, SAcc: 1) activates Yieldex and grants permissions
User->>SAcc: Create smart account<br/>+ Setup session keys
SAcc-->>User: Done
Note over DCM, DMM: 2) Data collection and decision logic
DCM->>DMM: Yield/APY data
DMM->>DMM: Profit analysis (Delta\_Profit > threshold?)
alt Profit is significant
DMM->>OIM: Call to Action<br/> {operation: rebalance}
OIM->>SAcc: Transaction request<br/> deposit/withdraw
SAcc->>SAcc: Check session key
SAcc->>Protocol: re-deposit/withdraw
Protocol-->>SAcc: Done
SAcc-->>OIM: Transaction executed
else Small profit
DMM->>DMM: Skip
end" %}
