Skip to content

Conversation

@Neros0
Copy link
Member

@Neros0 Neros0 commented Oct 7, 2025

📄 Summary

This pull request introduces the getAmountOut external view function to the TestAMMContract.sol contract. The function allows off-chain or frontend interfaces to estimate swap outcomes without executing transactions, improving user experience and enabling accurate slippage calculations.

✨ Features Added

  • getAmountOut external view function

    • Computes the expected output for a given swap input using the constant product formula.
    • Provides accurate, on-chain-calculated estimations for UI previews and analytics tools.
    • Does not modify state, ensuring gas-free read access for prediction market interfaces.
  • NatSpec documentation

    • Detailed comments describing purpose, parameters, return values, and requirements.
    • Added @custom:preview and @custom:formula tags for developer clarity.

🧠 Rationale

This addition enhances front-end and analytical tooling integration by enabling:

  • Real-time swap output predictions.
  • Accurate slippage visualization for users.
  • Improved market transparency without performing actual trades.

🧪 Files Modified

  • src/onchain/TestAMMContract.sol
    • 19 additions
    • 0 deletions

✅ Commit History

  • feat: Add getAmountOut External View Function Natspec Comments

📅 Date

October 7, 2025


Reviewer Note:
Ensure consistency between getAmountOut logic and the actual swap execution function to prevent any discrepancies in user-facing calculations.

@Neros0 Neros0 self-assigned this Oct 7, 2025
@Neros0 Neros0 added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 7, 2025
@Neros0 Neros0 merged commit 1933eeb into main Oct 7, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants