Skip to content

Holiday season challenge: Add Constant Product AMM Implementation - #26

Open
FibrinLab wants to merge 2 commits into
cardano-foundation:mainfrom
FibrinLab:constant-product-amm
Open

Holiday season challenge: Add Constant Product AMM Implementation#26
FibrinLab wants to merge 2 commits into
cardano-foundation:mainfrom
FibrinLab:constant-product-amm

Conversation

@FibrinLab

Copy link
Copy Markdown
Contributor

Implements a constant product automated market maker (AMM) on Cardano using the x * y = k formula.

On-chain (Aiken)
Parameterised validator supporting swaps, liquidity addition/removal
Constant product formula with configurable fees (basis points)
LP token minting/burning for liquidity providers
8 unit tests covering success and failure cases

Off-chain (Lucid Evolution)
TypeScript client for pool creation and token swaps
Deno configuration with npm compatibility workarounds
Basic CLI commands for AMM operations

Features

  1. Token swaps with slippage protection
  2. Initial and subsequent liquidity provision
  3. Proportional liquidity removal
  4. Fee calculation and distribution
  5. Full test coverage
  6. Includes documentation, setup instructions, and follows repository patterns.

…tibility

- Fix Aiken validator compilation errors in identity.ak
  - Correct validator arity (3-arg spend signature)
  - Fix type assertions and boolean comparisons
  - Update test calls to match new validator signature

- Add workaround for Deno npm compatibility issue with libsodium-wrappers-sumo
  - Create fix-libsodium.sh script to copy missing libsodium-sumo.mjs file
  - Add .gitignore for wallet files
  - Update README with setup instructions including workaround

All tests pass and validator builds successfully.
}

validator identity {
spend(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transaction needs a trusted initial state. You can achieve this by a minting validator and require the new token being locked in this contract next to the initial datum state. During the spending operations you'll need to make sure this token on the utxo is around to avoid someone from locking a malicious utxo with an arbitrary datum.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants