diff --git a/package.json b/package.json index 15daba6b1..8837455c4 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@emotion/styled": "^11.10.4", "@ethersproject/address": "^5.7.0", "@ethersproject/providers": "^5.7.2", - "@galacticcouncil/apps": "^4.0.0", + "@galacticcouncil/apps": "^4.1.0", "@galacticcouncil/math-lbp": "^1.0.0", "@galacticcouncil/math-liquidity-mining": "^1.0.0", "@galacticcouncil/math-omnipool": "^1.0.0", @@ -39,7 +39,7 @@ "@galacticcouncil/math-staking": "^1.0.0", "@galacticcouncil/math-xyk": "^1.0.0", "@galacticcouncil/sdk": "^3.0.1", - "@galacticcouncil/ui": "^4.0.0", + "@galacticcouncil/ui": "^4.0.3", "@galacticcouncil/xcm-cfg": "^2.5.0", "@galacticcouncil/xcm-core": "^1.4.0", "@galacticcouncil/xcm-sdk": "^3.3.0", diff --git a/src/api/era.tsx b/src/api/era.tsx index 55560924e..ca9a75813 100644 --- a/src/api/era.tsx +++ b/src/api/era.tsx @@ -4,7 +4,9 @@ import { ExtrinsicEra } from "@polkadot/types/interfaces/extrinsics" import { bnToBn } from "@polkadot/util" import { useTimestamp } from "./timestamp" import { useMemo } from "react" -import { BLOCK_TIME } from "utils/constants" +import { PARACHAIN_BLOCK_TIME } from "utils/constants" + +const DEFAULT_PERIOD = 900 export const useEra = ( era: ExtrinsicEra, @@ -14,21 +16,27 @@ export const useEra = ( const blockNumber = bnToBn(hexBlockNumber) const mortal = useMemo(() => { + if (blockNumber.isZero()) return null if (era.isMortalEra) { const mortal = era.asMortalEra const period = new BN(mortal.period.toHex()) // Blocks validity - if (!blockNumber.isZero()) { - const birth = new BN(mortal.birth(blockNumber)) - const death = new BN(mortal.death(blockNumber)) - return { - birth, - death, - period, - } + const birth = new BN(mortal.birth(blockNumber)) + const death = new BN(mortal.death(blockNumber)) + return { + birth, + death, + period, } } - return null + + const birth = new BN(blockNumber.toString()) + const period = new BN(DEFAULT_PERIOD) + return { + birth, + death: birth.plus(period), + period, + } }, [era, blockNumber]) const timestamp = useTimestamp(mortal?.birth, enabled) @@ -38,14 +46,21 @@ export const useEra = ( const birthDate = new Date(timestamp.data) const deathDate = addSeconds( birthDate, - mortal.period.times(BLOCK_TIME).toNumber(), + mortal.period.times(PARACHAIN_BLOCK_TIME).toNumber(), ) return { birthDate, deathDate, + period: mortal.period, + isLoading: false, } } - return null - }, [timestamp.data, mortal?.period]) + return { + birthDate: null, + deathDate: null, + period: null, + isLoading: timestamp.isLoading, + } + }, [timestamp.data, timestamp.isLoading, mortal?.period]) } diff --git a/src/api/farms.ts b/src/api/farms.ts index 6c1c2a682..e5d50f20c 100644 --- a/src/api/farms.ts +++ b/src/api/farms.ts @@ -20,6 +20,8 @@ import request, { gql } from "graphql-request" import { AccountId32 } from "@polkadot/types/interfaces" import { useMemo } from "react" import { scale } from "utils/balance" +import { getAccountResolver } from "utils/farms/claiming/accountResolver" +import { useAccountBalances, useAccountsBalances } from "./accountBalances" const NEW_YIELD_FARMS_BLOCKS = (48 * 60 * 60) / PARACHAIN_BLOCK_TIME.toNumber() // 48 hours @@ -34,6 +36,7 @@ type FarmAprs = ReturnType export interface Farm { globalFarm: PalletLiquidityMiningGlobalFarmData yieldFarm: PalletLiquidityMiningYieldFarmData + globalFarmPotAddress: string poolId: string } @@ -161,6 +164,7 @@ const getGlobalFarm = } export const useFarms = (poolIds: Array) => { + const { api } = useRpcProvider() const activeYieldFarmsQuery = useActiveYieldFarms(poolIds) const farmIds = activeYieldFarmsQuery @@ -170,6 +174,15 @@ export const useFarms = (poolIds: Array) => { }, []) .flat(2) + const accountResolver = getAccountResolver(api.registry) + const globalFarmPotAddresses = farmIds?.map((farm) => { + const potAddresss = accountResolver(Number(farm.globalFarmId)).toString() + return { + globalFarmId: farm.globalFarmId.toString(), + potAddresss, + } + }) + const globalFarms = useGlobalFarms(farmIds) const yieldFarms = useYieldFarms(farmIds) @@ -191,6 +204,10 @@ export const useFarms = (poolIds: Array) => { ) })?.data?.farm + const globalFarmPotAddress = globalFarmPotAddresses.find( + (farm) => farm.globalFarmId === globalFarm?.id.toString(), + )?.potAddresss + const yieldFarm = yieldFarms.find((yieldFarm) => { const data = yieldFarm.data @@ -202,10 +219,15 @@ export const useFarms = (poolIds: Array) => { if (!globalFarm || !yieldFarm) return undefined - return { globalFarm, yieldFarm, poolId: farmId.poolId } + return { + globalFarm, + yieldFarm, + globalFarmPotAddress, + poolId: farmId.poolId, + } }) .filter((x): x is Farm => x != null) - }, [farmIds, globalFarms, yieldFarms]) + }, [farmIds, globalFarms, yieldFarms, globalFarmPotAddresses]) return { data, isLoading } } @@ -247,6 +269,7 @@ function getFarmApr( }, farm: Farm, priceAdjustment: BigNumber, + potBalance?: BigNumber, ) { const { globalFarm, yieldFarm } = farm const { rewardCurrency, incentivizedAsset } = globalFarm @@ -330,11 +353,16 @@ function getFarmApr( const minApr = loyaltyFactor ? apr.times(loyaltyFactor) : null + const potMaxRewards = potBalance + ? distributedRewards.plus(potBalance) + : undefined + return { apr, minApr, distributedRewards, maxRewards, + potMaxRewards, fullness, estimatedEndBlock: estimatedEndBlock, assetId: globalFarm.rewardCurrency, @@ -347,43 +375,48 @@ function getFarmApr( } } -export const useFarmApr = (farm: { - globalFarm: PalletLiquidityMiningGlobalFarmData - yieldFarm: PalletLiquidityMiningYieldFarmData - poolId: string -}) => { +export const useFarmApr = (farm: Farm) => { + const { assets } = useRpcProvider() const bestNumber = useBestNumber() const rewardCurrency = farm.globalFarm.rewardCurrency.toString() const incentivizedAsset = farm.globalFarm.incentivizedAsset.toString() + const accountBalance = useAccountBalances(farm.globalFarmPotAddress) const oraclePrice = useOraclePrice(rewardCurrency, incentivizedAsset) return useQueryReduce( [bestNumber, oraclePrice] as const, (bestNumber, oraclePrice) => { + const rewardCurrency = farm.globalFarm.rewardCurrency.toString() + const potBalance = + rewardCurrency === assets.native.id + ? accountBalance.data?.native.freeBalance + : accountBalance.data?.balances.find( + (balance) => balance.id.toString() === rewardCurrency, + )?.freeBalance + return getFarmApr( bestNumber, farm, oraclePrice?.oraclePrice ?? farm.globalFarm.priceAdjustment.toBigNumber(), + potBalance, ) }, ) } -export const useFarmAprs = ( - farms: { - globalFarm: PalletLiquidityMiningGlobalFarmData - yieldFarm: PalletLiquidityMiningYieldFarmData - poolId: string - }[], -) => { +export const useFarmAprs = (farms: Farm[]) => { + const { assets } = useRpcProvider() const bestNumber = useBestNumber() const ids = farms.map((farm) => ({ rewardCurrency: farm.globalFarm.rewardCurrency.toString(), incentivizedAsset: farm.globalFarm.incentivizedAsset.toString(), })) const oraclePrices = useOraclePrices(ids) + const accountsBalances = useAccountsBalances( + farms.map((farm) => farm.globalFarmPotAddress), + ) return useQueryReduce([bestNumber] as const, (bestNumber) => { return farms.map((farm) => { @@ -394,11 +427,24 @@ export const useFarmAprs = ( oraclePrice.data?.id.incentivizedAsset === incentivizedAsset && oraclePrice.data?.id.rewardCurrency === rewardCurrency, ) + const accountBalance = accountsBalances.data?.find( + (balance) => balance.accountId.toString() === farm.globalFarmPotAddress, + ) + + const potBalance = accountBalance + ? rewardCurrency === assets.native.id + ? accountBalance.native.freeBalance + : accountBalance.balances.find( + (balance) => balance.id.toString() === rewardCurrency, + )?.freeBalance + : undefined + return getFarmApr( bestNumber, farm, oraclePrice?.data?.oraclePrice ?? farm.globalFarm.priceAdjustment.toBigNumber(), + potBalance, ) }) }) diff --git a/src/api/timestamp.ts b/src/api/timestamp.ts index 1d4b40ede..17becdc50 100644 --- a/src/api/timestamp.ts +++ b/src/api/timestamp.ts @@ -11,12 +11,13 @@ export function useTimestamp( enabled = true, ) { const { api } = useRpcProvider() + const queryEnabled = !!blockNumber && enabled + return useQuery( QUERY_KEYS.timestamp(blockNumber), - () => - blockNumber !== null ? getTimestamp(api, blockNumber) : undefinedNoop(), + () => (queryEnabled ? getTimestamp(api, blockNumber) : undefinedNoop()), { - enabled: !!blockNumber && enabled, + enabled: queryEnabled, }, ) } @@ -25,7 +26,7 @@ export async function getTimestamp( api: ApiPromise, blockNumber?: u32 | BigNumber, ) { - if (blockNumber != null) { + if (blockNumber) { const blockHash = await api.rpc.chain.getBlockHash(blockNumber.toString()) const apiAt = await api.at(blockHash) const now = await apiAt.query.timestamp.now() diff --git a/src/assets/icons/HydraLogo.svg b/src/assets/icons/HydraLogo.svg index 4e0ff1b01..6cae33745 100644 --- a/src/assets/icons/HydraLogo.svg +++ b/src/assets/icons/HydraLogo.svg @@ -1,3 +1,3 @@ - - + + diff --git a/src/components/AppProviders/AppProviders.tsx b/src/components/AppProviders/AppProviders.tsx index 58d144f95..720e644b0 100644 --- a/src/components/AppProviders/AppProviders.tsx +++ b/src/components/AppProviders/AppProviders.tsx @@ -10,9 +10,9 @@ import * as Apps from "@galacticcouncil/apps" import { createComponent } from "@lit-labs/react" import { MigrationProvider } from "sections/migration/MigrationProvider" -const AppsPersistenceProvider = createComponent({ - tagName: "gc-database-provider", - elementClass: Apps.DatabaseProvider, +const AppsContextProvider = createComponent({ + tagName: "gc-context-provider", + elementClass: Apps.ContextProvider, react: React, }) @@ -28,7 +28,7 @@ export const AppProviders: FC = ({ children }) => { highlightColor={`rgba(${theme.rgbColors.white}, 0.24)`} borderRadius={4} > - {children} + {children} diff --git a/src/components/AssetIcon/AssetIcon.tsx b/src/components/AssetIcon/AssetIcon.tsx index 24f67ccb7..2d1f685e3 100644 --- a/src/components/AssetIcon/AssetIcon.tsx +++ b/src/components/AssetIcon/AssetIcon.tsx @@ -15,9 +15,6 @@ import { AnyParachain } from "@galacticcouncil/xcm-core" import { isAnyParachain } from "utils/helpers" import { MetadataStore } from "@galacticcouncil/ui" -const EXTERNAL_ASSETS_WHITELIST = - MetadataStore.getInstance().externalWhitelist() - const chains = Array.from(chainsMap.values()) export const UigcAssetPlaceholder = createComponent({ @@ -48,6 +45,11 @@ export const AssetLogo = ({ id }: { id?: string }) => { const { t } = useTranslation() const { assets } = useRpcProvider() + const externalAssetsWhitelist = useMemo( + () => MetadataStore.getInstance().externalWhitelist(), + [], + ) + const asset = useMemo(() => { const assetDetails = id ? assets.getAsset(id) : undefined @@ -58,7 +60,7 @@ export const AssetLogo = ({ id }: { id?: string }) => { ) as AnyParachain const isWhitelisted = assetDetails - ? EXTERNAL_ASSETS_WHITELIST.includes(assetDetails.id) + ? externalAssetsWhitelist.includes(assetDetails.id) : false const badgeVariant: "warning" | "danger" | "" = assetDetails?.isExternal @@ -72,7 +74,7 @@ export const AssetLogo = ({ id }: { id?: string }) => { symbol: assetDetails?.symbol, badgeVariant, } - }, [assets, id]) + }, [assets, externalAssetsWhitelist, id]) if (asset.chain || asset.symbol) return ( diff --git a/src/components/Layout/Header/Header.tsx b/src/components/Layout/Header/Header.tsx index e483aecd9..f66f778e0 100644 --- a/src/components/Layout/Header/Header.tsx +++ b/src/components/Layout/Header/Header.tsx @@ -42,7 +42,13 @@ export const Header = () => { : } + icon={ + !isMediumMedia ? ( + + ) : ( + } /> + ) + } /> diff --git a/src/components/Modal/Modal.styled.ts b/src/components/Modal/Modal.styled.ts index 98af74049..5c9e809ef 100644 --- a/src/components/Modal/Modal.styled.ts +++ b/src/components/Modal/Modal.styled.ts @@ -58,7 +58,7 @@ export const SContainer = styled(Content)` --modal-header-padding-x: 12px; --modal-header-btn-size: 34px; --modal-header-height: calc( - var(--modal-header-btn-size) + var(--modal-header-padding-y) * 2 + var(--modal-header-btn-size) + var(--modal-header-padding-y) * 1.5 ); --modal-content-padding: 12px; diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts index 57c2359a7..e1e8b5ba3 100644 --- a/src/i18n/i18n.ts +++ b/src/i18n/i18n.ts @@ -93,7 +93,7 @@ i18n if (num == null) return null return formatNum( num.toFixed(), - { notation: "compact" }, + { notation: "compact", maximumSignificantDigits: 2 }, lng, )?.replaceAll( getFormatSeparators(lng).group ?? ",", diff --git a/src/i18n/locales/en/translations.json b/src/i18n/locales/en/translations.json index 98689e901..702d5ae62 100644 --- a/src/i18n/locales/en/translations.json +++ b/src/i18n/locales/en/translations.json @@ -285,7 +285,8 @@ "liquidity.reviewTransaction.modal.title": "Review transaction details", "liquidity.reviewTransaction.modal.desc": "Please review your transaction", "liquidity.reviewTransaction.modal.detail.cost": "Transaction cost:", - "liquidity.reviewTransaction.modal.detail.lifetime": "Transaction lifetime:", + "liquidity.reviewTransaction.modal.detail.lifetime": "Transaction expiration:", + "liquidity.reviewTransaction.modal.detail.lifetime.tooltip": "If the transaction is not included by this time, it will be cancelled.", "liquidity.reviewTransaction.modal.detail.nonce": "Nonce:", "liquidity.reviewTransaction.modal.detail.tip":"Tip the block author:", "liquidity.reviewTransaction.modal.detail.tip.name":"Display user tip", @@ -377,7 +378,7 @@ "otc.offers.table.header.status": "Order status", "otc.offers.table.actions.fill": "Fill order", "otc.offers.table.actions.cancel": "Cancel order", - "transaction.mortal.expire": "{{ date, dd/MM/yyyy hh:mm:ss }}", + "transaction.mortal.expire": "{{ date, dd/MM/yyyy HH:mm:ss }}", "transaction.immortal.expire": "Never", "walletConnect.provider.title": "Connect wallet", "walletConnect.provider.description.default": "Select your wallet of choice.", @@ -596,7 +597,7 @@ "farms.modal.join.toast.onLoading": "<0>Joining farm with <1>{{ amount, bignumber(type: 'token') }} <0>asset shares.", "farms.modal.join.toast.onSuccess": "<0>Joined farm with <1>{{ amount, bignumber(type: 'token') }} <0>asset shares.", "farms.modal.join.step": "Join Farm {{number}} ", - "farms.modal.join.minDeposit": "Minimum for entering the farm is {{ value, bignumber(type: 'token') }} asset share", + "farms.modal.join.minDeposit": "Minimal deposit is not reached", "farms.modal.footer.title": "Available asset shares", "farms.modal.details.title": "Farm details", "farms.modal.details.loyaltyRewards.label": "Loyalty rewards", @@ -909,7 +910,7 @@ "migration.export.question": "Would you like to migrate all past app settings to the new app?", "migration.export.button": "Migrate Settings", "migration.import.overwrite.title": "Do you wish to overwrite your settings?", - "migration.import.overwrite.description": "You already transferred your settings on {{ date, dd/MM/yyyy hh:mm:ss }}. Do you wish to overwrite your current settings?", + "migration.import.overwrite.description": "You already transferred your settings on {{ date, dd/MM/yyyy HH:mm:ss }}. Do you wish to overwrite your current settings?", "migration.import.overwrite.button": "Overwrite Settings", "migration.import.confirm.title": "You have opened a migration link", "migration.import.confirm.description": "Do you want to import new app settings?", diff --git a/src/sections/pools/components/NewFarmsBanner.styled.ts b/src/sections/pools/components/NewFarmsBanner.styled.ts index fc83597ec..7a0da4ccf 100644 --- a/src/sections/pools/components/NewFarmsBanner.styled.ts +++ b/src/sections/pools/components/NewFarmsBanner.styled.ts @@ -6,7 +6,9 @@ export const NewFarmsBannerContainer = styled.div` display: flex; justify-content: center; align-items: center; - gap: 14px; + flex-direction: row; + + gap: 4px; padding: 6px 0; ` diff --git a/src/sections/pools/components/NewFarmsBanner.tsx b/src/sections/pools/components/NewFarmsBanner.tsx index bd9b0129f..d89e4b423 100644 --- a/src/sections/pools/components/NewFarmsBanner.tsx +++ b/src/sections/pools/components/NewFarmsBanner.tsx @@ -8,45 +8,71 @@ import { LINKS } from "utils/navigation" import { useTranslation } from "react-i18next" import Star from "assets/icons/Star.svg?react" import { Icon } from "components/Icon/Icon" +import { useState } from "react" +import CrossIcon from "assets/icons/CrossIcon.svg?react" export const NewFarmsBanner = () => { const { assets } = useRpcProvider() const { t } = useTranslation() const poolAssets = useFarmsPoolAssets() - if (!poolAssets.data?.length) return null + const [visible, setVisible] = useState(true) + + if (!poolAssets.data?.length || !visible) return null return ( -
- } sx={{ color: "white" }} /> - - {t("banner.newFarms.label", { - symbols: poolAssets.data - .map((poolAsset) => assets.getAsset(poolAsset.toString()).symbol) - .join(" & "), - })} - -
- - - +
+ } sx={{ color: "white" }} /> + + {t("banner.newFarms.label", { + symbols: poolAssets.data + .map( + (poolAsset) => assets.getAsset(poolAsset.toString()).symbol, + ) + .join(" & "), + })} + +
+ + + + {t("banner.newFarms.link")} -
- + + + + { + e.stopPropagation() + setVisible(false) + }} + /> + } + /> ) } diff --git a/src/sections/pools/farms/components/claimAllDropdown/ClaimAllContent.tsx b/src/sections/pools/farms/components/claimAllDropdown/ClaimAllContent.tsx index c2073578e..4508191aa 100644 --- a/src/sections/pools/farms/components/claimAllDropdown/ClaimAllContent.tsx +++ b/src/sections/pools/farms/components/claimAllDropdown/ClaimAllContent.tsx @@ -68,7 +68,7 @@ export const ClaimAllContent = forwardRef( {claimable.isLoading && } {claimableAssets.map((claimableAsset, index) => (
- + {t("value.tokenWithSymbol", { value: claimableAsset.value, fixedPointScale: claimableAsset.decimals.toString(), diff --git a/src/sections/pools/farms/components/claimableCard/ClaimRewardsCard.tsx b/src/sections/pools/farms/components/claimableCard/ClaimRewardsCard.tsx index bec4e0067..604e79659 100644 --- a/src/sections/pools/farms/components/claimableCard/ClaimRewardsCard.tsx +++ b/src/sections/pools/farms/components/claimableCard/ClaimRewardsCard.tsx @@ -98,7 +98,6 @@ export const ClaimRewardsCard = (props: { {claimableAssets.map((claimableAsset) => ( diff --git a/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.styled.ts b/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.styled.ts index 8467930fc..49253c91b 100644 --- a/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.styled.ts +++ b/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.styled.ts @@ -8,12 +8,16 @@ export const SContainer = styled.button<{ variant: CardVariant isJoined?: boolean }>` - display: grid; - grid-row-gap: 12px; + display: flex; + justify-content: space-between; + gap: 16px; + align-items: stretch; + flex-direction: column; - width: 100%; + position: relative; padding: 12px; + padding-right: 22px; border-radius: 4px; background-color: rgba(${theme.rgbColors.alpha0}, 0.12); @@ -23,36 +27,22 @@ export const SContainer = styled.button<{ outline: none; border: 1px solid transparent; - ${({ variant, isJoined }) => { + ${({ variant }) => { if (variant === "div") { return css` - grid-template-columns: 25% 75%; - grid-template-areas: "tag tag" "apr apr" "details details"; - @media ${theme.viewport.gte.sm} { + flex-direction: row; padding: 20px 30px; - - grid-column-gap: 10px; - grid-template-areas: - "${isJoined ? "tag" : "apr"} details" - "apr details"; } ` } return css` - grid-template-columns: 25% 70% auto; - grid-template-areas: "tag tag icon" "apr apr icon" "details details icon"; - cursor: pointer; @media ${theme.viewport.gte.sm} { + flex-direction: row; padding: 20px 30px; - - grid-column-gap: 10px; - grid-template-areas: - "${isJoined ? "tag" : "apr"} details icon" - "apr details icon"; } &:hover { @@ -77,4 +67,10 @@ export const SRow = styled.div` export const SIcon = styled(Icon)` transform: rotate(-90deg); + + position: absolute; + top: 0; + bottom: 0; + right: 0; + margin: auto 0; ` diff --git a/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx b/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx index 900a92ea7..065e75522 100644 --- a/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx +++ b/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx @@ -1,7 +1,7 @@ import { Tag } from "components/Tag/Tag" import { Text } from "components/Typography/Text/Text" import { Trans, useTranslation } from "react-i18next" -import { SContainer, SIcon, SRow } from "./FarmDetailsCard.styled" +import { SIcon, SRow, SContainer } from "./FarmDetailsCard.styled" import { FillBar } from "components/FillBar/FillBar" import { scaleHuman } from "utils/balance" import { GradientText } from "components/Typography/GradientText/GradientText" @@ -82,32 +82,43 @@ export const FarmDetailsCard = ({ onClick={() => onSelect?.()} isJoined={!!depositNft} > - {depositNft && ( -
- {t("farms.details.card.tag.label")} -
- )}
-
- } /> - - {asset.symbol} + {depositNft && ( +
+ {t("farms.details.card.tag.label")} +
+ )} +
+
+ } /> + + {asset.symbol} + +
+ + {apr.data.minApr && apr.data?.apr.gt(0) + ? t("value.APR.range", { + from: apr.data.minApr, + to: apr.data?.apr, + }) + : t("value.APR", { apr: apr.data?.apr })}
- - {apr.data.minApr && apr.data?.apr.gt(0) - ? t("value.APR.range", { from: apr.data.minApr, to: apr.data?.apr }) - : t("value.APR", { apr: apr.data?.apr })} -
-
+ +
@@ -181,7 +192,6 @@ export const FarmDetailsCard = ({ } - css={{ gridArea: "icon" }} /> )} diff --git a/src/sections/pools/farms/modals/join/JoinFarmsModal.tsx b/src/sections/pools/farms/modals/join/JoinFarmsModal.tsx index 0c52d0ad6..3c10ba5f6 100644 --- a/src/sections/pools/farms/modals/join/JoinFarmsModal.tsx +++ b/src/sections/pools/farms/modals/join/JoinFarmsModal.tsx @@ -53,7 +53,11 @@ export const JoinFarmModal = ({ const meta = assets.getAsset(poolId.toString()) const bestNumber = useBestNumber() - const zodSchema = useZodSchema(meta.id, farms, !!isRedeposit) + const zodSchema = useZodSchema( + meta.id, + farms, + !!isRedeposit || !!initialShares, + ) const form = useForm<{ amount: string }>({ mode: "onChange", diff --git a/src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts b/src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts index 8fbd4a8f5..48066b000 100644 --- a/src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts +++ b/src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts @@ -12,7 +12,7 @@ import { useTranslation } from "react-i18next" export const useZodSchema = ( id: string, farms: Farm[], - isRedeposit: boolean, + withoutMaxBalance: boolean, ) => { const { t } = useTranslation() const { account } = useAccount() @@ -38,15 +38,24 @@ export const useZodSchema = ( .times(oraclePrice.data?.price?.n ?? 1) .div(oraclePrice.data?.price?.d ?? 1) - return valueInHub.gte(minDeposit) + return ( + valueInHub.gte(minDeposit) && + scale(value, meta.decimals).gte(minDeposit) + ) }, t("farms.modal.join.minDeposit", { - value: scaleHuman(minDeposit, meta.decimals), + value: scaleHuman( + minDeposit + .times(oraclePrice.data?.price?.d ?? 1) + .div(oraclePrice.data?.price?.n ?? 1), + + meta.decimals, + ), }), ) return z.object({ - amount: isRedeposit + amount: withoutMaxBalance ? rule : rule.pipe(maxBalance(balance?.balance ?? BN_0, meta.decimals)), }) diff --git a/src/sections/pools/modals/RemoveLiquidity/RemoveLiquidityForm.tsx b/src/sections/pools/modals/RemoveLiquidity/RemoveLiquidityForm.tsx index 218f29ea3..222a756e4 100644 --- a/src/sections/pools/modals/RemoveLiquidity/RemoveLiquidityForm.tsx +++ b/src/sections/pools/modals/RemoveLiquidity/RemoveLiquidityForm.tsx @@ -63,12 +63,12 @@ export const RemoveLiquidityForm = ({ }} >
- + {t("liquidity.remove.modal.value", { value: scaleHuman(removeShares, decimals), })} - + {t("value.percentage", { value })} {!isPositionMultiple && ( diff --git a/src/sections/pools/modals/RemoveLiquidity/RemoveXYKLiquidityForm.tsx b/src/sections/pools/modals/RemoveLiquidity/RemoveXYKLiquidityForm.tsx index cb6028206..3a0ef988a 100644 --- a/src/sections/pools/modals/RemoveLiquidity/RemoveXYKLiquidityForm.tsx +++ b/src/sections/pools/modals/RemoveLiquidity/RemoveXYKLiquidityForm.tsx @@ -124,7 +124,7 @@ export const RemoveXYKLiquidityForm = ({ >
- + {t("liquidity.remove.modal.value", { value: getFloatingPointAmount( removeShareToken, @@ -132,7 +132,7 @@ export const RemoveXYKLiquidityForm = ({ ), })} - + {t("value.percentage", { value })} - {!meta.isStableSwap && ( - - )} +
- + {t("liquidity.remove.modal.value", { value: getFloatingPointAmount( removeSharesValue, @@ -167,13 +167,7 @@ export const RemoveStablepoolLiquidityForm = ({ ), })} - + {t("value.percentage", { value })}
diff --git a/src/sections/referrals/components/RewardsCard/RewardsCard.tsx b/src/sections/referrals/components/RewardsCard/RewardsCard.tsx index e873acc02..7b5394f71 100644 --- a/src/sections/referrals/components/RewardsCard/RewardsCard.tsx +++ b/src/sections/referrals/components/RewardsCard/RewardsCard.tsx @@ -42,7 +42,7 @@ export const RewardsCard = () => { rewards.isLoading ? ( ) : ( - + {t("value.tokenWithSymbol", { value: rewards.data?.totalRewards, symbol: assets.native.symbol, diff --git a/src/sections/staking/sections/dashboard/components/AvailableRewards/AvailableRewards.tsx b/src/sections/staking/sections/dashboard/components/AvailableRewards/AvailableRewards.tsx index c4d4e64bc..26283ba1a 100644 --- a/src/sections/staking/sections/dashboard/components/AvailableRewards/AvailableRewards.tsx +++ b/src/sections/staking/sections/dashboard/components/AvailableRewards/AvailableRewards.tsx @@ -21,6 +21,7 @@ import { useMedia } from "react-use" import { theme } from "theme" import { useRpcProvider } from "providers/rpcProvider" import { useAccount } from "sections/web3-connect/Web3Connect.utils" +import { BN_0 } from "utils/constants" export const AvailableRewards = () => { const { api, assets } = useRpcProvider() @@ -95,12 +96,11 @@ export const AvailableRewards = () => { {t("value.tokenWithSymbol", { - value: reward.data.maxRewards, + value: reward.data.maxRewards ?? BN_0, symbol: "HDX", decimalPlaces: 2, })} @@ -111,9 +111,11 @@ export const AvailableRewards = () => { tAlign="right" >
@@ -138,7 +140,6 @@ export const AvailableRewards = () => { @@ -174,7 +175,6 @@ export const AvailableRewards = () => { diff --git a/src/sections/staking/sections/dashboard/components/PieChart/PieChart.tsx b/src/sections/staking/sections/dashboard/components/PieChart/PieChart.tsx index 8c87e1c38..2f2abc407 100644 --- a/src/sections/staking/sections/dashboard/components/PieChart/PieChart.tsx +++ b/src/sections/staking/sections/dashboard/components/PieChart/PieChart.tsx @@ -26,9 +26,7 @@ export const PieChart = (props: Props) => { const label = ( <> {t("staking.dashboard.stats.chart.label")} - - {isInvalid ? "N/a" : `${props.percentage}%`} - + {isInvalid ? "N/a" : `${props.percentage}%`} {!isInvalid && ( {`of ${t( "value.token", diff --git a/src/sections/stats/sections/LRNA/components/Burning/Burning.tsx b/src/sections/stats/sections/LRNA/components/Burning/Burning.tsx index b7a62aff7..59a8d6391 100644 --- a/src/sections/stats/sections/LRNA/components/Burning/Burning.tsx +++ b/src/sections/stats/sections/LRNA/components/Burning/Burning.tsx @@ -69,7 +69,7 @@ export const Burning = () => { ) : ( <> - + {t("value.tokenWithSymbol", { value: formatValue(imbalance, meta?.decimals), symbol, @@ -95,7 +95,7 @@ export const Burning = () => { ) : ( <> - + {t("value.tokenWithSymbol", { value: formatValue(fees, meta?.decimals), symbol, diff --git a/src/sections/stats/sections/LRNA/components/Distribution/TotalValue.tsx b/src/sections/stats/sections/LRNA/components/Distribution/TotalValue.tsx index 82ff021c2..7d36ee216 100644 --- a/src/sections/stats/sections/LRNA/components/Distribution/TotalValue.tsx +++ b/src/sections/stats/sections/LRNA/components/Distribution/TotalValue.tsx @@ -28,7 +28,7 @@ export const TotalValue = ({ ) : (
- + {t(compact ? "value.compact" : "value", { value: data })}
diff --git a/src/sections/stats/sections/omnipoolAsset/StatsOmnipoolAsset.tsx b/src/sections/stats/sections/omnipoolAsset/StatsOmnipoolAsset.tsx index 6bc20fc54..66922336c 100644 --- a/src/sections/stats/sections/omnipoolAsset/StatsOmnipoolAsset.tsx +++ b/src/sections/stats/sections/omnipoolAsset/StatsOmnipoolAsset.tsx @@ -104,9 +104,7 @@ const OmnipoolAssetHeader = ({ {isLoading || !tvl ? ( ) : ( - - {t("value.usd", { amount: tvl })} - + {t("value.usd", { amount: tvl })} )} diff --git a/src/sections/stats/sections/omnipoolAsset/stats/AssetStatsCard.tsx b/src/sections/stats/sections/omnipoolAsset/stats/AssetStatsCard.tsx index 950ab2cdf..9ef39cb85 100644 --- a/src/sections/stats/sections/omnipoolAsset/stats/AssetStatsCard.tsx +++ b/src/sections/stats/sections/omnipoolAsset/stats/AssetStatsCard.tsx @@ -33,7 +33,7 @@ export const AssetStatsCard = ({ {loading || !value ? ( ) : ( - + {value} )} diff --git a/src/sections/trade/sections/bonds/details/components/BondInfoCards/BondInfoCards.tsx b/src/sections/trade/sections/bonds/details/components/BondInfoCards/BondInfoCards.tsx index 8f577071e..2e6df3736 100644 --- a/src/sections/trade/sections/bonds/details/components/BondInfoCards/BondInfoCards.tsx +++ b/src/sections/trade/sections/bonds/details/components/BondInfoCards/BondInfoCards.tsx @@ -102,7 +102,7 @@ export const BondInfoCards = ({ label: t("bonds.details.card.bondPrice"), value: (
- + {spotPriceBondAccumulated.isInitialLoading ? ( @@ -127,12 +127,7 @@ export const BondInfoCards = ({ }), value: (
- + {spotPriceAccumulated.isInitialLoading ? ( @@ -159,7 +154,6 @@ export const BondInfoCards = ({ fs={[13, 15]} lh={[13, 15]} color={isDiscount ? "white" : "red300"} - font="GeistMono" sx={{ mb: 6 }} > {t("value.percentage", { value: discount })} diff --git a/src/sections/trade/sections/bonds/details/components/DetailCard/DetailCard.tsx b/src/sections/trade/sections/bonds/details/components/DetailCard/DetailCard.tsx index 39e1960f1..df3beee89 100644 --- a/src/sections/trade/sections/bonds/details/components/DetailCard/DetailCard.tsx +++ b/src/sections/trade/sections/bonds/details/components/DetailCard/DetailCard.tsx @@ -38,7 +38,7 @@ export const DetailCard = ({ }} > {typeof value === "string" ? ( - + {value} ) : ( diff --git a/src/sections/trade/sections/otc/modals/PartialFillOrder.tsx b/src/sections/trade/sections/otc/modals/PartialFillOrder.tsx index 678695a5c..b1ab965ba 100644 --- a/src/sections/trade/sections/otc/modals/PartialFillOrder.tsx +++ b/src/sections/trade/sections/otc/modals/PartialFillOrder.tsx @@ -170,7 +170,7 @@ export const PartialFillOrder = ({ {"Remaining amount:"} - + {t("otc.order.fill.remaining", { remaining: accepting.amount, symbol: accepting.symbol, diff --git a/src/sections/trade/sections/swap/SwapPage.tsx b/src/sections/trade/sections/swap/SwapPage.tsx index a8423203d..268d6ee4b 100644 --- a/src/sections/trade/sections/swap/SwapPage.tsx +++ b/src/sections/trade/sections/swap/SwapPage.tsx @@ -18,7 +18,6 @@ import { useRemount } from "hooks/useRemount" import { ExternalAssetImportModal } from "sections/trade/modal/ExternalAssetImportModal" import { AddTokenModal } from "sections/wallet/addToken/modal/AddTokenModal" import { useState } from "react" -import { useUserExternalTokenStore } from "sections/wallet/addToken/AddToken.utils" const defaultEvmTokenId: string = import.meta.env.VITE_EVM_NATIVE_ASSET_ID @@ -61,13 +60,9 @@ export function SwapPage() { const { stableCoinId } = useDisplayAssetStore() const preference = useProviderRpcUrlStore() const [addToken, setAddToken] = useState(false) - const { tokens: externalTokensStored } = useUserExternalTokenStore.getState() const isEvm = isEvmAccount(account?.address) - const version = useRemount([ - isEvm, - externalTokensStored[preference.getDataEnv()].length, - ]) + const version = useRemount([isEvm]) const rpcUrl = preference.rpcUrl ?? import.meta.env.VITE_PROVIDER_URL diff --git a/src/sections/transaction/ReviewTransactionForm.tsx b/src/sections/transaction/ReviewTransactionForm.tsx index f63eabb02..6a7e2253c 100644 --- a/src/sections/transaction/ReviewTransactionForm.tsx +++ b/src/sections/transaction/ReviewTransactionForm.tsx @@ -83,6 +83,7 @@ export const ReviewTransactionForm: FC = (props) => { isLinkedAccount, storedReferralCode, tx, + era, } = transactionValues.data const isLinking = !isLinkedAccount && storedReferralCode @@ -121,6 +122,7 @@ export const ReviewTransactionForm: FC = (props) => { } const signature = await tx.signAsync(address, { + era: era?.period?.toNumber(), tip: tipAmount?.gte(0) ? tipAmount.toString() : undefined, signer: wallet.signer, // defer to polkadot/api to handle nonce w/ regard to mempool diff --git a/src/sections/transaction/ReviewTransactionForm.utils.tsx b/src/sections/transaction/ReviewTransactionForm.utils.tsx index 374ff55bc..f1f151355 100644 --- a/src/sections/transaction/ReviewTransactionForm.utils.tsx +++ b/src/sections/transaction/ReviewTransactionForm.utils.tsx @@ -105,7 +105,6 @@ export const useTransactionValues = ({ const era = useEra( boundedTx.era, bestNumber.data?.parachainBlockNumber.toString(), - boundedTx.era.isMortalEra, ) const feePaymentValue = paymentInfo?.partialFee.toBigNumber() ?? BN_NAN diff --git a/src/sections/transaction/ReviewTransactionSummary.tsx b/src/sections/transaction/ReviewTransactionSummary.tsx index 812593d3c..818d29ac3 100644 --- a/src/sections/transaction/ReviewTransactionSummary.tsx +++ b/src/sections/transaction/ReviewTransactionSummary.tsx @@ -12,6 +12,8 @@ import { useRpcProvider } from "providers/rpcProvider" import { ReviewTransactionAuthorTip } from "sections/transaction/ReviewTransactionAuthorTip" import { NATIVE_EVM_ASSET_SYMBOL } from "utils/evm" import { Transaction } from "state/store" +import { InfoTooltip } from "components/InfoTooltip/InfoTooltip" +import { SInfoIcon } from "components/InfoTooltip/InfoTooltip.styled" type ReviewTransactionSummaryProps = { tx: SubmittableExtrinsic<"promise"> @@ -24,7 +26,6 @@ type ReviewTransactionSummaryProps = { } export const ReviewTransactionSummary: FC = ({ - tx, transactionValues, xcallMeta, editFeePaymentAssetEnabled, @@ -116,11 +117,28 @@ export const ReviewTransactionSummary: FC = ({ rows={[ { label: t("liquidity.reviewTransaction.modal.detail.lifetime"), - content: tx.era.isMortalEra - ? t("transaction.mortal.expire", { - date: era?.deathDate, - }) - : t("transaction.immortal.expire"), + content: ( + + {era?.isLoading ? ( + + ) : era?.deathDate ? ( + <> + {t("transaction.mortal.expire", { + date: era.deathDate, + })} + + + + + ) : ( + t("transaction.immortal.expire") + )} + + ), }, { label: t("liquidity.reviewTransaction.modal.detail.nonce"), diff --git a/src/sections/wallet/assets/WalletAssets.utils.ts b/src/sections/wallet/assets/WalletAssets.utils.ts index 2e0511669..847aa89c0 100644 --- a/src/sections/wallet/assets/WalletAssets.utils.ts +++ b/src/sections/wallet/assets/WalletAssets.utils.ts @@ -61,25 +61,6 @@ export const useWalletAssetsTotals = ({ const shareTokenBalances = useTokensBalances(shareTokenIds, account?.address) const spotPrices = useDisplayShareTokenPrice(shareTokenIds) - const { warnings, setWarnings } = useWarningsStore() - - const isHdxPosition = lpPositions.data.some( - (position) => position.assetId === NATIVE_ASSET_ID, - ) - - useEffect(() => { - if (lpPositions.data.length) { - if (isHdxPosition && warnings.hdxLiquidity.visible == null) { - setWarnings("hdxLiquidity", true) - } - } - }, [ - warnings.hdxLiquidity.visible, - setWarnings, - lpPositions.data.length, - isHdxPosition, - ]) - const assetsTotal = useMemo(() => { if (!assets.data) return BN_0 diff --git a/yarn.lock b/yarn.lock index c52b9435a..e653b4152 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2586,10 +2586,10 @@ resolved "https://registry.yarnpkg.com/@galacticcouncil/api-augment/-/api-augment-0.0.6.tgz#fc54c04c3bb953db3f739ea2c5820153088d564d" integrity sha512-5Qq+dzRoyuMS6uUXjl1asRrosIQ1n0vD0dzbxK8H8f3hmIzDdpiQVqlqWBLEc7D/PA7VM/7j1scICpdjtJJELw== -"@galacticcouncil/apps@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@galacticcouncil/apps/-/apps-4.0.0.tgz#2691a27a724d973f06bf8fcd8ae2ec88cd8873b2" - integrity sha512-hH0mK++kjRed4yuflzbS8fnJjG8OM0La7vjHniA0Lsrh7YA7ZNfaPcR00oSAe6wjH1vAG8DaFmLOMu3I/bBEww== +"@galacticcouncil/apps@^4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@galacticcouncil/apps/-/apps-4.1.0.tgz#051c81890f3e98591dd1f818535b0caa3feebebd" + integrity sha512-xv8BrB2bDIQ+rarPOr7TN4euHYYxy4tVgAwDb/BD8qNDHecPGF71uKrRHCQiM23UYMpYkoPb3YCGSoCkrLvSJQ== dependencies: "@cfx-kit/wallet-avatar" "0.0.5" "@thi.ng/atom" "^5.1.3" @@ -2646,10 +2646,10 @@ bignumber.js "^9.1.0" lodash.clonedeep "^4.5.0" -"@galacticcouncil/ui@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@galacticcouncil/ui/-/ui-4.0.0.tgz#bde951dc5ac21c74474098083e5846bc74fb8c1e" - integrity sha512-4AB7mK4U2s3qUgSKp6zDuUbybDqGro6Y5h23a0nQ+atWSbcd+7c41YRbYV7ZA007qOtVawNyd/tW5ht38U2LwQ== +"@galacticcouncil/ui@^4.0.3": + version "4.0.3" + resolved "https://registry.yarnpkg.com/@galacticcouncil/ui/-/ui-4.0.3.tgz#23f633e104e805f33f43e676f2e41b061c8c6f8c" + integrity sha512-BvNOkfS03p3l3kij+tOK2HAgTVDcyT3uCyY/YnYMA73mJFJIX3biG9iAaxKwhCskKA0yXlaX7c+yoPKX97KE+g== dependencies: "@floating-ui/dom" "^1.5.1" "@lit/reactive-element" "^1.0.0"