lfglabs-dev / api.starknet.quest

starknet.quest rust backend
9 stars 37 forks source link

Add base APRs for Nimbora #281

Closed Marchand-Nicolas closed 1 month ago

Marchand-Nicolas commented 1 month 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 1 month ago

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

0xdevcollins commented 1 month 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 1 month ago

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

MatiasAchucarro commented 1 month 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.

GideonBature commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Software Engineer with working knowledge of Rust, also proficient in JavaScript and TypeScript. I have built projects personally on Rust, also JavaScript and TypeScript. Also, I have contributed to the Stark Quest project for the first time during the just concluded ODhack. I have worked with APIs before and even built some in Actix Web, hence I believe that my experiencial knowledge will definitely help me in solving this challenge.

How I plan on tackling this issue

First of all I will go through the Readme once again to see if there are any changes to setting up my environment for testing, as I have the repository set up on my local machine already so that I will be able to test my work.

Next, I will go through the file having this problem to see what is currently there and From the description of the problem, there is a very clear suggestion which is to first call the Nimbora's API to fetch strategies, afterwards using a map to check if the strategy is available or not, as this will make the code scalable, since there is the possibility of having more protocols other than Nimbora's in the future.

Finally, if there are issues with calling Nimbora's API, it's to leave it so as for it to default to using the Data from DeFi spring. Afterwards I test to make sure it's working.

Benjtalkshow commented 1 month ago

GM @Marchand-Nicolas I would be glad to work on this issue. Thanks