Hermes is our off-chain yield optimizer (keeper) program, designed to dynamically allocate liquidity across lending platforms for optimal yield while managing risk. Below, we break down its algorithmic approach and the rationale behind each step.


How Hermes Optimizes Yield

Key Factors Affecting APR

Amount Borrowed

Higher utilization (more borrowed) increases APR for depositors.

Amount Deposited

More deposits dilute the APR, as interest is shared among more depositors.

Interest Rate Model

Each platform’s model determines how APR changes with utilization.


Step-by-Step: Optimal Allocation Algorithm

1

1. Divide Liquidity into Portions

Liquidity is split into small portions (e.g., 100+), configurable by admin.

2

2. Simulate Deposits Across Platforms

For each portion, simulate depositing it into every lending platform and calculate the resulting APR.

3

3. Select Highest APR

Assign the portion to the platform offering the highest simulated APR.

4

4. Update Simulated Allocations

Update the simulated allocation and repeat until all liquidity is distributed.

5

5. Compare to Previous Allocation

If the new allocation differs from the previous by more than 0.1%, trigger a rebalance.


Pseudocode

#Off chain simulation
portion ← x #x is minimally 100, set by admin
deposit_amount ← vault.total_amount / portion
last_allocation[] ← current allocation of vault.total_amount in each lending platform
allocation[] ← track allocation after simulation to each lending platform
FOR each portion
    FOR each platform
        Simulate deposit_amount to platform
        APR[platform] ← APR of platform after simulated deposit
    ENDFOR
    highest_APR_platform ← Select platform with the highest APR in APR[platform]
    allocation[highest_APR_platform] ← deposit_amount + allocation[highest_APR_platform]
    Update deposit_amount to platform
ENDFOR
#On Chain Rebalance crank
IF diff(allocation[], last_allocation[]) > 0.1% THEN
    Send rebalance crank to allocate funds according to allocation[]
ENDIF