Beispiel #1
0
def new_sai() -> SaiDeployment:
    def deploy(web3, contract_name, args=None):
        contract_factory = web3.eth.contract(
            abi=json.loads(
                pkg_resources.resource_string('keeper.api.feed',
                                              f'abi/{contract_name}.abi')),
            bytecode=pkg_resources.resource_string('keeper.api.feed',
                                                   f'abi/{contract_name}.bin'))
        tx_hash = contract_factory.deploy(args=args)
        receipt = web3.eth.getTransactionReceipt(tx_hash)
        return receipt['contractAddress']

    web3 = Web3(EthereumTesterProvider())
    web3.eth.defaultAccount = web3.eth.accounts[0]
    our_address = Address(web3.eth.defaultAccount)
    sai = DSToken.deploy(web3, 'SAI')
    sin = DSToken.deploy(web3, 'SIN')
    gem = DSToken.deploy(web3, 'ETH')
    pip = DSValue.deploy(web3)
    skr = DSToken.deploy(web3, 'SKR')
    pot = DSVault.deploy(web3)
    pit = DSVault.deploy(web3)
    tip = deploy(web3, 'Tip')
    dad = DSGuard.deploy(web3)
    jug = deploy(web3, 'SaiJug', [sai.address.address, sin.address.address])
    jar = deploy(
        web3, 'SaiJar',
        [skr.address.address, gem.address.address, pip.address.address])

    tub = Tub.deploy(web3, Address(jar), Address(jug), pot.address,
                     pit.address, Address(tip))
    tap = Tap.deploy(web3, tub.address, pit.address)
    top = Top.deploy(web3, tub.address, tap.address)

    # set permissions
    dad.permit(DSGuard.ANY, DSGuard.ANY, DSGuard.ANY).transact()
    tub.set_authority(dad.address)
    for auth in [sai, sin, skr, pot, pit, tap, top]:
        auth.set_authority(dad.address).transact()

    # approve, mint some GEMs
    tub.approve(directly())
    gem.mint(Wad.from_number(1000000)).transact()

    web3.currentProvider.rpc_methods.evm_snapshot()
    return SaiDeployment(web3, our_address, gem, sai, sin, skr, tub, tap, top)
Beispiel #2
0
 def setup_method(self):
     self.web3 = Web3(EthereumTesterProvider())
     self.web3.eth.defaultAccount = self.web3.eth.accounts[0]
     self.dsvalue = DSValue.deploy(self.web3)
Beispiel #3
0
 def setup_method(self):
     self.web3 = Web3(EthereumTesterProvider())
     self.dsvalue = DSValue.deploy(self.web3)