Skip to content

Commit

Permalink
fine tune the remaining vesting periods
Browse files Browse the repository at this point in the history
  • Loading branch information
dekm committed May 29, 2024
1 parent 58777bb commit b872b5d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions x/ugdvesting/keeper/hedgehog_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,19 @@ func (k *Keeper) ProcessPendingVesting(ctx sdk.Context) {
remainingAmount = append(remainingAmount, sdk.NewCoin(coin.Denom, coin.Amount.Sub(tgeAmount.AmountOf(coin.Denom))))
}

// Calculate ramp-up amount
rampUpAmount := sdk.Coins{}
// Calculate total vesting parts excluding TGE
totalVestingParts := data.Parts - 1

// Calculate vesting amount per period
vestingAmountPerPeriod := sdk.Coins{}
for _, coin := range remainingAmount {
rampUpAmount = append(rampUpAmount, sdk.NewCoin(coin.Denom, coin.Amount.Quo(math.NewInt(int64(data.Cliff)))))
vestingAmountPerPeriod = append(vestingAmountPerPeriod, sdk.NewCoin(coin.Denom, coin.Amount.Quo(math.NewInt(int64(totalVestingParts)))))
}

// Calculate final vesting periods amount
finalVestingAmount := sdk.Coins{}
for _, coin := range remainingAmount {
finalVestingAmount = append(finalVestingAmount, sdk.NewCoin(coin.Denom, coin.Amount.Quo(math.NewInt(int64(data.Parts-1)))))
// Calculate ramp-up amount
rampUpAmountPerPeriod := sdk.Coins{}
for _, coin := range vestingAmountPerPeriod {
rampUpAmountPerPeriod = append(rampUpAmountPerPeriod, sdk.NewCoin(coin.Denom, coin.Amount.Quo(math.NewInt(int64(data.Cliff)))))
}

periods := vestingtypes.Periods{}
Expand All @@ -125,15 +128,15 @@ func (k *Keeper) ProcessPendingVesting(ctx sdk.Context) {
for i := 0; i < int(data.Cliff); i++ {
periods = append(periods, vestingtypes.Period{
Length: int64(periodTime.Seconds()),
Amount: rampUpAmount,
Amount: rampUpAmountPerPeriod,
})
}

// Regular vesting periods
for i := 0; i < int(data.Parts-1); i++ { // Subtract 1 to account for ramp UP period
for i := 0; i < int(totalVestingParts)-int(data.Cliff); i++ {
periods = append(periods, vestingtypes.Period{
Length: int64(periodTime.Seconds()),
Amount: finalVestingAmount,
Amount: vestingAmountPerPeriod,
})
}

Expand Down

0 comments on commit b872b5d

Please sign in to comment.