@reyaxyz/api-sdk 0.55.0 → 0.56.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.
- package/dist/clients/modules/depth-chart.simulation/index.js +16 -10
- package/dist/clients/modules/depth-chart.simulation/index.js.map +1 -1
- package/dist/clients/modules/depth-chart.simulation/types.js.map +1 -1
- package/dist/clients/modules/lp/index.js +2 -4
- package/dist/clients/modules/lp/index.js.map +1 -1
- package/dist/clients/modules/lp/types.js.map +1 -1
- package/dist/types/clients/modules/depth-chart.simulation/index.d.ts +0 -1
- package/dist/types/clients/modules/depth-chart.simulation/index.d.ts.map +1 -1
- package/dist/types/clients/modules/depth-chart.simulation/types.d.ts +3 -2
- package/dist/types/clients/modules/depth-chart.simulation/types.d.ts.map +1 -1
- package/dist/types/clients/modules/lp/index.d.ts.map +1 -1
- package/dist/types/clients/modules/lp/types.d.ts +0 -1
- package/dist/types/clients/modules/lp/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/modules/depth-chart.simulation/index.ts +17 -13
- package/src/clients/modules/depth-chart.simulation/types.ts +3 -2
- package/src/clients/modules/lp/index.ts +2 -4
- package/src/clients/modules/lp/types.ts +0 -1
|
@@ -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
|
|
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.
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
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;QAGrD,oBAAoB;QACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,uDAAuD;IACjD,wCAAG,GAAT,UAAU,MAAqC;;;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pClient 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 {
|
|
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.
|
|
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;;
|
|
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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etLpPoolResult,\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.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
|
|
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 +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,
|
|
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 {
|
|
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,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,E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AM,EAAE,uCAAuC,GAC9C,OAAO,CAAC,uCAAuC,CAAC;
|
|
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"}
|
|
@@ -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,uBA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AW,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.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"bignumber.js": "^9.1.2"
|
|
38
38
|
},
|
|
39
39
|
"packageManager": "pnpm@8.10.4",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "47286a9b0cb70dcec5a341f25c5a8ef9930baf64"
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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.
|
|
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
|
}
|