def exchange(self, sourceKey, sourceAmount, destinationKey): sourceKey = strTo32HexString(sourceKey) destinationKey = strTo32HexString(destinationKey) if not self.isAssetSupported(sourceKey): raise Exception('Source asset not supported') if not self.isAssetSupported(destinationKey): raise Exception('Destination asset not supported') return self.contract.exchange(sourceKey, sourceAmount, destinationKey, self.fromSigner)
def createPool( self, privatePool, managerName, poolName, assets=["sETH"], managerFeeNumerator=100, ): for i in range(len(assets)): assets[i] = strTo32HexString(assets[i]) createPoolTx = self.factory.createFund(privatePool, self.signer, managerName, poolName, managerFeeNumerator, assets, self.fromSigner) creationEvent = createPoolTx.events['FundCreated'] if not creationEvent: raise Exception('Fund not created') poolAddress = creationEvent['fundAddress'] pool = Pool(self.signer, poolAddress) return pool
def getExchangeRates(self): resolverAddress = self.getAddressResolver() resolver = Contract.from_abi('Address resolver', resolverAddress, address_resolver_abi) exchangeRatesAddress = resolver.getAddress( strTo32HexString('ExchangeRates')) return ExchangeRates(self.signer, exchangeRatesAddress)
def isAssetSupported(self, key, convert=False): if convert: key = strTo32HexString(key) return self.contract.isAssetSupported(key)
def removeAsset(self, key): key = strTo32HexString(key) if not self.isAssetSupported(key): raise Exception('Asset not supported') return self.contract.removeFromSupportedAssets(key, self.fromSigner)
def addAsset(self, key): key = strTo32HexString(key) if self.isAssetSupported(key): raise Exception('Asset already supported') return self.contract.addToSupportedAssets(key, self.fromSigner)
def assetValue(self, key): key = strTo32HexString(key) if not self.isAssetSupported(key): raise Exception('Asset not supported') return self.contract.assetValue(key)
def getAsset(self, key): key = strTo32HexString(key) proxy = self.contract.getAssetProxy(key) token = Token(proxy, self.signer) return token
def getEffectiveValue(self, source, amount, destination): source = strTo32HexString(source) destination = strTo32HexString(destination) return self.contract.effectiveValue(source, amount, destination)
def rateForCurrency(self, key): key = strTo32HexString(key) return self.contract.rateForCurrency(key)