add earnings to stake overview

This commit is contained in:
Marco van Dijk 2022-04-18 19:00:53 +02:00
parent 5a8f2e7228
commit 387d581bba
4 changed files with 41 additions and 15 deletions

View File

@ -591,8 +591,7 @@ export const getAllEnsInfo = () => async dispatch => {
}; };
export const getEnsInfo = async (addr) => { export const getEnsInfo = async (addr) => {
const response = await apiUtil.getEnsInfo(addr); const response = apiUtil.getEnsInfo(addr);
const data = await response.json();
}; };
@ -606,10 +605,7 @@ export const getAllThreeBoxInfo = () => async dispatch => {
}; };
export const getThreeBoxInfo = async (addr) => { export const getThreeBoxInfo = async (addr) => {
const response = await apiUtil.getThreeBox(addr); const response = apiUtil.getThreeBox(addr);
if (response.ok) {
const data = await response.json();
}
}; };
export const getOrchestratorScores = (year, month) => async dispatch => { export const getOrchestratorScores = (year, month) => async dispatch => {

View File

@ -76,21 +76,24 @@ const StakeOverview = (obj) => {
let orchIdx = livepeer.orchInfo.length - 1; let orchIdx = livepeer.orchInfo.length - 1;
// calc sum of stake // calc sum of stake
let totalStake = 0; let totalStake = 0;
let totalEarnings = 0;
while (orchIdx >= 0) { while (orchIdx >= 0) {
const thisOrch = livepeer.orchInfo[orchIdx]; const thisOrch = livepeer.orchInfo[orchIdx];
orchIdx -= 1; orchIdx -= 1;
if (removeOnlyStakers && !parseInt(thisOrch.totalVolumeUSD)) { if (removeOnlyStakers && !parseFloat(thisOrch.totalVolumeUSD)) {
continue; continue;
} }
totalStake += parseInt(thisOrch.totalStake); totalStake += parseFloat(thisOrch.totalStake);
totalEarnings += parseFloat(thisOrch.totalVolumeETH);
} }
// create slices // create slices
orchIdx = livepeer.orchInfo.length - 1; orchIdx = livepeer.orchInfo.length - 1;
while (orchIdx >= 0) { while (orchIdx >= 0) {
const thisOrch = livepeer.orchInfo[orchIdx]; const thisOrch = livepeer.orchInfo[orchIdx];
const thisStake = parseInt(thisOrch.totalStake); const thisStake = parseFloat(thisOrch.totalStake);
const thisEarnings = parseFloat(thisOrch.totalVolumeETH);
orchIdx -= 1; orchIdx -= 1;
if (removeOnlyStakers && !parseInt(thisOrch.totalVolumeUSD)) { if (removeOnlyStakers && !parseFloat(thisOrch.totalVolumeUSD)) {
continue; continue;
} }
// Add orch stat descending // Add orch stat descending
@ -108,13 +111,17 @@ const StakeOverview = (obj) => {
orchList.push({ orchList.push({
address: thisOrch.id, address: thisOrch.id,
sum: thisStake, sum: thisStake,
ratio: (thisStake / totalStake) * 100 ratio: (thisStake / totalStake) * 100,
earnings: thisEarnings,
earningsRatio: (thisEarnings / totalEarnings) * 100
}); });
} else { } else {
orchList.splice(idx + 1, 0, { orchList.splice(idx + 1, 0, {
address: thisOrch.id, address: thisOrch.id,
sum: thisStake, sum: thisStake,
ratio: (thisStake / totalStake) * 100 ratio: (thisStake / totalStake) * 100,
earnings: thisEarnings,
earningsRatio: (thisEarnings / totalEarnings) * 100
}); });
} }
// Add slice // Add slice
@ -175,6 +182,21 @@ const StakeOverview = (obj) => {
<div className="stroke"> <div className="stroke">
{pieObj} {pieObj}
<div className="flexContainer forceWrap"> <div className="flexContainer forceWrap">
<div className="row">
<div className="rowAlignLeft">
<h4>Orchestrator</h4>
</div>
<div className="strokeSmollLeft" style={{ minWidth: '100px' }} >
<div className="rowAlignLeft" >
<h4>Stake</h4>
</div>
</div>
<div className="strokeSmollLeft" style={{ minWidth: '100px' }} >
<div className="rowAlignLeft" >
<h4>Earnings</h4>
</div>
</div>
</div>
{ {
orchList.map(function (orch) { orchList.map(function (orch) {
return ( return (
@ -190,6 +212,14 @@ const StakeOverview = (obj) => {
<span>({orch.ratio.toFixed(2)} %)</span> <span>({orch.ratio.toFixed(2)} %)</span>
</div> </div>
</div> </div>
<div className="strokeSmollLeft" style={{ minWidth: '100px' }} >
<div className="rowAlignLeft" >
<h4>{orch.earnings.toFixed(2)} Eth</h4>
</div>
<div className="rowAlignRight" >
<span>({orch.earningsRatio.toFixed(2)} %)</span>
</div>
</div>
</div> </div>
) )
}) })

View File

@ -65,7 +65,7 @@ const Home = (obj) => {
<button className="waveButton" onClick={() => { <button className="waveButton" onClick={() => {
setRedirectToTickets(true); setRedirectToTickets(true);
}}> }}>
<p>💵 Tickets 💰</p> <p>📈 Statistics 💰</p>
</button> </button>
</div> </div>
<div className="verticalDivider" /> <div className="verticalDivider" />

View File

@ -13,7 +13,7 @@ const Tickets = (obj) => {
const [ticketsPerMonth, setTicketsPerMonth] = useState([]); const [ticketsPerMonth, setTicketsPerMonth] = useState([]);
const [redirectToHome, setRedirectToHome] = useState(false); const [redirectToHome, setRedirectToHome] = useState(false);
console.log("Rendering Winning Ticket Viewer"); console.log("Rendering Stats Viewer");
useEffect(() => { useEffect(() => {
// Process Winning tickets as: // Process Winning tickets as:
@ -185,7 +185,7 @@ const Tickets = (obj) => {
}}> }}>
<h1>🏠</h1> <h1>🏠</h1>
</button> </button>
<h4 className="rowAlignLeft withWrap showNeverOnMobile">Winning Tickets</h4> <h4 className="rowAlignLeft withWrap showNeverOnMobile">Statistics</h4>
</div> </div>
</div> </div>
<div id='bodyContent'> <div id='bodyContent'>