def setup_method(self):
     self.web3 = web3()
     self.mcd = mcd(web3())
     self.keeper_address = keeper_address(web3())
     self.mcd.approve_dai(self.keeper_address)
     self.our_address = our_address(web3())
     self.mcd.approve_dai(self.our_address)
     self.collateral = self.mcd.collaterals['ETH-B']
Exemple #2
0
    def setup_method(self):
        self.web3 = web3()
        self.our_address = our_address(self.web3)
        self.keeper_address = keeper_address(self.web3)
        self.other_address = other_address(self.web3)
        self.gal_address = gal_address(self.web3)
        self.mcd = mcd(self.web3)
        self.flopper = self.mcd.flopper
        self.flopper.approve(
            self.mcd.vat.address,
            approval_function=hope_directly(from_address=self.keeper_address))
        self.flopper.approve(
            self.mcd.vat.address,
            approval_function=hope_directly(from_address=self.other_address))

        self.keeper = AuctionKeeper(args=args(
            f"--eth-from {self.keeper_address} "
            f"--type flop "
            f"--from-block 1 "
            f"--bid-check-interval 0.05 "
            f"--model ./bogus-model.sh"),
                                    web3=self.web3)
        self.keeper.approve()

        reserve_dai(self.mcd, self.mcd.collaterals['ETH-C'],
                    self.keeper_address, Wad.from_number(200.00000))
        reserve_dai(self.mcd, self.mcd.collaterals['ETH-C'],
                    self.other_address, Wad.from_number(200.00000))

        self.sump = self.mcd.vow.sump()  # Rad
    def setup_method(self):
        self.web3 = web3()
        self.our_address = our_address(self.web3)
        self.keeper_address = keeper_address(self.web3)
        self.other_address = other_address(self.web3)
        self.gal_address = gal_address(self.web3)
        self.mcd = mcd(self.web3)
        self.flopper = self.mcd.flopper
        self.flopper.approve(
            self.mcd.vat.address,
            approval_function=hope_directly(from_address=self.keeper_address))
        self.flopper.approve(
            self.mcd.vat.address,
            approval_function=hope_directly(from_address=self.other_address))

        self.keeper = AuctionKeeper(args=args(
            f"--eth-from {self.keeper_address} "
            f"--type flop "
            f"--from-block 1 "
            f"--model ./bogus-model.sh"),
                                    web3=self.web3)
        self.keeper.approve()

        assert isinstance(self.keeper.gas_price, DynamicGasPrice)
        self.default_gas_price = self.keeper.gas_price.get_gas_price(0)

        reserve_dai(self.mcd, self.mcd.collaterals['ETH-C'],
                    self.keeper_address, Wad.from_number(200.00000))
        reserve_dai(self.mcd, self.mcd.collaterals['ETH-C'],
                    self.other_address, Wad.from_number(200.00000))

        self.sump = self.mcd.vow.sump()  # Rad
Exemple #4
0
    def setup_method(self):
        self.web3 = web3()
        self.our_address = our_address(self.web3)
        self.keeper_address = keeper_address(self.web3)
        self.other_address = other_address(self.web3)
        self.gal_address = gal_address(self.web3)
        self.mcd = mcd(self.web3)
        self.flapper = self.mcd.flapper
        self.flapper.approve(self.mcd.mkr.address,
                             directly(from_address=self.other_address))

        self.keeper = AuctionKeeper(args=args(
            f"--eth-from {self.keeper_address} "
            f"--type flap "
            f"--from-block 1 "
            f"--model ./bogus-model.sh"),
                                    web3=self.web3)
        self.keeper.approve()

        mint_mkr(self.mcd.mkr, self.keeper_address, Wad.from_number(50000))
        mint_mkr(self.mcd.mkr, self.other_address, Wad.from_number(50000))

        assert isinstance(self.keeper.gas_price, DynamicGasPrice)
        # Since no args were assigned, gas strategy should return a GeometricGasPrice starting at 10 Gwei
        self.default_gas_price = 10 * DynamicGasPrice.GWEI
