import { BigDecimal } from '@nadohq/utils'; import { HealthType } from './healthTypes.js'; import { ProductEngineType, SpotProduct, PerpProduct } from './productTypes.js'; type BalanceSide = 'long' | 'short'; type BalanceHealthContributions = Record; /** * Shared properties of a product balance */ interface BaseBalance { type: ProductEngineType; productId: number; amount: BigDecimal; healthContributions: BalanceHealthContributions; } /** * Balance for a perp product */ interface PerpBalance extends BaseBalance { type: ProductEngineType.PERP; /** * As there is no "quote" product for the perp engine, this is a representation of the net quote balance * associated with the position. The entry cost and funding is rolled into this. */ vQuoteBalance: BigDecimal; } type PerpBalanceWithProduct = PerpBalance & PerpProduct; /** * Balance for a spot product */ interface SpotBalance extends BaseBalance { type: ProductEngineType.SPOT; } type SpotBalanceWithProduct = SpotBalance & SpotProduct; type Balance = PerpBalance | SpotBalance; type BalanceWithProduct = SpotBalanceWithProduct | PerpBalanceWithProduct; export type { Balance, BalanceHealthContributions, BalanceSide, BalanceWithProduct, PerpBalance, PerpBalanceWithProduct, SpotBalance, SpotBalanceWithProduct };