Why I built it
Managing leveraged Bitcoin by hand means watching moving-average crossovers around the clock, and acting late when a signal fires overnight. I wanted the timing automated without handing custody to a platform.
What it does
- Reads 20, 50 and 200-day moving averages and maps trend strength to five levels
- Each level sets a leverage target within the user’s risk tier: 1.1×, 1.3× or 1.5× at most
- Each user gets their own isolated vault contract, using Aave for collateral and borrowing
- Users can repay debt or withdraw at any time
How it’s built
A factory contract deploys one strategy contract per user. Rebalancing happens on-chain when the signal changes, with deposits kept separate from active collateral.
The hard part
Gas. Every rebalance touches Aave several times, and if it costs too much relative to the adjustment, the strategy eats its own returns. Cutting storage reads and batching calls kept it worthwhile.
Stack
SolidityTypeScriptAaveEVM