Skip to content

Commit

Permalink
Merge pull request #1384 from madfish-solutions/v3.4.2
Browse files Browse the repository at this point in the history
V3.4.2
  • Loading branch information
Digberi authored Jan 5, 2024
2 parents 1d2e3db + 5b54caf commit 21fb5fc
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 88 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quipuswap-webapp-2",
"version": "3.4.1",
"version": "3.4.2",
"private": true,
"scripts": {
"pre-build": "node -v && npm -v && yarn -v && node ./scripts/build.js",
Expand All @@ -26,7 +26,7 @@
"@craco/craco": "^6.4.3",
"@percy/cli": "^1.7.2",
"@quipuswap/sdk": "^3.0.3",
"@quipuswap/tokens-whitelist": "^1.1.19",
"@quipuswap/tokens-whitelist": "^1.1.25",
"@sentry/react": "^7.11.1",
"@sentry/tracing": "^7.11.1",
"@taquito/beacon-wallet": "17.3.0",
Expand Down
6 changes: 4 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import { DAppProvider } from '@providers/use-dapp';
import { ExchangeRatesProvider, NewExchangeRatesProvider } from '@providers/use-new-exchange-rate';
import { sentryService } from '@shared/services';

import { App } from './app';
import { App } from './app'; //

import './overrides';

// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
require('dotenv').config(); //
require('dotenv').config();

const container = document.getElementById('root');

Expand Down
6 changes: 4 additions & 2 deletions src/modules/liquidity/api/blockchain/dex-two-liquidity.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import BigNumber from 'bignumber.js';

import { BucketContractStorage, DexTwoContractStorage } from '@modules/liquidity/types';
import { getContract, getStorageInfo } from '@shared/dapp';
import { defined } from '@shared/helpers';
import { defined, unpackOption } from '@shared/helpers';
import { Nullable } from '@shared/types';

// TODO: https://madfish.atlassian.net/browse/QUIPU-613
export class BlockchainDexTwoLiquidityApi {
static async getBucketContract(tezos: TezosToolkit, contractAddress: string, poolId: BigNumber) {
const storage = await getStorageInfo<DexTwoContractStorage>(tezos, contractAddress);

const { bucket: bucketAddress } = defined(await storage.storage.pairs.get(poolId));
const pair = await storage.storage.pairs.get(poolId);

const bucketAddress = unpackOption(defined(pair).bucket);

if (bucketAddress) {
return await getContract(tezos, bucketAddress);
Expand Down
8 changes: 4 additions & 4 deletions src/modules/liquidity/pages/cpmm-item/cpmm-page-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { PageNotFoundPage } from '@modules/errors';
import { LoaderFallback, StateWrapper } from '@shared/components';
import { SentryRoutes } from '@shared/services';

import { CpmmDexTwoClaimRewards } from './cpmm-dex-two-claim-rewards';
// import { CpmmDexTwoClaimRewards } from './cpmm-dex-two-claim-rewards';
import { DexTwoAddLiq } from './dex-two-add-liq';
import { DexTwoRemoveLiq } from './dex-two-remove-liq';
import { useCpmmViewModel } from './use-dex-two-item-page.vm';
import { LiquidityTabs } from '../../liquidity-routes.enum';
import { LiquidityCreatePage } from '../create';

export const CpmmPageRouter: FC = observer(() => {
const { isInitialized, title } = useCpmmViewModel();
const { isInitialized } = useCpmmViewModel();

return (
<StateWrapper isLoading={!isInitialized} loaderFallback={<LoaderFallback />}>
Expand All @@ -25,8 +25,8 @@ export const CpmmPageRouter: FC = observer(() => {
<Route path={`${LiquidityTabs.add}/:pairSlug`} element={<DexTwoAddLiq />} />
<Route path={`${LiquidityTabs.remove}/${NOT_FOUND_ROUTE_NAME}`} element={<PageNotFoundPage />} />
<Route path={`${LiquidityTabs.remove}/:pairSlug`} element={<DexTwoRemoveLiq />} />
<Route path={`${LiquidityTabs.claim}/${NOT_FOUND_ROUTE_NAME}`} element={<PageNotFoundPage />} />
<Route path={`${LiquidityTabs.claim}/:pairSlug`} element={<CpmmDexTwoClaimRewards title={title} />} />
{/* <Route path={`${LiquidityTabs.claim}/${NOT_FOUND_ROUTE_NAME}`} element={<PageNotFoundPage />} />
<Route path={`${LiquidityTabs.claim}/:pairSlug`} element={<CpmmDexTwoClaimRewards title={title} />} /> */}
<Route path={`${LiquidityTabs.create}`} element={<LiquidityCreatePage />} />
<Route path="*" element={<PageNotFoundPage />} />
</SentryRoutes>
Expand Down
53 changes: 0 additions & 53 deletions src/modules/liquidity/pages/liquidity/hooks/helpers/find-dex.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { FoundDex, Token as QuipuswapSdkToken } from '@quipuswap/sdk';
import { FoundDex, Token as QuipuswapSdkToken, findDex } from '@quipuswap/sdk';
import { TezosToolkit } from '@taquito/taquito';

import { FACTORIES } from '@config/config';
import { Nullable, SupportedNetworks, Token } from '@shared/types';

import { findDex } from './find-dex';
import { findNotTezToken } from '../../liquidity-cards/helpers';

export const loadTezDex = async ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { FC, useContext } from 'react';

import cx from 'classnames';
import { useLocation } from 'react-router-dom';
import { useLocation, useParams } from 'react-router-dom';

import { IS_NETWORK_MAINNET } from '@config/config';
import { SLASH } from '@config/constants';
import { ColorModes, ColorThemeContext } from '@providers/color-theme-context';
import { Button, Card } from '@shared/components';
Expand All @@ -20,16 +21,51 @@ const modeClass = {
export const OpenNewPosition: FC = () => {
const { t } = useTranslation();
const { colorThemeMode } = useContext(ColorThemeContext);

const { pathname } = useLocation();
const sanitizedPathname = `/${getRouterParts(pathname).join(SLASH)}`;
const url = `${sanitizedPathname}${LiquidityRoutes.create}`;

const params = useParams();

const is83 = params?.id === '83' && IS_NETWORK_MAINNET;

return (
<Card contentClassName={styles.content} className={cx(modeClass[colorThemeMode], styles.root)}>
<p className={styles.text}>{t('liquidity|induceToOpenNewPosition')}</p>
<Button className={styles.button} href={url}>
{t('liquidity|createPosition')}
</Button>
<Card
style={{
minHeight: is83 ? '88px' : 'auto'
}}
contentClassName={styles.content}
className={cx(modeClass[colorThemeMode], styles.root)}
>
{is83 ? (
<div
style={{
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
minHeight: '88px',
background: '#000',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: '1.5rem',
color: 'rgba(255, 255, 0, 0.8)',
paddingLeft: 8
}}
>
<p>The deposits to the pool are paused.</p>
</div>
) : (
<>
<p className={styles.text}>{t('liquidity|induceToOpenNewPosition')}</p>
<Button disabled className={styles.button} href={url}>
{t('liquidity|createPosition')}
</Button>
</>
)}
</Card>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,34 @@ import { OpenNewPositionForm, PageTitleContainer, PoolDetailsCreate, PositionFor
import { useCreateNewPositionPageViewModel } from './use-create-new-position-page.vm';

export const CreateNewPositionPage = observer(() => {
const { titleText, backHref, ...formProps } = useCreateNewPositionPageViewModel();
const { titleText, backHref, isBlocked, ...formProps } = useCreateNewPositionPageViewModel();

return (
<>
<TestnetAlert />
<PageTitleContainer dataTestId="v3LiqCreatePosition" titleText={titleText} />
<StickyBlock>
<PositionFormCard backHref={backHref}>
<OpenNewPositionForm {...formProps} />
{isBlocked ? (
<div
style={{
width: '100%',
height: '100%',
minHeight: '88px',
background: '#000',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: '1.5rem',
color: 'rgba(255, 255, 0, 0.8)',
paddingLeft: 8
}}
>
<p>The deposits to the pool are paused.</p>
</div>
) : (
<OpenNewPositionForm {...formProps} />
)}
</PositionFormCard>
<PoolDetailsCreate />
</StickyBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useMemo } from 'react';

import BigNumber from 'bignumber.js';

import { IS_NETWORK_MAINNET } from '@config/config';
import { ZERO_AMOUNT_BN } from '@config/constants';
import {
useGetLiquidityV3ItemWithPositions,
Expand Down Expand Up @@ -109,6 +110,7 @@ export const useCreateNewPositionPageViewModel = () => {
rangeInputsProps,
titleText: t('liquidity|createPosition'),
backHref,
warningMessages
warningMessages,
isBlocked: poolStore.poolId?.toFixed() === '83' && IS_NETWORK_MAINNET
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect } from 'react';

import { useParams } from 'react-router-dom';

import { IS_NETWORK_MAINNET } from '@config/config';
import {
useLiquidityV3PoolStore,
useLiquidityV3ItemTokens,
Expand Down Expand Up @@ -35,5 +36,5 @@ export const useV3ItemPageViewModel = () => {
void v3PositionsStore.positionsStore.load();
}, [getLiquidityV3ItemBalances, getLiquidityV3Pool, v3PositionsStore.positionsStore, poolId, tabId]);

return { isLoading, error, isAddLiqForm, tabId };
return { isLoading, error, isAddLiqForm, tabId, isBlocked: poolId?.toFixed() === '83' && IS_NETWORK_MAINNET };
};
27 changes: 25 additions & 2 deletions src/modules/liquidity/pages/v3-item-page/v3-item-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import styles from './v3-item-page.module.scss';

export const V3ItemPage: FC = observer(() => {
const { t } = useTranslation();
const { isLoading, isAddLiqForm, tabId } = useV3ItemPageViewModel();
const { isLoading, isAddLiqForm, tabId, isBlocked } = useV3ItemPageViewModel();

return (
<>
Expand All @@ -28,7 +28,30 @@ export const V3ItemPage: FC = observer(() => {
</StateWrapper>
<StickyBlock>
<LiquidityV3FormTabsCard tabActiveId={tabId}>
{isAddLiqForm ? <V3AddLiqForm /> : <V3RemoveLiqForm />}
{isAddLiqForm ? (
isBlocked ? (
<div
style={{
width: '100%',
height: '100%',
minHeight: '88px',
background: '#000',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: '1.5rem',
color: 'rgba(255, 255, 0, 0.8)',
paddingLeft: 8
}}
>
<p>The deposits to the pool are paused.</p>
</div>
) : (
<V3AddLiqForm />
)
) : (
<V3RemoveLiqForm />
)}
</LiquidityV3FormTabsCard>
<PositionDetails />
</StickyBlock>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/liquidity/types/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigMap, BlockInfoWrap, nat, Nullable } from '@shared/types';
import { BigMap, BlockInfoWrap, nat, Option } from '@shared/types';

export interface NewLiquidityStatsResponse extends IRawNewLiquidityStats, BlockInfoWrap {}

Expand All @@ -19,7 +19,7 @@ export interface DexTwoPair {
token_b_price_cml: nat;
total_supply: nat;
last_block_timestamp: Date | string;
bucket: Nullable<string>;
bucket: Option<string>;
}

export interface DexTwoContractStorage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js';

import { DEFAULT_STABLESWAP_POOL_ID, STABLESWAP_DIVIDENDS_ACCUM_PRECISION, ZERO_AMOUNT } from '@config/constants';
import { getStorageInfo } from '@shared/dapp/get-storage-info';
import { isExist, isNull, resolveOrNull, toArray } from '@shared/helpers';
import { isExist, isNull, toArray } from '@shared/helpers';
import { nat, Nullable } from '@shared/types';

import { earningsMapSchema, rewardMapSchema } from '../../../schemas/get-staker-info.schemas';
Expand Down Expand Up @@ -49,9 +49,8 @@ const getSinglePoolStakerInfo = async (
) => {
const { storage } = await getStorageInfo<StableswapStorage>(tezos, contractAddress);
const { pools, stakers_balance } = storage;
const _stakerAccum = await resolveOrNull(stakers_balance.get([accountPkh, poolId]));

const stakerAccum = _stakerAccum ?? {
const stakerAccum = (await stakers_balance.get([accountPkh, poolId])) ?? {
balance: new BigNumber(ZERO_AMOUNT),
earnings: new MichelsonMap<nat, EarningsValue>(earningsMapSchema)
};
Expand Down
24 changes: 24 additions & 0 deletions src/overrides.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable no-console */
import { HttpResponseError, STATUS_CODE } from '@taquito/http-utils';
import { BigMapAbstraction } from '@taquito/taquito';

import { BigMapKeyType } from '@shared/types';

const originalGet = BigMapAbstraction.prototype.get;

BigMapAbstraction.prototype.get = async function <T>(
keyToEncode: BigMapKeyType,
block?: number
): Promise<T | undefined> {
const promiseResponse = originalGet.call(this, keyToEncode, block) as Promise<T>;

try {
return await promiseResponse;
} catch (error) {
if (error instanceof HttpResponseError && error.status === STATUS_CODE.NOT_FOUND) {
return undefined;
}

throw error;
}
};
1 change: 1 addition & 0 deletions src/shared/helpers/blockchain/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './batch-operations';
export * from './get-blockchain-timestamp';
export * from './unpack-option';
5 changes: 5 additions & 0 deletions src/shared/helpers/blockchain/unpack-option.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Option } from '@shared/types';

export const unpackOption = <T>(option: Option<T>): T | null => {
return option?.Some ?? null;
};
Loading

1 comment on commit 21fb5fc

@vercel
Copy link

@vercel vercel bot commented on 21fb5fc Jan 5, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.