@lifi/perps-sdk 24.0.0 → 25.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/README.md +34 -28
- package/dist/cjs/decimal/arithmetic.d.ts +2 -0
- package/dist/cjs/decimal/arithmetic.d.ts.map +1 -1
- package/dist/cjs/decimal/arithmetic.js +6 -1
- package/dist/cjs/decimal/arithmetic.js.map +1 -1
- package/dist/cjs/decimal/convert.d.ts +0 -2
- package/dist/cjs/decimal/convert.d.ts.map +1 -1
- package/dist/cjs/decimal/convert.js +2 -11
- package/dist/cjs/decimal/convert.js.map +1 -1
- package/dist/cjs/decimal/decimalStringToBig.d.ts.map +1 -1
- package/dist/cjs/decimal/decimalStringToBig.js +3 -5
- package/dist/cjs/decimal/decimalStringToBig.js.map +1 -1
- package/dist/cjs/decimal/parse.d.ts +1 -0
- package/dist/cjs/decimal/parse.d.ts.map +1 -1
- package/dist/cjs/decimal/parse.js +2 -1
- package/dist/cjs/decimal/parse.js.map +1 -1
- package/dist/cjs/errors/invalidInput.d.ts +3 -0
- package/dist/cjs/errors/invalidInput.d.ts.map +1 -0
- package/dist/cjs/errors/invalidInput.js +9 -0
- package/dist/cjs/errors/invalidInput.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +10 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/math/order.d.ts +4 -4
- package/dist/cjs/math/order.d.ts.map +1 -1
- package/dist/cjs/math/order.js +31 -18
- package/dist/cjs/math/order.js.map +1 -1
- package/dist/cjs/math/position.d.ts +3 -3
- package/dist/cjs/math/position.d.ts.map +1 -1
- package/dist/cjs/math/position.js +13 -11
- package/dist/cjs/math/position.js.map +1 -1
- package/dist/cjs/types/provider.d.ts.map +1 -1
- package/dist/cjs/utils/warnOnce.d.ts +6 -2
- package/dist/cjs/utils/warnOnce.d.ts.map +1 -1
- package/dist/cjs/utils/warnOnce.js +12 -6
- package/dist/cjs/utils/warnOnce.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/websocket/wsLog.d.ts +1 -1
- package/dist/cjs/websocket/wsLog.d.ts.map +1 -1
- package/dist/cjs/websocket/wsLog.js +4 -3
- package/dist/cjs/websocket/wsLog.js.map +1 -1
- package/dist/cjs/wire/orderAmounts.d.ts +3 -2
- package/dist/cjs/wire/orderAmounts.d.ts.map +1 -1
- package/dist/cjs/wire/orderAmounts.js +17 -13
- package/dist/cjs/wire/orderAmounts.js.map +1 -1
- package/dist/cjs/wire/refuel.js +2 -2
- package/dist/cjs/wire/refuel.js.map +1 -1
- package/dist/esm/decimal/arithmetic.d.ts +24 -10
- package/dist/esm/decimal/arithmetic.d.ts.map +1 -1
- package/dist/esm/decimal/arithmetic.js +26 -10
- package/dist/esm/decimal/arithmetic.js.map +1 -1
- package/dist/esm/decimal/compare.d.ts +3 -3
- package/dist/esm/decimal/compare.js +3 -3
- package/dist/esm/decimal/convert.d.ts +2 -24
- package/dist/esm/decimal/convert.d.ts.map +1 -1
- package/dist/esm/decimal/convert.js +3 -32
- package/dist/esm/decimal/convert.js.map +1 -1
- package/dist/esm/decimal/decimalStringToBig.d.ts +4 -5
- package/dist/esm/decimal/decimalStringToBig.d.ts.map +1 -1
- package/dist/esm/decimal/decimalStringToBig.js +7 -10
- package/dist/esm/decimal/decimalStringToBig.js.map +1 -1
- package/dist/esm/decimal/format.js +3 -3
- package/dist/esm/decimal/parse.d.ts +8 -1
- package/dist/esm/decimal/parse.d.ts.map +1 -1
- package/dist/esm/decimal/parse.js +8 -1
- package/dist/esm/decimal/parse.js.map +1 -1
- package/dist/esm/errors/invalidInput.d.ts +4 -0
- package/dist/esm/errors/invalidInput.d.ts.map +1 -0
- package/dist/esm/errors/invalidInput.js +7 -0
- package/dist/esm/errors/invalidInput.js.map +1 -0
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/math/fills.d.ts +4 -4
- package/dist/esm/math/fills.js +4 -4
- package/dist/esm/math/order.d.ts +24 -26
- package/dist/esm/math/order.d.ts.map +1 -1
- package/dist/esm/math/order.js +52 -41
- package/dist/esm/math/order.js.map +1 -1
- package/dist/esm/math/position.d.ts +27 -27
- package/dist/esm/math/position.d.ts.map +1 -1
- package/dist/esm/math/position.js +38 -36
- package/dist/esm/math/position.js.map +1 -1
- package/dist/esm/services/resolveSubscribeQuote.d.ts +1 -1
- package/dist/esm/services/resolveSubscribeQuote.js +1 -1
- package/dist/esm/types/provider.d.ts +4 -3
- package/dist/esm/types/provider.d.ts.map +1 -1
- package/dist/esm/utils/createSafeFunction.d.ts +1 -1
- package/dist/esm/utils/createSafeFunction.js +1 -1
- package/dist/esm/utils/warnOnce.d.ts +17 -6
- package/dist/esm/utils/warnOnce.d.ts.map +1 -1
- package/dist/esm/utils/warnOnce.js +22 -10
- package/dist/esm/utils/warnOnce.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/websocket/wsLog.d.ts +4 -4
- package/dist/esm/websocket/wsLog.d.ts.map +1 -1
- package/dist/esm/websocket/wsLog.js +8 -7
- package/dist/esm/websocket/wsLog.js.map +1 -1
- package/dist/esm/wire/orderAmounts.d.ts +9 -7
- package/dist/esm/wire/orderAmounts.d.ts.map +1 -1
- package/dist/esm/wire/orderAmounts.js +22 -18
- package/dist/esm/wire/orderAmounts.js.map +1 -1
- package/dist/esm/wire/refuel.d.ts +1 -1
- package/dist/esm/wire/refuel.js +4 -4
- package/dist/esm/wire/refuel.js.map +1 -1
- package/dist/esm/wire/transferable.d.ts +2 -2
- package/dist/esm/wire/transferable.js +2 -2
- package/dist/types/decimal/arithmetic.d.ts +24 -10
- package/dist/types/decimal/arithmetic.d.ts.map +1 -1
- package/dist/types/decimal/compare.d.ts +3 -3
- package/dist/types/decimal/convert.d.ts +2 -24
- package/dist/types/decimal/convert.d.ts.map +1 -1
- package/dist/types/decimal/decimalStringToBig.d.ts +4 -5
- package/dist/types/decimal/decimalStringToBig.d.ts.map +1 -1
- package/dist/types/decimal/parse.d.ts +8 -1
- package/dist/types/decimal/parse.d.ts.map +1 -1
- package/dist/types/errors/invalidInput.d.ts +4 -0
- package/dist/types/errors/invalidInput.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/math/fills.d.ts +4 -4
- package/dist/types/math/order.d.ts +24 -26
- package/dist/types/math/order.d.ts.map +1 -1
- package/dist/types/math/position.d.ts +27 -27
- package/dist/types/math/position.d.ts.map +1 -1
- package/dist/types/services/resolveSubscribeQuote.d.ts +1 -1
- package/dist/types/types/provider.d.ts +4 -3
- package/dist/types/types/provider.d.ts.map +1 -1
- package/dist/types/utils/createSafeFunction.d.ts +1 -1
- package/dist/types/utils/warnOnce.d.ts +17 -6
- package/dist/types/utils/warnOnce.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/websocket/wsLog.d.ts +4 -4
- package/dist/types/websocket/wsLog.d.ts.map +1 -1
- package/dist/types/wire/orderAmounts.d.ts +9 -7
- package/dist/types/wire/orderAmounts.d.ts.map +1 -1
- package/dist/types/wire/refuel.d.ts +1 -1
- package/dist/types/wire/transferable.d.ts +2 -2
- package/package.json +2 -2
- package/src/decimal/arithmetic.ts +36 -10
- package/src/decimal/compare.ts +3 -3
- package/src/decimal/convert.ts +3 -40
- package/src/decimal/decimalStringToBig.ts +7 -12
- package/src/decimal/format.ts +3 -3
- package/src/decimal/parse.ts +12 -1
- package/src/errors/invalidInput.ts +10 -0
- package/src/index.ts +8 -3
- package/src/math/fills.ts +4 -4
- package/src/math/order.ts +56 -48
- package/src/math/position.ts +43 -42
- package/src/services/resolveSubscribeQuote.ts +1 -1
- package/src/types/provider.ts +4 -3
- package/src/utils/createSafeFunction.ts +1 -1
- package/src/utils/warnOnce.ts +28 -12
- package/src/version.ts +1 -1
- package/src/websocket/wsLog.ts +22 -9
- package/src/wire/orderAmounts.ts +42 -24
- package/src/wire/refuel.ts +4 -4
- package/src/wire/transferable.ts +2 -2
|
@@ -27,27 +27,39 @@ export const createWarnOnce = () => {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
const MAX_VALUE_CHARS = 64;
|
|
30
|
+
/**
|
|
31
|
+
* Cut venue text to a fixed length, so a warner key or message built from it
|
|
32
|
+
* stays small.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export const cutVenueText = (value) => {
|
|
37
|
+
const text = String(value);
|
|
38
|
+
return text.length > MAX_VALUE_CHARS
|
|
39
|
+
? `${text.slice(0, MAX_VALUE_CHARS)}…`
|
|
40
|
+
: text;
|
|
41
|
+
};
|
|
30
42
|
/**
|
|
31
43
|
* Describe a skipped venue row. The venue value is cut to a fixed length, so
|
|
32
44
|
* a warner key built from the text stays small.
|
|
33
45
|
*
|
|
34
46
|
* @internal
|
|
35
47
|
*/
|
|
36
|
-
export const skippedRowMessage = (source, row, field, value, expected) => {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
return `[${source}] skipping ${row} row: \`${field}\` is not a valid ${expected}: '${shown}'`;
|
|
48
|
+
export const skippedRowMessage = (source, row, field, value, expected, marketId) => {
|
|
49
|
+
const market = marketId === undefined ? '' : ` on market '${marketId}'`;
|
|
50
|
+
return `[${source}] skipping ${row} row${market}: \`${field}\` is not a valid ${expected}: '${cutVenueText(value)}'`;
|
|
40
51
|
};
|
|
41
52
|
const warnSkippedRowOnce = createWarnOnce();
|
|
42
53
|
/**
|
|
43
|
-
* Warn once for each provider, row, field
|
|
44
|
-
* mapper skipped a venue row because a required field is not valid.
|
|
45
|
-
* holds no venue value, so a second bad value for the same field
|
|
54
|
+
* Warn once for each provider, row, field, expected kind and market that a
|
|
55
|
+
* provider mapper skipped a venue row because a required field is not valid.
|
|
56
|
+
* The key holds no venue value, so a second bad value for the same field on
|
|
57
|
+
* the same market stays silent.
|
|
46
58
|
*
|
|
47
|
-
* @param expected - What the field must be. Defaults to `'decimal'`.
|
|
59
|
+
* @param options.expected - What the field must be. Defaults to `'decimal'`.
|
|
48
60
|
* @internal
|
|
49
61
|
*/
|
|
50
|
-
export const warnSkippedVenueRow = (provider, row, field, value, expected = 'decimal') => {
|
|
51
|
-
warnSkippedRowOnce(`${provider}|${row}|${field}|${expected}`, skippedRowMessage(provider, row, field, value, expected));
|
|
62
|
+
export const warnSkippedVenueRow = (provider, row, field, value, { marketId, expected = 'decimal', } = {}) => {
|
|
63
|
+
warnSkippedRowOnce(`${provider}|${row}|${field}|${expected}|${marketId ?? ''}`, skippedRowMessage(provider, row, field, value, expected, marketId));
|
|
52
64
|
};
|
|
53
65
|
//# sourceMappingURL=warnOnce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warnOnce.js","sourceRoot":"","sources":["../../../src/utils/warnOnce.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAA6C,EAAE;IAC3E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QACtB,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAClB,OAAM;QACR,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,IAAI,gBAAgB,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YACzC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACrB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,GAAG,CAA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G;QACtC,CAAC,CAAC,IAAI,CAAA;AACV,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,MAAc,EACd,GAAW,EACX,KAAa,EACb,KAAc,EACd,QAAgB,EAChB,QAAiB,EACT,EAAE;IACV,MAAM,MAAM,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,QAAQ,GAAG,CAAA;IACvE,OAAO,IAAI,MAAM,cAAc,GAAG,OAAO,MAAM,OAAO,KAAK,qBAAqB,QAAQ,MAAM,YAAY,CAAC,KAAK,CAAC,GAAG,CAAA;AACtH,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG,cAAc,EAAE,CAAA;AAE3C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAAgB,EAChB,GAAW,EACX,KAAa,EACb,KAAc,EACd,EACE,QAAQ,EACR,QAAQ,GAAG,SAAS,MACwB,EAAE,EAC1C,EAAE;IACR,kBAAkB,CAChB,GAAG,QAAQ,IAAI,GAAG,IAAI,KAAK,IAAI,QAAQ,IAAI,QAAQ,IAAI,EAAE,EAAE,EAC3D,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CACnE,CAAA;AACH,CAAC,CAAA"}
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
|
@@ -38,14 +38,14 @@ export declare const wsLog: {
|
|
|
38
38
|
readonly unknownMarket: (provider: string, marketId: string) => void;
|
|
39
39
|
/**
|
|
40
40
|
* A frame row or order-book level with a required field that is not valid.
|
|
41
|
-
* Only that row is skipped. Logged once at `warn` for each provider, row
|
|
42
|
-
* field; the key holds no venue value.
|
|
41
|
+
* Only that row is skipped. Logged once at `warn` for each provider, row,
|
|
42
|
+
* field and market; the key holds no venue value.
|
|
43
43
|
*/
|
|
44
|
-
readonly skippedRow: (provider: string, row: string, field: string, value: unknown) => void;
|
|
44
|
+
readonly skippedRow: (provider: string, row: string, field: string, value: unknown, marketId?: string) => void;
|
|
45
45
|
/**
|
|
46
46
|
* A frame row the mapper rejected for a reason other than one field, such as
|
|
47
47
|
* a lifecycle state the SDK does not carry. Logged once at `warn` for each
|
|
48
|
-
* provider and
|
|
48
|
+
* provider, row and reason; the reason is cut to a fixed length.
|
|
49
49
|
*/
|
|
50
50
|
readonly droppedRow: (provider: string, row: string, reason: string) => void;
|
|
51
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsLog.d.ts","sourceRoot":"","sources":["../../../src/websocket/wsLog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wsLog.d.ts","sourceRoot":"","sources":["../../../src/websocket/wsLog.ts"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,eAAO,MAAM,KAAK;IAChB;;;OAGG;sCACoB,MAAM,OAAO,MAAM,KAAG,IAAI;IAGjD;;;;OAIG;wCACsB,MAAM,SAAS,OAAO,KAAG,IAAI;IAGtD;;;;;OAKG;qCACmB,MAAM,WAAW,MAAM,KAAG,IAAI;IAGpD;;;;OAIG;0CACwB,MAAM,WAAW,MAAM,SAAS,OAAO,KAAG,IAAI;IAMzE;;;;OAIG;uCACqB,MAAM,YAAY,MAAM,KAAG,IAAI;IAKvD;;;;OAIG;oCAES,MAAM,OACX,MAAM,SACJ,MAAM,SACN,OAAO,aACH,MAAM,KAChB,IAAI;IAaP;;;;OAIG;oCACkB,MAAM,OAAO,MAAM,UAAU,MAAM,KAAG,IAAI;IAO/D;;;OAGG;8CAC4B,MAAM,SAAS,OAAO,KAAG,IAAI;IAG5D;;;OAGG;yCAES,MAAM,gBACF,MAAM,SACb,OAAO,KACb,IAAI;CAMC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createWarnOnce, skippedRowMessage } from '../utils/warnOnce.js';
|
|
1
|
+
import { createWarnOnce, cutVenueText, skippedRowMessage, } from '../utils/warnOnce.js';
|
|
2
2
|
const MAX_PAYLOAD_CHARS = 512;
|
|
3
3
|
const truncate = (raw) => raw.length > MAX_PAYLOAD_CHARS
|
|
4
4
|
? `${raw.slice(0, MAX_PAYLOAD_CHARS)}…(${raw.length} chars)`
|
|
@@ -54,19 +54,20 @@ export const wsLog = {
|
|
|
54
54
|
},
|
|
55
55
|
/**
|
|
56
56
|
* A frame row or order-book level with a required field that is not valid.
|
|
57
|
-
* Only that row is skipped. Logged once at `warn` for each provider, row
|
|
58
|
-
* field; the key holds no venue value.
|
|
57
|
+
* Only that row is skipped. Logged once at `warn` for each provider, row,
|
|
58
|
+
* field and market; the key holds no venue value.
|
|
59
59
|
*/
|
|
60
|
-
skippedRow(provider, row, field, value) {
|
|
61
|
-
warnSkippedRowOnce(`${provider}|${row}|${field}`, skippedRowMessage(`${provider}:ws`, row, field, value, 'decimal'));
|
|
60
|
+
skippedRow(provider, row, field, value, marketId) {
|
|
61
|
+
warnSkippedRowOnce(`${provider}|${row}|${field}|${marketId ?? ''}`, skippedRowMessage(`${provider}:ws`, row, field, value, 'decimal', marketId));
|
|
62
62
|
},
|
|
63
63
|
/**
|
|
64
64
|
* A frame row the mapper rejected for a reason other than one field, such as
|
|
65
65
|
* a lifecycle state the SDK does not carry. Logged once at `warn` for each
|
|
66
|
-
* provider and
|
|
66
|
+
* provider, row and reason; the reason is cut to a fixed length.
|
|
67
67
|
*/
|
|
68
68
|
droppedRow(provider, row, reason) {
|
|
69
|
-
|
|
69
|
+
const shown = cutVenueText(reason);
|
|
70
|
+
warnSkippedRowOnce(`${provider}|${row}|dropped|${shown}`, `[${provider}:ws] skipping ${row} row: ${shown}`);
|
|
70
71
|
},
|
|
71
72
|
/**
|
|
72
73
|
* A background market-registry refetch rejected. Unknown-market items keep
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsLog.js","sourceRoot":"","sources":["../../../src/websocket/wsLog.ts"],"names":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I,QAAQ,0CAA0C,QAAQ,GAAG,CAClE,CAAA;IACH,CAAC;IACD;;;;OAIG;IACH,UAAU,CACR,QAAgB,EAChB,GAAW,EACX,KAAa,EACb,KAAc,EACd,QAAiB;QAEjB,kBAAkB,CAChB,GAAG,QAAQ,IAAI,GAAG,IAAI,KAAK,IAAI,QAAQ,IAAI,EAAE,EAAE,EAC/C,iBAAiB,CACf,GAAG,QAAQ,KAAK,EAChB,GAAG,EACH,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,CACT,CACF,CAAA;IACH,CAAC;IACD;;;;OAIG;IACH,UAAU,CAAC,QAAgB,EAAE,GAAW,EAAE,MAAc;QACtD,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAA;QAClC,kBAAkB,CAChB,GAAG,QAAQ,IAAI,GAAG,YAAY,KAAK,EAAE,EACrC,IAAI,QAAQ,iBAAiB,GAAG,SAAS,KAAK,EAAE,CACjD,CAAA;IACH,CAAC;IACD;;;OAGG;IACH,oBAAoB,CAAC,QAAgB,EAAE,KAAc;QACnD,OAAO,CAAC,IAAI,CAAC,IAAI,QAAQ,qCAAqC,EAAE,KAAK,CAAC,CAAA;IACxE,CAAC;IACD;;;OAGG;IACH,eAAe,CACb,QAAgB,EAChB,YAAoB,EACpB,KAAc;QAEd,OAAO,CAAC,KAAK,CACX,IAAI,QAAQ,+BAA+B,YAAY,WAAW,EAClE,KAAK,CACN,CAAA;IACH,CAAC;CACO,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DecimalString, type Market } from '@lifi/perps-types';
|
|
2
2
|
import type { PerpsSDKClient } from '../types/provider.js';
|
|
3
3
|
/** @public */
|
|
4
4
|
export interface OrderAmountsInput {
|
|
@@ -30,12 +30,14 @@ export interface OrderAmounts {
|
|
|
30
30
|
* `notional` is the snapped size × price, and a derived margin is
|
|
31
31
|
* `notional ÷ leverage` in `DivBig` (40 places, half-up).
|
|
32
32
|
*
|
|
33
|
-
* @
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* provider plugin.
|
|
33
|
+
* @throws {PerpsError} `ValidationError` that names `amount` or `price` when
|
|
34
|
+
* it is not a positive decimal, or `leverage` when it is not a finite number
|
|
35
|
+
* above zero. `ValidationError` with the lot size when the snapped size is
|
|
36
|
+
* zero (below one lot). `SDKError` when `market.providerId` names no
|
|
37
|
+
* registered provider plugin.
|
|
38
38
|
* @public
|
|
39
39
|
*/
|
|
40
|
-
export declare function calculateOrderAmounts(input: OrderAmountsInput): OrderAmounts
|
|
40
|
+
export declare function calculateOrderAmounts(input: OrderAmountsInput): OrderAmounts;
|
|
41
|
+
/** @public */
|
|
42
|
+
export declare const safeCalculateOrderAmounts: (input: OrderAmountsInput) => OrderAmounts | undefined;
|
|
41
43
|
//# sourceMappingURL=orderAmounts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderAmounts.d.ts","sourceRoot":"","sources":["../../../src/wire/orderAmounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"orderAmounts.d.ts","sourceRoot":"","sources":["../../../src/wire/orderAmounts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,MAAM,EAEZ,MAAM,mBAAmB,CAAA;AAO1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D,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;AAgBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAkC5E;AAED,cAAc;AACd,eAAO,MAAM,yBAAyB,wDAGrC,CAAA"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { PerpsErrorCode, } from '@lifi/perps-types';
|
|
1
2
|
import { DivBig, TruncBig } from '../decimal/big.js';
|
|
2
3
|
import { isDecimalStringZero } from '../decimal/compare.js';
|
|
3
4
|
import { isDecimalString } from '../decimal/parse.js';
|
|
5
|
+
import { invalidInput } from '../errors/invalidInput.js';
|
|
6
|
+
import { PerpsError } from '../errors/PerpsError.js';
|
|
7
|
+
import { createSafeFunction } from '../utils/createSafeFunction.js';
|
|
4
8
|
import { snapOrderSize } from './snap.js';
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
function requirePositiveDecimal(value, parameter) {
|
|
10
|
+
const parsed = isDecimalString(value) ? new TruncBig(value) : undefined;
|
|
11
|
+
if (parsed === undefined || !parsed.gt(0)) {
|
|
12
|
+
throw invalidInput(parameter, `must be a positive decimal, got '${String(value)}'`);
|
|
8
13
|
}
|
|
9
|
-
|
|
10
|
-
return parsed.gt(0) ? parsed : null;
|
|
14
|
+
return parsed;
|
|
11
15
|
}
|
|
16
|
+
const lotSize = (market) => market.sizeIncrement ?? new TruncBig(`1e-${market.szDecimals}`).toFixed();
|
|
12
17
|
/**
|
|
13
18
|
* The three order-entry amounts, derived from whichever one the user typed.
|
|
14
19
|
* Only `size` snaps, onto the market's venue lot grid, because an order sends
|
|
@@ -16,22 +21,19 @@ function positiveDecimal(value) {
|
|
|
16
21
|
* `notional` is the snapped size × price, and a derived margin is
|
|
17
22
|
* `notional ÷ leverage` in `DivBig` (40 places, half-up).
|
|
18
23
|
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* provider plugin.
|
|
24
|
+
* @throws {PerpsError} `ValidationError` that names `amount` or `price` when
|
|
25
|
+
* it is not a positive decimal, or `leverage` when it is not a finite number
|
|
26
|
+
* above zero. `ValidationError` with the lot size when the snapped size is
|
|
27
|
+
* zero (below one lot). `SDKError` when `market.providerId` names no
|
|
28
|
+
* registered provider plugin.
|
|
24
29
|
* @public
|
|
25
30
|
*/
|
|
26
31
|
export function calculateOrderAmounts(input) {
|
|
27
32
|
const { sdk, market, held, leverage } = input;
|
|
28
|
-
const amount =
|
|
29
|
-
const price =
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
!Number.isFinite(leverage) ||
|
|
33
|
-
leverage <= 0) {
|
|
34
|
-
return null;
|
|
33
|
+
const amount = requirePositiveDecimal(input.amount, 'amount');
|
|
34
|
+
const price = requirePositiveDecimal(input.price, 'price');
|
|
35
|
+
if (!Number.isFinite(leverage) || leverage <= 0) {
|
|
36
|
+
throw invalidInput('leverage', `must be a finite number above zero, got ${leverage}`);
|
|
35
37
|
}
|
|
36
38
|
const requested = held === 'size'
|
|
37
39
|
? input.amount
|
|
@@ -40,7 +42,7 @@ export function calculateOrderAmounts(input) {
|
|
|
40
42
|
: amount.times(leverage).div(price).toFixed();
|
|
41
43
|
const size = snapOrderSize(sdk, market, requested);
|
|
42
44
|
if (isDecimalStringZero(size)) {
|
|
43
|
-
|
|
45
|
+
throw new PerpsError(PerpsErrorCode.ValidationError, `The order size ${requested} is below the lot size ${lotSize(market)}.`);
|
|
44
46
|
}
|
|
45
47
|
const notional = new TruncBig(size).times(price);
|
|
46
48
|
return {
|
|
@@ -51,4 +53,6 @@ export function calculateOrderAmounts(input) {
|
|
|
51
53
|
notional: notional.toFixed(),
|
|
52
54
|
};
|
|
53
55
|
}
|
|
56
|
+
/** @public */
|
|
57
|
+
export const safeCalculateOrderAmounts = createSafeFunction('calculateOrderAmounts', calculateOrderAmounts);
|
|
54
58
|
//# sourceMappingURL=orderAmounts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderAmounts.js","sourceRoot":"","sources":["../../../src/wire/orderAmounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orderAmounts.js","sourceRoot":"","sources":["../../../src/wire/orderAmounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,GACf,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AA2BzC,SAAS,sBAAsB,CAAC,KAAoB,EAAE,SAAiB;IACrE,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACvE,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,MAAM,YAAY,CAChB,SAAS,EACT,oCAAoC,MAAM,CAAC,KAAK,CAAC,GAAG,CACrD,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,MAAc,EAAiB,EAAE,CAChD,MAAM,CAAC,aAAa,IAAI,IAAI,QAAQ,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,C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AC,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;AAED,cAAc;AACd,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CACzD,uBAAuB,EACvB,qBAAqB,CACtB,CAAA"}
|
|
@@ -30,7 +30,7 @@ export interface RefuelAmountInput {
|
|
|
30
30
|
* when `recommendedAmount`, `recommendedUsd` or `priceUsd` is not greater
|
|
31
31
|
* than zero: a route with nothing to refuel, not a failure.
|
|
32
32
|
* @throws {PerpsError} `ValidationError` when a base-unit field is not an
|
|
33
|
-
* integer string, a USD field
|
|
33
|
+
* integer string, a USD field does not match the decimal pattern, or `decimals`
|
|
34
34
|
* is not a non-negative integer.
|
|
35
35
|
* @public
|
|
36
36
|
*/
|
package/dist/esm/wire/refuel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PerpsErrorCode } from '@lifi/perps-types';
|
|
2
2
|
import { DivBig } from '../decimal/big.js';
|
|
3
3
|
import { BASE_UNITS_PATTERN } from '../decimal/convert.js';
|
|
4
|
-
import {
|
|
4
|
+
import { decimalStringToDivBig } from '../decimal/decimalStringToBig.js';
|
|
5
5
|
import { PerpsError } from '../errors/PerpsError.js';
|
|
6
6
|
/**
|
|
7
7
|
* Headroom, in percent, that {@link calculateRefuelAmount} adds over the gas
|
|
@@ -27,7 +27,7 @@ function requireBaseUnits(value, field) {
|
|
|
27
27
|
* when `recommendedAmount`, `recommendedUsd` or `priceUsd` is not greater
|
|
28
28
|
* than zero: a route with nothing to refuel, not a failure.
|
|
29
29
|
* @throws {PerpsError} `ValidationError` when a base-unit field is not an
|
|
30
|
-
* integer string, a USD field
|
|
30
|
+
* integer string, a USD field does not match the decimal pattern, or `decimals`
|
|
31
31
|
* is not a non-negative integer.
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
@@ -38,8 +38,8 @@ export function calculateRefuelAmount(input) {
|
|
|
38
38
|
}
|
|
39
39
|
const recommended = requireBaseUnits(input.recommendedAmount, 'recommendedAmount');
|
|
40
40
|
const balance = requireBaseUnits(input.nativeBalance, 'nativeBalance');
|
|
41
|
-
const recommendedUsd =
|
|
42
|
-
const priceUsd =
|
|
41
|
+
const recommendedUsd = decimalStringToDivBig(input.recommendedUsd);
|
|
42
|
+
const priceUsd = decimalStringToDivBig(input.priceUsd);
|
|
43
43
|
const deficit = recommended.minus(balance);
|
|
44
44
|
if (!recommended.gt(0) ||
|
|
45
45
|
!recommendedUsd.gt(0) ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refuel.js","sourceRoot":"","sources":["../../../src/wire/refuel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"refuel.js","sourceRoot":"","sources":["../../../src/wire/refuel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAgB3C,SAAS,gBAAgB,CAAC,KAAoB,EAAE,KAAa;IAC3D,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,IAA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K,CAAC,QAAQ,CAAC,CAAC;SAC3C,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC;SAC/B,OAAO,CAAC,QAAQ,CAAC,CAAA;AACtB,CAAC"}
|
|
@@ -7,8 +7,8 @@ import type { DecimalString } from '@lifi/perps-types';
|
|
|
7
7
|
* @param venueFigure - The venue's free figure for the category, which can
|
|
8
8
|
* exceed `units` or fall below zero.
|
|
9
9
|
* @param units - Units held in the category, the upper bound of the clamp.
|
|
10
|
-
* @throws {PerpsError} `ValidationError` when either input
|
|
11
|
-
*
|
|
10
|
+
* @throws {PerpsError} `ValidationError` when either input does not match the
|
|
11
|
+
* decimal pattern, naming the field.
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
export declare function calculateTransferable(venueFigure: DecimalString, units: DecimalString): DecimalString;
|
|
@@ -7,8 +7,8 @@ import { decimalStringToBig } from '../decimal/decimalStringToBig.js';
|
|
|
7
7
|
* @param venueFigure - The venue's free figure for the category, which can
|
|
8
8
|
* exceed `units` or fall below zero.
|
|
9
9
|
* @param units - Units held in the category, the upper bound of the clamp.
|
|
10
|
-
* @throws {PerpsError} `ValidationError` when either input
|
|
11
|
-
*
|
|
10
|
+
* @throws {PerpsError} `ValidationError` when either input does not match the
|
|
11
|
+
* decimal pattern, naming the field.
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
export function calculateTransferable(venueFigure, units) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Exact `a + b`.
|
|
3
|
-
* `addDecimalString('$4', '$6')` is `'10'`.
|
|
2
|
+
* Exact `a + b`.
|
|
4
3
|
*
|
|
5
|
-
* @throws {PerpsError} `ValidationError` when an input
|
|
4
|
+
* @throws {PerpsError} `ValidationError` when an input does not match the decimal pattern.
|
|
6
5
|
* @public
|
|
7
6
|
*/
|
|
8
7
|
export declare function addDecimalString(a: string, b: string): string;
|
|
@@ -12,10 +11,25 @@ export declare function addDecimalString(a: string, b: string): string;
|
|
|
12
11
|
* @public
|
|
13
12
|
*/
|
|
14
13
|
export declare const safeAddDecimalString: (a: string, b: string) => string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Exact sum of every value; `'0'` for an empty list.
|
|
16
|
+
*
|
|
17
|
+
* @throws {PerpsError} `ValidationError` when a value does not match the
|
|
18
|
+
* decimal pattern.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function addDecimalStrings(values: readonly string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* {@link addDecimalStrings}, or `undefined` with a warning when it throws.
|
|
24
|
+
* One bad value gives `undefined`, never a partial sum.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare const safeAddDecimalStrings: (values: readonly string[]) => string | undefined;
|
|
15
29
|
/**
|
|
16
30
|
* Exact `a - b`.
|
|
17
31
|
*
|
|
18
|
-
* @throws {PerpsError} `ValidationError` when an input
|
|
32
|
+
* @throws {PerpsError} `ValidationError` when an input does not match the decimal pattern.
|
|
19
33
|
* @public
|
|
20
34
|
*/
|
|
21
35
|
export declare function subtractDecimalString(a: string, b: string): string;
|
|
@@ -28,7 +42,7 @@ export declare const safeSubtractDecimalString: (a: string, b: string) => string
|
|
|
28
42
|
/**
|
|
29
43
|
* Exact `a × b`.
|
|
30
44
|
*
|
|
31
|
-
* @throws {PerpsError} `ValidationError` when an input
|
|
45
|
+
* @throws {PerpsError} `ValidationError` when an input does not match the decimal pattern.
|
|
32
46
|
* @public
|
|
33
47
|
*/
|
|
34
48
|
export declare function multiplyDecimalString(a: string, b: string): string;
|
|
@@ -41,8 +55,8 @@ export declare const safeMultiplyDecimalString: (a: string, b: string) => string
|
|
|
41
55
|
/**
|
|
42
56
|
* `a ÷ b` to 40 decimal places, rounded half up.
|
|
43
57
|
*
|
|
44
|
-
* @throws {PerpsError} `ValidationError` when an input
|
|
45
|
-
*
|
|
58
|
+
* @throws {PerpsError} `ValidationError` when an input does not match the
|
|
59
|
+
* decimal pattern or `b` is zero.
|
|
46
60
|
* @public
|
|
47
61
|
*/
|
|
48
62
|
export declare function divideDecimalString(a: string, b: string): string;
|
|
@@ -56,8 +70,8 @@ export declare const safeDivideDecimalString: (a: string, b: string) => string |
|
|
|
56
70
|
* `a ÷ b` to 40 decimal places, truncated toward zero, so a derived amount
|
|
57
71
|
* never exceeds the exact quotient.
|
|
58
72
|
*
|
|
59
|
-
* @throws {PerpsError} `ValidationError` when an input
|
|
60
|
-
*
|
|
73
|
+
* @throws {PerpsError} `ValidationError` when an input does not match the
|
|
74
|
+
* decimal pattern or `b` is zero.
|
|
61
75
|
* @public
|
|
62
76
|
*/
|
|
63
77
|
export declare function divideDecimalStringRoundDown(a: string, b: string): string;
|
|
@@ -71,7 +85,7 @@ export declare const safeDivideDecimalStringRoundDown: (a: string, b: string) =>
|
|
|
71
85
|
/**
|
|
72
86
|
* Exact `|value|`.
|
|
73
87
|
*
|
|
74
|
-
* @throws {PerpsError} `ValidationError` when `value`
|
|
88
|
+
* @throws {PerpsError} `ValidationError` when `value` does not match the decimal pattern.
|
|
75
89
|
* @public
|
|
76
90
|
*/
|
|
77
91
|
export declare function absDecimalString(value: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arithmetic.d.ts","sourceRoot":"","sources":["../../../src/decimal/arithmetic.ts"],"names":[],"mappings":"AAOA
|
|
1
|
+
{"version":3,"file":"arithmetic.d.ts","sourceRoot":"","sources":["../../../src/decimal/arithmetic.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,8CAGhC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAOnE;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,mDAGjC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,8CAGrC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,8CAGrC,CAAA;AAaD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,8CAGnC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,8CAG5C,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,uCAGhC,CAAA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* gate can tell `'1.0000000000000001'` from `'1'`. The other relations follow
|
|
4
4
|
* from it: `a <= b` is `!isDecimalStringGreaterThan(a, b)`.
|
|
5
5
|
*
|
|
6
|
-
* @throws {PerpsError} `ValidationError` when either operand
|
|
6
|
+
* @throws {PerpsError} `ValidationError` when either operand does not match the decimal pattern.
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
export declare function isDecimalStringGreaterThan(a: string, b: string): boolean;
|
|
@@ -18,7 +18,7 @@ export declare const safeIsDecimalStringGreaterThan: (a: string, b: string) => b
|
|
|
18
18
|
* Exact `value == 0`, so a flat-position check never reads `'0.0'` as
|
|
19
19
|
* non-zero.
|
|
20
20
|
*
|
|
21
|
-
* @throws {PerpsError} `ValidationError` when `value`
|
|
21
|
+
* @throws {PerpsError} `ValidationError` when `value` does not match the decimal pattern.
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
24
|
export declare function isDecimalStringZero(value: string): boolean;
|
|
@@ -32,7 +32,7 @@ export declare const safeIsDecimalStringZero: (value: string) => boolean | undef
|
|
|
32
32
|
* Exact three-way compare for a sort: `-1` when `a < b`, `0` when equal, `1`
|
|
33
33
|
* when `a > b`.
|
|
34
34
|
*
|
|
35
|
-
* @throws {PerpsError} `ValidationError` when either operand
|
|
35
|
+
* @throws {PerpsError} `ValidationError` when either operand does not match the decimal pattern.
|
|
36
36
|
* @public
|
|
37
37
|
*/
|
|
38
38
|
export declare function compareDecimalStrings(a: string, b: string): -1 | 0 | 1;
|
|
@@ -12,7 +12,7 @@ export type DecimalRounding = 'truncate' | 'round' | 'up';
|
|
|
12
12
|
* The result has no trailing zeros: `roundDecimalString('1.50', 1, 'round')`
|
|
13
13
|
* is `'1.5'`.
|
|
14
14
|
*
|
|
15
|
-
* @throws {PerpsError} `ValidationError` when `value`
|
|
15
|
+
* @throws {PerpsError} `ValidationError` when `value` does not match the decimal pattern,
|
|
16
16
|
* or `decimals` is not a non-negative integer.
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
@@ -28,7 +28,7 @@ export declare const safeRoundDecimalString: (value: string, decimals: number, r
|
|
|
28
28
|
* arithmetic: `'0.29'` at 2 decimals is 29, never 28. Off-grid input resolves
|
|
29
29
|
* per `rounding`. No `$`, `%` or `,` is removed first.
|
|
30
30
|
*
|
|
31
|
-
* @throws {PerpsError} `ValidationError` when `value`
|
|
31
|
+
* @throws {PerpsError} `ValidationError` when `value` does not match the decimal pattern,
|
|
32
32
|
* `decimals` is not a non-negative integer, or the result's magnitude
|
|
33
33
|
* exceeds `Number.MAX_SAFE_INTEGER`.
|
|
34
34
|
* @public
|
|
@@ -58,28 +58,6 @@ export declare function scaledIntegerToDecimalString(amount: string, decimals: n
|
|
|
58
58
|
* @public
|
|
59
59
|
*/
|
|
60
60
|
export declare const safeScaledIntegerToDecimalString: (amount: string, decimals: number) => string | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Round `value` down to `decimals` and pad the result to exactly that many
|
|
63
|
-
* decimal places. The padding is the point: this seeds a fixed-decimal input,
|
|
64
|
-
* where `'500.00'` and `'500'` are two renderings of one amount and the field
|
|
65
|
-
* wants the first. For a canonical wire amount with no trailing zeros, read
|
|
66
|
-
* the amount off `calculateOrderAmounts` or a provider snap instead.
|
|
67
|
-
*
|
|
68
|
-
* Exact decimal arithmetic throughout, so there is no 2^53 ceiling and no
|
|
69
|
-
* float artifact: `'0.01'` at 18 decimals gives
|
|
70
|
-
* `'0.010000000000000000'`, which `Number#toFixed` cannot.
|
|
71
|
-
*
|
|
72
|
-
* @throws {PerpsError} `ValidationError` when `value` is not a
|
|
73
|
-
* decimal string, or `decimals` is not a non-negative integer.
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
export declare function truncateDecimal(value: string, decimals: number): string;
|
|
77
|
-
/**
|
|
78
|
-
* {@link truncateDecimal}, or `undefined` with a warning when it throws.
|
|
79
|
-
*
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
export declare const safeTruncateDecimal: (value: string, decimals: number) => string | undefined;
|
|
83
61
|
/**
|
|
84
62
|
* Spell a `number` as a {@link DecimalString} in plain notation: `1e-7`
|
|
85
63
|
* becomes `'0.0000001'`, never `'1e-7'`. The boundary helper for a venue or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/decimal/convert.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,IAAI,CAAA;AAQzD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,KA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;GAKG;AACH,eAAO,MAAM,gCAAgC,0DAG5C,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,uCAGrC,CAAA"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import Big from 'big.js';
|
|
2
2
|
/**
|
|
3
|
-
* Read a decimal string as a `Big`.
|
|
4
|
-
*
|
|
5
|
-
* `DECIMAL_PATTERN`, so an exponent form such as `'1e5'` is rejected.
|
|
3
|
+
* Read a decimal string as a `Big`. The string must match `DECIMAL_PATTERN`,
|
|
4
|
+
* so `'$1,234.5'`, `'0.05%'` and the exponent form `'1e5'` are rejected.
|
|
6
5
|
*
|
|
7
|
-
* @throws {PerpsError} `ValidationError` when `value`
|
|
8
|
-
*
|
|
6
|
+
* @throws {PerpsError} `ValidationError` when `value` does not match the
|
|
7
|
+
* decimal pattern.
|
|
9
8
|
* @internal
|
|
10
9
|
*/
|
|
11
10
|
export declare function decimalStringToBig(value: string): Big;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimalStringToBig.d.ts","sourceRoot":"","sources":["../../../src/decimal/decimalStringToBig.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"decimalStringToBig.d.ts","sourceRoot":"","sources":["../../../src/decimal/decimalStringToBig.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,QAAQ,CAAA;AAIxB;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAQrD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAErD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAExD"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* float holds about 15 significant digits, so the result can lose precision;
|
|
4
4
|
* never use it for an amount sent to a venue.
|
|
5
5
|
*
|
|
6
|
-
* @throws {PerpsError} `ValidationError` when `value`
|
|
6
|
+
* @throws {PerpsError} `ValidationError` when `value` does not match the decimal pattern
|
|
7
7
|
* or is too large for a finite float.
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
@@ -32,4 +32,11 @@ export declare function isDecimalString(value: unknown): value is string;
|
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
34
|
export declare function unknownToDecimalString(value: unknown, field: string, tool: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* The safe pair of {@link unknownToDecimalString}: `undefined` and a warning
|
|
37
|
+
* in place of a throw.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare const safeUnknownToDecimalString: (value: unknown, field: string, tool: string) => string | undefined;
|
|
35
42
|
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/decimal/parse.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,uCAGrC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE/D;AA2BD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,MAAM,CAWR"}
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/decimal/parse.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,uCAGrC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE/D;AA2BD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,MAAM,CAWR;AAED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,qEAGtC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidInput.d.ts","sourceRoot":"","sources":["../../../src/errors/invalidInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAKxE"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,13 +10,13 @@ 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 { absDecimalString, addDecimalString, divideDecimalString, divideDecimalStringRoundDown, multiplyDecimalString, safeAbsDecimalString, safeAddDecimalString, safeDivideDecimalString, safeDivideDecimalStringRoundDown, safeMultiplyDecimalString, safeSubtractDecimalString, subtractDecimalString, } from './decimal/arithmetic.js';
|
|
13
|
+
export { absDecimalString, addDecimalString, addDecimalStrings, divideDecimalString, divideDecimalStringRoundDown, multiplyDecimalString, safeAbsDecimalString, safeAddDecimalString, safeAddDecimalStrings, safeDivideDecimalString, safeDivideDecimalStringRoundDown, safeMultiplyDecimalString, safeSubtractDecimalString, subtractDecimalString, } from './decimal/arithmetic.js';
|
|
14
14
|
export { compareDecimalStrings, isDecimalStringGreaterThan, isDecimalStringZero, safeCompareDecimalStrings, safeIsDecimalStringGreaterThan, safeIsDecimalStringZero, } from './decimal/compare.js';
|
|
15
15
|
export type { DecimalRounding } from './decimal/convert.js';
|
|
16
|
-
export { decimalStringToScaledInteger, numberToDecimalString, roundDecimalString, safeDecimalStringToScaledInteger, safeNumberToDecimalString, safeRoundDecimalString, safeScaledIntegerToDecimalString,
|
|
16
|
+
export { decimalStringToScaledInteger, numberToDecimalString, roundDecimalString, safeDecimalStringToScaledInteger, safeNumberToDecimalString, safeRoundDecimalString, safeScaledIntegerToDecimalString, scaledIntegerToDecimalString, } from './decimal/convert.js';
|
|
17
17
|
export type { FormatOptions, RoundingMode } from './decimal/format.js';
|
|
18
18
|
export { formatCompactUsd, formatNumber, formatPrice, formatSignedPercent, formatSignedUsd, formatUsd, } from './decimal/format.js';
|
|
19
|
-
export { decimalStringToNumber, isDecimalString, safeDecimalStringToNumber, unknownToDecimalString, } from './decimal/parse.js';
|
|
19
|
+
export { decimalStringToNumber, isDecimalString, safeDecimalStringToNumber, safeUnknownToDecimalString, unknownToDecimalString, } from './decimal/parse.js';
|
|
20
20
|
export { PerpsErrorMessage } from './errors/constants.js';
|
|
21
21
|
export { PerpsError } from './errors/PerpsError.js';
|
|
22
22
|
export { classifyFill, classifyFillFromPosition, FillClassification, } from './math/fills.js';
|
|
@@ -82,6 +82,7 @@ export type { DeclaredDepositAsset, DepositFlow, DepositFlowFirstDepositPipeline
|
|
|
82
82
|
export type { ActionSignerContribution, LiquidationEstimateParams, PerpsProvider, PerpsProviderPlugin, PerpsSDKClient, ProviderAccountExistsParams, ProviderGetAccountParams, ProviderGetActivityParams, ProviderGetAvailableToTradeParams, ProviderGetDepositFlowParams, ProviderGetFillsParams, ProviderGetMarketSettingsParams, ProviderGetOrderParams, ProviderGetOrdersParams, ProviderGetPortfolioHistoryParams, ProviderGetPositionsParams, ProviderGetQuoteParams, ProviderGetWithdrawableBalancesParams, ProviderGetWithdrawalTypesParams, ProviderGetWithdrawFlowParams, QuoteListener, SignActionProgress, SignActionsContext, } from './types/provider.js';
|
|
83
83
|
export type { ProviderWithdrawableBalance, WithdrawableBalance, WithdrawalSourceTypes, WithdrawalTypeOption, WithdrawFlow, WithdrawFlowReady, WithdrawFlowSetupRequired, } from './types/withdrawal.js';
|
|
84
84
|
export { paginateActivity } from './utils/activityPaging.js';
|
|
85
|
+
export { createSafeFunction } from './utils/createSafeFunction.js';
|
|
85
86
|
export { ETHEREUM_NATIVE_GAS, ETHEREUM_USDC, HYPERLIQUID_USDC, LIGHTER_USDC, ROBINHOOD_NATIVE_GAS, ROBINHOOD_USDG, } from './utils/depositAssets.js';
|
|
86
87
|
export { ExplorerChainId, explorerTxUrl, explorerTxUrlFromBase, } from './utils/explorer.js';
|
|
87
88
|
export { ACTIVE_ORDER_STATUSES, isActiveOrderStatus, isRegularOrder, isStopLossOrder, isTakeProfitOrder, isTpSlOrder, isTriggerOrder, isTwapOrder, triggerConditionFor, } from './utils/orderClassification.js';
|
|
@@ -101,7 +102,7 @@ export type { EventForSubscription, SubscriptionListener, WsConnectionStatus, Ws
|
|
|
101
102
|
export { WS_CHANNEL_TEARDOWN_LINGER_MS, WsProviderBase, } from './websocket/WsProviderBase.js';
|
|
102
103
|
export { wsLog } from './websocket/wsLog.js';
|
|
103
104
|
export type { OrderAmounts, OrderAmountsInput, } from './wire/orderAmounts.js';
|
|
104
|
-
export { calculateOrderAmounts } from './wire/orderAmounts.js';
|
|
105
|
+
export { calculateOrderAmounts, safeCalculateOrderAmounts, } from './wire/orderAmounts.js';
|
|
105
106
|
export type { RefuelAmountInput } from './wire/refuel.js';
|
|
106
107
|
export { calculateRefuelAmount, REFUEL_FEE_MARGIN_PERCENT, } from './wire/refuel.js';
|
|
107
108
|
export { snapOrderPrice, snapOrderSize } from './wire/snap.js';
|