{{ $n(truncate(ethers.utils.formatEther(amount.toString()) ?? '0', 2)) }}
diff --git a/src/staking-v3/hooks/useDappStaking.ts b/src/staking-v3/hooks/useDappStaking.ts
index e97e695e0..dff1125d1 100644
--- a/src/staking-v3/hooks/useDappStaking.ts
+++ b/src/staking-v3/hooks/useDappStaking.ts
@@ -31,6 +31,7 @@ import { initialDappTiersConfiguration, initialTiersConfiguration } from '../sto
import { checkIsDappStakingV3 } from 'src/modules/dapp-staking';
import { ApiPromise } from '@polkadot/api';
import { isValidEvmAddress } from '@astar-network/astar-sdk-core';
+import { docsUrl } from 'src/links';
export interface RewardsPerPeriod {
period: number;
@@ -135,7 +136,7 @@ export function useDappStaking() {
const rewardExpiresInNextPeriod = (period: number): boolean =>
period == protocolState.value!.periodInfo.number - constants.value!.rewardRetentionInPeriods;
- const hasStakerRewards = computed(() => !!rewards.value.staker);
+ const hasStakerRewards = computed(() => !!rewards.value.staker.amount);
const hasDappRewards = computed(() => !!rewards.value.dApp);
const hasBonusRewards = computed(() => !!rewards.value.bonus);
const hasRewards = computed(
@@ -326,8 +327,7 @@ export function useDappStaking() {
const stakingV3service = container.get<() => IDappStakingService>(
Symbols.DappStakingServiceFactoryV3
)();
- const ownedContractAddress = getOwnedDappAddress();
-
+ const ownedContracts = getOwnedDappAddress();
let staker = {
amount: BigInt(0),
eraCount: 0,
@@ -340,8 +340,13 @@ export function useDappStaking() {
staker = await stakingV3service.getStakerRewards(currentAccount.value);
bonus = await stakingV3service.getBonusRewards(currentAccount.value);
- if (ownedContractAddress) {
- dApp = await stakingV3service.getDappRewards(ownedContractAddress ?? '');
+ if (ownedContracts.length > 0) {
+ for await (const ownedContractAddress of ownedContracts) {
+ if (ownedContractAddress) {
+ const dAppRewards = await stakingV3service.getDappRewards(ownedContractAddress);
+ dApp += dAppRewards;
+ }
+ }
}
}
@@ -375,8 +380,10 @@ export function useDappStaking() {
return result;
};
- const getOwnedDappAddress = (): string | undefined => {
- return registeredDapps.value.find((x) => x.chain.owner === currentAccount.value)?.chain.address;
+ const getOwnedDappAddress = (): string[] => {
+ return registeredDapps.value
+ .filter((x) => x.chain.owner === currentAccount.value)
+ .map((x) => x.chain.address);
};
const fetchConstantsToStore = async (): Promise => {
@@ -395,21 +402,29 @@ export function useDappStaking() {
store.commit('stakingV3/setCurrentEraInfo', eraInfo);
};
- const canStake = (stakes: DappStakeInfo[], availableTokensBalance: bigint): [boolean, string] => {
+ const canStake = (
+ stakes: DappStakeInfo[],
+ availableTokensBalance: bigint
+ //Returns: [result, message, docsUrl]
+ ): [boolean, string, string] => {
let stakeSum = BigInt(0);
for (const stake of stakes) {
const stakeAmount = ethers.utils.parseEther(stake.amount.toString()).toBigInt();
stakeSum += stakeAmount;
if (!stake.address) {
- return [false, t('stakingV3.noDappSelected')];
+ return [false, t('stakingV3.noDappSelected'), ''];
} else if (stake.amount <= 0) {
- return [false, t('stakingV3.dappStaking.ZeroAmount')];
+ return [false, t('stakingV3.dappStaking.ZeroAmount'), ''];
} else if (
constants.value &&
(ledger.value?.contractStakeCount ?? 0) >= constants.value.maxNumberOfStakedContracts
) {
- return [false, t('stakingV3.dappStaking.TooManyStakedContracts')];
+ return [
+ false,
+ t('stakingV3.dappStaking.TooManyStakedContracts'),
+ docsUrl.dappStakingStaked16Dapps,
+ ];
} else if (
constants.value?.minStakeAmountToken &&
stake.amount < constants.value.minStakeAmountToken &&
@@ -420,11 +435,12 @@ export function useDappStaking() {
t('stakingV3.dappStaking.LockedAmountBelowThreshold', {
amount: constants.value.minStakeAmountToken,
}),
+ '',
];
} else if (protocolState.value?.maintenance) {
- return [false, t('stakingV3.dappStaking.Disabled')];
+ return [false, t('stakingV3.dappStaking.Disabled'), ''];
} else if (stakeSum > availableTokensBalance) {
- return [false, t('stakingV3.dappStaking.UnavailableStakeFunds')];
+ return [false, t('stakingV3.dappStaking.UnavailableStakeFunds'), ''];
} else if (
constants.value &&
ethers.utils.parseEther(constants.value.minBalanceAfterStaking.toString()).toBigInt() >
@@ -436,18 +452,19 @@ export function useDappStaking() {
amount: constants.value.minBalanceAfterStaking,
symbol: nativeTokenSymbol.value,
}),
+ '',
];
} else if (
protocolState.value?.periodInfo.subperiod === PeriodType.BuildAndEarn &&
protocolState.value.periodInfo.nextSubperiodStartEra <= protocolState.value.era + 1
) {
- return [false, t('stakingV3.dappStaking.PeriodEndsNextEra')];
+ return [false, t('stakingV3.dappStaking.PeriodEndsNextEra'), ''];
} else if (getDapp(stake.address)?.chain?.state === 'Unregistered') {
- return [false, t('stakingV3.dappStaking.NotOperatedDApp')];
+ return [false, t('stakingV3.dappStaking.NotOperatedDApp'), ''];
}
}
- return [true, ''];
+ return [true, '', ''];
};
const canUnStake = (dappAddress: string, amount: number): [boolean, string] => {