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

[MEX-663] Fix tokens liquidity #1549

Merged
merged 8 commits into from
Jan 28, 2025

Conversation

mad2sm0key
Copy link
Contributor

@mad2sm0key mad2sm0key commented Jan 23, 2025

Reasoning

  1. Skewed TVL and ranking for tokens and pairs (due to pairs containing tokens with a high supply and low liquidity)
  2. Displayed Total locked value on analytics is sometimes wrong (too small) at the beginning of each hour. This happens because the start and end dates used in the queries will differ at the benning of an hour

Proposed Changes

  • (1) fix compute methods for pairs and tokens locked value by comparing the difference between the 2 tokens. If the difference exceeds a threshold of 1000000 only use the smallest value
  • (1) add bulk get methods for pair first and second tocken locked values + update pair dataloader
  • (2) increase cron time for updateHistoricPairsData and decrease query cache warmer delay value

How to test

  • N/A

@mad2sm0key mad2sm0key marked this pull request as ready for review January 27, 2025 11:44
bogdan-rosianu
bogdan-rosianu previously approved these changes Jan 27, 2025
break;

const relevantPairs = pairs.filter((pair) =>
[pair.firstTokenID, pair.secondTokenID].includes(tokenID),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking, but a new array will be allocated at each iteration. either extract the array outside of the filter or refactor like:
tokenID === pair.firstTokenID || tokenID === pair.secondTokenID

new BigNumber(firstTokenLockedValueUSD)
.minus(secondTokenLockedValueUSD)
.abs()
.gt(1000000)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we extract this in config, or at least a constant?

.abs()
.gt(1000000)
) {
return BigNumber.min(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not accurate because it is missing the second half of the liquidity. We should use the common token from the pair to compute the total value locked for a pair in this scenario. In addition, we should consider the double of the common token as the whole liquidity locked in a pool

const secondTokenLockedValueUSD =
allSecondTokensLockedValueUSD[index];

if (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should reconsider this check as it isn't accurate.

@claudiulataretu claudiulataretu merged commit 0ae072b into development Jan 28, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants