Configuration

Learn how to configure your liquid staking protocol.

Last updated: 2024-03-21
Edit on GitHub

Overview

Proper configuration is crucial for running a secure and efficient liquid staking protocol. This guide covers all aspects of protocol configuration, from basic parameters to advanced security settings and performance optimization.

Configuration Checklist

  • Core parameters set
  • Security measures configured
  • Performance tuned
  • Monitoring setup complete

Core Parameters

Configure the fundamental parameters that define your protocol's behavior.

Protocol Settings

1export const PROTOCOL_CONFIG = {
2  // Token settings
3  tokenDecimals: 9,
4  tokenName: "Staked SOL",
5  tokenSymbol: "stSOL",
6  
7  // Staking parameters
8  minStakeAmount: new BN(1_000_000_000), // 1 SOL
9  maxStakeAmount: new BN(1_000_000_000_000), // 1000 SOL
10  cooldownPeriod: 2 * 24 * 60 * 60, // 2 days
11  
12  // Fee structure
13  protocolFee: 0.02, // 2%
14  validatorFee: 0.05, // 5%
15  withdrawalFee: 0.001, // 0.1%
16  
17  // Exchange rate
18  initialExchangeRate: 1.0,
19  maxRateChange: 0.01, // 1% max change per update
20}

Network Settings

1export const NETWORK_CONFIG = {
2  // RPC settings
3  rpcEndpoint: process.env.RPC_ENDPOINT,
4  rpcTimeout: 30000, // 30 seconds
5  maxRetries: 3,
6  
7  // Commitment settings
8  defaultCommitment: 'finalized',
9  minConfirmations: 32,
10  
11  // Transaction settings
12  maxTransactionRetries: 3,
13  transactionTimeout: 90000, // 90 seconds
14  priorityFee: 10000, // 0.00001 SOL
15  
16  // Batch settings
17  maxBatchSize: 100,
18  batchInterval: 60000, // 1 minute
19}

Security Settings

Configure security parameters to protect your protocol and users.

Security Configuration

1export const SECURITY_CONFIG = {
2  // Access control
3  adminMultisig: {
4    threshold: 3,
5    owners: [/* list of admin pubkeys */],
6    timelock: 24 * 60 * 60, // 24 hours
7  },
8  
9  // Rate limiting
10  rateLimits: {
11    maxDepositsPerBlock: 10,
12    maxWithdrawalsPerBlock: 5,
13    maxStakePerBlock: new BN(100_000_000_000_000), // 100,000 SOL
14  },
15  
16  // Emergency settings
17  emergency: {
18    shutdownThreshold: 0.95, // 95% slashing triggers shutdown
19    maxSlashingRate: 0.01, // 1% max slashing per validator
20    pauseTimeout: 12 * 60 * 60, // 12 hours
21  },
22  
23  // Validator security
24  validator: {
25    maxStakePerValidator: 0.1, // 10% of total stake
26    minValidatorScore: 0.8, // 80% minimum score
27    delinquencyThreshold: 10, // blocks
28    slashingPenalty: 0.1, // 10% penalty
29  }
30}
Security Best Practices
  • Always use multisig for admin operations
  • Implement proper rate limiting
  • Set reasonable thresholds for emergency procedures
  • Monitor validator performance and health
  • Regularly review and update security parameters

Performance Configuration

Optimize your protocol's performance with these settings.

Performance Settings

1export const PERFORMANCE_CONFIG = {
2  // Caching
3  cache: {
4    validatorListTTL: 300, // 5 minutes
5    exchangeRateTTL: 60, // 1 minute
6    stakingMetricsTTL: 600, // 10 minutes
7  },
8  
9  // Batch processing
10  batch: {
11    maxSize: 100,
12    interval: 60000, // 1 minute
13    retryDelay: 5000, // 5 seconds
14  },
15  
16  // Resource limits
17  limits: {
18    maxConcurrentRequests: 50,
19    maxQueueSize: 1000,
20    timeoutMS: 30000, // 30 seconds
21  },
22  
23  // Optimization
24  optimization: {
25    precomputeScores: true,
26    useIndexedDB: true,
27    compressLogs: true,
28  }
29}

