impermax-sdk 2.1.208 → 2.1.209

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.
@@ -14,6 +14,8 @@ export interface Position {
14
14
  debtY: number;
15
15
  depositX(amount: number): void;
16
16
  depositY(amount: number): void;
17
+ depositX(amount: number): void;
18
+ depositY(amount: number): void;
17
19
  withdrawX(amount: number): void;
18
20
  withdrawY(amount: number): void;
19
21
  borrowX(amount: number): void;
@@ -22,10 +24,13 @@ export interface Position {
22
24
  repayY(amount: number): void;
23
25
  isUnderwater(): boolean;
24
26
  isLiquidatable(): boolean;
27
+ getInitialDepositedX(): number;
28
+ getInitialDepositedY(): number;
25
29
  getDepositedX(): number;
26
30
  getDepositedY(): number;
27
31
  getNetX(): number;
28
32
  getNetY(): number;
33
+ getInitialLeverage(): number;
29
34
  getLeverage(): number;
30
35
  getLiquidationRange(): {
31
36
  priceA: number;
@@ -43,8 +43,11 @@ export declare class UniswapV2Position implements Position {
43
43
  private getValueGivenAmounts;
44
44
  private getAmountXGivenValue;
45
45
  private getAmountYGivenValue;
46
+ private getInitialDebtValue;
46
47
  private getDebtValueGivenPrice;
48
+ private getInitialCollateralValue;
47
49
  private getCollateralValueGivenPrice;
50
+ private getInitialEquityValue;
48
51
  private getEquityValueGivenPrice;
49
52
  private getDebtValue;
50
53
  private getCollateralValue;
@@ -70,6 +73,8 @@ export declare class UniswapV2Position implements Position {
70
73
  /**
71
74
  * PUBLIC GETTERS
72
75
  */
76
+ getInitialDepositedX(): number;
77
+ getInitialDepositedY(): number;
73
78
  getDepositedX(): number;
74
79
  getDepositedY(): number;
75
80
  getNetX(): number;
@@ -80,6 +85,7 @@ export declare class UniswapV2Position implements Position {
80
85
  priceA: number;
81
86
  priceB: number;
82
87
  } | undefined;
88
+ getInitialLeverage(): number;
83
89
  getLeverage(): number;
84
90
  getOptimalLiquidity(amountX: number, amountY: number): {
85
91
  liquidity: number;
@@ -114,12 +114,21 @@ class UniswapV2Position {
114
114
  getAmountYGivenValue(value) {
115
115
  return value;
116
116
  }
117
+ getInitialDebtValue() {
118
+ return this.getValueGivenAmounts(this.initialDebtX, this.initialDebtY);
119
+ }
117
120
  getDebtValueGivenPrice(price) {
118
121
  return this.getValueGivenPriceAndAmounts(price, this.debtX, this.debtY);
119
122
  }
123
+ getInitialCollateralValue() {
124
+ return this.getValueGivenAmounts(this.getInitialRealX(), this.getInitialRealY());
125
+ }
120
126
  getCollateralValueGivenPrice(price) {
121
127
  return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenPrice(price), this.getRealYGivenPrice(price));
122
128
  }
129
+ getInitialEquityValue() {
130
+ return this.getInitialCollateralValue() - this.getInitialDebtValue();
131
+ }
123
132
  getEquityValueGivenPrice(price) {
124
133
  return this.getCollateralValueGivenPrice(price) - this.getDebtValueGivenPrice(price);
125
134
  }
@@ -205,6 +214,12 @@ class UniswapV2Position {
205
214
  /**
206
215
  * PUBLIC GETTERS
207
216
  */
217
+ getInitialDepositedX() {
218
+ return this.getInitialRealX();
219
+ }
220
+ getInitialDepositedY() {
221
+ return this.getInitialRealY();
222
+ }
208
223
  getDepositedX() {
209
224
  return this.getRealX();
210
225
  }
@@ -238,6 +253,16 @@ class UniswapV2Position {
238
253
  priceB: priceB && priceB < HIGHEST_PRICE ? priceB : Infinity,
239
254
  };
240
255
  }
256
+ getInitialLeverage() {
257
+ const leverage = this.getInitialCollateralValue() / this.getInitialEquityValue();
258
+ if (!leverage)
259
+ return 1;
260
+ if (Number.isNaN(leverage))
261
+ return 1;
262
+ if (leverage < 1)
263
+ return 1;
264
+ return leverage;
265
+ }
241
266
  getLeverage() {
242
267
  const leverage = this.getCollateralValue() / this.getEquityValue();
243
268
  if (!leverage)
@@ -49,10 +49,13 @@ export declare class UniswapV3Position implements Position {
49
49
  private getValueGivenAmounts;
50
50
  private getAmountXGivenValue;
51
51
  private getAmountYGivenValue;
52
+ private getInitialDebtValue;
52
53
  private getDebtValueGivenPrice;
54
+ private getInitialCollateralValue;
53
55
  private getCollateralValueGivenPrice;
54
56
  private getWeightedCollateralValueGivenPrice;
55
57
  private getWeightedCollateralValueGivenPriceAndDeltaLeverage;
58
+ private getInitialEquityValue;
56
59
  private getEquityValueGivenPrice;
57
60
  private getDebtValue;
58
61
  private getCollateralValue;
@@ -84,6 +87,8 @@ export declare class UniswapV3Position implements Position {
84
87
  /**
85
88
  * PUBLIC GETTERS
86
89
  */
90
+ getInitialDepositedX(): number;
91
+ getInitialDepositedY(): number;
87
92
  getDepositedX(): number;
88
93
  getDepositedY(): number;
89
94
  getNetX(): number;
@@ -94,6 +99,7 @@ export declare class UniswapV3Position implements Position {
94
99
  priceA: number;
95
100
  priceB: number;
96
101
  } | undefined;
102
+ getInitialLeverage(): number;
97
103
  getLeverage(): number;
98
104
  getOptimalLiquidity(amountX: number, amountY: number): {
99
105
  liquidity: number;
@@ -130,9 +130,15 @@ class UniswapV3Position {
130
130
  getAmountYGivenValue(value) {
131
131
  return value;
132
132
  }
133
+ getInitialDebtValue() {
134
+ return this.getValueGivenAmounts(this.initialDebtX, this.initialDebtY);
135
+ }
133
136
  getDebtValueGivenPrice(price) {
134
137
  return this.getValueGivenPriceAndAmounts(price, this.debtX, this.debtY);
135
138
  }
139
+ getInitialCollateralValue() {
140
+ return this.getValueGivenAmounts(this.getInitialRealX() + this.initialUnclaimedFeesX, this.getInitialRealY() + this.initialUnclaimedFeesY);
141
+ }
136
142
  getCollateralValueGivenPrice(price) {
137
143
  return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenPrice(price) + this.unclaimedFeesX, this.getRealYGivenPrice(price) + this.unclaimedFeesY);
138
144
  }
@@ -143,6 +149,9 @@ class UniswapV3Position {
143
149
  const liquidity = this.getLiquidityGivenAmounts(deltaX, deltaY);
144
150
  return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenLiquidityAndPrice(this.liquidity + liquidity, price) + this.unclaimedFeesX * FEE_COLLECTED_WEIGHT, this.getRealYGivenLiquidityAndPrice(this.liquidity + liquidity, price) + this.unclaimedFeesY * FEE_COLLECTED_WEIGHT);
145
151
  }
152
+ getInitialEquityValue() {
153
+ return this.getInitialCollateralValue() - this.getInitialDebtValue();
154
+ }
146
155
  getEquityValueGivenPrice(price) {
147
156
  return this.getCollateralValueGivenPrice(price) - this.getDebtValueGivenPrice(price);
148
157
  }
@@ -270,6 +279,12 @@ class UniswapV3Position {
270
279
  /**
271
280
  * PUBLIC GETTERS
272
281
  */
282
+ getInitialDepositedX() {
283
+ return this.getInitialRealX() + this.initialUnclaimedFeesX;
284
+ }
285
+ getInitialDepositedY() {
286
+ return this.getInitialRealY() + this.initialUnclaimedFeesY;
287
+ }
273
288
  getDepositedX() {
274
289
  return this.getRealX() + this.unclaimedFeesX;
275
290
  }
@@ -303,6 +318,16 @@ class UniswapV3Position {
303
318
  priceB: priceB && priceB < HIGHEST_PRICE ? priceB : Infinity,
304
319
  };
305
320
  }
321
+ getInitialLeverage() {
322
+ const leverage = this.getInitialCollateralValue() / this.getInitialEquityValue();
323
+ if (!leverage)
324
+ return 1;
325
+ if (Number.isNaN(leverage))
326
+ return 1;
327
+ if (leverage < 1)
328
+ return 1;
329
+ return leverage;
330
+ }
306
331
  getLeverage() {
307
332
  const leverage = this.getCollateralValue() / this.getEquityValue();
308
333
  if (!leverage)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.208",
3
+ "version": "2.1.209",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",