@reyaxyz/common 0.5.0 → 0.6.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/dist/services/getSocketAddresses.js +38 -0
- package/dist/services/getSocketAddresses.js.map +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -1
- package/dist/types/services/getSocketAddresses.d.ts +4 -0
- package/dist/types/services/getSocketAddresses.d.ts.map +1 -0
- package/dist/types/services/index.d.ts +1 -0
- package/dist/types/services/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +25 -7
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/services/getSocketAddresses.ts +44 -0
- package/src/services/index.ts +1 -0
- package/src/types.ts +36 -7
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getSocketController = exports.getSocketConnector = void 0;
|
|
5
|
+
var types_1 = require("../types");
|
|
6
|
+
// TODO: add proper config
|
|
7
|
+
var socketConnectors = (_a = {},
|
|
8
|
+
_a[types_1.ReyaChainId.polygonMumbai] = {
|
|
9
|
+
'': '',
|
|
10
|
+
},
|
|
11
|
+
_a[types_1.ReyaChainId.reyaCronos] = {
|
|
12
|
+
'': '',
|
|
13
|
+
},
|
|
14
|
+
_a[types_1.ReyaChainId.reyaNetwork] = {
|
|
15
|
+
'': '',
|
|
16
|
+
},
|
|
17
|
+
_a);
|
|
18
|
+
var getSocketConnector = function (params) {
|
|
19
|
+
return socketConnectors[params.reyaChainId][params.tokenAddress];
|
|
20
|
+
};
|
|
21
|
+
exports.getSocketConnector = getSocketConnector;
|
|
22
|
+
// TODO: add proper config
|
|
23
|
+
var socketControllers = (_b = {},
|
|
24
|
+
_b[types_1.ReyaChainId.polygonMumbai] = {
|
|
25
|
+
'': '',
|
|
26
|
+
},
|
|
27
|
+
_b[types_1.ReyaChainId.reyaCronos] = {
|
|
28
|
+
'': '',
|
|
29
|
+
},
|
|
30
|
+
_b[types_1.ReyaChainId.reyaNetwork] = {
|
|
31
|
+
'': '',
|
|
32
|
+
},
|
|
33
|
+
_b);
|
|
34
|
+
var getSocketController = function (params) {
|
|
35
|
+
return socketControllers[params.reyaChainId][params.tokenAddress];
|
|
36
|
+
};
|
|
37
|
+
exports.getSocketController = getSocketController;
|
|
38
|
+
//# sourceMappingURL=getSocketAddresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSocketAddresses.js","sourceRoot":"/","sources":["services/getSocketAddresses.ts"],"names":[],"mappings":";;;;AAAA,kCAKkB;AAElB,0BAA0B;AAC1B,IAAM,gBAAgB;IACpB,GAAC,mBAAW,CAAC,aAAa,IAAG;QAC3B,EAAE,EAAE,EAAE;KACP;IACD,GAAC,mBAAW,CAAC,UAAU,IAAG;QACxB,EAAE,EAAE,EAAE;KACP;IACD,GAAC,mBAAW,CAAC,WAAW,IAAG;QACzB,EAAE,EAAE,EAAE;KACP;OACF,CAAC;AAEK,IAAM,kBAAkB,GAAG,UAChC,MAAgC;IAEhC,OAAO,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACnE,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B;AAEF,0BAA0B;AAC1B,IAAM,iBAAiB;IACrB,GAAC,mBAAW,CAAC,aAAa,IAAG;QAC3B,EAAE,EAAE,EAAE;KACP;IACD,GAAC,mBAAW,CAAC,UAAU,IAAG;QACxB,EAAE,EAAE,EAAE;KACP;IACD,GAAC,mBAAW,CAAC,WAAW,IAAG;QACzB,EAAE,EAAE,EAAE;KACP;OACF,CAAC;AAEK,IAAM,mBAAmB,GAAG,UACjC,MAAiC;IAEjC,OAAO,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACpE,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import {\n ReyaChainId,\n GetSocketConnectorParams,\n Address,\n GetSocketControllerParams,\n} from '../types';\n\n// TODO: add proper config\nconst socketConnectors: Record<ReyaChainId, Record<Address, Address>> = {\n [ReyaChainId.polygonMumbai]: {\n '': '',\n },\n [ReyaChainId.reyaCronos]: {\n '': '',\n },\n [ReyaChainId.reyaNetwork]: {\n '': '',\n },\n};\n\nexport const getSocketConnector = (\n params: GetSocketConnectorParams,\n): string => {\n return socketConnectors[params.reyaChainId][params.tokenAddress];\n};\n\n// TODO: add proper config\nconst socketControllers: Record<ReyaChainId, Record<Address, Address>> = {\n [ReyaChainId.polygonMumbai]: {\n '': '',\n },\n [ReyaChainId.reyaCronos]: {\n '': '',\n },\n [ReyaChainId.reyaNetwork]: {\n '': '',\n },\n};\n\nexport const getSocketController = (\n params: GetSocketControllerParams,\n): string => {\n return socketControllers[params.reyaChainId][params.tokenAddress];\n};\n"]}
|
package/dist/services/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./getAllowedChainsForMoneyInOut"), exports);
|
|
18
|
+
__exportStar(require("./getSocketAddresses"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD","sourcesContent":["export * from './getAllowedChainsForMoneyInOut';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,uDAAqC","sourcesContent":["export * from './getAllowedChainsForMoneyInOut';\nexport * from './getSocketAddresses';\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GetSocketConnectorParams, GetSocketControllerParams } from '../types';
|
|
2
|
+
export declare const getSocketConnector: (params: GetSocketConnectorParams) => string;
|
|
3
|
+
export declare const getSocketController: (params: GetSocketControllerParams) => string;
|
|
4
|
+
//# sourceMappingURL=getSocketAddresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSocketAddresses.d.ts","sourceRoot":"/","sources":["services/getSocketAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,EAExB,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAelB,eAAO,MAAM,kBAAkB,WACrB,wBAAwB,KAC/B,MAEF,CAAC;AAeF,eAAO,MAAM,mBAAmB,WACtB,yBAAyB,KAChC,MAEF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type Address = Lowercase<string>;
|
|
1
2
|
export type MarketOrderInfo = {
|
|
2
3
|
counterpartyAccountIds: number[];
|
|
3
4
|
exchangeId: number;
|
|
@@ -52,6 +53,14 @@ export interface Candle {
|
|
|
52
53
|
}
|
|
53
54
|
export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
|
|
54
55
|
export type Side = 'long' | 'short';
|
|
56
|
+
export type CollateralEntity = {
|
|
57
|
+
token: string;
|
|
58
|
+
percentage: number;
|
|
59
|
+
balance: number;
|
|
60
|
+
balanceRUSD: number;
|
|
61
|
+
exchangeRate: number;
|
|
62
|
+
exchangeRateChange24HPercentage: number;
|
|
63
|
+
};
|
|
55
64
|
export type MarginAccountEntity = {
|
|
56
65
|
id: number;
|
|
57
66
|
name: string;
|
|
@@ -59,12 +68,13 @@ export type MarginAccountEntity = {
|
|
|
59
68
|
marginRatioPercentage: number;
|
|
60
69
|
totalBalance: number;
|
|
61
70
|
totalBalanceUnderlyingAsset: string;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
totalBalanceChange24HPercentage: 5;
|
|
72
|
+
livePnL: number;
|
|
73
|
+
livePnLUnderlyingAsset: string;
|
|
74
|
+
realizedPnL: number;
|
|
75
|
+
realizedPnLUnderlyingAsset: string;
|
|
76
|
+
totalPositionsCount: number;
|
|
77
|
+
collaterals: CollateralEntity[];
|
|
68
78
|
};
|
|
69
79
|
export type PositionEntity = {
|
|
70
80
|
id: number;
|
|
@@ -143,7 +153,7 @@ export type MarginAccountTransactionHistoryEntity = {
|
|
|
143
153
|
};
|
|
144
154
|
export type TokenEntity = {
|
|
145
155
|
id: string;
|
|
146
|
-
address:
|
|
156
|
+
address: Address;
|
|
147
157
|
};
|
|
148
158
|
export declare enum BalanceGranularity {
|
|
149
159
|
ONE_MINUTE = 60000,
|
|
@@ -177,4 +187,12 @@ export type GetLpPoolPerformanceChartDataResult = {
|
|
|
177
187
|
capitalInvested: number;
|
|
178
188
|
capitalInvestedChangePercentage: number;
|
|
179
189
|
};
|
|
190
|
+
export type GetSocketConnectorParams = {
|
|
191
|
+
reyaChainId: ReyaChainId;
|
|
192
|
+
tokenAddress: Address;
|
|
193
|
+
};
|
|
194
|
+
export type GetSocketControllerParams = {
|
|
195
|
+
reyaChainId: ReyaChainId;
|
|
196
|
+
tokenAddress: Address;
|
|
197
|
+
};
|
|
180
198
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":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AE;QACJ,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,GAAG,EAAE,MAAM,CAAC;IACZ,mBAAmB,EAAE,MAAM,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAIF,MAAM,MAAM,mCAAmC,GAAG;IAChD,mBAAmB,EAAE;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,WAAW,EAAE;QACX,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB,EAAE,MAAM,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,+BAA+B,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":";;;AA0BA,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,mEAAqB,CAAA;IACrB,gCAAgC;IAChC,4DAAgB,CAAA;IAChB,4DAAiB,CAAA;AACnB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC3B,sFAA0B,CAAA;AAC5B,CAAC,EAFW,iBAAiB,iCAAjB,iBAAiB,QAE5B;AAED,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,2CAAsB,CAAA;IACtB,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,uCAAkB,CAAA;IAClB,0CAAqB,CAAA;IACrB,qCAAgB,CAAA;AAClB,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B;AAyJD,6GAA6G;AAC7G,0BAA0B;AAC1B,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,2EAAsB,CAAA;IACtB,yEAAyB,CAAA;IACzB,wEAA6B,CAAA;IAC7B,2EAAkC,CAAA;IAClC,8EAAoC,CAAA;IACpC,6EAAoC,CAAA;AACtC,CAAC,EAPW,kBAAkB,kCAAlB,kBAAkB,QAO7B","sourcesContent":["export type Address = Lowercase<string>;\n\n// -- Markets --\nexport type MarketOrderInfo = {\n counterpartyAccountIds: number[];\n exchangeId: number;\n};\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n description: string;\n orderInfo: MarketOrderInfo;\n tickSizeDecimals: number;\n};\n\nexport enum ReyaChainId {\n polygonMumbai = 80001,\n // TODO: add the correct ID here\n reyaNetwork = -1,\n reyaCronos = 1729,\n}\n\nexport enum MoneyInOutChainId {\n ethereumSepolia = 11155111,\n}\n\nexport enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n id: string;\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n}\n\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'long' | 'short';\n\nexport type CollateralEntity = {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n // TODO: Milan evaluate type\n exchangeRate: number;\n // TODO: Milan evaluate type\n exchangeRateChange24HPercentage: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n totalBalanceChange24HPercentage: 5;\n // TODO: Milan evaluate type\n livePnL: number;\n // TODO: Milan evaluate type\n livePnLUnderlyingAsset: string;\n // TODO: Milan evaluate type\n realizedPnL: number;\n // TODO: Milan evaluate type\n realizedPnLUnderlyingAsset: string;\n // TODO: Milan evaluate type\n totalPositionsCount: number;\n collaterals: CollateralEntity[];\n};\n\nexport type PositionEntity = {\n id: number;\n side: Side;\n size: number;\n base: number;\n price: number;\n markPrice: number;\n orderStatus: Status;\n realisedPnl?: number | null;\n unrealisedPnl?: number | null;\n liquidationPrice: number;\n fundingRate: number;\n market: MarketEntity;\n date: Date;\n};\n\nexport type TradingHistoryEntity = {\n id: number;\n price: number;\n priceUnderlyingToken: string;\n size: number;\n sizeUnderlyingToken: string;\n timestampMillisecondsUTC: number;\n};\n\nexport type OrderType = 'market';\n\nexport type PositionHistoryType =\n | 'long-trade'\n | 'short-trade'\n | 'long-liquidation'\n | 'short-liquidation';\n\nexport type PositionHistoryEntity = {\n id: number;\n action: PositionHistoryType;\n orderType: OrderType;\n size: number;\n executionPrice: number;\n realisedPnl?: number | null;\n fees: number;\n timestamp: number;\n market: MarketEntity;\n};\n\nexport type LpPoolEntity = {\n id: number;\n name: string;\n description: string;\n longDescription: string;\n readMoreLink: string;\n currentAPY: number;\n balanceSupplied?: number | null;\n apyChange24H: number;\n tokenAddress: string;\n token: string;\n allowedChainsForLiquidity: MoneyInOutChainId[];\n};\n\nexport type TransactionHistoryType = 'deposit' | 'withdrawal';\n\nexport type LpTransactionHistoryEntity = {\n id: number;\n type: TransactionHistoryType;\n token: string;\n amount: number;\n transactionHash: string;\n timestamp: number;\n};\n\nexport type LpPositionEntity = {\n id: number;\n deposited: number;\n currentBalance: number;\n pnl: number;\n fundingRate: number;\n lpPool: LpPoolEntity;\n};\n\nexport type MarginAccountTransactionHistoryType =\n | 'deposit'\n | 'withdrawal'\n | 'transfer'\n | 'auto_exchange';\n\nexport type MarginAccountTransactionHistoryEntity = {\n id: number;\n type: MarginAccountTransactionHistoryType;\n token: string;\n amount: number;\n transactionHash: string;\n timestamp: number;\n};\n\nexport type TokenEntity = {\n id: string;\n address: Address;\n};\n// TODO: Milan evaluate if these need to be in common. At moment of writting it was shared in api and api-sdk\n// --- Lp Pool Balance ---\nexport enum BalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n// TODO: Milan evaluate if these need to be in common. At moment of writting it was shared in api and api-sdk\nexport type GetLpPoolBalanceChartDataResult = {\n data: {\n timestampInMs: number;\n value: number;\n }[];\n tvl: number;\n tvlChangePercentage: number;\n apy: number;\n apyChangePercentage: number;\n};\n\n// TODO: Milan evaluate if these need to be in common. At moment of writting it was shared in api and api-sdk\n// - LP Account Performance -\nexport type GetLpPoolPerformanceChartDataResult = {\n capitalInvestedData: {\n timestampInMs: number;\n value: number;\n }[];\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n capitalInvested: number;\n capitalInvestedChangePercentage: number;\n};\n\nexport type GetSocketConnectorParams = {\n reyaChainId: ReyaChainId;\n tokenAddress: Address;\n};\n\nexport type GetSocketControllerParams = {\n reyaChainId: ReyaChainId;\n tokenAddress: Address;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
41
41
|
},
|
|
42
42
|
"packageManager": "pnpm@8.10.4",
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "c21f595afd7fbe3a31cebc5d1ff632c75ff8c7e7"
|
|
44
44
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReyaChainId,
|
|
3
|
+
GetSocketConnectorParams,
|
|
4
|
+
Address,
|
|
5
|
+
GetSocketControllerParams,
|
|
6
|
+
} from '../types';
|
|
7
|
+
|
|
8
|
+
// TODO: add proper config
|
|
9
|
+
const socketConnectors: Record<ReyaChainId, Record<Address, Address>> = {
|
|
10
|
+
[ReyaChainId.polygonMumbai]: {
|
|
11
|
+
'': '',
|
|
12
|
+
},
|
|
13
|
+
[ReyaChainId.reyaCronos]: {
|
|
14
|
+
'': '',
|
|
15
|
+
},
|
|
16
|
+
[ReyaChainId.reyaNetwork]: {
|
|
17
|
+
'': '',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const getSocketConnector = (
|
|
22
|
+
params: GetSocketConnectorParams,
|
|
23
|
+
): string => {
|
|
24
|
+
return socketConnectors[params.reyaChainId][params.tokenAddress];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// TODO: add proper config
|
|
28
|
+
const socketControllers: Record<ReyaChainId, Record<Address, Address>> = {
|
|
29
|
+
[ReyaChainId.polygonMumbai]: {
|
|
30
|
+
'': '',
|
|
31
|
+
},
|
|
32
|
+
[ReyaChainId.reyaCronos]: {
|
|
33
|
+
'': '',
|
|
34
|
+
},
|
|
35
|
+
[ReyaChainId.reyaNetwork]: {
|
|
36
|
+
'': '',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const getSocketController = (
|
|
41
|
+
params: GetSocketControllerParams,
|
|
42
|
+
): string => {
|
|
43
|
+
return socketControllers[params.reyaChainId][params.tokenAddress];
|
|
44
|
+
};
|
package/src/services/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type Address = Lowercase<string>;
|
|
2
|
+
|
|
1
3
|
// -- Markets --
|
|
2
4
|
export type MarketOrderInfo = {
|
|
3
5
|
counterpartyAccountIds: number[];
|
|
@@ -64,6 +66,17 @@ export interface Candle {
|
|
|
64
66
|
export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
|
|
65
67
|
export type Side = 'long' | 'short';
|
|
66
68
|
|
|
69
|
+
export type CollateralEntity = {
|
|
70
|
+
token: string;
|
|
71
|
+
percentage: number;
|
|
72
|
+
balance: number;
|
|
73
|
+
balanceRUSD: number;
|
|
74
|
+
// TODO: Milan evaluate type
|
|
75
|
+
exchangeRate: number;
|
|
76
|
+
// TODO: Milan evaluate type
|
|
77
|
+
exchangeRateChange24HPercentage: number;
|
|
78
|
+
};
|
|
79
|
+
|
|
67
80
|
export type MarginAccountEntity = {
|
|
68
81
|
id: number;
|
|
69
82
|
name: string;
|
|
@@ -71,12 +84,18 @@ export type MarginAccountEntity = {
|
|
|
71
84
|
marginRatioPercentage: number;
|
|
72
85
|
totalBalance: number;
|
|
73
86
|
totalBalanceUnderlyingAsset: string;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
totalBalanceChange24HPercentage: 5;
|
|
88
|
+
// TODO: Milan evaluate type
|
|
89
|
+
livePnL: number;
|
|
90
|
+
// TODO: Milan evaluate type
|
|
91
|
+
livePnLUnderlyingAsset: string;
|
|
92
|
+
// TODO: Milan evaluate type
|
|
93
|
+
realizedPnL: number;
|
|
94
|
+
// TODO: Milan evaluate type
|
|
95
|
+
realizedPnLUnderlyingAsset: string;
|
|
96
|
+
// TODO: Milan evaluate type
|
|
97
|
+
totalPositionsCount: number;
|
|
98
|
+
collaterals: CollateralEntity[];
|
|
80
99
|
};
|
|
81
100
|
|
|
82
101
|
export type PositionEntity = {
|
|
@@ -175,7 +194,7 @@ export type MarginAccountTransactionHistoryEntity = {
|
|
|
175
194
|
|
|
176
195
|
export type TokenEntity = {
|
|
177
196
|
id: string;
|
|
178
|
-
address:
|
|
197
|
+
address: Address;
|
|
179
198
|
};
|
|
180
199
|
// TODO: Milan evaluate if these need to be in common. At moment of writting it was shared in api and api-sdk
|
|
181
200
|
// --- Lp Pool Balance ---
|
|
@@ -215,3 +234,13 @@ export type GetLpPoolPerformanceChartDataResult = {
|
|
|
215
234
|
capitalInvested: number;
|
|
216
235
|
capitalInvestedChangePercentage: number;
|
|
217
236
|
};
|
|
237
|
+
|
|
238
|
+
export type GetSocketConnectorParams = {
|
|
239
|
+
reyaChainId: ReyaChainId;
|
|
240
|
+
tokenAddress: Address;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export type GetSocketControllerParams = {
|
|
244
|
+
reyaChainId: ReyaChainId;
|
|
245
|
+
tokenAddress: Address;
|
|
246
|
+
};
|