Monitoring Thresholds

1export const MONITORING_CONFIG = {
2  // Performance alerts
3  alerts: {
4    highLatency: 1000, // 1 second
5    highErrorRate: 0.01, // 1%
6    lowThroughput: 10, // tx/s
7  },
8  
9  // Resource monitoring
10  resources: {
11    maxMemoryUsage: 0.9, // 90%
12    maxCPUUsage: 0.8, // 80%
13    maxDiskUsage: 0.85, // 85%
14  },
15  
16  // Health checks
17  health: {
18    interval: 60000, // 1 minute
19    timeout: 5000, // 5 seconds
20    unhealthyThreshold: 3,
21  }
22}

Validator Configuration

Configure validator selection and management parameters.

Validator Settings

1export const VALIDATOR_CONFIG = {
2  // Selection criteria
3  selection: {
4    minCommission: 5,
5    maxCommission: 10,
6    minStake: new BN(1000_000_000_000), // 1000 SOL
7    maxStake: new BN(100_000_000_000_000), // 100,000 SOL
8    minUptime: 0.98, // 98%
9    maxSkipRate: 0.01, // 1%
10  },
11  
12  // Scoring weights
13  weights: {
14    uptime: 0.3,
15    stake: 0.2,
16    performance: 0.3,
17    commission: 0.1,
18    governance: 0.1,
19  },
20  
21  // Rebalancing
22  rebalancing: {
23    threshold: 0.1, // 10% imbalance triggers rebalance
24    maxPerUpdate: 0.05, // 5% max change per update
25    cooldown: 24 * 60 * 60, // 24 hours
26  },
27  
28  // Monitoring
29  monitoring: {
30    checkInterval: 300, // 5 minutes
31    graceBlocks: 10,
32    warningThreshold: 0.9,
33    criticalThreshold: 0.95,
34  }
35}

Advanced Configuration

Fine-tune advanced protocol features and optimizations.

Advanced Features

1export const ADVANCED_CONFIG = {
2  // MEV protection
3  mev: {
4    enabled: true,
5    maxReward: 0.1, // 10% max MEV reward
6    minBlockAge: 10,
7    blacklist: [/* known MEV addresses */],
8  },
9  
10  // Governance
11  governance: {
12    proposalThreshold: new BN(1000_000_000_000), // 1000 SOL
13    votingPeriod: 7 * 24 * 60 * 60, // 7 days
14    executionDelay: 2 * 24 * 60 * 60, // 2 days
15  },
16  
17  // Analytics
18  analytics: {
19    retentionDays: 90,
20    aggregationLevels: ['1h', '1d', '1w'],
21    metrics: ['tvl', 'apy', 'validators'],
22  }
23}

Optimization Settings

1export const OPTIMIZATION_CONFIG = {
2  // Memory management
3  memory: {
4    maxCacheSize: 100 * 1024 * 1024, // 100MB
5    gcInterval: 3600, // 1 hour
6    compactInterval: 86400, // 1 day
7  },
8  
9  // Database
10  database: {
11    maxConnections: 20,
12    connectionTimeout: 10000,
13    queryTimeout: 5000,
14    maxBatchSize: 1000,
15  },
16  
17  // Indexing
18  indexing: {
19    enabled: true,
20    fields: ['validator', 'epoch', 'stake'],
21    updateInterval: 300, // 5 minutes
22  }
23}
Configuration Tips
  • Start with conservative values and adjust based on monitoring
  • Test configuration changes on devnet first
  • Document all configuration changes and their impacts
  • Regularly review and update configurations
  • Keep security parameters strict
  • Monitor performance metrics after changes