Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Fix QF formula #1

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ import * as pomelo from "pomelo-sdk"

// Round Computations
const match_value = 100000;
const sum_square = 1578.29538956198575761;
const divisor = pomelo.calculate_divisor(match_value, sum_square);
// => 63.359495732767975
const sum_square = 6815.9417537;
const sum_value = 3010;
const divisor = pomelo.calculate_divisor(match_value, sum_square, sum_value);
// => 26.2747058341

// Grant Computations
const square = 706.30066043198416992;
const grant_estimate = pomelo.calculate_grant_estimated_match(square, divisor);
// => 44750.85368069151
const sum_sqrt = 60.104076406;
const sum_value = 1712.5;
const grant_estimate = pomelo.calculate_grant_estimated_match(sum_sqrt, sum_value, divisor);
// => 1900.0000

// User Computations
const value = 180
Expand Down
8 changes: 4 additions & 4 deletions src/computations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export function calculate_divisor(match_value: number, sum_square: number) {
return match_value / sum_square;
export function calculate_divisor(round_match_value: number, round_sum_square: number, round_sum_value: number) {
return round_match_value / (round_sum_square - round_sum_value);
}

export function calculate_grant_estimated_match(square: number, divisor: number) {
return square * divisor;
export function calculate_grant_estimated_match(sum_sqrt: number, sum_value: number, divisor: number) {
return (sum_sqrt * sum_sqrt - sum_value) * divisor;
}

export function calculate_funding_estimated_match(value: number, sum_sqrt: number, grant_estimate: number) {
Expand Down