@strkfarm/sdk 2.0.0-staging.15 → 2.0.0-staging.18

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.
@@ -15,10 +15,9 @@ import { HealthFactorMath } from "@/utils/health-factor-math";
15
15
  import { findMaxInputWithSlippage } from "@/utils/math-utils";
16
16
 
17
17
  export interface HyperLSTStrategySettings extends UniversalStrategySettings {
18
- borrowable_assets: TokenInfo[];
18
+ borrowable_assets: { token: TokenInfo, poolId: ContractAddr }[];
19
19
  underlyingToken: TokenInfo;
20
20
  defaultPoolId: ContractAddr;
21
- altSupportedPoolIds: ContractAddr[];
22
21
  }
23
22
 
24
23
  export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTStrategySettings> {
@@ -58,20 +57,20 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
58
57
  // todo support lending assets of underlying as well (like if xSTRK looping is not viable, simply supply STRK)
59
58
  getVesuAdapters() {
60
59
  const adapters: VesuAdapter[] = [];
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
- }
60
+ for (const borrowableInfo of this.metadata.additionalInfo.borrowable_assets) {
61
+ // do not add adapter if the pool id does not match
62
+ const asset = borrowableInfo.token;
63
+ const poolId = borrowableInfo.poolId;
64
+ const vesuAdapter1 = new VesuAdapter({
65
+ poolId: 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);
75
74
  }
76
75
  return adapters;
77
76
  }
@@ -907,7 +906,7 @@ function addVesuLeaves(
907
906
  }]);
908
907
 
909
908
  // avnu multiply
910
- const { isV2, addr: _ } = getVesuSingletonAddress(poolId);
909
+ const { isV2, addr: poolAddr } = getVesuSingletonAddress(poolId);
911
910
 
912
911
  // vesu multiply looping
913
912
  const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
@@ -924,6 +923,10 @@ function addVesuLeaves(
924
923
  const multiplID = getVesuLegId(LST_MULTIPLIER_MANAGE_IDS.MULTIPLY_VESU, underlyingToken.symbol, poolId.toString());
925
924
  vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
926
925
 
926
+ // direct modify position stuff
927
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, UNIVERSAL_MANAGE_IDS.APPROVE_TOKEN1).bind(commonAdapter));
928
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
929
+
927
930
  return vesuAdapterLST;
928
931
  }
929
932
 
@@ -931,8 +934,7 @@ function getLooperSettings(
931
934
  lstSymbol: string,
932
935
  underlyingSymbol: string,
933
936
  vaultSettings: HyperLSTStrategySettings,
934
- defaultPoolId: ContractAddr,
935
- altSupportedPoolIds: ContractAddr[] = []
937
+ defaultPoolId: ContractAddr
936
938
  ) {
937
939
  vaultSettings.leafAdapters = [];
938
940
  const pool1 = vaultSettings.defaultPoolId;
@@ -957,15 +959,15 @@ function getLooperSettings(
957
959
  adapter: commonAdapter
958
960
  }]);
959
961
 
960
- // add vesu leaves for default pool id
961
- const vesuAdapterLST = addVesuLeaves(defaultPoolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter);
962
-
963
- // add vesu leaves for alt supported pool ids
964
- altSupportedPoolIds.map(poolId => addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter));
962
+ // add vesu leaves for all supported pool ids
963
+ vaultSettings.borrowable_assets.map(borrowableAsset => addVesuLeaves(borrowableAsset.poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter));
965
964
 
966
965
  // approve lst once to avnu
967
966
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, AVNU_EXCHANGE, LST_MULTIPLIER_MANAGE_IDS.AVNU_MULTIPLY_APPROVE_WITHDRAW).bind(commonAdapter));
968
- for (let borrowableAsset of vaultSettings.borrowable_assets) {
967
+
968
+ const uniqueBorrowableAssets = [...new Set(vaultSettings.borrowable_assets.map(borrowableAsset => borrowableAsset.token.symbol))];
969
+ for (let borrowableAssetSymbol of uniqueBorrowableAssets) {
970
+ const borrowableAsset = Global.getDefaultTokens().find(token => token.symbol === borrowableAssetSymbol)!;
969
971
  // in-efficient avnu swap looping (but good with endur integration)
970
972
  const debtAsset = borrowableAsset;
971
973
  const approve_debt_token_id = getAvnuManageIDs(LST_MULTIPLIER_MANAGE_IDS.AVNU_MULTIPLY_APPROVE_DEPOSIT, debtAsset.symbol);
@@ -974,23 +976,6 @@ function getLooperSettings(
974
976
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(debtAsset.address, AVNU_EXCHANGE, approve_debt_token_id).bind(commonAdapter));
975
977
  vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(debtAsset.address, lstToken.address, swap_debt_token_id, false).bind(commonAdapter));
976
978
  vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(lstToken.address, debtAsset.address, swap_lst_token_id, false).bind(commonAdapter));
