Skip to content

Commit

Permalink
Merge branch 'main' into egor/metoken-eg
Browse files Browse the repository at this point in the history
  • Loading branch information
kosegor committed Sep 15, 2023
2 parents 314cd4c + 87159cb commit 1e55cb3
Show file tree
Hide file tree
Showing 15 changed files with 338 additions and 113 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release-umee-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
# github.repository == <account>/<repo>
images: ghcr.io/${{ github.repository_owner }}/umeed
Expand All @@ -32,7 +32,7 @@ jobs:
latest=false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Print tags and labels
run: |
Expand All @@ -41,7 +41,7 @@ jobs:
echo labels "${{ steps.meta.outputs.labels }}"
- name: Login to GHCR
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -53,7 +53,7 @@ jobs:
make proto-update-swagger-docs
- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
file: ./contrib/images/umeed.dockerfile
platforms: linux/amd64
Expand Down
56 changes: 44 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section under the
appropriate stanza (see below). Each entry should ideally include a tag and
the Github PR referenced in the following format:
appropriate stanza (see below). Each entry should ideally include the Github
PR referenced in the following format:
* (<tag>) [#<PR-number>](https://github.com/umee-network/umee/pull/<PR-number>) <changelog entry>
* [PR-number](https://github.com/umee-network/umee/pull/PR-number) description
Types of changes (Stanzas):
Expand All @@ -34,7 +34,7 @@ To release a new version, ensure an appropriate release branch exists. Add a
release version and date to the existing Unreleased section which takes the form
of:
## [<version>](https://github.com/umee-network/umee/releases/tag/<version>) - YYYY-MM-DD
## [version](https://github.com/umee-network/umee/releases/tag/version) - YYYY-MM-DD
Once the version is tagged and released, a PR should be made against the main
branch to incorporate the new changelog updates.
Expand All @@ -46,43 +46,75 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v6.0.0](https://github.com/umee-network/umee/releases/tag/v6.0.0) - 2023-09-14

### Features

- [2128](https://github.com/umee-network/umee/pull/2128) CW transaction and query handlers for the incentive module.
- [2129](https://github.com/umee-network/umee/pull/2129) Emergency Group x/ugov proto.
- [2145](https://github.com/umee-network/umee/pull/2145) UMEE v2 Inflation.
- [2146](https://github.com/umee-network/umee/pull/2146) Add store `GetTimeMs` and `SetTimeMs`.
- [2157](https://github.com/umee-network/umee/pull/2157) Add `x/metoken` module.
- [2150](https://github.com/umee-network/umee/pull/2150) Add gov message to create Special Asset Pairs
- [2150](https://github.com/umee-network/umee/pull/2150), [2178](https://github.com/umee-network/umee/pull/2178) `x/leverage` Special Asset Pairs.
- [2145](https://github.com/umee-network/umee/pull/2145) Add New `Inflation Parms` to x/ugov proto and added `inflation rate` change logic to umint
- [2159](https://github.com/umee-network/umee/pull/2159) Add hard market cap for token emission.
- [2155](https://github.com/umee-network/umee/pull/2155) `bpmath`: basis points math package.
- [2166](https://github.com/umee-network/umee/pull/2166) Basis Points: `MulDec`
- [2170](https://github.com/umee-network/umee/pull/2170) Add SupplyFromModule and WithdrawToModule to leverage keeper.
- [2170](https://github.com/umee-network/umee/pull/2170) Add `SupplyFromModule` and `WithdrawToModule` to leverage keeper.
- [2177](https://github.com/umee-network/umee/pull/2177) metoken queries to cosmwasm and stargate queries.
- [2187](https://github.com/umee-network/umee/pull/2187) New CMD: `ibc_denom`. It creates ibc denom by base denom and channel-id.
- [2188](https://github.com/umee-network/umee/pull/2188) Emergency Group support for `x/leverage`.
- [2191](https://github.com/umee-network/umee/pull/2191) Emergency Group support for IBC Quota.
- [2242](https://github.com/umee-network/umee/pull/2242) New `MsgLeveragedLiquidate.MaxRepay` which allows to limit the liquidation size using the leveraged liquidation mechanism.

### Improvements

- [2134](https://github.com/umee-network/umee/pull/2134) Bump CometBFT to 34.29.
- [2135](https://github.com/umee-network/umee/pull/2135) Remove Gravity Bridge module.
- [2209](https://github.com/umee-network/umee/pull/2209) Move leverage module params from paramspace to regular leverage module state.

### State Machine Breaking

- [2197](https://github.com/umee-network/umee/pull/2197) Allowing duplicate symbols on leverage token registry. Fix the oracle voting miss counter on duplicate symbol denoms.
- [2145](https://github.com/umee-network/umee/pull/2145) new UMEE inflation schedule.
- [2176](https://github.com/umee-network/umee/pull/2176) x/ugov module v2: adding token emission params.

### Bug Fixes

- [2148](https://github.com/umee-network/umee/pull/2148) Fix MsgBeginUnbonding counting existing unbondings against max unbond twice.
- [2148](https://github.com/umee-network/umee/pull/2148) Fix MsgLeverageLiquidate CLI not actually allowing wildcard denoms.
- [2197](https://github.com/umee-network/umee/pull/2197) Allowing duplicate symbols on leverage token registry. Fix the oracle voting miss counter on duplicate symbol denoms.
- [2212](https://github.com/umee-network/umee/pull/2212) Fixes an x/oracle RPC endpoint spelling, changing "/umee/oracle/v1/valdiators/{validator_addr}/aggregate_vote" to "/umee/oracle/v1/validators/{validator_addr}/aggregate_vote"
- [2185](https://github.com/umee-network/umee/pull/2185) `x/oracle` end_blocker panic.

### API Breaking

- [2135](https://github.com/umee-network/umee/pull/2135) Gravity Bridge API is removed.
- [2140](https://github.com/umee-network/umee/pull/2140) Renamed ugov EventMinTxFees to EventMinGasPrice.
- [2165](https://github.com/umee-network/umee/pull/2165) Use underscore for message part in the web gRPC path format:
- `/umee/ugov/v1/min-gas-price` --> `/umee/ugov/v1/min_gas_price`
- `/umee/ugov/v1/emergency-group` --> `/umee/ugov/v1/emergency_group`
- `/umee/uibc/v1/all-outflows` --> `/umee/uibc/v1/all_outflows`
- [2169](https://github.com/umee-network/umee/pull/2169) Update numeric store getters (`util/store` package) to return bool if value is missing.
- [2180](https://github.com/umee-network/umee/pull/2180) Rename leverage `Keeper.ExchangeToken -> ToUToken`, `Keeper.ExchangeUToken -> ToToken` and `Keeper.ExchangeUTokens -> ToTokens`.
- [2183](https://github.com/umee-network/umee/pull/2183) Move `ToUTokenDenom`, `StripUTokenDenom` and `HasUTokenPrefix` from `leverage/keeper` to `coin` package.
- [2203](https://github.com/umee-network/umee/pull/2203) Rework proposal messages. Remove Title from `ugov/MsgGovSetIBCStatus`, `ugov/MsgGovUpdateQuota`, `leverage/MsgGovUpdateRegistry`
- [2234](https://github.com/umee-network/umee/pull/2234) Remove "Get" prefix from cli/ ref tests.

## [v5.2.0](https://github.com/umee-network/umee/releases/tag/v5.2.0) - 2023-08-31

### Improvements

- [2134](https://github.com/umee-network/umee/pull/2134) Bump CometBFT to 34.29.
- [2196](https://github.com/umee-network/umee/pull/2196) Adding Amino support to `x/leverage.MsgLeveragedLiquidate`.

### State Machine Breaking

- [2197](https://github.com/umee-network/umee/pull/2197) Allowing duplicate symbols on leverage token registry. Fix the oracle voting miss counter on duplicate symbol denoms.

### Bug Fixes

- [2148](https://github.com/umee-network/umee/pull/2148) Fix MsgBeginUnbonding counting existing unbondings against max unbond twice.
- [2148](https://github.com/umee-network/umee/pull/2148) Fix MsgLeverageLiquidate CLI not actually allowing wildcard denoms.
- [2197](https://github.com/umee-network/umee/pull/2197) Allowing duplicate symbols on leverage token registry. Fix the oracle voting miss counter on duplicate symbol denoms.

### API Breaking

- [2212](https://github.com/umee-network/umee/pull/2212) Fixes an x/oracle RPC endpoint spelling, changing "/umee/oracle/v1/valdiators/{validator_addr}/aggregate_vote" to "/umee/oracle/v1/validators/{validator_addr}/aggregate_vote"

## [v5.1.0](https://github.com/umee-network/umee/releases/tag/v5.1.0) - 2023-07-07

Expand Down
15 changes: 14 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ Release Procedure is defined in the [CONTRIBUTING](CONTRIBUTING.md#release-proce

Highlights:

- TODO: special assets, new Gov messages
- We introduce [Special Assets](https://github.com/umee-network/umee/blob/v6.0.0-beta2/x/leverage/README.md#special-asset-pairs): a new primitive to optimize positions in x/leverage.
- New [inflation mechanism](./docs/design_docs/012-umee-inflation-v2.md).
- [Emergency Groups](#emergency-groups).
- Full Gravity Bridge removal. We don't include GB module any more in Umee.
- New `MsgLeveragedLiquidate.MaxRepay` which allows to limit the liquidation size using the leveraged liquidation mechanism.
- Renamed ugov `EventMinTxFees` to `EventMinGasPrice`.

### New Inflation Mechanism

Expand All @@ -28,6 +32,15 @@ The new Inflation Cycle will start on 2023-10-15 15:00 UTC. This will mark the f

The x/staking Bonded Goal stays the same: 33.00%.

### Emergency Groups

Currently, any parameter update requires going through a standard governance process, which takes 4 days. In a critical situation we need to act immediately:

- Control IBC Quota parameters (eg disable IBC)
- apply safe updates to oracle, leverage or incentive module parameters.

Emergency Group can trigger safe parameter updates at any time as a standard transaction. The Emergency Group address is controlled by the Umee Chain governance (`x/gov`) and can be disabled at any time.

### Validators

#### libwasmvm update
Expand Down
3 changes: 1 addition & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ func (app UmeeApp) RegisterUpgradeHandlers() {
func (app *UmeeApp) registerUpgrade6(upgradeInfo upgradetypes.Plan) {
planName := "v6.0"
gravityModuleName := "gravity" // hardcoded to avoid dependency on GB module
// TODO: update the address for the mainnet
emergencyGroup, err := sdk.AccAddressFromBech32("umee178nsnzse8capyfak4nwlntvfg64p4lmsau4t5n")
emergencyGroup, err := sdk.AccAddressFromBech32("umee1gy3c8n2xysawysq2xf2hxn253srx4ehduevq6c")
util.Panic(err)

app.UpgradeKeeper.SetUpgradeHandler(planName,
Expand Down
7 changes: 7 additions & 0 deletions proto/umee/leverage/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ service Msg {
// executing this transaction, instead of the regular 100%. Also allows repayment and reward denoms to
// be left blank - if not specified, the module will automatically select the first (alphabetically by denom)
// borrow and/or collateral on the target account and the proceed normally.
// After v6.0, includes a MaxRepay field which limits repay value in USD. To prevent dust exploits, this
// value cannot be below $1.00
rpc LeveragedLiquidate(MsgLeveragedLiquidate) returns (MsgLeveragedLiquidateResponse);

// SupplyCollateral combines the Supply and Collateralize actions.
Expand Down Expand Up @@ -174,6 +176,11 @@ message MsgLeveragedLiquidate {
// RewardDenom is the uToken denom that the liquidator will receive as a liquidation reward
// and immediately collateralize.
string reward_denom = 4;
// MaxRepay optionally limits the USD value to repay. If specified, this cannot be below $1.00
string max_repay = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// MsgSupplyCollateral represents a user's request to supply and collateralize assets to the module.
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_leverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *E2ETest) leverageLiquidate(addr, target sdk.AccAddress, repayDenom stri
}

func (s *E2ETest) leverageLeveragedLiquidate(addr, target sdk.AccAddress, repay, reward string) {
s.mustSucceedTx(leveragetypes.NewMsgLeveragedLiquidate(addr, target, repay, reward))
s.mustSucceedTx(leveragetypes.NewMsgLeveragedLiquidate(addr, target, repay, reward, sdk.ZeroDec()))
}

func (s *E2ETest) TestLeverageBasics() {
Expand Down
13 changes: 9 additions & 4 deletions x/leverage/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,19 @@ $ umeed tx leverage liquidate %s 50000000uumee u/uumee --from mykey`,
// transaction with a MsgLeveragedLiquidate message.
func LeveragedLiquidate() *cobra.Command {
cmd := &cobra.Command{
Use: "lev-liquidate [borrower] [repay-denom] [reward-denom]",
Use: "lev-liquidate [borrower] [repay-denom] [reward-denom] [max-repay]",
Args: cobra.RangeArgs(1, 3),
Short: "Liquidates by moving borrower debt to the liquidator and immediately collateralizes the reward.",
Long: strings.TrimSpace(
fmt.Sprintf(`
Borrow tokens to liquidate a borrower's debt and immediately collateralize the reward.
Will attempt to repay the maximum amount allowed by the targeted borrower's debt and collateral positions.
Will attempt to repay the max amount allowed by the targeted borrower's position unless max repay (USD) is specified.
The transaction will fail if the liquidator, with new borrow and collateral positions, would be above 0.8 borrow limit.
Example:
$ umeed tx leverage lev-liquidate %s uumee uumee --from mykey`,
$ umeed tx leverage lev-liquidate %s uumee uumee 123.4 --from mykey`,
"umee1qqy7cst5qm83ldupph2dcq0wypprkfpc9l3jg2",
),
),
Expand All @@ -350,6 +350,7 @@ $ umeed tx leverage lev-liquidate %s uumee uumee --from mykey`,
}

var repayDenom, rewardDenom string
maxRepay := sdk.ZeroDec()
if len(args) > 1 {
repayDenom = args[1]
}
Expand All @@ -358,7 +359,11 @@ $ umeed tx leverage lev-liquidate %s uumee uumee --from mykey`,
rewardDenom = args[2]
}

msg := types.NewMsgLeveragedLiquidate(clientCtx.GetFromAddress(), borrowerAddr, repayDenom, rewardDenom)
if len(args) > 3 {
maxRepay = sdk.MustNewDecFromStr(args[3])
}

msg := types.NewMsgLeveragedLiquidate(clientCtx.GetFromAddress(), borrowerAddr, repayDenom, rewardDenom, maxRepay)
if err = msg.ValidateBasic(); err != nil {
return err
}
Expand Down
17 changes: 14 additions & 3 deletions x/leverage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,13 @@ func (k Keeper) Liquidate(

// LeveragedLiquidate
func (k Keeper) LeveragedLiquidate(
ctx sdk.Context, liquidatorAddr, borrowerAddr sdk.AccAddress, repayDenom, rewardDenom string,
ctx sdk.Context, liquidatorAddr, borrowerAddr sdk.AccAddress,
repayDenom, rewardDenom string, maxRepay sdk.Dec,
) (repaid sdk.Coin, reward sdk.Coin, err error) {
// If the message did not specify repay or reward denoms, select one arbitrarily (first in
// denom alphabetical order) from borrower position. Then proceed normally with the transaction.
borrowed := k.GetBorrowerBorrows(ctx, borrowerAddr)
if repayDenom == "" {
borrowed := k.GetBorrowerBorrows(ctx, borrowerAddr)
if !borrowed.IsZero() {
repayDenom = borrowed[0].Denom
}
Expand All @@ -488,11 +489,21 @@ func (k Keeper) LeveragedLiquidate(
}
uRewardDenom := coin.ToUTokenDenom(rewardDenom)

// If the message did not specify max repay, attempt to liquidate the full amount
maxRepayCoin := sdk.NewCoin(repayDenom, borrowed.AmountOf(repayDenom))
if !maxRepay.IsZero() {
// Otherwise, convert from max USD repay to token
maxRepayCoin, err = k.TokenWithValue(ctx, repayDenom, maxRepay, types.PriceModeSpot)
if err != nil {
return sdk.Coin{}, sdk.Coin{}, err
}
}

tokenRepay, uTokenReward, _, err := k.getLiquidationAmounts(
ctx,
liquidatorAddr,
borrowerAddr,
sdk.NewCoin(repayDenom, sdk.OneInt()), // amount is ignored for LeveragedLiquidate
maxRepayCoin,
rewardDenom,
false,
true,
Expand Down
4 changes: 2 additions & 2 deletions x/leverage/keeper/liquidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ func (k Keeper) getLiquidationAmounts(
// for traditional liquidations, liquidator account balance limits repayment
availableRepay := k.bankKeeper.SpendableCoins(ctx, liquidatorAddr).AmountOf(repayDenom)
maxRepay = sdk.MinInt(maxRepay, availableRepay)
// maximum requested by liquidator
maxRepay = sdk.MinInt(maxRepay, requestedRepay.Amount)
}
// maximum requested by liquidator
maxRepay = sdk.MinInt(maxRepay, requestedRepay.Amount)
maxRepay = sdk.MinInt(maxRepay, maxRepayAfterCloseFactor) // close factor

// compute final liquidation amounts
Expand Down
3 changes: 2 additions & 1 deletion x/leverage/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ func (s msgServer) LeveragedLiquidate(
return nil, err
}

repaid, reward, err := s.keeper.LeveragedLiquidate(ctx, liquidator, borrower, msg.RepayDenom, msg.RewardDenom)
repaid, reward, err := s.keeper.LeveragedLiquidate(
ctx, liquidator, borrower, msg.RepayDenom, msg.RewardDenom, msg.MaxRepay)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 1e55cb3

Please sign in to comment.