@reyaxyz/api-sdk 0.157.0 → 0.159.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 (94) hide show
  1. package/dist/clients/api-client.js +0 -60
  2. package/dist/clients/api-client.js.map +1 -1
  3. package/dist/clients/modules/account/index.js +33 -94
  4. package/dist/clients/modules/account/index.js.map +1 -1
  5. package/dist/clients/modules/account/types.js.map +1 -1
  6. package/dist/clients/modules/auth/types.js.map +1 -1
  7. package/dist/clients/modules/conditional-orders/types.js.map +1 -1
  8. package/dist/clients/modules/deposit-existing-MA.simulation/types.js.map +1 -1
  9. package/dist/clients/modules/edit-collateral.simulation/types.js.map +1 -1
  10. package/dist/clients/modules/markets/index.js +0 -15
  11. package/dist/clients/modules/markets/index.js.map +1 -1
  12. package/dist/clients/modules/owner/index.js +0 -36
  13. package/dist/clients/modules/owner/index.js.map +1 -1
  14. package/dist/clients/modules/transfer-MA-Pool.simulation/types.js.map +1 -1
  15. package/dist/clients/modules/transfer-margin-between-MAs.simulation/types.js.map +1 -1
  16. package/dist/clients/modules/withdraw-MA.simulation/types.js.map +1 -1
  17. package/dist/clients/types.js +0 -3
  18. package/dist/clients/types.js.map +1 -1
  19. package/dist/types/clients/api-client.d.ts +0 -42
  20. package/dist/types/clients/api-client.d.ts.map +1 -1
  21. package/dist/types/clients/modules/account/index.d.ts +2 -10
  22. package/dist/types/clients/modules/account/index.d.ts.map +1 -1
  23. package/dist/types/clients/modules/account/types.d.ts +24 -24
  24. package/dist/types/clients/modules/account/types.d.ts.map +1 -1
  25. package/dist/types/clients/modules/auth/types.d.ts +1 -2
  26. package/dist/types/clients/modules/auth/types.d.ts.map +1 -1
  27. package/dist/types/clients/modules/conditional-orders/types.d.ts +3 -3
  28. package/dist/types/clients/modules/conditional-orders/types.d.ts.map +1 -1
  29. package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts +3 -3
  30. package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts.map +1 -1
  31. package/dist/types/clients/modules/edit-collateral.simulation/types.d.ts +4 -4
  32. package/dist/types/clients/modules/edit-collateral.simulation/types.d.ts.map +1 -1
  33. package/dist/types/clients/modules/markets/index.d.ts +1 -2
  34. package/dist/types/clients/modules/markets/index.d.ts.map +1 -1
  35. package/dist/types/clients/modules/owner/index.d.ts +1 -5
  36. package/dist/types/clients/modules/owner/index.d.ts.map +1 -1
  37. package/dist/types/clients/modules/transfer-MA-Pool.simulation/types.d.ts +3 -3
  38. package/dist/types/clients/modules/transfer-MA-Pool.simulation/types.d.ts.map +1 -1
  39. package/dist/types/clients/modules/transfer-margin-between-MAs.simulation/types.d.ts +7 -7
  40. package/dist/types/clients/modules/transfer-margin-between-MAs.simulation/types.d.ts.map +1 -1
  41. package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts +3 -3
  42. package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts.map +1 -1
  43. package/dist/types/clients/socket-client.d.ts +1 -1
  44. package/dist/types/clients/types.d.ts +1 -4
  45. package/dist/types/clients/types.d.ts.map +1 -1
  46. package/package.json +4 -4
  47. package/src/clients/api-client.ts +0 -58
  48. package/src/clients/modules/account/index.ts +34 -90
  49. package/src/clients/modules/account/types.ts +25 -24
  50. package/src/clients/modules/auth/types.ts +1 -2
  51. package/src/clients/modules/conditional-orders/types.ts +3 -3
  52. package/src/clients/modules/deposit-existing-MA.simulation/types.ts +3 -3
  53. package/src/clients/modules/edit-collateral.simulation/types.ts +4 -4
  54. package/src/clients/modules/markets/index.ts +1 -12
  55. package/src/clients/modules/owner/index.ts +0 -36
  56. package/src/clients/modules/transfer-MA-Pool.simulation/types.ts +3 -3
  57. package/src/clients/modules/transfer-margin-between-MAs.simulation/types.ts +7 -7
  58. package/src/clients/modules/withdraw-MA.simulation/types.ts +3 -3
  59. package/src/clients/types.ts +1 -4
  60. package/dist/clients/modules/isolated-order.simulation/index.js +0 -302
  61. package/dist/clients/modules/isolated-order.simulation/index.js.map +0 -1
  62. package/dist/clients/modules/isolated-order.simulation/types.js +0 -3
  63. package/dist/clients/modules/isolated-order.simulation/types.js.map +0 -1
  64. package/dist/clients/modules/rage-trade/index.js +0 -99
  65. package/dist/clients/modules/rage-trade/index.js.map +0 -1
  66. package/dist/clients/modules/rage-trade/types.js +0 -3
  67. package/dist/clients/modules/rage-trade/types.js.map +0 -1
  68. package/dist/clients/modules/trade.simulation/index.js +0 -331
  69. package/dist/clients/modules/trade.simulation/index.js.map +0 -1
  70. package/dist/clients/modules/trade.simulation/types.js +0 -3
  71. package/dist/clients/modules/trade.simulation/types.js.map +0 -1
  72. package/dist/clients/modules/trade.simulation/utils.js +0 -35
  73. package/dist/clients/modules/trade.simulation/utils.js.map +0 -1
  74. package/dist/types/clients/modules/isolated-order.simulation/index.d.ts +0 -24
  75. package/dist/types/clients/modules/isolated-order.simulation/index.d.ts.map +0 -1
  76. package/dist/types/clients/modules/isolated-order.simulation/types.d.ts +0 -44
  77. package/dist/types/clients/modules/isolated-order.simulation/types.d.ts.map +0 -1
  78. package/dist/types/clients/modules/rage-trade/index.d.ts +0 -9
  79. package/dist/types/clients/modules/rage-trade/index.d.ts.map +0 -1
  80. package/dist/types/clients/modules/rage-trade/types.d.ts +0 -80
  81. package/dist/types/clients/modules/rage-trade/types.d.ts.map +0 -1
  82. package/dist/types/clients/modules/trade.simulation/index.d.ts +0 -22
  83. package/dist/types/clients/modules/trade.simulation/index.d.ts.map +0 -1
  84. package/dist/types/clients/modules/trade.simulation/types.d.ts +0 -85
  85. package/dist/types/clients/modules/trade.simulation/types.d.ts.map +0 -1
  86. package/dist/types/clients/modules/trade.simulation/utils.d.ts +0 -8
  87. package/dist/types/clients/modules/trade.simulation/utils.d.ts.map +0 -1
  88. package/src/clients/modules/isolated-order.simulation/index.ts +0 -490
  89. package/src/clients/modules/isolated-order.simulation/types.ts +0 -55
  90. package/src/clients/modules/rage-trade/index.ts +0 -38
  91. package/src/clients/modules/rage-trade/types.ts +0 -91
  92. package/src/clients/modules/trade.simulation/index.ts +0 -534
  93. package/src/clients/modules/trade.simulation/types.ts +0 -98
  94. package/src/clients/modules/trade.simulation/utils.ts +0 -52
