Skip to content

Commit

Permalink
feat(neuron-ui): rename APY to APC
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Nov 14, 2019
1 parent e6d6060 commit c337a21
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DefaultButton } from 'office-ui-fabric-react'
import { useTranslation } from 'react-i18next'
import { ckbCore, getBlockByNumber } from 'services/chain'
import { showMessage } from 'services/remote'
import calculateAPY from 'utils/calculateAPY'
import calculateAPC from 'utils/calculateAPC'
import { shannonToCKBFormatter, uniformTimeFormatter, localNumberFormatter } from 'utils/formatters'
import calculateClaimEpochNumber from 'utils/calculateClaimEpochNumber'
import { epochParser } from 'utils/parsers'
Expand Down Expand Up @@ -142,7 +142,7 @@ const DAORecord = ({
</div>
</div>
<div className={styles.secondaryInfo}>
<span>{`APY: ~${calculateAPY(compensation.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
<span>{`APC: ~${calculateAPC(compensation.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
<span>{uniformTimeFormatter(+timestamp)}</span>
<span>{metaInfo}</span>
</div>
Expand Down
12 changes: 6 additions & 6 deletions packages/neuron-ui/src/components/NervosDAO/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import appState from 'states/initStates/app'
import { AppActions, StateWithDispatch } from 'states/stateProvider/reducer'
import { updateNervosDaoData, clearNervosDaoData } from 'states/stateProvider/actionCreators'

import calculateGlobalAPY from 'utils/calculateGlobalAPY'
import calculateGlobalAPC from 'utils/calculateGlobalAPC'
import calculateFee from 'utils/calculateFee'
import { shannonToCKBFormatter, CKBToShannonFormatter } from 'utils/formatters'
import { MIN_DEPOSIT_AMOUNT, MEDIUM_FEE_RATE, SHANNON_CKB_RATIO, CapacityUnit } from 'utils/const'
Expand Down Expand Up @@ -45,7 +45,7 @@ const NervosDAO = ({
const [activeRecord, setActiveRecord] = useState<State.NervosDAORecord | null>(null)
const [errorMessage, setErrorMessage] = useState('')
const [withdrawList, setWithdrawList] = useState<(string | null)[]>([])
const [globalAPY, setGlobalAPY] = useState(0)
const [globalAPC, setGlobalAPC] = useState(0)

const clearGeneratedTx = useCallback(() => {
dispatch({
Expand Down Expand Up @@ -106,8 +106,8 @@ const NervosDAO = ({

useEffect(() => {
if (tipBlockTimestamp) {
calculateGlobalAPY(tipBlockTimestamp).then(apy => {
setGlobalAPY(apy)
calculateGlobalAPC(tipBlockTimestamp).then(apc => {
setGlobalAPC(apc)
})
}
}, [tipBlockTimestamp])
Expand Down Expand Up @@ -298,10 +298,10 @@ const NervosDAO = ({
<Text as="span" variant="small" block>{`Epoch number: ${epochInfo.number}`}</Text>
<Text as="span" variant="small" block>{`Epoch index: ${epochInfo.index}`}</Text>
<Text as="span" variant="small" block>{`Epoch length: ${epochInfo.length}`}</Text>
<Text as="span" variant="small" block>{`APY: ~${globalAPY}%`}</Text>
<Text as="span" variant="small" block>{`APC: ~${globalAPC}%`}</Text>
</Stack>
)
}, [epoch, globalAPY])
}, [epoch, globalAPC])

const lockAndFreeProperties = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
"locked": "Locked",
"deposit": "Deposit",
"deposit-receipts": "Deposit Receipts",
"apy": "APY",
"apc": "APC",
"deposit-at": "Deposit at {{time}}",
"claim": "Claim",
"withdraw": "Withdraw",
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
"locked": "已锁定",
"deposit": "存入",
"deposit-receipts": "存款凭证",
"apy": "预期年化利率",
"apc": "年化锁定补贴率",
"deposit-at": "存入于{{time}}",
"claim": "取款",
"withdraw": "结算",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ export default {
'return 0 if the genesis block is not loaded': {
currentTime: Date.now(),
genesisTime: undefined,
expectAPY: 0,
expectAPC: 0,
},
'one period and one handrand days': {
currentTime: new Date('2023-04-10').getTime(),
genesisTime: new Date('2019-01-01').getTime(),
expectAPY: 2.369552868619654,
expectAPC: 2.369552868619654,
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import calculateGlobalAPC from 'utils/calculateGlobalAPC'
import fixtures from './fixtures'

describe('calculate the global apc', () => {
const fixtureTable = Object.entries(fixtures).map(([title, { currentTime, genesisTime, expectAPC }]) => [
title,
currentTime,
genesisTime,
expectAPC,
])

test.each(fixtureTable)(`%s`, async (_title, currentTime, genesisTime, expectAPC) => {
const apc = await calculateGlobalAPC(currentTime, genesisTime)
expect(apc).toBe(expectAPC === 0 ? 0 : +expectAPC.toFixed(2))
})
})

This file was deleted.

0 comments on commit c337a21

Please sign in to comment.