Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show dash if no liquidity #10587

Merged
merged 3 commits into from
Feb 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 65 additions & 63 deletions packages/augur-simplified/src/modules/common/tables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ const PositionHeader = () => {
owned
</>
) : (
'quantity owned'
)}
'quantity owned'
)}
</li>
<li>
{isMobile ? (
Expand All @@ -103,28 +103,30 @@ const PositionHeader = () => {
price
</>
) : (
'avg. price paid'
)}
'avg. price paid'
)}
</li>
<li>init. value</li>
<li>cur.{isMobile ? <br /> : ' '}value</li>
<li>p/l {generateTooltip('Display values might be rounded, consider this in calculations.', 'pnltip-positionheader')}</li>
<li>p/l {generateTooltip('Display values might be rounded. Dashes are displayed when liquidity is depleted.', 'pnltip-positionheader')}</li>
</ul>
);
};

const PositionRow = ({ position }: { position: PositionBalance }) => (
const PositionRow = ({ position, hasLiquidity = true }: { position: PositionBalance, hasLiquidity: boolean }) => (
<ul className={Styles.PositionRow}>
<li>{position.outcomeName}</li>
<li>{formatSimpleShares(position.quantity).formattedValue}</li>
<li>{formatSimplePrice(position.avgPrice).formattedValue}</li>
<li>{formatDai(position.initCostUsd).full}</li>
<li>{formatDai(position.usdValue).full}</li>
<li>{hasLiquidity ? formatDai(position.usdValue).full : '-'}</li>
<li>
<MovementLabel
value={formatDai(position.totalChangeUsd)}
numberValue={parseFloat(position.totalChangeUsd)}
/>
{hasLiquidity ?
<MovementLabel
value={formatDai(position.totalChangeUsd)}
numberValue={parseFloat(position.totalChangeUsd)}
/>
: '-'}
</li>
</ul>
);
Expand Down Expand Up @@ -180,10 +182,9 @@ export const PositionFooter = ({
<>
<span>{`${formatPercent(settlementFee).full} fee charged on settlement`}</span>
<PrimaryButton
text={`Claim Winnings (${
formatCash(claimableWinnings?.claimableBalance, amm?.cash?.name)
text={`Claim Winnings (${formatCash(claimableWinnings?.claimableBalance, amm?.cash?.name)
.full
})`}
})`}
action={claim}
/>
</>
Expand All @@ -205,10 +206,10 @@ export const AllPositionTable = ({ page }) => {
} = useAppStatusStore();
const positions = marketShares
? ((Object.values(marketShares) as unknown[]) as {
ammExchange: AmmExchange;
positions: PositionBalance[];
claimableWinnings: Winnings;
}[])
ammExchange: AmmExchange;
positions: PositionBalance[];
claimableWinnings: Winnings;
}[])
: [];

const positionVis = sliceByPage(
Expand Down Expand Up @@ -246,6 +247,7 @@ export const PositionTable = ({
seenPositionWarnings && seenPositionWarnings[marketAmmId]?.add;
const seenMarketPositionWarningRemove =
seenPositionWarnings && seenPositionWarnings[marketAmmId]?.remove;
const hasLiquidity = ammExchange.liquidity !== "0";
return (
<>
<div className={Styles.PositionTable}>
Expand All @@ -258,7 +260,7 @@ export const PositionTable = ({
positions
.filter((p) => p.visible)
.map((position, id) => (
<PositionRow key={id} position={position} />
<PositionRow key={id} position={position} hasLiquidity={hasLiquidity} />
))}
<PositionFooter
showTradeButton={!singleMarket}
Expand All @@ -269,7 +271,7 @@ export const PositionTable = ({
{!seenMarketPositionWarningAdd &&
singleMarket &&
positions.filter((position) => position.positionFromLiquidity).length >
0 && (
0 && (
<WarningBanner
className={Styles.MarginTop}
title='Why do I have a position after adding liquidity?'
Expand Down Expand Up @@ -372,10 +374,10 @@ export const AllLiquidityTable = ({ page }) => {
const { ammExchanges } = processed;
const liquidities = lpTokens
? Object.keys(lpTokens).map((ammId) => ({
ammExchange: ammExchanges[ammId],
market: ammExchanges[ammId].market,
lpTokens: lpTokens[ammId],
}))
ammExchange: ammExchanges[ammId],
market: ammExchanges[ammId].market,
lpTokens: lpTokens[ammId],
}))
: [];
const liquiditiesViz = sliceByPage(
liquidities,
Expand Down Expand Up @@ -476,17 +478,17 @@ export const PositionsLiquidityViewSwitcher = ({

const positions = marketShares
? ((Object.values(marketShares) as unknown[]) as {
ammExchange: AmmExchange;
positions: PositionBalance[];
claimableWinnings: Winnings;
}[])
ammExchange: AmmExchange;
positions: PositionBalance[];
claimableWinnings: Winnings;
}[])
: [];
const liquidities = lpTokens
? Object.keys(lpTokens).map((ammId) => ({
ammExchange: ammExchanges[ammId],
market: ammExchanges[ammId].market,
lpTokens: lpTokens[ammId],
}))
ammExchange: ammExchanges[ammId],
market: ammExchanges[ammId].market,
lpTokens: lpTokens[ammId],
}))
: [];
return (
<div className={Styles.PositionsLiquidityViewSwitcher}>
Expand Down Expand Up @@ -602,41 +604,41 @@ const TransactionsHeader = ({
defaultValue={ALL}
/>
) : (
<>
<span
className={classNames({
[Styles.Selected]: selectedType === ALL,
})}
onClick={() => setSelectedType(ALL)}
>
all
<>
<span
className={classNames({
[Styles.Selected]: selectedType === ALL,
})}
onClick={() => setSelectedType(ALL)}
>
all
</span>
<span
className={classNames({
[Styles.Selected]: selectedType === SWAP,
})}
onClick={() => setSelectedType(SWAP)}
>
swaps
<span
className={classNames({
[Styles.Selected]: selectedType === SWAP,
})}
onClick={() => setSelectedType(SWAP)}
>
swaps
</span>
<span
className={classNames({
[Styles.Selected]: selectedType === ADD,
})}
onClick={() => setSelectedType(ADD)}
>
adds
<span
className={classNames({
[Styles.Selected]: selectedType === ADD,
})}
onClick={() => setSelectedType(ADD)}
>
adds
</span>
<span
className={classNames({
[Styles.Selected]: selectedType === REMOVE,
})}
onClick={() => setSelectedType(REMOVE)}
>
removes
<span
className={classNames({
[Styles.Selected]: selectedType === REMOVE,
})}
onClick={() => setSelectedType(REMOVE)}
>
removes
</span>
</>
)}
</>
)}
</li>
<li>total value</li>
<li>token amount</li>
Expand Down