From 0af06792e6e157bc031c5491b52543f6515c68d7 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 20 Aug 2020 12:54:54 +0200 Subject: [PATCH] refactor --- .../AssetActions/Pool/Token.module.css | 6 ++++-- .../organisms/AssetActions/Pool/index.tsx | 20 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/organisms/AssetActions/Pool/Token.module.css b/src/components/organisms/AssetActions/Pool/Token.module.css index 54cd29e04..815e31164 100644 --- a/src/components/organisms/AssetActions/Pool/Token.module.css +++ b/src/components/organisms/AssetActions/Pool/Token.module.css @@ -1,6 +1,6 @@ .token { font-weight: var(--font-weight-bold); - margin-bottom: calc(var(--spacer) / 4); + margin-bottom: calc(var(--spacer) / 3); white-space: nowrap; } @@ -17,6 +17,7 @@ padding: 0.3rem; vertical-align: middle; margin-right: calc(var(--spacer) / 8); + margin-top: -0.3rem; } .icon svg { @@ -32,6 +33,7 @@ stroke-linejoin: round; } -.icon[class*='%'] { +.icon[class*='%'], +.icon[class*='BPT'] { opacity: 0; } diff --git a/src/components/organisms/AssetActions/Pool/index.tsx b/src/components/organisms/AssetActions/Pool/index.tsx index f0a652256..572e78508 100644 --- a/src/components/organisms/AssetActions/Pool/index.tsx +++ b/src/components/organisms/AssetActions/Pool/index.tsx @@ -10,7 +10,6 @@ import Add from './Add' import Remove from './Remove' import Tooltip from '../../../atoms/Tooltip' import Conversion from '../../../atoms/Price/Conversion' -import { ReactComponent as External } from '../../../../images/external.svg' import EtherscanLink from '../../../atoms/EtherscanLink' interface Balance { @@ -19,9 +18,10 @@ interface Balance { } export default function Pool({ ddo }: { ddo: DDO }): ReactElement { - const { ocean, accountId } = useOcean() + const { ocean, accountId, account } = useOcean() const { getBestPool } = useMetadata() const [poolAddress, setPoolAddress] = useState() + const [poolTokens, setPoolTokens] = useState() const [totalBalance, setTotalBalance] = useState() const [dtPrice, setDtPrice] = useState() const [dtSymbol, setDtSymbol] = useState() @@ -56,16 +56,25 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { dt: dtReserve }) - const sharesBalance = await ocean.pool.sharesBalance( + const poolTokens = await ocean.pool.sharesBalance( accountId, poolAddress ) + setPoolTokens(poolTokens) + // TODO: figure out how to get that + const totalPoolTokens = await ocean.accounts.getTokenBalance( + poolAddress, + account + ) + console.log(totalPoolTokens) + + // TODO: replace `dtReserve` with `totalPoolTokens` const userBalance = { ocean: `${ - (Number(sharesBalance) / Number(dtReserve)) * Number(oceanReserve) + (Number(poolTokens) / Number(dtReserve)) * Number(oceanReserve) }`, - dt: sharesBalance + dt: '0' } setUserBalance(userBalance) @@ -118,6 +127,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { +