function deriveMultisigState (selectedEpoch, Balance, {InitialBalance, UnlockDuration, StartEpoch} ) {
if (!UnlockDuration){
return { VestingStart: undefined, VestingEnd: undefined, VestedFIL: 0, UnvestedFIL: 0}
}
const VestingStart = heightToDate(StartEpoch)
const VestingEnd = heightToDate(StartEpoch + UnlockDuration)
if (StartEpoch >= selectedEpoch) {
return { VestingStart, VestingEnd, VestedFIL: 0, UnvestedFIL: InitialBalance / 1e18}
} else {
const vestPerEpoch = InitialBalance / UnlockDuration
const vestedEpochs = Math.min(selectedEpoch - StartEpoch, UnlockDuration)
const vestedAttoFil = Math.ceil(vestedEpochs * vestPerEpoch)
const unvestedAttoFil = InitialBalance - vestedAttoFil
return {
VestingStart,
VestingEnd,
VestedFIL: vestedAttoFil / 1e18,
UnvestedFIL: unvestedAttoFil / 1e18,
}
}
}