@strkfarm/sdk 1.1.28 → 1.1.31
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 +255 -45
- package/dist/index.browser.mjs +255 -45
- package/dist/index.d.ts +32 -4
- package/dist/index.js +263 -51
- package/dist/index.mjs +261 -51
- package/package.json +1 -1
- package/src/strategies/universal-adapters/adapter-utils.ts +2 -0
- package/src/strategies/universal-adapters/common-adapter.ts +6 -6
- package/src/strategies/universal-adapters/vesu-adapter.ts +29 -21
- package/src/strategies/universal-lst-muliplier-strategy.tsx +263 -17
- package/src/strategies/universal-strategy.tsx +13 -2
|
@@ -28641,6 +28641,7 @@ ${r2}}` : "}", l2;
|
|
|
28641
28641
|
var index_browser_exports = {};
|
|
28642
28642
|
__export(index_browser_exports, {
|
|
28643
28643
|
AUMTypes: () => AUMTypes,
|
|
28644
|
+
AVNU_EXCHANGE: () => AVNU_EXCHANGE,
|
|
28644
28645
|
AVNU_MIDDLEWARE: () => AVNU_MIDDLEWARE,
|
|
28645
28646
|
AutoCompounderSTRK: () => AutoCompounderSTRK,
|
|
28646
28647
|
AvnuWrapper: () => AvnuWrapper,
|
|
@@ -28679,6 +28680,7 @@ ${r2}}` : "}", l2;
|
|
|
28679
28680
|
UniversalStrategies: () => UniversalStrategies,
|
|
28680
28681
|
UniversalStrategy: () => UniversalStrategy,
|
|
28681
28682
|
VESU_SINGLETON: () => VESU_SINGLETON,
|
|
28683
|
+
VESU_V2_MODIFY_POSITION_SANITIZER: () => VESU_V2_MODIFY_POSITION_SANITIZER,
|
|
28682
28684
|
VesuAdapter: () => VesuAdapter,
|
|
28683
28685
|
VesuAmountDenomination: () => VesuAmountDenomination,
|
|
28684
28686
|
VesuAmountType: () => VesuAmountType,
|
|
@@ -83040,9 +83042,11 @@ spurious results.`);
|
|
|
83040
83042
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
83041
83043
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
83042
83044
|
var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
|
|
83045
|
+
var VESU_V2_MODIFY_POSITION_SANITIZER = ContractAddr.from("0x04Bf71F2BD9D6F8819057c9dD524F0d5fbc38317C00500d7b9a0FdCf01195066");
|
|
83043
83046
|
var SIMPLE_SANITIZER_VESU_V1_DELEGATIONS = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
|
|
83044
83047
|
var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
|
|
83045
83048
|
var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
|
|
83049
|
+
var AVNU_EXCHANGE = ContractAddr.from("0x04270219d365d6b017231b52e92b3fb5d7c8378b05e9abc97724537a80e93b0f");
|
|
83046
83050
|
var VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
|
|
83047
83051
|
function toBigInt3(value) {
|
|
83048
83052
|
if (typeof value === "string") {
|
|
@@ -83186,11 +83190,11 @@ spurious results.`);
|
|
|
83186
83190
|
};
|
|
83187
83191
|
};
|
|
83188
83192
|
}
|
|
83189
|
-
getAvnuAdapter(fromToken, toToken, id) {
|
|
83193
|
+
getAvnuAdapter(fromToken, toToken, id, isMiddleware) {
|
|
83190
83194
|
return () => ({
|
|
83191
83195
|
leaf: this.constructSimpleLeafData({
|
|
83192
83196
|
id,
|
|
83193
|
-
target: AVNU_MIDDLEWARE,
|
|
83197
|
+
target: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
|
|
83194
83198
|
method: "multi_route_swap",
|
|
83195
83199
|
packedArguments: [
|
|
83196
83200
|
fromToken.toBigInt(),
|
|
@@ -83198,15 +83202,15 @@ spurious results.`);
|
|
|
83198
83202
|
this.config.vaultAllocator.toBigInt()
|
|
83199
83203
|
]
|
|
83200
83204
|
}),
|
|
83201
|
-
callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
|
|
83205
|
+
callConstructor: this.getAvnuCall(fromToken, toToken, isMiddleware).bind(this)
|
|
83202
83206
|
});
|
|
83203
83207
|
}
|
|
83204
|
-
getAvnuCall(fromToken, toToken) {
|
|
83208
|
+
getAvnuCall(fromToken, toToken, isMiddleware) {
|
|
83205
83209
|
return (params) => {
|
|
83206
83210
|
return {
|
|
83207
83211
|
sanitizer: SIMPLE_SANITIZER,
|
|
83208
83212
|
call: {
|
|
83209
|
-
contractAddress: AVNU_MIDDLEWARE,
|
|
83213
|
+
contractAddress: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
|
|
83210
83214
|
selector: hash_exports.getSelectorFromName("multi_route_swap"),
|
|
83211
83215
|
calldata: [
|
|
83212
83216
|
fromToken.toBigInt(),
|
|
@@ -87957,24 +87961,30 @@ spurious results.`);
|
|
|
87957
87961
|
this.VESU_MULTIPLY = ContractAddr.from("0x027fef272d0a9a3844767c851a64b36fe4f0115141d81134baade95d2b27b781");
|
|
87958
87962
|
this.getModifyPosition = () => {
|
|
87959
87963
|
const positionData = [0n];
|
|
87960
|
-
const
|
|
87961
|
-
|
|
87962
|
-
// pool id
|
|
87964
|
+
const { addr, isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
87965
|
+
const commonPackedData = [
|
|
87963
87966
|
toBigInt3(this.config.collateral.address.toString()),
|
|
87964
87967
|
// collateral
|
|
87965
87968
|
toBigInt3(this.config.debt.address.toString()),
|
|
87966
87969
|
// debt
|
|
87967
|
-
toBigInt3(this.config.vaultAllocator.toString())
|
|
87970
|
+
toBigInt3(this.config.vaultAllocator.toString())
|
|
87968
87971
|
// vault allocator
|
|
87972
|
+
];
|
|
87973
|
+
const packedArguments = isV2 ? [
|
|
87974
|
+
...commonPackedData
|
|
87975
|
+
] : [
|
|
87976
|
+
toBigInt3(this.config.poolId.toString()),
|
|
87977
|
+
// pool id
|
|
87978
|
+
...commonPackedData,
|
|
87969
87979
|
toBigInt3(positionData.length),
|
|
87970
87980
|
...positionData
|
|
87971
87981
|
];
|
|
87972
87982
|
const output = this.constructSimpleLeafData({
|
|
87973
87983
|
id: this.config.id,
|
|
87974
|
-
target:
|
|
87984
|
+
target: addr,
|
|
87975
87985
|
method: "modify_position",
|
|
87976
87986
|
packedArguments
|
|
87977
|
-
});
|
|
87987
|
+
}, isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER);
|
|
87978
87988
|
return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
|
|
87979
87989
|
};
|
|
87980
87990
|
this.getModifyPositionCall = (params) => {
|
|
@@ -88015,7 +88025,7 @@ spurious results.`);
|
|
|
88015
88025
|
}
|
|
88016
88026
|
});
|
|
88017
88027
|
return {
|
|
88018
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
88028
|
+
sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
|
|
88019
88029
|
call: {
|
|
88020
88030
|
contractAddress: ContractAddr.from(contract.address),
|
|
88021
88031
|
selector: hash_exports.getSelectorFromName("modify_position"),
|
|
@@ -88025,25 +88035,27 @@ spurious results.`);
|
|
|
88025
88035
|
}
|
|
88026
88036
|
};
|
|
88027
88037
|
};
|
|
88028
|
-
this.getMultiplyAdapter = () => {
|
|
88029
|
-
|
|
88030
|
-
|
|
88031
|
-
|
|
88032
|
-
|
|
88033
|
-
|
|
88034
|
-
|
|
88035
|
-
|
|
88036
|
-
|
|
88037
|
-
|
|
88038
|
-
|
|
88039
|
-
|
|
88040
|
-
|
|
88041
|
-
|
|
88042
|
-
|
|
88043
|
-
|
|
88044
|
-
|
|
88045
|
-
|
|
88046
|
-
|
|
88038
|
+
this.getMultiplyAdapter = (id) => {
|
|
88039
|
+
return () => {
|
|
88040
|
+
const packedArguments = [
|
|
88041
|
+
toBigInt3(this.config.poolId.toString()),
|
|
88042
|
+
// pool id
|
|
88043
|
+
toBigInt3(this.config.collateral.address.toString()),
|
|
88044
|
+
// collateral
|
|
88045
|
+
toBigInt3(this.config.debt.address.toString()),
|
|
88046
|
+
// debt
|
|
88047
|
+
toBigInt3(this.config.vaultAllocator.toString())
|
|
88048
|
+
// vault allocator
|
|
88049
|
+
];
|
|
88050
|
+
const { isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
88051
|
+
const output = this.constructSimpleLeafData({
|
|
88052
|
+
id,
|
|
88053
|
+
target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
|
|
88054
|
+
method: "modify_lever",
|
|
88055
|
+
packedArguments
|
|
88056
|
+
}, SIMPLE_SANITIZER_V2);
|
|
88057
|
+
return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
|
|
88058
|
+
};
|
|
88047
88059
|
};
|
|
88048
88060
|
this.getMultiplyCall = (params) => {
|
|
88049
88061
|
const isIncrease = params.isIncrease;
|
|
@@ -90732,7 +90744,11 @@ spurious results.`);
|
|
|
90732
90744
|
id: "defispring"
|
|
90733
90745
|
}] };
|
|
90734
90746
|
}
|
|
90747
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
90748
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
90749
|
+
rewardAPYs.push(0);
|
|
90735
90750
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
90751
|
+
weights.push(unusedBalanceAPY.weight);
|
|
90736
90752
|
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
90737
90753
|
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
90738
90754
|
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
@@ -90747,6 +90763,12 @@ spurious results.`);
|
|
|
90747
90763
|
id: "defispring"
|
|
90748
90764
|
}] };
|
|
90749
90765
|
}
|
|
90766
|
+
async getUnusedBalanceAPY() {
|
|
90767
|
+
return {
|
|
90768
|
+
apy: 0,
|
|
90769
|
+
weight: 0
|
|
90770
|
+
};
|
|
90771
|
+
}
|
|
90750
90772
|
computeAPY(apys, weights, currentAUM) {
|
|
90751
90773
|
assert3(apys.length === weights.length, "APYs and weights length mismatch");
|
|
90752
90774
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
@@ -91241,7 +91263,7 @@ spurious results.`);
|
|
|
91241
91263
|
vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
|
|
91242
91264
|
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
91243
91265
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
91244
|
-
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS
|
|
91266
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */, true).bind(commonAdapter));
|
|
91245
91267
|
return vaultSettings;
|
|
91246
91268
|
}
|
|
91247
91269
|
var _riskFactor3 = [
|
|
@@ -91594,6 +91616,160 @@ spurious results.`);
|
|
|
91594
91616
|
logger2.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
91595
91617
|
return price;
|
|
91596
91618
|
}
|
|
91619
|
+
async getAvnuSwapMultiplyCall(params) {
|
|
91620
|
+
return this._getAvnuDepositSwapLegCall({
|
|
91621
|
+
...params,
|
|
91622
|
+
minHF: 1.02
|
|
91623
|
+
});
|
|
91624
|
+
}
|
|
91625
|
+
async _getAvnuDepositSwapLegCall(params) {
|
|
91626
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall params: ${JSON.stringify(params)}`);
|
|
91627
|
+
assert3(params.isDeposit, "Only deposit is supported in _getAvnuDepositSwapLegCall");
|
|
91628
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
91629
|
+
const legLTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
91630
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall legLTV: ${legLTV}`);
|
|
91631
|
+
const existingPositions = await vesuAdapter1.getPositions(this.config);
|
|
91632
|
+
const collateralisation = await vesuAdapter1.getCollateralization(this.config);
|
|
91633
|
+
const existingCollateralInfo = existingPositions[0];
|
|
91634
|
+
const existingDebtInfo = existingPositions[1];
|
|
91635
|
+
logger2.debug(`${this.getTag()}::_getAvnuDepositSwapLegCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
|
|
91636
|
+
existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
|
|
91637
|
+
const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
|
|
91638
|
+
const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
|
|
91639
|
+
logger2.debug(`${this.getTag()}::_getAvnuDepositSwapLegCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
|
|
91640
|
+
const totalCollateral = existingCollateralInfo.amount.plus(params.leg1DepositAmount);
|
|
91641
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall totalCollateral: ${totalCollateral}`);
|
|
91642
|
+
const totalDebtAmount = totalCollateral.multipliedBy(collateralPrice).multipliedBy(legLTV).dividedBy(debtPrice).dividedBy(params.minHF);
|
|
91643
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall totalDebtAmount: ${totalDebtAmount}`);
|
|
91644
|
+
const debtAmount = totalDebtAmount.minus(existingDebtInfo.amount);
|
|
91645
|
+
if (debtAmount.lt(0)) {
|
|
91646
|
+
const lstDEXPrice = await this.getLSTDexPrice();
|
|
91647
|
+
const debtAmountInLST = debtAmount.abs().dividedBy(lstDEXPrice);
|
|
91648
|
+
const calls = await this.getVesuMultiplyCall({
|
|
91649
|
+
isDeposit: false,
|
|
91650
|
+
leg1DepositAmount: debtAmountInLST
|
|
91651
|
+
});
|
|
91652
|
+
assert3(calls.length == 1, "Expected 1 call for unwind");
|
|
91653
|
+
return calls[0];
|
|
91654
|
+
}
|
|
91655
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall debtAmount: ${debtAmount}`);
|
|
91656
|
+
const STEP0 = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
91657
|
+
const manage0Info = this.getProofs(STEP0);
|
|
91658
|
+
const manageCall0 = manage0Info.callConstructor({
|
|
91659
|
+
amount: params.leg1DepositAmount
|
|
91660
|
+
});
|
|
91661
|
+
const STEP1 = "vesu_leg1" /* VESU_LEG1 */;
|
|
91662
|
+
const manage1Info = this.getProofs(STEP1);
|
|
91663
|
+
const manageCall1 = manage1Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
|
|
91664
|
+
collateralAmount: params.leg1DepositAmount,
|
|
91665
|
+
isAddCollateral: params.isDeposit,
|
|
91666
|
+
debtAmount,
|
|
91667
|
+
isBorrow: params.isDeposit
|
|
91668
|
+
}));
|
|
91669
|
+
const proofIds = [STEP0, STEP1];
|
|
91670
|
+
const manageCalls = [manageCall0, manageCall1];
|
|
91671
|
+
if (debtAmount.gt(0)) {
|
|
91672
|
+
const STEP2 = "avnu_multiply_approve_deposit" /* AVNU_MULTIPLY_APPROVE_DEPOSIT */;
|
|
91673
|
+
const manage2Info = this.getProofs(STEP2);
|
|
91674
|
+
const manageCall2 = manage2Info.callConstructor({
|
|
91675
|
+
amount: debtAmount
|
|
91676
|
+
});
|
|
91677
|
+
const debtTokenInfo = vesuAdapter1.config.debt;
|
|
91678
|
+
const lstTokenInfo = this.asset();
|
|
91679
|
+
const avnuModule = new AvnuWrapper();
|
|
91680
|
+
const quote = await avnuModule.getQuotes(
|
|
91681
|
+
debtTokenInfo.address.address,
|
|
91682
|
+
lstTokenInfo.address.address,
|
|
91683
|
+
debtAmount.toWei(),
|
|
91684
|
+
this.metadata.additionalInfo.vaultAllocator.address
|
|
91685
|
+
);
|
|
91686
|
+
const minAmount = await this._getMinOutputAmountLSTBuy(debtAmount);
|
|
91687
|
+
const minAmountWei = minAmount.toWei();
|
|
91688
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall minAmount: ${minAmount}`);
|
|
91689
|
+
const swapInfo = await avnuModule.getSwapInfo(
|
|
91690
|
+
quote,
|
|
91691
|
+
this.metadata.additionalInfo.vaultAllocator.address,
|
|
91692
|
+
0,
|
|
91693
|
+
this.address.address,
|
|
91694
|
+
minAmountWei
|
|
91695
|
+
);
|
|
91696
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall swapInfo: ${JSON.stringify(swapInfo)}`);
|
|
91697
|
+
const STEP3 = "avnu_multiply_swap_deposit" /* AVNU_MULTIPLY_SWAP_DEPOSIT */;
|
|
91698
|
+
const manage3Info = this.getProofs(STEP3);
|
|
91699
|
+
const manageCall3 = manage3Info.callConstructor({
|
|
91700
|
+
props: swapInfo
|
|
91701
|
+
});
|
|
91702
|
+
proofIds.push(STEP2);
|
|
91703
|
+
proofIds.push(STEP3);
|
|
91704
|
+
manageCalls.push(manageCall2, manageCall3);
|
|
91705
|
+
const newCollateral = minAmount.plus(totalCollateral);
|
|
91706
|
+
const newHF = newCollateral.multipliedBy(collateralPrice).multipliedBy(legLTV).dividedBy(totalDebtAmount).dividedBy(debtPrice).toNumber();
|
|
91707
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
91708
|
+
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
91709
|
+
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
91710
|
+
const STEP4 = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
91711
|
+
const manage4Info = this.getProofs(STEP4);
|
|
91712
|
+
const manageCall4 = manage4Info.callConstructor({
|
|
91713
|
+
amount: minAmount
|
|
91714
|
+
});
|
|
91715
|
+
const STEP5 = "vesu_leg1" /* VESU_LEG1 */;
|
|
91716
|
+
const manage5Info = this.getProofs(STEP5);
|
|
91717
|
+
const manageCall5 = manage5Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
|
|
91718
|
+
collateralAmount: minAmount,
|
|
91719
|
+
isAddCollateral: true,
|
|
91720
|
+
debtAmount: Web3Number.fromWei("0", this.asset().decimals),
|
|
91721
|
+
isBorrow: params.isDeposit
|
|
91722
|
+
}));
|
|
91723
|
+
proofIds.push(STEP4, STEP5);
|
|
91724
|
+
manageCalls.push(manageCall4, manageCall5);
|
|
91725
|
+
}
|
|
91726
|
+
}
|
|
91727
|
+
const manageCall = this.getManageCall(proofIds, manageCalls);
|
|
91728
|
+
return manageCall;
|
|
91729
|
+
}
|
|
91730
|
+
// todo unwind or not deposit when the yield is bad.
|
|
91731
|
+
async getLSTMultiplierRebalanceCall() {
|
|
91732
|
+
const positions = await this.getVaultPositions();
|
|
91733
|
+
assert3(positions.length == 3, "Rebalance call is only supported for 3 positions");
|
|
91734
|
+
const existingCollateralInfo = positions[0];
|
|
91735
|
+
const existingDebtInfo = positions[1];
|
|
91736
|
+
const unusedBalance = positions[2];
|
|
91737
|
+
const [healthFactor] = await this.getVesuHealthFactors();
|
|
91738
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
91739
|
+
const legLTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
91740
|
+
const collateralisation = await vesuAdapter1.getCollateralization(this.config);
|
|
91741
|
+
logger2.debug(`${this.getTag()}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
|
|
91742
|
+
existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
|
|
91743
|
+
const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
|
|
91744
|
+
const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
|
|
91745
|
+
logger2.debug(`${this.getTag()}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
|
|
91746
|
+
const isHFTooLow = healthFactor < this.metadata.additionalInfo.minHealthFactor;
|
|
91747
|
+
const isHFTooHigh = healthFactor > this.metadata.additionalInfo.targetHealthFactor + 0.05;
|
|
91748
|
+
if (isHFTooLow || isHFTooHigh) {
|
|
91749
|
+
const manageCall = await this._getAvnuDepositSwapLegCall({
|
|
91750
|
+
isDeposit: true,
|
|
91751
|
+
leg1DepositAmount: unusedBalance.amount,
|
|
91752
|
+
minHF: 1.02
|
|
91753
|
+
// todo, shouldnt use this 1.02 HF, if there isn;t more looping left.
|
|
91754
|
+
});
|
|
91755
|
+
return { shouldRebalance: true, manageCall };
|
|
91756
|
+
} else {
|
|
91757
|
+
return { shouldRebalance: false, manageCall: void 0 };
|
|
91758
|
+
}
|
|
91759
|
+
}
|
|
91760
|
+
//
|
|
91761
|
+
async _getMinOutputAmountLSTBuy(amountInUnderlying) {
|
|
91762
|
+
const lstTruePrice = await this.getLSTExchangeRate();
|
|
91763
|
+
const minOutputAmount = amountInUnderlying.dividedBy(lstTruePrice);
|
|
91764
|
+
return minOutputAmount;
|
|
91765
|
+
}
|
|
91766
|
+
async _getMinOutputAmountLSTSell(amountInLST) {
|
|
91767
|
+
const lstTruePrice = await this.getLSTExchangeRate();
|
|
91768
|
+
const minOutputAmount = amountInLST.multipliedBy(lstTruePrice).multipliedBy(0.995);
|
|
91769
|
+
return minOutputAmount;
|
|
91770
|
+
}
|
|
91771
|
+
// todo add a function to findout max borrowable amount without fucking yield
|
|
91772
|
+
// if the current net yield < LST yield, add a function to calculate how much to unwind.
|
|
91597
91773
|
/**
|
|
91598
91774
|
* Uses vesu's multiple call to create leverage on LST
|
|
91599
91775
|
* Deposit amount is in LST
|
|
@@ -91645,12 +91821,40 @@ spurious results.`);
|
|
|
91645
91821
|
async getLSTAPR(_address) {
|
|
91646
91822
|
try {
|
|
91647
91823
|
const vesuAdapter1 = this.getVesuAdapters()[0];
|
|
91648
|
-
|
|
91824
|
+
const apr = await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
|
|
91825
|
+
if (!apr) {
|
|
91826
|
+
throw new Error("Failed to get LST APR");
|
|
91827
|
+
}
|
|
91828
|
+
return apr;
|
|
91649
91829
|
} catch (error2) {
|
|
91650
91830
|
logger2.warn(`${this.getTag()}: Failed to get LST APR: ${error2}`);
|
|
91651
91831
|
return 0;
|
|
91652
91832
|
}
|
|
91653
91833
|
}
|
|
91834
|
+
// todo undo this
|
|
91835
|
+
async netAPY() {
|
|
91836
|
+
const { net, splits } = await super.netAPY();
|
|
91837
|
+
let _net = net;
|
|
91838
|
+
if (this.asset().symbol == "xWBTC") {
|
|
91839
|
+
const debtToken = this.getVesuAdapters()[0].config.debt;
|
|
91840
|
+
const lstAPY = await this.getLSTAPR(debtToken.address);
|
|
91841
|
+
_net = lstAPY * 5;
|
|
91842
|
+
}
|
|
91843
|
+
return {
|
|
91844
|
+
net: _net,
|
|
91845
|
+
splits
|
|
91846
|
+
};
|
|
91847
|
+
}
|
|
91848
|
+
async getUnusedBalanceAPY() {
|
|
91849
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
91850
|
+
const vesuAdapter = this.getVesuAdapters()[0];
|
|
91851
|
+
const underlying = vesuAdapter.config.debt;
|
|
91852
|
+
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
91853
|
+
return {
|
|
91854
|
+
apy: lstAPY,
|
|
91855
|
+
weight: unusedBalance.usdValue
|
|
91856
|
+
};
|
|
91857
|
+
}
|
|
91654
91858
|
async getLSTExchangeRate() {
|
|
91655
91859
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
91656
91860
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -91681,7 +91885,7 @@ spurious results.`);
|
|
|
91681
91885
|
const proofsIDs = [];
|
|
91682
91886
|
const manageCalls = [];
|
|
91683
91887
|
if (params.marginAmount.greaterThan(0)) {
|
|
91684
|
-
const STEP1_ID = "
|
|
91888
|
+
const STEP1_ID = "multiple_approve" /* MULTIPLE_APPROVE */;
|
|
91685
91889
|
const manage1Info = this.getProofs(STEP1_ID);
|
|
91686
91890
|
const depositAmount = params.marginAmount;
|
|
91687
91891
|
const manageCall1 = manage1Info.callConstructor({
|
|
@@ -91811,7 +92015,7 @@ spurious results.`);
|
|
|
91811
92015
|
collateral: lstToken,
|
|
91812
92016
|
debt: underlyingToken,
|
|
91813
92017
|
vaultAllocator: vaultSettings.vaultAllocator,
|
|
91814
|
-
id: "
|
|
92018
|
+
id: "vesu_leg1" /* VESU_LEG1 */
|
|
91815
92019
|
});
|
|
91816
92020
|
const commonAdapter = new CommonAdapter({
|
|
91817
92021
|
manager: vaultSettings.manager,
|
|
@@ -91820,10 +92024,10 @@ spurious results.`);
|
|
|
91820
92024
|
vaultAddress: vaultSettings.vaultAddress,
|
|
91821
92025
|
vaultAllocator: vaultSettings.vaultAllocator
|
|
91822
92026
|
});
|
|
91823
|
-
const { isV2 } = getVesuSingletonAddress(pool1);
|
|
92027
|
+
const { isV2, addr: poolAddr } = getVesuSingletonAddress(pool1);
|
|
91824
92028
|
const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
|
|
91825
|
-
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "
|
|
91826
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
|
|
92029
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "multiple_approve" /* MULTIPLE_APPROVE */).bind(commonAdapter));
|
|
92030
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter("multiply_vesu" /* MULTIPLY_VESU */).bind(vesuAdapterLST));
|
|
91827
92031
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
|
|
91828
92032
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
|
|
91829
92033
|
vaultSettings.adapters.push(...[{
|
|
@@ -91833,12 +92037,18 @@ spurious results.`);
|
|
|
91833
92037
|
id: "common_adapter" /* COMMON */,
|
|
91834
92038
|
adapter: commonAdapter
|
|
91835
92039
|
}]);
|
|
92040
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(underlyingToken.address, AVNU_EXCHANGE, "avnu_multiply_approve_deposit" /* AVNU_MULTIPLY_APPROVE_DEPOSIT */).bind(commonAdapter));
|
|
92041
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(underlyingToken.address, lstToken.address, "avnu_multiply_swap_deposit" /* AVNU_MULTIPLY_SWAP_DEPOSIT */, false).bind(commonAdapter));
|
|
92042
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, AVNU_EXCHANGE, "avnu_multiply_approve_withdraw" /* AVNU_MULTIPLY_APPROVE_WITHDRAW */).bind(commonAdapter));
|
|
92043
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(lstToken.address, underlyingToken.address, "avnu_multiply_swap_withdraw" /* AVNU_MULTIPLY_SWAP_WITHDRAW */, false).bind(commonAdapter));
|
|
92044
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
92045
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
91836
92046
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
|
|
91837
92047
|
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
|
|
91838
92048
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterLST));
|
|
91839
92049
|
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
91840
|
-
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address,
|
|
91841
|
-
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS
|
|
92050
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_EXCHANGE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
92051
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */, false).bind(commonAdapter));
|
|
91842
92052
|
return vaultSettings;
|
|
91843
92053
|
}
|
|
91844
92054
|
var AUDIT_URL4 = "https://docs.troves.fi/p/security#starknet-vault-kit";
|
|
@@ -91939,11 +92149,11 @@ spurious results.`);
|
|
|
91939
92149
|
minHealthFactor: 1.05
|
|
91940
92150
|
};
|
|
91941
92151
|
var hyperxLBTC = {
|
|
91942
|
-
vaultAddress: ContractAddr.from("
|
|
91943
|
-
manager: ContractAddr.from("
|
|
91944
|
-
vaultAllocator: ContractAddr.from("
|
|
91945
|
-
redeemRequestNFT: ContractAddr.from("
|
|
91946
|
-
aumOracle: ContractAddr.from("
|
|
92152
|
+
vaultAddress: ContractAddr.from("0x64cf24d4883fe569926419a0569ab34497c6956a1a308fa883257f7486d7030"),
|
|
92153
|
+
manager: ContractAddr.from("0x203530a4022a99b8f4b406aaf33b0849d43ad7422c1d5cc14ff8c667abec6c0"),
|
|
92154
|
+
vaultAllocator: ContractAddr.from("0x7dbc8ccd4eabce6ea6c19e0e5c9ccca3a93bd510303b9e071cbe25fc508546e"),
|
|
92155
|
+
redeemRequestNFT: ContractAddr.from("0x5ee66a39af9aef3d0d48982b4a63e8bd2a5bad021916bd87fb0eae3a26800b8"),
|
|
92156
|
+
aumOracle: ContractAddr.from("0x23d69e4391fa72d10e625e7575d8bddbb4aff96f04503f83fdde23123bf41d0"),
|
|
91947
92157
|
leafAdapters: [],
|
|
91948
92158
|
adapters: [],
|
|
91949
92159
|
targetHealthFactor: 1.1,
|