@lifi/perps-sdk 0.0.0-preview-c7fd2414 → 0.0.0-preview-a5f7ffc1
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 +6 -5
- package/dist/cjs/math/leverage.d.ts.map +1 -1
- package/dist/cjs/math/leverage.js +2 -1
- package/dist/cjs/math/leverage.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 +6 -1
- package/dist/cjs/wire/orderAmounts.d.ts.map +1 -1
- package/dist/cjs/wire/orderAmounts.js.map +1 -1
- package/dist/esm/math/leverage.d.ts +3 -2
- package/dist/esm/math/leverage.d.ts.map +1 -1
- package/dist/esm/math/leverage.js +5 -3
- package/dist/esm/math/leverage.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 +12 -1
- package/dist/esm/wire/orderAmounts.d.ts.map +1 -1
- package/dist/esm/wire/orderAmounts.js.map +1 -1
- package/dist/types/math/leverage.d.ts +3 -2
- package/dist/types/math/leverage.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wire/orderAmounts.d.ts +12 -1
- package/dist/types/wire/orderAmounts.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/math/leverage.ts +5 -3
- package/src/version.ts +1 -1
- package/src/wire/orderAmounts.ts +10 -1
package/README.md
CHANGED
|
@@ -386,7 +386,7 @@ A settings-preserving action, such as a margin-mode change or an order at the cu
|
|
|
386
386
|
|
|
387
387
|
Before `POST /createAction`, the Lighter provider attaches `params.initialMarginFractionBps` to an `updateLeverage` request and to a `placeOrder` request that carries `leverage` or the IMF:
|
|
388
388
|
|
|
389
|
-
- A present IMF goes to the backend unchanged. The SDK does not re-encode the leverage multiple.
|
|
389
|
+
- A present IMF goes to the backend unchanged, as plain digits (`'700.0'` is sent as `'700'`). The SDK does not re-encode the leverage multiple. The two-decimal leverage `6.67` with the reported IMF `'1500'` sends `'1500'`, while an encoding of `6.67` would give `1499`. When both fields are present, the IMF wins, so a new leverage choice must omit it.
|
|
390
390
|
- An absent IMF with a leverage sends the half-up `round(10000 ÷ leverage)`. Selection `15` sends `'667'`, and `14.9` sends `'671'`.
|
|
391
391
|
- A `placeOrder` without either field sends no IMF.
|
|
392
392
|
- An IMF that is not a positive integer, or a leverage that encodes no positive IMF, throws `ValidationError` before any request.
|
|
@@ -400,7 +400,7 @@ The backend uses a present IMF as the signing fraction, so the field needs a bac
|
|
|
400
400
|
`resolveExactLeverage(source)` gives the leverage multiple for the TP/SL and liquidation formulas from a `MarketSettings` or a `Position`: `10000 ÷ initialMarginFractionBps` to 40 places when the native IMF is present, else `source.leverage` unchanged.
|
|
401
401
|
It throws `ValidationError` when the IMF is present but not a positive integer, or when both fields are unusable. `safeResolveExactLeverage` gives `undefined` in place of the throw.
|
|
402
402
|
A display leverage never feeds a formula.
|
|
403
|
-
`validateInitialMarginFractionBps(value)` gives a positive integer IMF
|
|
403
|
+
`validateInitialMarginFractionBps(value)` gives a positive integer IMF as plain digits and throws `ValidationError` for any other value.
|
|
404
404
|
|
|
405
405
|
### Order amounts and venue grids
|
|
406
406
|
|
|
@@ -461,9 +461,10 @@ the message, when the snapped size is zero (below one lot).
|
|
|
461
461
|
`safeCalculateOrderAmounts` gives `undefined` in place of the throw. A
|
|
462
462
|
sub-cent margin is a valid order when the lot grid takes the size.
|
|
463
463
|
|
|
464
|
-
`OrderAmountsInput
|
|
465
|
-
`initialMarginFractionBps
|
|
466
|
-
`MarketSettings.initialMarginFractionBps` for a
|
|
464
|
+
`OrderAmountsInput` requires `leverage` (a `number`) or
|
|
465
|
+
`initialMarginFractionBps`, and the SDK does not read `leverage` when the IMF
|
|
466
|
+
is present. Pass the reported `MarketSettings.initialMarginFractionBps` for a
|
|
467
|
+
venue that stores one.
|
|
467
468
|
`Position.leverage` is a `DecimalString`, so a caller converts it with
|
|
468
469
|
`safeDecimalStringToNumber`.
|
|
469
470
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leverage.d.ts","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"leverage.d.ts","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAYtD,eAAO,MAAM,qBAAqB,UAAU,CAAA;AAS5C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,wBAAwB,CAAC,EAAE,aAAa,CAAA;CACzC;AAWD,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,aAAa,EACpB,SAAS,SAA6B,GACrC,aAAa,CASf;AAcD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,CAe1E;AAGD,eAAO,MAAM,wBAAwB,gDAGpC,CAAA"}
|
|
@@ -5,6 +5,7 @@ exports.validateInitialMarginFractionBps = validateInitialMarginFractionBps;
|
|
|
5
5
|
exports.resolveExactLeverage = resolveExactLeverage;
|
|
6
6
|
const arithmetic_js_1 = require("../decimal/arithmetic.js");
|
|
7
7
|
const compare_js_1 = require("../decimal/compare.js");
|
|
8
|
+
const convert_js_1 = require("../decimal/convert.js");
|
|
8
9
|
const parse_js_1 = require("../decimal/parse.js");
|
|
9
10
|
const invalidInput_js_1 = require("../errors/invalidInput.js");
|
|
10
11
|
const createSafeFunction_js_1 = require("../utils/createSafeFunction.js");
|
|
@@ -15,7 +16,7 @@ function validateInitialMarginFractionBps(value, parameter = 'initialMarginFract
|
|
|
15
16
|
!(0, compare_js_1.isDecimalStringInteger)(value)) {
|
|
16
17
|
throw (0, invalidInput_js_1.invalidInput)(parameter, `must be a positive integer, got '${value}'`);
|
|
17
18
|
}
|
|
18
|
-
return value;
|
|
19
|
+
return (0, convert_js_1.roundDecimalString)(value, 0, 'truncate');
|
|
19
20
|
}
|
|
20
21
|
function resolveExactLeverage(source) {
|
|
21
22
|
const { initialMarginFractionBps, leverage } = source;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leverage.js","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"leverage.js","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":";;;AAmCA,4EAYC;AAcD,oDAeC;AA3ED,4DAA8D;AAC9D,sDAG8B;AAC9B,sDAA0D;AAC1D,kDAAqD;AACrD,+DAAwD;AACxD,0EAAmE;AAGtD,QAAA,qBAAqB,GAAG,OAAO,CAAA;AAuB5C,SAAgB,gCAAgC,CAC9C,KAAoB,EACpB,SAAS,GAAG,0BAA0B;IAEtC,IACE,CAAC,IAAA,0BAAe,EAAC,KAAK,CAAC;QACvB,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,GAAG,CAAC;QACvC,CAAC,IAAA,mCAAsB,EAAC,KAAK,CAAC,EAC9B,CAAC;QACD,MAAM,IAAA,8BAAY,EAAC,SAAS,EAAE,oCAAoC,KAAK,GAAG,CAAC,CAAA;IAC7E,CAAC;IACD,OAAO,IAAA,+BAAkB,EAAC,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAA;AACjD,CAAC;AAcD,SAAgB,oBAAoB,CAAC,MAAsB;IACzD,MAAM,EAAE,wBAAwB,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;IACrD,IAAI,wBAAwB,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,IAAA,mCAAmB,EACxB,6BAAqB,EACrB,gCAAgC,CAAC,wBAAwB,CAAC,CAC3D,CAAA;IACH,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,IAAA,uCAA0B,EAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;QACzE,MAAM,IAAA,8BAAY,EAChB,UAAU,EACV,oCAAoC,MAAM,CAAC,QAAQ,CAAC,GAAG,CACxD,CAAA;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAGY,QAAA,wBAAwB,GAAG,IAAA,0CAAkB,EACxD,sBAAsB,EACtB,oBAAoB,CACrB,CAAA"}
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.version = exports.name = void 0;
|
|
4
4
|
exports.name = '@lifi/perps-sdk';
|
|
5
|
-
exports.version = '0.0.0-preview-
|
|
5
|
+
exports.version = '0.0.0-preview-a5f7ffc1';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DecimalString, type Market } from '@lifi/perps-types';
|
|
2
2
|
import type { PerpsSDKClient } from '../types/provider.js';
|
|
3
|
-
export interface
|
|
3
|
+
export interface OrderAmountsInputBase {
|
|
4
4
|
sdk: PerpsSDKClient;
|
|
5
5
|
market: Market;
|
|
6
6
|
held: 'margin' | 'size' | 'notional';
|
|
@@ -9,6 +9,11 @@ export interface OrderAmountsInput {
|
|
|
9
9
|
initialMarginFractionBps?: DecimalString;
|
|
10
10
|
price: DecimalString;
|
|
11
11
|
}
|
|
12
|
+
export type OrderAmountsInput = OrderAmountsInputBase & ({
|
|
13
|
+
leverage: number;
|
|
14
|
+
} | {
|
|
15
|
+
initialMarginFractionBps: DecimalString;
|
|
16
|
+
});
|
|
12
17
|
export interface OrderAmounts {
|
|
13
18
|
margin: DecimalString;
|
|
14
19
|
size: DecimalString;
|
|
@@ -1 +1 @@
|
|
|
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;AAW1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAK1D,MAAM,WAAW,
|
|
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;AAW1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAK1D,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IAEd,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAA;IACpC,MAAM,EAAE,aAAa,CAAA;IAErB,QAAQ,CAAC,EAAE,MAAM,CAAA;IAMjB,wBAAwB,CAAC,EAAE,aAAa,CAAA;IACxC,KAAK,EAAE,aAAa,CAAA;CACrB;AAQD,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GACnD,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,wBAAwB,EAAE,aAAa,CAAA;CAAE,CAAC,CAAA;AAGtE,MAAM,WAAW,YAAY;IAM3B,MAAM,EAAE,aAAa,CAAA;IAErB,IAAI,EAAE,aAAa,CAAA;IAEnB,QAAQ,EAAE,aAAa,CAAA;CACxB;AA+DD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAmC5E;AAGD,eAAO,MAAM,yBAAyB,wDAGrC,CAAA"}
|
|
@@ -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":";;;AAyHA,sDAmCC;AA5JD,m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C,aAAa,CAAC;iBACpB,GAAG,CAAC,eAAe,CAAC;iBACpB,OAAO,EAAE;QAClB,IAAI;QACJ,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE;KAC7B,CAAA;AACH,CAAC;AAGY,QAAA,yBAAyB,GAAG,IAAA,0CAAkB,EACzD,uBAAuB,EACvB,qBAAqB,CACtB,CAAA"}
|
|
@@ -13,8 +13,9 @@ export interface LeverageSource {
|
|
|
13
13
|
initialMarginFractionBps?: DecimalString;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* The native IMF
|
|
17
|
-
*
|
|
16
|
+
* The native IMF as a canonical integer string (`'700.0'` gives `'700'`), so
|
|
17
|
+
* a formula reads it as an exact margin rate and a venue request carries
|
|
18
|
+
* plain digits. `parameter` names the input in the error.
|
|
18
19
|
*
|
|
19
20
|
* @throws {PerpsError} `ValidationError` when `value` is not a positive
|
|
20
21
|
* integer decimal string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leverage.d.ts","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"leverage.d.ts","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAWtD,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB,UAAU,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,wBAAwB,CAAC,EAAE,aAAa,CAAA;CACzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,aAAa,EACpB,SAAS,SAA6B,GACrC,aAAa,CASf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,CAe1E;AAED,cAAc;AACd,eAAO,MAAM,wBAAwB,gDAGpC,CAAA"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { divideDecimalString } from '../decimal/arithmetic.js';
|
|
2
2
|
import { isDecimalStringGreaterThan, isDecimalStringInteger, } from '../decimal/compare.js';
|
|
3
|
+
import { roundDecimalString } from '../decimal/convert.js';
|
|
3
4
|
import { isDecimalString } from '../decimal/parse.js';
|
|
4
5
|
import { invalidInput } from '../errors/invalidInput.js';
|
|
5
6
|
import { createSafeFunction } from '../utils/createSafeFunction.js';
|
|
6
7
|
/** Basis points in one whole unit: an IMF of `'700'` is `700 ÷ 10000`. */
|
|
7
8
|
export const BASIS_POINTS_PER_UNIT = '10000';
|
|
8
9
|
/**
|
|
9
|
-
* The native IMF
|
|
10
|
-
*
|
|
10
|
+
* The native IMF as a canonical integer string (`'700.0'` gives `'700'`), so
|
|
11
|
+
* a formula reads it as an exact margin rate and a venue request carries
|
|
12
|
+
* plain digits. `parameter` names the input in the error.
|
|
11
13
|
*
|
|
12
14
|
* @throws {PerpsError} `ValidationError` when `value` is not a positive
|
|
13
15
|
* integer decimal string.
|
|
@@ -19,7 +21,7 @@ export function validateInitialMarginFractionBps(value, parameter = 'initialMarg
|
|
|
19
21
|
!isDecimalStringInteger(value)) {
|
|
20
22
|
throw invalidInput(parameter, `must be a positive integer, got '${value}'`);
|
|
21
23
|
}
|
|
22
|
-
return value;
|
|
24
|
+
return roundDecimalString(value, 0, 'truncate');
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* The exact leverage multiple of a venue setting, for the TP/SL and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leverage.js","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,uBAAuB,CAAA;AAC9B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AwB,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,mBAAmB,CACxB,qBAAqB,EACrB,gCAAgC,CAAC,wBAAwB,CAAC,CAC3D,CAAA;IACH,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;QACzE,MAAM,YAAY,CAChB,UAAU,EACV,oCAAoC,MAAM,CAAC,QAAQ,CAAC,GAAG,CACxD,CAAA;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,cAAc;AACd,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CACxD,sBAAsB,EACtB,oBAAoB,CACrB,CAAA"}
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DecimalString, type Market } from '@lifi/perps-types';
|
|
2
2
|
import type { PerpsSDKClient } from '../types/provider.js';
|
|
3
3
|
/** @public */
|
|
4
|
-
export interface
|
|
4
|
+
export interface OrderAmountsInputBase {
|
|
5
5
|
sdk: PerpsSDKClient;
|
|
6
6
|
market: Market;
|
|
7
7
|
/** The field the user typed; the other two are calculated from it. */
|
|
@@ -17,6 +17,17 @@ export interface OrderAmountsInput {
|
|
|
17
17
|
initialMarginFractionBps?: DecimalString;
|
|
18
18
|
price: DecimalString;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The order-entry input with at least one margin-rate source: the leverage
|
|
22
|
+
* multiple, the native IMF, or both.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export type OrderAmountsInput = OrderAmountsInputBase & ({
|
|
27
|
+
leverage: number;
|
|
28
|
+
} | {
|
|
29
|
+
initialMarginFractionBps: DecimalString;
|
|
30
|
+
});
|
|
20
31
|
/** @public */
|
|
21
32
|
export interface OrderAmounts {
|
|
22
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
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;AAW1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D,cAAc;AACd,MAAM,WAAW,
|
|
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;AAW1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D,cAAc;AACd,MAAM,WAAW,qBAAqB;IACpC,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,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,aAAa,CAAA;IACxC,KAAK,EAAE,aAAa,CAAA;CACrB;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GACnD,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,wBAAwB,EAAE,aAAa,CAAA;CAAE,CAAC,CAAA;AAEtE,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;AA+CD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAmC5E;AAED,cAAc;AACd,eAAO,MAAM,yBAAyB,wDAGrC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
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;AACpD,OAAO,EACL,qBAAqB,EACrB,gCAAgC,GACjC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;
|
|
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;AACpD,OAAO,EACL,qBAAqB,EACrB,gCAAgC,GACjC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,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7B,CAAA;AACH,CAAC;AAED,cAAc;AACd,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CACzD,uBAAuB,EACvB,qBAAqB,CACtB,CAAA"}
|
|
@@ -13,8 +13,9 @@ export interface LeverageSource {
|
|
|
13
13
|
initialMarginFractionBps?: DecimalString;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* The native IMF
|
|
17
|
-
*
|
|
16
|
+
* The native IMF as a canonical integer string (`'700.0'` gives `'700'`), so
|
|
17
|
+
* a formula reads it as an exact margin rate and a venue request carries
|
|
18
|
+
* plain digits. `parameter` names the input in the error.
|
|
18
19
|
*
|
|
19
20
|
* @throws {PerpsError} `ValidationError` when `value` is not a positive
|
|
20
21
|
* integer decimal string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leverage.d.ts","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"leverage.d.ts","sourceRoot":"","sources":["../../../src/math/leverage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAWtD,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB,UAAU,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,wBAAwB,CAAC,EAAE,aAAa,CAAA;CACzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,aAAa,EACpB,SAAS,SAA6B,GACrC,aAAa,CASf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,CAe1E;AAED,cAAc;AACd,eAAO,MAAM,wBAAwB,gDAGpC,CAAA"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DecimalString, type Market } from '@lifi/perps-types';
|
|
2
2
|
import type { PerpsSDKClient } from '../types/provider.js';
|
|
3
3
|
/** @public */
|
|
4
|
-
export interface
|
|
4
|
+
export interface OrderAmountsInputBase {
|
|
5
5
|
sdk: PerpsSDKClient;
|
|
6
6
|
market: Market;
|
|
7
7
|
/** The field the user typed; the other two are calculated from it. */
|
|
@@ -17,6 +17,17 @@ export interface OrderAmountsInput {
|
|
|
17
17
|
initialMarginFractionBps?: DecimalString;
|
|
18
18
|
price: DecimalString;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The order-entry input with at least one margin-rate source: the leverage
|
|
22
|
+
* multiple, the native IMF, or both.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export type OrderAmountsInput = OrderAmountsInputBase & ({
|
|
27
|
+
leverage: number;
|
|
28
|
+
} | {
|
|
29
|
+
initialMarginFractionBps: DecimalString;
|
|
30
|
+
});
|
|
20
31
|
/** @public */
|
|
21
32
|
export interface OrderAmounts {
|
|
22
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
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;AAW1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D,cAAc;AACd,MAAM,WAAW,
|
|
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;AAW1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D,cAAc;AACd,MAAM,WAAW,qBAAqB;IACpC,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,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,aAAa,CAAA;IACxC,KAAK,EAAE,aAAa,CAAA;CACrB;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GACnD,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,wBAAwB,EAAE,aAAa,CAAA;CAAE,CAAC,CAAA;AAEtE,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;AA+CD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAmC5E;AAED,cAAc;AACd,eAAO,MAAM,yBAAyB,wDAGrC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/perps-sdk",
|
|
3
|
-
"version": "0.0.0-preview-
|
|
3
|
+
"version": "0.0.0-preview-a5f7ffc1",
|
|
4
4
|
"description": "LI.FI Perps SDK for perpetuals trading",
|
|
5
5
|
"homepage": "https://github.com/lifinance/perps-sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@lifi/types": "^18.3.0",
|
|
46
46
|
"big.js": "^7.0.1",
|
|
47
47
|
"partysocket": "^1.1.19",
|
|
48
|
-
"@lifi/perps-types": "^0.0.0-preview-
|
|
48
|
+
"@lifi/perps-types": "^0.0.0-preview-a5f7ffc1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"viem": ">=2.57.11 <2.57.12"
|
package/src/math/leverage.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
isDecimalStringGreaterThan,
|
|
5
5
|
isDecimalStringInteger,
|
|
6
6
|
} from '../decimal/compare.js'
|
|
7
|
+
import { roundDecimalString } from '../decimal/convert.js'
|
|
7
8
|
import { isDecimalString } from '../decimal/parse.js'
|
|
8
9
|
import { invalidInput } from '../errors/invalidInput.js'
|
|
9
10
|
import { createSafeFunction } from '../utils/createSafeFunction.js'
|
|
@@ -24,8 +25,9 @@ export interface LeverageSource {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
|
-
* The native IMF
|
|
28
|
-
*
|
|
28
|
+
* The native IMF as a canonical integer string (`'700.0'` gives `'700'`), so
|
|
29
|
+
* a formula reads it as an exact margin rate and a venue request carries
|
|
30
|
+
* plain digits. `parameter` names the input in the error.
|
|
29
31
|
*
|
|
30
32
|
* @throws {PerpsError} `ValidationError` when `value` is not a positive
|
|
31
33
|
* integer decimal string.
|
|
@@ -42,7 +44,7 @@ export function validateInitialMarginFractionBps(
|
|
|
42
44
|
) {
|
|
43
45
|
throw invalidInput(parameter, `must be a positive integer, got '${value}'`)
|
|
44
46
|
}
|
|
45
|
-
return value
|
|
47
|
+
return roundDecimalString(value, 0, 'truncate')
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
/**
|
package/src/version.ts
CHANGED
package/src/wire/orderAmounts.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { createSafeFunction } from '../utils/createSafeFunction.js'
|
|
|
18
18
|
import { snapOrderSize } from './snap.js'
|
|
19
19
|
|
|
20
20
|
/** @public */
|
|
21
|
-
export interface
|
|
21
|
+
export interface OrderAmountsInputBase {
|
|
22
22
|
sdk: PerpsSDKClient
|
|
23
23
|
market: Market
|
|
24
24
|
/** The field the user typed; the other two are calculated from it. */
|
|
@@ -35,6 +35,15 @@ export interface OrderAmountsInput {
|
|
|
35
35
|
price: DecimalString
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The order-entry input with at least one margin-rate source: the leverage
|
|
40
|
+
* multiple, the native IMF, or both.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export type OrderAmountsInput = OrderAmountsInputBase &
|
|
45
|
+
({ leverage: number } | { initialMarginFractionBps: DecimalString })
|
|
46
|
+
|
|
38
47
|
/** @public */
|
|
39
48
|
export interface OrderAmounts {
|
|
40
49
|
/**
|