@strkfarm/sdk 1.1.70 → 1.1.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,8 @@ import { findMaxInputWithSlippage } from "@/utils/math-utils";
17
17
  export interface HyperLSTStrategySettings extends UniversalStrategySettings {
18
18
  borrowable_assets: TokenInfo[];
19
19
  underlyingToken: TokenInfo;
20
+ defaultPoolId: ContractAddr;
21
+ altSupportedPoolIds: ContractAddr[];
20
22
  }
21
23
 
22
24
  export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTStrategySettings> {
@@ -37,7 +39,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
37
39
  }
38
40
 
39
41
  asset() {
40
- return this.getVesuSameTokenAdapter().config.collateral;
42
+ return this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId).config.collateral;
41
43
  }
42
44
 
43
45
  getTag() {
@@ -45,8 +47,8 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
45
47
  }
46
48
 
47
49
  // Vesu adapter with LST and base token match
48
- getVesuSameTokenAdapter() {
49
- const baseAdapter = this.getAdapter(getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, this.metadata.additionalInfo.underlyingToken.symbol)) as VesuAdapter;
50
+ getVesuSameTokenAdapter(poolId: ContractAddr) {
51
+ const baseAdapter = this.getAdapter(getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, this.metadata.additionalInfo.underlyingToken.symbol, poolId.toString())) as VesuAdapter;
50
52
  baseAdapter.networkConfig = this.config;
51
53
  baseAdapter.pricer = this.pricer;
52
54
  return baseAdapter;
@@ -56,18 +58,20 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
56
58
  // todo support lending assets of underlying as well (like if xSTRK looping is not viable, simply supply STRK)
57
59
  getVesuAdapters() {
58
60
  const adapters: VesuAdapter[] = [];
59
- const baseAdapter = this.getVesuSameTokenAdapter();
60
- for (const asset of this.metadata.additionalInfo.borrowable_assets) {
61
- const vesuAdapter1 = new VesuAdapter({
62
- poolId: baseAdapter.config.poolId,
63
- collateral: this.asset(),
64
- debt: asset,
65
- vaultAllocator: this.metadata.additionalInfo.vaultAllocator,
66
- id: ''
67
- })
68
- vesuAdapter1.pricer = this.pricer;
69
- vesuAdapter1.networkConfig = this.config;
70
- adapters.push(vesuAdapter1);
61
+ for (const poolId of [this.metadata.additionalInfo.defaultPoolId, ...this.metadata.additionalInfo.altSupportedPoolIds]) {
62
+ const baseAdapter = this.getVesuSameTokenAdapter(poolId);
63
+ for (const asset of this.metadata.additionalInfo.borrowable_assets) {
64
+ const vesuAdapter1 = new VesuAdapter({
65
+ poolId: baseAdapter.config.poolId,
66
+ collateral: this.asset(),
67
+ debt: asset,
68
+ vaultAllocator: this.metadata.additionalInfo.vaultAllocator,
69
+ id: ''
70
+ })
71
+ vesuAdapter1.pricer = this.pricer;
72
+ vesuAdapter1.networkConfig = this.config;
73
+ adapters.push(vesuAdapter1);
74
+ }
71
75
  }
72
76
  return adapters;
73
77
  }
@@ -223,7 +227,8 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
223
227
  const debtAmountInLST = debtAmount.abs().dividedBy(lstDEXPrice);
224
228
  const calls = await this.getVesuMultiplyCall({
225
229
  isDeposit: false,
226
- leg1DepositAmount: debtAmountInLST
230
+ leg1DepositAmount: debtAmountInLST,
231
+ poolId: vesuAdapter.config.poolId
227
232
  })
228
233
  assert(calls.length == 1, `Expected 1 call for unwind, got ${calls.length}`);
229
234
  return calls[0];
@@ -234,7 +239,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
234
239
  const manageCall0 = manage0Info.callConstructor({
235
240
  amount: newDepositAmount
236
241
  });
237
- const STEP1 = getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, vesuAdapter.config.debt.symbol);
242
+ const STEP1 = getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, vesuAdapter.config.debt.symbol, vesuAdapter.config.poolId.toString());
238
243
  const manage1Info = this.getProofs<VesuModifyPositionCallParams>(STEP1);
239
244
  const manageCall1 = manage1Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
240
245
  collateralAmount: newDepositAmount,
@@ -300,7 +305,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
300
305
  amount: minAmount
301
306
  });
302
307
 
