Standalone

Quadratic Public Goods

close button

Part II

Quadratic Funding

Beyond decision-making in governance, quadratic relationships can also help democratize crowdfunding.

Consider a crowdfunding system that wishes to support a set of projects. In this system, there are two parties:

  1. Participants: Individuals who contribute funds to their preferred projects.

  2. Sponsor: An organization, or coalition of organizations, that wishes to deploy capital to support the set of projects, but wish to delegate the decision-making process to the participants.

Typically, in sponsor-backed crowdfunding systems, participants signal their preferences through individual contributions. Then, based on the distribution of these contributions, sponsors allocate a matching amount to each project. There are good reasons for sponsors to delegate decision-making. For example, sponsors may simply want to support a general ecosystem, but do not know the best way to distribute capital. By delegating decision-making to a decentralized market process, sponsors might be able to better maximize public utility.

Linear Funding

In a naive crowdfunding system, matching funds can be distributed with the same ratio as participant contribution. Consider the following example.

Participant

Preferred Project

Contribution

1

Project #1

$1600

2

Project #2

$400

3

Project #3

$400

In this scenario, Project #1 raises $1600 from participants, while Project #2 raises $800. Say the sponsor wishes to allocate an additional $3000, it will grant $2000 to Project #1 and $1000 to Project #2.

However, under economic theory, this system is not optimal. The proof of why is quite mathematical, but the intuition is simple: the distribution of participant contribution merely signals the maximization of each individual's utility. It does not necessarily consider the collective utility of the group. This is a problem inherent to funding public goods.

Quadratic Funding

Quadratic funding is a mechanism that aims to help sponsors better allocate their funds to public goods. The mechanism is based on a quadratic formula that mathematically maximizes collective benefit. We say mathematical because the claim is based of an economic model. The mechanism, albeit simplified, is as follows.

The next part will use a little mathematical notation. If you dislike mathematical notation, you can also refer to the example further below.

  1. A sponsor allocates some amount of funds #lang:latex#F, to be distributed among a set of projects.

  2. Participants contribute funds to their preferred projects. Let cjic_j^i​ be the contribution of participant ii to project jj.

  3. Let mjm_j ​be the sum of square roots of contributions to project jj. Specifically, mj=icji​​m_j = \sum_i \sqrt{c^i_j}​​. We will refer to mj2m_j^2​ as the matching power of project jj.

  4. Let the sum of matching powers M=jmj2M = \sum_j m_j^2​ be the total matching power.

  5. The sponsor then distributes its funds FF to each project jj according to the following formula: fj=F(mj2/M)f_j = F \cdot (m_j^2 / M).

Let us use our earlier example of Project #1 and Project #2 to illustrate this mechanism.

  1. The sponsor allocates $3000 to distribute to the two projects.

  2. Participant 1 contribute $1600 to Project #1. Participants 2 and 3 contributes $400 to Project #2 each.

  3. The matching power of Project #1 is given by (1600)2=1600(\sqrt{1600})^2 = 1600.
    The matching power of Project #2 is (400+400)2=1600(\sqrt{400} + \sqrt{400})^2 = 1600

  4. Since the two projects have equal matching power, the sponsor will distribute $1500 to each project.

Finally, Project 1 raises $3100 in total while Project 2 raises $2300. As we can see, similar to quadratic voting, quadratic funding systems tend to back projects that have broader support from the masses.

Village Funding

Our village now wants a quadratic funding system to support their grassroot projects. The system can be broken into three phases.

  1. Setup Phase.
    The village fund is deployed with some ETH. This fund wants to support some given projects (each represented by an address).

  2. Contribution Phase.
    Villagers can then donate to their preferred projects. Each villager can donate multiple times, but only once per project.

  3. Distribution Phase.
    After the funding period ends, donations will be closed and funds can be finalized (using quadratic funding). Once finalized, projects will then be able to claim their funds.

All contributions must be made before the funding period ends (7 days).

VillageFunding.sol

In the contracts/ folder, you will find a contract called VillageFunding. The contract is responsible for the quadratic funding system and supports the following ABI.

Function

Description

constructor(...)

Initializes a new VillageFunding contract, initially supplied with total matching amount from sponsors.

donate(addres _project) payable

A function that villagers call to donate ETH to a certain project. The function should be called before the contribution phase ends (7 days). Villagers can only donate to each project once.

finalizeFunds()

Finalize funds raised by each project. This is only callable after the contribution phase ends (7 days).

withdraw()

Projects call this function to withdraw their raised funds. If funds have not been finalized or msg.sender is not eligible to withdraw any funds.

View Function

Description

getProjects()

Returns the addresses of the projects raising funds.

finalFunds(address _project)

The final amount of funds eligible to a given project. Returns 0 if funds are not finalized yet or if funds already claimed.

The detailed interface can be found in interfaces/IVillageFunding.sol.

Notes

  • The contribution phase will last 7 days.

  • Square root calculation should be rounded down to the nearest integer.

Your Task

Implement all the functions listed above in contracts/VillageFunding.sol.

Run tests in Questplay

Submit work in Questplay

Now a decision has been made, it’s time to figure out a way to fund the repairs…