@strkfarm/sdk 1.1.70 → 1.1.72
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/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.browser.global.js +8523 -7752
- package/dist/index.browser.mjs +122 -85
- package/dist/index.d.ts +12 -2
- package/dist/index.js +125 -88
- package/dist/index.mjs +125 -88
- package/package.json +1 -1
- package/src/modules/harvests.ts +15 -14
- package/src/strategies/ekubo-cl-vault.tsx +1 -1
- package/src/strategies/universal-adapters/vesu-adapter.ts +5 -3
- package/src/strategies/universal-lst-muliplier-strategy.tsx +138 -76
package/dist/index.browser.mjs
CHANGED
|
@@ -4201,26 +4201,27 @@ var STRK = "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d";
|
|
|
4201
4201
|
var EkuboHarvests = class _EkuboHarvests extends Harvests {
|
|
4202
4202
|
async getHarvests(addr) {
|
|
4203
4203
|
logger.verbose(`${_EkuboHarvests.name}: getHarvests => addr: ${addr.address}`);
|
|
4204
|
-
const EKUBO_API = `https://
|
|
4204
|
+
const EKUBO_API = `https://prod-api.ekubo.org/claims/${addr.address}`;
|
|
4205
4205
|
const resultEkubo = await fetch(EKUBO_API);
|
|
4206
|
-
const
|
|
4207
|
-
|
|
4206
|
+
const data = await resultEkubo.json();
|
|
4207
|
+
const claims = data.claims || [];
|
|
4208
|
+
logger.verbose(`${_EkuboHarvests.name}: getHarvests => claims length: ${claims.length}`);
|
|
4208
4209
|
const rewards = [];
|
|
4209
|
-
for (let i = 0; i <
|
|
4210
|
-
const
|
|
4211
|
-
assert(
|
|
4210
|
+
for (let i = 0; i < claims.length; ++i) {
|
|
4211
|
+
const claimData = claims[i];
|
|
4212
|
+
assert(claimData.key.token == STRK, "expected strk token only");
|
|
4212
4213
|
rewards.push({
|
|
4213
|
-
rewardsContract: ContractAddr.from(
|
|
4214
|
+
rewardsContract: ContractAddr.from(claimData.dropAddress),
|
|
4214
4215
|
token: ContractAddr.from(STRK),
|
|
4215
|
-
startDate: new Date(
|
|
4216
|
-
endDate: new Date(
|
|
4216
|
+
startDate: /* @__PURE__ */ new Date(0),
|
|
4217
|
+
endDate: /* @__PURE__ */ new Date(0),
|
|
4217
4218
|
claim: {
|
|
4218
|
-
id:
|
|
4219
|
-
amount: Web3Number.fromWei(
|
|
4220
|
-
claimee: ContractAddr.from(
|
|
4219
|
+
id: claimData.claim.index,
|
|
4220
|
+
amount: Web3Number.fromWei(claimData.claim.amount, 18),
|
|
4221
|
+
claimee: ContractAddr.from(claimData.claim.account)
|
|
4221
4222
|
},
|
|
4222
|
-
actualReward: Web3Number.fromWei(
|
|
4223
|
-
proof:
|
|
4223
|
+
actualReward: Web3Number.fromWei(claimData.claim.amount, 18),
|
|
4224
|
+
proof: claimData.proof
|
|
4224
4225
|
});
|
|
4225
4226
|
}
|
|
4226
4227
|
return rewards.sort((a, b) => b.endDate.getTime() - a.endDate.getTime());
|
|
@@ -15874,7 +15875,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15874
15875
|
* @returns {Promise<number>} The weighted average APY across all pools
|
|
15875
15876
|
*/
|
|
15876
15877
|
async netAPY(blockIdentifier = "latest", sinceBlocks = 6e5, timeperiod = "24h") {
|
|
15877
|
-
const isUSDCQouteToken = this.metadata.additionalInfo.quoteAsset.symbol === "USDC.e";
|
|
15878
|
+
const isUSDCQouteToken = this.metadata.additionalInfo.quoteAsset.symbol === "USDC.e" || this.metadata.additionalInfo.quoteAsset.symbol === "USDC";
|
|
15878
15879
|
if (!isUSDCQouteToken) {
|
|
15879
15880
|
return this.netSharesBasedTrueAPY(blockIdentifier, sinceBlocks);
|
|
15880
15881
|
} else {
|
|
@@ -27078,7 +27079,8 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27078
27079
|
var VesuPools = {
|
|
27079
27080
|
Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"),
|
|
27080
27081
|
Re7xSTRK: ContractAddr.from("0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161"),
|
|
27081
|
-
Re7xBTC: ContractAddr.from("0x3a8416bf20d036df5b1cf3447630a2e1cb04685f6b0c3a70ed7fb1473548ecf")
|
|
27082
|
+
Re7xBTC: ContractAddr.from("0x3a8416bf20d036df5b1cf3447630a2e1cb04685f6b0c3a70ed7fb1473548ecf"),
|
|
27083
|
+
Prime: ContractAddr.from("0x451fe483d5921a2919ddd81d0de6696669bccdacd859f72a4fba7656b97c3b5")
|
|
27082
27084
|
};
|
|
27083
27085
|
var extensionMap = {};
|
|
27084
27086
|
extensionMap[VesuPools.Re7xSTRK.address] = ContractAddr.from("0x04e06e04b8d624d039aa1c3ca8e0aa9e21dc1ccba1d88d0d650837159e0ee054");
|
|
@@ -27405,14 +27407,15 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27405
27407
|
const assetConfig = isV2 ? _assetConfig : _assetConfig["0"];
|
|
27406
27408
|
const timeDelta = assetConfig.last_updated;
|
|
27407
27409
|
const lastFullUtilizationRate = assetConfig.last_full_utilization_rate;
|
|
27408
|
-
const
|
|
27410
|
+
const debtSharePrice = Web3Number.fromWei(assetConfig.last_rate_accumulator, 18);
|
|
27411
|
+
const currentDebt = new Web3Number((Number(assetConfig.total_nominal_debt) / 1e18).toFixed(9), asset.decimals).multipliedBy(debtSharePrice);
|
|
27409
27412
|
const totalSupply = currentDebt.plus(Web3Number.fromWei(assetConfig.reserve, asset.decimals));
|
|
27410
27413
|
const ratePerSecond = BigInt(Math.round(maxBorrowAPY / 365 / 24 / 60 / 60 * Number(SCALE)));
|
|
27411
27414
|
const maxUtilisation = this.getMaxUtilizationGivenRatePerSecond(interestRateConfig, ratePerSecond, timeDelta, lastFullUtilizationRate);
|
|
27412
27415
|
logger.verbose(`${asset.symbol}::VesuAdapter::getMaxBorrowableByInterestRate maxUtilisation: ${Number(maxUtilisation) / 1e18}, totalSupply: ${totalSupply.toString()}`);
|
|
27413
27416
|
const maxDebtToHave = totalSupply.multipliedBy(Number(maxUtilisation) / 1e18);
|
|
27414
27417
|
logger.verbose(`${asset.symbol}::VesuAdapter::getMaxBorrowableByInterestRate currentDebt: ${currentDebt.toString()}, maxDebtToHave: ${maxDebtToHave.toString()}`);
|
|
27415
|
-
return maxDebtToHave.minus(currentDebt);
|
|
27418
|
+
return { maxDebtToHave: maxDebtToHave.minus(currentDebt), currentDebt, totalSupply };
|
|
27416
27419
|
}
|
|
27417
27420
|
async getLTVConfig(config, blockNumber = "latest") {
|
|
27418
27421
|
const CACHE_KEY = `ltv_config_${blockNumber}`;
|
|
@@ -30914,14 +30917,14 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
30914
30917
|
}
|
|
30915
30918
|
}
|
|
30916
30919
|
asset() {
|
|
30917
|
-
return this.getVesuSameTokenAdapter().config.collateral;
|
|
30920
|
+
return this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId).config.collateral;
|
|
30918
30921
|
}
|
|
30919
30922
|
getTag() {
|
|
30920
30923
|
return `${_UniversalLstMultiplierStrategy.name}:${this.metadata.name}`;
|
|
30921
30924
|
}
|
|
30922
30925
|
// Vesu adapter with LST and base token match
|
|
30923
|
-
getVesuSameTokenAdapter() {
|
|
30924
|
-
const baseAdapter = this.getAdapter(getVesuLegId("vesu_leg1" /* VESU_LEG1 */, this.metadata.additionalInfo.underlyingToken.symbol));
|
|
30926
|
+
getVesuSameTokenAdapter(poolId) {
|
|
30927
|
+
const baseAdapter = this.getAdapter(getVesuLegId("vesu_leg1" /* VESU_LEG1 */, this.metadata.additionalInfo.underlyingToken.symbol, poolId.toString()));
|
|
30925
30928
|
baseAdapter.networkConfig = this.config;
|
|
30926
30929
|
baseAdapter.pricer = this.pricer;
|
|
30927
30930
|
return baseAdapter;
|
|
@@ -30930,18 +30933,20 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
30930
30933
|
// todo support lending assets of underlying as well (like if xSTRK looping is not viable, simply supply STRK)
|
|
30931
30934
|
getVesuAdapters() {
|
|
30932
30935
|
const adapters = [];
|
|
30933
|
-
const
|
|
30934
|
-
|
|
30935
|
-
const
|
|
30936
|
-
|
|
30937
|
-
|
|
30938
|
-
|
|
30939
|
-
|
|
30940
|
-
|
|
30941
|
-
|
|
30942
|
-
|
|
30943
|
-
|
|
30944
|
-
|
|
30936
|
+
for (const poolId of [this.metadata.additionalInfo.defaultPoolId, ...this.metadata.additionalInfo.altSupportedPoolIds]) {
|
|
30937
|
+
const baseAdapter = this.getVesuSameTokenAdapter(poolId);
|
|
30938
|
+
for (const asset of this.metadata.additionalInfo.borrowable_assets) {
|
|
30939
|
+
const vesuAdapter1 = new VesuAdapter({
|
|
30940
|
+
poolId: baseAdapter.config.poolId,
|
|
30941
|
+
collateral: this.asset(),
|
|
30942
|
+
debt: asset,
|
|
30943
|
+
vaultAllocator: this.metadata.additionalInfo.vaultAllocator,
|
|
30944
|
+
id: ""
|
|
30945
|
+
});
|
|
30946
|
+
vesuAdapter1.pricer = this.pricer;
|
|
30947
|
+
vesuAdapter1.networkConfig = this.config;
|
|
30948
|
+
adapters.push(vesuAdapter1);
|
|
30949
|
+
}
|
|
30945
30950
|
}
|
|
30946
30951
|
return adapters;
|
|
30947
30952
|
}
|
|
@@ -31062,7 +31067,8 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31062
31067
|
const debtAmountInLST = debtAmount.abs().dividedBy(lstDEXPrice);
|
|
31063
31068
|
const calls = await this.getVesuMultiplyCall({
|
|
31064
31069
|
isDeposit: false,
|
|
31065
|
-
leg1DepositAmount: debtAmountInLST
|
|
31070
|
+
leg1DepositAmount: debtAmountInLST,
|
|
31071
|
+
poolId: vesuAdapter.config.poolId
|
|
31066
31072
|
});
|
|
31067
31073
|
assert(calls.length == 1, `Expected 1 call for unwind, got ${calls.length}`);
|
|
31068
31074
|
return calls[0];
|
|
@@ -31073,7 +31079,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31073
31079
|
const manageCall0 = manage0Info.callConstructor({
|
|
31074
31080
|
amount: newDepositAmount
|
|
31075
31081
|
});
|
|
31076
|
-
const STEP1 = getVesuLegId("vesu_leg1" /* VESU_LEG1 */, vesuAdapter.config.debt.symbol);
|
|
31082
|
+
const STEP1 = getVesuLegId("vesu_leg1" /* VESU_LEG1 */, vesuAdapter.config.debt.symbol, vesuAdapter.config.poolId.toString());
|
|
31077
31083
|
const manage1Info = this.getProofs(STEP1);
|
|
31078
31084
|
const manageCall1 = manage1Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
|
|
31079
31085
|
collateralAmount: newDepositAmount,
|
|
@@ -31128,7 +31134,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31128
31134
|
const manageCall4 = manage4Info.callConstructor({
|
|
31129
31135
|
amount: minAmount
|
|
31130
31136
|
});
|
|
31131
|
-
const STEP5 = getVesuLegId("vesu_leg1" /* VESU_LEG1 */, vesuAdapter.config.debt.symbol);
|
|
31137
|
+
const STEP5 = getVesuLegId("vesu_leg1" /* VESU_LEG1 */, vesuAdapter.config.debt.symbol, vesuAdapter.config.poolId.toString());
|
|
31132
31138
|
const manage5Info = this.getProofs(STEP5);
|
|
31133
31139
|
const manageCall5 = manage5Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
|
|
31134
31140
|
collateralAmount: minAmount,
|
|
@@ -31228,7 +31234,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31228
31234
|
*/
|
|
31229
31235
|
async getVesuMultiplyCall(params) {
|
|
31230
31236
|
const maxEkuboPriceImpact = params.maxEkuboPriceImpact || 0.01;
|
|
31231
|
-
const vesuAdapter1 = this.getVesuSameTokenAdapter();
|
|
31237
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(params.poolId);
|
|
31232
31238
|
const legLTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
31233
31239
|
logger.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
|
|
31234
31240
|
if (!params.isDeposit) {
|
|
@@ -31267,11 +31273,12 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31267
31273
|
debtAmount,
|
|
31268
31274
|
lstDexPriceInUnderlying: dexPrice,
|
|
31269
31275
|
isIncrease: debtAmount.greaterThan(0),
|
|
31270
|
-
maxEkuboPriceImpact
|
|
31276
|
+
maxEkuboPriceImpact,
|
|
31277
|
+
poolId: params.poolId
|
|
31271
31278
|
});
|
|
31272
31279
|
}
|
|
31273
31280
|
getLSTUnderlyingTokenInfo() {
|
|
31274
|
-
const vesuAdapter1 = this.getVesuSameTokenAdapter();
|
|
31281
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
31275
31282
|
return vesuAdapter1.config.debt;
|
|
31276
31283
|
}
|
|
31277
31284
|
async getMaxBorrowableAmount(params = { isAPYComputation: false }) {
|
|
@@ -31279,7 +31286,9 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31279
31286
|
let netMaxBorrowableAmount = Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals);
|
|
31280
31287
|
const maxBorrowables = [];
|
|
31281
31288
|
for (const vesuAdapter of vesuAdapters) {
|
|
31282
|
-
|
|
31289
|
+
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
31290
|
+
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
31291
|
+
maxBorrowables.push({ ...output, ltv });
|
|
31283
31292
|
}
|
|
31284
31293
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
31285
31294
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -31305,9 +31314,13 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31305
31314
|
async getMaxBorrowableAmountByVesuAdapter(vesuAdapter, isAPYComputation) {
|
|
31306
31315
|
const lstAPY = await this.getLSTAPR(this.getLSTUnderlyingTokenInfo().address);
|
|
31307
31316
|
const maxInterestRate = lstAPY * 0.8;
|
|
31308
|
-
const maxBorrowableAmount = await vesuAdapter.getMaxBorrowableByInterestRate(this.config, vesuAdapter.config.debt, maxInterestRate);
|
|
31317
|
+
const { maxDebtToHave: maxBorrowableAmount, currentDebt } = await vesuAdapter.getMaxBorrowableByInterestRate(this.config, vesuAdapter.config.debt, maxInterestRate);
|
|
31309
31318
|
const debtCap = await vesuAdapter.getDebtCap(this.config);
|
|
31310
|
-
|
|
31319
|
+
if (currentDebt.gte(debtCap)) {
|
|
31320
|
+
return { amount: Web3Number.fromWei("0", vesuAdapter.config.debt.decimals), dexSwappableAmount: Web3Number.fromWei("0", vesuAdapter.config.debt.decimals), maxBorrowableAmount: Web3Number.fromWei("0", vesuAdapter.config.debt.decimals), borrowableAsset: vesuAdapter.config.debt };
|
|
31321
|
+
}
|
|
31322
|
+
const availableToBorrow = debtCap.minus(currentDebt);
|
|
31323
|
+
const maxBorrowable = maxBorrowableAmount.minimum(availableToBorrow).multipliedBy(0.999);
|
|
31311
31324
|
if (vesuAdapter.config.debt.address.eq(this.getLSTUnderlyingTokenInfo().address) || isAPYComputation) {
|
|
31312
31325
|
return { amount: maxBorrowable, dexSwappableAmount: maxBorrowable, maxBorrowableAmount: maxBorrowable, borrowableAsset: vesuAdapter.config.debt };
|
|
31313
31326
|
}
|
|
@@ -31329,7 +31342,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31329
31342
|
*/
|
|
31330
31343
|
async getLSTAPR(_address) {
|
|
31331
31344
|
try {
|
|
31332
|
-
const vesuAdapter1 = this.getVesuSameTokenAdapter();
|
|
31345
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
31333
31346
|
const apr = await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
|
|
31334
31347
|
if (!apr) {
|
|
31335
31348
|
throw new Error("Failed to get LST APR");
|
|
@@ -31362,29 +31375,21 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31362
31375
|
}
|
|
31363
31376
|
async maxNewDeposits(params = { isAPYComputation: false }) {
|
|
31364
31377
|
const maxBorrowableAmounts = await this.getMaxBorrowableAmount(params);
|
|
31378
|
+
let numerator = 0;
|
|
31365
31379
|
let ltv = void 0;
|
|
31366
31380
|
for (let adapter of this.getVesuAdapters()) {
|
|
31367
|
-
const
|
|
31368
|
-
if (!
|
|
31381
|
+
const maxBorrowableAmountInfo = maxBorrowableAmounts.maxBorrowables.find((b) => b.borrowableAsset.address.eq(adapter.config.debt.address));
|
|
31382
|
+
if (!maxBorrowableAmountInfo || !maxBorrowableAmountInfo?.amount) {
|
|
31369
31383
|
throw new Error(`Max borrowable amount not found for adapter: ${adapter.config.debt.symbol}`);
|
|
31370
31384
|
}
|
|
31371
|
-
|
|
31372
|
-
if (!ltv) {
|
|
31373
|
-
ltv = maxLTV;
|
|
31374
|
-
} else if (ltv != maxLTV) {
|
|
31375
|
-
throw new Error(`LTV mismatch for adapter: ${adapter.config.debt.symbol}`);
|
|
31376
|
-
}
|
|
31377
|
-
}
|
|
31378
|
-
if (!ltv) {
|
|
31379
|
-
throw new Error("LTV not found");
|
|
31385
|
+
numerator += this.metadata.additionalInfo.targetHealthFactor * maxBorrowableAmountInfo.amount.toNumber() / maxBorrowableAmountInfo.ltv;
|
|
31380
31386
|
}
|
|
31381
|
-
const numerator = this.metadata.additionalInfo.targetHealthFactor * maxBorrowableAmounts.netMaxBorrowableAmount.toNumber() / ltv;
|
|
31382
31387
|
return numerator - maxBorrowableAmounts.netMaxBorrowableAmount.toNumber();
|
|
31383
31388
|
}
|
|
31384
31389
|
// todo revisit cases where 0th adapters is used
|
|
31385
31390
|
async getUnusedBalanceAPY() {
|
|
31386
31391
|
const unusedBalance = await this.getUnusedBalance();
|
|
31387
|
-
const vesuAdapter = this.getVesuSameTokenAdapter();
|
|
31392
|
+
const vesuAdapter = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
31388
31393
|
const underlying = vesuAdapter.config.debt;
|
|
31389
31394
|
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
31390
31395
|
return {
|
|
@@ -31393,7 +31398,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31393
31398
|
};
|
|
31394
31399
|
}
|
|
31395
31400
|
async getLSTExchangeRate() {
|
|
31396
|
-
const vesuAdapter1 = this.getVesuSameTokenAdapter();
|
|
31401
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
31397
31402
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
31398
31403
|
const lstABI = new Contract10({
|
|
31399
31404
|
abi: erc4626_abi_default,
|
|
@@ -31412,7 +31417,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31412
31417
|
async getModifyLeverCall(params) {
|
|
31413
31418
|
logger.verbose(`${this.getTag()}::getModifyLeverCall marginAmount: ${params.marginAmount}, debtAmount: ${params.debtAmount}, lstDexPriceInUnderlying: ${params.lstDexPriceInUnderlying}, isIncrease: ${params.isIncrease}`);
|
|
31414
31419
|
assert(!params.marginAmount.isZero() || !params.debtAmount.isZero(), "Deposit/debt must be non-0");
|
|
31415
|
-
const vesuAdapter1 = this.getVesuSameTokenAdapter();
|
|
31420
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(params.poolId);
|
|
31416
31421
|
const lstTokenInfo = this.asset();
|
|
31417
31422
|
const lstUnderlyingTokenInfo = vesuAdapter1.config.debt;
|
|
31418
31423
|
const maxAmounts = lstTokenInfo.symbol == "xSTRK" ? 5e5 : 0.5;
|
|
@@ -31422,7 +31427,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31422
31427
|
const proofsIDs = [];
|
|
31423
31428
|
const manageCalls = [];
|
|
31424
31429
|
if (params.marginAmount.greaterThan(0)) {
|
|
31425
|
-
const STEP1_ID = "multiple_approve" /* MULTIPLE_APPROVE
|
|
31430
|
+
const STEP1_ID = getVesuGenericLegId(params.poolId.toString(), "multiple_approve" /* MULTIPLE_APPROVE */);
|
|
31426
31431
|
const manage1Info = this.getProofs(STEP1_ID);
|
|
31427
31432
|
const depositAmount = params.marginAmount;
|
|
31428
31433
|
const manageCall1 = manage1Info.callConstructor({
|
|
@@ -31455,12 +31460,12 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31455
31460
|
const maxUsedCollateralInLST = params.debtAmount.abs().dividedBy(lstTrueExchangeRate).multipliedBy(1.005);
|
|
31456
31461
|
logger.verbose(`${this.getTag()}::getModifyLeverCall maxUsedCollateralInLST: ${maxUsedCollateralInLST}, maxUsedCollateral: ${maxUsedCollateral}`);
|
|
31457
31462
|
maxUsedCollateral = maxUsedCollateralInLST;
|
|
31458
|
-
const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON
|
|
31463
|
+
const STEP2_ID = getVesuGenericLegId(params.poolId.toString(), "switch_delegation_on" /* SWITCH_DELEGATION_ON */);
|
|
31459
31464
|
const manage2Info = this.getProofs(STEP2_ID);
|
|
31460
31465
|
const manageCall2 = manage2Info.callConstructor({
|
|
31461
31466
|
delegation: true
|
|
31462
31467
|
});
|
|
31463
|
-
const STEP3_ID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, vesuAdapter1.config.debt.symbol);
|
|
31468
|
+
const STEP3_ID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, vesuAdapter1.config.debt.symbol, vesuAdapter1.config.poolId.toString());
|
|
31464
31469
|
const manage3Info = this.getProofs(STEP3_ID);
|
|
31465
31470
|
const multiplyParams = params.isIncrease ? {
|
|
31466
31471
|
isIncrease: true,
|
|
@@ -31487,7 +31492,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31487
31492
|
}
|
|
31488
31493
|
};
|
|
31489
31494
|
const manageCall3 = manage3Info.callConstructor(multiplyParams);
|
|
31490
|
-
const STEP4_ID = "switch_delegation_off" /* SWITCH_DELEGATION_OFF
|
|
31495
|
+
const STEP4_ID = getVesuGenericLegId(params.poolId.toString(), "switch_delegation_off" /* SWITCH_DELEGATION_OFF */);
|
|
31491
31496
|
const manage4Info = this.getProofs(STEP4_ID);
|
|
31492
31497
|
const manageCall4 = manage4Info.callConstructor({
|
|
31493
31498
|
delegation: false
|
|
@@ -31547,20 +31552,46 @@ function getDescription2(tokenSymbol, underlyingSymbol) {
|
|
|
31547
31552
|
function getAvnuManageIDs(baseID, debtTokenSymbol) {
|
|
31548
31553
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}`;
|
|
31549
31554
|
}
|
|
31550
|
-
function
|
|
31551
|
-
return `${
|
|
31555
|
+
function getVesuGenericLegId(poolId, action) {
|
|
31556
|
+
return `${action}_${poolId.slice(-4).toLowerCase()}`;
|
|
31552
31557
|
}
|
|
31553
|
-
function
|
|
31554
|
-
|
|
31558
|
+
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
31559
|
+
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
31560
|
+
}
|
|
31561
|
+
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
31555
31562
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
31556
31563
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
31557
31564
|
const vesuAdapterLST = new VesuAdapter({
|
|
31558
|
-
poolId
|
|
31565
|
+
poolId,
|
|
31559
31566
|
collateral: lstToken,
|
|
31560
31567
|
debt: underlyingToken,
|
|
31561
31568
|
vaultAllocator: vaultSettings.vaultAllocator,
|
|
31562
|
-
id: getVesuLegId("vesu_leg1" /* VESU_LEG1 */, underlyingToken.symbol)
|
|
31569
|
+
id: getVesuLegId("vesu_leg1" /* VESU_LEG1 */, underlyingToken.symbol, poolId.toString())
|
|
31563
31570
|
});
|
|
31571
|
+
vaultSettings.adapters.push(...[{
|
|
31572
|
+
id: getVesuLegId("vesu_leg1" /* VESU_LEG1 */, underlyingToken.symbol, poolId.toString()),
|
|
31573
|
+
adapter: vesuAdapterLST
|
|
31574
|
+
}]);
|
|
31575
|
+
const { isV2, addr: _ } = getVesuSingletonAddress(poolId);
|
|
31576
|
+
const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
|
|
31577
|
+
const leafIdApprove = getVesuGenericLegId(poolId.toString(), "multiple_approve" /* MULTIPLE_APPROVE */);
|
|
31578
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, leafIdApprove).bind(commonAdapter));
|
|
31579
|
+
const leafIdDelegationOn = getVesuGenericLegId(poolId.toString(), "switch_delegation_on" /* SWITCH_DELEGATION_ON */);
|
|
31580
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn).bind(vesuAdapterLST));
|
|
31581
|
+
const leafIdDelegationOff = getVesuGenericLegId(poolId.toString(), "switch_delegation_off" /* SWITCH_DELEGATION_OFF */);
|
|
31582
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff).bind(vesuAdapterLST));
|
|
31583
|
+
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
31584
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
31585
|
+
return vesuAdapterLST;
|
|
31586
|
+
}
|
|
31587
|
+
function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, defaultPoolId, altSupportedPoolIds = []) {
|
|
31588
|
+
vaultSettings.leafAdapters = [];
|
|
31589
|
+
const pool1 = vaultSettings.defaultPoolId;
|
|
31590
|
+
if (!pool1.eq(defaultPoolId)) {
|
|
31591
|
+
throw new Error(`Dont include default pool id in supported pool ids`);
|
|
31592
|
+
}
|
|
31593
|
+
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
31594
|
+
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
31564
31595
|
const commonAdapter = new CommonAdapter({
|
|
31565
31596
|
manager: vaultSettings.manager,
|
|
31566
31597
|
asset: lstToken.address,
|
|
@@ -31569,17 +31600,11 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
|
|
|
31569
31600
|
vaultAllocator: vaultSettings.vaultAllocator
|
|
31570
31601
|
});
|
|
31571
31602
|
vaultSettings.adapters.push(...[{
|
|
31572
|
-
id: getVesuLegId("vesu_leg1" /* VESU_LEG1 */, underlyingToken.symbol),
|
|
31573
|
-
adapter: vesuAdapterLST
|
|
31574
|
-
}, {
|
|
31575
31603
|
id: "common_adapter" /* COMMON */,
|
|
31576
31604
|
adapter: commonAdapter
|
|
31577
31605
|
}]);
|
|
31578
|
-
const
|
|
31579
|
-
|
|
31580
|
-
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "multiple_approve" /* MULTIPLE_APPROVE */).bind(commonAdapter));
|
|
31581
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
|
|
31582
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
|
|
31606
|
+
const vesuAdapterLST = addVesuLeaves(defaultPoolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter);
|
|
31607
|
+
altSupportedPoolIds.map((poolId) => addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter));
|
|
31583
31608
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, AVNU_EXCHANGE, "avnu_mul_approve_withdr" /* AVNU_MULTIPLY_APPROVE_WITHDRAW */).bind(commonAdapter));
|
|
31584
31609
|
for (let borrowableAsset of vaultSettings.borrowable_assets) {
|
|
31585
31610
|
const debtAsset = borrowableAsset;
|
|
@@ -31594,12 +31619,14 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
|
|
|
31594
31619
|
collateral: lstToken,
|
|
31595
31620
|
debt: debtAsset,
|
|
31596
31621
|
vaultAllocator: vaultSettings.vaultAllocator,
|
|
31597
|
-
id: getVesuLegId("vesu_leg1" /* VESU_LEG1 */, debtAsset.symbol)
|
|
31622
|
+
id: getVesuLegId("vesu_leg1" /* VESU_LEG1 */, debtAsset.symbol, pool1.toString())
|
|
31598
31623
|
});
|
|
31624
|
+
const { isV2, addr: poolAddr } = getVesuSingletonAddress(pool1);
|
|
31599
31625
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
31600
31626
|
vaultSettings.leafAdapters.push(vesuAdapter.getModifyPosition.bind(vesuAdapter));
|
|
31601
|
-
|
|
31602
|
-
|
|
31627
|
+
if (borrowableAsset.address.eq(underlyingToken.address)) {
|
|
31628
|
+
continue;
|
|
31629
|
+
}
|
|
31603
31630
|
}
|
|
31604
31631
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
|
|
31605
31632
|
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
|
|
@@ -31679,7 +31706,9 @@ var hyperxSTRK = {
|
|
|
31679
31706
|
targetHealthFactor: 1.1,
|
|
31680
31707
|
minHealthFactor: 1.05,
|
|
31681
31708
|
borrowable_assets: Global.getDefaultTokens().filter((token) => token.symbol === "STRK"),
|
|
31682
|
-
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK")
|
|
31709
|
+
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
31710
|
+
defaultPoolId: VesuPools.Re7xSTRK,
|
|
31711
|
+
altSupportedPoolIds: [VesuPools.Prime]
|
|
31683
31712
|
};
|
|
31684
31713
|
var hyperxWBTC = {
|
|
31685
31714
|
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
|
@@ -31692,7 +31721,9 @@ var hyperxWBTC = {
|
|
|
31692
31721
|
targetHealthFactor: 1.1,
|
|
31693
31722
|
minHealthFactor: 1.05,
|
|
31694
31723
|
borrowable_assets: borrowableAssets.map((asset) => Global.getDefaultTokens().find((token) => token.symbol === asset)),
|
|
31695
|
-
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "WBTC")
|
|
31724
|
+
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
|
|
31725
|
+
defaultPoolId: VesuPools.Re7xBTC,
|
|
31726
|
+
altSupportedPoolIds: []
|
|
31696
31727
|
};
|
|
31697
31728
|
var hyperxtBTC = {
|
|
31698
31729
|
vaultAddress: ContractAddr.from("0x47d5f68477e5637ce0e56436c6b5eee5a354e6828995dae106b11a48679328"),
|
|
@@ -31705,7 +31736,9 @@ var hyperxtBTC = {
|
|
|
31705
31736
|
targetHealthFactor: 1.1,
|
|
31706
31737
|
minHealthFactor: 1.05,
|
|
31707
31738
|
borrowable_assets: Global.getDefaultTokens().filter((token) => token.symbol === "tBTC" || token.symbol === "WBTC"),
|
|
31708
|
-
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "tBTC")
|
|
31739
|
+
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "tBTC"),
|
|
31740
|
+
defaultPoolId: VesuPools.Re7xBTC,
|
|
31741
|
+
altSupportedPoolIds: []
|
|
31709
31742
|
};
|
|
31710
31743
|
var hyperxsBTC = {
|
|
31711
31744
|
vaultAddress: ContractAddr.from("0x437ef1e7d0f100b2e070b7a65cafec0b2be31b0290776da8b4112f5473d8d9"),
|
|
@@ -31718,7 +31751,9 @@ var hyperxsBTC = {
|
|
|
31718
31751
|
targetHealthFactor: 1.1,
|
|
31719
31752
|
minHealthFactor: 1.05,
|
|
31720
31753
|
borrowable_assets: Global.getDefaultTokens().filter((token) => token.symbol === "solvBTC"),
|
|
31721
|
-
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "solvBTC")
|
|
31754
|
+
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "solvBTC"),
|
|
31755
|
+
defaultPoolId: VesuPools.Re7xBTC,
|
|
31756
|
+
altSupportedPoolIds: []
|
|
31722
31757
|
};
|
|
31723
31758
|
var hyperxLBTC = {
|
|
31724
31759
|
vaultAddress: ContractAddr.from("0x64cf24d4883fe569926419a0569ab34497c6956a1a308fa883257f7486d7030"),
|
|
@@ -31731,7 +31766,9 @@ var hyperxLBTC = {
|
|
|
31731
31766
|
targetHealthFactor: 1.1,
|
|
31732
31767
|
minHealthFactor: 1.05,
|
|
31733
31768
|
borrowable_assets: Global.getDefaultTokens().filter((token) => token.symbol === "LBTC"),
|
|
31734
|
-
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "LBTC")
|
|
31769
|
+
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "LBTC"),
|
|
31770
|
+
defaultPoolId: VesuPools.Re7xBTC,
|
|
31771
|
+
altSupportedPoolIds: []
|
|
31735
31772
|
};
|
|
31736
31773
|
function getInvestmentSteps(lstSymbol, underlyingSymbol) {
|
|
31737
31774
|
return [
|
|
@@ -31750,7 +31787,7 @@ function getStrategySettings(lstSymbol, underlyingSymbol, addresses, isPreview =
|
|
|
31750
31787
|
launchBlock: 0,
|
|
31751
31788
|
type: "Other",
|
|
31752
31789
|
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
|
|
31753
|
-
additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, lstSymbol === "xSTRK" ? VesuPools.
|
|
31790
|
+
additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, addresses.defaultPoolId, lstSymbol === "xSTRK" ? [VesuPools.Prime] : []),
|
|
31754
31791
|
risk: {
|
|
31755
31792
|
riskFactor: _riskFactor4,
|
|
31756
31793
|
netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
|
package/dist/index.d.ts
CHANGED
|
@@ -1155,6 +1155,7 @@ declare const VesuPools: {
|
|
|
1155
1155
|
Genesis: ContractAddr;
|
|
1156
1156
|
Re7xSTRK: ContractAddr;
|
|
1157
1157
|
Re7xBTC: ContractAddr;
|
|
1158
|
+
Prime: ContractAddr;
|
|
1158
1159
|
};
|
|
1159
1160
|
declare const extensionMap: {
|
|
1160
1161
|
[key: string]: ContractAddr;
|
|
@@ -1209,7 +1210,11 @@ declare class VesuAdapter extends BaseAdapter {
|
|
|
1209
1210
|
};
|
|
1210
1211
|
getDebtCap(config: IConfig): Promise<Web3Number>;
|
|
1211
1212
|
getCurrentDebtUtilisationAmount(config: IConfig): Promise<Web3Number>;
|
|
1212
|
-
getMaxBorrowableByInterestRate(config: IConfig, asset: TokenInfo, maxBorrowAPY: number): Promise<
|
|
1213
|
+
getMaxBorrowableByInterestRate(config: IConfig, asset: TokenInfo, maxBorrowAPY: number): Promise<{
|
|
1214
|
+
maxDebtToHave: Web3Number;
|
|
1215
|
+
currentDebt: Web3Number;
|
|
1216
|
+
totalSupply: Web3Number;
|
|
1217
|
+
}>;
|
|
1213
1218
|
getLTVConfig(config: IConfig, blockNumber?: BlockIdentifier): Promise<number>;
|
|
1214
1219
|
getPositions(config: IConfig, blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
|
|
1215
1220
|
getCollateralization(config: IConfig, blockNumber?: BlockIdentifier): Promise<Omit<VaultPosition, 'amount'>[]>;
|
|
@@ -1425,13 +1430,15 @@ declare const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[
|
|
|
1425
1430
|
interface HyperLSTStrategySettings extends UniversalStrategySettings {
|
|
1426
1431
|
borrowable_assets: TokenInfo[];
|
|
1427
1432
|
underlyingToken: TokenInfo;
|
|
1433
|
+
defaultPoolId: ContractAddr;
|
|
1434
|
+
altSupportedPoolIds: ContractAddr[];
|
|
1428
1435
|
}
|
|
1429
1436
|
declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTStrategySettings> {
|
|
1430
1437
|
private quoteAmountToFetchPrice;
|
|
1431
1438
|
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<HyperLSTStrategySettings>);
|
|
1432
1439
|
asset(): TokenInfo;
|
|
1433
1440
|
getTag(): string;
|
|
1434
|
-
getVesuSameTokenAdapter(): VesuAdapter;
|
|
1441
|
+
getVesuSameTokenAdapter(poolId: ContractAddr): VesuAdapter;
|
|
1435
1442
|
getVesuAdapters(): VesuAdapter[];
|
|
1436
1443
|
protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
|
|
1437
1444
|
getLSTDexPrice(): Promise<number>;
|
|
@@ -1471,6 +1478,7 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTS
|
|
|
1471
1478
|
isDeposit: boolean;
|
|
1472
1479
|
leg1DepositAmount: Web3Number;
|
|
1473
1480
|
maxEkuboPriceImpact?: number;
|
|
1481
|
+
poolId: ContractAddr;
|
|
1474
1482
|
}): Promise<Call[]>;
|
|
1475
1483
|
getLSTUnderlyingTokenInfo(): TokenInfo;
|
|
1476
1484
|
getMaxBorrowableAmount(params?: {
|
|
@@ -1482,6 +1490,7 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTS
|
|
|
1482
1490
|
dexSwappableAmount: Web3Number;
|
|
1483
1491
|
maxBorrowableAmount: Web3Number;
|
|
1484
1492
|
borrowableAsset: TokenInfo;
|
|
1493
|
+
ltv: number;
|
|
1485
1494
|
}[];
|
|
1486
1495
|
}>;
|
|
1487
1496
|
getMaxSwappableWithMaxSlippage(fromToken: TokenInfo, toToken: TokenInfo, maxSlippage: number, maxAmount: Web3Number): Promise<Web3Number>;
|
|
@@ -1521,6 +1530,7 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTS
|
|
|
1521
1530
|
lstDexPriceInUnderlying: number;
|
|
1522
1531
|
isIncrease: boolean;
|
|
1523
1532
|
maxEkuboPriceImpact: number;
|
|
1533
|
+
poolId: ContractAddr;
|
|
1524
1534
|
}): Promise<Call[]>;
|
|
1525
1535
|
}
|
|
1526
1536
|
declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
|