@strkfarm/sdk 2.0.0-dev.22 → 2.0.0-dev.24
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/index.browser.global.js +919 -251
- package/dist/index.browser.mjs +845 -177
- package/dist/index.d.ts +16 -2
- package/dist/index.js +847 -177
- package/dist/index.mjs +845 -177
- package/package.json +1 -1
- package/src/strategies/universal-adapters/avnu-adapter.ts +2 -1
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +1 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +113 -28
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +1114 -327
package/dist/index.mjs
CHANGED
|
@@ -28135,7 +28135,9 @@ var calculateAmountDistributionForWithdrawal = async (amountInUsdc, collateralPr
|
|
|
28135
28135
|
vesu_leverage
|
|
28136
28136
|
};
|
|
28137
28137
|
} catch (err) {
|
|
28138
|
-
logger.error(
|
|
28138
|
+
logger.error(
|
|
28139
|
+
`error calculating amount distribution for withdrawal: ${err}`
|
|
28140
|
+
);
|
|
28139
28141
|
return null;
|
|
28140
28142
|
}
|
|
28141
28143
|
};
|
|
@@ -28188,15 +28190,22 @@ var calculateAmountDepositOnExtendedWhenIncurringLosses = async (client) => {
|
|
|
28188
28190
|
const extended_leverage = calculateExtendedLevergae();
|
|
28189
28191
|
const latestPosition = (await client.getPositions()).data.pop();
|
|
28190
28192
|
if (!extendedHoldings || !latestPosition) {
|
|
28191
|
-
logger.error(
|
|
28193
|
+
logger.error(
|
|
28194
|
+
`error getting extended position: extendedHoldings=${extendedHoldings}, latestPosition=${latestPosition}`
|
|
28195
|
+
);
|
|
28192
28196
|
return null;
|
|
28193
28197
|
}
|
|
28194
|
-
const positionValueInUSD = new Web3Number(
|
|
28198
|
+
const positionValueInUSD = new Web3Number(
|
|
28199
|
+
latestPosition.value,
|
|
28200
|
+
USDC_TOKEN_DECIMALS
|
|
28201
|
+
);
|
|
28195
28202
|
const equity = extendedHoldings.data.equity;
|
|
28196
28203
|
const deposit = positionValueInUSD.dividedBy(extended_leverage).minus(equity).toFixed(2);
|
|
28197
28204
|
return new Web3Number(deposit, USDC_TOKEN_DECIMALS);
|
|
28198
28205
|
} catch (err) {
|
|
28199
|
-
logger.error(
|
|
28206
|
+
logger.error(
|
|
28207
|
+
`error calculating amount deposit on extended when incurring losses: ${err}`
|
|
28208
|
+
);
|
|
28200
28209
|
return null;
|
|
28201
28210
|
}
|
|
28202
28211
|
};
|
|
@@ -28222,14 +28231,14 @@ var calculateExposureDelta = (exposure_extended, exposure_vesu) => {
|
|
|
28222
28231
|
var calculateBTCPriceDelta = (btcPrice, lastBtcPrice) => {
|
|
28223
28232
|
return (btcPrice - lastBtcPrice) / lastBtcPrice * 100;
|
|
28224
28233
|
};
|
|
28225
|
-
var calculateVesUPositionSizeGivenExtended = (extendedPositonValue, extendedHoldingAmount, collateralAmount, collateralPrice) => {
|
|
28234
|
+
var calculateVesUPositionSizeGivenExtended = (extendedPositonValue, extendedHoldingAmount, collateralAmount, collateralPrice, vesuDebtAmountToBeRepaid) => {
|
|
28226
28235
|
const extendedLeverage = calculateExtendedLevergae();
|
|
28227
28236
|
const vesuLeverage = calculateVesuLeverage();
|
|
28228
28237
|
const extendedAmount = extendedHoldingAmount;
|
|
28229
28238
|
const extendedAmountInBTC = extendedAmount.dividedBy(collateralPrice);
|
|
28230
28239
|
const numerator1 = extendedAmount.multipliedBy(extendedLeverage).plus(extendedPositonValue);
|
|
28231
28240
|
const numerator2 = collateralAmount.multipliedBy(collateralPrice).multipliedBy(-1);
|
|
28232
|
-
const vesuAmountInUsd = numerator1.plus(numerator2).dividedBy(vesuLeverage);
|
|
28241
|
+
const vesuAmountInUsd = numerator1.plus(numerator2).dividedBy(vesuLeverage).plus(vesuDebtAmountToBeRepaid);
|
|
28233
28242
|
const vesuAmountInBTC = vesuAmountInUsd.dividedBy(collateralPrice).toFixed(WBTC_TOKEN_DECIMALS);
|
|
28234
28243
|
return {
|
|
28235
28244
|
vesuAmountInUsd: vesuAmountInUsd.toFixed(2),
|
|
@@ -28237,6 +28246,41 @@ var calculateVesUPositionSizeGivenExtended = (extendedPositonValue, extendedHold
|
|
|
28237
28246
|
extendedAmountInBTC
|
|
28238
28247
|
};
|
|
28239
28248
|
};
|
|
28249
|
+
var calculateDeltaDebtAmount = (maxLtv = MAX_LTV_BTC_USDC, existingVesuCollateral, existingVesuDebt, collateralPrice, debtPrice, targetHf = TARGET_HF) => {
|
|
28250
|
+
try {
|
|
28251
|
+
const term1 = existingVesuCollateral.multipliedBy(collateralPrice).multipliedBy(maxLtv).dividedBy(targetHf);
|
|
28252
|
+
const term2 = existingVesuDebt.multipliedBy(debtPrice).multipliedBy(targetHf).multipliedBy(-1);
|
|
28253
|
+
const debtAmountToBeRepaid = term1.plus(term2).dividedBy(targetHf);
|
|
28254
|
+
return debtAmountToBeRepaid;
|
|
28255
|
+
} catch (err) {
|
|
28256
|
+
logger.error(`error calculating delta position: ${err}`);
|
|
28257
|
+
return null;
|
|
28258
|
+
}
|
|
28259
|
+
};
|
|
28260
|
+
var calculatePositionToCloseToWithdrawAmount = async (extendedBalance, extendedPositions, amountToWithdraw) => {
|
|
28261
|
+
try {
|
|
28262
|
+
const extendedPosition = extendedPositions.value;
|
|
28263
|
+
const unrealisedPnl = new Web3Number(
|
|
28264
|
+
extendedBalance.unrealisedPnl,
|
|
28265
|
+
USDC_TOKEN_DECIMALS
|
|
28266
|
+
);
|
|
28267
|
+
const availableForWithdrawal = new Web3Number(
|
|
28268
|
+
extendedBalance.availableForWithdrawal,
|
|
28269
|
+
USDC_TOKEN_DECIMALS
|
|
28270
|
+
);
|
|
28271
|
+
const netAmount = amountToWithdraw.minus(availableForWithdrawal);
|
|
28272
|
+
const upnlPercent = unrealisedPnl.dividedBy(extendedPosition);
|
|
28273
|
+
console.log(`upnlPercent: ${upnlPercent}`);
|
|
28274
|
+
const denm = upnlPercent.multipliedBy(3).plus(1);
|
|
28275
|
+
const amountToClose = netAmount.multipliedBy(3).dividedBy(denm);
|
|
28276
|
+
return new Web3Number(Math.ceil(amountToClose.toNumber()), USDC_TOKEN_DECIMALS);
|
|
28277
|
+
} catch (err) {
|
|
28278
|
+
logger.error(
|
|
28279
|
+
`error calculating position to close to withdraw amount: ${err}`
|
|
28280
|
+
);
|
|
28281
|
+
return new Web3Number(0, USDC_TOKEN_DECIMALS);
|
|
28282
|
+
}
|
|
28283
|
+
};
|
|
28240
28284
|
|
|
28241
28285
|
// src/utils/health-factor-math.ts
|
|
28242
28286
|
var HealthFactorMath = class {
|
|
@@ -30659,6 +30703,8 @@ var AvnuAdapter = class _AvnuAdapter extends BaseAdapter {
|
|
|
30659
30703
|
quote,
|
|
30660
30704
|
vaultAllocator.address
|
|
30661
30705
|
);
|
|
30706
|
+
const dataObject = quote;
|
|
30707
|
+
logger.info(`${_AvnuAdapter.name}::getQuotesAvnu finalAmountOfWbtcOut : ${dataObject.avnuFees} ${parseInt(dataObject.buyAmount.toString(), 16)} ${parseInt(dataObject.sellAmount.toString(), 16)} ${parseInt(dataObject.sellAmount.toString(), 16)}`);
|
|
30662
30708
|
const swapCallData = getCalldata[0];
|
|
30663
30709
|
const amount = uint25614.bnToUint256(quote.sellAmountInUsd * 10 ** 7);
|
|
30664
30710
|
return [
|
|
@@ -34405,11 +34451,17 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34405
34451
|
WALLET_ADDRESS,
|
|
34406
34452
|
usdceToken.decimals
|
|
34407
34453
|
);
|
|
34408
|
-
logger.info(
|
|
34454
|
+
logger.info(
|
|
34455
|
+
`${_VesuExtendedMultiplierStrategy.name}::moveAssetsToVaultAllocator walletBalance: ${walletBalance}`
|
|
34456
|
+
);
|
|
34409
34457
|
const amountToBeTransferred = amount.minimum(walletBalance);
|
|
34410
|
-
logger.info(
|
|
34458
|
+
logger.info(
|
|
34459
|
+
`${_VesuExtendedMultiplierStrategy.name}::moveAssetsToVaultAllocator amountToBeTransferred: ${amountToBeTransferred.toNumber()}`
|
|
34460
|
+
);
|
|
34411
34461
|
if (amountToBeTransferred.lessThan(0)) {
|
|
34412
|
-
logger.error(
|
|
34462
|
+
logger.error(
|
|
34463
|
+
`${_VesuExtendedMultiplierStrategy.name}::moveAssetsToVaultAllocator amountToBeTransferred is less than 0: ${amountToBeTransferred.toNumber()}`
|
|
34464
|
+
);
|
|
34413
34465
|
return {
|
|
34414
34466
|
calls: [],
|
|
34415
34467
|
status: false
|
|
@@ -34447,10 +34499,14 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34447
34499
|
}
|
|
34448
34500
|
async shouldInvest() {
|
|
34449
34501
|
try {
|
|
34450
|
-
logger.info(
|
|
34502
|
+
logger.info(
|
|
34503
|
+
`${_VesuExtendedMultiplierStrategy.name}::shouldInvest starting`
|
|
34504
|
+
);
|
|
34451
34505
|
const vesuAdapter = await this.getVesuAdapter();
|
|
34452
34506
|
const extendedAdapter = await this.getExtendedAdapter();
|
|
34453
|
-
logger.info(
|
|
34507
|
+
logger.info(
|
|
34508
|
+
`${_VesuExtendedMultiplierStrategy.name}::shouldInvest adapters fetched: vesuAdapter=${!!vesuAdapter}, extendedAdapter=${!!extendedAdapter}, extendedAdapter.client=${!!extendedAdapter?.client}`
|
|
34509
|
+
);
|
|
34454
34510
|
if (!vesuAdapter) {
|
|
34455
34511
|
logger.error(
|
|
34456
34512
|
`Vesu adapter not configured in metadata. This is a configuration issue, not a temporary failure.`
|
|
@@ -34462,7 +34518,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34462
34518
|
extendedLeverage: 0,
|
|
34463
34519
|
collateralPrice: 0,
|
|
34464
34520
|
debtPrice: 0,
|
|
34465
|
-
vesuLeverage: 0
|
|
34521
|
+
vesuLeverage: 0,
|
|
34522
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34466
34523
|
};
|
|
34467
34524
|
}
|
|
34468
34525
|
if (!extendedAdapter) {
|
|
@@ -34476,7 +34533,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34476
34533
|
extendedLeverage: 0,
|
|
34477
34534
|
collateralPrice: 0,
|
|
34478
34535
|
debtPrice: 0,
|
|
34479
|
-
vesuLeverage: 0
|
|
34536
|
+
vesuLeverage: 0,
|
|
34537
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34480
34538
|
};
|
|
34481
34539
|
}
|
|
34482
34540
|
if (!extendedAdapter.client) {
|
|
@@ -34490,10 +34548,13 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34490
34548
|
extendedLeverage: 0,
|
|
34491
34549
|
collateralPrice: 0,
|
|
34492
34550
|
debtPrice: 0,
|
|
34493
|
-
vesuLeverage: 0
|
|
34551
|
+
vesuLeverage: 0,
|
|
34552
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34494
34553
|
};
|
|
34495
34554
|
}
|
|
34496
|
-
logger.info(
|
|
34555
|
+
logger.info(
|
|
34556
|
+
`${_VesuExtendedMultiplierStrategy.name}::shouldInvest calling getUnusedBalance`
|
|
34557
|
+
);
|
|
34497
34558
|
const balance = await this.getUnusedBalance();
|
|
34498
34559
|
if (!Number.isFinite(balance.usdValue) || balance.usdValue < 0) {
|
|
34499
34560
|
logger.error(
|
|
@@ -34506,13 +34567,18 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34506
34567
|
extendedLeverage: 0,
|
|
34507
34568
|
collateralPrice: 0,
|
|
34508
34569
|
debtPrice: 0,
|
|
34509
|
-
vesuLeverage: 0
|
|
34570
|
+
vesuLeverage: 0,
|
|
34571
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34510
34572
|
};
|
|
34511
34573
|
}
|
|
34512
|
-
logger.info(
|
|
34574
|
+
logger.info(
|
|
34575
|
+
`${_VesuExtendedMultiplierStrategy.name}::shouldInvest balance: ${balance.usdValue}`
|
|
34576
|
+
);
|
|
34513
34577
|
const usdcBalanceOnExtended = await extendedAdapter.getExtendedDepositAmount();
|
|
34514
34578
|
if (usdcBalanceOnExtended) {
|
|
34515
|
-
const availableForWithdrawal = parseFloat(
|
|
34579
|
+
const availableForWithdrawal = parseFloat(
|
|
34580
|
+
usdcBalanceOnExtended.availableForWithdrawal
|
|
34581
|
+
);
|
|
34516
34582
|
if (!Number.isFinite(availableForWithdrawal) || availableForWithdrawal < 0) {
|
|
34517
34583
|
logger.error(
|
|
34518
34584
|
`Invalid usdcBalanceOnExtended.availableForWithdrawal: ${usdcBalanceOnExtended.availableForWithdrawal}. Expected a finite, non-negative number.`
|
|
@@ -34524,11 +34590,15 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34524
34590
|
extendedLeverage: 0,
|
|
34525
34591
|
collateralPrice: 0,
|
|
34526
34592
|
debtPrice: 0,
|
|
34527
|
-
vesuLeverage: 0
|
|
34593
|
+
vesuLeverage: 0,
|
|
34594
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34528
34595
|
};
|
|
34529
34596
|
}
|
|
34530
34597
|
}
|
|
34531
|
-
const amountToInvest = new Web3Number(
|
|
34598
|
+
const amountToInvest = new Web3Number(
|
|
34599
|
+
balance.usdValue,
|
|
34600
|
+
USDC_TOKEN_DECIMALS
|
|
34601
|
+
).plus(usdcBalanceOnExtended?.availableForTrade ?? 0).multipliedBy(1 - LIMIT_BALANCE);
|
|
34532
34602
|
const amountToInvestNumber = amountToInvest.toNumber();
|
|
34533
34603
|
if (!Number.isFinite(amountToInvestNumber)) {
|
|
34534
34604
|
logger.error(
|
|
@@ -34541,10 +34611,13 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34541
34611
|
extendedLeverage: 0,
|
|
34542
34612
|
collateralPrice: 0,
|
|
34543
34613
|
debtPrice: 0,
|
|
34544
|
-
vesuLeverage: 0
|
|
34614
|
+
vesuLeverage: 0,
|
|
34615
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34545
34616
|
};
|
|
34546
34617
|
}
|
|
34547
|
-
logger.info(
|
|
34618
|
+
logger.info(
|
|
34619
|
+
`${_VesuExtendedMultiplierStrategy.name}::shouldInvest amountToInvest: ${amountToInvestNumber}`
|
|
34620
|
+
);
|
|
34548
34621
|
if (amountToInvest.lessThan(LIMIT_BALANCE_VALUE)) {
|
|
34549
34622
|
return {
|
|
34550
34623
|
shouldInvest: false,
|
|
@@ -34553,7 +34626,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34553
34626
|
extendedLeverage: 0,
|
|
34554
34627
|
collateralPrice: 0,
|
|
34555
34628
|
debtPrice: 0,
|
|
34556
|
-
vesuLeverage: 0
|
|
34629
|
+
vesuLeverage: 0,
|
|
34630
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34557
34631
|
};
|
|
34558
34632
|
}
|
|
34559
34633
|
const extendedPositon = await extendedAdapter.getAllOpenPositions();
|
|
@@ -34566,14 +34640,12 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34566
34640
|
extendedLeverage: 0,
|
|
34567
34641
|
collateralPrice: 0,
|
|
34568
34642
|
debtPrice: 0,
|
|
34569
|
-
vesuLeverage: 0
|
|
34643
|
+
vesuLeverage: 0,
|
|
34644
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34570
34645
|
};
|
|
34571
34646
|
}
|
|
34572
|
-
const { collateralTokenAmount } = await vesuAdapter.vesuAdapter.getAssetPrices();
|
|
34573
|
-
const {
|
|
34574
|
-
collateralPrice,
|
|
34575
|
-
debtPrice
|
|
34576
|
-
} = await this.getAssetPrices();
|
|
34647
|
+
const { collateralTokenAmount, debtTokenAmount } = await vesuAdapter.vesuAdapter.getAssetPrices();
|
|
34648
|
+
const { collateralPrice, debtPrice } = await this.getAssetPrices();
|
|
34577
34649
|
if (!Number.isFinite(collateralPrice.price) || collateralPrice.price <= 0) {
|
|
34578
34650
|
logger.error(
|
|
34579
34651
|
`Invalid collateralPrice: ${collateralPrice.price}. Expected a finite, positive number.`
|
|
@@ -34585,7 +34657,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34585
34657
|
extendedLeverage: 0,
|
|
34586
34658
|
collateralPrice: 0,
|
|
34587
34659
|
debtPrice: 0,
|
|
34588
|
-
vesuLeverage: 0
|
|
34660
|
+
vesuLeverage: 0,
|
|
34661
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34589
34662
|
};
|
|
34590
34663
|
}
|
|
34591
34664
|
if (!Number.isFinite(debtPrice.price) || debtPrice.price <= 0) {
|
|
@@ -34599,11 +34672,34 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34599
34672
|
extendedLeverage: 0,
|
|
34600
34673
|
collateralPrice: 0,
|
|
34601
34674
|
debtPrice: 0,
|
|
34602
|
-
vesuLeverage: 0
|
|
34675
|
+
vesuLeverage: 0,
|
|
34676
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34603
34677
|
};
|
|
34604
34678
|
}
|
|
34679
|
+
const debtAmountToBeRepaid = calculateDeltaDebtAmount(
|
|
34680
|
+
MAX_LTV_BTC_USDC,
|
|
34681
|
+
collateralTokenAmount,
|
|
34682
|
+
debtTokenAmount,
|
|
34683
|
+
collateralPrice.price,
|
|
34684
|
+
debtPrice.price,
|
|
34685
|
+
this.metadata.additionalInfo.targetHealthFactor
|
|
34686
|
+
);
|
|
34687
|
+
if (!debtAmountToBeRepaid) {
|
|
34688
|
+
logger.error("error calculating debt amount to be repaid");
|
|
34689
|
+
return {
|
|
34690
|
+
shouldInvest: false,
|
|
34691
|
+
vesuAmount: new Web3Number(0, 0),
|
|
34692
|
+
extendedAmount: new Web3Number(0, 0),
|
|
34693
|
+
extendedLeverage: 0,
|
|
34694
|
+
collateralPrice: 0,
|
|
34695
|
+
debtPrice: 0,
|
|
34696
|
+
vesuLeverage: 0,
|
|
34697
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34698
|
+
};
|
|
34699
|
+
}
|
|
34700
|
+
const amountToInvestAfterRepayingDebt = amountToInvest.minus(debtAmountToBeRepaid);
|
|
34605
34701
|
const { vesu_amount, extended_amount, extended_leverage, vesu_leverage } = await calculateAmountDistribution(
|
|
34606
|
-
|
|
34702
|
+
amountToInvestAfterRepayingDebt.toNumber(),
|
|
34607
34703
|
extendedAdapter.client,
|
|
34608
34704
|
extendedAdapter.config.extendedMarketName,
|
|
34609
34705
|
collateralPrice.price,
|
|
@@ -34622,10 +34718,13 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34622
34718
|
extendedLeverage: 0,
|
|
34623
34719
|
collateralPrice: 0,
|
|
34624
34720
|
debtPrice: 0,
|
|
34625
|
-
vesuLeverage: 0
|
|
34721
|
+
vesuLeverage: 0,
|
|
34722
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34626
34723
|
};
|
|
34627
34724
|
}
|
|
34628
|
-
logger.info(
|
|
34725
|
+
logger.info(
|
|
34726
|
+
`${_VesuExtendedMultiplierStrategy.name}::shouldInvest vesu_amount: ${vesu_amount.toNumber()}, extended_amount: ${extended_amount.toNumber()}`
|
|
34727
|
+
);
|
|
34629
34728
|
return {
|
|
34630
34729
|
shouldInvest: true,
|
|
34631
34730
|
vesuAmount: vesu_amount,
|
|
@@ -34633,7 +34732,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34633
34732
|
extendedLeverage: extended_leverage,
|
|
34634
34733
|
vesuLeverage: vesu_leverage,
|
|
34635
34734
|
collateralPrice: collateralPrice.price,
|
|
34636
|
-
debtPrice: debtPrice.price
|
|
34735
|
+
debtPrice: debtPrice.price,
|
|
34736
|
+
debtAmountToBeRepaid
|
|
34637
34737
|
};
|
|
34638
34738
|
} catch (err) {
|
|
34639
34739
|
logger.error(`error deciding invest: ${err}`);
|
|
@@ -34644,7 +34744,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34644
34744
|
extendedLeverage: 0,
|
|
34645
34745
|
collateralPrice: 0,
|
|
34646
34746
|
debtPrice: 0,
|
|
34647
|
-
vesuLeverage: 0
|
|
34747
|
+
vesuLeverage: 0,
|
|
34748
|
+
debtAmountToBeRepaid: new Web3Number(0, 0)
|
|
34648
34749
|
};
|
|
34649
34750
|
}
|
|
34650
34751
|
}
|
|
@@ -34667,33 +34768,49 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34667
34768
|
const usdcAmountOnExtendedAvailableForTrade = parseFloat(
|
|
34668
34769
|
extendedHoldings.availableForTrade
|
|
34669
34770
|
);
|
|
34670
|
-
logger.info(
|
|
34771
|
+
logger.info(
|
|
34772
|
+
`${_VesuExtendedMultiplierStrategy.name}::shouldMoveAssets calculating movements - Extended current: ${usdcAmountOnExtendedAvailableForTrade}, Wallet: ${usdcAmountInWallet.toNumber()}, Target Extended: ${extendedAmount.toNumber()}, Target Vesu: ${vesuAmount.toNumber()}`
|
|
34773
|
+
);
|
|
34671
34774
|
let totalExtendedWithdrawal = new Web3Number(0, USDC_TOKEN_DECIMALS);
|
|
34672
34775
|
let totalExtendedDeposit = new Web3Number(0, USDC_TOKEN_DECIMALS);
|
|
34673
34776
|
if (extendedAmount.isNegative() && extendedAmount.abs().greaterThan(extendedAdapter.minimumExtendedMovementAmount)) {
|
|
34674
|
-
totalExtendedWithdrawal = totalExtendedWithdrawal.plus(
|
|
34777
|
+
totalExtendedWithdrawal = totalExtendedWithdrawal.plus(
|
|
34778
|
+
extendedAmount.abs()
|
|
34779
|
+
);
|
|
34675
34780
|
}
|
|
34676
34781
|
const extendedTargetAmount = extendedAmount.abs();
|
|
34677
34782
|
let projectedExtendedBalance = usdcAmountOnExtendedAvailableForTrade;
|
|
34678
34783
|
if (extendedAmount.isNegative()) {
|
|
34679
34784
|
projectedExtendedBalance = projectedExtendedBalance - extendedAmount.abs().toNumber();
|
|
34680
34785
|
}
|
|
34681
|
-
const extendedAmountDifference = extendedTargetAmount.minus(
|
|
34786
|
+
const extendedAmountDifference = extendedTargetAmount.minus(
|
|
34787
|
+
projectedExtendedBalance
|
|
34788
|
+
);
|
|
34682
34789
|
const extendedAmountDifferenceAbs = extendedAmountDifference.abs();
|
|
34683
34790
|
if (extendedAmountDifference.lessThan(0)) {
|
|
34684
|
-
totalExtendedWithdrawal = totalExtendedWithdrawal.plus(
|
|
34791
|
+
totalExtendedWithdrawal = totalExtendedWithdrawal.plus(
|
|
34792
|
+
extendedAmountDifferenceAbs
|
|
34793
|
+
);
|
|
34685
34794
|
} else if (extendedAmountDifference.greaterThan(0)) {
|
|
34686
|
-
totalExtendedDeposit = totalExtendedDeposit.plus(
|
|
34795
|
+
totalExtendedDeposit = totalExtendedDeposit.plus(
|
|
34796
|
+
extendedAmountDifference
|
|
34797
|
+
);
|
|
34687
34798
|
}
|
|
34688
34799
|
const vesuTargetAmount = vesuAmount.abs();
|
|
34689
34800
|
const projectedWalletBalance = usdcAmountInWallet.plus(totalExtendedWithdrawal).minus(totalExtendedDeposit);
|
|
34690
34801
|
let vesuAmountDifference = vesuTargetAmount.minus(projectedWalletBalance);
|
|
34691
34802
|
const vesuAmountDifferenceAbs = vesuAmountDifference.abs();
|
|
34692
|
-
logger.info(
|
|
34803
|
+
logger.info(
|
|
34804
|
+
`${_VesuExtendedMultiplierStrategy.name}::shouldMoveAssets calculated movements - Extended withdrawal: ${totalExtendedWithdrawal.toNumber()}, Extended deposit: ${totalExtendedDeposit.toNumber()}, Extended diff: ${extendedAmountDifference.toNumber()}, Projected wallet: ${projectedWalletBalance.toNumber()}, Vesu diff: ${vesuAmountDifference.toNumber()}`
|
|
34805
|
+
);
|
|
34693
34806
|
let transactionResults = [];
|
|
34694
34807
|
if (extendedAmount.isNegative() && extendedAmount.abs().greaterThan(extendedAdapter.minimumExtendedMovementAmount)) {
|
|
34695
34808
|
try {
|
|
34696
|
-
const {
|
|
34809
|
+
const {
|
|
34810
|
+
calls: extendedCalls,
|
|
34811
|
+
status: extendedStatus,
|
|
34812
|
+
transactionMetadata: extendedTransactionMetadata
|
|
34813
|
+
} = await this.moveAssets(
|
|
34697
34814
|
{
|
|
34698
34815
|
to: Protocols.VAULT.name,
|
|
34699
34816
|
from: Protocols.EXTENDED.name,
|
|
@@ -34713,16 +34830,44 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34713
34830
|
}
|
|
34714
34831
|
});
|
|
34715
34832
|
} else {
|
|
34716
|
-
return [
|
|
34833
|
+
return [
|
|
34834
|
+
this.createTransactionResult(
|
|
34835
|
+
[],
|
|
34836
|
+
false,
|
|
34837
|
+
{
|
|
34838
|
+
from: Protocols.EXTENDED.name,
|
|
34839
|
+
to: Protocols.VAULT.name,
|
|
34840
|
+
amount: extendedAmount.abs()
|
|
34841
|
+
},
|
|
34842
|
+
"NONE",
|
|
34843
|
+
"INVESTMENT" /* INVESTMENT */
|
|
34844
|
+
)
|
|
34845
|
+
];
|
|
34717
34846
|
}
|
|
34718
34847
|
} catch (err) {
|
|
34719
34848
|
logger.error(`Failed moving assets to vault: ${err}`);
|
|
34720
|
-
return [
|
|
34849
|
+
return [
|
|
34850
|
+
this.createTransactionResult(
|
|
34851
|
+
[],
|
|
34852
|
+
false,
|
|
34853
|
+
{
|
|
34854
|
+
from: Protocols.EXTENDED.name,
|
|
34855
|
+
to: Protocols.VAULT.name,
|
|
34856
|
+
amount: extendedAmount.abs()
|
|
34857
|
+
},
|
|
34858
|
+
"NONE",
|
|
34859
|
+
"INVESTMENT" /* INVESTMENT */
|
|
34860
|
+
)
|
|
34861
|
+
];
|
|
34721
34862
|
}
|
|
34722
34863
|
}
|
|
34723
34864
|
if (vesuAmount.isNegative() && vesuAmount.abs().greaterThan(vesuAdapter.minimumVesuMovementAmount)) {
|
|
34724
34865
|
try {
|
|
34725
|
-
const {
|
|
34866
|
+
const {
|
|
34867
|
+
calls: vesuCalls,
|
|
34868
|
+
status: vesuStatus,
|
|
34869
|
+
transactionMetadata: vesuTransactionMetadata
|
|
34870
|
+
} = await this.moveAssets(
|
|
34726
34871
|
{
|
|
34727
34872
|
to: Protocols.EXTENDED.name,
|
|
34728
34873
|
from: Protocols.VESU.name,
|
|
@@ -34733,7 +34878,19 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34733
34878
|
vesuAdapter
|
|
34734
34879
|
);
|
|
34735
34880
|
if (!vesuStatus) {
|
|
34736
|
-
return [
|
|
34881
|
+
return [
|
|
34882
|
+
this.createTransactionResult(
|
|
34883
|
+
[],
|
|
34884
|
+
false,
|
|
34885
|
+
{
|
|
34886
|
+
from: Protocols.VESU.name,
|
|
34887
|
+
to: Protocols.EXTENDED.name,
|
|
34888
|
+
amount: vesuAmount.abs()
|
|
34889
|
+
},
|
|
34890
|
+
"NONE",
|
|
34891
|
+
"INVESTMENT" /* INVESTMENT */
|
|
34892
|
+
)
|
|
34893
|
+
];
|
|
34737
34894
|
}
|
|
34738
34895
|
transactionResults.push({
|
|
34739
34896
|
status: vesuStatus,
|
|
@@ -34744,14 +34901,34 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34744
34901
|
}
|
|
34745
34902
|
});
|
|
34746
34903
|
} catch (err) {
|
|
34747
|
-
logger.error(
|
|
34748
|
-
|
|
34904
|
+
logger.error(
|
|
34905
|
+
`Failed moving assets to extended via vault allocator: ${err}`
|
|
34906
|
+
);
|
|
34907
|
+
return [
|
|
34908
|
+
this.createTransactionResult(
|
|
34909
|
+
[],
|
|
34910
|
+
false,
|
|
34911
|
+
{
|
|
34912
|
+
from: Protocols.VESU.name,
|
|
34913
|
+
to: Protocols.EXTENDED.name,
|
|
34914
|
+
amount: vesuAmount.abs()
|
|
34915
|
+
},
|
|
34916
|
+
"NONE",
|
|
34917
|
+
"INVESTMENT" /* INVESTMENT */
|
|
34918
|
+
)
|
|
34919
|
+
];
|
|
34749
34920
|
}
|
|
34750
34921
|
}
|
|
34751
|
-
if (extendedAmountDifferenceAbs.greaterThan(
|
|
34922
|
+
if (extendedAmountDifferenceAbs.greaterThan(
|
|
34923
|
+
extendedAdapter.minimumExtendedMovementAmount
|
|
34924
|
+
)) {
|
|
34752
34925
|
if (extendedAmountDifference.greaterThan(0)) {
|
|
34753
34926
|
try {
|
|
34754
|
-
const {
|
|
34927
|
+
const {
|
|
34928
|
+
calls: extendedCalls,
|
|
34929
|
+
status: extendedStatus,
|
|
34930
|
+
transactionMetadata: extendedTransactionMetadata
|
|
34931
|
+
} = await this.moveAssets(
|
|
34755
34932
|
{
|
|
34756
34933
|
to: Protocols.EXTENDED.name,
|
|
34757
34934
|
from: Protocols.VAULT.name,
|
|
@@ -34768,16 +34945,46 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34768
34945
|
transactionMetadata: extendedTransactionMetadata
|
|
34769
34946
|
});
|
|
34770
34947
|
} else {
|
|
34771
|
-
logger.error(
|
|
34772
|
-
|
|
34948
|
+
logger.error(
|
|
34949
|
+
`Failed to move assets to extended - operation returned false status`
|
|
34950
|
+
);
|
|
34951
|
+
return [
|
|
34952
|
+
this.createTransactionResult(
|
|
34953
|
+
[],
|
|
34954
|
+
false,
|
|
34955
|
+
{
|
|
34956
|
+
from: Protocols.VAULT.name,
|
|
34957
|
+
to: Protocols.EXTENDED.name,
|
|
34958
|
+
amount: extendedAmountDifference
|
|
34959
|
+
},
|
|
34960
|
+
"NONE",
|
|
34961
|
+
"INVESTMENT" /* INVESTMENT */
|
|
34962
|
+
)
|
|
34963
|
+
];
|
|
34773
34964
|
}
|
|
34774
34965
|
} catch (err) {
|
|
34775
34966
|
logger.error(`Failed moving assets to extended: ${err}`);
|
|
34776
|
-
return [
|
|
34967
|
+
return [
|
|
34968
|
+
this.createTransactionResult(
|
|
34969
|
+
[],
|
|
34970
|
+
false,
|
|
34971
|
+
{
|
|
34972
|
+
from: Protocols.VAULT.name,
|
|
34973
|
+
to: Protocols.EXTENDED.name,
|
|
34974
|
+
amount: extendedAmountDifference
|
|
34975
|
+
},
|
|
34976
|
+
"NONE",
|
|
34977
|
+
"INVESTMENT" /* INVESTMENT */
|
|
34978
|
+
)
|
|
34979
|
+
];
|
|
34777
34980
|
}
|
|
34778
34981
|
} else if (extendedAmountDifference.lessThan(0)) {
|
|
34779
34982
|
try {
|
|
34780
|
-
const {
|
|
34983
|
+
const {
|
|
34984
|
+
calls: extendedCalls,
|
|
34985
|
+
status: extendedStatus,
|
|
34986
|
+
transactionMetadata: extendedTransactionMetadata
|
|
34987
|
+
} = await this.moveAssets(
|
|
34781
34988
|
{
|
|
34782
34989
|
to: Protocols.VAULT.name,
|
|
34783
34990
|
from: Protocols.EXTENDED.name,
|
|
@@ -34797,23 +35004,55 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34797
35004
|
}
|
|
34798
35005
|
});
|
|
34799
35006
|
} else {
|
|
34800
|
-
logger.error(
|
|
34801
|
-
|
|
35007
|
+
logger.error(
|
|
35008
|
+
`Failed to withdraw from extended - operation returned false status`
|
|
35009
|
+
);
|
|
35010
|
+
return [
|
|
35011
|
+
this.createTransactionResult(
|
|
35012
|
+
[],
|
|
35013
|
+
false,
|
|
35014
|
+
{
|
|
35015
|
+
from: Protocols.EXTENDED.name,
|
|
35016
|
+
to: Protocols.VAULT.name,
|
|
35017
|
+
amount: extendedAmountDifferenceAbs
|
|
35018
|
+
},
|
|
35019
|
+
"NONE",
|
|
35020
|
+
"INVESTMENT" /* INVESTMENT */
|
|
35021
|
+
)
|
|
35022
|
+
];
|
|
34802
35023
|
}
|
|
34803
35024
|
} catch (err) {
|
|
34804
35025
|
logger.error(`Failed moving assets from extended to vault: ${err}`);
|
|
34805
|
-
return [
|
|
35026
|
+
return [
|
|
35027
|
+
this.createTransactionResult(
|
|
35028
|
+
[],
|
|
35029
|
+
false,
|
|
35030
|
+
{
|
|
35031
|
+
from: Protocols.EXTENDED.name,
|
|
35032
|
+
to: Protocols.VAULT.name,
|
|
35033
|
+
amount: extendedAmountDifferenceAbs
|
|
35034
|
+
},
|
|
35035
|
+
"NONE",
|
|
35036
|
+
"INVESTMENT" /* INVESTMENT */
|
|
35037
|
+
)
|
|
35038
|
+
];
|
|
34806
35039
|
}
|
|
34807
35040
|
}
|
|
34808
35041
|
}
|
|
34809
|
-
if (vesuAmountDifferenceAbs.greaterThan(
|
|
35042
|
+
if (vesuAmountDifferenceAbs.greaterThan(
|
|
35043
|
+
vesuAdapter.minimumVesuMovementAmount
|
|
35044
|
+
)) {
|
|
34810
35045
|
if (vesuAmountDifference.lessThanOrEqualTo(0)) {
|
|
34811
35046
|
logger.warn(
|
|
34812
35047
|
`Vesu amount difference is negative or zero: ${vesuAmountDifference.toNumber()}. Skipping operation.`
|
|
34813
35048
|
);
|
|
34814
35049
|
} else {
|
|
34815
35050
|
try {
|
|
34816
|
-
const {
|
|
35051
|
+
const {
|
|
35052
|
+
calls: vesuCalls,
|
|
35053
|
+
status: vesuStatus,
|
|
35054
|
+
transactionMetadata: vesuTransactionMetadata
|
|
35055
|
+
} = await this.moveAssets(
|
|
34817
35056
|
{
|
|
34818
35057
|
to: Protocols.VAULT.name,
|
|
34819
35058
|
from: Protocols.EXTENDED.name,
|
|
@@ -34824,8 +35063,22 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34824
35063
|
vesuAdapter
|
|
34825
35064
|
);
|
|
34826
35065
|
if (!vesuStatus) {
|
|
34827
|
-
logger.error(
|
|
34828
|
-
|
|
35066
|
+
logger.error(
|
|
35067
|
+
`Failed to move assets to vesu - operation returned false status`
|
|
35068
|
+
);
|
|
35069
|
+
return [
|
|
35070
|
+
this.createTransactionResult(
|
|
35071
|
+
[],
|
|
35072
|
+
false,
|
|
35073
|
+
{
|
|
35074
|
+
from: Protocols.EXTENDED.name,
|
|
35075
|
+
to: Protocols.VAULT.name,
|
|
35076
|
+
amount: vesuAmountDifference
|
|
35077
|
+
},
|
|
35078
|
+
"NONE",
|
|
35079
|
+
"INVESTMENT" /* INVESTMENT */
|
|
35080
|
+
)
|
|
35081
|
+
];
|
|
34829
35082
|
}
|
|
34830
35083
|
transactionResults.push({
|
|
34831
35084
|
status: vesuStatus,
|
|
@@ -34837,14 +35090,38 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34837
35090
|
});
|
|
34838
35091
|
} catch (err) {
|
|
34839
35092
|
logger.error(`Failed moving assets to vault: ${err}`);
|
|
34840
|
-
return [
|
|
35093
|
+
return [
|
|
35094
|
+
this.createTransactionResult(
|
|
35095
|
+
[],
|
|
35096
|
+
false,
|
|
35097
|
+
{
|
|
35098
|
+
from: Protocols.EXTENDED.name,
|
|
35099
|
+
to: Protocols.VAULT.name,
|
|
35100
|
+
amount: vesuAmountDifference
|
|
35101
|
+
},
|
|
35102
|
+
"NONE",
|
|
35103
|
+
"INVESTMENT" /* INVESTMENT */
|
|
35104
|
+
)
|
|
35105
|
+
];
|
|
34841
35106
|
}
|
|
34842
35107
|
}
|
|
34843
35108
|
}
|
|
34844
35109
|
return transactionResults;
|
|
34845
35110
|
} catch (err) {
|
|
34846
35111
|
logger.error(`Failed moving assets to vesu: ${err}`);
|
|
34847
|
-
return [
|
|
35112
|
+
return [
|
|
35113
|
+
this.createTransactionResult(
|
|
35114
|
+
[],
|
|
35115
|
+
false,
|
|
35116
|
+
{
|
|
35117
|
+
from: Protocols.EXTENDED.name,
|
|
35118
|
+
to: Protocols.VAULT.name,
|
|
35119
|
+
amount: new Web3Number(0, USDC_TOKEN_DECIMALS)
|
|
35120
|
+
},
|
|
35121
|
+
"NONE",
|
|
35122
|
+
"INVESTMENT" /* INVESTMENT */
|
|
35123
|
+
)
|
|
35124
|
+
];
|
|
34848
35125
|
}
|
|
34849
35126
|
}
|
|
34850
35127
|
/**
|
|
@@ -34865,7 +35142,18 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34865
35142
|
}
|
|
34866
35143
|
};
|
|
34867
35144
|
}
|
|
34868
|
-
return {
|
|
35145
|
+
return {
|
|
35146
|
+
calls: [],
|
|
35147
|
+
status: false,
|
|
35148
|
+
transactionMetadata: {
|
|
35149
|
+
protocolFrom: "",
|
|
35150
|
+
protocolTo: "",
|
|
35151
|
+
transactionType: "DEPOSIT",
|
|
35152
|
+
usdAmount: "0",
|
|
35153
|
+
status: "FAILED",
|
|
35154
|
+
cycleType
|
|
35155
|
+
}
|
|
35156
|
+
};
|
|
34869
35157
|
}
|
|
34870
35158
|
/**
|
|
34871
35159
|
* This method is used to move assets between protocols
|
|
@@ -34873,7 +35161,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34873
35161
|
* @param extendedAdapter - The extended adapter
|
|
34874
35162
|
* @param vesuAdapter - The vesu adapter
|
|
34875
35163
|
* @returns The transaction result
|
|
34876
|
-
* If Extended amount is greater than amount of withdrawal from extended, then we need to open a long position
|
|
35164
|
+
* If Extended amount is greater than amount of withdrawal from extended, then we need to open a long position
|
|
34877
35165
|
* so that the amount of withdrawal from extended is fullfilled
|
|
34878
35166
|
*/
|
|
34879
35167
|
async moveAssets(params, extendedAdapter, vesuAdapter) {
|
|
@@ -34882,18 +35170,28 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34882
35170
|
logger.error(
|
|
34883
35171
|
`Invalid amount for moveAssets: ${params.amount.toNumber()}. Amount must be positive.`
|
|
34884
35172
|
);
|
|
34885
|
-
return this.createTransactionResult(
|
|
35173
|
+
return this.createTransactionResult(
|
|
35174
|
+
[],
|
|
35175
|
+
false,
|
|
35176
|
+
params,
|
|
35177
|
+
"NONE",
|
|
35178
|
+
params.cycleType
|
|
35179
|
+
);
|
|
34886
35180
|
}
|
|
34887
35181
|
const avnuAdapter = await this.getAvnuAdapter();
|
|
34888
35182
|
if (!avnuAdapter) {
|
|
34889
35183
|
logger.error(`avnu adapter not found: ${avnuAdapter}`);
|
|
34890
|
-
return this.createTransactionResult(
|
|
35184
|
+
return this.createTransactionResult(
|
|
35185
|
+
[],
|
|
35186
|
+
false,
|
|
35187
|
+
params,
|
|
35188
|
+
"NONE",
|
|
35189
|
+
params.cycleType
|
|
35190
|
+
);
|
|
34891
35191
|
}
|
|
34892
35192
|
logger.info(`moveAssets params, ${JSON.stringify(params)}`);
|
|
34893
35193
|
const collateralToken = vesuAdapter.config.supportedPositions[0].asset;
|
|
34894
|
-
const {
|
|
34895
|
-
collateralPrice
|
|
34896
|
-
} = await this.getAssetPrices();
|
|
35194
|
+
const { collateralPrice } = await this.getAssetPrices();
|
|
34897
35195
|
if (params.to === Protocols.EXTENDED.name && params.from === Protocols.VAULT.name) {
|
|
34898
35196
|
const proofsInfo = extendedAdapter.getProofs(
|
|
34899
35197
|
true,
|
|
@@ -34906,28 +35204,58 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34906
35204
|
await proofsInfo.callConstructor({ amount: params.amount })
|
|
34907
35205
|
);
|
|
34908
35206
|
calls.push(call);
|
|
34909
|
-
return this.createTransactionResult(
|
|
35207
|
+
return this.createTransactionResult(
|
|
35208
|
+
calls,
|
|
35209
|
+
true,
|
|
35210
|
+
params,
|
|
35211
|
+
"DEPOSIT",
|
|
35212
|
+
params.cycleType
|
|
35213
|
+
);
|
|
34910
35214
|
} else if (params.to === Protocols.VAULT.name && params.from === Protocols.EXTENDED.name) {
|
|
34911
35215
|
const extendedLeverage = calculateExtendedLevergae();
|
|
34912
35216
|
const extendedHoldings = await extendedAdapter.getExtendedDepositAmount();
|
|
34913
35217
|
if (!extendedHoldings) {
|
|
34914
35218
|
logger.error(`error getting extended holdings: ${extendedHoldings}`);
|
|
34915
|
-
return this.createTransactionResult(
|
|
35219
|
+
return this.createTransactionResult(
|
|
35220
|
+
[],
|
|
35221
|
+
false,
|
|
35222
|
+
params,
|
|
35223
|
+
"NONE",
|
|
35224
|
+
params.cycleType
|
|
35225
|
+
);
|
|
34916
35226
|
}
|
|
34917
35227
|
const extendedHoldingAmount = new Web3Number(
|
|
34918
35228
|
extendedHoldings.availableForWithdrawal,
|
|
34919
35229
|
USDC_TOKEN_DECIMALS
|
|
34920
35230
|
);
|
|
34921
|
-
logger.info(
|
|
35231
|
+
logger.info(
|
|
35232
|
+
`${_VesuExtendedMultiplierStrategy.name}::moveAssets extendedHoldingAmount: ${extendedHoldingAmount.toNumber()}`
|
|
35233
|
+
);
|
|
35234
|
+
const extendedPositions = await extendedAdapter.getAllOpenPositions();
|
|
35235
|
+
if (!extendedPositions) {
|
|
35236
|
+
logger.error(`error getting extended positions: ${extendedPositions} while moving assets from extended to vault`);
|
|
35237
|
+
return this.createTransactionResult(
|
|
35238
|
+
[],
|
|
35239
|
+
false,
|
|
35240
|
+
params,
|
|
35241
|
+
"NONE",
|
|
35242
|
+
params.cycleType
|
|
35243
|
+
);
|
|
35244
|
+
}
|
|
34922
35245
|
if (params.amount.abs().greaterThan(extendedHoldingAmount)) {
|
|
34923
|
-
const leftAmountAfterWithdrawalAmountInAccount = new Web3Number(
|
|
34924
|
-
|
|
35246
|
+
const leftAmountAfterWithdrawalAmountInAccount = new Web3Number(
|
|
35247
|
+
Math.ceil(
|
|
35248
|
+
params.amount.abs().minus(extendedHoldingAmount).toNumber()
|
|
35249
|
+
),
|
|
35250
|
+
USDC_TOKEN_DECIMALS
|
|
35251
|
+
);
|
|
35252
|
+
const positionAmountToClose = await calculatePositionToCloseToWithdrawAmount(extendedHoldings, extendedPositions[0], params.amount);
|
|
35253
|
+
logger.info(`positionAmountToClose: ${positionAmountToClose.toNumber()}`);
|
|
35254
|
+
logger.info(
|
|
35255
|
+
`${_VesuExtendedMultiplierStrategy.name}::moveAssets leftAmountAfterWithdrawalAmountInAccount: ${leftAmountAfterWithdrawalAmountInAccount.toNumber()}`
|
|
35256
|
+
);
|
|
34925
35257
|
let priceOfBTC;
|
|
34926
|
-
const {
|
|
34927
|
-
ask,
|
|
34928
|
-
bid,
|
|
34929
|
-
status
|
|
34930
|
-
} = await extendedAdapter.fetchOrderBookBTCUSDC();
|
|
35258
|
+
const { ask, bid, status } = await extendedAdapter.fetchOrderBookBTCUSDC();
|
|
34931
35259
|
const price = ask.plus(bid).dividedBy(2);
|
|
34932
35260
|
if (status) {
|
|
34933
35261
|
priceOfBTC = price;
|
|
@@ -34935,7 +35263,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34935
35263
|
logger.error(`error fetching order book btc usdc: ${status}`);
|
|
34936
35264
|
priceOfBTC = collateralPrice.price;
|
|
34937
35265
|
}
|
|
34938
|
-
const btcAmount =
|
|
35266
|
+
const btcAmount = positionAmountToClose.dividedBy(priceOfBTC);
|
|
34939
35267
|
const openLongPosition = btcAmount.multipliedBy(3).greaterThan(MINIMUM_EXTENDED_POSITION_SIZE) ? await extendedAdapter.createOrder(
|
|
34940
35268
|
extendedLeverage.toString(),
|
|
34941
35269
|
btcAmount.toNumber(),
|
|
@@ -34950,38 +35278,95 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34950
35278
|
logger.error(`error opening long position: ${openLongPosition}`);
|
|
34951
35279
|
}
|
|
34952
35280
|
const updatedHoldings = await extendedAdapter.getExtendedDepositAmount();
|
|
34953
|
-
if (!updatedHoldings || new Web3Number(
|
|
34954
|
-
|
|
34955
|
-
|
|
35281
|
+
if (!updatedHoldings || new Web3Number(
|
|
35282
|
+
updatedHoldings.availableForWithdrawal,
|
|
35283
|
+
USDC_TOKEN_DECIMALS
|
|
35284
|
+
).lessThan(params.amount.abs())) {
|
|
35285
|
+
logger.error(
|
|
35286
|
+
`Insufficient balance after opening position. Available: ${updatedHoldings?.availableForWithdrawal}, Needed: ${params.amount.abs()}`
|
|
35287
|
+
);
|
|
35288
|
+
return this.createTransactionResult(
|
|
35289
|
+
[],
|
|
35290
|
+
false,
|
|
35291
|
+
params,
|
|
35292
|
+
"NONE",
|
|
35293
|
+
params.cycleType
|
|
35294
|
+
);
|
|
34956
35295
|
}
|
|
34957
35296
|
}
|
|
34958
35297
|
const {
|
|
34959
35298
|
status: withdrawalFromExtendedStatus,
|
|
34960
35299
|
receivedTxnHash: withdrawalFromExtendedTxnHash
|
|
34961
35300
|
} = await extendedAdapter.withdrawFromExtended(params.amount);
|
|
34962
|
-
logger.info(
|
|
35301
|
+
logger.info(
|
|
35302
|
+
`withdrawalFromExtendedStatus: ${withdrawalFromExtendedStatus}, withdrawalFromExtendedTxnHash: ${withdrawalFromExtendedTxnHash}`
|
|
35303
|
+
);
|
|
34963
35304
|
if (withdrawalFromExtendedStatus && withdrawalFromExtendedTxnHash) {
|
|
34964
35305
|
const extendedHoldings2 = await extendedAdapter.getExtendedDepositAmount();
|
|
34965
|
-
logger.info(
|
|
35306
|
+
logger.info(
|
|
35307
|
+
`extendedHoldings after withdrawal ${extendedHoldings2?.availableForWithdrawal}`
|
|
35308
|
+
);
|
|
34966
35309
|
await new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
34967
|
-
const { calls, status } = await this.moveAssetsToVaultAllocator(
|
|
35310
|
+
const { calls, status } = await this.moveAssetsToVaultAllocator(
|
|
35311
|
+
params.amount,
|
|
35312
|
+
extendedAdapter
|
|
35313
|
+
);
|
|
34968
35314
|
if (calls.length > 0 && status) {
|
|
34969
|
-
return this.createTransactionResult(
|
|
35315
|
+
return this.createTransactionResult(
|
|
35316
|
+
calls,
|
|
35317
|
+
true,
|
|
35318
|
+
params,
|
|
35319
|
+
"WITHDRAWAL",
|
|
35320
|
+
params.cycleType
|
|
35321
|
+
);
|
|
34970
35322
|
} else {
|
|
34971
|
-
return this.createTransactionResult(
|
|
35323
|
+
return this.createTransactionResult(
|
|
35324
|
+
[],
|
|
35325
|
+
true,
|
|
35326
|
+
params,
|
|
35327
|
+
"WITHDRAWAL",
|
|
35328
|
+
params.cycleType
|
|
35329
|
+
);
|
|
34972
35330
|
}
|
|
34973
35331
|
} else if (withdrawalFromExtendedStatus && !withdrawalFromExtendedTxnHash) {
|
|
34974
|
-
logger.error(
|
|
34975
|
-
|
|
35332
|
+
logger.error(
|
|
35333
|
+
"withdrawal from extended successful, but funds didn't get transferred to the wallet"
|
|
35334
|
+
);
|
|
35335
|
+
return this.createTransactionResult(
|
|
35336
|
+
[],
|
|
35337
|
+
true,
|
|
35338
|
+
params,
|
|
35339
|
+
"WITHDRAWAL",
|
|
35340
|
+
params.cycleType
|
|
35341
|
+
);
|
|
34976
35342
|
} else {
|
|
34977
35343
|
logger.error("withdrawal from extended failed");
|
|
34978
|
-
return this.createTransactionResult(
|
|
35344
|
+
return this.createTransactionResult(
|
|
35345
|
+
[],
|
|
35346
|
+
false,
|
|
35347
|
+
params,
|
|
35348
|
+
"NONE",
|
|
35349
|
+
params.cycleType
|
|
35350
|
+
);
|
|
34979
35351
|
}
|
|
34980
35352
|
} else if (params.to === Protocols.VAULT.name && params.from === Protocols.VESU.name) {
|
|
34981
|
-
const isPriceDifferenceBetweenAvnuAndExtended = await this.checkPriceDifferenceBetweenAvnuAndExtended(
|
|
35353
|
+
const isPriceDifferenceBetweenAvnuAndExtended = await this.checkPriceDifferenceBetweenAvnuAndExtended(
|
|
35354
|
+
extendedAdapter,
|
|
35355
|
+
vesuAdapter,
|
|
35356
|
+
avnuAdapter,
|
|
35357
|
+
"close" /* CLOSE */
|
|
35358
|
+
);
|
|
34982
35359
|
if (!isPriceDifferenceBetweenAvnuAndExtended) {
|
|
34983
|
-
logger.warn(
|
|
34984
|
-
|
|
35360
|
+
logger.warn(
|
|
35361
|
+
`price difference between avnu and extended doesn't fit the range for close position, ${avnuAdapter.config.maximumExtendedPriceDifferenceForSwapClosing}`
|
|
35362
|
+
);
|
|
35363
|
+
return this.createTransactionResult(
|
|
35364
|
+
[],
|
|
35365
|
+
false,
|
|
35366
|
+
params,
|
|
35367
|
+
"NONE",
|
|
35368
|
+
params.cycleType
|
|
35369
|
+
);
|
|
34985
35370
|
}
|
|
34986
35371
|
const vesuAmountInBTC = new Web3Number(
|
|
34987
35372
|
params.amount.dividedBy(collateralPrice.price).toFixed(WBTC_TOKEN_DECIMALS),
|
|
@@ -34995,19 +35380,41 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
34995
35380
|
await proofsInfo.callConstructor({ amount: vesuAmountInBTC })
|
|
34996
35381
|
);
|
|
34997
35382
|
calls.push(call);
|
|
34998
|
-
const swapProofsInfo = avnuAdapter.getProofs(
|
|
35383
|
+
const swapProofsInfo = avnuAdapter.getProofs(
|
|
35384
|
+
false,
|
|
35385
|
+
this.getMerkleTree()
|
|
35386
|
+
);
|
|
34999
35387
|
const swapProofGroups = swapProofsInfo.proofs;
|
|
35000
35388
|
const swapCall = this.getManageCall(
|
|
35001
35389
|
swapProofGroups,
|
|
35002
35390
|
await swapProofsInfo.callConstructor({ amount: vesuAmountInBTC })
|
|
35003
35391
|
);
|
|
35004
35392
|
calls.push(swapCall);
|
|
35005
|
-
return this.createTransactionResult(
|
|
35393
|
+
return this.createTransactionResult(
|
|
35394
|
+
calls,
|
|
35395
|
+
true,
|
|
35396
|
+
params,
|
|
35397
|
+
"WITHDRAWAL",
|
|
35398
|
+
params.cycleType
|
|
35399
|
+
);
|
|
35006
35400
|
} else if (params.to === Protocols.EXTENDED.name && params.from === Protocols.VESU.name) {
|
|
35007
|
-
const isPriceDifferenceBetweenAvnuAndExtended = await this.checkPriceDifferenceBetweenAvnuAndExtended(
|
|
35401
|
+
const isPriceDifferenceBetweenAvnuAndExtended = await this.checkPriceDifferenceBetweenAvnuAndExtended(
|
|
35402
|
+
extendedAdapter,
|
|
35403
|
+
vesuAdapter,
|
|
35404
|
+
avnuAdapter,
|
|
35405
|
+
"close" /* CLOSE */
|
|
35406
|
+
);
|
|
35008
35407
|
if (!isPriceDifferenceBetweenAvnuAndExtended) {
|
|
35009
|
-
logger.warn(
|
|
35010
|
-
|
|
35408
|
+
logger.warn(
|
|
35409
|
+
`price difference between avnu and extended doesn't fit the range for close position, ${avnuAdapter.config.maximumExtendedPriceDifferenceForSwapClosing}`
|
|
35410
|
+
);
|
|
35411
|
+
return this.createTransactionResult(
|
|
35412
|
+
[],
|
|
35413
|
+
false,
|
|
35414
|
+
params,
|
|
35415
|
+
"NONE",
|
|
35416
|
+
params.cycleType
|
|
35417
|
+
);
|
|
35011
35418
|
}
|
|
35012
35419
|
const vesuAmountInBTC = new Web3Number(
|
|
35013
35420
|
params.amount.dividedBy(collateralPrice.price).toNumber(),
|
|
@@ -35021,7 +35428,10 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35021
35428
|
await proofsInfo.callConstructor({ amount: vesuAmountInBTC })
|
|
35022
35429
|
);
|
|
35023
35430
|
calls.push(call);
|
|
35024
|
-
const swapProofsInfo = avnuAdapter.getProofs(
|
|
35431
|
+
const swapProofsInfo = avnuAdapter.getProofs(
|
|
35432
|
+
false,
|
|
35433
|
+
this.getMerkleTree()
|
|
35434
|
+
);
|
|
35025
35435
|
const swapProofGroups = swapProofsInfo.proofs;
|
|
35026
35436
|
const swapCall = this.getManageCall(
|
|
35027
35437
|
swapProofGroups,
|
|
@@ -35038,21 +35448,61 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35038
35448
|
await proofsInfoDeposit.callConstructor({ amount: params.amount })
|
|
35039
35449
|
);
|
|
35040
35450
|
calls.push(callDeposit);
|
|
35041
|
-
return this.createTransactionResult(
|
|
35451
|
+
return this.createTransactionResult(
|
|
35452
|
+
calls,
|
|
35453
|
+
true,
|
|
35454
|
+
params,
|
|
35455
|
+
"DEPOSIT",
|
|
35456
|
+
params.cycleType
|
|
35457
|
+
);
|
|
35042
35458
|
}
|
|
35043
|
-
logger.error(
|
|
35044
|
-
|
|
35459
|
+
logger.error(
|
|
35460
|
+
`Unsupported assets movement: ${params.from} to ${params.to}`
|
|
35461
|
+
);
|
|
35462
|
+
return this.createTransactionResult(
|
|
35463
|
+
[],
|
|
35464
|
+
false,
|
|
35465
|
+
params,
|
|
35466
|
+
"NONE",
|
|
35467
|
+
params.cycleType
|
|
35468
|
+
);
|
|
35045
35469
|
} catch (err) {
|
|
35046
35470
|
logger.error(`error moving assets: ${err}`);
|
|
35047
|
-
return this.createTransactionResult(
|
|
35471
|
+
return this.createTransactionResult(
|
|
35472
|
+
[],
|
|
35473
|
+
false,
|
|
35474
|
+
params,
|
|
35475
|
+
"NONE",
|
|
35476
|
+
params.cycleType
|
|
35477
|
+
);
|
|
35048
35478
|
}
|
|
35049
35479
|
}
|
|
35050
35480
|
async handleDeposit() {
|
|
35051
35481
|
try {
|
|
35052
|
-
return this.createTransactionResult(
|
|
35482
|
+
return this.createTransactionResult(
|
|
35483
|
+
[],
|
|
35484
|
+
false,
|
|
35485
|
+
{
|
|
35486
|
+
from: Protocols.VAULT.name,
|
|
35487
|
+
to: Protocols.VAULT.name,
|
|
35488
|
+
amount: new Web3Number(0, 0)
|
|
35489
|
+
},
|
|
35490
|
+
"NONE",
|
|
35491
|
+
"INVESTMENT" /* INVESTMENT */
|
|
35492
|
+
);
|
|
35053
35493
|
} catch (err) {
|
|
35054
35494
|
logger.error(`error handling deposit: ${err}`);
|
|
35055
|
-
return this.createTransactionResult(
|
|
35495
|
+
return this.createTransactionResult(
|
|
35496
|
+
[],
|
|
35497
|
+
false,
|
|
35498
|
+
{
|
|
35499
|
+
from: Protocols.VAULT.name,
|
|
35500
|
+
to: Protocols.VAULT.name,
|
|
35501
|
+
amount: new Web3Number(0, 0)
|
|
35502
|
+
},
|
|
35503
|
+
"NONE",
|
|
35504
|
+
"INVESTMENT" /* INVESTMENT */
|
|
35505
|
+
);
|
|
35056
35506
|
}
|
|
35057
35507
|
}
|
|
35058
35508
|
/**
|
|
@@ -35064,32 +35514,42 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35064
35514
|
* @returns true if the price difference is within the acceptable range, false otherwise
|
|
35065
35515
|
*/
|
|
35066
35516
|
async checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter, vesuAdapter, avnuAdapter, positionType) {
|
|
35067
|
-
const {
|
|
35068
|
-
ask,
|
|
35069
|
-
bid
|
|
35070
|
-
} = await extendedAdapter.fetchOrderBookBTCUSDC();
|
|
35517
|
+
const { ask, bid } = await extendedAdapter.fetchOrderBookBTCUSDC();
|
|
35071
35518
|
const price = ask.plus(bid).dividedBy(2);
|
|
35072
35519
|
const btcToken = vesuAdapter.config.supportedPositions[0].asset;
|
|
35073
|
-
const btcPriceAvnu = await avnuAdapter.getPriceOfToken(
|
|
35520
|
+
const btcPriceAvnu = await avnuAdapter.getPriceOfToken(
|
|
35521
|
+
btcToken.address.toString()
|
|
35522
|
+
);
|
|
35074
35523
|
if (!btcPriceAvnu) {
|
|
35075
35524
|
logger.error(`error getting btc price avnu: ${btcPriceAvnu}`);
|
|
35076
35525
|
return false;
|
|
35077
35526
|
}
|
|
35078
35527
|
logger.info(`price: ${price}`);
|
|
35079
35528
|
logger.info(`btcPriceAvnu: ${btcPriceAvnu}`);
|
|
35080
|
-
const priceDifference = new Web3Number(
|
|
35529
|
+
const priceDifference = new Web3Number(
|
|
35530
|
+
price.minus(btcPriceAvnu).toFixed(2),
|
|
35531
|
+
0
|
|
35532
|
+
);
|
|
35081
35533
|
logger.info(`priceDifference: ${priceDifference}`);
|
|
35082
35534
|
if (priceDifference.isNegative()) {
|
|
35083
35535
|
return false;
|
|
35084
35536
|
}
|
|
35085
35537
|
if (positionType === "open" /* OPEN */) {
|
|
35086
|
-
logger.info(
|
|
35087
|
-
|
|
35538
|
+
logger.info(
|
|
35539
|
+
`price difference between avnu and extended for open position: ${priceDifference.toNumber()}, minimumExtendedPriceDifferenceForSwapOpen: ${avnuAdapter.config.minimumExtendedPriceDifferenceForSwapOpen}`
|
|
35540
|
+
);
|
|
35541
|
+
const result = priceDifference.greaterThanOrEqualTo(
|
|
35542
|
+
avnuAdapter.config.minimumExtendedPriceDifferenceForSwapOpen
|
|
35543
|
+
);
|
|
35088
35544
|
logger.info(`result: ${result}`);
|
|
35089
35545
|
return result;
|
|
35090
35546
|
} else {
|
|
35091
|
-
logger.info(
|
|
35092
|
-
|
|
35547
|
+
logger.info(
|
|
35548
|
+
`price difference between avnu and extended for close position: ${priceDifference.toNumber()}, maximumExtendedPriceDifferenceForSwapClosing: ${avnuAdapter.config.maximumExtendedPriceDifferenceForSwapClosing}`
|
|
35549
|
+
);
|
|
35550
|
+
const result = priceDifference.lessThanOrEqualTo(
|
|
35551
|
+
avnuAdapter.config.maximumExtendedPriceDifferenceForSwapClosing
|
|
35552
|
+
);
|
|
35093
35553
|
logger.info(`result: ${result}`);
|
|
35094
35554
|
return result;
|
|
35095
35555
|
}
|
|
@@ -35111,7 +35571,19 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35111
35571
|
amount: usdcBalanceVaultAllocator.amount
|
|
35112
35572
|
});
|
|
35113
35573
|
calls.push(withdrawCall2);
|
|
35114
|
-
return [
|
|
35574
|
+
return [
|
|
35575
|
+
this.createTransactionResult(
|
|
35576
|
+
calls,
|
|
35577
|
+
true,
|
|
35578
|
+
{
|
|
35579
|
+
from: Protocols.VAULT.name,
|
|
35580
|
+
to: Protocols.NONE.name,
|
|
35581
|
+
amount
|
|
35582
|
+
},
|
|
35583
|
+
"WITHDRAWAL",
|
|
35584
|
+
"WITHDRAWAL" /* WITHDRAWAL */
|
|
35585
|
+
)
|
|
35586
|
+
];
|
|
35115
35587
|
}
|
|
35116
35588
|
const vesuAdapter = await this.getVesuAdapter();
|
|
35117
35589
|
const extendedAdapter = await this.getExtendedAdapter();
|
|
@@ -35120,18 +35592,40 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35120
35592
|
logger.error(
|
|
35121
35593
|
`vesu or extended adapter not found: vesuAdapter=${vesuAdapter}, extendedAdapter=${extendedAdapter}`
|
|
35122
35594
|
);
|
|
35123
|
-
return [
|
|
35595
|
+
return [
|
|
35596
|
+
this.createTransactionResult(
|
|
35597
|
+
calls,
|
|
35598
|
+
status,
|
|
35599
|
+
{
|
|
35600
|
+
from: Protocols.VAULT.name,
|
|
35601
|
+
to: Protocols.NONE.name,
|
|
35602
|
+
amount
|
|
35603
|
+
},
|
|
35604
|
+
"NONE",
|
|
35605
|
+
"WITHDRAWAL" /* WITHDRAWAL */
|
|
35606
|
+
)
|
|
35607
|
+
];
|
|
35124
35608
|
}
|
|
35125
35609
|
let transactionResults = [];
|
|
35126
35610
|
const { collateralTokenAmount } = await vesuAdapter.vesuAdapter.getAssetPrices();
|
|
35127
|
-
const {
|
|
35128
|
-
collateralPrice
|
|
35129
|
-
} = await this.getAssetPrices();
|
|
35611
|
+
const { collateralPrice } = await this.getAssetPrices();
|
|
35130
35612
|
const extendedPositon = await extendedAdapter.getAllOpenPositions();
|
|
35131
35613
|
if (!extendedPositon) {
|
|
35132
35614
|
status = false;
|
|
35133
35615
|
logger.error("error getting extended position", extendedPositon);
|
|
35134
|
-
return [
|
|
35616
|
+
return [
|
|
35617
|
+
this.createTransactionResult(
|
|
35618
|
+
calls,
|
|
35619
|
+
status,
|
|
35620
|
+
{
|
|
35621
|
+
from: Protocols.VAULT.name,
|
|
35622
|
+
to: Protocols.NONE.name,
|
|
35623
|
+
amount
|
|
35624
|
+
},
|
|
35625
|
+
"NONE",
|
|
35626
|
+
"WITHDRAWAL" /* WITHDRAWAL */
|
|
35627
|
+
)
|
|
35628
|
+
];
|
|
35135
35629
|
}
|
|
35136
35630
|
const amountDistributionForWithdrawal = await calculateAmountDistributionForWithdrawal(
|
|
35137
35631
|
usdcBalanceDifference,
|
|
@@ -35144,11 +35638,27 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35144
35638
|
logger.error(
|
|
35145
35639
|
`error calculating amount distribution for withdrawal: ${amountDistributionForWithdrawal}`
|
|
35146
35640
|
);
|
|
35147
|
-
return [
|
|
35641
|
+
return [
|
|
35642
|
+
this.createTransactionResult(
|
|
35643
|
+
calls,
|
|
35644
|
+
status,
|
|
35645
|
+
{
|
|
35646
|
+
from: Protocols.VAULT.name,
|
|
35647
|
+
to: Protocols.NONE.name,
|
|
35648
|
+
amount
|
|
35649
|
+
},
|
|
35650
|
+
"NONE",
|
|
35651
|
+
"WITHDRAWAL" /* WITHDRAWAL */
|
|
35652
|
+
)
|
|
35653
|
+
];
|
|
35148
35654
|
}
|
|
35149
35655
|
const { vesu_amount, extended_amount } = amountDistributionForWithdrawal;
|
|
35150
35656
|
if (status && vesu_amount.greaterThan(0)) {
|
|
35151
|
-
const {
|
|
35657
|
+
const {
|
|
35658
|
+
calls: vesuCalls,
|
|
35659
|
+
status: vesuStatus,
|
|
35660
|
+
transactionMetadata: vesuTransactionMetadata
|
|
35661
|
+
} = await this.moveAssets(
|
|
35152
35662
|
{
|
|
35153
35663
|
amount: vesu_amount,
|
|
35154
35664
|
from: Protocols.VESU.name,
|
|
@@ -35166,7 +35676,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35166
35676
|
});
|
|
35167
35677
|
}
|
|
35168
35678
|
if (status && extended_amount.greaterThan(0)) {
|
|
35169
|
-
const {
|
|
35679
|
+
const {
|
|
35680
|
+
calls: extendedCalls,
|
|
35681
|
+
status: extendedStatus,
|
|
35682
|
+
transactionMetadata: extendedTransactionMetadata
|
|
35683
|
+
} = await this.moveAssets(
|
|
35170
35684
|
{
|
|
35171
35685
|
amount: extended_amount,
|
|
35172
35686
|
from: Protocols.EXTENDED.name,
|
|
@@ -35184,8 +35698,22 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35184
35698
|
transactionMetadata: extendedTransactionMetadata
|
|
35185
35699
|
});
|
|
35186
35700
|
} else {
|
|
35187
|
-
logger.error(
|
|
35188
|
-
|
|
35701
|
+
logger.error(
|
|
35702
|
+
"error moving assets to vault: extendedStatus: ${extendedStatus}"
|
|
35703
|
+
);
|
|
35704
|
+
return [
|
|
35705
|
+
this.createTransactionResult(
|
|
35706
|
+
[],
|
|
35707
|
+
status,
|
|
35708
|
+
{
|
|
35709
|
+
from: Protocols.VAULT.name,
|
|
35710
|
+
to: Protocols.NONE.name,
|
|
35711
|
+
amount
|
|
35712
|
+
},
|
|
35713
|
+
"NONE",
|
|
35714
|
+
"WITHDRAWAL" /* WITHDRAWAL */
|
|
35715
|
+
)
|
|
35716
|
+
];
|
|
35189
35717
|
}
|
|
35190
35718
|
}
|
|
35191
35719
|
const withdrawCall = await this.getBringLiquidityCall({
|
|
@@ -35207,7 +35735,19 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35207
35735
|
return transactionResults;
|
|
35208
35736
|
} catch (err) {
|
|
35209
35737
|
logger.error(`error handling withdrawal: ${err}`);
|
|
35210
|
-
return [
|
|
35738
|
+
return [
|
|
35739
|
+
this.createTransactionResult(
|
|
35740
|
+
[],
|
|
35741
|
+
false,
|
|
35742
|
+
{
|
|
35743
|
+
from: Protocols.VAULT.name,
|
|
35744
|
+
to: Protocols.NONE.name,
|
|
35745
|
+
amount
|
|
35746
|
+
},
|
|
35747
|
+
"NONE",
|
|
35748
|
+
"WITHDRAWAL" /* WITHDRAWAL */
|
|
35749
|
+
)
|
|
35750
|
+
];
|
|
35211
35751
|
}
|
|
35212
35752
|
}
|
|
35213
35753
|
async getAUM() {
|
|
@@ -35259,8 +35799,12 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35259
35799
|
const txnsToBeExecuted = txnData.filter((txn) => {
|
|
35260
35800
|
return txn.transactionMetadata.transactionType !== "NONE" && txn.transactionMetadata.protocolFrom !== "" && txn.transactionMetadata.protocolTo !== "";
|
|
35261
35801
|
});
|
|
35262
|
-
const callsToBeExecutedFinal = txnsToBeExecuted.flatMap(
|
|
35263
|
-
|
|
35802
|
+
const callsToBeExecutedFinal = txnsToBeExecuted.flatMap(
|
|
35803
|
+
(txn) => txn.calls
|
|
35804
|
+
);
|
|
35805
|
+
const txnMetadata = txnsToBeExecuted.map(
|
|
35806
|
+
(txn) => txn.transactionMetadata
|
|
35807
|
+
);
|
|
35264
35808
|
return { callsToBeExecutedFinal, txnMetadata };
|
|
35265
35809
|
} catch (err) {
|
|
35266
35810
|
logger.error(`error processing transaction data from SDK: ${err}`);
|
|
@@ -35290,23 +35834,42 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35290
35834
|
if (!vesuAdapter || !extendedAdapter) {
|
|
35291
35835
|
return new Web3Number(0, 0);
|
|
35292
35836
|
}
|
|
35293
|
-
const extendedFundingRate = new Web3Number(
|
|
35837
|
+
const extendedFundingRate = new Web3Number(
|
|
35838
|
+
(await extendedAdapter.getNetAPY()).toFixed(4),
|
|
35839
|
+
0
|
|
35840
|
+
);
|
|
35294
35841
|
const extendedPositions = await extendedAdapter.getAllOpenPositions();
|
|
35295
35842
|
if (!extendedPositions || extendedPositions.length === 0) {
|
|
35296
35843
|
logger.info(`no extended positions found`);
|
|
35297
35844
|
return new Web3Number(0, 0);
|
|
35298
35845
|
}
|
|
35299
|
-
const extendePositionSizeUSD = new Web3Number(
|
|
35846
|
+
const extendePositionSizeUSD = new Web3Number(
|
|
35847
|
+
extendedPositions[0].value || 0,
|
|
35848
|
+
0
|
|
35849
|
+
);
|
|
35300
35850
|
const vesuPositions = await vesuAdapter.getPositions();
|
|
35301
35851
|
const vesuSupplyApy = vesuPositions[0].apy.apy;
|
|
35302
|
-
const vesuCollateralSizeUSD = new Web3Number(
|
|
35303
|
-
|
|
35852
|
+
const vesuCollateralSizeUSD = new Web3Number(
|
|
35853
|
+
vesuPositions[0].usdValue.toFixed(USDC_TOKEN_DECIMALS),
|
|
35854
|
+
USDC_TOKEN_DECIMALS
|
|
35855
|
+
);
|
|
35856
|
+
const vesuDebtSizeUSD = new Web3Number(
|
|
35857
|
+
vesuPositions[1].usdValue.toFixed(USDC_TOKEN_DECIMALS),
|
|
35858
|
+
USDC_TOKEN_DECIMALS
|
|
35859
|
+
);
|
|
35304
35860
|
const num1 = extendePositionSizeUSD.multipliedBy(extendedFundingRate);
|
|
35305
35861
|
const num22 = vesuCollateralSizeUSD.multipliedBy(vesuSupplyApy);
|
|
35306
35862
|
const num32 = vesuDebtSizeUSD.abs();
|
|
35307
35863
|
const maxBorrowApy = num1.plus(num22).minus(0.1).dividedBy(num32);
|
|
35308
|
-
const vesuMaxBorrowableAmount = await vesuAdapter.vesuAdapter.getMaxBorrowableByInterestRate(
|
|
35309
|
-
|
|
35864
|
+
const vesuMaxBorrowableAmount = await vesuAdapter.vesuAdapter.getMaxBorrowableByInterestRate(
|
|
35865
|
+
this.config,
|
|
35866
|
+
vesuAdapter.config.debt,
|
|
35867
|
+
maxBorrowApy.toNumber()
|
|
35868
|
+
);
|
|
35869
|
+
return new Web3Number(
|
|
35870
|
+
vesuMaxBorrowableAmount.toFixed(USDC_TOKEN_DECIMALS),
|
|
35871
|
+
USDC_TOKEN_DECIMALS
|
|
35872
|
+
);
|
|
35310
35873
|
}
|
|
35311
35874
|
async getVesuHealthFactors() {
|
|
35312
35875
|
const vesuAdapter = await this.getVesuAdapter();
|
|
@@ -35315,18 +35878,33 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35315
35878
|
return [0, 0];
|
|
35316
35879
|
}
|
|
35317
35880
|
const vesuPositions = await vesuAdapter.getPositions();
|
|
35318
|
-
const vesuCollateralSizeUSD = new Web3Number(
|
|
35319
|
-
|
|
35881
|
+
const vesuCollateralSizeUSD = new Web3Number(
|
|
35882
|
+
vesuPositions[0].usdValue.toFixed(USDC_TOKEN_DECIMALS),
|
|
35883
|
+
0
|
|
35884
|
+
);
|
|
35885
|
+
const vesuDebtSizeUSD = new Web3Number(
|
|
35886
|
+
vesuPositions[1].usdValue.toFixed(USDC_TOKEN_DECIMALS),
|
|
35887
|
+
0
|
|
35888
|
+
);
|
|
35320
35889
|
const actualLtv = vesuDebtSizeUSD.dividedBy(vesuCollateralSizeUSD).abs();
|
|
35321
35890
|
logger.info(`actualLtv: ${actualLtv.toNumber()}`);
|
|
35322
|
-
const maxLtv = new Web3Number(
|
|
35323
|
-
|
|
35891
|
+
const maxLtv = new Web3Number(
|
|
35892
|
+
await vesuAdapter.vesuAdapter.getLTVConfig(this.config),
|
|
35893
|
+
4
|
|
35894
|
+
);
|
|
35895
|
+
const healthFactor = new Web3Number(
|
|
35896
|
+
maxLtv.dividedBy(actualLtv).toFixed(4),
|
|
35897
|
+
4
|
|
35898
|
+
);
|
|
35324
35899
|
logger.info(`healthFactor: ${healthFactor.toNumber()}`);
|
|
35325
35900
|
const extendedBalance = await extendedAdapter.getExtendedDepositAmount();
|
|
35326
35901
|
if (!extendedBalance) {
|
|
35327
35902
|
return [0, 0];
|
|
35328
35903
|
}
|
|
35329
|
-
const extendedLeverage = new Web3Number(
|
|
35904
|
+
const extendedLeverage = new Web3Number(
|
|
35905
|
+
(Number(extendedBalance.marginRatio) * 100).toFixed(4),
|
|
35906
|
+
4
|
|
35907
|
+
);
|
|
35330
35908
|
logger.info(`extendedLeverage: ${extendedLeverage.toNumber()}`);
|
|
35331
35909
|
return [healthFactor.toNumber(), extendedLeverage.toNumber()];
|
|
35332
35910
|
}
|
|
@@ -35347,12 +35925,16 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35347
35925
|
splits: []
|
|
35348
35926
|
};
|
|
35349
35927
|
}
|
|
35350
|
-
let vesuPositions = allPositions.filter(
|
|
35928
|
+
let vesuPositions = allPositions.filter(
|
|
35929
|
+
(item) => item.protocol === Protocols.VESU
|
|
35930
|
+
);
|
|
35351
35931
|
vesuPositions.map((item) => {
|
|
35352
35932
|
item.apy.apy = item.apy.apy * 0.1;
|
|
35353
35933
|
});
|
|
35354
35934
|
const extendedPositions = await extendedAdapter.getAllOpenPositions();
|
|
35355
|
-
const usdcToken = Global.getDefaultTokens().find(
|
|
35935
|
+
const usdcToken = Global.getDefaultTokens().find(
|
|
35936
|
+
(token) => token.symbol === "USDC"
|
|
35937
|
+
);
|
|
35356
35938
|
if (!extendedPositions || !usdcToken) {
|
|
35357
35939
|
return {
|
|
35358
35940
|
net: 0,
|
|
@@ -35365,7 +35947,10 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35365
35947
|
const totalHoldingsUSDValue = allPositions.reduce((acc, curr) => acc + curr.usdValue, 0) + Number(extendedEquity);
|
|
35366
35948
|
console.log(totalHoldingsUSDValue);
|
|
35367
35949
|
const extendedPositionSizeMultipliedByApy = Number(extendedPosition.value) * extendedApy;
|
|
35368
|
-
let weightedAPYs = allPositions.reduce(
|
|
35950
|
+
let weightedAPYs = allPositions.reduce(
|
|
35951
|
+
(acc, curr) => acc + curr.apy.apy * curr.usdValue,
|
|
35952
|
+
0
|
|
35953
|
+
) + extendedPositionSizeMultipliedByApy;
|
|
35369
35954
|
console.log(weightedAPYs);
|
|
35370
35955
|
const netAPY = weightedAPYs / totalHoldingsUSDValue;
|
|
35371
35956
|
console.log(netAPY);
|
|
@@ -35379,13 +35964,22 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
|
|
|
35379
35964
|
});
|
|
35380
35965
|
return {
|
|
35381
35966
|
net: netAPY,
|
|
35382
|
-
splits: allPositions.map((p) => ({
|
|
35967
|
+
splits: allPositions.map((p) => ({
|
|
35968
|
+
apy: p.apy.apy,
|
|
35969
|
+
id: p.remarks ?? ""
|
|
35970
|
+
}))
|
|
35383
35971
|
};
|
|
35384
35972
|
}
|
|
35385
35973
|
async getWalletHoldings() {
|
|
35386
|
-
const usdceToken = Global.getDefaultTokens().find(
|
|
35387
|
-
|
|
35388
|
-
|
|
35974
|
+
const usdceToken = Global.getDefaultTokens().find(
|
|
35975
|
+
(token) => token.symbol === "USDCe"
|
|
35976
|
+
);
|
|
35977
|
+
const wbtcToken = Global.getDefaultTokens().find(
|
|
35978
|
+
(token) => token.symbol === "WBTC"
|
|
35979
|
+
);
|
|
35980
|
+
const usdcToken = Global.getDefaultTokens().find(
|
|
35981
|
+
(token) => token.symbol === "USDC"
|
|
35982
|
+
);
|
|
35389
35983
|
if (!usdceToken || !wbtcToken || !usdcToken) {
|
|
35390
35984
|
return [];
|
|
35391
35985
|
}
|
|
@@ -35459,9 +36053,7 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1, e
|
|
|
35459
36053
|
});
|
|
35460
36054
|
const extendedAdapter = new ExtendedAdapter({
|
|
35461
36055
|
...baseAdapterConfig,
|
|
35462
|
-
supportedPositions: [
|
|
35463
|
-
{ asset: usdcToken, isDebt: true }
|
|
35464
|
-
],
|
|
36056
|
+
supportedPositions: [{ asset: usdcToken, isDebt: true }],
|
|
35465
36057
|
vaultIdExtended,
|
|
35466
36058
|
extendedContract: EXTENDED_CONTRACT,
|
|
35467
36059
|
extendedBackendWriteUrl,
|
|
@@ -35518,11 +36110,11 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1, e
|
|
|
35518
36110
|
asset: wbtcToken.address
|
|
35519
36111
|
});
|
|
35520
36112
|
vaultSettings.leafAdapters.push(() => vesuMultiplyAdapter.getDepositLeaf());
|
|
36113
|
+
vaultSettings.leafAdapters.push(() => vesuMultiplyAdapter.getWithdrawLeaf());
|
|
36114
|
+
vaultSettings.leafAdapters.push(() => extendedAdapter.getDepositLeaf());
|
|
35521
36115
|
vaultSettings.leafAdapters.push(
|
|
35522
|
-
() =>
|
|
36116
|
+
() => extendedAdapter.getSwapFromLegacyLeaf()
|
|
35523
36117
|
);
|
|
35524
|
-
vaultSettings.leafAdapters.push(() => extendedAdapter.getDepositLeaf());
|
|
35525
|
-
vaultSettings.leafAdapters.push(() => extendedAdapter.getSwapFromLegacyLeaf());
|
|
35526
36118
|
vaultSettings.leafAdapters.push(() => avnuAdapter.getDepositLeaf());
|
|
35527
36119
|
vaultSettings.leafAdapters.push(() => avnuAdapter.getWithdrawLeaf());
|
|
35528
36120
|
vaultSettings.leafAdapters.push(
|
|
@@ -35567,29 +36159,70 @@ function VaultDescription2(lstSymbol, underlyingSymbol) {
|
|
|
35567
36159
|
" to create leverage. Depositors receive vault shares that represent a proportional claim on the underlying assets and accrued yield."
|
|
35568
36160
|
] }),
|
|
35569
36161
|
/* @__PURE__ */ jsxs4("p", { style: { fontSize: "14px", lineHeight: "1.5", marginBottom: "16px" }, children: [
|
|
35570
|
-
"This vault uses Vesu for lending and borrowing. The oracle used by this pool is a
|
|
35571
|
-
|
|
36162
|
+
"This vault uses Vesu for lending and borrowing. The oracle used by this pool is a",
|
|
36163
|
+
" ",
|
|
36164
|
+
highlightTextWithLinks("conversion rate oracle", [
|
|
36165
|
+
{
|
|
36166
|
+
highlight: "conversion rate oracle",
|
|
36167
|
+
link: "https://docs.pragma.build/starknet/development#conversion-rate"
|
|
36168
|
+
}
|
|
36169
|
+
]),
|
|
35572
36170
|
" ",
|
|
35573
36171
|
"which is resilient to liquidity issues and price volatility, hence reducing the risk of liquidation. However, overtime, if left un-monitored, debt can increase enough to trigger a liquidation. But no worries, our continuous monitoring systems look for situations with reduced health factor and balance collateral/debt to bring it back to safe levels. With Troves, you can have a peaceful sleep."
|
|
35574
36172
|
] }),
|
|
35575
|
-
/* @__PURE__ */ jsx5(
|
|
35576
|
-
|
|
35577
|
-
|
|
35578
|
-
|
|
35579
|
-
|
|
35580
|
-
|
|
35581
|
-
|
|
35582
|
-
|
|
35583
|
-
|
|
35584
|
-
|
|
36173
|
+
/* @__PURE__ */ jsx5(
|
|
36174
|
+
"div",
|
|
36175
|
+
{
|
|
36176
|
+
style: {
|
|
36177
|
+
backgroundColor: "#222",
|
|
36178
|
+
padding: "10px",
|
|
36179
|
+
borderRadius: "8px",
|
|
36180
|
+
marginBottom: "20px",
|
|
36181
|
+
border: "1px solid #444"
|
|
36182
|
+
},
|
|
36183
|
+
children: /* @__PURE__ */ jsxs4("p", { style: { fontSize: "13px", color: "#ccc" }, children: [
|
|
36184
|
+
/* @__PURE__ */ jsx5("strong", { children: "Withdrawals:" }),
|
|
36185
|
+
" Requests can take up to",
|
|
36186
|
+
" ",
|
|
36187
|
+
/* @__PURE__ */ jsx5("strong", { children: "1-2 hours" }),
|
|
36188
|
+
" to process as the vault unwinds and settles routing."
|
|
36189
|
+
] })
|
|
36190
|
+
}
|
|
36191
|
+
),
|
|
36192
|
+
/* @__PURE__ */ jsx5(
|
|
36193
|
+
"div",
|
|
36194
|
+
{
|
|
36195
|
+
style: {
|
|
36196
|
+
backgroundColor: "#222",
|
|
36197
|
+
padding: "10px",
|
|
36198
|
+
borderRadius: "8px",
|
|
36199
|
+
marginBottom: "20px",
|
|
36200
|
+
border: "1px solid #444"
|
|
36201
|
+
},
|
|
36202
|
+
children: /* @__PURE__ */ jsxs4("p", { style: { fontSize: "13px", color: "#ccc" }, children: [
|
|
36203
|
+
/* @__PURE__ */ jsx5("strong", { children: "Debt limits:" }),
|
|
36204
|
+
" Pools on Vesu have debt caps that are gradually increased over time. Until caps are raised, deposited Tokens remain in the vault, generating a shared net return for all depositors. There is no additional fee taken by Troves on Yield token's APY, its only on added gain."
|
|
36205
|
+
] })
|
|
36206
|
+
}
|
|
36207
|
+
)
|
|
35585
36208
|
] });
|
|
35586
36209
|
}
|
|
35587
36210
|
var re7UsdcPrimeDevansh = {
|
|
35588
|
-
vaultAddress: ContractAddr.from(
|
|
35589
|
-
|
|
35590
|
-
|
|
35591
|
-
|
|
35592
|
-
|
|
36211
|
+
vaultAddress: ContractAddr.from(
|
|
36212
|
+
"0x058905be22d6a81792df79425dc9641cf3e1b77f36748631b7d7e5d713a32b55"
|
|
36213
|
+
),
|
|
36214
|
+
manager: ContractAddr.from(
|
|
36215
|
+
"0x02648d703783feb2d967cf0520314cb5aa800d69a9426f3e3b317395af44de16"
|
|
36216
|
+
),
|
|
36217
|
+
vaultAllocator: ContractAddr.from(
|
|
36218
|
+
"0x07d533c838eab6a4d854dd3aea96a55993fccd35821921970d00bde946b63b6f"
|
|
36219
|
+
),
|
|
36220
|
+
redeemRequestNFT: ContractAddr.from(
|
|
36221
|
+
"0x01ef91f08fb99729c00f82fc6e0ece37917bcc43952596c19996259dc8adbbba"
|
|
36222
|
+
),
|
|
36223
|
+
aumOracle: ContractAddr.from(
|
|
36224
|
+
"0x030b6acfec162f5d6e72b8a4d2798aedce78fb39de78a8f549f7cd277ae8bc8d"
|
|
36225
|
+
),
|
|
35593
36226
|
leafAdapters: [],
|
|
35594
36227
|
adapters: [],
|
|
35595
36228
|
targetHealthFactor: 1.4,
|
|
@@ -35601,13 +36234,29 @@ var re7UsdcPrimeDevansh = {
|
|
|
35601
36234
|
"0.001",
|
|
35602
36235
|
Global.getDefaultTokens().find((token) => token.symbol === "WBTC").decimals
|
|
35603
36236
|
),
|
|
35604
|
-
borrowable_assets: [
|
|
36237
|
+
borrowable_assets: [
|
|
36238
|
+
Global.getDefaultTokens().find((token) => token.symbol === "WBTC")
|
|
36239
|
+
],
|
|
35605
36240
|
minimumWBTCDifferenceForAvnuSwap: MINIMUM_WBTC_DIFFERENCE_FOR_AVNU_SWAP,
|
|
35606
36241
|
walletAddress: WALLET_ADDRESS
|
|
35607
36242
|
};
|
|
35608
36243
|
var VesuExtendedTestStrategies = (extendedBackendReadUrl, extendedBackendWriteUrl, vaultIdExtended, minimumExtendedMovementAmount, minimumVesuMovementAmount, minimumExtendedRetriesDelayForOrderStatus, minimumExtendedPriceDifferenceForSwapOpen, maximumExtendedPriceDifferenceForSwapClosing) => {
|
|
35609
36244
|
return [
|
|
35610
|
-
getStrategySettingsVesuExtended(
|
|
36245
|
+
getStrategySettingsVesuExtended(
|
|
36246
|
+
"WBTC",
|
|
36247
|
+
"USDC",
|
|
36248
|
+
re7UsdcPrimeDevansh,
|
|
36249
|
+
false,
|
|
36250
|
+
false,
|
|
36251
|
+
extendedBackendReadUrl,
|
|
36252
|
+
extendedBackendWriteUrl,
|
|
36253
|
+
vaultIdExtended,
|
|
36254
|
+
minimumExtendedMovementAmount,
|
|
36255
|
+
minimumVesuMovementAmount,
|
|
36256
|
+
minimumExtendedRetriesDelayForOrderStatus,
|
|
36257
|
+
minimumExtendedPriceDifferenceForSwapOpen,
|
|
36258
|
+
maximumExtendedPriceDifferenceForSwapClosing
|
|
36259
|
+
)
|
|
35611
36260
|
];
|
|
35612
36261
|
};
|
|
35613
36262
|
function getStrategySettingsVesuExtended(lstSymbol, underlyingSymbol, addresses, isPreview = false, isLST, extendedBackendReadUrl, extendedBackendWriteUrl, vaultIdExtended, minimumExtendedMovementAmount, minimumVesuMovementAmount, minimumExtendedRetriesDelayForOrderStatus, minimumExtendedPriceDifferenceForSwapOpen, maximumExtendedPriceDifferenceForSwapClosing) {
|
|
@@ -35617,8 +36266,25 @@ function getStrategySettingsVesuExtended(lstSymbol, underlyingSymbol, addresses,
|
|
|
35617
36266
|
address: addresses.vaultAddress,
|
|
35618
36267
|
launchBlock: 0,
|
|
35619
36268
|
type: "Other",
|
|
35620
|
-
depositTokens: [
|
|
35621
|
-
|
|
36269
|
+
depositTokens: [
|
|
36270
|
+
Global.getDefaultTokens().find(
|
|
36271
|
+
(token) => token.symbol === underlyingSymbol
|
|
36272
|
+
)
|
|
36273
|
+
],
|
|
36274
|
+
additionalInfo: getLooperSettings2(
|
|
36275
|
+
lstSymbol,
|
|
36276
|
+
underlyingSymbol,
|
|
36277
|
+
addresses,
|
|
36278
|
+
VesuPools.Re7USDCPrime,
|
|
36279
|
+
extendedBackendReadUrl,
|
|
36280
|
+
extendedBackendWriteUrl,
|
|
36281
|
+
vaultIdExtended,
|
|
36282
|
+
minimumExtendedMovementAmount,
|
|
36283
|
+
minimumVesuMovementAmount,
|
|
36284
|
+
minimumExtendedRetriesDelayForOrderStatus,
|
|
36285
|
+
minimumExtendedPriceDifferenceForSwapOpen,
|
|
36286
|
+
maximumExtendedPriceDifferenceForSwapClosing
|
|
36287
|
+
),
|
|
35622
36288
|
risk: {
|
|
35623
36289
|
riskFactor: _riskFactor3,
|
|
35624
36290
|
netRisk: _riskFactor3.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor3.reduce((acc, curr) => acc + curr.weight, 0),
|
|
@@ -39942,8 +40608,10 @@ export {
|
|
|
39942
40608
|
calculateBTCPriceDelta,
|
|
39943
40609
|
calculateDebtAmount,
|
|
39944
40610
|
calculateDebtReductionAmountForWithdrawal,
|
|
40611
|
+
calculateDeltaDebtAmount,
|
|
39945
40612
|
calculateExposureDelta,
|
|
39946
40613
|
calculateExtendedLevergae,
|
|
40614
|
+
calculatePositionToCloseToWithdrawAmount,
|
|
39947
40615
|
calculateVesUPositionSizeGivenExtended,
|
|
39948
40616
|
calculateVesuLeverage,
|
|
39949
40617
|
calculateWBTCAmountToMaintainLTV,
|