|
|
@ -12,7 +12,7 @@ import store from '~/store'; |
|
|
|
import '~/styles/pledge.scss' |
|
|
|
import { Contract_Factory } from '~/types/store'; |
|
|
|
import { toFixed2 } from '~/utils'; |
|
|
|
import { toBigInt, toWei, wei } from '~/utils/wei'; |
|
|
|
import { toBigInt, toString, toWei, wei } from '~/utils/wei'; |
|
|
|
//
|
|
|
|
const Pledge = () => { |
|
|
|
|
|
|
@ -23,9 +23,9 @@ const Pledge = () => { |
|
|
|
const { Pledge__factory, FIL__factory, Pool__factory } = contract._contract ? contract._contract : {} as Contract_Factory |
|
|
|
|
|
|
|
const [pledgeList, setPledgeList] = useState([ |
|
|
|
{ day: 180, rate: 14 }, |
|
|
|
{ day: 270, rate: 15 }, |
|
|
|
{ day: 360, rate: 16 }, |
|
|
|
{ day: 180, rate: 1408 }, |
|
|
|
{ day: 270, rate: 1521 }, |
|
|
|
{ day: 360, rate: 1623 }, |
|
|
|
]) |
|
|
|
|
|
|
|
const [amount, setAmount] = useState('') |
|
|
@ -134,8 +134,8 @@ const Pledge = () => { |
|
|
|
const rate = toBigInt(pledgeList[tabIndex].rate) |
|
|
|
const year = toBigInt(365) |
|
|
|
const total = pledgeAmount * rate / year * pledgeDay; |
|
|
|
const _profit = ethers.formatUnits(total, 20) |
|
|
|
const _totalProfit = ethers.formatUnits(toWei(toFixed2(_profit,18)) + pledgeAmount,18) |
|
|
|
const _profit = ethers.formatUnits(total, 22) |
|
|
|
const _totalProfit = ethers.formatUnits(toWei(toFixed2(_profit, 18)) + pledgeAmount, 18) |
|
|
|
|
|
|
|
setProfit(_profit) |
|
|
|
setTotalProfit(_totalProfit) |
|
|
@ -178,7 +178,7 @@ const Pledge = () => { |
|
|
|
> |
|
|
|
<div> |
|
|
|
<div className=''><span className='fz-wb-550 fz-18'>{item.day}</span> {t('Days')}</div> |
|
|
|
<div className='mt-5px'><span className='fz-24 fz-wb-550'>{item.rate}</span> %</div> |
|
|
|
<div className='mt-5px'><span className='fz-24 fz-wb-550'>{toString(item.rate, 2)}</span> %</div> |
|
|
|
<div className='fz-14 mt-5px'>{t('Est.APR')}</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|