Cleaned up spec further
This commit is contained in:
parent
2ac55ebb1d
commit
feb9a22663
|
@ -21,6 +21,10 @@ type VestingAccount interface {
|
||||||
Account
|
Account
|
||||||
AssertIsVestingAccount() // existence implies that account is vesting.
|
AssertIsVestingAccount() // existence implies that account is vesting.
|
||||||
ConvertAccount(sdk.Context) BaseAccount
|
ConvertAccount(sdk.Context) BaseAccount
|
||||||
|
|
||||||
|
// Calculates total amount of unlocked coins released by vesting schedule
|
||||||
|
// May be larger than total coins in account right now
|
||||||
|
TotalUnlockedCoins(sdk.Context) sdk.Coins
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements Vesting Account
|
// Implements Vesting Account
|
||||||
|
@ -37,10 +41,13 @@ type ContinuousVestingAccount struct {
|
||||||
|
|
||||||
// ConvertAccount converts VestingAccount into BaseAccount
|
// ConvertAccount converts VestingAccount into BaseAccount
|
||||||
// Will convert only after account has fully vested
|
// Will convert only after account has fully vested
|
||||||
ConvertAccount(vacc ContinuousVestingAccount) (BaseAccount):
|
ConvertAccount(vacc ContinuousVestingAccount, ctx sdk.Context) (BaseAccount):
|
||||||
if Now > vacc.EndTime:
|
if Now > vacc.EndTime:
|
||||||
account = NewBaseAccount(vacc.Address, vacc.OriginalCoins + vacc.ReceivedCoins)
|
return vacc.BaseAccount
|
||||||
return account
|
|
||||||
|
// Uses time in context to calculate total unlocked coins
|
||||||
|
TotalUnlockedCoins(vacc ContinuousVestingAccount, ctx sdk.Context) sdk.Coins:
|
||||||
|
return ReceivedCoins + OriginalCoins * (Now - StartTime) / (EndTime - StartTime)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -69,8 +76,7 @@ if Now < vestingAccount.EndTime:
|
||||||
// NOTE: SendableCoins may be greater than total coins in account
|
// NOTE: SendableCoins may be greater than total coins in account
|
||||||
// because coins can be subtracted by staking module
|
// because coins can be subtracted by staking module
|
||||||
// SendableCoins denotes maximum coins allowed to be spent.
|
// SendableCoins denotes maximum coins allowed to be spent.
|
||||||
SendableCoins := ReceivedCoins + OriginalCoins * (Now - StartTime) / (EndTime - StartTime)
|
if msg.Amount > vestingAccount.TotalUnlockedCoins() then fail
|
||||||
if msg.Amount > SendableCoins then fail
|
|
||||||
|
|
||||||
// Account fully vested, convert to BaseAccount
|
// Account fully vested, convert to BaseAccount
|
||||||
else:
|
else:
|
||||||
|
@ -148,6 +154,8 @@ Coins currently in Account:
|
||||||
|
|
||||||
`CurrentCoins = OriginalCoins + ReceivedCoins - Delegated - Sent`
|
`CurrentCoins = OriginalCoins + ReceivedCoins - Delegated - Sent`
|
||||||
|
|
||||||
|
`CurrentCoins = vestingAccount.BaseAccount.GetCoins()`
|
||||||
|
|
||||||
**Maximum amount of coins spendable right now:**
|
**Maximum amount of coins spendable right now:**
|
||||||
|
|
||||||
`min( ReceivedCoins + OriginalCoins - LockedCoins, CurrentCoins )`
|
`min( ReceivedCoins + OriginalCoins - LockedCoins, CurrentCoins )`
|
||||||
|
|
Loading…
Reference in New Issue