refactor: user loan details for mint markets from Zustand store to TanStack query #1623
+388
−372
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.
While working on manage soft liquidation, I kept running into confusing user specific loan logic because of Zustand stores.
This PR aims to move user loan detail fetching out of Zustand stores and into a TanStack query for mint markets. You'll find that this is basically the same as what JJ's done for lend markets in
main\src\lend\entities\user-loan-details.ts.The query itself is an exact copy of what was inside the store and
apiCrvusd.ts. I did not intent to refactor this too much to minimize potential bugs. This includes silly usage ofPromise.allSettledandfulfilledValue. The query itself also fetches a lot of data which ideally should be split up in smaller queries. That's outside of the scope of this PR.Like has been said previously, there exists a query for lend markets already, but there's still old Zustand and
apiLending.tscode that's practically a duplicate of whatever's in that query. This will have to be removed in another PR.Note that this query is only about user information. General information about the loan itself still happens in the Zustand stores in the remaining
fetchLoanDetailsfunction. What has been removed fromfetchLoanDetails, however, is that it would also fetch user info and aloanExists. This has been refactored out, such thatfetchLoanDetailsonly returns pure loan information, and no additional user loan information.