1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

fail safe against empty creator liquidity, just read out weights

This commit is contained in:
Matthias Kretschmann 2022-01-14 17:25:20 +00:00
parent 8996722fcb
commit c6011d29ef
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -175,22 +175,23 @@ export default function Pool(): ReactElement {
setSwapFee(swapFee)
// Get weights
function getWeight(weight: string) {
return isValidNumber(weight)
? new Decimal(weight).mul(10).toString()
: '0'
}
const weightDt = dataLiquidity.pool.datatokenWeight
const weightDtDecimal = isValidNumber(weightDt)
? new Decimal(weightDt).mul(10).toString()
: '0'
const weightDtDecimal = getWeight(weightDt)
setWeightDt(weightDtDecimal)
const weightOceanDecimal = isValidNumber(weightDt)
? new Decimal(100).minus(new Decimal(weightDt).mul(10)).toString()
: '0'
const weightOcean = dataLiquidity.pool.baseTokenWeight
const weightOceanDecimal = getWeight(weightOcean)
setWeightOcean(weightOceanDecimal)
//
// Get everything the creator put into the pool
//
const creatorPoolTokens = dataLiquidity.pool.shares[0].shares
const creatorPoolTokens = dataLiquidity.pool.shares[0]?.shares
setCreatorPoolTokens(creatorPoolTokens)
const creatorOceanBalance =