Skip to content

Commit

Permalink
Lm pool view fixes (#748)
Browse files Browse the repository at this point in the history
* add execution fee asset into settings

* remove unnecessary

* replace swap action form with operation form

* remove old deps

* fix ergo swap fees display

* fix warnings

* fix cardano swap info

* fix OperationSettings.tsx

* update ido notification

* update deps and fix params

* Spf modal (#739)

* add amplitude and firstlaunch / session start events

* update analytics

* add events

* update event

* update analytics

* add redeem close confirm / swap close confirm

* fix after review

* update ci

* update request modal

* add spf modal

* add spf modal all states

* add claim spf notification

* update names & add polling & add request

* some fixes

* fix spf modal

* update spf status view

* fix modal styles

* update filter fns

* spf modal fixes

* fix spf links

* remove claim button from mobile devices

* new spf button logic

* some fixes

* add polling to reward

* add polling disabling on last stage

* ClaimSpfButton.tsx

* update paddings

* spf design fixes

* fix spf screens

* fix notification z-index

* fix build analytics methods

* update urls and comment amplitude analytics

* update version

* remove ido notification

---------

Co-authored-by: deadit <stdeadit@gmail.com>

* update spf id

* fix nothing to claim state links

* add to variable to CurrencyConverter.ts

* enable cardano update screen

* update version

* Update links to pp and tos (#740)

* update links

* fix claim spf styles

---------

Co-authored-by: ridel1e <ridellee@gmail.com>

* update cardano sdk and remove and remove cardano update page

* fix CurrencyConverter.ts

* remove old files

* add new ergo execution

* fix swap info content

* update confirmations

* add swap validators

* update libs and rename pool actions

* fix warnings

* add walletSwap switch

* add swap operation

* fix cardano swap info

* fix cardano swap validators

* add remove liquidity fee switcher

* switch logger

* add spf fee remove liquidity

* fix warnings

* fix fees order

* remove old redeem validator fee

* add validators to cardano network

* add deposit validators

* add native deposit max button click

* fix warnings and add maxLiquidity spf button

* add deposit operation switcher

* fix streams

* add spf deposit operation

* add PoolInfoView

* add farms to positions

* add locked liquidity chart

* remove trash

* some pool overview update

* update positions request

* update some constants

* fix lock liquidity not enough data state

* update ergo-dex-sdk

* update price history styles and fix warnings

---------

Co-authored-by: deadit <stdeadit@gmail.com>
Co-authored-by: yb <43601702+yasha-black@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 27, 2023
1 parent a30997d commit cbe83e8
Show file tree
Hide file tree
Showing 37 changed files with 1,185 additions and 564 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"@babel/preset-env": "^7.15.6",
"@emurgo/cardano-serialization-lib-nodejs": "^11.0.5",
"@ergolabs/cardano-dex-sdk": "^0.0.70",
"@ergolabs/ergo-dex-sdk": "^1.9.52",
"@ergolabs/ergo-dex-sdk": "^1.9.54",
"@ergolabs/ergo-sdk": "^0.5.6",
"@ergolabs/ui-kit": "^2.4.21",
"@ergolabs/ui-kit": "^2.4.22",
"@rehooks/local-storage": "2.4.0",
"@sentry/react": "^6.16.1",
"@sentry/tracing": "^6.16.1",
Expand Down
2 changes: 1 addition & 1 deletion src/common/constants/erg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const MIN_NITRO = 1.2;
export const UI_FEE = 0;
export const UI_FEE_BIGINT = 0n;

export const NEW_MIN_BOX_VALUE = 250000n;
export const NEW_MIN_BOX_VALUE = 400000n;
22 changes: 19 additions & 3 deletions src/common/models/Position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Searchable } from '../utils/Searchable';
import { AmmPool } from './AmmPool';
import { AssetLock, AssetLockStatus } from './AssetLock';
import { Currency } from './Currency';
import { Farm } from './Farm';

export class Position implements Searchable {
static noop(ammPool: AmmPool): Position {
Expand All @@ -15,6 +16,7 @@ export class Position implements Searchable {
true,
[],
0,
[],
);
}

Expand Down Expand Up @@ -45,17 +47,17 @@ export class Position implements Searchable {

@cache
get totalX(): Currency {
return this.availableX.plus(this.lockedX);
return this.availableX.plus(this.lockedX).plus(this.stakedX);
}

@cache
get totalY(): Currency {
return this.availableY.plus(this.lockedY);
return this.availableY.plus(this.lockedY).plus(this.stakedY);
}

@cache
get totalLp(): Currency {
return this.availableLp.plus(this.lockedLp);
return this.availableLp.plus(this.lockedLp).plus(this.stakedLp);
}

match(term?: string): boolean {
Expand Down Expand Up @@ -85,12 +87,19 @@ export class Position implements Searchable {

readonly withdrawableLockedLp: Currency;

readonly stakedX: Currency;

readonly stakedY: Currency;

readonly stakedLp: Currency;

constructor(
public pool: AmmPool,
public availableLp: Currency,
public empty = false,
tokenLocks: TokenLock[],
networkHeight: number,
farms: Farm[],
) {
this.locks = tokenLocks.map((tl) => new AssetLock(this, tl, networkHeight));
const {
Expand Down Expand Up @@ -137,5 +146,12 @@ export class Position implements Searchable {
this.withdrawableLockedLp = withdrawableLockedLp;
this.withdrawableLockedY = withdrawableLockedY;
this.withdrawableLockedX = withdrawableLockedX;

this.stakedLp = farms.reduce<Currency>(
(sum, f) => sum.plus(f.yourStakeLq),
new Currency(0n, this.pool.lp.asset),
);
this.stakedX = this.pool.shares(this.stakedLp)[0];
this.stakedY = this.pool.shares(this.stakedLp)[1];
}
}
3 changes: 2 additions & 1 deletion src/components/AssetIcon/AssetIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ type TokenIconProps = React.DetailedHTMLProps<
HTMLDivElement
> & {
asset?: AssetInfo;
size?: 'medium' | 'large' | 'small' | 'extraSmall' | 'extraLarge';
size?: 'medium' | 'large' | 'small' | 'extraSmall' | 'extraLarge' | 'tiny';
inline?: boolean;
};

const MAP_SIZE_TO_NUMBER = {
tiny: 10,
extraSmall: 16,
small: 20,
medium: 24,
Expand Down
21 changes: 18 additions & 3 deletions src/components/AssetTitle/AssetTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ import { Truncate } from '../Truncate/Truncate';
export interface TokenTitleProps {
readonly asset: AssetInfo;
readonly size?: 'large' | 'small' | 'extraSmall';
readonly level?: 1 | 2 | 3 | 4 | 5 | 'body' | 'body-secondary' | undefined;
readonly level?:
| 1
| 2
| 3
| 4
| 5
| 'body'
| 'body-secondary'
| 'small-strong'
| undefined;
readonly gap?: number;
readonly limit?: number;
}
Expand All @@ -24,8 +33,14 @@ export const AssetTitle: FC<TokenTitleProps> = ({
<Flex.Item marginRight={gap}>
<AssetIcon size={size} asset={asset} />
</Flex.Item>
{level === 'body' || level === 'body-secondary' ? (
<Typography.Body secondary={level === 'body-secondary'}>
{level === 'body' ||
level === 'body-secondary' ||
level === 'small-strong' ? (
<Typography.Body
secondary={level === 'body-secondary'}
size={level === 'small-strong' ? 'small' : undefined}
strong={level === 'small-strong'}
>
<Truncate limit={limit}>{asset.ticker || asset.name}</Truncate>
</Typography.Body>
) : (
Expand Down
31 changes: 31 additions & 0 deletions src/components/InlineGrid/InlineGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Flex } from '@ergolabs/ui-kit';
import React, { FC, ReactNode } from 'react';

export interface InlineGridItemProps {
readonly title: ReactNode | ReactNode[] | string;
readonly value: ReactNode | ReactNode[] | string;
}

const InlineGridItem: FC<InlineGridItemProps> = ({ title, value }) => (
<Flex align="center">
<Flex.Item flex={1}>{title}</Flex.Item>
<Flex.Item>{value}</Flex.Item>
</Flex>
);

export interface InlineGridProps {
readonly gap?: number;
readonly children?: ReactNode | ReactNode[] | string;
}

export const InlineGrid: FC<InlineGridProps> & {
Item: FC<InlineGridItemProps>;
} = ({ gap, children }) => {
return (
<Flex col gap={gap}>
{children}
</Flex>
);
};

InlineGrid.Item = InlineGridItem;
18 changes: 12 additions & 6 deletions src/components/Page/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Flex, Typography } from '@ergolabs/ui-kit';
import { ButtonProps, Flex, Typography } from '@ergolabs/ui-kit';
import React, { ReactNode } from 'react';

import { Position } from '../../../common/models/Position';
Expand All @@ -11,33 +11,39 @@ interface FormHeaderProps {
actionsMenu?: ReactNode | ReactNode[] | undefined;
actionsMenuWidth?: number;
children?: ReactNode | ReactNode[] | undefined;
actionButtonSize?: ButtonProps['size'];
level?: 4 | 3;
}

const PageHeader: React.FC<FormHeaderProps> = ({
position,
actionsMenu,
actionsMenuWidth,
children,
level,
actionButtonSize,
}) => {
return (
<Flex justify="space-between" align="center">
<Flex align="center">
<Flex.Item display="flex" align="center" marginRight={2} flex={1}>
<Flex.Item display="flex" marginRight={2}>
<AssetIconPair
assetX={position.availableX.asset}
assetY={position.availableY.asset}
/>
</Flex.Item>
<Flex.Item marginRight={2}>
<Typography.Title level={4}>
<Typography.Title level={level || 4}>
<Truncate>{position.availableX.asset.ticker}</Truncate> /{' '}
<Truncate>{position.availableY.asset.ticker}</Truncate>
</Typography.Title>
</Flex.Item>
{children}
</Flex>
<Flex.Item flex={1}>{children}</Flex.Item>
</Flex.Item>
{actionsMenu && (
<OptionsButton width={actionsMenuWidth}>{actionsMenu}</OptionsButton>
<OptionsButton size={actionButtonSize} width={actionsMenuWidth}>
{actionsMenu}
</OptionsButton>
)}
</Flex>
);
Expand Down
16 changes: 13 additions & 3 deletions src/components/Page/PageSection/PageSection.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
import { Flex, Typography } from '@ergolabs/ui-kit';
import React from 'react';
import React, { ReactNode } from 'react';

import { FormSpace } from '../../common/FormView/FormSpace/FormSpace';

interface FormSectionProps {
title: string;
children: React.ReactChild | React.ReactChild[];
subtitle?: ReactNode | ReactNode[] | string;
noPadding?: boolean;
noBorder?: boolean;
boxed?: boolean;
glass?: boolean;
height?: number;
}

const PageSection: React.FC<FormSectionProps> = ({
children,
title,
subtitle,
noPadding,
noBorder,
boxed,
glass,
height,
}) => {
return (
<Flex direction="col">
<Flex.Item marginBottom={2}>
<Flex.Item marginBottom={subtitle ? 1 : 2}>
<Typography.Body strong>{title}</Typography.Body>
</Flex.Item>
{subtitle && <Flex.Item marginBottom={2}>{subtitle}</Flex.Item>}
{boxed || boxed === undefined ? (
<FormSpace noBorder={noBorder} glass={glass} noPadding={noPadding}>
<FormSpace
height={height}
noBorder={noBorder}
glass={glass}
noPadding={noPadding}
>
{children}
</FormSpace>
) : (
Expand Down
26 changes: 26 additions & 0 deletions src/components/TitledBox/TitledBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Box, BoxProps, Flex } from '@ergolabs/ui-kit';
import React, { FC, ReactNode } from 'react';

export interface TitledBoxProps extends BoxProps {
readonly title?: ReactNode | ReactNode[] | string;
readonly titleGap?: number;
readonly subtitle?: ReactNode | ReactNode[] | string;
readonly subtitleGap?: number;
}

export const TitledBox: FC<TitledBoxProps> = ({
titleGap,
title,
subtitleGap,
subtitle,
width,
...rest
}) => {
return (
<Flex col width={width}>
{title && <Flex.Item marginBottom={titleGap}>{title}</Flex.Item>}
{subtitle && <Flex.Item marginBottom={subtitleGap}>{subtitle}</Flex.Item>}
<Box width={width} {...rest} />
</Flex>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ChooseWalletModal } from './ChooseWalletModal/ChooseWalletModal';

export interface ConnectWalletButtonProps {
readonly size?: ButtonProps['size'];
readonly width?: ButtonProps['width'];
readonly className?: string;
readonly children?: ReactNode | ReactNode[] | string;
readonly analytics?: PAnalytics;
Expand All @@ -25,6 +26,7 @@ export const ConnectWalletButton: FC<ConnectWalletButtonProps> = ({
className,
children,
analytics,
width,
}) => {
const [isWalletConnected] = useObservable(isWalletSetuped$);

Expand All @@ -44,6 +46,7 @@ export const ConnectWalletButton: FC<ConnectWalletButtonProps> = ({
className={cn(className, 'connect-wallet-btn')}
isWalletConnected={isWalletConnected}
caption={<Trans>Connect wallet</Trans>}
width={width}
>
{children}
</SpectrumConnectWalletButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import { Truncate } from '../../../Truncate/Truncate';

interface PairSpaceProps {
readonly title: string;
readonly subtitle?: ReactNode | ReactNode[] | string;
readonly xAmount: Currency;
readonly yAmount: Currency;
readonly fees?: boolean;
readonly children?: ReactNode | ReactNode[];
readonly noBorder?: boolean;
readonly glass?: boolean;
readonly boxed?: boolean;
}

const TOKEN_NAME_SYMBOLS_LIMIT = 15;
Expand All @@ -27,9 +29,17 @@ const FormPairSection: React.FC<PairSpaceProps> = ({
children,
noBorder,
glass,
subtitle,
boxed,
}): JSX.Element => {
return (
<PageSection title={title} noBorder={noBorder} glass={glass}>
<PageSection
boxed={boxed}
title={title}
noBorder={noBorder}
glass={glass}
subtitle={subtitle}
>
<Flex direction="col">
<Flex.Item marginBottom={2}>
<Flex justify="space-between" align="center">
Expand Down
3 changes: 3 additions & 0 deletions src/components/common/FormView/FormSpace/FormSpace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ interface FormSpaceProps {
noPadding?: boolean;
noBorder?: boolean;
glass?: boolean;
height?: number;
}

const FormSpace: React.FC<FormSpaceProps> = ({
children,
noPadding,
noBorder,
glass,
height,
}): JSX.Element => {
return (
<Box
secondary
glass={glass}
padding={noPadding ? 0 : 4}
borderRadius="l"
height={height}
bordered={!noBorder}
>
{children}
Expand Down
1 change: 1 addition & 0 deletions src/network/cardano/api/positions/positions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const positions$ = zip([ammPools$, lpBalance$, networkContext$]).pipe(
false,
[],
networkContext.height,
[],
),
),
),
Expand Down
Loading

0 comments on commit cbe83e8

Please sign in to comment.