From 85aa120f54d2f6b5c9bd99feb9a535f4e5b39c07 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Wed, 24 Apr 2024 10:19:52 +0200 Subject: [PATCH 1/3] feat(ics20): support leverage/MsgRepay in Memo --- x/uibc/uics20/memo_handler.go | 4 ++++ x/uibc/uics20/memo_handler_test.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/x/uibc/uics20/memo_handler.go b/x/uibc/uics20/memo_handler.go index d8ec86d66d..450ef0e083 100644 --- a/x/uibc/uics20/memo_handler.go +++ b/x/uibc/uics20/memo_handler.go @@ -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: @@ -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: diff --git a/x/uibc/uics20/memo_handler_test.go b/x/uibc/uics20/memo_handler_test.go index d9d594e588..e8ddd6ca31 100644 --- a/x/uibc/uics20/memo_handler_test.go +++ b/x/uibc/uics20/memo_handler_test.go @@ -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") @@ -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}, ""}, @@ -167,6 +169,7 @@ func TestMemoExecute(t *testing.T) { mh := MemoHandler{leverage: lvg} ctx, _ := tsdk.NewCtxOneStore(t, storetypes.NewMemoryStoreKey("quota")) msgs := []sdk.Msg{<ypes.MsgSupply{}} + msgsRepay := []sdk.Msg{<ypes.MsgRepay{}} tcs := []struct { enabled bool @@ -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}, From 206e1bb8c3d3de1e91f8a249191d93fd67aa3a48 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Wed, 24 Apr 2024 10:21:36 +0200 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e00bdc8ee6..0c5a25ec59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [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 + ### Improvements From 2d0f857bdb46141817cbb055211ffd4c0f0d3e14 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Wed, 24 Apr 2024 11:56:52 +0200 Subject: [PATCH 3/3] lint --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c5a25ec59..f7f6e0ca08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [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 - ### Improvements - [2474](https://github.com/umee-network/umee/pull/2474) (proto) add `gogo.messagename_all` option to all messages.