303
- const STEP5 = getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, vesuAdapter.config.debt.symbol);
308
+ const STEP5 = getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, vesuAdapter.config.debt.symbol, vesuAdapter.config.poolId.toString());
304
309
  const manage5Info = this.getProofs<VesuModifyPositionCallParams>(STEP5);
305
310
  const manageCall5 = manage5Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
306
311
  collateralAmount: minAmount,
@@ -428,10 +433,11 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
428
433
  async getVesuMultiplyCall(params: {
429
434
  isDeposit: boolean,
430
435
  leg1DepositAmount: Web3Number,
431
- maxEkuboPriceImpact?: number
436
+ maxEkuboPriceImpact?: number,
437
+ poolId: ContractAddr
432
438
  }) {
433
439
  const maxEkuboPriceImpact = params.maxEkuboPriceImpact || 0.01;
434
- const vesuAdapter1 = this.getVesuSameTokenAdapter();
440
+ const vesuAdapter1 = this.getVesuSameTokenAdapter(params.poolId);
435
441
  const legLTV = await vesuAdapter1.getLTVConfig(this.config);
436
442
  logger.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
437
443
 
@@ -508,21 +514,24 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
508
514
  debtAmount,
509
515
  lstDexPriceInUnderlying: dexPrice,
510
516
  isIncrease: debtAmount.greaterThan(0),
511
- maxEkuboPriceImpact
517
+ maxEkuboPriceImpact,
518
+ poolId: params.poolId
512
519
  });
513
520
  }
514
521
 
515
522
  getLSTUnderlyingTokenInfo() {
516
- const vesuAdapter1 = this.getVesuSameTokenAdapter();
523
+ const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
517
524
  return vesuAdapter1.config.debt;
518
525
  }
519
526
 
520
527
  async getMaxBorrowableAmount(params: { isAPYComputation: boolean } = { isAPYComputation: false }) {
521
528
  const vesuAdapters = this.getVesuAdapters();
522
529
  let netMaxBorrowableAmount = Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals);
523
- const maxBorrowables: {amount: Web3Number, dexSwappableAmount: Web3Number, maxBorrowableAmount: Web3Number, borrowableAsset: TokenInfo}[] = [];
530
+ const maxBorrowables: {amount: Web3Number, dexSwappableAmount: Web3Number, maxBorrowableAmount: Web3Number, borrowableAsset: TokenInfo, ltv: number}[] = [];
524
531
  for (const vesuAdapter of vesuAdapters) {
525
- maxBorrowables.push(await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation));
532
+ const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
533
+ const ltv = await vesuAdapter.getLTVConfig(this.config);
534
+ maxBorrowables.push({...output, ltv});
526
535
  }
527
536
  maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
528
537
  netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
