Skip to content

Implement cancel offer functionality#18

Merged
jaykayudo merged 1 commit intomainfrom
feat/cancel-offer
Apr 28, 2025
Merged

Implement cancel offer functionality#18
jaykayudo merged 1 commit intomainfrom
feat/cancel-offer

Conversation

@jaykayudo
Copy link
Contributor

Description

This PR implements the Cancel Offer functionality for the lending protocol backend, allowing lenders to delete their open offers from the system.

Canceling an offer gives lenders control to withdraw any offers they no longer wish to keep active. Instead of marking offers as canceled, this implementation deletes the offer record completely, ensuring it is no longer available for matching or loan creation.


Key Changes:

  • New API Endpoint:

    • POST /offer/cancel
    • Accepts the offer_id.
    • Authenticates the user to ensure only the original lender can cancel their own offer.
  • Offer Deletion:

    • The offer is permanently deleted from the database if the validation passes.
    • Deleted offers are completely removed from active listings, backend queries, and loan creation processes.
  • Validation Logic:

    • Confirm that the requester is the offer creator.
    • Confirm that the offer exists
    • Return appropriate errors if:
      • The offer doesn't exist.
      • An unauthorized user tries to cancel.

Acceptance Criteria:

  • Lenders can delete their own active offers.
  • Deleted offers are no longer retrievable in offer listings or eligible for loan creation.
  • Unauthorized or invalid cancellation attempts are properly handled with error responses.
  • Unit and integration tests are written to cover success and failure cases.

Notes:

  • Backend deletion ensures clean offer management.
  • Smart contract (on-chain) invalidation still needs to happen separately where applicable to secure against signature replay attacks.

Related Issue

Fixes #17

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement
  • Code refactoring
  • Documentation update
  • Test coverage improvement
  • CI/CD related changes

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Security Considerations

  • This PR introduces no security concerns
  • This PR modifies authentication/authorization
  • This PR handles sensitive data
  • This PR modifies financial transaction logic

Performance Impact

  • This PR has no significant performance impact
  • This PR improves performance
  • This PR may impact performance negatively (explain why it's necessary)

Additional Context

@jaykayudo jaykayudo added BACKEND INTERNAL The issue is for the project maintainers difficulty:medium labels Apr 28, 2025
@jaykayudo jaykayudo self-assigned this Apr 28, 2025
@jaykayudo jaykayudo merged commit 4ddd70e into main Apr 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BACKEND difficulty:medium INTERNAL The issue is for the project maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Cancel Offer Functionality (Backend)

1 participant