Fee Model

Fee Model - Transaction Fees and Economics

This document describes the fee model, fee calculation, and economic incentives in the Roru Protocol.

Fee Structure

Fee Components

Fee Types:

  1. Base Fee: Fixed fee per transaction

  2. Size Fee: Fee based on transaction size

  3. Priority Fee: Optional priority fee

  4. Network Fee: Chain-specific network fees

Fee Format:

pub struct TransactionFees {
    pub base_fee: u64,
    pub size_fee: u64,
    pub priority_fee: Option<u64>,
    pub network_fee: u64,
    pub total: u64,
}

Fee Calculation

Base Fee

Base Fee Calculation:

Size Fee

Size Fee Calculation:

Priority Fee

Priority Fee Calculation:

Network Fee

Network Fee Calculation:

Total Fee Calculation

Calculation Process

Total Fee:

Fee Payment

Payment Methods

Payment Options:

  1. Dedicated Fee Note: Separate note for fees

  2. Change Output: Fees from change

  3. Public Fee: Public fee payment

  4. Asset-Specific: Pay in specific asset

Fee Note Creation

Fee Note:

Economic Model

Fee Distribution

Distribution:

  • Infrastructure providers

  • Prover nodes

  • Relayer nodes

  • Protocol treasury (optional)

Distribution Code:

Dynamic Fee Adjustment

Fee Adjustment

Adjustment Factors:

  • Network congestion

  • Demand

  • Supply

  • Historical data

Adjustment Algorithm:

Fee Estimation

Estimation Process

Estimation Steps:

  1. Estimate transaction size

  2. Get current network fees

  3. Calculate base fees

  4. Apply priority

  5. Return estimate

Estimation Code:

Fee Optimization

Optimization Strategies

Strategies:

  • Batch transactions

  • Optimize transaction size

  • Choose optimal priority

  • Time transactions

Batch Optimization

Batch Fees:

Fee Refunds

Refund Scenarios

Refund Cases:

  • Transaction failure

  • Network errors

  • Invalid transactions

  • Timeout

Refund Process:

Fee Transparency

Fee Display

Display Format:

  • Breakdown by component

  • Total fee

  • Fee in different units

  • Historical comparison

Fee Reporting

Reporting:

  • Per-transaction fees

  • Aggregate fees

  • Fee trends

  • Cost analysis

Conclusion

The fee model provides:

  • Fairness: Transparent fee structure

  • Efficiency: Optimized fees

  • Flexibility: Multiple payment methods

  • Economics: Sustainable model

  • Transparency: Clear fee breakdown

Understanding fees is essential for economic analysis.

Last updated