From 082655dc7d1f4ade26e0ae64ba4f828651d9f63d Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 7 Jun 2024 17:10:09 +0200 Subject: [PATCH 01/16] Improve Farms --- src/api/farms.ts | 74 +++++++++++++++---- src/i18n/i18n.ts | 2 +- .../detailsCard/FarmDetailsCard.tsx | 2 +- .../farms/modals/join/JoinFarmsModal.tsx | 6 +- .../farms/modals/join/JoinFarmsModal.utils.ts | 12 ++- .../pool/positions/LiquidityPosition.tsx | 12 ++- 6 files changed, 81 insertions(+), 27 deletions(-) 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/i18n/i18n.ts b/src/i18n/i18n.ts index 57c2359a7..ad068c447 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: 1 }, lng, )?.replaceAll( getFormatSeparators(lng).group ?? ",", diff --git a/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx b/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx index 900a92ea7..003ae3e09 100644 --- a/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx +++ b/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx @@ -124,7 +124,7 @@ export const FarmDetailsCard = ({ apr.data.distributedRewards, asset.decimals, ), - max: scaleHuman(apr.data.maxRewards, asset.decimals), + max: scaleHuman(apr.data.potMaxRewards, asset.decimals), }} > 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..c13215cf8 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() @@ -41,12 +41,18 @@ export const useZodSchema = ( return valueInHub.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/pool/positions/LiquidityPosition.tsx b/src/sections/pools/pool/positions/LiquidityPosition.tsx index 5ce2b1afe..ad41c7816 100644 --- a/src/sections/pools/pool/positions/LiquidityPosition.tsx +++ b/src/sections/pools/pool/positions/LiquidityPosition.tsx @@ -107,13 +107,11 @@ export const LiquidityPosition = ({ gap: 12, }} > - {!meta.isStableSwap && ( - - )} + Date: Fri, 7 Jun 2024 17:23:50 +0200 Subject: [PATCH 02/16] wip --- src/i18n/i18n.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts index ad068c447..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", maximumSignificantDigits: 1 }, + { notation: "compact", maximumSignificantDigits: 2 }, lng, )?.replaceAll( getFormatSeparators(lng).group ?? ",", From 2dbedfcc209c9f23abf764ed7661464ab6f6e964 Mon Sep 17 00:00:00 2001 From: Pavol Noha Date: Mon, 10 Jun 2024 11:11:13 +0200 Subject: [PATCH 03/16] upgrade apps & ui (external icons) --- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index e7bed63d4..e92fa428e 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": "^3.9.1", + "@galacticcouncil/apps": "^4.0.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": "^3.2.3", + "@galacticcouncil/ui": "^4.0.0", "@galacticcouncil/xcm-cfg": "^2.5.0", "@galacticcouncil/xcm-core": "^1.4.0", "@galacticcouncil/xcm-sdk": "^3.3.0", diff --git a/yarn.lock b/yarn.lock index f92258fb2..c52b9435a 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@^3.9.1": - version "3.9.1" - resolved "https://registry.yarnpkg.com/@galacticcouncil/apps/-/apps-3.9.1.tgz#3cafd864a8eddb8eac82bb52397d3789a1499f4e" - integrity sha512-t69sW8dWexThPkITIAzTJdvwGMO16UuIYCuWISFzieIUnCgBbD0Q8pnDyh2Av7ZNKK5d8NPDbjDiW29CTCpCVQ== +"@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== 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@^3.2.3": - version "3.2.3" - resolved "https://registry.yarnpkg.com/@galacticcouncil/ui/-/ui-3.2.3.tgz#847da6005d09d4a1910544f6b233157f30565382" - integrity sha512-SLCrwNwalVwV9PCmfXgFZ8wVTDEBRsZp40G1nLXzuDNwnkjx7UhXY1L6M9N7KLi92cnswoM4baRKXHgyNVzkAQ== +"@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== dependencies: "@floating-ui/dom" "^1.5.1" "@lit/reactive-element" "^1.0.0" From 4b5c892ad380227c8c4ec0a1491a1db7175594bc Mon Sep 17 00:00:00 2001 From: vkulinich Date: Mon, 10 Jun 2024 12:35:26 +0200 Subject: [PATCH 04/16] Remove GeistMono font for number values --- .../claimAllDropdown/ClaimAllContent.tsx | 2 +- .../components/claimableCard/ClaimRewardsCard.tsx | 1 - .../components/detailsCard/FarmDetailsCard.tsx | 2 +- .../modals/RemoveLiquidity/RemoveLiquidityForm.tsx | 4 ++-- .../RemoveLiquidity/RemoveXYKLiquidityForm.tsx | 4 ++-- .../removeLiquidity/RemoveLiquidityForm.tsx | 10 ++-------- .../components/RewardsCard/RewardsCard.tsx | 2 +- .../AvailableRewards/AvailableRewards.tsx | 14 +++++++------- .../dashboard/components/PieChart/PieChart.tsx | 4 +--- .../sections/LRNA/components/Burning/Burning.tsx | 4 ++-- .../LRNA/components/Distribution/TotalValue.tsx | 2 +- .../sections/omnipoolAsset/StatsOmnipoolAsset.tsx | 4 +--- .../omnipoolAsset/stats/AssetStatsCard.tsx | 2 +- .../components/BondInfoCards/BondInfoCards.tsx | 10 ++-------- .../details/components/DetailCard/DetailCard.tsx | 2 +- .../trade/sections/otc/modals/PartialFillOrder.tsx | 2 +- 16 files changed, 26 insertions(+), 43 deletions(-) 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.tsx b/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx index 003ae3e09..677d4b7aa 100644 --- a/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx +++ b/src/sections/pools/farms/components/detailsCard/FarmDetailsCard.tsx @@ -101,7 +101,7 @@ export const FarmDetailsCard = ({ {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 })} 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 })}
- + {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, From 8b2eb2d6b4f385f14a1467b4201889ca5c3a8feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Von=C3=A1=C5=A1ek?= Date: Mon, 10 Jun 2024 17:50:39 +0200 Subject: [PATCH 05/16] Hide HDX LP position warning --- .../wallet/assets/WalletAssets.utils.ts | 19 ------------------- 1 file changed, 19 deletions(-) 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 From 12e096665d0bbabe9c3129366785b36b4515e98b Mon Sep 17 00:00:00 2001 From: vkulinich Date: Mon, 10 Jun 2024 18:31:41 +0200 Subject: [PATCH 06/16] Fix join farm validation --- src/i18n/locales/en/translations.json | 2 +- src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/i18n/locales/en/translations.json b/src/i18n/locales/en/translations.json index 98689e901..14a8eab8a 100644 --- a/src/i18n/locales/en/translations.json +++ b/src/i18n/locales/en/translations.json @@ -596,7 +596,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", diff --git a/src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts b/src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts index c13215cf8..48066b000 100644 --- a/src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts +++ b/src/sections/pools/farms/modals/join/JoinFarmsModal.utils.ts @@ -38,7 +38,10 @@ 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( From 95d4dbbd66fc92004008ac4d7fe3a1d130c270bd Mon Sep 17 00:00:00 2001 From: vkulinich Date: Tue, 11 Jun 2024 12:44:04 +0200 Subject: [PATCH 07/16] Fix ios styling issues --- src/assets/icons/HydraLogo.svg | 4 +- src/components/Layout/Header/Header.tsx | 8 ++- src/components/Modal/Modal.styled.ts | 2 +- .../pools/components/NewFarmsBanner.styled.ts | 4 +- .../pools/components/NewFarmsBanner.tsx | 70 +++++++++++++------ .../detailsCard/FarmDetailsCard.styled.ts | 36 +++++----- .../detailsCard/FarmDetailsCard.tsx | 52 ++++++++------ 7 files changed, 108 insertions(+), 68 deletions(-) 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/Layout/Header/Header.tsx b/src/components/Layout/Header/Header.tsx index 5146a19ad..5ee3cbeb2 100644 --- a/src/components/Layout/Header/Header.tsx +++ b/src/components/Layout/Header/Header.tsx @@ -41,7 +41,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/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/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 677d4b7aa..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 })} -
-
+ +
} - css={{ gridArea: "icon" }} /> )} From d9ed7d03674cb8b9cec36c22036a442d28608c47 Mon Sep 17 00:00:00 2001 From: Pavol Noha Date: Tue, 11 Jun 2024 19:36:34 +0200 Subject: [PATCH 08/16] upgrade apps & ui kit --- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index e92fa428e..2e77a5659 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.1", "@galacticcouncil/xcm-cfg": "^2.5.0", "@galacticcouncil/xcm-core": "^1.4.0", "@galacticcouncil/xcm-sdk": "^3.3.0", diff --git a/yarn.lock b/yarn.lock index c52b9435a..6d0b392b5 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.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@galacticcouncil/ui/-/ui-4.0.1.tgz#8a9d9eabdea3e7bdac4c14171ac2f499192fd260" + integrity sha512-CL5QzikCWGZIuEDgpwOfwLgRDjVRNPcWm62QeB0SUYNt5LnTgAEVwA9RLbC+LQqC+xkgE98Dcz/18zeaKJZmAg== dependencies: "@floating-ui/dom" "^1.5.1" "@lit/reactive-element" "^1.0.0" From de4d9a53b8904d204ed0a6bd349a89d484c77333 Mon Sep 17 00:00:00 2001 From: Pavol Noha Date: Tue, 11 Jun 2024 19:40:57 +0200 Subject: [PATCH 09/16] fix context provider --- src/components/AppProviders/AppProviders.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/AppProviders/AppProviders.tsx b/src/components/AppProviders/AppProviders.tsx index cb9f571cf..4785a5c9a 100644 --- a/src/components/AppProviders/AppProviders.tsx +++ b/src/components/AppProviders/AppProviders.tsx @@ -11,9 +11,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, }) @@ -29,7 +29,7 @@ export const AppProviders: FC = ({ children }) => { highlightColor={`rgba(${theme.rgbColors.white}, 0.24)`} borderRadius={4} > - {children} + {children} From d245a50a273ba529dc90798f788fd1127dba06ac Mon Sep 17 00:00:00 2001 From: Pavol Noha Date: Tue, 11 Jun 2024 21:14:00 +0200 Subject: [PATCH 10/16] upgrade ui kit (fix logo host display) --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2e77a5659..7c09e4a78 100644 --- a/package.json +++ b/package.json @@ -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.1", + "@galacticcouncil/ui": "^4.0.2", "@galacticcouncil/xcm-cfg": "^2.5.0", "@galacticcouncil/xcm-core": "^1.4.0", "@galacticcouncil/xcm-sdk": "^3.3.0", diff --git a/yarn.lock b/yarn.lock index 6d0b392b5..be010dfb5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2646,10 +2646,10 @@ bignumber.js "^9.1.0" lodash.clonedeep "^4.5.0" -"@galacticcouncil/ui@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@galacticcouncil/ui/-/ui-4.0.1.tgz#8a9d9eabdea3e7bdac4c14171ac2f499192fd260" - integrity sha512-CL5QzikCWGZIuEDgpwOfwLgRDjVRNPcWm62QeB0SUYNt5LnTgAEVwA9RLbC+LQqC+xkgE98Dcz/18zeaKJZmAg== +"@galacticcouncil/ui@^4.0.2": + version "4.0.2" + resolved "https://registry.yarnpkg.com/@galacticcouncil/ui/-/ui-4.0.2.tgz#85ad9ca689bed0b6196ad8d94f84739befe0c5f8" + integrity sha512-1VxyDZTbuXu8BIKco3yxzmdjbZIy6hn1pqhkUq4nPa6PqBIab3hNScHwah4hL+F4znT1eGRHbRqb9H5W9SaFbA== dependencies: "@floating-ui/dom" "^1.5.1" "@lit/reactive-element" "^1.0.0" From c0eba769ee3740ff6cc1561a919a7404a35fe01a Mon Sep 17 00:00:00 2001 From: Pavol Noha Date: Tue, 11 Jun 2024 21:48:08 +0200 Subject: [PATCH 11/16] remove swap remount on external change --- package.json | 2 +- src/sections/trade/sections/swap/SwapPage.tsx | 9 --------- yarn.lock | 8 ++++---- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 7c09e4a78..468c0bfbd 100644 --- a/package.json +++ b/package.json @@ -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.2", + "@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/sections/trade/sections/swap/SwapPage.tsx b/src/sections/trade/sections/swap/SwapPage.tsx index a8423203d..de8d273dd 100644 --- a/src/sections/trade/sections/swap/SwapPage.tsx +++ b/src/sections/trade/sections/swap/SwapPage.tsx @@ -14,11 +14,9 @@ import { useAccount } from "sections/web3-connect/Web3Connect.utils" import { useDisplayAssetStore } from "utils/displayAsset" import { isEvmAccount } from "utils/evm" import { NATIVE_ASSET_ID } from "utils/api" -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,14 +59,8 @@ 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 rpcUrl = preference.rpcUrl ?? import.meta.env.VITE_PROVIDER_URL const rawSearch = useSearch() @@ -125,7 +117,6 @@ export function SwapPage() { return ( { if (r) { r.setAttribute("chart", "") diff --git a/yarn.lock b/yarn.lock index be010dfb5..e653b4152 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2646,10 +2646,10 @@ bignumber.js "^9.1.0" lodash.clonedeep "^4.5.0" -"@galacticcouncil/ui@^4.0.2": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@galacticcouncil/ui/-/ui-4.0.2.tgz#85ad9ca689bed0b6196ad8d94f84739befe0c5f8" - integrity sha512-1VxyDZTbuXu8BIKco3yxzmdjbZIy6hn1pqhkUq4nPa6PqBIab3hNScHwah4hL+F4znT1eGRHbRqb9H5W9SaFbA== +"@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" From 6d97db35e672449bb85cc95e19b09a609fd35f8a Mon Sep 17 00:00:00 2001 From: Pavol Noha Date: Wed, 12 Jun 2024 10:11:54 +0200 Subject: [PATCH 12/16] evm wallet hook rollback --- src/sections/trade/sections/swap/SwapPage.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sections/trade/sections/swap/SwapPage.tsx b/src/sections/trade/sections/swap/SwapPage.tsx index de8d273dd..268d6ee4b 100644 --- a/src/sections/trade/sections/swap/SwapPage.tsx +++ b/src/sections/trade/sections/swap/SwapPage.tsx @@ -14,6 +14,7 @@ import { useAccount } from "sections/web3-connect/Web3Connect.utils" import { useDisplayAssetStore } from "utils/displayAsset" import { isEvmAccount } from "utils/evm" import { NATIVE_ASSET_ID } from "utils/api" +import { useRemount } from "hooks/useRemount" import { ExternalAssetImportModal } from "sections/trade/modal/ExternalAssetImportModal" import { AddTokenModal } from "sections/wallet/addToken/modal/AddTokenModal" import { useState } from "react" @@ -61,6 +62,8 @@ export function SwapPage() { const [addToken, setAddToken] = useState(false) const isEvm = isEvmAccount(account?.address) + const version = useRemount([isEvm]) + const rpcUrl = preference.rpcUrl ?? import.meta.env.VITE_PROVIDER_URL const rawSearch = useSearch() @@ -117,6 +120,7 @@ export function SwapPage() { return ( { if (r) { r.setAttribute("chart", "") From a00e8fe7caba67cf4a4cf01e638d53ba4a4277ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Von=C3=A1=C5=A1ek?= Date: Wed, 12 Jun 2024 12:37:15 +0200 Subject: [PATCH 13/16] updated whitelist source --- src/components/AssetIcon/AssetIcon.tsx | 27 +++++++++----------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/components/AssetIcon/AssetIcon.tsx b/src/components/AssetIcon/AssetIcon.tsx index 2a3781725..8e5592afd 100644 --- a/src/components/AssetIcon/AssetIcon.tsx +++ b/src/components/AssetIcon/AssetIcon.tsx @@ -13,19 +13,7 @@ import { useRpcProvider } from "providers/rpcProvider" import { useTranslation } from "react-i18next" import { AnyParachain } from "@galacticcouncil/xcm-core" import { isAnyParachain } from "utils/helpers" - -const EXTERNAL_ASSETS_WHITELIST = [ - // PINK - { id: "23", origin: 1000 }, - // STINK - { id: "42069", origin: 1000 }, - // WUD - { id: "31337", origin: 1000 }, - // WIFD - { id: "17", origin: 1000 }, - // BNDT - { id: "8889", origin: 1000 }, -] +import { MetadataStore } from "@galacticcouncil/ui" const chains = Array.from(chainsMap.values()) @@ -57,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 @@ -66,11 +59,9 @@ export const AssetLogo = ({ id }: { id?: string }) => { chain.parachainId === Number(assetDetails?.parachainId), ) as AnyParachain - const isWhitelisted = EXTERNAL_ASSETS_WHITELIST.some( - (item) => - item.id === assetDetails?.externalId && - item.origin === chain?.parachainId, - ) + const isWhitelisted = assetDetails + ? externalAssetsWhitelist.includes(assetDetails.id) + : false const badgeVariant: "warning" | "danger" | "" = assetDetails?.isExternal ? isWhitelisted From 7954e5193db0e102c9f396ed641c82dd60399c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Von=C3=A1=C5=A1ek?= Date: Wed, 12 Jun 2024 13:56:17 +0200 Subject: [PATCH 14/16] Set era to 900 blocks --- src/api/era.tsx | 41 +++++++++++++------ src/api/timestamp.ts | 9 ++-- src/i18n/locales/en/translations.json | 4 +- .../transaction/ReviewTransactionForm.tsx | 2 + .../ReviewTransactionForm.utils.tsx | 1 - .../transaction/ReviewTransactionSummary.tsx | 19 ++++++--- 6 files changed, 50 insertions(+), 26 deletions(-) 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/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/i18n/locales/en/translations.json b/src/i18n/locales/en/translations.json index 14a8eab8a..f056242b0 100644 --- a/src/i18n/locales/en/translations.json +++ b/src/i18n/locales/en/translations.json @@ -377,7 +377,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.", @@ -909,7 +909,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/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..8cacb5890 100644 --- a/src/sections/transaction/ReviewTransactionSummary.tsx +++ b/src/sections/transaction/ReviewTransactionSummary.tsx @@ -24,7 +24,6 @@ type ReviewTransactionSummaryProps = { } export const ReviewTransactionSummary: FC = ({ - tx, transactionValues, xcallMeta, editFeePaymentAssetEnabled, @@ -116,11 +115,19 @@ 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"), From ec34164ca123d24842e62fcfc0d8092deb867b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Von=C3=A1=C5=A1ek?= Date: Wed, 12 Jun 2024 14:17:38 +0200 Subject: [PATCH 15/16] added lifetime tooltip --- src/i18n/locales/en/translations.json | 1 + .../transaction/ReviewTransactionSummary.tsx | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/i18n/locales/en/translations.json b/src/i18n/locales/en/translations.json index f056242b0..fd8500e68 100644 --- a/src/i18n/locales/en/translations.json +++ b/src/i18n/locales/en/translations.json @@ -286,6 +286,7 @@ "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.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", diff --git a/src/sections/transaction/ReviewTransactionSummary.tsx b/src/sections/transaction/ReviewTransactionSummary.tsx index 8cacb5890..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"> @@ -116,13 +118,22 @@ export const ReviewTransactionSummary: FC = ({ { label: t("liquidity.reviewTransaction.modal.detail.lifetime"), content: ( - + {era?.isLoading ? ( ) : era?.deathDate ? ( - t("transaction.mortal.expire", { - date: era.deathDate, - }) + <> + {t("transaction.mortal.expire", { + date: era.deathDate, + })} + + + + ) : ( t("transaction.immortal.expire") )} From 9b4b4d478b632a10edca3e72404109b51795aef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Von=C3=A1=C5=A1ek?= Date: Wed, 12 Jun 2024 14:59:36 +0200 Subject: [PATCH 16/16] update tx lifetime summary label --- src/i18n/locales/en/translations.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/locales/en/translations.json b/src/i18n/locales/en/translations.json index fd8500e68..702d5ae62 100644 --- a/src/i18n/locales/en/translations.json +++ b/src/i18n/locales/en/translations.json @@ -285,7 +285,7 @@ "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:",