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
def test_should_detect_flap(self, web3, mcd, c, gal_address, keeper_address): # given some MKR is available to the keeper and a count of flap auctions mint_mkr(mcd.mkr, keeper_address, Wad.from_number(50000)) kicks = mcd.flapper.kicks() # when surplus is generated create_cdp_with_surplus(mcd, c, gal_address) self.keeper.check_flap() wait_for_other_threads() # then ensure another flap auction was kicked off assert mcd.flapper.kicks() == kicks + 1 # clean up by letting the auction expire time_travel_by(web3, mcd.flapper.tau() + 1)
def test_should_detect_flap(self, web3, mcd, c, gal_address, keeper_address): # given some MKR is available to the keeper and a count of flap auctions mint_mkr(mcd.mkr, keeper_address, Wad.from_number(50000)) kicks = mcd.flapper.kicks() # when surplus is generated create_cdp_with_surplus(mcd, c, gal_address) self.keeper.check_flap() wait_for_other_threads() # then ensure another flap auction was kicked off kick = mcd.flapper.kicks() assert kick == kicks + 1 # clean up by letting someone else bid and waiting until the auction ends auction = self.flapper.bids(kick) assert self.flapper.tend(kick, auction.lot, Wad.from_number(30)).transact(from_address=self.other_address) time_travel_by(web3, mcd.flapper.ttl() + 1)
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))
# 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))}' )