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

Remove MultiProviderContractWrapper #571

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 1 deletion fastlane_bot/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

- Constants (``constants`` and ``selectors``; various constants)
- ``MultiCaller`` and related (``multicaller``; TODO: what is this?)
- ``MultiProviderContractWrapper`` (``multiprovided``; TODO: what is this?)
- ``NetworkBase`` and ``EthereumNetwork`` (``connect``; network/chain connection code TODO: details)
- ``Cloaker`` (``cloaker``; deprecated)

Expand Down
3 changes: 1 addition & 2 deletions fastlane_bot/config/multicaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from eth_abi import decode
from web3 import Web3

from fastlane_bot.config.multiprovider import MultiProviderContractWrapper
from fastlane_bot.data.abi import MULTICALL_ABI


Expand Down Expand Up @@ -112,7 +111,7 @@ class MultiCaller(ContextManager):
__VERSION__ = "0.0.2"


def __init__(self, contract: MultiProviderContractWrapper or web3.contract.Contract,
def __init__(self, contract: web3.contract.Contract,
web3: Web3,
block_identifier: Any = 'latest', multicall_address = "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696"):
self._contract_calls: List[Callable] = []
Expand Down
30 changes: 0 additions & 30 deletions fastlane_bot/config/multiprovider.py

This file was deleted.

3 changes: 0 additions & 3 deletions fastlane_bot/events/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from fastlane_bot import Config
from fastlane_bot.bot import CarbonBot
from fastlane_bot.config.multiprovider import MultiProviderContractWrapper
from fastlane_bot.data.abi import FAST_LANE_CONTRACT_ABI
from fastlane_bot.exceptions import ReadOnlyException
from fastlane_bot.events.interface import QueryInterface
Expand Down Expand Up @@ -939,8 +938,6 @@ def update_pools_from_contracts(
The number of jobs to run in parallel.
rows_to_update : List[int]
A list of rows to update.
multicall_contract : MultiProviderContractWrapper or web3.contract.Contract
The multicall contract.
current_block : int, optional
The current block number, by default None

Expand Down
26 changes: 7 additions & 19 deletions fastlane_bot/tests/test_899_CustomMulticall.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
# ------------------------------------------------------------



import json

from fastlane_bot.config.multiprovider import MultiProviderContractWrapper
from fastlane_bot.data.abi import CARBON_CONTROLLER_ABI
import os
from unittest.mock import Mock, patch
Expand All @@ -21,8 +17,7 @@
from fastlane_bot.config.multicaller import MultiCaller
from fastlane_bot.config.multicaller import ContractMethodWrapper


import pytest
from web3 import Web3

print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(MultiCaller))
print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(ContractMethodWrapper))
Expand All @@ -36,15 +31,8 @@
require("3.0", __VERSION__)

WEB3_ALCHEMY_PROJECT_ID = os.environ.get("WEB3_ALCHEMY_PROJECT_ID")

CONTRACT_ABI = CARBON_CONTROLLER_ABI
RPC_URL = f"https://eth-mainnet.alchemyapi.io/v2/{WEB3_ALCHEMY_PROJECT_ID}"
CARBON_CONTROLLER_ADDRESS = "0xC537e898CD774e2dCBa3B14Ea6f34C93d5eA45e1"
CONTRACT_ADDRESS = CARBON_CONTROLLER_ADDRESS

providers = {
"mainnet": f"https://eth-mainnet.alchemyapi.io/v2/{WEB3_ALCHEMY_PROJECT_ID}",
"tenderly": "https://rpc.tenderly.co/fork/5f70ee18-8d2f-40d7-8131-58d0c8ff4736",
}

class MockWeb3:
class HTTPProvider:
Expand Down Expand Up @@ -93,21 +81,21 @@ def decode_abi(self):

start_time = time.time()

contract = MultiProviderContractWrapper(CONTRACT_ABI, CONTRACT_ADDRESS, providers)
w3 = Web3(Web3.HTTPProvider(RPC_URL, request_kwargs={'timeout': 60}))
contract = w3.eth.contract(address=CARBON_CONTROLLER_ADDRESS, abi=CARBON_CONTROLLER_ABI)

mainnet_pairs = contract.mainnet.functions.pairs().call()
tenderly_pairs = contract.tenderly.functions.pairs().call()
mainnet_pairs = contract.caller.pairs()

if len(mainnet_pairs) > 10:
mainnet_pairs = mainnet_pairs[:10]

pair_fees_without_multicall = [contract.mainnet.functions.pairTradingFeePPM(pair[0], pair[1]).call() for pair in mainnet_pairs]
pair_fees_without_multicall = [contract.caller.pairTradingFeePPM(pair[0], pair[1]) for pair in mainnet_pairs]

pair_fees_time_without_multicall = time.time() - start_time

start_time = time.time()

strats_by_pair_without_multicall = [contract.mainnet.functions.strategiesByPair(pair[0], pair[1], 0, 5000).call() for pair in mainnet_pairs]
strats_by_pair_without_multicall = [contract.caller.strategiesByPair(pair[0], pair[1], 0, 5000) for pair in mainnet_pairs]

strats_by_pair_time_without_multicall = time.time() - start_time

Expand Down
Loading