@merkl/api 0.12.3 → 0.12.4

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.
@@ -1,4 +1,7 @@
1
+ import { Redis } from "../cache";
1
2
  import { redisClient } from "../cache/redis";
3
+ import { getEulerV2Vaults } from "../libs/campaigns/utils/getEulerV2Vaults";
4
+ import { getUniswapV4Pools } from "../libs/campaigns/utils/getUniswapV4Pools";
2
5
  import { DungeonKeeperController } from "../modules/v4/dungeonKeeper";
3
6
  import { log } from "../utils/logger";
4
7
  import { engineDbClient } from "../utils/prisma";
@@ -25,6 +28,12 @@ new Elysia({
25
28
  .use(priceUpdater) // /v3/updatePrices
26
29
  .use(healthCheck) // /v3/health
27
30
  .use(sync) // GET /jobs/api/sync-with-engine
31
+ .get("/eulerUpdate", async () => {
32
+ await Redis.safeSet("EulerV2Vaults", getEulerV2Vaults);
33
+ })
34
+ .get("/uniswapv4Update", async () => {
35
+ await Redis.safeSet("UniswapV4Pools", getUniswapV4Pools);
36
+ })
28
37
  .group("/v4", app => {
29
38
  return app.use(DungeonKeeperController);
30
39
  })
@@ -32,7 +32,7 @@ export declare const CacheDeclaration: {
32
32
  };
33
33
  EulerV2Vaults: {
34
34
  compressed: false;
35
- redisTTL: TTLType.Minutes30;
35
+ redisTTL: TTLType.Hours3;
36
36
  localCache: false;
37
37
  };
38
38
  CompoundV2ForksVaults: {
@@ -20,7 +20,7 @@ export const CacheDeclaration = {
20
20
  },
21
21
  EulerV2Vaults: {
22
22
  compressed: false,
23
- redisTTL: TTLType.Minutes30,
23
+ redisTTL: TTLType.Hours3,
24
24
  localCache: false,
25
25
  },
26
26
  CompoundV2ForksVaults: {
@@ -18,4 +18,5 @@ export type EulerVaultType = {
18
18
  symbolUnderlying: string;
19
19
  }[];
20
20
  };
21
+ export declare function getEulerV2Vaults(): Promise<EulerVaultType[]>;
21
22
  export declare const getEulerV2VaultsWithCache: () => Promise<EulerVaultType[]>;
@@ -12,7 +12,7 @@ export var LoggedEntityType;
12
12
  LoggedEntityType["EULER"] = "EULER_VAULT";
13
13
  LoggedEntityType["UNISWAP_V4"] = "UNISWAP_V4";
14
14
  })(LoggedEntityType || (LoggedEntityType = {}));
15
- async function getEulerV2Vaults() {
15
+ export async function getEulerV2Vaults() {
16
16
  let vaults = [];
17
17
  // 0_ Fetch all euler vaults from database
18
18
  const storedVaults = await apiDbClient.logged.findMany({
@@ -4,4 +4,5 @@ export type UniswapV4PoolsReturnType = {
4
4
  [poolId: string]: UniswapV4PoolType;
5
5
  };
6
6
  };
7
+ export declare function getUniswapV4Pools(): Promise<UniswapV4PoolsReturnType>;
7
8
  export declare const getUniswapV4PoolsWithCache: () => Promise<UniswapV4PoolsReturnType>;
@@ -2,11 +2,11 @@ import { Redis } from "../../../cache";
2
2
  import { log } from "../../../utils/logger";
3
3
  import { apiDbClient } from "../../../utils/prisma";
4
4
  import { providers } from "../../../utils/providers";
5
- import { ChainInteractionService, ERC20Interface, NETWORK_LABELS, NULL_ADDRESS, PoolManagerInterface, UniswapV4Addresses, getContractCreationBlock, } from "@sdk";
5
+ import { ChainInteractionService, ERC20Interface, NETWORK_LABELS, NULL_ADDRESS, UniswapV4Addresses, UniswapV4PoolManagerInterface, getContractCreationBlock, } from "@sdk";
6
6
  import { safeFetchLogs } from "./fetchLogs";
7
7
  import { LoggedEntityType } from "./getEulerV2Vaults";
8
8
  const UNIV4_CHAINIDS = Object.keys(UniswapV4Addresses).map((x) => Number(x));
9
- async function getUniswapV4Pools() {
9
+ export async function getUniswapV4Pools() {
10
10
  const pools = {};
11
11
  // 0_ Fetch all euler vaults from database
12
12
  const storedPools = await apiDbClient.logged.findMany({
@@ -30,9 +30,9 @@ async function getUniswapV4Pools() {
30
30
  }
31
31
  const toBlock = await jsonRPCprovider.getBlockNumber();
32
32
  const logs = await safeFetchLogs(chainId, // TODO: rm type enforcing
33
- [PoolManagerInterface.getEventTopic("Initialize")], [poolManagerAddress], fromBlock, toBlock);
33
+ [UniswapV4PoolManagerInterface.getEventTopic("Initialize")], [poolManagerAddress], fromBlock, toBlock);
34
34
  const decodedPools = await Promise.all(logs.map(async (log) => {
35
- const [id, currency0, currency1, fee, tickSpacing, hooks] = PoolManagerInterface.decodeEventLog("Initialize", log.data, log.topics);
35
+ const [id, currency0, currency1, fee, tickSpacing, hooks] = UniswapV4PoolManagerInterface.decodeEventLog("Initialize", log.data, log.topics);
36
36
  // Respect typing
37
37
  return {
38
38
  poolId: id,
@@ -5,5 +5,5 @@ export default (app) => app.get("/euler", async () => {
5
5
  return await getEulerV2VaultsWithCache();
6
6
  }, {
7
7
  query: t.Object({}),
8
- tags: ["Protocols"],
8
+ tags: ["euler"],
9
9
  });