예제 #1
0
def main():
    user = get_account()
    network.gas_price("1.0 gwei")
    LOB.addTrailingStopMarketOrderAbs(
        '0x0f346e19F01471C02485DF1758cfd3d624E399B4', [Wei("1000 ether")],
        [Wei("0.00001 ether")], [Wei("1 ether")], [Wei("10 ether")],
        [Wei("0.01 ether")], False, 0, {'from': user.address})
예제 #2
0
def main():
    account = None
    if network.show_active() in ["mainnet-fork"]:
        account = accounts.at(myWalletAddress, force=True)
    elif network.show_active() in ["mainnet"]:
        account = accounts.load("maindev")

    # Set the gas price
    network.gas_price("120 gwei")
    network.gas_limit("auto")

    # Deploy/Get contract
    #bountyHunter = BountyHunter.deploy({"from":account})
    bountyHunter = BountyHunter.at(BOUNTY_HUNTER_ADDRESS)

    print("My wallet eth amount before claim: " + str(account.balance()))

    print("Claiming bounty...")
    bountyHunter.claimBounty({"from": account, "value": ETH_TO_SELL})

    print("Amount of Eth required: " + str(ETH_TO_SELL - bountyHunter.balance()))

    # print("The amount of Eth needed to buy back UNI tokens: " + str(200000000000000000 - bountyHunter.balance()))
    print("My wallet eth amount after claim: " + str(account.balance()))
    uniToken = interface.ERC20(UNI_TOKEN_ADDRESS)
    print("My wallet uni amount after claim: " + str(uniToken.balanceOf(myWalletAddress)))
예제 #3
0
def main():
    privateKey = 'private key'
    factoryAddr = '0x44226Fc17074A4F019FAA6412E85eff3e01b8368'  # factory addr on kovan
    poolAddr = 'pool addr'
    acc = accounts.add(privateKey)
    network.gas_limit(10000000)  # Not work without it on kovan
    network.gas_price(Wei('1 gwei'))  # Not work without it on kovan

    factory = Factory(acc, factoryAddr)
    pool = factory.loadPool(poolAddr)

    print('Pool Address', pool.getAddress())
    print('isPool', pool.getAddress(), factory.isPool(pool.getAddress()))
    print('isPool', '0xb12DC0644f505028388Da4A919eD72d422175dA8',
          factory.isPool('0xb12DC0644f505028388Da4A919eD72d422175dA8'))
    print('Pool manager fee', factory.getManagerFee(pool.getAddress()))
    print('Dao fee', factory.getDaoFee())
    print('Dao address', factory.getDaoAddress())
    print('Exit fee', factory.getExitFee())
    print('Maximum manager fee', factory.getMaximumManagerFee())
    print('Exit fee cooldown', factory.getExitFeeCooldown())
    print('Max assets', factory.getMaximumAssetCount())
    print('Total pools', factory.getPoolCount())

    # Pool test
    print('Is pool private', pool.isPrivate())
    print('Creator', pool.getCreator())
    print('Creation time', pool.getCreationTime())
    print('Factory address', pool.getFactory())
    print('Assets', pool.getAssets())
    print('Token price at last fee mint', pool.getTokenPriceAtLastFeeMint())
    print('Manager', pool.getManager())
    print('Manager name', pool.getManagerName())
    print('Pool members', pool.getMembers())
    print('Pool member count', pool.getMemberCount())

    sUSD = pool.getAsset('sUSD')
    balance = sUSD.balanceOf(factory.signer)
    print('sUSD balance', balance)

    sUSD.contract.approve(pool.getAddress(), '1000000000000000000',
                          {'from': acc})
    pool.deposit('1000000000000000000')
    print('Pool Value', pool.getPoolValue())

    pool.exchange('sUSD', '500000000000000000', 'sETH')

    print('Pool Value', pool.getPoolValue())
    print('sUSD value', pool.assetValue('sUSD'))
    print('sETH value', pool.assetValue('sETH'))

    print('Summary', pool.getSummary())
    print('Composition', pool.getComposition())
    print('Waiting periods', pool.getWaitingPeriods())
    print('Suspended assets', pool.getSuspendedAssets())
예제 #4
0
def main():
    network.gas_price(GAS_PRICE)
    deployer = accounts.load(ACCOUNT)
    balance = deployer.balance()

    markets = []
    for is_put in [False, True]:
        market = create_market(deployer, is_put)
        markets.append(market)

    for market in markets:
        print(f"Deployed at: {market.address}")

    print(f"Gas used in deployment: {(balance - deployer.balance()) / 1e18:.4f} ETH")
예제 #5
0
def main():
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
        datefmt='%m-%d %H:%M',
        filename='apex.log',
        filemode='w')
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s %(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)
    user = get_account()
    assets = get_amms()
    logging.info('Connected with: %s' % user)
    network.gas_price(1000000000)
    network.main.gas_buffer(1.25)
    timer = 0
    if UPDATES_FROM_TELEGRAM == True:
        telegram_send_initialise()
    while True:
        orders = get_orders(assets)
        get_prices(assets)
        account_balances = get_account_balances()

        if timer % TRAILING_ORDER_TIMER == 0:
            trailing_order_update(LOB, assets, orders, user)
        logging.info('%s outstanding orders' % len(orders))
        for order in orders:
            if quick_check_can_execute_order(order, account_balances):
                if full_check_can_execute_order(ClearingHouse, order,
                                                account_balances):
                    try:
                        execute_order(LOB, order, user)
                    except:
                        next

        if timer % TELEGRAM_BOT_TIMER == 0 and UPDATES_FROM_TELEGRAM == True:
            telegram_send_update_health(numOrders=len(orders))

        time.sleep(POLLING_TIMER)
        timer = timer + 1
예제 #6
0
def main():
    privateKey = 'private key'
    factoryAddr = '0x44226Fc17074A4F019FAA6412E85eff3e01b8368'  # factory addr on kovan

    acc = accounts.add(privateKey)

    factory = Factory(acc, factoryAddr)

    network.gas_limit(10000000)  # Not work without it on kovan
    network.gas_price(Wei('1 gwei'))  # Not work without it on kovan

    privatePool = False
    managerName = 'Test'
    poolName = 'Test'
    assets = ['sETH', 'sBTC']

    managerFeeNumerator = 100
    secho('create pool...', fg="green")

    pool = factory.createPool(privatePool, managerName, poolName, assets,
                              managerFeeNumerator)
    secho(f'pool {pool.address} created', fg="green")

    comp = pool.getComposition()
    secho(f'composition: {comp}', fg="yellow")

    sUSD = pool.getAsset('sUSD')
    secho('approve sUSD...', fg="green")
    tx = sUSD.contract.approve(pool.address, Wei('100000000000000 ether'),
                               {'from': acc})
    tx.wait(1)

    secho('deposit sUSD...', fg="green")
    tx = pool.deposit(Wei('5 ether'))
    tx.wait(1)

    secho('exchange synths...', fg="green")
    tx = pool.exchange('sUSD', Wei('5 ether'), 'sETH')
    tx.wait(1)

    comp = pool.getComposition()
    secho(f'composition: {comp}', fg="yellow")
예제 #7
0
def cli(
    ctx,
    etherscan_token,
    gas_speed,
    gas_max_speed,
    gas_increment,
    gas_block_duration,
    network,
):
    ctx.ensure_object(dict)

    # put this into the environment so that brownie sees it
    os.environ["ETHERSCAN_TOKEN"] = etherscan_token

    # setup the project and network the same way brownie's run helper does
    brownie_project = project.load(get_project_root())
    brownie_project.load_config()

    if network != "none":
        brownie_network.connect(network)

        logger.info(
            f"{brownie_project._name} is the active {network} project.")

        if network in ["mainnet", "mainnet-fork"]:
            # TODO: write my own strategy
            gas_strategy = GasNowScalingStrategy(
                initial_speed=gas_speed,
                max_speed=gas_max_speed,
                increment=gas_increment,
                block_duration=gas_block_duration,
            )
            gas_price(gas_strategy)
            logger.info(f"Default gas strategy: {gas_strategy}")
        elif network in ["bsc", "bsc-fork"]:
            gas_strategy = "10 gwei"
            gas_price(gas_strategy)
            logger.info(f"Default gas price: {gas_strategy}")
        elif network in ["matic", "matic-fork"]:
            gas_strategy = "1 gwei"
            gas_price(gas_strategy)
            logger.info(f"Default gas price: {gas_strategy}")
        else:
            logger.warning(
                "No default gas price or gas strategy has been set!")
    else:
        logger.warning(
            f"{brownie_project._name} is the active project. It is not conencted to any networks"
        )

    # pass the project on to the other functions
    ctx.obj["brownie_project"] = brownie_project
    def brownie_connect():
        # this allows later click commands to set the default. there might be a better way
        network = ctx.obj["brownie_network"] or ctx.obj.get("default_brownie_network")

        # setup the project and network the same way brownie's run helper does
        brownie_project = project.load(get_project_root(), "ArgobytesBrownieProject")
        brownie_project.load_config()

        ctx.obj["brownie_project"] = brownie_project

        if network == "none" or network is None:
            logger.warning(f"{brownie_project._name} is the active project. Not connected to any networks")
        else:
            brownie_network.connect(network)

            logger.info(f"{brownie_project._name} is the active {network} project.")

            if flashbot_account:
                print(f"Using {flashbot_account} for signing flashbot bundles.")
                flashbot(web3, flashbot_account)

            if network in ["mainnet", "mainnet-fork"]:
                # TODO: write my own strategy
                gas_strategy = GasNowScalingStrategy(
                    initial_speed=gas_speed,
                    max_speed=gas_max_speed,
                    increment=gas_increment,
                    block_duration=gas_block_duration,
                )
                gas_price(gas_strategy)
                logger.info(f"Default gas strategy: {gas_strategy}")
            elif network in ["bsc-main", "bsc-main-fork"]:
                gas_strategy = "5010000000"  # 5.01 gwei
                gas_price(gas_strategy)
                logger.info(f"Default gas price: {gas_strategy}")
            elif network in ["polygon", "polygon-fork"]:
                gas_strategy = "1010000000"  # "1.01 gwei"
                gas_price(gas_strategy)
                logger.info(f"Default gas price: {gas_strategy}")
            else:
                logger.warning("No default gas price or gas strategy has been set!")
예제 #9
0
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()
예제 #10
0
 def set_default(self, strategy):
     gas_price(strategy)
예제 #11
0
from brownie import accounts, interface, Contract
from brownie import (Bank, SimpleBankConfig, SimplePriceOracle,
                     PancakeswapGoblin, StrategyAllBNBOnly, StrategyLiquidate,
                     StrategyWithdrawMinimizeTrading,
                     StrategyAddTwoSidesOptimal, PancakeswapGoblinConfig,
                     TripleSlopeModel, ConfigurableInterestBankConfig,
                     PancakeswapPool1Goblin, ProxyAdminImpl,
                     TransparentUpgradeableProxyImpl)
from brownie import network
from .utils import *
from .constant import *
import eth_abi

# set default gas price
network.gas_price('10 gwei')


def deploy(deployer):
    triple_slope_model = TripleSlopeModel.deploy({'from': deployer})

    # min debt 0.2 BNB at 10 gwei gas price (killBps 5% -> at least 0.01BNB bonus)
    # reserve pool bps 1000 (10%)
    # kill bps 500 (5%)
    bank_config = ConfigurableInterestBankConfig.deploy(
        2 * 10**17, 1000, 500, triple_slope_model, {'from': deployer})

    proxy_admin = ProxyAdminImpl.deploy({'from': deployer})
    bank_impl = Bank.deploy({'from': deployer})
    bank = TransparentUpgradeableProxyImpl.deploy(
        bank_impl, proxy_admin, bank_impl.initialize.encode_input(bank_config),
        {'from': deployer})
from brownie import interface, accounts, Contract
from brownie import AggregatorOracle, BandAdapterOracle, ChainlinkAdapterOracle, HomoraBank, CoreOracle, UniswapV2SpellV1
from .utils import *
from .tokens import *
import eth_abi

from brownie.network.gas.strategies import GasNowScalingStrategy
from brownie import network

gas_strategy = GasNowScalingStrategy(
    initial_speed="fast", max_speed="fast", increment=1.085, block_duration=20)

# set gas strategy
network.gas_price(gas_strategy)

token_names = ['weth', 'aave', 'band', 'comp', 'crv', 'dai',
               'dpi', 'link', 'mkr', 'perp', 'ren', 'renbtc',
               'snx', 'susd', 'sushi', 'uma', 'uni', 'usdc', 'usdt', 'wbtc', 'yfi'
               ]
