Skip to content

Commit 2dafdb7

Browse files
committed
pool+batches: only display open markets in the UI
1 parent 1f0507a commit 2dafdb7

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

app/src/store/views/batchesView.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { keys, makeAutoObservable } from 'mobx';
2-
import { NodeTier } from 'types/generated/auctioneer_pb';
1+
import { entries, makeAutoObservable } from 'mobx';
2+
import { DurationBucketState, NodeTier } from 'types/generated/auctioneer_pb';
33
import { toPercent } from 'util/bigmath';
44
import { Store } from 'store';
55

@@ -80,17 +80,24 @@ export default class BatchesView {
8080
return `${this._store.batchStore.selectedLeaseDuration}`;
8181
}
8282

83+
/** the markets that are currently open (accepting & matching orders) */
84+
get openMarkets() {
85+
return entries(this._store.batchStore.leaseDurations)
86+
.map(([duration, state]) => ({ duration, state }))
87+
.filter(({ state }) => state === DurationBucketState.MARKET_OPEN);
88+
}
89+
8390
/** the list of markets to display as badges */
8491
get marketOptions() {
85-
return keys(this._store.batchStore.leaseDurations).map(duration => ({
92+
return this.openMarkets.map(({ duration }) => ({
8693
label: `${duration}`,
8794
value: `${duration}`,
8895
}));
8996
}
9097

9198
/** determines if the market badges should be visible above the chart */
9299
get showMarketBadges() {
93-
return this._store.batchStore.leaseDurations.size > 1;
100+
return this.openMarkets.length > 1;
94101
}
95102

96103
//

app/src/store/views/orderFormView.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { keys, makeAutoObservable, runInAction } from 'mobx';
2-
import { NodeTier } from 'types/generated/auctioneer_pb';
1+
import { entries, makeAutoObservable, runInAction } from 'mobx';
2+
import { DurationBucketState, NodeTier } from 'types/generated/auctioneer_pb';
33
import { LeaseDuration } from 'types/state';
44
import { annualPercentRate, toBasisPoints, toPercent } from 'util/bigmath';
55
import { BLOCKS_PER_DAY } from 'util/constants';
@@ -80,6 +80,14 @@ export default class OrderFormView {
8080
return '';
8181
}
8282

83+
/** the markets currently open or accepting orders */
84+
get marketsAcceptingOrders() {
85+
const { MARKET_OPEN, ACCEPTING_ORDERS } = DurationBucketState;
86+
return entries(this._store.batchStore.leaseDurations)
87+
.map(([duration, state]) => ({ duration, state }))
88+
.filter(({ state }) => state === MARKET_OPEN || state === ACCEPTING_ORDERS);
89+
}
90+
8391
/** the available options for the lease duration field */
8492
get durationOptions() {
8593
// add a default option with a value of zero to signify that the duration
@@ -88,7 +96,7 @@ export default class OrderFormView {
8896
label: `${l('inView')} (${this._store.batchStore.selectedLeaseDuration})`,
8997
value: '0',
9098
};
91-
const durations = keys(this._store.batchStore.leaseDurations).map(duration => ({
99+
const durations = this.marketsAcceptingOrders.map(({ duration }) => ({
92100
label: `${duration}`,
93101
value: `${duration}`,
94102
}));
@@ -97,7 +105,7 @@ export default class OrderFormView {
97105

98106
/** determines if the lease duration field should be visible */
99107
get durationVisible() {
100-
return this._store.batchStore.leaseDurations.size > 1;
108+
return this.marketsAcceptingOrders.length > 1;
101109
}
102110

103111
/** the chosen duration or the value selected in the batch store */

app/src/util/tests/sampleData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,9 @@ export const poolLeaseDurations: POOL.LeaseDurationResponse.AsObject = {
654654
leaseDurationsMap: [], // deprecated
655655
leaseDurationBucketsMap: [
656656
[2016, AUCT.DurationBucketState.MARKET_OPEN],
657-
[4032, AUCT.DurationBucketState.MARKET_CLOSED],
657+
[4032, AUCT.DurationBucketState.MARKET_OPEN],
658658
[6048, AUCT.DurationBucketState.ACCEPTING_ORDERS],
659-
[8064, AUCT.DurationBucketState.NO_MARKET],
659+
[8064, AUCT.DurationBucketState.MARKET_CLOSED],
660660
],
661661
};
662662

0 commit comments

Comments
 (0)