@@ -550,10 +559,16 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
550
559
  async getMaxBorrowableAmountByVesuAdapter(vesuAdapter: VesuAdapter, isAPYComputation: boolean) {
551
560
  const lstAPY = await this.getLSTAPR(this.getLSTUnderlyingTokenInfo().address);
552
561
  const maxInterestRate = lstAPY * 0.8;
553
- const maxBorrowableAmount = await vesuAdapter.getMaxBorrowableByInterestRate(this.config, vesuAdapter.config.debt, maxInterestRate);
562
+ const {maxDebtToHave: maxBorrowableAmount, currentDebt} = await vesuAdapter.getMaxBorrowableByInterestRate(this.config, vesuAdapter.config.debt, maxInterestRate);
554
563
  const debtCap = await vesuAdapter.getDebtCap(this.config);
555
564
 
556
- const maxBorrowable = maxBorrowableAmount.minimum(debtCap).multipliedBy(0.999);
565
+ if (currentDebt.gte(debtCap)) {
566
+ return {amount: Web3Number.fromWei("0", vesuAdapter.config.debt.decimals), dexSwappableAmount: Web3Number.fromWei("0", vesuAdapter.config.debt.decimals), maxBorrowableAmount: Web3Number.fromWei("0", vesuAdapter.config.debt.decimals), borrowableAsset: vesuAdapter.config.debt};
567
+ }
568
+
569
+ const availableToBorrow = debtCap.minus(currentDebt);
570
+
571
+ const maxBorrowable = maxBorrowableAmount.minimum(availableToBorrow).multipliedBy(0.999);
557
572
  // Dont compute precise max swappable for APY computation
558
573
  if (vesuAdapter.config.debt.address.eq(this.getLSTUnderlyingTokenInfo().address) || isAPYComputation) {
559
574
  return {amount: maxBorrowable, dexSwappableAmount: maxBorrowable, maxBorrowableAmount: maxBorrowable, borrowableAsset: vesuAdapter.config.debt};
@@ -579,7 +594,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
579
594
  */
580
595
  async getLSTAPR(_address: ContractAddr): Promise<number> {
581
596
  try {
582
- const vesuAdapter1 = this.getVesuSameTokenAdapter();
597
+ const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
583
598
  const apr = await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
584
599
  if (!apr) {
585
600
  throw new Error('Failed to get LST APR');
@@ -619,32 +634,25 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
619
634
 
620
635
  async maxNewDeposits(params: { isAPYComputation: boolean } = { isAPYComputation: false }) {
621
636
  const maxBorrowableAmounts = await this.getMaxBorrowableAmount(params);
622
-
637
+ let numerator = 0;
638
+
623
639
  let ltv: number | undefined = undefined;
624
640
  for (let adapter of this.getVesuAdapters()) {
625
- const maxBorrowableAmount = maxBorrowableAmounts.maxBorrowables.find(b => b.borrowableAsset.address.eq(adapter.config.debt.address))?.amount;
626
- if (!maxBorrowableAmount) {
641
+ const maxBorrowableAmountInfo = maxBorrowableAmounts.maxBorrowables.find(b => b.borrowableAsset.address.eq(adapter.config.debt.address));
642
+ if (!maxBorrowableAmountInfo || !maxBorrowableAmountInfo?.amount) {
627
643
  throw new Error(`Max borrowable amount not found for adapter: ${adapter.config.debt.symbol}`);
628
644
  }
629
- const maxLTV = await adapter.getLTVConfig(this.config);
630
- if (!ltv) {
631
- ltv = maxLTV;
632
- } else if (ltv != maxLTV) {
633
- throw new Error(`LTV mismatch for adapter: ${adapter.config.debt.symbol}`);
634
- }
635
- }
636
- if (!ltv) {
637
- throw new Error('LTV not found');
645
+
646
+ numerator += this.metadata.additionalInfo.targetHealthFactor * maxBorrowableAmountInfo.amount.toNumber() / maxBorrowableAmountInfo.ltv;
638
647
  }
639
- // for simplicity, we assume 1 underlying = 1 LST
640
- const numerator = this.metadata.additionalInfo.targetHealthFactor * maxBorrowableAmounts.netMaxBorrowableAmount.toNumber() / (ltv)
648
+
641
649
  return numerator - maxBorrowableAmounts.netMaxBorrowableAmount.toNumber();
642
650
  }
643
651
 
644
652
  // todo revisit cases where 0th adapters is used
645
653
  protected async getUnusedBalanceAPY() {
646
654
  const unusedBalance = await this.getUnusedBalance();
647
- const vesuAdapter = this.getVesuSameTokenAdapter();
655
+ const vesuAdapter = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
648
656
  const underlying = vesuAdapter.config.debt;
649
657
  const lstAPY = await this.getLSTAPR(underlying.address);
650
658
  return {
@@ -653,7 +661,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
653
661
  }
654
662
 
655
663
  async getLSTExchangeRate() {
656
- const vesuAdapter1 = this.getVesuSameTokenAdapter();
664
+ const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
657
665
  const lstTokenInfo = vesuAdapter1.config.collateral;
658
666
  const lstABI = new Contract({
659
667
  abi: ERC4626Abi,
@@ -676,12 +684,13 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
676
684
  debtAmount: Web3Number,
677
685
  lstDexPriceInUnderlying: number,
678
686
  isIncrease: boolean,
679
- maxEkuboPriceImpact: number
687
+ maxEkuboPriceImpact: number,
688
+ poolId: ContractAddr
680
689
  }): Promise<Call[]> {
681
690
  logger.verbose(`${this.getTag()}::getModifyLeverCall marginAmount: ${params.marginAmount}, debtAmount: ${params.debtAmount}, lstDexPriceInUnderlying: ${params.lstDexPriceInUnderlying}, isIncrease: ${params.isIncrease}`);
682
691
  assert(!params.marginAmount.isZero() || !params.debtAmount.isZero(), 'Deposit/debt must be non-0');
683
692
 
684
- const vesuAdapter1 = this.getVesuSameTokenAdapter();
693
+ const vesuAdapter1 = this.getVesuSameTokenAdapter(params.poolId);
685
694
  const lstTokenInfo = this.asset();
686
695
  const lstUnderlyingTokenInfo = vesuAdapter1.config.debt;
687
696
 
@@ -697,7 +706,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
697
706
 
698
707
  // approve token
699
708
  if (params.marginAmount.greaterThan(0)) {
700
- const STEP1_ID = LST_MULTIPLIER_MANAGE_IDS.MULTIPLE_APPROVE;
709
+ const STEP1_ID = getVesuGenericLegId(params.poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.MULTIPLE_APPROVE);
701
710
  const manage1Info = this.getProofs<ApproveCallParams>(STEP1_ID);
702
711
  const depositAmount = params.marginAmount;
703
712
  const manageCall1 = manage1Info.callConstructor({
@@ -748,14 +757,14 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
748
757
  // }
749
758
  maxUsedCollateral = maxUsedCollateralInLST; // in any case, we are ok with this, bcz the BTC LST spread shouldnt be high
750
759
 
751
- const STEP2_ID = LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_ON;
760
+ const STEP2_ID = getVesuGenericLegId(params.poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_ON);
752
761
  const manage2Info = this.getProofs<VesuModifyDelegationCallParams>(STEP2_ID);
753
762
  const manageCall2 = manage2Info.callConstructor({
754
763
  delegation: true
755
764
  });
756
765
 
757
766
  // deposit and borrow or repay and withdraw
758
- const STEP3_ID = getVesuLegId(LST_MULTIPLIER_MANAGE_IDS.MULTIPLY_VESU, vesuAdapter1.config.debt.symbol);
767
+ const STEP3_ID = getVesuLegId(LST_MULTIPLIER_MANAGE_IDS.MULTIPLY_VESU, vesuAdapter1.config.debt.symbol, vesuAdapter1.config.poolId.toString());
759
768
  const manage3Info = this.getProofs<VesuMultiplyCallParams>(STEP3_ID);
760
769
  const multiplyParams: VesuMultiplyCallParams = params.isIncrease ? {
761
770
  isIncrease: true,
@@ -784,7 +793,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
784
793
  const manageCall3 = manage3Info.callConstructor(multiplyParams);
785
794
 
786
795
  // switch delegation off
787
- const STEP4_ID = LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_OFF;
796
+ const STEP4_ID = getVesuGenericLegId(params.poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_OFF);
788
797
  const manage4Info = this.getProofs<VesuModifyDelegationCallParams>(STEP4_ID);
789
798
  const manageCall4 = manage4Info.callConstructor({
790
799
  delegation: false
@@ -864,28 +873,75 @@ function getAvnuManageIDs(baseID: LST_MULTIPLIER_MANAGE_IDS, debtTokenSymbol: st
864
873
  return `${baseID}_${debtTokenSymbol.toLowerCase()}`;
865
874
  }
866
875
 
867
- function getVesuLegId(baseID: string, debtTokenSymbol: string) {
868
- return `${baseID}_${debtTokenSymbol.toLowerCase()}`;
876
+ function getVesuGenericLegId(poolId: string, action: string) {
877
+ return `${action}_${poolId.slice(-4).toLowerCase()}`;
869
878
  }
870
879
 
871
- function getLooperSettings(
880
+ function getVesuLegId(baseID: string, debtTokenSymbol: string, poolId: string) {
881
+ return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
882
+ }
883
+
884
+ function addVesuLeaves(
885
+ poolId: ContractAddr,
872
886
  lstSymbol: string,
873
887
  underlyingSymbol: string,
874
888
  vaultSettings: HyperLSTStrategySettings,
875
- pool1: ContractAddr,
889
+ commonAdapter: CommonAdapter,
876
890
  ) {
877
- vaultSettings.leafAdapters = [];
878
-
879
891
  const lstToken = Global.getDefaultTokens().find(token => token.symbol === lstSymbol)!;
880
892
  const underlyingToken = Global.getDefaultTokens().find(token => token.symbol === underlyingSymbol)!;
881
893
 
882
894
  const vesuAdapterLST = new VesuAdapter({
883
- poolId: pool1,
895
+ poolId: poolId,
884
896
  collateral: lstToken,
885
897
  debt: underlyingToken,
886
898
  vaultAllocator: vaultSettings.vaultAllocator,
887
- id: getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, underlyingToken.symbol)
888
- })
899
+ id: getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, underlyingToken.symbol, poolId.toString())
900
+ });
901
+
902
+ // Useful for returning adapter class objects that can compute
903
+ // certain things for us (e.g. positions, hfs)
904
+ vaultSettings.adapters.push(...[{
905
+ id: getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, underlyingToken.symbol, poolId.toString()),
906
+ adapter: vesuAdapterLST
907
+ }]);
908
+
909
+ // avnu multiply
910
+ const { isV2, addr: _ } = getVesuSingletonAddress(poolId);
911
+
912
+ // vesu multiply looping
913
+ const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
914
+
915
+ const leafIdApprove = getVesuGenericLegId(poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.MULTIPLE_APPROVE);
916
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, leafIdApprove).bind(commonAdapter));
917
+
918
+ const leafIdDelegationOn = getVesuGenericLegId(poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_ON);
919
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn).bind(vesuAdapterLST));
920
+
921
+ const leafIdDelegationOff = getVesuGenericLegId(poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_OFF);
922
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff).bind(vesuAdapterLST));
923
+
924
+ const multiplID = getVesuLegId(LST_MULTIPLIER_MANAGE_IDS.MULTIPLY_VESU, underlyingToken.symbol, poolId.toString());
925
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
926
+
927
+ return vesuAdapterLST;
928
+ }
929
+
930
+ function getLooperSettings(
931
+ lstSymbol: string,
932
+ underlyingSymbol: string,
933
+ vaultSettings: HyperLSTStrategySettings,
934
+ defaultPoolId: ContractAddr,
935
+ altSupportedPoolIds: ContractAddr[] = []
936
+ ) {
937
+ vaultSettings.leafAdapters = [];
938
+ const pool1 = vaultSettings.defaultPoolId;
939
+ if (!pool1.eq(defaultPoolId)) {
940
+ throw new Error(`Dont include default pool id in supported pool ids`);
941
+ }
942
+
943
+ const lstToken = Global.getDefaultTokens().find(token => token.symbol === lstSymbol)!;
944
+ const underlyingToken = Global.getDefaultTokens().find(token => token.symbol === underlyingSymbol)!;
889
945
 
890
946
  const commonAdapter = new CommonAdapter({
891
947
  manager: vaultSettings.manager,
@@ -893,26 +949,20 @@ function getLooperSettings(
893
949
  id: '',
894
950
  vaultAddress: vaultSettings.vaultAddress,
895
951
  vaultAllocator: vaultSettings.vaultAllocator,
896
- })
952
+ });
897
953
 
898
- // Useful for returning adapter class objects that can compute
899
- // certain things for us (e.g. positions, hfs)
954
+ // add common adapter to adapters
900
955
  vaultSettings.adapters.push(...[{
901
- id: getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, underlyingToken.symbol),
902
- adapter: vesuAdapterLST
903
- },{
904
956
  id: UNIVERSAL_ADAPTERS.COMMON,
905
957
  adapter: commonAdapter
906
- }])
958
+ }]);
907
959
 
908
- // avnu multiply
909
- const { isV2, addr:poolAddr } = getVesuSingletonAddress(pool1);
910
- // vesu multiply looping
911
- const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
912
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, LST_MULTIPLIER_MANAGE_IDS.MULTIPLE_APPROVE).bind(commonAdapter));
913
- vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_ON).bind(vesuAdapterLST));
914
- vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_OFF).bind(vesuAdapterLST));
960
+ // add vesu leaves for default pool id
961
+ const vesuAdapterLST = addVesuLeaves(defaultPoolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter);
915
962
 
