@strkfarm/sdk 1.1.61 → 1.1.63

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.
@@ -26,6 +26,7 @@ export class Pricer extends PricerBase {
26
26
  /**
27
27
  * TOKENA and TOKENB are the two token names to get price of TokenA in terms of TokenB
28
28
  */
29
+ // ! switch to USDC (new) later
29
30
  protected PRICE_API = `https://api.coinbase.com/v2/prices/{{PRICER_KEY}}/buy`;
30
31
  protected EKUBO_API = 'https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_ADDRESS}}/0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8'; // e.g. ETH/USDC
31
32
 
@@ -37,7 +37,7 @@ import { EkuboHarvests, HarvestInfo } from "@/modules/harvests";
37
37
  import { logger } from "@/utils/logger";
38
38
  import { COMMON_CONTRACTS } from "./constants";
39
39
  import { DepegRiskLevel, ImpermanentLossLevel, MarketRiskLevel, SmartContractRiskLevel } from "@/interfaces/risks";
40
- import { gql } from "@apollo/client";
40
+ import { from, gql } from "@apollo/client";
41
41
  import apolloClient from "@/modules/apollo-client";
42
42
  import { binarySearch } from "@/utils/math-utils";
43
43
  import { Quote } from "@avnu/avnu-sdk";
@@ -504,7 +504,8 @@ export class EkuboCLVault extends BaseStrategy<
504
504
  sinceBlocks = 600000,
505
505
  timeperiod: '24h' | '7d' | '30d' | '3m' = '24h' // temp thing for fee based APY
506
506
  ): Promise<number> {
507
- const isUSDCQouteToken = this.metadata.additionalInfo.quoteAsset.symbol === "USDC";
507
+ // ! switch to USDC later
508
+ const isUSDCQouteToken = this.metadata.additionalInfo.quoteAsset.symbol === "USDC.e";
508
509
  if (!isUSDCQouteToken) {
509
510
  // good for LSTs and stables
510
511
  return this.netSharesBasedTrueAPY(blockIdentifier, sinceBlocks);
@@ -1032,6 +1033,12 @@ export class EkuboCLVault extends BaseStrategy<
1032
1033
  amount1: availableAmount1.minus(y),
1033
1034
  ratio: 0,
1034
1035
  };
1036
+ } else if (ratio.eq(Infinity)) {
1037
+ return {
1038
+ amount0: availableAmount0,
1039
+ amount1: Web3Number.fromWei("0", availableAmount1.decimals),
1040
+ ratio: Infinity,
1041
+ };
1035
1042
  }
1036
1043
  return {
1037
1044
  amount0: availableAmount0.plus(x),
@@ -1198,6 +1205,7 @@ export class EkuboCLVault extends BaseStrategy<
1198
1205
  const tokenToSell = expectedAmounts.amount0.lessThan(token0Bal)
1199
1206
  ? poolKey.token0
1200
1207
  : poolKey.token1;
1208
+ logger.verbose(`getSwapParams => tokenToSell: ${tokenToSell.address}, expectedAmounts: ${expectedAmounts.amount0.toString()}, bal0: ${token0Bal.toString()}`);
1201
1209
  // The other token is the one to buy
1202
1210
  const tokenToBuy =
1203
1211
  tokenToSell == poolKey.token0 ? poolKey.token1 : poolKey.token0;
@@ -1432,6 +1440,7 @@ export class EkuboCLVault extends BaseStrategy<
1432
1440
  }
1433
1441
 
1434
1442
  const fromAmount = uint256.uint256ToBN(swapInfo.token_from_amount);
