pickle-finance / pf-core

13 stars 9 forks source link

LQTY showing no real yield #222

Closed rawbdor closed 2 years ago

rawbdor commented 2 years ago

JAR_LQTY (or "LQTY" as the api key) is showing no real yield.

Function getOrLoadYearnDataFromDune is returning a nully errory response:

{"data":{"query_results":[{"id":"90b9cec0-c576-4f87-b5e3-770ceaa99e45","job_id":"b5401cf8-1032-44ff-a797-94e436a16feb","error":null,"runtime":0,"generated_at":"2021-06-23T11:26:22.93985+00:00","columns":["content"],"__typename":"query_results"}],"get_result_by_result_id":[{"data":{"content":"stored_in_snapshot"},"__typename":"get_result_template"}]}}

Request was as follows:

const DUNE_API = "https://core-hsr.duneanalytics.com/v1/graphql";
const body = {
  operationName: "FindResultDataByResult",
  query:
    "query FindResultDataByResult($result_id: uuid!) {\n  query_results(where: {id: {_eq: $result_id}}) {\n    id\n    job_id\n    error\n    runtime\n    generated_at\n    columns\n    __typename\n  }\n  get_result_by_result_id(args: {want_result_id: $result_id}) {\n    data\n    __typename\n  }\n}\n",
  variables: { result_id: "90b9cec0-c576-4f87-b5e3-770ceaa99e45" },
};

export async function fetchYearnDataFromDune(): Promise<any> {
  const data: any = await fetch(DUNE_API, {
    body: JSON.stringify(body),
    method: "POST",
    mode: "cors",
  }).then((x) => x.json());
  return data;
}

No idea how to fix this.

janklimo commented 2 years ago

@rawbdor do you have a link to the Dune dashboard we're fetching data from? For the landing page I do this in a 2 step process of fetching the current result id and then fetching data for that result id. I suspect the result id is stale here because it's hardcoded.

rawbdor commented 2 years ago
const DUNE_API = "https://core-hsr.duneanalytics.com/v1/graphql";
const body = {
  operationName: "FindResultDataByResult",
  query:
    "query FindResultDataByResult($result_id: uuid!) {\n  query_results(where: {id: {_eq: $result_id}}) {\n    id\n    job_id\n    error\n    runtime\n    generated_at\n    columns\n    __typename\n  }\n  get_result_by_result_id(args: {want_result_id: $result_id}) {\n    data\n    __typename\n  }\n}\n",
  variables: { result_id: "90b9cec0-c576-4f87-b5e3-770ceaa99e45" },
};

So yeah it looks like the result_id is hard-coded, but I have no idea what the query id was or where we get it from. Is there a way to find a query id from a stale result id?

rawbdor commented 2 years ago

Seems pbamm uses the same utility method... bad

rawbdor commented 2 years ago

Thanks for the help @janklimo