977
-
978
- // approve LST to add collateral
979
- const vesuAdapter = new VesuAdapter({
980
- poolId: pool1,
981
- collateral: lstToken,
982
- debt: debtAsset,
983
- vaultAllocator: vaultSettings.vaultAllocator,
984
- id: getVesuLegId(UNIVERSAL_MANAGE_IDS.VESU_LEG1, debtAsset.symbol, pool1.toString())
985
- });
986
- const { isV2, addr:poolAddr } = getVesuSingletonAddress(pool1);
987
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, UNIVERSAL_MANAGE_IDS.APPROVE_TOKEN1).bind(commonAdapter));
988
- vaultSettings.leafAdapters.push(vesuAdapter.getModifyPosition.bind(vesuAdapter));
989
-
990
- // Vesu multiply
991
- if (borrowableAsset.address.eq(underlyingToken.address)) {
992
- continue; // already added in addVesuLeaves
993
- }
994
979
  }
995
980
 
996
981
 
@@ -998,8 +983,8 @@ function getLooperSettings(
998
983
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, UNIVERSAL_MANAGE_IDS.APPROVE_BRING_LIQUIDITY).bind(commonAdapter));
999
984
  vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter(UNIVERSAL_MANAGE_IDS.BRING_LIQUIDITY).bind(commonAdapter));
1000
985
 
1001
- // claim rewards
1002
- vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter(UNIVERSAL_MANAGE_IDS.DEFISPRING_REWARDS).bind(vesuAdapterLST));
986
+ // claim rewards (defi spring ended)
987
+ // vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter(UNIVERSAL_MANAGE_IDS.DEFISPRING_REWARDS).bind(vesuAdapterLST));
1003
988
 
1004
989
  // avnu swap for claims rewards
1005
990
  const STRKToken = Global.getDefaultTokens().find(token => token.symbol === 'STRK')!;
@@ -1069,7 +1054,7 @@ const _riskFactor: RiskFactor[] = [
1069
1054
  {type: RiskType.DEPEG_RISK, value: DepegRiskLevel.GENERALLY_STABLE, weight: 25, reason: "Generally stable pegged assets" },
1070
1055
  ];
1071
1056
 
1072
- const borrowableAssets = [
1057
+ const btcBorrowableAssets = [
1073
1058
  'WBTC', 'tBTC', 'LBTC', 'solvBTC'
1074
1059
  ]
1075
1060
 
@@ -1083,10 +1068,12 @@ const hyperxSTRK: HyperLSTStrategySettings = {
1083
1068
  adapters: [],
1084
1069
  targetHealthFactor: 1.1,
1085
1070
  minHealthFactor: 1.05,
1086
- borrowable_assets: Global.getDefaultTokens().filter(token => token.symbol === 'STRK'),
1071
+ borrowable_assets: [
1072
+ ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
1073
+ ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Prime })),
1074
+ ],
1087
1075
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'STRK')!,
1088
1076
  defaultPoolId: VesuPools.Re7xSTRK,
1089
- altSupportedPoolIds: [VesuPools.Prime],
1090
1077
  }
1091
1078
 
