1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-16 02:04:54 +01:00

pool token updates

This commit is contained in:
Matthias Kretschmann 2020-08-20 18:37:12 +02:00
parent 9e37127360
commit 2fd4b59adf
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 15 additions and 15 deletions

6
package-lock.json generated
View File

@ -3208,9 +3208,9 @@
"integrity": "sha512-z7ziNbRwsPrJi+zGyokgUEKivD90a5/9jjV+WLj1q5U96g60rd5rxox4EKNPNGlHx/m5rWBJhHBV4rseJjtFjg==" "integrity": "sha512-z7ziNbRwsPrJi+zGyokgUEKivD90a5/9jjV+WLj1q5U96g60rd5rxox4EKNPNGlHx/m5rWBJhHBV4rseJjtFjg=="
}, },
"@oceanprotocol/lib": { "@oceanprotocol/lib": {
"version": "0.1.14", "version": "0.1.15",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.14.tgz", "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.15.tgz",
"integrity": "sha512-a4vAa56SYcMc7muq/FUpc5Nki7NiEqCgnIOuXOBJ1YvdNYHTefL5Gy96zMGTjWF1Y+ppj9AT3s+QOfGiZVEukg==", "integrity": "sha512-56KOmHTWGt0E/ax+UNklqqtlLoPy06n6180hC59zGv0d0UGpGk7nvxFQtQ7a9moblpUh8rN5yFD/OCxNfx+dCg==",
"requires": { "requires": {
"@ethereum-navigator/navigator": "^0.5.0", "@ethereum-navigator/navigator": "^0.5.0",
"@oceanprotocol/contracts": "^0.3.4", "@oceanprotocol/contracts": "^0.3.4",

View File

@ -22,7 +22,7 @@
"@coingecko/cryptoformat": "^0.3.8", "@coingecko/cryptoformat": "^0.3.8",
"@loadable/component": "^5.13.1", "@loadable/component": "^5.13.1",
"@oceanprotocol/art": "^3.0.0", "@oceanprotocol/art": "^3.0.0",
"@oceanprotocol/lib": "^0.1.14", "@oceanprotocol/lib": "^0.1.15",
"@oceanprotocol/react": "^0.0.40", "@oceanprotocol/react": "^0.0.40",
"@oceanprotocol/typographies": "^0.1.0", "@oceanprotocol/typographies": "^0.1.0",
"@sindresorhus/slugify": "^1.0.0", "@sindresorhus/slugify": "^1.0.0",

View File

@ -22,6 +22,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
const { price, poolAddress } = useMetadata(ddo) const { price, poolAddress } = useMetadata(ddo)
const [poolTokens, setPoolTokens] = useState<string>() const [poolTokens, setPoolTokens] = useState<string>()
const [totalPoolTokens, setTotalPoolTokens] = useState<string>()
const [totalBalance, setTotalBalance] = useState<Balance>() const [totalBalance, setTotalBalance] = useState<Balance>()
const [dtSymbol, setDtSymbol] = useState<string>() const [dtSymbol, setDtSymbol] = useState<string>()
const [userBalance, setUserBalance] = useState<Balance>() const [userBalance, setUserBalance] = useState<Balance>()
@ -30,10 +31,14 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
const [showRemove, setShowRemove] = useState(false) const [showRemove, setShowRemove] = useState(false)
const [isLoading, setIsLoading] = useState(true) const [isLoading, setIsLoading] = useState(true)
// const isLoading = !ocean || !totalBalance || !userBalance || !price
const hasAddedLiquidity = const hasAddedLiquidity =
userBalance && (Number(userBalance.ocean) > 0 || Number(userBalance.dt) > 0) userBalance && (Number(userBalance.ocean) > 0 || Number(userBalance.dt) > 0)
const poolShare =
totalBalance &&
userBalance &&
((Number(totalPoolTokens) * Number(poolTokens)) / 100).toFixed(2)
useEffect(() => { useEffect(() => {
if (!ocean || !accountId || !poolAddress || !price) return if (!ocean || !accountId || !poolAddress || !price) return
@ -63,14 +68,13 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
) )
setPoolTokens(poolTokens) setPoolTokens(poolTokens)
// TODO: figure out how to get that const totalPoolTokens = await ocean.pool.totalSupply(poolAddress)
// const totalPoolTokens = await ocean.pool.totalSupply(poolAddress) setTotalPoolTokens(totalPoolTokens)
// console.log(totalPoolTokens)
// TODO: replace `dtReserve` with `totalPoolTokens`
const userBalance = { const userBalance = {
ocean: `${ ocean: `${
(Number(poolTokens) / Number(dtReserve)) * Number(oceanReserve) (Number(poolTokens) / Number(totalPoolTokens)) *
Number(oceanReserve)
}`, }`,
dt: '0' dt: '0'
} }
@ -85,11 +89,6 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
init() init()
}, [ocean, accountId, price, poolAddress]) }, [ocean, accountId, price, poolAddress])
const poolShare =
totalBalance &&
userBalance &&
((Number(totalBalance.dt) * Number(userBalance.dt)) / 100).toFixed(2)
return ( return (
<> <>
{isLoading && !userBalance ? ( {isLoading && !userBalance ? (
@ -135,6 +134,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
<h3 className={styles.title}>Total Pooled Tokens</h3> <h3 className={styles.title}>Total Pooled Tokens</h3>
<Token symbol="OCEAN" balance={totalBalance.ocean} /> <Token symbol="OCEAN" balance={totalBalance.ocean} />
<Token symbol={dtSymbol} balance={totalBalance.dt} /> <Token symbol={dtSymbol} balance={totalBalance.dt} />
<Token symbol="BPT" balance={totalPoolTokens} />
</div> </div>
</div> </div>