Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Monitoring and Risk Management

Templar Protocol uses available tools and established practices for monitoring protocol health and managing risks.

Protocol Monitoring Tools

Available Monitoring

Bot Infrastructure

The protocol includes operational bots for automated tasks:

  • Liquidation Bot: Monitors positions and executes liquidations

    • Configurable intervals and concurrency
    • Market registry monitoring
    • Oracle price feed integration
    • Automated liquidation execution
  • Accumulator Bot: Handles interest accumulation

    • Periodic interest calculations
    • Multi-market support
    • Configurable execution parameters

Gas Usage Monitoring

Gas analysis tools provide performance insights:

./script/ci/gas-report.sh

This generates detailed reports on:

  • Function execution costs
  • Snapshot iteration limits
  • Performance bottlenecks

Manual Monitoring Procedures

Protocol Health Checks

Regular checks can be performed using:

  1. Market Status: Query market configurations and states

    # Get market configuration
    near contract call-function as-read-only <market-address> get_configuration json-args {} network-config mainnet now
    
    # Check current market snapshot
    near contract call-function as-read-only <market-address> get_current_snapshot json-args {} network-config mainnet now
    
    # Get borrow asset metrics
    near contract call-function as-read-only <market-address> get_borrow_asset_metrics json-args {} network-config mainnet now
    
    # List all deployed markets from registry
    near contract call-function as-read-only v1.tmplr.near list_deployments json-args '{"offset": 0, "count": 100}' network-config mainnet now
    
  2. Oracle Health: Verify price feed freshness and accuracy

    # Check oracle prices
    near contract call-function as-read-only pyth-oracle.near get_price json-args '{"price_identifier": "<asset-price-id>"}' network-config mainnet now
    
    # Check LST oracle adapter
    near contract call-function as-read-only lst.oracle.tmplr.near get_price_data json-args '{}' network-config mainnet now
    

    Price Feed Status: Monitor price feed health at Pyth Network Price Feeds

Market Data Analysis

Using available view functions:

  • Supply Positions: Monitor individual and aggregate supply positions

    # Get supply positions
    near contract call-function as-read-only <market-address> list_supply_positions json-args '{"offset": 0, "count": 100}' network-config mainnet now
    
  • Withdrawal Queue: Check pending withdrawal requests

    # Check withdrawal queue status
    near contract call-function as-read-only <market-address> get_supply_withdrawal_queue_status json-args {} network-config mainnet now
    
  • Historical Snapshots: Analyze market history

    # Get finalized snapshots for historical analysis
    near contract call-function as-read-only <market-address> list_finalized_snapshots json-args '{"offset": 0, "count": 10}' network-config mainnet now
    
  • Total Value Locked: Monitor TVL at DefiLlama - Templar Protocol

  • Utilization Rate: Calculate from borrow asset metrics

    # Get borrow asset metrics to calculate utilization (borrowed / available)
    near contract call-function as-read-only <market-address> get_borrow_asset_metrics json-args {} network-config mainnet now
    
  • Current Interest Rate: Monitor current rate for supply positions

    # Get current yield rate for suppliers
    near contract call-function as-read-only <market-address> get_last_yield_rate json-args {} network-config mainnet now
    

    Note: Historical interest rate analysis requires an indexer for time-series data

Risk Management

Economic Risk Assessment

Available Analysis Tools

  • Market Configuration Review: Analyze MCR ratios and interest rate models TODO: Get parameters from each market deployed
  • Oracle Price Monitoring: Track price volatility and feed reliability
  • Liquidation Efficiency: Monitor liquidation success rates TODO: Get data from liquidator
  • Position Analysis: Assess individual and aggregate position health
    • Individual positions: My Account
    • Aggregate analysis: TODO: Create from contract data

Risk Mitigation Strategies

  • Conservative Parameters: Well-tested collateralization ratios
  • Oracle Integration: Multiple validation layers for price feeds
  • Liquidation Incentives: Economic incentives for timely liquidations
  • Interest Rate Models: Dynamic models responding to market conditions

Operational Monitoring

For operational monitoring procedures, refer to:

Criminal Activity Monitoring

SEVERE Account Labels

  • SEVERE Account Detection: Telegram notification of SEVERE accounts interacting with Templar contracts
  • Monitoring Repository: Details available at templar-monitoring