import BigNumber from "bignumber.js"
import { ethers } from "ethers"
async function getLPExposure(
// since one pool may has multi-perps, lp may has a group of positions
const result: Array<BigNumber> = []
const pool = await getLiquidityPool(reader, liquidityPool)
const shareToken = await getERC20Contract(pool.shareToken, reader.provider)
const lpBalance = new BigNumber((await shareToken.balanceOf(lp)).toString())
const totalLP = new BigNumber((await shareToken.totalSupply()).toString())
const shares = lpBalance.div(totalLP)
for (let i = 0; i < pool.perpetuals.size; i++) {
// read AMM positions, AMM is a trader with the address of liquidity pool
const account = await getAccountStorage(
const ammPosition = account.positionAmount
// lp shares the position
const lpPosition = ammPosition.times(shares)