Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pie 482 #292

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/components/staking/Rewards.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@
{:else}
{#if $stakingData.rewards && $stakingData.rewards.length > 0}
{#each $stakingData.rewards.slice(0, itemsNumber) as reward}
{#if reward.type != 'distributed'}
<!-- <a
href={"#/staking_reward_breakdown/" + reward.timestamp * 1000}
target="_blank"
{#if reward.type != 'distributed' && reward.rewardToken == smartcontracts.reward}
<a
href={`#/staking_reward_breakdown/${reward.windowIndex}/${reward.amount}`}
class="flex flex-col nowrap w-92pc mx-4pc mt-6 swap-from rounded-20px bg-white p-16px"
> -->
<a
>
<!-- <a
target="_blank"
href="https://etherscan.io/tx/{reward.id}"
class="flex flex-col nowrap w-92pc mx-4pc mt-6 swap-from rounded-20px bg-white p-16px">
class="flex flex-col nowrap w-92pc mx-4pc mt-6 swap-from rounded-20px bg-white p-16px"> -->
<div class="flex items-center justify-between">
<div class="flex nowrap intems-center p-1 font-thin">
{new Date(reward.timestamp * 1000).toDateString()}
Expand Down
29 changes: 13 additions & 16 deletions src/components/staking/rewards/Activity.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import { formatFiat } from '../../../components/helpers.js';
import { toNum } from '../../../helpers/staking.js';
import images from '../../../config/images.json';
import epochsJSON from '../../../config/epochs.json';
import BigNumber from 'bignumber.js';

export let timestamp;
export let epoch;
export let rewardsAmount;
let currentAddress;
let epoch;
let currentAccount;
let votingPower;
let accountWithdrawnRewards;
Expand All @@ -18,27 +17,25 @@
if (currentAddress !== $eth.address) {
currentAddress = $eth.address;

// TODO: this should be changed, fetch the epochs from backend
epoch = epochsJSON.epochs.find(
(epoch) => epoch.startDate <= timestamp && epoch.endDate >= timestamp,
let currentAccountIndex = Object.keys(epoch.merkleTree.claims).find((address) =>
address.toLowerCase() == $eth.address.toLowerCase()
);

currentAccount = epoch.merkleTree.leafs.find((leaf) => leaf.staker.id == $eth.address);
currentAccount = epoch.merkleTree.claims[currentAccountIndex];

if(currentAccount) {
currentAccount.participant = epoch.participants.find(
(participant) => participant.address == $eth.address,
(participant) => participant.address.toLowerCase() == $eth.address.toLowerCase()
);

let accountVeTokenBalance = new BigNumber(currentAccount.staker.accountVeTokenBalance);
let accountVeTokenBalance = new BigNumber(currentAccount.metaData.staker.accountVeTokenBalance);
let veTokenTotalSupply = new BigNumber(epoch.stakingStats.veTokenTotalSupply);
votingPower = accountVeTokenBalance.times(100).div(veTokenTotalSupply).toFixed(2);
votingPower = accountVeTokenBalance.times(100).div(veTokenTotalSupply).toFixed(3);

accountWithdrawnRewards = new BigNumber(currentAccount.staker.accountWithdrawnRewards);
accountWithdrawnRewards = accountWithdrawnRewards.times(epoch.slice.usd);
accountWithdrawnRewards = new BigNumber(rewardsAmount);
accountWithdrawnRewards = accountWithdrawnRewards.times(epoch.slice.nav);
console.log(currentAccount.metaData.staker, epoch.slice.nav);
}

console.log("account has changed, currentAccount is now", currentAccount);
}
}
</script>
Expand Down Expand Up @@ -73,7 +70,7 @@
</div>
<div class="flex flex-col items-right">
<div class="">
{underlying.amount}
{formatFiat(toNum(underlying.amount), ',', '.', '')}
</div>
</div>
</div>
Expand All @@ -87,7 +84,7 @@
</div>
<div class="flex flex-col items-right">
<div class="">
{formatFiat(toNum(currentAccount.staker.accountVeTokenBalance), ',', '.', '')}
{formatFiat(toNum(currentAccount.metaData.staker.accountVeTokenBalance), ',', '.', '')}
</div>
</div>
</div>
Expand Down
31 changes: 17 additions & 14 deletions src/components/staking/rewards/Governance.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
import { formatFiat } from '../../../components/helpers.js';
import { toNum, AVG_SECONDS_MONTH} from '../../../helpers/staking.js';
import images from '../../../config/images.json';
import epochsJSON from '../../../config/epochs.json';

export let timestamp;
let report;
let totalVeDoughVoted;
export let epoch;
let participationRatio;
let totalVeDoughScore = 0;

// TODO: this should be changed, fetch the epochs from backend
report = epochsJSON.epochs.find(epoch => epoch.startDate <= timestamp && epoch.endDate >= timestamp);

totalVeDoughVoted = report.participants.reduce((previousValue, currentValue) => {
return {score: previousValue.score + currentValue.score};
epoch.participants.forEach(participant => {
if(participant.votes.length > 0) {
let participantScoreTotal = 0;

participant.votes.forEach(vote => {
participantScoreTotal += vote.score;
});

totalVeDoughScore += participantScoreTotal / participant.votes.length;
}
});

participationRatio = ((totalVeDoughVoted.score * 100) / toNum(report.stakingStats.veTokenTotalSupply)).toFixed(2);
participationRatio = ((totalVeDoughScore * 100) / toNum(epoch.stakingStats.veTokenTotalSupply)).toFixed(2);
</script>

<div class="flex flex-col items-center w-full md:w-1/2 p-1px bg-lightgrey rounded-16 m-10px">
Expand All @@ -29,7 +32,7 @@
</div>
<div class="flex flex-col items-right">
<div class="">
{formatFiat(toNum(report.stakingStats.veTokenTotalSupply), ',', '.', '')}
{formatFiat(toNum(epoch.stakingStats.veTokenTotalSupply), ',', '.', '')}
</div>
</div>
</div>
Expand All @@ -40,7 +43,7 @@
</div>
<div class="flex flex-col items-right">
<div class="">
{Math.floor(report.stakingStats.averageTimeLock / AVG_SECONDS_MONTH)}
{Math.floor(epoch.stakingStats.averageTimeLock / AVG_SECONDS_MONTH)}
</div>
</div>
</div>
Expand All @@ -51,7 +54,7 @@
</div>
<div class="flex flex-col items-right">
<div class="">
{report.proposals.length}
{epoch.proposals.length}
</div>
</div>
</div>
Expand All @@ -73,7 +76,7 @@
</div>
<div class="flex flex-col items-right">
<div class="">
{formatFiat(totalVeDoughVoted.score, ',', '.', '')}
{formatFiat(totalVeDoughScore, ',', '.', '')}
</div>
</div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/components/staking/rewards/Revenues.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import { formatFiat } from '../../../components/helpers.js';
import images from '../../../config/images.json';

export let timestamp;
let revenue = revenuesJSON.revenues.find(revenue => revenue.startDate <= timestamp && revenue.endDate >= timestamp);
console.log(revenue);
export let windowIndex;
let revenue = revenuesJSON.revenues.find(revenue => revenue.windowIndex <= windowIndex);
</script>

<div class="flex flex-col items-center w-full md:w-1/2 p-1px bg-lightgrey rounded-16 m-10px">
Expand Down
110 changes: 108 additions & 2 deletions src/config/dao-revenues.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"startDate": 1627768800000,
"endDate": 1630360800000,
"startBlock": 12970475,
"endBlock": 13171232,
"endBlock": 13171232,
"windowIndex": 0,
"total": 1320238.56,
"breakdowns": [
{
Expand Down Expand Up @@ -103,6 +104,111 @@
]
}
]
}
},
{
"startDate": 1627768800000,
"endDate": 1630360800000,
"startBlock": 12970475,
"endBlock": 13171232,
"windowIndex": 2,
"total": 1320238.56,
"breakdowns": [
{
"title": "Actively Managed Treasury",
"total": 432123,
"underlyings": [
{
"symbol": "SLICE Issued",
"amount": 123123
},
{
"symbol": "SLICE Nav",
"amount": 456456,
"fiat": "$"
},
{
"symbol": "SLICE Redistributed",
"amount": 789789
},
{
"address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"symbol": "WBTC",
"amount": 424
},
{
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"symbol": "WETH",
"amount": 123213.45
},
{
"address": "0x8d1ce361eb68e9e05573443c407d4a3bed23b033",
"symbol": "DEFI++",
"amount": 12354.476
}
]
},
{
"title": "Products Streaming Fees",
"total": 123321,
"underlyings": [
{
"address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"symbol": "WBTC",
"amount": 424,
"fiat": "$"
},
{
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"symbol": "WETH",
"amount": 123213.45,
"fiat": "$"
},
{
"address": "0x8d1ce361eb68e9e05573443c407d4a3bed23b033",
"symbol": "DEFI++",
"amount": 12354.476,
"fiat": "$"
}
]
},
{
"title": "Misc",
"total": 44321234,
"underlyings": [
{
"symbol": "Strategies Performance Fees",
"amount": 424123431,
"fiat": "$"
},
{
"symbol": "Linear Finance DEFI++",
"amount": 123213.45,
"fiat": "$"
},
{
"symbol": "Withdrawal Fees on Farming",
"amount": 12354.476,
"fiat": "$"
}
]
},
{
"title": "Treasury Vaults",
"total": 12123412341,
"underlyings": [
{
"symbol": "Treasury Vaults Management",
"amount": 424123431,
"fiat": "$"
},
{
"symbol": "Treasury Vaults Performance",
"amount": 123213.45,
"fiat": "$"
}
]
}
]
}
]
}
Loading