Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/carbondefi #256

Conversation

tiagofilipenunes
Copy link
Contributor

@tiagofilipenunes tiagofilipenunes commented Dec 20, 2023

Closes #255

A description of the changes proposed in the pull request:

In this pull request, a Carbon DeFi AMM connector is added. The following endpoints are available:

  • Functions to expose in the gateway
    • AMMish
      • amm/trade POST
      • amm/price POST
      • amm/estimateGas POST
    • Generic
      • connectors GET
      • chain/tokens GET

Tests performed by the developer:

Test for Carbonamm

  • Carbon constructor
  • estimateSellTrade
    • with possible trade path
    • without possible trade path
  • estimateBuyTrade
    • with possible trade path
    • without possible trade path
  • getAllowedSlippage
    • non-null input
    • null input
    • malformed input
  • POST amm/price
    • SELL side
      • valid parameters
      • invalid parameters
    • BUY side
      • valid parameters
      • invalid parameters
  • POST amm/trade
    • BUY side
      • valid parameters
      • invalid parameters
    • SELL side
      • valid parameters
      • invalid parameters
      • changing maxFeePerGas
  • Creating the connector with unsupported chain
  • Malformed allowedSlippage
    • in the request amm/trade
    • in the carbon.conf file

Coverage:

File % Stmts % Branch % Funcs % Lines Uncovered Line
connectors/carbon 98.53 90 98.52 99.69
carbon.config.ts 100 100 100 100
carbon.utils.ts 100 97.29 100 100 100
carbonAMM.ts 100 100 100 100

Tips for QA testing and comments/questions:

  • If using a private RPC, you can go to https://app.carbondefi.xyz/debug and input it there, then use the app to observe reflected changes coming from interacting with the gateway.
  • The CarbonSDK is used, which can be found at https://github.com/bancorprotocol/carbon-sdk
  • Both connectors initiate a cache and keep it up to date by polling events
    • The Carbon CLOB connector purposely hits the miss cache handler on initialisation to get all the on-chain information as it is a pre-requisite for the functionality of most CLOB endpoints
    • The Carbon AMM syncs in the background and can handle /price and /trade requests and hit cache miss handle
  • jest.config.js modification - problem with jest not supporting subpath imports and exports pre version v29.4.0. Hummingbot gateway is currently using version 27.3.1. A workaround by modifying the jest.config file to manually add the subpath imports was used.

@tiagofilipenunes tiagofilipenunes marked this pull request as ready for review December 20, 2023 13:27
Copy link
Contributor

@fengtality fengtality left a comment

Choose a reason for hiding this comment

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

Requested changes:

  • Please move all tests to the test-bronze folder, so that they are not included in workflows

  • I recommend that this PR should only add the AMM connector initially, that is within the bounds of the existing Gateway structure. Keep in mind that DEX connectors are only meant to be standard integrations that work with a specific strategy, like AMM-ARB. Afterwards it's merged in, I think you can add the custom functionality as another PR.

  • Regarding swapping ETH, you can modify the amm/trade and amm/price endpoints to remove the check for ETH for this connector.

  • I think the CLOB functionality, limit orders support, and associated endpoints could be part of this connector or as part of a different connector folder - it's up to how you want this connector to be used. Currently, Gateway assumes that these connectors are being added so that users can run standard strategies like AMM-ARB with them. However, if you want to add custom scripts that allow users to use other endpoints that this connector supports, that approach could work too.

@tiagofilipenunes
Copy link
Contributor Author

Thank you for the review Michael. Changes:

@fengtality
Copy link
Contributor

Thank you for the review Michael. Changes:

Looks good @tiagofilipenunes. I think you should be able to create a Pull Request Proposal to have us review and merge this connector into the codebase.

@rapcmia rapcmia requested review from rapcmia and nikspz January 29, 2024 05:02
Copy link

feat/carbondefi #256

@nikspz nikspz changed the base branch from main to development February 1, 2024 16:47
@nikspz
Copy link
Contributor

nikspz commented Feb 1, 2024

hi @tiagofilipenunes Please resolve branch conflicts and be informed that all PRs should use development branch and be pointed to development branch (not main or master)

https://hummingbot.org/developers/contributions/#checklist

@tiagofilipenunes
Copy link
Contributor Author

tiagofilipenunes commented Feb 1, 2024

@nikspz Thanks for pointing that out, just merged and resolved conflicts.

  • Did I create my branch from development?
  • Did I follow the correct naming convention for my branch?
  • Is my branch focused on a single main change?
  • Do all of my changes directly relate to this change?
  • Did I rebase the upstream development branch after I finished all my work? Merged them
  • Did I write a clear pull request message detailing what changes I made?
  • Did I get a code review?
  • Did I make any requested changes from that code review?

@rapcmia
Copy link
Contributor

rapcmia commented Feb 2, 2024

PR update:

  • Setup with latest development client ok
  • Ran API tests:
    • GET connector displays carbonamm
    • POST balances and poll ok
    • POST allowance, approve and cancel ok
    • POST for price and estimateGas ok
    • POST trade also gets valid / insufficient balance response ok
  • Current PR does not support CLOB atm and base on previous comments, a separate PR shall be submitted pending

@fengtality
Copy link
Contributor

As @rapcmia's tests are successful, I will merge this PR in so that other PRs can resolve any conflicts if needed.

@fengtality fengtality merged commit bc7310b into hummingbot:development Feb 2, 2024
3 checks passed
@david-hummingbot
Copy link
Contributor

Hi @tiagofilipenunes, please add connector docs here - https://github.com/hummingbot/hummingbot-site
You can use any of the existing DEX connectors as a template - https://hummingbot.org/dex-connectors/
Thanks!

@tiagofilipenunes
Copy link
Contributor Author

Hi @david-hummingbot thanks for the reminder! Here is the PR to add the connector docs:

hummingbot/hummingbot-site#347

@david-hummingbot
Copy link
Contributor

Thanks @tiagofilipenunes, this will be included in the 1.25.0 release next week.

@tiagofilipenunes tiagofilipenunes deleted the tiagofilipenunes-feat/carbondefi branch October 23, 2024 13:14
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.

feat/carbondefi - Add Carbon DeFi AMM and CLOB_SPOT connector
5 participants