lfglabs-dev / api.starknet.quest

starknet.quest rust backend
3 stars 19 forks source link

Add base APRs for Nimbora #281

Open Marchand-Nicolas opened 5 hours ago

Marchand-Nicolas commented 5 hours ago

There is the following problem in src/endpoints/discover/defi/get_alt_protocol_stats.rs: we only count DeFi Spring APRs. This route should return the APRs of different strategies, but it is currently only using the APRs provided by the DeFi Spring for these strategies. The aim of this issue is to add an API call to Nimbora at the begining of the file, so that the APR of every strategy returned by the DeFi Spring API is replaced by the one from the Nimbora API (which counts the base APR + the DeFi Spring one).

Example to illustrate: When callinghttps://api.starknet.quest/discover/defi/get_alt_protocol_stats (which is the current state of the API), we get:

image

And when calling the Nimbora API https://stats.nimbora.io/yield-dex/strategies:

image

We get, (this screenshot only contains this example strategy, but all other strategies are returned by the API), for instance,

      "base": "0.7026797371850104",
      "boost": "0",
      "incentives": "13.09410701089488"
    },
    "apr": "13.7967867480798904",

The problem is that our API only count the incentives(returned by the DeFi Spring API), and not the base. That's why you'll need to use both API's, to get the accurate computer APR.

You'll need to set the following field in you config.toml in order to test:

alt_protocols_api_endpoint = "https://kx58j6x5me.execute-api.us-east-1.amazonaws.com/starknet/fetchFile?file=prod-api/phase4/phase4_strk_grant.json"

Suggested implementation:

ShantelPeters commented 5 hours ago

Hi @Marchand-Nicolas please can I be assigned to this issue , I will love to work on it

devcollinss commented 5 hours ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I would like to be assigned this issue. I'll prioritize it and begin working on it immediately

mimisavage commented 5 hours ago

@Marchand-Nicolas can I be assigned this task? I'll deliver as soon as possible

MatiasAchucarro commented 1 hour ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a passionate and results-driven web developer, currently deepening my knowledge in web3 technologies, Cairo, and open-source development through Dojo Coding. My skill set includes expertise in JavaScript, React, HTML, CSS, and C# with .NET Entity Framework, among others. I also have experience with tools like Git, GitHub, SQL Server, and Postman. My focus has been on building solid web applications, from task lists to full-fledged CRUD systems, with front-end, back-end, and database integration. I have already made a contribution to Starknet Quest, and I am eager to take on more opportunities

How I plan on tackling this issue

I would start by adding a Nimbora API call to the beginning of the path in get_alt_protocol_stats.rs. I would use a library like reqwest to make the HTTP request, deserializing the response into a structure containing the APR values ​​for each strategy, including base and incentives. If the call fails, I handle the error by returning only the current DeFi Spring data.

After getting the data from Nimbora, the DeFi Spring APRs, which only include incentives, are processed as usual. Then, for each strategy returned by DeFi Spring, I would look for the matching strategy in the Nimbora response. If a match is found, I replace the DeFi Spring APR value with the Nimbora APR value (which includes both base and incentives).

If a matching strategy is not found in Nimbora or if an error occurs during the call to its API, the system continues to run by returning the data from DeFi Spring. This ensures that the integration with the Nimbora API is solid and does not interrupt the current flow of the system.

For testing, I also add the alt_protocols_api_endpoint field to the config.toml configuration file, allowing you to easily change the endpoint.