{"version":3,"file":"indexerBalanceValue.cjs","names":[],"sources":["../../src/utils/indexerBalanceValue.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { IndexerPerpBalance, IndexerSpotBalance } from '../types';\n\n/**\n * Most of these calculations take oraclePrice as a separate parameter. This allows us to not rely on the Snapshot\n * interfaces to give clients the optionality to pass either the pre or post balance\n */\n\n/**\n * Calculates the quote value of an indexer spot balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerSpotBalanceValue(\n  balance: IndexerSpotBalance,\n  oraclePrice: BigNumber,\n): BigNumber {\n  return balance.amount.multipliedBy(oraclePrice);\n}\n\n/**\n * Calculates the notional value of an indexer perp balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceNotionalValue(\n  balance: IndexerPerpBalance,\n  oraclePrice: BigNumber,\n): BigNumber {\n  return balance.amount.multipliedBy(oraclePrice).abs();\n}\n\n/**\n * Calculates the true quote value of a indexer perp balance, which is the same as its unrealized pnl / unsettled quote\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceValue(\n  balance: IndexerPerpBalance,\n  oraclePrice: BigNumber,\n): BigNumber {\n  return balance.amount.multipliedBy(oraclePrice).plus(balance.vQuoteBalance);\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,4BACd,SACA,aACW;CACX,OAAO,QAAQ,OAAO,aAAa,WAAW;AAChD;;;;;;;AAQA,SAAgB,oCACd,SACA,aACW;CACX,OAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,IAAI;AACtD;;;;;;;AAQA,SAAgB,4BACd,SACA,aACW;CACX,OAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,KAAK,QAAQ,aAAa;AAC5E"}