Skip to content

Commit

Permalink
style: lint with black v24
Browse files Browse the repository at this point in the history
  • Loading branch information
gosuto-inzasheru committed Jun 11, 2024
1 parent 61a171d commit 3a2a4b5
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion great_ape_safe/ape_api/helpers/uni_v3/uni_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rich.pretty import pprint


Q128 = 2 ** 128
Q128 = 2**128

LABELS = {
"pool_positions": [
Expand Down
8 changes: 4 additions & 4 deletions great_ape_safe/ape_api/helpers/uni_v3/uni_v3_sdk.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from math import ceil

BASE = 1.0001
Q128 = 2 ** 128
Q96 = 2 ** 96
Q32 = 2 ** 32
MAXUINT256 = 2 ** 256 - 1
Q128 = 2**128
Q96 = 2**96
Q32 = 2**32
MAXUINT256 = 2**256 - 1


def maxLiquidityForAmount0(sqrtA, sqrtB, amount):
Expand Down
6 changes: 3 additions & 3 deletions great_ape_safe/ape_api/uni_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, safe):
)

# constant helpers
self.Q128 = 2 ** 128
self.Q128 = 2**128
self.deadline = 60 * 180
self.slippage = 0.98

Expand Down Expand Up @@ -357,12 +357,12 @@ def mint_position(self, pool_addr, range0, range1, token0_amount, token1_amount)

# params for minting method
lower_tick = int(
math.log((1 / range1) * 10 ** decimals_diff, BASE)
math.log((1 / range1) * 10**decimals_diff, BASE)
// tick_spacing
* tick_spacing
)
upper_tick = int(
math.log((1 / range0) * 10 ** decimals_diff, BASE)
math.log((1 / range0) * 10**decimals_diff, BASE)
// tick_spacing
* tick_spacing
)
Expand Down
18 changes: 13 additions & 5 deletions great_ape_safe/great_ape_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ContractWrapperExtended:
Add the possibilty to instantiate a contract from a given interface or
from the explorer, else revert to BrownieSafe's default behaviour
"""

def __init__(self, account, instance):
self.account = account
self.instance = instance
Expand Down Expand Up @@ -417,26 +418,31 @@ def _debank_pre_execution(self, receipt, gas):
r.raise_for_status()
print(r.json())


class GreatApeSafeV111(GreatApeSafeBase, SafeV111):
pass


class GreatApeSafeV120(GreatApeSafeBase, SafeV120):
pass


class GreatApeSafeV130(GreatApeSafeBase, SafeV130):
pass


class GreatApeSafeV141(GreatApeSafeBase, SafeV141):
pass


PATCHED_SAFE_VERSIONS = {
'1.1.1': GreatApeSafeV111,
'1.2.0': GreatApeSafeV120,
'1.3.0': GreatApeSafeV130,
'1.4.1': GreatApeSafeV141,
"1.1.1": GreatApeSafeV111,
"1.2.0": GreatApeSafeV120,
"1.3.0": GreatApeSafeV130,
"1.4.1": GreatApeSafeV141,
}


def GreatApeSafe(address, base_url=None, multisend=None):
"""
Create an GreatApeSafe from an address or a ENS name and use a default connection.
Expand All @@ -449,7 +455,9 @@ def GreatApeSafe(address, base_url=None, multisend=None):
accounts[0].transfer(address, 10e18)

great_ape_safe = PATCHED_SAFE_VERSIONS[safe.get_version()](address, ethereum_client)
great_ape_safe.transaction_service = TransactionServiceApi(ethereum_client.get_network(), ethereum_client, base_url)
great_ape_safe.transaction_service = TransactionServiceApi(
ethereum_client.get_network(), ethereum_client, base_url
)
great_ape_safe.multisend = MultiSend(ethereum_client, multisend, call_only=True)

return great_ape_safe
2 changes: 1 addition & 1 deletion helpers/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AddressZero = "0x0000000000000000000000000000000000000000"
MaxUint256 = str(int(2 ** 256 - 1))
MaxUint256 = str(int(2**256 - 1))
EmptyBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000"

