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 all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ 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

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