impermax-sdk 2.1.170 → 2.1.172
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/lib/index.d.ts +2 -1
- package/lib/index.js +5 -3
- package/lib/utils/position/index.d.ts +1 -0
- package/lib/utils/position/index.js +1 -0
- package/lib/utils/position/uniswapV2/index.d.ts +98 -0
- package/lib/utils/position/uniswapV2/index.js +332 -310
- package/lib/utils/position/uniswapV3/index.d.ts +1 -0
- package/lib/utils/position/uniswapV3/index.js +7 -5
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -46,4 +46,5 @@ import OffchainAccountLendingPoolV3 from "./offchain/account/lendingPool/offchai
|
|
|
46
46
|
import OffchainAccountNftlpUniswapV3 from './offchain/account/lendingPool/nftlp/offchainAccountNftlpUniswapV3';
|
|
47
47
|
import { MAX_TICK, MIN_TICK, formatPriceSqrtX96, uniV3TickToPrice } from "./utils/nftlpMath/uniswapV3General";
|
|
48
48
|
import UniswapV3Position from './utils/position/uniswapV3';
|
|
49
|
-
|
|
49
|
+
import UniswapV2Position from './utils/position/uniswapV2';
|
|
50
|
+
export { offchain, OffchainMultichain, Offchain, OffchainLendingPool, OffchainPoolToken, OffchainCollateral, OffchainBorrowable, OffchainVault, OffchainLeveragedVault, OffchainLendingVault, OffchainHedgedVault, OffchainConfigManager, OffchainPairConfig, OffchainProposal, OffchainMultichainAccount, OffchainAccount, OffchainAccountLendingPool, OffchainAccountPoolToken, OffchainAccountCollateral, OffchainAccountBorrowable, OffchainLeveragedPosition, OffchainAccountVault, OffchainPriceHelper, OffchainSolidexHelper, PoolTokenData, BorrowableData, CollateralData, BorrowablePastData, TokenData, RewardData, PairData, FarmingPoolData, LendingPoolPastData, LendingPoolData, CollateralPosition, SupplyPosition, BorrowPosition, UserData, TvlData, XimxData, LendingVaultData, VaultPosition, PairConfigData, ProposalData, ProposalMetadata, VaultRisk, VaultType, onchain, Onchain, OnchainLendingPool, OnchainPoolToken, OnchainBorrowable, OnchainCollateral, OnchainLendingVault, OnchainConfigManager, OnchainProposal, OnchainPairConfig, OnchainAccount, OnchainAccountLendingPool, OnchainAccountLendingPoolV2, OnchainAccountLendingPoolV3, OnchainAccountNftlpUniswapV3, OnchainAccountPoolToken, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingVault, OnchainContractsHelper, OnchainImpermaxFactory, OnchainInteractions, OnchainInteractionsLendingPool, OnchainInteractionsPoolToken, OnchainInteractionsCollateral, OnchainInteractionsBorrowable, OnchainInteractionsLendingVault, OnchainInteractionsConfigManager, Contract, ApprovalType, PermitData, OnchainConfig, Changes, NO_CHANGES, Values, AirdropData, PendingRewardUI, CollateralConfig, BorrowableV2Config, BorrowableV3Config, PairConfig, CLAIM_AGGREGATOR, IMPERMAX_CHEF, IMX, IMPERMAX_FACTORY, getNetworkFactories, getFactoryByAddress, LENDING_VAULT_WATCHER, MERKLE_DISTRIBUTOR_IBEX, MERKLE_DISTRIBUTOR_IBEX_2, MERKLE_DISTRIBUTOR_ETH, ROUTER, SIMPLE_UNISWAP_ORACLE, WETH, MERKLE_URL_ETH, MERKLE_URL_IBEX, MERKLE_URL_IBEX_2, hrAmms, AMM_FACTORY, getAmmByFactory, AMM_SUBGRAPH_URLS, ADD_LIQUIDITY_URLS, AMM_LP_FEE, DEBANK_IDS, ETH_SYMBOL, ETH_NAME, SOLIDEX_FACTORIES, BORROW_FEE_FACTORIES, OLD_KINK_MULTIPLIER_FACTORIES, LIQUIDATION_FEE_FACTORIES, V2_FACTORIES, Farms, hrFarms, FarmIndex, STAKED_LP_FACTORY, getFarmByStakedLPFactory, NOT_SYNCED, DEADLINE, ZERO, APPROVE_AMOUNT, IMPERMAX_SUBGRAPH_URL, IMPERMAX_CHEF_SUBGRAPH_URL, BLOCKS_SUBGRAPH_URL, XIMX_SUBGRAPH_URL, Networks, Factory, Extension, PoolTokenType, Amms, Address, NetworkIndex, FactoryIndex, AddressIndex, NetworkFactoryIndex, LendingPoolIndex, AmmIndex, DistributorDetails, ProposalState, WhitelistState, VaultListOrderBy, VaultListParams, LendingPoolListOrderBy, LendingPoolListParams, SortDirection, LendingPoolVersion, PositionType, AccountPosition, PermitType, Permits, Permit, Borrowable, OnchainInteractionsLendingPoolV3, OnchainInteractionsNftlpUniswapV3, decimalToBalance, OffchainAccountLendingPoolV3, OffchainAccountNftlpUniswapV3, MAX_TICK, MIN_TICK, formatPriceSqrtX96, uniV3TickToPrice, isV3Factory, UniswapV3Position, UniswapV2Position, };
|
package/lib/index.js
CHANGED
|
@@ -26,9 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
29
|
+
exports.OnchainInteractionsPoolToken = exports.OnchainInteractionsLendingPool = exports.OnchainInteractions = exports.OnchainImpermaxFactory = exports.OnchainContractsHelper = exports.OnchainAccountLendingVault = exports.OnchainAccountCollateral = exports.OnchainAccountBorrowable = exports.OnchainAccountPoolToken = exports.OnchainAccountNftlpUniswapV3 = exports.OnchainAccountLendingPoolV3 = exports.OnchainAccountLendingPoolV2 = exports.OnchainAccountLendingPool = exports.OnchainAccount = exports.OnchainPairConfig = exports.OnchainProposal = exports.OnchainConfigManager = exports.OnchainLendingVault = exports.OnchainCollateral = exports.OnchainBorrowable = exports.OnchainPoolToken = exports.OnchainLendingPool = exports.Onchain = exports.onchain = exports.VaultType = exports.VaultRisk = exports.OffchainSolidexHelper = exports.OffchainPriceHelper = exports.OffchainAccountVault = exports.OffchainLeveragedPosition = exports.OffchainAccountBorrowable = exports.OffchainAccountCollateral = exports.OffchainAccountPoolToken = exports.OffchainAccountLendingPool = exports.OffchainAccount = exports.OffchainMultichainAccount = exports.OffchainProposal = exports.OffchainPairConfig = exports.OffchainConfigManager = exports.OffchainHedgedVault = exports.OffchainLendingVault = exports.OffchainLeveragedVault = exports.OffchainVault = exports.OffchainBorrowable = exports.OffchainCollateral = exports.OffchainPoolToken = exports.OffchainLendingPool = exports.Offchain = exports.OffchainMultichain = exports.offchain = void 0;
|
|
30
|
+
exports.Factory = exports.Networks = exports.XIMX_SUBGRAPH_URL = exports.BLOCKS_SUBGRAPH_URL = exports.IMPERMAX_CHEF_SUBGRAPH_URL = exports.IMPERMAX_SUBGRAPH_URL = exports.APPROVE_AMOUNT = exports.ZERO = exports.DEADLINE = exports.NOT_SYNCED = exports.getFarmByStakedLPFactory = exports.STAKED_LP_FACTORY = exports.hrFarms = exports.Farms = exports.V2_FACTORIES = exports.LIQUIDATION_FEE_FACTORIES = exports.OLD_KINK_MULTIPLIER_FACTORIES = exports.BORROW_FEE_FACTORIES = exports.SOLIDEX_FACTORIES = exports.ETH_NAME = exports.ETH_SYMBOL = exports.DEBANK_IDS = exports.AMM_LP_FEE = exports.ADD_LIQUIDITY_URLS = exports.AMM_SUBGRAPH_URLS = exports.getAmmByFactory = exports.AMM_FACTORY = exports.hrAmms = exports.MERKLE_URL_IBEX_2 = exports.MERKLE_URL_IBEX = exports.MERKLE_URL_ETH = exports.WETH = exports.SIMPLE_UNISWAP_ORACLE = exports.ROUTER = exports.MERKLE_DISTRIBUTOR_ETH = exports.MERKLE_DISTRIBUTOR_IBEX_2 = exports.MERKLE_DISTRIBUTOR_IBEX = exports.LENDING_VAULT_WATCHER = exports.getFactoryByAddress = exports.getNetworkFactories = exports.IMPERMAX_FACTORY = exports.IMX = exports.IMPERMAX_CHEF = exports.CLAIM_AGGREGATOR = exports.NO_CHANGES = exports.ApprovalType = exports.OnchainInteractionsConfigManager = exports.OnchainInteractionsLendingVault = exports.OnchainInteractionsBorrowable = exports.OnchainInteractionsCollateral = void 0;
|
|
31
|
+
exports.UniswapV2Position = exports.UniswapV3Position = exports.isV3Factory = exports.uniV3TickToPrice = exports.formatPriceSqrtX96 = exports.MIN_TICK = exports.MAX_TICK = exports.OffchainAccountNftlpUniswapV3 = exports.OffchainAccountLendingPoolV3 = exports.decimalToBalance = exports.OnchainInteractionsNftlpUniswapV3 = exports.OnchainInteractionsLendingPoolV3 = exports.Borrowable = exports.PermitType = exports.PositionType = exports.LendingPoolVersion = exports.SortDirection = exports.LendingPoolListOrderBy = exports.VaultListOrderBy = exports.WhitelistState = exports.ProposalState = exports.Amms = exports.PoolTokenType = exports.Extension = void 0;
|
|
32
32
|
const offchain_1 = __importStar(require("./offchain"));
|
|
33
33
|
exports.Offchain = offchain_1.default;
|
|
34
34
|
Object.defineProperty(exports, "OffchainAccount", { enumerable: true, get: function () { return offchain_1.OffchainAccount; } });
|
|
@@ -203,3 +203,5 @@ Object.defineProperty(exports, "formatPriceSqrtX96", { enumerable: true, get: fu
|
|
|
203
203
|
Object.defineProperty(exports, "uniV3TickToPrice", { enumerable: true, get: function () { return uniswapV3General_1.uniV3TickToPrice; } });
|
|
204
204
|
const uniswapV3_1 = __importDefault(require("./utils/position/uniswapV3"));
|
|
205
205
|
exports.UniswapV3Position = uniswapV3_1.default;
|
|
206
|
+
const uniswapV2_1 = __importDefault(require("./utils/position/uniswapV2"));
|
|
207
|
+
exports.UniswapV2Position = uniswapV2_1.default;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Position } from "../interface";
|
|
2
|
+
export declare class UniswapV2Position implements Position {
|
|
3
|
+
lockStateChange: boolean;
|
|
4
|
+
state: number;
|
|
5
|
+
/**
|
|
6
|
+
* NOTICE all values inside this class are normalized (no decimals or mantissa to take into account)
|
|
7
|
+
*/
|
|
8
|
+
liquidity: number;
|
|
9
|
+
debtX: number;
|
|
10
|
+
debtY: number;
|
|
11
|
+
initialLiquidity: number;
|
|
12
|
+
initialDebtX: number;
|
|
13
|
+
initialDebtY: number;
|
|
14
|
+
marketPrice: number;
|
|
15
|
+
oraclePrice: number;
|
|
16
|
+
safetyMargin: number;
|
|
17
|
+
liquidationPenalty: number;
|
|
18
|
+
constructor(_liquidity: number, // lp amount fixed by exchangeRate and k
|
|
19
|
+
_debtX: number, _debtY: number, _marketPrice: number, _oraclePrice: number, _safetyMargin: number, _liquidationPenalty: number, _lockStateChange: boolean);
|
|
20
|
+
private checkLock;
|
|
21
|
+
/**
|
|
22
|
+
* PRIVATE SETTERS
|
|
23
|
+
*/
|
|
24
|
+
private setRealXRealY;
|
|
25
|
+
private setRealX;
|
|
26
|
+
private setRealY;
|
|
27
|
+
private setDebtX;
|
|
28
|
+
private setDebtY;
|
|
29
|
+
/**
|
|
30
|
+
* PRIVATE GETTERS
|
|
31
|
+
*/
|
|
32
|
+
private getRealXGivenLiquidityAndPrice;
|
|
33
|
+
private getRealYGivenLiquidityAndPrice;
|
|
34
|
+
private getRealXGivenLiquidity;
|
|
35
|
+
private getRealYGivenLiquidity;
|
|
36
|
+
private getRealXGivenPrice;
|
|
37
|
+
private getRealYGivenPrice;
|
|
38
|
+
private getRealX;
|
|
39
|
+
private getRealY;
|
|
40
|
+
private getInitialRealX;
|
|
41
|
+
private getInitialRealY;
|
|
42
|
+
private getValueGivenPriceAndAmounts;
|
|
43
|
+
private getValueGivenAmounts;
|
|
44
|
+
private getAmountXGivenValue;
|
|
45
|
+
private getAmountYGivenValue;
|
|
46
|
+
private getDebtValueGivenPrice;
|
|
47
|
+
private getCollateralValueGivenPrice;
|
|
48
|
+
private getEquityValueGivenPrice;
|
|
49
|
+
private getDebtValue;
|
|
50
|
+
private getCollateralValue;
|
|
51
|
+
private getEquityValue;
|
|
52
|
+
private getLiquidityPostLiquidationValueGivenPriceAndDebt;
|
|
53
|
+
private isLiquidatableGivenPriceAndDebt;
|
|
54
|
+
private isLiquidatableGivenDebt;
|
|
55
|
+
private isLiquidatableGivenPrice;
|
|
56
|
+
private isUnderwaterGivenPrice;
|
|
57
|
+
private getLiquidationPriceInRange;
|
|
58
|
+
private getMaxDeltaDebtInRange;
|
|
59
|
+
/**
|
|
60
|
+
* PUBLIC SETTERS
|
|
61
|
+
*/
|
|
62
|
+
depositX(amount: number): void;
|
|
63
|
+
depositY(amount: number): void;
|
|
64
|
+
withdrawX(amount: number): void;
|
|
65
|
+
withdrawY(amount: number): void;
|
|
66
|
+
borrowX(amount: number): void;
|
|
67
|
+
borrowY(amount: number): void;
|
|
68
|
+
repayX(amount: number): void;
|
|
69
|
+
repayY(amount: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* PUBLIC GETTERS
|
|
72
|
+
*/
|
|
73
|
+
getDepositedX(): number;
|
|
74
|
+
getDepositedY(): number;
|
|
75
|
+
getNetX(): number;
|
|
76
|
+
getNetY(): number;
|
|
77
|
+
isLiquidatable(): boolean;
|
|
78
|
+
isUnderwater(): boolean;
|
|
79
|
+
getLiquidationRange(): {
|
|
80
|
+
priceA: number;
|
|
81
|
+
priceB: number;
|
|
82
|
+
} | undefined;
|
|
83
|
+
getLeverage(): number;
|
|
84
|
+
getOptimalLiquidity(amountX: number, amountY: number): {
|
|
85
|
+
liquidity: number;
|
|
86
|
+
amountX: number;
|
|
87
|
+
amountY: number;
|
|
88
|
+
};
|
|
89
|
+
getMaxLeverage(): number;
|
|
90
|
+
getMinLeverage(): number;
|
|
91
|
+
getMaxWithdrawable(): {
|
|
92
|
+
amountX: number;
|
|
93
|
+
amountY: number;
|
|
94
|
+
};
|
|
95
|
+
getMaxBorrowableX(): number;
|
|
96
|
+
getMaxBorrowableY(): number;
|
|
97
|
+
}
|
|
98
|
+
export default UniswapV2Position;
|
|
@@ -1,310 +1,332 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
//
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
//
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniswapV2Position = void 0;
|
|
4
|
+
function getRealX(liquidity, price) {
|
|
5
|
+
return liquidity / Math.sqrt(price);
|
|
6
|
+
}
|
|
7
|
+
function getRealY(liquidity, price) {
|
|
8
|
+
return liquidity * Math.sqrt(price);
|
|
9
|
+
}
|
|
10
|
+
const LOWEST_PRICE = 1 / 1e18;
|
|
11
|
+
const HIGHEST_PRICE = 1e18;
|
|
12
|
+
class UniswapV2Position {
|
|
13
|
+
constructor(_liquidity, // lp amount fixed by exchangeRate and k
|
|
14
|
+
_debtX, _debtY, _marketPrice, _oraclePrice, _safetyMargin, _liquidationPenalty, _lockStateChange) {
|
|
15
|
+
this.liquidity = _liquidity;
|
|
16
|
+
this.debtX = _debtX;
|
|
17
|
+
this.debtY = _debtY;
|
|
18
|
+
this.initialLiquidity = _liquidity;
|
|
19
|
+
this.initialDebtX = _debtX;
|
|
20
|
+
this.initialDebtY = _debtY;
|
|
21
|
+
this.marketPrice = _marketPrice;
|
|
22
|
+
this.oraclePrice = _oraclePrice;
|
|
23
|
+
this.safetyMargin = _safetyMargin;
|
|
24
|
+
this.liquidationPenalty = _liquidationPenalty;
|
|
25
|
+
this.lockStateChange = _lockStateChange;
|
|
26
|
+
this.state = 0;
|
|
27
|
+
}
|
|
28
|
+
checkLock() {
|
|
29
|
+
if (this.lockStateChange)
|
|
30
|
+
throw Error("Can't change state of original position object");
|
|
31
|
+
else
|
|
32
|
+
this.state++;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* PRIVATE SETTERS
|
|
36
|
+
*/
|
|
37
|
+
setRealXRealY(amountX, amountY) {
|
|
38
|
+
if (Number.isNaN(amountX))
|
|
39
|
+
return;
|
|
40
|
+
if (Number.isNaN(amountY))
|
|
41
|
+
return;
|
|
42
|
+
this.checkLock();
|
|
43
|
+
const { liquidity } = this.getOptimalLiquidity(amountX, amountY);
|
|
44
|
+
this.liquidity = liquidity;
|
|
45
|
+
}
|
|
46
|
+
setRealX(amountX) {
|
|
47
|
+
if (Number.isNaN(amountX))
|
|
48
|
+
return;
|
|
49
|
+
this.checkLock();
|
|
50
|
+
const { liquidity } = this.getOptimalLiquidity(amountX, Infinity);
|
|
51
|
+
this.liquidity = liquidity;
|
|
52
|
+
}
|
|
53
|
+
setRealY(amountY) {
|
|
54
|
+
if (Number.isNaN(amountY))
|
|
55
|
+
return;
|
|
56
|
+
this.checkLock();
|
|
57
|
+
const { liquidity } = this.getOptimalLiquidity(Infinity, amountY);
|
|
58
|
+
this.liquidity = liquidity;
|
|
59
|
+
}
|
|
60
|
+
setDebtX(_debtX) {
|
|
61
|
+
if (Number.isNaN(_debtX))
|
|
62
|
+
return;
|
|
63
|
+
this.checkLock();
|
|
64
|
+
this.debtX = _debtX;
|
|
65
|
+
}
|
|
66
|
+
setDebtY(_debtY) {
|
|
67
|
+
if (Number.isNaN(_debtY))
|
|
68
|
+
return;
|
|
69
|
+
this.checkLock();
|
|
70
|
+
this.debtY = _debtY;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* PRIVATE GETTERS
|
|
74
|
+
*/
|
|
75
|
+
getRealXGivenLiquidityAndPrice(liquidity, price) {
|
|
76
|
+
return getRealX(liquidity, price);
|
|
77
|
+
}
|
|
78
|
+
getRealYGivenLiquidityAndPrice(liquidity, price) {
|
|
79
|
+
return getRealY(liquidity, price);
|
|
80
|
+
}
|
|
81
|
+
getRealXGivenLiquidity(liquidity) {
|
|
82
|
+
return this.getRealXGivenLiquidityAndPrice(liquidity, this.marketPrice);
|
|
83
|
+
}
|
|
84
|
+
getRealYGivenLiquidity(liquidity) {
|
|
85
|
+
return this.getRealYGivenLiquidityAndPrice(liquidity, this.marketPrice);
|
|
86
|
+
}
|
|
87
|
+
getRealXGivenPrice(price) {
|
|
88
|
+
return this.getRealXGivenLiquidityAndPrice(this.liquidity, price);
|
|
89
|
+
}
|
|
90
|
+
getRealYGivenPrice(price) {
|
|
91
|
+
return this.getRealYGivenLiquidityAndPrice(this.liquidity, price);
|
|
92
|
+
}
|
|
93
|
+
getRealX() {
|
|
94
|
+
return this.getRealXGivenLiquidityAndPrice(this.liquidity, this.marketPrice);
|
|
95
|
+
}
|
|
96
|
+
getRealY() {
|
|
97
|
+
return this.getRealYGivenLiquidityAndPrice(this.liquidity, this.marketPrice);
|
|
98
|
+
}
|
|
99
|
+
getInitialRealX() {
|
|
100
|
+
return this.getRealXGivenLiquidityAndPrice(this.initialLiquidity, this.marketPrice);
|
|
101
|
+
}
|
|
102
|
+
getInitialRealY() {
|
|
103
|
+
return this.getRealYGivenLiquidityAndPrice(this.initialLiquidity, this.marketPrice);
|
|
104
|
+
}
|
|
105
|
+
getValueGivenPriceAndAmounts(price, amountX, amountY) {
|
|
106
|
+
return amountX * price + amountY;
|
|
107
|
+
}
|
|
108
|
+
getValueGivenAmounts(amountX, amountY) {
|
|
109
|
+
return amountX * this.marketPrice + amountY;
|
|
110
|
+
}
|
|
111
|
+
getAmountXGivenValue(value) {
|
|
112
|
+
return value / this.marketPrice;
|
|
113
|
+
}
|
|
114
|
+
getAmountYGivenValue(value) {
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
getDebtValueGivenPrice(price) {
|
|
118
|
+
return this.getValueGivenPriceAndAmounts(price, this.debtX, this.debtY);
|
|
119
|
+
}
|
|
120
|
+
getCollateralValueGivenPrice(price) {
|
|
121
|
+
return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenPrice(price), this.getRealYGivenPrice(price));
|
|
122
|
+
}
|
|
123
|
+
getEquityValueGivenPrice(price) {
|
|
124
|
+
return this.getCollateralValueGivenPrice(price) - this.getDebtValueGivenPrice(price);
|
|
125
|
+
}
|
|
126
|
+
getDebtValue() {
|
|
127
|
+
return this.getDebtValueGivenPrice(this.marketPrice);
|
|
128
|
+
}
|
|
129
|
+
getCollateralValue() {
|
|
130
|
+
return this.getCollateralValueGivenPrice(this.marketPrice);
|
|
131
|
+
}
|
|
132
|
+
getEquityValue() {
|
|
133
|
+
return this.getEquityValueGivenPrice(this.marketPrice);
|
|
134
|
+
}
|
|
135
|
+
getLiquidityPostLiquidationValueGivenPriceAndDebt(price, debtX, debtY) {
|
|
136
|
+
const debtValue = this.getValueGivenPriceAndAmounts(price, debtX, debtY);
|
|
137
|
+
const collateralValue = this.getCollateralValueGivenPrice(price);
|
|
138
|
+
const collateralNeeded = debtValue * this.liquidationPenalty;
|
|
139
|
+
return collateralValue - collateralNeeded;
|
|
140
|
+
}
|
|
141
|
+
isLiquidatableGivenPriceAndDebt(price, debtX, debtY) {
|
|
142
|
+
return this.getLiquidityPostLiquidationValueGivenPriceAndDebt(price / this.safetyMargin, debtX, debtY) < 0
|
|
143
|
+
|| this.getLiquidityPostLiquidationValueGivenPriceAndDebt(price * this.safetyMargin, debtX, debtY) < 0;
|
|
144
|
+
}
|
|
145
|
+
isLiquidatableGivenDebt(debtX, debtY) {
|
|
146
|
+
return this.isLiquidatableGivenPriceAndDebt(this.marketPrice, debtX, debtY);
|
|
147
|
+
}
|
|
148
|
+
isLiquidatableGivenPrice(price) {
|
|
149
|
+
return this.getEquityValueGivenPrice(price / this.safetyMargin) < 0 || this.getEquityValueGivenPrice(price * this.safetyMargin) < 0;
|
|
150
|
+
}
|
|
151
|
+
isUnderwaterGivenPrice(price) {
|
|
152
|
+
return this.getEquityValueGivenPrice(price) < 0;
|
|
153
|
+
}
|
|
154
|
+
getLiquidationPriceInRange(lowPrice, highPrice, lowIsLiquidatable, highIsLiquidatable) {
|
|
155
|
+
if (lowIsLiquidatable == highIsLiquidatable)
|
|
156
|
+
return undefined;
|
|
157
|
+
const avgPrice = Math.sqrt(lowPrice * highPrice);
|
|
158
|
+
if (lowPrice / highPrice > 0.9999)
|
|
159
|
+
return avgPrice;
|
|
160
|
+
const avgIsLiquidatable = this.isLiquidatableGivenPrice(avgPrice);
|
|
161
|
+
return this.getLiquidationPriceInRange(lowPrice, avgPrice, lowIsLiquidatable, avgIsLiquidatable)
|
|
162
|
+
?? this.getLiquidationPriceInRange(avgPrice, highPrice, avgIsLiquidatable, highIsLiquidatable);
|
|
163
|
+
}
|
|
164
|
+
getMaxDeltaDebtInRange(lowDeltaX, lowDeltaY, highDeltaX, highDeltaY) {
|
|
165
|
+
if (Number.isNaN(lowDeltaX) || Number.isNaN(lowDeltaY) || Number.isNaN(highDeltaX) || Number.isNaN(highDeltaY))
|
|
166
|
+
return [0, 0];
|
|
167
|
+
if (highDeltaX == 0 && highDeltaY == 0)
|
|
168
|
+
return [0, 0];
|
|
169
|
+
if (Math.abs(highDeltaX / lowDeltaX) < 1.001 || Math.abs(highDeltaY / lowDeltaY) < 1.001)
|
|
170
|
+
return [lowDeltaX, lowDeltaY];
|
|
171
|
+
const avgDeltaX = (lowDeltaX + highDeltaX) / 2;
|
|
172
|
+
const avgDeltaY = (lowDeltaY + highDeltaY) / 2;
|
|
173
|
+
if (this.isLiquidatableGivenDebt(this.debtX + avgDeltaX, this.debtY + avgDeltaY))
|
|
174
|
+
return this.getMaxDeltaDebtInRange(lowDeltaX, lowDeltaY, avgDeltaX, avgDeltaY);
|
|
175
|
+
else
|
|
176
|
+
return this.getMaxDeltaDebtInRange(avgDeltaX, avgDeltaY, highDeltaX, highDeltaY);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* PUBLIC SETTERS
|
|
180
|
+
*/
|
|
181
|
+
depositX(amount) {
|
|
182
|
+
this.setRealX(this.getInitialRealX() + amount);
|
|
183
|
+
}
|
|
184
|
+
depositY(amount) {
|
|
185
|
+
this.setRealY(this.getInitialRealY() + amount);
|
|
186
|
+
}
|
|
187
|
+
withdrawX(amount) {
|
|
188
|
+
this.setRealX(Math.max(this.getInitialRealX() - amount, 0));
|
|
189
|
+
}
|
|
190
|
+
withdrawY(amount) {
|
|
191
|
+
this.setRealY(Math.max(this.getInitialRealY() - amount, 0));
|
|
192
|
+
}
|
|
193
|
+
borrowX(amount) {
|
|
194
|
+
this.setDebtX(this.initialDebtX + amount);
|
|
195
|
+
}
|
|
196
|
+
borrowY(amount) {
|
|
197
|
+
this.setDebtY(this.initialDebtY + amount);
|
|
198
|
+
}
|
|
199
|
+
repayX(amount) {
|
|
200
|
+
this.setDebtX(Math.max(this.initialDebtX - amount, 0));
|
|
201
|
+
}
|
|
202
|
+
repayY(amount) {
|
|
203
|
+
this.setDebtY(Math.max(this.initialDebtY - amount, 0));
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* PUBLIC GETTERS
|
|
207
|
+
*/
|
|
208
|
+
getDepositedX() {
|
|
209
|
+
return this.getRealX();
|
|
210
|
+
}
|
|
211
|
+
getDepositedY() {
|
|
212
|
+
return this.getRealY();
|
|
213
|
+
}
|
|
214
|
+
getNetX() {
|
|
215
|
+
return this.getDepositedX() - this.debtX;
|
|
216
|
+
}
|
|
217
|
+
getNetY() {
|
|
218
|
+
return this.getDepositedY() - this.debtY;
|
|
219
|
+
}
|
|
220
|
+
isLiquidatable() {
|
|
221
|
+
return this.isLiquidatableGivenPrice(this.oraclePrice);
|
|
222
|
+
}
|
|
223
|
+
isUnderwater() {
|
|
224
|
+
return this.isUnderwaterGivenPrice(this.marketPrice);
|
|
225
|
+
}
|
|
226
|
+
getLiquidationRange() {
|
|
227
|
+
const isLiquidatable = this.isLiquidatable();
|
|
228
|
+
if (isLiquidatable)
|
|
229
|
+
return undefined;
|
|
230
|
+
const lowIsLiquidatable = this.isLiquidatableGivenPrice(LOWEST_PRICE);
|
|
231
|
+
const highIsLiquidatable = this.isLiquidatableGivenPrice(HIGHEST_PRICE);
|
|
232
|
+
const priceA = this.getLiquidationPriceInRange(LOWEST_PRICE, this.marketPrice, lowIsLiquidatable, isLiquidatable);
|
|
233
|
+
const priceB = this.getLiquidationPriceInRange(this.marketPrice, HIGHEST_PRICE, isLiquidatable, highIsLiquidatable);
|
|
234
|
+
return {
|
|
235
|
+
priceA: priceA && priceA > LOWEST_PRICE ? priceA : 0,
|
|
236
|
+
priceB: priceB && priceB < HIGHEST_PRICE ? priceB : Infinity,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
getLeverage() {
|
|
240
|
+
const leverage = this.getCollateralValue() / this.getEquityValue();
|
|
241
|
+
if (!leverage)
|
|
242
|
+
return 1;
|
|
243
|
+
if (Number.isNaN(leverage))
|
|
244
|
+
return 1;
|
|
245
|
+
if (leverage < 1)
|
|
246
|
+
return 1;
|
|
247
|
+
return leverage;
|
|
248
|
+
}
|
|
249
|
+
// amountX and amountY are expected to have the same sign
|
|
250
|
+
getOptimalLiquidity(amountX, amountY) {
|
|
251
|
+
const liquidityA = amountX * Math.sqrt(this.marketPrice);
|
|
252
|
+
const liquidityB = amountY / Math.sqrt(this.marketPrice);
|
|
253
|
+
const liquidity = Math.min(liquidityA, liquidityB);
|
|
254
|
+
return {
|
|
255
|
+
liquidity: Number.isNaN(liquidity) ? 0 : liquidity ?? 0,
|
|
256
|
+
amountX: Number.isNaN(amountX) ? 0 : amountX ?? 0,
|
|
257
|
+
amountY: Number.isNaN(amountY) ? 0 : amountY ?? 0,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
getMaxLeverage() {
|
|
261
|
+
const currentLeverage = this.getLeverage();
|
|
262
|
+
if (this.isLiquidatable())
|
|
263
|
+
return currentLeverage;
|
|
264
|
+
const highLeverage = 100; // we assume the position is liquidatable with this leverage
|
|
265
|
+
let setLiquidityToZero = false;
|
|
266
|
+
if (this.liquidity === 0) {
|
|
267
|
+
this.liquidity = 0.000001;
|
|
268
|
+
setLiquidityToZero = true;
|
|
269
|
+
}
|
|
270
|
+
const realX = this.getRealX();
|
|
271
|
+
const realY = this.getRealY();
|
|
272
|
+
const projectedRealX = realX * highLeverage / currentLeverage;
|
|
273
|
+
const projectedRealY = realY * highLeverage / currentLeverage;
|
|
274
|
+
const projectedDebtX = this.debtX + projectedRealX - realX;
|
|
275
|
+
const projectedDebtY = this.debtY + projectedRealY - realY;
|
|
276
|
+
const normalizedDeltaDebtX = projectedDebtX * currentLeverage / highLeverage - this.debtX;
|
|
277
|
+
const normalizedDeltaDebtY = projectedDebtY * currentLeverage / highLeverage - this.debtY;
|
|
278
|
+
const [deltaDebtX, deltaDebtY] = this.getMaxDeltaDebtInRange(0, 0, normalizedDeltaDebtX, normalizedDeltaDebtY);
|
|
279
|
+
const collateralValue = this.getCollateralValue();
|
|
280
|
+
const debtValue = this.getValueGivenAmounts(this.debtX + deltaDebtX, this.debtY + deltaDebtY);
|
|
281
|
+
const equityValue = collateralValue - debtValue;
|
|
282
|
+
if (setLiquidityToZero)
|
|
283
|
+
this.liquidity = 0;
|
|
284
|
+
return collateralValue / equityValue;
|
|
285
|
+
}
|
|
286
|
+
getMinLeverage() {
|
|
287
|
+
const depositedX = this.getDepositedX();
|
|
288
|
+
const depositedY = this.getDepositedY();
|
|
289
|
+
if (depositedX >= this.debtX && depositedY >= this.debtY)
|
|
290
|
+
return 0;
|
|
291
|
+
// TODO binary search
|
|
292
|
+
return 0;
|
|
293
|
+
}
|
|
294
|
+
getMaxWithdrawable() {
|
|
295
|
+
const depositedX = this.getDepositedX();
|
|
296
|
+
const depositedY = this.getDepositedY();
|
|
297
|
+
let percentage = 0;
|
|
298
|
+
if (!this.isLiquidatable()) {
|
|
299
|
+
if (this.debtX == 0 && this.debtY == 0) {
|
|
300
|
+
percentage = 1;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
const highRatio = this.getEquityValue() / this.getDebtValue();
|
|
304
|
+
const [deltaDebtX, deltaDebtY] = this.getMaxDeltaDebtInRange(0, 0, this.debtX * highRatio, this.debtY * highRatio);
|
|
305
|
+
const ratio = this.debtX > 0 ? deltaDebtX / this.debtX : deltaDebtY / this.debtY;
|
|
306
|
+
percentage = 1 / (1 / ratio + 1);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
amountX: depositedX * percentage,
|
|
311
|
+
amountY: depositedY * percentage,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
getMaxBorrowableX() {
|
|
315
|
+
if (this.isLiquidatable())
|
|
316
|
+
return 0;
|
|
317
|
+
const equityValue = this.getEquityValue();
|
|
318
|
+
const highDebtX = this.getAmountXGivenValue(equityValue);
|
|
319
|
+
const [debtX,] = this.getMaxDeltaDebtInRange(0, 0, highDebtX, 0);
|
|
320
|
+
return debtX + this.debtX - this.initialDebtX;
|
|
321
|
+
}
|
|
322
|
+
getMaxBorrowableY() {
|
|
323
|
+
if (this.isLiquidatable())
|
|
324
|
+
return 0;
|
|
325
|
+
const equityValue = this.getEquityValue();
|
|
326
|
+
const highDebtY = this.getAmountYGivenValue(equityValue);
|
|
327
|
+
const [, debtY] = this.getMaxDeltaDebtInRange(0, 0, 0, highDebtY);
|
|
328
|
+
return debtY + this.debtY - this.initialDebtY;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
exports.UniswapV2Position = UniswapV2Position;
|
|
332
|
+
exports.default = UniswapV2Position;
|
|
@@ -51,6 +51,7 @@ export declare class UniswapV3Position implements Position {
|
|
|
51
51
|
private getDebtValueGivenPrice;
|
|
52
52
|
private getCollateralValueGivenPrice;
|
|
53
53
|
private getWeightedCollateralValueGivenPrice;
|
|
54
|
+
private getWeightedCollateralValueGivenPriceAndDeltaLeverage;
|
|
54
55
|
private getEquityValueGivenPrice;
|
|
55
56
|
private getDebtValue;
|
|
56
57
|
private getCollateralValue;
|
|
@@ -21,7 +21,6 @@ const LOWEST_PRICE = 1 / 1e18;
|
|
|
21
21
|
const HIGHEST_PRICE = 1e18;
|
|
22
22
|
const FEE_COLLECTED_WEIGHT = 0.95;
|
|
23
23
|
class UniswapV3Position {
|
|
24
|
-
// TODO add fee logic
|
|
25
24
|
constructor(_liquidity, _uncollectedFeesX, _uncollectedFeesY, _debtX, _debtY, _marketPrice, _oraclePrice, _priceA, _priceB, _safetyMargin, _liquidationPenalty, _lockStateChange) {
|
|
26
25
|
this.liquidity = _liquidity;
|
|
27
26
|
this.uncollectedFeesX = _uncollectedFeesX;
|
|
@@ -140,6 +139,10 @@ class UniswapV3Position {
|
|
|
140
139
|
getWeightedCollateralValueGivenPrice(price) {
|
|
141
140
|
return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenPrice(price) + this.uncollectedFeesX * FEE_COLLECTED_WEIGHT, this.getRealYGivenPrice(price) + this.uncollectedFeesY * FEE_COLLECTED_WEIGHT);
|
|
142
141
|
}
|
|
142
|
+
getWeightedCollateralValueGivenPriceAndDeltaLeverage(price, deltaX, deltaY) {
|
|
143
|
+
const liquidity = this.getLiquidityGivenAmounts(deltaX, deltaY);
|
|
144
|
+
return this.getValueGivenPriceAndAmounts(price, this.getRealXGivenLiquidityAndPrice(this.liquidity + liquidity, price) + this.uncollectedFeesX * FEE_COLLECTED_WEIGHT, this.getRealYGivenLiquidityAndPrice(this.liquidity + liquidity, price) + this.uncollectedFeesY * FEE_COLLECTED_WEIGHT);
|
|
145
|
+
}
|
|
143
146
|
getEquityValueGivenPrice(price) {
|
|
144
147
|
return this.getCollateralValueGivenPrice(price) - this.getDebtValueGivenPrice(price);
|
|
145
148
|
}
|
|
@@ -165,9 +168,8 @@ class UniswapV3Position {
|
|
|
165
168
|
return collateralValue - collateralNeeded;
|
|
166
169
|
}
|
|
167
170
|
getWeightedLiquidityPostLiquidationValueGivenPriceAndDeltaLeverage(price, deltaX, deltaY) {
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const collateralValue = this.getWeightedCollateralValueGivenPrice(price) + deltaValue;
|
|
171
|
+
const debtValue = this.getDebtValueGivenPrice(price) + this.getValueGivenPriceAndAmounts(price, deltaX, deltaY);
|
|
172
|
+
const collateralValue = this.getWeightedCollateralValueGivenPriceAndDeltaLeverage(price, deltaX, deltaY);
|
|
171
173
|
const collateralNeeded = debtValue * this.liquidationPenalty;
|
|
172
174
|
return collateralValue - collateralNeeded;
|
|
173
175
|
}
|
|
@@ -233,7 +235,7 @@ class UniswapV3Position {
|
|
|
233
235
|
return [lowDeltaX, lowDeltaY];
|
|
234
236
|
const avgDeltaX = (lowDeltaX + highDeltaX) / 2;
|
|
235
237
|
const avgDeltaY = (lowDeltaY + highDeltaY) / 2;
|
|
236
|
-
if (this.isLiquidatableGivenDeltaLeverage(
|
|
238
|
+
if (this.isLiquidatableGivenDeltaLeverage(avgDeltaX, avgDeltaY))
|
|
237
239
|
return this.getMaxDeltaLeverageInRange(lowDeltaX, lowDeltaY, avgDeltaX, avgDeltaY);
|
|
238
240
|
else
|
|
239
241
|
return this.getMaxDeltaLeverageInRange(avgDeltaX, avgDeltaY, highDeltaX, highDeltaY);
|