Skip to content

WGlynn/pairwise-fairness

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

PairwiseFairness

On-chain fairness verification for Solidity. Verify that reward distributions, fee allocations, or any proportional split satisfies mathematical fairness properties.

Properties Verified

Property What It Checks
Pairwise Proportionality reward_A / reward_B ≈ weight_A / weight_B for every pair
Efficiency sum(allocations) == totalValue — no value created or destroyed
Null Player weight == 0 → reward == 0
Time Neutrality Same inputs in different periods → same outputs

Installation

forge install WGlynn/pairwise-fairness

Usage

import {PairwiseFairness} from "pairwise-fairness/src/PairwiseFairness.sol";

// Verify two participants are treated proportionally
PairwiseFairness.FairnessResult memory result = PairwiseFairness.verifyPairwiseProportionality(
    rewardA, rewardB,
    weightA, weightB,
    tolerance  // should scale with totalWeight, not numParticipants
);
require(result.fair, "Pairwise proportionality violated");

// Verify all pairs in one call
(bool allFair, uint256 worstDeviation, , ) = PairwiseFairness.verifyAllPairs(
    rewards, weights, tolerance
);

// Verify efficiency
PairwiseFairness.FairnessResult memory eff = PairwiseFairness.verifyEfficiency(
    allocations, totalValue, tolerance
);

Why This Exists

Most DeFi protocols distribute rewards proportionally but never verify the distribution is actually fair. Rounding errors, dust accumulation, and edge cases can cause systematic bias that benefits certain participants over others.

This library makes fairness auditable on-chain. Any user can call the verification functions to check that a distribution treated them fairly.

From VibeSwap

Extracted from VibeSwap, an omnichain DEX that uses cooperative game theory (Shapley values) for reward distribution. The fairness verification is the audit layer that proves the math works.

License

MIT

About

On-chain fairness verification for Solidity. Verify proportionality, efficiency, null player for any reward distribution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors