コード例 #1
0
 def unwrap_weth(self, gas_price):
     weth_address = Address(abis.weth_address)
     weth_contract = self.web3.eth.contract(address=abis.weth_address, abi=abis.weth_abi)
     weth_balance = weth_contract.functions.balanceOf(self.our_address.address).call()
     if weth_balance > 0:
         withdraw = Transact(self, self.web3, abis.weth_abi, weth_address, weth_contract, 'withdraw', [weth_balance])
         withdraw.transact (gas_price=gas_price)
         time.sleep(1)
         eth_balance = self.web3.eth.getBalance(self.our_address.address)
         self.logger.info(f"New ETH balance: {eth_balance/1e18}")
     else:
         logging.info(f"No WETH to unwrap")
コード例 #2
0
    def deploy_staking_rewards_factory():
        genesis_block_timestamp = int(self.web3.eth.getBlock('latest')['timestamp'])
        self.staking_rewards_factory_address = self._deploy(self.web3, self.staking_rewards_factory_abi, self.staking_rewards_factory_bin, [self.reward_token.address.address, genesis_block_timestamp + 10])
        self.staking_rewards_factory_contract = self._get_contract(self.web3, self.staking_rewards_factory_abi, self.staking_rewards_factory_address)

        self.liquidity_token = self.deploy_liquidity_token()

        staking_rewards_deploy_args = [self.liquidity_token.address.address, 10000]
        staking_rewards_deploy_tx = Transact(self, self.web3, self.staking_rewards_factory_abi, self.staking_rewards_factory_address, self.staking_rewards_factory_contract,
                        'deploy', staking_rewards_deploy_args)

        receipt = staking_rewards_deploy_tx.transact(from_address=self.our_address)
コード例 #3
0
    def approval_function(token: ERC20Token, spender_address: Address,
                          spender_name: str):
        address_to_check = kwargs[
            'from_address'] if 'from_address' in kwargs else Address(
                token.web3.eth.defaultAccount)

        move_contract = Contract._get_contract(web3=token.web3,
                                               abi=move_abi,
                                               address=token.address)
        if move_contract.functions.can(
                address_to_check.address,
                spender_address.address).call() is False:
            logger = logging.getLogger()
            logger.info(
                f"Approving {spender_name} ({spender_address}) to move our {token.address} directly"
            )

            hope = Transact(move_contract,
                            move_contract.web3, move_contract.abi,
                            Address(move_contract.address), move_contract,
                            'hope', [spender_address.address])

            if not hope.transact(**kwargs):
                raise RuntimeError("Approval failed!")
コード例 #4
0
ファイル: test_config.py プロジェクト: cdyfng/auction-keeper
 def test_empty_tx(self):
     empty_tx = Transact(self, self.web3, None, self.keeper_address, None,
                         None,
                         [self.keeper_address, Wad(0)])
     empty_tx.transact()