I am fetching specific cryptocurrency data from CoinGecko using the Data Fetcher and populating it into a table called Tokens. Additionally, I have a table called Positions, which is linked to the Tokens table. The Positions table is where I track my Liquidity Pools.
The challenge arises because the order of the Tokens table can change dynamically since it is populated with live data refreshed several times a day. Changes in market cap or the addition of new coins may shift data up or down in the Tokens table. This can lead to issues in the Positions table, where the linked entries might display incorrect coins.
For example, let's say my Tokens table initially contains the following coins: BTC, ETH, ARB, USDC, SUI, FET, and MATIC. Suppose I’m tracking the MATIC/USDC pair in a Liquidity Pool within the Positions table. At first, MATIC is in row 7, and USDC is in row 4 in the Tokens table.
Now, if the market cap changes or I add a new coin, such as SOL, which is inserted into row 4, the data in the Tokens table shifts. USDC moves to row 5, and row 4 now shows SOL. Consequently, the Positions table updates incorrectly, displaying MATIC/SOL instead of MATIC/USDC.
Is there a way to prevent this issue and ensure that the Positions table maintains accurate references to the intended coins, regardless of the shifting rows in the Tokens table?