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

feat(ics20): support leverage/MsgRepay in Memo #2506

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@

- [2472](https://github.com/umee-network/umee/pull/2472) un-wire the `crisis` module from umee app.
- [2500](https://github.com/umee-network/umee/pull/2500) (x/leverage): add Rewards Auction fees and `params.rewards_auction_factor`.
- [2506](https://github.com/umee-network/umee/pull/2506) (ics20): support leverage/MsgRepay in Memo


Check failure on line 55 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Multiple consecutive blank lines

CHANGELOG.md:55 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md012.md
### Improvements

- [2474](https://github.com/umee-network/umee/pull/2474) (proto) add `gogo.messagename_all` option to all messages.
Expand Down
4 changes: 4 additions & 0 deletions x/uibc/uics20/memo_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ func (mh MemoHandler) validateMemoMsg() error {
// collateral = asset
case *ltypes.MsgSupply:
asset = &msg.Asset
case *ltypes.MsgRepay:
asset = &msg.Asset
case *ltypes.MsgLiquidate:
asset = &msg.Repayment
default:
Expand Down Expand Up @@ -197,6 +199,8 @@ func (mh MemoHandler) handleMemoMsg(ctx *sdk.Context, msg sdk.Msg) (err error) {
_, err = mh.leverage.Supply(*ctx, msg)
case *ltypes.MsgSupplyCollateral:
_, err = mh.leverage.SupplyCollateral(*ctx, msg)
case *ltypes.MsgRepay:
_, err = mh.leverage.Repay(*ctx, msg)
case *ltypes.MsgLiquidate:
_, err = mh.leverage.Liquidate(*ctx, msg)
default:
Expand Down
8 changes: 6 additions & 2 deletions x/uibc/uics20/memo_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestValidateMemoMsg(t *testing.T) {
goodMsgSupplyColl := ltypes.NewMsgSupplyCollateral(receiver, asset)
// goodMsgSupplyCollH := ltypes.NewMsgSupplyCollateral(receiver, assetH)
goodMsgSupplyColl11 := ltypes.NewMsgSupplyCollateral(receiver, asset11)
goodMsgRepay := ltypes.NewMsgRepay(receiver, asset11)
goodMsgBorrow := ltypes.NewMsgBorrow(receiver, asset)
goodMsgBorrowH := ltypes.NewMsgBorrow(receiver, assetH)
goodMsgLiquidate := ltypes.NewMsgLiquidate(receiver, accs.Bob, assetH, "uumee")
Expand All @@ -53,9 +54,10 @@ func TestValidateMemoMsg(t *testing.T) {
// good messages[0]
{[]sdk.Msg{goodMsgSupply}, ""},
{[]sdk.Msg{goodMsgSupplyColl}, ""},
{[]sdk.Msg{goodMsgLiquidate}, ""}, // in handlers v2 this will be a good message
{[]sdk.Msg{goodMsgRepay}, ""},
{[]sdk.Msg{goodMsgLiquidate}, ""},

// messages[0] use more assets than the transfer -> OK
// messages[0] use more assets than the transfer -> OK: should be adjusted
{[]sdk.Msg{goodMsgSupply11}, ""},
{[]sdk.Msg{goodMsgSupplyColl11}, ""},
{[]sdk.Msg{goodMsgSupplyColl11}, ""},
Expand Down Expand Up @@ -167,6 +169,7 @@ func TestMemoExecute(t *testing.T) {
mh := MemoHandler{leverage: lvg}
ctx, _ := tsdk.NewCtxOneStore(t, storetypes.NewMemoryStoreKey("quota"))
msgs := []sdk.Msg{&ltypes.MsgSupply{}}
msgsRepay := []sdk.Msg{&ltypes.MsgRepay{}}

tcs := []struct {
enabled bool
Expand All @@ -176,6 +179,7 @@ func TestMemoExecute(t *testing.T) {
}{
{true, true, msgs, nil},
{true, false, msgs, nil},
{true, false, msgsRepay, nil},
{true, false, nil, nil},

{false, true, nil, errHooksDisabled},
Expand Down
Loading