diff --git a/data/networks.js b/data/networks.js index d802998f4b..bb5e9eef5c 100644 --- a/data/networks.js +++ b/data/networks.js @@ -221,7 +221,7 @@ module.exports = [ // enabled: true, // icon: 'https://app.lunie.io/img/networks/polkadot-testnet.png', // slug: 'kusama' - // }, + // } // { // id: 'livepeer-mainnet', // title: 'Livepeer', diff --git a/docker-compose.yml b/docker-compose.yml index 02542d5cff..54f34e2057 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,11 @@ services: loki-url: "http://admin:${LOKI_PASSWORD}@monitoring.lunie.io:3100/loki/api/v1/push" deploy: replicas: 1 + resources: + limits: + memory: 2.5G + restart_policy: + condition: on-failure environment: - HASURA_URL=$HASURA_URL - HASURA_ADMIN_KEY=$HASURA_ADMIN_KEY diff --git a/lib/reducers/cosmosV0-reducers.js b/lib/reducers/cosmosV0-reducers.js index 5019fce1c2..08e12bcb6a 100644 --- a/lib/reducers/cosmosV0-reducers.js +++ b/lib/reducers/cosmosV0-reducers.js @@ -503,7 +503,28 @@ function transactionReducerV2(transaction, reducers, stakingDenom) { const filteredMessages = transaction.tx.value.msg.filter( ({ type }) => getMessageType(type) !== 'Unknown' ) - const returnedMessages = filteredMessages.map(({ value, type }, index) => ({ + const { claimMessages, otherMessages } = filteredMessages.reduce( + ({ claimMessages, otherMessages }, message) => { + // we need to aggregate all withdraws as we display them together in one transaction + if (getMessageType(message.type) === lunieMessageTypes.CLAIM_REWARDS) { + claimMessages.push(message) + } else { + otherMessages.push(message) + } + return { claimMessages, otherMessages } + }, + { claimMessages: [], otherMessages: [] } + ) + + // we need to aggregate claim rewards messages in one single one to avoid transaction repetition + const claimMessage = + claimMessages.length > 0 + ? claimRewardsMessagesAggregator(claimMessages) + : undefined + const allMessages = claimMessage + ? otherMessages.concat(claimMessage) // add aggregated claim message + : otherMessages + const returnedMessages = allMessages.map(({ value, type }, index) => ({ type: getMessageType(type), hash: transaction.txhash, height: transaction.height, @@ -637,7 +658,7 @@ function transactionDetailsReducer( break case lunieMessageTypes.CLAIM_REWARDS: details = claimRewardsDetailsReducer( - transaction.tx.value.msg, + message, reducers, transaction, stakingDenom @@ -662,6 +683,19 @@ function transactionDetailsReducer( } } +function claimRewardsMessagesAggregator(claimMessages) { + // reduce all withdraw messages to one one collecting the validators from all the messages + const onlyValidatorsAddressesArray = claimMessages.map( + msg => msg.value.validator_address + ) + return { + type: `type/MsgWithdrawDelegationReward`, + value: { + validators: onlyValidatorsAddressesArray + } + } +} + function sendDetailsReducer(message, reducers) { return { from: [message.from_address], @@ -693,15 +727,13 @@ function unstakeDetailsReducer(message, reducers) { } function claimRewardsDetailsReducer( - messages, + message, reducers, transaction, stakingDenom ) { return { - from: messages - .filter(msg => msg.type.split(`/`)[1] === `MsgWithdrawDelegationReward`) - .map(msg => msg.value.validator_address), + from: message.validators, amount: claimRewardsAmountReducer(transaction, reducers, stakingDenom) } } diff --git a/lib/source/cosmosV0-source.js b/lib/source/cosmosV0-source.js index d74a85eb5d..b87d027e0e 100644 --- a/lib/source/cosmosV0-source.js +++ b/lib/source/cosmosV0-source.js @@ -464,14 +464,12 @@ class CosmosV0API extends RESTDataSource { return expectedReturns } - async getRewards(delegatorAddress, validatorsDictionary, delegations = null) { + async getRewards(delegatorAddress, validatorsDictionary) { this.checkAddress(delegatorAddress) - if (!delegations) { - delegations = await this.getDelegationsForDelegatorAddress( - delegatorAddress, - validatorsDictionary - ) - } + const delegations = await this.getDelegationsForDelegatorAddress( + delegatorAddress, + validatorsDictionary + ) const rewards = await Promise.all( delegations.map(async ({ validatorAddress, validator }) => ({ validator, diff --git a/lib/source/terraV3-source.js b/lib/source/terraV3-source.js index 5419399fac..f6aed77f92 100644 --- a/lib/source/terraV3-source.js +++ b/lib/source/terraV3-source.js @@ -3,10 +3,11 @@ const BigNumber = require('bignumber.js') const { keyBy } = require('lodash') const { pubkeyToAddress } = require('../tools') +// these are the gas prices per microunit const gasPrices = [ { denom: 'ukrw', - price: '0.091' + price: '0.01' }, { denom: 'uluna', @@ -14,15 +15,15 @@ const gasPrices = [ }, { denom: 'umnt', - price: '0.091' + price: '0.01' }, { denom: 'usdr', - price: '0.091' + price: '0.01' }, { denom: 'uusd', - price: '0.091' + price: '0.01' } ] @@ -130,10 +131,9 @@ class TerraV3API extends CosmosV2API { const rewards = (result.rewards || []).filter( ({ reward }) => reward && reward.length > 0 ) - const rewardsWithFiatValue = await this.insertFiatValueinRewards( - rewards, - fiatCurrency - ) + const rewardsWithFiatValue = this.calculateFiatValue + ? await this.insertFiatValueinRewards(rewards, fiatCurrency) + : rewards return this.reducers.rewardReducer( rewardsWithFiatValue, validatorsDictionary