963
+ // add vesu leaves for alt supported pool ids
964
+ altSupportedPoolIds.map(poolId => addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter));
965
+
916
966
  // approve lst once to avnu
917
967
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, AVNU_EXCHANGE, LST_MULTIPLIER_MANAGE_IDS.AVNU_MULTIPLY_APPROVE_WITHDRAW).bind(commonAdapter));
918
968
  for (let borrowableAsset of vaultSettings.borrowable_assets) {
@@ -931,14 +981,16 @@ function getLooperSettings(
931
981
  collateral: lstToken,
932
982
  debt: debtAsset,
933
983
  vaultAllocator: vaultSettings.vaultAllocator,
934
- id: getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, debtAsset.symbol)
984
+ id: getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, debtAsset.symbol, pool1.toString())
935
985
  });
986
+ const { isV2, addr:poolAddr } = getVesuSingletonAddress(pool1);
936
987
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, UNIVERSAL_MANAGE_IDS.APPROVE_TOKEN1).bind(commonAdapter));
937
988
  vaultSettings.leafAdapters.push(vesuAdapter.getModifyPosition.bind(vesuAdapter));
938
989
 
939
990
  // Vesu multiply
940
- const multiplID = getVesuLegId(LST_MULTIPLIER_MANAGE_IDS.MULTIPLY_VESU, debtAsset.symbol);
941
- vaultSettings.leafAdapters.push(vesuAdapter.getMultiplyAdapter(multiplID).bind(vesuAdapter));
991
+ if (borrowableAsset.address.eq(underlyingToken.address)) {
992
+ continue; // already added in addVesuLeaves
993
+ }
942
994
  }
