Skip to content

Commit

Permalink
pre-commit linting
Browse files Browse the repository at this point in the history
  • Loading branch information
heswithme committed Sep 25, 2024
1 parent 51ec201 commit 8beaf4b
Show file tree
Hide file tree
Showing 18 changed files with 258 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
max-line-length =100
# codestyles - numpy, google, pep8
# formatter - black
# instead of flake and black use ruff - same written in rust
# instead of flake and black use ruff - same written in rust
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ coverage.xml
*.pot

# Django stuff:
*.log
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
Expand Down Expand Up @@ -218,7 +218,7 @@ coverage.xml
*.pot

# Django stuff:
*.log
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
Expand Down Expand Up @@ -320,4 +320,4 @@ set_env.py
# test logs
all_tests.log
test_suite/test_reports/
wip_diary.mdd
wip_diary.mdd
2 changes: 1 addition & 1 deletion contracts/main/CurveStableSwapNGViews.vy
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_dy(i: int128, j: int128, dx: uint256, pool: address) -> uint256:
base_fee: uint256 = StableSwapNG(pool).fee()
fee_multiplier: uint256 = StableSwapNG(pool).offpeg_fee_multiplier()
fee: uint256 = self._dynamic_fee((xp[i] + x) / 2, (xp[j] + y) / 2, base_fee, fee_multiplier) * dy / FEE_DENOMINATOR

return (dy - fee) * PRECISION / rates[j]


Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ERC20Rebasing.vy
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def transfer(_to: address, _value: uint256) -> bool:
def transferFrom(_from: address, _to: address, _value: uint256) -> bool:
_shares: uint256 = self._get_shares_by_coins(_value)
_shares = min(self.shares[_from], _shares)

if _shares > 0:
# only rebase on nonzero transfers
self._rebase()
Expand Down
418 changes: 199 additions & 219 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions scripts/deploy_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ def set_contract_pragma(contract_file, network) -> boa.contracts.vyper.vyper_con

if is_shanghai_chain and "# pragma evm-version paris" in source:
logger.log("Replacing EVM version to Shanghai ...")
new_source = source.replace("# pragma evm-version paris\n", "# pragma evm-version shanghai\n")
new_source = source.replace(
"# pragma evm-version paris\n", "# pragma evm-version shanghai\n"
)
elif not is_shanghai_chain and "# pragma evm-version shanghai" in source:
logger.log("Replacing EVM version to Paris ...")
new_source = source.replace("# pragma evm-version shanghai\n", "# pragma evm-version paris\n")
new_source = source.replace(
"# pragma evm-version shanghai\n", "# pragma evm-version paris\n"
)
else: # all looks good ...
new_source = source

Expand Down Expand Up @@ -61,7 +65,9 @@ def check_and_deploy(contract_obj, contract_designation, network, blueprint: boo
contract = contract_obj.deploy(*args)
if args:
constructor_args = encode(["address", "address"], args)
logger.log(f"Constructor arguments for {contract_designation}: {constructor_args.hex()}")
logger.log(
f"Constructor arguments for {contract_designation}: {constructor_args.hex()}"
)
else:
if "zksync:mainnet" in network:
if "CurveStableSwapNG.vy" == contract_name:
Expand Down Expand Up @@ -108,7 +114,9 @@ def check_and_deploy(contract_obj, contract_designation, network, blueprint: boo

logger.log(f"Deployed! At: {contract.address}.")
else:
logger.log(f"Deployed {contract_designation} contract exists. Using {deployed_contract} ...")
logger.log(
f"Deployed {contract_designation} contract exists. Using {deployed_contract} ..."
)
contract = contract_obj.at(deployed_contract)

return contract
Expand Down Expand Up @@ -162,7 +170,9 @@ def deploy_infra(network, url, account, fork=False):
meta_blueprint = check_and_deploy(meta_contract_obj, "meta_amm", network, blueprint=True)

# Factory:
factory_contract_obj = set_contract_pragma("./contracts/main/CurveStableSwapFactoryNG.vy", network)
factory_contract_obj = set_contract_pragma(
"./contracts/main/CurveStableSwapFactoryNG.vy", network
)
args = [fee_receiver, deploy_utils.FIDDYDEPLOYER]
factory = check_and_deploy(factory_contract_obj, "factory", network, False, args)

Expand Down
8 changes: 6 additions & 2 deletions scripts/deploy_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,12 @@ def deploy_pool_and_gauge(network, url, account, pool_type, fork):

def main():
fork = False
deploy_pool_and_gauge("ethereum:mainnet", os.environ["RPC_ETHEREUM"], "FIDDYDEPLOYER", "plain", fork)
deploy_pool_and_gauge("ethereum:mainnet", "http://localhost:9090/", "FIDDYDEPLOYER", "meta", fork)
deploy_pool_and_gauge(
"ethereum:mainnet", os.environ["RPC_ETHEREUM"], "FIDDYDEPLOYER", "plain", fork
)
deploy_pool_and_gauge(
"ethereum:mainnet", "http://localhost:9090/", "FIDDYDEPLOYER", "meta", fork
)


if __name__ == "__main__":
Expand Down
19 changes: 15 additions & 4 deletions scripts/set_up_base_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,20 @@ class BasePoolSettings:
BasePoolSettings( # 2pool
pool="0x7f90122BF0700F9E7e1F688fe926940E8839F353",
lp_token="0x7f90122BF0700F9E7e1F688fe926940E8839F353",
coins=["0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],
coins=[
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
],
asset_types=[0, 0],
n_coins=2,
),
BasePoolSettings( # fraxbp
pool="0xC9B8a3FDECB9D5b218d02555a8Baf332E5B740d5",
lp_token="0xC9B8a3FDECB9D5b218d02555a8Baf332E5B740d5",
coins=["0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F", "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"],
coins=[
"0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F",
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
],
asset_types=[0, 0],
n_coins=2,
),
Expand All @@ -102,7 +108,10 @@ class BasePoolSettings:
BasePoolSettings( # fraxbp
pool="0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7",
lp_token="0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7",
coins=["0x2E3D870790dC77A83DD1d18184Acc7439A53f475", "0x7F5c764cBc14f9669B88837ca1490cCa17c31607"],
coins=[
"0x2E3D870790dC77A83DD1d18184Acc7439A53f475",
"0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
],
asset_types=[0, 0],
n_coins=2,
),
Expand Down Expand Up @@ -147,7 +156,9 @@ def set_up_base_pools(network, url, account, fork: bool = False):
factory.add_base_pool(data.pool, data.lp_token, data.asset_types, data.n_coins)
logger.log(f"Added {data.pool} to factory {factory_address} on {network}.")
else:
logger.log(f"{data.pool} is already configured as a base pool in factory {factory_address}.")
logger.log(
f"{data.pool} is already configured as a base pool in factory {factory_address}."
)

assert factory.base_pool_data(data.pool)[0] == data.lp_token

Expand Down
4 changes: 3 additions & 1 deletion scripts/vote_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def prepare_evm_script(target: Dict, actions: List[Tuple]) -> str:
contract = ape.Contract(address)
fn = getattr(contract, fn_name)
calldata = fn.as_transaction(*args, sender=agent.address, gas_price=0).data
agent_calldata = agent.execute.as_transaction(address, 0, calldata, sender=voting, gas_price=0).data
agent_calldata = agent.execute.as_transaction(
address, 0, calldata, sender=voting, gas_price=0
).data
length = hex(len(agent_calldata.hex()) // 2)[2:].zfill(8)
evm_script = f"{evm_script}{agent.address[2:]}{length}{agent_calldata.hex()}"

Expand Down
3 changes: 2 additions & 1 deletion test_suite/debug_script.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import sys

import pytest


def is_debug_mode():
return sys.gettrace() is not None
Expand Down
1 change: 1 addition & 0 deletions test_suite/generate_report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re

import pandas as pd
from tabulate import tabulate

Expand Down
2 changes: 1 addition & 1 deletion test_suite/initial_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
| 32 | token/test_get_D | 1 | 0 | 0 | 0 | 0 | 11 | 12 | 1.56 |
| 0 | factory/test_factory_add_pools | 6 | 0 | 0 | 0 | 0 | 11 | 6 | 3.62 |
| 2 | factory/test_factory_forked | 1 | 0 | 1 | 0 | 0 | 11 | 1 | 7.82 |
+----+--------------------------------------------------+--------+--------+----------+--------+-----------+------------+---------+--------+
+----+--------------------------------------------------+--------+--------+----------+--------+-----------+------------+---------+--------+
2 changes: 1 addition & 1 deletion test_suite/latest_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
| 2 | factory/test_factory_forked | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 7.4 |
| 1 | factory/test_factory_basic | 126 | 0 | 0 | 0 | 0 | 0 | 126 | 4.75 |
| 0 | factory/test_factory_add_pools | 20 | 0 | 0 | 0 | 0 | 0 | 20 | 7.14 |
+----+--------------------------------------------------+--------+--------+----------+--------+-----------+------------+---------+---------+
+----+--------------------------------------------------+--------+--------+----------+--------+-----------+------------+---------+---------+
5 changes: 1 addition & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


def pytest_generate_tests(metafunc):

# some targeted debug
# if metafunc.function.__name__ == "test_price_ema_remove_imbalance":
# print("Debugging...")
Expand Down Expand Up @@ -60,9 +59,7 @@ def pytest_generate_tests(metafunc):

# Parametrize both pool_type and metapool_token_type together
metafunc.parametrize(
("pool_type", "metapool_token_type"),
combined_params,
ids=combined_ids,
("pool_type", "metapool_token_type"), combined_params, ids=combined_ids
)
elif "pool_type" in metafunc.fixturenames:
# or parametrize pool_type only
Expand Down
3 changes: 1 addition & 2 deletions tests/fixtures/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import pytest
from eth_account.account import Account, LocalAccount

from tests.utils.tokens import mint_for_testing

from tests.constants import POOL_TYPES
from tests.fixtures.constants import INITIAL_AMOUNT
from tests.utils.tokens import mint_for_testing


@pytest.fixture()
Expand Down
3 changes: 2 additions & 1 deletion tests/pools/exchange/test_exchange_reverts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time

import boa
import pytest
import time

pytestmark = pytest.mark.usefixtures("initial_setup")

Expand Down
4 changes: 2 additions & 2 deletions tests/pools/liquidity/test_add_liquidity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re

import boa
import pytest
import re

from tests.fixtures.constants import INITIAL_AMOUNT
from tests.utils.transactions import call_returning_result_and_logs
Expand Down Expand Up @@ -69,7 +70,6 @@ def test_add_one_coin(
metapool_token_type,
idx,
):

amounts = [0] * len(pool_tokens)
amounts[idx] = deposit_amounts[idx]

Expand Down
6 changes: 3 additions & 3 deletions tests/utils/transactions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Any

from boa.contracts.vyper.event import Event
from boa.contracts.vyper.vyper_contract import VyperContract, VyperFunction

# from boa.vyper.contract import VyperContract, VyperFunction
# from boa.vyper.event import Event

from boa.contracts.vyper.vyper_contract import VyperContract, VyperFunction
from boa.contracts.vyper.event import Event


def call_returning_result_and_logs_old(
# previous function, commits by Oleg 14 months ago
Expand Down

0 comments on commit 8beaf4b

Please sign in to comment.