Skip to content

Commit

Permalink
Merge pull request #683 from artizen-fund/updateData
Browse files Browse the repository at this point in the history
Update data
  • Loading branch information
rubelux authored Dec 6, 2023
2 parents c2f95e5 + f71b81f commit 5975084
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
21 changes: 2 additions & 19 deletions src/components/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,9 @@ const Leaderboard = ({ openEditions, isWinner, count, totalSales, matchFundPoole
'NEXT_PUBLIC_BASE_ARTIFACT_PRICE',
)

const { salesArtifacts, spli80, prize, totalAward, projectMatchFund, calculateMatchFundContribution } =
const { salesArtifacts, prize, totalAward, projectMatchFund, calculateMatchFundContribution, getSalesArtifacts } =
calculateSales(isWinner, matchFundPooled, count, totalSales)

// const salesArtifacts = BASE_ARTIFACT_PRICE * count

// //add match to matchFundPooled
// const spli80 = (80 * matchFundPooled) / 100
// //only winners get 20% of the match fund on top of their sales
// const split20 = (20 * matchFundPooled) / 100

// const getMatchFundMoney = (countH: number): number => {
// const split = totalSales > 0 ? (countH * 100) / totalSales : 0
// console.log('this project split is: ', split)
// //split: 6*100/8 = 75%
// //spli80: 80*10/100 = 8
// return (spli80 * split) / 100
// }

// const sells = (salesArtifacts + getMatchFundMoney(count) + salesArtifacts + (isWinner ? split20 : 0)).toFixed(2)

const title = (
<div>
<BiggerText>Ξ{totalAward} raised:</BiggerText>
Expand All @@ -76,7 +59,7 @@ const Leaderboard = ({ openEditions, isWinner, count, totalSales, matchFundPoole
{index === 0 && <StyledGlyph glyph="crown" level={1} color="black" darkColor="algae" />}
</div>
<div>
<Grey>Ξ&nbsp;{BASE_ARTIFACT_PRICE * user.copies}</Grey>
<Grey>Ξ&nbsp;{getSalesArtifacts(user.copies)}</Grey>
<Green>+&nbsp; Ξ&nbsp;{calculateMatchFundContribution(user.copies)}</Green>{' '}
<Amount>
| <span> minted</span> {user.copies}
Expand Down
16 changes: 9 additions & 7 deletions src/lib/calculateSales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ export const calculateSales = (isWinner: boolean, matchFundPooled: number, count

const totalProjectSales = getSalesArtifacts(count)

const spli80 = (80 * matchFundPooled) / 100
const split20 = (20 * matchFundPooled) / 100
const projectMatchFund = getMatchFundMoney(totalSales, count, spli80)
const spli90 = (90 * matchFundPooled) / 100
const split10 = (10 * matchFundPooled) / 100
const projectMatchFund = getMatchFundMoney(totalSales, count, spli90)

const totalAward = (totalProjectSales + projectMatchFund + (isWinner ? split20 : 0)).toFixed(2)
const totalAward = (totalProjectSales + projectMatchFund + (isWinner ? split10 : 0)).toFixed(2)

return {
salesArtifacts: totalProjectSales,
projectMatchFund: projectMatchFund.toFixed(2),
spli80: spli80.toFixed(2),
prize: split20.toFixed(2),
spli80: spli90.toFixed(2),
prize: split10.toFixed(2),
totalAward,
getSalesArtifacts: (newCount: any) => getSalesArtifacts(newCount).toFixed(2),
calculateMatchFundContribution: (newCount: any) => {
return (getSalesArtifacts(newCount) + getMatchFundMoney(totalSales, newCount, spli80)).toFixed(2)
return getMatchFundMoney(totalSales, newCount, spli90).toFixed(2)
// return (getSalesArtifacts(newCount) + getMatchFundMoney(totalSales, newCount, spli90)).toFixed(2)
},
}
}

0 comments on commit 5975084

Please sign in to comment.