1092
1079
  const hyperxWBTC: HyperLSTStrategySettings = {
@@ -1099,10 +1086,14 @@ const hyperxWBTC: HyperLSTStrategySettings = {
1099
1086
  adapters: [],
1100
1087
  targetHealthFactor: 1.1,
1101
1088
  minHealthFactor: 1.05,
1102
- borrowable_assets: borrowableAssets.map(asset => Global.getDefaultTokens().find(token => token.symbol === asset)!),
1089
+ borrowable_assets: [
1090
+ // allow all BTC flavours borrowing on Re7xBTC pool
1091
+ ...btcBorrowableAssets.map(asset => Global.getDefaultTokens().find(token => token.symbol === asset)!).map(token => ({ token, poolId: VesuPools.Re7xBTC })),
1092
+ // allow only WBTC borrowing on Prime pool
1093
+ ...Global.getDefaultTokens().filter(token => token.symbol === 'WBTC').map(token => ({ token, poolId: VesuPools.Prime })),
1094
+ ],
1103
1095
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'WBTC')!,
1104
1096
  defaultPoolId: VesuPools.Re7xBTC,
1105
- altSupportedPoolIds: [VesuPools.Prime],
1106
1097
  redemptionRouter: ContractAddr.from('0x6ea649f402898f69baf775c1afdd08522c071c640b9c4460192070ec2b96417')
1107
1098
  }
1108
1099
 
@@ -1116,10 +1107,11 @@ const hyperxtBTC: HyperLSTStrategySettings = {
1116
1107
  adapters: [],
1117
1108
  targetHealthFactor: 1.1,
1118
1109
  minHealthFactor: 1.05,
1119
- borrowable_assets: Global.getDefaultTokens().filter(token => token.symbol === 'tBTC' || token.symbol === 'WBTC'),
1110
+ borrowable_assets: [
1111
+ ...Global.getDefaultTokens().filter(token => token.symbol === 'tBTC' || token.symbol === 'WBTC').map(token => ({ token, poolId: VesuPools.Re7xBTC })),
1112
+ ],
1120
1113
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'tBTC')!,
1121
1114
  defaultPoolId: VesuPools.Re7xBTC,
1122
- altSupportedPoolIds: [],
1123
1115
  redemptionRouter: ContractAddr.from('0x3de9c409d1e357e25778fb7a3e2e2393666956846a5c2caa607296fa8e76b5d')
1124
1116
  }
1125
1117
 
@@ -1133,10 +1125,11 @@ const hyperxsBTC: HyperLSTStrategySettings = {
1133
1125
  adapters: [],
1134
1126
  targetHealthFactor: 1.1,
1135
1127
  minHealthFactor: 1.05,
1136
- borrowable_assets: Global.getDefaultTokens().filter(token => token.symbol === 'solvBTC'),
1128
+ borrowable_assets: [
1129
+ ...Global.getDefaultTokens().filter(token => token.symbol === 'solvBTC').map(token => ({ token, poolId: VesuPools.Re7xBTC })),
1130
+ ],
1137
1131
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'solvBTC')!,
1138
1132
  defaultPoolId: VesuPools.Re7xBTC,
1139
- altSupportedPoolIds: [],
1140
1133
  }
1141
1134
 
1142
1135
  const hyperxLBTC: HyperLSTStrategySettings = {
@@ -1149,10 +1142,11 @@ const hyperxLBTC: HyperLSTStrategySettings = {
1149
1142
  adapters: [],
1150
1143
  targetHealthFactor: 1.1,
1151
1144
  minHealthFactor: 1.05,
1152
- borrowable_assets: Global.getDefaultTokens().filter(token => token.symbol === 'LBTC'),
1145
+ borrowable_assets: [
1146
+ ...Global.getDefaultTokens().filter(token => token.symbol === 'LBTC').map(token => ({ token, poolId: VesuPools.Re7xBTC })),
1147
+ ],
1153
1148
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'LBTC')!,
1154
1149
  defaultPoolId: VesuPools.Re7xBTC,
1155
- altSupportedPoolIds: [],
1156
1150
  }
1157
1151
 
