Skip to content

Commit

Permalink
Merge pull request #596 from UnUniFi/fix/min-deposit
Browse files Browse the repository at this point in the history
feat: add error that min_deposit_rate too high
  • Loading branch information
kimurayu45z authored Jun 8, 2023
2 parents c5744c9 + 8e10ac8 commit a42b02e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions x/nftbackedloan/keeper/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func validateListNftMsg(k Keeper, ctx sdk.Context, msg *types.MsgListNft) error
if err != nil {
return err
}
return checkListNft(k, ctx, sender, msg.NftId, msg.BidToken)
return checkListNft(k, ctx, sender, msg.NftId, msg.BidToken, msg.MinimumDepositRate)
}

func checkListNft(k Keeper, ctx sdk.Context, sender sdk.AccAddress, nftId types.NftIdentifier, bidToken string) error {
func checkListNft(k Keeper, ctx sdk.Context, sender sdk.AccAddress, nftId types.NftIdentifier, bidToken string, minimumDepositRate sdk.Dec) error {
// check listing already exists
_, err := k.GetNftListingByIdBytes(ctx, nftId.IdBytes())
if err == nil {
Expand All @@ -45,5 +45,10 @@ func checkListNft(k Keeper, ctx sdk.Context, sender sdk.AccAddress, nftId types.
for !Contains(params.BidTokens, bidToken) {
return types.ErrNotSupportedBidToken
}

if minimumDepositRate.GTE(sdk.MustNewDecFromStr("0.5")) {
return types.ErrMinimumDepositRateTooHigh
}

return nil
}
1 change: 1 addition & 0 deletions x/nftbackedloan/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ var (
ErrInsufficientBalance = sdkerrors.Register(ModuleName, 37, "insufficient balance")
ErrSmallBiddingPeriod = sdkerrors.Register(ModuleName, 38, "bidding period is too short")
ErrNotExistsNft = sdkerrors.Register(ModuleName, 39, "not exists nft")
ErrMinimumDepositRateTooHigh = sdkerrors.Register(ModuleName, 40, "minimum deposit rate too high")
)

0 comments on commit a42b02e

Please sign in to comment.