Anchor-Protocol / anchor-web-app

A monorepo containing everything user-facing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Historical Earn APY displayed incorrectly

davordavidovic opened this issue · comments

Problem
The historical APY in the Earn interest section shows today's date (eg: Sep 12, 2021) on all slider values. Looking at the network tab I can see these values fetched from the https://mantle.anchorprotocol.com/?earn--apy-history endpoint.

{
    "apyHistory": [
        {
            "DepositRate": "0.000000041816843557",
            "Height": 4498946,
            "Timestamp": 1631452797
        },
        {
            "DepositRate": "0.000000041816843557",
            "Height": 4498424,
            "Timestamp": 1631449190
        },
        {
            "DepositRate": "0.000000041833331018",
            "Height": 4497901,
            "Timestamp": 1631445583
        },
        {
            "DepositRate": "0.000000041833331018",
            "Height": 4497379,
            "Timestamp": 1631441980
        },
        {
            "DepositRate": "0.000000041833331018",
            "Height": 4496858,
            "Timestamp": 1631438377
        },
        {
            "DepositRate": "0.000000041833331018",
            "Height": 4496335,
            "Timestamp": 1631434775
        },
        {
            "DepositRate": "0.000000041637400716",
            "Height": 4495810,
            "Timestamp": 1631431173
        },
        {
            "DepositRate": "0.000000041637400716",
            "Height": 4495287,
            "Timestamp": 1631427571
        },
        {
            "DepositRate": "0.000000041637400716",
            "Height": 4494764,
            "Timestamp": 1631423966
        }
    ]
}

Parsing the timestamps using new Date(timestamp * 1000) as done in the InterestSection.tsx I get that the timestamps are from today's date, each an hour apart.

Proposed solution
If possible the values fetched should be from previous days and not hours. Otherwise, the time should also be included in the slider label (eg: 13h, Sep 12, 2021). Ideally a larger historical view is shown (past 50, 100 or 1000 days).

We're working to solve this. This needs support from the backend where APY snapshot is taken every hour. We have the code for it but didn't implement it on the webapp front due to other tasks being of higher priority.