Yield Math

Why not standard Solidity Math?

circle-info

Calculating compound interest requires exponential formulas ($A = P(1+r)^t$). In Solidity, this is notoriously difficult and gas-expensive because the EVM does not support floating-point numbers natively.

LegacyVault leverages Rust's computational efficiency to solve this using an Iterative Approach.

The Iterative Algorithm

Instead of an estimation, we run a precise loop for every day that has passed.

The Logic:

Balancenew=Balanceold×101100\text{Balance}_{new} = \text{Balance}_{old} \times \frac{101}{100}

(Repeated $N$ times, where $N$ is days elapsed)

Rust Implementation:

lending-pool/src/lib.rs
let mut current_value = principal;
// Iterate for every day elapsed
for _ in 0..days {
    // 1% daily growth
    current_value = (current_value * 101) / 100;
}