1158
1152
  function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string) {
@@ -1249,7 +1243,7 @@ const HYPER_LST_SECURITY = {
1249
1243
  const HYPER_LST_REDEMPTION_INFO: RedemptionInfo = {
1250
1244
  instantWithdrawalVault: InstantWithdrawalVault.NO,
1251
1245
  redemptionsInfo: [{
1252
- title: "Usual time",
1246
+ title: "Typical Duration",
1253
1247
  description: "1-2 hours"
1254
1248
  }],
1255
1249
  alerts: [{
@@ -1262,14 +1256,14 @@ const HYPER_LST_REDEMPTION_INFO: RedemptionInfo = {
1262
1256
  function getStrategySettings(
1263
1257
  lstSymbol: string,
1264
1258
  underlyingSymbol: string,
1265
- addresses: HyperLSTStrategySettings,
1259
+ settings: HyperLSTStrategySettings,
1266
1260
  isPreview: boolean = false
1267
1261
  ): IStrategyMetadata<HyperLSTStrategySettings> {
1268
1262
  return {
1269
1263
  id: `hyper_${lstSymbol.toLowerCase()}`,
1270
1264
  name: `Hyper ${lstSymbol}`,
1271
1265
  description: getDescription(lstSymbol, underlyingSymbol),
1272
- address: addresses.vaultAddress,
1266
+ address: settings.vaultAddress,
1273
1267
  launchBlock: 0,
1274
1268
  type: "Other",
1275
1269
  vaultType: {
@@ -1284,8 +1278,8 @@ function getStrategySettings(
1284
1278
  additionalInfo: getLooperSettings(
1285
1279
  lstSymbol,
1286
1280
  underlyingSymbol,
1287
- addresses,
1288
- lstSymbol === "xSTRK" ? VesuPools.Re7xSTRK : VesuPools.Re7xBTC
1281
+ settings,
1282
+ lstSymbol === "xSTRK" ? VesuPools.Re7xSTRK : VesuPools.Re7xBTC,
1289
1283
  ),
1290
1284
  risk: {
1291
1285
  riskFactor: _riskFactor,
@@ -1303,7 +1297,7 @@ function getStrategySettings(
1303
1297
  logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
1304
1298
  },
1305
1299
  settings: createHyperLSTSettings(lstSymbol, underlyingSymbol),
1306
- contractDetails: getContractDetails(addresses),
1300
+ contractDetails: getContractDetails(settings),
1307
1301
  faqs: getFAQs(lstSymbol, underlyingSymbol),
1308
1302
  investmentSteps: getInvestmentSteps(lstSymbol, underlyingSymbol),
1309
1303
  isPreview: isPreview,
@@ -1312,6 +1306,8 @@ function getStrategySettings(
1312
1306
  tags: lstSymbol.includes('BTC') ? [StrategyTag.BTC, StrategyTag.LEVERED] : [StrategyTag.LEVERED],
1313
1307
  security: HYPER_LST_SECURITY,
1314
1308
  redemptionInfo: HYPER_LST_REDEMPTION_INFO,
1309
+ usualTimeToEarnings: "2 weeks",
1310
+ usualTimeToEarningsDescription: "Strategy returns depend on LST price on DEXes. Even though the true price of LST on Endur increases continuously, the DEX price may lag sometimes, and historically is seen to rebase at least once every 2 hours. This is when you realise your earnings.",
1315
1311
  points: [{
1316
1312
  multiplier: 4,
1317
1313
  logo: 'https://endur.fi/favicon.ico',
@@ -1288,7 +1288,7 @@ const EVERGREEN_SECURITY = {
1288
1288
  const EVERGREEN_REDEMPTION_INFO: RedemptionInfo = {
1289
1289
  instantWithdrawalVault: InstantWithdrawalVault.NO,
1290
1290
  redemptionsInfo: [{
1291
- title: "Usual time",
1291
+ title: "Typical Duration",
1292
1292
  description: "1-2 hours"
1293
1293
  }],
1294
1294
  alerts: [{
@@ -1342,7 +1342,9 @@ const createUniversalStrategy = (params: {
1342
1342
  investmentSteps: investmentSteps,
1343
1343
  tags: params.tags,
1344
1344
  security: EVERGREEN_SECURITY,
1345
- redemptionInfo: EVERGREEN_REDEMPTION_INFO
1345
+ redemptionInfo: EVERGREEN_REDEMPTION_INFO,
1346
+ usualTimeToEarnings: null,
1347
+ usualTimeToEarningsDescription: null,
1346
1348
  });
1347
1349
 
1348
1350
  export const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[] =
@@ -1078,6 +1078,8 @@ const createVesuRebalanceStrategy = (
1078
1078
  tags: [],
1079
1079
  security: VESU_SECURITY,
1080
1080
  redemptionInfo: VESU_REDEMPTION_INFO,
1081
+ usualTimeToEarnings: null,
1082
+ usualTimeToEarningsDescription: null,
1081
1083
  });
1082
1084
 
1083
1085
  // Shared security & redemption metadata for all Vesu strategies