Skip to content

Volume Validation System

O edited this page Oct 7, 2025 · 1 revision

Volume Validation and Unit Conversion System

🎯 Purpose: Standardize Water Prices to 1 Liter

The O Blockchain stablecoin is calibrated to water prices at 1 liter = 1 O coin. However, water is sold in various container sizes and measurement systems worldwide. This system ensures all measurements are accurately converted to price per liter while accepting common container sizes.


πŸ“ Acceptable Volume Ranges

Metric System (Liters/Milliliters)

  • Minimum: 0.9 liters (900 mL)
  • Maximum: 1.1 liters (1,100 mL)
  • Target: 1.0 liter (1,000 mL)
  • Common Sizes: 1L, 1000mL, 950mL, 1050mL bottles

Imperial/US System (Fluid Ounces)

  • Minimum: 30 fl oz (~0.887 liters)
  • Maximum: 37 fl oz (~1.094 liters)
  • Target: 33.814 fl oz (~1.0 liter)
  • Common Sizes: 33.8 fl oz (1L equivalent in USA)

Why These Ranges?

  1. Β±10% tolerance around 1 liter accommodates common bottle sizes
  2. Prevents gaming (can't submit tiny/huge containers for manipulation)
  3. Matches real market (most water bottles are close to 1 liter)
  4. International compatibility (works for both metric and imperial)

πŸ”„ Pro-Rating System

When a container is not exactly 1 liter, the system automatically pro-rates the price:

Formula:

Price per Liter = (Container Price) / (Container Volume in Liters)

Examples:

Example 1: Metric System

Container: 950mL water bottle costs $1.14 (114 cents)
Conversion: 950mL = 0.95L
Pro-rated: $1.14 / 0.95L = $1.20 per liter (120 cents/L)

Example 2: Imperial System (USA)

Container: 33.8 fl oz water bottle costs $1.00 (100 cents)
Conversion: 33.8 fl oz = 0.9996L β‰ˆ 1.0L
Pro-rated: $1.00 / 1.0L = $1.00 per liter (100 cents/L)

Example 3: Larger Container

Container: 1.1L water bottle costs $1.32 (132 cents)
Conversion: 1.1L (already in liters)
Pro-rated: $1.32 / 1.1L = $1.20 per liter (120 cents/L)

🌍 Supported Units

Metric Units:

Unit Abbreviations Conversion to Liters
Liters L, liter, liters, litre, litres 1.0
Milliliters mL, milliliter, milliliters Γ· 1000

Imperial/US Units:

Unit Abbreviations Conversion to Liters
Fluid Ounces oz, fl oz, floz, fluid ounce Γ· 33.814
US Gallons gal, gallon, us gal Γ— 3.78541
UK Gallons uk gal, imperial gallon Γ— 4.54609
Pints pt, pint, pints Γ— 0.473176
Quarts qt, quart, quarts Γ— 0.946353

Auto-Detection by Country:

  • USA: Defaults to fl oz (fluid ounces)
  • UK: Defaults to fl oz (fluid ounces)
  • All Other Countries: Defaults to L (liters)

βœ… Validation Process

Step 1: Unit Parsing

Input: "33.8 fl oz"
Parse: volume=33.8, unit="fl oz"
Result: VolumeUnit::FLUID_OUNCES

Step 2: Volume Range Check

Convert to liters: 33.8 fl oz = 0.9996L
Check range: 0.9L ≀ 0.9996L ≀ 1.1L βœ…
Result: VALID

Step 3: Price Pro-Rating

Container price: 100 cents
Volume: 0.9996L
Price per liter: 100 / 0.9996 = 100.04 cents/L
Result: 100 cents/L (rounded)

Step 4: Reasonableness Check

Price per liter: 100 cents
Range check: 1 cent/L ≀ 100 cents/L ≀ 10,000,000 cents/L βœ…
Result: REASONABLE

🚫 Rejection Examples

Volume Too Small:

Container: 500mL (0.5L) costs 50 cents
Volume check: 0.5L < 0.9L ❌
Result: REJECTED - "Volume out of acceptable range (0.9 - 1.1 L)"

Volume Too Large:

Container: 2.0L costs 200 cents
Volume check: 2.0L > 1.1L ❌
Result: REJECTED - "Volume out of acceptable range (0.9 - 1.1 L)"

Invalid Unit:

Container: 12 inches costs 100 cents
Unit parse: "inches" ❌
Result: REJECTED - "Invalid or unsupported volume unit: inches"

Unreasonable Price:

Container: 1.0L costs 10,000,000,000 cents
Price check: 10,000,000,000 cents/L > 10,000,000 cents/L ❌
Result: REJECTED - "Price per liter is unreasonable"

πŸ“Š Measurement Struct Updates

New Fields in WaterPriceMeasurement:

struct WaterPriceMeasurement {
    // ... existing fields ...
    
    // NEW FIELDS:
    double volume;           // Container volume (e.g., 1.0, 0.95, 33.8)
    string volume_unit;      // Unit (e.g., "L", "mL", "fl oz")
    int64_t price_per_liter; // Calculated price per liter (pro-rated)
    
    // ... rest of fields ...
};

Submission Requirements:

BEFORE:
- submitter
- currency_code
- price (total container price)
- location or source_url

AFTER (REQUIRED):
- submitter
- currency_code
- price (total container price)
- volume (container size)         ← NEW
- volume_unit (e.g., "L", "fl oz") ← NEW
- location or source_url

πŸ” Validator Requirements

When validators check measurements, they must verify:

  1. βœ… Volume is accurate (matches photo/URL)
  2. βœ… Unit is correct (metric vs imperial)
  3. βœ… Price is accurate (matches photo/URL)
  4. βœ… Container size is within range (0.9L - 1.1L equivalent)

Validation Examples:

Online Validation:

User submits: $1.20 for 1.0L from walmart.com
Validator checks URL: Confirms 1.0L bottle costs $1.20 βœ…
Result: VALIDATED

Offline Validation:

User submits: Photo of 33.8 fl oz bottle with $1.00 price tag
Validator checks photo: 
  - Confirms 33.8 fl oz visible on label βœ…
  - Confirms $1.00 price tag βœ…
  - Confirms contenance (volume) matches label βœ…
Result: VALIDATED

🎯 Benefits

For Accuracy:

  • βœ… All prices standardized to per-liter basis
  • βœ… Eliminates confusion from different container sizes
  • βœ… Fair comparison across different regions

For Users:

  • βœ… Can submit measurements for any common bottle size
  • βœ… Automatic conversion (no manual calculation needed)
  • βœ… Clear validation rules

For the System:

  • βœ… Consistent data for stablecoin calibration
  • βœ… Prevents manipulation through unusual container sizes
  • βœ… Works globally with different measurement systems

For Validators:

  • βœ… Clear requirements (volume + unit must match photo/URL)
  • βœ… Easy to verify (just check container label)
  • βœ… Protected against fraud (volume range limits)

πŸ’‘ Real-World Scenarios

Scenario 1: USA Convenience Store

Measurement:
  - Container: 33.8 fl oz (1L equivalent)
  - Price: $1.50
  - Unit: "fl oz"
  
Processing:
  - Convert: 33.8 fl oz = 0.9996L
  - Pro-rate: $1.50 / 0.9996L = $1.5006/L
  - Store: 150 cents/L
  
Result: βœ… Accepted

Scenario 2: European Supermarket

Measurement:
  - Container: 1.0L
  - Price: €1.20 (120 euro-cents)
  - Unit: "L"
  
Processing:
  - Convert: 1.0L (already in liters)
  - Pro-rate: 120 cents / 1.0L = 120 cents/L
  - Store: 120 cents/L
  
Result: βœ… Accepted

Scenario 3: Japan Vending Machine

Measurement:
  - Container: 1000mL
  - Price: Β₯110 (110 yen)
  - Unit: "mL"
  
Processing:
  - Convert: 1000mL = 1.0L
  - Pro-rate: Β₯110 / 1.0L = Β₯110/L
  - Store: 110 yen/L
  
Result: βœ… Accepted

Scenario 4: Australia (Smaller Bottle)

Measurement:
  - Container: 950mL
  - Price: A$1.90 (190 cents)
  - Unit: "mL"
  
Processing:
  - Convert: 950mL = 0.95L
  - Pro-rate: 190 cents / 0.95L = 200 cents/L
  - Store: 200 cents/L
  
Result: βœ… Accepted (within 0.9L - 1.1L range)

πŸ”§ Technical Implementation

Files:

  • src/measurement/volume_conversion.h - Volume unit definitions and conversion logic
  • src/measurement/volume_conversion.cpp - Implementation of conversions and validation
  • src/measurement/measurement_system.h - Updated WaterPriceMeasurement struct
  • src/measurement/measurement_system.cpp - Integration with submission process

Key Functions:

// Validate and convert a measurement
VolumeValidationResult ValidateWaterPriceVolume(
    double volume,
    string unit_str,
    int64_t price,
    string currency_code
);

// Convert any unit to liters
double VolumeConverter::ToLiters(double volume, VolumeUnit unit);

// Calculate price per liter
int64_t VolumeConverter::CalculatePricePerLiter(
    int64_t price_for_volume,
    double volume,
    VolumeUnit unit
);

Automatic Integration:

All water price submissions are automatically validated and converted during the SubmitWaterPrice() function. No manual intervention required.


πŸ“ For Measurers and Validators

When You Receive an Invitation:

When you receive a measurement invitation, you have TWO OPTIONS - choose whichever is most convenient:

Option 1: ONLINE Measurement (Lower Reward: 10.00 O)

  • Find water price on a website (e.g., walmart.com, amazon.com, local grocery store site)
  • Provide: URL + price + volume + unit
  • Quick and convenient

Option 2: OFFLINE Measurement (Higher Reward: 100.00 O)

  • Take photo of water bottle with price tag in a physical store
  • Provide: Photo + GPS location + price + volume + unit
  • Requires physical travel but pays more

You decide which method to use based on:

  • Your location (near a store vs at home)
  • Your time (quick URL vs store visit)
  • Your preference (privacy vs convenience)
  • Reward difference (10x more for offline)

When Submitting a Measurement:

  1. Look at the water bottle/container (physical or online)
  2. Note the volume (e.g., "1L", "33.8 fl oz", "1000mL")
  3. Note the price
  4. Note the unit used on the label
  5. Submit with exact volume and unit from the label

When Validating a Measurement:

  1. Check the photo/URL provided
  2. Verify the volume matches what's shown
  3. Verify the unit matches the label
  4. Verify the price matches
  5. Confirm volume is within acceptable range (0.9L - 1.1L)

Important Notes:

  • βœ… DO submit the exact container size (not rounded)
  • βœ… DO include the unit from the label
  • βœ… DO use the price for that specific container
  • ❌ DON'T try to manually calculate price per liter
  • ❌ DON'T round volumes to "1L" if the label says otherwise
  • ❌ DON'T submit containers outside the 0.9L - 1.1L range

πŸŽ‰ Conclusion

The Volume Validation and Unit Conversion System ensures:

  1. βœ… Accurate water prices calibrated to 1 liter
  2. βœ… Global compatibility with different measurement systems
  3. βœ… Fair comparisons across regions and container sizes
  4. βœ… Fraud prevention through volume range limits
  5. βœ… User-friendly automatic conversion

The O Blockchain now accurately handles water price measurements from anywhere in the world, regardless of container size or measurement system! πŸ’§πŸŒ

Clone this wiki locally