class GasStrategies: def __init__(self): self.standard = GasNowStrategy("standard") self.fast = GasNowStrategy("fast") self.rapid = GasNowStrategy("rapid") self.bsc_static = StaticGasStrategy(bsc_static_price) print(self.fast.get_gas_price()) self.exponentialScaling = ExponentialScalingStrategy( initial_gas_price=self.standard.get_gas_price(), max_gas_price=Wei(exponential_scaling_config["max_gas_price"]), time_duration=120, ) self.exponentialScalingFast = ExponentialScalingStrategy( initial_gas_price=self.fast.get_gas_price(), max_gas_price=Wei(exponential_scaling_config["max_gas_price"]), time_duration=60, ) def set_default(self, strategy): gas_price(strategy) def set_default_for_active_chain(self): chain = network_manager.get_active_network() if chain == "eth": self.set_default(self.exponentialScaling) elif chain == "bsc": self.set_default(self.bsc_static)
def __init__(self): self.standard = GasNowStrategy("standard") self.fast = GasNowStrategy("fast") self.rapid = GasNowStrategy("rapid") self.bsc_static = StaticGasStrategy(bsc_static_price) self.analyzed = analyze_gas({"timeframe": "minutes", "periods": 15}) print( "gas prices - fast:", self.fast.get_gas_price(), "recent average:", self.analyzed.mode, ) self.exponentialScaling = ExponentialScalingStrategy( initial_gas_price=self.standard.get_gas_price(), max_gas_price=Wei(exponential_scaling_config["max_gas_price"]), time_duration=120, ) self.exponentialScalingFast = ExponentialScalingStrategy( initial_gas_price=self.fast.get_gas_price(), max_gas_price=Wei(exponential_scaling_config["max_gas_price"]), time_duration=60, )
def __init__(self): self.standard = GasNowStrategy("standard") self.fast = GasNowStrategy("fast") self.rapid = GasNowStrategy("rapid") self.bsc_static = StaticGasStrategy(bsc_static_price) print(self.fast.get_gas_price()) self.exponentialScaling = ExponentialScalingStrategy( initial_gas_price=self.standard.get_gas_price(), max_gas_price=Wei(exponential_scaling_config["max_gas_price"]), time_duration=120)
class GasStrategies: def __init__(self): self.standard = GasNowStrategy("standard") self.fast = GasNowStrategy("fast") self.rapid = GasNowStrategy("rapid") self.bsc_static = StaticGasStrategy(bsc_static_price) self.analyzed = analyze_gas({"timeframe": "minutes", "periods": 15}) print( "gas prices - fast:", self.fast.get_gas_price(), "recent average:", self.analyzed.mode, ) self.exponentialScaling = ExponentialScalingStrategy( initial_gas_price=self.standard.get_gas_price(), max_gas_price=Wei(exponential_scaling_config["max_gas_price"]), time_duration=120, ) self.exponentialScalingFast = ExponentialScalingStrategy( initial_gas_price=self.fast.get_gas_price(), max_gas_price=Wei(exponential_scaling_config["max_gas_price"]), time_duration=60, ) def set_default(self, strategy): gas_price(strategy) def gas_cost(self, gas_estimate): """ total gas cost of estimate in wei """ return Web3.toWei( Web3.fromWei(self.fast.get_gas_price(), "gwei") * gas_estimate, "gwei" ) def set_default_for_active_chain(self): chain = network_manager.get_active_network() if chain == "eth": self.set_default(self.exponentialScaling) elif chain == "bsc": self.set_default(self.bsc_static) def optimal_price(self): return min(self.fast.get_gas_price(), self.analyzed.mode)
def main(): print(f"You are using the '{network.show_active()}' network") dev = accounts.load("dev") print(f"You are using: 'dev' [{dev.address}]") print(f"You are using 'gas price' [{GAS_PRICE}]") gas_strategy = GasNowStrategy(GAS_PRICE) if input("Deploy TrustedVaultMigrator? y/[N]: ").lower() != "y": return publish_source = click.confirm("Verify source on etherscan?") TrustedVaultMigrator.deploy( PublicKeyAccount("v2.registry.ychad.eth").address, "0x0000000000004946c0e9F43F4Dee607b0eF1fA1c", # Mainnet Chi Token {"from": dev, "gas_price": gas_strategy}, publish_source=publish_source, )
def main(): print(f"You are using the '{network.show_active()}' network") dev = accounts.load("dev") print(f"You are using: 'dev' [{dev.address}]") print(f"You are using 'gas price' [{GAS_PRICE}]") gas_strategy = GasNowStrategy(GAS_PRICE) if input("Deploy ZapYvWETH? y/[N]: ").lower() != "y": return publish_source = click.confirm("Verify source on etherscan?") ZapYvWETH.deploy( { "from": dev, "gas_price": gas_strategy }, publish_source=publish_source, )
import json from tqdm import tqdm from config.badger_config import badger_config from rich.console import Console from scripts.systems.badger_system import connect_badger from assistant.rewards.rewards_assistant import fetch_current_rewards_tree from assistant.rewards.rewards_utils import process_cumulative_rewards from assistant.rewards.meta_rewards.tree_rewards import calc_tree_rewards from assistant.rewards.rewards_checker import test_claims from assistant.rewards.classes.RewardsList import RewardsList from config.rewards_config import rewards_config from brownie.network.gas.strategies import GasNowStrategy from assistant.rewards.classes.MerkleTree import rewards_to_merkle_tree from assistant.rewards.aws_utils import upload gas_strategy = GasNowStrategy("fast") console = Console() def hash(value): return web3.toHex(web3.keccak(text=value)) def main(): test = False badger = connect_badger(load_root_proposer=True) nextCycle = badger.badgerTree.currentCycle() + 1 startBlock = 0 endBlock = chain.height
from helpers.gnosis_safe import GnosisSafe, MultisigTxMetadata import json from assistant.rewards.rewards_checker import push_rewards, test_claims, verify_rewards from scripts.rewards.rewards_utils import calc_next_cycle_range import time from brownie import * from config.badger_config import badger_config from rich.console import Console from scripts.systems.badger_system import connect_badger from assistant.rewards.rewards_assistant import fetch_current_rewards_tree, fetch_pending_rewards_tree, run_action console = Console() gas_strategy = GasNowStrategy("rapid") def test_main(): main() def main(): badger = connect_badger(badger_config.prod_json, load_keeper=True, load_guardian=True) pendingContentHash = "0x346ec98585b52d981d43584477e1b831ce32165cb8e0a06d14d236241b36328e" pendingFile = "rewards-1-" + str(pendingContentHash) + ".json" with open(pendingFile) as f: after_file = json.load(f)
from brownie import * from brownie.network import gas_price from brownie.network.gas.strategies import GasNowStrategy from scripts.helpers.utils import * gas_price(GasNowStrategy("rapid")) whale = accounts[0] registry = load_registry() crv_price = coin_price("curve-dao-token") eth_price = coin_price("ethereum") def main(): # Setup -- Deposit to first pool first_pool = load_pool_from_index(13) seth_rewards = deposit_to_eth_pool(first_pool, whale, 1 * 1e18) pools = [ZERO_ADDRESS] * 8 pools[0] = seth_rewards init_eth = accounts[0].balance() # Balance if unchanged chain.snapshot() chain.mine(timedelta=24 * 60 * 60) print(f"--- Initial {registry.get_pool_name(first_pool)} ---") display_balances(pools, init_eth) # Test Redeposit chain.revert()
c = Contract.from_explorer('0xA39d1e9CBecdb17901bFa87a5B306D67f15A2391') def claim(r): d = DotMap() d.id = r['id'] d.account = r['account'] d.amount = int('0' + r['amount']) d.r = int('0' + r['r']) d.s = int('0' + r['s']) d.v = int('0' + r['v']) c.claim(d.id, d.account, d.amount, d.v, d.r, d.s) with Status('API not updated..'): while True: strategy = GasNowStrategy(speed='rapid') gas_price(strategy) url = f'https://cu3pxr9ydi.execute-api.us-east-1.amazonaws.com/prod/distributor' \ f'/{accounts.main}' r = requests.get(url).json()[0] if r['id'] != '': claim(r) for a in accounts.others: url = f'https://cu3pxr9ydi.execute-api.us-east-1.amazonaws.com/prod/distributor' \ f'/{a}' r = requests.get(url).json()[0] claim(r) time.sleep(1)