Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vacekj/pluralistic-rs
Rust library for running quadratic funding and quadratic voting calculations
https://github.com/vacekj/pluralistic-rs
qf quadratic-funding qv
Last synced: about 2 months ago
JSON representation
Rust library for running quadratic funding and quadratic voting calculations
- Host: GitHub
- URL: https://github.com/vacekj/pluralistic-rs
- Owner: vacekj
- Created: 2023-12-12T14:00:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-05T22:07:01.000Z (11 months ago)
- Last Synced: 2024-10-31T11:56:53.119Z (2 months ago)
- Topics: qf, quadratic-funding, qv
- Language: Rust
- Homepage:
- Size: 11.4 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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:
```toml
[dependencies]
pluralistic-rs = "0.1.0"
```## Usage
1. **Defining Contributions**: Contributions are represented by the `Contribution` struct, which includes sender,
recipient, and amount details.1. **Calculating Distributions**: Use `calculate_linear_qf` to calculate the quadratic funding distribution based on the
contributions, matching pot, and options provided.2. **Applying Cap Strategies**: Utilize the `MatchingCapStrategy` to define how contributions are capped or
redistributed when necessary.
3. **Generating Random Contributions**: Use the `Random` trait to generate random contributions for testing and
simulation purposes.## Example
```rust
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