pluralistic-rs

Crates.iopluralistic-rs
lib.rspluralistic-rs
version0.2.0
sourcesrc
created_at2024-01-23 20:19:12.571565
updated_at2024-02-05 22:00:36.691077
descriptionA Rust crate for Quadratic Funding calculations
homepagehttps://github.com/vacekj/pluralistic-rs
repositoryhttps://github.com/vacekj/pluralistic-rs
max_upload_size
id1111130
size36,085
Josef (vacekj)

documentation

README

pluralistic-rs

Overview

The pluralistic-rs library is a Rust crate providing functionality to calculate quadratic funding distributions based on a set of contributions. The library includes a robust implementation for generating random contributions, managing contributions, and applying quadratic funding formulas to distribute a matching pot of funds.

Features

  • Quadratic Funding Calculation: Calculate funding distributions using the calculate_linear_qf function.
  • Matching Upscale: Upscale matching to saturate a round.
  • Matching Cap Strategies: Apply different cap strategies (Cap and Redistribute) using MatchingCapStrategy.
  • Random Contribution Generation: Generate random contributions with the Random trait implemented for Contribution.

Installation

Add pluralistic-rs to your Cargo.toml dependencies:

[dependencies]
pluralistic-rs = "0.1.0"

Usage

  1. Defining Contributions: Contributions are represented by the Contribution struct, which includes sender, recipient, and amount details.

  2. Calculating Distributions: Use calculate_linear_qf to calculate the quadratic funding distribution based on the contributions, matching pot, and options provided.

  3. Applying Cap Strategies: Utilize the MatchingCapStrategy to define how contributions are capped or redistributed when necessary.

  4. Generating Random Contributions: Use the Random trait to generate random contributions for testing and simulation purposes.

Example

use pluralistic_rs::{Contribution, calculate_linear_qf, LinearQfOptions, Random};

fn main() {
    // Generate random contributions
    let contributions = vec![Contribution::rnd(), Contribution::rnd(), ...];

    // Define options for quadratic funding calculation
    let options = LinearQfOptions {
        matching_cap_amount: Some(1000.0),
        matching_cap_strategy: MatchingCapStrategy::Cap,
        ..Default::default()
    };

    // Calculate distributions
    let distributions = calculate_linear_qf(contributions, 5000.0, options);

    // Process distributions...
}

Testing

The library includes a tests module with test cases to ensure the functionality works as expected.

Dependencies

  • rand: Used for generating random contributions and other randomness-related functionalities.

License

MIT

Commit count: 0

cargo fmt