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.gem_addr = Contract._deploy(self.web3, gem_abi, gem_bin, [b'ABC']) self.gem = DSToken(web3=self.web3, address=self.gem_addr) self.dai_addr = Contract._deploy(self.web3, gem_abi, gem_bin, [b'DAI']) self.dai = DSToken(web3=self.web3, address=self.dai_addr) self.flipper = Flipper.deploy(self.web3, self.dai.address, self.gem.address) # Set allowance to allow flipper to move dai and gem self.dai.approve(self.flipper.address).transact() self.dai.approve( self.flipper.address).transact(from_address=self.gal_address) self.dai.approve( self.flipper.address).transact(from_address=self.other_address) self.gem.approve( self.flipper.address).transact(from_address=self.gal_address) self.gem.approve( self.flipper.address).transact(from_address=self.other_address) self.keeper = AuctionKeeper(args=args( f"--eth-from {self.keeper_address} " f"--flipper {self.flipper.address} " f"--model ./bogus-model.sh"), web3=self.web3) self.keeper.approve() # So that `keeper_address` and `other_address` can bid in auctions, # they both need to have DAI in their accounts. self.dai.mint(Wad.from_number(20000000)).transact() self.dai.transfer(self.other_address, Wad.from_number(10000000)).transact() # So that `gal_address` can kick auction he need to have GEM in his accounts self.gem.mint(Wad.from_number(1000000)).transact() self.gem.transfer(self.gal_address, Wad.from_number(1000000)).transact() 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)
def setup_method(self): # Use Ganache docker container self.web3 = Web3(HTTPProvider("http://0.0.0.0:8555")) self.web3.eth.defaultAccount = Web3.toChecksumAddress( "0x9596C16D7bF9323265C2F2E22f43e6c80eB3d943") self.our_address = Address(self.web3.eth.defaultAccount) self.private_key = "0x91cf2cc3671a365fcbf38010ff97ee31a5b7e674842663c56769e41600696ead" register_private_key(self.web3, self.private_key) self.weth_address = Contract._deploy(self.web3, self.weth_abi, self.weth_bin, []) self.factory_address = Contract._deploy(self.web3, self.factory_abi, self.factory_bin, [self.our_address.address]) self.router_address = Contract._deploy( self.web3, self.router_abi, self.router_bin, [self.factory_address.address, self.weth_address.address]) self._weth_contract = Contract._get_contract(self.web3, self.weth_abi, self.weth_address) self.deploy_tokens() token_config = { "tokens": { "DAI": { "tokenAddress": self.ds_dai.address.address }, "KEEP": { "tokenAddress": self.ds_keep.address.address }, "LEV": { "tokenAddress": self.ds_lev.address.address, "tokenDecimals": 9 }, "USDC": { "tokenAddress": self.ds_usdc.address.address, "tokenDecimals": 6 }, "WBTC": { "tokenAddress": self.ds_wbtc.address.address, "tokenDecimals": 8 }, "WETH": { "tokenAddress": self.weth_address.address } } } # write token config with locally deployed addresses to file with open("test-token-config.json", "w+") as outfile: outfile.write(json.dumps(token_config))
def deploy(web3: Web3, dust_token: Address, dust_limit: Wad, price_oracle: Address, support_address: Optional[Address] = None): """Deploy a new instance of the `MatchingMarket` contract. Args: web3: An instance of `Web` from `web3.py`. dust_token: Address of token serving as unit of measurement for dust_limit dust_limit: The limit itself price_oracle: Exposes getPriceFor method for price conversion support_address: Ethereum address of the `MakerOtcSupportMethods` contract (optional). Returns: A `MatchingMarket` class instance. """ assert isinstance(dust_token, Address) assert isinstance(dust_limit, Wad) assert isinstance(price_oracle, Address) return MatchingMarket( web3=web3, address=Contract._deploy( web3, MatchingMarket.abi, MatchingMarket.bin, [dust_token.address, dust_limit.value, price_oracle.address]), support_address=support_address)
def deploy(web3: Web3, dai: Address, gem: Address): assert (isinstance(dai, Address)) assert (isinstance(gem, Address)) return Flipper(web3=web3, address=Contract._deploy(web3, Flipper.abi, Flipper.bin, [dai.address, gem.address]))
def deploy(web3: Web3, vat: Address): assert isinstance(web3, Web3) assert isinstance(vat, Address) return Cat(web3=web3, address=Contract._deploy(web3, Cat.abi, Cat.bin, [vat.address]))
def deploy(web3: Web3, pit: Address, ilk: Ilk): assert isinstance(web3, Web3) assert isinstance(pit, Address) assert isinstance(ilk, Ilk) return Spotter( web3=web3, address=Contract._deploy(web3, Spotter.abi, Spotter.bin, [pit.address, ilk.toBytes()]))
def deploy(web3: Web3, vat: Address, ilk: Ilk, gem: Address): assert isinstance(web3, Web3) assert isinstance(vat, Address) assert isinstance(ilk, Ilk) assert isinstance(gem, Address) return GemMock(web3=web3, address=Contract._deploy(web3, GemMock.abi, GemMock.bin, [vat.address, ilk.toBytes(), gem.address]))
def deploy(web3: Web3): """Deploy a new instance of the `SimpleMarket` contract. Args: web3: An instance of `Web3` from `web3.py`. Returns: A `SimpleMarket` class instance. """ return SimpleMarket(web3=web3, address=Contract._deploy(web3, SimpleMarket.abi, SimpleMarket.bin, []))
def deploy(web3: Web3, fee_account: Address): """Deploy a new instance of the IDEX Exchange contract. Args: web3: An instance of `Web` from `web3.py`. fee_account: The address of the account which will collect fees. Returns: An `IDEX` class instance. """ return IDEX(web3=web3, address=Contract._deploy(web3, IDEX.abi, IDEX.bin, [fee_account.address]))
def deploy(web3: Web3): """Deploy a new instance of the `DSEthToken` contract. Args: web3: An instance of `Web` from `web3.py`. Returns: A `DSEthToken` class instance. """ return DSEthToken(web3=web3, address=Contract._deploy(web3, DSEthToken.abi, DSEthToken.bin, []))
def setup_method(self): GeneralMarketTest.setup_method(self) support_abi = Contract._load_abi(__name__, '../pymaker/abi/MakerOtcSupportMethods.abi') support_bin = Contract._load_bin(__name__, '../pymaker/abi/MakerOtcSupportMethods.bin') support_address = Contract._deploy(self.web3, support_abi, support_bin, []) self.price_oracle = OasisMockPriceOracle.deploy(self.web3) self.otc = MatchingMarket.deploy(self.web3, self.token1.address, Wad(0), self.price_oracle.address, support_address) self.otc.add_token_pair_whitelist(self.token1.address, self.token2.address).transact() self.otc.add_token_pair_whitelist(self.token1.address, self.token3.address).transact() self.otc.add_token_pair_whitelist(self.token2.address, self.token3.address).transact()
def deploy(web3: Web3, close_time: int): """Deploy a new instance of the `MatchingMarket` contract. Args: web3: An instance of `Web` from `web3.py`. close_time: Unix timestamp of when the market will close. Returns: A `MatchingMarket` class instance. """ return MatchingMarket(web3=web3, address=Contract._deploy(web3, MatchingMarket.abi, MatchingMarket.bin, [close_time]))
def setup_method(self): # Use Ganache docker container self.web3 = Web3(HTTPProvider("http://0.0.0.0:8555")) self.web3.eth.defaultAccount = Web3.toChecksumAddress( "0x9596C16D7bF9323265C2F2E22f43e6c80eB3d943") self.our_address = Address(self.web3.eth.defaultAccount) self.private_key = "0x91cf2cc3671a365fcbf38010ff97ee31a5b7e674842663c56769e41600696ead" register_private_key(self.web3, self.private_key) self.weth_address = Contract._deploy(self.web3, self.weth_abi, self.weth_bin, []) self.factory_address = Contract._deploy(self.web3, self.factory_abi, self.factory_bin, [self.our_address.address]) self.router_address = Contract._deploy( self.web3, self.router_abi, self.router_bin, [self.factory_address.address, self.weth_address.address]) self._weth_contract = Contract._get_contract(self.web3, self.weth_abi, self.weth_address) self.ds_dai = DSToken.deploy(self.web3, 'DAI') self.ds_dai.mint( Wad.from_number(500)).transact(from_address=self.our_address) self.token_dai = Token("DAI", self.ds_dai.address, 18) self.token_weth = Token("WETH", self.weth_address, 18) token_config = { "tokens": { "DAI": { "tokenAddress": self.ds_dai.address.address }, "WETH": { "tokenAddress": self.weth_address.address } } } # write token config with locally deployed addresses to file with open("test-token-config.json", "w+") as outfile: outfile.write(json.dumps(token_config))
def deploy(web3: Web3, zrx_asset: str): """Deploy a new instance of the 0x `Exchange` contract. Args: web3: An instance of `Web` from `web3.py`. zrx_token: The address of the ZRX token this exchange will use. Returns: A `ZrxExchange` class instance. """ return ZrxExchangeV2(web3=web3, address=Contract._deploy(web3, ZrxExchangeV2.abi, ZrxExchangeV2.bin, []))
def deploy(web3: Web3, close_time: int, support_address: Optional[Address] = None): """Deploy a new instance of the `MatchingMarket` contract. Args: web3: An instance of `Web` from `web3.py`. close_time: Unix timestamp of when the market will close. support_address: Ethereum address of the `MakerOtcSupportMethods` contract (optional). Returns: A `MatchingMarket` class instance. """ return MatchingMarket(web3=web3, address=Contract._deploy(web3, MatchingMarket.abi, MatchingMarket.bin, [close_time]), support_address=support_address)
def deploy(web3: Web3, symbol: str): """Deploy a new instance of the `DSToken` contract. Args: web3: An instance of `Web` from `web3.py`. symbol: Symbol of the new token. Returns: A `DSToken` class instance. """ assert (isinstance(symbol, str)) return DSToken(web3=web3, address=Contract._deploy(web3, DSToken.abi, DSToken.bin, [bytes(symbol, "utf-8")]))
def deploy(web3: Web3, sai: Address, sin: Address, skr: Address, gem: Address, gov: Address, pip: Address, pep: Address, vox: Address, pit: Address): assert(isinstance(sai, Address)) assert(isinstance(sin, Address)) assert(isinstance(skr, Address)) assert(isinstance(gem, Address)) assert(isinstance(gov, Address)) assert(isinstance(pip, Address)) assert(isinstance(pep, Address)) assert(isinstance(vox, Address)) assert(isinstance(pit, Address)) return Tub(web3=web3, address=Contract._deploy(web3, Tub.abi, Tub.bin, [sai.address, sin.address, skr.address, gem.address, gov.address, pip.address, pep.address, vox.address, pit.address]))
def deploy(web3: Web3, zrx_token: Address, token_transfer_proxy: Address): """Deploy a new instance of the 0x `Exchange` contract. Args: web3: An instance of `Web` from `web3.py`. zrx_token: The address of the ZRX token this exchange will use. token_transfer_proxy: The address of the token transfer proxy this exchange will use. Returns: A `ZrxExchange` class instance. """ return ZrxExchange(web3=web3, address=Contract._deploy(web3, ZrxExchange.abi, ZrxExchange.bin, [ zrx_token.address, token_transfer_proxy.address ]))
def deploy(web3: Web3, admin: Address, fee_account: Address, account_levels_addr: Address, fee_make: Wad, fee_take: Wad, fee_rebate: Wad): """Deploy a new instance of the `EtherDelta` contract. Args: web3: An instance of `Web` from `web3.py`. Returns: A `EtherDelta` class instance. """ return EtherDelta( web3=web3, address=Contract._deploy(web3, EtherDelta.abi, EtherDelta.bin, [ admin.address, fee_account.address, account_levels_addr.address, fee_make.value, fee_take.value, fee_rebate.value ]))
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.token1 = DSToken.deploy(self.web3, 'AAA') self.token1_tokenclass = Token('AAA', self.token1.address, 18) self.token1.mint(Wad.from_number(10000)).transact() self.token2 = DSToken.deploy(self.web3, 'BBB') self.token2_tokenclass = Token('BBB', self.token2.address, 6) self.token2.mint(Wad.from_number(10000)).transact() support_abi = Contract._load_abi(__name__, '../pymaker/abi/MakerOtcSupportMethods.abi') support_bin = Contract._load_bin(__name__, '../pymaker/abi/MakerOtcSupportMethods.bin') support_address = Contract._deploy(self.web3, support_abi, support_bin, []) price_oracle = OasisMockPriceOracle.deploy(self.web3) self.otc = MatchingMarket.deploy(self.web3, self.token1.address, Wad(0), price_oracle.address, support_address) self.otc.add_token_pair_whitelist(self.token1.address, self.token2.address).transact() self.otc.approve([self.token1, self.token2], directly())
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.other_address_1 = Address(self.web3.eth.accounts[1]) self.other_address_2 = Address(self.web3.eth.accounts[2]) self.dai = DSToken.deploy(self.web3, 'DAI') # we need a GemLike version of DSToken with push(bytes32, uint function) self.gem_addr = Contract._deploy(self.web3, Contract._load_abi(__name__, 'abi/GemMock.abi'), Contract._load_bin(__name__, 'abi/GemMock.bin'), [b'ABC']) self.gem = DSToken(web3=self.web3, address=self.gem_addr) self.flipper = Flipper.deploy(self.web3, self.dai.address, self.gem.address) # Set allowance to allow flipper to move dai and gem # With full deployment kick is only done by Cat via flip() which take care of allowance via gem.hope() self.gem.approve(self.flipper.address).transact() self.gem.approve(self.flipper.address).transact(from_address=self.other_address_1) self.dai.approve(self.flipper.address).transact()
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)
def deploy(web3: Web3): return DSAuth(web3=web3, address=Contract._deploy(web3, DSAuth.abi, DSAuth.bin, []))
def deploy(web3: Web3, pauseAddress: Address, vatAddress: Address): return DSSSpell(web3=web3, address=Contract._deploy(web3, DSSSpell.abi, DSSSpell.bin, [pauseAddress.address, vatAddress.address]))
def deploy(web3: Web3): return DSValue(web3=web3, address=Contract._deploy(web3, DSValue.abi, DSValue.bin, []))
def deploy(web3: Web3): return DSGuard(web3=web3, address=Contract._deploy(web3, DSGuard.abi, DSGuard.bin, []))
def deploy(web3: Web3, per: Ray): assert (isinstance(per, Ray)) return Vox(web3=web3, address=Contract._deploy(web3, Vox.abi, Vox.bin, [per.value]))
def deploy(web3: Web3, tub: Address, tap: Address): assert (isinstance(tub, Address)) assert (isinstance(tap, Address)) return Top(web3=web3, address=Contract._deploy(web3, Top.abi, Top.bin, [tub.address, tap.address]))
def deploy(web3: Web3, delay: int, owner: Address, ds_auth: DSAuth): return DSPause(web3=web3, address=Contract._deploy( web3, DSPause.abi, DSPause.bin, [delay, owner.address, ds_auth.address.address]))
def deploy(web3: Web3): return DSSBadSpell(web3=web3, address=Contract._deploy(web3, DSSBadSpell.abi, DSSBadSpell.bin, []))