On-chain fairness verification for Solidity. Verify that reward distributions, fee allocations, or any proportional split satisfies mathematical fairness properties.
| 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 |
forge install WGlynn/pairwise-fairnessimport {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
);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.
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.
MIT