Skip to content

Commit

Permalink
Analytics: changed voting power % to quadratic
Browse files Browse the repository at this point in the history
  • Loading branch information
namedotget committed Sep 14, 2023
1 parent c3c5479 commit 9af0ff3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
6 changes: 3 additions & 3 deletions ui/components/dashboard/analytics/AnalyticsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function AnalyticsPage() {
{/*Stats frame*/}
<Frame>
<div className="p-4">
<Label text="Voting Power Key Figures" />
<Label text="Voting Power Key Figures (L1)" />
<div className="flex flex-col justify-around lg:flex-row">
<Data
text={'Voting Power Balance'}
Expand Down Expand Up @@ -106,11 +106,11 @@ export default function AnalyticsPage() {

<div className="w-full mt-2 flex flex-col items-center justify-center lg:mt-3">
<div className="">
<Label text="Voting Power %" />
<Label text="Voting Power" />
</div>
</div>
<div>
<Pie data={analyticsData.distribution} lightMode={lightMode} />
<Pie data={analyticsData.holdersByVMooney} lightMode={lightMode} />
</div>
<div
id="dashboard-analytics-holders-list"
Expand Down
14 changes: 6 additions & 8 deletions ui/components/dashboard/analytics/HoldersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactPaginate from 'react-paginate'
function Box({ text }: any) {
return (
<div className="justify-left flex w-1/3 items-center">
<h4 className="text-[slategrey]">{text}</h4>
<h4 className="text-[slategrey] px-1">{text}</h4>
</div>
)
}
Expand All @@ -21,21 +21,19 @@ function Holders({ currentItems }: any) {
{currentItems &&
currentItems.map((item: any) => (
<div
className="justify-left component-background flex w-full items-center gap-[10%] rounded-2xl border-2 px-2 hover:scale-x-[1.05] transition-all duration-150"
className="justify-left component-background flex w-full items-center gap-[0%] rounded-2xl border-2 px-2 hover:scale-x-[1.05] transition-all duration-150 divide-x-2"
key={item.id}
onClick={() =>
window.open(`https://etherscan.io/address/${item.address}`)
}
>
<h4 className="px-0.5text-[1.25vw] text-blue-600 dark:text-moon-gold">
<h4 className="w-[75px] text-blue-600 dark:text-moon-gold">
{item.id}
</h4>
<div className="flex w-full gap-1">
<div className="flex w-full gap-1 divide-x-2 divide-[#ffffff25]">
<Box text={Number(item.totalLocked).toLocaleString()} />
<Box
text={Math.round(item.totalLocked).toLocaleString('en-US')}
/>
<Box
text={Math.round(item.totalvMooney).toLocaleString('en-US')}
text={Number(item.totalvMooney).toFixed(2).toLocaleString()}
/>
<Box text={item.locktime} />
</div>
Expand Down
11 changes: 8 additions & 3 deletions ui/components/dashboard/analytics/charts/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ Chart.register(ArcElement)

export default function PieChart({ data }: any) {
data.sort((a: any, b: any) => b.value - a.value)
const labels = data.map((item: any) => item.label)
const values = data.map((item: any) => item.value * 100)
const labels = data.map(
(h: any) => h.address.slice(0, 6) + '...' + h.address.slice(-4)
)
const values = data.map((h: any) => h.totalvMooney)

const sum = data.map((data) => data.value).reduce((a, b) => a + b)
console.log(sum)

const chartData = {
labels: labels,
datasets: [
{
label: 'Voting Power %',
label: 'Voting Power',
data: values,
borderWidth: 1,
//background Colors from red to light gold, total of 6
Expand Down
8 changes: 1 addition & 7 deletions ui/lib/tokens/ve-subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function getVMOONEYData() {
const holders = res.data.holders.map((h: any, i: number, arr: any) => {
totalHolders++
const mooney = h.totalLocked / 10 ** 18
const vmooney = mooney * ((h.locktime - now) / (4 * 365 * 86400))
const vmooney = Math.sqrt(mooney * ((h.locktime - now) / (4 * 365 * 86400)))
const holder = {
x: moment.unix(h.initialLock).format('YYYY-MM-DD HH:mm'),
y: totalHolders,
Expand All @@ -55,16 +55,10 @@ export async function getVMOONEYData() {
const holdersByVMooney = [...holders].sort(
(a, b) => b.totalvMooney - a.totalvMooney
)
const distribution = holders.map((h: any) => ({
id: h.id,
label: h.id,
value: h.totalvMooney / totalVMooney,
}))
const totalLockedMooney = res.data.supplies[0].supply / 10 ** 18
return {
holders,
holdersByVMooney,
distribution,
totals: {
vMooney: totalVMooney,
Mooney: totalLockedMooney,
Expand Down

0 comments on commit 9af0ff3

Please sign in to comment.