Skip to content

Commit

Permalink
Fix unbonding flow (#856)
Browse files Browse the repository at this point in the history
* fix pool stats data reference

* testnet release 2.14.25

* fix unbonding flow

* testnet release 2.14.26
  • Loading branch information
pgoos authored Dec 14, 2023
1 parent 1e0d956 commit 1928444
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "2.14.24",
"version": "2.14.26",
"private": true,
"scripts": {
"bump": "bump patch --tag --commit 'testnet release '",
Expand Down
13 changes: 7 additions & 6 deletions app/src/domains/clp/queries/liquidityProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ export const useLiquidityProviderQuery = (
services.chains.get(Network.SIFCHAIN),
);

const liquidityProvider =
await sifchainClients.queryClient.clp.GetLiquidityProvider({
lpAddress: walletAddress,
symbol: externalAssetEntryQuery.data.value?.denom ?? "",
});
const liquidityProvider = externalAssetEntryQuery.data.value?.denom
? await sifchainClients.queryClient.clp.GetLiquidityProvider({
lpAddress: walletAddress,
symbol: externalAssetEntryQuery.data.value?.denom,
})
: null;

const currentHeight = await sifchainClients.signingClient.getHeight();

const lpWithAddedDetails =
liquidityProvider.liquidityProvider === undefined ||
liquidityProvider?.liquidityProvider === undefined ||
rewardsParamsQuery.data.value?.params === undefined
? undefined
: addDetailToLiquidityProvider(
Expand Down
10 changes: 5 additions & 5 deletions app/src/domains/clp/queries/unlockLiquidityByPercentage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ export const useUnlockLiquidityByPercentage = (
const tokenEntries = useTokenRegistryEntriesQuery();

return computed(() => {
if (!isNil(lpQuery.error.value) || !isNil(tokenEntries.error.value)) {
if (!isNil(lpQuery?.error.value) || !isNil(tokenEntries.error.value)) {
return { status: "rejected" as const };
}

if (lpQuery.isLoading.value || tokenEntries.isLoading.value) {
if (lpQuery?.isLoading.value || tokenEntries.isLoading.value) {
return { status: "pending" as const };
}

const externalAssetBalance = lpQuery.data.value?.externalAssetBalance;
const nativeAssetBalance = lpQuery.data.value?.nativeAssetBalance;
const lp = lpQuery.data.value?.liquidityProvider;
const externalAssetBalance = lpQuery?.data.value?.externalAssetBalance;
const nativeAssetBalance = lpQuery?.data.value?.nativeAssetBalance;
const lp = lpQuery?.data.value?.liquidityProvider;

const externalAssetFractionalDigits =
tokenEntries.data.value?.registry?.entries
Expand Down
15 changes: 8 additions & 7 deletions app/src/views/PoolPage/children/UnbondLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useCurrentRewardPeriodStatistics } from "~/domains/clp/queries/params";
import { useUnlockLiquidityByPercentage } from "~/domains/clp/queries/unlockLiquidityByPercentage";
import { useAppWalletPicker } from "~/hooks/useAppWalletPicker";
import { useAssetBySymbol } from "~/hooks/useAssetBySymbol";
import { usePoolStats } from "~/hooks/usePoolStats";
import { PoolStat, usePoolStats } from "~/hooks/usePoolStats";
import { useDeliverTxDetails } from "~/hooks/useTransactionDetails";
import { useWalletButton } from "~/hooks/useWalletButton";
import { accountStore } from "~/store/modules/accounts";
Expand Down Expand Up @@ -67,12 +67,13 @@ const UnbondLiquidity = defineComponent({
.toNumber(),
);

const externalAssetPriceUsd = computed(
() =>
poolStats.data.value?.poolData.pools.find(
(x) => x.symbol === externalAssetBaseDenom.value,
)?.priceToken,
);
const externalAssetPriceUsd = computed(() => {
const poolData = poolStats.data?.value?.poolData;
const pools = poolData?.pools as Record<string, PoolStat>;
return Object.values(pools).find(
(x) => x.symbol === externalAssetBaseDenom.value,
)?.priceToken;
});

const externalAssetWithdrawalUsd = computed(() => {
return Amount(withdrawData.withdrawExternalAssetAmount.value)
Expand Down

1 comment on commit 1928444

@vercel
Copy link

@vercel vercel bot commented on 1928444 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sifchain-ui – ./

dex.sifchain.finance
sifchain-ui-sifchain.vercel.app
sifchain-ui-git-master-sifchain.vercel.app

Please sign in to comment.