@strkfarm/sdk 2.0.0-dev.27 → 2.0.0-dev.28

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.
Files changed (70) hide show
  1. package/dist/cli.js +190 -36
  2. package/dist/cli.mjs +188 -34
  3. package/dist/index.browser.global.js +79130 -49357
  4. package/dist/index.browser.mjs +18039 -11434
  5. package/dist/index.d.ts +2869 -898
  6. package/dist/index.js +19036 -12210
  7. package/dist/index.mjs +18942 -12161
  8. package/package.json +1 -1
  9. package/src/data/avnu.abi.json +840 -0
  10. package/src/data/ekubo-price-fethcer.abi.json +265 -0
  11. package/src/dataTypes/_bignumber.ts +13 -4
  12. package/src/dataTypes/index.ts +3 -2
  13. package/src/dataTypes/mynumber.ts +141 -0
  14. package/src/global.ts +76 -41
  15. package/src/index.browser.ts +2 -1
  16. package/src/interfaces/common.tsx +167 -2
  17. package/src/modules/ExtendedWrapperSDk/types.ts +26 -4
  18. package/src/modules/ExtendedWrapperSDk/wrapper.ts +110 -67
  19. package/src/modules/apollo-client-config.ts +28 -0
  20. package/src/modules/avnu.ts +4 -4
  21. package/src/modules/ekubo-pricer.ts +79 -0
  22. package/src/modules/ekubo-quoter.ts +46 -30
  23. package/src/modules/erc20.ts +17 -0
  24. package/src/modules/harvests.ts +43 -29
  25. package/src/modules/pragma.ts +23 -8
  26. package/src/modules/pricer-from-api.ts +156 -15
  27. package/src/modules/pricer-lst.ts +1 -1
  28. package/src/modules/pricer.ts +40 -4
  29. package/src/modules/pricerBase.ts +2 -1
  30. package/src/node/deployer.ts +36 -1
  31. package/src/node/pricer-redis.ts +2 -1
  32. package/src/strategies/base-strategy.ts +78 -10
  33. package/src/strategies/ekubo-cl-vault.tsx +906 -347
  34. package/src/strategies/factory.ts +159 -0
  35. package/src/strategies/index.ts +6 -1
  36. package/src/strategies/registry.ts +239 -0
  37. package/src/strategies/sensei.ts +335 -7
  38. package/src/strategies/svk-strategy.ts +97 -27
  39. package/src/strategies/types.ts +4 -0
  40. package/src/strategies/universal-adapters/adapter-utils.ts +2 -1
  41. package/src/strategies/universal-adapters/avnu-adapter.ts +177 -268
  42. package/src/strategies/universal-adapters/baseAdapter.ts +263 -251
  43. package/src/strategies/universal-adapters/common-adapter.ts +206 -203
  44. package/src/strategies/universal-adapters/extended-adapter.ts +155 -336
  45. package/src/strategies/universal-adapters/index.ts +9 -8
  46. package/src/strategies/universal-adapters/token-transfer-adapter.ts +200 -0
  47. package/src/strategies/universal-adapters/usdc<>usdce-adapter.ts +200 -0
  48. package/src/strategies/universal-adapters/vesu-adapter.ts +110 -75
  49. package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +476 -0
  50. package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +762 -844
  51. package/src/strategies/universal-adapters/vesu-position-common.ts +251 -0
  52. package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +18 -3
  53. package/src/strategies/universal-lst-muliplier-strategy.tsx +396 -204
  54. package/src/strategies/universal-strategy.tsx +1426 -1178
  55. package/src/strategies/vesu-extended-strategy/services/executionService.ts +2251 -0
  56. package/src/strategies/vesu-extended-strategy/services/extended-vesu-state-manager.ts +2941 -0
  57. package/src/strategies/vesu-extended-strategy/services/operationService.ts +12 -1
  58. package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +52 -0
  59. package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +1 -0
  60. package/src/strategies/vesu-extended-strategy/utils/constants.ts +2 -0
  61. package/src/strategies/vesu-extended-strategy/utils/helper.ts +158 -124
  62. package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +377 -1788
  63. package/src/strategies/vesu-rebalance.tsx +255 -152
  64. package/src/utils/health-factor-math.ts +4 -1
  65. package/src/utils/index.ts +2 -1
  66. package/src/utils/logger.browser.ts +22 -4
  67. package/src/utils/logger.node.ts +259 -24
  68. package/src/utils/starknet-call-parser.ts +1036 -0
  69. package/src/utils/strategy-utils.ts +61 -0
  70. package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
