@@ -31,22 +31,42 @@ export function addResultToEvents(
3131 } ) ;
3232
3333 linears . map ( ( l : LinearAdapterResult , i : number ) => {
34- if ( i == linears . length ) return ;
35- const l2 = linears [ i ] ;
36- const thisRate = i == 0 ? 0 : ratePerPeriod ( l , precision ) ;
37- const nextRate = ratePerPeriod ( l2 , precision ) ;
38- if ( Math . abs ( Number ( thisRate ) - Number ( nextRate ) ) / thisRate < 0.001 )
39- return ;
40- if ( ! metadata . events ) metadata . events = [ ] ;
41- metadata . events . push ( {
42- description : `Linear unlock ${ isFuture ( l . start ) ? "will" : "was" } ${
43- Number ( thisRate ) > Number ( nextRate ) ? "decrease" : "increase"
44- } ${
45- isFuture ( l . start ) ? "" : "d"
46- } from {tokens[0]} to {tokens[1]} tokens per week from ${ section } on {timestamp}`,
47- timestamp : l . start ,
48- noOfTokens : [ thisRate , nextRate ] ,
49- } ) ;
34+ // compare current with the next one if it exists
35+ if ( i < linears . length - 1 ) {
36+ const l2 = linears [ i + 1 ] ;
37+ const thisRate = ratePerPeriod ( l , precision ) ;
38+ const nextRate = ratePerPeriod ( l2 , precision ) ;
39+
40+ if ( Math . abs ( Number ( thisRate ) - Number ( nextRate ) ) / ( thisRate || 1 ) >= 0.001 ) {
41+ if ( ! metadata . events ) metadata . events = [ ] ;
42+ metadata . events . push ( {
43+ description : `Linear unlock ${ isFuture ( l2 . start ) ? "will" : "was" } ${
44+ Number ( thisRate ) > Number ( nextRate ) ? "decrease" : "increase"
45+ } ${
46+ isFuture ( l2 . start ) ? "" : "d"
47+ } from {tokens[0]} to {tokens[1]} tokens per week from ${ section } on {timestamp}`,
48+ timestamp : l2 . start ,
49+ noOfTokens : [ thisRate , nextRate ] ,
50+ } ) ;
51+ }
52+ }
53+
54+ // handle first linear period to show the initial rate increase from 0
55+ if ( i === 0 ) {
56+ const initialRate = ratePerPeriod ( l , precision ) ;
57+ if ( initialRate > 0 ) {
58+ if ( ! metadata . events ) metadata . events = [ ] ;
59+ metadata . events . push ( {
60+ description : `Linear unlock ${ isFuture ( l . start ) ? "will" : "was" } ${
61+ 0 > Number ( initialRate ) ? "decrease" : "increase"
62+ } ${
63+ isFuture ( l . start ) ? "" : "d"
64+ } from {tokens[0]} to {tokens[1]} tokens per week from ${ section } on {timestamp}`,
65+ timestamp : l . start ,
66+ noOfTokens : [ 0 , initialRate ] ,
67+ } ) ;
68+ }
69+ }
5070 } ) ;
5171
5272 steps . map ( ( s : StepAdapterResult ) => {
0 commit comments