Skip to content

Commit

Permalink
Merge pull request #1377 from edenia/dev
Browse files Browse the repository at this point in the history
Production Release
  • Loading branch information
xavier506 committed Nov 3, 2023
2 parents 48ce00d + 8bde3a8 commit cb65e3b
Show file tree
Hide file tree
Showing 31 changed files with 300 additions and 405 deletions.
72 changes: 38 additions & 34 deletions hapi/src/utils/producer.util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const axiosUtil = require('./axios.util')
const eosUtil = require('./eos.util')
const hasuraUtil = require('./hasura.util')
const net = require('node:net')
const os = require('node:os')

Expand Down Expand Up @@ -108,6 +107,15 @@ const getEndpoints = (nodes) => {
return endpoints
}

const getCurrencyStats = async () => {
const systemData = await eosUtil.getCurrencyStats({
symbol: eosConfig.rewardsToken,
code: 'eosio.token'
})

return systemData[eosConfig.rewardsToken]
}

const getExpectedRewards = async (producers, totalVotes) => {
let rewards = []

Expand Down Expand Up @@ -162,39 +170,49 @@ const getLibreRewards = async (producers) => {
}

const getTelosRewards = async (producers) => {
const telosPrice = (await getEOSPrice()) || 0
const estimatedRewards = 8.34 * telosPrice ** -0.516 // approximate rewards per half hour
const producerRewards = Math.min(estimatedRewards * 48, 28000)
const currencyStats = await getCurrencyStats()
const { rows: payrateRows } = await eosUtil.getTableRows({
code: 'eosio',
scope: 'eosio',
table: 'payrate',
reverse: false,
limit: 1,
json: true,
lower_bound: null
})

const tokenSupply = parseFloat(currencyStats.supply)
const bPayRate = payrateRows?.at(0)?.bpay_rate / 100000
const toProducers = (bPayRate * tokenSupply) / 365 // (bPayRate * tokenSupply * secondsPerDay) / secondsPerYear

const MAX_PAID_PRODUCERS = 42
const topProducers = producers.slice(0, MAX_PAID_PRODUCERS)
const activeCount = topProducers.length
const shareCount =
activeCount <= 21
? activeCount * 2
: MAX_PAID_PRODUCERS + (activeCount - 21)

const topProducers = producers.slice(0, 42)
const producerRewards = toProducers / shareCount

return topProducers.map((producer, i) => {
const totalRewards = i < 21 ? producerRewards : producerRewards / 2
const totalRewards = i < 21 ? producerRewards * 2 : producerRewards

return {
producer: producer.owner,
vote_rewards: totalRewards * 0.75,
block_rewards: totalRewards * 0.25,
vote_rewards: 0,
block_rewards: totalRewards,
total_rewards: totalRewards
}
})
}

const getEOSIORewards = async (producers, totalVotes) => {
const systemData = await eosUtil.getCurrencyStats({
symbol: eosConfig.rewardsToken,
code: 'eosio.token'
})
const currencyStats = await getCurrencyStats()
let inflation = 0

if (
systemData[eosConfig.rewardsToken] &&
systemData[eosConfig.rewardsToken].supply
) {
inflation =
parseInt(systemData[eosConfig.rewardsToken].supply.split(' ')[0]) /
100 /
365
if (currencyStats && currencyStats.supply) {
inflation = parseInt(currencyStats.supply.split(' ')[0]) / 100 / 365
}

let blockReward = 0.25 // reward for each block produced
Expand Down Expand Up @@ -263,7 +281,6 @@ const getEOSIORewards = async (producers, totalVotes) => {
const getVotes = (votes) => {
switch (eosConfig.networkName) {
case eosConfig.knownNetworks.telos:
return parseFloat(votes)
case eosConfig.knownNetworks.libre:
return parseFloat(votes) / 10000
case eosConfig.knownNetworks.wax:
Expand All @@ -281,19 +298,6 @@ const getEOSIOVotes = (votes, weekHalfLife) => {
return parseFloat(votes) / 2 ** weight
}

const getEOSPrice = async () => {
const query = `
query {
setting: setting_by_pk(id: 1) {
token_price
}
}
`
const data = await hasuraUtil.request(query)

return data?.setting?.token_price
}

const jsonParse = (string) => {
try {
const json = JSON.parse(string)
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.jungle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</url>
<url>
<loc>https://jungle.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://jungle.antelope.tools/cpu-benchmark</loc>
Expand All @@ -49,11 +49,11 @@
</url>
<url>
<loc>https://jungle.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://jungle.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://jungle.antelope.tools/block-producers/lioninjungle</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.libre-testnet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</url>
<url>
<loc>https://libre-testnet.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://libre-testnet.antelope.tools/block-distribution</loc>
Expand Down Expand Up @@ -65,11 +65,11 @@
</url>
<url>
<loc>https://libre-testnet.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://libre-testnet.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://libre-testnet.antelope.tools/block-producers/rioblocks</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.libre.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</url>
<url>
<loc>https://libre.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://libre.antelope.tools/ricardian-contract</loc>
Expand All @@ -57,11 +57,11 @@
</url>
<url>
<loc>https://libre.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://libre.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://libre.antelope.tools/block-producers/libretech</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.mainnet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</url>
<url>
<loc>https://eos.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://eos.antelope.tools/ricardian-contract</loc>
Expand All @@ -45,11 +45,11 @@
</url>
<url>
<loc>https://eos.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://eos.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://eos.antelope.tools/block-producers/aus1genereos</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.telos-testnet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</url>
<url>
<loc>https://telos-testnet.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://telos-testnet.antelope.tools/ricardian-contract</loc>
Expand All @@ -54,11 +54,11 @@
</url>
<url>
<loc>https://telos-testnet.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://telos-testnet.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://telos-testnet.antelope.tools/block-producers/southafrica1</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.telos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</url>
<url>
<loc>https://telos.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://telos.antelope.tools/ricardian-contract</loc>
Expand All @@ -54,11 +54,11 @@
</url>
<url>
<loc>https://telos.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://telos.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://telos.antelope.tools/block-producers/caleosblocks</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.wax-testnet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</url>
<url>
<loc>https://wax-testnet.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-01-19</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://wax-testnet.antelope.tools/ricardian-contract</loc>
Expand All @@ -46,11 +46,11 @@
</url>
<url>
<loc>https://wax-testnet.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://wax-testnet.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://wax-testnet.antelope.tools/block-producers/blokcrafters</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.wax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</url>
<url>
<loc>https://wax.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://wax.antelope.tools/ricardian-contract</loc>
Expand All @@ -46,11 +46,11 @@
</url>
<url>
<loc>https://wax.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://wax.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://wax.antelope.tools/block-producers/nation.wax</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.xpr-testnet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</url>
<url>
<loc>https://xpr-testnet.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://xpr-testnet.antelope.tools/nodes-distribution</loc>
Expand All @@ -50,11 +50,11 @@
</url>
<url>
<loc>https://xpr-testnet.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://xpr-testnet.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://xpr-testnet.antelope.tools/block-producers/saltant</loc>
Expand Down
6 changes: 3 additions & 3 deletions webapp/public/sitemap.xpr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</url>
<url>
<loc>https://xpr.antelope.tools/undiscoverable-bps</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://xpr.antelope.tools/nodes-distribution</loc>
Expand All @@ -50,11 +50,11 @@
</url>
<url>
<loc>https://xpr.antelope.tools/about</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://xpr.antelope.tools/help</loc>
<lastmod>2023-09-30</lastmod>
<lastmod>2023-11-02</lastmod>
</url>
<url>
<loc>https://xpr.antelope.tools/block-producers/protonnz</loc>
Expand Down
26 changes: 14 additions & 12 deletions webapp/src/components/EmptyState/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react'
import { Link as RouterLink } from 'react-router-dom'
import { Link } from 'react-router-dom'
import { makeStyles } from '@mui/styles'
import { useTranslation } from 'react-i18next'
import Link from '@mui/material/Link'
import Button from '@mui/material/Button'

import styles from './styles'

const useStyles = makeStyles(styles)

const EmptyState = () => {
const EmptyState = ({ isNonCompliant }) => {
const classes = useStyles()
const { t } = useTranslation('producerCardComponent')

Expand All @@ -21,15 +21,17 @@ const EmptyState = () => {
alt=""
/>
<span>{t('emptyState')}</span>
<Link
component={RouterLink}
to="/undiscoverable-bps"
variant="contained"
color="primary"
mt={2}
>
{t('viewList')}
</Link>
{isNonCompliant && (
<Button
component={Link}
to="/undiscoverable-bps"
variant="contained"
color="primary"
mt={2}
>
{t('viewList')}
</Button>
)}
</div>
)
}
Expand Down
Loading

0 comments on commit cb65e3b

Please sign in to comment.