@strkfarm/sdk 2.0.0-staging.22 → 2.0.0-staging.23
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 +76 -10
- package/dist/index.browser.mjs +76 -10
- package/dist/index.d.ts +23 -4
- package/dist/index.js +77 -10
- package/dist/index.mjs +76 -10
- package/package.json +1 -1
- package/src/strategies/index.ts +1 -0
- package/src/strategies/types.ts +4 -0
- package/src/strategies/universal-lst-muliplier-strategy.tsx +94 -8
- package/src/strategies/universal-strategy.tsx +6 -3
|
@@ -27931,6 +27931,7 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
27931
27931
|
Initializable: () => Initializable,
|
|
27932
27932
|
InstantWithdrawalVault: () => InstantWithdrawalVault,
|
|
27933
27933
|
LSTAPRService: () => LSTAPRService,
|
|
27934
|
+
LSTPriceType: () => LSTPriceType,
|
|
27934
27935
|
MarginType: () => MarginType,
|
|
27935
27936
|
MyNumber: () => MyNumber,
|
|
27936
27937
|
Network: () => Network2,
|
|
@@ -118344,6 +118345,13 @@ spurious results.`);
|
|
|
118344
118345
|
}
|
|
118345
118346
|
];
|
|
118346
118347
|
|
|
118348
|
+
// src/strategies/types.ts
|
|
118349
|
+
var LSTPriceType = /* @__PURE__ */ ((LSTPriceType2) => {
|
|
118350
|
+
LSTPriceType2["ENDUR_PRICE"] = "ENDUR_PRICE";
|
|
118351
|
+
LSTPriceType2["AVNU_PRICE"] = "AVNU_PRICE";
|
|
118352
|
+
return LSTPriceType2;
|
|
118353
|
+
})(LSTPriceType || {});
|
|
118354
|
+
|
|
118347
118355
|
// src/strategies/universal-strategy.tsx
|
|
118348
118356
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime());
|
|
118349
118357
|
var AUMTypes = /* @__PURE__ */ ((AUMTypes3) => {
|
|
@@ -118652,7 +118660,7 @@ spurious results.`);
|
|
|
118652
118660
|
usdValue
|
|
118653
118661
|
};
|
|
118654
118662
|
}
|
|
118655
|
-
async getVesuAUM(adapter2) {
|
|
118663
|
+
async getVesuAUM(adapter2, _priceType) {
|
|
118656
118664
|
const legAUM = await adapter2.getPositions(this.config);
|
|
118657
118665
|
const underlying = this.asset();
|
|
118658
118666
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
@@ -118678,13 +118686,15 @@ spurious results.`);
|
|
|
118678
118686
|
logger2.verbose(`${this.getTag()} Prev AUM: ${prevAum}`);
|
|
118679
118687
|
return prevAum;
|
|
118680
118688
|
}
|
|
118681
|
-
async getAUM() {
|
|
118689
|
+
async getAUM(unrealizedAUM) {
|
|
118682
118690
|
const prevAum = await this.getPrevAUM();
|
|
118683
118691
|
const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
118684
118692
|
const vesuAdapters = this.getVesuAdapters();
|
|
118685
118693
|
let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
|
|
118686
118694
|
for (const adapter2 of vesuAdapters) {
|
|
118687
|
-
|
|
118695
|
+
const priceType = unrealizedAUM ? "ENDUR_PRICE" /* ENDUR_PRICE */ : "AVNU_PRICE" /* AVNU_PRICE */;
|
|
118696
|
+
const aumValue = await this.getVesuAUM(adapter2, priceType);
|
|
118697
|
+
vesuAum = vesuAum.plus(aumValue);
|
|
118688
118698
|
}
|
|
118689
118699
|
const balance = await this.getUnusedBalance();
|
|
118690
118700
|
logger2.verbose(`${this.getTag()} unused balance: ${balance.amount.toNumber()}`);
|
|
@@ -119659,7 +119669,6 @@ spurious results.`);
|
|
|
119659
119669
|
assert3(calls.length == 1, `Expected 1 call for unwind, got ${calls.length}`);
|
|
119660
119670
|
return calls[0];
|
|
119661
119671
|
}
|
|
119662
|
-
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
119663
119672
|
const STEP0 = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
119664
119673
|
const manage0Info = this.getProofs(STEP0);
|
|
119665
119674
|
const manageCall0 = manage0Info.callConstructor({
|
|
@@ -119673,7 +119682,6 @@ spurious results.`);
|
|
|
119673
119682
|
debtAmount,
|
|
119674
119683
|
isBorrow: params.isDeposit
|
|
119675
119684
|
}));
|
|
119676
|
-
console.log(`manageCall1`, manageCall1.call, debtAmount.toWei(), newDepositAmount.toWei());
|
|
119677
119685
|
const proofIds = [STEP0, STEP1];
|
|
119678
119686
|
const manageCalls = [manageCall0, manageCall1];
|
|
119679
119687
|
if (debtAmount.gt(0)) {
|
|
@@ -119778,14 +119786,33 @@ spurious results.`);
|
|
|
119778
119786
|
return { shouldRebalance: false, manageCall: void 0 };
|
|
119779
119787
|
}
|
|
119780
119788
|
}
|
|
119781
|
-
async getVesuAUM(adapter2) {
|
|
119789
|
+
async getVesuAUM(adapter2, priceType = "AVNU_PRICE" /* AVNU_PRICE */) {
|
|
119782
119790
|
const legAUM = await adapter2.getPositions(this.config);
|
|
119783
119791
|
const underlying = this.asset();
|
|
119784
119792
|
assert3(underlying.symbol.startsWith("x"), "Underlying is not an LST of Endur");
|
|
119785
119793
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
119786
|
-
let tokenUnderlyingPrice
|
|
119787
|
-
|
|
119788
|
-
|
|
119794
|
+
let tokenUnderlyingPrice;
|
|
119795
|
+
if (priceType === "ENDUR_PRICE" /* ENDUR_PRICE */) {
|
|
119796
|
+
tokenUnderlyingPrice = await this.getLSTExchangeRate();
|
|
119797
|
+
if (tokenUnderlyingPrice === 0) {
|
|
119798
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Endur) is 0`);
|
|
119799
|
+
}
|
|
119800
|
+
const avnuRate = await this.getLSTAvnuRate();
|
|
119801
|
+
if (avnuRate === 0) {
|
|
119802
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
119803
|
+
}
|
|
119804
|
+
const diff = Math.abs(tokenUnderlyingPrice - avnuRate) / tokenUnderlyingPrice;
|
|
119805
|
+
if (diff > 0.02) {
|
|
119806
|
+
throw new Error(`${this.getTag()}::getVesuAUM: Endur and Avnu prices differ by more than 2% (Endur: ${tokenUnderlyingPrice}, Avnu: ${avnuRate})`);
|
|
119807
|
+
}
|
|
119808
|
+
logger2.verbose(`${this.getTag()} tokenUnderlyingPrice (Endur): ${tokenUnderlyingPrice}, avnuRate: ${avnuRate}, diff: ${diff}`);
|
|
119809
|
+
} else {
|
|
119810
|
+
tokenUnderlyingPrice = await this.getLSTAvnuRate();
|
|
119811
|
+
if (tokenUnderlyingPrice === 0) {
|
|
119812
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
119813
|
+
}
|
|
119814
|
+
logger2.verbose(`${this.getTag()} tokenUnderlyingPrice (Avnu): ${tokenUnderlyingPrice}`);
|
|
119815
|
+
}
|
|
119789
119816
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
119790
119817
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
119791
119818
|
} else {
|
|
@@ -119797,9 +119824,26 @@ spurious results.`);
|
|
|
119797
119824
|
vesuAum = vesuAum.minus(legAUM[1].amount.dividedBy(tokenUnderlyingPrice));
|
|
119798
119825
|
}
|
|
119799
119826
|
;
|
|
119800
|
-
|
|
119827
|
+
const priceTypeLabel = priceType === "ENDUR_PRICE" /* ENDUR_PRICE */ ? "Endur Price" : "Avnu Price";
|
|
119828
|
+
logger2.verbose(`${this.getTag()} Vesu AUM (${priceTypeLabel}): ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
|
|
119801
119829
|
return vesuAum;
|
|
119802
119830
|
}
|
|
119831
|
+
async getTVLUnrealized() {
|
|
119832
|
+
return await this.getAUM(true);
|
|
119833
|
+
}
|
|
119834
|
+
async getUserUnrealizedGains(user) {
|
|
119835
|
+
const tvl = await this.getTVL();
|
|
119836
|
+
const unrealizedTVL = await this.getTVLUnrealized();
|
|
119837
|
+
const unrealizedDiff = unrealizedTVL.net.amount.minus(tvl.amount);
|
|
119838
|
+
const userTVL = await this.getUserTVL(user);
|
|
119839
|
+
const userShare = userTVL.amount.dividedBy(tvl.amount);
|
|
119840
|
+
const unrealizedGains = unrealizedDiff.multipliedBy(userShare);
|
|
119841
|
+
return {
|
|
119842
|
+
unrealizedGains,
|
|
119843
|
+
userShare: userShare.toNumber(),
|
|
119844
|
+
tokenInfo: this.asset()
|
|
119845
|
+
};
|
|
119846
|
+
}
|
|
119803
119847
|
//
|
|
119804
119848
|
async _getMinOutputAmountLSTBuy(amountInUnderlying) {
|
|
119805
119849
|
const lstTruePrice = await this.getLSTExchangeRate();
|
|
@@ -119983,6 +120027,28 @@ spurious results.`);
|
|
|
119983
120027
|
weight: unusedBalance.usdValue
|
|
119984
120028
|
};
|
|
119985
120029
|
}
|
|
120030
|
+
async getLSTAvnuRate() {
|
|
120031
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
120032
|
+
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
120033
|
+
const underlyingTokenInfo = vesuAdapter1.config.debt;
|
|
120034
|
+
const avnuModule = new AvnuWrapper();
|
|
120035
|
+
const sellAmount = lstTokenInfo.priceCheckAmount ? new Web3Number(lstTokenInfo.priceCheckAmount, underlyingTokenInfo.decimals) : new Web3Number(1, underlyingTokenInfo.decimals);
|
|
120036
|
+
const quote = await avnuModule.getQuotes(
|
|
120037
|
+
underlyingTokenInfo.address.address,
|
|
120038
|
+
lstTokenInfo.address.address,
|
|
120039
|
+
sellAmount.toWei(),
|
|
120040
|
+
this.metadata.additionalInfo.vaultAllocator.address
|
|
120041
|
+
);
|
|
120042
|
+
const underlyingAmountNumber = sellAmount.toNumber();
|
|
120043
|
+
const lstAmountNumber = Web3Number.fromWei(
|
|
120044
|
+
quote.buyAmount.toString(),
|
|
120045
|
+
lstTokenInfo.decimals
|
|
120046
|
+
).toNumber();
|
|
120047
|
+
assert3(lstAmountNumber > 0, "Avnu LST amount is zero");
|
|
120048
|
+
const exchangeRate = underlyingAmountNumber / lstAmountNumber;
|
|
120049
|
+
logger2.verbose(`${this.getTag()}:: LST Avnu Exchange Rate: ${exchangeRate}`);
|
|
120050
|
+
return exchangeRate;
|
|
120051
|
+
}
|
|
119986
120052
|
async getLSTExchangeRate() {
|
|
119987
120053
|
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
119988
120054
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
package/dist/index.browser.mjs
CHANGED
|
@@ -30944,6 +30944,13 @@ var vault_manager_abi_default = [
|
|
|
30944
30944
|
}
|
|
30945
30945
|
];
|
|
30946
30946
|
|
|
30947
|
+
// src/strategies/types.ts
|
|
30948
|
+
var LSTPriceType = /* @__PURE__ */ ((LSTPriceType2) => {
|
|
30949
|
+
LSTPriceType2["ENDUR_PRICE"] = "ENDUR_PRICE";
|
|
30950
|
+
LSTPriceType2["AVNU_PRICE"] = "AVNU_PRICE";
|
|
30951
|
+
return LSTPriceType2;
|
|
30952
|
+
})(LSTPriceType || {});
|
|
30953
|
+
|
|
30947
30954
|
// src/strategies/universal-strategy.tsx
|
|
30948
30955
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
30949
30956
|
var AUMTypes = /* @__PURE__ */ ((AUMTypes3) => {
|
|
@@ -31252,7 +31259,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31252
31259
|
usdValue
|
|
31253
31260
|
};
|
|
31254
31261
|
}
|
|
31255
|
-
async getVesuAUM(adapter) {
|
|
31262
|
+
async getVesuAUM(adapter, _priceType) {
|
|
31256
31263
|
const legAUM = await adapter.getPositions(this.config);
|
|
31257
31264
|
const underlying = this.asset();
|
|
31258
31265
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
@@ -31278,13 +31285,15 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31278
31285
|
logger.verbose(`${this.getTag()} Prev AUM: ${prevAum}`);
|
|
31279
31286
|
return prevAum;
|
|
31280
31287
|
}
|
|
31281
|
-
async getAUM() {
|
|
31288
|
+
async getAUM(unrealizedAUM) {
|
|
31282
31289
|
const prevAum = await this.getPrevAUM();
|
|
31283
31290
|
const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
31284
31291
|
const vesuAdapters = this.getVesuAdapters();
|
|
31285
31292
|
let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
|
|
31286
31293
|
for (const adapter of vesuAdapters) {
|
|
31287
|
-
|
|
31294
|
+
const priceType = unrealizedAUM ? "ENDUR_PRICE" /* ENDUR_PRICE */ : "AVNU_PRICE" /* AVNU_PRICE */;
|
|
31295
|
+
const aumValue = await this.getVesuAUM(adapter, priceType);
|
|
31296
|
+
vesuAum = vesuAum.plus(aumValue);
|
|
31288
31297
|
}
|
|
31289
31298
|
const balance = await this.getUnusedBalance();
|
|
31290
31299
|
logger.verbose(`${this.getTag()} unused balance: ${balance.amount.toNumber()}`);
|
|
@@ -32262,7 +32271,6 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32262
32271
|
assert(calls.length == 1, `Expected 1 call for unwind, got ${calls.length}`);
|
|
32263
32272
|
return calls[0];
|
|
32264
32273
|
}
|
|
32265
|
-
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
32266
32274
|
const STEP0 = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
32267
32275
|
const manage0Info = this.getProofs(STEP0);
|
|
32268
32276
|
const manageCall0 = manage0Info.callConstructor({
|
|
@@ -32276,7 +32284,6 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32276
32284
|
debtAmount,
|
|
32277
32285
|
isBorrow: params.isDeposit
|
|
32278
32286
|
}));
|
|
32279
|
-
console.log(`manageCall1`, manageCall1.call, debtAmount.toWei(), newDepositAmount.toWei());
|
|
32280
32287
|
const proofIds = [STEP0, STEP1];
|
|
32281
32288
|
const manageCalls = [manageCall0, manageCall1];
|
|
32282
32289
|
if (debtAmount.gt(0)) {
|
|
@@ -32381,14 +32388,33 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32381
32388
|
return { shouldRebalance: false, manageCall: void 0 };
|
|
32382
32389
|
}
|
|
32383
32390
|
}
|
|
32384
|
-
async getVesuAUM(adapter) {
|
|
32391
|
+
async getVesuAUM(adapter, priceType = "AVNU_PRICE" /* AVNU_PRICE */) {
|
|
32385
32392
|
const legAUM = await adapter.getPositions(this.config);
|
|
32386
32393
|
const underlying = this.asset();
|
|
32387
32394
|
assert(underlying.symbol.startsWith("x"), "Underlying is not an LST of Endur");
|
|
32388
32395
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
32389
|
-
let tokenUnderlyingPrice
|
|
32390
|
-
|
|
32391
|
-
|
|
32396
|
+
let tokenUnderlyingPrice;
|
|
32397
|
+
if (priceType === "ENDUR_PRICE" /* ENDUR_PRICE */) {
|
|
32398
|
+
tokenUnderlyingPrice = await this.getLSTExchangeRate();
|
|
32399
|
+
if (tokenUnderlyingPrice === 0) {
|
|
32400
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Endur) is 0`);
|
|
32401
|
+
}
|
|
32402
|
+
const avnuRate = await this.getLSTAvnuRate();
|
|
32403
|
+
if (avnuRate === 0) {
|
|
32404
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
32405
|
+
}
|
|
32406
|
+
const diff = Math.abs(tokenUnderlyingPrice - avnuRate) / tokenUnderlyingPrice;
|
|
32407
|
+
if (diff > 0.02) {
|
|
32408
|
+
throw new Error(`${this.getTag()}::getVesuAUM: Endur and Avnu prices differ by more than 2% (Endur: ${tokenUnderlyingPrice}, Avnu: ${avnuRate})`);
|
|
32409
|
+
}
|
|
32410
|
+
logger.verbose(`${this.getTag()} tokenUnderlyingPrice (Endur): ${tokenUnderlyingPrice}, avnuRate: ${avnuRate}, diff: ${diff}`);
|
|
32411
|
+
} else {
|
|
32412
|
+
tokenUnderlyingPrice = await this.getLSTAvnuRate();
|
|
32413
|
+
if (tokenUnderlyingPrice === 0) {
|
|
32414
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
32415
|
+
}
|
|
32416
|
+
logger.verbose(`${this.getTag()} tokenUnderlyingPrice (Avnu): ${tokenUnderlyingPrice}`);
|
|
32417
|
+
}
|
|
32392
32418
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
32393
32419
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
32394
32420
|
} else {
|
|
@@ -32400,9 +32426,26 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32400
32426
|
vesuAum = vesuAum.minus(legAUM[1].amount.dividedBy(tokenUnderlyingPrice));
|
|
32401
32427
|
}
|
|
32402
32428
|
;
|
|
32403
|
-
|
|
32429
|
+
const priceTypeLabel = priceType === "ENDUR_PRICE" /* ENDUR_PRICE */ ? "Endur Price" : "Avnu Price";
|
|
32430
|
+
logger.verbose(`${this.getTag()} Vesu AUM (${priceTypeLabel}): ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
|
|
32404
32431
|
return vesuAum;
|
|
32405
32432
|
}
|
|
32433
|
+
async getTVLUnrealized() {
|
|
32434
|
+
return await this.getAUM(true);
|
|
32435
|
+
}
|
|
32436
|
+
async getUserUnrealizedGains(user) {
|
|
32437
|
+
const tvl = await this.getTVL();
|
|
32438
|
+
const unrealizedTVL = await this.getTVLUnrealized();
|
|
32439
|
+
const unrealizedDiff = unrealizedTVL.net.amount.minus(tvl.amount);
|
|
32440
|
+
const userTVL = await this.getUserTVL(user);
|
|
32441
|
+
const userShare = userTVL.amount.dividedBy(tvl.amount);
|
|
32442
|
+
const unrealizedGains = unrealizedDiff.multipliedBy(userShare);
|
|
32443
|
+
return {
|
|
32444
|
+
unrealizedGains,
|
|
32445
|
+
userShare: userShare.toNumber(),
|
|
32446
|
+
tokenInfo: this.asset()
|
|
32447
|
+
};
|
|
32448
|
+
}
|
|
32406
32449
|
//
|
|
32407
32450
|
async _getMinOutputAmountLSTBuy(amountInUnderlying) {
|
|
32408
32451
|
const lstTruePrice = await this.getLSTExchangeRate();
|
|
@@ -32586,6 +32629,28 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32586
32629
|
weight: unusedBalance.usdValue
|
|
32587
32630
|
};
|
|
32588
32631
|
}
|
|
32632
|
+
async getLSTAvnuRate() {
|
|
32633
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
32634
|
+
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
32635
|
+
const underlyingTokenInfo = vesuAdapter1.config.debt;
|
|
32636
|
+
const avnuModule = new AvnuWrapper();
|
|
32637
|
+
const sellAmount = lstTokenInfo.priceCheckAmount ? new Web3Number(lstTokenInfo.priceCheckAmount, underlyingTokenInfo.decimals) : new Web3Number(1, underlyingTokenInfo.decimals);
|
|
32638
|
+
const quote = await avnuModule.getQuotes(
|
|
32639
|
+
underlyingTokenInfo.address.address,
|
|
32640
|
+
lstTokenInfo.address.address,
|
|
32641
|
+
sellAmount.toWei(),
|
|
32642
|
+
this.metadata.additionalInfo.vaultAllocator.address
|
|
32643
|
+
);
|
|
32644
|
+
const underlyingAmountNumber = sellAmount.toNumber();
|
|
32645
|
+
const lstAmountNumber = Web3Number.fromWei(
|
|
32646
|
+
quote.buyAmount.toString(),
|
|
32647
|
+
lstTokenInfo.decimals
|
|
32648
|
+
).toNumber();
|
|
32649
|
+
assert(lstAmountNumber > 0, "Avnu LST amount is zero");
|
|
32650
|
+
const exchangeRate = underlyingAmountNumber / lstAmountNumber;
|
|
32651
|
+
logger.verbose(`${this.getTag()}:: LST Avnu Exchange Rate: ${exchangeRate}`);
|
|
32652
|
+
return exchangeRate;
|
|
32653
|
+
}
|
|
32589
32654
|
async getLSTExchangeRate() {
|
|
32590
32655
|
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
32591
32656
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -33357,6 +33422,7 @@ export {
|
|
|
33357
33422
|
Initializable,
|
|
33358
33423
|
InstantWithdrawalVault,
|
|
33359
33424
|
LSTAPRService,
|
|
33425
|
+
LSTPriceType,
|
|
33360
33426
|
MarginType,
|
|
33361
33427
|
MyNumber,
|
|
33362
33428
|
Network,
|
package/dist/index.d.ts
CHANGED
|
@@ -1535,6 +1535,11 @@ declare const AVNU_EXCHANGE: ContractAddr;
|
|
|
1535
1535
|
declare const VESU_SINGLETON: ContractAddr;
|
|
1536
1536
|
declare function toBigInt(value: string | number): bigint;
|
|
1537
1537
|
|
|
1538
|
+
declare enum LSTPriceType {
|
|
1539
|
+
ENDUR_PRICE = "ENDUR_PRICE",
|
|
1540
|
+
AVNU_PRICE = "AVNU_PRICE"
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1538
1543
|
interface UniversalManageCall {
|
|
1539
1544
|
proofs: string[];
|
|
1540
1545
|
manageCall: ManageCall;
|
|
@@ -1629,9 +1634,9 @@ declare class UniversalStrategy<S extends UniversalStrategySettings> extends Bas
|
|
|
1629
1634
|
usdValue: number;
|
|
1630
1635
|
}>;
|
|
1631
1636
|
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
1632
|
-
protected getVesuAUM(adapter: VesuAdapter): Promise<Web3Number>;
|
|
1637
|
+
protected getVesuAUM(adapter: VesuAdapter, _priceType?: LSTPriceType): Promise<Web3Number>;
|
|
1633
1638
|
getPrevAUM(): Promise<Web3Number>;
|
|
1634
|
-
getAUM(): Promise<{
|
|
1639
|
+
getAUM(unrealizedAUM?: boolean): Promise<{
|
|
1635
1640
|
net: SingleTokenInfo;
|
|
1636
1641
|
prevAum: Web3Number;
|
|
1637
1642
|
splits: {
|
|
@@ -1750,7 +1755,20 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTS
|
|
|
1750
1755
|
shouldRebalance: boolean;
|
|
1751
1756
|
manageCall: Call | undefined;
|
|
1752
1757
|
}>;
|
|
1753
|
-
protected getVesuAUM(adapter: VesuAdapter): Promise<Web3Number>;
|
|
1758
|
+
protected getVesuAUM(adapter: VesuAdapter, priceType?: LSTPriceType): Promise<Web3Number>;
|
|
1759
|
+
getTVLUnrealized(): Promise<{
|
|
1760
|
+
net: SingleTokenInfo;
|
|
1761
|
+
prevAum: Web3Number;
|
|
1762
|
+
splits: {
|
|
1763
|
+
id: string;
|
|
1764
|
+
aum: Web3Number;
|
|
1765
|
+
}[];
|
|
1766
|
+
}>;
|
|
1767
|
+
getUserUnrealizedGains(user: ContractAddr): Promise<{
|
|
1768
|
+
unrealizedGains: Web3Number;
|
|
1769
|
+
userShare: number;
|
|
1770
|
+
tokenInfo: TokenInfo;
|
|
1771
|
+
}>;
|
|
1754
1772
|
private _getMinOutputAmountLSTBuy;
|
|
1755
1773
|
private _getMinOutputAmountLSTSell;
|
|
1756
1774
|
/**
|
|
@@ -1803,6 +1821,7 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTS
|
|
|
1803
1821
|
apy: number;
|
|
1804
1822
|
weight: number;
|
|
1805
1823
|
}>;
|
|
1824
|
+
getLSTAvnuRate(): Promise<number>;
|
|
1806
1825
|
getLSTExchangeRate(): Promise<number>;
|
|
1807
1826
|
/**
|
|
1808
1827
|
*
|
|
@@ -2184,4 +2203,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
2184
2203
|
decrypt(encryptedData: string, password: string): any;
|
|
2185
2204
|
}
|
|
2186
2205
|
|
|
2187
|
-
export { APYType, AUMTypes, AVNU_EXCHANGE, AVNU_MIDDLEWARE, type AccessControlInfo, AccessControlType, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type AmountInfo, type AmountsInfo, type ApproveCallParams, AuditStatus, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FactoryStrategyType, FatalError, type FilterOption, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, InstantWithdrawalVault, LSTAPRService, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, MyNumber, type NetAPYDetails, type NetAPYSplit, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, type PositionAPY, type PositionInfo, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerLST, PricerRedis, Protocols, type RedemptionInfo, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, type SecurityMetadata, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, type SourceCodeInfo, SourceCodeType, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type StrategyAlert, type StrategyCapabilities, type StrategyFilterMetadata, StrategyLiveStatus, type StrategyMetadata, type StrategyRegistryEntry, type StrategySettings, StrategyTag, StrategyType, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VaultType, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPoolMetadata, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, buildStrategyRegistry, createEkuboCLStrategy, createHyperLSTStrategy, createSenseiStrategy, createStrategy, createUniversalStrategy, createVesuRebalanceStrategy, detectCapabilities, extensionMap, getAPIUsingHeadlessBrowser, getAllStrategyMetadata, getAllStrategyTags, getContractDetails, getDefaultStoreConfig, getFilterMetadata, getLiveStrategies, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getStrategiesByType, getStrategyTagDesciption, getStrategyTypeFromMetadata, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, isDualTokenStrategy, logger, toAmountsInfo, toBigInt };
|
|
2206
|
+
export { APYType, AUMTypes, AVNU_EXCHANGE, AVNU_MIDDLEWARE, type AccessControlInfo, AccessControlType, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type AmountInfo, type AmountsInfo, type ApproveCallParams, AuditStatus, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FactoryStrategyType, FatalError, type FilterOption, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, InstantWithdrawalVault, LSTAPRService, LSTPriceType, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, MyNumber, type NetAPYDetails, type NetAPYSplit, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, type PositionAPY, type PositionInfo, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerLST, PricerRedis, Protocols, type RedemptionInfo, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, type SecurityMetadata, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, type SourceCodeInfo, SourceCodeType, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type StrategyAlert, type StrategyCapabilities, type StrategyFilterMetadata, StrategyLiveStatus, type StrategyMetadata, type StrategyRegistryEntry, type StrategySettings, StrategyTag, StrategyType, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VaultType, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPoolMetadata, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, buildStrategyRegistry, createEkuboCLStrategy, createHyperLSTStrategy, createSenseiStrategy, createStrategy, createUniversalStrategy, createVesuRebalanceStrategy, detectCapabilities, extensionMap, getAPIUsingHeadlessBrowser, getAllStrategyMetadata, getAllStrategyTags, getContractDetails, getDefaultStoreConfig, getFilterMetadata, getLiveStrategies, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getStrategiesByType, getStrategyTagDesciption, getStrategyTypeFromMetadata, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, isDualTokenStrategy, logger, toAmountsInfo, toBigInt };
|
package/dist/index.js
CHANGED
|
@@ -56,6 +56,7 @@ __export(index_exports, {
|
|
|
56
56
|
Initializable: () => Initializable,
|
|
57
57
|
InstantWithdrawalVault: () => InstantWithdrawalVault,
|
|
58
58
|
LSTAPRService: () => LSTAPRService,
|
|
59
|
+
LSTPriceType: () => LSTPriceType,
|
|
59
60
|
MarginType: () => MarginType,
|
|
60
61
|
MyNumber: () => MyNumber,
|
|
61
62
|
Network: () => Network,
|
|
@@ -31077,6 +31078,13 @@ var vault_manager_abi_default = [
|
|
|
31077
31078
|
}
|
|
31078
31079
|
];
|
|
31079
31080
|
|
|
31081
|
+
// src/strategies/types.ts
|
|
31082
|
+
var LSTPriceType = /* @__PURE__ */ ((LSTPriceType2) => {
|
|
31083
|
+
LSTPriceType2["ENDUR_PRICE"] = "ENDUR_PRICE";
|
|
31084
|
+
LSTPriceType2["AVNU_PRICE"] = "AVNU_PRICE";
|
|
31085
|
+
return LSTPriceType2;
|
|
31086
|
+
})(LSTPriceType || {});
|
|
31087
|
+
|
|
31080
31088
|
// src/strategies/universal-strategy.tsx
|
|
31081
31089
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
31082
31090
|
var AUMTypes = /* @__PURE__ */ ((AUMTypes3) => {
|
|
@@ -31385,7 +31393,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31385
31393
|
usdValue
|
|
31386
31394
|
};
|
|
31387
31395
|
}
|
|
31388
|
-
async getVesuAUM(adapter) {
|
|
31396
|
+
async getVesuAUM(adapter, _priceType) {
|
|
31389
31397
|
const legAUM = await adapter.getPositions(this.config);
|
|
31390
31398
|
const underlying = this.asset();
|
|
31391
31399
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
@@ -31411,13 +31419,15 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31411
31419
|
logger.verbose(`${this.getTag()} Prev AUM: ${prevAum}`);
|
|
31412
31420
|
return prevAum;
|
|
31413
31421
|
}
|
|
31414
|
-
async getAUM() {
|
|
31422
|
+
async getAUM(unrealizedAUM) {
|
|
31415
31423
|
const prevAum = await this.getPrevAUM();
|
|
31416
31424
|
const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
31417
31425
|
const vesuAdapters = this.getVesuAdapters();
|
|
31418
31426
|
let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
|
|
31419
31427
|
for (const adapter of vesuAdapters) {
|
|
31420
|
-
|
|
31428
|
+
const priceType = unrealizedAUM ? "ENDUR_PRICE" /* ENDUR_PRICE */ : "AVNU_PRICE" /* AVNU_PRICE */;
|
|
31429
|
+
const aumValue = await this.getVesuAUM(adapter, priceType);
|
|
31430
|
+
vesuAum = vesuAum.plus(aumValue);
|
|
31421
31431
|
}
|
|
31422
31432
|
const balance = await this.getUnusedBalance();
|
|
31423
31433
|
logger.verbose(`${this.getTag()} unused balance: ${balance.amount.toNumber()}`);
|
|
@@ -32395,7 +32405,6 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32395
32405
|
assert(calls.length == 1, `Expected 1 call for unwind, got ${calls.length}`);
|
|
32396
32406
|
return calls[0];
|
|
32397
32407
|
}
|
|
32398
|
-
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
32399
32408
|
const STEP0 = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
32400
32409
|
const manage0Info = this.getProofs(STEP0);
|
|
32401
32410
|
const manageCall0 = manage0Info.callConstructor({
|
|
@@ -32409,7 +32418,6 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32409
32418
|
debtAmount,
|
|
32410
32419
|
isBorrow: params.isDeposit
|
|
32411
32420
|
}));
|
|
32412
|
-
console.log(`manageCall1`, manageCall1.call, debtAmount.toWei(), newDepositAmount.toWei());
|
|
32413
32421
|
const proofIds = [STEP0, STEP1];
|
|
32414
32422
|
const manageCalls = [manageCall0, manageCall1];
|
|
32415
32423
|
if (debtAmount.gt(0)) {
|
|
@@ -32514,14 +32522,33 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32514
32522
|
return { shouldRebalance: false, manageCall: void 0 };
|
|
32515
32523
|
}
|
|
32516
32524
|
}
|
|
32517
|
-
async getVesuAUM(adapter) {
|
|
32525
|
+
async getVesuAUM(adapter, priceType = "AVNU_PRICE" /* AVNU_PRICE */) {
|
|
32518
32526
|
const legAUM = await adapter.getPositions(this.config);
|
|
32519
32527
|
const underlying = this.asset();
|
|
32520
32528
|
assert(underlying.symbol.startsWith("x"), "Underlying is not an LST of Endur");
|
|
32521
32529
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
32522
|
-
let tokenUnderlyingPrice
|
|
32523
|
-
|
|
32524
|
-
|
|
32530
|
+
let tokenUnderlyingPrice;
|
|
32531
|
+
if (priceType === "ENDUR_PRICE" /* ENDUR_PRICE */) {
|
|
32532
|
+
tokenUnderlyingPrice = await this.getLSTExchangeRate();
|
|
32533
|
+
if (tokenUnderlyingPrice === 0) {
|
|
32534
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Endur) is 0`);
|
|
32535
|
+
}
|
|
32536
|
+
const avnuRate = await this.getLSTAvnuRate();
|
|
32537
|
+
if (avnuRate === 0) {
|
|
32538
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
32539
|
+
}
|
|
32540
|
+
const diff = Math.abs(tokenUnderlyingPrice - avnuRate) / tokenUnderlyingPrice;
|
|
32541
|
+
if (diff > 0.02) {
|
|
32542
|
+
throw new Error(`${this.getTag()}::getVesuAUM: Endur and Avnu prices differ by more than 2% (Endur: ${tokenUnderlyingPrice}, Avnu: ${avnuRate})`);
|
|
32543
|
+
}
|
|
32544
|
+
logger.verbose(`${this.getTag()} tokenUnderlyingPrice (Endur): ${tokenUnderlyingPrice}, avnuRate: ${avnuRate}, diff: ${diff}`);
|
|
32545
|
+
} else {
|
|
32546
|
+
tokenUnderlyingPrice = await this.getLSTAvnuRate();
|
|
32547
|
+
if (tokenUnderlyingPrice === 0) {
|
|
32548
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
32549
|
+
}
|
|
32550
|
+
logger.verbose(`${this.getTag()} tokenUnderlyingPrice (Avnu): ${tokenUnderlyingPrice}`);
|
|
32551
|
+
}
|
|
32525
32552
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
32526
32553
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
32527
32554
|
} else {
|
|
@@ -32533,9 +32560,26 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32533
32560
|
vesuAum = vesuAum.minus(legAUM[1].amount.dividedBy(tokenUnderlyingPrice));
|
|
32534
32561
|
}
|
|
32535
32562
|
;
|
|
32536
|
-
|
|
32563
|
+
const priceTypeLabel = priceType === "ENDUR_PRICE" /* ENDUR_PRICE */ ? "Endur Price" : "Avnu Price";
|
|
32564
|
+
logger.verbose(`${this.getTag()} Vesu AUM (${priceTypeLabel}): ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
|
|
32537
32565
|
return vesuAum;
|
|
32538
32566
|
}
|
|
32567
|
+
async getTVLUnrealized() {
|
|
32568
|
+
return await this.getAUM(true);
|
|
32569
|
+
}
|
|
32570
|
+
async getUserUnrealizedGains(user) {
|
|
32571
|
+
const tvl = await this.getTVL();
|
|
32572
|
+
const unrealizedTVL = await this.getTVLUnrealized();
|
|
32573
|
+
const unrealizedDiff = unrealizedTVL.net.amount.minus(tvl.amount);
|
|
32574
|
+
const userTVL = await this.getUserTVL(user);
|
|
32575
|
+
const userShare = userTVL.amount.dividedBy(tvl.amount);
|
|
32576
|
+
const unrealizedGains = unrealizedDiff.multipliedBy(userShare);
|
|
32577
|
+
return {
|
|
32578
|
+
unrealizedGains,
|
|
32579
|
+
userShare: userShare.toNumber(),
|
|
32580
|
+
tokenInfo: this.asset()
|
|
32581
|
+
};
|
|
32582
|
+
}
|
|
32539
32583
|
//
|
|
32540
32584
|
async _getMinOutputAmountLSTBuy(amountInUnderlying) {
|
|
32541
32585
|
const lstTruePrice = await this.getLSTExchangeRate();
|
|
@@ -32719,6 +32763,28 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32719
32763
|
weight: unusedBalance.usdValue
|
|
32720
32764
|
};
|
|
32721
32765
|
}
|
|
32766
|
+
async getLSTAvnuRate() {
|
|
32767
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
32768
|
+
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
32769
|
+
const underlyingTokenInfo = vesuAdapter1.config.debt;
|
|
32770
|
+
const avnuModule = new AvnuWrapper();
|
|
32771
|
+
const sellAmount = lstTokenInfo.priceCheckAmount ? new Web3Number(lstTokenInfo.priceCheckAmount, underlyingTokenInfo.decimals) : new Web3Number(1, underlyingTokenInfo.decimals);
|
|
32772
|
+
const quote = await avnuModule.getQuotes(
|
|
32773
|
+
underlyingTokenInfo.address.address,
|
|
32774
|
+
lstTokenInfo.address.address,
|
|
32775
|
+
sellAmount.toWei(),
|
|
32776
|
+
this.metadata.additionalInfo.vaultAllocator.address
|
|
32777
|
+
);
|
|
32778
|
+
const underlyingAmountNumber = sellAmount.toNumber();
|
|
32779
|
+
const lstAmountNumber = Web3Number.fromWei(
|
|
32780
|
+
quote.buyAmount.toString(),
|
|
32781
|
+
lstTokenInfo.decimals
|
|
32782
|
+
).toNumber();
|
|
32783
|
+
assert(lstAmountNumber > 0, "Avnu LST amount is zero");
|
|
32784
|
+
const exchangeRate = underlyingAmountNumber / lstAmountNumber;
|
|
32785
|
+
logger.verbose(`${this.getTag()}:: LST Avnu Exchange Rate: ${exchangeRate}`);
|
|
32786
|
+
return exchangeRate;
|
|
32787
|
+
}
|
|
32722
32788
|
async getLSTExchangeRate() {
|
|
32723
32789
|
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
32724
32790
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -34079,6 +34145,7 @@ var deployer_default = Deployer;
|
|
|
34079
34145
|
Initializable,
|
|
34080
34146
|
InstantWithdrawalVault,
|
|
34081
34147
|
LSTAPRService,
|
|
34148
|
+
LSTPriceType,
|
|
34082
34149
|
MarginType,
|
|
34083
34150
|
MyNumber,
|
|
34084
34151
|
Network,
|
package/dist/index.mjs
CHANGED
|
@@ -30947,6 +30947,13 @@ var vault_manager_abi_default = [
|
|
|
30947
30947
|
}
|
|
30948
30948
|
];
|
|
30949
30949
|
|
|
30950
|
+
// src/strategies/types.ts
|
|
30951
|
+
var LSTPriceType = /* @__PURE__ */ ((LSTPriceType2) => {
|
|
30952
|
+
LSTPriceType2["ENDUR_PRICE"] = "ENDUR_PRICE";
|
|
30953
|
+
LSTPriceType2["AVNU_PRICE"] = "AVNU_PRICE";
|
|
30954
|
+
return LSTPriceType2;
|
|
30955
|
+
})(LSTPriceType || {});
|
|
30956
|
+
|
|
30950
30957
|
// src/strategies/universal-strategy.tsx
|
|
30951
30958
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
30952
30959
|
var AUMTypes = /* @__PURE__ */ ((AUMTypes3) => {
|
|
@@ -31255,7 +31262,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31255
31262
|
usdValue
|
|
31256
31263
|
};
|
|
31257
31264
|
}
|
|
31258
|
-
async getVesuAUM(adapter) {
|
|
31265
|
+
async getVesuAUM(adapter, _priceType) {
|
|
31259
31266
|
const legAUM = await adapter.getPositions(this.config);
|
|
31260
31267
|
const underlying = this.asset();
|
|
31261
31268
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
@@ -31281,13 +31288,15 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31281
31288
|
logger.verbose(`${this.getTag()} Prev AUM: ${prevAum}`);
|
|
31282
31289
|
return prevAum;
|
|
31283
31290
|
}
|
|
31284
|
-
async getAUM() {
|
|
31291
|
+
async getAUM(unrealizedAUM) {
|
|
31285
31292
|
const prevAum = await this.getPrevAUM();
|
|
31286
31293
|
const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
31287
31294
|
const vesuAdapters = this.getVesuAdapters();
|
|
31288
31295
|
let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
|
|
31289
31296
|
for (const adapter of vesuAdapters) {
|
|
31290
|
-
|
|
31297
|
+
const priceType = unrealizedAUM ? "ENDUR_PRICE" /* ENDUR_PRICE */ : "AVNU_PRICE" /* AVNU_PRICE */;
|
|
31298
|
+
const aumValue = await this.getVesuAUM(adapter, priceType);
|
|
31299
|
+
vesuAum = vesuAum.plus(aumValue);
|
|
31291
31300
|
}
|
|
31292
31301
|
const balance = await this.getUnusedBalance();
|
|
31293
31302
|
logger.verbose(`${this.getTag()} unused balance: ${balance.amount.toNumber()}`);
|
|
@@ -32265,7 +32274,6 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32265
32274
|
assert(calls.length == 1, `Expected 1 call for unwind, got ${calls.length}`);
|
|
32266
32275
|
return calls[0];
|
|
32267
32276
|
}
|
|
32268
|
-
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
32269
32277
|
const STEP0 = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
32270
32278
|
const manage0Info = this.getProofs(STEP0);
|
|
32271
32279
|
const manageCall0 = manage0Info.callConstructor({
|
|
@@ -32279,7 +32287,6 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32279
32287
|
debtAmount,
|
|
32280
32288
|
isBorrow: params.isDeposit
|
|
32281
32289
|
}));
|
|
32282
|
-
console.log(`manageCall1`, manageCall1.call, debtAmount.toWei(), newDepositAmount.toWei());
|
|
32283
32290
|
const proofIds = [STEP0, STEP1];
|
|
32284
32291
|
const manageCalls = [manageCall0, manageCall1];
|
|
32285
32292
|
if (debtAmount.gt(0)) {
|
|
@@ -32384,14 +32391,33 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32384
32391
|
return { shouldRebalance: false, manageCall: void 0 };
|
|
32385
32392
|
}
|
|
32386
32393
|
}
|
|
32387
|
-
async getVesuAUM(adapter) {
|
|
32394
|
+
async getVesuAUM(adapter, priceType = "AVNU_PRICE" /* AVNU_PRICE */) {
|
|
32388
32395
|
const legAUM = await adapter.getPositions(this.config);
|
|
32389
32396
|
const underlying = this.asset();
|
|
32390
32397
|
assert(underlying.symbol.startsWith("x"), "Underlying is not an LST of Endur");
|
|
32391
32398
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
32392
|
-
let tokenUnderlyingPrice
|
|
32393
|
-
|
|
32394
|
-
|
|
32399
|
+
let tokenUnderlyingPrice;
|
|
32400
|
+
if (priceType === "ENDUR_PRICE" /* ENDUR_PRICE */) {
|
|
32401
|
+
tokenUnderlyingPrice = await this.getLSTExchangeRate();
|
|
32402
|
+
if (tokenUnderlyingPrice === 0) {
|
|
32403
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Endur) is 0`);
|
|
32404
|
+
}
|
|
32405
|
+
const avnuRate = await this.getLSTAvnuRate();
|
|
32406
|
+
if (avnuRate === 0) {
|
|
32407
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
32408
|
+
}
|
|
32409
|
+
const diff = Math.abs(tokenUnderlyingPrice - avnuRate) / tokenUnderlyingPrice;
|
|
32410
|
+
if (diff > 0.02) {
|
|
32411
|
+
throw new Error(`${this.getTag()}::getVesuAUM: Endur and Avnu prices differ by more than 2% (Endur: ${tokenUnderlyingPrice}, Avnu: ${avnuRate})`);
|
|
32412
|
+
}
|
|
32413
|
+
logger.verbose(`${this.getTag()} tokenUnderlyingPrice (Endur): ${tokenUnderlyingPrice}, avnuRate: ${avnuRate}, diff: ${diff}`);
|
|
32414
|
+
} else {
|
|
32415
|
+
tokenUnderlyingPrice = await this.getLSTAvnuRate();
|
|
32416
|
+
if (tokenUnderlyingPrice === 0) {
|
|
32417
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
32418
|
+
}
|
|
32419
|
+
logger.verbose(`${this.getTag()} tokenUnderlyingPrice (Avnu): ${tokenUnderlyingPrice}`);
|
|
32420
|
+
}
|
|
32395
32421
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
32396
32422
|
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
32397
32423
|
} else {
|
|
@@ -32403,9 +32429,26 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32403
32429
|
vesuAum = vesuAum.minus(legAUM[1].amount.dividedBy(tokenUnderlyingPrice));
|
|
32404
32430
|
}
|
|
32405
32431
|
;
|
|
32406
|
-
|
|
32432
|
+
const priceTypeLabel = priceType === "ENDUR_PRICE" /* ENDUR_PRICE */ ? "Endur Price" : "Avnu Price";
|
|
32433
|
+
logger.verbose(`${this.getTag()} Vesu AUM (${priceTypeLabel}): ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
|
|
32407
32434
|
return vesuAum;
|
|
32408
32435
|
}
|
|
32436
|
+
async getTVLUnrealized() {
|
|
32437
|
+
return await this.getAUM(true);
|
|
32438
|
+
}
|
|
32439
|
+
async getUserUnrealizedGains(user) {
|
|
32440
|
+
const tvl = await this.getTVL();
|
|
32441
|
+
const unrealizedTVL = await this.getTVLUnrealized();
|
|
32442
|
+
const unrealizedDiff = unrealizedTVL.net.amount.minus(tvl.amount);
|
|
32443
|
+
const userTVL = await this.getUserTVL(user);
|
|
32444
|
+
const userShare = userTVL.amount.dividedBy(tvl.amount);
|
|
32445
|
+
const unrealizedGains = unrealizedDiff.multipliedBy(userShare);
|
|
32446
|
+
return {
|
|
32447
|
+
unrealizedGains,
|
|
32448
|
+
userShare: userShare.toNumber(),
|
|
32449
|
+
tokenInfo: this.asset()
|
|
32450
|
+
};
|
|
32451
|
+
}
|
|
32409
32452
|
//
|
|
32410
32453
|
async _getMinOutputAmountLSTBuy(amountInUnderlying) {
|
|
32411
32454
|
const lstTruePrice = await this.getLSTExchangeRate();
|
|
@@ -32589,6 +32632,28 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32589
32632
|
weight: unusedBalance.usdValue
|
|
32590
32633
|
};
|
|
32591
32634
|
}
|
|
32635
|
+
async getLSTAvnuRate() {
|
|
32636
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
32637
|
+
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
32638
|
+
const underlyingTokenInfo = vesuAdapter1.config.debt;
|
|
32639
|
+
const avnuModule = new AvnuWrapper();
|
|
32640
|
+
const sellAmount = lstTokenInfo.priceCheckAmount ? new Web3Number(lstTokenInfo.priceCheckAmount, underlyingTokenInfo.decimals) : new Web3Number(1, underlyingTokenInfo.decimals);
|
|
32641
|
+
const quote = await avnuModule.getQuotes(
|
|
32642
|
+
underlyingTokenInfo.address.address,
|
|
32643
|
+
lstTokenInfo.address.address,
|
|
32644
|
+
sellAmount.toWei(),
|
|
32645
|
+
this.metadata.additionalInfo.vaultAllocator.address
|
|
32646
|
+
);
|
|
32647
|
+
const underlyingAmountNumber = sellAmount.toNumber();
|
|
32648
|
+
const lstAmountNumber = Web3Number.fromWei(
|
|
32649
|
+
quote.buyAmount.toString(),
|
|
32650
|
+
lstTokenInfo.decimals
|
|
32651
|
+
).toNumber();
|
|
32652
|
+
assert(lstAmountNumber > 0, "Avnu LST amount is zero");
|
|
32653
|
+
const exchangeRate = underlyingAmountNumber / lstAmountNumber;
|
|
32654
|
+
logger.verbose(`${this.getTag()}:: LST Avnu Exchange Rate: ${exchangeRate}`);
|
|
32655
|
+
return exchangeRate;
|
|
32656
|
+
}
|
|
32592
32657
|
async getLSTExchangeRate() {
|
|
32593
32658
|
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
32594
32659
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -33948,6 +34013,7 @@ export {
|
|
|
33948
34013
|
Initializable,
|
|
33949
34014
|
InstantWithdrawalVault,
|
|
33950
34015
|
LSTAPRService,
|
|
34016
|
+
LSTPriceType,
|
|
33951
34017
|
MarginType,
|
|
33952
34018
|
MyNumber,
|
|
33953
34019
|
Network,
|
package/package.json
CHANGED
package/src/strategies/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { Call, Contract, uint256 } from "starknet";
|
|
|
13
13
|
import ERC4626Abi from "@/data/erc4626.abi.json";
|
|
14
14
|
import { HealthFactorMath } from "@/utils/health-factor-math";
|
|
15
15
|
import { findMaxInputWithSlippage } from "@/utils/math-utils";
|
|
16
|
+
import { LSTPriceType } from "./types";
|
|
16
17
|
|
|
17
18
|
export interface HyperLSTStrategySettings extends UniversalStrategySettings {
|
|
18
19
|
borrowable_assets: { token: TokenInfo, poolId: ContractAddr }[];
|
|
@@ -232,7 +233,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
232
233
|
assert(calls.length == 1, `Expected 1 call for unwind, got ${calls.length}`);
|
|
233
234
|
return calls[0];
|
|
234
235
|
}
|
|
235
|
-
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
236
|
+
// console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
236
237
|
const STEP0 = UNIVERSAL_MANAGE_IDS.APPROVE_TOKEN1;
|
|
237
238
|
const manage0Info = this.getProofs<ApproveCallParams>(STEP0);
|
|
238
239
|
const manageCall0 = manage0Info.callConstructor({
|
|
@@ -247,7 +248,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
247
248
|
isBorrow: params.isDeposit
|
|
248
249
|
}));
|
|
249
250
|
|
|
250
|
-
console.log(`manageCall1`, manageCall1.call, debtAmount.toWei(), newDepositAmount.toWei());
|
|
251
|
+
// console.log(`manageCall1`, manageCall1.call, debtAmount.toWei(), newDepositAmount.toWei());
|
|
251
252
|
|
|
252
253
|
const proofIds: string[] = [STEP0, STEP1];
|
|
253
254
|
const manageCalls: ManageCall[] = [manageCall0, manageCall1];
|
|
@@ -375,7 +376,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
375
376
|
}
|
|
376
377
|
}
|
|
377
378
|
|
|
378
|
-
protected async getVesuAUM(adapter: VesuAdapter) {
|
|
379
|
+
protected async getVesuAUM(adapter: VesuAdapter, priceType: LSTPriceType = LSTPriceType.AVNU_PRICE) {
|
|
379
380
|
const legAUM = await adapter.getPositions(this.config);
|
|
380
381
|
const underlying = this.asset();
|
|
381
382
|
// assert its an LST of Endur
|
|
@@ -383,10 +384,33 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
383
384
|
|
|
384
385
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
385
386
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
387
|
+
// Get the price based on the price type
|
|
388
|
+
let tokenUnderlyingPrice: number;
|
|
389
|
+
if (priceType === LSTPriceType.ENDUR_PRICE) {
|
|
390
|
+
tokenUnderlyingPrice = await this.getLSTExchangeRate();
|
|
391
|
+
if (tokenUnderlyingPrice === 0) {
|
|
392
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Endur) is 0`);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// For Endur price, also check against Avnu rate to ensure they're within 2%
|
|
396
|
+
const avnuRate = await this.getLSTAvnuRate();
|
|
397
|
+
if (avnuRate === 0) {
|
|
398
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const diff = Math.abs(tokenUnderlyingPrice - avnuRate) / tokenUnderlyingPrice;
|
|
402
|
+
if (diff > 0.02) {
|
|
403
|
+
throw new Error(`${this.getTag()}::getVesuAUM: Endur and Avnu prices differ by more than 2% (Endur: ${tokenUnderlyingPrice}, Avnu: ${avnuRate})`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
logger.verbose(`${this.getTag()} tokenUnderlyingPrice (Endur): ${tokenUnderlyingPrice}, avnuRate: ${avnuRate}, diff: ${diff}`);
|
|
407
|
+
} else {
|
|
408
|
+
tokenUnderlyingPrice = await this.getLSTAvnuRate();
|
|
409
|
+
if (tokenUnderlyingPrice === 0) {
|
|
410
|
+
throw new Error(`${this.getTag()}::getVesuAUM: tokenUnderlyingPrice (Avnu) is 0`);
|
|
411
|
+
}
|
|
412
|
+
logger.verbose(`${this.getTag()} tokenUnderlyingPrice (Avnu): ${tokenUnderlyingPrice}`);
|
|
413
|
+
}
|
|
390
414
|
|
|
391
415
|
// handle collateral
|
|
392
416
|
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
@@ -402,10 +426,41 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
402
426
|
vesuAum = vesuAum.minus(legAUM[1].amount.dividedBy(tokenUnderlyingPrice));
|
|
403
427
|
};
|
|
404
428
|
|
|
405
|
-
|
|
429
|
+
const priceTypeLabel = priceType === LSTPriceType.ENDUR_PRICE ? 'Endur Price' : 'Avnu Price';
|
|
430
|
+
logger.verbose(`${this.getTag()} Vesu AUM (${priceTypeLabel}): ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
|
|
406
431
|
return vesuAum;
|
|
407
432
|
}
|
|
408
433
|
|
|
434
|
+
async getTVLUnrealized(): Promise<{net: SingleTokenInfo, prevAum: Web3Number, splits: {id: string, aum: Web3Number}[]}> {
|
|
435
|
+
return await this.getAUM(true);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
async getUserUnrealizedGains(user: ContractAddr) {
|
|
439
|
+
// Get total TVL (realized)
|
|
440
|
+
const tvl = await this.getTVL();
|
|
441
|
+
|
|
442
|
+
// Get unrealized TVL (using Endur prices)
|
|
443
|
+
const unrealizedTVL = await this.getTVLUnrealized();
|
|
444
|
+
|
|
445
|
+
// Calculate the difference between unrealized and realized TVL
|
|
446
|
+
const unrealizedDiff = unrealizedTVL.net.amount.minus(tvl.amount);
|
|
447
|
+
|
|
448
|
+
// Get user's TVL
|
|
449
|
+
const userTVL = await this.getUserTVL(user);
|
|
450
|
+
|
|
451
|
+
// Calculate user's share of the total TVL
|
|
452
|
+
const userShare = userTVL.amount.dividedBy(tvl.amount);
|
|
453
|
+
|
|
454
|
+
// Calculate user's unrealized gains (in token amount)
|
|
455
|
+
const unrealizedGains = unrealizedDiff.multipliedBy(userShare);
|
|
456
|
+
|
|
457
|
+
return {
|
|
458
|
+
unrealizedGains,
|
|
459
|
+
userShare: userShare.toNumber(),
|
|
460
|
+
tokenInfo: this.asset()
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
|
|
409
464
|
//
|
|
410
465
|
private async _getMinOutputAmountLSTBuy(amountInUnderlying: Web3Number) {
|
|
411
466
|
const lstTruePrice = await this.getLSTExchangeRate();
|
|
@@ -659,6 +714,37 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
659
714
|
}
|
|
660
715
|
}
|
|
661
716
|
|
|
717
|
+
async getLSTAvnuRate() {
|
|
718
|
+
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
719
|
+
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
720
|
+
const underlyingTokenInfo = vesuAdapter1.config.debt;
|
|
721
|
+
|
|
722
|
+
const avnuModule = new AvnuWrapper();
|
|
723
|
+
|
|
724
|
+
const sellAmount = lstTokenInfo.priceCheckAmount
|
|
725
|
+
? new Web3Number(lstTokenInfo.priceCheckAmount,underlyingTokenInfo.decimals)
|
|
726
|
+
: new Web3Number(1,underlyingTokenInfo.decimals)
|
|
727
|
+
|
|
728
|
+
const quote = await avnuModule.getQuotes(
|
|
729
|
+
underlyingTokenInfo.address.address,
|
|
730
|
+
lstTokenInfo.address.address,
|
|
731
|
+
sellAmount.toWei(),
|
|
732
|
+
this.metadata.additionalInfo.vaultAllocator.address
|
|
733
|
+
);
|
|
734
|
+
|
|
735
|
+
const underlyingAmountNumber = sellAmount.toNumber();
|
|
736
|
+
const lstAmountNumber = Web3Number.fromWei(
|
|
737
|
+
quote.buyAmount.toString(),
|
|
738
|
+
lstTokenInfo.decimals
|
|
739
|
+
).toNumber();
|
|
740
|
+
|
|
741
|
+
assert(lstAmountNumber > 0, 'Avnu LST amount is zero');
|
|
742
|
+
|
|
743
|
+
const exchangeRate = underlyingAmountNumber / lstAmountNumber;
|
|
744
|
+
logger.verbose(`${this.getTag()}:: LST Avnu Exchange Rate: ${exchangeRate}`);
|
|
745
|
+
return exchangeRate;
|
|
746
|
+
}
|
|
747
|
+
|
|
662
748
|
async getLSTExchangeRate() {
|
|
663
749
|
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
664
750
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -11,6 +11,7 @@ import { ApproveCallParams, AvnuSwapCallParams, BaseAdapter, CommonAdapter, Flas
|
|
|
11
11
|
import { Global } from "@/global";
|
|
12
12
|
import { AvnuWrapper, ERC20 } from "@/modules";
|
|
13
13
|
import { AVNU_MIDDLEWARE, VESU_SINGLETON } from "./universal-adapters/adapter-utils";
|
|
14
|
+
import { LSTPriceType } from "./types";
|
|
14
15
|
import { HarvestInfo, VesuHarvests } from "@/modules/harvests";
|
|
15
16
|
|
|
16
17
|
export interface UniversalManageCall {
|
|
@@ -435,7 +436,7 @@ export class UniversalStrategy<
|
|
|
435
436
|
};
|
|
436
437
|
}
|
|
437
438
|
|
|
438
|
-
protected async getVesuAUM(adapter: VesuAdapter) {
|
|
439
|
+
protected async getVesuAUM(adapter: VesuAdapter, _priceType?: LSTPriceType) {
|
|
439
440
|
const legAUM = await adapter.getPositions(this.config);
|
|
440
441
|
const underlying = this.asset();
|
|
441
442
|
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
@@ -468,7 +469,7 @@ export class UniversalStrategy<
|
|
|
468
469
|
return prevAum;
|
|
469
470
|
}
|
|
470
471
|
|
|
471
|
-
async getAUM(): Promise<{net: SingleTokenInfo, prevAum: Web3Number, splits: {id: string, aum: Web3Number}[]}> {
|
|
472
|
+
async getAUM(unrealizedAUM?: boolean): Promise<{net: SingleTokenInfo, prevAum: Web3Number, splits: {id: string, aum: Web3Number}[]}> {
|
|
472
473
|
const prevAum = await this.getPrevAUM();
|
|
473
474
|
const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
474
475
|
|
|
@@ -476,7 +477,9 @@ export class UniversalStrategy<
|
|
|
476
477
|
const vesuAdapters = this.getVesuAdapters();
|
|
477
478
|
let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
|
|
478
479
|
for (const adapter of vesuAdapters) {
|
|
479
|
-
|
|
480
|
+
const priceType = unrealizedAUM ? LSTPriceType.ENDUR_PRICE : LSTPriceType.AVNU_PRICE;
|
|
481
|
+
const aumValue = await this.getVesuAUM(adapter, priceType);
|
|
482
|
+
vesuAum = vesuAum.plus(aumValue);
|
|
480
483
|
}
|
|
481
484
|
|
|
482
485
|
// account unused balance as aum as well (from vault allocator)
|