-
Notifications
You must be signed in to change notification settings - Fork 6.6k
add: add partial support for EVO DEX on supra #16941
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
Open
vscorpio
wants to merge
1
commit into
DefiLlama:main
Choose a base branch
from
EvoMarket:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+74
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| const { invokeViewFunction } = require("../helper/chain/supra"); | ||
|
|
||
| // Constants | ||
| const EVO_CLMM_PACKAGE = | ||
| "0x3a56a0fcb8f23212fe880485c206dd03e08011ae88f02dbf9d0842be99eeac4b"; | ||
| const GET_ALL_POOLS_FUNCTION = `${EVO_CLMM_PACKAGE}::evo_clamm_liquidity_pool::get_all_pools`; | ||
| const GET_POOL_VIEW_FUNCTION = `${EVO_CLMM_PACKAGE}::evo_clamm_liquidity_pool::get_pool_view`; | ||
|
|
||
| /** | ||
| * Retrieves all pool IDs from EVO CLMM contract | ||
| * @param {string} chain - The blockchain name | ||
| * @returns {Promise<Array<string>>} - Array of pool IDs | ||
| */ | ||
| const getPoolIds = async chain => { | ||
| try { | ||
| const pools = await invokeViewFunction( | ||
| GET_ALL_POOLS_FUNCTION, | ||
| [], | ||
| [] | ||
| ); | ||
| return pools[0].map(pool => pool.inner); | ||
| } catch (error) { | ||
| console.error(`Error fetching pool IDs: ${error.message}`); | ||
| return []; | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * Fetches data for a specific pool | ||
| * @param {string} poolId - Pool identifier | ||
| * @param {string} chain - The blockchain name | ||
| * @returns {Promise<Object|null>} - Pool data or null if error | ||
| */ | ||
| const getPoolData = async (poolId, chain) => { | ||
| try { | ||
| const result = await invokeViewFunction( | ||
| GET_POOL_VIEW_FUNCTION, | ||
| [], | ||
| [poolId] | ||
| ); | ||
| return result[0]; | ||
| } catch (error) { | ||
| console.error(`Error fetching data for pool ${poolId}: ${error.message}`); | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| module.exports = { | ||
| timetravel: false, | ||
| methodology: "Aggregates TVL in all pools in EVO CLMM.", | ||
| supra: { | ||
| tvl: async api => { | ||
| const poolIds = await getPoolIds(api.chain); | ||
| console.log("poolIds: ", poolIds) | ||
| // Process pools in parallel for better performance | ||
| const poolDataPromises = poolIds.map(id => getPoolData(id, api.chain)); | ||
| const poolsData = await Promise.all(poolDataPromises); | ||
|
|
||
| console.log("poolsData: ", poolsData) | ||
|
|
||
| // Add token reserves to TVL | ||
| poolsData.forEach(pool => { | ||
| if (pool) { | ||
| console.log('Adding token:', pool.token_0, 'with reserve:', pool.token_0_reserve); | ||
| api.add(pool.token_0, pool.token_0_reserve); | ||
| console.log('Adding token:', pool.token_1, 'with reserve:', pool.token_1_reserve); | ||
| api.add(pool.token_1, pool.token_1_reserve); | ||
| } | ||
| }); | ||
|
|
||
| console.log('Final balances:', api.getBalances()); | ||
| } | ||
| } | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please no try catch and please remove any console logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I get that, they were left on purpose as instructed on Discord. Would you already have FA support so I can run the test again on my end and confirm TVL is showing correctly?
Will remove the try and console lgos as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you link me to the message? What is FA? You can test using
node test.js <path to adapter>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conversation we had on Discord is linked within the original PR under Important information. It also states what the "issue" is with the adapter and why it is posted like that.
Supra is a Aptos-based blockchain, where there are multiple type of assets. In the above mentioned section, the "coreAssets.json" which is likely used to compute prices is only supporting the "Legacy" version of Supra (chain's base currency); The DEX is using the "Fungible Asset" version.
I was also aware of the test command, since that is also mentioned within my section and what the result/issue is.
Useful links:
Supra Fungible Asset
Aptos Legacy Coin
Aptos Fungible Asset