fix(governance): tranches data (#3708)
This commit is contained in:
parent
b4c7dc6f59
commit
a8c17b6807
@ -50,7 +50,22 @@ export const useTranches = create<TranchesStore>()((set) => ({
|
|||||||
?.map((t) => {
|
?.map((t) => {
|
||||||
const tranche_progress =
|
const tranche_progress =
|
||||||
t.duration !== 0 ? (now - t.cliff_start) / t.duration : 0;
|
t.duration !== 0 ? (now - t.cliff_start) / t.duration : 0;
|
||||||
const lockedDecimal = tranche_progress < 0 ? 1 : 1 - tranche_progress;
|
let lockedDecimal;
|
||||||
|
if (t.duration !== 0) {
|
||||||
|
if (tranche_progress < 0) {
|
||||||
|
lockedDecimal = 1;
|
||||||
|
} else {
|
||||||
|
lockedDecimal = 1 - tranche_progress;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (now < t.cliff_start) {
|
||||||
|
lockedDecimal = 1;
|
||||||
|
} else {
|
||||||
|
lockedDecimal = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const clampedLockedDecimal = Math.max(0, Math.min(1, lockedDecimal));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tranche_id: t.tranche_id,
|
tranche_id: t.tranche_id,
|
||||||
tranche_start: secondsToDate(t.cliff_start),
|
tranche_start: secondsToDate(t.cliff_start),
|
||||||
@ -60,7 +75,7 @@ export const useTranches = create<TranchesStore>()((set) => ({
|
|||||||
toBigNum(t.current_balance, decimals)
|
toBigNum(t.current_balance, decimals)
|
||||||
),
|
),
|
||||||
locked_amount: toBigNum(t.initial_balance, decimals).times(
|
locked_amount: toBigNum(t.initial_balance, decimals).times(
|
||||||
lockedDecimal
|
clampedLockedDecimal
|
||||||
),
|
),
|
||||||
users: t.users,
|
users: t.users,
|
||||||
};
|
};
|
||||||
|
@ -54,22 +54,16 @@ export const TrancheItem = ({
|
|||||||
{formatNumber(total, 2)}
|
{formatNumber(total, 2)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<table className="w-full">
|
<div className="grid grid-cols-2 my-2">
|
||||||
<tbody>
|
<div>
|
||||||
<tr>
|
<span>{t('Starts unlocking')}:</span>{' '}
|
||||||
<td>{t('Starts unlocking')}</td>
|
<span>{format(tranche.tranche_start, DATE_FORMAT_LONG)}</span>
|
||||||
<td className="text-right">
|
</div>
|
||||||
{format(tranche.tranche_start, DATE_FORMAT_LONG)}
|
<div className="justify-self-end">
|
||||||
</td>
|
<span>{t('Fully unlocked')}:</span>{' '}
|
||||||
</tr>
|
<span>{format(tranche.tranche_end, DATE_FORMAT_LONG)}</span>
|
||||||
<tr>
|
</div>
|
||||||
<td>{t('Fully unlocked')}</td>
|
</div>
|
||||||
<td className="text-right">
|
|
||||||
{format(tranche.tranche_end, DATE_FORMAT_LONG)}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<LockedProgress
|
<LockedProgress
|
||||||
locked={locked}
|
locked={locked}
|
||||||
unlocked={unlocked}
|
unlocked={unlocked}
|
||||||
|
Loading…
Reference in New Issue
Block a user