943
995
 
944
996
 
@@ -1033,6 +1085,8 @@ const hyperxSTRK: HyperLSTStrategySettings = {
1033
1085
  minHealthFactor: 1.05,
1034
1086
  borrowable_assets: Global.getDefaultTokens().filter(token => token.symbol === 'STRK'),
1035
1087
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'STRK')!,
1088
+ defaultPoolId: VesuPools.Re7xSTRK,
1089
+ altSupportedPoolIds: [VesuPools.Prime],
1036
1090
  }
1037
1091
 
1038
1092
  const hyperxWBTC: HyperLSTStrategySettings = {
@@ -1047,6 +1101,8 @@ const hyperxWBTC: HyperLSTStrategySettings = {
1047
1101
  minHealthFactor: 1.05,
1048
1102
  borrowable_assets: borrowableAssets.map(asset => Global.getDefaultTokens().find(token => token.symbol === asset)!),
1049
1103
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'WBTC')!,
1104
+ defaultPoolId: VesuPools.Re7xBTC,
1105
+ altSupportedPoolIds: [],
1050
1106
  }
1051
1107
 
1052
1108
  const hyperxtBTC: HyperLSTStrategySettings = {
@@ -1061,6 +1117,8 @@ const hyperxtBTC: HyperLSTStrategySettings = {
1061
1117
  minHealthFactor: 1.05,
1062
1118
  borrowable_assets: Global.getDefaultTokens().filter(token => token.symbol === 'tBTC' || token.symbol === 'WBTC'),
1063
1119
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'tBTC')!,
1120
+ defaultPoolId: VesuPools.Re7xBTC,
1121
+ altSupportedPoolIds: [],
1064
1122
  }
