From 26e823b9725f8eb505fd2c62a023351e9c0d1937 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:44:40 +0000 Subject: [PATCH 1/9] Initial plan From 39d857a388a9b707b5acea107b6716b84ff8c8ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:49:00 +0000 Subject: [PATCH 2/9] Add support for tokens with different decimals (fixes USDC with 9 decimals) Co-authored-by: trizin <25263018+trizin@users.noreply.github.com> --- df_py/util/base18.py | 12 +++++------ df_py/util/dispense.py | 7 +++++-- df_py/util/test/test_base18.py | 21 ++++++++++++++++++++ df_py/util/test/test_dispense.py | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 8 deletions(-) diff --git a/df_py/util/base18.py b/df_py/util/base18.py index bc81a8168..f48d344d9 100644 --- a/df_py/util/base18.py +++ b/df_py/util/base18.py @@ -2,15 +2,15 @@ @enforce_types -def from_wei(amt_base: int) -> float: - return float(amt_base / 1e18) +def from_wei(amt_base: int, decimals: int = 18) -> float: + return float(amt_base / (10 ** decimals)) @enforce_types -def to_wei(amt_eth) -> int: - return int(amt_eth * 1e18) +def to_wei(amt_eth, decimals: int = 18) -> int: + return int(amt_eth * (10 ** decimals)) @enforce_types -def str_with_wei(amt_wei: int) -> str: - return f"{from_wei(amt_wei)} ({amt_wei} wei)" +def str_with_wei(amt_wei: int, decimals: int = 18) -> str: + return f"{from_wei(amt_wei, decimals)} ({amt_wei} wei)" diff --git a/df_py/util/dispense.py b/df_py/util/dispense.py index 407fb168e..a2dc1fe8a 100644 --- a/df_py/util/dispense.py +++ b/df_py/util/dispense.py @@ -53,12 +53,14 @@ def dispense( multisigaddr = chain_id_to_multisig_addr(web3.eth.chain_id) df_rewards = ContractBase(web3, "DFRewards", dfrewards_addr) TOK = ContractBase(web3, "OceanToken", token_addr) + token_decimals = TOK.decimals() + logger.info(f" Token decimals: {token_decimals}") logger.info(f" Total amount: {sum(rewards.values())} {TOK.symbol()}") # checksum addresses rewards = {web3.to_checksum_address(k): v for k, v in rewards.items()} to_addrs = list(rewards.keys()) - values = [to_wei(rewards[to_addr]) for to_addr in to_addrs] + values = [to_wei(rewards[to_addr], token_decimals) for to_addr in to_addrs] N = len(rewards) sts = list(range(N))[::batch_size] # send in batches to avoid gas issues @@ -140,7 +142,8 @@ def approveAmt(amt): @enforce_types def multisig_transfer_tokens(web3, ocean, receiver_address, amount): - amount_wei = to_wei(amount) + token_decimals = ocean.decimals() + amount_wei = to_wei(amount, token_decimals) transfer_data = ocean.contract.encodeABI( fn_name="transfer", args=[receiver_address, amount_wei] ) diff --git a/df_py/util/test/test_base18.py b/df_py/util/test/test_base18.py index be0cd3791..d01cf93be 100644 --- a/df_py/util/test/test_base18.py +++ b/df_py/util/test/test_base18.py @@ -16,3 +16,24 @@ def test_wei(): assert to_wei(0.1234) == 0.1234 * 1e18 and type(to_wei(0.1234)) == int assert str_with_wei(int(12.34 * 1e18)) == "12.34 (12340000000000000000 wei)" + + +def test_wei_with_custom_decimals(): + # Test with 9 decimals (USDC) + assert from_wei(int(1234 * 1e9), decimals=9) == 1234 + assert from_wei(int(12.34 * 1e9), decimals=9) == 12.34 + assert from_wei(int(0.1234 * 1e9), decimals=9) == 0.1234 + + assert to_wei(1234, decimals=9) == 1234 * 1e9 and type(to_wei(1234, decimals=9)) == int + assert to_wei(12.34, decimals=9) == 12.34 * 1e9 and type(to_wei(12.34, decimals=9)) == int + assert to_wei(0.1234, decimals=9) == 0.1234 * 1e9 and type(to_wei(0.1234, decimals=9)) == int + + assert str_with_wei(int(12.34 * 1e9), decimals=9) == "12.34 (12340000000 wei)" + + # Test with 6 decimals (USDT) + assert from_wei(int(100 * 1e6), decimals=6) == 100 + assert to_wei(100, decimals=6) == 100 * 1e6 and type(to_wei(100, decimals=6)) == int + + # Test with 8 decimals (WBTC) + assert from_wei(int(50 * 1e8), decimals=8) == 50 + assert to_wei(50, decimals=8) == 50 * 1e8 and type(to_wei(50, decimals=8)) == int diff --git a/df_py/util/test/test_dispense.py b/df_py/util/test/test_dispense.py index 8d9f89a92..950266017 100644 --- a/df_py/util/test/test_dispense.py +++ b/df_py/util/test/test_dispense.py @@ -106,6 +106,40 @@ def test_multisig_transfer_tokens(w3): assert mock.call_count == 1 +@enforce_types +def test_dispense_with_9_decimals(w3): + # Create a token with 9 decimals (like USDC on Sapphire) + token = ContractBase( + w3, "OceanToken", constructor_args=["USDC", "USDC", 9, to_wei(100e18, decimals=9)] + ) + + df_rewards = ContractBase(w3, "DFRewards", constructor_args=[]) + df_strategy = ContractBase( + w3, "DFStrategyV1", constructor_args=[df_rewards.address] + ) + + rewards_at_chain = {a1.address: 10.5, a2.address: 20.5, a3.address: 30.5} + dispense.dispense( + w3, + rewards_at_chain, + dfrewards_addr=df_rewards.address, + token_addr=token.address, + from_account=accounts[0], + ) + + # a1 claims for itself - should receive rewards with 9 decimals + bal_before = from_wei(token.balanceOf(a1), decimals=9) + df_strategy.claim([token.address], {"from": accounts[1]}) + bal_after = from_wei(token.balanceOf(a1), decimals=9) + assert (bal_after - bal_before) == pytest.approx(10.5) + + # a3 claims + bal_before = from_wei(token.balanceOf(a3), decimals=9) + df_rewards.claimFor(a3, token.address, {"from": accounts[8]}) + bal_after = from_wei(token.balanceOf(a3), decimals=9) + assert (bal_after - bal_before) == pytest.approx(30.5) + + @enforce_types def setup_function(): oceantestutil.fill_accounts_with_OCEAN(accounts) From 3461e4da552e5fc294089bbb5b37b07030ce5225 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:49:43 +0000 Subject: [PATCH 3/9] Fix code formatting with black Co-authored-by: trizin <25263018+trizin@users.noreply.github.com> --- df_py/util/base18.py | 4 ++-- df_py/util/test/test_base18.py | 14 +++++++++++--- df_py/util/test/test_dispense.py | 4 +++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/df_py/util/base18.py b/df_py/util/base18.py index f48d344d9..cf2c5956a 100644 --- a/df_py/util/base18.py +++ b/df_py/util/base18.py @@ -3,12 +3,12 @@ @enforce_types def from_wei(amt_base: int, decimals: int = 18) -> float: - return float(amt_base / (10 ** decimals)) + return float(amt_base / (10**decimals)) @enforce_types def to_wei(amt_eth, decimals: int = 18) -> int: - return int(amt_eth * (10 ** decimals)) + return int(amt_eth * (10**decimals)) @enforce_types diff --git a/df_py/util/test/test_base18.py b/df_py/util/test/test_base18.py index d01cf93be..ba650829c 100644 --- a/df_py/util/test/test_base18.py +++ b/df_py/util/test/test_base18.py @@ -24,9 +24,17 @@ def test_wei_with_custom_decimals(): assert from_wei(int(12.34 * 1e9), decimals=9) == 12.34 assert from_wei(int(0.1234 * 1e9), decimals=9) == 0.1234 - assert to_wei(1234, decimals=9) == 1234 * 1e9 and type(to_wei(1234, decimals=9)) == int - assert to_wei(12.34, decimals=9) == 12.34 * 1e9 and type(to_wei(12.34, decimals=9)) == int - assert to_wei(0.1234, decimals=9) == 0.1234 * 1e9 and type(to_wei(0.1234, decimals=9)) == int + assert ( + to_wei(1234, decimals=9) == 1234 * 1e9 and type(to_wei(1234, decimals=9)) == int + ) + assert ( + to_wei(12.34, decimals=9) == 12.34 * 1e9 + and type(to_wei(12.34, decimals=9)) == int + ) + assert ( + to_wei(0.1234, decimals=9) == 0.1234 * 1e9 + and type(to_wei(0.1234, decimals=9)) == int + ) assert str_with_wei(int(12.34 * 1e9), decimals=9) == "12.34 (12340000000 wei)" diff --git a/df_py/util/test/test_dispense.py b/df_py/util/test/test_dispense.py index 950266017..1f5d637ae 100644 --- a/df_py/util/test/test_dispense.py +++ b/df_py/util/test/test_dispense.py @@ -110,7 +110,9 @@ def test_multisig_transfer_tokens(w3): def test_dispense_with_9_decimals(w3): # Create a token with 9 decimals (like USDC on Sapphire) token = ContractBase( - w3, "OceanToken", constructor_args=["USDC", "USDC", 9, to_wei(100e18, decimals=9)] + w3, + "OceanToken", + constructor_args=["USDC", "USDC", 9, to_wei(100e18, decimals=9)], ) df_rewards = ContractBase(w3, "DFRewards", constructor_args=[]) From c9acacf671fe2cd815bfec0ce7402917c671b72b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 13:50:33 +0000 Subject: [PATCH 4/9] Address code review feedback: use keyword arguments and fix test token amount Co-authored-by: trizin <25263018+trizin@users.noreply.github.com> --- df_py/util/dispense.py | 4 ++-- df_py/util/test/test_dispense.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/df_py/util/dispense.py b/df_py/util/dispense.py index a2dc1fe8a..4e85c3f6c 100644 --- a/df_py/util/dispense.py +++ b/df_py/util/dispense.py @@ -60,7 +60,7 @@ def dispense( # checksum addresses rewards = {web3.to_checksum_address(k): v for k, v in rewards.items()} to_addrs = list(rewards.keys()) - values = [to_wei(rewards[to_addr], token_decimals) for to_addr in to_addrs] + values = [to_wei(rewards[to_addr], decimals=token_decimals) for to_addr in to_addrs] N = len(rewards) sts = list(range(N))[::batch_size] # send in batches to avoid gas issues @@ -143,7 +143,7 @@ def approveAmt(amt): @enforce_types def multisig_transfer_tokens(web3, ocean, receiver_address, amount): token_decimals = ocean.decimals() - amount_wei = to_wei(amount, token_decimals) + amount_wei = to_wei(amount, decimals=token_decimals) transfer_data = ocean.contract.encodeABI( fn_name="transfer", args=[receiver_address, amount_wei] ) diff --git a/df_py/util/test/test_dispense.py b/df_py/util/test/test_dispense.py index 1f5d637ae..3296b67c5 100644 --- a/df_py/util/test/test_dispense.py +++ b/df_py/util/test/test_dispense.py @@ -112,7 +112,7 @@ def test_dispense_with_9_decimals(w3): token = ContractBase( w3, "OceanToken", - constructor_args=["USDC", "USDC", 9, to_wei(100e18, decimals=9)], + constructor_args=["USDC", "USDC", 9, to_wei(100000, decimals=9)], ) df_rewards = ContractBase(w3, "DFRewards", constructor_args=[]) From 07940b206e9d7cd0619b0871cdfaf6f9b26d1a42 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 08:59:17 +0000 Subject: [PATCH 5/9] Fix all pylint errors: disable deprecated option, add too-many-positional-arguments, fix line-too-long Co-authored-by: trizin <25263018+trizin@users.noreply.github.com> --- .pylintrc | 3 ++- df_py/util/dftool_module.py | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.pylintrc b/.pylintrc index a7a5b2d52..046495b06 100644 --- a/.pylintrc +++ b/.pylintrc @@ -65,7 +65,7 @@ persistent=yes # When enabled, pylint would attempt to guess common misconfiguration and emit # user-friendly hints instead of false-positive error messages. -suggestion-mode=yes +# suggestion-mode=yes # Deprecated in newer versions of pylint # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. @@ -108,6 +108,7 @@ disable=too-many-locals, use-symbolic-message-instead, use-implicit-booleaness-not-comparison, too-many-arguments, + too-many-positional-arguments, consider-using-f-string, consider-using-in, global-variable-not-assigned, diff --git a/df_py/util/dftool_module.py b/df_py/util/dftool_module.py index a4b3c5d98..06c1f07da 100644 --- a/df_py/util/dftool_module.py +++ b/df_py/util/dftool_module.py @@ -67,7 +67,8 @@ def do_volsym(): parser = StartFinArgumentParser( description="Query chain, output volumes, symbols, owners", epilog=f"""Uses these envvars: - \nADDRESS_FILE -- eg: export ADDRESS_FILE={networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} + \nADDRESS_FILE -- eg: export ADDRESS_FILE=""" + f"""{networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} \nSECRET_SEED -- secret integer used to seed the rng """, command_name="volsym", @@ -96,7 +97,7 @@ def do_volsym(): web3, arguments.ST, arguments.FIN, arguments.NSAMP, SECRET_SEED ) - (Vi, Ci, SYMi) = retry_function( + Vi, Ci, SYMi = retry_function( queries.queryVolsOwnersSymbols, arguments.RETRIES, 60, rng, chain_id ) @@ -628,7 +629,8 @@ def do_init_dev_wallets(): "Init wallets with OCEAN. (GANACHE ONLY)", "init_dev_wallets", epilog=f"""Uses these envvars: - ADDRESS_FILE -- eg: export ADDRESS_FILE={networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} + ADDRESS_FILE -- eg: export ADDRESS_FILE=""" + f"""{networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} """, ) chain_id = parser.print_args_and_get_chain() @@ -661,7 +663,8 @@ def do_many_random(): "deploy many datatokens + locks OCEAN + allocates + consumes (for testing)", "many_random", epilog=f"""Uses these envvars: - ADDRESS_FILE -- eg: export ADDRESS_FILE={networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} + ADDRESS_FILE -- eg: export ADDRESS_FILE=""" + f"""{networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} """, ) @@ -703,7 +706,8 @@ def do_fake_rewards(): "create some rewards (for testing)", "fake_rewards", epilog=f"""Uses these envvars: - ADDRESS_FILE -- eg: export ADDRESS_FILE={networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} + ADDRESS_FILE -- eg: export ADDRESS_FILE=""" + f"""{networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} """, ) @@ -833,12 +837,10 @@ def do_new_veallocate(): # ======================================================================== @enforce_types def do_ve_set_allocation(): - parser = argparse.ArgumentParser( - description=""" + parser = argparse.ArgumentParser(description=""" Allocate weight to veAllocate contract (for testing). Set to 0 to trigger resetAllocation event. - """ - ) + """) parser.add_argument("command", choices=["ve_set_allocation"]) parser.add_argument("CHAINID", type=chain_type, help=CHAINID_EXAMPLES) parser.add_argument("amount", type=int, help="") From d7025e429eaf2b564c4dc523dd0ba174674f3a6e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 20:59:17 +0000 Subject: [PATCH 6/9] Fix black formatting errors across codebase Co-authored-by: trizin <25263018+trizin@users.noreply.github.com> --- df_py/predictoor/calc_rewards.py | 2 +- df_py/util/blocktime.py | 2 +- df_py/util/contract_base.py | 1 + df_py/util/contract_utils.py | 2 +- df_py/util/oceantestutil.py | 4 ++-- df_py/util/test/test_blocktime_ganache.py | 8 ++++---- df_py/util/test/test_vesting_schedule.py | 1 - df_py/volume/reward_calculator.py | 2 +- df_py/volume/test/test_calc_rewards_rank.py | 4 ++-- df_py/volume/test/test_queries.py | 10 +++++----- df_py/volume/test/test_rank.py | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/df_py/predictoor/calc_rewards.py b/df_py/predictoor/calc_rewards.py index 2e084993b..45c043ef1 100644 --- a/df_py/predictoor/calc_rewards.py +++ b/df_py/predictoor/calc_rewards.py @@ -71,7 +71,7 @@ def calc_predictoor_rewards( def aggregate_predictoor_rewards( - predictoor_rewards: Dict[str, Dict[str, float]] + predictoor_rewards: Dict[str, Dict[str, float]], ) -> Dict[str, float]: # Aggregate total reward per predictor address aggregated_rewards: Dict[str, float] = {} diff --git a/df_py/util/blocktime.py b/df_py/util/blocktime.py index 4476551b4..47cb0f567 100644 --- a/df_py/util/blocktime.py +++ b/df_py/util/blocktime.py @@ -140,7 +140,7 @@ def timestamp_to_block(web3, timestamp: Union[float, int]) -> int: return web3.eth.get_block("latest").number # pylint: disable=unused-variable - (block_i, results) = optimize.bisect(f, a, b, xtol=0.4, full_output=True) + block_i, results = optimize.bisect(f, a, b, xtol=0.4, full_output=True) # uncomment to debug # --- diff --git a/df_py/util/contract_base.py b/df_py/util/contract_base.py index 5ebaa47c9..4cbcd967a 100644 --- a/df_py/util/contract_base.py +++ b/df_py/util/contract_base.py @@ -4,6 +4,7 @@ # """All contracts inherit from `ContractBase` class.""" + import logging from typing import Optional diff --git a/df_py/util/contract_utils.py b/df_py/util/contract_utils.py index f1179b723..258b9970c 100644 --- a/df_py/util/contract_utils.py +++ b/df_py/util/contract_utils.py @@ -142,7 +142,7 @@ def get_contracts_addresses(config: dict) -> Optional[Dict[str, str]]: # Check singnet/snet-cli#142 (comment). You need to provide a lowercase address # then call web3.to_checksum_address() for software safety. def _checksum_contract_addresses( - network_addresses: Dict[str, Any] + network_addresses: Dict[str, Any], ) -> Optional[Dict[str, Any]]: for key, value in network_addresses.items(): if key == "chainId": diff --git a/df_py/util/oceantestutil.py b/df_py/util/oceantestutil.py index 10b2bdcc9..f8027c1a6 100644 --- a/df_py/util/oceantestutil.py +++ b/df_py/util/oceantestutil.py @@ -128,7 +128,7 @@ def random_create_dataNFT_with_FREs(web3: Web3, num_FRE: int, base_token): else: account_i = random.randint(0, len(accounts)) - (data_NFT, DT, exchangeId) = oceanutil.create_data_nft_with_fre( + data_NFT, DT, exchangeId = oceanutil.create_data_nft_with_fre( web3, accounts[account_i], base_token ) assert oceanutil.FixedPrice(web3.eth.chain_id).isActive(exchangeId) is True @@ -166,7 +166,7 @@ def random_consume_FREs(FRE_tup: list, base_token): # consume data assets from FREs randomly for consume_i in range(NUM_CONSUMES): tup = random.choice(FRE_tup) - (pub_account_i, _, DT, exchangeId) = tup + pub_account_i, _, DT, exchangeId = tup # choose consume account cand_I = [i for i in range(9) if i != pub_account_i] diff --git a/df_py/util/test/test_blocktime_ganache.py b/df_py/util/test/test_blocktime_ganache.py index 0e91479ba..4e7953004 100644 --- a/df_py/util/test/test_blocktime_ganache.py +++ b/df_py/util/test/test_blocktime_ganache.py @@ -172,24 +172,24 @@ def test_get_st_fin_blocks(w3): provider.make_request("evm_mine", []) # by block number - (st, fin) = get_st_fin_blocks(w3, "0", "1") + st, fin = get_st_fin_blocks(w3, "0", "1") assert st == 0 assert fin > 0 # get by latest fin - (st, fin) = get_st_fin_blocks(w3, "0", "latest") + st, fin = get_st_fin_blocks(w3, "0", "latest") assert st == 0 assert fin > 0 # get by thu fin - (st, fin) = get_st_fin_blocks(w3, "0", "thu") + st, fin = get_st_fin_blocks(w3, "0", "thu") assert st == 0 assert fin > 0 # get by datetime YYYY-MM-DD now_date = datetime.utcfromtimestamp(w3.eth.get_block("latest").timestamp) now_date = now_date.strftime("%Y-%m-%d") - (st, fin) = get_st_fin_blocks(w3, "0", now_date) + st, fin = get_st_fin_blocks(w3, "0", now_date) assert st == 0 assert fin >= 0 diff --git a/df_py/util/test/test_vesting_schedule.py b/df_py/util/test/test_vesting_schedule.py index d1f0f7ad9..8e1eab44c 100644 --- a/df_py/util/test/test_vesting_schedule.py +++ b/df_py/util/test/test_vesting_schedule.py @@ -8,7 +8,6 @@ from df_py.util.base18 import from_wei from df_py.util.constants import ACTIVE_REWARDS_MULTIPLIER, PREDICTOOR_OCEAN_BUDGET - predictoor_substream = "predictoor" volume_substream = "volume" test_params = [ diff --git a/df_py/volume/reward_calculator.py b/df_py/volume/reward_calculator.py index f22de25e2..4ba7b1814 100644 --- a/df_py/volume/reward_calculator.py +++ b/df_py/volume/reward_calculator.py @@ -105,7 +105,7 @@ def calculate(self): self._freeze_attributes = True - (rewardsperlp, rewardsinfo) = self._reward_array_to_dicts() + rewardsperlp, rewardsinfo = self._reward_array_to_dicts() return rewardsperlp, rewardsinfo diff --git a/df_py/volume/test/test_calc_rewards_rank.py b/df_py/volume/test/test_calc_rewards_rank.py index 16595efbb..a85f0c2dc 100644 --- a/df_py/volume/test/test_calc_rewards_rank.py +++ b/df_py/volume/test/test_calc_rewards_rank.py @@ -63,7 +63,7 @@ def _test_rank_N_NFTs(N: int): OCEAN_avail = 10.0 # equal volumes - (_, LP_addrs, stakes, nftvols) = _rank_testvals(N, equal_vol=True) + _, LP_addrs, stakes, nftvols = _rank_testvals(N, equal_vol=True) rew, _ = calc_rewards_C1(stakes, nftvols, OCEAN_avail, do_rank=True) assert len(rew) == N assert LP_addrs == sorted(rew.keys()) @@ -71,7 +71,7 @@ def _test_rank_N_NFTs(N: int): assert min(rew.values()) == max(rew.values()) # unequal volumes - (_, LP_addrs, stakes, nftvols) = _rank_testvals(N, equal_vol=False) + _, LP_addrs, stakes, nftvols = _rank_testvals(N, equal_vol=False) rew, _ = calc_rewards_C1(stakes, nftvols, OCEAN_avail, do_rank=True) max_N = min(N, MAX_N_RANK_ASSETS) assert len(rew) == max_N diff --git a/df_py/volume/test/test_queries.py b/df_py/volume/test/test_queries.py index b9eca195c..ebc5516b2 100644 --- a/df_py/volume/test/test_queries.py +++ b/df_py/volume/test/test_queries.py @@ -297,7 +297,7 @@ def _test_queryVolsOwnersSymbols(w3, st, fin): print("_test_queryVolsOwnersSymbols()...") n = 500 rng = BlockRange(st, fin, n, web3=w3) - (V0, C0, SYM0) = queries.queryVolsOwnersSymbols(rng, CHAINID) + V0, C0, SYM0 = queries.queryVolsOwnersSymbols(rng, CHAINID) assert CO2_addr in V0 assert C0 @@ -410,7 +410,7 @@ def _test_dftool_allocations(tmp_path, start_block, fin_block): @enforce_types def _test_end_to_end_without_csvs(rng): print("_test_end_to_end_without_csvs()...") - (V0, C0, SYM0) = queries.queryVolsOwnersSymbols(rng, CHAINID) + V0, C0, SYM0 = queries.queryVolsOwnersSymbols(rng, CHAINID) V = {CHAINID: V0} C = {CHAINID: C0} SYM = {CHAINID: SYM0} @@ -452,7 +452,7 @@ def _test_end_to_end_with_csvs(w3, rng, tmp_path, god_acct): csvs.save_rate_csv(CO2_sym, 1.00, csv_dir) # 2. simulate "dftool volsym" - (V0, C0, SYM0) = queries.queryVolsOwnersSymbols(rng, CHAINID) + V0, C0, SYM0 = queries.queryVolsOwnersSymbols(rng, CHAINID) csvs.save_nftvols_csv(V0, csv_dir, CHAINID) csvs.save_owners_csv(C0, csv_dir, CHAINID) csvs.save_symbols_csv(SYM0, csv_dir, CHAINID) @@ -550,10 +550,10 @@ def sim_epoch(): def _test_ghost_consume(start_block, fin_block, rng, ghost_consume_nft_addr): print("_test_ghost_consume()...") - (V0, _, _) = queries.queryVolsOwnersSymbols(rng, CHAINID) + V0, _, _ = queries.queryVolsOwnersSymbols(rng, CHAINID) assert V0[CO2_addr][ghost_consume_nft_addr] == approx(1.0, 0.5) - (V0, _, _) = queries._queryVolsOwners(start_block, fin_block, CHAINID) + V0, _, _ = queries._queryVolsOwners(start_block, fin_block, CHAINID) assert V0[CO2_addr][ghost_consume_nft_addr] == 21.0 swaps = queries._querySwaps(start_block, fin_block, CHAINID) diff --git a/df_py/volume/test/test_rank.py b/df_py/volume/test/test_rank.py index 3d04ac271..42d89f821 100644 --- a/df_py/volume/test/test_rank.py +++ b/df_py/volume/test/test_rank.py @@ -41,7 +41,7 @@ def test_rank_based_allocate_3_simple(): def test_rank_based_allocate_3_exact(op): V_USD = np.array([10.0, 99.0, 3.0], dtype=float) - (p, ranks, max_N, allocs, I) = rank_based_allocate( + p, ranks, max_N, allocs, I = rank_based_allocate( V_USD, max_n_rank_assets=100, rank_scale_op=op, return_info=True ) From 4d8da6cf1197a1092ac44a3271b5a36d5cf2fbc0 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Tue, 24 Feb 2026 12:52:13 +0100 Subject: [PATCH 7/9] Update .pylintrc --- .pylintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.pylintrc b/.pylintrc index 046495b06..594ca391a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -34,6 +34,7 @@ ignore= LICENSE, docker-compose.yml, brownie-config.yaml, + PREDICTOOR-DISPENSE.md, Dockerfile, dfpy_docker, package-lock.json, From 658efefa5205b74d5abebdb792cefd6e2107dc54 Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Tue, 24 Feb 2026 12:59:57 +0000 Subject: [PATCH 8/9] formatting --- df_py/util/dftool_module.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/df_py/util/dftool_module.py b/df_py/util/dftool_module.py index 06c1f07da..4e5063b25 100644 --- a/df_py/util/dftool_module.py +++ b/df_py/util/dftool_module.py @@ -837,10 +837,12 @@ def do_new_veallocate(): # ======================================================================== @enforce_types def do_ve_set_allocation(): - parser = argparse.ArgumentParser(description=""" + parser = argparse.ArgumentParser( + description=""" Allocate weight to veAllocate contract (for testing). Set to 0 to trigger resetAllocation event. - """) + """ + ) parser.add_argument("command", choices=["ve_set_allocation"]) parser.add_argument("CHAINID", type=chain_type, help=CHAINID_EXAMPLES) parser.add_argument("amount", type=int, help="") From 6e168f794316ccd0768448ed78ee004bde366e4f Mon Sep 17 00:00:00 2001 From: trizin <25263018+trizin@users.noreply.github.com> Date: Tue, 24 Feb 2026 13:04:55 +0000 Subject: [PATCH 9/9] restore --- .pylintrc | 1 - df_py/util/blocktime.py | 2 +- df_py/util/contract_base.py | 1 - df_py/util/contract_utils.py | 2 +- df_py/util/dftool_module.py | 14 +++++--------- df_py/util/oceantestutil.py | 4 ++-- df_py/util/test/test_blocktime_ganache.py | 8 ++++---- df_py/util/test/test_vesting_schedule.py | 1 + df_py/volume/reward_calculator.py | 2 +- df_py/volume/test/test_calc_rewards_rank.py | 4 ++-- df_py/volume/test/test_queries.py | 10 +++++----- df_py/volume/test/test_rank.py | 2 +- 12 files changed, 23 insertions(+), 28 deletions(-) diff --git a/.pylintrc b/.pylintrc index 594ca391a..2a0787c90 100644 --- a/.pylintrc +++ b/.pylintrc @@ -109,7 +109,6 @@ disable=too-many-locals, use-symbolic-message-instead, use-implicit-booleaness-not-comparison, too-many-arguments, - too-many-positional-arguments, consider-using-f-string, consider-using-in, global-variable-not-assigned, diff --git a/df_py/util/blocktime.py b/df_py/util/blocktime.py index 47cb0f567..4476551b4 100644 --- a/df_py/util/blocktime.py +++ b/df_py/util/blocktime.py @@ -140,7 +140,7 @@ def timestamp_to_block(web3, timestamp: Union[float, int]) -> int: return web3.eth.get_block("latest").number # pylint: disable=unused-variable - block_i, results = optimize.bisect(f, a, b, xtol=0.4, full_output=True) + (block_i, results) = optimize.bisect(f, a, b, xtol=0.4, full_output=True) # uncomment to debug # --- diff --git a/df_py/util/contract_base.py b/df_py/util/contract_base.py index 4cbcd967a..5ebaa47c9 100644 --- a/df_py/util/contract_base.py +++ b/df_py/util/contract_base.py @@ -4,7 +4,6 @@ # """All contracts inherit from `ContractBase` class.""" - import logging from typing import Optional diff --git a/df_py/util/contract_utils.py b/df_py/util/contract_utils.py index 258b9970c..f1179b723 100644 --- a/df_py/util/contract_utils.py +++ b/df_py/util/contract_utils.py @@ -142,7 +142,7 @@ def get_contracts_addresses(config: dict) -> Optional[Dict[str, str]]: # Check singnet/snet-cli#142 (comment). You need to provide a lowercase address # then call web3.to_checksum_address() for software safety. def _checksum_contract_addresses( - network_addresses: Dict[str, Any], + network_addresses: Dict[str, Any] ) -> Optional[Dict[str, Any]]: for key, value in network_addresses.items(): if key == "chainId": diff --git a/df_py/util/dftool_module.py b/df_py/util/dftool_module.py index 4e5063b25..a4b3c5d98 100644 --- a/df_py/util/dftool_module.py +++ b/df_py/util/dftool_module.py @@ -67,8 +67,7 @@ def do_volsym(): parser = StartFinArgumentParser( description="Query chain, output volumes, symbols, owners", epilog=f"""Uses these envvars: - \nADDRESS_FILE -- eg: export ADDRESS_FILE=""" - f"""{networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} + \nADDRESS_FILE -- eg: export ADDRESS_FILE={networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} \nSECRET_SEED -- secret integer used to seed the rng """, command_name="volsym", @@ -97,7 +96,7 @@ def do_volsym(): web3, arguments.ST, arguments.FIN, arguments.NSAMP, SECRET_SEED ) - Vi, Ci, SYMi = retry_function( + (Vi, Ci, SYMi) = retry_function( queries.queryVolsOwnersSymbols, arguments.RETRIES, 60, rng, chain_id ) @@ -629,8 +628,7 @@ def do_init_dev_wallets(): "Init wallets with OCEAN. (GANACHE ONLY)", "init_dev_wallets", epilog=f"""Uses these envvars: - ADDRESS_FILE -- eg: export ADDRESS_FILE=""" - f"""{networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} + ADDRESS_FILE -- eg: export ADDRESS_FILE={networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} """, ) chain_id = parser.print_args_and_get_chain() @@ -663,8 +661,7 @@ def do_many_random(): "deploy many datatokens + locks OCEAN + allocates + consumes (for testing)", "many_random", epilog=f"""Uses these envvars: - ADDRESS_FILE -- eg: export ADDRESS_FILE=""" - f"""{networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} + ADDRESS_FILE -- eg: export ADDRESS_FILE={networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} """, ) @@ -706,8 +703,7 @@ def do_fake_rewards(): "create some rewards (for testing)", "fake_rewards", epilog=f"""Uses these envvars: - ADDRESS_FILE -- eg: export ADDRESS_FILE=""" - f"""{networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} + ADDRESS_FILE -- eg: export ADDRESS_FILE={networkutil.chain_id_to_address_file(chainID=DEV_CHAINID)} """, ) diff --git a/df_py/util/oceantestutil.py b/df_py/util/oceantestutil.py index f8027c1a6..10b2bdcc9 100644 --- a/df_py/util/oceantestutil.py +++ b/df_py/util/oceantestutil.py @@ -128,7 +128,7 @@ def random_create_dataNFT_with_FREs(web3: Web3, num_FRE: int, base_token): else: account_i = random.randint(0, len(accounts)) - data_NFT, DT, exchangeId = oceanutil.create_data_nft_with_fre( + (data_NFT, DT, exchangeId) = oceanutil.create_data_nft_with_fre( web3, accounts[account_i], base_token ) assert oceanutil.FixedPrice(web3.eth.chain_id).isActive(exchangeId) is True @@ -166,7 +166,7 @@ def random_consume_FREs(FRE_tup: list, base_token): # consume data assets from FREs randomly for consume_i in range(NUM_CONSUMES): tup = random.choice(FRE_tup) - pub_account_i, _, DT, exchangeId = tup + (pub_account_i, _, DT, exchangeId) = tup # choose consume account cand_I = [i for i in range(9) if i != pub_account_i] diff --git a/df_py/util/test/test_blocktime_ganache.py b/df_py/util/test/test_blocktime_ganache.py index 4e7953004..0e91479ba 100644 --- a/df_py/util/test/test_blocktime_ganache.py +++ b/df_py/util/test/test_blocktime_ganache.py @@ -172,24 +172,24 @@ def test_get_st_fin_blocks(w3): provider.make_request("evm_mine", []) # by block number - st, fin = get_st_fin_blocks(w3, "0", "1") + (st, fin) = get_st_fin_blocks(w3, "0", "1") assert st == 0 assert fin > 0 # get by latest fin - st, fin = get_st_fin_blocks(w3, "0", "latest") + (st, fin) = get_st_fin_blocks(w3, "0", "latest") assert st == 0 assert fin > 0 # get by thu fin - st, fin = get_st_fin_blocks(w3, "0", "thu") + (st, fin) = get_st_fin_blocks(w3, "0", "thu") assert st == 0 assert fin > 0 # get by datetime YYYY-MM-DD now_date = datetime.utcfromtimestamp(w3.eth.get_block("latest").timestamp) now_date = now_date.strftime("%Y-%m-%d") - st, fin = get_st_fin_blocks(w3, "0", now_date) + (st, fin) = get_st_fin_blocks(w3, "0", now_date) assert st == 0 assert fin >= 0 diff --git a/df_py/util/test/test_vesting_schedule.py b/df_py/util/test/test_vesting_schedule.py index 8e1eab44c..d1f0f7ad9 100644 --- a/df_py/util/test/test_vesting_schedule.py +++ b/df_py/util/test/test_vesting_schedule.py @@ -8,6 +8,7 @@ from df_py.util.base18 import from_wei from df_py.util.constants import ACTIVE_REWARDS_MULTIPLIER, PREDICTOOR_OCEAN_BUDGET + predictoor_substream = "predictoor" volume_substream = "volume" test_params = [ diff --git a/df_py/volume/reward_calculator.py b/df_py/volume/reward_calculator.py index 4ba7b1814..f22de25e2 100644 --- a/df_py/volume/reward_calculator.py +++ b/df_py/volume/reward_calculator.py @@ -105,7 +105,7 @@ def calculate(self): self._freeze_attributes = True - rewardsperlp, rewardsinfo = self._reward_array_to_dicts() + (rewardsperlp, rewardsinfo) = self._reward_array_to_dicts() return rewardsperlp, rewardsinfo diff --git a/df_py/volume/test/test_calc_rewards_rank.py b/df_py/volume/test/test_calc_rewards_rank.py index a85f0c2dc..16595efbb 100644 --- a/df_py/volume/test/test_calc_rewards_rank.py +++ b/df_py/volume/test/test_calc_rewards_rank.py @@ -63,7 +63,7 @@ def _test_rank_N_NFTs(N: int): OCEAN_avail = 10.0 # equal volumes - _, LP_addrs, stakes, nftvols = _rank_testvals(N, equal_vol=True) + (_, LP_addrs, stakes, nftvols) = _rank_testvals(N, equal_vol=True) rew, _ = calc_rewards_C1(stakes, nftvols, OCEAN_avail, do_rank=True) assert len(rew) == N assert LP_addrs == sorted(rew.keys()) @@ -71,7 +71,7 @@ def _test_rank_N_NFTs(N: int): assert min(rew.values()) == max(rew.values()) # unequal volumes - _, LP_addrs, stakes, nftvols = _rank_testvals(N, equal_vol=False) + (_, LP_addrs, stakes, nftvols) = _rank_testvals(N, equal_vol=False) rew, _ = calc_rewards_C1(stakes, nftvols, OCEAN_avail, do_rank=True) max_N = min(N, MAX_N_RANK_ASSETS) assert len(rew) == max_N diff --git a/df_py/volume/test/test_queries.py b/df_py/volume/test/test_queries.py index ebc5516b2..b9eca195c 100644 --- a/df_py/volume/test/test_queries.py +++ b/df_py/volume/test/test_queries.py @@ -297,7 +297,7 @@ def _test_queryVolsOwnersSymbols(w3, st, fin): print("_test_queryVolsOwnersSymbols()...") n = 500 rng = BlockRange(st, fin, n, web3=w3) - V0, C0, SYM0 = queries.queryVolsOwnersSymbols(rng, CHAINID) + (V0, C0, SYM0) = queries.queryVolsOwnersSymbols(rng, CHAINID) assert CO2_addr in V0 assert C0 @@ -410,7 +410,7 @@ def _test_dftool_allocations(tmp_path, start_block, fin_block): @enforce_types def _test_end_to_end_without_csvs(rng): print("_test_end_to_end_without_csvs()...") - V0, C0, SYM0 = queries.queryVolsOwnersSymbols(rng, CHAINID) + (V0, C0, SYM0) = queries.queryVolsOwnersSymbols(rng, CHAINID) V = {CHAINID: V0} C = {CHAINID: C0} SYM = {CHAINID: SYM0} @@ -452,7 +452,7 @@ def _test_end_to_end_with_csvs(w3, rng, tmp_path, god_acct): csvs.save_rate_csv(CO2_sym, 1.00, csv_dir) # 2. simulate "dftool volsym" - V0, C0, SYM0 = queries.queryVolsOwnersSymbols(rng, CHAINID) + (V0, C0, SYM0) = queries.queryVolsOwnersSymbols(rng, CHAINID) csvs.save_nftvols_csv(V0, csv_dir, CHAINID) csvs.save_owners_csv(C0, csv_dir, CHAINID) csvs.save_symbols_csv(SYM0, csv_dir, CHAINID) @@ -550,10 +550,10 @@ def sim_epoch(): def _test_ghost_consume(start_block, fin_block, rng, ghost_consume_nft_addr): print("_test_ghost_consume()...") - V0, _, _ = queries.queryVolsOwnersSymbols(rng, CHAINID) + (V0, _, _) = queries.queryVolsOwnersSymbols(rng, CHAINID) assert V0[CO2_addr][ghost_consume_nft_addr] == approx(1.0, 0.5) - V0, _, _ = queries._queryVolsOwners(start_block, fin_block, CHAINID) + (V0, _, _) = queries._queryVolsOwners(start_block, fin_block, CHAINID) assert V0[CO2_addr][ghost_consume_nft_addr] == 21.0 swaps = queries._querySwaps(start_block, fin_block, CHAINID) diff --git a/df_py/volume/test/test_rank.py b/df_py/volume/test/test_rank.py index 42d89f821..3d04ac271 100644 --- a/df_py/volume/test/test_rank.py +++ b/df_py/volume/test/test_rank.py @@ -41,7 +41,7 @@ def test_rank_based_allocate_3_simple(): def test_rank_based_allocate_3_exact(op): V_USD = np.array([10.0, 99.0, 3.0], dtype=float) - p, ranks, max_N, allocs, I = rank_based_allocate( + (p, ranks, max_N, allocs, I) = rank_based_allocate( V_USD, max_n_rank_assets=100, rank_scale_op=op, return_info=True )