osmosis icon indicating copy to clipboard operation
osmosis copied to clipboard

Call to GetArithmeticTwap with wrong order of arguments

Open migueldingli1997 opened this issue 3 years ago • 1 comments

System information

Osmosis version: main (at time of writing) OS & Version: n/a Commit hash: 8a19d8b3edb53c18c2607750ac8e9b5b3b37e71b

Expected behaviour

All callers of this function provide the base asset followed by the quote asset

https://github.com/osmosis-labs/osmosis/blob/8a19d8b3edb53c18c2607750ac8e9b5b3b37e71b/x/twap/api.go#L31-L38

Actual behaviour

Some callers under wasmbinding/queries.go call the function with quote asset followed by base asset

https://github.com/osmosis-labs/osmosis/blob/8a19d8b3edb53c18c2607750ac8e9b5b3b37e71b/wasmbinding/queries.go#L122

and

https://github.com/osmosis-labs/osmosis/blob/8a19d8b3edb53c18c2607750ac8e9b5b3b37e71b/wasmbinding/queries.go#L140

Steps to reproduce the behaviour

n/a

Backtrace

n/a

migueldingli1997 avatar Oct 07 '22 08:10 migueldingli1997

Oh good catch! Thanks for this issue, we should be solving this by the next upgrade. Meanwhile, querying via correct arguments should be able to be done via stargate queries instead of bindings

mattverse avatar Oct 07 '22 09:10 mattverse

I don't know how problematic this is, but I noticed that the order is incorrect in the unit tests as well. And if the order is switched to base, quote some unit tests start failing.

https://github.com/osmosis-labs/osmosis/blob/8a19d8b3edb53c18c2607750ac8e9b5b3b37e71b/x/twap/api_test.go#L329-L331

migueldingli1997 avatar Oct 14 '22 08:10 migueldingli1997

I believe this is now solved. Closing for now. Thank you @migueldingli1997

p0mvn avatar Nov 17 '22 21:11 p0mvn

Actually, this is not solved. I mistook it for another refactor we did. Keeping open until further investigations

p0mvn avatar Nov 17 '22 21:11 p0mvn

@mattverse seeing that you are assigned here. Any updates on this? I'm still seeing some twap tests having assets misplaced

p0mvn avatar Nov 17 '22 21:11 p0mvn