tokens = [
    Tokens.WETH,
    Tokens.AAVE,
    Tokens.BAND,
    Tokens.COMP,
    Tokens.CRV,
    Tokens.DAI,
    Tokens.DPI,
    Tokens.LINK,
    Tokens.MKR,
    Tokens.PERP,
    Tokens.REN,
예제 #13
0

API_VERSION = config["dependencies"][0].split("@")[-1]
Vault = project.load(
    Path.home() / ".brownie" / "packages" / config["dependencies"][0]
).Vault

# 1INCH token
WANT_TOKEN = "0x111111111117dC0aa78b770fA6A738034120C302"
STRATEGIST_ADDR = "0xAa9E20bAb58d013220D632874e9Fe44F8F971e4d"
# Deployer as governance
GOVERNANCE = STRATEGIST_ADDR
# Rewards to deployer,we can change it to yearn governance after approval
REWARDS = STRATEGIST_ADDR
# Set gas price as fast
gas_price(62 * 1e9)


def get_address(msg: str) -> str:
    while True:
        val = input(msg)
        if is_checksum_address(val):
            return val
        else:
            addr = web3.ens.address(val)
            if addr:
                print(f"Found ENS '{val}' [{addr}]")
                return addr
        print(f"I'm sorry, but '{val}' is not a checksummed address or ENS")

예제 #14
0
VAULT_REGISTRY = "0xE15461B18EE31b7379019Dc523231C57d1Cbc18c"
SHARER = "0x2C641e14AfEcb16b4Aa6601A40EE60c3cc792f7D"
STRATEGIST_MULTISIG = "0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7"
TREASURY = "0x93A62dA5a14C80f265DAbC077fCEE437B1a0Efde"
KEEP3R_MANAGER = "0x13dAda6157Fee283723c0254F43FF1FdADe4EEd6"
DEV_MS = "0x846e211e8ba920B353FB717631C015cf04061Cc9"
BRS_MS = "0xcF02A27199b4d2c842B442B08b55bBe27ca6Cb7C"
# Deployer as governance
GOVERNANCE = STRATEGIST_ADDR
# Rewards to deployer,we can change it to yearn governance after approval
REWARDS = STRATEGIST_ADDR
# Set this to true if we are using a experimental deploy flow
EXPERIMENTAL_DEPLOY = True
BASE_GASLIMIT = 400000
# Set gas price as fast
gas_price(200 * 1e9)


def get_address(msg: str) -> str:
    while True:
        val = input(msg)
        if is_checksum_address(val):
            return val
        else:
            addr = web3.ens.address(val)
            if addr:
                print(f"Found ENS '{val}' [{addr}]")
                return addr
        print(f"I'm sorry, but '{val}' is not a checksummed address or ENS")

예제 #15
0
파일: main.py 프로젝트: thegismar/auc
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)
예제 #16
0
VAULT_REGISTRY = "0xE15461B18EE31b7379019Dc523231C57d1Cbc18c"
SHARER = "0x2C641e14AfEcb16b4Aa6601A40EE60c3cc792f7D"
STRATEGIST_MULTISIG = "0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7"
TREASURY = "0x93A62dA5a14C80f265DAbC077fCEE437B1a0Efde"
KEEP3R_MANAGER = "0x13dAda6157Fee283723c0254F43FF1FdADe4EEd6"
DEV_MS = "0x846e211e8ba920B353FB717631C015cf04061Cc9"
# BRS_MS = "0xcF02A27199b4d2c842B442B08b55bBe27ca6Cb7C"
# Deployer as governance
GOVERNANCE = STRATEGIST_ADDR
# Rewards to deployer,we can change it to yearn governance after approval
REWARDS = STRATEGIST_ADDR
# Set this to true if we are using a experimental deploy flow
EXPERIMENTAL_DEPLOY = True
BASE_GASLIMIT = 400000
# Set gas price as fast
gas_price(70 * 1e9)


def get_address(msg: str) -> str:
    while True:
        val = input(msg)
        if is_checksum_address(val):
            return val
        else:
            addr = web3.ens.address(val)
            if addr:
                print(f"Found ENS '{val}' [{addr}]")
                return addr
        print(f"I'm sorry, but '{val}' is not a checksummed address or ENS")

