Public
Edited
Mar 31, 2023
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barY(extendedProposals, { x: "rank", y: "whaleVotePct" }),
Plot.ruleY([0])
]
})
Insert cell
extendedProposals = R.pipe(
R.slice(0, 6),
R.map((proposal) => ({ ...proposal, whalePct: whalePct(proposal.votes) })),
R.map((proposal) => ({
...proposal,
whaleVotePct: proposal.whalePct.whaleVotePct
}))
)(sortedProposals)
Insert cell
whaleVoteFilter(sortedProposals[0].votes)
Insert cell
whalePct = (votes) => {
let voteSum = sumVotes(votes);
let whaleVotes = sumVotes(whaleVoteFilter(votes));
let nonWhaleVotes = sumVotes(notWhaleVoteFilter(votes));
return {
whaleVotes,
nonWhaleVotes,
whaleVotePct: (whaleVotes / voteSum) * 100,
nonWhaleVotePct: (nonWhaleVotes / voteSum) * 100
};
}
Insert cell
sumVotes = (votes) =>
votes.reduce(
(sum, vote) => sum + (vote.direction === 1 ? vote.weight : 0 - vote.weight),
0
)
Insert cell
whaleVoteFilter = R.filter(
(vote) => vote.address.toLocaleLowerCase() === TRAIT_WHALE
)
Insert cell
notWhaleVoteFilter = R.filter(
(vote) => vote.address.toLocaleLowerCase() !== TRAIT_WHALE
)
Insert cell
sortedProposals = round.proposals
.sort((a, b) => b.voteCount - a.voteCount)
.map((proposal, rank) => ({ ...proposal, rank: rank + 1 }))
Insert cell
round = (
await axios.post("https://prod.backend.prop.house/graphql", {
query: `{
auction(id: 179) {
title
proposals {
id,
title,
tldr,
voteCount,
votes {
id
address
direction
weight
}
}
}
}`
})
).data.data.auction
Insert cell
TRAIT_WHALE = String(
"0x624E7931F317bdfA1C2C0aCe61B5F82591140195".toLocaleLowerCase()
)
Insert cell
axios = require("axios")
Insert cell
R = require("ramda")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more