impermax-sdk 2.1.156 → 2.1.158

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.
@@ -51,7 +51,6 @@ export declare class UniswapV3Position implements Position {
51
51
  /**
52
52
  * PUBLIC SETTERS
53
53
  */
54
- setLiquidity(_liquidity: number): void;
55
54
  setRealXRealY(amountX: number, amountY: number): void;
56
55
  setRealX(amountX: number): void;
57
56
  setRealY(amountY: number): void;
@@ -155,30 +155,42 @@ class UniswapV3Position {
155
155
  * PUBLIC SETTERS
156
156
  */
157
157
  // Setters
158
- setLiquidity(_liquidity) {
159
- this.checkLock();
160
- this.liquidity = _liquidity;
161
- }
158
+ /*public setLiquidity(_liquidity: number) {
159
+ this.checkLock();
160
+ this.liquidity = _liquidity;
161
+ }*/
162
162
  setRealXRealY(amountX, amountY) {
163
+ if (Number.isNaN(amountX))
164
+ return;
165
+ if (Number.isNaN(amountY))
166
+ return;
163
167
  this.checkLock();
164
168
  const { liquidity } = this.getOptimalLiquidity(amountX, amountY);
165
169
  this.liquidity = liquidity;
166
170
  }
167
171
  setRealX(amountX) {
172
+ if (Number.isNaN(amountX))
173
+ return;
168
174
  this.checkLock();
169
175
  const { liquidity } = this.getOptimalLiquidity(amountX, Infinity);
170
176
  this.liquidity = liquidity;
171
177
  }
172
178
  setRealY(amountY) {
179
+ if (Number.isNaN(amountY))
180
+ return;
173
181
  this.checkLock();
174
182
  const { liquidity } = this.getOptimalLiquidity(Infinity, amountY);
175
183
  this.liquidity = liquidity;
176
184
  }
177
185
  setDebtX(_debtX) {
186
+ if (Number.isNaN(_debtX))
187
+ return;
178
188
  this.checkLock();
179
189
  this.debtX = _debtX;
180
190
  }
181
191
  setDebtY(_debtY) {
192
+ if (Number.isNaN(_debtY))
193
+ return;
182
194
  this.checkLock();
183
195
  this.debtY = _debtY;
184
196
  }
@@ -284,8 +296,10 @@ class UniswapV3Position {
284
296
  const normalizedDeltaDebtX = projectedDebtX * currentLeverage / highLeverage - this.debtX;
285
297
  const normalizedDeltaDebtY = projectedDebtY * currentLeverage / highLeverage - this.debtY;
286
298
  const [deltaDebtX, deltaDebtY] = this.getMaxDeltaDebtInRange(0, 0, normalizedDeltaDebtX, normalizedDeltaDebtY);
287
- const ratio = realX > 0 ? deltaDebtX / normalizedDeltaDebtX : deltaDebtY / normalizedDeltaDebtY;
288
- return currentLeverage + (highLeverage - currentLeverage) * ratio;
299
+ const collateralValue = this.getCollateralValue();
300
+ const debtValue = this.getValueGivenAmounts(this.debtX + deltaDebtX, this.debtY + deltaDebtY);
301
+ const equityValue = collateralValue - debtValue;
302
+ return collateralValue / equityValue;
289
303
  }
290
304
  getMinLeverage() {
291
305
  const realX = this.getRealX();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.156",
3
+ "version": "2.1.158",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",