Skip to content

Commit

Permalink
Merge pull request #639 from bancorprotocol/sei-release-candidate
Browse files Browse the repository at this point in the history
Sei release candidate
  • Loading branch information
zavelevsky authored May 21, 2024
2 parents 815ae61 + 7444e5e commit e2955cf
Show file tree
Hide file tree
Showing 72 changed files with 1,630 additions and 554 deletions.
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ logs/*
missing_tokens_df.csv
tokens_and_fee_df.csv
fastlane_bot/tests/nbtest/*

.python-version
2 changes: 2 additions & 0 deletions fastlane_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
from .modes.pairwise_multi_pol import FindArbitrageMultiPairwisePol
from .modes.pairwise_single import FindArbitrageSinglePairwise
from .modes.triangle_multi import ArbitrageFinderTriangleMulti
from .modes.triangle_multi_complete import ArbitrageFinderTriangleMultiComplete
from .modes.triangle_single import ArbitrageFinderTriangleSingle
from .modes.triangle_bancor_v3_two_hop import ArbitrageFinderTriangleBancor3TwoHop
from .utils import num_format
Expand Down Expand Up @@ -109,6 +110,7 @@ class CarbonBot:
"b3_two_hop": ArbitrageFinderTriangleBancor3TwoHop,
"multi_pairwise_pol": FindArbitrageMultiPairwisePol,
"multi_pairwise_all": FindArbitrageMultiPairwiseAll,
"multi_triangle_complete": ArbitrageFinderTriangleMultiComplete,
}

class NoArbAvailable(Exception):
Expand Down
16 changes: 16 additions & 0 deletions fastlane_bot/config/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
}

ETHEREUM = "ethereum"
UNISWAP_V2_NAME = "uniswap_v2"
UNISWAP_V3_NAME = "uniswap_v3"
PANCAKESWAP_V2_NAME = "pancakeswap_v2"
PANCAKESWAP_V3_NAME = "pancakeswap_v3"
BUTTER_V3_NAME = "butter_v3"
Expand All @@ -31,3 +33,17 @@
ECHODEX_V3_NAME = "echodex_v3"
SECTA_V3_NAME = "secta_v3"
METAVAULT_V3_NAME = "metavault_v3"
ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"

BLOCK_CHUNK_SIZE_MAP = {
"ethereum": 0,
"polygon": 0,
"polygon_zkevm": 0,
"arbitrum_one": 0,
"optimism": 0,
"coinbase_base": 0,
"fantom": 5000,
"mantle": 0,
"linea": 0,
"sei": 0,
}
7 changes: 4 additions & 3 deletions fastlane_bot/config/multicaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
All rights reserved.
Licensed under MIT.
"""
from typing import Callable, Any, List, Dict
from typing import Any, List, Dict

from eth_abi import decode
from web3.contract.contract import ContractFunction

from fastlane_bot.data.abi import MULTICALL_ABI

Expand Down Expand Up @@ -45,10 +46,10 @@ class MultiCaller:

def __init__(self, web3: Any, multicall_contract_address: str):
self.multicall_contract = web3.eth.contract(abi=MULTICALL_ABI, address=multicall_contract_address)
self.contract_calls: List[Callable] = []
self.contract_calls: List[ContractFunction] = []
self.output_types_list: List[List[str]] = []

def add_call(self, call: Callable):
def add_call(self, call: ContractFunction):
self.contract_calls.append({'target': call.address, 'callData': call._encode_transaction_data()})
self.output_types_list.append([collapse_if_tuple(item) for item in call.abi['outputs']])

Expand Down
42 changes: 40 additions & 2 deletions fastlane_bot/config/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ class ConfigNetwork(ConfigBase):
NETWORK_FANTOM = S.NETWORK_FANTOM
NETWORK_MANTLE = S.NETWORK_MANTLE
NETWORK_LINEA = S.NETWORK_LINEA
NETWORK_SEI = S.NETWORK_SEI

# FLAGS
#######################################################################################
GAS_TKN_IN_FLASHLOAN_TOKENS = None
IS_NO_FLASHLOAN_AVAILABLE = False

# HOOKS
Expand Down Expand Up @@ -317,7 +317,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 @@ -783,6 +785,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 = "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 = "0x57eE725BEeB991c70c53f9642f36755EC6eb2139" # 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 = {
"0x57eE725BEeB991c70c53f9642f36755EC6eb2139": "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
63 changes: 63 additions & 0 deletions fastlane_bot/data/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@
"name": "PairCreated",
"anonymous": False,
"inputs": [{"indexed": True, "internalType": "address", "name": "token0", "type": "address"}, {"indexed": True, "internalType": "address", "name": "token1", "type": "address"}, {"indexed": False, "internalType": "address", "name": "pair", "type": "address"}, {"indexed": False, "internalType": "uint256", "name": "", "type": "uint256"}]
},
{
"type": "function",
"name": "getPair",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "", "type": "address"}, {"internalType": "address", "name": "", "type": "address"}],
"outputs": [{"internalType": "address", "name": "", "type": "address"}]
}
]

Expand All @@ -173,6 +180,13 @@
"name": "PoolCreated",
"anonymous": False,
"inputs": [{"indexed": True, "internalType": "address", "name": "token0", "type": "address"}, {"indexed": True, "internalType": "address", "name": "token1", "type": "address"}, {"indexed": True, "internalType": "uint24", "name": "fee", "type": "uint24"}, {"indexed": False, "internalType": "int24", "name": "tickSpacing", "type": "int24"}, {"indexed": False, "internalType": "address", "name": "pool", "type": "address"}]
},
{
"type": "function",
"name": "getPool",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "", "type": "address"}, {"internalType": "address", "name": "", "type": "address"}, {"internalType": "uint24", "name": "", "type": "uint24"}],
"outputs": [{"internalType": "address", "name": "", "type": "address"}],
}
]

Expand All @@ -189,6 +203,13 @@
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "pool", "type": "address"}, {"internalType": "bool", "name": "_stable", "type": "bool"}],
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}]
},
{
"type": "function",
"name": "getPool",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "tokenA", "type": "address"}, {"internalType": "address", "name": "tokenB", "type": "address"}, {"internalType": "bool", "name": "stable", "type": "bool"}],
"outputs": [{"internalType": "address", "name": "", "type": "address"}],
}
]

Expand All @@ -205,6 +226,13 @@
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "_pair", "type": "address"}],
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}]
},
{
"type": "function",
"name": "getPair",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "", "type": "address"}, {"internalType": "address", "name": "", "type": "address"}, {"internalType": "bool", "name": "", "type": "bool"}],
"outputs": [{"internalType": "address", "name": "", "type": "address"}]
}
]

Expand All @@ -221,6 +249,13 @@
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "_pair", "type": "address"}],
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}]
},
{
"type": "function",
"name": "getPair",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "", "type": "address"}, {"internalType": "address", "name": "", "type": "address"}, {"internalType": "bool", "name": "", "type": "bool"}],
"outputs": [{"internalType": "address", "name": "", "type": "address"}]
}
]

Expand All @@ -237,6 +272,13 @@
"stateMutability": "view",
"inputs": [{"type": "address", "name": "_pair", "internalType": "address"}, {"type": "bool", "name": "_stable", "internalType": "bool"}],
"outputs": [{"type": "uint256", "name": "", "internalType": "uint256"}]
},
{
"type": "function",
"name": "getPair",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "", "type": "address"}, {"internalType": "address", "name": "", "type": "address"}, {"internalType": "bool", "name": "", "type": "bool"}],
"outputs": [{"internalType": "address", "name": "", "type": "address"}]
}
]

Expand All @@ -253,6 +295,13 @@
"stateMutability": "view",
"inputs": [{"internalType": "bool", "name": "_stable", "type": "bool"}],
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}]
},
{
"type": "function",
"name": "getPair",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "", "type": "address"}, {"internalType": "address", "name": "", "type": "address"}, {"internalType": "bool", "name": "", "type": "bool"}],
"outputs": [{"internalType": "address", "name": "", "type": "address"}]
}
]

Expand All @@ -269,6 +318,13 @@
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "_pool", "type": "address"}],
"outputs": [{"internalType": "uint256", "name": "fee", "type": "uint256"}]
},
{
"type": "function",
"name": "getPair",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "", "type": "address"}, {"internalType": "address", "name": "", "type": "address"}, {"internalType": "bool", "name": "", "type": "bool"}],
"outputs": [{"internalType": "address", "name": "", "type": "address"}]
}
]

Expand All @@ -285,6 +341,13 @@
"stateMutability": "view",
"inputs": [],
"outputs": [{"internalType": "address", "name": "", "type": "address"}]
},
{
"type": "function",
"name": "getPool",
"stateMutability": "view",
"inputs": [{"internalType": "address", "name": "_token", "type": "address"}],
"outputs": [{"internalType": "address", "name": "pool", "type": "address"}],
}
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exchange,address
4 changes: 4 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,4 @@
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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
0xe3aead757d877a15316e4896d5c5ab7639adbcba1ff76e3434b4e0af90f6225e,0,,2354,dragonswap 0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C/0xF983afa393199D6902a1Dd04f8E93465915ffD8B,0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C/0xF983afa393199D6902a1Dd04f8E93465915ffD8B,dragonswap,0.003,0.003,0x72A788B0A83e18ce1757171321E82c03e4351498,,0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C,0xF983afa393199D6902a1Dd04f8E93465915ffD8B,6,6,3,USDC,USDT,0,0,0,,,,,dragonswap,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
9 changes: 9 additions & 0 deletions fastlane_bot/data/blockchain_data/sei/tokens.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
address,decimals,symbol
0x26841a0A5D958B128209F4ea9a1DD7E61558c330,18,WSEI
0xace5f7Ea93439Af39b46d2748fA1aC19951c8d7C,6,USDC
0x027D2E627209f1cebA52ADc8A5aFE9318459b44B,18,WSEI
0x7b75109369ACb528d9fa989E227812a6589712b9,18,DSWAP
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE,18,SEI
0x9e7A8e558Ce582511f4104465a886b7bEfBC146b,18,JLY
0x57eE725BEeB991c70c53f9642f36755EC6eb2139,18,WSEI
0xF983afa393199D6902a1Dd04f8E93465915ffD8B,6,USDT
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exchange,address
dragonswap,0x01A34Dfa104F020FEE739268679338169945D5B1
dragonswap,0x85CB6BFd781e1f42f4E79Efb6bf1F1fEfE4E9732
dragonswap,0x38BcEBb9A3fbF05B0Ab7ce9b485c9669578409fE
dragonswap,0x72A788B0A83e18ce1757171321E82c03e4351498
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exchange,address
4 changes: 4 additions & 0 deletions fastlane_bot/data/multichain_addresses.csv
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@ 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,0.003,1008775,
jellyswap,sei,balancer,BALANCER_VAULT_ADDRESS,0x7ccBebeb88696f9c8b061f1112Bb970158e29cA5,0,222832,
uniswap_v3,sei,uniswap_v3,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,,1,
9 changes: 5 additions & 4 deletions fastlane_bot/events/async_event_update_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from fastlane_bot.events.async_utils import get_contract_chunks
from fastlane_bot.events.utils import update_pools_from_events
from fastlane_bot.events.pools.utils import get_pool_cid
from .interfaces.event import Event

nest_asyncio.apply()

Expand Down Expand Up @@ -89,15 +90,15 @@ async def _get_missing_tkns(mgr: Any, c: List[Dict[str, Any]]) -> pd.DataFrame:
return pd.concat(vals)


async def _get_token_and_fee(mgr: Any, exchange_name: str, ex: Any, address: str, contract: AsyncContract, event: Any):
async def _get_token_and_fee(mgr: Any, exchange_name: str, ex: Any, address: str, contract: AsyncContract, event: Event):
"""
This function uses the exchange object to get the tokens and fee for a given pool.
Args:
ex(Any): The exchange object
address(str): The pool address
contract(AsyncContract): The contract object
event(Any): The event object
event(Event): The event object
Returns:
The tokens and fee info for the pool
Expand All @@ -119,7 +120,7 @@ async def _get_token_and_fee(mgr: Any, exchange_name: str, ex: Any, address: str
elif tkn1 == mgr.cfg.BNT_ADDRESS:
tkn0 = connector_token

strategy_id = 0 if not ex.is_carbon_v1_fork else str(event["args"]["id"])
strategy_id = 0 if not ex.is_carbon_v1_fork else str(event.args["id"])
pool_info = {
"exchange_name": exchange_name,
"address": address,
Expand Down Expand Up @@ -319,7 +320,7 @@ def _get_pool_contracts(mgr: Any) -> List[Dict[str, Any]]:
exchange_name = mgr.exchange_name_from_event(event)
ex = mgr.exchanges[exchange_name]
abi = ex.get_abi()
address = event["address"]
address = event.address
contracts.append(
{
"exchange_name": exchange_name,
Expand Down
Loading

0 comments on commit e2955cf

Please sign in to comment.