@reyaxyz/api-sdk 0.63.7 → 0.63.9
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 +15 -14
- 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/types/clients/modules/depth-chart.simulation/index.d.ts.map +1 -1
- package/dist/types/clients/modules/depth-chart.simulation/types.d.ts +1 -0
- package/dist/types/clients/modules/depth-chart.simulation/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/modules/depth-chart.simulation/index.ts +20 -13
- package/src/clients/modules/depth-chart.simulation/types.ts +1 -0
|
@@ -77,31 +77,32 @@ var DepthChartSimulationClient = /** @class */ (function () {
|
|
|
77
77
|
if (!this.loadedData) {
|
|
78
78
|
throw new Error('Data not loaded. Call arm() first.');
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
80
|
+
// Adjust initial step size based on max exposures
|
|
81
|
+
var maxExposure = Math.max(this.loadedData.maxLongExposure, Math.abs(this.loadedData.maxShortExposure));
|
|
82
|
+
var initialStepSize = maxExposure / ((params === null || params === void 0 ? void 0 : params.initialSteps) || 100) || 10; // Customize this based on your needs
|
|
83
|
+
var step = (params === null || params === void 0 ? void 0 : params.step) || initialStepSize;
|
|
84
|
+
var percentageChange = (params === null || params === void 0 ? void 0 : params.percentageChange) || 50;
|
|
85
|
+
var currentStep = step;
|
|
84
86
|
var leftResults = [];
|
|
85
87
|
var rightResults = [];
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
// Simplified loop conditions to focus on reaching maxExposure limits efficiently
|
|
89
|
+
var delta = 0;
|
|
90
|
+
while (Math.abs(delta) < maxExposure) {
|
|
91
|
+
delta -= currentStep;
|
|
89
92
|
var result = this.calculate(delta);
|
|
90
93
|
if (result.priceImpact >= percentageChange)
|
|
91
94
|
break;
|
|
92
95
|
leftResults.push(result);
|
|
93
|
-
|
|
94
|
-
currentStep *= dynamicStepIncreaseFactor; // Increase step size dynamically
|
|
96
|
+
// Adjust currentStep based on your liquidity model or other factors
|
|
95
97
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
delta = 0; // Reset for the right side
|
|
99
|
+
while (Math.abs(delta) < maxExposure) {
|
|
100
|
+
delta += currentStep;
|
|
99
101
|
var result = this.calculate(delta);
|
|
100
102
|
if (result.priceImpact >= percentageChange)
|
|
101
103
|
break;
|
|
102
104
|
rightResults.push(result);
|
|
103
|
-
|
|
104
|
-
currentStep *= dynamicStepIncreaseFactor; // Increase step size dynamically
|
|
105
|
+
// Adjust currentStep similarly
|
|
105
106
|
}
|
|
106
107
|
return {
|
|
107
108
|
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;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;;;;;;wBAC7C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;wBAEhC,KAAA,IAAI,CAAA;wBAAc,qBAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAA;;wBAAzD,GAAK,UAAU,GAAG,SAAuC,CAAC;;;;;KAC3D;IAEa,kDAAa,GAA3B,UAA4B,QAAgB;;;gBAC1C,sBAAO,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC;wBACrD,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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,AAzGD,IAyGC","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 // Adjust initial step size based on max exposures\n const maxExposure = Math.max(\n this.loadedData.maxLongExposure,\n Math.abs(this.loadedData.maxShortExposure),\n );\n const initialStepSize = maxExposure / (params?.initialSteps || 100) || 10; // Customize this based on your needs\n\n const step = params?.step || initialStepSize;\n const percentageChange = params?.percentageChange || 50;\n\n const currentStep = step;\n\n const leftResults: SimulateDepthEntity[] = [];\n const rightResults: SimulateDepthEntity[] = [];\n\n // Simplified loop conditions to focus on reaching maxExposure limits efficiently\n let delta = 0;\n while (Math.abs(delta) < maxExposure) {\n delta -= currentStep;\n const result = this.calculate(delta);\n if (result.priceImpact >= percentageChange) break;\n leftResults.push(result);\n // Adjust currentStep based on your liquidity model or other factors\n }\n\n delta = 0; // Reset for the right side\n while (Math.abs(delta) < maxExposure) {\n delta += currentStep;\n const result = this.calculate(delta);\n if (result.priceImpact >= percentageChange) break;\n rightResults.push(result);\n // Adjust currentStep similarly\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 { 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"]}
|
|
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 initialSteps?: number;\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,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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,E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|
|
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,EAAE,mBAAmB,EAAE,CAAC;IACjC,UAAU,EAAE,mBAAmB,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.63.
|
|
3
|
+
"version": "0.63.9",
|
|
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.
|
|
36
|
+
"@reyaxyz/common": "0.53.0",
|
|
37
37
|
"bignumber.js": "^9.1.2"
|
|
38
38
|
},
|
|
39
39
|
"packageManager": "pnpm@8.10.4",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "49b10d7c09c1a94e4c11d57e328423c3d304c686"
|
|
41
41
|
}
|
|
@@ -36,31 +36,38 @@ export default class DepthChartSimulationClient {
|
|
|
36
36
|
throw new Error('Data not loaded. Call arm() first.');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
// Adjust initial step size based on max exposures
|
|
40
|
+
const maxExposure = Math.max(
|
|
41
|
+
this.loadedData.maxLongExposure,
|
|
42
|
+
Math.abs(this.loadedData.maxShortExposure),
|
|
43
|
+
);
|
|
44
|
+
const initialStepSize = maxExposure / (params?.initialSteps || 100) || 10; // Customize this based on your needs
|
|
45
|
+
|
|
46
|
+
const step = params?.step || initialStepSize;
|
|
47
|
+
const percentageChange = params?.percentageChange || 50;
|
|
48
|
+
|
|
49
|
+
const currentStep = step;
|
|
43
50
|
|
|
44
51
|
const leftResults: SimulateDepthEntity[] = [];
|
|
45
52
|
const rightResults: SimulateDepthEntity[] = [];
|
|
46
|
-
let currentStep = step;
|
|
47
53
|
|
|
48
|
-
//
|
|
49
|
-
|
|
54
|
+
// Simplified loop conditions to focus on reaching maxExposure limits efficiently
|
|
55
|
+
let delta = 0;
|
|
56
|
+
while (Math.abs(delta) < maxExposure) {
|
|
57
|
+
delta -= currentStep;
|
|
50
58
|
const result = this.calculate(delta);
|
|
51
59
|
if (result.priceImpact >= percentageChange) break;
|
|
52
60
|
leftResults.push(result);
|
|
53
|
-
|
|
61
|
+
// Adjust currentStep based on your liquidity model or other factors
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
for (let i = 0, delta = 0; i < maxPoints; delta += currentStep, i++) {
|
|
64
|
+
delta = 0; // Reset for the right side
|
|
65
|
+
while (Math.abs(delta) < maxExposure) {
|
|
66
|
+
delta += currentStep;
|
|
60
67
|
const result = this.calculate(delta);
|
|
61
68
|
if (result.priceImpact >= percentageChange) break;
|
|
62
69
|
rightResults.push(result);
|
|
63
|
-
|
|
70
|
+
// Adjust currentStep similarly
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
return {
|