Beispiel #1
0
 def countTx(self):
     service = TransactionService()
     data = service.countTx()
     total = 0
     for key in data.keys():
         total += int(data.get(key).get('count', 0))
     data['total'] = total
     return data
 def dailyPrvFee(self):
     txService = TransactionService()
     fromDate = self.params.get('from_date', '')
     toDate = self.params.get('to_date', '')
     limit = self.params.get('limit', 0)
     page = self.params.get('page', 0)
     data = txService.dailyPRVFee(fromDate=fromDate, toDate=toDate, page=int(page), limit=int(limit))
     return data
Beispiel #3
0
 def getAvgFee(self):
     service = TransactionService()
     tokenID = ''
     if hasattr(self, 'params') and 'token_id' in self.params:
         tokenID = self.params['token_id']
     if tokenID == '':
         return {"PRV": service.getAvgPRVFee()}
     else:
         return {tokenID: service.getAvgFeeToken(tokenID)}
    def getTotalStakedTokens(self):
        txService = TransactionService()

        stakingTxs = txService.listStakingTxs()
        total = 0
        for v in stakingTxs:
            total += v.get('metadata').get('StakingAmountShard')

        unstakeTxs = txService.listUnStakingTxs()
        # for v in unstakeTxs:
        total -= (len(unstakeTxs) * 1750000000000)

        return total
Beispiel #5
0
    def listWithdrawLiquidityTx(self):

        page = self.params.get('page', 0)
        limit = self.params.get('limit', 0)
        order_trend = self.params.get('order_trend', 'ASC')

        service = TransactionService()
        txs = service.listTxByMetadataType(metadataType=93,
                                           page=int(page),
                                           limit=int(limit),
                                           order_trend=order_trend)
        result = []
        for tx in txs:
            result.append(tx)
        return result
Beispiel #6
0
    def listDepositCentralizeBridgeTx(self):

        tokenID = self.params.get('token_id', '')
        page = self.params.get('page', 0)
        limit = self.params.get('limit', 0)
        order_trend = self.params.get('order_trend', 'ASC')

        if tokenID == '':
            return {}

        service = TransactionService()
        txs = service.listTxByMetadataType(metadataType=24,
                                           page=int(page),
                                           limit=int(limit),
                                           order_trend=order_trend,
                                           bridgeTokenID=tokenID)
        result = []
        for tx in txs:
            result.append(tx)
        return result
    def tokenFee(self):
        txService = TransactionService()

        tokenID = self.params.get('token_id', '')

        tokenServie = TokenService()
        tokens = tokenServie.listTokens()

        tokenName = tokens.get(tokenID).get('name')

        pdexService = PdexService()
        pdexTokens = pdexService.getTokens()

        data = txService.sumTokenFee(tokenID=tokenID)
        result = {
            'name': tokenName,
            'fee': data[tokenID] / float(pdexTokens.get(tokenID).get('exchange_rate')),
            'id': tokenID,
            'rate': pdexTokens.get(tokenID).get('exchange_rate'),
        }
        return result
Beispiel #8
0
    def listContributeLiquidityTx(self):

        page = self.params.get('page', 0)
        limit = self.params.get('limit', 0)
        group = self.params.get('group', 0)
        order_trend = self.params.get('order_trend', 'ASC')

        service = TransactionService()
        txs = service.listTxByMetadataType(metadataType=90,
                                           page=int(page),
                                           limit=int(limit),
                                           order_trend=order_trend)

        pDexService = PdexService()
        data = pDexService.getTokens()

        for tx in txs:
            metadata = tx.get('metadata')
            tokenIDStr = metadata.get('TokenIDStr')
            token = data.get(tokenIDStr)
            if token is not None:
                tokeName = token.get('name')
                metadata['TokenNameStr'] = tokeName
            else:
                metadata['TokenNameStr'] = tokenIDStr
            tx['metadata'] = metadata

        if int(group) == 1:
            result = {}
            for tx in txs:
                PDEContributionPairID = tx['metadata']['PDEContributionPairID']
                if PDEContributionPairID not in result:
                    result[PDEContributionPairID] = []
                result[PDEContributionPairID].append(tx)
            return result
        else:
            result = []
            for tx in txs:
                result.append(tx)
            return result
    def dailytokenFee(self):
        txService = TransactionService()

        tokenID = self.params.get('token_id', '')
        fromDate = self.params.get('from_date', '')
        toDate = self.params.get('to_date', '')
        limit = self.params.get('limit', 0)
        page = self.params.get('page', 0)

        tokenServie = TokenService()
        tokens = tokenServie.listTokens()

        tokenName = tokens.get(tokenID).get('name')

        pdexService = PdexService()
        pdexTokens = pdexService.getTokens()

        data = txService.dailyTokenFee(tokenID=tokenID, fromDate=fromDate, toDate=toDate, page=int(page),
                                       limit=int(limit))

        for i in data:
            i['fee'] = i['fee'] / float(pdexTokens.get(tokenID).get('exchange_rate'))
        return data
Beispiel #10
0
 def getTxByHash(self):
     service = TransactionService()
     hash = self.params.get('hash', '')
     data = service.getTxByHash(hash=hash)
     return data
 def prvFee(self):
     txService = TransactionService()
     return txService.sumPRVFee()