Example #1
0
    def setup_method(self):
        self.web3 = Web3(HTTPProvider("http://localhost:8555"))
        self.web3.eth.defaultAccount = self.web3.eth.accounts[0]
        self.our_address = Address(self.web3.eth.defaultAccount)
        self.dai = DSToken.deploy(self.web3, 'DAI')
        self.gem = DSToken.deploy(self.web3, 'MKR')
        self.flopper = Flopper.deploy(self.web3, self.dai.address, self.gem.address)

        # so the Flopper can mint MKR
        dad = DSGuard.deploy(self.web3)
        dad.permit(self.flopper.address, self.gem.address, DSGuard.ANY).transact()
        self.gem.set_authority(dad.address).transact()
Example #2
0
    def setup_method(self):
        self.web3 = Web3(HTTPProvider("http://localhost:8555"))
        self.web3.eth.defaultAccount = self.web3.eth.accounts[0]
        self.keeper_address = Address(self.web3.eth.defaultAccount)
        self.gal_address = Address(self.web3.eth.accounts[1])
        self.other_address = Address(self.web3.eth.accounts[2])

        # GemMock version of DSToken with push(bytes32, uint function) an hope(address)
        gem_abi = Contract._load_abi(__name__,
                                     '../lib/pymaker/tests/abi/GemMock.abi')
        gem_bin = Contract._load_bin(__name__,
                                     '../lib/pymaker/tests/abi/GemMock.bin')
        self.dai_addr = Contract._deploy(self.web3, gem_abi, gem_bin, [b'DAI'])
        self.dai = DSToken(web3=self.web3, address=self.dai_addr)
        self.dai.mint(Wad.from_number(10000000)).transact()
        self.dai.transfer(self.other_address,
                          Wad.from_number(1000000)).transact()
        self.mkr = DSToken.deploy(self.web3, 'MKR')
        self.flopper = Flopper.deploy(self.web3, self.dai.address,
                                      self.mkr.address)

        # so the Flopper can mint MKR
        dad = DSGuard.deploy(self.web3)
        dad.permit(self.flopper.address, self.mkr.address,
                   DSGuard.ANY).transact()
        self.mkr.set_authority(dad.address).transact()

        self.keeper = AuctionKeeper(args=args(
            f"--eth-from {self.keeper_address} "
            f"--flopper {self.flopper.address} "
            f"--model ./bogus-model.sh"),
                                    web3=self.web3)

        self.keeper.approve()

        self.model = MagicMock()
        self.model.get_stance = MagicMock(return_value=None)
        self.model_factory = self.keeper.auctions.model_factory
        self.model_factory.create_model = MagicMock(return_value=self.model)
Example #3
0
    def deploy(web3: Web3, debt_ceiling: Wad):
        assert isinstance(web3, Web3)

        vat = Vat.deploy(web3=web3)

        pit = Pit.deploy(web3=web3, vat=vat.address)
        assert pit.file_global_line(debt_ceiling).transact()  # Global debt Ceiling
        assert vat.rely(pit.address).transact()

        dai = DSToken.deploy(web3=web3, symbol='DAI')
        dai_adapter = DaiAdapter.deploy(web3=web3, vat=vat.address, dai=dai.address)
        dai_move = DaiVat.deploy(web3=web3, vat=vat.address)
        assert vat.rely(dai_adapter.address).transact()
        assert vat.rely(dai_move.address).transact()

        mkr = DSToken.deploy(web3=web3, symbol='MKR')

        # TODO: use a DSProxy
        mom = DSGuard.deploy(web3)
        assert mom.permit(DSGuard.ANY, DSGuard.ANY, DSGuard.ANY).transact()
        assert dai.set_authority(mom.address).transact()
        assert mkr.set_authority(mom.address).transact()

        vow = Vow.deploy(web3=web3)
        drip = Drip.deploy(web3=web3, vat=vat.address)
        flap = Flapper.deploy(web3=web3, dai=dai_move.address, gem=mkr.address)

        assert vow.file_vat(vat).transact()
        assert vow.file_flap(flap).transact()
        assert vow.file_bump(Wad.from_number(1000)).transact()
        assert vow.file_sump(Wad.from_number(10)).transact()
        assert drip.file_vow(vow).transact()

        assert vat.rely(vow.address).transact()
        assert vat.rely(drip.address).transact()
        assert vat.rely(flap.address).transact()

        cat = Cat.deploy(web3=web3, vat=vat.address)
        assert cat.file_vow(vow).transact()
        assert cat.file_pit(pit).transact()

        flop = Flopper.deploy(web3=web3, dai=dai_move.address, gem=mkr.address)

        assert vow.file_flop(flop).transact()

        assert vat.rely(cat.address).transact()
        assert vat.rely(flop.address).transact()
        assert vow.rely(cat.address).transact()
        assert flop.rely(vow.address).transact()

        config = DssDeployment.Config(mom, vat, vow, drip, pit, cat, flap, flop, dai, dai_adapter, dai_move, mkr)
        deployment = DssDeployment(web3, config)

        collateral = Collateral.deploy(web3=web3, name='WETH', vat=vat)
        deployment.deploy_collateral(collateral,
                                     debt_ceiling=Wad.from_number(100000),
                                     penalty=Ray.from_number(1),
                                     flop_lot=Wad.from_number(10000),
                                     ratio=Ray.from_number(1.5),
                                     initial_price=Wad.from_number(219))

        return deployment