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

Optimizer API #608

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
db1341f
add_sei (devnet) initial commit
NIXBNT Apr 28, 2024
462acc2
CPC v3.5 (as_dicts, as_df, minrw, price estimate)
sklbancor Dec 11, 2023
1f0acff
MargPOptimizer 5.3-b1
sklbancor Dec 11, 2023
c068c3d
MargPOptimzer v5.3-b2
sklbancor Apr 30, 2024
88adf24
MargPOptimzer v5.3-b3
sklbancor Apr 30, 2024
058b1ae
MargPOptimizer v5.3
sklbancor May 1, 2024
d3eb398
Simplepair: adding spacing to token index (trivial)
sklbancor Apr 30, 2024
2458b92
NBTest 002, 003
sklbancor May 1, 2024
6de39c2
MargPOptimzer v5.3-b2
sklbancor Apr 30, 2024
cefcfc7
Test39: asserting all curves are being converted
sklbancor May 6, 2024
bafc7c9
Optimizer_XXX notebooks
sklbancor Dec 12, 2023
1647403
MargPOptimizer -- v5.3.1
sklbancor May 1, 2024
839566d
MargPOptimizer -- v5.3.2
sklbancor May 1, 2024
853857a
MargPOptimizer v5.4 [dump curves]
sklbancor May 2, 2024
d57d4cf
New NBTest: 100 (Convergence)
sklbancor May 1, 2024
4cd424b
CPC v3.6 [as_json, as_repr]
sklbancor May 1, 2024
496ce45
CPCArbOptimizer v5.3 [curve dump]
sklbancor May 2, 2024
9e83b2a
New NBTest 101 - CPC, Optimizer New Features
sklbancor May 2, 2024
65a13c1
Optimizer Notebooks
sklbancor May 1, 2024
c6acf64
Docs (202312 ArbBot Convergence)
sklbancor Dec 12, 2023
6328921
>>>>> BRANCH_OPTIMIZER_API
sklbancor May 3, 2024
c48aa43
Create testing.py
sklbancor May 4, 2024
1ac9bba
CurveBase v1.0 (from cpcbase)
sklbancor May 3, 2024
89b83be
Create cpcbase.py
sklbancor May 3, 2024
cb1eda4
CPC v3.4+dev01
sklbancor May 3, 2024
7a2f616
MargPOptimizer v5.2+dev01 [pstart]
sklbancor May 3, 2024
bee37c6
CPC v4.0-alpha01
sklbancor May 3, 2024
78d9c6d
CPCContainer -> CurveContainer
sklbancor May 3, 2024
f47c3d1
CPC - removed Tokens NOETH v4.0beta1
sklbancor May 3, 2024
4ea9423
OptimizerBase: cleanup v5.1.1
sklbancor May 3, 2024
536d2eb
MargPOptimizer 6.0-alpha01
sklbancor May 3, 2024
186c3a7
MargPOptimizer: constants
sklbancor May 3, 2024
b31e72d
MargPOptimizer: MOXXX -> MO_XXX
sklbancor May 4, 2024
1606f19
MargPOptimizer v6.0beta1
sklbancor May 4, 2024
483c94f
CPCArbOptimizer: CurveContainer
sklbancor May 3, 2024
33e0fef
CPCArbOptimizer - TIF_DF8 v5.1.1
sklbancor May 3, 2024
bb03c2a
ConvexOptimizer: CurveContainer v5.0.2
sklbancor May 3, 2024
b9b938e
PairOptimizer: CurveContainer 6.0.2
sklbancor May 3, 2024
3d1b8f6
Analyzer: CurveContainer v1.5.1
sklbancor May 3, 2024
5e89921
NBTest Adjustments
sklbancor May 3, 2024
33906cd
New NBTest 102: API Basics
sklbancor May 3, 2024
66a9ee6
>>>>> NBTest 102: removing startswith
sklbancor May 3, 2024
3fa22f6
NBTest 102
sklbancor May 3, 2024
db31fc0
CPC - univ2: x,y -> liq
sklbancor May 4, 2024
56d5097
Moving cpc modules -> curves
sklbancor May 4, 2024
fbd9892
Moving cryptocompare, noneresult -> helpers
sklbancor May 5, 2024
764be88
Delete reformat.py
sklbancor May 5, 2024
9a1b488
cpc -> cpc, curvecontainer, cpcinverter
sklbancor May 4, 2024
a4be885
module init files (curves, optimizer)
sklbancor May 4, 2024
ce6fcdb
Fixing imports
sklbancor May 4, 2024
3d061f3
FIxing NBTest imports
sklbancor May 4, 2024
b843840
Fixing Optimizer imports
sklbancor May 4, 2024
73ec9a8
Fixing bot imports
sklbancor May 4, 2024
13d6a2f
clean-up imports and top matter
sklbancor May 5, 2024
ecdbf2a
NBTest 101
sklbancor May 5, 2024
585003f
CPCArbOptimizer: bugfix
sklbancor May 5, 2024
07e7882
CPCArbOptimizer: removing curve_container argument
sklbancor May 5, 2024
efc65ad
Fix tests following changes in the optimizer's API
May 5, 2024
35b1dad
MargPOptimizer: now requires pstart as arg, not in params
sklbancor May 6, 2024
315bdb9
Calling optimizer with pstart as argument
sklbancor May 6, 2024
eb4637c
poolandtokens: fixing uni_v2 imports
sklbancor May 6, 2024
f6fba7a
Fixing Test 050 (import T)
sklbancor May 6, 2024
0a52a48
Cleanup test 42 (double import)
sklbancor May 6, 2024
8e8e265
Fixing NBTest 002, 055
sklbancor May 6, 2024
d5e9367
Moving NBTest0xx -> 8xx
sklbancor May 6, 2024
118e1d1
Moving NBTest1xx -> 01x
sklbancor May 6, 2024
3de183c
Fixing the imports in the bot (top-level only)
sklbancor May 6, 2024
681c1f0
>>>>>> TESTS PASSED <<<<<<
sklbancor May 6, 2024
1da90af
>>> REMOVING SLOW TESTS
sklbancor May 6, 2024
73c78b1
chore: submodule added
platonfloria May 2, 2024
a73d251
chore: cleanup
platonfloria May 6, 2024
f6d54c4
fix: ci
platonfloria May 3, 2024
88d1996
fix: ci
platonfloria May 3, 2024
cb6363f
fix: ci
platonfloria May 3, 2024
8888768
chore: add Makefile
platonfloria May 3, 2024
4260545
fix: rebase conflicts
platonfloria May 6, 2024
8440505
cleanup
platonfloria May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export ETH_PRIVATE_KEY_BE_CAREFUL="0x123-USE-YOUR-OWN-PRIVATE-KEY-HERE"
export WEB3_FANTOM="FANTOM-API-KEY-HERE" // "public" can be used in place of a paid API key
export WEB3_MANTLE="MANTLE-API-KEY-HERE"
export WEB3_LINEA="LINEA-API-KEY-HERE" //
export WEB3_SEI="SEI-API-KEY-HERE" //

#******** For Development - not required to run bot ********#
export ETHERSCAN_TOKEN="ONLY_REQUIRED_IN_DEV"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-and-pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
steps:
# Checkout
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: true

# Check commit message
- id: check
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -40,7 +42,7 @@ jobs:
echo ETHERSCAN_TOKEN=$ETHERSCAN_TOKEN >> .env
echo DEFAULT_MIN_PROFIT_BNT=$DEFAULT_MIN_PROFIT_BNT >> .env
echo ETH_PRIVATE_KEY_BE_CAREFUL=$ETH_PRIVATE_KEY_BE_CAREFUL >> .env
cd resources/NBTest;ln -s ../../fastlane_bot fastlane_bot;cd ..;cd ..; poetry run ./run_tests
make test
env:
TENDERLY_FORK: '${{ secrets.TENDERLY_FORK }}'
WEB3_ALCHEMY_PROJECT_ID: '${{ secrets.WEB3_ALCHEMY_PROJECT_ID }}'
Expand Down
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ carbon/tools/*
*/.coverage
*/.coverage.*
*/.cover
NBTest/carbon/*
NBTest/carbon
resources/NBTest/fastlane_bot

.python-version

/.env
*.env
Expand Down Expand Up @@ -72,4 +71,3 @@ logs/*
/fastlane_bot/data/blockchain_data/*/token_detail/
missing_tokens_df.csv
tokens_and_fee_df.csv
fastlane_bot/tests/nbtest/*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "arb-optimizer"]
path = arb-optimizer
url = [email protected]:bancorprotocol/arb-optimizer.git
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
poetry run pytest fastlane_bot/tests -v $1
1 change: 1 addition & 0 deletions arb-optimizer
Submodule arb-optimizer added at 261f01
27 changes: 14 additions & 13 deletions fastlane_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
from typing import Generator, List, Dict, Tuple, Any, Callable
from typing import Optional

from arb_optimizer import CurveContainer, ConstantProductCurve as CPC

from fastlane_bot.config import Config
from fastlane_bot.helpers import (
TxRouteHandler,
Expand All @@ -66,7 +68,6 @@
split_carbon_trades,
maximize_last_trade_per_tkn
)
from fastlane_bot.tools.cpc import ConstantProductCurve as CPC, CPCContainer, T
sklbancor marked this conversation as resolved.
Show resolved Hide resolved
from .config.constants import FLASHLOAN_FEE_MAP
from .events.interface import QueryInterface
from .modes.pairwise_multi import FindArbitrageMultiPairwise
Expand Down Expand Up @@ -128,13 +129,13 @@ def __post_init__(self):
self.db = QueryInterface(ConfigObj=self.ConfigObj)
self.RUN_FLASHLOAN_TOKENS = [*self.ConfigObj.CHAIN_FLASHLOAN_TOKENS.values()]

def get_curves(self) -> CPCContainer:
def get_curves(self) -> CurveContainer:
"""
Gets the curves from the database.

Returns
-------
CPCContainer
CurveContainer
The container of curves.
"""
self.db.refresh_pool_data()
Expand Down Expand Up @@ -184,7 +185,7 @@ def get_curves(self) -> CPCContainer:
f"[bot.get_curves] MUST FIX UNEXPECTED ERROR converting pool to curve {p}\n[ERR={e}]\n\n"
)

return CPCContainer(curves)
return CurveContainer(curves)

def _simple_ordering_by_src_token(
self, best_trade_instructions_dic, best_src_token
Expand Down Expand Up @@ -277,7 +278,7 @@ def _get_arb_finder(cls, arb_mode: str) -> Callable:
def _find_arbitrage(
self,
flashloan_tokens: List[str],
CCm: CPCContainer,
CCm: CurveContainer,
arb_mode: str,
randomizer: int
) -> dict:
Expand All @@ -295,7 +296,7 @@ def _find_arbitrage(
def _run(
self,
flashloan_tokens: List[str],
CCm: CPCContainer,
CCm: CurveContainer,
*,
arb_mode: str,
randomizer: int,
Expand All @@ -311,7 +312,7 @@ def _run(
----------
flashloan_tokens: List[str]
The tokens to flashloan.
CCm: CPCContainer
CCm: CurveContainer
The container.
arb_mode: str
The arbitrage mode.
Expand Down Expand Up @@ -575,7 +576,7 @@ def custom_sort(self, data, sort_sequence):

def calculate_profit(
self,
CCm: CPCContainer,
CCm: CurveContainer,
best_profit: Decimal,
fl_token: str,
flashloan_fee_amt: int = 0,
Expand All @@ -585,7 +586,7 @@ def calculate_profit(

Parameters
----------
CCm: CPCContainer
CCm: CurveContainer
The container.
best_profit: Decimal
The best profit.
Expand Down Expand Up @@ -696,7 +697,7 @@ def calculate_arb(

def _handle_trade_instructions(
self,
CCm: CPCContainer,
CCm: CurveContainer,
arb_mode: str,
r: Any,
replay_from_block: int = None
Expand All @@ -709,7 +710,7 @@ def _handle_trade_instructions(

Parameters
----------
CCm: CPCContainer
CCm: CurveContainer
The container.
arb_mode: str
The arbitrage mode.
Expand Down Expand Up @@ -893,7 +894,7 @@ def run(
self,
*,
flashloan_tokens: List[str] = None,
CCm: CPCContainer = None,
CCm: CurveContainer = None,
arb_mode: str = None,
run_data_validator: bool = False,
randomizer: int = 0,
Expand All @@ -908,7 +909,7 @@ def run(
----------
flashloan_tokens: List[str]
The flashloan tokens (optional; default: RUN_FLASHLOAN_TOKENS)
CCm: CPCContainer
CCm: CurveContainer
The complete market data container (optional; default: database via get_curves())
arb_mode: str
the arbitrage mode (default: None; can be set depending on arbmode)
Expand Down
41 changes: 40 additions & 1 deletion fastlane_bot/config/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class ConfigNetwork(ConfigBase):
NETWORK_FANTOM = S.NETWORK_FANTOM
NETWORK_MANTLE = S.NETWORK_MANTLE
NETWORK_LINEA = S.NETWORK_LINEA
NETWORK_SEI = S.NETWORK_SEI

# FLAGS
#######################################################################################
Expand Down Expand Up @@ -317,7 +318,9 @@ def new(cls, network=None):
elif network == cls.NETWORK_MANTLE:
return _ConfigNetworkMantle(_direct=False)
elif network == cls.NETWORK_LINEA:
return _ConfigNetworkLinea(_direct=False)
return _ConfigNetworkLinea(_direct=False)
elif network == cls.NETWORK_SEI:
return _ConfigNetworkSei(_direct=False)
elif network == cls.NETWORK_TENDERLY:
return _ConfigNetworkTenderly(_direct=False)
else:
Expand Down Expand Up @@ -777,6 +780,42 @@ class _ConfigNetworkLinea(ConfigNetwork):
# Add any exchanges unique to the chain here
CHAIN_SPECIFIC_EXCHANGES = []

class _ConfigNetworkSei(ConfigNetwork):
"""
Fastlane bot config -- network [Base Mainnet]
"""

NETWORK = S.NETWORK_SEI
NETWORK_ID = "1" # TODO
NETWORK_NAME = "sei"
DEFAULT_PROVIDER = S.PROVIDER_ALCHEMY
RPC_ENDPOINT = "https://evm-rpc.arctic-1.seinetwork.io/" # TODO currently Sei devnet
WEB3_ALCHEMY_PROJECT_ID = os.environ.get("WEB3_SEI")

network_df = get_multichain_addresses(network=NETWORK_NAME)
FASTLANE_CONTRACT_ADDRESS = "0xC7Dd38e64822108446872c5C2105308058c5C55C" #TODO - UPDATE WITH Mainnet
MULTICALL_CONTRACT_ADDRESS = "0x1E05037b9c4fEFaF3c45CD6F4F2C3197e6A43cD8" # previously 0xcA11bde05977b3631167028862bE2a173976CA11

CARBON_CONTROLLER_ADDRESS = "0x59f21012B2E9BA67ce6a7605E74F945D0D4C84EA" #TODO - UPDATE WITH Mainnet
CARBON_CONTROLLER_VOUCHER = "0xe4816658ad10bF215053C533cceAe3f59e1f1087" #TODO - UPDATE WITH Mainnet

NATIVE_GAS_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
WRAPPED_GAS_TOKEN_ADDRESS = "0x26841a0A5D958B128209F4ea9a1DD7E61558c330" # TODO confirm for Mainnet
NATIVE_GAS_TOKEN_SYMBOL = "SEI"
WRAPPED_GAS_TOKEN_SYMBOL = "WSEI"
STABLECOIN_ADDRESS = "0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C" #TODO USDC on devnet

IS_INJECT_POA_MIDDLEWARE = False
# Balancer
BALANCER_VAULT_ADDRESS = "0x7ccBebeb88696f9c8b061f1112Bb970158e29cA5" # # TODO Jellyswap on devnet

CHAIN_FLASHLOAN_TOKENS = {
"0x26841a0A5D958B128209F4ea9a1DD7E61558c330": "WSEI", #TODO confirm for Mainnet
"0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C": "USDC", #TODO confirm for Mainnet
}
# Add any exchanges unique to the chain here
CHAIN_SPECIFIC_EXCHANGES = []

class _ConfigNetworkTenderly(ConfigNetwork):
"""
Fastlane bot config -- network [Ethereum Tenderly]
Expand Down
1 change: 1 addition & 0 deletions fastlane_bot/config/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
NETWORK_CANTO = "canto"
NETWORK_FANTOM = "fantom"
NETWORK_LINEA = "linea"
NETWORK_SEI = "sei"
NETWORK_MANTLE = "mantle"
NETWORK_SCROLL = "scroll"
NETWORK_BSC = "binance_smart_chain"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exchange,address
3 changes: 3 additions & 0 deletions fastlane_bot/data/blockchain_data/sei/static_pool_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cid,strategy_id,last_updated,last_updated_block,descr,pair_name,exchange_name,fee,fee_float,address,anchor,tkn0_address,tkn1_address,tkn0_decimals,tkn1_decimals,exchange_id,tkn0_symbol,tkn1_symbol,timestamp,tkn0_balance,tkn1_balance,liquidity,sqrt_price_q96,tick,tick_spacing,exchange,pool_type,tkn0_weight,tkn1_weight,tkn2_address,tkn2_decimals,tkn2_symbol,tkn2_balance,tkn2_weight,tkn3_address,tkn3_decimals,tkn3_symbol,tkn3_balance,tkn3_weight,tkn4_address,tkn4_decimals,tkn4_symbol,tkn4_balance,tkn4_weight,tkn5_address,tkn5_decimals,tkn5_symbol,tkn5_balance,tkn5_weight,tkn6_address,tkn6_decimals,tkn6_symbol,tkn6_balance,tkn6_weight,tkn7_address,tkn7_decimals,tkn7_symbol,tkn7_balance,tkn7_weight
0x1422169ab760ea6994358267b7d3783e8e7fa55c6a74b365b3fd3d17cbf4c6f1,0,,2354,dragonswap 0x027D2E627209f1cebA52ADc8A5aFE9318459b44B/0x7b75109369ACb528d9fa989E227812a6589712b9,0x027D2E627209f1cebA52ADc8A5aFE9318459b44B/0x7b75109369ACb528d9fa989E227812a6589712b9,dragonswap,0.003,0.003,0x01A34Dfa104F020FEE739268679338169945D5B1,,0x027D2E627209f1cebA52ADc8A5aFE9318459b44B,0x7b75109369ACb528d9fa989E227812a6589712b9,18,18,3,WSEI,DSWAP,0,0,0,,,,,dragonswap,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
0xbfd9612b2cb8035908dff18c040f64de75999cefd1020b5ce8a2e533c2ecd5dc,0,,2354,dragonswap 0x027D2E627209f1cebA52ADc8A5aFE9318459b44B/0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C,0x027D2E627209f1cebA52ADc8A5aFE9318459b44B/0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C,dragonswap,0.003,0.003,0x85CB6BFd781e1f42f4E79Efb6bf1F1fEfE4E9732,,0x027D2E627209f1cebA52ADc8A5aFE9318459b44B,0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C,18,6,3,WSEI,USDC,0,0,0,,,,,dragonswap,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
5 changes: 5 additions & 0 deletions fastlane_bot/data/blockchain_data/sei/tokens.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
address,decimals,symbol
0x26841a0A5D958B128209F4ea9a1DD7E61558c330,18,WSEI
0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C,6,USDC
0x027D2E627209f1cebA52ADc8A5aFE9318459b44B,18,WSEI
0x7b75109369ACb528d9fa989E227812a6589712b9,18,DSWAP
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exchange,address
dragonswap,0x01A34Dfa104F020FEE739268679338169945D5B1
dragonswap,0x85CB6BFd781e1f42f4E79Efb6bf1F1fEfE4E9732
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exchange,address
2 changes: 2 additions & 0 deletions fastlane_bot/data/multichain_addresses.csv
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,5 @@ sushiswap_v3,thundercore,uniswap_v3,0xc35DADB65012eC5796536bD9864eD8773aBc74C4,0
pancakeswap_v3,zkevm,uniswap_v3,0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865,0x1b81D678ffb9C0263b24A97847620C99d213eB14,,,
pancakeswap_v3,zksync,uniswap_v3,0x1BB72E0CbbEA93c08f535fc7856E0338D7F7a8aB,0xD70C70AD87aa8D45b8D59600342FB3AEe76E3c68,,,
xfai_v0,linea,solidly_v2,0xa5136eAd459F0E61C99Cec70fe8F5C24cF3ecA26,0xD538be6e9026C13D130C9e17d509E69C8Bb0eF33,,222864,
carbon_v1,sei,carbon_v1,0x59f21012B2E9BA67ce6a7605E74F945D0D4C84EA,0x59f21012B2E9BA67ce6a7605E74F945D0D4C84EA,,17658678,
dragonswap,sei,uniswap_v2,0x5D370a6189F89603FaB67e9C68383e63F7B6A262,0x2346d3A6fb18Ff3ae590Ea31d9e41E6AB8c9f5EB,,1008775,
7 changes: 4 additions & 3 deletions fastlane_bot/helpers/poolandtokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
from dataclasses import dataclass
from typing import Dict, Any, List, Union

from arb_optimizer import ConstantProductCurve

from fastlane_bot.config import Config

# from fastlane_bot.config import SUPPORTED_EXCHANGES, CARBON_V1_NAME, UNISWAP_V3_NAME
from fastlane_bot.helpers.univ3calc import Univ3Calculator
from fastlane_bot.tools.cpc import ConstantProductCurve
sklbancor marked this conversation as resolved.
Show resolved Hide resolved
from fastlane_bot.utils import EncodedOrder


Expand Down Expand Up @@ -368,8 +369,8 @@ def _other_to_cpc(self) -> List[Any]:

# create a typed-dictionary of the arguments
typed_args = {
"x_tknb": tkn0_balance,
"y_tknq": tkn1_balance,
"liq_tknb": tkn0_balance,
"liq_tknq": tkn1_balance,
"pair": self.pair_name.replace(self.ConfigObj.NATIVE_GAS_TOKEN_ADDRESS, self.ConfigObj.WRAPPED_GAS_TOKEN_ADDRESS),
"fee": self.fee,
"cid": self.cid,
Expand Down
3 changes: 2 additions & 1 deletion fastlane_bot/helpers/routehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import eth_abi
import pandas as pd

from arb_optimizer.curves import T

from .tradeinstruction import TradeInstruction
from ..events.interface import Pool
from ..tools.cpc import T
from fastlane_bot.config.constants import AGNI_V3_NAME, BUTTER_V3_NAME, CLEOPATRA_V3_NAME, PANCAKESWAP_V3_NAME, \
ETHEREUM, METAVAULT_V3_NAME

Expand Down
3 changes: 0 additions & 3 deletions fastlane_bot/modes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
from _decimal import Decimal
import pandas as pd

from fastlane_bot.tools.cpc import T
from fastlane_bot.utils import num_format


class ArbitrageFinderBase:
"""
Expand Down
7 changes: 4 additions & 3 deletions fastlane_bot/modes/base_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import itertools
from typing import List, Tuple, Any, Union

from arb_optimizer import CurveContainer

from fastlane_bot.modes.base import ArbitrageFinderBase
from fastlane_bot.tools.cpc import CPCContainer
sklbancor marked this conversation as resolved.
Show resolved Hide resolved


class ArbitrageFinderPairwiseBase(ArbitrageFinderBase):
Expand All @@ -30,14 +31,14 @@ def find_arbitrage(self, candidates: List[Any] = None, ops: Tuple = None, best_p

@staticmethod
def get_combos(
CCm: CPCContainer, flashloan_tokens: List[str]
CCm: CurveContainer, flashloan_tokens: List[str]
) -> Tuple[List[Any], List[Any]]:
"""
Get combos for pairwise arbitrage

Parameters
----------
CCm : CPCContainer
CCm : CurveContainer
Container for all the curves
flashloan_tokens : list
List of flashloan tokens
Expand Down
3 changes: 2 additions & 1 deletion fastlane_bot/modes/base_triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

import pandas as pd

from arb_optimizer.curves import T

from fastlane_bot.modes.base import ArbitrageFinderBase
from fastlane_bot.tools.cpc import T


class ArbitrageFinderTriangleBase(ArbitrageFinderBase):
Expand Down
8 changes: 4 additions & 4 deletions fastlane_bot/modes/pairwise_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

import pandas as pd

from arb_optimizer import CurveContainer, PairOptimizer

from fastlane_bot.modes.base_pairwise import ArbitrageFinderPairwiseBase
from fastlane_bot.tools.cpc import CPCContainer
sklbancor marked this conversation as resolved.
Show resolved Hide resolved
from fastlane_bot.tools.optimizer import MargPOptimizer, PairOptimizer


class FindArbitrageMultiPairwise(ArbitrageFinderPairwiseBase):
Expand Down Expand Up @@ -161,12 +161,12 @@ def run_main_flow(
"""
Run main flow to find arbitrage.
"""
CC_cc = CPCContainer(curves)
CC_cc = CurveContainer(curves)
O = PairOptimizer(CC_cc)
pstart = {
tkn0: CC_cc.bypairs(f"{tkn0}/{tkn1}")[0].p
} # this intentionally selects the non_carbon curve
r = O.optimize(src_token, params=dict(pstart=pstart))
r = O.optimize(src_token)
profit_src = -r.result
trade_instructions_df = r.trade_instructions(O.TIF_DFAGGR)
return O, profit_src, r, trade_instructions_df
Expand Down
Loading
Loading