Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate TVL amount #140

Open
djeck1432 opened this issue Oct 29, 2024 · 19 comments · May be fixed by #159
Open

Calculate TVL amount #140

djeck1432 opened this issue Oct 29, 2024 · 19 comments · May be fixed by #159
Assignees
Labels
good first issue Good for newcomers ODHack9

Comments

@djeck1432
Copy link
Owner

  1. Read guidelines.
  2. We're fetching amount for all opened position here but we sum all position together despite on the token for each position, however, there could be different tokens, like: ETH, STRK, USDC.
  3. Fetch current prices using this method get_current_prices
  4. Map current prices and amount for each token position and then return in this methodget_stats sum of all assets based on current price:
    p.s. so if you have in db ETH: 100, STRK: 20, USDC: 100, you should convert ETH and STRK to USDC current price and multiply on the amount of these tokens appropriate and return total amount of all assets in USDC
@djeck1432 djeck1432 added good first issue Good for newcomers ODHack9 labels Oct 29, 2024
@mimisavage
Copy link

Can I work on this ?

@josephchimebuka
Copy link

Could I be assigned to this?

@martinvibes
Copy link
Contributor

martinvibes commented Oct 29, 2024

holla @djeck1432
can i work on this issue :)
i like 🍒

@Akshola00
Copy link

Akshola00 commented Oct 29, 2024

Hi
i would love to work on this issue
this will be my first contribution to this project
i like 🍒

@mimisavage
Copy link

I want to take on this issue, can I be assigned?

@Yunusabdul38
Copy link

I’d like to resolve this.

@anonfedora
Copy link

hi, i'm a fullstack blockchain developer, and i can handle the issue efficiently. ETA: 8hours

@mimisavage
Copy link

I want to take on this issue, can I be assigned?

@aniruddhaaps
Copy link

I'm a python dev, a new-comer here. I want to take up the issue and solve it.

@mimisavage
Copy link

I want to take on this issue, can I be assigned?

@suhas-sensei
Copy link

I like 🍒. I'll implement a token-price aggregation solution using async batched price fetching and decimal precision handling for accurate multi-token position valuation in USDC, delivering by Nov 1st. Experienced with DeFi protocols and token price normalization implementations.

@mimisavage
Copy link

Would love to tackle this

@aniruddhaaps
Copy link

I modified the get_stats method to pull the prices using the get_current_prices method; however, each token needs to be converted into USD and then added together as all assets in USDC. With this, assets will be valued differently across every token.

@0xdevcollins
Copy link
Contributor

May I handle this issue?

@caxtonacollins
Copy link
Contributor

Is it okay if I take this? I like 🍒 and am ready to work..... please assign me

@mimisavage
Copy link

Will resolve this by trying to retrieve all opened positions from the database, regardless of token type (ETH, STRK, USDC, etc.).
Get current prices
Using the get_current_prices method, I'll fetch the current prices for each token.
Map prices to positions
Will then create a dictionary mapping each token to its current price
Convert tokens to USDC
For each position, I'll convert the token amount to USDC using the current price.
Calculate total assets
I'll sum up the USDC-converted amounts for all positions.
Return total stats
In the get_stats method, 'll return the total sum of all assets in USDC.

@Benjtalkshow
Copy link
Contributor

Benjtalkshow commented Oct 29, 2024

I am a Full Stack Developer with a strong background in blockchain and extensive experience in Next.js, TypeScript, and Python. I’ve made over 31 contributions to over 12 projects in the OnlyDust ecosystem, solving complex issues and delivering efficient, scalable solutions.

I will tackle this task by enhancing the stats endpoint by implementing accurate TVL calculation that properly handles multiple token types.
The current implementation incorrectly sums different token amounts without price conversion. I will modify the PositionDBConnector to group opened positions by token symbol, fetch current prices using the existing get_current_prices() method, convert each token position to its "USDC" equivalent, and aggregate all values for total TVL in "USDC". For example, if we have "100 ETH at $3000/ETH, 20 STRK at $50/STRK", and 100 "USDC", the system will correctly report TVL as "301,100 USDC "rather than just summing raw amounts. The implementation will include error handling, logging, and use Decimal type for precision. ETA 48 hours from task assignment. I like 🍇.

@djeck1432
Copy link
Owner Author

@suhas-sensei 1. November, it won't work, if you can do it till during 24 hours, it's okay

@suhas-sensei
Copy link

@djeck1432 maybe i can try in 24hours, ill reschedule some of my work for later

@djeck1432 djeck1432 linked a pull request Oct 30, 2024 that will close this issue
@josephchimebuka josephchimebuka linked a pull request Oct 31, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers ODHack9
Projects
None yet
Development

Successfully merging a pull request may close this issue.