fix getCpmmLiquidityPoolWeights
This commit is contained in:
parent
d063e209dd
commit
fc06b03af8
|
@ -1,4 +1,4 @@
|
|||
import { sum, groupBy, mapValues, sumBy } from 'lodash'
|
||||
import { sum, groupBy, mapValues, sumBy, zip } from 'lodash'
|
||||
|
||||
import { CPMMContract } from './contract'
|
||||
import { CREATOR_FEE, Fees, LIQUIDITY_FEE, PLATFORM_FEE } from './fees'
|
||||
|
@ -275,16 +275,16 @@ export function getCpmmLiquidityPoolWeights(
|
|||
const liquidityShares = liquidities.map(calcLiqudity)
|
||||
const shareSum = sum(liquidityShares)
|
||||
|
||||
const includedLiquidities = excludeAntes
|
||||
? liquidityShares.filter((_, i) => !liquidities[i].isAnte)
|
||||
: liquidityShares
|
||||
|
||||
const weights = includedLiquidities.map((s, i) => ({
|
||||
weight: s / shareSum,
|
||||
const weights = liquidityShares.map((shares, i) => ({
|
||||
weight: shares / shareSum,
|
||||
providerId: liquidities[i].userId,
|
||||
}))
|
||||
|
||||
const userWeights = groupBy(weights, (w) => w.providerId)
|
||||
const includedWeights = excludeAntes
|
||||
? weights.filter((_, i) => !liquidities[i].isAnte)
|
||||
: weights
|
||||
|
||||
const userWeights = groupBy(includedWeights, (w) => w.providerId)
|
||||
const totalUserWeights = mapValues(userWeights, (userWeight) =>
|
||||
sumBy(userWeight, (w) => w.weight)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user