Skip to content

Commit c337a21

Browse files
committed
feat(neuron-ui): rename APY to APC
1 parent e6d6060 commit c337a21

9 files changed

Lines changed: 28 additions & 28 deletions

File tree

packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DefaultButton } from 'office-ui-fabric-react'
33
import { useTranslation } from 'react-i18next'
44
import { ckbCore, getBlockByNumber } from 'services/chain'
55
import { showMessage } from 'services/remote'
6-
import calculateAPY from 'utils/calculateAPY'
6+
import calculateAPC from 'utils/calculateAPC'
77
import { shannonToCKBFormatter, uniformTimeFormatter, localNumberFormatter } from 'utils/formatters'
88
import calculateClaimEpochNumber from 'utils/calculateClaimEpochNumber'
99
import { epochParser } from 'utils/parsers'
@@ -142,7 +142,7 @@ const DAORecord = ({
142142
</div>
143143
</div>
144144
<div className={styles.secondaryInfo}>
145-
<span>{`APY: ~${calculateAPY(compensation.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
145+
<span>{`APC: ~${calculateAPC(compensation.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
146146
<span>{uniformTimeFormatter(+timestamp)}</span>
147147
<span>{metaInfo}</span>
148148
</div>

packages/neuron-ui/src/components/NervosDAO/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import appState from 'states/initStates/app'
88
import { AppActions, StateWithDispatch } from 'states/stateProvider/reducer'
99
import { updateNervosDaoData, clearNervosDaoData } from 'states/stateProvider/actionCreators'
1010

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

5050
const clearGeneratedTx = useCallback(() => {
5151
dispatch({
@@ -106,8 +106,8 @@ const NervosDAO = ({
106106

107107
useEffect(() => {
108108
if (tipBlockTimestamp) {
109-
calculateGlobalAPY(tipBlockTimestamp).then(apy => {
110-
setGlobalAPY(apy)
109+
calculateGlobalAPC(tipBlockTimestamp).then(apc => {
110+
setGlobalAPC(apc)
111111
})
112112
}
113113
}, [tipBlockTimestamp])
@@ -298,10 +298,10 @@ const NervosDAO = ({
298298
<Text as="span" variant="small" block>{`Epoch number: ${epochInfo.number}`}</Text>
299299
<Text as="span" variant="small" block>{`Epoch index: ${epochInfo.index}`}</Text>
300300
<Text as="span" variant="small" block>{`Epoch length: ${epochInfo.length}`}</Text>
301-
<Text as="span" variant="small" block>{`APY: ~${globalAPY}%`}</Text>
301+
<Text as="span" variant="small" block>{`APC: ~${globalAPC}%`}</Text>
302302
</Stack>
303303
)
304-
}, [epoch, globalAPY])
304+
}, [epoch, globalAPC])
305305

306306
const lockAndFreeProperties = [
307307
{

packages/neuron-ui/src/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
"locked": "Locked",
315315
"deposit": "Deposit",
316316
"deposit-receipts": "Deposit Receipts",
317-
"apy": "APY",
317+
"apc": "APC",
318318
"deposit-at": "Deposit at {{time}}",
319319
"claim": "Claim",
320320
"withdraw": "Withdraw",

packages/neuron-ui/src/locales/zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
"locked": "已锁定",
315315
"deposit": "存入",
316316
"deposit-receipts": "存款凭证",
317-
"apy": "预期年化利率",
317+
"apc": "年化锁定补贴率",
318318
"deposit-at": "存入于{{time}}",
319319
"claim": "取款",
320320
"withdraw": "结算",

packages/neuron-ui/src/tests/calculation/calculateGlobalAPY/fixtures.ts renamed to packages/neuron-ui/src/tests/calculation/calculateGlobalAPC/fixtures.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ export default {
22
'return 0 if the genesis block is not loaded': {
33
currentTime: Date.now(),
44
genesisTime: undefined,
5-
expectAPY: 0,
5+
expectAPC: 0,
66
},
77
'one period and one handrand days': {
88
currentTime: new Date('2023-04-10').getTime(),
99
genesisTime: new Date('2019-01-01').getTime(),
10-
expectAPY: 2.369552868619654,
10+
expectAPC: 2.369552868619654,
1111
},
1212
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import calculateGlobalAPC from 'utils/calculateGlobalAPC'
2+
import fixtures from './fixtures'
3+
4+
describe('calculate the global apc', () => {
5+
const fixtureTable = Object.entries(fixtures).map(([title, { currentTime, genesisTime, expectAPC }]) => [
6+
title,
7+
currentTime,
8+
genesisTime,
9+
expectAPC,
10+
])
11+
12+
test.each(fixtureTable)(`%s`, async (_title, currentTime, genesisTime, expectAPC) => {
13+
const apc = await calculateGlobalAPC(currentTime, genesisTime)
14+
expect(apc).toBe(expectAPC === 0 ? 0 : +expectAPC.toFixed(2))
15+
})
16+
})

packages/neuron-ui/src/tests/calculation/calculateGlobalAPY/index.test.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)