Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Aggregated Data to ETL API for Earn APY #4

Open
kostovster opened this issue Jun 11, 2024 · 0 comments
Open

Add Aggregated Data to ETL API for Earn APY #4

kostovster opened this issue Jun 11, 2024 · 0 comments
Assignees

Comments

@kostovster
Copy link
Member

SELECT
    DATE("LS_timestamp") AS "date",
    MAX("LS_interest") AS "max_interest"
  FROM
    "LS_Opening"
  WHERE
    "LS_timestamp" >= CURRENT_DATE - INTERVAL '7 days'
    AND "LS_loan_pool_id" = <<<LPP address>>>
  GROUP BY
    "date";

Горното куери е част от калкулацията за earn apy на дадено lpp. Бихме искали да го изкараме в ETL API под формата на ендпойнт:

/max_ls_interest_7d/{lpp_address}

с примерен response:

{
  "01.01.1970": 131, //date:max_interest
  "01.02.1970": 122,
  …
}
SELECT
    DATE("LP_Pool_timestamp") AS "date",
    MAX(
      "LP_Pool_total_borrowed_stable" / "LP_Pool_total_value_locked_stable"
    ) AS "ratio"
  FROM
    "LP_Pool_State"
  WHERE
    "LP_Pool_timestamp" >= CURRENT_DATE - INTERVAL '7 days'
    AND "LP_Pool_id" = <<<LPP address>>>
  GROUP BY
    "date";

Горното куери също в отделен ендпойнт:
/max_lp_ratio/{lpp_address}
с примерен response:

{
  "01.01.1970": 0.124, //Date: utilization_ratio
  "01.02.1970": 0.444,
  …
}

В допълнение може да добавим една колона към LS_State таблицата, която да съдържа бройката токени от позицията.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants