Skip to content

DorkFiMCP: detect deposit cap and fail early in deposit_txn #7

@temptemp3

Description

@temptemp3

Summary

DorkFiMCP's deposit_txn (and related deposit flows) should detect when a deposit would exceed the market deposit cap and fail early with a clear error, instead of building/signing and potentially failing on-chain or giving a confusing result.

Problem

When a user calls deposit_txn with an amount that would push total supplied (e.g. existing supply + new deposit) over the market's deposit cap:

  • The MCP may build transactions that will fail on-chain or behave unexpectedly
  • Users get a poor experience (e.g. signing then failure, or unclear reason for failure)
  • No upfront validation against the cap in the MCP layer

Expected behavior

  • Before building deposit_txn, DorkFiMCP should:
    1. Resolve the market's deposit cap (if any) and current total supplied / user supply
    2. Compute whether current supply + deposit amount would exceed the cap
    3. If over cap: return a clear error (e.g. "Deposit would exceed market cap: current X, cap Y, requested Z") and do not return transaction bytes
  • If there is no cap or cap is not applicable, proceed as today

Suggested implementation

  • In the code path that handles deposit_txn (and any wrapper that uses it):
    • Fetch market info (e.g. via get_market or equivalent) including deposit cap and current supplied amounts
    • Optionally fetch user's current supply in that market
    • Validate (user_current_supply + deposit_amount) and/or (total_supplied + deposit_amount) against cap
    • If over cap, return a structured error and no txn payload
  • Add or extend MCP/unit tests for: at-cap, over-cap, and no-cap scenarios

Context

Improves UX and reliability for DorkFi MCP callers; aligns with deposit cap behavior in the app (see e.g. DorkFi/dorkfi-app#246).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions