@reyaxyz/api-sdk 0.55.0 → 0.56.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,23 +42,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
43
43
  var DepthChartSimulationClient = /** @class */ (function () {
44
44
  function DepthChartSimulationClient(lpClient) {
45
- this.poolId = null;
46
45
  this.marketId = null;
47
46
  this.loadedData = null;
48
47
  // Constructor added
49
48
  this.lpClient = lpClient;
50
49
  }
51
- // Method to asynchronously load data based on marketId and poolId
50
+ // Method to asynchronously load data based on marketId
52
51
  DepthChartSimulationClient.prototype.arm = function (params) {
53
52
  return __awaiter(this, void 0, void 0, function () {
54
53
  var _a;
55
54
  return __generator(this, function (_b) {
56
55
  switch (_b.label) {
57
56
  case 0:
58
- this.poolId = params.poolId;
59
57
  this.marketId = params.marketId;
60
58
  _a = this;
61
- return [4 /*yield*/, this.fetchPoolData(this.poolId, this.marketId)];
59
+ return [4 /*yield*/, this.fetchPoolData(this.marketId)];
62
60
  case 1:
63
61
  _a.loadedData = _b.sent();
64
62
  return [2 /*return*/];
@@ -66,36 +64,44 @@ var DepthChartSimulationClient = /** @class */ (function () {
66
64
  });
67
65
  });
68
66
  };
69
- DepthChartSimulationClient.prototype.fetchPoolData = function (poolId, marketId) {
67
+ DepthChartSimulationClient.prototype.fetchPoolData = function (marketId) {
70
68
  return __awaiter(this, void 0, void 0, function () {
71
69
  return __generator(this, function (_a) {
72
70
  return [2 /*return*/, this.lpClient.getLpPoolDepthChartSimulationData({
73
- poolId: poolId,
74
71
  marketId: marketId,
75
72
  })];
76
73
  });
77
74
  });
78
75
  };
79
76
  DepthChartSimulationClient.prototype.getDepthChart = function (params) {
80
- // step is in notional
81
77
  if (!this.loadedData) {
82
78
  throw new Error('Data not loaded. Call arm() first.');
83
79
  }
84
- var step = (params === null || params === void 0 ? void 0 : params.step) || 10;
80
+ var step = (params === null || params === void 0 ? void 0 : params.step) || 10; // Initial step size
85
81
  var percentageChange = (params === null || params === void 0 ? void 0 : params.percentageChange) || 30;
82
+ var maxPoints = (params === null || params === void 0 ? void 0 : params.maxPoints) || 100; // Maximum points on each side
83
+ var dynamicStepIncreaseFactor = (params === null || params === void 0 ? void 0 : params.dynamicStepIncreaseFactor) || 2; // Factor to increase step size dynamically
86
84
  var leftResults = [];
87
85
  var rightResults = [];
88
- for (var delta = 0;; delta += step) {
86
+ var currentStep = step;
87
+ // Collect points for the left side
88
+ for (var i = 0, delta = 0; i < maxPoints; delta -= currentStep, i++) {
89
89
  var result = this.calculate(delta);
90
90
  if (result.priceImpact >= percentageChange)
91
91
  break;
92
92
  leftResults.push(result);
93
+ if (i % (maxPoints / 10) === 0)
94
+ currentStep *= dynamicStepIncreaseFactor; // Increase step size dynamically
93
95
  }
94
- for (var delta = 0;; delta -= step) {
96
+ currentStep = step; // Reset step size for the right side
97
+ // Collect points for the right side
98
+ for (var i = 0, delta = 0; i < maxPoints; delta += currentStep, i++) {
95
99
  var result = this.calculate(delta);
96
100
  if (result.priceImpact >= percentageChange)
97
101
  break;
98
102
  rightResults.push(result);
103
+ if (i % (maxPoints / 10) === 0)
104
+ currentStep *= dynamicStepIncreaseFactor; // Increase step size dynamically
99
105
  }
100
106
  return {
101
107
  leftChart: leftResults.reverse(),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8DAAqC;AAErC;IAKE,oCAAY,QAAkB;QAJtB,WAAM,GAAkB,IAAI,CAAC;QAC7B,aAAQ,GAAkB,IAAI,CAAC;QAC/B,eAAU,GAAgC,IAAI,CAAC;QAGrD,oBAAoB;QACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,kEAAkE;IAC5D,wCAAG,GAA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AE,IAAI,CAAC,QAAQ,EAAE;YAC1B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE;YAC9C,WAAW,EAAE,0BAA0B,CAAC,8BAA8B,CACpE,IAAI,CAAC,UAAU,CAAC,SAAS,EACzB,YAAY,CAAC,QAAQ,EAAE,CACxB;SACF,CAAC;IACJ,CAAC;IAEM,yDAA8B,GAArC,UACE,KAAa,EACb,cAAsB;QAEtB,iCAAiC;QACjC,IAAM,eAAe,GAAG,cAAc,GAAG,KAAK,CAAC;QAE/C,IAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACrD,kCAAkC;QAClC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC;IACtD,CAAC;IACH,iCAAC;AAAD,CAAC,AA9FD,IA8FC","sourcesContent":["import {\n GetDepthChartParams,\n GetDepthChartResult,\n DepthSimulationLoadDataParams,\n SimulateDepthEntity,\n} from './types';\n\nimport LpClient from '../lp';\nimport { DepthSimulationState } from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\n\nexport default class DepthChartSimulationClient {\n private poolId: number | null = null;\n private marketId: number | null = null;\n private loadedData: DepthSimulationState | null = null;\n private lpClient: LpClient;\n constructor(lpClient: LpClient) {\n // Constructor added\n this.lpClient = lpClient;\n }\n\n // Method to asynchronously load data based on marketId and poolId\n async arm(params: DepthSimulationLoadDataParams): Promise<void> {\n this.poolId = params.poolId;\n this.marketId = params.marketId;\n\n this.loadedData = await this.fetchPoolData(this.poolId, this.marketId);\n }\n\n private async fetchPoolData(\n poolId: number,\n marketId: number,\n ): Promise<DepthSimulationState> {\n return this.lpClient.getLpPoolDepthChartSimulationData({\n poolId: poolId,\n marketId: marketId,\n });\n }\n\n getDepthChart(params?: GetDepthChartParams): GetDepthChartResult {\n // step is in notional\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n const step = params?.step || 10;\n const percentageChange = params?.percentageChange || 30;\n\n const leftResults: SimulateDepthEntity[] = [];\n const rightResults: SimulateDepthEntity[] = [];\n for (let delta = 0; ; delta += step) {\n const result = this.calculate(delta);\n if (result.priceImpact >= percentageChange) break;\n leftResults.push(result);\n }\n\n for (let delta = 0; ; delta -= step) {\n const result = this.calculate(delta);\n if (result.priceImpact >= percentageChange) break;\n rightResults.push(result);\n }\n\n return {\n leftChart: leftResults.reverse(),\n rightChart: rightResults,\n };\n }\n\n private calculate(delta: number): SimulateDepthEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const n0Delta = BigNumber(this.loadedData.netExposure).plus(delta);\n const maxExposure = n0Delta.gt(0)\n ? BigNumber(this.loadedData.maxLongExposure)\n : BigNumber(this.loadedData.maxShortExposure);\n\n const currentPrice = BigNumber(this.loadedData.spotPrice).times(\n BigNumber(1).minus(n0Delta.div(BigNumber(n0Delta).plus(maxExposure))),\n );\n\n const size = BigNumber(delta).div(this.loadedData.spotPrice).abs();\n\n return {\n price: currentPrice.toNumber(),\n totalSize: size.toNumber(),\n totalCost: size.times(currentPrice).toNumber(),\n priceImpact: DepthChartSimulationClient.calculatePriceChangePercentage(\n this.loadedData.spotPrice,\n currentPrice.toNumber(),\n ),\n };\n }\n\n static calculatePriceChangePercentage(\n price: number,\n estimatedPrice: number,\n ): number {\n // Calculate the price difference\n const priceDifference = estimatedPrice - price;\n\n const absPriceDifference = Math.abs(priceDifference);\n // Calculate the percentage change\n return (absPriceDifference / Math.abs(price)) * 100;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8DAAqC;AAErC;IAIE,oCAAY,QAAkB;QAHtB,aAAQ,GAAkB,IAAI,CAAC;QAC/B,eAAU,GAAgC,IAAI,CAAC;Q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AAAD,CAAC,AAlGD,IAkGC","sourcesContent":["import {\n GetDepthChartParams,\n GetDepthChartResult,\n DepthSimulationLoadDataParams,\n SimulateDepthEntity,\n} from './types';\n\nimport LpClient from '../lp';\nimport { DepthSimulationState } from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\n\nexport default class DepthChartSimulationClient {\n private marketId: number | null = null;\n private loadedData: DepthSimulationState | null = null;\n private lpClient: LpClient;\n constructor(lpClient: LpClient) {\n // Constructor added\n this.lpClient = lpClient;\n }\n\n // Method to asynchronously load data based on marketId\n async arm(params: DepthSimulationLoadDataParams): Promise<void> {\n this.marketId = params.marketId;\n\n this.loadedData = await this.fetchPoolData(this.marketId);\n }\n\n private async fetchPoolData(marketId: number): Promise<DepthSimulationState> {\n return this.lpClient.getLpPoolDepthChartSimulationData({\n marketId: marketId,\n });\n }\n\n getDepthChart(params?: GetDepthChartParams): GetDepthChartResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const step = params?.step || 10; // Initial step size\n const percentageChange = params?.percentageChange || 30;\n const maxPoints = params?.maxPoints || 100; // Maximum points on each side\n const dynamicStepIncreaseFactor = params?.dynamicStepIncreaseFactor || 2; // Factor to increase step size dynamically\n\n const leftResults: SimulateDepthEntity[] = [];\n const rightResults: SimulateDepthEntity[] = [];\n let currentStep = step;\n\n // Collect points for the left side\n for (let i = 0, delta = 0; i < maxPoints; delta -= currentStep, i++) {\n const result = this.calculate(delta);\n if (result.priceImpact >= percentageChange) break;\n leftResults.push(result);\n if (i % (maxPoints / 10) === 0) currentStep *= dynamicStepIncreaseFactor; // Increase step size dynamically\n }\n\n currentStep = step; // Reset step size for the right side\n\n // Collect points for the right side\n for (let i = 0, delta = 0; i < maxPoints; delta += currentStep, i++) {\n const result = this.calculate(delta);\n if (result.priceImpact >= percentageChange) break;\n rightResults.push(result);\n if (i % (maxPoints / 10) === 0) currentStep *= dynamicStepIncreaseFactor; // Increase step size dynamically\n }\n\n return {\n leftChart: leftResults.reverse(),\n rightChart: rightResults,\n };\n }\n\n private calculate(delta: number): SimulateDepthEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const n0Delta = BigNumber(this.loadedData.netExposure).plus(delta);\n const maxExposure = n0Delta.gt(0)\n ? BigNumber(this.loadedData.maxLongExposure)\n : BigNumber(this.loadedData.maxShortExposure);\n\n const currentPrice = BigNumber(this.loadedData.spotPrice).times(\n BigNumber(1).minus(n0Delta.div(BigNumber(n0Delta).plus(maxExposure))),\n );\n\n const size = BigNumber(delta).div(this.loadedData.spotPrice).abs();\n\n return {\n price: currentPrice.toNumber(),\n totalSize: size.toNumber(),\n totalCost: size.times(currentPrice).toNumber(),\n priceImpact: DepthChartSimulationClient.calculatePriceChangePercentage(\n this.loadedData.spotPrice,\n currentPrice.toNumber(),\n ),\n };\n }\n\n static calculatePriceChangePercentage(\n price: number,\n estimatedPrice: number,\n ): number {\n // Calculate the price difference\n const priceDifference = estimatedPrice - price;\n\n const absPriceDifference = Math.abs(priceDifference);\n // Calculate the percentage change\n return (absPriceDifference / Math.abs(price)) * 100;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { LpPoolEntity, MarketEntity } from '@reyaxyz/common';\n\nexport type DepthSimulationLoadDataParams = {\n poolId: LpPoolEntity['id'];\n marketId: MarketEntity['id'];\n};\n\nexport type SimulateDepthEntity = {\n price: number;\n totalSize: number;\n totalCost: number;\n priceImpact: number;\n};\n\nexport type GetDepthChartResult = {\n leftChart: SimulateDepthEntity[];\n rightChart: SimulateDepthEntity[];\n};\n\nexport type GetDepthChartParams = {\n step?: number;\n percentageChange?: number;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarketEntity } from '@reyaxyz/common';\n\nexport type DepthSimulationLoadDataParams = {\n marketId: MarketEntity['id'];\n};\n\nexport type SimulateDepthEntity = {\n price: number;\n totalSize: number;\n totalCost: number;\n priceImpact: number;\n};\n\nexport type GetDepthChartResult = {\n leftChart: SimulateDepthEntity[];\n rightChart: SimulateDepthEntity[];\n};\n\nexport type GetDepthChartParams = {\n step?: number;\n percentageChange?: number;\n maxPoints?: number;\n dynamicStepIncreaseFactor?: number;\n};\n"]}
@@ -138,10 +138,8 @@ var LpClient = /** @class */ (function (_super) {
138
138
  return __awaiter(this, void 0, void 0, function () {
139
139
  var uri;
140
140
  return __generator(this, function (_a) {
141
- uri = "/api/lp-pools/".concat(params.poolId, "/depth-simulation-data");
142
- return [2 /*return*/, this.get(uri, {
143
- marketId: params.marketId,
144
- })];
141
+ uri = "/api/lp-pools/".concat(params.marketId, "/depth-simulation-data");
142
+ return [2 /*return*/, this.get(uri)];
145
143
  });
146
144
  });
147
145
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,0CAKyB;AACzB;IAAsC,4BAAU;IAAhD;;IAoEA,CAAC;IAnEO,6BAAU,GAAhB;;;;gBACQ,GAAG,GAAG,eAAe,CAAC;gBAC5B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,4BAAS,GAAf,UAAgB,MAAuB;;;;gBAC/B,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,CAAE,CAAC;gBACzC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,8CAA2B,GAAjC,UACE,MAAyC;;;;gBAEnC,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,yBAAsB,CAAC;gBAC7D,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,EAAE,M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AAG,EAAE;wBACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;qBAC1B,CAAC,EAAC;;;KACJ;IACH,eAAC;AAAD,CAAC,AApED,CAAsC,mBAAU,GAoE/C","sourcesContent":["import {\n GetLpPoolParams,\n GetLpPositionsParams,\n GetLpPoolResult,\n GetLpPoolsResult,\n GetLpPoolTransactionHistoryParams,\n GetLpPoolTransactionHistoryResult,\n GetLpPositionsResult,\n GetLpPoolWithdrawBalanceParams,\n GetLpPoolWithdrawBalanceResult,\n GetLpPoolBalanceChartDataParams,\n GetLpPoolPerformanceChartDataParams,\n getLpPoolDepthChartSimulationDataParams,\n} from './types';\nimport {\n GetLpPoolBalanceChartDataResult,\n GetLpPoolPerformanceChartDataResult,\n RestClient,\n GetLpPoolDepthChartSimulationDataResult,\n} from '@reyaxyz/common';\nexport default class LpClient extends RestClient {\n async getLpPools(): Promise<GetLpPoolsResult> {\n const uri = '/api/lp-pools';\n return this.get(uri);\n }\n\n async getLpPool(params: GetLpPoolParams): Promise<GetLpPoolResult> {\n const uri = `/api/lp-pools/${params.id}`;\n return this.get(uri);\n }\n\n async getLpPoolTransactionHistory(\n params: GetLpPoolTransactionHistoryParams,\n ): Promise<GetLpPoolTransactionHistoryResult> {\n const uri = `/api/lp-pools/${params.id}/transaction-history`;\n return this.get(uri, {\n limit: params.limit,\n address: params.address,\n });\n }\n\n async getLpPositions(\n params: GetLpPositionsParams,\n ): Promise<GetLpPositionsResult> {\n const uri = `/api/lp-pools/${params.id}/positions`;\n return this.get(uri, {\n address: params.address,\n });\n }\n\n async getLpPoolWithdrawBalance(\n params: GetLpPoolWithdrawBalanceParams,\n ): Promise<GetLpPoolWithdrawBalanceResult> {\n const uri = `/api/lp-pools/${params.id}/withdraw-balance`;\n return this.get(uri, {\n address: params.address,\n });\n }\n\n async getLpPoolBalanceChartData(\n params: GetLpPoolBalanceChartDataParams,\n ): Promise<GetLpPoolBalanceChartDataResult> {\n const uri = `/api/lp-pools/${params.poolId}/balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getLpPoolPerformanceChartData(\n params: GetLpPoolPerformanceChartDataParams,\n ): Promise<GetLpPoolPerformanceChartDataResult> {\n const uri = `/api/lp-pools/${params.poolId}/performance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n address: params.address,\n });\n }\n\n async getLpPoolDepthChartSimulationData(\n params: getLpPoolDepthChartSimulationDataParams,\n ): Promise<GetLpPoolDepthChartSimulationDataResult> {\n const uri = `/api/lp-pools/${params.poolId}/depth-simulation-data`;\n return this.get(uri, {\n marketId: params.marketId,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,0CAKyB;AACzB;IAAsC,4BAAU;IAAhD;;IAkEA,CAAC;IAjEO,6BAAU,GAAhB;;;;gBACQ,GAAG,GAAG,eAAe,CAAC;gBAC5B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,4BAAS,GAAf,UAAgB,MAAuB;;;;gBAC/B,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,CAAE,CAAC;gBACzC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,8CAA2B,GAAjC,UACE,MAAyC;;;;gBAEnC,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,yBAAsB,CAAC;gBAC7D,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,OAAO,EAAE,MAAM,CAAC,OAAO;qBACxB,CAAC,EAAC;;;KACJ;IAEK,iCAAc,GAApB,UACE,MAA4B;;;;gBAEtB,GAAG,GAAG,wBAAi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oolsResult,\n GetLpPoolTransactionHistoryParams,\n GetLpPoolTransactionHistoryResult,\n GetLpPositionsResult,\n GetLpPoolWithdrawBalanceParams,\n GetLpPoolWithdrawBalanceResult,\n GetLpPoolBalanceChartDataParams,\n GetLpPoolPerformanceChartDataParams,\n getLpPoolDepthChartSimulationDataParams,\n} from './types';\nimport {\n GetLpPoolBalanceChartDataResult,\n GetLpPoolPerformanceChartDataResult,\n RestClient,\n GetLpPoolDepthChartSimulationDataResult,\n} from '@reyaxyz/common';\nexport default class LpClient extends RestClient {\n async getLpPools(): Promise<GetLpPoolsResult> {\n const uri = '/api/lp-pools';\n return this.get(uri);\n }\n\n async getLpPool(params: GetLpPoolParams): Promise<GetLpPoolResult> {\n const uri = `/api/lp-pools/${params.id}`;\n return this.get(uri);\n }\n\n async getLpPoolTransactionHistory(\n params: GetLpPoolTransactionHistoryParams,\n ): Promise<GetLpPoolTransactionHistoryResult> {\n const uri = `/api/lp-pools/${params.id}/transaction-history`;\n return this.get(uri, {\n limit: params.limit,\n address: params.address,\n });\n }\n\n async getLpPositions(\n params: GetLpPositionsParams,\n ): Promise<GetLpPositionsResult> {\n const uri = `/api/lp-pools/${params.id}/positions`;\n return this.get(uri, {\n address: params.address,\n });\n }\n\n async getLpPoolWithdrawBalance(\n params: GetLpPoolWithdrawBalanceParams,\n ): Promise<GetLpPoolWithdrawBalanceResult> {\n const uri = `/api/lp-pools/${params.id}/withdraw-balance`;\n return this.get(uri, {\n address: params.address,\n });\n }\n\n async getLpPoolBalanceChartData(\n params: GetLpPoolBalanceChartDataParams,\n ): Promise<GetLpPoolBalanceChartDataResult> {\n const uri = `/api/lp-pools/${params.poolId}/balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getLpPoolPerformanceChartData(\n params: GetLpPoolPerformanceChartDataParams,\n ): Promise<GetLpPoolPerformanceChartDataResult> {\n const uri = `/api/lp-pools/${params.poolId}/performance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n address: params.address,\n });\n }\n\n async getLpPoolDepthChartSimulationData(\n params: getLpPoolDepthChartSimulationDataParams,\n ): Promise<GetLpPoolDepthChartSimulationDataResult> {\n const uri = `/api/lp-pools/${params.marketId}/depth-simulation-data`;\n return this.get(uri);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/lp/types.ts"],"names":[],"mappings":";;;AA+CA,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,mFAAsB,CAAA;IACtB,iFAAyB,CAAA;IACzB,gFAA6B,CAAA;IAC7B,mFAAkC,CAAA;IAClC,sFAAoC,CAAA;IACpC,qFAAoC,CAAA;AACtC,CAAC,EAPW,sBAAsB,sCAAtB,sBAAsB,QAOjC","sourcesContent":["import {\n LpPoolEntity,\n LpPositionEntity,\n LpTransactionHistoryEntity,\n LpBalanceGranularity,\n LpWithdrawBalanceEntity,\n MarketEntity,\n} from '@reyaxyz/common';\n\nexport type GetLpPoolsResult = LpPoolEntity[];\n\nexport type GetLpPoolResult = LpPoolEntity;\n\nexport type GetLpPoolParams = {\n id: LpPoolEntity['id'];\n};\n\nexport type GetLpPoolTransactionHistoryResult = LpTransactionHistoryEntity[];\n\nexport type GetLpPositionsParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n};\n\nexport type GetLpPositionsResult = LpPositionEntity[];\n\nexport type GetLpPoolWithdrawBalanceParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n};\n\nexport type GetLpPoolWithdrawBalanceResult = LpWithdrawBalanceEntity;\n\nexport type GetLpPoolTransactionHistoryParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n limit?: number;\n};\n\nexport type GetLpPoolBalanceChartDataParams = {\n poolId: LpPoolEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: LpBalanceGranularity;\n };\n};\n\nexport enum PerformanceGranularity {\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\nexport type GetLpPoolPerformanceChartDataParams = {\n poolId: LpPoolEntity['id'];\n address: string; // wallet address\n filters: {\n timeframeMs: number;\n granularity: PerformanceGranularity;\n };\n};\n\nexport type getLpPoolDepthChartSimulationDataParams = {\n poolId: LpPoolEntity['id'];\n marketId: MarketEntity['id'];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/lp/types.ts"],"names":[],"mappings":";;;AA+CA,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,mFAAsB,CAAA;IACtB,iFAAyB,CAAA;IACzB,gFAA6B,CAAA;IAC7B,mFAAkC,CAAA;IAClC,sFAAoC,CAAA;IACpC,qFAAoC,CAAA;AACtC,CAAC,EAPW,sBAAsB,sCAAtB,sBAAsB,QAOjC","sourcesContent":["import {\n LpPoolEntity,\n LpPositionEntity,\n LpTransactionHistoryEntity,\n LpBalanceGranularity,\n LpWithdrawBalanceEntity,\n MarketEntity,\n} from '@reyaxyz/common';\n\nexport type GetLpPoolsResult = LpPoolEntity[];\n\nexport type GetLpPoolResult = LpPoolEntity;\n\nexport type GetLpPoolParams = {\n id: LpPoolEntity['id'];\n};\n\nexport type GetLpPoolTransactionHistoryResult = LpTransactionHistoryEntity[];\n\nexport type GetLpPositionsParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n};\n\nexport type GetLpPositionsResult = LpPositionEntity[];\n\nexport type GetLpPoolWithdrawBalanceParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n};\n\nexport type GetLpPoolWithdrawBalanceResult = LpWithdrawBalanceEntity;\n\nexport type GetLpPoolTransactionHistoryParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n limit?: number;\n};\n\nexport type GetLpPoolBalanceChartDataParams = {\n poolId: LpPoolEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: LpBalanceGranularity;\n };\n};\n\nexport enum PerformanceGranularity {\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\nexport type GetLpPoolPerformanceChartDataParams = {\n poolId: LpPoolEntity['id'];\n address: string; // wallet address\n filters: {\n timeframeMs: number;\n granularity: PerformanceGranularity;\n };\n};\n\nexport type getLpPoolDepthChartSimulationDataParams = {\n marketId: MarketEntity['id'];\n};\n"]}
@@ -1,7 +1,6 @@
1
1
  import { GetDepthChartParams, GetDepthChartResult, DepthSimulationLoadDataParams } from './types';
2
2
  import LpClient from '../lp';
3
3
  export default class DepthChartSimulationClient {
4
- private poolId;
5
4
  private marketId;
6
5
  private loadedData;
7
6
  private lpClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAE9B,MAAM,SAAS,CAAC;AAEjB,OAAO,QAAQ,MAAM,OAAO,CAAC;AAI7B,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,QAAQ,CAAW;gBACf,QAAQ,EAAE,QAAQ;IAMxB,GAAG,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;YAOjD,aAAa;IAU3B,aAAa,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,mBAAmB;IA4BhE,OAAO,CAAC,SAAS;IA2BjB,MAAM,CAAC,8BAA8B,CACnC,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,GACrB,MAAM;CAQV"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAE9B,MAAM,SAAS,CAAC;AAEjB,OAAO,QAAQ,MAAM,OAAO,CAAC;AAI7B,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,QAAQ,CAAW;gBACf,QAAQ,EAAE,QAAQ;IAMxB,GAAG,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;YAMjD,aAAa;IAM3B,aAAa,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,mBAAmB;IAsChE,OAAO,CAAC,SAAS;IA2BjB,MAAM,CAAC,8BAA8B,CACnC,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,GACrB,MAAM;CAQV"}
@@ -1,6 +1,5 @@
1
- import { LpPoolEntity, MarketEntity } from '@reyaxyz/common';
1
+ import { MarketEntity } from '@reyaxyz/common';
2
2
  export type DepthSimulationLoadDataParams = {
3
- poolId: LpPoolEntity['id'];
4
3
  marketId: MarketEntity['id'];
5
4
  };
6
5
  export type SimulateDepthEntity = {
@@ -16,5 +15,7 @@ export type GetDepthChartResult = {
16
15
  export type GetDepthChartParams = {
17
16
  step?: number;
18
17
  percentageChange?: number;
18
+ maxPoints?: number;
19
+ dynamicStepIncreaseFactor?: number;
19
20
  };
20
21
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/types.ts"],"names":[],"mappings":"AAAA,OAA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B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,iCAAiC,EACjC,iCAAiC,EACjC,oBAAoB,EACpB,8BAA8B,EAC9B,8BAA8B,EAC9B,+BAA+B,EAC/B,mCAAmC,EACnC,uCAAuC,EACxC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,EACnC,UAAU,EACV,uCAAuC,EACxC,MAAM,iBAAiB,CAAC;AACzB,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IACxC,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAKvC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAK5D,2BAA2B,CAC/B,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAQvC,cAAc,CAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAO1B,wBAAwB,CAC5B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAOpC,yBAAyB,CAC7B,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,+BAA+B,CAAC;IAQrC,6BAA6B,CACjC,MAAM,EAAE,mCAAmC,GAC1C,OAAO,CAAC,mCAAmC,CAAC;IASzC,iCAAiC,CACrC,MAAM,EAAE,uCAAuC,GAC9C,OAAO,CAAC,uCAAuC,CAAC;CAMpD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,iCAAiC,EACjC,iCAAiC,EACjC,oBAAoB,EACpB,8BAA8B,EAC9B,8BAA8B,EAC9B,+BAA+B,EAC/B,mCAAmC,EACnC,uCAAuC,EACxC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,EACnC,UAAU,EACV,uCAAuC,EACxC,MAAM,iBAAiB,CAAC;AACzB,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IACxC,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAKvC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAK5D,2BAA2B,CAC/B,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAQvC,cAAc,CAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAO1B,wBAAwB,CAC5B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAOpC,yBAAyB,CAC7B,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,+BAA+B,CAAC;IAQrC,6BAA6B,CACjC,MAAM,EAAE,mCAAmC,GAC1C,OAAO,CAAC,mCAAmC,CAAC;IASzC,iCAAiC,CACrC,MAAM,EAAE,uCAAuC,GAC9C,OAAO,CAAC,uCAAuC,CAAC;CAIpD"}
@@ -44,7 +44,6 @@ export type GetLpPoolPerformanceChartDataParams = {
44
44
  };
45
45
  };
46
46
  export type getLpPoolDepthChartSimulationDataParams = {
47
- poolId: LpPoolEntity['id'];
48
47
  marketId: MarketEntity['id'];
49
48
  };
50
49
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/lp/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,YAAY,EACb,MAAM,iBA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CAAC,CAAC;IAC3B,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,oBAAoB,CAAC;KACnC,CAAC;CACH,CAAC;AAEF,oBAAY,sBAAsB;IAChC,UAAU,QAAY;IACtB,QAAQ,UAAiB;IACzB,OAAO,WAAsB;IAC7B,QAAQ,YAA0B;IAClC,SAAS,aAA2B;IACpC,QAAQ,cAA4B;CACrC;AAED,MAAM,MAAM,mCAAmC,GAAG;IAChD,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,sBAAsB,CAAC;KACrC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.55.0",
3
+ "version": "0.56.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -33,9 +33,9 @@
33
33
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
34
34
  },
35
35
  "dependencies": {
36
- "@reyaxyz/common": "0.37.0",
36
+ "@reyaxyz/common": "0.37.1",
37
37
  "bignumber.js": "^9.1.2"
38
38
  },
39
39
  "packageManager": "pnpm@8.10.4",
40
- "gitHead": "32bd99005ada02134cb54b281e33ab9da1920f4d"
40
+ "gitHead": "688a5c3a795181be3db27acd09092ce58343c33e"
41
41
  }
@@ -10,7 +10,6 @@ import { DepthSimulationState } from '@reyaxyz/common';
10
10
  import BigNumber from 'bignumber.js';
11
11
 
12
12
  export default class DepthChartSimulationClient {
13
- private poolId: number | null = null;
14
13
  private marketId: number | null = null;
15
14
  private loadedData: DepthSimulationState | null = null;
16
15
  private lpClient: LpClient;
@@ -19,44 +18,49 @@ export default class DepthChartSimulationClient {
19
18
  this.lpClient = lpClient;
20
19
  }
21
20
 
22
- // Method to asynchronously load data based on marketId and poolId
21
+ // Method to asynchronously load data based on marketId
23
22
  async arm(params: DepthSimulationLoadDataParams): Promise<void> {
24
- this.poolId = params.poolId;
25
23
  this.marketId = params.marketId;
26
24
 
27
- this.loadedData = await this.fetchPoolData(this.poolId, this.marketId);
25
+ this.loadedData = await this.fetchPoolData(this.marketId);
28
26
  }
29
27
 
30
- private async fetchPoolData(
31
- poolId: number,
32
- marketId: number,
33
- ): Promise<DepthSimulationState> {
28
+ private async fetchPoolData(marketId: number): Promise<DepthSimulationState> {
34
29
  return this.lpClient.getLpPoolDepthChartSimulationData({
35
- poolId: poolId,
36
30
  marketId: marketId,
37
31
  });
38
32
  }
39
33
 
40
34
  getDepthChart(params?: GetDepthChartParams): GetDepthChartResult {
41
- // step is in notional
42
35
  if (!this.loadedData) {
43
36
  throw new Error('Data not loaded. Call arm() first.');
44
37
  }
45
- const step = params?.step || 10;
38
+
39
+ const step = params?.step || 10; // Initial step size
46
40
  const percentageChange = params?.percentageChange || 30;
41
+ const maxPoints = params?.maxPoints || 100; // Maximum points on each side
42
+ const dynamicStepIncreaseFactor = params?.dynamicStepIncreaseFactor || 2; // Factor to increase step size dynamically
47
43
 
48
44
  const leftResults: SimulateDepthEntity[] = [];
49
45
  const rightResults: SimulateDepthEntity[] = [];
50
- for (let delta = 0; ; delta += step) {
46
+ let currentStep = step;
47
+
48
+ // Collect points for the left side
49
+ for (let i = 0, delta = 0; i < maxPoints; delta -= currentStep, i++) {
51
50
  const result = this.calculate(delta);
52
51
  if (result.priceImpact >= percentageChange) break;
53
52
  leftResults.push(result);
53
+ if (i % (maxPoints / 10) === 0) currentStep *= dynamicStepIncreaseFactor; // Increase step size dynamically
54
54
  }
55
55
 
56
- for (let delta = 0; ; delta -= step) {
56
+ currentStep = step; // Reset step size for the right side
57
+
58
+ // Collect points for the right side
59
+ for (let i = 0, delta = 0; i < maxPoints; delta += currentStep, i++) {
57
60
  const result = this.calculate(delta);
58
61
  if (result.priceImpact >= percentageChange) break;
59
62
  rightResults.push(result);
63
+ if (i % (maxPoints / 10) === 0) currentStep *= dynamicStepIncreaseFactor; // Increase step size dynamically
60
64
  }
61
65
 
62
66
  return {
@@ -1,7 +1,6 @@
1
- import { LpPoolEntity, MarketEntity } from '@reyaxyz/common';
1
+ import { MarketEntity } from '@reyaxyz/common';
2
2
 
3
3
  export type DepthSimulationLoadDataParams = {
4
- poolId: LpPoolEntity['id'];
5
4
  marketId: MarketEntity['id'];
6
5
  };
7
6
 
@@ -20,4 +19,6 @@ export type GetDepthChartResult = {
20
19
  export type GetDepthChartParams = {
21
20
  step?: number;
22
21
  percentageChange?: number;
22
+ maxPoints?: number;
23
+ dynamicStepIncreaseFactor?: number;
23
24
  };
@@ -81,9 +81,7 @@ export default class LpClient extends RestClient {
81
81
  async getLpPoolDepthChartSimulationData(
82
82
  params: getLpPoolDepthChartSimulationDataParams,
83
83
  ): Promise<GetLpPoolDepthChartSimulationDataResult> {
84
- const uri = `/api/lp-pools/${params.poolId}/depth-simulation-data`;
85
- return this.get(uri, {
86
- marketId: params.marketId,
87
- });
84
+ const uri = `/api/lp-pools/${params.marketId}/depth-simulation-data`;
85
+ return this.get(uri);
88
86
  }
89
87
  }
@@ -64,6 +64,5 @@ export type GetLpPoolPerformanceChartDataParams = {
64
64
  };
65
65
 
66
66
  export type getLpPoolDepthChartSimulationDataParams = {
67
- poolId: LpPoolEntity['id'];
68
67
  marketId: MarketEntity['id'];
69
68
  };