From 50eeeb5dd7193c52c94fa94f420e598b65ad92a2 Mon Sep 17 00:00:00 2001 From: bluezdot <72647326+bluezdot@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:47:58 +0700 Subject: [PATCH] [Issue-2651] feat: Add withdrawal time for bifrost liquid staking vDot --- .../handlers/liquid-staking/bifrost.ts | 14 +++++--------- .../EarningPositionDetail/WithdrawInfoPart.tsx | 8 +++++++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost.ts b/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost.ts index 340e38e350..21b4a26cde 100644 --- a/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost.ts +++ b/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost.ts @@ -201,25 +201,21 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo ]); const exchangeRate = new BigNumber(rate); - const currentRelayEraObj = _currentRelayEra.toPrimitive() as Record; - - const currentRelayEra = currentRelayEraObj.era; + const currentRelayEra = currentRelayEraObj.era; // .round in case parachain (vMAnta) const unlockLedgerList: BifrostUnlockLedger[] = []; - const activeBalanceMap: Record = {}; for (let i = 0; i < balances.length; i++) { const balanceItem = balances[i]; const address = useAddresses[i]; const formattedAddress = reformatAddress(address); + const unlockLedger = _unlockLedgerList[i].toPrimitive(); activeBalanceMap[formattedAddress] = balanceItem.free || BN_ZERO; - const _unlockLedger = _unlockLedgerList[i]; - const unlockLedger = _unlockLedger.toPrimitive(); - + // need refactor this get ledgerIds if (unlockLedger) { // @ts-ignore // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access @@ -247,7 +243,7 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo const owner = reformatAddress(unlockInfo[0] as string); const amount = (unlockInfo[1] as number).toString(); // @ts-ignore - const withdrawalEra = unlockInfo[2].era as number; + const withdrawalEra = unlockInfo[2].era as number; // recheck in case round if (owner in unlockingMap) { unlockingMap[owner].push({ @@ -275,7 +271,7 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo if (unlockings) { unlockings.forEach((unlocking) => { - const isClaimable = unlocking.era - currentRelayEra < 0; + const isClaimable = unlocking.era - currentRelayEra <= 0; const remainingEra = unlocking.era - currentRelayEra; const waitingTime = remainingEra * _STAKING_ERA_LENGTH_MAP[this.chain]; // const currentTimestampMs = Date.now(); diff --git a/packages/extension-koni-ui/src/Popup/Home/Earning/EarningPositionDetail/WithdrawInfoPart.tsx b/packages/extension-koni-ui/src/Popup/Home/Earning/EarningPositionDetail/WithdrawInfoPart.tsx index 6cbd83a4f1..b9aa9b02fb 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Earning/EarningPositionDetail/WithdrawInfoPart.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Earning/EarningPositionDetail/WithdrawInfoPart.tsx @@ -114,9 +114,15 @@ function Component ({ className, inputAsset, poolInfo, transactionChainValue, tr navigate('/transaction/cancel-unstake'); }, [navigate, setCancelUnStakeStorage, slug, transactionChainValue, transactionFromValue]); - const renderWithdrawTime = useCallback( + const renderWithdrawTime = useCallback( // todo: need refactor conditions for this block (item: UnstakingInfo) => { if (!poolInfo.metadata.availableMethod.withdraw) { + if (item.waitingTime) { + return ( +
{t(getWaitingTime(t, currentTimestampMs, item.targetTimestampMs, item.waitingTime))}
+ ); + } + return (
{t('Automatic withdrawal')}
);