Crates.io | pluralistic-rs |
lib.rs | pluralistic-rs |
version | 0.2.0 |
source | src |
created_at | 2024-01-23 20:19:12.571565 |
updated_at | 2024-02-05 22:00:36.691077 |
description | A Rust crate for Quadratic Funding calculations |
homepage | https://github.com/vacekj/pluralistic-rs |
repository | https://github.com/vacekj/pluralistic-rs |
max_upload_size | |
id | 1111130 |
size | 36,085 |
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.
calculate_linear_qf
function.Cap
and Redistribute
) using MatchingCapStrategy
.Random
trait implemented
for Contribution
.Add pluralistic-rs
to your Cargo.toml
dependencies:
[dependencies]
pluralistic-rs = "0.1.0"
Defining Contributions: Contributions are represented by the Contribution
struct, which includes sender,
recipient, and amount details.
Calculating Distributions: Use calculate_linear_qf
to calculate the quadratic funding distribution based on the
contributions, matching pot, and options provided.
Applying Cap Strategies: Utilize the MatchingCapStrategy
to define how contributions are capped or
redistributed when necessary.
Generating Random Contributions: Use the Random
trait to generate random contributions for testing and
simulation purposes.
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...
}
The library includes a tests
module with test cases to ensure the functionality works as expected.
rand
: Used for generating random contributions and other randomness-related functionalities.MIT