@@ -39,7 +39,7 @@ export const vested: ContractFormula = makeSimpleContractFormula<
39
39
40
40
// Convert to seconds.
41
41
const tSeconds = t ? BigInt ( t ) / 1_000_000_000n : block . timeUnixMs / 1_000n
42
- const elapsed = tSeconds - BigInt ( start_time ) / 1_000_000_000n
42
+ const x = tSeconds - BigInt ( start_time ) / 1_000_000_000n
43
43
44
44
if ( 'constant' in vested ) {
45
45
return vested . constant . y
@@ -51,12 +51,12 @@ export const vested: ContractFormula = makeSimpleContractFormula<
51
51
const minY = BigInt ( vested . saturating_linear . min_y )
52
52
const maxY = BigInt ( vested . saturating_linear . max_y )
53
53
54
- if ( elapsed < minX || minX === maxX ) {
54
+ if ( x < minX || minX === maxX ) {
55
55
return minY . toString ( )
56
- } else if ( elapsed > maxX ) {
56
+ } else if ( x > maxX ) {
57
57
return maxY . toString ( )
58
58
} else {
59
- return interpolate ( [ minX , minY ] , [ maxX , maxY ] , elapsed ) . toString ( )
59
+ return interpolate ( [ minX , minY ] , [ maxX , maxY ] , x ) . toString ( )
60
60
}
61
61
} else if ( 'piecewise_linear' in vested ) {
62
62
// https://github.com/wynddao/wynddao/blob/909ee2f2b382eff06cf9f7af4102f0920da8c8a3/packages/utils/src/curve.rs#L270-L302
@@ -69,7 +69,7 @@ export const vested: ContractFormula = makeSimpleContractFormula<
69
69
]
70
70
for ( const [ stepX , stepY ] of steps ) {
71
71
// only break if x is not above prev
72
- if ( elapsed > next [ 0 ] ) {
72
+ if ( x > next [ 0 ] ) {
73
73
prev = next
74
74
next = [ BigInt ( stepX ) , BigInt ( stepY ) ]
75
75
} else {
@@ -82,15 +82,15 @@ export const vested: ContractFormula = makeSimpleContractFormula<
82
82
// x may be greater than next (if higher than last item)
83
83
// OR x may be between prev and next (interpolate)
84
84
if ( prev ) {
85
- if ( elapsed === prev [ 0 ] ) {
85
+ if ( x === prev [ 0 ] ) {
86
86
// this handles exact match with low end
87
87
return prev [ 1 ] . toString ( )
88
- } else if ( elapsed >= next [ 0 ] ) {
88
+ } else if ( x >= next [ 0 ] ) {
89
89
// this handles both higher than all and exact match
90
90
return next [ 1 ] . toString ( )
91
91
} else {
92
92
// here we do linear interpolation
93
- return interpolate ( prev , next , elapsed ) . toString ( )
93
+ return interpolate ( prev , next , x ) . toString ( )
94
94
}
95
95
} else {
96
96
// lower than all, use first
0 commit comments