lfglabs-dev / api.starknet.quest

starknet.quest rust backend
7 stars 28 forks source link

feat: add endpoints for adding defi stats #226

Closed ayushtom closed 4 months ago

ayushtom commented 4 months ago

This pr handles the api endpoints provided by the foundation regarding the different aprs and rewards for different strategies in each protocol.

I return the latest data for the previous day in the api endpoint and will format it in the front for display. The sample responses are as below -

get_pair_stats

{
    "Ekubo": {
        "ETH/USDC": {
            "date": "2024-06-18",
            "allocation": 5863.07,
            "token0_allocation": 3743.49,
            "token1_allocation": 2119.59,
            "thirty_day_realized_volatility": 0.1364525322953435,
            "tvl_usd": 5596459.101936933,
            "apr": 0.2804138115521346
        },
        "STRK/ETH": {
            "date": "2024-06-18",
            "allocation": 18039.36,
            "token0_allocation": 7967.06,
            "token1_allocation": 7510.9,
            "thirty_day_realized_volatility": 0.2587158437924051,
            "tvl_usd": 8253722.569733291,
            "apr": 0.5850041060084309
        },
  }

get_lend_stats

  {
    "Hashstack": {
        "USDC": {
            "date": "2024-06-18",
            "allocation": 78.59,
            "supply_usd": 86427.23077579163,
            "non_recursive_supply_usd": 86427.23077579163,
            "non_recursive_revenue_usd": 22.80230737815523,
            "strk_grant_apr_ts": 0.24338992715743263,
            "strk_grant_apr_nrs": 0.24338992715743263
        },
        "ETH": {
            "date": "2024-06-18",
            "allocation": 218.67,
            "supply_usd": 224151.65076972952,
            "non_recursive_supply_usd": 224151.65076972952,
            "non_recursive_revenue_usd": 27.51244360879861,
            "strk_grant_apr_ts": 0.2611170530182506,
            "strk_grant_apr_nrs": 0.2611170530182506
        },
}

get_derivatives_stats

{
    "ZKX": {
        "date": "2024-06-18",
        "protocol": "ZKX",
        "allocation": 3494.52,
        "tvl": 2410881.0,
        "volumes": 6052825.909477409,
        "beta_fees": -10757.658141097429,
        "apr": 0.3879711317773768
    },
    "Carmine": {
        "date": "2024-06-18",
        "protocol": "Carmine",
        "allocation": 1454.04,
        "tvl": 998644.3744394524,
        "volumes": 33563.579490000004,
        "beta_fees": 25.289142806738905,
        "apr": 0.38972040906339134
    }
}

get_alt_protocol_stats

{
    "Nimbora": {
        "pendle": {
            "date": "2024-06-18",
            "allocation": 1674.17,
            "tvl_usd": 1310354.0191398698,
            "apr": 0.341978313298579
        },
        "spark": {
            "date": "2024-06-18",
            "allocation": 867.59,
            "tvl_usd": 679051.5769283344,
            "apr": 0.3419789946152406
        },
        "liquity": {
            "date": "2024-06-18",
            "allocation": 71.48,
            "tvl_usd": 55944.856868423754,
            "apr": 0.34198891742852466
        }
    }
}