From 0670d80bcbac120ca378ecfa6d2f2a5a48cbb7f8 Mon Sep 17 00:00:00 2001 From: peroxy Date: Fri, 22 Dec 2023 16:39:12 +0100 Subject: [PATCH] Add resampled obligation entities --- .../hubble-db/src/models/KLendObligationStateEntity.ts | 9 +++++++++ packages/hubble-db/src/models/index.ts | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/hubble-db/src/models/KLendObligationStateEntity.ts b/packages/hubble-db/src/models/KLendObligationStateEntity.ts index 41f8cd57..187dfb1d 100644 --- a/packages/hubble-db/src/models/KLendObligationStateEntity.ts +++ b/packages/hubble-db/src/models/KLendObligationStateEntity.ts @@ -6,4 +6,13 @@ export interface KlendObligationStateEntity { created_on: Date; } +export interface ResampledObligationStateEntity { + id: BigInt; + klend_obligation_id: number; + raw_json: string; + metrics: string; + created_on: Date; + resampled_on: Date; +} + export default KlendObligationStateEntity; diff --git a/packages/hubble-db/src/models/index.ts b/packages/hubble-db/src/models/index.ts index 96c3308d..90e287c7 100644 --- a/packages/hubble-db/src/models/index.ts +++ b/packages/hubble-db/src/models/index.ts @@ -98,4 +98,13 @@ export const FARM_STATE_TABLE = 'farm_state'; export const FARM_USER_TABLE = 'farm_user'; export const FARM_USER_STATE_TABLE = 'farm_user_state'; export const FARM_REWARD_TABLE = 'farm_reward_state'; +export type RESAMPLE_FREQUENCY = 'hour' | 'day'; +export const HOURLY_FREQUENCY = 'hour'; +export const DAILY_FREQUENCY = 'day'; +export const GET_OBLIGATION_STATE_RESAMPLED_TABLE = (frequency: RESAMPLE_FREQUENCY) => { + if (frequency !== HOURLY_FREQUENCY && frequency !== DAILY_FREQUENCY) { + throw Error(`Frequency ${frequency} not supported`); + } + return `klend_obligation_state_resampled_${frequency}`; +}; export const API_SCHEMA: string = 'api';