Skip to content

Commit

Permalink
✨ unable top_weighted disribution method
Browse files Browse the repository at this point in the history
  • Loading branch information
stepandel committed Sep 6, 2024
1 parent 53081ac commit 247d5fa
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/app/api/common/ballots/ballotDistributionStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fetchBallot } from "./getBallots";
export enum DistributionStrategy {
IMPACT_GROUPS = "IMPACT_GROUPS",
TOP_TO_BOTTOM = "TOP_TO_BOTTOM",
// TOP_WEIGHTED = "TOP_WEIGHTED",
TOP_WEIGHTED = "TOP_WEIGHTED",
}

const applyDistributionStrategyApi = async (
Expand Down Expand Up @@ -75,27 +75,27 @@ async function applyDistributionStrategyForAddress({
});
}

// if (strategy === DistributionStrategy.TOP_WEIGHTED) {
// const y = topWeighted({
// max,
// total: totalFunding,
// n,
// });

// projectsAllocation.forEach((project, i) => {
// if (project.impact) {
// newProjectsAllocation.push({
// ...project,
// allocation: y(i),
// });
// }
// });

// console.log(
// "total",
// newProjectsAllocation.reduce((acc, p) => acc + (p.allocation ?? 0), 0)
// );
// }
if (strategy === DistributionStrategy.TOP_WEIGHTED) {
const y = topWeighted({
max: 500_000, // TODO: adjust this number
total: totalFunding,
n,
});

projectsAllocation.forEach((project, i) => {
if (project.impact) {
newProjectsAllocation.push({
...project,
allocation: y(i),
});
}
});

console.log(
"total",
newProjectsAllocation.reduce((acc, p) => acc + (p.allocation ?? 0), 0)
);
}

if (strategy === DistributionStrategy.IMPACT_GROUPS) {
const nk = projectsAllocation.reduce(
Expand Down

0 comments on commit 247d5fa

Please sign in to comment.