1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00

adding todos

This commit is contained in:
Matthias Kretschmann 2020-08-26 20:59:11 +02:00
parent bd88f40d4d
commit f54c461edf
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 24 additions and 7 deletions

View File

@ -43,6 +43,7 @@ export default function Add({
poolAddress, poolAddress,
amount amount
) )
// TODO: Figure out the result structure, thenreplace `any` return in lib-js
console.log(result) console.log(result)
} catch (error) { } catch (error) {
console.error(error.message) console.error(error.message)

View File

@ -31,6 +31,7 @@ export default function Remove({
amount, amount,
maximumPoolShares maximumPoolShares
) )
// TODO: Figure out the result structure, thenreplace `any` return in lib-js
console.log(result) console.log(result)
} catch (error) { } catch (error) {
console.error(error.message) console.error(error.message)

View File

@ -17,6 +17,12 @@ export interface Balance {
dt: string dt: string
} }
/*
TODO: figure out correct userBalance
TODO: create tooltip copy
TODO: figure out what to do with BPT
*/
export default function Pool({ ddo }: { ddo: DDO }): ReactElement { export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
const { ocean, accountId } = useOcean() const { ocean, accountId } = useOcean()
const { price, poolAddress } = useMetadata(ddo) const { price, poolAddress } = useMetadata(ddo)
@ -46,12 +52,18 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
setIsLoading(true) setIsLoading(true)
try { try {
//
// Get data token symbol
//
const dtSymbol = await ocean.datatokens.getSymbol( const dtSymbol = await ocean.datatokens.getSymbol(
ddo.dataToken, ddo.dataToken,
accountId accountId
) )
setDtSymbol(dtSymbol) setDtSymbol(dtSymbol)
//
// Get everything which is in the pool
//
const oceanReserve = await ocean.pool.getOceanReserve( const oceanReserve = await ocean.pool.getOceanReserve(
accountId, accountId,
poolAddress poolAddress
@ -62,20 +74,23 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
dt: dtReserve dt: dtReserve
}) })
const totalPoolTokens = await ocean.pool.totalSupply(poolAddress)
setTotalPoolTokens(totalPoolTokens)
//
// Get everything the user has put into the pool
//
const poolTokens = await ocean.pool.sharesBalance( const poolTokens = await ocean.pool.sharesBalance(
accountId, accountId,
poolAddress poolAddress
) )
setPoolTokens(poolTokens) setPoolTokens(poolTokens)
const totalPoolTokens = await ocean.pool.totalSupply(poolAddress) const userOceanBalance =
setTotalPoolTokens(totalPoolTokens) (Number(poolTokens) / Number(totalPoolTokens)) * Number(oceanReserve)
const userBalance = { const userBalance = {
ocean: `${ ocean: `${userOceanBalance}`,
(Number(poolTokens) / Number(totalPoolTokens)) *
Number(oceanReserve)
}`,
dt: '-' dt: '-'
} }
@ -122,7 +137,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
<div className={styles.poolTokens}> <div className={styles.poolTokens}>
<div className={styles.tokens}> <div className={styles.tokens}>
<h3 className={styles.title}> <h3 className={styles.title}>
Your Liquidity{' '} Your Liquidity
<Tooltip content="Explain what this represents, advantage of providing liquidity..." /> <Tooltip content="Explain what this represents, advantage of providing liquidity..." />
</h3> </h3>
<Token symbol="OCEAN" balance={userBalance.ocean} /> <Token symbol="OCEAN" balance={userBalance.ocean} />