@orderly.network/perp 1.0.1 → 1.0.3
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/index.d.mts +19 -19
- package/dist/index.d.ts +19 -19
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -15,7 +15,7 @@ declare function notional(qty: number, mark_price: number): number;
|
|
|
15
15
|
* @link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Total-Notional
|
|
16
16
|
*/
|
|
17
17
|
declare function totalNotional(positions: API.Position[]): number;
|
|
18
|
-
type UnrealPnLInputs = {
|
|
18
|
+
declare type UnrealPnLInputs = {
|
|
19
19
|
markPrice: number;
|
|
20
20
|
openPrice: number;
|
|
21
21
|
qty: number;
|
|
@@ -26,7 +26,7 @@ type UnrealPnLInputs = {
|
|
|
26
26
|
* @param price 价格
|
|
27
27
|
*/
|
|
28
28
|
declare function unrealizedPnL(inputs: UnrealPnLInputs): number;
|
|
29
|
-
type UnrealPnLROIInputs = {
|
|
29
|
+
declare type UnrealPnLROIInputs = {
|
|
30
30
|
positionQty: number;
|
|
31
31
|
openPrice: number;
|
|
32
32
|
IMR: number;
|
|
@@ -38,7 +38,7 @@ declare function unrealizedPnLROI(inputs: UnrealPnLROIInputs): number;
|
|
|
38
38
|
* @param inputs
|
|
39
39
|
*/
|
|
40
40
|
declare function totalUnrealizedPnL(positions: API.Position[]): number;
|
|
41
|
-
type LiqPriceInputs = {
|
|
41
|
+
declare type LiqPriceInputs = {
|
|
42
42
|
markPrice: number;
|
|
43
43
|
totalCollateral: number;
|
|
44
44
|
positionQty: number;
|
|
@@ -50,13 +50,13 @@ type LiqPriceInputs = {
|
|
|
50
50
|
* @see {@link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Position-Liq.-Price}
|
|
51
51
|
*/
|
|
52
52
|
declare function liqPrice(inputs: LiqPriceInputs): number;
|
|
53
|
-
type MMInputs = {
|
|
53
|
+
declare type MMInputs = {
|
|
54
54
|
positionQty: number;
|
|
55
55
|
markPrice: number;
|
|
56
56
|
MMR: number;
|
|
57
57
|
};
|
|
58
58
|
declare function maintenanceMargin(inputs: MMInputs): number;
|
|
59
|
-
type UnsettlementPnLInputs = {
|
|
59
|
+
declare type UnsettlementPnLInputs = {
|
|
60
60
|
positionQty: number;
|
|
61
61
|
markPrice: number;
|
|
62
62
|
costPosition: number;
|
|
@@ -68,7 +68,7 @@ type UnsettlementPnLInputs = {
|
|
|
68
68
|
* @link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Total-Unsettlement-PNL-%5BinlineExtension%5D
|
|
69
69
|
*/
|
|
70
70
|
declare function unsettlementPnL(inputs: UnsettlementPnLInputs): number;
|
|
71
|
-
type TotalUnsettlementPnLInputs = {
|
|
71
|
+
declare type TotalUnsettlementPnLInputs = {
|
|
72
72
|
positions: (API.Position & {
|
|
73
73
|
sum_unitary_funding: number;
|
|
74
74
|
})[];
|
|
@@ -132,10 +132,10 @@ declare namespace positions {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
type ResultOptions = {
|
|
135
|
+
declare type ResultOptions = {
|
|
136
136
|
dp: number;
|
|
137
137
|
};
|
|
138
|
-
type TotalValueInputs = {
|
|
138
|
+
declare type TotalValueInputs = {
|
|
139
139
|
totalUnsettlementPnL: number;
|
|
140
140
|
USDCHolding: number;
|
|
141
141
|
nonUSDCHolding: {
|
|
@@ -154,7 +154,7 @@ declare function totalValue(inputs: TotalValueInputs): Decimal;
|
|
|
154
154
|
*
|
|
155
155
|
* @see {@link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Free-collateral}
|
|
156
156
|
*/
|
|
157
|
-
type FreeCollateralInputs = {
|
|
157
|
+
declare type FreeCollateralInputs = {
|
|
158
158
|
totalCollateral: Decimal;
|
|
159
159
|
totalInitialMarginWithOrders: number;
|
|
160
160
|
};
|
|
@@ -162,7 +162,7 @@ type FreeCollateralInputs = {
|
|
|
162
162
|
* 计算可用保证金
|
|
163
163
|
*/
|
|
164
164
|
declare function freeCollateral(inputs: FreeCollateralInputs): Decimal;
|
|
165
|
-
type TotalCollateralValueInputs = {
|
|
165
|
+
declare type TotalCollateralValueInputs = {
|
|
166
166
|
USDCHolding: number;
|
|
167
167
|
nonUSDCHolding: {
|
|
168
168
|
holding: number;
|
|
@@ -177,7 +177,7 @@ type TotalCollateralValueInputs = {
|
|
|
177
177
|
*/
|
|
178
178
|
declare function totalCollateral(inputs: TotalCollateralValueInputs): Decimal;
|
|
179
179
|
declare function initialMarginWithOrder(): void;
|
|
180
|
-
type PositionNotionalWithOrderInputs = {
|
|
180
|
+
declare type PositionNotionalWithOrderInputs = {
|
|
181
181
|
markPrice: number;
|
|
182
182
|
positionQtyWithOrders: number;
|
|
183
183
|
};
|
|
@@ -185,7 +185,7 @@ type PositionNotionalWithOrderInputs = {
|
|
|
185
185
|
* 單一 Symbol position / orders notional 加總
|
|
186
186
|
*/
|
|
187
187
|
declare function positionNotionalWithOrder_by_symbol(inputs: PositionNotionalWithOrderInputs): Decimal;
|
|
188
|
-
type PositionQtyWithOrderInputs = {
|
|
188
|
+
declare type PositionQtyWithOrderInputs = {
|
|
189
189
|
positionQty: number;
|
|
190
190
|
buyOrdersQty: number;
|
|
191
191
|
sellOrdersQty: number;
|
|
@@ -194,7 +194,7 @@ type PositionQtyWithOrderInputs = {
|
|
|
194
194
|
* 單一 Symbol position / orders qty 加總
|
|
195
195
|
*/
|
|
196
196
|
declare function positionQtyWithOrders_by_symbol(inputs: PositionQtyWithOrderInputs): number;
|
|
197
|
-
type IMRInputs = {
|
|
197
|
+
declare type IMRInputs = {
|
|
198
198
|
maxLeverage: number;
|
|
199
199
|
baseIMR: number;
|
|
200
200
|
IMR_Factor: number;
|
|
@@ -223,7 +223,7 @@ declare function getPositonsAndOrdersNotionalBySymbol(inputs: {
|
|
|
223
223
|
symbol: string;
|
|
224
224
|
markPrice: number;
|
|
225
225
|
}): number;
|
|
226
|
-
type TotalInitialMarginWithOrdersInputs = {
|
|
226
|
+
declare type TotalInitialMarginWithOrdersInputs = {
|
|
227
227
|
positions: API.Position[];
|
|
228
228
|
orders: API.Order[];
|
|
229
229
|
markPrices: {
|
|
@@ -251,7 +251,7 @@ declare function groupOrdersBySymbol(orders: API.Order[]): {
|
|
|
251
251
|
* @returns An array of unique symbols.
|
|
252
252
|
*/
|
|
253
253
|
declare function extractSymbols(positions: Pick<API.Position, "symbol">[], orders: Pick<API.Order, "symbol">[]): string[];
|
|
254
|
-
type OtherIMsInputs = {
|
|
254
|
+
declare type OtherIMsInputs = {
|
|
255
255
|
positions: API.Position[];
|
|
256
256
|
orders: API.Order[];
|
|
257
257
|
markPrices: {
|
|
@@ -267,7 +267,7 @@ type OtherIMsInputs = {
|
|
|
267
267
|
* 除当前symbol外的其他symbol已占用的总保证金
|
|
268
268
|
*/
|
|
269
269
|
declare function otherIMs(inputs: OtherIMsInputs): number;
|
|
270
|
-
type MaxQtyInputs = {
|
|
270
|
+
declare type MaxQtyInputs = {
|
|
271
271
|
symbol: string;
|
|
272
272
|
baseMaxQty: number;
|
|
273
273
|
/**
|
|
@@ -295,7 +295,7 @@ type MaxQtyInputs = {
|
|
|
295
295
|
declare function maxQty(side: OrderSide, inputs: MaxQtyInputs, options?: ResultOptions): number;
|
|
296
296
|
declare function maxQtyByLong(inputs: Omit<MaxQtyInputs, "side">): number;
|
|
297
297
|
declare function maxQtyByShort(inputs: Omit<MaxQtyInputs, "side">): number;
|
|
298
|
-
type TotalMarginRatioInputs = {
|
|
298
|
+
declare type TotalMarginRatioInputs = {
|
|
299
299
|
totalCollateral: number;
|
|
300
300
|
markPrices: {
|
|
301
301
|
[key: string]: number;
|
|
@@ -306,7 +306,7 @@ type TotalMarginRatioInputs = {
|
|
|
306
306
|
* @see {@link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Total-Margin-Ratio}
|
|
307
307
|
*/
|
|
308
308
|
declare function totalMarginRatio(inputs: TotalMarginRatioInputs, dp?: number): number;
|
|
309
|
-
type TotalUnrealizedROIInputs = {
|
|
309
|
+
declare type TotalUnrealizedROIInputs = {
|
|
310
310
|
totalUnrealizedPnL: number;
|
|
311
311
|
totalValue: number;
|
|
312
312
|
};
|
|
@@ -319,7 +319,7 @@ declare function totalUnrealizedROI(inputs: TotalUnrealizedROIInputs): number;
|
|
|
319
319
|
* @see {@link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Current-account-leverage}
|
|
320
320
|
*/
|
|
321
321
|
declare function currentLeverage(totalMarginRatio: number): number;
|
|
322
|
-
type AvailableBalanceInputs = {
|
|
322
|
+
declare type AvailableBalanceInputs = {
|
|
323
323
|
USDCHolding: number;
|
|
324
324
|
unsettlementPnL: number;
|
|
325
325
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ declare function notional(qty: number, mark_price: number): number;
|
|
|
15
15
|
* @link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Total-Notional
|
|
16
16
|
*/
|
|
17
17
|
declare function totalNotional(positions: API.Position[]): number;
|
|
18
|
-
type UnrealPnLInputs = {
|
|
18
|
+
declare type UnrealPnLInputs = {
|
|
19
19
|
markPrice: number;
|
|
20
20
|
openPrice: number;
|
|
21
21
|
qty: number;
|
|
@@ -26,7 +26,7 @@ type UnrealPnLInputs = {
|
|
|
26
26
|
* @param price 价格
|
|
27
27
|
*/
|
|
28
28
|
declare function unrealizedPnL(inputs: UnrealPnLInputs): number;
|
|
29
|
-
type UnrealPnLROIInputs = {
|
|
29
|
+
declare type UnrealPnLROIInputs = {
|
|
30
30
|
positionQty: number;
|
|
31
31
|
openPrice: number;
|
|
32
32
|
IMR: number;
|
|
@@ -38,7 +38,7 @@ declare function unrealizedPnLROI(inputs: UnrealPnLROIInputs): number;
|
|
|
38
38
|
* @param inputs
|
|
39
39
|
*/
|
|
40
40
|
declare function totalUnrealizedPnL(positions: API.Position[]): number;
|
|
41
|
-
type LiqPriceInputs = {
|
|
41
|
+
declare type LiqPriceInputs = {
|
|
42
42
|
markPrice: number;
|
|
43
43
|
totalCollateral: number;
|
|
44
44
|
positionQty: number;
|
|
@@ -50,13 +50,13 @@ type LiqPriceInputs = {
|
|
|
50
50
|
* @see {@link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Position-Liq.-Price}
|
|
51
51
|
*/
|
|
52
52
|
declare function liqPrice(inputs: LiqPriceInputs): number;
|
|
53
|
-
type MMInputs = {
|
|
53
|
+
declare type MMInputs = {
|
|
54
54
|
positionQty: number;
|
|
55
55
|
markPrice: number;
|
|
56
56
|
MMR: number;
|
|
57
57
|
};
|
|
58
58
|
declare function maintenanceMargin(inputs: MMInputs): number;
|
|
59
|
-
type UnsettlementPnLInputs = {
|
|
59
|
+
declare type UnsettlementPnLInputs = {
|
|
60
60
|
positionQty: number;
|
|
61
61
|
markPrice: number;
|
|
62
62
|
costPosition: number;
|
|
@@ -68,7 +68,7 @@ type UnsettlementPnLInputs = {
|
|
|
68
68
|
* @link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Total-Unsettlement-PNL-%5BinlineExtension%5D
|
|
69
69
|
*/
|
|
70
70
|
declare function unsettlementPnL(inputs: UnsettlementPnLInputs): number;
|
|
71
|
-
type TotalUnsettlementPnLInputs = {
|
|
71
|
+
declare type TotalUnsettlementPnLInputs = {
|
|
72
72
|
positions: (API.Position & {
|
|
73
73
|
sum_unitary_funding: number;
|
|
74
74
|
})[];
|
|
@@ -132,10 +132,10 @@ declare namespace positions {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
type ResultOptions = {
|
|
135
|
+
declare type ResultOptions = {
|
|
136
136
|
dp: number;
|
|
137
137
|
};
|
|
138
|
-
type TotalValueInputs = {
|
|
138
|
+
declare type TotalValueInputs = {
|
|
139
139
|
totalUnsettlementPnL: number;
|
|
140
140
|
USDCHolding: number;
|
|
141
141
|
nonUSDCHolding: {
|
|
@@ -154,7 +154,7 @@ declare function totalValue(inputs: TotalValueInputs): Decimal;
|
|
|
154
154
|
*
|
|
155
155
|
* @see {@link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Free-collateral}
|
|
156
156
|
*/
|
|
157
|
-
type FreeCollateralInputs = {
|
|
157
|
+
declare type FreeCollateralInputs = {
|
|
158
158
|
totalCollateral: Decimal;
|
|
159
159
|
totalInitialMarginWithOrders: number;
|
|
160
160
|
};
|
|
@@ -162,7 +162,7 @@ type FreeCollateralInputs = {
|
|
|
162
162
|
* 计算可用保证金
|
|
163
163
|
*/
|
|
164
164
|
declare function freeCollateral(inputs: FreeCollateralInputs): Decimal;
|
|
165
|
-
type TotalCollateralValueInputs = {
|
|
165
|
+
declare type TotalCollateralValueInputs = {
|
|
166
166
|
USDCHolding: number;
|
|
167
167
|
nonUSDCHolding: {
|
|
168
168
|
holding: number;
|
|
@@ -177,7 +177,7 @@ type TotalCollateralValueInputs = {
|
|
|
177
177
|
*/
|
|
178
178
|
declare function totalCollateral(inputs: TotalCollateralValueInputs): Decimal;
|
|
179
179
|
declare function initialMarginWithOrder(): void;
|
|
180
|
-
type PositionNotionalWithOrderInputs = {
|
|
180
|
+
declare type PositionNotionalWithOrderInputs = {
|
|
181
181
|
markPrice: number;
|
|
182
182
|
positionQtyWithOrders: number;
|
|
183
183
|
};
|
|
@@ -185,7 +185,7 @@ type PositionNotionalWithOrderInputs = {
|
|
|
185
185
|
* 單一 Symbol position / orders notional 加總
|
|
186
186
|
*/
|
|
187
187
|
declare function positionNotionalWithOrder_by_symbol(inputs: PositionNotionalWithOrderInputs): Decimal;
|
|
188
|
-
type PositionQtyWithOrderInputs = {
|
|
188
|
+
declare type PositionQtyWithOrderInputs = {
|
|
189
189
|
positionQty: number;
|
|
190
190
|
buyOrdersQty: number;
|
|
191
191
|
sellOrdersQty: number;
|
|
@@ -194,7 +194,7 @@ type PositionQtyWithOrderInputs = {
|
|
|
194
194
|
* 單一 Symbol position / orders qty 加總
|
|
195
195
|
*/
|
|
196
196
|
declare function positionQtyWithOrders_by_symbol(inputs: PositionQtyWithOrderInputs): number;
|
|
197
|
-
type IMRInputs = {
|
|
197
|
+
declare type IMRInputs = {
|
|
198
198
|
maxLeverage: number;
|
|
199
199
|
baseIMR: number;
|
|
200
200
|
IMR_Factor: number;
|
|
@@ -223,7 +223,7 @@ declare function getPositonsAndOrdersNotionalBySymbol(inputs: {
|
|
|
223
223
|
symbol: string;
|
|
224
224
|
markPrice: number;
|
|
225
225
|
}): number;
|
|
226
|
-
type TotalInitialMarginWithOrdersInputs = {
|
|
226
|
+
declare type TotalInitialMarginWithOrdersInputs = {
|
|
227
227
|
positions: API.Position[];
|
|
228
228
|
orders: API.Order[];
|
|
229
229
|
markPrices: {
|
|
@@ -251,7 +251,7 @@ declare function groupOrdersBySymbol(orders: API.Order[]): {
|
|
|
251
251
|
* @returns An array of unique symbols.
|
|
252
252
|
*/
|
|
253
253
|
declare function extractSymbols(positions: Pick<API.Position, "symbol">[], orders: Pick<API.Order, "symbol">[]): string[];
|
|
254
|
-
type OtherIMsInputs = {
|
|
254
|
+
declare type OtherIMsInputs = {
|
|
255
255
|
positions: API.Position[];
|
|
256
256
|
orders: API.Order[];
|
|
257
257
|
markPrices: {
|
|
@@ -267,7 +267,7 @@ type OtherIMsInputs = {
|
|
|
267
267
|
* 除当前symbol外的其他symbol已占用的总保证金
|
|
268
268
|
*/
|
|
269
269
|
declare function otherIMs(inputs: OtherIMsInputs): number;
|
|
270
|
-
type MaxQtyInputs = {
|
|
270
|
+
declare type MaxQtyInputs = {
|
|
271
271
|
symbol: string;
|
|
272
272
|
baseMaxQty: number;
|
|
273
273
|
/**
|
|
@@ -295,7 +295,7 @@ type MaxQtyInputs = {
|
|
|
295
295
|
declare function maxQty(side: OrderSide, inputs: MaxQtyInputs, options?: ResultOptions): number;
|
|
296
296
|
declare function maxQtyByLong(inputs: Omit<MaxQtyInputs, "side">): number;
|
|
297
297
|
declare function maxQtyByShort(inputs: Omit<MaxQtyInputs, "side">): number;
|
|
298
|
-
type TotalMarginRatioInputs = {
|
|
298
|
+
declare type TotalMarginRatioInputs = {
|
|
299
299
|
totalCollateral: number;
|
|
300
300
|
markPrices: {
|
|
301
301
|
[key: string]: number;
|
|
@@ -306,7 +306,7 @@ type TotalMarginRatioInputs = {
|
|
|
306
306
|
* @see {@link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Total-Margin-Ratio}
|
|
307
307
|
*/
|
|
308
308
|
declare function totalMarginRatio(inputs: TotalMarginRatioInputs, dp?: number): number;
|
|
309
|
-
type TotalUnrealizedROIInputs = {
|
|
309
|
+
declare type TotalUnrealizedROIInputs = {
|
|
310
310
|
totalUnrealizedPnL: number;
|
|
311
311
|
totalValue: number;
|
|
312
312
|
};
|
|
@@ -319,7 +319,7 @@ declare function totalUnrealizedROI(inputs: TotalUnrealizedROIInputs): number;
|
|
|
319
319
|
* @see {@link https://wootraders.atlassian.net/wiki/spaces/WOOFI/pages/346030144/v2#Current-account-leverage}
|
|
320
320
|
*/
|
|
321
321
|
declare function currentLeverage(totalMarginRatio: number): number;
|
|
322
|
-
type AvailableBalanceInputs = {
|
|
322
|
+
declare type AvailableBalanceInputs = {
|
|
323
323
|
USDCHolding: number;
|
|
324
324
|
unsettlementPnL: number;
|
|
325
325
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orderly.network/perp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"author": "leo",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@orderly.network/types": "0.1.
|
|
11
|
+
"@orderly.network/types": "0.1.3"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"tsconfig": "0.0.82"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@orderly.network/types": "0.1.
|
|
29
|
+
"@orderly.network/types": "0.1.3",
|
|
30
30
|
"@orderly.network/utils": "0.0.75"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|