@lifi/perps-sdk 0.0.0-preview-e927c9c → 0.0.0-preview-0b4b647
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/README.md +94 -6
- package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
- package/dist/cjs/client/PerpsClient.js +4 -1
- package/dist/cjs/client/PerpsClient.js.map +1 -1
- package/dist/cjs/{utils/decimal.d.ts → decimal/big.d.ts} +1 -1
- package/dist/cjs/decimal/big.d.ts.map +1 -0
- package/dist/cjs/{utils/decimal.js → decimal/big.js} +1 -1
- package/dist/cjs/decimal/big.js.map +1 -0
- package/dist/cjs/decimal/convert.d.ts +11 -0
- package/dist/cjs/decimal/convert.d.ts.map +1 -0
- package/dist/cjs/decimal/convert.js +57 -0
- package/dist/cjs/decimal/convert.js.map +1 -0
- package/dist/cjs/decimal/format.d.ts.map +1 -0
- package/dist/cjs/decimal/format.js.map +1 -0
- package/dist/cjs/decimal/parse.d.ts +7 -0
- package/dist/cjs/decimal/parse.d.ts.map +1 -0
- package/dist/cjs/{utils → decimal}/parse.js +10 -4
- package/dist/cjs/decimal/parse.js.map +1 -0
- package/dist/cjs/decimal/requireDecimal.d.ts +4 -0
- package/dist/cjs/decimal/requireDecimal.d.ts.map +1 -0
- package/dist/cjs/decimal/requireDecimal.js +17 -0
- package/dist/cjs/decimal/requireDecimal.js.map +1 -0
- package/dist/cjs/index.d.ts +17 -15
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +78 -61
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/math/fills.d.ts +5 -0
- package/dist/cjs/math/fills.d.ts.map +1 -0
- package/dist/cjs/{utils/fillClassification.js → math/fills.js} +16 -1
- package/dist/cjs/math/fills.js.map +1 -0
- package/dist/cjs/math/order.d.ts +45 -0
- package/dist/cjs/math/order.d.ts.map +1 -0
- package/dist/cjs/math/order.js +256 -0
- package/dist/cjs/math/order.js.map +1 -0
- package/dist/cjs/math/position.d.ts +59 -0
- package/dist/cjs/math/position.d.ts.map +1 -0
- package/dist/cjs/math/position.js +172 -0
- package/dist/cjs/math/position.js.map +1 -0
- package/dist/cjs/services/resolveQuote.d.ts.map +1 -1
- package/dist/cjs/services/resolveQuote.js +2 -2
- package/dist/cjs/services/resolveQuote.js.map +1 -1
- package/dist/cjs/services/resolveSubscribeQuote.d.ts.map +1 -1
- package/dist/cjs/services/resolveSubscribeQuote.js +2 -2
- package/dist/cjs/services/resolveSubscribeQuote.js.map +1 -1
- package/dist/cjs/types/provider.d.ts +3 -3
- package/dist/cjs/types/provider.d.ts.map +1 -1
- package/dist/cjs/types/withdrawal.d.ts +7 -5
- package/dist/cjs/types/withdrawal.d.ts.map +1 -1
- package/dist/cjs/utils/orderClassification.d.ts +1 -3
- package/dist/cjs/utils/orderClassification.d.ts.map +1 -1
- package/dist/cjs/utils/orderClassification.js +1 -15
- package/dist/cjs/utils/orderClassification.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wire/orderAmounts.d.ts +17 -0
- package/dist/cjs/wire/orderAmounts.d.ts.map +1 -0
- package/dist/cjs/wire/orderAmounts.js +46 -0
- package/dist/cjs/wire/orderAmounts.js.map +1 -0
- package/dist/cjs/wire/refuel.d.ts +8 -0
- package/dist/cjs/wire/refuel.d.ts.map +1 -0
- package/dist/cjs/wire/refuel.js +23 -0
- package/dist/cjs/wire/refuel.js.map +1 -0
- package/dist/cjs/wire/snap.d.ts +5 -0
- package/dist/cjs/wire/snap.d.ts.map +1 -0
- package/dist/cjs/wire/snap.js +12 -0
- package/dist/cjs/wire/snap.js.map +1 -0
- package/dist/cjs/wire/transferable.d.ts +3 -0
- package/dist/cjs/wire/transferable.d.ts.map +1 -0
- package/dist/cjs/wire/transferable.js +13 -0
- package/dist/cjs/wire/transferable.js.map +1 -0
- package/dist/cjs/wire/withdraw.d.ts +4 -0
- package/dist/cjs/wire/withdraw.d.ts.map +1 -0
- package/dist/cjs/wire/withdraw.js +13 -0
- package/dist/cjs/wire/withdraw.js.map +1 -0
- package/dist/esm/client/PerpsClient.d.ts.map +1 -1
- package/dist/esm/client/PerpsClient.js +4 -1
- package/dist/esm/client/PerpsClient.js.map +1 -1
- package/dist/esm/{utils/decimal.d.ts → decimal/big.d.ts} +1 -1
- package/dist/esm/decimal/big.d.ts.map +1 -0
- package/dist/esm/{utils/decimal.js → decimal/big.js} +1 -1
- package/dist/esm/decimal/big.js.map +1 -0
- package/dist/esm/decimal/convert.d.ts +80 -0
- package/dist/esm/decimal/convert.d.ts.map +1 -0
- package/dist/esm/decimal/convert.js +105 -0
- package/dist/esm/decimal/convert.js.map +1 -0
- package/dist/esm/decimal/format.d.ts.map +1 -0
- package/dist/esm/decimal/format.js.map +1 -0
- package/dist/esm/decimal/parse.d.ts +35 -0
- package/dist/esm/decimal/parse.d.ts.map +1 -0
- package/dist/esm/{utils → decimal}/parse.js +18 -10
- package/dist/esm/decimal/parse.js.map +1 -0
- package/dist/esm/decimal/requireDecimal.d.ts +11 -0
- package/dist/esm/decimal/requireDecimal.d.ts.map +1 -0
- package/dist/esm/decimal/requireDecimal.js +18 -0
- package/dist/esm/decimal/requireDecimal.js.map +1 -0
- package/dist/esm/index.d.ts +17 -15
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +12 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/math/fills.d.ts +26 -0
- package/dist/esm/math/fills.d.ts.map +1 -0
- package/dist/esm/{utils/fillClassification.js → math/fills.js} +26 -2
- package/dist/esm/math/fills.js.map +1 -0
- package/dist/esm/{utils/calculations.d.ts → math/order.d.ts} +70 -75
- package/dist/esm/math/order.d.ts.map +1 -0
- package/dist/esm/{utils/calculations.js → math/order.js} +155 -111
- package/dist/esm/math/order.js.map +1 -0
- package/dist/esm/math/position.d.ts +227 -0
- package/dist/esm/math/position.d.ts.map +1 -0
- package/dist/esm/math/position.js +322 -0
- package/dist/esm/math/position.js.map +1 -0
- package/dist/esm/services/resolveQuote.d.ts.map +1 -1
- package/dist/esm/services/resolveQuote.js +1 -1
- package/dist/esm/services/resolveQuote.js.map +1 -1
- package/dist/esm/services/resolveSubscribeQuote.d.ts.map +1 -1
- package/dist/esm/services/resolveSubscribeQuote.js +1 -1
- package/dist/esm/services/resolveSubscribeQuote.js.map +1 -1
- package/dist/esm/types/provider.d.ts +23 -11
- package/dist/esm/types/provider.d.ts.map +1 -1
- package/dist/esm/types/withdrawal.d.ts +17 -5
- package/dist/esm/types/withdrawal.d.ts.map +1 -1
- package/dist/esm/utils/orderClassification.d.ts +1 -14
- package/dist/esm/utils/orderClassification.d.ts.map +1 -1
- package/dist/esm/utils/orderClassification.js +1 -25
- package/dist/esm/utils/orderClassification.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wire/orderAmounts.d.ts +41 -0
- package/dist/esm/wire/orderAmounts.d.ts.map +1 -0
- package/dist/esm/wire/orderAmounts.js +54 -0
- package/dist/esm/wire/orderAmounts.js.map +1 -0
- package/dist/esm/wire/refuel.d.ts +28 -0
- package/dist/esm/wire/refuel.d.ts.map +1 -0
- package/dist/esm/wire/refuel.js +36 -0
- package/dist/esm/wire/refuel.js.map +1 -0
- package/dist/esm/wire/snap.d.ts +24 -0
- package/dist/esm/wire/snap.d.ts.map +1 -0
- package/dist/esm/wire/snap.js +27 -0
- package/dist/esm/wire/snap.js.map +1 -0
- package/dist/esm/wire/transferable.d.ts +15 -0
- package/dist/esm/wire/transferable.d.ts.map +1 -0
- package/dist/esm/wire/transferable.js +22 -0
- package/dist/esm/wire/transferable.js.map +1 -0
- package/dist/esm/wire/withdraw.d.ts +14 -0
- package/dist/esm/wire/withdraw.d.ts.map +1 -0
- package/dist/esm/wire/withdraw.js +20 -0
- package/dist/esm/wire/withdraw.js.map +1 -0
- package/dist/types/client/PerpsClient.d.ts.map +1 -1
- package/dist/types/{utils/decimal.d.ts → decimal/big.d.ts} +1 -1
- package/dist/types/decimal/big.d.ts.map +1 -0
- package/dist/types/decimal/convert.d.ts +80 -0
- package/dist/types/decimal/convert.d.ts.map +1 -0
- package/dist/types/decimal/format.d.ts.map +1 -0
- package/dist/types/decimal/parse.d.ts +35 -0
- package/dist/types/decimal/parse.d.ts.map +1 -0
- package/dist/types/decimal/requireDecimal.d.ts +11 -0
- package/dist/types/decimal/requireDecimal.d.ts.map +1 -0
- package/dist/types/index.d.ts +17 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/math/fills.d.ts +26 -0
- package/dist/types/math/fills.d.ts.map +1 -0
- package/dist/types/{utils/calculations.d.ts → math/order.d.ts} +70 -75
- package/dist/types/math/order.d.ts.map +1 -0
- package/dist/types/math/position.d.ts +227 -0
- package/dist/types/math/position.d.ts.map +1 -0
- package/dist/types/services/resolveQuote.d.ts.map +1 -1
- package/dist/types/services/resolveSubscribeQuote.d.ts.map +1 -1
- package/dist/types/types/provider.d.ts +23 -11
- package/dist/types/types/provider.d.ts.map +1 -1
- package/dist/types/types/withdrawal.d.ts +17 -5
- package/dist/types/types/withdrawal.d.ts.map +1 -1
- package/dist/types/utils/orderClassification.d.ts +1 -14
- package/dist/types/utils/orderClassification.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wire/orderAmounts.d.ts +41 -0
- package/dist/types/wire/orderAmounts.d.ts.map +1 -0
- package/dist/types/wire/refuel.d.ts +28 -0
- package/dist/types/wire/refuel.d.ts.map +1 -0
- package/dist/types/wire/snap.d.ts +24 -0
- package/dist/types/wire/snap.d.ts.map +1 -0
- package/dist/types/wire/transferable.d.ts +15 -0
- package/dist/types/wire/transferable.d.ts.map +1 -0
- package/dist/types/wire/withdraw.d.ts +14 -0
- package/dist/types/wire/withdraw.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/client/PerpsClient.ts +4 -1
- package/src/decimal/convert.ts +150 -0
- package/src/{utils → decimal}/parse.ts +22 -11
- package/src/decimal/requireDecimal.ts +21 -0
- package/src/index.ts +86 -57
- package/src/{utils/fillClassification.ts → math/fills.ts} +30 -1
- package/src/{utils/calculations.ts → math/order.ts} +205 -127
- package/src/math/position.ts +394 -0
- package/src/services/resolveQuote.ts +1 -1
- package/src/services/resolveSubscribeQuote.ts +1 -1
- package/src/types/provider.ts +23 -10
- package/src/types/withdrawal.ts +22 -5
- package/src/utils/orderClassification.ts +0 -30
- package/src/version.ts +1 -1
- package/src/wire/orderAmounts.ts +90 -0
- package/src/wire/refuel.ts +51 -0
- package/src/wire/snap.ts +38 -0
- package/src/wire/transferable.ts +26 -0
- package/src/wire/withdraw.ts +29 -0
- package/dist/cjs/utils/calculations.d.ts +0 -47
- package/dist/cjs/utils/calculations.d.ts.map +0 -1
- package/dist/cjs/utils/calculations.js +0 -214
- package/dist/cjs/utils/calculations.js.map +0 -1
- package/dist/cjs/utils/decimal.d.ts.map +0 -1
- package/dist/cjs/utils/decimal.js.map +0 -1
- package/dist/cjs/utils/fillClassification.d.ts +0 -3
- package/dist/cjs/utils/fillClassification.d.ts.map +0 -1
- package/dist/cjs/utils/fillClassification.js.map +0 -1
- package/dist/cjs/utils/format.d.ts.map +0 -1
- package/dist/cjs/utils/format.js.map +0 -1
- package/dist/cjs/utils/math.d.ts +0 -4
- package/dist/cjs/utils/math.d.ts.map +0 -1
- package/dist/cjs/utils/math.js +0 -8
- package/dist/cjs/utils/math.js.map +0 -1
- package/dist/cjs/utils/orderEntry.d.ts +0 -6
- package/dist/cjs/utils/orderEntry.d.ts.map +0 -1
- package/dist/cjs/utils/orderEntry.js +0 -20
- package/dist/cjs/utils/orderEntry.js.map +0 -1
- package/dist/cjs/utils/orderMath.d.ts +0 -6
- package/dist/cjs/utils/orderMath.d.ts.map +0 -1
- package/dist/cjs/utils/orderMath.js +0 -85
- package/dist/cjs/utils/orderMath.js.map +0 -1
- package/dist/cjs/utils/parse.d.ts +0 -3
- package/dist/cjs/utils/parse.d.ts.map +0 -1
- package/dist/cjs/utils/parse.js.map +0 -1
- package/dist/cjs/utils/positionMath.d.ts +0 -37
- package/dist/cjs/utils/positionMath.d.ts.map +0 -1
- package/dist/cjs/utils/positionMath.js +0 -99
- package/dist/cjs/utils/positionMath.js.map +0 -1
- package/dist/cjs/utils/scaleToInteger.d.ts +0 -3
- package/dist/cjs/utils/scaleToInteger.d.ts.map +0 -1
- package/dist/cjs/utils/scaleToInteger.js +0 -30
- package/dist/cjs/utils/scaleToInteger.js.map +0 -1
- package/dist/cjs/utils/units.d.ts +0 -3
- package/dist/cjs/utils/units.d.ts.map +0 -1
- package/dist/cjs/utils/units.js +0 -18
- package/dist/cjs/utils/units.js.map +0 -1
- package/dist/cjs/utils/validation.d.ts +0 -2
- package/dist/cjs/utils/validation.d.ts.map +0 -1
- package/dist/cjs/utils/validation.js +0 -16
- package/dist/cjs/utils/validation.js.map +0 -1
- package/dist/esm/utils/calculations.d.ts.map +0 -1
- package/dist/esm/utils/calculations.js.map +0 -1
- package/dist/esm/utils/decimal.d.ts.map +0 -1
- package/dist/esm/utils/decimal.js.map +0 -1
- package/dist/esm/utils/fillClassification.d.ts +0 -13
- package/dist/esm/utils/fillClassification.d.ts.map +0 -1
- package/dist/esm/utils/fillClassification.js.map +0 -1
- package/dist/esm/utils/format.d.ts.map +0 -1
- package/dist/esm/utils/format.js.map +0 -1
- package/dist/esm/utils/math.d.ts +0 -6
- package/dist/esm/utils/math.d.ts.map +0 -1
- package/dist/esm/utils/math.js +0 -5
- package/dist/esm/utils/math.js.map +0 -1
- package/dist/esm/utils/orderEntry.d.ts +0 -26
- package/dist/esm/utils/orderEntry.d.ts.map +0 -1
- package/dist/esm/utils/orderEntry.js +0 -34
- package/dist/esm/utils/orderEntry.js.map +0 -1
- package/dist/esm/utils/orderMath.d.ts +0 -37
- package/dist/esm/utils/orderMath.d.ts.map +0 -1
- package/dist/esm/utils/orderMath.js +0 -113
- package/dist/esm/utils/orderMath.js.map +0 -1
- package/dist/esm/utils/parse.d.ts +0 -28
- package/dist/esm/utils/parse.d.ts.map +0 -1
- package/dist/esm/utils/parse.js.map +0 -1
- package/dist/esm/utils/positionMath.d.ts +0 -120
- package/dist/esm/utils/positionMath.d.ts.map +0 -1
- package/dist/esm/utils/positionMath.js +0 -173
- package/dist/esm/utils/positionMath.js.map +0 -1
- package/dist/esm/utils/scaleToInteger.d.ts +0 -22
- package/dist/esm/utils/scaleToInteger.d.ts.map +0 -1
- package/dist/esm/utils/scaleToInteger.js +0 -34
- package/dist/esm/utils/scaleToInteger.js.map +0 -1
- package/dist/esm/utils/units.d.ts +0 -27
- package/dist/esm/utils/units.d.ts.map +0 -1
- package/dist/esm/utils/units.js +0 -38
- package/dist/esm/utils/units.js.map +0 -1
- package/dist/esm/utils/validation.d.ts +0 -18
- package/dist/esm/utils/validation.d.ts.map +0 -1
- package/dist/esm/utils/validation.js +0 -29
- package/dist/esm/utils/validation.js.map +0 -1
- package/dist/types/utils/calculations.d.ts.map +0 -1
- package/dist/types/utils/decimal.d.ts.map +0 -1
- package/dist/types/utils/fillClassification.d.ts +0 -13
- package/dist/types/utils/fillClassification.d.ts.map +0 -1
- package/dist/types/utils/format.d.ts.map +0 -1
- package/dist/types/utils/math.d.ts +0 -6
- package/dist/types/utils/math.d.ts.map +0 -1
- package/dist/types/utils/orderEntry.d.ts +0 -26
- package/dist/types/utils/orderEntry.d.ts.map +0 -1
- package/dist/types/utils/orderMath.d.ts +0 -37
- package/dist/types/utils/orderMath.d.ts.map +0 -1
- package/dist/types/utils/parse.d.ts +0 -28
- package/dist/types/utils/parse.d.ts.map +0 -1
- package/dist/types/utils/positionMath.d.ts +0 -120
- package/dist/types/utils/positionMath.d.ts.map +0 -1
- package/dist/types/utils/scaleToInteger.d.ts +0 -22
- package/dist/types/utils/scaleToInteger.d.ts.map +0 -1
- package/dist/types/utils/units.d.ts +0 -27
- package/dist/types/utils/units.d.ts.map +0 -1
- package/dist/types/utils/validation.d.ts +0 -18
- package/dist/types/utils/validation.d.ts.map +0 -1
- package/src/utils/math.ts +0 -7
- package/src/utils/orderEntry.ts +0 -38
- package/src/utils/orderMath.ts +0 -152
- package/src/utils/positionMath.ts +0 -209
- package/src/utils/scaleToInteger.ts +0 -56
- package/src/utils/units.ts +0 -39
- package/src/utils/validation.ts +0 -38
- /package/dist/cjs/{utils → decimal}/format.d.ts +0 -0
- /package/dist/cjs/{utils → decimal}/format.js +0 -0
- /package/dist/esm/{utils → decimal}/format.d.ts +0 -0
- /package/dist/esm/{utils → decimal}/format.js +0 -0
- /package/dist/types/{utils → decimal}/format.d.ts +0 -0
- /package/src/{utils/decimal.ts → decimal/big.ts} +0 -0
- /package/src/{utils → decimal}/format.ts +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DecimalString, Market } from '@lifi/perps-types';
|
|
2
|
+
import type { PerpsSDKClient } from '../types/provider.js';
|
|
3
|
+
/** @public */
|
|
4
|
+
export interface OrderAmountsInput {
|
|
5
|
+
sdk: PerpsSDKClient;
|
|
6
|
+
market: Market;
|
|
7
|
+
/** The field the user typed; the other two are calculated from it. */
|
|
8
|
+
held: 'margin' | 'size' | 'notional';
|
|
9
|
+
amount: DecimalString;
|
|
10
|
+
leverage: number;
|
|
11
|
+
price: DecimalString;
|
|
12
|
+
}
|
|
13
|
+
/** @public */
|
|
14
|
+
export interface OrderAmounts {
|
|
15
|
+
/**
|
|
16
|
+
* The held `amount`, byte-identical, when the user holds the margin;
|
|
17
|
+
* otherwise `notional ÷ leverage`, a display and comparison value that
|
|
18
|
+
* never reaches a venue.
|
|
19
|
+
*/
|
|
20
|
+
margin: DecimalString;
|
|
21
|
+
/** Snapped onto the venue lot grid; the one amount an order sends. */
|
|
22
|
+
size: DecimalString;
|
|
23
|
+
/** Exactly `size × price`, from the snapped size. */
|
|
24
|
+
notional: DecimalString;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The three order-entry amounts, derived from whichever one the user typed.
|
|
28
|
+
* Only `size` snaps, onto the market's venue lot grid, because an order sends
|
|
29
|
+
* size alone; no quote amount has a grid. A held margin returns byte-identical,
|
|
30
|
+
* `notional` is the snapped size × price, and a derived margin is
|
|
31
|
+
* `notional ÷ leverage` in `DivBig` (40 places, half-up).
|
|
32
|
+
*
|
|
33
|
+
* @returns `null` when `amount` or `price` is not a positive
|
|
34
|
+
* {@link DecimalString}, when `leverage` is not a positive finite number, or
|
|
35
|
+
* when the snapped size is zero (below one lot).
|
|
36
|
+
* @throws {PerpsError} `SDKError` when `market.providerId` names no registered
|
|
37
|
+
* provider plugin.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function calculateOrderAmounts(input: OrderAmountsInput): OrderAmounts | null;
|
|
41
|
+
//# sourceMappingURL=orderAmounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderAmounts.d.ts","sourceRoot":"","sources":["../../../src/wire/orderAmounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAI9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG1D,cAAc;AACd,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,sEAAsE;IACtE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAA;IACpC,MAAM,EAAE,aAAa,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,aAAa,CAAA;CACrB;AAED,cAAc;AACd,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,EAAE,aAAa,CAAA;IACrB,sEAAsE;IACtE,IAAI,EAAE,aAAa,CAAA;IACnB,qDAAqD;IACrD,QAAQ,EAAE,aAAa,CAAA;CACxB;AAUD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,iBAAiB,GACvB,YAAY,GAAG,IAAI,CAiCrB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import Big from 'big.js';
|
|
2
|
+
import { DivBig, TruncBig } from '../decimal/big.js';
|
|
3
|
+
import { isDecimalString } from '../decimal/parse.js';
|
|
4
|
+
import { snapOrderSize } from './snap.js';
|
|
5
|
+
function positiveDecimal(value) {
|
|
6
|
+
if (!isDecimalString(value)) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const parsed = new TruncBig(value);
|
|
10
|
+
return parsed.gt(0) ? parsed : null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The three order-entry amounts, derived from whichever one the user typed.
|
|
14
|
+
* Only `size` snaps, onto the market's venue lot grid, because an order sends
|
|
15
|
+
* size alone; no quote amount has a grid. A held margin returns byte-identical,
|
|
16
|
+
* `notional` is the snapped size × price, and a derived margin is
|
|
17
|
+
* `notional ÷ leverage` in `DivBig` (40 places, half-up).
|
|
18
|
+
*
|
|
19
|
+
* @returns `null` when `amount` or `price` is not a positive
|
|
20
|
+
* {@link DecimalString}, when `leverage` is not a positive finite number, or
|
|
21
|
+
* when the snapped size is zero (below one lot).
|
|
22
|
+
* @throws {PerpsError} `SDKError` when `market.providerId` names no registered
|
|
23
|
+
* provider plugin.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export function calculateOrderAmounts(input) {
|
|
27
|
+
const { sdk, market, held, leverage } = input;
|
|
28
|
+
const amount = positiveDecimal(input.amount);
|
|
29
|
+
const price = positiveDecimal(input.price);
|
|
30
|
+
if (amount === null ||
|
|
31
|
+
price === null ||
|
|
32
|
+
!Number.isFinite(leverage) ||
|
|
33
|
+
leverage <= 0) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const requested = held === 'size'
|
|
37
|
+
? input.amount
|
|
38
|
+
: held === 'notional'
|
|
39
|
+
? amount.div(price).toFixed()
|
|
40
|
+
: amount.times(leverage).div(price).toFixed();
|
|
41
|
+
const size = snapOrderSize(sdk, market, requested);
|
|
42
|
+
if (new Big(size).eq(0)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const notional = new TruncBig(size).times(price);
|
|
46
|
+
return {
|
|
47
|
+
margin: held === 'margin'
|
|
48
|
+
? input.amount
|
|
49
|
+
: new DivBig(notional).div(leverage).toFixed(),
|
|
50
|
+
size,
|
|
51
|
+
notional: notional.toFixed(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=orderAmounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderAmounts.js","sourceRoot":"","sources":["../../../src/wire/orderAmounts.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AA2BzC,SAAS,eAAe,CAAC,KAAoB;IAC3C,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAA;IAClC,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;AACrC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAwB;IAExB,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC7C,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAC1C,IACE,MAAM,KAAK,IAAI;QACf,KAAK,KAAK,IAAI;QACd,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC1B,QAAQ,IAAI,CAAC,EACb,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,SAAS,GACb,IAAI,KAAK,MAAM;QACb,CAAC,CAAC,KAAK,CAAC,MAAM;QACd,CAAC,CAAC,IAAI,KAAK,UAAU;YACnB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE;YAC7B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;IACnD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IAClD,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAChD,OAAO;QACL,MAAM,EACJ,IAAI,KAAK,QAAQ;YACf,CAAC,CAAC,KAAK,CAAC,MAAM;YACd,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;QAClD,IAAI;QACJ,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE;KAC7B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type DecimalString } from '@lifi/perps-types';
|
|
2
|
+
/** @public */
|
|
3
|
+
export interface RefuelAmountInput {
|
|
4
|
+
/** USD value of the gas the route recommends. */
|
|
5
|
+
gasUsd: DecimalString;
|
|
6
|
+
/** USD price of one whole source token. */
|
|
7
|
+
priceUsd: DecimalString;
|
|
8
|
+
/** Decimals of the source token, which the result is spelled to exactly. */
|
|
9
|
+
decimals: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Source-token amount whose USD value covers `gasUsd`, rounded **up** onto
|
|
13
|
+
* the token's decimal grid so a refuel never lands short of the
|
|
14
|
+
* recommendation. The result keeps trailing zeros to `decimals`, so it seeds
|
|
15
|
+
* an amount input at the token's own precision.
|
|
16
|
+
*
|
|
17
|
+
* The quotient does not terminate for most prices, which is why this is a
|
|
18
|
+
* big.js primitive: an 18-decimal token needs a ceiling at 10^-18, far past
|
|
19
|
+
* what a `number` can carry.
|
|
20
|
+
*
|
|
21
|
+
* @returns `undefined` when `gasUsd` or `priceUsd` is not greater than zero,
|
|
22
|
+
* which is a route with nothing to refuel rather than a failure.
|
|
23
|
+
* @throws {PerpsError} `ValidationError` when `gasUsd` or `priceUsd` is not a
|
|
24
|
+
* {@link DecimalString}, or when `decimals` is not a non-negative integer.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare function calculateRefuelAmount(input: RefuelAmountInput): DecimalString | undefined;
|
|
28
|
+
//# sourceMappingURL=refuel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refuel.d.ts","sourceRoot":"","sources":["../../../src/wire/refuel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,mBAAmB,CAAA;AAKtE,cAAc;AACd,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,MAAM,EAAE,aAAa,CAAA;IACrB,2CAA2C;IAC3C,QAAQ,EAAE,aAAa,CAAA;IACvB,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,iBAAiB,GACvB,aAAa,GAAG,SAAS,CAiB3B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PerpsErrorCode } from '@lifi/perps-types';
|
|
2
|
+
import { DivBig } from '../decimal/big.js';
|
|
3
|
+
import { requireDecimal } from '../decimal/requireDecimal.js';
|
|
4
|
+
import { PerpsError } from '../errors/PerpsError.js';
|
|
5
|
+
/**
|
|
6
|
+
* Source-token amount whose USD value covers `gasUsd`, rounded **up** onto
|
|
7
|
+
* the token's decimal grid so a refuel never lands short of the
|
|
8
|
+
* recommendation. The result keeps trailing zeros to `decimals`, so it seeds
|
|
9
|
+
* an amount input at the token's own precision.
|
|
10
|
+
*
|
|
11
|
+
* The quotient does not terminate for most prices, which is why this is a
|
|
12
|
+
* big.js primitive: an 18-decimal token needs a ceiling at 10^-18, far past
|
|
13
|
+
* what a `number` can carry.
|
|
14
|
+
*
|
|
15
|
+
* @returns `undefined` when `gasUsd` or `priceUsd` is not greater than zero,
|
|
16
|
+
* which is a route with nothing to refuel rather than a failure.
|
|
17
|
+
* @throws {PerpsError} `ValidationError` when `gasUsd` or `priceUsd` is not a
|
|
18
|
+
* {@link DecimalString}, or when `decimals` is not a non-negative integer.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export function calculateRefuelAmount(input) {
|
|
22
|
+
const { decimals } = input;
|
|
23
|
+
if (!Number.isInteger(decimals) || decimals < 0) {
|
|
24
|
+
throw new PerpsError(PerpsErrorCode.ValidationError, `Invalid \`decimals\` for a refuel amount: ${decimals}`);
|
|
25
|
+
}
|
|
26
|
+
const gasUsd = requireDecimal(input.gasUsd, 'gasUsd');
|
|
27
|
+
const priceUsd = requireDecimal(input.priceUsd, 'priceUsd');
|
|
28
|
+
if (!gasUsd.gt(0) || !priceUsd.gt(0)) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return new DivBig(gasUsd)
|
|
32
|
+
.div(priceUsd)
|
|
33
|
+
.round(decimals, DivBig.roundUp)
|
|
34
|
+
.toFixed(decimals);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=refuel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refuel.js","sourceRoot":"","sources":["../../../src/wire/refuel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAYpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAwB;IAExB,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC1B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,UAAU,CAClB,cAAc,CAAC,eAAe,EAC9B,6CAA6C,QAAQ,EAAE,CACxD,CAAA;IACH,CAAC;IACD,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACrD,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IAC3D,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC;SACtB,GAAG,CAAC,QAAQ,CAAC;SACb,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC;SAC/B,OAAO,CAAC,QAAQ,CAAC,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DecimalString, Market } from '@lifi/perps-types';
|
|
2
|
+
import type { PerpsSDKClient } from '../types/provider.js';
|
|
3
|
+
/**
|
|
4
|
+
* Snap `size` onto the lot grid of `market`'s venue, truncating toward zero,
|
|
5
|
+
* through the market's own provider. Takes and gives a {@link DecimalString},
|
|
6
|
+
* so a caller never converts an order size to a `number`.
|
|
7
|
+
*
|
|
8
|
+
* @throws {PerpsError} `SDKError` when `market.providerId` names no registered
|
|
9
|
+
* provider plugin.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare function snapOrderSize(sdk: PerpsSDKClient, market: Market, size: DecimalString): DecimalString;
|
|
13
|
+
/**
|
|
14
|
+
* Snap `price` onto the tick grid of `market`'s venue, rounding half-up,
|
|
15
|
+
* through the market's own provider. Takes and gives a {@link DecimalString},
|
|
16
|
+
* so a caller never converts an order price to a `number`.
|
|
17
|
+
*
|
|
18
|
+
* @throws {PerpsError} `SDKError` when `market.providerId` names no registered
|
|
19
|
+
* provider plugin, or `ValidationError` when the market lacks the tick
|
|
20
|
+
* metadata the venue's rules need.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function snapOrderPrice(sdk: PerpsSDKClient, market: Market, price: DecimalString): DecimalString;
|
|
24
|
+
//# sourceMappingURL=snap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snap.d.ts","sourceRoot":"","sources":["../../../src/wire/snap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,GAClB,aAAa,CAEf;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,GACnB,aAAa,CAEf"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { requireProvider } from '../client/requireProvider.js';
|
|
2
|
+
/**
|
|
3
|
+
* Snap `size` onto the lot grid of `market`'s venue, truncating toward zero,
|
|
4
|
+
* through the market's own provider. Takes and gives a {@link DecimalString},
|
|
5
|
+
* so a caller never converts an order size to a `number`.
|
|
6
|
+
*
|
|
7
|
+
* @throws {PerpsError} `SDKError` when `market.providerId` names no registered
|
|
8
|
+
* provider plugin.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export function snapOrderSize(sdk, market, size) {
|
|
12
|
+
return requireProvider(sdk, market.providerId).snapOrderSize(market, size);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Snap `price` onto the tick grid of `market`'s venue, rounding half-up,
|
|
16
|
+
* through the market's own provider. Takes and gives a {@link DecimalString},
|
|
17
|
+
* so a caller never converts an order price to a `number`.
|
|
18
|
+
*
|
|
19
|
+
* @throws {PerpsError} `SDKError` when `market.providerId` names no registered
|
|
20
|
+
* provider plugin, or `ValidationError` when the market lacks the tick
|
|
21
|
+
* metadata the venue's rules need.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export function snapOrderPrice(sdk, market, price) {
|
|
25
|
+
return requireProvider(sdk, market.providerId).snapOrderPrice(market, price);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=snap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snap.js","sourceRoot":"","sources":["../../../src/wire/snap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAG9D;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAmB,EACnB,MAAc,EACd,IAAmB;IAEnB,OAAO,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAC5E,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAmB,EACnB,MAAc,EACd,KAAoB;IAEpB,OAAO,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAC9E,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DecimalString } from '@lifi/perps-types';
|
|
2
|
+
/**
|
|
3
|
+
* The part of `units` that a venue-wide free figure releases: never below
|
|
4
|
+
* zero, never above the units held. `Balance.transferable` on every provider
|
|
5
|
+
* is this clamp over the venue's own free-margin or unlocked-balance figure.
|
|
6
|
+
*
|
|
7
|
+
* @param venueFigure - The venue's free figure for the category, which can
|
|
8
|
+
* exceed `units` or fall below zero.
|
|
9
|
+
* @param units - Units held in the category, the upper bound of the clamp.
|
|
10
|
+
* @throws {PerpsError} `ValidationError` when either input is not a
|
|
11
|
+
* {@link DecimalString}, naming the field.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateTransferable(venueFigure: DecimalString, units: DecimalString): DecimalString;
|
|
15
|
+
//# sourceMappingURL=transferable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transferable.d.ts","sourceRoot":"","sources":["../../../src/wire/transferable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGtD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,aAAa,EAC1B,KAAK,EAAE,aAAa,GACnB,aAAa,CAOf"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { requireDecimal } from '../decimal/requireDecimal.js';
|
|
2
|
+
/**
|
|
3
|
+
* The part of `units` that a venue-wide free figure releases: never below
|
|
4
|
+
* zero, never above the units held. `Balance.transferable` on every provider
|
|
5
|
+
* is this clamp over the venue's own free-margin or unlocked-balance figure.
|
|
6
|
+
*
|
|
7
|
+
* @param venueFigure - The venue's free figure for the category, which can
|
|
8
|
+
* exceed `units` or fall below zero.
|
|
9
|
+
* @param units - Units held in the category, the upper bound of the clamp.
|
|
10
|
+
* @throws {PerpsError} `ValidationError` when either input is not a
|
|
11
|
+
* {@link DecimalString}, naming the field.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export function calculateTransferable(venueFigure, units) {
|
|
15
|
+
const figure = requireDecimal(venueFigure, 'venueFigure');
|
|
16
|
+
const held = requireDecimal(units, 'units');
|
|
17
|
+
if (figure.lt(0)) {
|
|
18
|
+
return '0';
|
|
19
|
+
}
|
|
20
|
+
return (figure.gt(held) ? held : figure).toFixed();
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=transferable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transferable.js","sourceRoot":"","sources":["../../../src/wire/transferable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAE7D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAA0B,EAC1B,KAAoB;IAEpB,MAAM,MAAM,GAAG,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;IACzD,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC3C,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DecimalString } from '@lifi/perps-types';
|
|
2
|
+
import type { WithdrawableBalance } from '../types/withdrawal.js';
|
|
3
|
+
/**
|
|
4
|
+
* Largest `amount` a withdrawable row can fund: `available` when the venue
|
|
5
|
+
* deducts the fee from the amount or publishes no fee, and
|
|
6
|
+
* `available − withdrawalFee` floored at zero when the venue charges the fee
|
|
7
|
+
* on top (`isFeeDeducted === false`).
|
|
8
|
+
*
|
|
9
|
+
* @throws {PerpsError} `ValidationError` when `available` or `withdrawalFee`
|
|
10
|
+
* is not a {@link DecimalString}, naming the field.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function calculateWithdrawMax(row: Pick<WithdrawableBalance, 'available' | 'withdrawalFee' | 'isFeeDeducted'>): DecimalString;
|
|
14
|
+
//# sourceMappingURL=withdraw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdraw.d.ts","sourceRoot":"","sources":["../../../src/wire/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAEjE;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,IAAI,CACP,mBAAmB,EACnB,WAAW,GAAG,eAAe,GAAG,eAAe,CAChD,GACA,aAAa,CASf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { requireDecimal } from '../decimal/requireDecimal.js';
|
|
2
|
+
/**
|
|
3
|
+
* Largest `amount` a withdrawable row can fund: `available` when the venue
|
|
4
|
+
* deducts the fee from the amount or publishes no fee, and
|
|
5
|
+
* `available − withdrawalFee` floored at zero when the venue charges the fee
|
|
6
|
+
* on top (`isFeeDeducted === false`).
|
|
7
|
+
*
|
|
8
|
+
* @throws {PerpsError} `ValidationError` when `available` or `withdrawalFee`
|
|
9
|
+
* is not a {@link DecimalString}, naming the field.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export function calculateWithdrawMax(row) {
|
|
13
|
+
const available = requireDecimal(row.available, 'available');
|
|
14
|
+
if (row.isFeeDeducted !== false || row.withdrawalFee === undefined) {
|
|
15
|
+
return available.toFixed();
|
|
16
|
+
}
|
|
17
|
+
const funded = available.minus(requireDecimal(row.withdrawalFee, 'withdrawalFee'));
|
|
18
|
+
return funded.gt(0) ? funded.toFixed() : '0';
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=withdraw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdraw.js","sourceRoot":"","sources":["../../../src/wire/withdraw.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAG7D;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAGC;IAED,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;IAC5D,IAAI,GAAG,CAAC,aAAa,KAAK,KAAK,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACnE,OAAO,SAAS,CAAC,OAAO,EAAE,CAAA;IAC5B,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAC5B,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,eAAe,CAAC,CACnD,CAAA;IACD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;AAC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PerpsClient.d.ts","sourceRoot":"","sources":["../../../src/client/PerpsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,cAAc,EACd,eAAe,EAEf,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,EACL,cAAc,EACd,wBAAwB,EACxB,QAAQ,EAGR,WAAW,EACX,WAAW,EAEZ,MAAM,mBAAmB,CAAA;A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M,EAAE,SAAS,CAAA;QACjB,MAAM,EAAE,KAAK,GAAG,QAAQ,CAAA;QACxB,MAAM,EAAE,MAAM,CAAA;KACf,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQlC;;;;;;;OAOG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAStE;;;;;;;;;OASG;IACG,SAAS,CACb,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAUjC;;;;;;;;;OASG;IACG,OAAO,CAAC,CAAC,SAAS,UAAU,EAAE,MAAM,EAAE;QAC1C,QAAQ,EAAE,MAAM,CAAA;QAChB,OAAO,EAAE,OAAO,CAAA;QAChB,MAAM,EAAE,CAAC,CAAA;QACT,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;QAC1B;sEAC8D;QAC9D,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAA;KACpD,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKlC,uEAAuE;YACzD,SAAS;IAyDvB;;;;;;;;;;;;OAYG;IACG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,qBAAqB,CAAC;IASjC;;;;;;;;OAQG;IACG,kBAAkB,CACtB,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,qBAAqB,CAAC;IASjC;;;;;;;;;;;;;;;OAeG;IACG,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAC9C,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACjC,OAAO,CAAC,qBAAqB,CAAC;CA+ClC"}
|
|
@@ -11,4 +11,4 @@ export declare const DivBig: Big.BigConstructor;
|
|
|
11
11
|
export declare const TruncBig: Big.BigConstructor;
|
|
12
12
|
/** True when every value is a finite number, so `new DivBig(value)` cannot throw. */
|
|
13
13
|
export declare function areFinite(...values: number[]): boolean;
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=big.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"big.d.ts","sourceRoot":"","sources":["../../../src/decimal/big.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;AAExB;;;GAGG;AACH,eAAO,MAAM,MAAM,oBAAQ,CAAA;AAG3B;;;GAGG;AACH,eAAO,MAAM,QAAQ,oBAAQ,CAAA;AAI7B,qFAAqF;AACrF,wBAAgB,SAAS,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAEtD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type DecimalString } from '@lifi/perps-types';
|
|
2
|
+
/**
|
|
3
|
+
* Off-grid resolution for {@link decimalToBaseUnits}:
|
|
4
|
+
* - `truncate` — toward zero, for sizes and collateral amounts. The wire
|
|
5
|
+
* value never exceeds the caller's intent.
|
|
6
|
+
* - `round` — half away from zero, for prices, which snap to the nearest
|
|
7
|
+
* tick.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type BaseUnitsRounding = 'truncate' | 'round';
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `BaseUnitsRounding`. Removed in the next major.
|
|
13
|
+
*/
|
|
14
|
+
export type ScaleToIntegerPolicy = BaseUnitsRounding;
|
|
15
|
+
/**
|
|
16
|
+
* Scale a decimal string to a scaled integer in exact decimal arithmetic — an
|
|
17
|
+
* on-grid input maps to its exact scaled integer with no binary float
|
|
18
|
+
* artifacts (`'0.29'` at 2 decimals is 29, never 28). Off-grid input resolves
|
|
19
|
+
* per `rounding`; there is no silent default.
|
|
20
|
+
*
|
|
21
|
+
* @throws {PerpsError} `ValidationError` when `value` is not a
|
|
22
|
+
* {@link DecimalString}, `decimals` is not a non-negative integer, or the scaled
|
|
23
|
+
* result's magnitude exceeds `Number.MAX_SAFE_INTEGER`.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare const decimalToBaseUnits: (value: DecimalString, decimals: number, rounding: BaseUnitsRounding) => number;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use `decimalToBaseUnits`. Removed in the next major.
|
|
29
|
+
*/
|
|
30
|
+
export declare const scaleToInteger: (value: DecimalString, decimals: number, rounding: BaseUnitsRounding) => number;
|
|
31
|
+
/**
|
|
32
|
+
* Convert a base-unit amount (bigint string) to a decimal string.
|
|
33
|
+
*
|
|
34
|
+
* @param amount - Amount in base units (e.g. "1000000" for 1 USDC)
|
|
35
|
+
* @param decimals - Token decimals (e.g. 6 for USDC)
|
|
36
|
+
* @returns Decimal string; `"0"` when `amount` is not a valid bigint
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* baseUnitsToDecimal('1000000', 6) // '1'
|
|
40
|
+
* ```
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare function baseUnitsToDecimal(amount: string, decimals: number): DecimalString;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `baseUnitsToDecimal`. Removed in the next major.
|
|
46
|
+
*/
|
|
47
|
+
export declare const fromBaseUnits: typeof baseUnitsToDecimal;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Compose `parseDecimal(baseUnitsToDecimal(...))`. Removed in the
|
|
50
|
+
* next major.
|
|
51
|
+
*/
|
|
52
|
+
export declare function fromBaseUnitsNumber(amount: string, decimals: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Round `value` down to `decimals` and pad the result to exactly that many
|
|
55
|
+
* decimal places. The padding is the point: this seeds a fixed-decimal input,
|
|
56
|
+
* where `'500.00'` and `'500'` are two renderings of one amount and the field
|
|
57
|
+
* wants the first. For a canonical wire amount with no trailing zeros, read
|
|
58
|
+
* the amount off `calculateOrderAmounts` or a provider snap instead.
|
|
59
|
+
*
|
|
60
|
+
* Exact decimal arithmetic throughout, so there is no 2^53 ceiling and no
|
|
61
|
+
* float artifact: `'0.01'` at 18 decimals gives
|
|
62
|
+
* `'0.010000000000000000'`, which `Number#toFixed` cannot.
|
|
63
|
+
*
|
|
64
|
+
* @throws {PerpsError} `ValidationError` when `value` is not a
|
|
65
|
+
* {@link DecimalString}, or `decimals` is not a non-negative integer.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare function truncateDecimal(value: DecimalString, decimals: number): DecimalString;
|
|
69
|
+
/**
|
|
70
|
+
* Spell a `number` as a {@link DecimalString} in plain notation: `1e-7`
|
|
71
|
+
* becomes `'0.0000001'`, never `'1e-7'`. The boundary helper for a venue or
|
|
72
|
+
* browser API that hands out numbers; a value already spelled as a decimal
|
|
73
|
+
* string must not round-trip through here, because above 15 significant
|
|
74
|
+
* digits the `number` has already lost digits.
|
|
75
|
+
*
|
|
76
|
+
* @throws {PerpsError} `ValidationError` when `value` is `NaN` or infinite.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare function numberToDecimalString(value: number): DecimalString;
|
|
80
|
+
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/decimal/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,mBAAmB,CAAA;AAOtE;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,OAAO,CAAA;AAEpD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAA;AAEpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,aAAa,EACpB,UAAU,MAAM,EAChB,UAAU,iBAAiB,KAC1B,MAiBF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,UAzBlB,aAAa,YACV,MAAM,YACN,iBAAiB,KAC1B,MAsB6C,CAAA;AAEhD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,QAAQ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H,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAaR;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAqBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAkBR"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type DecimalString } from '@lifi/perps-types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a string to a float, stripping common formatting artefacts.
|
|
4
|
+
*
|
|
5
|
+
* Handles:
|
|
6
|
+
* - Currency prefixes/suffixes ($, USD, etc.)
|
|
7
|
+
* - Explicit sign prefixes (+/-)
|
|
8
|
+
* - Thousands separators (commas)
|
|
9
|
+
* - Percentage suffixes (%)
|
|
10
|
+
* - Whitespace
|
|
11
|
+
*
|
|
12
|
+
* @returns Parsed number; `0` for empty/blank input, `NaN` when a non-empty
|
|
13
|
+
* string contains no parseable number
|
|
14
|
+
*/
|
|
15
|
+
declare function toFloat(value: string): number;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `parseDecimal`. Removed in the next major.
|
|
18
|
+
*/
|
|
19
|
+
export declare const stringToFloat: typeof toFloat;
|
|
20
|
+
/**
|
|
21
|
+
* Parse an optional decimal field, tolerating currency symbols, grouping
|
|
22
|
+
* separators and a percentage suffix around the number.
|
|
23
|
+
* Gives back `undefined` for a missing, malformed or non-finite value, and `0` for an empty string.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseDecimal(value: DecimalString | string | null | undefined): number | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Narrows an unknown value to a {@link DecimalString}.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare function isDecimalString(value: unknown): value is DecimalString;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/decimal/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEvE;;;;;;;;;;;;GAYG;AACH,iBAAS,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAStC;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,gBAAU,CAAA;AAKpC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAC/C,MAAM,GAAG,SAAS,CAYpB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DecimalString } from '@lifi/perps-types';
|
|
2
|
+
import Big from 'big.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parse a decimal input, naming the field it came from when the
|
|
5
|
+
* value breaks the {@link DecimalString} contract, so a malformed amount
|
|
6
|
+
* fails at the SDK boundary instead of inside big.js.
|
|
7
|
+
*
|
|
8
|
+
* @throws {PerpsError} `ValidationError` naming `field`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function requireDecimal(value: DecimalString, field: string): Big;
|
|
11
|
+
//# sourceMappingURL=requireDecimal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requireDecimal.d.ts","sourceRoot":"","sources":["../../../src/decimal/requireDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,mBAAmB,CAAA;AACtE,OAAO,GAAG,MAAM,QAAQ,CAAA;AAIxB;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAQvE"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,8 +10,17 @@ export * from '@lifi/perps-types';
|
|
|
10
10
|
export { createPerpsClient, DEFAULT_API_URL, } from './client/createPerpsClient.js';
|
|
11
11
|
export { PerpsClient } from './client/PerpsClient.js';
|
|
12
12
|
export { requireProvider } from './client/requireProvider.js';
|
|
13
|
+
export type { BaseUnitsRounding, ScaleToIntegerPolicy, } from './decimal/convert.js';
|
|
14
|
+
export { baseUnitsToDecimal, decimalToBaseUnits, fromBaseUnits, fromBaseUnitsNumber, numberToDecimalString, scaleToInteger, truncateDecimal, } from './decimal/convert.js';
|
|
15
|
+
export type { FormatOptions, RoundingMode } from './decimal/format.js';
|
|
16
|
+
export { formatCompactUsd, formatNumber, formatPrice, formatSignedPercent, formatSignedUsd, formatUsd, } from './decimal/format.js';
|
|
17
|
+
export { isDecimalString, parseDecimal, stringToFloat, } from './decimal/parse.js';
|
|
13
18
|
export { PerpsErrorMessage } from './errors/constants.js';
|
|
14
19
|
export { PerpsError } from './errors/PerpsError.js';
|
|
20
|
+
export { classifyFill, classifyFillFromPosition, FillClassification, } from './math/fills.js';
|
|
21
|
+
export type { ExpectedPnl } from './math/order.js';
|
|
22
|
+
export { applySlippage, buildQuote, calculateExpectedPnl, calculatePositionSize, calculateRealizedPnlPercent, calculateSize, calculateTriggerPercent, calculateTriggerPrice, estimateFees, estimateRealizedPnl, expectedRealizedPnlForOpenOrder, expectedRealizedPnlForTriggerOrder, findMatchingPosition, percentFromPrice, priceFromPercent, resolveCloseSize, walkOrderbook, } from './math/order.js';
|
|
23
|
+
export { calculateEffectiveLeverage, calculateLiquidationDistance, calculateNotionalValue, calculateRealizedPnl, calculateRequiredMargin, calculateRoe, calculateUnrealizedPnl, directionSign, effectiveLeverage, estimateAverageEntryPrice, estimateIsolatedLiquidationPrice, estimateLiquidationPrice, estimateNewLeverage, estimateUnrealizedPnl, liquidationDistancePercent, positionSupportsMarginAdjustment, positionSupportsMarginRemoval, predictAverageEntryPrice, predictNewLeverage, predictUnrealizedPnl, realizedPnlOnClose, wouldImmediatelyLiquidate, } from './math/position.js';
|
|
15
24
|
export { AssetRegistry, getAssetRegistry, toAssetDisplay, } from './registry/assetRegistry.js';
|
|
16
25
|
export type { DefaultMarketProvider } from './registry/marketRegistry.js';
|
|
17
26
|
export { DEFAULT_MARKET_ID, getDefaultMarketId, getMarketRegistry, isActiveMarket, MarketRegistry, toMarketDisplay, toPerpsMarketDisplay, } from './registry/marketRegistry.js';
|
|
@@ -71,25 +80,11 @@ export type { DeclaredDepositAsset, DepositFlow, DepositFlowFirstDepositPipeline
|
|
|
71
80
|
export type { ActionSignerContribution, LiquidationEstimateParams, PerpsProvider, PerpsProviderPlugin, PerpsSDKClient, ProviderAccountExistsParams, ProviderGetAccountParams, ProviderGetActivityParams, ProviderGetAvailableToTradeParams, ProviderGetDepositFlowParams, ProviderGetFillsParams, ProviderGetMarketSettingsParams, ProviderGetOrderParams, ProviderGetOrdersParams, ProviderGetPortfolioHistoryParams, ProviderGetPositionsParams, ProviderGetQuoteParams, ProviderGetWithdrawableBalancesParams, ProviderGetWithdrawFlowParams, QuoteListener, SignActionProgress, SignActionsContext, } from './types/provider.js';
|
|
72
81
|
export type { ProviderWithdrawableBalance, WithdrawableBalance, WithdrawalRoute, WithdrawFlow, WithdrawFlowReady, WithdrawFlowSetupRequired, } from './types/withdrawal.js';
|
|
73
82
|
export { paginateActivity } from './utils/activityPaging.js';
|
|
74
|
-
export type { ExpectedPnl } from './utils/calculations.js';
|
|
75
|
-
export { applySlippage, buildQuote, calculateExpectedPnl, calculateNotionalValue, calculatePositionSize, calculateRealizedPnlPercent, calculateRequiredMargin, calculateRoe, calculateUnrealizedPnl, effectiveLeverage, estimateFees, liquidationDistancePercent, percentFromPrice, priceFromPercent, walkOrderbook, } from './utils/calculations.js';
|
|
76
83
|
export { ETHEREUM_NATIVE_GAS, ETHEREUM_USDC, HYPERLIQUID_USDC, LIGHTER_USDC, ROBINHOOD_NATIVE_GAS, ROBINHOOD_USDG, } from './utils/depositAssets.js';
|
|
77
84
|
export { ExplorerChainId, explorerTxUrl, explorerTxUrlFromBase, } from './utils/explorer.js';
|
|
78
|
-
export {
|
|
79
|
-
export type { FormatOptions, RoundingMode } from './utils/format.js';
|
|
80
|
-
export { formatCompactUsd, formatNumber, formatPrice, formatSignedPercent, formatSignedUsd, formatUsd, } from './utils/format.js';
|
|
81
|
-
export { maxOf, minOf } from './utils/math.js';
|
|
82
|
-
export { ACTIVE_ORDER_STATUSES, classifyFill, FillClassification, isActiveOrderStatus, isRegularOrder, isStopLossOrder, isTakeProfitOrder, isTpSlOrder, isTriggerOrder, isTwapOrder, triggerConditionFor, } from './utils/orderClassification.js';
|
|
83
|
-
export { marginFromNotional, marginFromSize, sizeFromMargin, sizeFromNotional, } from './utils/orderEntry.js';
|
|
84
|
-
export { expectedRealizedPnlForOpenOrder, expectedRealizedPnlForTriggerOrder, findMatchingPosition, resolveCloseSize, } from './utils/orderMath.js';
|
|
85
|
-
export { parseDecimal, stringToFloat } from './utils/parse.js';
|
|
86
|
-
export { directionSign, estimateIsolatedLiquidationPrice, predictAverageEntryPrice, predictNewLeverage, predictUnrealizedPnl, realizedPnlOnClose, wouldImmediatelyLiquidate, } from './utils/positionMath.js';
|
|
87
|
-
export type { ScaleToIntegerPolicy } from './utils/scaleToInteger.js';
|
|
88
|
-
export { scaleToInteger } from './utils/scaleToInteger.js';
|
|
85
|
+
export { ACTIVE_ORDER_STATUSES, isActiveOrderStatus, isRegularOrder, isStopLossOrder, isTakeProfitOrder, isTpSlOrder, isTriggerOrder, isTwapOrder, triggerConditionFor, } from './utils/orderClassification.js';
|
|
89
86
|
export { isSetupOptionFor, selectUserSetupActions, } from './utils/setupActions.js';
|
|
90
87
|
export { signTypedData, signTypedDataWithSigner, } from './utils/signTypedData.js';
|
|
91
|
-
export { fromBaseUnits, fromBaseUnitsNumber } from './utils/units.js';
|
|
92
|
-
export { validateMargin } from './utils/validation.js';
|
|
93
88
|
export { createWarnOnce } from './utils/warnOnce.js';
|
|
94
89
|
export { name, version } from './version.js';
|
|
95
90
|
export { cachePromise } from './websocket/cachePromise.js';
|
|
@@ -102,4 +97,11 @@ export { ReconnectingWebSocket } from './websocket/ReconnectingWebSocket.js';
|
|
|
102
97
|
export type { EventForSubscription, SubscriptionListener, WsConnectionStatus, WsProvider, WsStatusListener, } from './websocket/types.js';
|
|
103
98
|
export { WS_CHANNEL_TEARDOWN_LINGER_MS, WsProviderBase, } from './websocket/WsProviderBase.js';
|
|
104
99
|
export { wsLog } from './websocket/wsLog.js';
|
|
100
|
+
export type { OrderAmounts, OrderAmountsInput, } from './wire/orderAmounts.js';
|
|
101
|
+
export { calculateOrderAmounts } from './wire/orderAmounts.js';
|
|
102
|
+
export type { RefuelAmountInput } from './wire/refuel.js';
|
|
103
|
+
export { calculateRefuelAmount } from './wire/refuel.js';
|
|
104
|
+
export { snapOrderPrice, snapOrderSize } from './wire/snap.js';
|
|
105
|
+
export { calculateTransferable } from './wire/transferable.js';
|
|
106
|
+
export { calculateWithdrawMax } from './wire/withdraw.js';
|
|
105
107
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,cAAc,mBAAmB,CAAA;AACjC,OAAO,EACL,iBAAiB,EACjB,eAAe,GAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":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