@@ -0,0 +1,476 @@
1
+ import { ContractAddr, Web3Number } from "@/dataTypes";
2
+ import { IProtocol, Protocols, TokenInfo } from "@/interfaces";
3
+ import {
4
+ BaseAdapter,
5
+ BaseAdapterConfig,
6
+ ManageCall,
7
+ PositionAmount,
8
+ PositionAPY,
9
+ PositionInfo,
10
+ SupportedPosition,
11
+ } from "./baseAdapter";
12
+ import { TokenMarketData } from "@/modules";
13
+ import {
14
+ SIMPLE_SANITIZER,
15
+ VESU_V2_MODIFY_POSITION_SANITIZER,
16
+ toBigInt,
17
+ } from "./adapter-utils";
18
+ import { CairoCustomEnum, hash, uint256 } from "starknet";
19
+ import {
20
+ VesuAdapter,
21
+ getVesuSingletonAddress,
22
+ } from "./vesu-adapter";
23
+ import {
24
+ VesuPositionCommonContext,
25
+ getVesuCommonAPY,
26
+ getVesuCommonMaxDeposit,
27
+ getVesuCommonMaxWithdraw,
28
+ getVesuCommonPosition,
29
+ } from "./vesu-position-common";
30
+ import { logger } from "@/utils";
31
+ import { HealthFactorMath } from "@/utils/health-factor-math";
32
+
33
+ type SignedDelta = {
34
+ amount: Web3Number;
35
+ isNegative: boolean;
36
+ };
37
+
38
+ export interface VesuModifyPositionDepositParams {
39
+ amount: Web3Number;
40
+ debtAmount?: Web3Number;
41
+ }
42
+
43
+ export interface VesuModifyPositionWithdrawParams {
44
+ amount: Web3Number;
45
+ debtAmount?: Web3Number;
46
+ }
47
+
48
+ export interface VesuModifyPositionAdapterConfig extends BaseAdapterConfig {
49
+ poolId: ContractAddr;
50
+ collateral: TokenInfo;
51
+ debt: TokenInfo;
52
+ targetLtv: number;
53
+ maxLtv: number;
54
+ }
55
+
56
+ export class VesuModifyPositionAdapter extends BaseAdapter<
57
+ VesuModifyPositionDepositParams,
58
+ VesuModifyPositionWithdrawParams
59
+ > {
60
+ readonly config: VesuModifyPositionAdapterConfig;
61
+ readonly _vesuAdapter: VesuAdapter;
62
+ private readonly _tokenMarketData: TokenMarketData;
63
+
64
+ constructor(config: VesuModifyPositionAdapterConfig) {
65
+ super(config, VesuModifyPositionAdapter.name, Protocols.VESU);
66
+ this.config = config;
67
+ this._vesuAdapter = new VesuAdapter({
68
+ poolId: config.poolId,
69
+ collateral: config.collateral,
70
+ debt: config.debt,
71
+ vaultAllocator: config.vaultAllocator,
72
+ id: "",
73
+ });
74
+ this._vesuAdapter.networkConfig = this.config.networkConfig;
75
+ this._vesuAdapter.pricer = this.config.pricer;
76
+ this._tokenMarketData = new TokenMarketData(
77
+ this.config.pricer,
78
+ this.config.networkConfig,
79
+ );
80
+ }
81
+
82
+ private _prepareVesuAdapter() {
83
+ this._vesuAdapter.networkConfig = this.config.networkConfig;
84
+ this._vesuAdapter.pricer = this.config.pricer;
85
+ }
86
+
87
+ private _getTargetHealthFactor(): number {
88
+ if (this.config.targetLtv <= 0) {
89
+ return 1.0;
90
+ }
91
+ return this.config.maxLtv / this.config.targetLtv;
92
+ }
93
+
94
+ private _getPositionCommonContext(): VesuPositionCommonContext {
95
+ return {
96
+ adapterName: VesuModifyPositionAdapter.name,
97
+ protocol: this.protocol,
98
+ poolId: this.config.poolId,
99
+ collateral: this.config.collateral,
100
+ debt: this.config.debt,
101
+ networkConfig: this.config.networkConfig,
102
+ pricer: this.config.pricer,
103
+ vesuAdapter: this._vesuAdapter,
104
+ tokenMarketData: this._tokenMarketData,
105
+ targetHealthFactor: this._getTargetHealthFactor(),
106
+ getCache: this.getCache.bind(this),
107
+ setCache: this.setCache.bind(this),
108
+ getUSDValue: this.getUSDValue.bind(this),
109
+ };
110
+ }
111
+
112
+ private _getEffectiveMaxLtv(onchainLtv: number): number {
113
+ return Math.min(onchainLtv, this.config.maxLtv);
114
+ }
115
+
116
+ private _toSigned(amount: Web3Number, isNegative: boolean): SignedDelta {
117
+ if (amount.isZero()) {
118
+ return { amount: Web3Number.fromWei(0, amount.decimals), isNegative: false };
119
+ }
120
+ return { amount: amount.abs(), isNegative };
121
+ }
122
+
123
+ private _depositApproveProofReadableId(): string {
124
+ return `vmp_ad_c_${this.config.poolId.shortString()}_${this.config.collateral.symbol}_${this.config.debt.symbol}`;
125
+ }
126
+
127
+ private _depositModifyProofReadableId(): string {
128
+ return `vmp_dep_${this.config.poolId.shortString()}_${this.config.collateral.symbol}_${this.config.debt.symbol}`;
129
+ }
130
+
131
+ private _withdrawApproveProofReadableId(): string {
132
+ return `vmp_aw_d_${this.config.poolId.shortString()}_${this.config.collateral.symbol}_${this.config.debt.symbol}`;
133
+ }
134
+
135
+ private _withdrawModifyProofReadableId(): string {
136
+ return `vmp_wdr_${this.config.poolId.shortString()}_${this.config.collateral.symbol}_${this.config.debt.symbol}`;
137
+ }
138
+
139
+ private _clampWithdrawCollateral(
140
+ collateralDelta: SignedDelta,
141
+ currentCollateral: Web3Number,
142
+ ): SignedDelta {
143
+ if (!collateralDelta.isNegative) {
144
+ return collateralDelta;
145
+ }
146
+ if (collateralDelta.amount.greaterThan(currentCollateral)) {
147
+ return this._toSigned(currentCollateral, true);
148
+ }
149
+ return collateralDelta;
150
+ }
151
+
152
+ private _clampRepayDebt(debtDelta: SignedDelta, currentDebt: Web3Number): SignedDelta {
153
+ if (!debtDelta.isNegative) {
154
+ return debtDelta;
155
+ }
156
+ if (debtDelta.amount.greaterThan(currentDebt)) {
157
+ return this._toSigned(currentDebt, true);
158
+ }
159
+ return debtDelta;
160
+ }
161
+
162
+ private _normalizeDebtAmountFromHelper(helperAmount: Web3Number): Web3Number {
163
+ return new Web3Number(
164
+ helperAmount.abs().toFixed(this.config.debt.decimals),
165
+ this.config.debt.decimals,
166
+ );
167
+ }
168
+
169
+ private async _getState() {
170
+ const [positions, ltvConfig, prices] = await Promise.all([
171
+ this._vesuAdapter.getPositions(this.config.networkConfig),
172
+ this._vesuAdapter.getLTVConfig(this.config.networkConfig),
173
+ this._vesuAdapter.getAssetPrices(),
174
+ ]);
175
+ return {
176
+ currentCollateral: positions[0].amount,
177
+ currentDebt: positions[1].amount,
178
+ onchainLtv: ltvConfig,
179
+ collateralPrice: prices.collateralPrice,
180
+ debtPrice: prices.debtPrice,
181
+ };
182
+ }
183
+
184
+ private async _buildDefaultDepositDeltas(
185
+ params: VesuModifyPositionDepositParams,
186
+ ): Promise<{ collateral: SignedDelta; debt: SignedDelta }> {
187
+ const state = await this._getState();
188
+ const collateralToAdd = params.amount;
189
+ const effectiveMaxLtv = this._getEffectiveMaxLtv(state.onchainLtv);
190
+ const helperOutput = HealthFactorMath.getMaxDebtAmount(
191
+ state.currentCollateral.plus(collateralToAdd),
192
+ state.collateralPrice,
193
+ effectiveMaxLtv,
194
+ this._getTargetHealthFactor(),
195
+ state.debtPrice,
196
+ this.config.debt,
197
+ );
198
+ if (!helperOutput || helperOutput.lessThan(0)) {
199
+ throw new Error(`Failed to calculate default deposit debt delta: ${helperOutput?.toNumber()}`);
200
+ }
201
+ const normalizedDebtAmount = this._normalizeDebtAmountFromHelper(
202
+ helperOutput,
203
+ );
204
+ return {
205
+ collateral: this._toSigned(collateralToAdd, false),
206
+ debt: this._toSigned(normalizedDebtAmount, false),
207
+ };
208
+ }
209
+
210
+ private async _buildDefaultWithdrawDeltas(
211
+ params: VesuModifyPositionWithdrawParams,
212
+ ): Promise<{ collateral: SignedDelta; debt: SignedDelta }> {
213
+ const state = await this._getState();
214
+ const collateralToWithdraw = params.amount;
215
+ const effectiveMaxLtv = this._getEffectiveMaxLtv(state.onchainLtv);
216
+ const helperOutput = HealthFactorMath.getMaxDebtAmount(
217
+ state.currentCollateral.minus(collateralToWithdraw),
218
+ state.collateralPrice,
219
+ effectiveMaxLtv,
220
+ this._getTargetHealthFactor(),
221
+ state.debtPrice,
222
+ this.config.debt,
223
+ );
224
+ if (!helperOutput || helperOutput.greaterThan(0)) {
225
+ throw new Error(`Failed to calculate default withdraw debt delta: ${helperOutput?.toNumber()}`);
226
+ }
227
+ const normalizedDebtAmount = this._normalizeDebtAmountFromHelper(
228
+ helperOutput,
229
+ ).minus(state.currentDebt); // debt to repay.
230
+
231
+ if (normalizedDebtAmount.greaterThan(0)) { // > 0 means borrow
232
+ throw new Error(`Failed to calculate default withdraw debt delta: ${normalizedDebtAmount?.toNumber()}`);
233
+ }
234
+
235
+ let collateral = this._toSigned(collateralToWithdraw, true);
236
+ let debt = this._toSigned(normalizedDebtAmount, true);
237
+ collateral = this._clampWithdrawCollateral(collateral, state.currentCollateral);
238
+ debt = this._clampRepayDebt(debt, state.currentDebt);
239
+ return { collateral, debt };
240
+ }
241
+
242
+ private _amountStruct(delta: SignedDelta) {
243
+ return {
244
+ denomination: new CairoCustomEnum({ Assets: {} }),
245
+ value: {
246
+ abs: uint256.bnToUint256(delta.amount.toWei()),
247
+ is_negative: delta.amount.isZero() ? false : delta.isNegative,
248
+ },
249
+ };
250
+ }
251
+
252
+ private async _getModifyPositionCall(
253
+ collateralDelta: SignedDelta,
254
+ debtDelta: SignedDelta,
255
+ proofReadableId: string,
256
+ ): Promise<ManageCall> {
257
+ const { contract, isV2 } = this._vesuAdapter.getVesuSingletonContract(
258
+ this.config.networkConfig,
259
+ this.config.poolId,
260
+ );
261
+ const { addr } = getVesuSingletonAddress(this.config.poolId);
262
+ const call = contract.populate("modify_position", {
263
+ params: isV2
264
+ ? {
265
+ collateral_asset: this.config.collateral.address.toBigInt(),
266
+ debt_asset: this.config.debt.address.toBigInt(),
267
+ user: this.config.vaultAllocator.toBigInt(),
268
+ collateral: this._amountStruct(collateralDelta),
269
+ debt: this._amountStruct(debtDelta),
270
+ }
271
+ : {
272
+ pool_id: this.config.poolId.toBigInt(),
273
+ collateral_asset: this.config.collateral.address.toBigInt(),
274
+ debt_asset: this.config.debt.address.toBigInt(),
275
+ user: this.config.vaultAllocator.toBigInt(),
276
+ collateral: this._amountStruct(collateralDelta),
277
+ debt: this._amountStruct(debtDelta),
278
+ data: [0],
279
+ },
280
+ });
281
+ return {
282
+ proofReadableId,
283
+ sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
284
+ call: {
285
+ contractAddress: addr,
286
+ selector: hash.getSelectorFromName("modify_position"),
287
+ calldata: call.calldata as bigint[],
288
+ },
289
+ };
290
+ }
291
+
292
+ private _getApproveCall(
293
+ token: TokenInfo,
294
+ amount: Web3Number,
295
+ proofReadableId: string,
296
+ ): ManageCall {
297
+ const { addr } = getVesuSingletonAddress(this.config.poolId);
298
+ const amount256 = uint256.bnToUint256(amount.toWei());
299
+ return {
300
+ proofReadableId,
301
+ sanitizer: SIMPLE_SANITIZER,
302
+ call: {
303
+ contractAddress: token.address,
304
+ selector: hash.getSelectorFromName("approve"),
305
+ calldata: [
306
+ addr.toBigInt(),
307
+ toBigInt(amount256.low.toString()),
308
+ toBigInt(amount256.high.toString()),
309
+ ],
310
+ },
311
+ };
312
+ }
313
+
314
+ protected async getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY> {
315
+ return getVesuCommonAPY(this._getPositionCommonContext(), _supportedPosition);
316
+ }
317
+
318
+ protected async getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount> {
319
+ return getVesuCommonPosition(this._getPositionCommonContext(), supportedPosition);
320
+ }
321
+
322
+ async maxDeposit(amount?: Web3Number): Promise<PositionInfo> {
323
+ return getVesuCommonMaxDeposit(this._getPositionCommonContext(), amount);
324
+ }
325
+
326
+ async maxWithdraw(): Promise<PositionInfo> {
327
+ return getVesuCommonMaxWithdraw(this._getPositionCommonContext());
328
+ }
329
+
330
+ protected _getDepositLeaf(): {
331
+ target: ContractAddr;
332
+ method: string;
333
+ packedArguments: bigint[];
334
+ sanitizer: ContractAddr;
335
+ id: string;
336
+ }[] {
337
+ const { addr, isV2 } = getVesuSingletonAddress(this.config.poolId);
338
+ const modifyPackedArguments = isV2
339
+ ? [
340
+ this.config.collateral.address.toBigInt(),
341
+ this.config.debt.address.toBigInt(),
342
+ this.config.vaultAllocator.toBigInt(),
343
+ ]
344
+ : [
345
+ this.config.poolId.toBigInt(),
346
+ this.config.collateral.address.toBigInt(),
347
+ this.config.debt.address.toBigInt(),
348
+ this.config.vaultAllocator.toBigInt(),
349
+ 1n,
350
+ 0n,
351
+ ];
352
+
353
+ return [
354
+ {
355
+ target: this.config.collateral.address,
356
+ method: "approve",
357
+ packedArguments: [addr.toBigInt()],
358
+ sanitizer: SIMPLE_SANITIZER,
359
+ id: this._depositApproveProofReadableId(),
360
+ },
361
+ {
362
+ target: addr,
363
+ method: "modify_position",
364
+ packedArguments: modifyPackedArguments,
365
+ sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
366
+ id: this._depositModifyProofReadableId(),
367
+ },
368
+ ];
369
+ }
370
+
371
+ protected _getWithdrawLeaf(): {
372
+ target: ContractAddr;
373
+ method: string;
374
+ packedArguments: bigint[];
375
+ sanitizer: ContractAddr;
376
+ id: string;
377
+ }[] {
378
+ const { addr, isV2 } = getVesuSingletonAddress(this.config.poolId);
379
+ const modifyPackedArguments = isV2
380
+ ? [
381
+ this.config.collateral.address.toBigInt(),
382
+ this.config.debt.address.toBigInt(),
383
+ this.config.vaultAllocator.toBigInt(),
384
+ ]
385
+ : [
386
+ this.config.poolId.toBigInt(),
387
+ this.config.collateral.address.toBigInt(),
388
+ this.config.debt.address.toBigInt(),
389
+ this.config.vaultAllocator.toBigInt(),
390
+ 1n,
391
+ 0n,
392
+ ];
393
+
394
+ return [
395
+ {
396
+ target: this.config.debt.address,
397
+ method: "approve",
398
+ packedArguments: [addr.toBigInt()],
399
+ sanitizer: SIMPLE_SANITIZER,
400
+ id: this._withdrawApproveProofReadableId(),
401
+ },
402
+ {
403
+ target: addr,
404
+ method: "modify_position",
405
+ packedArguments: modifyPackedArguments,
406
+ sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
407
+ id: this._withdrawModifyProofReadableId(),
408
+ },
409
+ ];
410
+ }
411
+
412
+ async getDepositCall(params: VesuModifyPositionDepositParams): Promise<ManageCall[]> {
413
+ const state = await this._getState();
414
+
415
+ let collateralDelta: SignedDelta;
416
+ let debtDelta: SignedDelta;
417
+
418
+ if (params.debtAmount === undefined) {
419
+ const defaults = await this._buildDefaultDepositDeltas(params);
420
+ collateralDelta = defaults.collateral;
421
+ debtDelta = defaults.debt;
422
+ } else {
423
+ collateralDelta = this._toSigned(params.amount, false);
424
+ debtDelta = this._toSigned(params.debtAmount!, false);
425
+ }
426
+
427
+ debtDelta = this._clampRepayDebt(debtDelta, state.currentDebt);
428
+ if (collateralDelta.isNegative || debtDelta.isNegative) {
429
+ throw new Error("Invalid deposit call");
430
+ }
431
+ const collateralApproveAmount = collateralDelta.amount;
432
+
433
+ logger.verbose(`getDepositCall: collateralApproveAmount=${collateralApproveAmount.toNumber()}, debtApproveAmount=${debtDelta.amount.toNumber()}`);
434
+ return [
435
+ ...(collateralApproveAmount.gt(0)
436
+ ? [this._getApproveCall(this.config.collateral, collateralApproveAmount, this._depositApproveProofReadableId())]
437
+ : []),
438
+ await this._getModifyPositionCall(collateralDelta, debtDelta, this._depositModifyProofReadableId()),
439
+ ];
440
+ }
441
+
442
+ async getWithdrawCall(params: VesuModifyPositionWithdrawParams): Promise<ManageCall[]> {
443
+ const state = await this._getState();
444
+
445
+ let collateralDelta: SignedDelta;
446
+ let debtDelta: SignedDelta;
447
+
448
+ if (params.debtAmount === undefined) {
449
+ const defaults = await this._buildDefaultWithdrawDeltas(params);
450
+ collateralDelta = defaults.collateral;
451
+ debtDelta = defaults.debt;
452
+ } else {
453
+ collateralDelta = this._toSigned(params.amount, true);
454
+ debtDelta = this._toSigned(params.debtAmount!, true);
455
+ }
456
+
457
+ collateralDelta = this._clampWithdrawCollateral(collateralDelta, state.currentCollateral);
458
+ debtDelta = this._clampRepayDebt(debtDelta, state.currentDebt);
459
+ if ((!collateralDelta.amount.isZero() && !collateralDelta.isNegative) || (!debtDelta.amount.isZero() && !debtDelta.isNegative)) {
460
+ throw new Error(`Invalid withdraw call: collateralDelta=${collateralDelta.amount.toNumber()} [${collateralDelta.isNegative ? "-" : "+"}], debtDelta=${debtDelta.amount.toNumber()} [${debtDelta.isNegative ? "-" : "+"}]`);
461
+ }
462
+ const debtApproveAmount = debtDelta.amount;
463
+
464
+ return [
465
+ ...(debtApproveAmount.gt(0)
466
+ ? [this._getApproveCall(this.config.debt, debtApproveAmount, this._withdrawApproveProofReadableId())]
467
+ : []),
468
+ await this._getModifyPositionCall(collateralDelta, debtDelta, this._withdrawModifyProofReadableId()),
469
+ ];
470
+ }
471
+
472
+ async getHealthFactor(): Promise<number> {
473
+ this._prepareVesuAdapter();
474
+ return this._vesuAdapter.getHealthFactor();
475
+ }
476
+ }