1065
1123
 
1066
1124
  const hyperxsBTC: HyperLSTStrategySettings = {
@@ -1075,6 +1133,8 @@ const hyperxsBTC: HyperLSTStrategySettings = {
1075
1133
  minHealthFactor: 1.05,
1076
1134
  borrowable_assets: Global.getDefaultTokens().filter(token => token.symbol === 'solvBTC'),
1077
1135
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'solvBTC')!,
1136
+ defaultPoolId: VesuPools.Re7xBTC,
1137
+ altSupportedPoolIds: [],
1078
1138
  }
1079
1139
 
1080
1140
  const hyperxLBTC: HyperLSTStrategySettings = {
@@ -1089,6 +1149,8 @@ const hyperxLBTC: HyperLSTStrategySettings = {
1089
1149
  minHealthFactor: 1.05,
1090
1150
  borrowable_assets: Global.getDefaultTokens().filter(token => token.symbol === 'LBTC'),
1091
1151
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'LBTC')!,
1152
+ defaultPoolId: VesuPools.Re7xBTC,
1153
+ altSupportedPoolIds: [],
1092
1154
  }
1093
1155
 
1094
1156
  function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string) {
@@ -1109,7 +1171,7 @@ function getStrategySettings(lstSymbol: string, underlyingSymbol: string, addres
1109
1171
  launchBlock: 0,
1110
1172
  type: 'Other',
1111
1173
  depositTokens: [Global.getDefaultTokens().find(token => token.symbol === lstSymbol)!],
1112
- additionalInfo: getLooperSettings(lstSymbol, underlyingSymbol, addresses, lstSymbol === 'xSTRK' ? VesuPools.Re7xSTRK : VesuPools.Re7xBTC),
1174
+ additionalInfo: getLooperSettings(lstSymbol, underlyingSymbol, addresses, addresses.defaultPoolId, lstSymbol === 'xSTRK' ? [VesuPools.Prime] : []),
1113
1175
  risk: {
1114
1176
  riskFactor: _riskFactor,
1115
1177
  netRisk: