Skip to content
Open
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
24 changes: 6 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
run:
tests: false
govet:
# Enable analyzers by name (in addition to default).
# Run `go tool vet help` to see all analyzers.
# Default: []
enable:
- fieldalignment

linters:
enable:
# - dupl
# - nestif
# - rowserrcheck -- enable when it will support generics
# - whitespace
# - wsl
- asciicheck
- bodyclose
# TODO; we need re-enable this linter once golangci-lint or .depguard.yaml is done
# - depguard
- dogsled
- errcheck
Expand Down Expand Up @@ -56,27 +44,27 @@ issues:
- linters:
- lll
source: "https://"

max-same-issues: 50

linters-settings:
gosec:
excludes:
- G115 # FIXME temporarily suppress 'G115: integer overflow conversion': it produces many hits, some of which may be false positives, and need to be looked at;
- G115

dogsled:
max-blank-identifiers: 3

misspell:
locale: US

nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false

revive:
confidence: 0
severity: error
error-code: 1
warning-code: 0
# List of rules to enable explicitly should be a subset of .revive.toml
# so only critical rules cause CI to fail instead of just generating annotations.
rules:
- name: blank-imports
- name: context-as-argument
Expand Down
44 changes: 44 additions & 0 deletions proto/umee/leverage/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,47 @@ message EventFundOracle {
// Assets sent to oracle module
repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false];
}


// EventRepayIsolatedBadDebt is emitted when isolated bad debt is repaid (partial or full)
message EventRepayIsolatedBadDebt {
// who paid
string from = 1;

// borrower whose debt is being repaid
string borrower = 2;

// denom of the asset
string denom = 3;

// total amount repaid (principal + interest)
cosmos.base.v1beta1.Coin total_repaid = 4 [(gogoproto.nullable) = false];

// principal repaid
string principal_repaid = 5 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];

// interest repaid
string interest_repaid = 6 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];

// remaining principal after repayment
string remaining_principal = 7 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];

// remaining interest after repayment
string remaining_interest = 8 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
21 changes: 20 additions & 1 deletion proto/umee/leverage/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,26 @@ message GenesisState {
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated SpecialAssetPair special_pairs = 10 [(gogoproto.nullable) = false];
repeated SpecialAssetPair special_pairs = 10 [(gogoproto.nullable) = false];
repeated IsolatedBadDebt isolated_bad_debts = 11 [(gogoproto.nullable) = false];
}

// IsolatedBadDebt is an isolated bad debt instance used in the leverage module's genesis state.
message IsolatedBadDebt {
string address = 1;
string denom = 2;
string amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string interest_scalar = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_accrued = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

// AdjustedBorrow is a borrow struct used in the leverage module's genesis
Expand Down
60 changes: 60 additions & 0 deletions proto/umee/leverage/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,66 @@ service Query {
returns (QueryInspectAccountResponse) {
option (google.api.http).get = "/umee/leverage/v1/inspect-account";
}

// IsolatedBadDebts returns all isolated bad debts.
rpc IsolatedBadDebts(QueryIsolatedBadDebts) returns (QueryIsolatedBadDebtsResponse) {
option (google.api.http).get = "/umee/leverage/v1/isolated_bad_debts";
}

// InterestScalars returns all interest scalars.
rpc InterestScalars(QueryInterestScalars) returns (QueryInterestScalarsResponse) {
option (google.api.http).get = "/umee/leverage/v1/interest_scalars";
}

// AllReserves returns all reserves.
rpc AllReserves(QueryAllReserves) returns (QueryAllReservesResponse) {
option (google.api.http).get = "/umee/leverage/v1/all_reserves";
}

// LastInterestTime returns the last interest time.
rpc LastInterestTime(QueryLastInterestTime) returns (QueryLastInterestTimeResponse) {
option (google.api.http).get = "/umee/leverage/v1/last_interest_time";
}
}

// QueryLastInterestTime defines the request structure for the LastInterestTime
// gRPC service handler.
message QueryLastInterestTime {}

// QueryLastInterestTimeResponse defines the response structure for the LastInterestTime
// gRPC service handler.
message QueryLastInterestTimeResponse {
int64 last_interest_time = 1;
}

// QueryAllReserves defines the request structure for the Reserves
// gRPC service handler.
message QueryAllReserves {}

// QueryAllReservesResponse defines the response structure for the Reserves
// gRPC service handler.
message QueryAllReservesResponse {
repeated cosmos.base.v1beta1.Coin reserves = 1 [(gogoproto.nullable) = false];
}

// QueryInterestScalars defines the request structure for the InterestScalars
// gRPC service handler.
message QueryInterestScalars {}

// QueryInterestScalarsResponse defines the response structure for the InterestScalars
// gRPC service handler.
message QueryInterestScalarsResponse {
repeated InterestScalar interest_scalars = 1 [(gogoproto.nullable) = false];
}

// QueryIsolatedBadDebts defines the request structure for the IsolatedBadDebts
// gRPC service handler.
message QueryIsolatedBadDebts {}

// QueryIsolatedBadDebtsResponse defines the response structure for the IsolatedBadDebts
// gRPC service handler.
message QueryIsolatedBadDebtsResponse {
repeated IsolatedBadDebt isolated_bad_debts = 1 [(gogoproto.nullable) = false];
}

// QueryParams defines the request structure for the Params gRPC service
Expand Down
16 changes: 16 additions & 0 deletions proto/umee/leverage/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ service Msg {

// GovSetParams is used by governance proposals to update parameters.
rpc GovSetParams(MsgGovSetParams) returns (MsgGovSetParamsResponse);

// RepayIsolatedBadDebt allows a user to repay isolated bad debts.
rpc RepayIsolatedBadDebt(MsgRepayIsolatedBadDebt) returns (MsgRepayIsolatedBadDebtResponse);
}

// MsgRepayIsolatedBadDebt represents a user's request to repay isolated bad debts.
message MsgRepayIsolatedBadDebt {
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string borrower = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin asset = 3 [(gogoproto.nullable) = false];
bool repay_interest = 4;
}

// MsgRepayIsolatedBadDebtResponse defines the Msg/RepayIsolatedBadDebt response type.
message MsgRepayIsolatedBadDebtResponse {
cosmos.base.v1beta1.Coin asset = 1 [(gogoproto.nullable) = false];
}

// MsgSupply represents a user's request to supply assets to the module.
Expand Down
4 changes: 2 additions & 2 deletions x/auction/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ func DefaultGenesis() *GenesisState {

func (gs *GenesisState) Validate() error {
if gs.RewardsParams.BidDuration <= 60 {
return errors.New("RewardsParams.BidDuration must be at least 60s")
return errors.New("rewards params bid duration must be at least 60s")
}
if gs.RewardsParams.BidDuration >= 180*24*3600 {
return errors.New("RewardsParams.BidDuration must be at most 15552000s = 180days")
return errors.New("rewards params bid duration must be at most 15552000s = 180days")
}
for _, elem := range gs.RewardsAuctions {
coins := sdk.Coins(elem.Rewards.Rewards)
Expand Down
3 changes: 3 additions & 0 deletions x/leverage/client/cli/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package cli

const FlagRepayInterest = "repay-interest"
96 changes: 96 additions & 0 deletions x/leverage/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func GetQueryCmd() *cobra.Command {
QueryMaxBorrow(),
QueryInspect(),
QueryInspectAccount(),
QueryIsolatedBadDebts(),
QueryInterestScalars(),
QueryAllReserves(),
QueryLastInterestTime(),
)

return cmd
Expand Down Expand Up @@ -427,3 +431,95 @@ func QueryInspectAccount() *cobra.Command {

return cmd
}

func QueryIsolatedBadDebts() *cobra.Command {
cmd := &cobra.Command{
Use: "isolated-bad-debts",
Args: cobra.ExactArgs(0),
Short: "Query for all isolated bad debts",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryIsolatedBadDebts{}
resp, err := queryClient.IsolatedBadDebts(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

func QueryInterestScalars() *cobra.Command {
cmd := &cobra.Command{
Use: "interest-scalars",
Args: cobra.ExactArgs(0),
Short: "Query for all interest scalars",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryInterestScalars{}
resp, err := queryClient.InterestScalars(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

func QueryAllReserves() *cobra.Command {
cmd := &cobra.Command{
Use: "all-reserves",
Args: cobra.ExactArgs(0),
Short: "Query for all reserves",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryAllReserves{}
resp, err := queryClient.AllReserves(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

func QueryLastInterestTime() *cobra.Command {
cmd := &cobra.Command{
Use: "last-interest-time",
Args: cobra.ExactArgs(0),
Short: "Query for the last interest time",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryLastInterestTime{}
resp, err := queryClient.LastInterestTime(cmd.Context(), req)
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading
Loading