Skip to content

Conversation

@luchobonatti
Copy link
Member

Fix Position Error Handling and Type Consistency

Changes Made

  • Removed try/catch block in getPosition function that was silently returning undefined
  • Updated return type to be more precise: Promise<GetPositionResponse>
  • Updated JSDoc documentation to accurately reflect function behavior
  • Fixed error propagation in position-related functions
  • Aligned error handling with other utility functions in the codebase
  • Updated GetPositionResponse interface to include tokenId and match SDK types

Why

The previous implementation was silently failing by returning undefined instead of propagating errors. This made error handling more difficult for consumers of the function and made testing less reliable. The response type update ensures better type safety and consistency with the SDK.

Testing

  • Updated tests to verify proper error propagation
  • All tests now passing
  • Verified error cases:
    • SDK instance not found
    • Tokens not found
    • Zero liquidity
    • Successful position retrieval

Impact

This change makes the position-related functions more predictable and consistent with the rest of the codebase's error handling patterns. The updated response type provides better type safety and developer experience.

@luchobonatti luchobonatti merged commit 9fad3c8 into main May 26, 2025
1 check passed
@luchobonatti luchobonatti deleted the fix/getPosition-return branch May 26, 2025 12:13
@github-actions
Copy link

🎉 This PR is included in version 1.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants