calculateBaseAssetValue = market value of closing entire position
Base Asset Value. : Precision QUOTE_PRECISION
Precision: MARK_PRICE_PRECISION (10^10)
In the case of a levered loss, the exchange first pays out undistributed fees and then the insurance fund. Thus the de facto size of the insurance fund is the amount in the insurance vault plus the sum of each markets undistributed fees.
Precision : QUOTE_ASSET_PRECISION
// TODO-PRECISION
calculatePositionPNL = BaseAssetAmount * (Avg Exit Price - Avg Entry Price)
(adds unrealized funding payment pnl to result)
BaseAssetAmount : Precision QUOTE_PRECISION
Helper function calculating constant product curve output. Agnostic to whether input asset is quote or base
newInputAssetReserve and newOutputAssetReserve after swap. : Precision AMM_RESERVE_PRECISION
calculateTargetPriceTrade simple function for finding arbitraging trades
optional default is 100% gap filling, can set smaller.
trade direction/size in order to push price to a targetPrice,
[ direction => direction of trade required, TODO-PRECISION tradeSize => size of trade required, TODO-PRECISION entryPrice => the entry price for the trade, TODO-PRECISION targetPrice => the target price TODO-PRECISION ]
Calculates acquired amounts for trade executed
| 'acquiredBase' => positive/negative change in user's base : BN TODO-PRECISION
| 'acquiredQuote' => positive/negative change in user's quote : BN TODO-PRECISION
Calculates avg/max slippage (price impact) for candidate trade
'pctAvgSlippage' => the percentage change to entryPrice (average est slippage in execution) : Precision MARK_PRICE_PRECISION
'pctMaxSlippage' => the percentage change to maxPrice (highest est slippage in execution) : Precision MARK_PRICE_PRECISION
'entryPrice' => the average price of the trade : Precision MARK_PRICE_PRECISION
'newPrice' => the price of the asset after the trade : Precision MARK_PRICE_PRECISION
Translate long/shorting quote/base asset into amm operation
Allows customization of the SDK's environment and endpoints. You can pass individual settings to override the settings with your own presets.
Defaults to master environment if you don't use this function.
Generated using TypeDoc
Helper function calculating adjust k cost