Exemple #5
0
 def setup_class(cls):
     cls.web3 = web3()
     cls.mcd = mcd(cls.web3)
     cls.collateral = collateral_clip(cls.mcd)
     cls.dai_collateral = cls.mcd.collaterals['ETH-C']
     cls.clipper = cls.collateral.clipper
     cls.keeper_address = keeper_address(cls.web3)
     cls.gal_address = gal_address(cls.web3)
     cls.other_address = other_address(cls.web3)
Exemple #6
0
 def setup_class(self):
     """ I'm excluding initialization of a specific collateral perchance we use multiple collaterals
     to improve test speeds.  This prevents us from instantiating the keeper as a class member. """
     self.web3 = web3()
     self.mcd = mcd(self.web3)
     self.keeper_address = keeper_address(self.mcd.web3)
     self.web3.eth.defaultAccount = self.keeper_address.address
     self.collateral = self.mcd.collaterals['ETH-A']
     self.collateral.approve(self.keeper_address)
     assert self.collateral.gem.deposit(Wad.from_number(1)).transact()
     self.ilk = self.collateral.ilk
Exemple #7
0
 def setup_class(cls):
     cls.web3 = web3()
     cls.our_address = our_address(cls.web3)
     cls.gal_address = gal_address(cls.web3)
     cls.keeper_address = keeper_address(cls.web3)
     cls.other_address = other_address(cls.web3)
     cls.mcd = mcd(cls.web3)
     cls.flopper = cls.mcd.flopper
     cls.flopper.approve(
         cls.mcd.vat.address,
         approval_function=hope_directly(from_address=cls.keeper_address))
     cls.flopper.approve(
         cls.mcd.vat.address,
         approval_function=hope_directly(from_address=cls.other_address))
Exemple #8
0
 def setup_class(self):
     """ I'm excluding initialization of a specific collateral perchance we use multiple collaterals
     to improve test speeds.  This prevents us from instantiating the keeper as a class member. """
     self.web3 = web3()
     self.mcd = mcd(self.web3)
     self.keeper_address = keeper_address(self.web3)
     self.collateral = self.mcd.collaterals['ETH-B']
     self.keeper = AuctionKeeper(args=args(
         f"--eth-from {self.keeper_address.address} "
         f"--type flip "
         f"--from-block 1 "
         f"--ilk {self.collateral.ilk.name} "
         f"--bid-check-interval 0.03 "
         f"--model ./bogus-model.sh"),
                                 web3=self.mcd.web3)
     self.keeper.approve()
Exemple #9
0
    def setup_method(self):
        self.web3 = web3()
        self.our_address = our_address(self.web3)
        self.keeper_address = keeper_address(self.web3)
        self.other_address = other_address(self.web3)
        self.gal_address = gal_address(self.web3)
        self.mcd = mcd(self.web3)
        self.flapper = self.mcd.flapper
        self.flapper.approve(self.mcd.mkr.address, directly(from_address=self.other_address))

        self.keeper = AuctionKeeper(args=args(f"--eth-from {self.keeper_address} "
                                              f"--type flap "
                                              f"--from-block 1 "
                                              f"--model ./bogus-model.sh"), web3=self.web3)
        self.keeper.approve()

        mint_mkr(self.mcd.mkr, self.keeper_address, Wad.from_number(50000))
        mint_mkr(self.mcd.mkr, self.other_address, Wad.from_number(50000))
Exemple #10
0
    def setup_class(self):
        """ I'm excluding initialization of a specific collateral perchance we use multiple collaterals
        to improve test speeds.  This prevents us from instantiating the keeper as a class member. """
        self.web3 = web3()
        self.mcd = mcd(self.web3)
        self.c = self.mcd.collaterals['ETH-C']
        self.keeper_address = keeper_address(self.web3)
        self.keeper = AuctionKeeper(args=args(f"--eth-from {self.keeper_address.address} "
                                     f"--type flip "
                                     f"--from-block 1 "
                                     f"--ilk {self.c.ilk.name} "
                                     f"--model ./bogus-model.sh"), web3=self.mcd.web3)
        self.keeper.approve()

        # Keeper won't bid with a 0 Dai balance
        purchase_dai(Wad.from_number(20), self.keeper_address)
        assert self.mcd.dai_adapter.join(self.keeper_address, Wad.from_number(20)).transact(
            from_address=self.keeper_address)
Exemple #11
0
 def teardown_class(cls):
     cls.mcd = mcd(web3())
     if not repay_urn(cls.mcd, c(cls.mcd), gal_address(web3())):
         liquidate_urn(cls.mcd, c(cls.mcd), gal_address(web3()), keeper_address(web3()))
     kill_other_threads()
Exemple #12
0
 def teardown_class(cls):
     cls.eliminate_queued_debt(web3(), mcd(web3()), keeper_address(web3()))
 def setup_class(self):
     self.mcd = mcd(web3())
     self.strategy = FlopperStrategy(self.mcd.flopper)
     self.mock_flopper = MockFlopper()
 def teardown_class(cls):
     cls.cleanup_debt(web3(), mcd(web3()), other_address(web3()))
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

from pyflex.numeric import Wad, Ray, Rad
from tests.conftest import keeper_address, geb, other_address, reserve_system_coin, web3

geb = geb(web3())
collateral = geb.collaterals['ETH-C']
keeper_address = keeper_address(web3())
seller = other_address(web3())

amount = Wad.from_number(float(sys.argv[1]))
assert amount > Wad(0)

web3().eth.defaultAccount = seller.address
collateral.approve(seller)
geb.approve_system_coin(seller)

reserve_system_coin(geb, geb.collaterals['ETH-C'], seller, amount, Wad.from_number(2))
assert geb.system_coin_adapter.exit(seller, amount).transact(from_address=seller)
assert geb.system_coin.transfer_from(seller, keeper_address, amount).transact(from_address=seller)
print(f'Purchased {str(amount)} system coin, keeper token balance is {str(geb.system_coin.balance_of(keeper_address))}')
Exemple #16
0
 def teardown_class(cls):
     cls.mcd = mcd(web3())
     cls.liquidate_urn(web3(), cls.mcd, c(cls.mcd), gal_address(web3()),
                       our_address(web3()))
Exemple #17
0
 def setup_method(self):
     """ I'm excluding initialization of a specific collateral perchance we use multiple collaterals
     to improve test speeds.  This prevents us from instantiating the keeper as a class member. """
     self.web3 = web3()
     self.keeper_address = keeper_address(self.web3)
 def teardown_class(cls):
     w3 = web3()
     cls.eliminate_queued_debt(w3, mcd(w3), keeper_address(w3))
Exemple #19
0
 def setup_class(cls):
     cls.mcd = mcd(web3())
     cls.strategy = FlopperStrategy(cls.mcd.flopper)
     cls.mock_flopper = MockFlopper()
Exemple #20
0
                    action='store_true',
                    default=False,
                    help="Print surplus and debt balances in the Vow")
parser.add_argument('--auctions',
                    dest='auctions',
                    action='store_true',
                    default=False,
                    help="Dump auction details")
parser.add_argument('--missed-flops',
                    dest='missed_flops',
                    action='store_true',
                    default=False,
                    help="List flops which were not bid upon")
arguments = parser.parse_args(sys.argv[1:])

mcd = mcd(web3())
address = gal_address(web3())


def print_balances():
    joy = mcd.vat.dai(mcd.vow.address)
    awe = mcd.vat.sin(mcd.vow.address)
    woe = (awe - mcd.vow.sin()) - mcd.vow.ash()
    print(f"joy={str(joy)[:6]}, awe={str(awe)[:9]}, woe={str(woe)[:9]}, "
          f"Sin={str(mcd.vow.sin())[:9]}, Ash={str(mcd.vow.ash())[:9]}, "
          f"debt={str(mcd.vat.debt())[:9]}, vice={str(mcd.vat.vice())[:9]}")
    #f"bump={str(mcd.vow.bump())[:9]}, sump={str(mcd.vow.sump())[:9]}")


