@strkfarm/sdk 1.1.28 → 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.
@@ -90732,7 +90732,11 @@ spurious results.`);
90732
90732
  id: "defispring"
90733
90733
  }] };
90734
90734
  }
90735
+ const unusedBalanceAPY = await this.getUnusedBalanceAPY();
90736
+ baseAPYs.push(...[unusedBalanceAPY.apy]);
90737
+ rewardAPYs.push(0);
90735
90738
  const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
90739
+ weights.push(unusedBalanceAPY.weight);
90736
90740
  const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
90737
90741
  const prevAUMUSD = prevAUM.multipliedBy(price.price);
90738
90742
  const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
@@ -90747,6 +90751,12 @@ spurious results.`);
90747
90751
  id: "defispring"
90748
90752
  }] };
90749
90753
  }
90754
+ async getUnusedBalanceAPY() {
90755
+ return {
90756
+ apy: 0,
90757
+ weight: 0
90758
+ };
90759
+ }
90750
90760
  computeAPY(apys, weights, currentAUM) {
90751
90761
  assert3(apys.length === weights.length, "APYs and weights length mismatch");
90752
90762
  const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
@@ -91594,6 +91604,9 @@ spurious results.`);
91594
91604
  logger2.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
91595
91605
  return price;
91596
91606
  }
91607
+ async getAvnuSwapMultiplyCall(params) {
91608
+ return [];
91609
+ }
91597
91610
  /**
91598
91611
  * Uses vesu's multiple call to create leverage on LST
91599
91612
  * Deposit amount is in LST
@@ -91651,6 +91664,28 @@ spurious results.`);
91651
91664
  return 0;
91652
91665
  }
91653
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
+ }
91654
91689
  async getLSTExchangeRate() {
91655
91690
  const [vesuAdapter1] = this.getVesuAdapters();
91656
91691
  const lstTokenInfo = vesuAdapter1.config.collateral;
@@ -26828,7 +26828,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
26828
26828
  id: "defispring"
26829
26829
  }] };
26830
26830
  }
26831
+ const unusedBalanceAPY = await this.getUnusedBalanceAPY();
26832
+ baseAPYs.push(...[unusedBalanceAPY.apy]);
26833
+ rewardAPYs.push(0);
26831
26834
  const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
26835
+ weights.push(unusedBalanceAPY.weight);
26832
26836
  const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
26833
26837
  const prevAUMUSD = prevAUM.multipliedBy(price.price);
26834
26838
  const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
@@ -26843,6 +26847,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
26843
26847
  id: "defispring"
26844
26848
  }] };
26845
26849
  }
26850
+ async getUnusedBalanceAPY() {
26851
+ return {
26852
+ apy: 0,
26853
+ weight: 0
26854
+ };
26855
+ }
26846
26856
  computeAPY(apys, weights, currentAUM) {
26847
26857
  assert(apys.length === weights.length, "APYs and weights length mismatch");
26848
26858
  const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
@@ -27691,6 +27701,9 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27691
27701
  logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
27692
27702
  return price;
27693
27703
  }
27704
+ async getAvnuSwapMultiplyCall(params) {
27705
+ return [];
27706
+ }
27694
27707
  /**
27695
27708
  * Uses vesu's multiple call to create leverage on LST
27696
27709
  * Deposit amount is in LST
@@ -27748,6 +27761,28 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27748
27761
  return 0;
27749
27762
  }
27750
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
+ }
27751
27786
  async getLSTExchangeRate() {
27752
27787
  const [vesuAdapter1] = this.getVesuAdapters();
27753
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.
@@ -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
@@ -1304,6 +1312,17 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<Universal
1304
1312
  * @returns Promise<number> The LST APR (not divided by 1e18)
1305
1313
  */
1306
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
+ }>;
1307
1326
  getLSTExchangeRate(): Promise<number>;
1308
1327
  /**
1309
1328
  *
package/dist/index.js CHANGED
@@ -26824,7 +26824,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
26824
26824
  id: "defispring"
26825
26825
  }] };
26826
26826
  }
26827
+ const unusedBalanceAPY = await this.getUnusedBalanceAPY();
26828
+ baseAPYs.push(...[unusedBalanceAPY.apy]);
26829
+ rewardAPYs.push(0);
26827
26830
  const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
26831
+ weights.push(unusedBalanceAPY.weight);
26828
26832
  const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
26829
26833
  const prevAUMUSD = prevAUM.multipliedBy(price.price);
26830
26834
  const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
@@ -26839,6 +26843,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
26839
26843
  id: "defispring"
26840
26844
  }] };
26841
26845
  }
26846
+ async getUnusedBalanceAPY() {
26847
+ return {
26848
+ apy: 0,
26849
+ weight: 0
26850
+ };
26851
+ }
26842
26852
  computeAPY(apys, weights, currentAUM) {
26843
26853
  assert(apys.length === weights.length, "APYs and weights length mismatch");
26844
26854
  const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
@@ -27687,6 +27697,9 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27687
27697
  logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
27688
27698
  return price;
27689
27699
  }
27700
+ async getAvnuSwapMultiplyCall(params) {
27701
+ return [];
27702
+ }
27690
27703
  /**
27691
27704
  * Uses vesu's multiple call to create leverage on LST
27692
27705
  * Deposit amount is in LST
@@ -27744,6 +27757,28 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27744
27757
  return 0;
27745
27758
  }
27746
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;
package/dist/index.mjs CHANGED
@@ -26726,7 +26726,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
26726
26726
  id: "defispring"
26727
26727
  }] };
26728
26728
  }
26729
+ const unusedBalanceAPY = await this.getUnusedBalanceAPY();
26730
+ baseAPYs.push(...[unusedBalanceAPY.apy]);
26731
+ rewardAPYs.push(0);
26729
26732
  const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
26733
+ weights.push(unusedBalanceAPY.weight);
26730
26734
  const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
26731
26735
  const prevAUMUSD = prevAUM.multipliedBy(price.price);
26732
26736
  const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
@@ -26741,6 +26745,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
26741
26745
  id: "defispring"
26742
26746
  }] };
26743
26747
  }
26748
+ async getUnusedBalanceAPY() {
26749
+ return {
26750
+ apy: 0,
26751
+ weight: 0
26752
+ };
26753
+ }
26744
26754
  computeAPY(apys, weights, currentAUM) {
26745
26755
  assert(apys.length === weights.length, "APYs and weights length mismatch");
26746
26756
  const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
@@ -27589,6 +27599,9 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27589
27599
  logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
27590
27600
  return price;
27591
27601
  }
27602
+ async getAvnuSwapMultiplyCall(params) {
27603
+ return [];
27604
+ }
27592
27605
  /**
27593
27606
  * Uses vesu's multiple call to create leverage on LST
27594
27607
  * Deposit amount is in LST
@@ -27646,6 +27659,28 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27646
27659
  return 0;
27647
27660
  }
27648
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.1.28",
3
+ "version": "1.1.29",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
@@ -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
@@ -165,6 +173,29 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<UniversalS
165
173
  }
166
174
  }
167
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
+
168
199
  async getLSTExchangeRate() {
169
200
  const [vesuAdapter1] = this.getVesuAdapters();
170
201
  const lstTokenInfo = vesuAdapter1.config.collateral;
@@ -351,7 +382,11 @@ function getDescription(tokenSymbol: string, underlyingSymbol: string) {
351
382
  enum LST_MULTIPLIER_MANAGE_IDS {
352
383
  MULTIPLY_VESU = 'multiply_vesu',
353
384
  SWITCH_DELEGATION_ON = 'switch_delegation_on',
354
- 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',
355
390
  }
356
391
 
357
392
  function getLooperSettings(
@@ -399,6 +434,12 @@ function getLooperSettings(
399
434
  adapter: commonAdapter
400
435
  }])
401
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
+
402
443
  // to bridge liquidity back to vault (used by bring_liquidity)
403
444
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, UNIVERSAL_MANAGE_IDS.APPROVE_BRING_LIQUIDITY).bind(commonAdapter));
404
445
  vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter(UNIVERSAL_MANAGE_IDS.BRING_LIQUIDITY).bind(commonAdapter));
@@ -257,8 +257,13 @@ export class UniversalStrategy<
257
257
  }]};
258
258
  }
259
259
 
260
+ const unusedBalanceAPY = await this.getUnusedBalanceAPY();
261
+ baseAPYs.push(...[unusedBalanceAPY.apy]);
262
+ rewardAPYs.push(0);
263
+
260
264
  // Compute APy using weights
261
265
  const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
266
+ weights.push(unusedBalanceAPY.weight);
262
267
  const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
263
268
  const prevAUMUSD = prevAUM.multipliedBy(price.price);
264
269
  const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
@@ -272,6 +277,12 @@ export class UniversalStrategy<
272
277
  }] };
273
278
  }
274
279
 
280
+ protected async getUnusedBalanceAPY() {
281
+ return {
282
+ apy: 0, weight: 0
283
+ }
284
+ }
285
+
275
286
  private computeAPY(apys: number[], weights: number[], currentAUM: Web3Number) {
276
287
  assert(apys.length === weights.length, "APYs and weights length mismatch");
277
288
  const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);