Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue-2651] Add withdrawal time for bifrost liquid staking vDot #3355

Open
wants to merge 1 commit into
base: subwallet-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,21 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
]);

const exchangeRate = new BigNumber(rate);

const currentRelayEraObj = _currentRelayEra.toPrimitive() as Record<string, number>;

const currentRelayEra = currentRelayEraObj.era;
const currentRelayEra = currentRelayEraObj.era; // .round in case parachain (vMAnta)

const unlockLedgerList: BifrostUnlockLedger[] = [];

const activeBalanceMap: Record<string, BN> = {};

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
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className={'__withdraw-time-label'}>{t(getWaitingTime(t, currentTimestampMs, item.targetTimestampMs, item.waitingTime))}</div>
);
}

return (
<div className={'__withdraw-time-label'}>{t('Automatic withdrawal')}</div>
);
Expand Down
Loading