def print_auctions():
    pprint(mcd.active_auctions())
Exemple #21
0
# Copyright (C) 2019 EdNoepel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

from pyflex.numeric import Wad, Ray, Rad
from tests.conftest import keeper_address, geb, mint_prot, web3

geb = geb(web3())
collateral = geb.collaterals['ETH-C']
keeper_address = keeper_address(web3())

amount = Wad.from_number(float(sys.argv[1]))
assert amount > Wad(0)

mint_prot(geb.prot, keeper_address, amount)

print(f'Minted {str(amount)} protocol tokens, keeper token balance is {str(geb.prot.balance_of(keeper_address))}')
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

from pyflex.numeric import Wad, Ray, Rad
from tests.conftest import geb, set_collateral_price, web3

geb = geb(web3())
price = Wad.from_number(float(
    sys.argv[1])) if len(sys.argv) > 1 else Wad.from_number(200)
collateral_type_name = str(sys.argv[2]) if len(sys.argv) > 2 else 'ETH-A'
set_collateral_price(geb, geb.collaterals[collateral_type_name], price)
print(
    f"safety_price={str(geb.safe_engine.collateral_type(collateral_type_name).safety_price)[:9]}"
)
print(
    f"liquidation_price={str(geb.safe_engine.collateral_type(collateral_type_name).liquidation_price)[:9]}"
)
Exemple #23
0
 def setup_class(self):
     dss_deployment = mcd(web3())
     self.ilk = dss_deployment.collaterals['ETH-A'].ilk
     self.cdpmanager = CdpManager(
         web3(), Address("0xa616ad7d4562dcd9208425af4038defd0a9057b0"))
Exemple #24
0
 def teardown_class(cls):
     flog_and_heal(web3(),
                   mcd(web3()),
                   past_blocks=1200,
                   require_heal=False)
Exemple #25
0
 def setup_class(self):
     dss_deployment = mcd(web3())
     self.ilk = dss_deployment.collaterals['ETH-A'].ilk
     self.cdpmanager = CdpManager(
         web3(), Address("0x84617303947304444Ceb641582c024f277BBF4Ff"))
Exemple #26
0
# This file is part of Maker Keeper Framework.
#
# Copyright (C) 2019 EdNoepel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

from pymaker.numeric import Wad, Ray, Rad
from tests.conftest import mcd, set_collateral_price, web3

mcd = mcd(web3())
price = Wad.from_number(float(
    sys.argv[1])) if len(sys.argv) > 1 else Wad.from_number(200)
ilk_name = str(sys.argv[2]) if len(sys.argv) > 2 else 'ETH-A'
set_collateral_price(mcd, mcd.collaterals[ilk_name], price)
print(f"spot={str(mcd.vat.ilk(ilk_name).spot)[:9]}")
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

from pyflex.numeric import Wad, Ray, Rad
from tests.conftest import geb, auction_income_recipient_address, web3, wrap_eth

geb = geb(web3())
address = auction_income_recipient_address(web3())


def create_safe_with_surplus():
    c = geb.collaterals['ETH-A']
    collateral_type = geb.safe_engine.collateral_type(c.collateral_type.name)
    delta_collateral = Wad.from_number(float(sys.argv[1]))

    wrap_eth(mcd, address, delta_collateral)
    c.approve(address)
    assert c.adapter.join(address,
                          delta_collateral).transact(from_address=address)

    delta_debt = (delta_collateral *
                  Wad(collateral_type.spot)) * Wad.from_number(0.99)
Exemple #28
0
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

from pymaker.numeric import Wad, Ray, Rad
from tests.conftest import keeper_address, mcd, mint_mkr, web3

mcd = mcd(web3())
collateral = mcd.collaterals['ETH-C']
keeper_address = keeper_address(web3())

amount = Wad.from_number(float(sys.argv[1]))
assert amount > Wad(0)

mint_mkr(mcd.mkr, keeper_address, amount)

print(
    f'Minted {str(amount)} MKR, keeper token balance is {str(mcd.mkr.balance_of(keeper_address))}'
)