1443
+ const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
1435
1444
  logger.verbose(
1436
1445
  `Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
1437
1446
  );
@@ -1451,7 +1460,7 @@ export class EkuboCLVault extends BaseStrategy<
1451
1460
  );
1452
1461
 
1453
1462
  const newSwapInfo = { ...swapInfo };
1454
- const currentAmount = Web3Number.fromWei(fromAmount.toString(), 18); // 18 is ok, as its toWei eventually anyways
1463
+ const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
1455
1464
  logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
1456
1465
  if (
1457
1466
  err.message.includes("invalid token0 balance") ||
@@ -1537,6 +1546,11 @@ export class EkuboCLVault extends BaseStrategy<
1537
1546
  throw err;
1538
1547
  }
1539
1548
  newSwapInfo.token_to_min_amount = uint256.bnToUint256("0");
1549
+
1550
+ // if (uint256.uint256ToBN(newSwapInfo.token_from_amount) == fromAmount && sameErrorCount.error == 'loop-stuck') {
1551
+ // logger.error("Swap amount did not change, cannot proceed");
1552
+ // sameErrorCount = { count: MAX_SAME_ERROR_COUNT, error: null };
1553
+ // }
1540
1554
  return this.rebalanceIter(
1541
1555
  newSwapInfo,
1542
1556
  acc,
@@ -2289,7 +2303,7 @@ const lstStrategies: IStrategyMetadata<CLVaultStrategySettings>[] = [
2289
2303
 
2290
2304
  const ETHUSDCRe7Strategy: IStrategyMetadata<CLVaultStrategySettings> = {
2291
2305
  ...xSTRKSTRK,
2292
- name: "Ekubo ETH/USDC",
2306
+ name: "Ekubo ETH/USDC.e",
2293
2307
  description: <></>,
2294
2308
  address: ContractAddr.from(
2295
2309
  "0x160d8fa4569ef6a12e6bf47cb943d7b5ebba8a41a69a14c1d943050ba5ff947"
@@ -2298,7 +2312,7 @@ const ETHUSDCRe7Strategy: IStrategyMetadata<CLVaultStrategySettings> = {
2298
2312
  // must be same order as poolKey token0 and token1
2299
2313
  depositTokens: [
2300
2314
  Global.getDefaultTokens().find((t) => t.symbol === "ETH")!,
2301
- Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
2315
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC.e")!
2302
2316
  ],
2303
2317
  apyMethodology:
2304
2318
  "Annualized fee APY, calculated as fees earned in the last 7d divided by TVL",
@@ -2312,7 +2326,7 @@ const ETHUSDCRe7Strategy: IStrategyMetadata<CLVaultStrategySettings> = {
2312
2326
  minWaitHours: 6,
2313
2327
  direction: "any"
2314
2328
  },
2315
- quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
2329
+ quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "USDC.e")!,
2316
2330
  },
2317
2331
  faqs: [
2318
2332
  ...faqs,
@@ -2336,7 +2350,7 @@ const RE7Strategies: IStrategyMetadata<CLVaultStrategySettings>[] = [
2336
2350
  ETHUSDCRe7Strategy,
2337
2351
  {
2338
2352
  ...ETHUSDCRe7Strategy,
2339
- name: "Ekubo USDC/USDT",
2353
+ name: "Ekubo USDC.e/USDT",
2340
2354
  description: <></>,
2341
2355
  address: ContractAddr.from(
2342
2356
  "0x3a4f8debaf12af97bb911099bc011d63d6c208d4c5ba8e15d7f437785b0aaa2"
@@ -2344,7 +2358,7 @@ const RE7Strategies: IStrategyMetadata<CLVaultStrategySettings>[] = [
2344
2358
  launchBlock: 1506139,
2345
2359
  // must be same order as poolKey token0 and token1
2346
2360
  depositTokens: [
2347
- Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
2361
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC.e")!,
2348
2362
  Global.getDefaultTokens().find((t) => t.symbol === "USDT")!
2349
2363
  ],
2350
2364
  risk: {
@@ -2357,7 +2371,7 @@ const RE7Strategies: IStrategyMetadata<CLVaultStrategySettings>[] = [
2357
2371
  },
2358
2372
  {
2359
2373
  ...ETHUSDCRe7Strategy,
2360
- name: "Ekubo STRK/USDC",
2374
+ name: "Ekubo STRK/USDC.e",
2361
2375
  description: <></>,
2362
2376
  address: ContractAddr.from(
2363
2377
  "0x351b36d0d9d8b40010658825adeeddb1397436cd41acd0ff6c6e23aaa8b5b30"
@@ -2366,7 +2380,7 @@ const RE7Strategies: IStrategyMetadata<CLVaultStrategySettings>[] = [
2366
2380
  // must be same order as poolKey token0 and token1
2367
2381
  depositTokens: [
2368
2382
  Global.getDefaultTokens().find((t) => t.symbol === "STRK")!,
2369
- Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
2383
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC.e")!
2370
2384
  ],
2371
2385
  risk: highRisk,
2372
2386
  },
@@ -2387,7 +2401,7 @@ const RE7Strategies: IStrategyMetadata<CLVaultStrategySettings>[] = [
2387
2401
  },
2388
2402
  {
2389
2403
  ...ETHUSDCRe7Strategy,
2390
- name: "Ekubo WBTC/USDC",
2404
+ name: "Ekubo WBTC/USDC.e",
2391
2405
  description: <></>,
2392
2406
  address: ContractAddr.from(
2393
2407
  "0x2bcaef2eb7706875a5fdc6853dd961a0590f850bc3a031c59887189b5e84ba1"
@@ -2396,13 +2410,13 @@ const RE7Strategies: IStrategyMetadata<CLVaultStrategySettings>[] = [
2396
2410
  // must be same order as poolKey token0 and token1
2397
2411
  depositTokens: [
2398
2412
  Global.getDefaultTokens().find((t) => t.symbol === "WBTC")!,
2399
- Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
2413
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC.e")!
2400
2414
  ],
2401
2415
  risk: mediumRisk,
2402
2416
  },
2403
2417
  {
2404
2418
  ...ETHUSDCRe7Strategy,
2405
- name: "Ekubo tBTC/USDC",
2419
+ name: "Ekubo tBTC/USDC.e",
2406
2420
  description: <></>,
2407
2421
  address: ContractAddr.from(
2408
2422
  "0x4aad891a2d4432fba06b6558631bb13f6bbd7f6f33ab8c3111e344889ea4456"
@@ -2411,7 +2425,7 @@ const RE7Strategies: IStrategyMetadata<CLVaultStrategySettings>[] = [
2411
2425
  // must be same order as poolKey token0 and token1
2412
2426
  depositTokens: [
2413
2427
  Global.getDefaultTokens().find((t) => t.symbol === "tBTC")!,
2414
- Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
2428
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC.e")!
2415
2429
  ],
2416
2430
  risk: mediumRisk,
2417
2431
  },
@@ -1143,13 +1143,13 @@ const AUDIT_URL = 'https://docs.troves.fi/p/security#starknet-vault-kit'
1143
1143
  export const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[] =
1144
1144
  [
1145
1145
  {
1146
- name: "USDC Evergreen",
1147
- description: getDescription('USDC', ['vesu', 'extended']),
1146
+ name: "USDC.e Evergreen",
1147
+ description: getDescription('USDC.e', ['vesu', 'extended']),
1148
1148
  address: ContractAddr.from('0x7e6498cf6a1bfc7e6fc89f1831865e2dacb9756def4ec4b031a9138788a3b5e'),
1149
1149
  launchBlock: 0,
1150
1150
  type: 'ERC4626',
1151
- depositTokens: [Global.getDefaultTokens().find(token => token.symbol === 'USDC')!],
1152
- additionalInfo: getLooperSettings('USDC', 'ETH', usdcVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
1151
+ depositTokens: [Global.getDefaultTokens().find(token => token.symbol === 'USDC.e')!],
1152
+ additionalInfo: getLooperSettings('USDC.e', 'ETH', usdcVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
1153
1153
  risk: {
1154
1154
  riskFactor: _riskFactor,
1155
1155
  netRisk:
@@ -1014,8 +1014,8 @@ export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[]
1014
1014
  investmentSteps: []
1015
1015
  },
1016
1016
  {
1017
- name: "Vesu Fusion USDC",
1018
- description: _description.replace("{{TOKEN}}", "USDC"),
1017
+ name: "Vesu Fusion USDC.e",
1018
+ description: _description.replace("{{TOKEN}}", "USDC.e"),
1019
1019
  address: ContractAddr.from(
1020
1020
  "0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"
1021
1021
  ),
@@ -1023,7 +1023,7 @@ export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[]
1023
1023
  type: "ERC4626",
1024
1024
  auditUrl: AUDIT_URL,
1025
1025
  depositTokens: [
1026
- Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
1026
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC.e")!
1027
1027
  ],
1028
1028
  protocols: [_protocol],
1029
1029
  maxTVL: Web3Number.fromWei("0", 6),