Skip to content

Add Liquidation Incentives & Auction to Borrowing Contract #496

@ONEONUORA

Description

@ONEONUORA

Component: Contracts (Borrowing) | Effort: 5-7 days | Priority: MEDIUM

Current State

Basic liquidation exists with fixed 5% bonus. No auction mechanism or competitive liquidation.

Missing Functions

Advanced liquidation functions:

  • start_liquidation_auction() - Start Dutch auction for liquidation
  • bid_on_liquidation() - Place bid in auction
  • execute_auction() - Execute winning bid
  • get_auction_status() - Get current auction state
  • cancel_auction() - Cancel if loan becomes healthy
  • get_liquidation_discount() - Calculate current discount in auction

Why This Matters

  • Fair pricing: Auctions find market price for collateral
  • Better recovery: Competition increases liquidation proceeds
  • Efficiency: Faster liquidations with multiple bidders
  • Transparency: Public auction process

Current Gap

The liquidate() function at line 331 uses fixed liquidation bonus. No price discovery mechanism.

Tasks

  • Add LiquidationAuction struct (loan_id, start_price, current_price, highest_bidder, status)
  • Implement start_liquidation_auction() function
    • Validate health factor < 120%
    • Set starting price
    • Set auction duration
    • Emit AuctionStarted event
  • Implement Dutch auction price decay
  • Add bid_on_liquidation() function
    • Validate bid amount
    • Update highest bidder
    • Emit BidPlaced event
  • Implement execute_auction() function
    • Transfer collateral to winner
    • Repay loan from proceeds
    • Return excess to borrower
    • Emit AuctionExecuted event
  • Add auction cancellation if loan repaid
  • Add tests for auction scenarios
  • Document auction mechanism

Acceptance Criteria

  • Auctions start for unhealthy loans
  • Dutch auction price decreases over time
  • Bids placed and tracked correctly
  • Winning bid executes liquidation
  • Excess returned to borrower
  • Tests cover auction lifecycle

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions