Skip to content

Backend DB incorrectly populating x/y IDs in "pools" table #39

@Eeysirhc

Description

@Eeysirhc

Issue: the "pools" table is not correctly populating the associated x/y ID ticker values for the respective liquidity pool ID.

Each LP pair has their own ID. For example, ERG/ergopad would have its own unique value and ergopad/ERG would have something else despite the asset ticker ID being the same - they are just switched.

If we run the following for the above example....

select 
distinct p.pool_id, 
p.x_id, 
a_x.ticker as x_ticker, 
p.y_id, 
a_y.ticker as y_ticker, 
a_x.ticker || '/' || a_y.ticker as ticker
from pools p 
LEFT JOIN assets a_x ON a_x.id = p.x_id
LEFT JOIN assets a_y ON a_y.id = p.y_id

where (a_x.ticker = 'ergopad' or a_y.ticker = 'ergopad')
and (a_x.ticker = 'ERG' or a_y.ticker = 'ERG')
;

We get the following results:

Row 1

pool_id: 61a579c46d92f2718576fc9839a2a1983f172e889ec234af8504b5bbf10edd89	
x_id: 0000000000000000000000000000000000000000000000000000000000000000
x_ticker: ERG	
y_id: d71693c49a84fbbecd4908c94813b46514b18b67a99952dc1e6e4791556de413
y_ticker: ergopad
ticker: ERG/ergopad

Row 2

pool_id: d7868533f26db1b1728c1f85c2326a3c0327b57ddab14e41a2b77a5d4c20f4b2	
x_id: 0000000000000000000000000000000000000000000000000000000000000000
x_ticker: ERG
y_id: d71693c49a84fbbecd4908c94813b46514b18b67a99952dc1e6e4791556de413
y_ticker: ergopad
ticker: ERG/ergopad

Despite being different pool IDs, the x_id and y_id columns are populating the same values for both and creating an incorrect output for the final ticker column.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions