Skip to content

Commit

Permalink
feat: Add calculator for DAO rewards (#275)
Browse files Browse the repository at this point in the history
Co-authored-by: Chen Yu <[email protected]>
  • Loading branch information
devchenyan and Keith-CY authored Apr 3, 2024
1 parent 672050a commit 9d0e75b
Show file tree
Hide file tree
Showing 13 changed files with 728 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/assets/go.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const ONE_MINUTE_SECOND = 60
export const EPOCHS_PER_HALVING = 8760
export const THEORETICAL_EPOCH_TIME = 1000 * 60 * 60 * 4 // 4 hours
export const PAGE_SIZE = 10
export const MIN_DEPOSIT_AMOUNT = 102
export const MAX_DECIMAL_DIGITS = 8

export const IS_MAINNET = config.CHAIN_TYPE === 'mainnet'

export function getPrimaryColor() {
Expand Down Expand Up @@ -153,3 +156,6 @@ export const MAINNET_URL = `https://${config.BASE_URL}`
export const TESTNET_URL = `https://${ChainName.Testnet}.${config.BASE_URL}`

export const TYPE_ID_CODE_HASH = '0x00000000000000000000000000000000000000000000000000545950455f4944'

export const NERVOS_DAO_RFC_URL =
'https://www.github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md'
23 changes: 22 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,28 @@
"days": "days+",
"24hrs_update": "24 Hours Changes(UTC+8:00)",
"today_update": "Today Changes(UTC+8:00)",
"deposit_address_tooltip": "Number of addresses with non-zero balance of Nervos DAO"
"deposit_address_tooltip": "Number of addresses with non-zero balance of Nervos DAO",
"deposit_to_dao": "Deposit to Nervos DAO",
"deposit_to_dao_description": "Deposit to receive an equivalent amount of CKB at the same rate as the secondary issuance, keep your assets away from being diluted by the secondary issuance.",
"reward_calculator": "Compensation Calculator",
"nervos_dao_rfc": "Nervos DAO RFC",
"learn_more": "Learn More",
"dao_reward_calculator": "Nervos DAO Compensation Calculator",
"deposit_terms": "Nervos DAO (generally)requires 102 CKBytes for hosting cell itself, and this portion of CKBytes won't be compensated. Please refer to the <0>Nervos DAO RFC</0> for more information on Nervos DAO.",
"you_deposit": "Your Deposit",
"you_can_withdraw": "You may withdraw approximately",
"estimated_rewards": "Make a withdrawal request after {{days}} days:",
"deposit_notice": "30 days work as a circle, if you didn’t make withdrawal request, the compensation will be calculated as compound compensation.",
"estimated_APC": "Estimated APC",
"exclude_inactive_ckb": "Exclude inactive CKB",
"exclude_inactive_ckb_tip": "",
"rewards": "Compensation",
"estimated_rewards_in_years": "Estimated compensation in",
"year": "Year",
"years": "Years",
"day": "Days",
"done": "Done",
"view_apc_trending": "View APC Trending"
},
"error": {
"maintain": "The tip block number {{tip}}, the current synced block lagging behind by {{lag}} blocks",
Expand Down
23 changes: 22 additions & 1 deletion src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,28 @@
"days": "天+",
"24hrs_update": "24 小时变动(UTC+8:00)",
"today_update": "今日变动(UTC+8:00)",
"deposit_address_tooltip": "Nervos DAO 锁定余额不为零的地址"
"deposit_address_tooltip": "Nervos DAO 锁定余额不为零的地址",
"deposit_to_dao": "锁定到 Nervos DAO",
"deposit_to_dao_description": "锁定以获得与二次发行利率相同的等额 CKB,避免您的资产被二次发行稀释。",
"reward_calculator": "补贴计算器",
"nervos_dao_rfc": "Nervos DAO RFC",
"learn_more": "了解更多",
"dao_reward_calculator": "Nervos DAO 补贴计算器",
"deposit_terms": "Nervos DAO (通常)需要 102 CKBytes 作为锁定记录的存储,这部分 CKBytes 是无法产生锁定补贴的。<br />请查看 <0>Nervos DAO RFC</0> 以了解 Nervos DAO 更多信息。",
"you_deposit": "锁定",
"you_can_withdraw": "可领取约",
"estimated_rewards": "{{days}} 天后提出提取申请:",
"deposit_notice": "30 天为一个周期,如果您没有提出提取要求,补贴将按复利计算",
"estimated_APC": "预计年化锁定补贴率",
"exclude_inactive_ckb": "不包含非活动的CKB",
"exclude_inactive_ckb_tip": "",
"rewards": "补贴",
"estimated_rewards_in_years": "预计补贴",
"year": "",
"years": "",
"day": "",
"done": "完成",
"view_apc_trending": "查看 APC 走势"
},
"error": {
"maintain": "最新区块为 {{tip}}, 当前同步高度落后 {{lag}} 区块",
Expand Down
97 changes: 97 additions & 0 deletions src/pages/NervosDao/DaoBanner/DaoBanner.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
@import '../../../styles/variables.module';

.bannerContainer {
height: 280px;
width: 100%;
border-radius: 4px;
background: #000;
color: #fff;
background-image: url('./banner_bg.svg');
background-repeat: no-repeat;
background-position: center center;
background-size: cover;

.content {
margin-top: 64px;
margin-left: calc((100% - 570px) / 4);
max-width: 570px;

p {
margin: 0;
}

.title {
font-size: 24px;
font-weight: 500;
}

.description {
font-size: 14px;
margin-top: 16px;
}

.actions {
display: flex;
gap: 16px;
margin-top: 24px;
}
}

.btn {
background: transparent;
color: #fff;
border: 1px solid #fff;
display: flex;
gap: 4px;
align-items: center;
justify-content: center;
border-radius: 4px;
padding: 8px 12px;
cursor: pointer;
font-size: 14px;
line-height: 14px;
transition: none;

.icon {
path {
fill: #fff;
}
}

&:hover {
color: var(--primary-color);
border: 1px solid var(--primary-color);

.icon {
path {
fill: var(--primary-color);
}
}
}
}
}

@media (width <= $mobileBreakPoint) {
.bannerContainer {
height: auto;
background-image: url('./banner_bg_mobile.svg');
background-repeat: no-repeat;
background-position: center center;
background-size: cover;

.content {
margin-top: 32px;
margin-bottom: 27px;
max-width: 100%;
margin-left: 16px;

.actions {
flex-direction: column;

.btn {
width: 160px;
}
}
}
}
}
50 changes: 50 additions & 0 deletions src/pages/NervosDao/DaoBanner/banner_bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions src/pages/NervosDao/DaoBanner/banner_bg_mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions src/pages/NervosDao/DaoBanner/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { ReactComponent as GoIcon } from '../../../assets/go.svg'
import RewardCalcutorModal from '../RewardCalcutorModal'
import { NERVOS_DAO_RFC_URL } from '../../../constants/common'
import styles from './DaoBanner.module.scss'

const DaoBanner = ({ estimatedApc }: { estimatedApc: string }) => {
const [showRewardCalcutorModal, setShowRewardCalcutorModal] = useState(false)
const { t } = useTranslation()

return (
<div className={styles.bannerContainer}>
<div className={styles.content}>
<p className={styles.title}>{t('nervos_dao.deposit_to_dao')}</p>
<p className={styles.description}>{t('nervos_dao.deposit_to_dao_description')}</p>
<div className={styles.actions}>
<button type="button" className={styles.btn} onClick={() => setShowRewardCalcutorModal(true)}>
{t('nervos_dao.reward_calculator')}
</button>
<a className={styles.btn} href={NERVOS_DAO_RFC_URL} target="_blank" rel="noopener noreferrer">
{t('nervos_dao.nervos_dao_rfc')}
<GoIcon className={styles.icon} />
</a>
<a
className={styles.btn}
href="https://www.nervos.org/knowledge-base/nervosdao_withdrawal_process_explained"
target="_blank"
rel="noopener noreferrer"
>
{t('nervos_dao.learn_more')}
<GoIcon className={styles.icon} />
</a>
</div>
</div>

{showRewardCalcutorModal ? (
<RewardCalcutorModal estimatedApc={estimatedApc} onClose={() => setShowRewardCalcutorModal(false)} />
) : null}
</div>
)
}

export default DaoBanner
Loading

0 comments on commit 9d0e75b

Please sign in to comment.