예제 #17
0
def main():
    # os.makedirs(DEPLOY_DIR, exist_ok=True)

    print("account 0:", accounts[0])

    # todo: automatic price to match mainnet default speed
    gas_price("20 gwei")

    argobytes_tip_address = web3.ens.resolve("tip.satoshiandkin.eth")

    print(f"argobytes_tip_address: {argobytes_tip_address}")

    argobytes_flash_borrower_arbitragers = [
        accounts[0],
        accounts[1],
        accounts[2],
        accounts[3],
        accounts[4],
    ]

    starting_balance = accounts[0].balance()

    # TODO: docs for using ERADICATE2
    # TODO: openzepplin helper uses bytes32, but gastoken uses uint256.
    salt = ""

    # deploy a dsproxy just to compare gas costs
    # TODO: whats the deploy cost of DSProxyFactory?
    ds_proxy_factory = ArgobytesInterfaces.DSProxyFactory(DSProxyFactoryAddress, accounts[5])
    ds_proxy_factory.build()

    # deploy ArgobytesFactory
    # deploy ArgobytesFlashBorrower
    # clone ArgobytesFlashBorrower for accounts[0]
    (argobytes_factory, argobytes_flash_borrower, argobytes_clone) = get_or_clone_flash_borrower(
        accounts[0],
    )

    # deploy ArgobytesAuthority
    argobytes_authority = get_or_create(accounts[0], ArgobytesBrownieProject.ArgobytesAuthority, salt=salt)

    # quick_save_contract(argobytes_authority)

    # TODO: setup auth for the proxy
    # for now, owner-only access works, but we need to allow a bot in to call atomicArbitrage

    # deploy the main contracts
    get_or_create(accounts[0], ArgobytesBrownieProject.ArgobytesMulticall)

    # deploy base actions
    argobytes_trader = get_or_create(accounts[0], ArgobytesBrownieProject.ArgobytesTrader)

    # deploy all the exchange actions
    get_or_create(accounts[0], ArgobytesBrownieProject.ExampleAction)
    # get_or_create(accounts[0], ArgobytesBrownieProject.OneSplitOffchainAction)
    kyber_action = get_or_create(
        accounts[0], ArgobytesBrownieProject.KyberAction, constructor_args=[argobytes_tip_address]
    )
    get_or_create(accounts[0], ArgobytesBrownieProject.UniswapV1Action)
    get_or_create(accounts[0], ArgobytesBrownieProject.UniswapV2Action)
    # get_or_create(accounts[0], ArgobytesBrownieProject.ZrxV3Action)
    get_or_create(accounts[0], ArgobytesBrownieProject.Weth9Action)
    get_or_create(accounts[0], ArgobytesBrownieProject.CurveFiAction)

    # deploy leverage cyy3crv actions
    get_or_create(accounts[0], ArgobytesBrownieProject.EnterCYY3CRVAction)
    get_or_create(accounts[0], ArgobytesBrownieProject.ExitCYY3CRVAction)

    get_or_create(accounts[0], ArgobytesBrownieProject.EnterUnit3CRVAction)
    # get_or_create(accounts[0], ArgobytesBrownieProject.ExitUnit3CRVAction)

    bulk_actions = [
        # allow bots to call argobytes_trader.atomicArbitrage
        # TODO: allow bots to flash loan from WETH10 and DyDx and Uniswap and any other wrappers that we trust
        # TODO: think about this more
        (
            argobytes_authority,
            0,  # 0=CALL
            False,
            argobytes_authority.allow.encode_input(
                argobytes_flash_borrower_arbitragers,
                argobytes_trader,
                0,  # 0=CALL
                argobytes_trader.atomicArbitrage.signature,
            ),
        ),
    ]

    argobytes_clone.executeMany(bulk_actions)

    print("gas used by accounts[0]:", accounts[0].gas_used)

    ending_balance = accounts[0].balance()

    assert ending_balance < starting_balance

    print("ETH used by accounts[0]:", (starting_balance - ending_balance) / 1e18)

    """
    # save all the addresses we might use, not just ones for own contracts
    quick_save("CurveFiBUSD", CurveFiBUSDAddress)
    quick_save("CurveFiCompound", CurveFiCompoundAddress)
    quick_save("CurveFiPAX", CurveFiPAXAddress)
    quick_save("CurveFiREN", CurveFiRENAddress)
    quick_save("CurveFiSUSDV2", CurveFiSUSDV2Address)
    quick_save("CurveFiTBTC", CurveFiTBTCAddress)
    quick_save("CurveFiUSDT", CurveFiUSDTAddress)
    quick_save("CurveFiY", CurveFiYAddress)
    quick_save("KollateralInvoker", KollateralInvokerAddress)
    quick_save("KyberNetworkProxy", KyberNetworkProxyAddress)
    quick_save("KyberRegisterWallet", KyberRegisterWalletAddress)
    quick_save("OneSplit", OneSplitAddress)
    quick_save("SynthetixAddressResolver", SynthetixAddressResolverAddress)
    quick_save("UniswapFactory", UniswapV1FactoryAddress)
    quick_save("UniswapV2Router", UniswapV2RouterAddress)
    quick_save("YearnWethVault", YearnWethVaultAddress)

    # TODO: this list is going to get long. use tokenlists.org instead
    quick_save("DAI", DAIAddress)
    quick_save("cDAI", cDAIAddress)
    quick_save("cUSDC", cUSDCAddress)
    quick_save("sUSD", ProxysUSDAddress)
    quick_save("USDC", USDCAddress)
    quick_save("COMP", COMPAddress)
    quick_save("AAVE", AAVEAddress)
    quick_save("LINK", LINKAddress)
    quick_save("MKR", MKRAddress)
    quick_save("SNX", SNXAddress)
    quick_save("WBTC", WBTCAddress)
    quick_save("YFI", YFIAddress)
    quick_save("WETH9", WETH9Address)
    quick_save("yvyCRV", YVYCRVAddress)
    """

    # # give the argobytes_flash_borrower a bunch of coins. it will forward them when deploying the diamond
    # accounts[1].transfer(DevHardwareAddress, 50 * 1e18)
    # accounts[2].transfer(DevHardwareAddress, 50 * 1e18)
    # accounts[3].transfer(DevHardwareAddress, 50 * 1e18)
    # accounts[4].transfer(DevMetamaskAddress, 50 * 1e18)

    # make a clone vault w/ auth for accounts[5] and approve a bot to call atomicArbitrage. then print total gas
    starting_balance = accounts[5].balance()

    deploy_tx = argobytes_factory.createClone19(
        argobytes_flash_borrower.address,
        salt,
        {"from": accounts[5]},
    )

    argobytes_flash_borrower_clone_5 = ArgobytesBrownieProject.ArgobytesFlashBorrower.at(
        deploy_tx.return_value, accounts[5]
    )

    bulk_actions = [
        # allow bots to call argobytes_trader.atomicArbitrage
        # TODO: think about this more. the msg.sender might not be what we need
        (
            argobytes_authority,
            0,  # 0=Call
            False,
            argobytes_authority.allow.encode_input(
                argobytes_flash_borrower_arbitragers,
                argobytes_trader,
                1,  # 1=delegatecall
                argobytes_trader.atomicArbitrage.signature,
            ),
        ),
        # TODO: gas_token.buyAndFree or gas_token.free depending on off-chain balance/price checks
    ]

    argobytes_flash_borrower_clone_5.executeMany(bulk_actions)

    ending_balance = accounts[5].balance()

    print(
        "ETH used by accounts[5] to deploy a proxy with auth:",
        (starting_balance - ending_balance) / 1e18,
    )

    # make a clone for accounts[6]. then print total gas
    starting_balance = accounts[6].balance()

    # TODO: optionally free gas token
    deploy_tx = argobytes_factory.createClone19(
        argobytes_flash_borrower.address,
        salt,
        {"from": accounts[6]},
    )

    argobytes_flash_borrower_clone_6 = ArgobytesBrownieProject.ArgobytesFlashBorrower.at(
        deploy_tx.return_value, accounts[6]
    )

    ending_balance = accounts[6].balance()

    print(
        "ETH used by accounts[6] to deploy a proxy:",
        (starting_balance - ending_balance) / 1e18,
    )

    # make a clone for accounts[7]. then print total gas
    starting_balance = accounts[7].balance()

    deploy_tx = argobytes_factory.createClone19(
        argobytes_flash_borrower.address,
        salt,
        accounts[7],
        {"from": accounts[7]},
    )

    argobytes_flash_borrower_clone_7 = ArgobytesBrownieProject.ArgobytesFlashBorrower.at(
        deploy_tx.return_value, accounts[7]
    )

    ending_balance = accounts[7].balance()

    print(
        "ETH used by accounts[7] to deploy a proxy:",
        (starting_balance - ending_balance) / 1e18,
    )
