Skip to content
This repository was archived by the owner on Jul 27, 2026. It is now read-only.

Commit 0df4ac5

Browse files
tomjeattbvottelerChanakya888danielsimaons212
authored
Tom/release/kintsugi/2.29.2 (#1116)
* chore: add resolutions for various polkadot packages (#1089) * Fix input field width issue (#1090) * fix: input field width * fix: rename max weeks to total weeks * chore: bump ui version * chore: bump XCM bridge (#1093) * feat(Wallet): add page (#1001) * feat(Wallet): add page * feat: add WalletIcon * feat: copy address * wip * feat: staking table * feat: refactor and add lending * refactor: clean up code * wip * feat: add List card * continue * fix: continue * feat: continue * feat(CTALink): improve * feat: add responsiveness and swap handling * feat: final * feat: add responsive prop * fix: clean up List and Divider * feat: add tests * feat: add final tests * fix: code review * feat: add vesting and tests * fix: code review * Tom/bug/burn form collateral tokens (#1042) * refactor: loop collateral to get burnable tokens * refactor: revert previous change and simplify * refactor: add function to filter tokens * refactor: fetch collateral currencies and render token values * wip: form layout and translation * wip: set data and selected collateral * chore: remove console log * refactor: remove single collateral code * chore: comment * fix: incorrect USD value * chore: remove testing code * refactor: remove native token import * refactor: add BurnableCollateral type * refactor: add fullWidth prop and label to token selector * refactor: collateral icon * chore: add dictionary item * chore: remove unnecessary conditional operators * refactor: handle callback * refactor: fix failing test * chore: remove unused code * refactor: add success notification to burn form * Add CORS to market data (#1096) * chore: add env variables to config * chore: add cors to market data api --------- Co-authored-by: ns212 <nikolai@interlay.io> * fix: revert to using 0.2.x version of the bridge (#1095) * chore: improve price impact warning copy * chore: release v2.29.0 * fix(amm): use correct hooks dependencies (#1105) * fix: update useGetCurrencies callbacks dependency arrays (#1108) * chore: release v2.29.1 * [wallet] improve wallet balance (#1109) * wip: correct wallet balance * refactor: account for borrow and lend positions when calculating total balance * refactor: add total liquidity balance * fix: typo * chore: add TODO * refactor: remove unnecessary toString call * refactor: redirect home route to wallet if enabled, defaulting to bridge if not * refactor: remove duplicated calculations * refactor: return liquidity pools calculation from hook * chore: release v2.29.2 --------- Co-authored-by: Brendon Votteler <bvotteler@users.noreply.github.com> Co-authored-by: Chanakya888 <samuraichanakya1@gmail.com> Co-authored-by: Daniel Simão <rui.daniel.simao@gmail.com> Co-authored-by: ns212 <nikolai@interlay.io> Co-authored-by: Dominik Harz <dominik.harz@gmail.com> Co-authored-by: Peter Slaný <47864599+peterslany@users.noreply.github.com>
1 parent 22f0dd0 commit 0df4ac5

5 files changed

Lines changed: 42 additions & 12 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "interbtc-ui",
3-
"version": "2.29.1",
3+
"version": "2.29.2",
44
"private": true,
55
"dependencies": {
66
"@craco/craco": "^6.1.1",
77
"@headlessui/react": "^1.1.1",
88
"@heroicons/react": "^2.0.0",
9-
"@interlay/bridge": "^0.2.7",
9+
"@interlay/bridge": "0.2.7",
1010
"@interlay/interbtc-api": "2.0.3",
1111
"@interlay/monetary-js": "0.7.2",
1212
"@polkadot/api": "9.14.2",

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ const App = (): JSX.Element => {
215215
<Route path={PAGES.ACTIONS}>
216216
<Actions />
217217
</Route>
218-
<Redirect exact from={PAGES.HOME} to={PAGES.BRIDGE} />
218+
<Redirect exact from={PAGES.HOME} to={isWalletEnabled ? PAGES.WALLET : PAGES.BRIDGE} />
219219
<Route path='*'>
220220
<NoMatch />
221221
</Route>

src/pages/Wallet/WalletOverview/components/WalletInsights/WalletInsights.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { convertMonetaryAmountToValueInUSD, formatUSD } from '@/common/utils/uti
55
import { Card, Dd, Dl, DlGroup, Dt, theme } from '@/component-library';
66
import { useMediaQuery } from '@/component-library/utils/use-media-query';
77
import { getTokenPrice } from '@/utils/helpers/prices';
8+
import { useGetAccountPools } from '@/utils/hooks/api/amm/use-get-account-pools';
9+
import { useGetAccountLendingStatistics } from '@/utils/hooks/api/loans/use-get-account-lending-statistics';
810
import { BalanceData } from '@/utils/hooks/api/tokens/use-get-balances';
911
import { useGetPrices } from '@/utils/hooks/api/use-get-prices';
1012

@@ -18,9 +20,12 @@ const WalletInsights = ({ balances }: WalletInsightsProps): JSX.Element => {
1820
const { t } = useTranslation();
1921

2022
const prices = useGetPrices();
23+
const { data: accountLendingStatistics } = useGetAccountLendingStatistics();
24+
const { data: accountPools } = useGetAccountPools();
25+
2126
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
2227

23-
const totalBalance =
28+
const rawBalance =
2429
balances &&
2530
Object.values(balances).reduce(
2631
(total, balance) =>
@@ -33,9 +38,14 @@ const WalletInsights = ({ balances }: WalletInsightsProps): JSX.Element => {
3338
new Big(0)
3439
);
3540

41+
const totalBalance = rawBalance
42+
?.add(accountLendingStatistics?.supplyAmountUSD || 0)
43+
.sub(accountLendingStatistics?.borrowAmountUSD || 0)
44+
.add(accountPools?.accountLiquidityUSD || 0);
45+
3646
const totalBalanceLabel = totalBalance ? formatUSD(totalBalance.toNumber(), { compact: true }) : '-';
3747

38-
const transfarableBalance =
48+
const transferableBalance =
3949
balances &&
4050
Object.values(balances).reduce(
4151
(total, balance) =>
@@ -48,8 +58,8 @@ const WalletInsights = ({ balances }: WalletInsightsProps): JSX.Element => {
4858
new Big(0)
4959
);
5060

51-
const transfarableBalanceLabel = transfarableBalance
52-
? formatUSD(transfarableBalance.toNumber(), { compact: true })
61+
const transferableBalanceLabel = transferableBalance
62+
? formatUSD(transferableBalance.toNumber(), { compact: true })
5363
: '-';
5464

5565
return (
@@ -73,7 +83,7 @@ const WalletInsights = ({ balances }: WalletInsightsProps): JSX.Element => {
7383
{t('transferable_balance')}
7484
</Dt>
7585
<Dd weight='bold' color='secondary'>
76-
{transfarableBalanceLabel}
86+
{transferableBalanceLabel}
7787
</Dd>
7888
</DlGroup>
7989
</Card>

src/utils/hooks/api/amm/use-get-account-pools.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { CurrencyExt, isCurrencyEqual, LiquidityPool, LpCurrency } from '@interlay/interbtc-api';
22
import { MonetaryAmount } from '@interlay/monetary-js';
33
import { AccountId } from '@polkadot/types/interfaces';
4+
import Big from 'big.js';
45
import { useErrorHandler } from 'react-error-boundary';
56
import { useQuery } from 'react-query';
67

8+
import { calculateAccountLiquidityUSD, calculateTotalLiquidityUSD } from '@/pages/AMM/shared/utils';
79
import { BLOCKTIME_REFETCH_INTERVAL } from '@/utils/constants/api';
10+
import { Prices, useGetPrices } from '@/utils/hooks/api/use-get-prices';
811

912
import useAccountId from '../../use-account-id';
1013
import { useGetLiquidityPools } from './use-get-liquidity-pools';
@@ -14,9 +17,14 @@ type AccountLiquidityPool = { data: LiquidityPool; amount: MonetaryAmount<LpCurr
1417
interface AccountPoolsData {
1518
positions: AccountLiquidityPool[];
1619
claimableRewards: Map<LpCurrency, MonetaryAmount<CurrencyExt>[]>;
20+
accountLiquidityUSD: Big;
1721
}
1822

19-
const getAccountLiqudityPools = async (accountId: AccountId, pools: LiquidityPool[]): Promise<AccountPoolsData> => {
23+
const getAccountLiqudityPools = async (
24+
accountId: AccountId,
25+
pools: LiquidityPool[],
26+
prices: Prices
27+
): Promise<AccountPoolsData> => {
2028
const accountLiquidityPools = await window.bridge.amm.getLiquidityProvidedByAccount(accountId);
2129
const claimableRewards = await window.bridge.amm.getClaimableFarmingRewards(accountId, accountLiquidityPools, pools);
2230
const filteredPools = accountLiquidityPools.filter((lpToken) => !lpToken.isZero());
@@ -31,7 +39,18 @@ const getAccountLiqudityPools = async (accountId: AccountId, pools: LiquidityPoo
3139
return [...acc, data];
3240
}, []);
3341

34-
return { positions, claimableRewards };
42+
const accountLiquidityUSD = positions
43+
.map(({ data, amount: accountLPTokenAmount }) => {
44+
const { pooledCurrencies, totalSupply } = data;
45+
const totalLiquidityUSD = calculateTotalLiquidityUSD(pooledCurrencies, prices);
46+
47+
return accountLPTokenAmount
48+
? calculateAccountLiquidityUSD(accountLPTokenAmount, totalLiquidityUSD, totalSupply)
49+
: 0;
50+
})
51+
.reduce((total, accountLPTokenAmount) => total.add(accountLPTokenAmount), new Big(0));
52+
53+
return { positions, claimableRewards, accountLiquidityUSD };
3554
};
3655

3756
interface UseGetAccountProvidedLiquidity {
@@ -42,12 +61,13 @@ interface UseGetAccountProvidedLiquidity {
4261
// Mixes current pools with liquidity provided by the account
4362
const useGetAccountPools = (): UseGetAccountProvidedLiquidity => {
4463
const accountId = useAccountId();
64+
const prices = useGetPrices();
4565

4666
const { data: liquidityPools, refetch: refetchLiquidityPools } = useGetLiquidityPools();
4767
const queryKey = ['account-pools', accountId];
4868
const { data, error, refetch: refetchQuery } = useQuery({
4969
queryKey: ['account-pools', accountId],
50-
queryFn: () => accountId && liquidityPools && getAccountLiqudityPools(accountId, liquidityPools),
70+
queryFn: () => accountId && liquidityPools && prices && getAccountLiqudityPools(accountId, liquidityPools, prices),
5171
enabled: !!liquidityPools,
5272
refetchInterval: BLOCKTIME_REFETCH_INTERVAL
5373
});

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2542,7 +2542,7 @@
25422542
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c"
25432543
integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==
25442544

2545-
"@interlay/bridge@^0.2.7":
2545+
"@interlay/bridge@0.2.7":
25462546
version "0.2.7"
25472547
resolved "https://registry.yarnpkg.com/@interlay/bridge/-/bridge-0.2.7.tgz#06b5e4bf531f5aad55e9258ee606b1dfb62e8b5a"
25482548
integrity sha512-kpdqBw+AFPx41nsnfEpBbfkQRbt+x1dyKq7zoEfm4a4vHQMgl15BK6UCvpO8LN4o6iRpIYP4xTOcfYytC7BzhQ==

0 commit comments

Comments
 (0)