mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-06 10:14:26 -08:00
fix incorrect vesting remainder behavior
also checks vesting schedule range when calculating
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package colinearmath
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
)
|
||||
@@ -11,11 +12,15 @@ import (
|
||||
func CalcAmountVestableLinear(
|
||||
total *big.Int,
|
||||
remaining *big.Int,
|
||||
date time.Time,
|
||||
now time.Time,
|
||||
beginDate time.Time,
|
||||
endDate time.Time,
|
||||
) (*big.Int, error) {
|
||||
timePassed := big.NewInt(date.Unix() - beginDate.Unix())
|
||||
timePassed := big.NewInt(now.Unix() - beginDate.Unix())
|
||||
if timePassed.Cmp(big.NewInt(0)) == -1 {
|
||||
return nil, fmt.Errorf("time %d is out of range (%d, %d)", now.Unix(), beginDate.Unix(), endDate.Unix())
|
||||
}
|
||||
|
||||
totalTime := big.NewInt(endDate.Unix() - beginDate.Unix())
|
||||
|
||||
taken := big.NewInt(0)
|
||||
|
||||
Reference in New Issue
Block a user