@@ -1,331 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- var common_1 = require("@reyaxyz/common");
43
- var bignumber_js_1 = __importDefault(require("bignumber.js"));
44
- var common_2 = require("@reyaxyz/common");
45
- var utils_1 = require("./utils");
46
- var TradeSimulationClient = /** @class */ (function () {
47
- function TradeSimulationClient(accountClient) {
48
- this.marketId = null;
49
- this.accountId = null;
50
- this.loadedData = null;
51
- // Constructor added
52
- this.accountClient = accountClient;
53
- }
54
- // Method to asynchronously load data based on marketId and accountId
55
- TradeSimulationClient.prototype.arm = function (params) {
56
- return __awaiter(this, void 0, void 0, function () {
57
- var tradeSimulationState, userAccountExposure, passivePoolExposure;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0:
61
- this.marketId = params.marketId;
62
- this.accountId = params.marginAccountId;
63
- return [4 /*yield*/, this.fetchMarketData(this.marketId, this.accountId)];
64
- case 1:
65
- tradeSimulationState = _a.sent();
66
- userAccountExposure = new common_1.ExposureCommand(tradeSimulationState.exposureDataAccount.accountId, tradeSimulationState.exposureDataAccount.rootCollateralPoolId, tradeSimulationState.exposureDataAccount.oraclePricePerMarket, tradeSimulationState.exposureDataAccount.accountBalancePerAsset, tradeSimulationState.exposureDataAccount.groupedByCollateral, tradeSimulationState.exposureDataAccount.riskMultipliers, tradeSimulationState.exposureDataAccount.riskMatrices, tradeSimulationState.exposureDataAccount.exchangeInfoPerAsset, tradeSimulationState.exposureDataAccount.positionInfoMarketConfiguration, tradeSimulationState.exposureDataAccount.uniqueTokenAddresses, tradeSimulationState.exposureDataAccount.uniqueQuoteCollaterals, tradeSimulationState.exposureDataAccount.tokenMarginInfoPerAsset, tradeSimulationState.exposureDataAccount.realizedPnLSum, tradeSimulationState.exposureDataAccount.unrealizedPnLSum, tradeSimulationState.exposureDataAccount.mtmRpnlSum, tradeSimulationState.exposureDataAccount.collateralAddressToExchangePrice);
67
- passivePoolExposure = new common_1.ExposureCommand(tradeSimulationState.exposureDataPassivePool.accountId, tradeSimulationState.exposureDataPassivePool.rootCollateralPoolId, tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket, tradeSimulationState.exposureDataPassivePool.accountBalancePerAsset, tradeSimulationState.exposureDataPassivePool.groupedByCollateral, tradeSimulationState.exposureDataPassivePool.riskMultipliers, tradeSimulationState.exposureDataPassivePool.riskMatrices, tradeSimulationState.exposureDataPassivePool.exchangeInfoPerAsset, tradeSimulationState.exposureDataPassivePool.positionInfoMarketConfiguration, tradeSimulationState.exposureDataPassivePool.uniqueTokenAddresses, tradeSimulationState.exposureDataPassivePool.uniqueQuoteCollaterals, tradeSimulationState.exposureDataPassivePool.tokenMarginInfoPerAsset, tradeSimulationState.exposureDataPassivePool.realizedPnLSum, tradeSimulationState.exposureDataPassivePool.unrealizedPnLSum, tradeSimulationState.exposureDataPassivePool.mtmRpnlSum, tradeSimulationState.exposureDataPassivePool.collateralAddressToExchangePrice);
68
- this.loadedData = {
69
- tradeSimulationState: tradeSimulationState,
70
- userAccountExposure: userAccountExposure,
71
- passivePoolExposure: passivePoolExposure,
72
- };
73
- return [2 /*return*/];
74
- }
75
- });
76
- });
77
- };
78
- TradeSimulationClient.prototype.fetchMarketData = function (marketId, accountId) {
79
- return __awaiter(this, void 0, void 0, function () {
80
- return __generator(this, function (_a) {
81
- return [2 /*return*/, this.accountClient.getTransactionSimulationInitialData({
82
- marginAccountId: accountId,
83
- marketId: marketId,
84
- })];
85
- });
86
- });
87
- };
88
- // Synchronous method to simulate operations based on an amount
89
- TradeSimulationClient.prototype.simulate = function (params) {
90
- if (!this.loadedData || !this.marketId) {
91
- throw new Error('Data not loaded. Call arm() first.');
92
- }
93
- var _a = this.loadedData, tradeSimulationState = _a.tradeSimulationState, userAccountExposure = _a.userAccountExposure, passivePoolExposure = _a.passivePoolExposure;
94
- var oraclePrice = tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[tradeSimulationState.marketConfiguration.market_id];
95
- var amount;
96
- if (params.fromBase) {
97
- amount = params.amount;
98
- }
99
- else {
100
- amount = (0, bignumber_js_1.default)(params.amount).div(oraclePrice).toNumber();
101
- }
102
- /*
103
- max amount of margin in rUSD terms that can be transferred from the source account to the destination account
104
- that performs the isolated position trade (PRE TRADE)
105
- */
106
- var availableMargin = userAccountExposure.getUsdNodeMarginInfo.initialDelta;
107
- var marginBalance = userAccountExposure.getUsdNodeMarginInfo.marginBalance;
108
- var slippage = passivePoolExposure.getSlippage((0, bignumber_js_1.default)(amount).negated().toNumber(), tradeSimulationState.marketConfiguration, tradeSimulationState.marketStorage);
109
- var estimatedPrice = common_1.ExposureCommand.calculateEstimatedPrice(oraclePrice, slippage);
110
- var feesV2 = (0, utils_1.computeFee)({
111
- tradeSimulationState: tradeSimulationState,
112
- marketId: this.marketId,
113
- orderBase: amount,
114
- });
115
- var _b = userAccountExposure.getUsdNodeMarginInfoPostTrade(amount, tradeSimulationState.marketStorage.quote_collateral, tradeSimulationState.marketConfiguration, tradeSimulationState.marketStorage.risk_block_id), newMarginInfo = _b.usdNodeMarginInfo, tokenMarginInfoPerAsset = _b.tokenMarginInfoPerAsset, positionInfoMarketConfiguration = _b.positionInfoMarketConfiguration;
116
- var newQuoteTokenMarginInfo = tokenMarginInfoPerAsset.find(function (marginInfo) {
117
- return (marginInfo.assetAddress ===
118
- tradeSimulationState.marketStorage.quote_collateral);
119
- });
120
- var positionInfo = positionInfoMarketConfiguration.find(function (positionInfo) {
121
- return (positionInfo.market_id ===
122
- tradeSimulationState.marketConfiguration.market_id);
123
- });
124
- if (!newQuoteTokenMarginInfo) {
125
- throw new Error('Error performing simulation');
126
- }
127
- /*
128
- * Note, required margin is the initial margin requirement in rUSD terms of the account after the trade.
129
- * margin balance rusd - initial delta rusd = margin balance rusd - (margin balance rusd - imr rusd) = imr rusd
130
- * */
131
- var requiredMargin = newQuoteTokenMarginInfo.marginBalance -
132
- newQuoteTokenMarginInfo.initialDelta;
133
- var liquidationPrice = common_1.ExposureCommand.calculateLiquidation(newMarginInfo.marginBalance, newQuoteTokenMarginInfo.liquidationMarginRequirement, oraclePrice, (0, bignumber_js_1.default)((positionInfo === null || positionInfo === void 0 ? void 0 : positionInfo.base) || 0).toNumber());
134
- var marginRatio = common_1.ExposureCommand.getMarginRatio(newMarginInfo);
135
- var marginRatioHealth = common_1.ExposureCommand.evaluateHealthStatus(marginRatio * 100);
136
- var baseSpacing = (0, common_1.amountNormalizer)(tradeSimulationState.marketConfiguration.base_spacing).toNumber();
137
- var snappedAmountInBase = this.roundToBaseSpacing(amount, baseSpacing);
138
- var snappedAmount = snappedAmountInBase * estimatedPrice;
139
- var xpEarnRangeMin = Math.round(Math.abs(snappedAmount) / common_2.INSTANT_TRADING_RATE_XP);
140
- var xpEarnRangeMax = Math.round((100 * Math.abs(snappedAmount)) / common_2.INSTANT_TRADING_RATE_XP);
141
- return {
142
- estimatedPrice: estimatedPrice,
143
- estimatedSlippage: slippage * 100,
144
- fees: feesV2.fee,
145
- takerFeesPercentage: feesV2.feePercentage,
146
- feesV2: feesV2,
147
- liquidationPrice: liquidationPrice.toNumber(),
148
- marginRatio: marginRatio * 100,
149
- marginRatioHealth: marginRatioHealth,
150
- marginBalance: marginBalance,
151
- availableMargin: availableMargin,
152
- requiredMargin: requiredMargin,
153
- snappedAmount: snappedAmount,
154
- snappedAmountInBase: snappedAmountInBase,
155
- xpEarnRange: {
156
- min: xpEarnRangeMin,
157
- max: xpEarnRangeMax,
158
- },
159
- maxSlippage: 1,
160
- };
161
- };
162
- TradeSimulationClient.prototype.getRiskMatrixElement = function () {
163
- if (!this.loadedData) {
164
- throw new Error('Data not loaded. Call arm() first.');
165
- }
166
- var tradeSimulationState = this.loadedData.tradeSimulationState;
167
- var riskBlockId = tradeSimulationState.marketStorage.risk_block_id;
168
- var riskMatrices = tradeSimulationState.exposureDataAccount.riskMatrices;
169
- var riskMatrix = riskMatrices.find(function (riskMatrix) { return riskMatrix.risk_block_id === riskBlockId; });
170
- if (!riskMatrix) {
171
- throw new Error('Risk matrix not found');
172
- }
173
- var riskMatrixIndex = tradeSimulationState.marketConfiguration.risk_matrix_index;
174
- return Number(riskMatrix.matrix[riskMatrixIndex][riskMatrixIndex]);
175
- };
176
- // Synchronous method to simulate operations based on an amount
177
- TradeSimulationClient.prototype.simulateLimit = function (params) {
178
- if (!this.loadedData) {
179
- throw new Error('Data not loaded. Call arm() first.');
180
- }
181
- var _a = this.loadedData, tradeSimulationState = _a.tradeSimulationState, userAccountExposure = _a.userAccountExposure;
182
- var amount;
183
- if (params.fromBase) {
184
- amount = params.amount;
185
- }
186
- else {
187
- amount = (0, bignumber_js_1.default)(params.amount).div(params.triggerPrice).toNumber();
188
- }
189
- var baseSpacing = (0, common_1.amountNormalizer)(tradeSimulationState.marketConfiguration.base_spacing).toNumber();
190
- var snappedAmountInBase = this.roundToBaseSpacing(amount, baseSpacing);
191
- var snappedAmount = snappedAmountInBase * params.triggerPrice;
192
- var fees = common_1.ExposureCommand.calculateFee({
193
- oraclePrice: params.triggerPrice,
194
- orderBase: amount,
195
- poolBasePreTrade: 0,
196
- feeParameter: tradeSimulationState.feeParameter,
197
- rebalancingFeeParameter: (0, bignumber_js_1.default)(0),
198
- }).fee;
199
- var marginBalance = userAccountExposure.getUsdNodeMarginInfo.marginBalance;
200
- var availableMargin = userAccountExposure.getUsdNodeMarginInfo.initialDelta;
201
- var imrMultiplier = (0, common_1.amountNormalizer)(String(userAccountExposure.riskMultipliers.im_multiplier)).toNumber();
202
- var riskMatrixElement = this.getRiskMatrixElement();
203
- var accountLMR = userAccountExposure.getUsdNodeMarginInfo.liquidationMarginRequirement;
204
- var accountIMR = accountLMR * imrMultiplier;
205
- var limitOrderLMR = Math.sqrt(riskMatrixElement) * Math.abs(snappedAmount);
206
- var limitOrderIMR = limitOrderLMR * imrMultiplier;
207
- var requiredMargin = accountIMR + limitOrderIMR;
208
- var liquidationMarginRequirement = userAccountExposure.getUsdNodeMarginInfo.liquidationMarginRequirement +
209
- limitOrderLMR;
210
- var marginRatio = common_1.ExposureCommand.getMarginRatio({
211
- marginBalance: marginBalance,
212
- liquidationMarginRequirement: liquidationMarginRequirement,
213
- });
214
- var marginRatioHealth = common_1.ExposureCommand.evaluateHealthStatus(marginRatio * 100);
215
- var xpEarnRangeMin = Math.round(Math.abs(snappedAmount) / common_2.INSTANT_TRADING_RATE_XP);
216
- var xpEarnRangeMax = Math.round((100 * Math.abs(snappedAmount)) / common_2.INSTANT_TRADING_RATE_XP);
217
- return {
218
- fees: fees,
219
- takerFeesPercentage: (0, bignumber_js_1.default)(tradeSimulationState.feeParameter).toNumber() * 100,
220
- snappedAmount: snappedAmount,
221
- snappedAmountInBase: snappedAmountInBase,
222
- estimatedPrice: params.triggerPrice,
223
- marginRatio: marginRatio * 100,
224
- marginRatioHealth: marginRatioHealth,
225
- availableMargin: availableMargin,
226
- marginBalance: marginBalance,
227
- requiredMargin: requiredMargin,
228
- xpEarnRange: {
229
- min: xpEarnRangeMin,
230
- max: xpEarnRangeMax,
231
- },
232
- };
233
- };
234
- TradeSimulationClient.prototype.getMaxAmountForLimitOrder = function (params) {
235
- if (!this.loadedData) {
236
- throw new Error('Data not loaded. Call arm() first.');
237
- }
238
- var _a = this.loadedData, userAccountExposure = _a.userAccountExposure, tradeSimulationState = _a.tradeSimulationState;
239
- var riskMatrixElement = this.getRiskMatrixElement();
240
- var imrMultiplier = (0, common_1.amountNormalizer)(String(userAccountExposure.riskMultipliers.im_multiplier)).toNumber();
241
- var availableMargin = userAccountExposure.getUsdNodeMarginInfo.initialDelta;
242
- var maxAmountSize = Math.max((availableMargin / Math.sqrt(riskMatrixElement) / imrMultiplier) * 0.97, // @todo implement dynamic buffer
243
- 0);
244
- var maxAmountBase = maxAmountSize / params.triggerPrice;
245
- var minAmountBase = (0, common_1.amountNormalizer)(tradeSimulationState.marketConfiguration.minimum_order_base).toNumber();
246
- var minAmountSize = minAmountBase * params.triggerPrice;
247
- return {
248
- maxAmountBase: maxAmountBase,
249
- maxAmountSize: maxAmountSize,
250
- minAmountBase: minAmountBase,
251
- minAmountSize: minAmountSize,
252
- };
253
- };
254
- TradeSimulationClient.prototype.convertValue = function (params) {
255
- if (!this.loadedData) {
256
- throw new Error('Data not loaded. Call arm() first.');
257
- }
258
- var tradeSimulationState = this.loadedData.tradeSimulationState;
259
- if (!params.fromBase)
260
- return (0, bignumber_js_1.default)(params.amount)
261
- .div(tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[tradeSimulationState.marketConfiguration.market_id])
262
- .toNumber();
263
- else
264
- return (0, bignumber_js_1.default)(params.amount)
265
- .times(tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[tradeSimulationState.marketConfiguration.market_id])
266
- .toNumber();
267
- };
268
- TradeSimulationClient.prototype.convertValueEstimatedPrice = function (params) {
269
- if (!this.loadedData) {
270
- throw new Error('Data not loaded. Call arm() first.');
271
- }
272
- var _a = this.loadedData, tradeSimulationState = _a.tradeSimulationState, passivePoolExposure = _a.passivePoolExposure;
273
- var amountForSlippage = params.fromBase
274
- ? params.amount
275
- : (0, bignumber_js_1.default)(params.amount)
276
- .div(tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[tradeSimulationState.marketConfiguration.market_id])
277
- .toNumber();
278
- var slippage = passivePoolExposure.getSlippage((0, bignumber_js_1.default)(amountForSlippage).negated().toNumber(), tradeSimulationState.marketConfiguration, tradeSimulationState.marketStorage);
279
- var estimatedPrice = common_1.ExposureCommand.calculateEstimatedPrice(tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[tradeSimulationState.marketConfiguration.market_id], slippage);
280
- if (!params.fromBase)
281
- return (0, bignumber_js_1.default)(params.amount).div(estimatedPrice).toNumber();
282
- else
283
- return (0, bignumber_js_1.default)(params.amount).times(estimatedPrice).toNumber();
284
- };
285
- TradeSimulationClient.prototype.customLeverage = function () {
286
- if (!this.loadedData) {
287
- throw new Error('Data not loaded. Call arm() first.');
288
- }
289
- var tradeSimulationState = this.loadedData.tradeSimulationState;
290
- return tradeSimulationState.customLeverage;
291
- };
292
- TradeSimulationClient.prototype.estimatedPrice = function (params) {
293
- if (!this.loadedData) {
294
- throw new Error('Data not loaded. Call arm() first.');
295
- }
296
- var _a = this.loadedData, tradeSimulationState = _a.tradeSimulationState, passivePoolExposure = _a.passivePoolExposure;
297
- var slippage = passivePoolExposure.getSlippage((0, bignumber_js_1.default)(params.amount).negated().toNumber(), tradeSimulationState.marketConfiguration, tradeSimulationState.marketStorage);
298
- var price = tradeSimulationState.exposureDataAccount.oraclePricePerMarket[tradeSimulationState.marketConfiguration.market_id];
299
- var estimatedPrice = common_1.ExposureCommand.calculateEstimatedPrice(tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[tradeSimulationState.marketConfiguration.market_id], slippage);
300
- return {
301
- estimatedPrice: estimatedPrice,
302
- markPrice: price,
303
- };
304
- };
305
- TradeSimulationClient.prototype.roundToBaseSpacing = function (amount, baseSpacing) {
306
- var snappedAmount = (0, bignumber_js_1.default)(amount)
307
- .abs()
308
- .dividedBy(baseSpacing)
309
- .integerValue(bignumber_js_1.default.ROUND_FLOOR)
310
- .multipliedBy(baseSpacing)
311
- .toNumber();
312
- if (amount < 0) {
313
- return -snappedAmount;
314
- }
315
- return snappedAmount;
316
- };
317
- TradeSimulationClient.prototype.updatePrice = function (price) {
318
- if (!this.loadedData || !this.marketId) {
319
- throw new Error('Data not loaded. Call arm() first.');
320
- }
321
- var tradeSimulationState = this.loadedData.tradeSimulationState;
322
- // update price
323
- var marketId = this.marketId;
324
- tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[marketId] = price;
325
- tradeSimulationState.exposureDataAccount.oraclePricePerMarket[marketId] =
326
- price;
327
- };
328
- return TradeSimulationClient;
329
- }());
330
- exports.default = TradeSimulationClient;
331
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,0CAMyB;AACzB,8DAAqC;AACrC,0CAA0D;AAC1D,iCAAqC;AAErC;IAUE,+BAAY,aAA4B;QAThC,aAAQ,GAAkB,IAAI,CAAC;QAC/B,cAAS,GAAkB,IAAI,CAAC;QAChC,eAAU,GAIP,IAAI,CAAC;QAId,oBAAoB;QACpB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,qEAAqE;IAC/D,mCAAG,GAAT,UAAU,MAAqC;;;;;;wBAC7C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;wBAChC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC;wBAEX,qBAAM,IAAI,CAAC,eAAe,CACrD,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,CACf,EAAA;;wBAHK,oBAAoB,GAAG,SAG5B;wBAEK,mBAAmB,GAAG,IAAI,wBAAe,CAC7C,oBAAoB,CAAC,mBAAmB,CAAC,SAAS,EAClD,oBAAoB,CAAC,mBAAmB,CAAC,oBAAoB,EAC7D,oBAAoB,CAAC,mBAAmB,CAAC,oBAAoB,EAC7D,oBAAoB,CAAC,mBAAmB,CAAC,sBAAsB,EAC/D,oBAAoB,CAAC,mBAAmB,CAAC,mBAAmB,EAC5D,oBAAoB,CAAC,mBAAmB,CAAC,eAAe,EACxD,oBAAoB,CAAC,mBAAmB,CAAC,YAAY,EACrD,oBAAoB,CAAC,mBAAmB,CAAC,oBAAoB,EAC7D,oBAAoB,CAAC,m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,IAAI,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAEO,IAAA,oBAAoB,GAAK,IAAI,CAAC,UAAU,qBAApB,CAAqB;QAEjD,eAAe;QACf,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,oBAAoB,CAAC,uBAAuB,CAAC,oBAAoB,CAC/D,QAAQ,CACT,GAAG,KAAK,CAAC;QACV,oBAAoB,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACrE,KAAK,CAAC;IACV,CAAC;IACH,4BAAC;AAAD,CAAC,AA3fD,IA2fC","sourcesContent":["import {\n EstimatedPriceParams,\n EstimatedPriceResult,\n LimitTradeMaxOrderSizeParams,\n LimitTradeMaxOrderSizeResult,\n SimulateLimitTradeEntity,\n SimulateTradeEntity,\n TradeSimulationConvertValueEstimatedPriceParams,\n TradeSimulationConvertValueParams,\n TradeSimulationConvertValueResult,\n TradeSimulationLoadDataParams,\n TradeSimulationSimulateLimitParams,\n TradeSimulationSimulateParams,\n} from './types';\nimport AccountClient from '../account';\nimport {\n amountNormalizer,\n ExposureCommand,\n MarginInfo,\n PositionInfo,\n TradeSimulationState,\n} from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\nimport { INSTANT_TRADING_RATE_XP } from '@reyaxyz/common';\nimport { computeFee } from './utils';\n\nexport default class TradeSimulationClient {\n private marketId: number | null = null;\n private accountId: number | null = null;\n private loadedData: {\n tradeSimulationState: TradeSimulationState;\n userAccountExposure: ExposureCommand;\n passivePoolExposure: ExposureCommand;\n } | null = null;\n private accountClient: AccountClient;\n\n constructor(accountClient: AccountClient) {\n // Constructor added\n this.accountClient = accountClient;\n }\n\n // Method to asynchronously load data based on marketId and accountId\n async arm(params: TradeSimulationLoadDataParams): Promise<void> {\n this.marketId = params.marketId;\n this.accountId = params.marginAccountId;\n\n const tradeSimulationState = await this.fetchMarketData(\n this.marketId,\n this.accountId,\n );\n\n const userAccountExposure = new ExposureCommand(\n tradeSimulationState.exposureDataAccount.accountId,\n tradeSimulationState.exposureDataAccount.rootCollateralPoolId,\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket,\n tradeSimulationState.exposureDataAccount.accountBalancePerAsset,\n tradeSimulationState.exposureDataAccount.groupedByCollateral,\n tradeSimulationState.exposureDataAccount.riskMultipliers,\n tradeSimulationState.exposureDataAccount.riskMatrices,\n tradeSimulationState.exposureDataAccount.exchangeInfoPerAsset,\n tradeSimulationState.exposureDataAccount.positionInfoMarketConfiguration,\n tradeSimulationState.exposureDataAccount.uniqueTokenAddresses,\n tradeSimulationState.exposureDataAccount.uniqueQuoteCollaterals,\n tradeSimulationState.exposureDataAccount.tokenMarginInfoPerAsset,\n tradeSimulationState.exposureDataAccount.realizedPnLSum,\n tradeSimulationState.exposureDataAccount.unrealizedPnLSum,\n tradeSimulationState.exposureDataAccount.mtmRpnlSum,\n tradeSimulationState.exposureDataAccount.collateralAddressToExchangePrice,\n );\n\n const passivePoolExposure = new ExposureCommand(\n tradeSimulationState.exposureDataPassivePool.accountId,\n tradeSimulationState.exposureDataPassivePool.rootCollateralPoolId,\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket,\n tradeSimulationState.exposureDataPassivePool.accountBalancePerAsset,\n tradeSimulationState.exposureDataPassivePool.groupedByCollateral,\n tradeSimulationState.exposureDataPassivePool.riskMultipliers,\n tradeSimulationState.exposureDataPassivePool.riskMatrices,\n tradeSimulationState.exposureDataPassivePool.exchangeInfoPerAsset,\n tradeSimulationState.exposureDataPassivePool.positionInfoMarketConfiguration,\n tradeSimulationState.exposureDataPassivePool.uniqueTokenAddresses,\n tradeSimulationState.exposureDataPassivePool.uniqueQuoteCollaterals,\n tradeSimulationState.exposureDataPassivePool.tokenMarginInfoPerAsset,\n tradeSimulationState.exposureDataPassivePool.realizedPnLSum,\n tradeSimulationState.exposureDataPassivePool.unrealizedPnLSum,\n tradeSimulationState.exposureDataPassivePool.mtmRpnlSum,\n tradeSimulationState.exposureDataPassivePool.collateralAddressToExchangePrice,\n );\n\n this.loadedData = {\n tradeSimulationState,\n userAccountExposure,\n passivePoolExposure,\n };\n }\n\n private async fetchMarketData(\n marketId: number,\n accountId: number,\n ): Promise<TradeSimulationState> {\n return this.accountClient.getTransactionSimulationInitialData({\n marginAccountId: accountId,\n marketId: marketId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(params: TradeSimulationSimulateParams): SimulateTradeEntity {\n if (!this.loadedData || !this.marketId) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, userAccountExposure, passivePoolExposure } =\n this.loadedData;\n\n const oraclePrice =\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ];\n\n let amount;\n if (params.fromBase) {\n amount = params.amount;\n } else {\n amount = BigNumber(params.amount).div(oraclePrice).toNumber();\n }\n\n /*\n max amount of margin in rUSD terms that can be transferred from the source account to the destination account\n that performs the isolated position trade (PRE TRADE)\n */\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const marginBalance =\n userAccountExposure.getUsdNodeMarginInfo.marginBalance;\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(amount).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n oraclePrice,\n slippage,\n );\n\n const feesV2 = computeFee({\n tradeSimulationState,\n marketId: this.marketId,\n orderBase: amount,\n });\n\n const {\n usdNodeMarginInfo: newMarginInfo,\n tokenMarginInfoPerAsset,\n positionInfoMarketConfiguration,\n } = userAccountExposure.getUsdNodeMarginInfoPostTrade(\n amount,\n tradeSimulationState.marketStorage.quote_collateral,\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage.risk_block_id,\n );\n\n const newQuoteTokenMarginInfo = tokenMarginInfoPerAsset.find(\n (marginInfo: MarginInfo) => {\n return (\n marginInfo.assetAddress ===\n tradeSimulationState.marketStorage.quote_collateral\n );\n },\n );\n\n const positionInfo = positionInfoMarketConfiguration.find(\n (positionInfo: PositionInfo) => {\n return (\n positionInfo.market_id ===\n tradeSimulationState.marketConfiguration.market_id\n );\n },\n );\n\n if (!newQuoteTokenMarginInfo) {\n throw new Error('Error performing simulation');\n }\n\n /*\n * Note, required margin is the initial margin requirement in rUSD terms of the account after the trade.\n * margin balance rusd - initial delta rusd = margin balance rusd - (margin balance rusd - imr rusd) = imr rusd\n * */\n\n const requiredMargin =\n newQuoteTokenMarginInfo.marginBalance -\n newQuoteTokenMarginInfo.initialDelta;\n\n const liquidationPrice = ExposureCommand.calculateLiquidation(\n newMarginInfo.marginBalance,\n newQuoteTokenMarginInfo.liquidationMarginRequirement,\n oraclePrice,\n BigNumber(positionInfo?.base || 0).toNumber(),\n );\n\n const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio * 100,\n );\n\n const baseSpacing = amountNormalizer(\n tradeSimulationState.marketConfiguration.base_spacing,\n ).toNumber();\n\n const snappedAmountInBase = this.roundToBaseSpacing(amount, baseSpacing);\n const snappedAmount = snappedAmountInBase * estimatedPrice;\n const xpEarnRangeMin = Math.round(\n Math.abs(snappedAmount) / INSTANT_TRADING_RATE_XP,\n );\n const xpEarnRangeMax = Math.round(\n (100 * Math.abs(snappedAmount)) / INSTANT_TRADING_RATE_XP,\n );\n\n return {\n estimatedPrice,\n estimatedSlippage: slippage * 100,\n fees: feesV2.fee,\n takerFeesPercentage: feesV2.feePercentage,\n feesV2,\n liquidationPrice: liquidationPrice.toNumber(),\n marginRatio: marginRatio * 100,\n marginRatioHealth,\n marginBalance,\n availableMargin,\n requiredMargin,\n snappedAmount,\n snappedAmountInBase,\n xpEarnRange: {\n min: xpEarnRangeMin,\n max: xpEarnRangeMax,\n },\n maxSlippage: 1,\n };\n }\n\n getRiskMatrixElement(): number {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n const riskBlockId = tradeSimulationState.marketStorage.risk_block_id;\n const riskMatrices = tradeSimulationState.exposureDataAccount.riskMatrices;\n\n const riskMatrix = riskMatrices.find(\n (riskMatrix) => riskMatrix.risk_block_id === riskBlockId,\n );\n\n if (!riskMatrix) {\n throw new Error('Risk matrix not found');\n }\n\n const riskMatrixIndex =\n tradeSimulationState.marketConfiguration.risk_matrix_index;\n\n return Number(riskMatrix.matrix[riskMatrixIndex][riskMatrixIndex]);\n }\n\n // Synchronous method to simulate operations based on an amount\n simulateLimit(\n params: TradeSimulationSimulateLimitParams,\n ): SimulateLimitTradeEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, userAccountExposure } = this.loadedData;\n\n let amount;\n if (params.fromBase) {\n amount = params.amount;\n } else {\n amount = BigNumber(params.amount).div(params.triggerPrice).toNumber();\n }\n\n const baseSpacing = amountNormalizer(\n tradeSimulationState.marketConfiguration.base_spacing,\n ).toNumber();\n\n const snappedAmountInBase = this.roundToBaseSpacing(amount, baseSpacing);\n const snappedAmount = snappedAmountInBase * params.triggerPrice;\n\n const { fee: fees } = ExposureCommand.calculateFee({\n oraclePrice: params.triggerPrice,\n orderBase: amount,\n poolBasePreTrade: 0,\n feeParameter: tradeSimulationState.feeParameter,\n rebalancingFeeParameter: BigNumber(0),\n });\n\n const marginBalance =\n userAccountExposure.getUsdNodeMarginInfo.marginBalance;\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const imrMultiplier = amountNormalizer(\n String(userAccountExposure.riskMultipliers.im_multiplier),\n ).toNumber();\n\n const riskMatrixElement = this.getRiskMatrixElement();\n\n const accountLMR =\n userAccountExposure.getUsdNodeMarginInfo.liquidationMarginRequirement;\n const accountIMR = accountLMR * imrMultiplier;\n\n const limitOrderLMR =\n Math.sqrt(riskMatrixElement) * Math.abs(snappedAmount);\n const limitOrderIMR = limitOrderLMR * imrMultiplier;\n\n const requiredMargin = accountIMR + limitOrderIMR;\n\n const liquidationMarginRequirement =\n userAccountExposure.getUsdNodeMarginInfo.liquidationMarginRequirement +\n limitOrderLMR;\n\n const marginRatio = ExposureCommand.getMarginRatio({\n marginBalance,\n liquidationMarginRequirement,\n });\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio * 100,\n );\n\n const xpEarnRangeMin = Math.round(\n Math.abs(snappedAmount) / INSTANT_TRADING_RATE_XP,\n );\n const xpEarnRangeMax = Math.round(\n (100 * Math.abs(snappedAmount)) / INSTANT_TRADING_RATE_XP,\n );\n\n return {\n fees,\n takerFeesPercentage:\n BigNumber(tradeSimulationState.feeParameter).toNumber() * 100,\n snappedAmount,\n snappedAmountInBase,\n estimatedPrice: params.triggerPrice,\n marginRatio: marginRatio * 100,\n marginRatioHealth,\n availableMargin,\n marginBalance,\n requiredMargin,\n xpEarnRange: {\n min: xpEarnRangeMin,\n max: xpEarnRangeMax,\n },\n };\n }\n\n getMaxAmountForLimitOrder(\n params: LimitTradeMaxOrderSizeParams,\n ): LimitTradeMaxOrderSizeResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { userAccountExposure, tradeSimulationState } = this.loadedData;\n\n const riskMatrixElement = this.getRiskMatrixElement();\n\n const imrMultiplier = amountNormalizer(\n String(userAccountExposure.riskMultipliers.im_multiplier),\n ).toNumber();\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const maxAmountSize = Math.max(\n (availableMargin / Math.sqrt(riskMatrixElement) / imrMultiplier) * 0.97, // @todo implement dynamic buffer\n 0,\n );\n const maxAmountBase = maxAmountSize / params.triggerPrice;\n\n const minAmountBase = amountNormalizer(\n tradeSimulationState.marketConfiguration.minimum_order_base,\n ).toNumber();\n\n const minAmountSize = minAmountBase * params.triggerPrice;\n\n return {\n maxAmountBase,\n maxAmountSize,\n minAmountBase,\n minAmountSize,\n };\n }\n\n convertValue(\n params: TradeSimulationConvertValueParams,\n ): TradeSimulationConvertValueResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n if (!params.fromBase)\n return BigNumber(params.amount)\n .div(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n else\n return BigNumber(params.amount)\n .times(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n }\n\n convertValueEstimatedPrice(\n params: TradeSimulationConvertValueEstimatedPriceParams,\n ): TradeSimulationConvertValueResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, passivePoolExposure } = this.loadedData;\n\n const amountForSlippage = params.fromBase\n ? params.amount\n : BigNumber(params.amount)\n .div(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(amountForSlippage).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n slippage,\n );\n\n if (!params.fromBase)\n return BigNumber(params.amount).div(estimatedPrice).toNumber();\n else return BigNumber(params.amount).times(estimatedPrice).toNumber();\n }\n\n customLeverage(): number | null {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n return tradeSimulationState.customLeverage;\n }\n\n estimatedPrice(params: EstimatedPriceParams): EstimatedPriceResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, passivePoolExposure } = this.loadedData;\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(params.amount).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n\n const price =\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ];\n\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n slippage,\n );\n\n return {\n estimatedPrice,\n markPrice: price,\n };\n }\n\n roundToBaseSpacing(amount: number, baseSpacing: number): number {\n const snappedAmount = BigNumber(amount)\n .abs()\n .dividedBy(baseSpacing)\n .integerValue(BigNumber.ROUND_FLOOR)\n .multipliedBy(baseSpacing)\n .toNumber();\n\n if (amount < 0) {\n return -snappedAmount;\n }\n return snappedAmount;\n }\n\n updatePrice(price: number): void {\n if (!this.loadedData || !this.marketId) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n // update price\n const marketId = this.marketId;\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n marketId\n ] = price;\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket[marketId] =\n price;\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarginAccountEntity, MarketEntity } from '@reyaxyz/common';\n\nexport type TradeSimulationLoadDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type TradeSimulationSimulateParams = {\n amount: number; // position size / base, + for long | - for short\n fromBase?: boolean;\n};\n\nexport type TradeSimulationConvertValueParams = {\n amount: number;\n fromBase: boolean;\n};\n\nexport type EstimatedPriceParams = {\n amount: number; // amount in base\n};\n\nexport type EstimatedPriceResult = {\n estimatedPrice: number;\n markPrice: number;\n};\n\nexport type TradeSimulationConvertValueEstimatedPriceParams = {\n amount: number;\n fromBase: boolean;\n};\n\nexport type TradeSimulationConvertValueEstimatedPriceResult = number;\n\nexport type SimulateTradeFeeEntity = {\n feeTier: number;\n feePercentage: number;\n rebalancingFeePercentage: number;\n fee: number;\n imbalancingFee: number;\n rebalancingFee: number;\n};\n\nexport type SimulateTradeEntity = {\n liquidationPrice: number;\n fees: number; // TODO: deprecate when feeV2 is linked up\n takerFeesPercentage: number; // TODO: deprecate when feeV2 is linked up\n feesV2: SimulateTradeFeeEntity;\n estimatedPrice: number;\n estimatedSlippage: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n availableMargin: number;\n marginBalance: number;\n requiredMargin: number;\n snappedAmount: number;\n snappedAmountInBase: number;\n xpEarnRange?: {\n min: number;\n max: number;\n };\n maxSlippage: number;\n};\n\nexport type TradeSimulationSimulateLimitParams = {\n triggerPrice: number;\n amount: number; // position size / base, + for long | - for short\n fromBase?: boolean;\n};\n\nexport type SimulateLimitTradeEntity = {\n fees: number;\n takerFeesPercentage: number;\n snappedAmount: number;\n snappedAmountInBase: number;\n estimatedPrice: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n availableMargin: number;\n marginBalance: number;\n requiredMargin: number;\n xpEarnRange: {\n min: number;\n max: number;\n };\n};\n\nexport type LimitTradeMaxOrderSizeParams = {\n triggerPrice: number;\n};\n\nexport type LimitTradeMaxOrderSizeResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n minAmountBase: number;\n minAmountSize: number;\n};\n\nexport type TradeSimulationConvertValueResult = number;\n"]}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.computeFee = void 0;
4
- var common_1 = require("@reyaxyz/common");
5
- var computeFee = function (_a) {
6
- var tradeSimulationState = _a.tradeSimulationState, marketId = _a.marketId, orderBase = _a.orderBase;
7
- var oraclePrice = tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[tradeSimulationState.marketConfiguration.market_id];
8
- var poolPosition = tradeSimulationState.exposureDataPassivePool.positionInfoMarketConfiguration.find(function (p) { return p.market_id === marketId; });
9
- var poolBasePreTrade = Number((poolPosition === null || poolPosition === void 0 ? void 0 : poolPosition.base) || 0);
10
- // TODO: once api is updated, change to the following:
11
- // const { feeParameter, rebalancingFeeParameter, feeTier } =
12
- // tradeSimulationState.feeParameters;
13
- var feeParameter = tradeSimulationState.feeParameter;
14
- var rebalancingFeeParameter = tradeSimulationState.feeParameter;
15
- var feeTier = 0;
16
- var _b = common_1.ExposureCommand.calculateFee({
17
- oraclePrice: oraclePrice,
18
- orderBase: orderBase,
19
- poolBasePreTrade: poolBasePreTrade,
20
- feeParameter: feeParameter,
21
- rebalancingFeeParameter: rebalancingFeeParameter,
22
- }), fee = _b.fee, rebalancingFee = _b.rebalancingFee, imbalancingFee = _b.imbalancingFee;
23
- var feePercentage = Number(feeParameter) * 100;
24
- var rebalancingFeePercentage = Number(rebalancingFeeParameter) * 100;
25
- return {
26
- feeTier: feeTier,
27
- feePercentage: feePercentage,
28
- rebalancingFeePercentage: rebalancingFeePercentage,
29
- fee: fee,
30
- rebalancingFee: rebalancingFee,
31
- imbalancingFee: imbalancingFee,
32
- };
33
- };
34
- exports.computeFee = computeFee;
35
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/utils.ts"],"names":[],"mappings":";;;AAAA,0CAAwE;AAGjE,IAAM,UAAU,GAAG,UAAC,EAQ1B;QAPC,oBAAoB,0BAAA,EACpB,QAAQ,cAAA,EACR,SAAS,eAAA;IAMT,IAAM,WAAW,GACf,oBAAoB,CAAC,uBAAuB,CAAC,oBAAoB,CAC/D,oBAAoB,CAAC,mBAAmB,CAAC,SAAS,CACnD,CAAC;IAEJ,IAAM,YAAY,GAChB,oBAAoB,CAAC,uBAAuB,CAAC,+BAA+B,CAAC,IAAI,CAC/E,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,SAAS,KAAK,QAAQ,EAAxB,CAAwB,CAChC,CAAC;IAEJ,IAAM,gBAAgB,GAAG,MAAM,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,KAAI,CAAC,CAAC,CAAC;IAEzD,sDAAsD;IACtD,6DAA6D;IAC7D,wCAAwC;IAExC,IAAM,YAAY,GAAG,oBAAoB,CAAC,YAAY,CAAC;IACvD,IAAM,uBAAuB,GAAG,oBAAoB,CAAC,YAAY,CAAC;IAClE,IAAM,OAAO,GAAG,CAAC,CAAC;IAEZ,IAAA,KAA0C,wBAAe,CAAC,YAAY,CAAC;QAC3E,WAAW,aAAA;QACX,SAAS,WAAA;QACT,gBAAgB,kBAAA;QAChB,YAAY,cAAA;QACZ,uBAAuB,yBAAA;KACxB,CAAC,EANM,GAAG,SAAA,EAAE,cAAc,oBAAA,EAAE,cAAc,oBAMzC,CAAC;IAEH,IAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC;IACjD,IAAM,wBAAwB,GAAG,MAAM,CAAC,uBAAuB,CAAC,GAAG,GAAG,CAAC;IAEvE,OAAO;QACL,OAAO,SAAA;QACP,aAAa,eAAA;QACb,wBAAwB,0BAAA;QACxB,GAAG,KAAA;QACH,cAAc,gBAAA;QACd,cAAc,gBAAA;KACf,CAAC;AACJ,CAAC,CAAC;AAhDW,QAAA,UAAU,cAgDrB","sourcesContent":["import { ExposureCommand, TradeSimulationState } from '@reyaxyz/common';\nimport { SimulateTradeFeeEntity } from './types';\n\nexport const computeFee = ({\n tradeSimulationState,\n marketId,\n orderBase,\n}: {\n marketId: number;\n tradeSimulationState: TradeSimulationState;\n orderBase: number;\n}): SimulateTradeFeeEntity => {\n const oraclePrice =\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ];\n\n const poolPosition =\n tradeSimulationState.exposureDataPassivePool.positionInfoMarketConfiguration.find(\n (p) => p.market_id === marketId,\n );\n\n const poolBasePreTrade = Number(poolPosition?.base || 0);\n\n // TODO: once api is updated, change to the following:\n // const { feeParameter, rebalancingFeeParameter, feeTier } =\n // tradeSimulationState.feeParameters;\n\n const feeParameter = tradeSimulationState.feeParameter;\n const rebalancingFeeParameter = tradeSimulationState.feeParameter;\n const feeTier = 0;\n\n const { fee, rebalancingFee, imbalancingFee } = ExposureCommand.calculateFee({\n oraclePrice,\n orderBase,\n poolBasePreTrade,\n feeParameter,\n rebalancingFeeParameter,\n });\n\n const feePercentage = Number(feeParameter) * 100;\n const rebalancingFeePercentage = Number(rebalancingFeeParameter) * 100;\n\n return {\n feeTier,\n feePercentage,\n rebalancingFeePercentage,\n fee,\n rebalancingFee,\n imbalancingFee,\n };\n};\n"]}
@@ -1,24 +0,0 @@
1
- import { SimulateIsolatedOrderEntity, IsolatedOrderSimulationConvertValueParams, IsolatedOrderSimulationConvertValueResult, IsolatedOrderSimulationLoadDataParams, IsolatedOrderSimulationSimulateParams, LeverageBoundsAndAvailableMarginResult, LeverageBoundsAndAvailableMarginParams } from './types';
2
- import AccountClient from '../account';
3
- import { ExposureCommand, ExposureCommandState } from '@reyaxyz/common';
4
- import { EstimatedPriceParams, EstimatedPriceResult, TradeSimulationConvertValueEstimatedPriceParams, TradeSimulationConvertValueResult } from '../trade.simulation/types';
5
- export default class IsolatedOrderSimulationClient {
6
- private loadedData;
7
- private accountClient;
8
- private marketId;
9
- constructor(accountClient: AccountClient);
10
- arm(params: IsolatedOrderSimulationLoadDataParams): Promise<void>;
11
- static genExposureCommandObject(exposureCommandState: ExposureCommandState): ExposureCommand;
12
- private fetchMarketData;
13
- simulate(params: IsolatedOrderSimulationSimulateParams): SimulateIsolatedOrderEntity;
14
- convertValue(params: IsolatedOrderSimulationConvertValueParams): IsolatedOrderSimulationConvertValueResult;
15
- convertValueEstimatedPrice(params: TradeSimulationConvertValueEstimatedPriceParams): TradeSimulationConvertValueResult;
16
- customLeverage(): number | null;
17
- estimatedPrice(params: EstimatedPriceParams): EstimatedPriceResult;
18
- roundToBaseSpacing(amount: number, baseSpacing: number): number;
19
- amountToSnappedAmount(amountInRusd: number, spotPrice: number, baseSpacing: number): number;
20
- calculateIsolatedLMR(isolatedExposure: number): number;
21
- leverageBoundsAndAvailableMargin({ amountTradedInRusd, }: LeverageBoundsAndAvailableMarginParams): LeverageBoundsAndAvailableMarginResult;
22
- updatePrice(price: number): void;
23
- }
24
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/isolated-order.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,yCAAyC,EACzC,yCAAyC,EACzC,qCAAqC,EACrC,qCAAqC,EACrC,sCAAsC,EACtC,sCAAsC,EACvC,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,YAAY,CAAC;AACvC,OAAO,EAEL,eAAe,EACf,oBAAoB,EAGrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,+CAA+C,EAC/C,iCAAiC,EAClC,MAAM,2BAA2B,CAAC;AAInC,MAAM,CAAC,OAAO,OAAO,6BAA6B;IAChD,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAAuB;gBAE3B,aAAa,EAAE,aAAa;IAMlC,GAAG,CAAC,MAAM,EAAE,qCAAqC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQvE,MAAM,CAAC,wBAAwB,CAC7B,oBAAoB,EAAE,oBAAoB,GACzC,eAAe;YAqBJ,eAAe;IAW7B,QAAQ,CACN,MAAM,EAAE,qCAAqC,GAC5C,2BAA2B;IA4H9B,YAAY,CACV,MAAM,EAAE,yCAAyC,GAChD,yCAAyC;IAuB5C,0BAA0B,CACxB,MAAM,EAAE,+CAA+C,GACtD,iCAAiC;IAmDpC,cAAc,IAAI,MAAM,GAAG,IAAI;IAS/B,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB;IA+ClE,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM;IAc/D,qBAAqB,CACnB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,MAAM;IAQT,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM;IAwCtD,gCAAgC,CAAC,EAC/B,kBAAkB,GACnB,EAAE,sCAAsC,GAAG,sCAAsC;IAsElF,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAUjC"}
@@ -1,44 +0,0 @@
1
- import { MarginAccountEntity, MarketEntity, EditCollateralAction } from '@reyaxyz/common';
2
- import { SimulateTradeFeeEntity } from '../trade.simulation/types';
3
- export type IsolatedOrderSimulationLoadDataParams = {
4
- marketId: MarketEntity['id'];
5
- marginAccountId: MarginAccountEntity['id'];
6
- };
7
- export type IsolatedOrderSimulationSimulateParams = {
8
- amount: number;
9
- isolatedPositionLeverage: number;
10
- fromBase?: boolean;
11
- };
12
- export type IsolatedOrderSimulationConvertValueParams = {
13
- amount: number;
14
- fromBase: boolean;
15
- };
16
- export type SimulateIsolatedOrderEntity = {
17
- liquidationPrice: number;
18
- fees: number;
19
- takerFeesPercentage: number;
20
- feesV2: SimulateTradeFeeEntity;
21
- estimatedPrice: number;
22
- estimatedSlippage: number;
23
- marginRatio: MarginAccountEntity['marginRatioPercentage'];
24
- marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
25
- snappedAmount: number;
26
- snappedAmountInBase: number;
27
- requiredMargin: number;
28
- editCollateralActions: EditCollateralAction[];
29
- maxSlippage: number;
30
- xpEarnRange?: {
31
- min: number;
32
- max: number;
33
- };
34
- };
35
- export type IsolatedOrderSimulationConvertValueResult = number;
36
- export type LeverageBoundsAndAvailableMarginResult = {
37
- minBound: number;
38
- maxBound: number;
39
- availableMargin: number;
40
- };
41
- export type LeverageBoundsAndAvailableMarginParams = {
42
- amountTradedInRusd: number;
43
- };
44
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/isolated-order.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,MAAM,MAAM,qCAAqC,GAAG;IAClD,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,yCAAyC,GAAG;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,yCAAyC,GAAG,MAAM,CAAC;AAE/D,MAAM,MAAM,sCAAsC,GAAG;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IAEnD,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC"}
@@ -1,9 +0,0 @@
1
- import { GetRageTradeDailyVolumeForPeriodParams, GetRageTradeDailyVolumeForPeriodResult, GetRageTradeLeaderboardForEpochAndTierResult, GetRageTradeLeaderboardForWalletAddressParams, GetRageTradeLeaderboardForWalletAddressResult, GetRageTradeRewardsPerEpochAndTierParams, GetRageTradeRewardsPerEpochAndTierResult } from './types';
2
- import { RestClient } from '@reyaxyz/common';
3
- export default class RageTradeClient extends RestClient {
4
- getRewardsPerEpochAndTier(): Promise<GetRageTradeRewardsPerEpochAndTierResult>;
5
- getLeaderboardForEpochAndTier(params: GetRageTradeRewardsPerEpochAndTierParams): Promise<GetRageTradeLeaderboardForEpochAndTierResult>;
6
- getLeaderboardDetailsForWalletAddress(params: GetRageTradeLeaderboardForWalletAddressParams): Promise<GetRageTradeLeaderboardForWalletAddressResult>;
7
- getDailyVolumeForPeriod(params: GetRageTradeDailyVolumeForPeriodParams): Promise<GetRageTradeDailyVolumeForPeriodResult>;
8
- }
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/rage-trade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,sCAAsC,EACtC,4CAA4C,EAC5C,6CAA6C,EAC7C,6CAA6C,EAC7C,wCAAwC,EACxC,wCAAwC,EACzC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU;IAC/C,yBAAyB,IAAI,OAAO,CAAC,wCAAwC,CAAC;IAK9E,6BAA6B,CACjC,MAAM,EAAE,wCAAwC,GAC/C,OAAO,CAAC,4CAA4C,CAAC;IAKlD,qCAAqC,CACzC,MAAM,EAAE,6CAA6C,GACpD,OAAO,CAAC,6CAA6C,CAAC;IAKnD,uBAAuB,CAC3B,MAAM,EAAE,sCAAsC,GAC7C,OAAO,CAAC,sCAAsC,CAAC;CAInD"}
@@ -1,80 +0,0 @@
1
- export type GetRageTradeRewardsPerEpochAndTierResult = {
2
- rewards: RageTradeRewards[];
3
- collateralTierLimits: RageTradeCollateralTierLimits;
4
- };
5
- export type RageTradeCollateralTierLimits = {
6
- '1': number;
7
- '2': number;
8
- '3': number;
9
- '4': number;
10
- };
11
- export type RageTradeRewards = {
12
- epochId: number;
13
- startTimeStamp: number;
14
- endTimeStamp: number;
15
- competitionName: string;
16
- rewards: RageTradeReward[];
17
- };
18
- export type RageTradeReward = {
19
- tierId: number;
20
- rewardsPerRank: RageTradeRewardsPerRank;
21
- };
22
- export type RageTradeRewardsPerRank = {
23
- '1': number;
24
- '2': number;
25
- '3': number;
26
- '4': number;
27
- '5': number;
28
- '6': number;
29
- '7': number;
30
- '8': number;
31
- '9': number;
32
- '10': number;
33
- };
34
- export type GetRageTradeLeaderboardForEpochAndTierResult = {
35
- totalCount: number;
36
- leaderboard: RageTradeLeaderboard[];
37
- maxCollateralAverage: number;
38
- };
39
- export type RageTradeLeaderboard = {
40
- epochId: number;
41
- tierId: number;
42
- rank: number;
43
- address: string;
44
- maxCollateral: number;
45
- pnl: number;
46
- roi: number;
47
- };
48
- export type GetRageTradeRewardsPerEpochAndTierParams = {
49
- epochId: string;
50
- tierId: string;
51
- skip: number;
52
- limit: number;
53
- walletAddress: string;
54
- };
55
- export type GetRageTradeLeaderboardForWalletAddressParams = {
56
- walletAddress: string;
57
- };
58
- export type GetRageTradeLeaderboardForWalletAddressResult = {
59
- tierId: number;
60
- address: string;
61
- rank: number;
62
- points: number;
63
- pnl: number;
64
- roi: number;
65
- maxCollateral: number;
66
- };
67
- export type GetRageTradeDailyVolumeForPeriodParams = {
68
- timestampFrom: number;
69
- timestampTo: number;
70
- };
71
- export type GetRageTradeDailyVolumeForPeriodResult = {
72
- total: number;
73
- data: RageTradeDailyVolumeForPeriodData[];
74
- };
75
- export type RageTradeDailyVolumeForPeriodData = {
76
- dateStartTimestamp: number;
77
- dateEndTimestamp: number;
78
- total_volume: number;
79
- };
80
- //# sourceMappingURL=types.d.ts.map