fix to hours till (#412)
Co-authored-by: Adrian Brzeziński <a.brzezinski94@gmail.com>
This commit is contained in:
parent
89e5e95394
commit
dbe4d99ae3
|
@ -4,6 +4,9 @@ import Button from '@components/shared/Button'
|
|||
import { useTranslation } from 'react-i18next'
|
||||
import { Table, Td, Th, TrBody, TrHead } from '@components/shared/TableElements'
|
||||
import TableTokenName from '@components/shared/TableTokenName'
|
||||
import useMangoAccount from 'hooks/useMangoAccount'
|
||||
import useMangoGroup from 'hooks/useMangoGroup'
|
||||
import { useMemo } from 'react'
|
||||
import FormatNumericValue from '@components/shared/FormatNumericValue'
|
||||
|
||||
type WarningProps = {
|
||||
|
@ -12,8 +15,26 @@ type WarningProps = {
|
|||
|
||||
const CollateralFeeWarningModal = ({ isOpen }: WarningProps) => {
|
||||
const { t } = useTranslation(['account'])
|
||||
const { setWasModalOpen, collateralFeeBanks, ltvRatio } =
|
||||
useCollateralFeePopupConditions()
|
||||
const {
|
||||
setWasModalOpen,
|
||||
marginPositionBalanceWithBanks,
|
||||
collateralFeeBanks,
|
||||
ltvRatio,
|
||||
} = useCollateralFeePopupConditions()
|
||||
console.log(marginPositionBalanceWithBanks)
|
||||
const { mangoAccount } = useMangoAccount()
|
||||
const { group } = useMangoGroup()
|
||||
const lastCharge = mangoAccount?.lastCollateralFeeCharge.toNumber()
|
||||
const collateralFeeInterval = group?.collateralFeeInterval.toNumber()
|
||||
|
||||
const hoursTillNextCharge = useMemo(() => {
|
||||
if (!lastCharge || !collateralFeeInterval) return
|
||||
const nowInSeconds = Date.now() / 1000
|
||||
const timeUntilChargeInSeconds =
|
||||
lastCharge + collateralFeeInterval - nowInSeconds
|
||||
const timeUntilChargeInHours = timeUntilChargeInSeconds / 3600
|
||||
return Math.round(timeUntilChargeInHours * 100) / 100
|
||||
}, [lastCharge, collateralFeeInterval])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
@ -23,7 +44,9 @@ const CollateralFeeWarningModal = ({ isOpen }: WarningProps) => {
|
|||
hideClose
|
||||
>
|
||||
<h2 className="mb-2 text-center">
|
||||
{t('collateral-funding-modal-heading')}
|
||||
{t('collateral-funding-modal-heading', {
|
||||
remaining_hours: hoursTillNextCharge,
|
||||
})}
|
||||
</h2>
|
||||
<a
|
||||
className="mb-6 flex justify-center text-base font-bold"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"assets": "Assets",
|
||||
"assets-liabilities": "Assets & Liabilities",
|
||||
"collateral": "Collateral",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral funding fees in X hours",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral fees in {{remaining_hours}} hours",
|
||||
"collateral-value": "Collateral Value",
|
||||
"custom-account-options-saved": "Advanced options set",
|
||||
"cumulative-interest-chart": "Cumulative Interest Chart",
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"assets": "Assets",
|
||||
"assets-liabilities": "Assets & Liabilities",
|
||||
"collateral": "Collateral",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral funding fees in X hours",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral fees in {{remaining_hours}} hours",
|
||||
"collateral-value": "Collateral Value",
|
||||
"custom-account-options-saved": "Advanced options set",
|
||||
"cumulative-interest-chart": "Cumulative Interest Chart",
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"assets": "Ativos",
|
||||
"assets-liabilities": "Ativos e Passivos",
|
||||
"collateral": "Collateral",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral funding fees in X hours",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral fees in {{remaining_hours}} hours",
|
||||
"collateral-value": "Valor do Colateral",
|
||||
"custom-account-options-saved": "Opções avançadas definidas",
|
||||
"cumulative-interest-chart": "Gráfico de Juros Acumulados",
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"assets": "Assets",
|
||||
"assets-liabilities": "Assets & Liabilities",
|
||||
"collateral": "Collateral",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral funding fees in X hours",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral fees in {{remaining_hours}} hours",
|
||||
"collateral-value": "Collateral Value",
|
||||
"custom-account-options-saved": "Advanced options set",
|
||||
"cumulative-interest-chart": "Cumulative Interest Chart",
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"assets": "资产",
|
||||
"assets-liabilities": "资产和债务",
|
||||
"collateral": "Collateral",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral funding fees in X hours",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral fees in {{remaining_hours}} hours",
|
||||
"collateral-value": "质押品价值",
|
||||
"custom-account-options-saved": "已改高级设定",
|
||||
"cumulative-interest-chart": "累积利息图表",
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"assets": "資產",
|
||||
"assets-liabilities": "資產和債務",
|
||||
"collateral": "Collateral",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral funding fees in X hours",
|
||||
"collateral-funding-modal-heading": "You'll be charged collateral fees in {{remaining_hours}} hours",
|
||||
"collateral-value": "質押品價值",
|
||||
"custom-account-options-saved": "已改高級設定",
|
||||
"cumulative-interest-chart": "累積利息圖表",
|
||||
|
|
Loading…
Reference in New Issue