Skip to content

feat: Integrate CowAMM #153

@tvinagre

Description

@tvinagre
  • Context

    We want to add support for CowAMM protocol to Tycho.

  • Technical Details

  • Provide a summary on how CowAMM contracts call each other [Cow AMM repo]

  • Solidity Adapter Contract

    • Please follow the official docs
    • Additional requirements:
      • Support regular swaps (swapExactAmountIn ) with no Fee:
        • Most deployed pools include a 99.99% swapFee, used for LVR Protection [see docs]. The swap function should consider a 0% swapFee, as it is done for CoW Protocol JIT orders
      • Support token <-> LPPool tokens swaps
        • Trigger the joinPool and exitPool methods as needed.
        • Swap any remaining amount of the superfluous token into the out_token.
        • Example: If a pool has 10 LP tokens, 500 USDT, and 500 USDC, and its weights are set to 50/50 :
          • A swap from 1LP Token -> USDC would do:
            • Burn 1 LP Token -> 50 USDT & 50 USDT
            • Swap 50 USDT -> 50 USDC (approx)
            • Return 100 USDC
  • Substreams package

    • Please follow the official docs
    • Please use the ethereum-template-factory as this protocol deploys a contract per amm pool.
    • Factory address should be configurable so the package can be deployed to other chains.
    • SwapFee is tracked via attributes
    • Pools should include the pool tokens + LP Token
    • Please add at least one integration test per pool configuration, with swaps simulation (tbd - so far it seems there is only a single pool configuration)
  • Acceptance criteria

    • Integration tests as described here at least one per pool configuration required.
    • Tests cover all types of swaps (Token <-> Token, Token <-> LPToken
  • Dialogue / Q&A

  • Q: Why are we swapping on a pool after withdrawing liquidity?
    A: We are aware that this approach is suboptimal but are prioritizing simplicity over optimization for this implementation.

  • Bounty Distribution

  • TBD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions