Skip to content
This repository was archived by the owner on Aug 12, 2023. It is now read-only.

Commit 64ca9a0

Browse files
authored
Make some tweaks to pricing aggregations (#371)
1 parent 4bd1912 commit 64ca9a0

File tree

5 files changed

+19
-24
lines changed

5 files changed

+19
-24
lines changed

src/app/routes/v1/util/transform-token.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ const transformToken = (token, tokenPrice, stats, statsPeriod) => {
3737
: {
3838
change: null,
3939
close: null,
40-
high: null,
40+
high: _.get(tokenPrice, 'maxPriceUSD', null),
4141
last: null,
42-
low: null,
42+
low: _.get(tokenPrice, 'minPriceUSD', null),
4343
open: null,
4444
};
4545

src/metrics/get-token-price-metrics.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ const getPriceForPreviousPeriod = async (tokenAddress, currentPeriodStart) => {
2323
},
2424
},
2525
{
26-
exists: {
27-
field: 'relayerId',
26+
range: {
27+
priceUSD: { gt: 0 },
2828
},
2929
},
3030
{
31-
exists: {
32-
field: 'priceUSD',
31+
range: {
32+
tradedAmountUSD: { gte: 1 },
3333
},
3434
},
3535
],
@@ -68,13 +68,13 @@ const getTokenMetrics = async (tokenAddress, period, granularity) => {
6868
},
6969
},
7070
{
71-
exists: {
72-
field: 'relayerId',
71+
range: {
72+
priceUSD: { gt: 0 },
7373
},
7474
},
7575
{
76-
exists: {
77-
field: 'priceUSD',
76+
range: {
77+
tradedAmountUSD: { gte: 1 },
7878
},
7979
},
8080
],
@@ -87,7 +87,7 @@ const getTokenMetrics = async (tokenAddress, period, granularity) => {
8787
field: 'date',
8888
calendar_interval: granularity,
8989
extended_bounds: {
90-
min: period === 'all' ? undefined : dateFrom,
90+
min: dateFrom,
9191
max: dateTo,
9292
},
9393
},

src/metrics/get-token-volume-metrics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const getTokenMetrics = async (tokenAddress, period, granularity) => {
1313
field: 'date',
1414
calendar_interval: granularity,
1515
extended_bounds: {
16-
min: period === 'all' ? undefined : dateFrom,
16+
min: dateFrom,
1717
max: dateTo,
1818
},
1919
},

src/tokens/get-token-prices.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ async function getTokenPrices(tokenAddresses, period) {
99
query: {
1010
bool: {
1111
filter: [
12-
{
13-
exists: {
14-
field: 'relayerId',
15-
},
16-
},
17-
{
18-
exists: {
19-
field: 'priceUSD',
20-
},
21-
},
2212
{
2313
terms: {
2414
tokenAddress: tokenAddresses,
@@ -29,6 +19,11 @@ async function getTokenPrices(tokenAddresses, period) {
2919
priceUSD: { gt: 0 },
3020
},
3121
},
22+
{
23+
range: {
24+
tradedAmountUSD: { gte: 1 },
25+
},
26+
},
3227
],
3328
},
3429
},

src/tokens/get-tokens-with-stats-for-dates.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ const getTokensWithStatsForDates = async (dateFrom, dateTo, options) => {
139139
: {
140140
change: null,
141141
close: null,
142-
high: null,
142+
high: _.get(price, 'maxPriceUSD', null),
143143
last: null,
144-
low: null,
144+
low: _.get(price, 'minPriceUSD', null),
145145
open: null,
146146
},
147147
stats: {

0 commit comments

Comments
 (0)