You need to divide dist by ZFAR
float dist = length(v_pos) / ZFAR;
I also see a minor error: you defined nearPlaneHS as a float, when it should be a vec2, but it wont make or break it
vec2 nearPlaneHalfSize = vec2(screenSize.x / screenSize.y, 1.0) * halfTan;
1. Check that the value of getDepth(refcoord) is constant for all positions in the scene
this is the most likely issue, that your depth texture is wrong somehow
2. Check that length(v_pos) is constant as you move around
I seriously doubt this one is wrong, but you never know
In both cases:
1. If you rotate your camera and move around, the color should only vary depending on distance from camera
2. The values should only range from [0, 1]
3. The values should be completely linear
Once you have verified that one of your inputs are simply wrong, you'll need to figure out the why
Eg. is the values of ZNEAR/ZFAR correct?