|
@ -30,6 +30,7 @@ const Pledge = () => { |
|
|
|
|
|
|
|
|
const [amount, setAmount] = useState('') |
|
|
const [amount, setAmount] = useState('') |
|
|
const [profit, setProfit] = useState('0.00') |
|
|
const [profit, setProfit] = useState('0.00') |
|
|
|
|
|
const [totalProfit, setTotalProfit] = useState('0.00') |
|
|
const [tabIndex, setTabIndex] = useState(location.state ? location.state.index : 0) |
|
|
const [tabIndex, setTabIndex] = useState(location.state ? location.state.index : 0) |
|
|
const [visible, setVisible] = useState(false) |
|
|
const [visible, setVisible] = useState(false) |
|
|
const [loading, setLoading] = useState(false) |
|
|
const [loading, setLoading] = useState(false) |
|
@ -125,15 +126,19 @@ const Pledge = () => { |
|
|
const calcIncome = () => { |
|
|
const calcIncome = () => { |
|
|
if (amount === '') { |
|
|
if (amount === '') { |
|
|
setProfit('0.00') |
|
|
setProfit('0.00') |
|
|
|
|
|
setTotalProfit('0.00') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
const pledgeAmount = toWei(amount) |
|
|
const pledgeAmount = toWei(amount) |
|
|
const pledgeDay = toBigInt(pledgeList[tabIndex].day) |
|
|
const pledgeDay = toBigInt(pledgeList[tabIndex].day) |
|
|
const rate = toBigInt(pledgeList[tabIndex].rate) |
|
|
const rate = toBigInt(pledgeList[tabIndex].rate) |
|
|
const year = toBigInt(365) |
|
|
const year = toBigInt(365) |
|
|
const total = pledgeAmount * rate / year * pledgeDay |
|
|
|
|
|
|
|
|
const total = pledgeAmount * rate / year * pledgeDay; |
|
|
const _profit = ethers.formatUnits(total, 20) |
|
|
const _profit = ethers.formatUnits(total, 20) |
|
|
|
|
|
const _totalProfit = ethers.formatUnits(toWei(toFixed2(_profit,18)) + pledgeAmount,18) |
|
|
|
|
|
|
|
|
setProfit(_profit) |
|
|
setProfit(_profit) |
|
|
|
|
|
setTotalProfit(_totalProfit) |
|
|
} |
|
|
} |
|
|
calcIncome() |
|
|
calcIncome() |
|
|
}, [amount, tabIndex]) |
|
|
}, [amount, tabIndex]) |
|
@ -209,7 +214,7 @@ const Pledge = () => { |
|
|
</div> |
|
|
</div> |
|
|
<div className='mt-1 row-between'> |
|
|
<div className='mt-1 row-between'> |
|
|
<div>{t('Est. Total Receivable')}:</div> |
|
|
<div>{t('Est. Total Receivable')}:</div> |
|
|
<div>{toFixed2(profit, 4)} FIL</div> |
|
|
|
|
|
|
|
|
<div>{toFixed2(totalProfit, 4)} FIL</div> |
|
|
</div> |
|
|
</div> |
|
|
<div className='mt-3 row-center'> |
|
|
<div className='mt-3 row-center'> |
|
|
<Button size='large' className='stake-button' onClick={pledge} loading={loading} loadingType="ball">{t('STAKE')}</Button> |
|
|
<Button size='large' className='stake-button' onClick={pledge} loading={loading} loadingType="ball">{t('STAKE')}</Button> |
|
|