def our_available_balance(self, token: TEthfinexToken) -> Wad: return Wad.from_number(token.balance_of(self.our_address))
MKR_WRAPPER_ADDRESS = Address(ethfinex_config['tokenRegistry']['MKR']['wrapperAddress']) MKR_TOKEN_ADDRESS = Address(ethfinex_config['tokenRegistry']['MKR']['tokenAddress']) OMG_WRAPPER_ADDRESS = Address(ethfinex_config['tokenRegistry']['OMG']['wrapperAddress']) # DAI dai_token = ERC20Token(web3, DAI_TOKEN_ADDRESS) # you have to approve each token if it is its first time use dai_approve = dai_token.approve(DAI_WRAPPER_ADDRESS) print(dai_approve.transact()) dai_wrapper = TEthfinexToken(web3, DAI_WRAPPER_ADDRESS, "DAI") # lock token amount on wrapper dai_transact = dai_wrapper.deposit(Wad.from_number(0.40), 1) print(dai_transact.transact()) print(dai_wrapper.balance_of(Address(web3.eth.defaultAccount))) # MKR mkr_token = ERC20Token(web3, MKR_TOKEN_ADDRESS) mkr_approve = mkr_token.approve(MKR_WRAPPER_ADDRESS) print(mkr_approve.transact()) mkr_wrapper = TEthfinexToken(web3, MKR_WRAPPER_ADDRESS, "MKR") # lock token mkr_transact = mkr_wrapper.deposit(Wad.from_number(0.001), 1) print(mkr_transact.transact()) print(mkr_wrapper.balance_of(Address(web3.eth.defaultAccount))) # ETH # eth does not need to approve