@lifi/perps-sdk-provider-lighter 35.1.0 → 36.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/LighterProvider.d.ts.map +1 -1
- package/dist/cjs/LighterProvider.js +101 -58
- package/dist/cjs/LighterProvider.js.map +1 -1
- package/dist/cjs/accountSummary.d.ts +1 -2
- package/dist/cjs/accountSummary.d.ts.map +1 -1
- package/dist/cjs/accountSummary.js +9 -16
- package/dist/cjs/accountSummary.js.map +1 -1
- package/dist/cjs/availableToTrade.d.ts +1 -2
- package/dist/cjs/availableToTrade.d.ts.map +1 -1
- package/dist/cjs/availableToTrade.js +8 -12
- package/dist/cjs/availableToTrade.js.map +1 -1
- package/dist/cjs/signers/LighterSigner.d.ts.map +1 -1
- package/dist/cjs/signers/LighterSigner.js +2 -6
- package/dist/cjs/signers/LighterSigner.js.map +1 -1
- package/dist/cjs/types/submit.d.ts +5 -0
- package/dist/cjs/types/submit.d.ts.map +1 -1
- package/dist/cjs/utils/index.d.ts +3 -3
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +5 -6
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/mapFill.d.ts +1 -1
- package/dist/cjs/utils/mapFill.d.ts.map +1 -1
- package/dist/cjs/utils/mapFill.js +44 -31
- package/dist/cjs/utils/mapFill.js.map +1 -1
- package/dist/cjs/utils/mapOpenPositions.d.ts +3 -1
- package/dist/cjs/utils/mapOpenPositions.d.ts.map +1 -1
- package/dist/cjs/utils/mapOpenPositions.js +20 -4
- package/dist/cjs/utils/mapOpenPositions.js.map +1 -1
- package/dist/cjs/utils/mapOrder.d.ts +1 -1
- package/dist/cjs/utils/mapOrder.d.ts.map +1 -1
- package/dist/cjs/utils/mapOrder.js +64 -26
- package/dist/cjs/utils/mapOrder.js.map +1 -1
- package/dist/cjs/utils/mapPortfolioHistory.d.ts +1 -2
- package/dist/cjs/utils/mapPortfolioHistory.d.ts.map +1 -1
- package/dist/cjs/utils/mapPortfolioHistory.js +29 -21
- package/dist/cjs/utils/mapPortfolioHistory.js.map +1 -1
- package/dist/cjs/utils/mapPosition.d.ts +3 -3
- package/dist/cjs/utils/mapPosition.d.ts.map +1 -1
- package/dist/cjs/utils/mapPosition.js +35 -38
- package/dist/cjs/utils/mapPosition.js.map +1 -1
- package/dist/cjs/utils/rowTimestamp.d.ts +2 -0
- package/dist/cjs/utils/rowTimestamp.d.ts.map +1 -0
- package/dist/cjs/utils/rowTimestamp.js +14 -0
- package/dist/cjs/utils/rowTimestamp.js.map +1 -0
- package/dist/cjs/utils/settlementPool.d.ts +2 -3
- package/dist/cjs/utils/settlementPool.d.ts.map +1 -1
- package/dist/cjs/utils/settlementPool.js +8 -7
- package/dist/cjs/utils/settlementPool.js.map +1 -1
- package/dist/cjs/utils/spotPrice.d.ts +3 -4
- package/dist/cjs/utils/spotPrice.d.ts.map +1 -1
- package/dist/cjs/utils/spotPrice.js +6 -11
- package/dist/cjs/utils/spotPrice.js.map +1 -1
- package/dist/cjs/utils/time.d.ts.map +1 -1
- package/dist/cjs/utils/time.js +3 -2
- package/dist/cjs/utils/time.js.map +1 -1
- package/dist/cjs/utils/transferMargin.d.ts.map +1 -1
- package/dist/cjs/utils/transferMargin.js +8 -11
- package/dist/cjs/utils/transferMargin.js.map +1 -1
- package/dist/cjs/utils/withdrawableBalances.d.ts +1 -1
- package/dist/cjs/utils/withdrawableBalances.d.ts.map +1 -1
- package/dist/cjs/utils/withdrawableBalances.js +12 -17
- package/dist/cjs/utils/withdrawableBalances.js.map +1 -1
- package/dist/cjs/utils/withdrawalTypes.d.ts +17 -0
- package/dist/cjs/utils/withdrawalTypes.d.ts.map +1 -0
- package/dist/cjs/utils/withdrawalTypes.js +58 -0
- package/dist/cjs/utils/withdrawalTypes.js.map +1 -0
- package/dist/cjs/websocket/LighterWsProvider.d.ts.map +1 -1
- package/dist/cjs/websocket/LighterWsProvider.js +46 -58
- package/dist/cjs/websocket/LighterWsProvider.js.map +1 -1
- package/dist/cjs/websocket/orderBookSide.d.ts +19 -0
- package/dist/cjs/websocket/orderBookSide.d.ts.map +1 -0
- package/dist/cjs/websocket/orderBookSide.js +71 -0
- package/dist/cjs/websocket/orderBookSide.js.map +1 -0
- package/dist/esm/LighterProvider.d.ts.map +1 -1
- package/dist/esm/LighterProvider.js +116 -62
- package/dist/esm/LighterProvider.js.map +1 -1
- package/dist/esm/accountSummary.d.ts +1 -2
- package/dist/esm/accountSummary.d.ts.map +1 -1
- package/dist/esm/accountSummary.js +10 -14
- package/dist/esm/accountSummary.js.map +1 -1
- package/dist/esm/availableToTrade.d.ts +1 -2
- package/dist/esm/availableToTrade.d.ts.map +1 -1
- package/dist/esm/availableToTrade.js +9 -10
- package/dist/esm/availableToTrade.js.map +1 -1
- package/dist/esm/signers/LighterSigner.d.ts.map +1 -1
- package/dist/esm/signers/LighterSigner.js +3 -4
- package/dist/esm/signers/LighterSigner.js.map +1 -1
- package/dist/esm/types/submit.d.ts +14 -0
- package/dist/esm/types/submit.d.ts.map +1 -1
- package/dist/esm/utils/index.d.ts +3 -3
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +2 -3
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/mapFill.d.ts +1 -1
- package/dist/esm/utils/mapFill.d.ts.map +1 -1
- package/dist/esm/utils/mapFill.js +51 -35
- package/dist/esm/utils/mapFill.js.map +1 -1
- package/dist/esm/utils/mapOpenPositions.d.ts +17 -3
- package/dist/esm/utils/mapOpenPositions.d.ts.map +1 -1
- package/dist/esm/utils/mapOpenPositions.js +31 -5
- package/dist/esm/utils/mapOpenPositions.js.map +1 -1
- package/dist/esm/utils/mapOrder.d.ts +6 -2
- package/dist/esm/utils/mapOrder.d.ts.map +1 -1
- package/dist/esm/utils/mapOrder.js +70 -25
- package/dist/esm/utils/mapOrder.js.map +1 -1
- package/dist/esm/utils/mapPortfolioHistory.d.ts +6 -3
- package/dist/esm/utils/mapPortfolioHistory.d.ts.map +1 -1
- package/dist/esm/utils/mapPortfolioHistory.js +34 -19
- package/dist/esm/utils/mapPortfolioHistory.js.map +1 -1
- package/dist/esm/utils/mapPosition.d.ts +12 -9
- package/dist/esm/utils/mapPosition.d.ts.map +1 -1
- package/dist/esm/utils/mapPosition.js +45 -42
- package/dist/esm/utils/mapPosition.js.map +1 -1
- package/dist/esm/utils/rowTimestamp.d.ts +6 -0
- package/dist/esm/utils/rowTimestamp.d.ts.map +1 -0
- package/dist/esm/utils/rowTimestamp.js +14 -0
- package/dist/esm/utils/rowTimestamp.js.map +1 -0
- package/dist/esm/utils/settlementPool.d.ts +2 -3
- package/dist/esm/utils/settlementPool.d.ts.map +1 -1
- package/dist/esm/utils/settlementPool.js +8 -7
- package/dist/esm/utils/settlementPool.js.map +1 -1
- package/dist/esm/utils/spotPrice.d.ts +3 -4
- package/dist/esm/utils/spotPrice.d.ts.map +1 -1
- package/dist/esm/utils/spotPrice.js +6 -8
- package/dist/esm/utils/spotPrice.js.map +1 -1
- package/dist/esm/utils/time.d.ts +10 -2
- package/dist/esm/utils/time.d.ts.map +1 -1
- package/dist/esm/utils/time.js +13 -4
- package/dist/esm/utils/time.js.map +1 -1
- package/dist/esm/utils/transferMargin.d.ts.map +1 -1
- package/dist/esm/utils/transferMargin.js +9 -9
- package/dist/esm/utils/transferMargin.js.map +1 -1
- package/dist/esm/utils/withdrawableBalances.d.ts +5 -3
- package/dist/esm/utils/withdrawableBalances.d.ts.map +1 -1
- package/dist/esm/utils/withdrawableBalances.js +17 -17
- package/dist/esm/utils/withdrawableBalances.js.map +1 -1
- package/dist/esm/utils/withdrawalTypes.d.ts +45 -0
- package/dist/esm/utils/withdrawalTypes.d.ts.map +1 -0
- package/dist/esm/utils/withdrawalTypes.js +68 -0
- package/dist/esm/utils/withdrawalTypes.js.map +1 -0
- package/dist/esm/websocket/LighterWsProvider.d.ts.map +1 -1
- package/dist/esm/websocket/LighterWsProvider.js +48 -57
- package/dist/esm/websocket/LighterWsProvider.js.map +1 -1
- package/dist/esm/websocket/orderBookSide.d.ts +33 -0
- package/dist/esm/websocket/orderBookSide.d.ts.map +1 -0
- package/dist/esm/websocket/orderBookSide.js +76 -0
- package/dist/esm/websocket/orderBookSide.js.map +1 -0
- package/dist/types/LighterProvider.d.ts.map +1 -1
- package/dist/types/accountSummary.d.ts +1 -2
- package/dist/types/accountSummary.d.ts.map +1 -1
- package/dist/types/availableToTrade.d.ts +1 -2
- package/dist/types/availableToTrade.d.ts.map +1 -1
- package/dist/types/signers/LighterSigner.d.ts.map +1 -1
- package/dist/types/types/submit.d.ts +14 -0
- package/dist/types/types/submit.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +3 -3
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/mapFill.d.ts +1 -1
- package/dist/types/utils/mapFill.d.ts.map +1 -1
- package/dist/types/utils/mapOpenPositions.d.ts +17 -3
- package/dist/types/utils/mapOpenPositions.d.ts.map +1 -1
- package/dist/types/utils/mapOrder.d.ts +6 -2
- package/dist/types/utils/mapOrder.d.ts.map +1 -1
- package/dist/types/utils/mapPortfolioHistory.d.ts +6 -3
- package/dist/types/utils/mapPortfolioHistory.d.ts.map +1 -1
- package/dist/types/utils/mapPosition.d.ts +12 -9
- package/dist/types/utils/mapPosition.d.ts.map +1 -1
- package/dist/types/utils/rowTimestamp.d.ts +6 -0
- package/dist/types/utils/rowTimestamp.d.ts.map +1 -0
- package/dist/types/utils/settlementPool.d.ts +2 -3
- package/dist/types/utils/settlementPool.d.ts.map +1 -1
- package/dist/types/utils/spotPrice.d.ts +3 -4
- package/dist/types/utils/spotPrice.d.ts.map +1 -1
- package/dist/types/utils/time.d.ts +10 -2
- package/dist/types/utils/time.d.ts.map +1 -1
- package/dist/types/utils/transferMargin.d.ts.map +1 -1
- package/dist/types/utils/withdrawableBalances.d.ts +5 -3
- package/dist/types/utils/withdrawableBalances.d.ts.map +1 -1
- package/dist/types/utils/withdrawalTypes.d.ts +45 -0
- package/dist/types/utils/withdrawalTypes.d.ts.map +1 -0
- package/dist/types/websocket/LighterWsProvider.d.ts.map +1 -1
- package/dist/types/websocket/orderBookSide.d.ts +33 -0
- package/dist/types/websocket/orderBookSide.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/LighterProvider.ts +236 -100
- package/src/accountSummary.ts +41 -22
- package/src/availableToTrade.ts +38 -15
- package/src/signers/LighterSigner.ts +11 -4
- package/src/types/submit.ts +15 -0
- package/src/utils/index.ts +9 -3
- package/src/utils/mapFill.ts +82 -43
- package/src/utils/mapOpenPositions.ts +45 -6
- package/src/utils/mapOrder.ts +99 -28
- package/src/utils/mapPortfolioHistory.ts +78 -24
- package/src/utils/mapPosition.ts +63 -47
- package/src/utils/rowTimestamp.ts +15 -0
- package/src/utils/settlementPool.ts +36 -12
- package/src/utils/spotPrice.ts +18 -12
- package/src/utils/time.ts +14 -4
- package/src/utils/transferMargin.ts +32 -15
- package/src/utils/withdrawableBalances.ts +34 -20
- package/src/utils/withdrawalTypes.ts +125 -0
- package/src/websocket/LighterWsProvider.ts +75 -92
- package/src/websocket/orderBookSide.ts +106 -0
- package/dist/cjs/utils/decimal.d.ts +0 -5
- package/dist/cjs/utils/decimal.d.ts.map +0 -1
- package/dist/cjs/utils/decimal.js +0 -38
- package/dist/cjs/utils/decimal.js.map +0 -1
- package/dist/cjs/utils/liquidation.d.ts +0 -4
- package/dist/cjs/utils/liquidation.d.ts.map +0 -1
- package/dist/cjs/utils/liquidation.js +0 -16
- package/dist/cjs/utils/liquidation.js.map +0 -1
- package/dist/esm/utils/decimal.d.ts +0 -15
- package/dist/esm/utils/decimal.d.ts.map +0 -1
- package/dist/esm/utils/decimal.js +0 -39
- package/dist/esm/utils/decimal.js.map +0 -1
- package/dist/esm/utils/liquidation.d.ts +0 -22
- package/dist/esm/utils/liquidation.d.ts.map +0 -1
- package/dist/esm/utils/liquidation.js +0 -31
- package/dist/esm/utils/liquidation.js.map +0 -1
- package/dist/types/utils/decimal.d.ts +0 -15
- package/dist/types/utils/decimal.d.ts.map +0 -1
- package/dist/types/utils/liquidation.d.ts +0 -22
- package/dist/types/utils/liquidation.d.ts.map +0 -1
- package/src/utils/decimal.ts +0 -52
- package/src/utils/liquidation.ts +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapPosition.d.ts","sourceRoot":"","sources":["../../../src/utils/mapPosition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapPosition.d.ts","sourceRoot":"","sources":["../../../src/utils/mapPosition.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAOrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAG1D;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAQtD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO5D,CAAA;AAOD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GACtB,KAAK,iBAAiB,EACtB,QAAQ,kBAAkB,KACzB,QAAQ,GAAG,SAqCb,CAAA"}
|
|
@@ -1,76 +1,79 @@
|
|
|
1
|
+
import { absDecimalString, divideDecimalString, isDecimalString, isDecimalStringZero, multiplyDecimalString, safeDivideDecimalString, safeIsDecimalStringGreaterThan, safeNumberToDecimalString, safeRoundDecimalString, warnSkippedVenueRow, } from '@lifi/perps-sdk';
|
|
1
2
|
import { MarginMode, PositionSide } from '@lifi/perps-types';
|
|
2
|
-
import
|
|
3
|
-
import { LIGHTER_IMF_PERCENT_SCALE, LIGHTER_LEVERAGE_PRECISION, } from '../constants.js';
|
|
3
|
+
import { LIGHTER_IMF_PERCENT_SCALE, LIGHTER_LEVERAGE_PRECISION, LIGHTER_PROVIDER_KEY, } from '../constants.js';
|
|
4
4
|
import { LT_MARGIN_MODE_ISOLATED } from '../types/index.js';
|
|
5
|
-
import { toPositiveRequiredBig, toRequiredBig } from './decimal.js';
|
|
6
5
|
/**
|
|
7
6
|
* Display leverage from an IMF percent string: `100 / IMF` in exact decimal
|
|
8
|
-
* arithmetic, rounded half-up to `LIGHTER_LEVERAGE_PRECISION
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* arithmetic, rounded half-up to `LIGHTER_LEVERAGE_PRECISION`, so the value a
|
|
8
|
+
* client reads is the value it saved. Provider risk calculations consume the
|
|
9
|
+
* original decimal IMF instead. `undefined` for a non-positive or unparsable
|
|
10
|
+
* IMF.
|
|
12
11
|
* @public
|
|
13
12
|
*/
|
|
14
13
|
export const leverageFromImf = (imf) => {
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
parsed = new Big(imf);
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
if (parsed.lte(0)) {
|
|
14
|
+
if (safeIsDecimalStringGreaterThan(imf, '0') !== true) {
|
|
23
15
|
return undefined;
|
|
24
16
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
const leverage = safeDivideDecimalString('100', imf);
|
|
18
|
+
return leverage === undefined
|
|
19
|
+
? undefined
|
|
20
|
+
: safeRoundDecimalString(leverage, LIGHTER_LEVERAGE_PRECISION, 'round');
|
|
29
21
|
};
|
|
30
22
|
/**
|
|
31
23
|
* Display leverage from an integer IMF on `LIGHTER_IMF_PERCENT_SCALE`, the
|
|
32
24
|
* unit of trade rows and order-book details: `500` is 5.00%, so 20x.
|
|
33
|
-
* `undefined` for a non-positive or
|
|
25
|
+
* `undefined` for a non-positive or non-finite IMF. Lighter declares the
|
|
34
26
|
* fraction a `StrictInt`, so the scale division is exact.
|
|
35
27
|
*/
|
|
36
28
|
export const leverageFromScaledImf = (imf) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
const scaled = safeNumberToDecimalString(imf);
|
|
30
|
+
const percent = scaled === undefined
|
|
31
|
+
? undefined
|
|
32
|
+
: safeDivideDecimalString(scaled, String(LIGHTER_IMF_PERCENT_SCALE));
|
|
33
|
+
return percent === undefined ? undefined : leverageFromImf(percent);
|
|
34
|
+
};
|
|
35
|
+
const skipPosition = (field, value) => {
|
|
36
|
+
warnSkippedVenueRow(LIGHTER_PROVIDER_KEY, 'position', field, value);
|
|
37
|
+
return undefined;
|
|
45
38
|
};
|
|
46
39
|
/**
|
|
47
|
-
* Map a raw Lighter account position to the generic Position type.
|
|
40
|
+
* Map a raw Lighter account position to the generic Position type. A row with
|
|
41
|
+
* an invalid size or value, or a non-positive initial margin fraction, gives
|
|
42
|
+
* `undefined`: the mapper derives the size, mark price, margin and leverage
|
|
43
|
+
* from them. Prices, PnL, funding and isolated margin pass through raw.
|
|
48
44
|
* @param market - Backend-resolved market identity for `pos.market_id`.
|
|
49
45
|
* @public
|
|
50
46
|
*/
|
|
51
47
|
export const mapPosition = (pos, market) => {
|
|
52
|
-
|
|
48
|
+
if (!isDecimalString(pos.position)) {
|
|
49
|
+
return skipPosition('position', pos.position);
|
|
50
|
+
}
|
|
51
|
+
if (!isDecimalString(pos.position_value)) {
|
|
52
|
+
return skipPosition('position_value', pos.position_value);
|
|
53
|
+
}
|
|
54
|
+
const imf = pos.initial_margin_fraction;
|
|
55
|
+
const leverage = isDecimalString(imf) ? leverageFromImf(imf) : undefined;
|
|
56
|
+
if (leverage === undefined) {
|
|
57
|
+
return skipPosition('initial_margin_fraction', imf);
|
|
58
|
+
}
|
|
53
59
|
const isIsolated = pos.margin_mode === LT_MARGIN_MODE_ISOLATED;
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const initialMarginRequirement = positionValue
|
|
57
|
-
const marginUsed = isIsolated
|
|
58
|
-
? pos.allocated_margin
|
|
59
|
-
: initialMarginRequirement.toFixed();
|
|
60
|
+
const size = absDecimalString(pos.position);
|
|
61
|
+
const positionValue = absDecimalString(pos.position_value);
|
|
62
|
+
const initialMarginRequirement = divideDecimalString(multiplyDecimalString(positionValue, imf), '100');
|
|
60
63
|
return {
|
|
61
64
|
market,
|
|
62
65
|
side: pos.sign >= 0 ? PositionSide.LONG : PositionSide.SHORT,
|
|
63
|
-
size
|
|
66
|
+
size,
|
|
64
67
|
entryPrice: pos.avg_entry_price,
|
|
65
|
-
markPrice: positionValue
|
|
68
|
+
markPrice: isDecimalStringZero(positionValue) || isDecimalStringZero(size)
|
|
66
69
|
? '0'
|
|
67
|
-
: positionValue
|
|
70
|
+
: divideDecimalString(positionValue, size),
|
|
68
71
|
liquidationPrice: pos.liquidation_price,
|
|
69
72
|
unrealizedPnl: pos.unrealized_pnl,
|
|
70
73
|
accruedFunding: pos.total_funding_paid_out ?? '0',
|
|
71
|
-
leverage
|
|
72
|
-
marginUsed,
|
|
73
|
-
initialMarginRequirement
|
|
74
|
+
leverage,
|
|
75
|
+
marginUsed: isIsolated ? pos.allocated_margin : initialMarginRequirement,
|
|
76
|
+
initialMarginRequirement,
|
|
74
77
|
marginMode: isIsolated ? MarginMode.ISOLATED : MarginMode.CROSS,
|
|
75
78
|
};
|
|
76
79
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapPosition.js","sourceRoot":"","sources":["../../../src/utils/mapPosition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapPosition.js","sourceRoot":"","sources":["../../../src/utils/mapPosition.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a venue row time as an ISO-8601 string, or `undefined` when the time is
|
|
3
|
+
* not valid. The caller logs the row skip, so this logs nothing.
|
|
4
|
+
*/
|
|
5
|
+
export declare const rowTimestampToIsoStringOrUndefined: (value: string | number) => string | undefined;
|
|
6
|
+
//# sourceMappingURL=rowTimestamp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowTimestamp.d.ts","sourceRoot":"","sources":["../../../src/utils/rowTimestamp.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,kCAAkC,GAC7C,OAAO,MAAM,GAAG,MAAM,KACrB,MAAM,GAAG,SAMX,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { timestampToIsoString } from '@lifi/perps-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Read a venue row time as an ISO-8601 string, or `undefined` when the time is
|
|
4
|
+
* not valid. The caller logs the row skip, so this logs nothing.
|
|
5
|
+
*/
|
|
6
|
+
export const rowTimestampToIsoStringOrUndefined = (value) => {
|
|
7
|
+
try {
|
|
8
|
+
return timestampToIsoString(value);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=rowTimestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowTimestamp.js","sourceRoot":"","sources":["../../../src/utils/rowTimestamp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,KAAsB,EACF,EAAE;IACtB,IAAI,CAAC;QACH,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type Big from 'big.js';
|
|
2
1
|
import type { LtAccountAsset } from '../types/account.js';
|
|
3
2
|
/** Both routes of a unified account's settlement asset, as one holding. */
|
|
4
|
-
export declare const pooledSettlementUnits: (asset: LtAccountAsset) =>
|
|
3
|
+
export declare const pooledSettlementUnits: (asset: LtAccountAsset) => string;
|
|
5
4
|
/**
|
|
6
5
|
* Spot units a unified account can spend from its settlement pool: the free
|
|
7
6
|
* spot route plus the margin route up to the account's `available_balance`.
|
|
8
7
|
* This is `computeSpotAvailableToTradeMarket` in Lighter's `lighter-ts` for an
|
|
9
8
|
* asset priced 1:1 with a `loan_to_value` of 1. The result can be negative.
|
|
10
9
|
*/
|
|
11
|
-
export declare const pooledSettlementSpendable: (asset: LtAccountAsset, availableBalance:
|
|
10
|
+
export declare const pooledSettlementSpendable: (asset: LtAccountAsset, availableBalance: string) => string;
|
|
12
11
|
/** Spot-route `balance` of the collateral asset; `'0'` when the account holds none. */
|
|
13
12
|
export declare const collateralSpotBalance: (assets: readonly LtAccountAsset[], settlementAssetIndex: number) => string;
|
|
14
13
|
//# sourceMappingURL=settlementPool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settlementPool.d.ts","sourceRoot":"","sources":["../../../src/utils/settlementPool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settlementPool.d.ts","sourceRoot":"","sources":["../../../src/utils/settlementPool.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,KAAG,MAQ3D,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,cAAc,EACrB,kBAAkB,MAAM,KACvB,MAmBF,CAAA;AAED,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,GAChC,QAAQ,SAAS,cAAc,EAAE,EACjC,sBAAsB,MAAM,KAC3B,MAKF,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { addDecimalString, isDecimalStringGreaterThan, subtractDecimalString, unknownToDecimalString, } from '@lifi/perps-sdk';
|
|
2
|
+
import { LIGHTER_PROVIDER_KEY } from '../constants.js';
|
|
2
3
|
/** Both routes of a unified account's settlement asset, as one holding. */
|
|
3
|
-
export const pooledSettlementUnits = (asset) =>
|
|
4
|
+
export const pooledSettlementUnits = (asset) => addDecimalString(unknownToDecimalString(asset.balance, 'balance', LIGHTER_PROVIDER_KEY), unknownToDecimalString(asset.margin_balance, 'margin_balance', LIGHTER_PROVIDER_KEY));
|
|
4
5
|
/**
|
|
5
6
|
* Spot units a unified account can spend from its settlement pool: the free
|
|
6
7
|
* spot route plus the margin route up to the account's `available_balance`.
|
|
@@ -8,16 +9,16 @@ export const pooledSettlementUnits = (asset) => toRequiredBig(asset.balance, 'ba
|
|
|
8
9
|
* asset priced 1:1 with a `loan_to_value` of 1. The result can be negative.
|
|
9
10
|
*/
|
|
10
11
|
export const pooledSettlementSpendable = (asset, availableBalance) => {
|
|
11
|
-
const marginBalance =
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const marginBalance = unknownToDecimalString(asset.margin_balance, 'margin_balance', LIGHTER_PROVIDER_KEY);
|
|
13
|
+
return addDecimalString(subtractDecimalString(unknownToDecimalString(asset.balance, 'balance', LIGHTER_PROVIDER_KEY), unknownToDecimalString(asset.locked_balance, 'locked_balance', LIGHTER_PROVIDER_KEY)), isDecimalStringGreaterThan(marginBalance, availableBalance)
|
|
14
|
+
? availableBalance
|
|
15
|
+
: marginBalance);
|
|
15
16
|
};
|
|
16
17
|
/** Spot-route `balance` of the collateral asset; `'0'` when the account holds none. */
|
|
17
18
|
export const collateralSpotBalance = (assets, settlementAssetIndex) => {
|
|
18
19
|
const asset = assets.find((a) => a.asset_id === settlementAssetIndex);
|
|
19
20
|
return asset === undefined
|
|
20
21
|
? '0'
|
|
21
|
-
:
|
|
22
|
+
: unknownToDecimalString(asset.balance, 'balance', LIGHTER_PROVIDER_KEY);
|
|
22
23
|
};
|
|
23
24
|
//# sourceMappingURL=settlementPool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settlementPool.js","sourceRoot":"","sources":["../../../src/utils/settlementPool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settlementPool.js","sourceRoot":"","sources":["../../../src/utils/settlementPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAGtD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAqB,EAAU,EAAE,CACrE,gBAAgB,CACd,sBAAsB,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,oBAAoB,CAAC,EACtE,sBAAsB,CACpB,KAAK,CAAC,cAAc,EACpB,gBAAgB,EAChB,oBAAoB,CACrB,CACF,CAAA;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,KAAqB,EACrB,gBAAwB,EAChB,EAAE;IACV,MAAM,aAAa,GAAG,sBAAsB,CAC1C,KAAK,CAAC,cAAc,EACpB,gBAAgB,EAChB,oBAAoB,CACrB,CAAA;IACD,OAAO,gBAAgB,CACrB,qBAAqB,CACnB,sBAAsB,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,oBAAoB,CAAC,EACtE,sBAAsB,CACpB,KAAK,CAAC,cAAc,EACpB,gBAAgB,EAChB,oBAAoB,CACrB,CACF,EACD,0BAA0B,CAAC,aAAa,EAAE,gBAAgB,CAAC;QACzD,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,aAAa,CAClB,CAAA;AACH,CAAC,CAAA;AAED,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,MAAiC,EACjC,oBAA4B,EACpB,EAAE;IACV,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,oBAAoB,CAAC,CAAA;IACrE,OAAO,KAAK,KAAK,SAAS;QACxB,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAA;AAC5E,CAAC,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Market, MarketContext } from '@lifi/perps-types';
|
|
2
|
-
import Big from 'big.js';
|
|
3
2
|
/**
|
|
4
3
|
* Unit prices keyed by spot base `Asset.id` (the venue `asset_id`), read from
|
|
5
4
|
* each spot market's `markPrice` for the base assets in `assetIds` only. A
|
|
@@ -10,14 +9,14 @@ import Big from 'big.js';
|
|
|
10
9
|
* @throws {PerpsError} `SDKError` when a context row for a requested asset
|
|
11
10
|
* carries a non-decimal mark.
|
|
12
11
|
*/
|
|
13
|
-
export declare const spotPriceByAssetId: (markets: readonly Market[], spotCategoryId: string, contexts: readonly MarketContext[], assetIds: ReadonlySet<string>) => Map<string,
|
|
12
|
+
export declare const spotPriceByAssetId: (markets: readonly Market[], spotCategoryId: string, contexts: readonly MarketContext[], assetIds: ReadonlySet<string>) => Map<string, string>;
|
|
14
13
|
/**
|
|
15
14
|
* USD value of `units` of a Lighter asset, with the unit price it used: the
|
|
16
15
|
* settlement asset at 1, any other at its `spotPrices` entry. An asset absent
|
|
17
16
|
* from `spotPrices` values at 0 and carries no price.
|
|
18
17
|
*/
|
|
19
|
-
export declare const spotValuation: (assetId: number, units: string, settlementAssetIndex: number, spotPrices: ReadonlyMap<string,
|
|
18
|
+
export declare const spotValuation: (assetId: number, units: string, settlementAssetIndex: number, spotPrices: ReadonlyMap<string, string>) => {
|
|
20
19
|
valueUsd: string;
|
|
21
|
-
price?:
|
|
20
|
+
price?: string;
|
|
22
21
|
};
|
|
23
22
|
//# sourceMappingURL=spotPrice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotPrice.d.ts","sourceRoot":"","sources":["../../../src/utils/spotPrice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spotPrice.d.ts","sourceRoot":"","sources":["../../../src/utils/spotPrice.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAG9D;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,SAAS,MAAM,EAAE,EAC1B,gBAAgB,MAAM,EACtB,UAAU,SAAS,aAAa,EAAE,EAClC,UAAU,WAAW,CAAC,MAAM,CAAC,KAC5B,GAAG,CAAC,MAAM,EAAE,MAAM,CAuBpB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,MAAM,EACf,OAAO,MAAM,EACb,sBAAsB,MAAM,EAC5B,YAAY,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAMpC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { isDecimalStringGreaterThan, multiplyDecimalString, unknownToDecimalString, } from '@lifi/perps-sdk';
|
|
2
|
+
import { LIGHTER_PROVIDER_KEY } from '../constants.js';
|
|
3
3
|
/**
|
|
4
4
|
* Unit prices keyed by spot base `Asset.id` (the venue `asset_id`), read from
|
|
5
5
|
* each spot market's `markPrice` for the base assets in `assetIds` only. A
|
|
@@ -21,8 +21,8 @@ export const spotPriceByAssetId = (markets, spotCategoryId, contexts, assetIds)
|
|
|
21
21
|
priceByAssetId.has(market.baseAsset.id)) {
|
|
22
22
|
continue;
|
|
23
23
|
}
|
|
24
|
-
const price =
|
|
25
|
-
if (price
|
|
24
|
+
const price = unknownToDecimalString(mark, 'markPrice', LIGHTER_PROVIDER_KEY);
|
|
25
|
+
if (isDecimalStringGreaterThan(price, '0')) {
|
|
26
26
|
priceByAssetId.set(market.baseAsset.id, price);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -34,11 +34,9 @@ export const spotPriceByAssetId = (markets, spotCategoryId, contexts, assetIds)
|
|
|
34
34
|
* from `spotPrices` values at 0 and carries no price.
|
|
35
35
|
*/
|
|
36
36
|
export const spotValuation = (assetId, units, settlementAssetIndex, spotPrices) => {
|
|
37
|
-
const price = assetId === settlementAssetIndex
|
|
38
|
-
? new Big(1)
|
|
39
|
-
: spotPrices.get(String(assetId));
|
|
37
|
+
const price = assetId === settlementAssetIndex ? '1' : spotPrices.get(String(assetId));
|
|
40
38
|
return price === undefined
|
|
41
39
|
? { valueUsd: '0' }
|
|
42
|
-
: { valueUsd:
|
|
40
|
+
: { valueUsd: multiplyDecimalString(units, price), price };
|
|
43
41
|
};
|
|
44
42
|
//# sourceMappingURL=spotPrice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotPrice.js","sourceRoot":"","sources":["../../../src/utils/spotPrice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spotPrice.js","sourceRoot":"","sources":["../../../src/utils/spotPrice.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,OAA0B,EAC1B,cAAsB,EACtB,QAAkC,EAClC,QAA6B,EACR,EAAE;IACvB,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAC9E,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAA;IAChD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC1C,IACE,MAAM,CAAC,UAAU,KAAK,cAAc;YACpC,IAAI,KAAK,SAAS;YAClB,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,EACvC,CAAC;YACD,SAAQ;QACV,CAAC;QACD,MAAM,KAAK,GAAG,sBAAsB,CAClC,IAAI,EACJ,WAAW,EACX,oBAAoB,CACrB,CAAA;QACD,IAAI,0BAA0B,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YAC3C,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAAe,EACf,KAAa,EACb,oBAA4B,EAC5B,UAAuC,EACD,EAAE;IACxC,MAAM,KAAK,GACT,OAAO,KAAK,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAC1E,OAAO,KAAK,KAAK,SAAS;QACxB,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE;QACnB,CAAC,CAAC,EAAE,QAAQ,EAAE,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,CAAA;AAC9D,CAAC,CAAA"}
|
package/dist/esm/utils/time.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Convert seconds since unix epoch to ISO-8601.
|
|
3
|
+
*
|
|
4
|
+
* @throws {PerpsError} `ValidationError` when `seconds` is not a valid time.
|
|
5
|
+
*/
|
|
2
6
|
export declare const toIsoFromSeconds: (seconds: number) => string;
|
|
3
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Convert milliseconds since unix epoch to ISO-8601.
|
|
9
|
+
*
|
|
10
|
+
* @throws {PerpsError} `ValidationError` when `ms` is not a valid time.
|
|
11
|
+
*/
|
|
4
12
|
export declare const toIsoFromMs: (ms: number) => string;
|
|
5
13
|
//# sourceMappingURL=time.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/utils/time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/utils/time.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,KAAG,MACb,CAAA;AAEtC;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,KAAG,MAAkC,CAAA"}
|
package/dist/esm/utils/time.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { timestampToIsoString } from '@lifi/perps-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Convert seconds since unix epoch to ISO-8601.
|
|
4
|
+
*
|
|
5
|
+
* @throws {PerpsError} `ValidationError` when `seconds` is not a valid time.
|
|
6
|
+
*/
|
|
7
|
+
export const toIsoFromSeconds = (seconds) => timestampToIsoString(seconds * 1000);
|
|
8
|
+
/**
|
|
9
|
+
* Convert milliseconds since unix epoch to ISO-8601.
|
|
10
|
+
*
|
|
11
|
+
* @throws {PerpsError} `ValidationError` when `ms` is not a valid time.
|
|
12
|
+
*/
|
|
13
|
+
export const toIsoFromMs = (ms) => timestampToIsoString(ms);
|
|
5
14
|
//# sourceMappingURL=time.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../../src/utils/time.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../../src/utils/time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE,CAC1D,oBAAoB,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAU,EAAU,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transferMargin.d.ts","sourceRoot":"","sources":["../../../src/utils/transferMargin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transferMargin.d.ts","sourceRoot":"","sources":["../../../src/utils/transferMargin.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAA;AA+B1B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,GACjB,aAAa,GAAG,SAAS,CAqB3B"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { PerpsError, positionSupportsMarginAdjustment, positionSupportsMarginRemoval,
|
|
1
|
+
import { addDecimalString, isDecimalString, isDecimalStringGreaterThan, PerpsError, positionSupportsMarginAdjustment, positionSupportsMarginRemoval, roundDecimalString, subtractDecimalString, } from '@lifi/perps-sdk';
|
|
2
2
|
import { PerpsErrorCode, } from '@lifi/perps-types';
|
|
3
|
-
import Big from 'big.js';
|
|
4
3
|
const AMOUNT_DECIMALS = 6;
|
|
5
4
|
function positionAmount(value, field) {
|
|
6
|
-
|
|
5
|
+
if (!isDecimalString(value)) {
|
|
6
|
+
throw new PerpsError(PerpsErrorCode.ValidationError, `Invalid \`Position.${field}\`: '${value}' is not a decimal string.`);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
7
9
|
}
|
|
8
10
|
function positivePositionAmount(value, field) {
|
|
9
11
|
const amount = positionAmount(value, field);
|
|
10
|
-
if (amount
|
|
12
|
+
if (!isDecimalStringGreaterThan(amount, '0')) {
|
|
11
13
|
throw new PerpsError(PerpsErrorCode.ValidationError, `Position.${field} must be greater than zero.`);
|
|
12
14
|
}
|
|
13
15
|
return amount;
|
|
@@ -33,12 +35,10 @@ export function positionRemovableMargin(position) {
|
|
|
33
35
|
if (!positionSupportsMarginRemoval(position)) {
|
|
34
36
|
return '0';
|
|
35
37
|
}
|
|
36
|
-
const removable = positivePositionAmount(position.marginUsed, 'marginUsed')
|
|
37
|
-
|
|
38
|
-
.minus(positivePositionAmount(position.initialMarginRequirement, 'initialMarginRequirement'));
|
|
39
|
-
if (removable.lte(0)) {
|
|
38
|
+
const removable = subtractDecimalString(addDecimalString(positivePositionAmount(position.marginUsed, 'marginUsed'), positionAmount(position.unrealizedPnl, 'unrealizedPnl')), positivePositionAmount(position.initialMarginRequirement, 'initialMarginRequirement'));
|
|
39
|
+
if (!isDecimalStringGreaterThan(removable, '0')) {
|
|
40
40
|
return '0';
|
|
41
41
|
}
|
|
42
|
-
return removable
|
|
42
|
+
return roundDecimalString(removable, AMOUNT_DECIMALS, 'truncate');
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=transferMargin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transferMargin.js","sourceRoot":"","sources":["../../../src/utils/transferMargin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gCAAgC,EAChC,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,cAAc,GAEf,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"transferMargin.js","sourceRoot":"","sources":["../../../src/utils/transferMargin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,0BAA0B,EAC1B,UAAU,EACV,gCAAgC,EAChC,6BAA6B,EAC7B,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,cAAc,GAEf,MAAM,mBAAmB,CAAA;AAE1B,MAAM,eAAe,GAAG,CAAC,CAAA;AAEzB,SAAS,cAAc,CACrB,KAAgC,EAChC,KAAa;IAEb,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,UAAU,CAClB,cAAc,CAAC,eAAe,EAC9B,sBAAsB,KAAK,QAAQ,KAAK,4BAA4B,CACrE,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,sBAAsB,CAC7B,KAAgC,EAChC,KAAa;IAEb,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC3C,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,UAAU,CAClB,cAAc,CAAC,eAAe,EAC9B,YAAY,KAAK,6BAA6B,CAC/C,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAkB;IAElB,IAAI,CAAC,gCAAgC,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChD,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,CAAC,6BAA6B,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7C,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,MAAM,SAAS,GAAG,qBAAqB,CACrC,gBAAgB,CACd,sBAAsB,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,EACzD,cAAc,CAAC,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC,CACxD,EACD,sBAAsB,CACpB,QAAQ,CAAC,wBAAwB,EACjC,0BAA0B,CAC3B,CACF,CAAA;IACD,IAAI,CAAC,0BAA0B,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,OAAO,kBAAkB,CAAC,SAAS,EAAE,eAAe,EAAE,UAAU,CAAC,CAAA;AACnE,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ProviderWithdrawableBalance } from '@lifi/perps-sdk';
|
|
2
2
|
import type { LtAccount } from '../types/account.js';
|
|
3
3
|
/**
|
|
4
|
-
* Split each held asset into the two
|
|
5
|
-
* spot draws on `balance` net of `locked_balance`, perps draws on
|
|
4
|
+
* Split each held asset into the two categories a Lighter withdrawal can
|
|
5
|
+
* name: spot draws on `balance` net of `locked_balance`, perps draws on
|
|
6
6
|
* `margin_balance`. The settlement asset's perps route is also capped by the
|
|
7
7
|
* account `available_balance`, which excludes the margin open positions use.
|
|
8
8
|
* Every other asset's perps route reports its full `margin_balance`, uncapped,
|
|
@@ -13,7 +13,9 @@ import type { LtAccount } from '../types/account.js';
|
|
|
13
13
|
*
|
|
14
14
|
* @param settlementAssetIndex - L2 asset index of the deployment's collateral
|
|
15
15
|
* asset, the only asset that `available_balance` is denominated in.
|
|
16
|
+
* @param perpsCategoryId - The instance's perps category id, the
|
|
17
|
+
* `categoryId` its collateral `Balance` rows carry.
|
|
16
18
|
* @public
|
|
17
19
|
*/
|
|
18
|
-
export declare const lighterWithdrawableBalances: (account: Pick<LtAccount, "assets" | "available_balance">, settlementAssetIndex: number) => ProviderWithdrawableBalance[];
|
|
20
|
+
export declare const lighterWithdrawableBalances: (account: Pick<LtAccount, "assets" | "available_balance">, settlementAssetIndex: number, perpsCategoryId: string) => ProviderWithdrawableBalance[];
|
|
19
21
|
//# sourceMappingURL=withdrawableBalances.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawableBalances.d.ts","sourceRoot":"","sources":["../../../src/utils/withdrawableBalances.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"withdrawableBalances.d.ts","sourceRoot":"","sources":["../../../src/utils/withdrawableBalances.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,2BAA2B,EAGjC,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,mBAAmB,CAAC,EACxD,sBAAsB,MAAM,EAC5B,iBAAiB,MAAM,KACtB,2BAA2B,EA8C7B,CAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { calculateTransferable, calculateWithdrawMax, } from '@lifi/perps-sdk';
|
|
2
|
-
import
|
|
3
|
-
import { toRequiredBig } from './decimal.js';
|
|
1
|
+
import { calculateTransferable, calculateWithdrawMax, isDecimalStringGreaterThan, subtractDecimalString, unknownToDecimalString, } from '@lifi/perps-sdk';
|
|
2
|
+
import { LIGHTER_PROVIDER_KEY, LIGHTER_SPOT_CATEGORY_ID } from '../constants.js';
|
|
4
3
|
/**
|
|
5
|
-
* Split each held asset into the two
|
|
6
|
-
* spot draws on `balance` net of `locked_balance`, perps draws on
|
|
4
|
+
* Split each held asset into the two categories a Lighter withdrawal can
|
|
5
|
+
* name: spot draws on `balance` net of `locked_balance`, perps draws on
|
|
7
6
|
* `margin_balance`. The settlement asset's perps route is also capped by the
|
|
8
7
|
* account `available_balance`, which excludes the margin open positions use.
|
|
9
8
|
* Every other asset's perps route reports its full `margin_balance`, uncapped,
|
|
@@ -14,30 +13,31 @@ import { toRequiredBig } from './decimal.js';
|
|
|
14
13
|
*
|
|
15
14
|
* @param settlementAssetIndex - L2 asset index of the deployment's collateral
|
|
16
15
|
* asset, the only asset that `available_balance` is denominated in.
|
|
16
|
+
* @param perpsCategoryId - The instance's perps category id, the
|
|
17
|
+
* `categoryId` its collateral `Balance` rows carry.
|
|
17
18
|
* @public
|
|
18
19
|
*/
|
|
19
|
-
export const lighterWithdrawableBalances = (account, settlementAssetIndex) => {
|
|
20
|
+
export const lighterWithdrawableBalances = (account, settlementAssetIndex, perpsCategoryId) => {
|
|
20
21
|
const rows = [];
|
|
21
22
|
for (const asset of account.assets) {
|
|
22
23
|
const assetId = String(asset.asset_id);
|
|
23
|
-
const spot =
|
|
24
|
-
if (spot
|
|
25
|
-
const available = spot.toFixed();
|
|
24
|
+
const spot = subtractDecimalString(unknownToDecimalString(asset.balance, 'balance', LIGHTER_PROVIDER_KEY), unknownToDecimalString(asset.locked_balance, 'locked_balance', LIGHTER_PROVIDER_KEY));
|
|
25
|
+
if (isDecimalStringGreaterThan(spot, '0')) {
|
|
26
26
|
rows.push({
|
|
27
27
|
assetId,
|
|
28
|
-
|
|
29
|
-
available,
|
|
30
|
-
max: calculateWithdrawMax({ available }),
|
|
28
|
+
categoryId: LIGHTER_SPOT_CATEGORY_ID,
|
|
29
|
+
available: spot,
|
|
30
|
+
max: calculateWithdrawMax({ available: spot }),
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
const marginBalance =
|
|
33
|
+
const marginBalance = unknownToDecimalString(asset.margin_balance, 'margin_balance', LIGHTER_PROVIDER_KEY);
|
|
34
34
|
const perps = asset.asset_id === settlementAssetIndex
|
|
35
|
-
? calculateTransferable(
|
|
36
|
-
: marginBalance
|
|
37
|
-
if (
|
|
35
|
+
? calculateTransferable(unknownToDecimalString(account.available_balance, 'available_balance', LIGHTER_PROVIDER_KEY), marginBalance)
|
|
36
|
+
: marginBalance;
|
|
37
|
+
if (isDecimalStringGreaterThan(perps, '0')) {
|
|
38
38
|
rows.push({
|
|
39
39
|
assetId,
|
|
40
|
-
|
|
40
|
+
categoryId: perpsCategoryId,
|
|
41
41
|
available: perps,
|
|
42
42
|
max: calculateWithdrawMax({ available: perps }),
|
|
43
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawableBalances.js","sourceRoot":"","sources":["../../../src/utils/withdrawableBalances.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"withdrawableBalances.js","sourceRoot":"","sources":["../../../src/utils/withdrawableBalances.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAE1B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAGhF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,OAAwD,EACxD,oBAA4B,EAC5B,eAAuB,EACQ,EAAE;IACjC,MAAM,IAAI,GAAkC,EAAE,CAAA;IAC9C,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACtC,MAAM,IAAI,GAAG,qBAAqB,CAChC,sBAAsB,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,oBAAoB,CAAC,EACtE,sBAAsB,CACpB,KAAK,CAAC,cAAc,EACpB,gBAAgB,EAChB,oBAAoB,CACrB,CACF,CAAA;QACD,IAAI,0BAA0B,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;YAC1C,IAAI,CAAC,IAAI,CAAC;gBACR,OAAO;gBACP,UAAU,EAAE,wBAAwB;gBACpC,SAAS,EAAE,IAAI;gBACf,GAAG,EAAE,oBAAoB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;aAC/C,CAAC,CAAA;QACJ,CAAC;QACD,MAAM,aAAa,GAAG,sBAAsB,CAC1C,KAAK,CAAC,cAAc,EACpB,gBAAgB,EAChB,oBAAoB,CACrB,CAAA;QACD,MAAM,KAAK,GACT,KAAK,CAAC,QAAQ,KAAK,oBAAoB;YACrC,CAAC,CAAC,qBAAqB,CACnB,sBAAsB,CACpB,OAAO,CAAC,iBAAiB,EACzB,mBAAmB,EACnB,oBAAoB,CACrB,EACD,aAAa,CACd;YACH,CAAC,CAAC,aAAa,CAAA;QACnB,IAAI,0BAA0B,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,IAAI,CAAC;gBACR,OAAO;gBACP,UAAU,EAAE,eAAe;gBAC3B,SAAS,EAAE,KAAK;gBAChB,GAAG,EAAE,oBAAoB,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;aAChD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ProviderWithdrawableBalance, type WithdrawalAssetRef, type WithdrawalSourceTypes } from '@lifi/perps-sdk';
|
|
2
|
+
import type { LtFastwithdrawInfoResponse, LtTransferFeeInfoResponse } from '../types/submit.js';
|
|
3
|
+
/**
|
|
4
|
+
* The `withdrawalOptions` a Lighter withdrawal accepts. `fast` sends the
|
|
5
|
+
* amount to the fast-withdraw operator account `toAccountIndex`; `fee` is the
|
|
6
|
+
* transfer fee in L2 6-decimal integer units.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type LighterWithdrawalOptions = {
|
|
11
|
+
mode: 'standard';
|
|
12
|
+
} | {
|
|
13
|
+
mode: 'fast';
|
|
14
|
+
toAccountIndex: number;
|
|
15
|
+
fee: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The fast-withdraw terms Lighter offers an account.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export interface LighterFastWithdrawal {
|
|
23
|
+
toAccountIndex: number;
|
|
24
|
+
fee: number;
|
|
25
|
+
/** The lower of `withdraw_limit` and `max_withdrawal_amount`, in collateral units. */
|
|
26
|
+
limit: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The fast-withdraw terms from `/fastwithdraw/info` and `/transferFeeInfo`, or
|
|
30
|
+
* `undefined` when either read reports a code other than 200 or no operator
|
|
31
|
+
* account is set.
|
|
32
|
+
*
|
|
33
|
+
* @throws {PerpsError} When a limit is not a decimal.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare const lighterFastWithdrawal: (info: LtFastwithdrawInfoResponse, feeInfo: LtTransferFeeInfoResponse) => LighterFastWithdrawal | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The withdrawal types per withdrawable row. Every row offers `STANDARD` up to
|
|
39
|
+
* its `max`. The `fastSource` row also offers `FAST` when `fast` is set, up to
|
|
40
|
+
* the lower of its `max` and `fast.limit`.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare const lighterWithdrawalTypes: (rows: ProviderWithdrawableBalance[], fastSource: WithdrawalAssetRef, fast: LighterFastWithdrawal | undefined) => WithdrawalSourceTypes[];
|
|
45
|
+
//# sourceMappingURL=withdrawalTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdrawalTypes.d.ts","sourceRoot":"","sources":["../../../src/utils/withdrawalTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,2BAA2B,EAEhC,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE3B,MAAM,iBAAiB,CAAA;AAGxB,OAAO,KAAK,EACV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,oBAAoB,CAAA;AAK3B;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAA;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,MAAM,0BAA0B,EAChC,SAAS,yBAAyB,KACjC,qBAAqB,GAAG,SA0B1B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,2BAA2B,EAAE,EACnC,YAAY,kBAAkB,EAC9B,MAAM,qBAAqB,GAAG,SAAS,KACtC,qBAAqB,EAgCpB,CAAA"}
|