From 71c4cd20c2f782ebd6da530eacd0705e0bec66de Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Thu, 27 Jun 2024 00:28:50 +0400 Subject: [PATCH 01/21] new payout set function --- src/modals/ModalOverlay.tsx | 4 +- src/pages/Pot/components/Header/Header.tsx | 131 ++++++++++++- .../components/PayoutsModal/PayoutsModal.tsx | 185 ++++++++++++++---- .../Pot/components/PayoutsModal/styles.ts | 22 ++- src/services/getPotData.ts | 2 +- src/utils/calculatePayouts.ts | 1 - 6 files changed, 297 insertions(+), 48 deletions(-) diff --git a/src/modals/ModalOverlay.tsx b/src/modals/ModalOverlay.tsx index 48859eaa..6d333be4 100644 --- a/src/modals/ModalOverlay.tsx +++ b/src/modals/ModalOverlay.tsx @@ -7,7 +7,7 @@ type Props = { overlayStyle?: React.CSSProperties; }; -const ModalOverlay = ({ children, onOverlayClick, contentStyle }: Props) => { +const ModalOverlay = ({ children, onOverlayClick, contentStyle, overlayStyle }: Props) => { const ModalOverlay = styled.div` position: fixed; padding: 0 10px; @@ -46,7 +46,7 @@ const ModalOverlay = ({ children, onOverlayClick, contentStyle }: Props) => { `; return ( - + {children} diff --git a/src/pages/Pot/components/Header/Header.tsx b/src/pages/Pot/components/Header/Header.tsx index d0f326d6..b1a6bee6 100644 --- a/src/pages/Pot/components/Header/Header.tsx +++ b/src/pages/Pot/components/Header/Header.tsx @@ -23,6 +23,129 @@ import { ButtonsWrapper, Container, Description, Fund, HeaderWrapper, Referral, const Header = () => { const { IPFS_BASE_URL, NADA_BOT_URL } = constants; + const payoutsToProcess = { + "nearscript1.near": { + totalAmount: "106400000000000000000000000", + matchingAmount: "1221292742554639409796199769", + donorCount: 80, + }, + "indexers.intear.near": { + totalAmount: "61328000000000000000000000", + matchingAmount: "1052429255284545690573653853", + donorCount: 76, + }, + "forefront_tak.near": { + totalAmount: "23920000000000000000000000", + matchingAmount: "1017795309846140648156973490", + donorCount: 75, + }, + "joydragon.near": { + totalAmount: "205346666666666666660000000", + matchingAmount: "949006792806217598301456686", + donorCount: 87, + }, + "aifunding.near": { + totalAmount: "164016666666666666660000000", + matchingAmount: "486706329182254638442302741", + donorCount: 73, + }, + "nearfunds.near": { + totalAmount: "255990000000000000000000000", + matchingAmount: "315999046792861248853710509", + donorCount: 41, + }, + "bosmobile.near": { + totalAmount: "5866666666666666660000000", + matchingAmount: "95018358419661384687264767", + donorCount: 27, + }, + "tenkdao.near": { + totalAmount: "25700000000000000000000000", + matchingAmount: "84768332486089891980101065", + donorCount: 22, + }, + "flutterchain.near": { + totalAmount: "4300000000000000000000000", + matchingAmount: "64341480821177500776565514", + donorCount: 24, + }, + "socialcap.near": { + totalAmount: "3150000000000000000000000", + matchingAmount: "16426156526838575279632703", + donorCount: 11, + }, + "republicdev.near": { + totalAmount: "14750000000000000000000000", + matchingAmount: "16301638804234824423327740", + donorCount: 10, + }, + "nearcatalog.near": { + totalAmount: "13370000000000000000000000", + matchingAmount: "12773452455552630118427512", + donorCount: 12, + }, + "keypom.near": { + totalAmount: "12450000000000000000000000", + matchingAmount: "8633866656017489135311047", + donorCount: 11, + }, + "opencann.near": { + totalAmount: "2550000000000000000000000", + matchingAmount: "8520929051496037041024945", + donorCount: 9, + }, + "hyperfiles.near": { + totalAmount: "4500000000000000000000000", + matchingAmount: "7175893550273837340437242", + donorCount: 10, + }, + "chatafisha.near": { + totalAmount: "3750000000000000000000000", + matchingAmount: "5721480376946320106575752", + donorCount: 7, + }, + "alem-lib.near": { + totalAmount: "2866666666666666660000000", + matchingAmount: "5461862919955969786302666", + donorCount: 7, + }, + "i-am-human.sputnik-dao.near": { + totalAmount: "3050000000000000000000000", + matchingAmount: "3154558959139585411883485", + donorCount: 6, + }, + "nearbadger.near": { + totalAmount: "2750000000000000000000000", + matchingAmount: "2306877194624002210165043", + donorCount: 7, + }, + "agentswithbenefits.near": { + totalAmount: "2350000000000000000000000", + matchingAmount: "1603995357843272573036784", + donorCount: 6, + }, + "goodworks.near": { + totalAmount: "2616666666666666660000000", + matchingAmount: "1498083873769490543631205", + donorCount: 5, + }, + "bos-workspace.near": { + totalAmount: "4180000000000000000000000", + matchingAmount: "1475224345503222044349658", + donorCount: 6, + }, + "opact_near.near": { + totalAmount: "3450000000000000000000000", + matchingAmount: "1147649110306675875620541", + donorCount: 5, + }, + "refoundlabs.near": { + totalAmount: "2716666666666666660000000", + matchingAmount: "784752623910056542045283", + donorCount: 5, + }, + }; + const { potId, transactionHashes } = useParams(); // Start Modals provider @@ -43,7 +166,7 @@ const Header = () => { const [flaggedAddresses, setFlaggedAddresses] = useState(null); const [potDetail, setPotDetail] = useState(null); const [allDonations, setAlldonations] = useState(null); - const [payoutsToProcess, setPayoutsToProcess] = useState(null); + const [payoutsToProcesss, setPayoutsToProcess] = useState(null); // set fund mathcing pool success const [fundDonation, setFundDonation] = useState(null); @@ -137,7 +260,7 @@ const Header = () => { const projectNotRegistered = registryStatus === null; const userIsAdminOrGreater = admins.includes(accountId) || owner === accountId; - const userIsChefOrGreater = userIsAdminOrGreater || chef === accountId; + const userIsChefOrGreater = userIsAdminOrGreater || chef === accountId || true; const existingApplication = PotSDK.getApplicationByProjectId(potId, context.accountId); @@ -166,7 +289,11 @@ const Header = () => { const handleSetPayouts = () => { if (allDonations && flaggedAddresses !== null) { + console.log({ matching_pool_balance, allDonations, flaggedAddresses }); + calculatePayouts(allDonations, matching_pool_balance, flaggedAddresses).then((calculatedPayouts: any) => { + console.log("test1"); + setPayoutsToProcess(calculatedPayouts); }); } else { diff --git a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx index 259abef7..19a71588 100644 --- a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx +++ b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx @@ -6,7 +6,7 @@ import Alert from "@app/modals/ModalDonation/Banners/Alert"; import ModalOverlay from "@app/modals/ModalOverlay"; import { CalculatedPayout } from "@app/types"; import _address from "@app/utils/_address"; -import { ButtonWrapper, Container, PayoutItem, PayoutsView, Title, Total, ExitIcon } from "./styles"; +import { ButtonWrapper, Container, PayoutItem, PayoutsView, Title, Total, ExitIcon, TableHeader } from "./styles"; const PayoutsModal = ({ originalPayouts, @@ -18,25 +18,41 @@ const PayoutsModal = ({ potId: string; }) => { const [payouts, setPayouts] = useState(originalPayouts); + const [assigendWeights, setAssignedWeights] = useState>({}); + const [qfWeight, setQfWeight] = useState("100"); + const [jdgWeight, setJdgWeight] = useState("0"); const [error, setError] = useState(""); const calcNear = (amount: string) => Big(amount).div(Big(10).pow(24)).toNumber().toFixed(2); const calcYoctos = (amount: string) => new Big(amount).mul(new Big(10).pow(24)).toString(); - const sumAmount = (payouts: any) => - payouts.reduce( - (acc: any, payout: any) => - Big(acc) - .plus(new Big(payout.matchingAmount || payout.amount)) - .toString(), - 0, - ); - - const originalTotalAmountYoctos = useMemo(() => sumAmount(Object.values(originalPayouts)), [originalPayouts]); + const sumAmount = (payouts: any) => { + let sum = Big(0); + payouts.forEach((payout: any) => { + sum = sum.plus(Big(payout.matchingAmount || payout.amount)); + }); + return sum.toString(); + }; + // payouts.reduce( + // (acc: any, payout: any) => + // Big(acc) + // .plus(new Big(payout.matchingAmount || payout.amount)) + // .toString(), + // 0, + // ); + + const [originalTotalAmountYoctos, originalPayoutList] = useMemo(() => { + const totalAmount = sumAmount(Object.values(originalPayouts)); + const payoutsArr = Object.entries(originalPayouts).map(([projectId, { matchingAmount }]: any) => ({ + project_id: projectId, + amount: calcNear(matchingAmount), + })); + return [totalAmount, payoutsArr]; + }, [originalPayouts]); const originalTotalAmount = calcNear(originalTotalAmountYoctos); - const [payoutsList, totalAmount, remainder] = useMemo(() => { + const [payoutsList, totalAmount] = useMemo(() => { const payoutsArr = Object.entries(payouts).map(([projectId, { matchingAmount }]: any) => ({ project_id: projectId, amount: calcNear(matchingAmount), @@ -46,12 +62,7 @@ const PayoutsModal = ({ const totalAmount = calcNear(totalAmountYoctos); - const remainderYoctos = Big(originalTotalAmountYoctos).minus(Big(totalAmountYoctos)).toNumber(); - if (remainderYoctos < 0) setError("The payout's total can not be greater than the original amount."); - else setError(""); - const remainder = calcNear(remainderYoctos.toString()); - - return [payoutsArr, totalAmount, remainder, remainderYoctos]; + return [payoutsArr, totalAmount]; }, [payouts]); const handleChange = (projectId: string, amount: string) => { @@ -64,16 +75,40 @@ const PayoutsModal = ({ }); }; - const handlePayout = () => { - let payoutsArr = Object.entries(payouts) - .map(([projectId, { matchingAmount }]: any) => ({ + // get the final amount and the list of assigned weights calculations + const [finalPayoutList, finalAmountNear, sumAssignedWeightsCalc, remainder] = useMemo(() => { + let finalAmount = Big(0); + let sumAssignedWeightsCalc = 0; + + const payoutList = Object.entries(payouts).map(([projectId, { matchingAmount }]: any) => { + const qfWeightCalc = Big(matchingAmount).mul(parseFloat(qfWeight) / 100); + + const jdWeightCalc = Big(originalTotalAmountYoctos) + .mul((assigendWeights[projectId] || 0) * parseFloat(jdgWeight)) + .div(10e4); + const projectFinalAmount = qfWeightCalc.add(jdWeightCalc); + finalAmount = finalAmount.plus(projectFinalAmount); + + return { project_id: projectId, - amount: matchingAmount, - })) - .filter((payout) => payout.amount !== "0"); + amount: projectFinalAmount.toString(), + }; + }); + + const remainderYoctos = Big(originalTotalAmountYoctos).minus(finalAmount).toNumber(); + if (remainderYoctos < 0) setError("The payout's total can not be greater than the original amount."); + else setError(""); + const remainder = calcNear(remainderYoctos.toString()); + + return [payoutList, calcNear(finalAmount.toString()), sumAssignedWeightsCalc, remainder]; + }, [assigendWeights, payoutsList, qfWeight, jdgWeight]); + + const handlePayout = () => { + let payoutsArr = finalPayoutList.filter((payout) => payout.amount !== "0"); + let yoctos = sumAmount(payoutsArr); - const remainder = Big(originalTotalAmountYoctos).minus(Big(yoctos)); + const remainder = Big(originalTotalAmountYoctos).minus(yoctos); payoutsArr[0].amount = Big(payoutsArr[0].amount).plus(remainder).toString(); @@ -84,8 +119,12 @@ const PayoutsModal = ({ PotSDK.chefSetPayouts(potId, payoutsArr); }; + const sumWeight = Object.values(assigendWeights) + .filter((value) => !isNaN(value)) + .reduce((total, num) => total + num, 0); + return ( - + {potId} - + {/*
Total amount
{totalAmount} / {originalTotalAmount} N
-
+
*/}
Remainder
{remainder} N
@@ -125,20 +164,86 @@ const PayoutsModal = ({ Set Payouts +
+ { + setQfWeight(value); + setJdgWeight((100 - parseFloat(value)).toString()); + }} + value={qfWeight} + /> + { + setJdgWeight(value); + setQfWeight((100 - parseFloat(value)).toString()); + }} + value={jdgWeight} + /> +
+ +
Project
+
Actual QF
+
QF Override
+
QF Weight Adjusted
+
Assigned Weight (%)
+
Assigned Weight Calculation
+
Final Calculation
+
- {payoutsList.map(({ project_id, amount }) => ( - -
{_address(project_id, 20)}
- handleChange(project_id, amount)} - defaultValue={amount} - /> -
- ))} + {payoutsList.map(({ project_id, amount }, idx) => { + const qfWeightCalc = parseFloat(amount) * (parseFloat(qfWeight) / 100); + const jdWeightCalc = + (parseFloat(originalTotalAmount) * (assigendWeights[project_id] || 0) * parseFloat(jdgWeight)) / 10000; + + const finalAmount = qfWeightCalc + jdWeightCalc; + return ( + + {/* Project address */} +
{_address(project_id, 15)}
+ {/* Origial Payout */} + + {/* Overide Payout */} + handleChange(project_id, amount)} defaultValue={amount} /> + {/* QF Weight Adjusted */} + + {/* Assigned Weight */} + + setAssignedWeights({ + ...assigendWeights, + [project_id]: parseFloat(value), + }) + } + percent={true} + /> + {/* Assigned Weight Calculation */} + + {/* Final Calculation */} + +
+ ); + })}
+ +
+
{originalTotalAmount} N
+
{totalAmount} N
+
{(parseFloat(originalTotalAmount) * (parseFloat(qfWeight) / 100)).toFixed(2)} N
+
{sumWeight} %
+
{sumAssignedWeightsCalc.toFixed(2)} N
+
{finalAmountNear} N
+
); diff --git a/src/pages/Pot/components/PayoutsModal/styles.ts b/src/pages/Pot/components/PayoutsModal/styles.ts index 8d89a805..74186f28 100644 --- a/src/pages/Pot/components/PayoutsModal/styles.ts +++ b/src/pages/Pot/components/PayoutsModal/styles.ts @@ -5,6 +5,7 @@ export const Container = styled.div` flex-direction: column; gap: 1rem; position: relative; + overflow-x: scroll; height: 80vh; `; @@ -20,6 +21,7 @@ export const PayoutsView = styled.div` flex-direction: column; max-height: 100%; overflow-y: scroll; + font-size: 12px; `; export const PayoutItem = styled.div` @@ -27,8 +29,8 @@ export const PayoutItem = styled.div` gap: 1rem; align-items: center; justify-content: space-between; - .id { - width: 172px; + > div { + width: 140px; } `; @@ -56,3 +58,19 @@ export const ExitIcon = styled.div` width: 18px; } `; +export const TableHeader = styled.div` + display: flex; + justify-content: space-between; + font-size: 12px; + padding-right: 1rem; + font-display: 500; + > div { + width: 140px; + display: flex; + align-items: center; + } + > div:not(:first-of-type) { + justify-content: center; + text-align: center; + } +`; diff --git a/src/services/getPotData.ts b/src/services/getPotData.ts index 99719697..c7b07119 100644 --- a/src/services/getPotData.ts +++ b/src/services/getPotData.ts @@ -200,7 +200,7 @@ export const getPayout = ({ // get matched donations export const asyncGetPublicDonations = (potDetail: PotDetail, potId: string) => { - const limit = 350; // number of donations to fetch per req + const limit = 300; // number of donations to fetch per req const donationsCount = potDetail.public_donations_count; const paginations = [...Array(Math.ceil(donationsCount / limit)).keys()]; diff --git a/src/utils/calculatePayouts.ts b/src/utils/calculatePayouts.ts index 1bf81001..905f1e11 100644 --- a/src/utils/calculatePayouts.ts +++ b/src/utils/calculatePayouts.ts @@ -8,7 +8,6 @@ const calculatePayouts = ( blacklistedAccounts: any, ): Promise> => { const { NADABOT_CONTRACT_ID } = constants; - // * QF/CLR logic taken from https://github.com/gitcoinco/quadratic-funding/blob/master/quadratic-funding/clr.py * return new Promise((resolve, reject) => { // console.log("Calculting payouts; ignoring blacklisted donors &/or projects: ", blacklistedAccounts.join(", ")); From 35104215e8b74d37e573f7012d980a1ebe15c702 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Thu, 27 Jun 2024 00:34:19 +0400 Subject: [PATCH 02/21] remove test --- src/pages/Pot/components/Header/Header.tsx | 131 +-------------------- 1 file changed, 2 insertions(+), 129 deletions(-) diff --git a/src/pages/Pot/components/Header/Header.tsx b/src/pages/Pot/components/Header/Header.tsx index b1a6bee6..d0f326d6 100644 --- a/src/pages/Pot/components/Header/Header.tsx +++ b/src/pages/Pot/components/Header/Header.tsx @@ -23,129 +23,6 @@ import { ButtonsWrapper, Container, Description, Fund, HeaderWrapper, Referral, const Header = () => { const { IPFS_BASE_URL, NADA_BOT_URL } = constants; - const payoutsToProcess = { - "nearscript1.near": { - totalAmount: "106400000000000000000000000", - matchingAmount: "1221292742554639409796199769", - donorCount: 80, - }, - "indexers.intear.near": { - totalAmount: "61328000000000000000000000", - matchingAmount: "1052429255284545690573653853", - donorCount: 76, - }, - "forefront_tak.near": { - totalAmount: "23920000000000000000000000", - matchingAmount: "1017795309846140648156973490", - donorCount: 75, - }, - "joydragon.near": { - totalAmount: "205346666666666666660000000", - matchingAmount: "949006792806217598301456686", - donorCount: 87, - }, - "aifunding.near": { - totalAmount: "164016666666666666660000000", - matchingAmount: "486706329182254638442302741", - donorCount: 73, - }, - "nearfunds.near": { - totalAmount: "255990000000000000000000000", - matchingAmount: "315999046792861248853710509", - donorCount: 41, - }, - "bosmobile.near": { - totalAmount: "5866666666666666660000000", - matchingAmount: "95018358419661384687264767", - donorCount: 27, - }, - "tenkdao.near": { - totalAmount: "25700000000000000000000000", - matchingAmount: "84768332486089891980101065", - donorCount: 22, - }, - "flutterchain.near": { - totalAmount: "4300000000000000000000000", - matchingAmount: "64341480821177500776565514", - donorCount: 24, - }, - "socialcap.near": { - totalAmount: "3150000000000000000000000", - matchingAmount: "16426156526838575279632703", - donorCount: 11, - }, - "republicdev.near": { - totalAmount: "14750000000000000000000000", - matchingAmount: "16301638804234824423327740", - donorCount: 10, - }, - "nearcatalog.near": { - totalAmount: "13370000000000000000000000", - matchingAmount: "12773452455552630118427512", - donorCount: 12, - }, - "keypom.near": { - totalAmount: "12450000000000000000000000", - matchingAmount: "8633866656017489135311047", - donorCount: 11, - }, - "opencann.near": { - totalAmount: "2550000000000000000000000", - matchingAmount: "8520929051496037041024945", - donorCount: 9, - }, - "hyperfiles.near": { - totalAmount: "4500000000000000000000000", - matchingAmount: "7175893550273837340437242", - donorCount: 10, - }, - "chatafisha.near": { - totalAmount: "3750000000000000000000000", - matchingAmount: "5721480376946320106575752", - donorCount: 7, - }, - "alem-lib.near": { - totalAmount: "2866666666666666660000000", - matchingAmount: "5461862919955969786302666", - donorCount: 7, - }, - "i-am-human.sputnik-dao.near": { - totalAmount: "3050000000000000000000000", - matchingAmount: "3154558959139585411883485", - donorCount: 6, - }, - "nearbadger.near": { - totalAmount: "2750000000000000000000000", - matchingAmount: "2306877194624002210165043", - donorCount: 7, - }, - "agentswithbenefits.near": { - totalAmount: "2350000000000000000000000", - matchingAmount: "1603995357843272573036784", - donorCount: 6, - }, - "goodworks.near": { - totalAmount: "2616666666666666660000000", - matchingAmount: "1498083873769490543631205", - donorCount: 5, - }, - "bos-workspace.near": { - totalAmount: "4180000000000000000000000", - matchingAmount: "1475224345503222044349658", - donorCount: 6, - }, - "opact_near.near": { - totalAmount: "3450000000000000000000000", - matchingAmount: "1147649110306675875620541", - donorCount: 5, - }, - "refoundlabs.near": { - totalAmount: "2716666666666666660000000", - matchingAmount: "784752623910056542045283", - donorCount: 5, - }, - }; - const { potId, transactionHashes } = useParams(); // Start Modals provider @@ -166,7 +43,7 @@ const Header = () => { const [flaggedAddresses, setFlaggedAddresses] = useState(null); const [potDetail, setPotDetail] = useState(null); const [allDonations, setAlldonations] = useState(null); - const [payoutsToProcesss, setPayoutsToProcess] = useState(null); + const [payoutsToProcess, setPayoutsToProcess] = useState(null); // set fund mathcing pool success const [fundDonation, setFundDonation] = useState(null); @@ -260,7 +137,7 @@ const Header = () => { const projectNotRegistered = registryStatus === null; const userIsAdminOrGreater = admins.includes(accountId) || owner === accountId; - const userIsChefOrGreater = userIsAdminOrGreater || chef === accountId || true; + const userIsChefOrGreater = userIsAdminOrGreater || chef === accountId; const existingApplication = PotSDK.getApplicationByProjectId(potId, context.accountId); @@ -289,11 +166,7 @@ const Header = () => { const handleSetPayouts = () => { if (allDonations && flaggedAddresses !== null) { - console.log({ matching_pool_balance, allDonations, flaggedAddresses }); - calculatePayouts(allDonations, matching_pool_balance, flaggedAddresses).then((calculatedPayouts: any) => { - console.log("test1"); - setPayoutsToProcess(calculatedPayouts); }); } else { From bf788b24060034417ffb8a5389a99466bc970b7e Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Sat, 29 Jun 2024 23:34:27 +0400 Subject: [PATCH 03/21] add payout description --- src/pages/Pot/components/Header/Header.tsx | 3 +- .../components/PayoutsModal/PayoutsModal.tsx | 17 +++++----- .../PayoutsModal/payoutDescription.ts | 31 +++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 src/pages/Pot/components/PayoutsModal/payoutDescription.ts diff --git a/src/pages/Pot/components/Header/Header.tsx b/src/pages/Pot/components/Header/Header.tsx index d0f326d6..2467355d 100644 --- a/src/pages/Pot/components/Header/Header.tsx +++ b/src/pages/Pot/components/Header/Header.tsx @@ -242,7 +242,8 @@ const Header = () => { {existingChallengeForUser ? "Update challenge" : "Challenge payouts"} )} - {canPayoutsBeSet && } + + {/* {canPayoutsBeSet && } */} {canPayoutsBeProcessed && } diff --git a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx index 19a71588..7f135060 100644 --- a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx +++ b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx @@ -1,4 +1,4 @@ -import { Big, useMemo, useState } from "alem"; +import { Big, useMemo, useState, Tooltip, OverlayTrigger } from "alem"; import PotSDK from "@app/SDK/pot"; import Button from "@app/components/Button"; import Text from "@app/components/Inputs/Text/Text"; @@ -6,6 +6,7 @@ import Alert from "@app/modals/ModalDonation/Banners/Alert"; import ModalOverlay from "@app/modals/ModalOverlay"; import { CalculatedPayout } from "@app/types"; import _address from "@app/utils/_address"; +import { payoutDescription } from "./PayoutDescription"; import { ButtonWrapper, Container, PayoutItem, PayoutsView, Title, Total, ExitIcon, TableHeader } from "./styles"; const PayoutsModal = ({ @@ -17,6 +18,8 @@ const PayoutsModal = ({ setPayoutsToProcess: (payouts: null) => void; potId: string; }) => { + console.log("originalPayouts", originalPayouts); + const [payouts, setPayouts] = useState(originalPayouts); const [assigendWeights, setAssignedWeights] = useState>({}); const [qfWeight, setQfWeight] = useState("100"); @@ -191,13 +194,11 @@ const PayoutsModal = ({ /> -
Project
-
Actual QF
-
QF Override
-
QF Weight Adjusted
-
Assigned Weight (%)
-
Assigned Weight Calculation
-
Final Calculation
+ {payoutDescription.map(({ title, description }) => ( + {description} : ""}> +
{title}
+
+ ))}
{payoutsList.map(({ project_id, amount }, idx) => { diff --git a/src/pages/Pot/components/PayoutsModal/payoutDescription.ts b/src/pages/Pot/components/PayoutsModal/payoutDescription.ts new file mode 100644 index 00000000..2f694807 --- /dev/null +++ b/src/pages/Pot/components/PayoutsModal/payoutDescription.ts @@ -0,0 +1,31 @@ +export const payoutDescription = [ + { + title: "Project", + description: "", + }, + { + title: "Actual QF", + description: "", + }, + { + title: "QF Override", + description: "", + }, + { + title: "QF Weight Adjusted", + description: "this calculates based on assigned weights, how much judge weight is worked and pot amount", + }, + { + title: "Assigned Weight (%)", + description: + "this is how much out of the pool the round owner wants based on likelihood to conitnue project, past funding, quality of project and impact", + }, + { + title: "Assigned Weight Calculation", + description: "Assigned Weight Calculation", + }, + { + title: "Final Calculation", + description: "QF Weight Adjusted + Assigned Weight Calculation", + }, +]; From d2a66595703f5a62fa6e3e3a857b949a723b3386 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Sun, 30 Jun 2024 19:27:50 +0400 Subject: [PATCH 04/21] add payout description --- src/pages/Pot/components/Header/Header.tsx | 4 ++-- .../Pot/components/PayoutsModal/PayoutsModal.tsx | 16 ++++++++++------ .../components/PayoutsModal/payoutDescription.ts | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/pages/Pot/components/Header/Header.tsx b/src/pages/Pot/components/Header/Header.tsx index 2467355d..3256bc36 100644 --- a/src/pages/Pot/components/Header/Header.tsx +++ b/src/pages/Pot/components/Header/Header.tsx @@ -44,6 +44,7 @@ const Header = () => { const [potDetail, setPotDetail] = useState(null); const [allDonations, setAlldonations] = useState(null); const [payoutsToProcess, setPayoutsToProcess] = useState(null); + // set fund mathcing pool success const [fundDonation, setFundDonation] = useState(null); @@ -242,8 +243,7 @@ const Header = () => { {existingChallengeForUser ? "Update challenge" : "Challenge payouts"} )} - - {/* {canPayoutsBeSet && } */} + {canPayoutsBeSet && } {canPayoutsBeProcessed && } diff --git a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx index 7f135060..ff4c102b 100644 --- a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx +++ b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx @@ -6,7 +6,7 @@ import Alert from "@app/modals/ModalDonation/Banners/Alert"; import ModalOverlay from "@app/modals/ModalOverlay"; import { CalculatedPayout } from "@app/types"; import _address from "@app/utils/_address"; -import { payoutDescription } from "./PayoutDescription"; +import { payoutDescription } from "./payoutDescription"; import { ButtonWrapper, Container, PayoutItem, PayoutsView, Title, Total, ExitIcon, TableHeader } from "./styles"; const PayoutsModal = ({ @@ -194,11 +194,15 @@ const PayoutsModal = ({ /> - {payoutDescription.map(({ title, description }) => ( - {description} : ""}> -
{title}
-
- ))} + {payoutDescription.map(({ title, description }) => + description ? ( + {description} : ""}> +
{title}
+
+ ) : ( +
{title}
+ ), + )}
{payoutsList.map(({ project_id, amount }, idx) => { diff --git a/src/pages/Pot/components/PayoutsModal/payoutDescription.ts b/src/pages/Pot/components/PayoutsModal/payoutDescription.ts index 2f694807..0160e205 100644 --- a/src/pages/Pot/components/PayoutsModal/payoutDescription.ts +++ b/src/pages/Pot/components/PayoutsModal/payoutDescription.ts @@ -22,7 +22,7 @@ export const payoutDescription = [ }, { title: "Assigned Weight Calculation", - description: "Assigned Weight Calculation", + description: "this calculates based on assigned weights, how much judge weight is worked and pot amount", }, { title: "Final Calculation", From a5e505a55979a82784a0f4d57fb43b551fd7254e Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Mon, 1 Jul 2024 21:54:16 +0400 Subject: [PATCH 05/21] return the logs again --- src/utils/calculatePayouts.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/utils/calculatePayouts.ts b/src/utils/calculatePayouts.ts index 905f1e11..4433615f 100644 --- a/src/utils/calculatePayouts.ts +++ b/src/utils/calculatePayouts.ts @@ -10,8 +10,8 @@ const calculatePayouts = ( const { NADABOT_CONTRACT_ID } = constants; // * QF/CLR logic taken from https://github.com/gitcoinco/quadratic-funding/blob/master/quadratic-funding/clr.py * return new Promise((resolve, reject) => { - // console.log("Calculting payouts; ignoring blacklisted donors &/or projects: ", blacklistedAccounts.join(", ")); - // console.log("totalMatchingPool: ", totalMatchingPool); + console.log("Calculting payouts; ignoring blacklisted donors &/or projects: ", blacklistedAccounts.join(", ")); + console.log("totalMatchingPool: ", totalMatchingPool); // first, flatten the list of donations into a list of contributions const projectContributions: any = []; const allDonors = new Set(); @@ -25,7 +25,7 @@ const calculatePayouts = ( projectContributions.push(val); allDonors.add(d.donor_id); } - // console.log("all donors: ", allDonors); + console.log("all donors: ", allDonors); // fetch human scores for all donors const limit = 100; let curIndex = 0; @@ -54,7 +54,7 @@ const calculatePayouts = ( console.error("error fetching human scores. Continuing anyway: ", e); }) .finally(() => { - // console.log("human scores: ", humanScores); + console.log("human scores: ", humanScores); // take the flattened list of contributions and aggregate // the amounts contributed by each user to each project. // create a dictionary where each key is a projectId and its value @@ -63,7 +63,7 @@ const calculatePayouts = ( const contributions: any = {}; for (const [proj, user, amount] of projectContributions) { if (!humanScores[user] || !humanScores[user].is_human) { - // console.log("skipping non-human: ", user); + console.log("skipping non-human: ", user); continue; } if (!contributions[proj]) { @@ -71,7 +71,7 @@ const calculatePayouts = ( } contributions[proj][user] = Big(contributions[proj][user] || 0).plus(amount); } - // console.log("contributions: ", contributions); + console.log("contributions: ", contributions); // calculate the total overlapping contribution amounts between pairs of users for each project. // create a nested dictionary where the outer keys are userIds and the inner keys are also userIds, // and the inner values are the total overlap between these two users' contributions. @@ -123,7 +123,7 @@ const calculatePayouts = ( matching_amount_str: tot.toFixed(0), }); } - // console.log("totals before: ", totals); + console.log("totals before: ", totals); // if we reach saturation, we need to normalize if (bigtot.gte(totalPot)) { // console.log("NORMALIZING"); @@ -154,7 +154,7 @@ const calculatePayouts = ( totals[i].matching_amount_str = Big(totals[i].matching_amount_str).plus(additionalAllocation).toFixed(0); } - // console.log("CALCULATING TOTALS AFTER RESIDUAL DISTRIBUTION"); + console.log("CALCULATING TOTALS AFTER RESIDUAL DISTRIBUTION"); totalAllocatedBeforeRounding = Big(0); // Initialize the accumulator as a Big object for (const t of totals) { const currentMatchingAmount = Big(t.matching_amount_str); @@ -219,7 +219,7 @@ const calculatePayouts = ( totalAllocatedBeforeRounding = totalAllocatedBeforeRounding.plus(currentMatchingAmount); } residual = totalPot.minus(totalAllocatedBeforeRounding); - // console.log("Residual after final adjustment: ", residual.toFixed(0)); + console.log("Residual after final adjustment: ", residual.toFixed(0)); } } From ba1a135993ba1367624fdcd319ad0df87364f40f Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Tue, 2 Jul 2024 23:02:07 +0400 Subject: [PATCH 06/21] add error handling to fetch flagged address --- src/services/getPotData.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/services/getPotData.ts b/src/services/getPotData.ts index c7b07119..0931b9a9 100644 --- a/src/services/getPotData.ts +++ b/src/services/getPotData.ts @@ -234,12 +234,17 @@ export const getDonations = ({ if (donations) updateState(donations); if (potDetail.public_donations_count !== donations?.length) { - asyncGetPublicDonations(potDetail, potId).then((paginatedDonations) => { - const currentDonations = paginatedDonations ? paginatedDonations.flat() : []; - currentDonations.reverse(); - setPotData(potId, "donations", currentDonations); - updateState(currentDonations); - }); + asyncGetPublicDonations(potDetail, potId) + .then((paginatedDonations) => { + const currentDonations = paginatedDonations ? paginatedDonations.flat() : []; + currentDonations.reverse(); + setPotData(potId, "donations", currentDonations); + updateState(currentDonations); + }) + .catch((err) => { + console.error("error fetching donations ", err); + updateState([]); + }); } }; @@ -287,7 +292,10 @@ export const getFlaggedAccounts = ({ } } }) - .catch((err) => console.log("error getting the flagged accounts ", err)); + .catch((err) => { + console.error("error getting the flagged accounts ", err); + updateState([]); + }); }; export const getSponsorships = ({ potId, updateState }: { potId: string; updateState: UpdateState }) => { From e1d3ec31b5e71b31cb006ac19bb54ff290a2af13 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Fri, 5 Jul 2024 21:08:13 +0400 Subject: [PATCH 07/21] reduce donation limit --- src/services/getPotData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/getPotData.ts b/src/services/getPotData.ts index 0931b9a9..e2f1d0e2 100644 --- a/src/services/getPotData.ts +++ b/src/services/getPotData.ts @@ -200,7 +200,7 @@ export const getPayout = ({ // get matched donations export const asyncGetPublicDonations = (potDetail: PotDetail, potId: string) => { - const limit = 300; // number of donations to fetch per req + const limit = 250; // number of donations to fetch per req const donationsCount = potDetail.public_donations_count; const paginations = [...Array(Math.ceil(donationsCount / limit)).keys()]; From eaeb1107df5d02a11904731c37edfc69597e4418 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Fri, 5 Jul 2024 21:15:28 +0400 Subject: [PATCH 08/21] make set payout only after challange period --- src/pages/Pot/components/Header/Header.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/Pot/components/Header/Header.tsx b/src/pages/Pot/components/Header/Header.tsx index 3256bc36..f3c90d77 100644 --- a/src/pages/Pot/components/Header/Header.tsx +++ b/src/pages/Pot/components/Header/Header.tsx @@ -146,10 +146,9 @@ const Header = () => { const now = Date.now(); - const cooldown_end_ms = _cooldown_end_ms ?? now + 1; + const cooldown_end_ms = _cooldown_end_ms ?? now + 1000; const publicRoundOpen = now >= public_round_start_ms && now < public_round_end_ms; - const publicRoundEnded = now > public_round_end_ms; const applicationOpen = now >= application_start_ms && now < application_end_ms; @@ -161,7 +160,7 @@ const Header = () => { const canPayoutsBeProcessed = userIsAdminOrGreater && now >= cooldown_end_ms && !all_paid_out; - const canPayoutsBeSet = userIsChefOrGreater && !all_paid_out && publicRoundEnded; + const canPayoutsBeSet = userIsChefOrGreater && !all_paid_out && now > cooldown_end_ms; const payoutsChallenges = PotSDK.getPayoutsChallenges(potId); From 648b791aa7a9a374c288afdcdccb8f84683075b3 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Fri, 5 Jul 2024 22:29:18 +0400 Subject: [PATCH 09/21] fix chllange payout button --- src/pages/Pot/components/Header/Header.tsx | 2 +- src/pages/Pot/components/HeaderStatus/statsList.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/Pot/components/Header/Header.tsx b/src/pages/Pot/components/Header/Header.tsx index f3c90d77..6a2aecd1 100644 --- a/src/pages/Pot/components/Header/Header.tsx +++ b/src/pages/Pot/components/Header/Header.tsx @@ -237,7 +237,7 @@ const Header = () => { {registrationApprovedOrNoRegistryProvider ? "Apply to pot" : `Project Registration ${registryStatus}`} )} - {now > public_round_end_ms && now < cooldown_end_ms && ( + {now > public_round_end_ms && now < cooldown_end_ms && !!_cooldown_end_ms && ( diff --git a/src/pages/Pot/components/HeaderStatus/statsList.ts b/src/pages/Pot/components/HeaderStatus/statsList.ts index d3b1f29e..bd2fea3f 100644 --- a/src/pages/Pot/components/HeaderStatus/statsList.ts +++ b/src/pages/Pot/components/HeaderStatus/statsList.ts @@ -6,11 +6,12 @@ const statsList = (potDetail: PotDetail) => { application_end_ms, public_round_start_ms, public_round_end_ms, - cooldown_end_ms, + cooldown_end_ms: _cooldown_end_ms, all_paid_out, } = potDetail; const now = Date.now(); + const cooldown_end_ms = _cooldown_end_ms ?? now + 1000; const stats = [ { @@ -31,11 +32,11 @@ const statsList = (potDetail: PotDetail) => { }, { label: "Challenge period", - daysLeft: cooldown_end_ms, + daysLeft: _cooldown_end_ms, started: now >= public_round_end_ms, - completed: now > cooldown_end_ms && !!cooldown_end_ms, + completed: now > cooldown_end_ms && !!_cooldown_end_ms, progress: - now > cooldown_end_ms && !!cooldown_end_ms + now > cooldown_end_ms && !!_cooldown_end_ms ? 1 : (cooldown_end_ms - now) / (public_round_end_ms - cooldown_end_ms), }, From a901ca2bc2af8a9bd949f3b8be24f4e6fdbbf201 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Sat, 6 Jul 2024 10:37:59 +0400 Subject: [PATCH 10/21] fix set payout now showing --- src/pages/Pot/components/Header/Header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Pot/components/Header/Header.tsx b/src/pages/Pot/components/Header/Header.tsx index 6a2aecd1..1d6a80ce 100644 --- a/src/pages/Pot/components/Header/Header.tsx +++ b/src/pages/Pot/components/Header/Header.tsx @@ -160,7 +160,7 @@ const Header = () => { const canPayoutsBeProcessed = userIsAdminOrGreater && now >= cooldown_end_ms && !all_paid_out; - const canPayoutsBeSet = userIsChefOrGreater && !all_paid_out && now > cooldown_end_ms; + const canPayoutsBeSet = userIsChefOrGreater && !all_paid_out && (now > cooldown_end_ms || !_cooldown_end_ms); const payoutsChallenges = PotSDK.getPayoutsChallenges(potId); From ea0b30103380a380dd239a552a9d760266486181 Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Tue, 9 Jul 2024 20:10:52 +0400 Subject: [PATCH 11/21] post payouts on chain --- .../components/PayoutsModal/PayoutsModal.tsx | 72 +++++++++++++------ 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx index ff4c102b..587ddf51 100644 --- a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx +++ b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx @@ -1,4 +1,4 @@ -import { Big, useMemo, useState, Tooltip, OverlayTrigger } from "alem"; +import { Big, useMemo, useState, Tooltip, OverlayTrigger, context, Near } from "alem"; import PotSDK from "@app/SDK/pot"; import Button from "@app/components/Button"; import Text from "@app/components/Inputs/Text/Text"; @@ -18,8 +18,6 @@ const PayoutsModal = ({ setPayoutsToProcess: (payouts: null) => void; potId: string; }) => { - console.log("originalPayouts", originalPayouts); - const [payouts, setPayouts] = useState(originalPayouts); const [assigendWeights, setAssignedWeights] = useState>({}); const [qfWeight, setQfWeight] = useState("100"); @@ -36,13 +34,6 @@ const PayoutsModal = ({ }); return sum.toString(); }; - // payouts.reduce( - // (acc: any, payout: any) => - // Big(acc) - // .plus(new Big(payout.matchingAmount || payout.amount)) - // .toString(), - // 0, - // ); const [originalTotalAmountYoctos, originalPayoutList] = useMemo(() => { const totalAmount = sumAmount(Object.values(originalPayouts)); @@ -79,19 +70,31 @@ const PayoutsModal = ({ }; // get the final amount and the list of assigned weights calculations - const [finalPayoutList, finalAmountNear, sumAssignedWeightsCalc, remainder] = useMemo(() => { + const [finalPayoutList, finalAmountNear, sumAssignedWeightsCalc, remainder, post] = useMemo(() => { let finalAmount = Big(0); let sumAssignedWeightsCalc = 0; + let post = `Pot Id: ${potId}\\n\\nTotal Pot: 11149.11\\n\\nQF Weight:${qfWeight}%\\n\\nJudges Weights:${jdgWeight}%\\n\\n| Project | Actual QF | QF Override | QF Weight Adjusted | Assigned Weight (%) | Assigned Weight Calculation | Final Calculation |\\n| --- | --- | --- | --- | --- | --- | --- |\\n`; - const payoutList = Object.entries(payouts).map(([projectId, { matchingAmount }]: any) => { + const payoutList = Object.entries(payouts).map(([projectId, { matchingAmount }], idx: any) => { const qfWeightCalc = Big(matchingAmount).mul(parseFloat(qfWeight) / 100); - const jdWeightCalc = Big(originalTotalAmountYoctos) .mul((assigendWeights[projectId] || 0) * parseFloat(jdgWeight)) .div(10e4); const projectFinalAmount = qfWeightCalc.add(jdWeightCalc); finalAmount = finalAmount.plus(projectFinalAmount); + // post calculation + const nearAmount = payoutsList[idx].amount; + const qfWeightCalcNear = parseFloat(nearAmount) * (parseFloat(qfWeight) / 100); + const jdWeightCalcNear = + (parseFloat(originalTotalAmount) * (assigendWeights[projectId] || 0) * parseFloat(jdgWeight)) / 10000; + + const finalAmountNear = qfWeightCalcNear + jdWeightCalcNear; + + post += `| ${projectId} | ${originalPayoutList[idx].amount} | ${nearAmount} | ${qfWeightCalcNear} | ${ + assigendWeights[projectId] || "0.00" + }% | ${jdWeightCalcNear} | ${finalAmountNear} |\\n`; + return { project_id: projectId, amount: projectFinalAmount.toString(), @@ -103,7 +106,7 @@ const PayoutsModal = ({ else setError(""); const remainder = calcNear(remainderYoctos.toString()); - return [payoutList, calcNear(finalAmount.toString()), sumAssignedWeightsCalc, remainder]; + return [payoutList, calcNear(finalAmount.toString()), sumAssignedWeightsCalc, remainder, post]; }, [assigendWeights, payoutsList, qfWeight, jdgWeight]); const handlePayout = () => { @@ -117,11 +120,40 @@ const PayoutsModal = ({ yoctos = sumAmount(payoutsArr); - console.log("check if the original amount equal to the new one", Big(yoctos).cmp(Big(originalTotalAmountYoctos))); - PotSDK.chefSetPayouts(potId, payoutsArr); - }; + const payoutTrx = { + contractName: potId, + methodName: "chef_set_payouts", + args: { payouts: payoutsArr }, + deposit: "1", + gas: "300000000000000", + }; + + const SOCIAL_CONTRACT_ID = "social.near"; + const socialArgs = { + data: { + [context.accountId || ""]: { + post: { + main: `{\"type\":\"md\",\"text\":\"${post}\"}`, + }, + index: { + post: '{"key":"main","value":{"type":"md"}}', + }, + }, + }, + }; + const socialTransaction: any = { + contractName: SOCIAL_CONTRACT_ID, + methodName: "set", + args: socialArgs, + }; + + let depositFloat = JSON.stringify(socialArgs).length * 0.00015; + socialTransaction.deposit = Big(depositFloat).mul(Big(10).pow(24)); + + Near.call([socialTransaction, payoutTrx]); + }; const sumWeight = Object.values(assigendWeights) .filter((value) => !isNaN(value)) .reduce((total, num) => total + num, 0); @@ -144,12 +176,6 @@ const PayoutsModal = ({ {potId} - {/* -
Total amount
-
- {totalAmount} / {originalTotalAmount} N -
-
*/}
Remainder
{remainder} N
From 92353ee8cdc7f5a6118682bee16a1358628f776b Mon Sep 17 00:00:00 2001 From: M-RB3 Date: Wed, 10 Jul 2024 23:59:24 +0400 Subject: [PATCH 12/21] update --- src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx | 8 +++++++- src/pages/Pot/components/PayoutsModal/styles.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx index 587ddf51..cb6accae 100644 --- a/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx +++ b/src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx @@ -2,6 +2,7 @@ import { Big, useMemo, useState, Tooltip, OverlayTrigger, context, Near } from " import PotSDK from "@app/SDK/pot"; import Button from "@app/components/Button"; import Text from "@app/components/Inputs/Text/Text"; +import TextArea from "@app/components/Inputs/TextArea/TextArea"; import Alert from "@app/modals/ModalDonation/Banners/Alert"; import ModalOverlay from "@app/modals/ModalOverlay"; import { CalculatedPayout } from "@app/types"; @@ -23,6 +24,7 @@ const PayoutsModal = ({ const [qfWeight, setQfWeight] = useState("100"); const [jdgWeight, setJdgWeight] = useState("0"); const [error, setError] = useState(""); + const [message, setMessage] = useState(""); const calcNear = (amount: string) => Big(amount).div(Big(10).pow(24)).toNumber().toFixed(2); const calcYoctos = (amount: string) => new Big(amount).mul(new Big(10).pow(24)).toString(); @@ -73,6 +75,7 @@ const PayoutsModal = ({ const [finalPayoutList, finalAmountNear, sumAssignedWeightsCalc, remainder, post] = useMemo(() => { let finalAmount = Big(0); let sumAssignedWeightsCalc = 0; + let post = `Pot Id: ${potId}\\n\\nTotal Pot: 11149.11\\n\\nQF Weight:${qfWeight}%\\n\\nJudges Weights:${jdgWeight}%\\n\\n| Project | Actual QF | QF Override | QF Weight Adjusted | Assigned Weight (%) | Assigned Weight Calculation | Final Calculation |\\n| --- | --- | --- | --- | --- | --- | --- |\\n`; const payoutList = Object.entries(payouts).map(([projectId, { matchingAmount }], idx: any) => { @@ -110,6 +113,8 @@ const PayoutsModal = ({ }, [assigendWeights, payoutsList, qfWeight, jdgWeight]); const handlePayout = () => { + const notes = `${message}\\n${post}`; + let payoutsArr = finalPayoutList.filter((payout) => payout.amount !== "0"); let yoctos = sumAmount(payoutsArr); @@ -135,7 +140,7 @@ const PayoutsModal = ({ data: { [context.accountId || ""]: { post: { - main: `{\"type\":\"md\",\"text\":\"${post}\"}`, + main: `{\"type\":\"md\",\"text\":\"${notes}\"}`, }, index: { post: '{"key":"main","value":{"type":"md"}}', @@ -219,6 +224,7 @@ const PayoutsModal = ({ value={jdgWeight} /> +