# HolderVault

## Contract HolderVault

1. Created for each holder

2. Parameters:
- crypto asset
- stable
- aave pool
- risk module
- HF Low / Middle-Low / Middle-High / High

3. Operations

- borrow and invest (daily): 
1. Deploys crypto  
2. If HF > HF-High ==> Borrow to HF High
3. If HF < HF-Middle-High => Deinvest yield, repay up to HF High
4. Calculate premium - If > stable balance, deinvest yield.
5. Pay policy
6. Reinvest in yield remaining stable

- withdraw stable (amount)
1. Deinvest max(yield - borrow, amount)
2. Send to owner

- repay loan (amount)
1. Deinvest amount
2. Repay amount

- withdraw crypto (amount)
1. Withdraw crypto (amount)
2. If HF < HF-High => Deinvest yield, repay up to HF High

- withdraw all
1. Deinvest all yield 
2. Repay loan
3. Withdraw all crypto to owner
4. Send remaining stable to owner


## Contract LiquidationProtectionRiskModule 

pricePolicy(customer, hfLow, hfSafe, duration)
newPolicy(customer (msg.sender), hfLow, hfSafe, duration)

trigger((policyParameters))
