Skip to content

Keeper System

Overview

The Keeper System is an automated off-chain service that manages JVAULT's weekly settlement cycle. It ensures reliable, timely execution of critical operations every Sunday.

Weekly Settlement Flow

Weekly Settlement Flow

Sunday 06:50 UTC+7: Pre-Settlement ├── Pause new deposits ├── Snapshot pending withdrawals
├── Begin position liquidation │ Sunday 07:00 UTC+7: Settlement Execution ├── Close all market-making positions ├── Calculate total vault value ├── Determine new NAV ├── Process withdrawal queue ├── Update on-chain state │ Sunday 07:30 UTC+7: Post-Settlement
├── Transfer USDC to withdrawal users ├── Burn JVAULT tokens ├── Emit settlement events ├── Resume normal operations │ Sunday 08:00 UTC+7: New Cycle └── Deploy 80% capital to market-making

Keeper Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Cron Scheduler │    │  Position Monitor│    │  Settlement Bot │
│   (AWS Lambda)   │────│   (Real-time)   │────│   (Execution)   │
└─────────────────┘    └─────────────────┘    └─────────────────┘
         │                       │                       │
         │                       │                       │
         ▼                       ▼                       ▼
┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Base L2        │    │   CEX APIs      │    │   Price Feeds   │
│   Smart Contract │    │   (Trading)     │    │   (Oracles)     │
└─────────────────┘    └─────────────────┘    └─────────────────┘

Keeper Operations

1. Position Monitoring 📊

javascript
// Pseudo-code for position tracking
async function monitorPositions() {
    const positions = await getAllPositions();
    
    for (const position of positions) {
        // Check PnL and risk metrics
        const pnl = calculatePnL(position);
        const risk = assessRisk(position);
        
        // Execute risk management
        if (risk > THRESHOLD) {
            await closePosition(position);
        }
    }
}

2. Settlement Execution ⚙️

javascript
// Sunday 07:00 UTC+7 settlement
async function executeSettlement() {
    // 1. Close all positions
    await closeAllPositions();
    
    // 2. Calculate vault value
    const totalValue = await calculateTotalValue();
    const newNAV = totalValue / totalSupply;
    
    // 3. Update on-chain NAV
    await updateNAVOnChain(newNAV);
    
    // 4. Process withdrawals
    await processWithdrawalQueue();
    
    // 5. Restart market-making
    await deployCapital();
}

3. Withdrawal Processing 💸

javascript
async function processWithdrawals() {
    const queue = await getWithdrawalQueue();
    
    for (const request of queue) {
        const usdcAmount = request.shares * currentNAV * 0.9975; // 0.25% fee
        
        await transferUSDC(request.user, usdcAmount);
        await burnShares(request.shares);
        await markProcessed(request.id);
    }
}

Redundancy & Reliability

Multi-Layer Backup

  • Primary: AWS Lambda with CloudWatch monitoring
  • Secondary: Local server with different ISP
  • Tertiary: Manual execution capability
  • Emergency: Multisig intervention

Monitoring Systems

  • Real-time position tracking
  • Price feed validation
  • Network connectivity checks
  • Gas price optimization
  • Transaction confirmation tracking

Keeper Security

Access Control

  • Dedicated wallet for keeper operations
  • Limited permissions (no admin functions)
  • Rate limiting and spending caps
  • Multi-signature emergency controls

Risk Management

javascript
const RISK_LIMITS = {
    MAX_POSITION_SIZE: 0.1, // 10% of vault
    MAX_DAILY_LOSS: 0.02,   // 2% of vault
    MAX_GAS_PRICE: 50,      // 50 gwei
    MIN_RESERVE_RATIO: 0.15 // 15% minimum
};

Failure Scenarios

Keeper Downtime

  • Automated failover to backup system
  • Manual execution procedures documented
  • Emergency multisig activation
  • Community notification protocols

Network Issues

  • Multiple RPC endpoints configured
  • Retry logic with exponential backoff
  • Gas price escalation strategies
  • Cross-chain bridge monitoring

Oracle Failures

  • Multiple price feed sources
  • Sanity checks and outlier detection
  • Fallback to alternative oracles
  • Manual price verification capability

Monitoring Dashboard

Real-Time Metrics

  • Keeper health status
  • Position performance
  • NAV tracking
  • Withdrawal queue size
  • Gas usage optimization

Alerts

  • Position loss thresholds
  • Network connectivity issues
  • Settlement delays
  • Oracle price deviations

Future Enhancements

Decentralization

  • Keeper network with multiple operators
  • Incentive mechanisms for reliability
  • Slash conditions for misbehavior
  • Community governance over parameters

AI Integration

  • Machine learning for optimal timing
  • Predictive risk management
  • Dynamic parameter adjustment
  • Automated strategy optimization

Previous: ← Smart Contracts | Next: FAQ →

Released under the MIT License.