Commit a6d8613b authored by ianlapham's avatar ianlapham

updated position cards

parent 2ca3bf8d
...@@ -35,8 +35,16 @@ function PositionCard({ exchangeAddress, token0, token1, history, minimal = fals ...@@ -35,8 +35,16 @@ function PositionCard({ exchangeAddress, token0, token1, history, minimal = fals
const poolTokenPercentage = const poolTokenPercentage =
!!userPoolBalance && !!totalPoolTokens ? new Percent(userPoolBalance.raw, totalPoolTokens.raw) : undefined !!userPoolBalance && !!totalPoolTokens ? new Percent(userPoolBalance.raw, totalPoolTokens.raw) : undefined
const token0Deposited = poolTokenPercentage?.multiply(allBalances[exchangeAddress][token0.address]) const token0Deposited =
const token1Deposited = poolTokenPercentage?.multiply(allBalances[exchangeAddress][token1.address]) token0 &&
totalPoolTokens &&
userPoolBalance &&
exchange.getLiquidityValue(token0, totalPoolTokens, userPoolBalance, false)
const token1Deposited =
token1 &&
totalPoolTokens &&
userPoolBalance &&
exchange.getLiquidityValue(token1, totalPoolTokens, userPoolBalance, false)
function DynamicCard({ children, ...rest }) { function DynamicCard({ children, ...rest }) {
if (!minimal) { if (!minimal) {
......
...@@ -2,7 +2,7 @@ import React, { useReducer, useState, useCallback, useEffect } from 'react' ...@@ -2,7 +2,7 @@ import React, { useReducer, useState, useCallback, useEffect } from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { ethers } from 'ethers' import { ethers } from 'ethers'
import { parseUnits } from '@ethersproject/units' import { parseUnits } from '@ethersproject/units'
import { TokenAmount, JSBI, Route, WETH } from '@uniswap/sdk' import { TokenAmount, JSBI, Route, WETH, Percent } from '@uniswap/sdk'
import Slider from '../../components/Slider' import Slider from '../../components/Slider'
import DoubleLogo from '../../components/DoubleLogo' import DoubleLogo from '../../components/DoubleLogo'
...@@ -14,7 +14,7 @@ import { Text } from 'rebass' ...@@ -14,7 +14,7 @@ import { Text } from 'rebass'
import { LightCard } from '../../components/Card' import { LightCard } from '../../components/Card'
import { ChevronDown } from 'react-feather' import { ChevronDown } from 'react-feather'
import { ArrowDown, Plus } from 'react-feather' import { ArrowDown, Plus } from 'react-feather'
import Row, { RowBetween, RowFixed, RowFlat } from '../../components/Row' import { RowBetween, RowFixed } from '../../components/Row'
import { AutoColumn, ColumnCenter } from '../../components/Column' import { AutoColumn, ColumnCenter } from '../../components/Column'
import { ButtonPrimary, ButtonEmpty } from '../../components/Button' import { ButtonPrimary, ButtonEmpty } from '../../components/Button'
...@@ -227,7 +227,6 @@ export default function RemoveLiquidity({ token0, token1 }) { ...@@ -227,7 +227,6 @@ export default function RemoveLiquidity({ token0, token1 }) {
// parse the amounts based on input // parse the amounts based on input
const parsedAmounts: { [field: number]: TokenAmount } = {} const parsedAmounts: { [field: number]: TokenAmount } = {}
// try to parse typed value
if ( if (
independentField === Field.PERCENTAGE && independentField === Field.PERCENTAGE &&
userLiquidity && userLiquidity &&
...@@ -258,9 +257,8 @@ export default function RemoveLiquidity({ token0, token1 }) { ...@@ -258,9 +257,8 @@ export default function RemoveLiquidity({ token0, token1 }) {
if (typedValueParsed !== '0') { if (typedValueParsed !== '0') {
// first get the exact percentage of tokens deposited // first get the exact percentage of tokens deposited
const inputTokenAmount = new TokenAmount(tokens[Field.INPUT], typedValueParsed) const inputTokenAmount = new TokenAmount(tokens[Field.INPUT], typedValueParsed)
const ratio = JSBI.divide(inputTokenAmount.raw, TokensDeposited[Field.INPUT].raw) const ratio = new Percent(inputTokenAmount.raw, TokensDeposited[Field.INPUT].raw)
const partialLiquidity = ratio.multiply(userLiquidity)
const partialLiquidity = JSBI.multiply(userLiquidity.raw, ratio)
const liquidityTokenAmount = new TokenAmount(exchange.liquidityToken, partialLiquidity) const liquidityTokenAmount = new TokenAmount(exchange.liquidityToken, partialLiquidity)
parsedAmounts[Field.POOL] = liquidityTokenAmount parsedAmounts[Field.POOL] = liquidityTokenAmount
parsedAmounts[Field.OUTPUT] = exchange.getLiquidityValue( parsedAmounts[Field.OUTPUT] = exchange.getLiquidityValue(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment