@@ -51,6 +51,8 @@ interface ChartData {
51
51
timestampNanos : number ;
52
52
computeUnits : number ;
53
53
activeBankCount : number ;
54
+ priority_fees_lamports : number ;
55
+ tips_lamports : number ;
54
56
}
55
57
56
58
const minRangeNanos = 50_000 ;
@@ -60,9 +62,9 @@ const wheelScrollSpeed = 1 / 3_000;
60
62
const smNanosThreshold = 5_000_000 ;
61
63
const mdNanosThreshold = 50_000_000 ;
62
64
const _segmentColors = [
65
+ { fill : "#1E9C50" , opacity : 0 } ,
63
66
{ fill : "#1E9C50" , opacity : 0.15 } ,
64
67
{ fill : "#AE5511" , opacity : 0.15 } ,
65
- { fill : "#CF321D" , opacity : 0.15 } ,
66
68
{ fill : "#F40505" , opacity : 0.15 } ,
67
69
{ fill : "#F40505" , opacity : 0.2 } ,
68
70
] ;
@@ -71,9 +73,7 @@ const getSegmentColor = (index: number) => {
71
73
} ;
72
74
const cuAxisId = "computeUnits" ;
73
75
const bankCountAxisId = "activeBankCount" ;
74
- const defaultCuTicks = [
75
- 8_000_000 , 16_000_000 , 24_000_000 , 32_000_000 , 40_000_000 , 48_000_000 ,
76
- ] ;
76
+ const incomeAxisId = "income" ;
77
77
78
78
const cusPerNs = 1 / 8 ;
79
79
const tickLabelWidth = 110 ;
@@ -103,6 +103,18 @@ function getChartData(computeUnits: ComputeUnits): ChartData[] {
103
103
: - computeUnits . txn_max_compute_units [ txn_idx ] +
104
104
computeUnits . txn_compute_units_consumed [ txn_idx ]
105
105
: 0 ;
106
+ const priority_fee =
107
+ ! event . start &&
108
+ computeUnits . txn_landed [ txn_idx ] &&
109
+ computeUnits . txn_error_code [ txn_idx ] === 0
110
+ ? Number ( computeUnits . txn_priority_fee [ txn_idx ] )
111
+ : 0 ;
112
+ const tip =
113
+ ! event . start &&
114
+ computeUnits . txn_landed [ txn_idx ] &&
115
+ computeUnits . txn_error_code [ txn_idx ] === 0
116
+ ? Number ( computeUnits . txn_tips [ txn_idx ] )
117
+ : 0 ;
106
118
107
119
const prev = chartData [ chartData . length - 1 ] ;
108
120
activeBanks [ computeUnits . txn_bank_idx [ txn_idx ] ] = event . start ;
@@ -113,18 +125,30 @@ function getChartData(computeUnits: ComputeUnits): ChartData[] {
113
125
if ( i > 0 && events [ i - 1 ] . timestampNanos === event . timestampNanos ) {
114
126
prev . computeUnits += cus_delta ;
115
127
prev . activeBankCount = activeBankCount ;
128
+ prev . priority_fees_lamports += priority_fee ;
129
+ prev . tips_lamports += tip ;
116
130
} else {
117
131
chartData . push ( {
118
132
timestampNanos : Number (
119
133
event . timestampNanos - computeUnits . start_timestamp_nanos ,
120
134
) ,
121
135
computeUnits : prev . computeUnits + cus_delta ,
122
136
activeBankCount,
137
+ priority_fees_lamports : prev . priority_fees_lamports + priority_fee ,
138
+ tips_lamports : prev . tips_lamports + tip ,
123
139
} ) ;
124
140
}
125
141
return chartData ;
126
142
} ,
127
- [ { timestampNanos : 0 , computeUnits : 0 , activeBankCount : 0 } ] ,
143
+ [
144
+ {
145
+ timestampNanos : 0 ,
146
+ computeUnits : 0 ,
147
+ activeBankCount : 0 ,
148
+ priority_fees_lamports : 0 ,
149
+ tips_lamports : 0 ,
150
+ } ,
151
+ ] ,
128
152
) ;
129
153
}
130
154
@@ -136,9 +160,10 @@ const getXTicks = memoize(function getXTicks(
136
160
return prettyIntervals ( tsMinNanos , tsMaxNanos , intervalCount ) ;
137
161
} ) ;
138
162
139
- function getDataDomain (
163
+ function getDataRangebyZoomWindow (
140
164
data : ChartData [ ] ,
141
- maxComputeUnits : number ,
165
+ field : keyof ChartData ,
166
+ maxRangeValue : number ,
142
167
zoomRange : ZoomRange | undefined ,
143
168
) : Domain | undefined {
144
169
if ( ! data . length ) return ;
@@ -161,8 +186,8 @@ function getDataDomain(
161
186
// if (pt.timestampNanos > endTime) break;
162
187
163
188
if ( pt !== undefined ) {
164
- min = Math . min ( min , pt . computeUnits ) ;
165
- max = Math . max ( max , pt . computeUnits ) ;
189
+ min = Math . min ( min , pt [ field ] ) ;
190
+ max = Math . max ( max , pt [ field ] ) ;
166
191
}
167
192
168
193
// Doing the check after the min/max means we included an additional data point past
@@ -173,7 +198,22 @@ function getDataDomain(
173
198
if ( ! Number . isFinite ( min ) || ! Number . isFinite ( max ) ) return ;
174
199
175
200
const domain = extendDomain ( [ min , max ] , 100 ) ;
176
- return [ Math . max ( 0 , domain [ 0 ] ) , Math . min ( maxComputeUnits , domain [ 1 ] ) ] ;
201
+ return [ Math . max ( 0 , domain [ 0 ] ) , Math . min ( maxRangeValue , domain [ 1 ] ) ] ;
202
+ }
203
+
204
+ function getDefaultYAxisTicks (
205
+ numTicks : number ,
206
+ maxRangeValue : number ,
207
+ approxBottomPadding : number ,
208
+ interval : number ,
209
+ ) : Array < number > {
210
+ const step =
211
+ Math . ceil (
212
+ ( maxRangeValue - approxBottomPadding ) / ( numTicks - 1 ) / interval ,
213
+ ) * interval ;
214
+ return Array . from ( { length : numTicks } , ( _ , i ) =>
215
+ Math . min ( maxRangeValue - i * step , maxRangeValue ) ,
216
+ ) ;
177
217
}
178
218
179
219
function getCuByTs ( {
@@ -375,9 +415,31 @@ export default function Chart({
375
415
[ xDomain , xLabelCount ] ,
376
416
) ;
377
417
418
+ const defaultCuTicks = useMemo (
419
+ ( ) => getDefaultYAxisTicks ( 6 , maxComputeUnits , 8_000_000 , 1_000_000 ) ,
420
+ [ maxComputeUnits ] ,
421
+ ) ;
422
+
423
+ const maxIncomeValue = Math . max (
424
+ data . reduce ( ( sum , d ) => sum + d . tips_lamports , 0 ) ,
425
+ data . reduce ( ( sum , d ) => sum + d . priority_fees_lamports , 0 ) ,
426
+ 12_000_000 ,
427
+ ) ;
428
+ const defaultIncomeTicks = useMemo (
429
+ ( ) => getDefaultYAxisTicks ( 6 , maxIncomeValue , 2_000_000 , 1_000_000 ) ,
430
+ [ maxIncomeValue ] ,
431
+ ) ;
432
+
378
433
const cuDomain = useMemo (
379
434
( ) =>
380
- fitYToData ? getDataDomain ( data , maxComputeUnits , zoomRange ) : undefined ,
435
+ fitYToData
436
+ ? getDataRangebyZoomWindow (
437
+ data ,
438
+ "computeUnits" ,
439
+ maxComputeUnits ,
440
+ zoomRange ,
441
+ )
442
+ : undefined ,
381
443
[ maxComputeUnits , data , fitYToData , zoomRange ] ,
382
444
) ;
383
445
@@ -766,7 +828,7 @@ export default function Chart({
766
828
yAxisId = { bankCountAxisId }
767
829
type = "stepAfter"
768
830
dataKey = "activeBankCount"
769
- stroke = "#BA7B1D "
831
+ stroke = "rgba(117, 77, 18, 1) "
770
832
strokeWidth = {
771
833
useActiveBanksLargeStroke
772
834
? 0.9
@@ -919,12 +981,32 @@ export default function Chart({
919
981
yAxisId = { cuAxisId }
920
982
type = "stepAfter"
921
983
dataKey = "computeUnits"
922
- stroke = "#1288F6 "
984
+ stroke = "rgba(105, 105, 255, 1) "
923
985
strokeWidth = { 1.3 }
924
986
dot = { false }
925
987
name = "CUs"
926
988
isAnimationActive = { false }
927
989
/>
990
+ < Line
991
+ yAxisId = { incomeAxisId }
992
+ type = "stepAfter"
993
+ dataKey = "priority_fees_lamports"
994
+ stroke = "rgba(82, 227, 203, 1)"
995
+ strokeWidth = { 1.3 }
996
+ dot = { false }
997
+ name = "Income"
998
+ isAnimationActive = { false }
999
+ />
1000
+ < Line
1001
+ yAxisId = { incomeAxisId }
1002
+ type = "stepAfter"
1003
+ dataKey = "tips_lamports"
1004
+ stroke = "rgba(84, 211, 94, 1)"
1005
+ strokeWidth = { 1.3 }
1006
+ dot = { false }
1007
+ name = "Income"
1008
+ isAnimationActive = { false }
1009
+ />
928
1010
< XAxis
929
1011
dataKey = "timestampNanos"
930
1012
scale = "time"
@@ -945,7 +1027,7 @@ export default function Chart({
945
1027
ticks = { cuDomain ? undefined : defaultCuTicks }
946
1028
allowDataOverflow = { ! ! cuDomain }
947
1029
minTickGap = { 0 }
948
- orientation = "right "
1030
+ orientation = "left "
949
1031
tickFormatter = { ( tick ) => {
950
1032
if ( typeof tick !== "number" ) return "" ;
951
1033
@@ -961,6 +1043,20 @@ export default function Chart({
961
1043
hide
962
1044
name = "active bank tiles"
963
1045
/>
1046
+ < YAxis
1047
+ yAxisId = { incomeAxisId }
1048
+ scale = "linear"
1049
+ type = "number"
1050
+ domain = { [ "auto" , "dataMax + 250000" ] }
1051
+ ticks = { defaultIncomeTicks }
1052
+ orientation = "right"
1053
+ tickFormatter = { ( tick ) => {
1054
+ if ( typeof tick !== "number" ) return "" ;
1055
+ return (
1056
+ ( tick / 1_000_000_000 ) . toFixed ( 3 ) . padEnd ( 3 , "0" ) + " ꜱᴏʟ"
1057
+ ) ;
1058
+ } }
1059
+ />
964
1060
965
1061
{ isActiveDragging && (
966
1062
< ReferenceArea
0 commit comments