Basic mechanisms like Quadratic Voting/Funding should be abstracted into a trusted, optimized library. Provide helper functions for specific actions in different strategies.
Solution
Implement the logic for voting and calculating matching amount for each recipient with Quadratic Funding formula.
Unit Tests
Resources
Spec for QFLibrary
library QFHelper {
using EnumerableSet for EnumerableSet.AddressSet;
using SafeMath for uint256;
/// Struct that defines a donation
struct Donation {
uint256 amount;
address funder;
}
/// Struct that defines the state of the donations to recipients
struct State {
EnumerableSet.AddressSet recipients;
mapping(address => Donation[]) donations;
/// The square of total contributions for each recipient
mapping(address => uint256) contributionsSquare;
}
/// Calculate the square root of a given number
function _sqrt(uint256 x) internal pure returns (uint256 y) {}
/// Donate to a recipient to allocate
function fundRecipients(
State storage _state,
address[] memory _recipients,
uint256[] memory _amounts
) internal {}
function getPayOutForRecipient(State storage _state, address _recipient) internal view returns (uint256) {}
function calculateDivisor(uint256 _matchingAmount, uint256 _totalContributions) internal view returns (uint256) {
return _matchingAmount.div(_totalContributions);
}
/// Quadratic Formula
function calculatePayout(State storage _state, address _recipient, uint256 _matchingAmount) internal view returns (uint256 _recipientPayout) {}
}
Problem
Basic mechanisms like Quadratic Voting/Funding should be abstracted into a trusted, optimized library. Provide helper functions for specific actions in different strategies.
Solution
Resources
Spec for QFLibrary