src/risk/index.ts
v0.3.0 · 1.8 KB
// Public API of the risk module: fees, fill accounting, builder fee, margin,
// liquidation approximation, ROE-to-price math for stops and fee-tier arithmetic.
// Everything here is pure math except `readUserFees`, which reads through an
// InfoRequester.
export {
PERP_FEE_TIERS,
PERP_MM_REBATE,
MAX_STAKING_DISCOUNT,
MAX_STAKING_DISCOUNT_HYPE,
USER_FEES_WEIGHT,
bpsToRate,
rateToBps,
feeTierForVolume,
feeRatesForVolume,
parseUserFees,
parseFeeScheduleTiers,
readUserFees,
fillNotional,
fillFee,
roundTripFeeUsd,
backtestTradePnlUsd,
fundingPaymentUsd,
} from './fees.js';
export type {
Numeric,
PerpFeeTierId,
PerpFeeTier,
FeeRates,
TierFeeRates,
FeeDiscountOptions,
AccountFeeRates,
FeeFillInput,
BacktestTradeInput,
} from './fees.js';
export { summarizeFills, isLiquidationFill } from './fill-summary.js';
export type { SummaryFill, SummarizeFillsOptions, FillsSummary } from './fill-summary.js';
export {
PERP_BUILDER_FEE_CAP,
builderFeeToBps,
builderFeeToPercent,
builderFeeToRate,
builderFeeUsd,
builderFeeToMaxFeeRate,
parseMaxFeeRate,
resolveBuilderFee,
} from './builder-fee.js';
export type { ResolveBuilderFeeInput } from './builder-fee.js';
export {
sideSign,
sideOfSzi,
clampLeverage,
assetAllowsCross,
leverageUpdateParams,
leverageMatches,
roeFromPnl,
roe,
entryRoe,
maintenanceMarginFraction,
liquidationRoe,
liquidationPriceMove,
estimateLiquidationPrice,
stopLiquidationBuffer,
positionMargin,
grossLeverage,
marginRatio,
} from './margin.js';
export type {
PositionSide,
LeverageAssetMeta,
LiquidationPriceInput,
} from './margin.js';
export { roeToPrice, roeToTriggerPrice, tpslLegPrices, averageEntryPx } from './stops.js';
export type { RoeBasis, RoeToPriceInput, TpslLegInput, TpslLegPrices, AverageEntryInput } from './stops.js';