Skip to content

Commit 9bc2021

Browse files
committed
updated variable name
1 parent ca7f019 commit 9bc2021

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/formulas/formulas/contract/external/cwVesting.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const vested: ContractFormula = makeSimpleContractFormula<
3939

4040
// Convert to seconds.
4141
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
4343

4444
if ('constant' in vested) {
4545
return vested.constant.y
@@ -51,12 +51,12 @@ export const vested: ContractFormula = makeSimpleContractFormula<
5151
const minY = BigInt(vested.saturating_linear.min_y)
5252
const maxY = BigInt(vested.saturating_linear.max_y)
5353

54-
if (elapsed < minX || minX === maxX) {
54+
if (x < minX || minX === maxX) {
5555
return minY.toString()
56-
} else if (elapsed > maxX) {
56+
} else if (x > maxX) {
5757
return maxY.toString()
5858
} else {
59-
return interpolate([minX, minY], [maxX, maxY], elapsed).toString()
59+
return interpolate([minX, minY], [maxX, maxY], x).toString()
6060
}
6161
} else if ('piecewise_linear' in vested) {
6262
// https://github.com/wynddao/wynddao/blob/909ee2f2b382eff06cf9f7af4102f0920da8c8a3/packages/utils/src/curve.rs#L270-L302
@@ -69,7 +69,7 @@ export const vested: ContractFormula = makeSimpleContractFormula<
6969
]
7070
for (const [stepX, stepY] of steps) {
7171
// only break if x is not above prev
72-
if (elapsed > next[0]) {
72+
if (x > next[0]) {
7373
prev = next
7474
next = [BigInt(stepX), BigInt(stepY)]
7575
} else {
@@ -82,15 +82,15 @@ export const vested: ContractFormula = makeSimpleContractFormula<
8282
// x may be greater than next (if higher than last item)
8383
// OR x may be between prev and next (interpolate)
8484
if (prev) {
85-
if (elapsed === prev[0]) {
85+
if (x === prev[0]) {
8686
// this handles exact match with low end
8787
return prev[1].toString()
88-
} else if (elapsed >= next[0]) {
88+
} else if (x >= next[0]) {
8989
// this handles both higher than all and exact match
9090
return next[1].toString()
9191
} else {
9292
// here we do linear interpolation
93-
return interpolate(prev, next, elapsed).toString()
93+
return interpolate(prev, next, x).toString()
9494
}
9595
} else {
9696
// lower than all, use first

0 commit comments

Comments
 (0)