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

381 add ability to split native vs wrapped carbon orders #390

Merged

Conversation

Lesigh-3100
Copy link
Collaborator

@Lesigh-3100 Lesigh-3100 commented Feb 22, 2024

Splitting Carbon Trades

New class:
CarbonTradeSplitter

Current problem:

In the main arb processing flow in bot.py _handle_trade_instructions, all trades that include Carbon deployments have been aggregated into a single trade action, which will cause trades to fail in cases in which a single trade action includes strategies that contain a mix of wrapped/native tokens (paired with the same token). a mix of strategies being traded on include native gas token, and some include wrapped gas token, or the trades occur on different carbon deployments.

Example 1:

  • Strategy 1 is trading ETH > TKN on Carbon
  • Strategy 2 is trading WETH > TKN on Carbon
  • Trade TKN > WETH on Uniswap

Current output:
Trade 1: Carbon, WETH > TKN [Strategy 1, 2]
Trade 2: Uniswap, TKN > WETH

Expected output:
Trade 1: Carbon, ETH > TKN [Strategy 1]
Trade 2: Carbon, WETH > TKN [Strategy 2]
Trade 3: Uniswap, TKN > WETH

Example 2:

  • Strategy 1 is trading ETH > TKN on Carbon
  • Strategy 2 is trading ETH > TKN on Carbon
  • Strategy 3 is trading WETH > TKN on Carbon
  • Strategy 4 is trading ETH > TKN on Graphene
    • Trade TKN > WETH on Uniswap

Current output:
Trade 1: Carbon, ETH > TKN [Strategy 1, 2, 3, 4]
Trade 2: Uniswap, TKN > WETH

Expected output:
Trade 1: Carbon, ETH > TKN [Strategy 1, 2]
Trade 2: Carbon, WETH > TKN [Strategy 3]
Trade 3: Graphene, ETH > TKN [Strategy 4]
Trade 4: Uniswap, TKN > WETH

Updated Wrap/Unwrap Algorithm

New class:
WrapUnwrapProcessor

To support the split trade upgrade, the wrap/unwrap algorithm has been updated to be significantly more robust. It can now handle much more complex routes (such as when you split Carbon trades!).

@Lesigh-3100 Lesigh-3100 added the enhancement New feature or request label Feb 22, 2024
@Lesigh-3100 Lesigh-3100 self-assigned this Feb 22, 2024
fastlane_bot/helpers/routehandler.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/routehandler.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/routehandler.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/routehandler.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/routehandler.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/tradeinstruction.py Show resolved Hide resolved
fastlane_bot/helpers/routehandler.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/routehandler.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/routehandler.py Outdated Show resolved Hide resolved
@Lesigh-3100 Lesigh-3100 marked this pull request as draft February 26, 2024 10:34
fastlane_bot/helpers/carbon_trade_splitter.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/carbon_trade_splitter.py Outdated Show resolved Hide resolved
fastlane_bot/bot.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/carbon_trade_splitter.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/carbon_trade_splitter.py Show resolved Hide resolved
fastlane_bot/helpers/wrap_unwrap_processor.py Outdated Show resolved Hide resolved
fastlane_bot/helpers/wrap_unwrap_processor.py Outdated Show resolved Hide resolved
fastlane_bot/bot.py Show resolved Hide resolved
fastlane_bot/bot.py Outdated Show resolved Hide resolved
@barakman barakman removed the request for review from NIXBNT March 19, 2024 14:55
@barakman barakman marked this pull request as ready for review March 19, 2024 14:55
barakman
barakman previously approved these changes Mar 19, 2024
 into 381-add-ability-to-split-native-vs-wrapped-carbon-orders
@Lesigh-3100 Lesigh-3100 dismissed mikewcasale’s stale review March 19, 2024 18:47

Changes addressed

zavelevsky
zavelevsky previously approved these changes Mar 19, 2024
Copy link
Contributor

@zavelevsky zavelevsky left a comment

Choose a reason for hiding this comment

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

LGTM!

@barakman barakman requested review from zavelevsky and barakman and removed request for mikewcasale and zavelevsky March 19, 2024 19:31
@barakman barakman merged commit 72c5b38 into develop Mar 19, 2024
3 checks passed
@barakman barakman deleted the 381-add-ability-to-split-native-vs-wrapped-carbon-orders branch March 19, 2024 19:32
@sklbancor sklbancor restored the 381-add-ability-to-split-native-vs-wrapped-carbon-orders branch March 19, 2024 20:12
@sklbancor sklbancor deleted the 381-add-ability-to-split-native-vs-wrapped-carbon-orders branch March 19, 2024 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants