Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ Lazy Vesting Schedule #183

Merged
merged 17 commits into from
Jun 21, 2019
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
## 0.2.2

- [\#185](https://github.com/terra-project/core/pull/185): Improve oracle specs
- [\#184](https://github.com/terra-project/core/pull/184): Fix `terracli` docs
- [\#183](https://github.com/terra-project/core/pull/183): Change all GradedVestingAccounts to LazyGradedVestingAccounts.
- [\#179](https://github.com/terra-project/core/pull/179): Conform querier responses to be returned in JSON format
- [\#178](https://github.com/terra-project/core/pull/178): Change BIP44 PATH to 330

### Changes
#### [\#185](https://github.com/terra-project/core/pull/185) Oracle `MsgFeederDelegatePermission` specs
Added docs for using `MsgFeederDelegatePermission` to oracle specs

#### [\#185](https://github.com/terra-project/core/pull/185) Oracle price vote denom error fix
Oracle specs now specify micro units `uluna` and `uusd` for correct denominations for price prevotes and votes

#### [\#184](https://github.com/terra-project/core/pull/184) Minor terracli fix

#### [\#183](https://github.com/terra-project/core/pull/183) Oracle param update
```
OracleRewardBand: 1% => 2%
```

#### [\#183](https://github.com/terra-project/core/pull/183) Market param update
```
DailyLunaDeltaCap: 0.5% => 0.1%
```

#### [\#183](https://github.com/terra-project/core/pull/183) LazyGradedVestingAccount

* Spread out the cliffs for presale investors, with varying degrees of severity (details [\#180](https://github.com/terra-project/core/issues/180))

#### [\#179](https://github.com/terra-project/core/pull/179) Align Querier responses to JSON

* Querier was returning misaligned formats for return values, now aligned to JSON format

#### [\#178](https://github.com/terra-project/core/pull/178) Correctly use 330 as the coin type field in BIP 44 PATH

* We were previously using the Cosmos coin type field for the BIP44 path. Changed to Terra's own 330.


## 0.2.1

- [\#166](https://github.com/terra-project/core/pull/166): Newly added parameters were not being added to the columbus-2 genesis.json file. Fixed.
Expand Down
4 changes: 4 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sort"

"github.com/terra-project/core/types"
"github.com/terra-project/core/update"
"github.com/terra-project/core/version"
"github.com/terra-project/core/x/budget"
"github.com/terra-project/core/x/market"
Expand Down Expand Up @@ -335,6 +336,9 @@ func (app *TerraApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.
treasuryTags := treasury.EndBlocker(ctx, app.treasuryKeeper)
tags = append(tags, treasuryTags...)

updateTags := update.EndBlocker(ctx, app.accountKeeper, app.oracleKeeper, app.marketKeeper)
tags = append(tags, updateTags...)

if app.assertInvariantsBlockly {
app.assertRuntimeInvariants()
}
Expand Down
42 changes: 30 additions & 12 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ type GenesisAccount struct {
AccountNumber uint64 `json:"account_number"`

// vesting account fields
OriginalVesting sdk.Coins `json:"original_vesting"` // total vesting coins upon initialization
DelegatedFree sdk.Coins `json:"delegated_free"` // delegated vested coins at time of delegation
DelegatedVesting sdk.Coins `json:"delegated_vesting"` // delegated vesting coins at time of delegation
StartTime int64 `json:"start_time"` // vesting start time (UNIX Epoch time)
EndTime int64 `json:"end_time"` // vesting end time (UNIX Epoch time)
VestingSchedules []types.VestingSchedule `json:"vesting_schedules"` // vesting end time (UNIX Epoch time)
OriginalVesting sdk.Coins `json:"original_vesting"` // total vesting coins upon initialization
DelegatedFree sdk.Coins `json:"delegated_free"` // delegated vested coins at time of delegation
DelegatedVesting sdk.Coins `json:"delegated_vesting"` // delegated vesting coins at time of delegation
StartTime int64 `json:"start_time"` // vesting start time (UNIX Epoch time)
EndTime int64 `json:"end_time"` // vesting end time (UNIX Epoch time)
VestingSchedules []types.VestingSchedule `json:"vesting_schedules"` // vesting schedule (clif: UNIX Epoch time, ratio: dec)
LazyVestingSchedules []types.LazyVestingSchedule `json:"lazy_vesting_schedules"` // lazy vesting schedule (start_time&end_time: UNIX Epoch time, ratio: dec)
}

// NewGenesisAccount returns new genesis account
Expand All @@ -122,15 +123,21 @@ func NewGenesisAccountI(acc auth.Account) GenesisAccount {

vacc, ok := acc.(auth.VestingAccount)
if ok {
gacc.OriginalVesting = vacc.GetOriginalVesting()
gacc.DelegatedFree = vacc.GetDelegatedFree()
gacc.DelegatedVesting = vacc.GetDelegatedVesting()
gacc.StartTime = vacc.GetStartTime()
gacc.EndTime = vacc.GetEndTime()

gvacc, ok := vacc.(types.GradedVestingAccount)
if ok {
gacc.OriginalVesting = gvacc.GetOriginalVesting()
gacc.DelegatedFree = gvacc.GetDelegatedFree()
gacc.DelegatedVesting = gvacc.GetDelegatedVesting()
gacc.StartTime = gvacc.GetStartTime()
gacc.EndTime = gvacc.GetEndTime()
gacc.VestingSchedules = gvacc.GetVestingSchedules()
}

lgvacc, ok := vacc.(types.LazyGradedVestingAccount)
if ok {
gacc.LazyVestingSchedules = lgvacc.GetLazyVestingSchedules()
}
}

return gacc
Expand Down Expand Up @@ -163,11 +170,16 @@ func (ga *GenesisAccount) ToAccount() auth.Account {
return &auth.DelayedVestingAccount{
BaseVestingAccount: baseVestingAcc,
}
} else {
} else if ga.VestingSchedules != nil {
return &types.BaseGradedVestingAccount{
BaseVestingAccount: baseVestingAcc,
VestingSchedules: ga.VestingSchedules,
}
} else if ga.LazyVestingSchedules != nil {
return &types.BaseLazyGradedVestingAccount{
BaseVestingAccount: baseVestingAcc,
LazyVestingSchedules: ga.LazyVestingSchedules,
}
}
}

Expand Down Expand Up @@ -307,6 +319,12 @@ func validateGenesisStateAccounts(accs []GenesisAccount) error {
return fmt.Errorf("schedule is invalid for vesting account; address: %s, denom: %s", addrStr, vestingSchedule.GetDenom())
}
}
} else if acc.LazyVestingSchedules != nil && len(acc.LazyVestingSchedules) > 0 {
for _, lazyVestingSchedule := range acc.LazyVestingSchedules {
if !lazyVestingSchedule.IsValid() {
return fmt.Errorf("lazy schedule is invalid for vesting account; address: %s, denom: %s", addrStr, lazyVestingSchedule.GetDenom())
}
}
} else {
if acc.EndTime == 0 {
return fmt.Errorf("missing end time for vesting account; address: %s", addrStr)
Expand Down
50 changes: 44 additions & 6 deletions client/lcd/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,16 @@ paths:
x-example: terra16gdxm24ht2mxtpz9cma6tr6a6d47x63hlq4pxt
responses:
200:
description: Account information on the blockchain (one of Account and GradedVestingAccount)
description: Account information on the blockchain (one of Account and GradedVestingAccount and LazyGradedVestingAccount)
schema:
type: object
properties:
Account:
$ref: "#/definitions/Account"
GradedVestingAccount:
$ref: "#/definitions/GradedVestingAccount"
LazyGradedVestingAccount:
$ref: "#/definitions/LazyGradedVestingAccount"


204:
Expand Down Expand Up @@ -2583,7 +2585,6 @@ definitions:
ratio:
type: string
example: "0.100000000000000000"

VestingSchedule:
type: object
properties:
Expand All @@ -2594,7 +2595,6 @@ definitions:
type: array
items:
$ref: "#/definitions/Schedule"

BaseGradedVestingAccount:
type: object
properties:
Expand All @@ -2603,9 +2603,7 @@ definitions:
vesting_schedules:
type: array
items:
$ref: "#/definitions/VestingSchedule"


$ref: "#/definitions/VestingSchedule"
GradedVestingAccount:
type: object
properties:
Expand All @@ -2614,6 +2612,46 @@ definitions:
example: "core/GradedVestingAccount"
value:
$ref: "#/definitions/BaseGradedVestingAccount"

LazySchedule:
type: object
properties:
start_time:
type: string
example: "1556085600"
end_time:
type: string
example: "1556085600"
ratio:
type: string
example: "0.100000000000000000"
LazyVestingSchedule:
type: object
properties:
denom:
type: string
example: "usdr"
lazy_schedules:
type: array
items:
$ref: "#/definitions/LazySchedule"
BaseLazyGradedVestingAccount:
type: object
properties:
BaseVestingAccount:
$ref: "#/definitions/BaseVestingAccount"
lazy_vesting_schedules:
type: array
items:
$ref: "#/definitions/LazyVestingSchedule"
LazyGradedVestingAccount:
type: object
properties:
type:
type: string
example: "core/LazyGradedVestingAccount"
value:
$ref: "#/definitions/BaseLazyGradedVestingAccount"

TendermintValidator:
type: object
Expand Down
1 change: 1 addition & 0 deletions types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(&Schedule{}, "core/Schedule", nil)
cdc.RegisterConcrete(&VestingSchedule{}, "core/VestingSchedule", nil)
cdc.RegisterConcrete(&BaseGradedVestingAccount{}, "core/GradedVestingAccount", nil)
cdc.RegisterConcrete(&BaseLazyGradedVestingAccount{}, "core/LazyGradedVestingAccount", nil)
}
Loading