예제 #18
0
VAULT_REGISTRY = "0xE15461B18EE31b7379019Dc523231C57d1Cbc18c"
SHARER = "0x2C641e14AfEcb16b4Aa6601A40EE60c3cc792f7D"
STRATEGIST_MULTISIG = "0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7"
TREASURY = "0x93A62dA5a14C80f265DAbC077fCEE437B1a0Efde"
KEEP3R_MANAGER = "0x13dAda6157Fee283723c0254F43FF1FdADe4EEd6"
DEV_MS = "0x846e211e8ba920B353FB717631C015cf04061Cc9"
BRS_MS = "0xcF02A27199b4d2c842B442B08b55bBe27ca6Cb7C"
# Deployer as governance
GOVERNANCE = STRATEGIST_ADDR
# Rewards to deployer,we can change it to yearn governance after approval
REWARDS = STRATEGIST_ADDR
# Set this to true if we are using a experimental deploy flow
EXPERIMENTAL_DEPLOY = False
BASE_GASLIMIT = 400000
# Set gas price as fast
gas_price(10 * 1e9)


def get_address(msg: str) -> str:
    while True:
        val = input(msg)
        if is_checksum_address(val):
            return val
        else:
            addr = web3.ens.address(val)
            if addr:
                print(f"Found ENS '{val}' [{addr}]")
                return addr
        print(f"I'm sorry, but '{val}' is not a checksummed address or ENS")

