From 06c4dd601dfef2c37ecaf3dde0ac5575f092f118 Mon Sep 17 00:00:00 2001 From: Gala Date: Wed, 3 Aug 2022 14:06:33 +0200 Subject: [PATCH] filter by use routing score instead of stake parameter --- .../src/components/Filters/filterSchema.ts | 73 ++++++------------- explorer/src/context/main.tsx | 4 +- explorer/src/typeDefs/filters.ts | 2 +- 3 files changed, 24 insertions(+), 55 deletions(-) diff --git a/explorer/src/components/Filters/filterSchema.ts b/explorer/src/components/Filters/filterSchema.ts index 0dce1c327e..40f230e734 100644 --- a/explorer/src/components/Filters/filterSchema.ts +++ b/explorer/src/components/Filters/filterSchema.ts @@ -47,64 +47,33 @@ export const generateFilterSchema = (upperSaturationValue?: number) => ({ max: upperSaturationValue, tooltipInfo: "Select nodes with <100% saturation. Any additional stake above 100% saturation won't get rewards", }, - stake: { - label: 'Routing Score (%)', - id: EnumFilterKey.stake, - value: [20, 90], - min: 20, - max: 90, + routingScore: { + label: 'Routing score (%)', + id: EnumFilterKey.routingScore, + value: [0, 100], marks: [ - { - value: 0, - label: '1', - }, - { - value: 10, - label: '10', - }, - { - value: 20, - label: '100', - }, - { - value: 30, - label: '1k', - }, - { - value: 40, - label: '10k', - }, - { - value: 50, - label: '100k', - }, - { - value: 60, - label: '1M', - }, - { - value: 70, - label: '10M', - }, - { - value: 80, - label: '100M', - }, - { - value: 90, - label: '1B', - }, + { label: '0', value: 0 }, + { label: '10', value: 10 }, + { label: '20', value: 20 }, + { label: '30', value: 30 }, + { label: '40', value: 40 }, + { label: '50', value: 50 }, + { label: '60', value: 60 }, + { label: '70', value: 70 }, + { label: '80', value: 80 }, + { label: '90', value: 90 }, + { label: '100', value: 100 }, ], tooltipInfo: 'The higher the routing score the better the performance of the node and so its rewards', }, }); -const formatStakeValuesToMinorDenom = ([value_1, value_2]: number[]) => { - const lowerValue = 10 ** (value_1 / 10) * 1_000_000; - const upperValue = 10 ** (value_2 / 10) * 1_000_000; +// const formatStakeValuesToMinorDenom = ([value_1, value_2]: number[]) => { +// const lowerValue = 10 ** (value_1 / 10) * 1_000_000; +// const upperValue = 10 ** (value_2 / 10) * 1_000_000; - return [lowerValue, upperValue]; -}; +// return [lowerValue, upperValue]; +// }; const formatStakeSaturationValues = ([value_1, value_2]: number[]) => { const lowerValue = value_1 / 100; @@ -114,7 +83,7 @@ const formatStakeSaturationValues = ([value_1, value_2]: number[]) => { }; export const formatOnSave = (filters: TFilters) => ({ - stake: formatStakeValuesToMinorDenom(filters.stake.value), + routingScore: filters.routingScore.value, profitMargin: filters.profitMargin.value, stakeSaturation: formatStakeSaturationValues(filters.stakeSaturation.value), }); diff --git a/explorer/src/context/main.tsx b/explorer/src/context/main.tsx index 7fca785209..9255eb20e3 100644 --- a/explorer/src/context/main.tsx +++ b/explorer/src/context/main.tsx @@ -102,8 +102,8 @@ export const MainContextProvider: React.FC = ({ children }) => { m.mix_node.profit_margin_percent <= filters.profitMargin[1] && m.stake_saturation >= filters.stakeSaturation[0] && m.stake_saturation <= filters.stakeSaturation[1] && - +m.pledge_amount.amount + +m.total_delegation.amount >= filters.stake[0] && - +m.pledge_amount.amount + +m.total_delegation.amount <= filters.stake[1], + m.avg_uptime >= filters.routingScore[0] && + m.avg_uptime <= filters.routingScore[1], ); setMixnodes({ data: filtered, isLoading: false }); }; diff --git a/explorer/src/typeDefs/filters.ts b/explorer/src/typeDefs/filters.ts index 07add70a85..2152f3a35f 100644 --- a/explorer/src/typeDefs/filters.ts +++ b/explorer/src/typeDefs/filters.ts @@ -4,7 +4,7 @@ import { Mark } from '@mui/base'; export enum EnumFilterKey { profitMargin = 'profitMargin', stakeSaturation = 'stakeSaturation', - stake = 'stake', + routingScore = 'routingScore', } export type TFilterItem = {