@storm-trade/dex-math
v1.1.0-alpha.0
Published
Those methods are used to calculate different position and amm properties offchain based on current state.
Downloads
234
Readme
Storm Trade math SDK
Those methods are used to calculate different position and amm properties offchain based on current state.
Where to get values to plug in
AmmState
, AmmSettings
, FundingSettings
you can get in https://api5.storm.tg/api/markets or https://api5.storm.tg/api/markets/{address}Position
you can get in https://api5.storm.tg/api/positions/{wallet_address}/active
For full API reference see https://api5.storm.tg/api/api-docs
List of available methods
calculateFundingRate(settings: AmmSettings, amm: AmmState, fundingSettings: FundingSettings | null): BN
calculateQuoteAssetWeight(amm: AmmState, terminalPrice: BN): { quoteAssetWeight: BN }
getAdjustedAmmState(amm: AmmState, terminalPrice: BN): AmmState
getCloseFee(positionNotional: Numeric, feeRate: Numeric, realizedRatio = 1): BN
getEntryPrice(position: Position): BN
getFee(params: GetFeeParams): BN
getFundingPremium(position: Position, amm: AmmState): BN
getIndexPrice(amm: AmmState): BN
getLeverage(position: Position, settlementOraclePrice: Numeric = 1): BN
getLiquidationPrice(position: Position, amm: AmmState, settings: AmmSettings, settlementOraclePrice: Numeric = 1, params: GetPriceByMarginRatioParams = {}): BN
getMarginRatio(position: Position, amm: AmmState, settings: AmmSettings, settlementOraclePrice: Numeric = 1, params: GetMarginRatioParams = {}): BN
getMarketPrice(amm: AmmState): BN
getMaximumLeverage(settings: AmmSettings): number
getMinimumLeverage(settings: AmmSettings): number
getPriceByProfitRate(profitRate: number, position: Position, amm: AmmState, settings: AmmSettings, settlementOraclePrice: Numeric = 1, params: GetPriceByMarginRatioParams = {}): BN
getPriceImpact(before: Numeric, after: Numeric): BN
getPriceSpread(amm: AmmState): Numeric
getQuoteAssetWeight(amm: AmmState, terminalPrice: BN): BN
getQuoteAssetWeight(amm: AmmState, terminalPrice: BN): BN
getRemainMarginWithFundingPayment(position: Position, amm: AmmState, settings: AmmSettings, settlementOraclePrice: Numeric = 1, params: GetRemainMarginWithFundingPaymentParams = {}): RemainMarginOutput
getRolloverFee(position: Position, settings: AmmSettings, params: GetRolloverFeeParams = {}): BN
swapInput(amm: AmmState, quoteAssetIn: Numeric, decimals = DECIMAL_UNIT): SwapInputResult
swapOutput(amm: AmmState, baseAssetIn: Numeric, decimals = DECIMAL_UNIT): SwapOutputResult
All BN's are intergers with 9 decimal places