@reyaxyz/common 0.302.0 → 0.302.1
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 +1 -1
- package/dist/commands/exposure/command.js +13 -0
- package/dist/commands/exposure/command.js.map +1 -1
- package/dist/trading-api-types.js.map +1 -1
- package/dist/types/commands/exposure/command.d.ts +2 -0
- package/dist/types/commands/exposure/command.d.ts.map +1 -1
- package/dist/types/trading-api-types.d.ts +4 -0
- package/dist/types/trading-api-types.d.ts.map +1 -1
- package/dist/types/types.d.ts +14 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/calculate.d.ts +2 -0
- package/dist/types/utils/calculate.d.ts.map +1 -1
- package/dist/types/utils/consts.d.ts +2 -1
- package/dist/types/utils/consts.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/calculate.js +5 -1
- package/dist/utils/calculate.js.map +1 -1
- package/dist/utils/consts.js +12 -1
- package/dist/utils/consts.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/exposure/command.ts +29 -0
- package/src/trading-api-types.ts +4 -0
- package/src/types.ts +29 -2
- package/src/utils/calculate.ts +9 -0
- package/src/utils/consts.ts +13 -0
package/src/trading-api-types.ts
CHANGED
|
@@ -43,6 +43,8 @@ type Order = {
|
|
|
43
43
|
block_timestamp: Decimal | null;
|
|
44
44
|
block_number: Decimal;
|
|
45
45
|
unique_id: bigint | null;
|
|
46
|
+
event_sequence_number: bigint | null;
|
|
47
|
+
exchange_id: Decimal | null;
|
|
46
48
|
created_at: Date;
|
|
47
49
|
};
|
|
48
50
|
|
|
@@ -160,6 +162,8 @@ type MarketData = {
|
|
|
160
162
|
openInterest?: number;
|
|
161
163
|
fundingRate?: number;
|
|
162
164
|
fundingRateVelocity?: number;
|
|
165
|
+
longFundingValue?: number;
|
|
166
|
+
shortFundingValue?: number;
|
|
163
167
|
last24hVolume: number;
|
|
164
168
|
priceChange24H?: number;
|
|
165
169
|
priceChange24HPercentage?: number;
|
package/src/types.ts
CHANGED
|
@@ -830,6 +830,11 @@ export enum ConditionalOrderStatus {
|
|
|
830
830
|
REJECTED = 'rejected',
|
|
831
831
|
}
|
|
832
832
|
|
|
833
|
+
export enum TierType {
|
|
834
|
+
REGULAR = 'REGULAR',
|
|
835
|
+
VIP = 'VIP',
|
|
836
|
+
}
|
|
837
|
+
|
|
833
838
|
export type ConditionalOrder = {
|
|
834
839
|
orderId: string;
|
|
835
840
|
accountId: number;
|
|
@@ -1101,10 +1106,15 @@ export type AssetPair =
|
|
|
1101
1106
|
| 'WLFIUSDMARK'
|
|
1102
1107
|
| 'LINEAUSDMARK';
|
|
1103
1108
|
|
|
1104
|
-
export type DerivedAssetPair = 'SDEUSDUSD';
|
|
1105
|
-
|
|
1106
1109
|
export type ContractId = string;
|
|
1107
1110
|
|
|
1111
|
+
export type Price = {
|
|
1112
|
+
symbol: number;
|
|
1113
|
+
oraclePrice: string;
|
|
1114
|
+
poolPrice: string | null;
|
|
1115
|
+
updatedAt: number;
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1108
1118
|
export type MarketPrice = {
|
|
1109
1119
|
marketId: number;
|
|
1110
1120
|
price: string;
|
|
@@ -1132,3 +1142,20 @@ export type ConditionalOrderSensitive = Unpacked<
|
|
|
1132
1142
|
>;
|
|
1133
1143
|
|
|
1134
1144
|
export type Position = Unpacked<Replication['replication:position']['result']>;
|
|
1145
|
+
|
|
1146
|
+
// Stringified replication data types for WebSocket transformers
|
|
1147
|
+
export type PositionReplicationData = Stringified<
|
|
1148
|
+
Unpacked<Replication['replication:position']['result']>
|
|
1149
|
+
>;
|
|
1150
|
+
|
|
1151
|
+
export type OrderReplicationData = Stringified<
|
|
1152
|
+
Unpacked<Replication['replication:ConditionalOrdersSensitive']['result']>
|
|
1153
|
+
>;
|
|
1154
|
+
|
|
1155
|
+
export type TradeReplicationData = Stringified<
|
|
1156
|
+
Unpacked<Replication['replication:orders']['result']>
|
|
1157
|
+
>;
|
|
1158
|
+
|
|
1159
|
+
export type MarketDataReplicationData = Stringified<
|
|
1160
|
+
Unpacked<Replication['replication:marketData']['result']>
|
|
1161
|
+
>;
|
package/src/utils/calculate.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mergeMap } from './struct';
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
2
3
|
|
|
3
4
|
export const POOL_IMR = 9.1;
|
|
4
5
|
|
|
@@ -311,6 +312,14 @@ export const calculateTotalMargin = ({
|
|
|
311
312
|
);
|
|
312
313
|
};
|
|
313
314
|
|
|
315
|
+
export const calculatePositionAdjustedQty = (
|
|
316
|
+
origQty: BigNumber,
|
|
317
|
+
marketBaseMultiplier: BigNumber,
|
|
318
|
+
positionBaseMultiplier: BigNumber,
|
|
319
|
+
) => {
|
|
320
|
+
return origQty.times(marketBaseMultiplier).div(positionBaseMultiplier);
|
|
321
|
+
};
|
|
322
|
+
|
|
314
323
|
export const calculateFundingPnl = (
|
|
315
324
|
fundingValue: number,
|
|
316
325
|
positionAvgEntryFundingValue: number,
|
package/src/utils/consts.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ConditionalOrderTypeName,
|
|
4
4
|
Rank,
|
|
5
5
|
RankTrading,
|
|
6
|
+
TierType,
|
|
6
7
|
} from '../types';
|
|
7
8
|
|
|
8
9
|
export const MAX_UINT128 = 2 ** 128 - 1;
|
|
@@ -132,6 +133,18 @@ export const VOLUME_TIER_MAP: Record<number, number> = {
|
|
|
132
133
|
6: 1_000_000_000, // Tier 6: $1,000,000,000 volume
|
|
133
134
|
};
|
|
134
135
|
|
|
136
|
+
export const TIER_TYPE_MAP: Record<number, TierType> = {
|
|
137
|
+
0: TierType.REGULAR,
|
|
138
|
+
1: TierType.REGULAR,
|
|
139
|
+
2: TierType.REGULAR,
|
|
140
|
+
3: TierType.REGULAR,
|
|
141
|
+
4: TierType.REGULAR,
|
|
142
|
+
5: TierType.REGULAR,
|
|
143
|
+
6: TierType.REGULAR,
|
|
144
|
+
100: TierType.VIP,
|
|
145
|
+
101: TierType.VIP,
|
|
146
|
+
};
|
|
147
|
+
|
|
135
148
|
export const SPECIAL_TIER_THRESHOLD = 100;
|
|
136
149
|
|
|
137
150
|
export const MA_HEALTH_DANGER_THRESHOLD = 95;
|