## eBTC Constants
Expand Down
1 change: 1 addition & 0 deletions helpers/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from brownie import web3


# Takes a string with a function signature and returns a 4 bytes hex string
def encode_signature(signature: str) -> str:
return web3.keccak(text=signature).hex()[0:10]
Expand Down
6 changes: 3 additions & 3 deletions scripts/merkl_incentive_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ def _verify_cli_args(
assert duration_campaign >= HOURS_PER_DAY, "campaign duration smaller than 1 day"
C.print(f"[green]duration_campaign={duration_campaign}\n[/green]")

weight_token_a = int(weight_token_a) * 10 ** 2
weight_token_b = int(weight_token_b) * 10 ** 2
weight_fees = int(weight_fees) * 10 ** 2
weight_token_a = int(weight_token_a) * 10**2
weight_token_b = int(weight_token_b) * 10**2
weight_fees = int(weight_fees) * 10**2
assert (
weight_token_a + weight_token_b + weight_fees == WEIGHTS_TOTAL_BASE
), "total weights does not match 10_000"
Expand Down
1 change: 1 addition & 0 deletions scripts/pys-changes/treasury_timelock_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
["string"], ["PYS_STAKING_REWARD_SPLIT_INTO_TREASURY_TIMELOCK"]
).hex()


# @note that txs are schedule individually due to timelock ui support (lack of batching support atm)
def main(sim=True):
# safe: security msig is a proposer in `highsec_timelock`
Expand Down
6 changes: 3 additions & 3 deletions scripts/seeding/seeding_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _max_wbtc_upper_bound(path, wbtc_pool_balance):
"""
wbtc_decimals = path[0].decimals()
decimals_diff = path[1].decimals() - wbtc_decimals
step_increase = 0.1 * 10 ** wbtc_decimals
step_increase = 0.1 * 10**wbtc_decimals
max_wbtc_amount = int(
wbtc_pool_balance / 3
) # start checking swaps of 1/3 of the pool balance
Expand All @@ -337,14 +337,14 @@ def _max_wbtc_upper_bound(path, wbtc_pool_balance):
chain.snapshot()
while True:
amount_out = safe.uni_v3.swap(path, max_wbtc_amount)
amount_out_wbtc_adjusted = int(amount_out / 10 ** decimals_diff)
amount_out_wbtc_adjusted = int(amount_out / 10**decimals_diff)
chain.revert()
# at this point the swap is returning less $ebtc than $wbtc in
if amount_out_wbtc_adjusted < max_wbtc_amount:
break
max_wbtc_amount += step_increase

return max_wbtc_amount / 10 ** wbtc_decimals
return max_wbtc_amount / 10**wbtc_decimals


def _calc_steth_out_to_peg_tick(pool, wbtc, ebtc, collateral):
Expand Down
2 changes: 1 addition & 1 deletion tests/univ3/test_pool_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_pool_creation(treasury, liq, wbtc):
common_decimal_denominator = liq.decimals() - wbtc.decimals()

# rounding here since in essence should be 0.99999...
p = round(((BASE ** initialized_tick) / (10 ** common_decimal_denominator)))
p = round(((BASE**initialized_tick) / (10**common_decimal_denominator)))

# assert the following conditions against the pool after initialization state
assert initialized_tick > 0 and initialized_sqrt_price_x96 > 0
Expand Down
4 changes: 2 additions & 2 deletions tests/univ3/test_position_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def test_position_creation(treasury, liq, wbtc):
positions = treasury.uni_v3.nonfungible_position_manager.positions(token_id)

price_lower_tick = round(
((BASE ** positions["tickLower"]) / (10 ** decimals_diff)), 4
((BASE ** positions["tickLower"]) / (10**decimals_diff)), 4
)
price_higher_tick = round(
((BASE ** positions["tickUpper"]) / (10 ** decimals_diff)), 4
((BASE ** positions["tickUpper"]) / (10**decimals_diff)), 4
)

assert (
Expand Down

0 comments on commit 3a2a4b5

Please sign in to comment.