Skip to content

Commit

Permalink
Merge branch 'main' into adam/test
Browse files Browse the repository at this point in the history
  • Loading branch information
toteki committed Jul 6, 2023
2 parents ce9773e + 4659561 commit e893041
Show file tree
Hide file tree
Showing 30 changed files with 761 additions and 170 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v5.1.0-rc1](https://github.com/umee-network/umee/releases/tag/v5.0.0-rc1) - 2023-06-30

### Features

- [2121](https://github.com/umee-network/umee/pull/2121) Allow `MsgLeveragedLiquidate` to auto-select repay and reward denoms if request fields left blank.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ See [Release procedure](CONTRIBUTING.md#release-procedure) for more information
| v4.2.x || v0.46.10+ | v5.2.x | v1.3.x+ | umee/v2.1.1 | umee/v4 v1.5.3-umee-4 | v1.1.1 |
| v4.3.x || v0.46.11+ | v6.1.x | v1.3.x+ | umee/v2.1.1 | umee/v4 v1.5.3-umee-6 | v1.2.1 |
| v4.4.x || v0.46.11+ | v6.1.x | v1.3.x+ | umee/v2.1.4+ | umee/v4 v1.5.3-umee-6 | v1.2.3 |
| v5.0.x || v0.46.13+ | v6.1.x | v1.3.x+ | umee/v2.1.4+ | umee/v4 v1.5.3-umee-8 | v1.2.4 |
| v5.1.x || v0.46.13+ | v6.1.x | v1.3.x+ | umee/v2.1.4+ | umee/v4 v1.5.3-umee-9 | v1.2.4 |
| v5.0.x || v0.46.13+ | v6.2.x | v1.3.x+ | umee/v2.1.4+ | umee/v4 v1.5.3-umee-8 | v1.2.4 |
| v5.1.x || v0.46.13+ | v6.2.x | --- | umee/v2.1.6+ | umee/v4 v1.5.3-umee-10 | v1.2.4 |

#### Price Feeder

Expand Down
28 changes: 8 additions & 20 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,22 @@

Release Procedure is defined in the [CONTRIBUTING](CONTRIBUTING.md#release-procedure) document.

## v5.0.0
## v5.1.0

Highlights:

- Cosmwasm integration (v0.31).
- Gravity Bridge phase-3: shutdown of the transfers. In this release we introduce valset burn mechanism,
which will block the Ethereum smart contract for processing any further transactions, as well
as sending transfers back to Ethereum. This follows the plan approved through in the
[prop-67](https://www.mintscan.io/umee/proposals/67).
NOTE: All validators must continue to use Peggo to not get slashed.
- Updated to the latest Cosmos SDK v0.46.12
- New generic functions for storage management: `util/store`.
- [`x/incentive`](x/incentive/README.md) module: allows to create incentive programs for liquidity mining.
- new x/leverage security measure: [Borrow Factor](x/leverage/README.md#borrow-factor)
- new x/leverage [`MsgLeveragedLiquidate`](proto/umee/leverage/v1/tx.proto#L59) was added. Allows suppliers to use their active collateral to absorb unhealthy debts. See [Liquidation](x/leverage/README.md#liquidation) for more details.
- Gravity Bridge phase-4: the GB valset was correctly burned. Slashing is removed and there is no need to run Peggo any more.

See [CHANGELOG](https://github.com/umee-network/umee/blob/v5.0.0/CHANGELOG.md).
[v5.1.0-rc1 CHANGELOG](https://github.com/umee-network/umee/blob/v5.1.0-rc1/CHANGELOG.md).

### Validators

#### libwasmvm update
#### Peggo

Our dependencies have been updated. Now the binary requires `libwasmvm v1.2.4`. When you build the binary from source on the server machine you probably don't need any change. However when you download a binary from GitHub, or from other source, make sure you update the `/usr/lib/libwasmvm.<cpu_arch>.so`. For example:

- copy from `$GOPATH/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.2.4/internal/api/libwasmvm.$(uname -m).so`
- or download from github `wget https://raw.githubusercontent.com/CosmWasm/wasmvm/v1.2.4/internal/api/libwasmvm.$(uname -m).so -O /lib/libwasmvm.$(uname -m).so`

You don't need to do anything if you are using our Docker image.
You can kill Peggo.

#### Min Gas Prices

Expand All @@ -40,16 +31,13 @@ Since v4.2 release we request all validators set a `minimum-gas-prices` setting
minimum-gas-prices = "0.1uumee"
```

You MUST also set the related parameter when starting Peggo `--cosmos-gas-prices="0.1uumee"`

### Upgrade instructions

- Download latest binary or build from source.
- Make sure `libwasmvm.$(uname -m).so` is properly linked
- Run the binary to make sure it works for you: `umeed version`
- Wait for software upgrade proposal to pass and trigger the chain upgrade.
- Swap binaries.
- Ensure latest Peggo (v1.4.0) is running
- Ensure latest Price Feeder (see [compatibility matrix](https://github.com/umee-network/umee/#release-compatibility-matrix)) is running and check your price feeder config is up to date.
- Restart the chain.

Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ func New(
availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,umee"

// Register umee custom plugin to wasm
wasmOpts = append(uwasm.RegisterCustomPlugins(app.LeverageKeeper, app.OracleKeeper), wasmOpts...)
wasmOpts = append(uwasm.RegisterCustomPlugins(app.LeverageKeeper, app.OracleKeeper, app.IncentiveKeeper), wasmOpts...)
// Register stargate queries
wasmOpts = append(wasmOpts, uwasm.RegisterStargateQueries(*bApp.GRPCQueryRouter(), appCodec)...)

Expand Down
14 changes: 7 additions & 7 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ func (app UmeeApp) RegisterUpgradeHandlers(bool) {
app.registerUpgrade("v4.4", upgradeInfo)
app.registerUpgrade("v5.0", upgradeInfo, ugov.ModuleName, wasm.ModuleName)
app.registerUpgrade5_1(upgradeInfo)
// TODO: set correct 5.1 name and add borrowFactor migration
}

func (app *UmeeApp) registerUpgrade5_1(upgradeInfo upgradetypes.Plan) {
planName := "v5.1"
app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
app.storeUpgrade(planName, upgradeInfo, storetypes.StoreUpgrades{
Added: []string{incentive.ModuleName},
})

// TODO: set the correct drain account. This will panic if executed.
if err := app.GravityKeeper.MigrateFundsToDrainAccount(
ctx,
sdk.MustAccAddressFromBech32("the_drain_account"),
sdk.MustAccAddressFromBech32("umee1gx9svenfs6ktvajje2wgqau3gk5mznwnyghq4l"),
); err != nil {
return nil, err
}
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})
},
)

app.storeUpgrade(planName, upgradeInfo, storetypes.StoreUpgrades{
Added: []string{incentive.ModuleName},
})
}

// performs upgrade from v4.2 to v4.3
Expand Down
4 changes: 3 additions & 1 deletion app/wasm/custom_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/umee-network/umee/v5/app/wasm/msg"
"github.com/umee-network/umee/v5/app/wasm/query"
inckeeper "github.com/umee-network/umee/v5/x/incentive/keeper"
leveragekeeper "github.com/umee-network/umee/v5/x/leverage/keeper"
oraclekeeper "github.com/umee-network/umee/v5/x/oracle/keeper"
)
Expand All @@ -16,8 +17,9 @@ import (
func RegisterCustomPlugins(
leverageKeeper leveragekeeper.Keeper,
oracleKeeper oraclekeeper.Keeper,
incentiveKeeper inckeeper.Keeper,
) []wasmkeeper.Option {
wasmQueryPlugin := query.NewQueryPlugin(leverageKeeper, oracleKeeper)
wasmQueryPlugin := query.NewQueryPlugin(leverageKeeper, oracleKeeper, incentiveKeeper)
queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{
Custom: wasmQueryPlugin.CustomQuerier(),
})
Expand Down
107 changes: 107 additions & 0 deletions app/wasm/query/handle_incentive.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package query

import (
"context"

"github.com/gogo/protobuf/proto"
"github.com/umee-network/umee/v5/x/incentive"
)

// HandleLeverageParams handles the get the x/leverage module's parameters.
func (q UmeeQuery) HandleIncentiveParams(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.Params(ctx, &incentive.QueryParams{})
}

// HandleTotalBonded handles the get the sum of all bonded collateral uTokens.
func (q UmeeQuery) HandleTotalBonded(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.TotalBonded(ctx, &incentive.QueryTotalBonded{Denom: q.TotalBonded.Denom})
}

// HandleTotalUnbonding handles the get the sum of all unbonding collateral uTokens.
func (q UmeeQuery) HandleTotalUnbonding(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.TotalUnbonding(ctx, &incentive.QueryTotalUnbonding{Denom: q.TotalUnbonding.Denom})
}

// HandleAccountBonds handles the get all bonded collateral and unbondings associated with an account.
func (q UmeeQuery) HandleAccountBonds(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.AccountBonds(ctx, &incentive.QueryAccountBonds{Address: q.AccountBonds.Address})
}

// HandlePendingRewards handles the gets all unclaimed incentive rewards associated with an account.
func (q UmeeQuery) HandlePendingRewards(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.PendingRewards(ctx, &incentive.QueryPendingRewards{Address: q.PendingRewards.Address})
}

// HandleCompletedIncentivePrograms handles the get all incentives programs that have been passed
// by governance,
func (q UmeeQuery) HandleCompletedIncentivePrograms(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.CompletedIncentivePrograms(ctx, &incentive.QueryCompletedIncentivePrograms{})
}

// HandleOngoingIncentivePrograms handles the get all incentives programs that have been passed
// by governance, funded, and started but not yet completed.
func (q UmeeQuery) HandleOngoingIncentivePrograms(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.OngoingIncentivePrograms(ctx, &incentive.QueryOngoingIncentivePrograms{})
}

// HandleUpcomingIncentivePrograms handles the get all incentives programs that have been passed
// by governance, but not yet started. They may or may not have been funded.
func (q UmeeQuery) HandleUpcomingIncentivePrograms(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.UpcomingIncentivePrograms(ctx, &incentive.QueryUpcomingIncentivePrograms{})
}

// HandleIncentiveProgram handles the get a single incentive program by ID.
func (q UmeeQuery) HandleIncentiveProgram(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.IncentiveProgram(ctx, &incentive.QueryIncentiveProgram{Id: q.IncentiveProgram.Id})
}

// HandleCurrentRates handles the get current rates of given denom
func (q UmeeQuery) HandleCurrentRates(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.CurrentRates(ctx, &incentive.QueryCurrentRates{UToken: q.CurrentRates.UToken})
}

// HandleActualRates handles the get the actutal rates of given denom
func (q UmeeQuery) HandleActualRates(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.ActualRates(ctx, &incentive.QueryActualRates{UToken: q.CurrentRates.UToken})
}

// HandleLastRewardTime handles the get last block time at which incentive rewards were calculated.
func (q UmeeQuery) HandleLastRewardTime(
ctx context.Context,
qs incentive.QueryServer,
) (proto.Message, error) {
return qs.LastRewardTime(ctx, &incentive.QueryLastRewardTime{})
}
39 changes: 35 additions & 4 deletions app/wasm/query/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/gogo/protobuf/proto"

"github.com/umee-network/umee/v5/x/incentive"
inckeeper "github.com/umee-network/umee/v5/x/incentive/keeper"
lvkeeper "github.com/umee-network/umee/v5/x/leverage/keeper"
lvtypes "github.com/umee-network/umee/v5/x/leverage/types"
ockeeper "github.com/umee-network/umee/v5/x/oracle/keeper"
Expand All @@ -17,18 +19,21 @@ import (

// Plugin wraps the query plugin with queriers.
type Plugin struct {
lvQueryServer lvtypes.QueryServer
ocQueryServer ocpes.QueryServer
lvQueryServer lvtypes.QueryServer
ocQueryServer ocpes.QueryServer
incQueryServer incentive.QueryServer
}

// NewQueryPlugin creates a plugin to query native modules.
func NewQueryPlugin(
leverageKeeper lvkeeper.Keeper,
oracleKeeper ockeeper.Keeper,
incentiveKeeper inckeeper.Keeper,
) *Plugin {
return &Plugin{
lvQueryServer: lvkeeper.NewQuerier(leverageKeeper),
ocQueryServer: ockeeper.NewQuerier(oracleKeeper),
lvQueryServer: lvkeeper.NewQuerier(leverageKeeper),
ocQueryServer: ockeeper.NewQuerier(oracleKeeper),
incQueryServer: inckeeper.NewQuerier(incentiveKeeper),
}
}

Expand Down Expand Up @@ -88,6 +93,32 @@ func (plugin *Plugin) CustomQuerier() func(ctx sdk.Context, request json.RawMess
case smartcontractQuery.MedianDeviations != nil:
resp, err = smartcontractQuery.HandleMedianDeviations(ctx, plugin.ocQueryServer)

// incentive
case smartcontractQuery.IncentiveParameters != nil:
resp, err = smartcontractQuery.HandleIncentiveParams(ctx, plugin.incQueryServer)
case smartcontractQuery.TotalBonded != nil:
resp, err = smartcontractQuery.HandleTotalBonded(ctx, plugin.incQueryServer)
case smartcontractQuery.TotalUnbonding != nil:
resp, err = smartcontractQuery.HandleTotalUnbonding(ctx, plugin.incQueryServer)
case smartcontractQuery.AccountBonds != nil:
resp, err = smartcontractQuery.HandleAccountBonds(ctx, plugin.incQueryServer)
case smartcontractQuery.PendingRewards != nil:
resp, err = smartcontractQuery.HandlePendingRewards(ctx, plugin.incQueryServer)
case smartcontractQuery.CompletedIncentivePrograms != nil:
resp, err = smartcontractQuery.HandleCompletedIncentivePrograms(ctx, plugin.incQueryServer)
case smartcontractQuery.UpcomingIncentivePrograms != nil:
resp, err = smartcontractQuery.HandleUpcomingIncentivePrograms(ctx, plugin.incQueryServer)
case smartcontractQuery.OngoingIncentivePrograms != nil:
resp, err = smartcontractQuery.HandleOngoingIncentivePrograms(ctx, plugin.incQueryServer)
case smartcontractQuery.IncentiveProgram != nil:
resp, err = smartcontractQuery.HandleIncentiveParams(ctx, plugin.incQueryServer)
case smartcontractQuery.CurrentRates != nil:
resp, err = smartcontractQuery.HandleCurrentRates(ctx, plugin.incQueryServer)
case smartcontractQuery.ActualRates != nil:
resp, err = smartcontractQuery.HandleActualRates(ctx, plugin.incQueryServer)
case smartcontractQuery.LastRewardTime != nil:
resp, err = smartcontractQuery.HandleLastRewardTime(ctx, plugin.incQueryServer)

default:
return nil, wasmvmtypes.UnsupportedRequest{Kind: "invalid umee query"}
}
Expand Down
34 changes: 34 additions & 0 deletions app/wasm/query/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

wasmvmtypes "github.com/CosmWasm/wasmvm/types"
"github.com/umee-network/umee/v5/x/incentive"
lvtypes "github.com/umee-network/umee/v5/x/leverage/types"
octypes "github.com/umee-network/umee/v5/x/oracle/types"
)
Expand Down Expand Up @@ -56,6 +57,39 @@ type UmeeQuery struct {
Medians *octypes.QueryMedians `json:"medians,omitempty"`
// Used to get all median deviations.
MedianDeviations *octypes.QueryMedianDeviations `json:"median_deviations,omitempty"`

// incentive queries
// Incentive module params .
IncentiveParameters *incentive.QueryParams `json:"incentive_parameters,omitempty"`
// TotalBonded queries the sum of all bonded collateral uTokens.
TotalBonded *incentive.QueryTotalBonded `json:"total_bonded,omitempty"`
// TotalUnbonding queries the sum of all unbonding collateral uTokens.
TotalUnbonding *incentive.QueryTotalUnbonding `json:"total_unbonding,omitempty"`
// AccountBonds queries all bonded collateral and unbondings associated with an account.
AccountBonds *incentive.QueryAccountBonds `json:"account_bonds,omitempty"`
// PendingRewards queries unclaimed incentive rewards associated with an account.
PendingRewards *incentive.QueryPendingRewards `json:"pending_rewards,omitempty"`
// CompletedIncentivePrograms queries for all incentives programs that have been passed
// by governance,
CompletedIncentivePrograms *incentive.QueryCompletedIncentivePrograms `json:"completed_incentive_programs,omitempty"`
// OngoingIncentivePrograms queries for all incentives programs that have been passed
// by governance, funded, and started but not yet completed.
OngoingIncentivePrograms *incentive.QueryOngoingIncentivePrograms `json:"ongoing_incentive_programs,omitempty"`
// UpcomingIncentivePrograms queries for all incentives programs that have been passed
// by governance, but not yet started. They may or may not have been funded.
UpcomingIncentivePrograms *incentive.QueryUpcomingIncentivePrograms `json:"upcoming_incentive_programs,omitempty"`
// IncentiveProgram queries a single incentive program by ID.
IncentiveProgram *incentive.QueryIncentiveProgram `json:"incentive_program,omitempty"`
// CurrentRates queries the hypothetical return of a bonded uToken denomination
// if current incentive rewards continued for one year. The response is an sdk.Coins
// of base token rewards, per reference amount (usually 10^exponent of the uToken.)
CurrentRates *incentive.QueryCurrentRates `json:"current_rates,omitempty"`
// ActualRates queries the hypothetical return of a bonded uToken denomination
// if current incentive rewards continued for one year. The response is an sdk.Dec
// representing an oracle-adjusted APY.
ActualRates *incentive.QueryActualRates `json:"actual_rates,omitempty"`
// LastRewardTime queries the last block time at which incentive rewards were calculated.
LastRewardTime *incentive.QueryLastRewardTime `json:"last_reward_time,omitempty"`
}

// MarshalResponse marshals any response.
Expand Down
Loading

0 comments on commit e893041

Please sign in to comment.