@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
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
AUMTypes: () => AUMTypes,
|
|
34
|
+
AVNU_EXCHANGE: () => AVNU_EXCHANGE,
|
|
34
35
|
AVNU_MIDDLEWARE: () => AVNU_MIDDLEWARE,
|
|
35
36
|
AutoCompounderSTRK: () => AutoCompounderSTRK,
|
|
36
37
|
AvnuWrapper: () => AvnuWrapper,
|
|
@@ -49,7 +50,7 @@ __export(index_exports, {
|
|
|
49
50
|
HyperLSTStrategies: () => HyperLSTStrategies,
|
|
50
51
|
ILending: () => ILending,
|
|
51
52
|
Initializable: () => Initializable,
|
|
52
|
-
LSTAPRService: () =>
|
|
53
|
+
LSTAPRService: () => LSTAPRService,
|
|
53
54
|
MarginType: () => MarginType,
|
|
54
55
|
Network: () => Network,
|
|
55
56
|
PRICE_ROUTER: () => PRICE_ROUTER,
|
|
@@ -76,6 +77,7 @@ __export(index_exports, {
|
|
|
76
77
|
UniversalStrategies: () => UniversalStrategies,
|
|
77
78
|
UniversalStrategy: () => UniversalStrategy,
|
|
78
79
|
VESU_SINGLETON: () => VESU_SINGLETON,
|
|
80
|
+
VESU_V2_MODIFY_POSITION_SANITIZER: () => VESU_V2_MODIFY_POSITION_SANITIZER,
|
|
79
81
|
VesuAdapter: () => VesuAdapter,
|
|
80
82
|
VesuAmountDenomination: () => VesuAmountDenomination,
|
|
81
83
|
VesuAmountType: () => VesuAmountType,
|
|
@@ -19125,9 +19127,11 @@ var import_starknet13 = require("starknet");
|
|
|
19125
19127
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
19126
19128
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
19127
19129
|
var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
|
|
19130
|
+
var VESU_V2_MODIFY_POSITION_SANITIZER = ContractAddr.from("0x04Bf71F2BD9D6F8819057c9dD524F0d5fbc38317C00500d7b9a0FdCf01195066");
|
|
19128
19131
|
var SIMPLE_SANITIZER_VESU_V1_DELEGATIONS = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
|
|
19129
19132
|
var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
|
|
19130
19133
|
var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
|
|
19134
|
+
var AVNU_EXCHANGE = ContractAddr.from("0x04270219d365d6b017231b52e92b3fb5d7c8378b05e9abc97724537a80e93b0f");
|
|
19131
19135
|
var VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
|
|
19132
19136
|
function toBigInt(value) {
|
|
19133
19137
|
if (typeof value === "string") {
|
|
@@ -19272,11 +19276,11 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
19272
19276
|
};
|
|
19273
19277
|
};
|
|
19274
19278
|
}
|
|
19275
|
-
getAvnuAdapter(fromToken, toToken, id) {
|
|
19279
|
+
getAvnuAdapter(fromToken, toToken, id, isMiddleware) {
|
|
19276
19280
|
return () => ({
|
|
19277
19281
|
leaf: this.constructSimpleLeafData({
|
|
19278
19282
|
id,
|
|
19279
|
-
target: AVNU_MIDDLEWARE,
|
|
19283
|
+
target: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
|
|
19280
19284
|
method: "multi_route_swap",
|
|
19281
19285
|
packedArguments: [
|
|
19282
19286
|
fromToken.toBigInt(),
|
|
@@ -19284,15 +19288,15 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
19284
19288
|
this.config.vaultAllocator.toBigInt()
|
|
19285
19289
|
]
|
|
19286
19290
|
}),
|
|
19287
|
-
callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
|
|
19291
|
+
callConstructor: this.getAvnuCall(fromToken, toToken, isMiddleware).bind(this)
|
|
19288
19292
|
});
|
|
19289
19293
|
}
|
|
19290
|
-
getAvnuCall(fromToken, toToken) {
|
|
19294
|
+
getAvnuCall(fromToken, toToken, isMiddleware) {
|
|
19291
19295
|
return (params) => {
|
|
19292
19296
|
return {
|
|
19293
19297
|
sanitizer: SIMPLE_SANITIZER,
|
|
19294
19298
|
call: {
|
|
19295
|
-
contractAddress: AVNU_MIDDLEWARE,
|
|
19299
|
+
contractAddress: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
|
|
19296
19300
|
selector: import_starknet14.hash.getSelectorFromName("multi_route_swap"),
|
|
19297
19301
|
calldata: [
|
|
19298
19302
|
fromToken.toBigInt(),
|
|
@@ -24046,24 +24050,30 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
24046
24050
|
this.VESU_MULTIPLY = ContractAddr.from("0x027fef272d0a9a3844767c851a64b36fe4f0115141d81134baade95d2b27b781");
|
|
24047
24051
|
this.getModifyPosition = () => {
|
|
24048
24052
|
const positionData = [0n];
|
|
24049
|
-
const
|
|
24050
|
-
|
|
24051
|
-
// pool id
|
|
24053
|
+
const { addr, isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
24054
|
+
const commonPackedData = [
|
|
24052
24055
|
toBigInt(this.config.collateral.address.toString()),
|
|
24053
24056
|
// collateral
|
|
24054
24057
|
toBigInt(this.config.debt.address.toString()),
|
|
24055
24058
|
// debt
|
|
24056
|
-
toBigInt(this.config.vaultAllocator.toString())
|
|
24059
|
+
toBigInt(this.config.vaultAllocator.toString())
|
|
24057
24060
|
// vault allocator
|
|
24061
|
+
];
|
|
24062
|
+
const packedArguments = isV2 ? [
|
|
24063
|
+
...commonPackedData
|
|
24064
|
+
] : [
|
|
24065
|
+
toBigInt(this.config.poolId.toString()),
|
|
24066
|
+
// pool id
|
|
24067
|
+
...commonPackedData,
|
|
24058
24068
|
toBigInt(positionData.length),
|
|
24059
24069
|
...positionData
|
|
24060
24070
|
];
|
|
24061
24071
|
const output = this.constructSimpleLeafData({
|
|
24062
24072
|
id: this.config.id,
|
|
24063
|
-
target:
|
|
24073
|
+
target: addr,
|
|
24064
24074
|
method: "modify_position",
|
|
24065
24075
|
packedArguments
|
|
24066
|
-
});
|
|
24076
|
+
}, isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER);
|
|
24067
24077
|
return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
|
|
24068
24078
|
};
|
|
24069
24079
|
this.getModifyPositionCall = (params) => {
|
|
@@ -24104,7 +24114,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
24104
24114
|
}
|
|
24105
24115
|
});
|
|
24106
24116
|
return {
|
|
24107
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
24117
|
+
sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
|
|
24108
24118
|
call: {
|
|
24109
24119
|
contractAddress: ContractAddr.from(contract.address),
|
|
24110
24120
|
selector: import_starknet15.hash.getSelectorFromName("modify_position"),
|
|
@@ -24114,25 +24124,27 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
24114
24124
|
}
|
|
24115
24125
|
};
|
|
24116
24126
|
};
|
|
24117
|
-
this.getMultiplyAdapter = () => {
|
|
24118
|
-
|
|
24119
|
-
|
|
24120
|
-
|
|
24121
|
-
|
|
24122
|
-
|
|
24123
|
-
|
|
24124
|
-
|
|
24125
|
-
|
|
24126
|
-
|
|
24127
|
-
|
|
24128
|
-
|
|
24129
|
-
|
|
24130
|
-
|
|
24131
|
-
|
|
24132
|
-
|
|
24133
|
-
|
|
24134
|
-
|
|
24135
|
-
|
|
24127
|
+
this.getMultiplyAdapter = (id) => {
|
|
24128
|
+
return () => {
|
|
24129
|
+
const packedArguments = [
|
|
24130
|
+
toBigInt(this.config.poolId.toString()),
|
|
24131
|
+
// pool id
|
|
24132
|
+
toBigInt(this.config.collateral.address.toString()),
|
|
24133
|
+
// collateral
|
|
24134
|
+
toBigInt(this.config.debt.address.toString()),
|
|
24135
|
+
// debt
|
|
24136
|
+
toBigInt(this.config.vaultAllocator.toString())
|
|
24137
|
+
// vault allocator
|
|
24138
|
+
];
|
|
24139
|
+
const { isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
24140
|
+
const output = this.constructSimpleLeafData({
|
|
24141
|
+
id,
|
|
24142
|
+
target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
|
|
24143
|
+
method: "modify_lever",
|
|
24144
|
+
packedArguments
|
|
24145
|
+
}, SIMPLE_SANITIZER_V2);
|
|
24146
|
+
return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
|
|
24147
|
+
};
|
|
24136
24148
|
};
|
|
24137
24149
|
this.getMultiplyCall = (params) => {
|
|
24138
24150
|
const isIncrease = params.isIncrease;
|
|
@@ -26824,7 +26836,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26824
26836
|
id: "defispring"
|
|
26825
26837
|
}] };
|
|
26826
26838
|
}
|
|
26839
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
26840
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
26841
|
+
rewardAPYs.push(0);
|
|
26827
26842
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
26843
|
+
weights.push(unusedBalanceAPY.weight);
|
|
26828
26844
|
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
26829
26845
|
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
26830
26846
|
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
@@ -26839,6 +26855,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26839
26855
|
id: "defispring"
|
|
26840
26856
|
}] };
|
|
26841
26857
|
}
|
|
26858
|
+
async getUnusedBalanceAPY() {
|
|
26859
|
+
return {
|
|
26860
|
+
apy: 0,
|
|
26861
|
+
weight: 0
|
|
26862
|
+
};
|
|
26863
|
+
}
|
|
26842
26864
|
computeAPY(apys, weights, currentAUM) {
|
|
26843
26865
|
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
26844
26866
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
@@ -27333,7 +27355,7 @@ function getLooperSettings(token1Symbol, token2Symbol, vaultSettings, pool1, poo
|
|
|
27333
27355
|
vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
|
|
27334
27356
|
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
27335
27357
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
27336
|
-
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS
|
|
27358
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */, true).bind(commonAdapter));
|
|
27337
27359
|
return vaultSettings;
|
|
27338
27360
|
}
|
|
27339
27361
|
var _riskFactor3 = [
|
|
@@ -27687,6 +27709,160 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27687
27709
|
logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
27688
27710
|
return price;
|
|
27689
27711
|
}
|
|
27712
|
+
async getAvnuSwapMultiplyCall(params) {
|
|
27713
|
+
return this._getAvnuDepositSwapLegCall({
|
|
27714
|
+
...params,
|
|
27715
|
+
minHF: 1.02
|
|
27716
|
+
});
|
|
27717
|
+
}
|
|
27718
|
+
async _getAvnuDepositSwapLegCall(params) {
|
|
27719
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall params: ${JSON.stringify(params)}`);
|
|
27720
|
+
assert(params.isDeposit, "Only deposit is supported in _getAvnuDepositSwapLegCall");
|
|
27721
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27722
|
+
const legLTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
27723
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall legLTV: ${legLTV}`);
|
|
27724
|
+
const existingPositions = await vesuAdapter1.getPositions(this.config);
|
|
27725
|
+
const collateralisation = await vesuAdapter1.getCollateralization(this.config);
|
|
27726
|
+
const existingCollateralInfo = existingPositions[0];
|
|
27727
|
+
const existingDebtInfo = existingPositions[1];
|
|
27728
|
+
logger.debug(`${this.getTag()}::_getAvnuDepositSwapLegCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
|
|
27729
|
+
existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
|
|
27730
|
+
const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
|
|
27731
|
+
const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
|
|
27732
|
+
logger.debug(`${this.getTag()}::_getAvnuDepositSwapLegCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
|
|
27733
|
+
const totalCollateral = existingCollateralInfo.amount.plus(params.leg1DepositAmount);
|
|
27734
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall totalCollateral: ${totalCollateral}`);
|
|
27735
|
+
const totalDebtAmount = totalCollateral.multipliedBy(collateralPrice).multipliedBy(legLTV).dividedBy(debtPrice).dividedBy(params.minHF);
|
|
27736
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall totalDebtAmount: ${totalDebtAmount}`);
|
|
27737
|
+
const debtAmount = totalDebtAmount.minus(existingDebtInfo.amount);
|
|
27738
|
+
if (debtAmount.lt(0)) {
|
|
27739
|
+
const lstDEXPrice = await this.getLSTDexPrice();
|
|
27740
|
+
const debtAmountInLST = debtAmount.abs().dividedBy(lstDEXPrice);
|
|
27741
|
+
const calls = await this.getVesuMultiplyCall({
|
|
27742
|
+
isDeposit: false,
|
|
27743
|
+
leg1DepositAmount: debtAmountInLST
|
|
27744
|
+
});
|
|
27745
|
+
assert(calls.length == 1, "Expected 1 call for unwind");
|
|
27746
|
+
return calls[0];
|
|
27747
|
+
}
|
|
27748
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall debtAmount: ${debtAmount}`);
|
|
27749
|
+
const STEP0 = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
27750
|
+
const manage0Info = this.getProofs(STEP0);
|
|
27751
|
+
const manageCall0 = manage0Info.callConstructor({
|
|
27752
|
+
amount: params.leg1DepositAmount
|
|
27753
|
+
});
|
|
27754
|
+
const STEP1 = "vesu_leg1" /* VESU_LEG1 */;
|
|
27755
|
+
const manage1Info = this.getProofs(STEP1);
|
|
27756
|
+
const manageCall1 = manage1Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
|
|
27757
|
+
collateralAmount: params.leg1DepositAmount,
|
|
27758
|
+
isAddCollateral: params.isDeposit,
|
|
27759
|
+
debtAmount,
|
|
27760
|
+
isBorrow: params.isDeposit
|
|
27761
|
+
}));
|
|
27762
|
+
const proofIds = [STEP0, STEP1];
|
|
27763
|
+
const manageCalls = [manageCall0, manageCall1];
|
|
27764
|
+
if (debtAmount.gt(0)) {
|
|
27765
|
+
const STEP2 = "avnu_multiply_approve_deposit" /* AVNU_MULTIPLY_APPROVE_DEPOSIT */;
|
|
27766
|
+
const manage2Info = this.getProofs(STEP2);
|
|
27767
|
+
const manageCall2 = manage2Info.callConstructor({
|
|
27768
|
+
amount: debtAmount
|
|
27769
|
+
});
|
|
27770
|
+
const debtTokenInfo = vesuAdapter1.config.debt;
|
|
27771
|
+
const lstTokenInfo = this.asset();
|
|
27772
|
+
const avnuModule = new AvnuWrapper();
|
|
27773
|
+
const quote = await avnuModule.getQuotes(
|
|
27774
|
+
debtTokenInfo.address.address,
|
|
27775
|
+
lstTokenInfo.address.address,
|
|
27776
|
+
debtAmount.toWei(),
|
|
27777
|
+
this.metadata.additionalInfo.vaultAllocator.address
|
|
27778
|
+
);
|
|
27779
|
+
const minAmount = await this._getMinOutputAmountLSTBuy(debtAmount);
|
|
27780
|
+
const minAmountWei = minAmount.toWei();
|
|
27781
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall minAmount: ${minAmount}`);
|
|
27782
|
+
const swapInfo = await avnuModule.getSwapInfo(
|
|
27783
|
+
quote,
|
|
27784
|
+
this.metadata.additionalInfo.vaultAllocator.address,
|
|
27785
|
+
0,
|
|
27786
|
+
this.address.address,
|
|
27787
|
+
minAmountWei
|
|
27788
|
+
);
|
|
27789
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall swapInfo: ${JSON.stringify(swapInfo)}`);
|
|
27790
|
+
const STEP3 = "avnu_multiply_swap_deposit" /* AVNU_MULTIPLY_SWAP_DEPOSIT */;
|
|
27791
|
+
const manage3Info = this.getProofs(STEP3);
|
|
27792
|
+
const manageCall3 = manage3Info.callConstructor({
|
|
27793
|
+
props: swapInfo
|
|
27794
|
+
});
|
|
27795
|
+
proofIds.push(STEP2);
|
|
27796
|
+
proofIds.push(STEP3);
|
|
27797
|
+
manageCalls.push(manageCall2, manageCall3);
|
|
27798
|
+
const newCollateral = minAmount.plus(totalCollateral);
|
|
27799
|
+
const newHF = newCollateral.multipliedBy(collateralPrice).multipliedBy(legLTV).dividedBy(totalDebtAmount).dividedBy(debtPrice).toNumber();
|
|
27800
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
27801
|
+
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
27802
|
+
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
27803
|
+
const STEP4 = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
27804
|
+
const manage4Info = this.getProofs(STEP4);
|
|
27805
|
+
const manageCall4 = manage4Info.callConstructor({
|
|
27806
|
+
amount: minAmount
|
|
27807
|
+
});
|
|
27808
|
+
const STEP5 = "vesu_leg1" /* VESU_LEG1 */;
|
|
27809
|
+
const manage5Info = this.getProofs(STEP5);
|
|
27810
|
+
const manageCall5 = manage5Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
|
|
27811
|
+
collateralAmount: minAmount,
|
|
27812
|
+
isAddCollateral: true,
|
|
27813
|
+
debtAmount: Web3Number.fromWei("0", this.asset().decimals),
|
|
27814
|
+
isBorrow: params.isDeposit
|
|
27815
|
+
}));
|
|
27816
|
+
proofIds.push(STEP4, STEP5);
|
|
27817
|
+
manageCalls.push(manageCall4, manageCall5);
|
|
27818
|
+
}
|
|
27819
|
+
}
|
|
27820
|
+
const manageCall = this.getManageCall(proofIds, manageCalls);
|
|
27821
|
+
return manageCall;
|
|
27822
|
+
}
|
|
27823
|
+
// todo unwind or not deposit when the yield is bad.
|
|
27824
|
+
async getLSTMultiplierRebalanceCall() {
|
|
27825
|
+
const positions = await this.getVaultPositions();
|
|
27826
|
+
assert(positions.length == 3, "Rebalance call is only supported for 3 positions");
|
|
27827
|
+
const existingCollateralInfo = positions[0];
|
|
27828
|
+
const existingDebtInfo = positions[1];
|
|
27829
|
+
const unusedBalance = positions[2];
|
|
27830
|
+
const [healthFactor] = await this.getVesuHealthFactors();
|
|
27831
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27832
|
+
const legLTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
27833
|
+
const collateralisation = await vesuAdapter1.getCollateralization(this.config);
|
|
27834
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
|
|
27835
|
+
existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
|
|
27836
|
+
const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
|
|
27837
|
+
const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
|
|
27838
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
|
|
27839
|
+
const isHFTooLow = healthFactor < this.metadata.additionalInfo.minHealthFactor;
|
|
27840
|
+
const isHFTooHigh = healthFactor > this.metadata.additionalInfo.targetHealthFactor + 0.05;
|
|
27841
|
+
if (isHFTooLow || isHFTooHigh) {
|
|
27842
|
+
const manageCall = await this._getAvnuDepositSwapLegCall({
|
|
27843
|
+
isDeposit: true,
|
|
27844
|
+
leg1DepositAmount: unusedBalance.amount,
|
|
27845
|
+
minHF: 1.02
|
|
27846
|
+
// todo, shouldnt use this 1.02 HF, if there isn;t more looping left.
|
|
27847
|
+
});
|
|
27848
|
+
return { shouldRebalance: true, manageCall };
|
|
27849
|
+
} else {
|
|
27850
|
+
return { shouldRebalance: false, manageCall: void 0 };
|
|
27851
|
+
}
|
|
27852
|
+
}
|
|
27853
|
+
//
|
|
27854
|
+
async _getMinOutputAmountLSTBuy(amountInUnderlying) {
|
|
27855
|
+
const lstTruePrice = await this.getLSTExchangeRate();
|
|
27856
|
+
const minOutputAmount = amountInUnderlying.dividedBy(lstTruePrice);
|
|
27857
|
+
return minOutputAmount;
|
|
27858
|
+
}
|
|
27859
|
+
async _getMinOutputAmountLSTSell(amountInLST) {
|
|
27860
|
+
const lstTruePrice = await this.getLSTExchangeRate();
|
|
27861
|
+
const minOutputAmount = amountInLST.multipliedBy(lstTruePrice).multipliedBy(0.995);
|
|
27862
|
+
return minOutputAmount;
|
|
27863
|
+
}
|
|
27864
|
+
// todo add a function to findout max borrowable amount without fucking yield
|
|
27865
|
+
// if the current net yield < LST yield, add a function to calculate how much to unwind.
|
|
27690
27866
|
/**
|
|
27691
27867
|
* Uses vesu's multiple call to create leverage on LST
|
|
27692
27868
|
* Deposit amount is in LST
|
|
@@ -27738,12 +27914,40 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27738
27914
|
async getLSTAPR(_address) {
|
|
27739
27915
|
try {
|
|
27740
27916
|
const vesuAdapter1 = this.getVesuAdapters()[0];
|
|
27741
|
-
|
|
27917
|
+
const apr = await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
|
|
27918
|
+
if (!apr) {
|
|
27919
|
+
throw new Error("Failed to get LST APR");
|
|
27920
|
+
}
|
|
27921
|
+
return apr;
|
|
27742
27922
|
} catch (error) {
|
|
27743
27923
|
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
27744
27924
|
return 0;
|
|
27745
27925
|
}
|
|
27746
27926
|
}
|
|
27927
|
+
// todo undo this
|
|
27928
|
+
async netAPY() {
|
|
27929
|
+
const { net, splits } = await super.netAPY();
|
|
27930
|
+
let _net = net;
|
|
27931
|
+
if (this.asset().symbol == "xWBTC") {
|
|
27932
|
+
const debtToken = this.getVesuAdapters()[0].config.debt;
|
|
27933
|
+
const lstAPY = await this.getLSTAPR(debtToken.address);
|
|
27934
|
+
_net = lstAPY * 5;
|
|
27935
|
+
}
|
|
27936
|
+
return {
|
|
27937
|
+
net: _net,
|
|
27938
|
+
splits
|
|
27939
|
+
};
|
|
27940
|
+
}
|
|
27941
|
+
async getUnusedBalanceAPY() {
|
|
27942
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
27943
|
+
const vesuAdapter = this.getVesuAdapters()[0];
|
|
27944
|
+
const underlying = vesuAdapter.config.debt;
|
|
27945
|
+
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
27946
|
+
return {
|
|
27947
|
+
apy: lstAPY,
|
|
27948
|
+
weight: unusedBalance.usdValue
|
|
27949
|
+
};
|
|
27950
|
+
}
|
|
27747
27951
|
async getLSTExchangeRate() {
|
|
27748
27952
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27749
27953
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -27774,7 +27978,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27774
27978
|
const proofsIDs = [];
|
|
27775
27979
|
const manageCalls = [];
|
|
27776
27980
|
if (params.marginAmount.greaterThan(0)) {
|
|
27777
|
-
const STEP1_ID = "
|
|
27981
|
+
const STEP1_ID = "multiple_approve" /* MULTIPLE_APPROVE */;
|
|
27778
27982
|
const manage1Info = this.getProofs(STEP1_ID);
|
|
27779
27983
|
const depositAmount = params.marginAmount;
|
|
27780
27984
|
const manageCall1 = manage1Info.callConstructor({
|
|
@@ -27904,7 +28108,7 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
|
|
|
27904
28108
|
collateral: lstToken,
|
|
27905
28109
|
debt: underlyingToken,
|
|
27906
28110
|
vaultAllocator: vaultSettings.vaultAllocator,
|
|
27907
|
-
id: "
|
|
28111
|
+
id: "vesu_leg1" /* VESU_LEG1 */
|
|
27908
28112
|
});
|
|
27909
28113
|
const commonAdapter = new CommonAdapter({
|
|
27910
28114
|
manager: vaultSettings.manager,
|
|
@@ -27913,10 +28117,10 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
|
|
|
27913
28117
|
vaultAddress: vaultSettings.vaultAddress,
|
|
27914
28118
|
vaultAllocator: vaultSettings.vaultAllocator
|
|
27915
28119
|
});
|
|
27916
|
-
const { isV2 } = getVesuSingletonAddress(pool1);
|
|
28120
|
+
const { isV2, addr: poolAddr } = getVesuSingletonAddress(pool1);
|
|
27917
28121
|
const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
|
|
27918
|
-
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "
|
|
27919
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
|
|
28122
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "multiple_approve" /* MULTIPLE_APPROVE */).bind(commonAdapter));
|
|
28123
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter("multiply_vesu" /* MULTIPLY_VESU */).bind(vesuAdapterLST));
|
|
27920
28124
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
|
|
27921
28125
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
|
|
27922
28126
|
vaultSettings.adapters.push(...[{
|
|
@@ -27926,12 +28130,18 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
|
|
|
27926
28130
|
id: "common_adapter" /* COMMON */,
|
|
27927
28131
|
adapter: commonAdapter
|
|
27928
28132
|
}]);
|
|
28133
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(underlyingToken.address, AVNU_EXCHANGE, "avnu_multiply_approve_deposit" /* AVNU_MULTIPLY_APPROVE_DEPOSIT */).bind(commonAdapter));
|
|
28134
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(underlyingToken.address, lstToken.address, "avnu_multiply_swap_deposit" /* AVNU_MULTIPLY_SWAP_DEPOSIT */, false).bind(commonAdapter));
|
|
28135
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, AVNU_EXCHANGE, "avnu_multiply_approve_withdraw" /* AVNU_MULTIPLY_APPROVE_WITHDRAW */).bind(commonAdapter));
|
|
28136
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(lstToken.address, underlyingToken.address, "avnu_multiply_swap_withdraw" /* AVNU_MULTIPLY_SWAP_WITHDRAW */, false).bind(commonAdapter));
|
|
28137
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
28138
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
27929
28139
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
|
|
27930
28140
|
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
|
|
27931
28141
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterLST));
|
|
27932
28142
|
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
27933
|
-
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address,
|
|
27934
|
-
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS
|
|
28143
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_EXCHANGE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
28144
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */, false).bind(commonAdapter));
|
|
27935
28145
|
return vaultSettings;
|
|
27936
28146
|
}
|
|
27937
28147
|
var AUDIT_URL4 = "https://docs.troves.fi/p/security#starknet-vault-kit";
|
|
@@ -28032,11 +28242,11 @@ var hyperxsBTC = {
|
|
|
28032
28242
|
minHealthFactor: 1.05
|
|
28033
28243
|
};
|
|
28034
28244
|
var hyperxLBTC = {
|
|
28035
|
-
vaultAddress: ContractAddr.from("
|
|
28036
|
-
manager: ContractAddr.from("
|
|
28037
|
-
vaultAllocator: ContractAddr.from("
|
|
28038
|
-
redeemRequestNFT: ContractAddr.from("
|
|
28039
|
-
aumOracle: ContractAddr.from("
|
|
28245
|
+
vaultAddress: ContractAddr.from("0x64cf24d4883fe569926419a0569ab34497c6956a1a308fa883257f7486d7030"),
|
|
28246
|
+
manager: ContractAddr.from("0x203530a4022a99b8f4b406aaf33b0849d43ad7422c1d5cc14ff8c667abec6c0"),
|
|
28247
|
+
vaultAllocator: ContractAddr.from("0x7dbc8ccd4eabce6ea6c19e0e5c9ccca3a93bd510303b9e071cbe25fc508546e"),
|
|
28248
|
+
redeemRequestNFT: ContractAddr.from("0x5ee66a39af9aef3d0d48982b4a63e8bd2a5bad021916bd87fb0eae3a26800b8"),
|
|
28249
|
+
aumOracle: ContractAddr.from("0x23d69e4391fa72d10e625e7575d8bddbb4aff96f04503f83fdde23123bf41d0"),
|
|
28040
28250
|
leafAdapters: [],
|
|
28041
28251
|
adapters: [],
|
|
28042
28252
|
targetHealthFactor: 1.1,
|
|
@@ -28133,7 +28343,7 @@ var PricerLST2 = class extends Pricer {
|
|
|
28133
28343
|
};
|
|
28134
28344
|
|
|
28135
28345
|
// src/modules/lst-apr.ts
|
|
28136
|
-
var
|
|
28346
|
+
var LSTAPRService = class {
|
|
28137
28347
|
// 5 minutes
|
|
28138
28348
|
/**
|
|
28139
28349
|
* Fetches LST stats from Endur API with caching
|
|
@@ -28228,10 +28438,10 @@ var LSTAPRService2 = class {
|
|
|
28228
28438
|
logger.verbose(`LSTAPRService: Cache cleared`);
|
|
28229
28439
|
}
|
|
28230
28440
|
};
|
|
28231
|
-
|
|
28232
|
-
|
|
28233
|
-
|
|
28234
|
-
|
|
28441
|
+
LSTAPRService.ENDUR_API_URL = "https://app.endur.fi/api/lst/stats";
|
|
28442
|
+
LSTAPRService.cache = null;
|
|
28443
|
+
LSTAPRService.cacheTimestamp = 0;
|
|
28444
|
+
LSTAPRService.CACHE_DURATION = 5 * 60 * 1e3;
|
|
28235
28445
|
|
|
28236
28446
|
// src/notifs/telegram.ts
|
|
28237
28447
|
var import_node_telegram_bot_api = __toESM(require("node-telegram-bot-api"));
|
|
@@ -28743,6 +28953,7 @@ var deployer_default = Deployer;
|
|
|
28743
28953
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28744
28954
|
0 && (module.exports = {
|
|
28745
28955
|
AUMTypes,
|
|
28956
|
+
AVNU_EXCHANGE,
|
|
28746
28957
|
AVNU_MIDDLEWARE,
|
|
28747
28958
|
AutoCompounderSTRK,
|
|
28748
28959
|
AvnuWrapper,
|
|
@@ -28788,6 +28999,7 @@ var deployer_default = Deployer;
|
|
|
28788
28999
|
UniversalStrategies,
|
|
28789
29000
|
UniversalStrategy,
|
|
28790
29001
|
VESU_SINGLETON,
|
|
29002
|
+
VESU_V2_MODIFY_POSITION_SANITIZER,
|
|
28791
29003
|
VesuAdapter,
|
|
28792
29004
|
VesuAmountDenomination,
|
|
28793
29005
|
VesuAmountType,
|