예제 #19
0
def main():
    # Acocunts
    load_accounts()

    gas_strategy = GasNowScalingStrategy("fast", increment=1.2)
    gas_price(gas_strategy)

    # MONA Token
    access_control = deploy_access_control()
    mona_token = get_mona_token()

    # Get Contracts 
    genesis_staking = get_genesis_staking()
    parent_staking = get_parent_staking()
    lp_staking = get_lp_staking()
    rewards = get_rewards()

    # # Set Tokens Claimable
    genesis_staking.setTokensClaimable(False, {'from':accounts[0]})
    parent_staking.setTokensClaimable(False, {'from':accounts[0]})
    lp_staking.setTokensClaimable(False, {'from':accounts[0]})

    # Accounting snapshot
    last_rewards = rewards.lastRewardTime({'from':accounts[0]})
    print("Last Rewards: ", str(last_rewards))

    genesis_paid = rewards.genesisRewardsPaid({'from':accounts[0]})
    parent_paid = rewards.parentRewardsPaid({'from':accounts[0]})
    lp_paid = rewards.lpRewardsPaid({'from':accounts[0]})
    print("Rewards Paid: G:", str(genesis_paid), " P:", str(parent_paid), " L:",str(lp_paid))

    week_points0 = rewards.weeklyWeightPoints(0, {'from':accounts[0]})
    print("Weekly Points0:", str(week_points0))
    week_points1 = rewards.weeklyWeightPoints(1, {'from':accounts[0]})
    print("Weekly Points1:", str(week_points1))

    # # Rewards Contract
    new_rewards = deploy_new_rewards(mona_token,genesis_staking,parent_staking,lp_staking,
                                    access_control,REWARDS_START_TIME, last_rewards,
                                     genesis_paid, parent_paid, lp_paid)

    # Set weekly rewards
    set_bonus(genesis_staking, new_rewards)
    set_rewards(new_rewards)
    print("rewards per second for week[0] =",new_rewards.weeklyRewardsPerSecond(0)* 7*24*60*60 /TENPOW18)
    print("rewards per second for week[8]=",new_rewards.weeklyRewardsPerSecond(8)* 7*24*60*60/TENPOW18)

    new_rewards.setInitialPoints(0, week_points0[0], week_points0[1], week_points0[2],{'from': accounts[0]})
    new_rewards.setInitialPoints(1, week_points1[0], week_points1[1], week_points1[2],{'from': accounts[0]})

    # Add Minter permissions 
    access_control.addMinterRole(new_rewards, {'from': accounts[0]})

    # Set Rewards contract on staking pooks
    genesis_staking.setRewardsContract(new_rewards,{'from': accounts[0]})
    parent_staking.setRewardsContract(new_rewards,{'from': accounts[0]})
    lp_staking.setRewardsContract(new_rewards,{'from': accounts[0]}) 

    # Set Tokens Claimable
    genesis_staking.setTokensClaimable(True, {'from':accounts[0]})
    parent_staking.setTokensClaimable(True, {'from':accounts[0]})
    lp_staking.setTokensClaimable(True, {'from':accounts[0]})

    # Refresh the updated time to check it works
    new_rewards.updateRewards({'from': accounts[0]})