From 836bd226ceb32dbbf0d3774ea6349c87b0299e89 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 26 Jan 2024 17:12:47 +0100 Subject: [PATCH 1/6] FIx textation --- 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 d1151dfa..d9f366c1 100644 --- a/src/i18n/locales/en/translations.json +++ b/src/i18n/locales/en/translations.json @@ -364,7 +364,7 @@ "fund.modal.crypto.buy": "Use cross-chain", "fund.button": "Fund wallet", "depeg.modal.title": "Important Notice", - "depeg.modal.desx": "Tether have dropped support for native USDT on Kusama - herefore USDT pools are currently not priced at $1", + "depeg.modal.desx": "Tether have dropped support for native USDT on Kusama - thefore USDT pools are currently not priced at $1", "depeg.modal.desx.crossChain": "Cross chain transfers in Kusama are temporarily suspended, please do not try to send tokens", "depeg.modal.icon": "More info" } From 4062659e6d97f387ea0e14132d341b3b71255012 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Tue, 13 Feb 2024 11:41:46 +0100 Subject: [PATCH 2/6] Fix lint --- src/api/farms.ts | 2 +- src/utils/farms/positions.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/farms.ts b/src/api/farms.ts index c8ceac72..7d900c19 100644 --- a/src/api/farms.ts +++ b/src/api/farms.ts @@ -221,7 +221,7 @@ export const getGlobalFarm = (api: ApiPromise, id: u32) => async () => { } export interface FarmIds { - poolId: AccountId32 + poolId: AccountId32 | string globalFarmId: u32 yieldFarmId: u32 } diff --git a/src/utils/farms/positions.ts b/src/utils/farms/positions.ts index bf41a102..fb5cdddd 100644 --- a/src/utils/farms/positions.ts +++ b/src/utils/farms/positions.ts @@ -22,12 +22,12 @@ export const useTotalInPositions = () => { ({ position: { yieldFarmId, globalFarmId }, poolId }) => ({ yieldFarmId: yieldFarmId, globalFarmId: globalFarmId, - poolId, + poolId: poolId.toString(), }), ) ?? [], ) const shareTokens = usePoolShareTokens( - deposits.data?.deposits?.map(({ deposit }) => deposit.ammPoolId) ?? [], + deposits.data?.deposits?.map(({ deposit }) => deposit.ammPoolId.toString()) ?? [], ) const totalIssuances = useTotalIssuances( shareTokens.map((st) => st.data?.token), From 9e0b8f202b214059475fc09cdff51af46ae639dc Mon Sep 17 00:00:00 2001 From: vkulinich Date: Tue, 13 Feb 2024 12:47:51 +0100 Subject: [PATCH 3/6] Fix lint frozen --- src/api/accountBalances.ts | 19 ++++++++++++++----- src/api/balances.ts | 14 +++++++++++--- .../table/data/WalletAssetsTableData.utils.ts | 12 ++++++++++-- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/api/accountBalances.ts b/src/api/accountBalances.ts index 59cfc181..ea6ed925 100644 --- a/src/api/accountBalances.ts +++ b/src/api/accountBalances.ts @@ -4,8 +4,13 @@ import { useQuery } from "@tanstack/react-query" import { QUERY_KEYS } from "utils/queryKeys" import { ApiPromise } from "@polkadot/api" import { Maybe, undefinedNoop } from "utils/helpers" -import { u32 } from "@polkadot/types" +import { u32, u128 } from "@polkadot/types" +import { PalletBalancesAccountData } from "@polkadot/types/lookup" +//import BN from "bignumber.js" import { BN } from "@polkadot/util" +interface PalletBalancesAccountDataCustom extends PalletBalancesAccountData { + frozen: u128 +} export const useAccountBalances = (id: Maybe) => { const api = useApiPromise() @@ -65,10 +70,14 @@ const getTokenAccountBalancesList = const [, assetId] = pairs[idx] if (assetId.toString() === NATIVE_ASSET_ID) { - let {data} = natives[nativeIdx] - const frozen = data.feeFrozen ? data.feeFrozen.add( - data.miscFrozen, - ) : data.frozen + //@ts-ignore + let { data }: { data: PalletBalancesAccountDataCustom } = + natives[nativeIdx] + + const frozen = data.feeFrozen + ? data.feeFrozen.add(data.miscFrozen) + : data.frozen + values.push({ free: data.free, reserved: data.reserved, diff --git a/src/api/balances.ts b/src/api/balances.ts index 6e60d5e2..791448a1 100644 --- a/src/api/balances.ts +++ b/src/api/balances.ts @@ -14,10 +14,18 @@ export const getTokenBalance = (api: ApiPromise, account: AccountId32 | string, id: string | u32) => async () => { if (id.toString() === NATIVE_ASSET_ID) { - const res = await api.query.system.account(account) + const res = (await api.query.system.account(account)) as any const freeBalance = new BigNumber(res.data.free.toHex()) - const miscFrozenBalance = new BigNumber(res.data.miscFrozen ? res.data.miscFrozen.toHex() : res.data.frozen.toHex()) - const feeFrozenBalance = new BigNumber(res.data.feeFrozen ? res.data.feeFrozen.toHex() : res.data.frozen.toHex()) + const miscFrozenBalance = new BigNumber( + res.data.miscFrozen + ? res.data.miscFrozen.toHex() + : res.data.frozen.toHex(), + ) + const feeFrozenBalance = new BigNumber( + res.data.feeFrozen + ? res.data.feeFrozen.toHex() + : res.data.frozen.toHex(), + ) const reservedBalance = new BigNumber(res.data.reserved.toHex()) const balance = new BigNumber( diff --git a/src/sections/wallet/assets/table/data/WalletAssetsTableData.utils.ts b/src/sections/wallet/assets/table/data/WalletAssetsTableData.utils.ts index 0f6a24f0..8906ac4e 100644 --- a/src/sections/wallet/assets/table/data/WalletAssetsTableData.utils.ts +++ b/src/sections/wallet/assets/table/data/WalletAssetsTableData.utils.ts @@ -278,8 +278,16 @@ const getNativeBalances = ( const dp = BN_10.pow(decimals) const free = balance.free.toBigNumber() const reservedBN = balance.reserved.toBigNumber() - const feeFrozen = balance.feeFrozen ? balance.feeFrozen.toBigNumber() : balance.frozen.toBigNumber() - const miscFrozen = balance.miscFrozen ? balance.miscFrozen.toBigNumber() : balance.frozen.toBigNumber() + + const feeFrozen = balance.feeFrozen + ? balance.feeFrozen.toBigNumber() + : //@ts-ignore + balance.frozen.toBigNumber() + + const miscFrozen = balance.miscFrozen + ? balance.miscFrozen.toBigNumber() + : //@ts-ignore + balance.frozen.toBigNumber() const total = free.plus(reservedBN).div(dp) const totalUSD = total.times(spotPrice) From 839b26ea70d043c11f00c5490995bd920c7544db Mon Sep 17 00:00:00 2001 From: vkulinich Date: Tue, 13 Feb 2024 12:48:52 +0100 Subject: [PATCH 4/6] wip --- src/api/accountBalances.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/accountBalances.ts b/src/api/accountBalances.ts index ea6ed925..d12549f7 100644 --- a/src/api/accountBalances.ts +++ b/src/api/accountBalances.ts @@ -6,7 +6,6 @@ import { ApiPromise } from "@polkadot/api" import { Maybe, undefinedNoop } from "utils/helpers" import { u32, u128 } from "@polkadot/types" import { PalletBalancesAccountData } from "@polkadot/types/lookup" -//import BN from "bignumber.js" import { BN } from "@polkadot/util" interface PalletBalancesAccountDataCustom extends PalletBalancesAccountData { frozen: u128 From b7019949b4fd056406eab71d7a63549760ac21c4 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Tue, 13 Feb 2024 12:51:03 +0100 Subject: [PATCH 5/6] Fix lint warning --- src/sections/pools/pool/modals/myPositions/MyPositionsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sections/pools/pool/modals/myPositions/MyPositionsList.tsx b/src/sections/pools/pool/modals/myPositions/MyPositionsList.tsx index 86b4f74b..67368585 100644 --- a/src/sections/pools/pool/modals/myPositions/MyPositionsList.tsx +++ b/src/sections/pools/pool/modals/myPositions/MyPositionsList.tsx @@ -27,6 +27,6 @@ export const MyPositionsList = ({ pool, onClose }: Props) => { onClose={onClose} /> )) - }, [depositNftList, pool]) + }, [depositNftList, onClose, pool]) return
{positionsList}
} From 9a5b00d58f923cf4dd1fb65555b2a7eba80b7414 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Tue, 13 Feb 2024 12:53:48 +0100 Subject: [PATCH 6/6] Format code --- src/utils/farms/apr.ts | 2 +- src/utils/farms/positions.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/farms/apr.ts b/src/utils/farms/apr.ts index d2ed95b5..9687eb36 100644 --- a/src/utils/farms/apr.ts +++ b/src/utils/farms/apr.ts @@ -71,7 +71,7 @@ export const useAPR = (poolId: AccountId32 | string) => { // all of the APR calculations are using only half of the position - // this is correct in terms of inputs but for the user, // they are not depositing only half of the position, they are depositing 2 assets - apr = globalFarm.id.toString() === '5'? BN_0: apr.div(2) + apr = globalFarm.id.toString() === "5" ? BN_0 : apr.div(2) const minApr = apr.times(loyaltyFactor) // max distribution of rewards diff --git a/src/utils/farms/positions.ts b/src/utils/farms/positions.ts index fb5cdddd..752d41b4 100644 --- a/src/utils/farms/positions.ts +++ b/src/utils/farms/positions.ts @@ -27,7 +27,9 @@ export const useTotalInPositions = () => { ) ?? [], ) const shareTokens = usePoolShareTokens( - deposits.data?.deposits?.map(({ deposit }) => deposit.ammPoolId.toString()) ?? [], + deposits.data?.deposits?.map(({ deposit }) => + deposit.ammPoolId.toString(), + ) ?? [], ) const totalIssuances = useTotalIssuances( shareTokens.map((st) => st.data?.token),