@strkfarm/sdk 1.1.27 → 1.1.29
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 +51 -17
- package/dist/index.browser.mjs +51 -17
- package/dist/index.d.ts +25 -1
- package/dist/index.js +57 -23
- package/dist/index.mjs +57 -23
- package/package.json +1 -1
- package/src/strategies/universal-lst-muliplier-strategy.tsx +57 -2
- package/src/strategies/universal-strategy.tsx +14 -18
|
@@ -53965,7 +53965,6 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
53965
53965
|
const stats = await this.getLSTStats();
|
|
53966
53966
|
const result2 = /* @__PURE__ */ new Map();
|
|
53967
53967
|
for (const stat of stats) {
|
|
53968
|
-
console.log("stat", stat);
|
|
53969
53968
|
result2.set(stat.assetAddress, stat);
|
|
53970
53969
|
}
|
|
53971
53970
|
return result2;
|
|
@@ -90711,20 +90710,12 @@ spurious results.`);
|
|
|
90711
90710
|
logger2.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
90712
90711
|
const baseAPYs = [];
|
|
90713
90712
|
const rewardAPYs = [];
|
|
90714
|
-
const underlyingAddresses = vesuAdapters.map((adapter) => adapter.config.debt.address);
|
|
90715
|
-
let lstAPRs;
|
|
90716
|
-
try {
|
|
90717
|
-
lstAPRs = await LSTAPRService.getLSTAPRs(underlyingAddresses);
|
|
90718
|
-
} catch (error2) {
|
|
90719
|
-
logger2.warn(`${this.metadata.name}::netAPY: Failed to fetch LST APRs from Endur API, using fallback: ${error2}`);
|
|
90720
|
-
lstAPRs = /* @__PURE__ */ new Map();
|
|
90721
|
-
}
|
|
90722
90713
|
for (const [index, pool] of pools.entries()) {
|
|
90723
90714
|
const vesuAdapter = vesuAdapters[index];
|
|
90724
90715
|
const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
|
|
90725
90716
|
const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
|
|
90726
90717
|
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
90727
|
-
const lstAPY =
|
|
90718
|
+
const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
|
|
90728
90719
|
logger2.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
|
|
90729
90720
|
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
90730
90721
|
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
|
|
@@ -90741,7 +90732,11 @@ spurious results.`);
|
|
|
90741
90732
|
id: "defispring"
|
|
90742
90733
|
}] };
|
|
90743
90734
|
}
|
|
90735
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
90736
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
90737
|
+
rewardAPYs.push(0);
|
|
90744
90738
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
90739
|
+
weights.push(unusedBalanceAPY.weight);
|
|
90745
90740
|
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
90746
90741
|
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
90747
90742
|
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
@@ -90756,6 +90751,12 @@ spurious results.`);
|
|
|
90756
90751
|
id: "defispring"
|
|
90757
90752
|
}] };
|
|
90758
90753
|
}
|
|
90754
|
+
async getUnusedBalanceAPY() {
|
|
90755
|
+
return {
|
|
90756
|
+
apy: 0,
|
|
90757
|
+
weight: 0
|
|
90758
|
+
};
|
|
90759
|
+
}
|
|
90759
90760
|
computeAPY(apys, weights, currentAUM) {
|
|
90760
90761
|
assert3(apys.length === weights.length, "APYs and weights length mismatch");
|
|
90761
90762
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
@@ -90953,13 +90954,8 @@ spurious results.`);
|
|
|
90953
90954
|
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
90954
90955
|
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
90955
90956
|
*/
|
|
90956
|
-
async getLSTAPR() {
|
|
90957
|
-
|
|
90958
|
-
return await LSTAPRService.getLSTAPR(this.asset().address);
|
|
90959
|
-
} catch (error2) {
|
|
90960
|
-
logger2.warn(`${this.getTag()}: Failed to get LST APR: ${error2}`);
|
|
90961
|
-
return 0;
|
|
90962
|
-
}
|
|
90957
|
+
async getLSTAPR(address) {
|
|
90958
|
+
return 0;
|
|
90963
90959
|
}
|
|
90964
90960
|
async getVesuHealthFactors() {
|
|
90965
90961
|
return await Promise.all(this.getVesuAdapters().map((v) => v.getHealthFactor()));
|
|
@@ -91608,6 +91604,9 @@ spurious results.`);
|
|
|
91608
91604
|
logger2.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
91609
91605
|
return price;
|
|
91610
91606
|
}
|
|
91607
|
+
async getAvnuSwapMultiplyCall(params) {
|
|
91608
|
+
return [];
|
|
91609
|
+
}
|
|
91611
91610
|
/**
|
|
91612
91611
|
* Uses vesu's multiple call to create leverage on LST
|
|
91613
91612
|
* Deposit amount is in LST
|
|
@@ -91652,6 +91651,41 @@ spurious results.`);
|
|
|
91652
91651
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
91653
91652
|
return vesuAdapter1.config.debt;
|
|
91654
91653
|
}
|
|
91654
|
+
/**
|
|
91655
|
+
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
91656
|
+
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
91657
|
+
*/
|
|
91658
|
+
async getLSTAPR(_address) {
|
|
91659
|
+
try {
|
|
91660
|
+
const vesuAdapter1 = this.getVesuAdapters()[0];
|
|
91661
|
+
return await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
|
|
91662
|
+
} catch (error2) {
|
|
91663
|
+
logger2.warn(`${this.getTag()}: Failed to get LST APR: ${error2}`);
|
|
91664
|
+
return 0;
|
|
91665
|
+
}
|
|
91666
|
+
}
|
|
91667
|
+
// todo undo this
|
|
91668
|
+
async netAPY() {
|
|
91669
|
+
const { net, splits } = await super.netAPY();
|
|
91670
|
+
let _net = net;
|
|
91671
|
+
if (this.asset().symbol == "xWBTC") {
|
|
91672
|
+
_net *= 5;
|
|
91673
|
+
}
|
|
91674
|
+
return {
|
|
91675
|
+
net: _net,
|
|
91676
|
+
splits
|
|
91677
|
+
};
|
|
91678
|
+
}
|
|
91679
|
+
async getUnusedBalanceAPY() {
|
|
91680
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
91681
|
+
const vesuAdapter = this.getVesuAdapters()[0];
|
|
91682
|
+
const underlying = vesuAdapter.config.debt;
|
|
91683
|
+
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
91684
|
+
return {
|
|
91685
|
+
apy: lstAPY,
|
|
91686
|
+
weight: unusedBalance.usdValue
|
|
91687
|
+
};
|
|
91688
|
+
}
|
|
91655
91689
|
async getLSTExchangeRate() {
|
|
91656
91690
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
91657
91691
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
package/dist/index.browser.mjs
CHANGED
|
@@ -2362,7 +2362,6 @@ var LSTAPRService = class {
|
|
|
2362
2362
|
const stats = await this.getLSTStats();
|
|
2363
2363
|
const result = /* @__PURE__ */ new Map();
|
|
2364
2364
|
for (const stat of stats) {
|
|
2365
|
-
console.log("stat", stat);
|
|
2366
2365
|
result.set(stat.assetAddress, stat);
|
|
2367
2366
|
}
|
|
2368
2367
|
return result;
|
|
@@ -26807,20 +26806,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26807
26806
|
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
26808
26807
|
const baseAPYs = [];
|
|
26809
26808
|
const rewardAPYs = [];
|
|
26810
|
-
const underlyingAddresses = vesuAdapters.map((adapter) => adapter.config.debt.address);
|
|
26811
|
-
let lstAPRs;
|
|
26812
|
-
try {
|
|
26813
|
-
lstAPRs = await LSTAPRService.getLSTAPRs(underlyingAddresses);
|
|
26814
|
-
} catch (error) {
|
|
26815
|
-
logger.warn(`${this.metadata.name}::netAPY: Failed to fetch LST APRs from Endur API, using fallback: ${error}`);
|
|
26816
|
-
lstAPRs = /* @__PURE__ */ new Map();
|
|
26817
|
-
}
|
|
26818
26809
|
for (const [index, pool] of pools.entries()) {
|
|
26819
26810
|
const vesuAdapter = vesuAdapters[index];
|
|
26820
26811
|
const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
|
|
26821
26812
|
const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
|
|
26822
26813
|
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
26823
|
-
const lstAPY =
|
|
26814
|
+
const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
|
|
26824
26815
|
logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
|
|
26825
26816
|
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
26826
26817
|
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
|
|
@@ -26837,7 +26828,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26837
26828
|
id: "defispring"
|
|
26838
26829
|
}] };
|
|
26839
26830
|
}
|
|
26831
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
26832
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
26833
|
+
rewardAPYs.push(0);
|
|
26840
26834
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
26835
|
+
weights.push(unusedBalanceAPY.weight);
|
|
26841
26836
|
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
26842
26837
|
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
26843
26838
|
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
@@ -26852,6 +26847,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26852
26847
|
id: "defispring"
|
|
26853
26848
|
}] };
|
|
26854
26849
|
}
|
|
26850
|
+
async getUnusedBalanceAPY() {
|
|
26851
|
+
return {
|
|
26852
|
+
apy: 0,
|
|
26853
|
+
weight: 0
|
|
26854
|
+
};
|
|
26855
|
+
}
|
|
26855
26856
|
computeAPY(apys, weights, currentAUM) {
|
|
26856
26857
|
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
26857
26858
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
@@ -27049,13 +27050,8 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
27049
27050
|
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
27050
27051
|
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
27051
27052
|
*/
|
|
27052
|
-
async getLSTAPR() {
|
|
27053
|
-
|
|
27054
|
-
return await LSTAPRService.getLSTAPR(this.asset().address);
|
|
27055
|
-
} catch (error) {
|
|
27056
|
-
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
27057
|
-
return 0;
|
|
27058
|
-
}
|
|
27053
|
+
async getLSTAPR(address) {
|
|
27054
|
+
return 0;
|
|
27059
27055
|
}
|
|
27060
27056
|
async getVesuHealthFactors() {
|
|
27061
27057
|
return await Promise.all(this.getVesuAdapters().map((v) => v.getHealthFactor()));
|
|
@@ -27705,6 +27701,9 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27705
27701
|
logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
27706
27702
|
return price;
|
|
27707
27703
|
}
|
|
27704
|
+
async getAvnuSwapMultiplyCall(params) {
|
|
27705
|
+
return [];
|
|
27706
|
+
}
|
|
27708
27707
|
/**
|
|
27709
27708
|
* Uses vesu's multiple call to create leverage on LST
|
|
27710
27709
|
* Deposit amount is in LST
|
|
@@ -27749,6 +27748,41 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27749
27748
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27750
27749
|
return vesuAdapter1.config.debt;
|
|
27751
27750
|
}
|
|
27751
|
+
/**
|
|
27752
|
+
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
27753
|
+
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
27754
|
+
*/
|
|
27755
|
+
async getLSTAPR(_address) {
|
|
27756
|
+
try {
|
|
27757
|
+
const vesuAdapter1 = this.getVesuAdapters()[0];
|
|
27758
|
+
return await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
|
|
27759
|
+
} catch (error) {
|
|
27760
|
+
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
27761
|
+
return 0;
|
|
27762
|
+
}
|
|
27763
|
+
}
|
|
27764
|
+
// todo undo this
|
|
27765
|
+
async netAPY() {
|
|
27766
|
+
const { net, splits } = await super.netAPY();
|
|
27767
|
+
let _net = net;
|
|
27768
|
+
if (this.asset().symbol == "xWBTC") {
|
|
27769
|
+
_net *= 5;
|
|
27770
|
+
}
|
|
27771
|
+
return {
|
|
27772
|
+
net: _net,
|
|
27773
|
+
splits
|
|
27774
|
+
};
|
|
27775
|
+
}
|
|
27776
|
+
async getUnusedBalanceAPY() {
|
|
27777
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
27778
|
+
const vesuAdapter = this.getVesuAdapters()[0];
|
|
27779
|
+
const underlying = vesuAdapter.config.debt;
|
|
27780
|
+
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
27781
|
+
return {
|
|
27782
|
+
apy: lstAPY,
|
|
27783
|
+
weight: unusedBalance.usdValue
|
|
27784
|
+
};
|
|
27785
|
+
}
|
|
27752
27786
|
async getLSTExchangeRate() {
|
|
27753
27787
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27754
27788
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
package/dist/index.d.ts
CHANGED
|
@@ -1191,6 +1191,10 @@ declare class UniversalStrategy<S extends UniversalStrategySettings> extends Bas
|
|
|
1191
1191
|
id: string;
|
|
1192
1192
|
}[];
|
|
1193
1193
|
}>;
|
|
1194
|
+
protected getUnusedBalanceAPY(): Promise<{
|
|
1195
|
+
apy: number;
|
|
1196
|
+
weight: number;
|
|
1197
|
+
}>;
|
|
1194
1198
|
private computeAPY;
|
|
1195
1199
|
/**
|
|
1196
1200
|
* Calculates the total TVL of the strategy.
|
|
@@ -1229,7 +1233,7 @@ declare class UniversalStrategy<S extends UniversalStrategySettings> extends Bas
|
|
|
1229
1233
|
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
1230
1234
|
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
1231
1235
|
*/
|
|
1232
|
-
getLSTAPR(): Promise<number>;
|
|
1236
|
+
getLSTAPR(address: ContractAddr): Promise<number>;
|
|
1233
1237
|
getVesuHealthFactors(): Promise<number[]>;
|
|
1234
1238
|
computeRebalanceConditionAndReturnCalls(): Promise<Call[]>;
|
|
1235
1239
|
private getNewHealthFactor;
|
|
@@ -1289,6 +1293,10 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<Universal
|
|
|
1289
1293
|
getVesuAdapters(): VesuAdapter[];
|
|
1290
1294
|
protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
|
|
1291
1295
|
getLSTDexPrice(): Promise<number>;
|
|
1296
|
+
getAvnuSwapMultiplyCall(params: {
|
|
1297
|
+
isDeposit: boolean;
|
|
1298
|
+
leg1DepositAmount: Web3Number;
|
|
1299
|
+
}): Promise<never[]>;
|
|
1292
1300
|
/**
|
|
1293
1301
|
* Uses vesu's multiple call to create leverage on LST
|
|
1294
1302
|
* Deposit amount is in LST
|
|
@@ -1299,6 +1307,22 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<Universal
|
|
|
1299
1307
|
leg1DepositAmount: Web3Number;
|
|
1300
1308
|
}): Promise<Call[]>;
|
|
1301
1309
|
getLSTUnderlyingTokenInfo(): TokenInfo;
|
|
1310
|
+
/**
|
|
1311
|
+
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
1312
|
+
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
1313
|
+
*/
|
|
1314
|
+
getLSTAPR(_address: ContractAddr): Promise<number>;
|
|
1315
|
+
netAPY(): Promise<{
|
|
1316
|
+
net: number;
|
|
1317
|
+
splits: {
|
|
1318
|
+
apy: number;
|
|
1319
|
+
id: string;
|
|
1320
|
+
}[];
|
|
1321
|
+
}>;
|
|
1322
|
+
protected getUnusedBalanceAPY(): Promise<{
|
|
1323
|
+
apy: number;
|
|
1324
|
+
weight: number;
|
|
1325
|
+
}>;
|
|
1302
1326
|
getLSTExchangeRate(): Promise<number>;
|
|
1303
1327
|
/**
|
|
1304
1328
|
*
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ __export(index_exports, {
|
|
|
49
49
|
HyperLSTStrategies: () => HyperLSTStrategies,
|
|
50
50
|
ILending: () => ILending,
|
|
51
51
|
Initializable: () => Initializable,
|
|
52
|
-
LSTAPRService: () =>
|
|
52
|
+
LSTAPRService: () => LSTAPRService2,
|
|
53
53
|
MarginType: () => MarginType,
|
|
54
54
|
Network: () => Network,
|
|
55
55
|
PRICE_ROUTER: () => PRICE_ROUTER,
|
|
@@ -26802,20 +26802,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26802
26802
|
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
26803
26803
|
const baseAPYs = [];
|
|
26804
26804
|
const rewardAPYs = [];
|
|
26805
|
-
const underlyingAddresses = vesuAdapters.map((adapter) => adapter.config.debt.address);
|
|
26806
|
-
let lstAPRs;
|
|
26807
|
-
try {
|
|
26808
|
-
lstAPRs = await LSTAPRService.getLSTAPRs(underlyingAddresses);
|
|
26809
|
-
} catch (error) {
|
|
26810
|
-
logger.warn(`${this.metadata.name}::netAPY: Failed to fetch LST APRs from Endur API, using fallback: ${error}`);
|
|
26811
|
-
lstAPRs = /* @__PURE__ */ new Map();
|
|
26812
|
-
}
|
|
26813
26805
|
for (const [index, pool] of pools.entries()) {
|
|
26814
26806
|
const vesuAdapter = vesuAdapters[index];
|
|
26815
26807
|
const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
|
|
26816
26808
|
const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
|
|
26817
26809
|
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
26818
|
-
const lstAPY =
|
|
26810
|
+
const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
|
|
26819
26811
|
logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
|
|
26820
26812
|
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
26821
26813
|
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
|
|
@@ -26832,7 +26824,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26832
26824
|
id: "defispring"
|
|
26833
26825
|
}] };
|
|
26834
26826
|
}
|
|
26827
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
26828
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
26829
|
+
rewardAPYs.push(0);
|
|
26835
26830
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
26831
|
+
weights.push(unusedBalanceAPY.weight);
|
|
26836
26832
|
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
26837
26833
|
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
26838
26834
|
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
@@ -26847,6 +26843,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26847
26843
|
id: "defispring"
|
|
26848
26844
|
}] };
|
|
26849
26845
|
}
|
|
26846
|
+
async getUnusedBalanceAPY() {
|
|
26847
|
+
return {
|
|
26848
|
+
apy: 0,
|
|
26849
|
+
weight: 0
|
|
26850
|
+
};
|
|
26851
|
+
}
|
|
26850
26852
|
computeAPY(apys, weights, currentAUM) {
|
|
26851
26853
|
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
26852
26854
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
@@ -27044,13 +27046,8 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
27044
27046
|
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
27045
27047
|
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
27046
27048
|
*/
|
|
27047
|
-
async getLSTAPR() {
|
|
27048
|
-
|
|
27049
|
-
return await LSTAPRService.getLSTAPR(this.asset().address);
|
|
27050
|
-
} catch (error) {
|
|
27051
|
-
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
27052
|
-
return 0;
|
|
27053
|
-
}
|
|
27049
|
+
async getLSTAPR(address) {
|
|
27050
|
+
return 0;
|
|
27054
27051
|
}
|
|
27055
27052
|
async getVesuHealthFactors() {
|
|
27056
27053
|
return await Promise.all(this.getVesuAdapters().map((v) => v.getHealthFactor()));
|
|
@@ -27700,6 +27697,9 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27700
27697
|
logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
27701
27698
|
return price;
|
|
27702
27699
|
}
|
|
27700
|
+
async getAvnuSwapMultiplyCall(params) {
|
|
27701
|
+
return [];
|
|
27702
|
+
}
|
|
27703
27703
|
/**
|
|
27704
27704
|
* Uses vesu's multiple call to create leverage on LST
|
|
27705
27705
|
* Deposit amount is in LST
|
|
@@ -27744,6 +27744,41 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27744
27744
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27745
27745
|
return vesuAdapter1.config.debt;
|
|
27746
27746
|
}
|
|
27747
|
+
/**
|
|
27748
|
+
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
27749
|
+
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
27750
|
+
*/
|
|
27751
|
+
async getLSTAPR(_address) {
|
|
27752
|
+
try {
|
|
27753
|
+
const vesuAdapter1 = this.getVesuAdapters()[0];
|
|
27754
|
+
return await LSTAPRService2.getLSTAPR(vesuAdapter1.config.debt.address);
|
|
27755
|
+
} catch (error) {
|
|
27756
|
+
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
27757
|
+
return 0;
|
|
27758
|
+
}
|
|
27759
|
+
}
|
|
27760
|
+
// todo undo this
|
|
27761
|
+
async netAPY() {
|
|
27762
|
+
const { net, splits } = await super.netAPY();
|
|
27763
|
+
let _net = net;
|
|
27764
|
+
if (this.asset().symbol == "xWBTC") {
|
|
27765
|
+
_net *= 5;
|
|
27766
|
+
}
|
|
27767
|
+
return {
|
|
27768
|
+
net: _net,
|
|
27769
|
+
splits
|
|
27770
|
+
};
|
|
27771
|
+
}
|
|
27772
|
+
async getUnusedBalanceAPY() {
|
|
27773
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
27774
|
+
const vesuAdapter = this.getVesuAdapters()[0];
|
|
27775
|
+
const underlying = vesuAdapter.config.debt;
|
|
27776
|
+
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
27777
|
+
return {
|
|
27778
|
+
apy: lstAPY,
|
|
27779
|
+
weight: unusedBalance.usdValue
|
|
27780
|
+
};
|
|
27781
|
+
}
|
|
27747
27782
|
async getLSTExchangeRate() {
|
|
27748
27783
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27749
27784
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -28133,7 +28168,7 @@ var PricerLST2 = class extends Pricer {
|
|
|
28133
28168
|
};
|
|
28134
28169
|
|
|
28135
28170
|
// src/modules/lst-apr.ts
|
|
28136
|
-
var
|
|
28171
|
+
var LSTAPRService2 = class {
|
|
28137
28172
|
// 5 minutes
|
|
28138
28173
|
/**
|
|
28139
28174
|
* Fetches LST stats from Endur API with caching
|
|
@@ -28215,7 +28250,6 @@ var LSTAPRService = class {
|
|
|
28215
28250
|
const stats = await this.getLSTStats();
|
|
28216
28251
|
const result = /* @__PURE__ */ new Map();
|
|
28217
28252
|
for (const stat of stats) {
|
|
28218
|
-
console.log("stat", stat);
|
|
28219
28253
|
result.set(stat.assetAddress, stat);
|
|
28220
28254
|
}
|
|
28221
28255
|
return result;
|
|
@@ -28229,10 +28263,10 @@ var LSTAPRService = class {
|
|
|
28229
28263
|
logger.verbose(`LSTAPRService: Cache cleared`);
|
|
28230
28264
|
}
|
|
28231
28265
|
};
|
|
28232
|
-
|
|
28233
|
-
|
|
28234
|
-
|
|
28235
|
-
|
|
28266
|
+
LSTAPRService2.ENDUR_API_URL = "https://app.endur.fi/api/lst/stats";
|
|
28267
|
+
LSTAPRService2.cache = null;
|
|
28268
|
+
LSTAPRService2.cacheTimestamp = 0;
|
|
28269
|
+
LSTAPRService2.CACHE_DURATION = 5 * 60 * 1e3;
|
|
28236
28270
|
|
|
28237
28271
|
// src/notifs/telegram.ts
|
|
28238
28272
|
var import_node_telegram_bot_api = __toESM(require("node-telegram-bot-api"));
|
package/dist/index.mjs
CHANGED
|
@@ -26704,20 +26704,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26704
26704
|
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
26705
26705
|
const baseAPYs = [];
|
|
26706
26706
|
const rewardAPYs = [];
|
|
26707
|
-
const underlyingAddresses = vesuAdapters.map((adapter) => adapter.config.debt.address);
|
|
26708
|
-
let lstAPRs;
|
|
26709
|
-
try {
|
|
26710
|
-
lstAPRs = await LSTAPRService.getLSTAPRs(underlyingAddresses);
|
|
26711
|
-
} catch (error) {
|
|
26712
|
-
logger.warn(`${this.metadata.name}::netAPY: Failed to fetch LST APRs from Endur API, using fallback: ${error}`);
|
|
26713
|
-
lstAPRs = /* @__PURE__ */ new Map();
|
|
26714
|
-
}
|
|
26715
26707
|
for (const [index, pool] of pools.entries()) {
|
|
26716
26708
|
const vesuAdapter = vesuAdapters[index];
|
|
26717
26709
|
const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
|
|
26718
26710
|
const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
|
|
26719
26711
|
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
26720
|
-
const lstAPY =
|
|
26712
|
+
const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
|
|
26721
26713
|
logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
|
|
26722
26714
|
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
26723
26715
|
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
|
|
@@ -26734,7 +26726,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26734
26726
|
id: "defispring"
|
|
26735
26727
|
}] };
|
|
26736
26728
|
}
|
|
26729
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
26730
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
26731
|
+
rewardAPYs.push(0);
|
|
26737
26732
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
26733
|
+
weights.push(unusedBalanceAPY.weight);
|
|
26738
26734
|
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
26739
26735
|
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
26740
26736
|
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
@@ -26749,6 +26745,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26749
26745
|
id: "defispring"
|
|
26750
26746
|
}] };
|
|
26751
26747
|
}
|
|
26748
|
+
async getUnusedBalanceAPY() {
|
|
26749
|
+
return {
|
|
26750
|
+
apy: 0,
|
|
26751
|
+
weight: 0
|
|
26752
|
+
};
|
|
26753
|
+
}
|
|
26752
26754
|
computeAPY(apys, weights, currentAUM) {
|
|
26753
26755
|
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
26754
26756
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
@@ -26946,13 +26948,8 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
26946
26948
|
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
26947
26949
|
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
26948
26950
|
*/
|
|
26949
|
-
async getLSTAPR() {
|
|
26950
|
-
|
|
26951
|
-
return await LSTAPRService.getLSTAPR(this.asset().address);
|
|
26952
|
-
} catch (error) {
|
|
26953
|
-
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
26954
|
-
return 0;
|
|
26955
|
-
}
|
|
26951
|
+
async getLSTAPR(address) {
|
|
26952
|
+
return 0;
|
|
26956
26953
|
}
|
|
26957
26954
|
async getVesuHealthFactors() {
|
|
26958
26955
|
return await Promise.all(this.getVesuAdapters().map((v) => v.getHealthFactor()));
|
|
@@ -27602,6 +27599,9 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27602
27599
|
logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
27603
27600
|
return price;
|
|
27604
27601
|
}
|
|
27602
|
+
async getAvnuSwapMultiplyCall(params) {
|
|
27603
|
+
return [];
|
|
27604
|
+
}
|
|
27605
27605
|
/**
|
|
27606
27606
|
* Uses vesu's multiple call to create leverage on LST
|
|
27607
27607
|
* Deposit amount is in LST
|
|
@@ -27646,6 +27646,41 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
27646
27646
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27647
27647
|
return vesuAdapter1.config.debt;
|
|
27648
27648
|
}
|
|
27649
|
+
/**
|
|
27650
|
+
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
27651
|
+
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
27652
|
+
*/
|
|
27653
|
+
async getLSTAPR(_address) {
|
|
27654
|
+
try {
|
|
27655
|
+
const vesuAdapter1 = this.getVesuAdapters()[0];
|
|
27656
|
+
return await LSTAPRService2.getLSTAPR(vesuAdapter1.config.debt.address);
|
|
27657
|
+
} catch (error) {
|
|
27658
|
+
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
27659
|
+
return 0;
|
|
27660
|
+
}
|
|
27661
|
+
}
|
|
27662
|
+
// todo undo this
|
|
27663
|
+
async netAPY() {
|
|
27664
|
+
const { net, splits } = await super.netAPY();
|
|
27665
|
+
let _net = net;
|
|
27666
|
+
if (this.asset().symbol == "xWBTC") {
|
|
27667
|
+
_net *= 5;
|
|
27668
|
+
}
|
|
27669
|
+
return {
|
|
27670
|
+
net: _net,
|
|
27671
|
+
splits
|
|
27672
|
+
};
|
|
27673
|
+
}
|
|
27674
|
+
async getUnusedBalanceAPY() {
|
|
27675
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
27676
|
+
const vesuAdapter = this.getVesuAdapters()[0];
|
|
27677
|
+
const underlying = vesuAdapter.config.debt;
|
|
27678
|
+
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
27679
|
+
return {
|
|
27680
|
+
apy: lstAPY,
|
|
27681
|
+
weight: unusedBalance.usdValue
|
|
27682
|
+
};
|
|
27683
|
+
}
|
|
27649
27684
|
async getLSTExchangeRate() {
|
|
27650
27685
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
27651
27686
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -28035,7 +28070,7 @@ var PricerLST2 = class extends Pricer {
|
|
|
28035
28070
|
};
|
|
28036
28071
|
|
|
28037
28072
|
// src/modules/lst-apr.ts
|
|
28038
|
-
var
|
|
28073
|
+
var LSTAPRService2 = class {
|
|
28039
28074
|
// 5 minutes
|
|
28040
28075
|
/**
|
|
28041
28076
|
* Fetches LST stats from Endur API with caching
|
|
@@ -28117,7 +28152,6 @@ var LSTAPRService = class {
|
|
|
28117
28152
|
const stats = await this.getLSTStats();
|
|
28118
28153
|
const result = /* @__PURE__ */ new Map();
|
|
28119
28154
|
for (const stat of stats) {
|
|
28120
|
-
console.log("stat", stat);
|
|
28121
28155
|
result.set(stat.assetAddress, stat);
|
|
28122
28156
|
}
|
|
28123
28157
|
return result;
|
|
@@ -28131,10 +28165,10 @@ var LSTAPRService = class {
|
|
|
28131
28165
|
logger.verbose(`LSTAPRService: Cache cleared`);
|
|
28132
28166
|
}
|
|
28133
28167
|
};
|
|
28134
|
-
|
|
28135
|
-
|
|
28136
|
-
|
|
28137
|
-
|
|
28168
|
+
LSTAPRService2.ENDUR_API_URL = "https://app.endur.fi/api/lst/stats";
|
|
28169
|
+
LSTAPRService2.cache = null;
|
|
28170
|
+
LSTAPRService2.cacheTimestamp = 0;
|
|
28171
|
+
LSTAPRService2.CACHE_DURATION = 5 * 60 * 1e3;
|
|
28138
28172
|
|
|
28139
28173
|
// src/notifs/telegram.ts
|
|
28140
28174
|
import TelegramBot from "node-telegram-bot-api";
|
|
@@ -28663,7 +28697,7 @@ export {
|
|
|
28663
28697
|
HyperLSTStrategies,
|
|
28664
28698
|
ILending,
|
|
28665
28699
|
Initializable,
|
|
28666
|
-
LSTAPRService,
|
|
28700
|
+
LSTAPRService2 as LSTAPRService,
|
|
28667
28701
|
MarginType,
|
|
28668
28702
|
Network,
|
|
28669
28703
|
PRICE_ROUTER,
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { Global } from "@/global";
|
|
|
6
6
|
import { ApproveCallParams, CommonAdapter, getVesuSingletonAddress, ManageCall, Swap, VesuAdapter, VesuModifyDelegationCallParams, VesuMultiplyCallParams, VesuPools } from "./universal-adapters";
|
|
7
7
|
import { AVNU_MIDDLEWARE } from "./universal-adapters/adapter-utils";
|
|
8
8
|
import { DepegRiskLevel, LiquidationRiskLevel, SmartContractRiskLevel, TechnicalRiskLevel } from "@/interfaces/risks";
|
|
9
|
-
import { EkuboQuoter, ERC20, PricerLST } from "@/modules";
|
|
9
|
+
import { EkuboQuoter, ERC20, LSTAPRService, PricerLST } from "@/modules";
|
|
10
10
|
import { assert, logger } from "@/utils";
|
|
11
11
|
import { SingleTokenInfo } from "./base-strategy";
|
|
12
12
|
import { Call, Contract, uint256 } from "starknet";
|
|
@@ -76,6 +76,14 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<UniversalS
|
|
|
76
76
|
return price;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
|
|
80
|
+
async getAvnuSwapMultiplyCall(params: {
|
|
81
|
+
isDeposit: boolean,
|
|
82
|
+
leg1DepositAmount: Web3Number
|
|
83
|
+
}) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
/**
|
|
80
88
|
* Uses vesu's multiple call to create leverage on LST
|
|
81
89
|
* Deposit amount is in LST
|
|
@@ -151,6 +159,43 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<UniversalS
|
|
|
151
159
|
return vesuAdapter1.config.debt;
|
|
152
160
|
}
|
|
153
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
164
|
+
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
165
|
+
*/
|
|
166
|
+
async getLSTAPR(_address: ContractAddr): Promise<number> {
|
|
167
|
+
try {
|
|
168
|
+
const vesuAdapter1 = this.getVesuAdapters()[0];
|
|
169
|
+
return await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// todo undo this
|
|
177
|
+
async netAPY(): Promise<{ net: number; splits: { apy: number; id: string; }[]; }> {
|
|
178
|
+
const { net, splits } = await super.netAPY();
|
|
179
|
+
let _net = net;
|
|
180
|
+
if (this.asset().symbol == 'xWBTC') {
|
|
181
|
+
_net *= 5;
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
net: _net,
|
|
185
|
+
splits: splits
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
protected async getUnusedBalanceAPY() {
|
|
190
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
191
|
+
const vesuAdapter = this.getVesuAdapters()[0];
|
|
192
|
+
const underlying = vesuAdapter.config.debt;
|
|
193
|
+
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
194
|
+
return {
|
|
195
|
+
apy: lstAPY, weight: unusedBalance.usdValue
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
154
199
|
async getLSTExchangeRate() {
|
|
155
200
|
const [vesuAdapter1] = this.getVesuAdapters();
|
|
156
201
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
@@ -337,7 +382,11 @@ function getDescription(tokenSymbol: string, underlyingSymbol: string) {
|
|
|
337
382
|
enum LST_MULTIPLIER_MANAGE_IDS {
|
|
338
383
|
MULTIPLY_VESU = 'multiply_vesu',
|
|
339
384
|
SWITCH_DELEGATION_ON = 'switch_delegation_on',
|
|
340
|
-
SWITCH_DELEGATION_OFF = 'switch_delegation_off'
|
|
385
|
+
SWITCH_DELEGATION_OFF = 'switch_delegation_off',
|
|
386
|
+
AVNU_MULTIPLY_APPROVE_DEPOSIT = 'avnu_multiply_approve_deposit',
|
|
387
|
+
AVNU_MULTIPLY_SWAP_DEPOSIT = 'avnu_multiply_swap_deposit',
|
|
388
|
+
AVNU_MULTIPLY_APPROVE_WITHDRAW = 'avnu_multiply_approve_withdraw',
|
|
389
|
+
AVNU_MULTIPLY_SWAP_WITHDRAW = 'avnu_multiply_swap_withdraw',
|
|
341
390
|
}
|
|
342
391
|
|
|
343
392
|
function getLooperSettings(
|
|
@@ -385,6 +434,12 @@ function getLooperSettings(
|
|
|
385
434
|
adapter: commonAdapter
|
|
386
435
|
}])
|
|
387
436
|
|
|
437
|
+
// avnu multiply
|
|
438
|
+
// vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(underlyingToken.address, AVNU_MIDDLEWARE, LST_MULTIPLIER_MANAGE_IDS.AVNU_MULTIPLY_APPROVE_DEPOSIT).bind(commonAdapter));
|
|
439
|
+
// vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(underlyingToken.address, lstToken.address, LST_MULTIPLIER_MANAGE_IDS.AVNU_MULTIPLY_SWAP_DEPOSIT).bind(commonAdapter));
|
|
440
|
+
// vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, AVNU_MIDDLEWARE, LST_MULTIPLIER_MANAGE_IDS.AVNU_MULTIPLY_APPROVE_WITHDRAW).bind(commonAdapter));
|
|
441
|
+
// vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(lstToken.address, underlyingToken.address, LST_MULTIPLIER_MANAGE_IDS.AVNU_MULTIPLY_SWAP_WITHDRAW).bind(commonAdapter));
|
|
442
|
+
|
|
388
443
|
// to bridge liquidity back to vault (used by bring_liquidity)
|
|
389
444
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, UNIVERSAL_MANAGE_IDS.APPROVE_BRING_LIQUIDITY).bind(commonAdapter));
|
|
390
445
|
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter(UNIVERSAL_MANAGE_IDS.BRING_LIQUIDITY).bind(commonAdapter));
|
|
@@ -228,16 +228,6 @@ export class UniversalStrategy<
|
|
|
228
228
|
const baseAPYs: number[] = [];
|
|
229
229
|
const rewardAPYs: number[] = [];
|
|
230
230
|
|
|
231
|
-
// Get LST APRs for all collateral assets with fallback
|
|
232
|
-
const underlyingAddresses = vesuAdapters.map(adapter => adapter.config.debt.address);
|
|
233
|
-
let lstAPRs: Map<string, number>;
|
|
234
|
-
try {
|
|
235
|
-
lstAPRs = await LSTAPRService.getLSTAPRs(underlyingAddresses);
|
|
236
|
-
} catch (error) {
|
|
237
|
-
logger.warn(`${this.metadata.name}::netAPY: Failed to fetch LST APRs from Endur API, using fallback: ${error}`);
|
|
238
|
-
// Fallback: create empty map (will result in 0 LST APR)
|
|
239
|
-
lstAPRs = new Map();
|
|
240
|
-
}
|
|
241
231
|
|
|
242
232
|
for (const [index, pool] of pools.entries()) {
|
|
243
233
|
const vesuAdapter = vesuAdapters[index];
|
|
@@ -246,7 +236,7 @@ export class UniversalStrategy<
|
|
|
246
236
|
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
247
237
|
|
|
248
238
|
// Use LST APR from Endur API instead of Vesu's lstApr
|
|
249
|
-
const lstAPY =
|
|
239
|
+
const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
|
|
250
240
|
logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
|
|
251
241
|
|
|
252
242
|
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
@@ -267,8 +257,13 @@ export class UniversalStrategy<
|
|
|
267
257
|
}]};
|
|
268
258
|
}
|
|
269
259
|
|
|
260
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
261
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
262
|
+
rewardAPYs.push(0);
|
|
263
|
+
|
|
270
264
|
// Compute APy using weights
|
|
271
265
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
266
|
+
weights.push(unusedBalanceAPY.weight);
|
|
272
267
|
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
273
268
|
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
274
269
|
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
@@ -282,6 +277,12 @@ export class UniversalStrategy<
|
|
|
282
277
|
}] };
|
|
283
278
|
}
|
|
284
279
|
|
|
280
|
+
protected async getUnusedBalanceAPY() {
|
|
281
|
+
return {
|
|
282
|
+
apy: 0, weight: 0
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
285
286
|
private computeAPY(apys: number[], weights: number[], currentAUM: Web3Number) {
|
|
286
287
|
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
287
288
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
@@ -521,13 +522,8 @@ export class UniversalStrategy<
|
|
|
521
522
|
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
522
523
|
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
523
524
|
*/
|
|
524
|
-
async getLSTAPR(): Promise<number> {
|
|
525
|
-
|
|
526
|
-
return await LSTAPRService.getLSTAPR(this.asset().address);
|
|
527
|
-
} catch (error) {
|
|
528
|
-
logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
|
|
529
|
-
return 0;
|
|
530
|
-
}
|
|
525
|
+
async getLSTAPR(address: ContractAddr): Promise<number> {
|
|
526
|
+
return 0;
|
|
531
527
|
}
|
|
532
528
|
|
|
533
529
|
async getVesuHealthFactors() {
|