@lifi/perps-sdk 0.0.0-preview-3fd8231 → 0.0.0-preview-7bd1054
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/types/withdrawal.d.ts +5 -5
- package/dist/cjs/types/withdrawal.d.ts.map +1 -1
- package/dist/cjs/utils/decimal.d.ts +1 -0
- package/dist/cjs/utils/decimal.d.ts.map +1 -1
- package/dist/cjs/utils/decimal.js +4 -1
- package/dist/cjs/utils/decimal.js.map +1 -1
- package/dist/cjs/utils/orderEntry.d.ts +1 -1
- package/dist/cjs/utils/orderEntry.d.ts.map +1 -1
- package/dist/cjs/utils/orderEntry.js +5 -11
- package/dist/cjs/utils/orderEntry.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/types/withdrawal.d.ts +5 -5
- package/dist/esm/types/withdrawal.d.ts.map +1 -1
- package/dist/esm/utils/decimal.d.ts +5 -0
- package/dist/esm/utils/decimal.d.ts.map +1 -1
- package/dist/esm/utils/decimal.js +7 -0
- package/dist/esm/utils/decimal.js.map +1 -1
- package/dist/esm/utils/orderEntry.d.ts +1 -1
- package/dist/esm/utils/orderEntry.d.ts.map +1 -1
- package/dist/esm/utils/orderEntry.js +1 -6
- package/dist/esm/utils/orderEntry.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/types/withdrawal.d.ts +5 -5
- package/dist/types/types/withdrawal.d.ts.map +1 -1
- package/dist/types/utils/decimal.d.ts +5 -0
- package/dist/types/utils/decimal.d.ts.map +1 -1
- package/dist/types/utils/orderEntry.d.ts +1 -1
- package/dist/types/utils/orderEntry.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/types/withdrawal.ts +10 -5
- package/src/utils/decimal.ts +8 -0
- package/src/utils/orderEntry.ts +2 -7
- package/src/version.ts +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { ActionType, Asset, WithdrawalRoute } from '@lifi/perps-types';
|
|
1
|
+
import type { ActionType, Asset, DecimalString, WithdrawalRoute } from '@lifi/perps-types';
|
|
2
2
|
import type { Address } from 'viem';
|
|
3
3
|
export type { WithdrawalRoute };
|
|
4
4
|
export interface ProviderWithdrawableBalance {
|
|
5
5
|
assetId: string;
|
|
6
6
|
route: WithdrawalRoute;
|
|
7
|
-
available:
|
|
8
|
-
withdrawalFee?:
|
|
7
|
+
available: DecimalString;
|
|
8
|
+
withdrawalFee?: DecimalString;
|
|
9
9
|
isFeeDeducted?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface WithdrawableBalance {
|
|
12
12
|
asset: Asset;
|
|
13
13
|
route: WithdrawalRoute;
|
|
14
|
-
available:
|
|
15
|
-
withdrawalFee?:
|
|
14
|
+
available: DecimalString;
|
|
15
|
+
withdrawalFee?: DecimalString;
|
|
16
16
|
isFeeDeducted?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export interface WithdrawFlowReady {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../../../src/types/withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../../../src/types/withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,KAAK,EACL,aAAa,EACb,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,YAAY,EAAE,eAAe,EAAE,CAAA;AAQ/B,MAAM,WAAW,2BAA2B;IAE1C,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,eAAe,CAAA;IAEtB,SAAS,EAAE,aAAa,CAAA;IAMxB,aAAa,CAAC,EAAE,aAAa,CAAA;IAM7B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AASD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,eAAe,CAAA;IAEtB,SAAS,EAAE,aAAa,CAAA;IAWxB,aAAa,CAAC,EAAE,aAAa,CAAA;IAM7B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAOD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;CACrB;AASD,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,eAAe,CAAA;IAErB,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB;AAQD,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,yBAAyB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../src/utils/decimal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;AAMxB,eAAO,MAAM,MAAM,oBAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../src/utils/decimal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;AAMxB,eAAO,MAAM,MAAM,oBAAQ,CAAA;AAO3B,eAAO,MAAM,QAAQ,oBAAQ,CAAA;AAK7B,wBAAgB,SAAS,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAEtD"}
|
|
@@ -3,11 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DivBig = void 0;
|
|
6
|
+
exports.TruncBig = exports.DivBig = void 0;
|
|
7
7
|
exports.areFinite = areFinite;
|
|
8
8
|
const big_js_1 = __importDefault(require("big.js"));
|
|
9
9
|
exports.DivBig = (0, big_js_1.default)();
|
|
10
10
|
exports.DivBig.DP = 40;
|
|
11
|
+
exports.TruncBig = (0, big_js_1.default)();
|
|
12
|
+
exports.TruncBig.DP = 40;
|
|
13
|
+
exports.TruncBig.RM = big_js_1.default.roundDown;
|
|
11
14
|
function areFinite(...values) {
|
|
12
15
|
return values.every(Number.isFinite);
|
|
13
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../../src/utils/decimal.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../../src/utils/decimal.ts"],"names":[],"mappings":";;;;;;AAkBA,8BAEC;AApBD,oDAAwB;AAMX,QAAA,MAAM,GAAG,IAAA,gBAAG,GAAE,CAAA;AAC3B,cAAM,CAAC,EAAE,GAAG,EAAE,CAAA;AAMD,QAAA,QAAQ,GAAG,IAAA,gBAAG,GAAE,CAAA;AAC7B,gBAAQ,CAAC,EAAE,GAAG,EAAE,CAAA;AAChB,gBAAQ,CAAC,EAAE,GAAG,gBAAG,CAAC,SAAS,CAAA;AAG3B,SAAgB,SAAS,CAAC,GAAG,MAAgB;IAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Big from 'big.js';
|
|
1
|
+
import type Big from 'big.js';
|
|
2
2
|
export declare function sizeFromMargin(margin: Big, leverage: number, price: Big): Big;
|
|
3
3
|
export declare function marginFromSize(size: Big, leverage: number, price: Big): Big;
|
|
4
4
|
export declare function sizeFromNotional(notionalUsd: Big, price: Big): Big;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderEntry.d.ts","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"orderEntry.d.ts","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAQ7B,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAE7E;AAOD,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAE3E;AAOD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAElE;AAOD,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAE1E"}
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.sizeFromMargin = sizeFromMargin;
|
|
7
4
|
exports.marginFromSize = marginFromSize;
|
|
8
5
|
exports.sizeFromNotional = sizeFromNotional;
|
|
9
6
|
exports.marginFromNotional = marginFromNotional;
|
|
10
|
-
const
|
|
11
|
-
const TruncBig = (0, big_js_1.default)();
|
|
12
|
-
TruncBig.DP = 40;
|
|
13
|
-
TruncBig.RM = big_js_1.default.roundDown;
|
|
7
|
+
const decimal_js_1 = require("./decimal.js");
|
|
14
8
|
function sizeFromMargin(margin, leverage, price) {
|
|
15
|
-
return new TruncBig(margin).times(leverage).div(price);
|
|
9
|
+
return new decimal_js_1.TruncBig(margin).times(leverage).div(price);
|
|
16
10
|
}
|
|
17
11
|
function marginFromSize(size, leverage, price) {
|
|
18
|
-
return new TruncBig(size).times(price).div(leverage);
|
|
12
|
+
return new decimal_js_1.TruncBig(size).times(price).div(leverage);
|
|
19
13
|
}
|
|
20
14
|
function sizeFromNotional(notionalUsd, price) {
|
|
21
|
-
return new TruncBig(notionalUsd).div(price);
|
|
15
|
+
return new decimal_js_1.TruncBig(notionalUsd).div(price);
|
|
22
16
|
}
|
|
23
17
|
function marginFromNotional(notionalUsd, leverage) {
|
|
24
|
-
return new TruncBig(notionalUsd).div(leverage);
|
|
18
|
+
return new decimal_js_1.TruncBig(notionalUsd).div(leverage);
|
|
25
19
|
}
|
|
26
20
|
//# sourceMappingURL=orderEntry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderEntry.js","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orderEntry.js","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":";;AAQA,wCAEC;AAOD,wCAEC;AAOD,4CAEC;AAOD,gDAEC;AApCD,6CAAuC;AAOvC,SAAgB,cAAc,CAAC,MAAW,EAAE,QAAgB,EAAE,KAAU;IACtE,OAAO,IAAI,qBAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACxD,CAAC;AAOD,SAAgB,cAAc,CAAC,IAAS,EAAE,QAAgB,EAAE,KAAU;IACpE,OAAO,IAAI,qBAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACtD,CAAC;AAOD,SAAgB,gBAAgB,CAAC,WAAgB,EAAE,KAAU;IAC3D,OAAO,IAAI,qBAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AAC7C,CAAC;AAOD,SAAgB,kBAAkB,CAAC,WAAgB,EAAE,QAAgB;IACnE,OAAO,IAAI,qBAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAChD,CAAC"}
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionType, Asset, WithdrawalRoute } from '@lifi/perps-types';
|
|
1
|
+
import type { ActionType, Asset, DecimalString, WithdrawalRoute } from '@lifi/perps-types';
|
|
2
2
|
import type { Address } from 'viem';
|
|
3
3
|
export type { WithdrawalRoute };
|
|
4
4
|
/**
|
|
@@ -12,13 +12,13 @@ export interface ProviderWithdrawableBalance {
|
|
|
12
12
|
assetId: string;
|
|
13
13
|
route: WithdrawalRoute;
|
|
14
14
|
/** Withdrawable amount in the asset's own units. Always greater than zero. */
|
|
15
|
-
available:
|
|
15
|
+
available: DecimalString;
|
|
16
16
|
/**
|
|
17
17
|
* Flat venue fee on a withdrawal from this row, in the asset's own units.
|
|
18
18
|
* Absent when the venue publishes no fee for the asset. The client rejects
|
|
19
19
|
* a value that is not a non-negative decimal.
|
|
20
20
|
*/
|
|
21
|
-
withdrawalFee?:
|
|
21
|
+
withdrawalFee?: DecimalString;
|
|
22
22
|
/**
|
|
23
23
|
* `true` when the venue takes `withdrawalFee` out of the requested amount,
|
|
24
24
|
* `false` when it charges the fee in addition. Set together with
|
|
@@ -37,7 +37,7 @@ export interface WithdrawableBalance {
|
|
|
37
37
|
asset: Asset;
|
|
38
38
|
route: WithdrawalRoute;
|
|
39
39
|
/** Withdrawable amount in the asset's own units. */
|
|
40
|
-
available:
|
|
40
|
+
available: DecimalString;
|
|
41
41
|
/**
|
|
42
42
|
* Flat venue fee on a withdrawal from this row, in the asset's own units.
|
|
43
43
|
* Absent when the venue publishes no fee for the asset. With
|
|
@@ -48,7 +48,7 @@ export interface WithdrawableBalance {
|
|
|
48
48
|
* is zero or negative when the fee is at or above `available`, and the row
|
|
49
49
|
* then funds no withdrawal.
|
|
50
50
|
*/
|
|
51
|
-
withdrawalFee?:
|
|
51
|
+
withdrawalFee?: DecimalString;
|
|
52
52
|
/**
|
|
53
53
|
* Present only together with `withdrawalFee`. Absent on a row from a
|
|
54
54
|
* provider plugin that does not report it; absence means unknown, not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../../../src/types/withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../../../src/types/withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,KAAK,EACL,aAAa,EACb,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,YAAY,EAAE,eAAe,EAAE,CAAA;AAE/B;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,eAAe,CAAA;IACtB,8EAA8E;IAC9E,SAAS,EAAE,aAAa,CAAA;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,eAAe,CAAA;IACtB,oDAAoD;IACpD,SAAS,EAAE,aAAa,CAAA;IACxB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,eAAe,CAAA;IACrB,qEAAqE;IACrE,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,yBAAyB,CAAA"}
|
|
@@ -4,6 +4,11 @@ import Big from 'big.js';
|
|
|
4
4
|
* shared global `Big.DP` and `Big.RM` stay untouched.
|
|
5
5
|
*/
|
|
6
6
|
export declare const DivBig: Big.BigConstructor;
|
|
7
|
+
/**
|
|
8
|
+
* As `DivBig`, but truncating, so a derived amount never rounds up past the
|
|
9
|
+
* exact quotient.
|
|
10
|
+
*/
|
|
11
|
+
export declare const TruncBig: Big.BigConstructor;
|
|
7
12
|
/** True when every value is a finite number, so `new DivBig(value)` cannot throw. */
|
|
8
13
|
export declare function areFinite(...values: number[]): boolean;
|
|
9
14
|
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../src/utils/decimal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;AAExB;;;GAGG;AACH,eAAO,MAAM,MAAM,oBAAQ,CAAA;AAG3B,qFAAqF;AACrF,wBAAgB,SAAS,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAEtD"}
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../src/utils/decimal.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"}
|
|
@@ -5,6 +5,13 @@ import Big from 'big.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export const DivBig = Big();
|
|
7
7
|
DivBig.DP = 40;
|
|
8
|
+
/**
|
|
9
|
+
* As `DivBig`, but truncating, so a derived amount never rounds up past the
|
|
10
|
+
* exact quotient.
|
|
11
|
+
*/
|
|
12
|
+
export const TruncBig = Big();
|
|
13
|
+
TruncBig.DP = 40;
|
|
14
|
+
TruncBig.RM = Big.roundDown;
|
|
8
15
|
/** True when every value is a finite number, so `new DivBig(value)` cannot throw. */
|
|
9
16
|
export function areFinite(...values) {
|
|
10
17
|
return values.every(Number.isFinite);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../../src/utils/decimal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAA;AAC3B,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;AAEd,qFAAqF;AACrF,MAAM,UAAU,SAAS,CAAC,GAAG,MAAgB;IAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACtC,CAAC"}
|
|
1
|
+
{"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../../src/utils/decimal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAA;AAC3B,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;AAEd;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAA;AAC7B,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAA;AAChB,QAAQ,CAAC,EAAE,GAAG,GAAG,CAAC,SAAS,CAAA;AAE3B,qFAAqF;AACrF,MAAM,UAAU,SAAS,CAAC,GAAG,MAAgB;IAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderEntry.d.ts","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"orderEntry.d.ts","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAG7B;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAE3E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAElE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAE1E"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
// Division precision well above any venue's size decimals, truncating so a
|
|
3
|
-
// derived amount never rounds up past the exact quotient.
|
|
4
|
-
const TruncBig = Big();
|
|
5
|
-
TruncBig.DP = 40;
|
|
6
|
-
TruncBig.RM = Big.roundDown;
|
|
1
|
+
import { TruncBig } from './decimal.js';
|
|
7
2
|
/**
|
|
8
3
|
* Base size the given margin buys at `leverage`: size = margin × leverage ÷ price.
|
|
9
4
|
* Truncates, so `size × price` never exceeds `margin × leverage`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderEntry.js","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orderEntry.js","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAW,EAAE,QAAgB,EAAE,KAAU;IACtE,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAS,EAAE,QAAgB,EAAE,KAAU;IACpE,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAgB,EAAE,KAAU;IAC3D,OAAO,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAgB,EAAE,QAAgB;IACnE,OAAO,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAChD,CAAC"}
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionType, Asset, WithdrawalRoute } from '@lifi/perps-types';
|
|
1
|
+
import type { ActionType, Asset, DecimalString, WithdrawalRoute } from '@lifi/perps-types';
|
|
2
2
|
import type { Address } from 'viem';
|
|
3
3
|
export type { WithdrawalRoute };
|
|
4
4
|
/**
|
|
@@ -12,13 +12,13 @@ export interface ProviderWithdrawableBalance {
|
|
|
12
12
|
assetId: string;
|
|
13
13
|
route: WithdrawalRoute;
|
|
14
14
|
/** Withdrawable amount in the asset's own units. Always greater than zero. */
|
|
15
|
-
available:
|
|
15
|
+
available: DecimalString;
|
|
16
16
|
/**
|
|
17
17
|
* Flat venue fee on a withdrawal from this row, in the asset's own units.
|
|
18
18
|
* Absent when the venue publishes no fee for the asset. The client rejects
|
|
19
19
|
* a value that is not a non-negative decimal.
|
|
20
20
|
*/
|
|
21
|
-
withdrawalFee?:
|
|
21
|
+
withdrawalFee?: DecimalString;
|
|
22
22
|
/**
|
|
23
23
|
* `true` when the venue takes `withdrawalFee` out of the requested amount,
|
|
24
24
|
* `false` when it charges the fee in addition. Set together with
|
|
@@ -37,7 +37,7 @@ export interface WithdrawableBalance {
|
|
|
37
37
|
asset: Asset;
|
|
38
38
|
route: WithdrawalRoute;
|
|
39
39
|
/** Withdrawable amount in the asset's own units. */
|
|
40
|
-
available:
|
|
40
|
+
available: DecimalString;
|
|
41
41
|
/**
|
|
42
42
|
* Flat venue fee on a withdrawal from this row, in the asset's own units.
|
|
43
43
|
* Absent when the venue publishes no fee for the asset. With
|
|
@@ -48,7 +48,7 @@ export interface WithdrawableBalance {
|
|
|
48
48
|
* is zero or negative when the fee is at or above `available`, and the row
|
|
49
49
|
* then funds no withdrawal.
|
|
50
50
|
*/
|
|
51
|
-
withdrawalFee?:
|
|
51
|
+
withdrawalFee?: DecimalString;
|
|
52
52
|
/**
|
|
53
53
|
* Present only together with `withdrawalFee`. Absent on a row from a
|
|
54
54
|
* provider plugin that does not report it; absence means unknown, not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../../../src/types/withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../../../src/types/withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,KAAK,EACL,aAAa,EACb,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,YAAY,EAAE,eAAe,EAAE,CAAA;AAE/B;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,eAAe,CAAA;IACtB,8EAA8E;IAC9E,SAAS,EAAE,aAAa,CAAA;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,eAAe,CAAA;IACtB,oDAAoD;IACpD,SAAS,EAAE,aAAa,CAAA;IACxB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,eAAe,CAAA;IACrB,qEAAqE;IACrE,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,yBAAyB,CAAA"}
|
|
@@ -4,6 +4,11 @@ import Big from 'big.js';
|
|
|
4
4
|
* shared global `Big.DP` and `Big.RM` stay untouched.
|
|
5
5
|
*/
|
|
6
6
|
export declare const DivBig: Big.BigConstructor;
|
|
7
|
+
/**
|
|
8
|
+
* As `DivBig`, but truncating, so a derived amount never rounds up past the
|
|
9
|
+
* exact quotient.
|
|
10
|
+
*/
|
|
11
|
+
export declare const TruncBig: Big.BigConstructor;
|
|
7
12
|
/** True when every value is a finite number, so `new DivBig(value)` cannot throw. */
|
|
8
13
|
export declare function areFinite(...values: number[]): boolean;
|
|
9
14
|
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../src/utils/decimal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;AAExB;;;GAGG;AACH,eAAO,MAAM,MAAM,oBAAQ,CAAA;AAG3B,qFAAqF;AACrF,wBAAgB,SAAS,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAEtD"}
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../src/utils/decimal.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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderEntry.d.ts","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"orderEntry.d.ts","sourceRoot":"","sources":["../../../src/utils/orderEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAG7B;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAE3E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAElE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAE1E"}
|
package/dist/types/version.d.ts
CHANGED
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-7bd1054",
|
|
4
4
|
"description": "LI.FI Perps SDK for perpetuals trading",
|
|
5
5
|
"homepage": "https://github.com/lifinance/perps-sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"big.js": "^7.0.1",
|
|
47
47
|
"partysocket": "^1.1.19",
|
|
48
48
|
"viem": "^2.55.18",
|
|
49
|
-
"@lifi/perps-types": "^
|
|
49
|
+
"@lifi/perps-types": "^0.0.0-preview-7bd1054"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
package/src/types/withdrawal.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ActionType,
|
|
3
|
+
Asset,
|
|
4
|
+
DecimalString,
|
|
5
|
+
WithdrawalRoute,
|
|
6
|
+
} from '@lifi/perps-types'
|
|
2
7
|
import type { Address } from 'viem'
|
|
3
8
|
|
|
4
9
|
export type { WithdrawalRoute }
|
|
@@ -14,13 +19,13 @@ export interface ProviderWithdrawableBalance {
|
|
|
14
19
|
assetId: string
|
|
15
20
|
route: WithdrawalRoute
|
|
16
21
|
/** Withdrawable amount in the asset's own units. Always greater than zero. */
|
|
17
|
-
available:
|
|
22
|
+
available: DecimalString
|
|
18
23
|
/**
|
|
19
24
|
* Flat venue fee on a withdrawal from this row, in the asset's own units.
|
|
20
25
|
* Absent when the venue publishes no fee for the asset. The client rejects
|
|
21
26
|
* a value that is not a non-negative decimal.
|
|
22
27
|
*/
|
|
23
|
-
withdrawalFee?:
|
|
28
|
+
withdrawalFee?: DecimalString
|
|
24
29
|
/**
|
|
25
30
|
* `true` when the venue takes `withdrawalFee` out of the requested amount,
|
|
26
31
|
* `false` when it charges the fee in addition. Set together with
|
|
@@ -40,7 +45,7 @@ export interface WithdrawableBalance {
|
|
|
40
45
|
asset: Asset
|
|
41
46
|
route: WithdrawalRoute
|
|
42
47
|
/** Withdrawable amount in the asset's own units. */
|
|
43
|
-
available:
|
|
48
|
+
available: DecimalString
|
|
44
49
|
/**
|
|
45
50
|
* Flat venue fee on a withdrawal from this row, in the asset's own units.
|
|
46
51
|
* Absent when the venue publishes no fee for the asset. With
|
|
@@ -51,7 +56,7 @@ export interface WithdrawableBalance {
|
|
|
51
56
|
* is zero or negative when the fee is at or above `available`, and the row
|
|
52
57
|
* then funds no withdrawal.
|
|
53
58
|
*/
|
|
54
|
-
withdrawalFee?:
|
|
59
|
+
withdrawalFee?: DecimalString
|
|
55
60
|
/**
|
|
56
61
|
* Present only together with `withdrawalFee`. Absent on a row from a
|
|
57
62
|
* provider plugin that does not report it; absence means unknown, not
|
package/src/utils/decimal.ts
CHANGED
|
@@ -7,6 +7,14 @@ import Big from 'big.js'
|
|
|
7
7
|
export const DivBig = Big()
|
|
8
8
|
DivBig.DP = 40
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* As `DivBig`, but truncating, so a derived amount never rounds up past the
|
|
12
|
+
* exact quotient.
|
|
13
|
+
*/
|
|
14
|
+
export const TruncBig = Big()
|
|
15
|
+
TruncBig.DP = 40
|
|
16
|
+
TruncBig.RM = Big.roundDown
|
|
17
|
+
|
|
10
18
|
/** True when every value is a finite number, so `new DivBig(value)` cannot throw. */
|
|
11
19
|
export function areFinite(...values: number[]): boolean {
|
|
12
20
|
return values.every(Number.isFinite)
|
package/src/utils/orderEntry.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import Big from 'big.js'
|
|
2
|
-
|
|
3
|
-
// Division precision well above any venue's size decimals, truncating so a
|
|
4
|
-
// derived amount never rounds up past the exact quotient.
|
|
5
|
-
const TruncBig = Big()
|
|
6
|
-
TruncBig.DP = 40
|
|
7
|
-
TruncBig.RM = Big.roundDown
|
|
1
|
+
import type Big from 'big.js'
|
|
2
|
+
import { TruncBig } from './decimal.js'
|
|
8
3
|
|
|
9
4
|
/**
|
|
10
5
|
* Base size the given margin buys at `leverage`: size = margin × leverage ÷ price.
|
package/src/version.ts
CHANGED