@reyaxyz/common 0.1.0

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.
Files changed (43) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +18 -0
  3. package/dist/commands/exposure/command.js +448 -0
  4. package/dist/commands/exposure/command.js.map +1 -0
  5. package/dist/commands/exposure/index.js +19 -0
  6. package/dist/commands/exposure/index.js.map +1 -0
  7. package/dist/commands/exposure/types.js +3 -0
  8. package/dist/commands/exposure/types.js.map +1 -0
  9. package/dist/commands/index.js +18 -0
  10. package/dist/commands/index.js.map +1 -0
  11. package/dist/index.js +20 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/types/commands/exposure/command.d.ts +58 -0
  14. package/dist/types/commands/exposure/command.d.ts.map +1 -0
  15. package/dist/types/commands/exposure/index.d.ts +3 -0
  16. package/dist/types/commands/exposure/index.d.ts.map +1 -0
  17. package/dist/types/commands/exposure/types.d.ts +113 -0
  18. package/dist/types/commands/exposure/types.d.ts.map +1 -0
  19. package/dist/types/commands/index.d.ts +2 -0
  20. package/dist/types/commands/index.d.ts.map +1 -0
  21. package/dist/types/index.d.ts +4 -0
  22. package/dist/types/index.d.ts.map +1 -0
  23. package/dist/types/types.d.ts +178 -0
  24. package/dist/types/types.d.ts.map +1 -0
  25. package/dist/types/utils/index.d.ts +2 -0
  26. package/dist/types/utils/index.d.ts.map +1 -0
  27. package/dist/types/utils/number.d.ts +3 -0
  28. package/dist/types/utils/number.d.ts.map +1 -0
  29. package/dist/types.js +30 -0
  30. package/dist/types.js.map +1 -0
  31. package/dist/utils/index.js +18 -0
  32. package/dist/utils/index.js.map +1 -0
  33. package/dist/utils/number.js +13 -0
  34. package/dist/utils/number.js.map +1 -0
  35. package/package.json +44 -0
  36. package/src/commands/exposure/command.ts +799 -0
  37. package/src/commands/exposure/index.ts +2 -0
  38. package/src/commands/exposure/types.ts +125 -0
  39. package/src/commands/index.ts +1 -0
  40. package/src/index.ts +3 -0
  41. package/src/types.ts +213 -0
  42. package/src/utils/index.ts +1 -0
  43. package/src/utils/number.ts +8 -0
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./commands"), exports);
19
+ __exportStar(require("./utils"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,0CAAwB","sourcesContent":["export * from './types';\nexport * from './commands';\nexport * from './utils';\n"]}
@@ -0,0 +1,58 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { AccountAssetBalance, CollateralInfo, ExchangeInfo, ExposureCommandState, MarginInfo, MarketConfiguration, MarketIdToOraclePriceMap, MarketStorage, PositionInfo, PositionInfoMarketConfiguration, RiskMatrix, RiskMultipliersConfiguration } from './types';
3
+ export declare class ExposureCommand {
4
+ rootCollateralPoolId: number;
5
+ oraclePricePerMarket: MarketIdToOraclePriceMap;
6
+ accountBalancePerAsset: AccountAssetBalance[];
7
+ groupedByCollateral: Record<string, AccountAssetBalance>;
8
+ riskMultipliers: RiskMultipliersConfiguration;
9
+ riskMatrices: RiskMatrix[];
10
+ exchangeInfoPerAsset: ExchangeInfo[];
11
+ positionInfoMarketConfiguration: PositionInfoMarketConfiguration[];
12
+ uniqueTokenAddresses: string[];
13
+ uniqueQuoteCollaterals: string[];
14
+ tokenMarginInfoPerAsset: MarginInfo[];
15
+ realizedPnLSum: BigNumber;
16
+ unrealizedPnLSum: BigNumber;
17
+ constructor(rootCollateralPoolId: number, oraclePricePerMarket: MarketIdToOraclePriceMap, accountBalancePerAsset: AccountAssetBalance[], groupedByCollateral: Record<string, AccountAssetBalance>, riskMultipliers: RiskMultipliersConfiguration, riskMatrices: RiskMatrix[], exchangeInfoPerAsset: ExchangeInfo[], positionInfoMarketConfiguration: PositionInfoMarketConfiguration[], uniqueTokenAddresses: string[], uniqueQuoteCollaterals: string[], tokenMarginInfoPerAsset: MarginInfo[], realizedPnLSum: BigNumber, unrealizedPnLSum: BigNumber);
18
+ getState(): ExposureCommandState;
19
+ get getUsdNodeMarginInfo(): MarginInfo;
20
+ get balancePerAsset(): MarginInfo[];
21
+ get exchangePricePerAsset(): ExchangeInfo[];
22
+ getUsdNodeMarginInfoPostTrade(positionAmount: number, collateralAddress: string, marketConfiguration: MarketConfiguration): MarginInfo;
23
+ static calculateTokenMarginInfoPerAsset(groupedByCollateral: Record<string, AccountAssetBalance>, rootCollateralPoolId: number, riskMatrices: RiskMatrix[], riskMultipliers: RiskMultipliersConfiguration, uniqueQuoteCollaterals: Set<string>, realizedPnLSum: BigNumber, unrealizedPnLSum: BigNumber, positionInfoMarketConfiguration: PositionInfoMarketConfiguration[], oraclePricePerMarket: MarketIdToOraclePriceMap): MarginInfo[];
24
+ static calculateLiquidation(globalMarginInfo: MarginInfo, oraclePrice: number, positionBase: number): BigNumber;
25
+ static calculateImpliedLeverage(notionalExposure: number, oldIMR: number, newIMR: number): number;
26
+ static combineMarginInfo(parentMarginInfo: MarginInfo, sonMarginInfo: MarginInfo, sonParentExchangeInfo: ExchangeInfo): MarginInfo;
27
+ static getUsdNodeMarginInfo(accountCollateralPoolId: number, quoteTokens: string[], exchangeInfoPerAsset: ExchangeInfo[], marginInfoPerToken: MarginInfo[]): MarginInfo;
28
+ static getCollateralInfo(collateralAddress: string, realisedPnl: BigNumber, unrealizedPnL: BigNumber, netDeposits: number): CollateralInfo;
29
+ static getTokenMarginInfo(rootCollateralPoolId: number, riskMatrices: RiskMatrix[], riskMultipliers: RiskMultipliersConfiguration, collateralInfo: CollateralInfo, collateralAddress: string, positions: PositionInfoMarketConfiguration[], oraclePricePerMarket: MarketIdToOraclePriceMap, uniqueQuoteTokens: string[]): MarginInfo;
30
+ static computeLiquidationMarginRequirement(matrix: BigNumber[][], filledExposures: BigNumber[]): number;
31
+ static getBlockExposures(positions: PositionInfoMarketConfiguration[], oraclePricePerMarket: MarketIdToOraclePriceMap): BigNumber[];
32
+ static getAccountFilledExposures(position: PositionInfo, marketConfiguration: MarketConfiguration, oraclePrice: number): {
33
+ exposure: BigNumber;
34
+ riskMatrixIndex: number;
35
+ };
36
+ static computePricePnL(openBase: BigNumber, openPrice: BigNumber, exitPrice: BigNumber): BigNumber;
37
+ static getMarginRatio(marginInfo: MarginInfo): number;
38
+ static exchangeWithPriceHaircut(quantity: number, price: number, haircut: number): number;
39
+ getSlippage(deltaBase: number, marketConfiguration: MarketConfiguration, marketStorage: MarketStorage): number;
40
+ getMaxExposure(marketConfiguration: MarketConfiguration, marketStorage: MarketStorage): {
41
+ maxExposureShort: number;
42
+ maxExposureLong: number;
43
+ exposures: BigNumber[];
44
+ };
45
+ static computeMaxExposures(riskMatrix: BigNumber[][], exposures: BigNumber[], lmr: number, balance: number, imrMultiplier: number, exposureIndex: number): {
46
+ maxExposureShort: number;
47
+ maxExposureLong: number;
48
+ };
49
+ static solveQuadraticEquation(a: number, b: number, c: number): {
50
+ x1: BigNumber;
51
+ x2: BigNumber;
52
+ };
53
+ static computeC(lmr: number, balance: number, imrMultiplier: number): number;
54
+ static calculateFee(price: number, amount: number, feeParameter: BigNumber): number;
55
+ static calculateEstimatedPrice(price: number, slippage: number): number;
56
+ static evaluateHealthStatus(number: number): "danger" | "healthy" | "warning";
57
+ }
58
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"/","sources":["commands/exposure/command.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,YAAY,EACZ,+BAA+B,EAC/B,UAAU,EACV,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AAGjB,qBAAa,eAAe;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,wBAAwB,CAAC;IAC/C,sBAAsB,EAAE,mBAAmB,EAAE,CAAC;IAC9C,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACzD,eAAe,EAAE,4BAA4B,CAAC;IAC9C,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,oBAAoB,EAAE,YAAY,EAAE,CAAC;IACrC,+BAA+B,EAAE,+BAA+B,EAAE,CAAC;IACnE,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,uBAAuB,EAAE,UAAU,EAAE,CAAC;IACtC,cAAc,EAAE,SAAS,CAAC;IAC1B,gBAAgB,EAAE,SAAS,CAAC;gBAE1B,oBAAoB,EAAE,MAAM,EAC5B,oBAAoB,EAAE,wBAAwB,EAC9C,sBAAsB,EAAE,mBAAmB,EAAE,EAC7C,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACxD,eAAe,EAAE,4BAA4B,EAC7C,YAAY,EAAE,UAAU,EAAE,EAC1B,oBAAoB,EAAE,YAAY,EAAE,EACpC,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ACzB,SAAS,EAAE,SAAS,EAAE,EACtB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM;;;;IAoCvB,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;;;;IA+B7D,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;IAe5E,MAAM,CAAC,YAAY,CACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,GACtB,MAAM;IAIT,MAAM,CAAC,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIvE,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM;CAU3C"}
@@ -0,0 +1,3 @@
1
+ export * from './command';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["commands/exposure/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,113 @@
1
+ import BigNumber from 'bignumber.js';
2
+ export interface MarketStorage {
3
+ market_id: number;
4
+ quote_collateral: string;
5
+ instrument_address: string;
6
+ name: string;
7
+ risk_block_id: number;
8
+ collateral_pool_id: number;
9
+ block_timestamp: number;
10
+ block_number: number;
11
+ }
12
+ export interface MarketConfiguration {
13
+ market_id: number;
14
+ risk_matrix_index: number;
15
+ max_open_base: number;
16
+ velocity_multiplier: number;
17
+ minimum_order_base: number;
18
+ base_spacing: number;
19
+ price_spacing: number;
20
+ oracle_node_id: string;
21
+ mtm_window: number;
22
+ dutch_config_lambda: number;
23
+ dutch_config_min_base: number;
24
+ slippage_params_phi: number;
25
+ slippage_params_beta: number;
26
+ block_timestamp: number;
27
+ block_number: number;
28
+ }
29
+ export type AccountAssetBalance = {
30
+ accountId: number;
31
+ collateral: string;
32
+ amount: number;
33
+ };
34
+ export interface RiskMultipliersConfiguration {
35
+ collateral_pool_id: number;
36
+ im_multiplier: number;
37
+ mmr_multiplier: number;
38
+ dutch_multiplier: number;
39
+ adl_multiplier: number;
40
+ im_buffer_multiplier: number;
41
+ block_timestamp: number;
42
+ block_number: number;
43
+ }
44
+ export interface RiskMatrix {
45
+ collateral_pool_id: number;
46
+ risk_block_id: number;
47
+ matrix: BigNumber[][];
48
+ }
49
+ export type MarketIdToOraclePriceMap = {
50
+ [marketId: number]: number;
51
+ };
52
+ export type CollateralAddressToExchangePriceMap = {
53
+ [address: string]: number;
54
+ };
55
+ export interface ExchangeInfo {
56
+ price: number;
57
+ priceHaircut: number;
58
+ autoExchangeDiscount: number;
59
+ tokenAddress: string;
60
+ }
61
+ export interface PositionInfo {
62
+ base: BigNumber;
63
+ realized_pnl: BigNumber;
64
+ last_price: BigNumber;
65
+ last_timestamp: BigNumber;
66
+ funding_value: BigNumber;
67
+ base_multiplier: BigNumber;
68
+ adl_unwind_price: BigNumber;
69
+ market_id: number;
70
+ }
71
+ export type PositionInfoMarketConfiguration = PositionInfo & {
72
+ market_configuration: MarketConfiguration;
73
+ };
74
+ export interface MarginInfo {
75
+ assetAddress: string;
76
+ marginBalance: number;
77
+ realBalance: number;
78
+ initialDelta: number;
79
+ maintenanceDelta: number;
80
+ liquidationDelta: number;
81
+ dutchDelta: number;
82
+ adlDelta: number;
83
+ initialBufferDelta: number;
84
+ liquidationMarginRequirement: number;
85
+ }
86
+ export interface CollateralInfo {
87
+ netDeposits: number;
88
+ marginBalance: number;
89
+ realBalance: number;
90
+ }
91
+ export type ExposureCommandState = {
92
+ rootCollateralPoolId: number;
93
+ oraclePricePerMarket: MarketIdToOraclePriceMap;
94
+ accountBalancePerAsset: AccountAssetBalance[];
95
+ groupedByCollateral: Record<string, AccountAssetBalance>;
96
+ riskMultipliers: RiskMultipliersConfiguration;
97
+ riskMatrices: RiskMatrix[];
98
+ exchangeInfoPerAsset: ExchangeInfo[];
99
+ positionInfoMarketConfiguration: PositionInfoMarketConfiguration[];
100
+ uniqueTokenAddresses: string[];
101
+ uniqueQuoteCollaterals: string[];
102
+ tokenMarginInfoPerAsset: MarginInfo[];
103
+ realizedPnLSum: BigNumber;
104
+ unrealizedPnLSum: BigNumber;
105
+ };
106
+ export type TradeSimulationState = {
107
+ feeParameter: BigNumber;
108
+ marketStorage: MarketStorage;
109
+ marketConfiguration: MarketConfiguration;
110
+ exposureDataAccount: ExposureCommandState;
111
+ exposureDataPassivePool: ExposureCommandState;
112
+ };
113
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["commands/exposure/types.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B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oB,GAAG;IACjC,YAAY,EAAE,SAAS,CAAC;IACxB,aAAa,EAAE,aAAa,CAAC;IAC7B,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,mBAAmB,EAAE,oBAAoB,CAAC;IAC1C,uBAAuB,EAAE,oBAAoB,CAAC;CAC/C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './exposure';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './commands';
3
+ export * from './utils';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,178 @@
1
+ export type MarketOrderInfo = {
2
+ counterpartyAccountIds: number[];
3
+ exchangeId: number;
4
+ };
5
+ export type MarketEntity = {
6
+ id: number;
7
+ ticker: string;
8
+ underlyingAsset: string;
9
+ quoteToken: string;
10
+ markPrice: number;
11
+ isActive: boolean;
12
+ maxLeverage: number;
13
+ volume24H: number;
14
+ priceChange24H: number;
15
+ priceChange24HPercentage: number;
16
+ openInterest: number;
17
+ fundingRate: number;
18
+ description: string;
19
+ orderInfo: MarketOrderInfo;
20
+ tickSizeDecimals: number;
21
+ chainId: SupportedChainId;
22
+ };
23
+ export declare enum SupportedChainId {
24
+ polygonMumbai = 80001,
25
+ reyaCronos = 1729
26
+ }
27
+ export declare enum CandlesResolution {
28
+ ONE_MINUTE = "1MIN",
29
+ FIVE_MINUTES = "5MINS",
30
+ FIFTEEN_MINUTES = "15MINS",
31
+ THIRTY_MINUTES = "30MINS",
32
+ ONE_HOUR = "1HOUR",
33
+ FOUR_HOURS = "4HOURS",
34
+ ONE_DAY = "1DAY"
35
+ }
36
+ export interface Candle {
37
+ id: string;
38
+ startedAt: string;
39
+ ticker: string;
40
+ resolution: CandlesResolution;
41
+ low: string;
42
+ high: string;
43
+ open: string;
44
+ close: string;
45
+ baseTokenVolume: string;
46
+ usdVolume: string;
47
+ trades: number;
48
+ startingOpenInterest: string;
49
+ }
50
+ export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
51
+ export type Side = 'long' | 'short';
52
+ export type MarginAccountEntity = {
53
+ id: number;
54
+ name: string;
55
+ marginRatioHealth: 'danger' | 'healthy' | 'warning';
56
+ marginRatioPercentage: number;
57
+ totalBalance: number;
58
+ totalBalanceUnderlyingAsset: string;
59
+ collaterals: {
60
+ token: string;
61
+ percentage: number;
62
+ balance: number;
63
+ balanceRUSD: number;
64
+ }[];
65
+ };
66
+ export type PositionEntity = {
67
+ id: number;
68
+ side: Side;
69
+ size: number;
70
+ base: number;
71
+ price: number;
72
+ markPrice: number;
73
+ orderStatus: Status;
74
+ realisedPnl?: number | null;
75
+ unrealisedPnl?: number | null;
76
+ liquidationPrice: number;
77
+ fundingRate: number;
78
+ market: MarketEntity;
79
+ date: Date;
80
+ };
81
+ export type TradingHistoryEntity = {
82
+ id: number;
83
+ price: number;
84
+ priceUnderlyingToken: string;
85
+ size: number;
86
+ sizeUnderlyingToken: string;
87
+ timestampMillisecondsUTC: number;
88
+ };
89
+ export type OrderType = 'market';
90
+ export type PositionHistoryType = 'long-trade' | 'short-trade' | 'long-liquidation' | 'short-liquidation';
91
+ export type PositionHistoryEntity = {
92
+ id: number;
93
+ action: PositionHistoryType;
94
+ orderType: OrderType;
95
+ size: number;
96
+ executionPrice: number;
97
+ realisedPnl?: number | null;
98
+ fees: number;
99
+ timestamp: number;
100
+ market: MarketEntity;
101
+ };
102
+ export type LpPoolEntity = {
103
+ id: number;
104
+ name: string;
105
+ description: string;
106
+ longDescription: string;
107
+ readMoreLink: string;
108
+ currentAPY: number;
109
+ balanceSupplied?: number | null;
110
+ apyChange24H: number;
111
+ tokenAddress: string;
112
+ token: string;
113
+ allowedChainsForLiquidity: number[];
114
+ chainId: SupportedChainId;
115
+ };
116
+ export type TransactionHistoryType = 'deposit' | 'withdrawal';
117
+ export type LpTransactionHistoryEntity = {
118
+ id: number;
119
+ type: TransactionHistoryType;
120
+ token: string;
121
+ amount: number;
122
+ transactionHash: string;
123
+ timestamp: number;
124
+ };
125
+ export type LpPositionEntity = {
126
+ id: number;
127
+ deposited: number;
128
+ currentBalance: number;
129
+ pnl: number;
130
+ fundingRate: number;
131
+ lpPool: LpPoolEntity;
132
+ };
133
+ export type MarginAccountTransactionHistoryType = 'deposit' | 'withdrawal' | 'transfer' | 'auto_exchange';
134
+ export type MarginAccountTransactionHistoryEntity = {
135
+ id: number;
136
+ type: MarginAccountTransactionHistoryType;
137
+ token: string;
138
+ amount: number;
139
+ transactionHash: string;
140
+ timestamp: number;
141
+ };
142
+ export type TokenEntity = {
143
+ id: string;
144
+ address: string;
145
+ };
146
+ export declare enum BalanceGranularity {
147
+ ONE_MINUTE = 60000,
148
+ ONE_HOUR = 3600000,
149
+ ONE_DAY = 86400000,
150
+ ONE_WEEK = 604800000,
151
+ ONE_MONTH = 2592000000,
152
+ ONE_YEAR = 31536000000
153
+ }
154
+ export type GetLpPoolBalanceChartDataResult = {
155
+ data: {
156
+ timestampInMs: number;
157
+ value: number;
158
+ }[];
159
+ tvl: number;
160
+ tvlChangePercentage: number;
161
+ apy: number;
162
+ apyChangePercentage: number;
163
+ };
164
+ export type GetLpPoolPerformanceChartDataResult = {
165
+ capitalInvestedData: {
166
+ timestampInMs: number;
167
+ value: number;
168
+ }[];
169
+ balanceData: {
170
+ timestampInMs: number;
171
+ value: number;
172
+ }[];
173
+ balance: number;
174
+ balanceChangePercentage: number;
175
+ capitalInvested: number;
176
+ capitalInvestedChangePercentage: number;
177
+ };
178
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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AAa,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"}
@@ -0,0 +1,2 @@
1
+ export * from './number';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ import BigNumber from 'bignumber.js';
2
+ export declare function amountNormalizer(value: BigNumber | number | string, decimals?: number): BigNumber;
3
+ //# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"/","sources":["utils/number.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,EAClC,QAAQ,GAAE,MAAW,GACpB,SAAS,CAEX"}
package/dist/types.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BalanceGranularity = exports.CandlesResolution = exports.SupportedChainId = void 0;
4
+ var SupportedChainId;
5
+ (function (SupportedChainId) {
6
+ SupportedChainId[SupportedChainId["polygonMumbai"] = 80001] = "polygonMumbai";
7
+ SupportedChainId[SupportedChainId["reyaCronos"] = 1729] = "reyaCronos";
8
+ })(SupportedChainId || (exports.SupportedChainId = SupportedChainId = {}));
9
+ var CandlesResolution;
10
+ (function (CandlesResolution) {
11
+ CandlesResolution["ONE_MINUTE"] = "1MIN";
12
+ CandlesResolution["FIVE_MINUTES"] = "5MINS";
13
+ CandlesResolution["FIFTEEN_MINUTES"] = "15MINS";
14
+ CandlesResolution["THIRTY_MINUTES"] = "30MINS";
15
+ CandlesResolution["ONE_HOUR"] = "1HOUR";
16
+ CandlesResolution["FOUR_HOURS"] = "4HOURS";
17
+ CandlesResolution["ONE_DAY"] = "1DAY";
18
+ })(CandlesResolution || (exports.CandlesResolution = CandlesResolution = {}));
19
+ // TODO: Milan evaluate if these need to be in common. At moment of writting it was shared in api and api-sdk
20
+ // --- Lp Pool Balance ---
21
+ var BalanceGranularity;
22
+ (function (BalanceGranularity) {
23
+ BalanceGranularity[BalanceGranularity["ONE_MINUTE"] = 60000] = "ONE_MINUTE";
24
+ BalanceGranularity[BalanceGranularity["ONE_HOUR"] = 3600000] = "ONE_HOUR";
25
+ BalanceGranularity[BalanceGranularity["ONE_DAY"] = 86400000] = "ONE_DAY";
26
+ BalanceGranularity[BalanceGranularity["ONE_WEEK"] = 604800000] = "ONE_WEEK";
27
+ BalanceGranularity[BalanceGranularity["ONE_MONTH"] = 2592000000] = "ONE_MONTH";
28
+ BalanceGranularity[BalanceGranularity["ONE_YEAR"] = 31536000000] = "ONE_YEAR";
29
+ })(BalanceGranularity || (exports.BalanceGranularity = BalanceGranularity = {}));
30
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":";;;AAyBA,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,6EAAqB,CAAA;IACrB,sEAAiB,CAAA;AACnB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;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;AAyID,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":["// -- 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 chainId: SupportedChainId;\n};\n\nexport enum SupportedChainId {\n polygonMumbai = 80001,\n reyaCronos = 1729,\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 MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n collaterals: {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n }[];\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: number[];\n chainId: SupportedChainId;\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: string;\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"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./number"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB","sourcesContent":["export * from './number';\n"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.amountNormalizer = void 0;
7
+ var bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ function amountNormalizer(value, decimals) {
9
+ if (decimals === void 0) { decimals = 18; }
10
+ return (0, bignumber_js_1.default)(value).div((0, bignumber_js_1.default)(10).pow(decimals));
11
+ }
12
+ exports.amountNormalizer = amountNormalizer;
13
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"/","sources":["utils/number.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqC;AAErC,SAAgB,gBAAgB,CAC9B,KAAkC,EAClC,QAAqB;IAArB,yBAAA,EAAA,aAAqB;IAErB,OAAO,IAAA,sBAAS,EAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAA,sBAAS,EAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC3D,CAAC;AALD,4CAKC","sourcesContent":["import BigNumber from 'bignumber.js';\n\nexport function amountNormalizer(\n value: BigNumber | number | string,\n decimals: number = 18,\n): BigNumber {\n return BigNumber(value).div(BigNumber(10).pow(decimals));\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@reyaxyz/common",
3
+ "version": "0.1.0",
4
+ "publishConfig": {
5
+ "access": "public",
6
+ "registry": "https://registry.npmjs.org"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/Reya-Labs/reya-off-chain-monorepo.git"
11
+ },
12
+ "main": "dist/index.js",
13
+ "types": "dist/types",
14
+ "license": "MIT",
15
+ "files": [
16
+ "src/**/*.*",
17
+ "dist/**/*.*",
18
+ "README.md"
19
+ ],
20
+ "devDependencies": {
21
+ "@types/lodash": "^4.14.202"
22
+ },
23
+ "dependencies": {
24
+ "bignumber.js": "^9.1.2",
25
+ "lodash": "^4.17.21"
26
+ },
27
+ "scripts": {
28
+ "prebuild": "rm -rf node_modules && rm -rf dist",
29
+ "build": "tsc -p tsconfig.build.json",
30
+ "ts:check-types": "npx tsc --noEmit",
31
+ "ts:circular-check": "dpdm --no-output --no-tree --no-warning --exit-code circular:1 -T src/index.ts",
32
+ "ts:check": "pnpm ts:check-types && pnpm ts:circular-check",
33
+ "lint:check": "eslint '{src, tests}/**/*.{ts,tsx}'",
34
+ "prettier:check": "npx prettier --log-level silent --check './{src, tests}/**/*.{ts,tsx}'",
35
+ "code-quality:check": "npx concurrently 'pnpm ts:check' 'pnpm prettier:check' 'pnpm lint:check --quiet'",
36
+ "lint:fix": "npx eslint --fix '{src, tests}/**/*.{ts,tsx}'",
37
+ "prettier:fix": "npx prettier --log-level silent --write './{src, tests}/**/*.{ts,tsx}'",
38
+ "test": "npx jest --silent",
39
+ "test:coverage": "npx jest test --coverage",
40
+ "generate:coverage-badges": "npx istanbul-badges-readme --silent"
41
+ },
42
+ "packageManager": "pnpm@8.10.4",
43
+ "gitHead": "d62614e48bb530169bacfc0e359a5cf63d73a86b"
44
+ }