diff --git a/proto/ununifi/nftbackedloan/nftbackedloan.proto b/proto/ununifi/nftbackedloan/nftbackedloan.proto index 079ce3d20..3a6c67db4 100644 --- a/proto/ununifi/nftbackedloan/nftbackedloan.proto +++ b/proto/ununifi/nftbackedloan/nftbackedloan.proto @@ -96,4 +96,11 @@ message Liquidation { message Liquidations { Liquidation liquidation = 1 [(gogoproto.nullable) = true]; repeated Liquidation next_liquidation = 2 [(gogoproto.nullable) = false]; +} + +message RepayInfo { + cosmos.base.v1beta1.Coin repaid_amount = 1 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin repaid_interest_amount = 2 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin remaining_amount = 3 [(gogoproto.nullable) = false]; + google.protobuf.Timestamp last_repaid_at = 4[(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } \ No newline at end of file diff --git a/x/nftbackedloan/abci.go b/x/nftbackedloan/abci.go index cb474814b..430d5bb14 100644 --- a/x/nftbackedloan/abci.go +++ b/x/nftbackedloan/abci.go @@ -10,7 +10,7 @@ import ( func EndBlocker(ctx sdk.Context, k keeper.Keeper) { // process liquidation of expired bids - k.ProcessLiquidateExpiredBids(ctx) + k.LiquidateExpiredBids(ctx) // handle full payment period endings k.HandleFullPaymentsPeriodEndings(ctx) diff --git a/x/nftbackedloan/keeper/bid.go b/x/nftbackedloan/keeper/bid.go index d60490ff7..145740956 100644 --- a/x/nftbackedloan/keeper/bid.go +++ b/x/nftbackedloan/keeper/bid.go @@ -377,46 +377,7 @@ func (k Keeper) PayRemainder(ctx sdk.Context, msg *types.MsgPayRemainder) error return nil } -// func CheckBidParams(listing types.NftListing, bid, deposit sdk.Coin, bids []types.NftBid) error { -// c := listing.MinimumDepositRate -// p := sdk.NewDecFromInt(bid.Amount) -// cp := c.Mul(p) -// depositDec := sdk.NewDecFromInt(deposit.Amount) -// if cp.GT(depositDec) { -// return types.ErrNotEnoughDeposit -// } -// q := bid -// s := deposit -// for _, bid := range bids { -// q = q.Add(bid.Price) -// s = s.Add(bid.Deposit) -// } - -// bidLen := 1 -// if len(bids) > 0 { -// // sum new bid and old bids -// bidLen = len(bids) + 1 -// } -// q.Amount = q.Amount.Quo(sdk.NewInt(int64(bidLen))) -// if q.IsLTE(s) { -// fmt.Println("q", q.String()) -// fmt.Println("s", s.String()) -// return types.ErrBidParamInvalid -// } -// q_s := q.Sub(s) -// q_s_dec := sdk.NewDecFromInt(q_s.Amount) -// // todo implement min{bid, q-s} - -// if depositDec.GT(q_s_dec) { -// fmt.Println("depositDec", depositDec.String()) -// fmt.Println("q_s_dec", q_s_dec.String()) -// // deposit amount bigger -// return types.ErrBidParamInvalid -// } -// return nil -// } - -func (k Keeper) GetActiveNftBiddingsExpired(ctx sdk.Context, endTime time.Time) []types.NftBid { +func (k Keeper) GetExpiredBids(ctx sdk.Context, endTime time.Time) []types.NftBid { store := ctx.KVStore(k.storeKey) timeKey := getTimeKey(types.KeyPrefixEndTimeNftBid, endTime) it := store.Iterator([]byte(types.KeyPrefixEndTimeNftBid), storetypes.InclusiveEndBytes(timeKey)) @@ -425,8 +386,6 @@ func (k Keeper) GetActiveNftBiddingsExpired(ctx sdk.Context, endTime time.Time) bids := []types.NftBid{} for ; it.Valid(); it.Next() { bidId := types.NftBidBytesToBidId(it.Value()) - fmt.Println("GetActiveNftBiddingsExpired") - fmt.Println(bidId) bidder, _ := sdk.AccAddressFromBech32(bidId.Bidder) bid, err := k.GetBid(ctx, bidId.NftId.IdBytes(), bidder) if err != nil { @@ -446,7 +405,7 @@ func (k Keeper) DeleteBidsWithoutBorrowing(ctx sdk.Context, bids []types.NftBid) continue } if listing.IsBidding() { - if !bid.IsBorrowing() { + if !bid.IsBorrowed() { err := k.SafeCloseBid(ctx, bid) if err != nil { fmt.Println(err) diff --git a/x/nftbackedloan/keeper/grpc_query.go b/x/nftbackedloan/keeper/grpc_query.go index 1213f0b42..1a4b4fd1b 100644 --- a/x/nftbackedloan/keeper/grpc_query.go +++ b/x/nftbackedloan/keeper/grpc_query.go @@ -185,18 +185,6 @@ func (k Keeper) GetListedClass(ctx sdk.Context, classId string, limit int) (*typ }, nil } -// func (k Keeper) Loans(c context.Context, req *types.QueryLoansRequest) (*types.QueryLoansResponse, error) { -// if req == nil { -// return nil, status.Error(codes.InvalidArgument, "invalid request") -// } - -// // ctx := sdk.UnwrapSDKContext(c) -// return &types.QueryLoansResponse{ -// // todo impl -// Loans: []types.Loan{}, -// }, nil -// } - func (k Keeper) Loan(c context.Context, req *types.QueryLoanRequest) (*types.QueryLoanResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") @@ -278,50 +266,6 @@ func (k Keeper) Rewards(c context.Context, req *types.QueryRewardsRequest) (*typ return &types.QueryRewardsResponse{}, nil } -// func (k Keeper) PaymentStatus(c context.Context, req *types.QueryPaymentStatusRequest) (*types.QueryPaymentStatusResponse, error) { -// if req == nil { -// return nil, status.Error(codes.InvalidArgument, "invalid request") -// } - -// ctx := sdk.UnwrapSDKContext(c) -// nft := types.NftIdentifier{ -// ClassId: req.ClassId, -// NftId: req.NftId, -// } -// listing, err := k.GetNftListingByIdBytes(ctx, nft.IdBytes()) -// if err != nil { -// return &types.QueryPaymentStatusResponse{}, err -// } -// bids := k.GetBidsByNft(ctx, nft.IdBytes()) -// if len(bids) == 0 { -// return nil, status.Error(codes.InvalidArgument, "not existing bidder") -// } - -// var bidderBid types.NftBid -// for _, v := range bids { -// if v.Id.Bidder == req.Bidder { -// bidderBid = v -// } -// } -// if (bidderBid.Equal(types.NftBid{})) { -// return nil, status.Error(codes.InvalidArgument, "does not match bidder") -// } - -// allPaid := listing.State >= types.ListingState_LIQUIDATION && bidderBid.Price.Amount.Equal(bidderBid.Deposit.Amount) -// return &types.QueryPaymentStatusResponse{ -// PaymentStatus: types.PaymentStatus{ -// NftId: listing.NftId, -// State: listing.State, -// Bidder: bidderBid.Id.Bidder, -// Amount: bidderBid.Price, -// AutomaticPayment: bidderBid.AutomaticPayment, -// PaidAmount: bidderBid.Deposit.Amount, -// CreatedAt: bidderBid.CreatedAt, -// AllPaid: allPaid, -// }, -// }, nil -// } - func (k Keeper) Liquidation(c context.Context, req *types.QueryLiquidationRequest) (*types.QueryLiquidationResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") diff --git a/x/nftbackedloan/keeper/liquidation.go b/x/nftbackedloan/keeper/liquidation.go index a0ca4d787..c973b725b 100644 --- a/x/nftbackedloan/keeper/liquidation.go +++ b/x/nftbackedloan/keeper/liquidation.go @@ -35,14 +35,6 @@ func (k Keeper) SetLiquidation(ctx sdk.Context, msg *types.MsgEndNftListing) err bids := k.GetBidsByNft(ctx, listing.NftId.IdBytes()) if len(bids) == 0 { - // sender, err := sdk.AccAddressFromBech32(msg.Sender) - // if err != nil { - // return err - // } - // err = k.nftKeeper.Transfer(ctx, listing.NftId.ClassId, listing.NftId.NftId, sender) - // if err != nil { - // return err - // } // enable NFT transfer data, found := k.nftKeeper.GetNftData(ctx, msg.NftId.ClassId, msg.NftId.NftId) @@ -104,16 +96,16 @@ func (k Keeper) SetLiquidation(ctx sdk.Context, msg *types.MsgEndNftListing) err return nil } -func (k Keeper) ProcessLiquidateExpiredBids(ctx sdk.Context) { +func (k Keeper) LiquidateExpiredBids(ctx sdk.Context) { fmt.Println("---Block time---") fmt.Println(ctx.BlockTime()) - bids := k.GetActiveNftBiddingsExpired(ctx, ctx.BlockTime()) + bids := k.GetExpiredBids(ctx, ctx.BlockTime()) fmt.Println("---expired bids---") fmt.Println(bids) k.DeleteBidsWithoutBorrowing(ctx, bids) checkListingsWithBorrowedBids := map[types.NftListing][]types.NftBid{} for _, bid := range bids { - if !bid.IsBorrowing() { + if !bid.IsBorrowed() { continue } @@ -147,7 +139,7 @@ func (k Keeper) ProcessLiquidateExpiredBids(ctx sdk.Context) { } } -func (k Keeper) LiquidationProcess(ctx sdk.Context, bids types.NftBids, listing types.NftListing, params types.Params) error { +func (k Keeper) RunLiquidationProcess(ctx sdk.Context, bids types.NftBids, listing types.NftListing, params types.Params) error { // loop to find winner bid (collect deposits + bid amount > repay amount) bidsSortedByDeposit := bids.SortHigherDeposit() winnerBid, forfeitedBids, refundBids, err := types.LiquidationBid(bidsSortedByDeposit, listing, listing.LiquidatedAt) @@ -158,7 +150,7 @@ func (k Keeper) LiquidationProcess(ctx sdk.Context, bids types.NftBids, listing cacheCtx, write := ctx.CacheContext() if winnerBid.IsNil() { // No one has PayRemainder. - err := k.LiquidationProcessNoWinner(cacheCtx, bidsSortedByDeposit, listing) + err := k.LiquidateWithoutWinner(cacheCtx, bidsSortedByDeposit, listing) if err != nil { fmt.Println("failed to liquidation process with no winner: %w", err) return err @@ -166,7 +158,7 @@ func (k Keeper) LiquidationProcess(ctx sdk.Context, bids types.NftBids, listing k.DeleteNftListings(ctx, listing) } else { // forfeitedBids, refundBids := types.ForfeitedBidsAndRefundBids(bidsSortedByDeposit, winnerBid) - err := k.LiquidationProcessWithWinner(cacheCtx, forfeitedBids, refundBids, listing) + err := k.LiquidateWithWinner(cacheCtx, forfeitedBids, refundBids, listing) if err != nil { fmt.Println("failed to liquidation process with winner: %w", err) return err @@ -181,20 +173,20 @@ func (k Keeper) LiquidationProcess(ctx sdk.Context, bids types.NftBids, listing } // todo add test -func (k Keeper) LiquidationProcessNoWinner(ctx sdk.Context, bids types.NftBids, listing types.NftListing) error { +func (k Keeper) LiquidateWithoutWinner(ctx sdk.Context, bids types.NftBids, listing types.NftListing) error { listingOwner, err := sdk.AccAddressFromBech32(listing.Owner) if err != nil { return err } // collect deposit from all bids - forfeitedDeposit, err := k.CollectedDepositFromBids(ctx, bids, listing) + forfeitedDeposit, err := k.ForfeitDepositsFromBids(ctx, bids, listing) if err != nil { return err } listing = listing.AddCollectedAmount(forfeitedDeposit) - borrowAmount := bids.TotalBorrowAmount() + borrowAmount := bids.TotalBorrowedAmount() // pay fee if listing.IsNegativeCollectedAmount() { return types.ErrNegativeCollectedAmount @@ -208,12 +200,6 @@ func (k Keeper) LiquidationProcessNoWinner(ctx sdk.Context, bids types.NftBids, return err } - // transfer nft to listing owner - // err = k.nftKeeper.Transfer(ctx, listing.NftId.ClassId, listing.NftId.NftId, listingOwner) - // if err != nil { - // return err - // } - // enable NFT transfer data, found := k.nftKeeper.GetNftData(ctx, listing.NftId.ClassId, listing.NftId.NftId) if !found { @@ -228,8 +214,8 @@ func (k Keeper) LiquidationProcessNoWinner(ctx sdk.Context, bids types.NftBids, } // todo add test -func (k Keeper) LiquidationProcessWithWinner(ctx sdk.Context, forfeitedBids, refundBids types.NftBids, listing types.NftListing) error { - forfeitedDeposit, err := k.CollectedDepositFromBids(ctx, forfeitedBids, listing) +func (k Keeper) LiquidateWithWinner(ctx sdk.Context, forfeitedBids, refundBids types.NftBids, listing types.NftListing) error { + forfeitedDeposit, err := k.ForfeitDepositsFromBids(ctx, forfeitedBids, listing) if err != nil { fmt.Println("failed to collect deposit from bids: %w", err) return err @@ -244,7 +230,7 @@ func (k Keeper) LiquidationProcessWithWinner(ctx sdk.Context, forfeitedBids, ref // refund bids if len(refundBids) > 0 { refundInterestAmount := refundBids.TotalCompoundInterest(listing.LiquidatedAt) - refundBorrowedAmount := refundBids.TotalBorrowAmount() + refundBorrowedAmount := refundBids.TotalBorrowedAmount() totalSubAmount = totalSubAmount.Add(refundInterestAmount).Add(refundBorrowedAmount) } @@ -271,7 +257,7 @@ func (k Keeper) RefundBids(ctx sdk.Context, refundBids types.NftBids, time time. } // todo add test -func (k Keeper) CollectedDepositFromBids(ctx sdk.Context, bids types.NftBids, listing types.NftListing) (sdk.Coin, error) { +func (k Keeper) ForfeitDepositsFromBids(ctx sdk.Context, bids types.NftBids, listing types.NftListing) (sdk.Coin, error) { result := sdk.NewCoin(listing.BidDenom, sdk.ZeroInt()) for _, bid := range bids { // not pay bidder amount, collected deposit diff --git a/x/nftbackedloan/keeper/loan.go b/x/nftbackedloan/keeper/loan.go index 5271dbe8e..db82c3961 100644 --- a/x/nftbackedloan/keeper/loan.go +++ b/x/nftbackedloan/keeper/loan.go @@ -147,8 +147,8 @@ func (k Keeper) ManualRepay(ctx sdk.Context, nft types.NftIdentifier, repays []t continue } - repaidResult := bid.RepaidResult(repay.Amount, ctx.BlockTime()) - bid.Borrow.Amount = repaidResult.RemainingBorrowAmount + repaidResult := bid.RepayInfo(repay.Amount, ctx.BlockTime()) + bid.Borrow.Amount = repaidResult.RemainingAmount bid.Borrow.LastRepaidAt = repaidResult.LastRepaidAt repaidAmount = repaidAmount.Add(repaidResult.RepaidAmount) @@ -208,10 +208,10 @@ func (k Keeper) AutoRepay(ctx sdk.Context, nft types.NftIdentifier, bids types.N continue } - repaidResult := bid.FullRepaidResult(ctx.BlockTime()) - bid.Borrow.Amount = repaidResult.RemainingBorrowAmount - bid.Borrow.LastRepaidAt = repaidResult.LastRepaidAt - repaidAmount = repaidAmount.Add(repaidResult.RepaidAmount) + repaidInfo := bid.RepayInfoInFull(ctx.BlockTime()) + bid.Borrow.Amount = repaidInfo.RemainingAmount + bid.Borrow.LastRepaidAt = repaidInfo.LastRepaidAt + repaidAmount = repaidAmount.Add(repaidInfo.RepaidAmount) err = k.SetBid(ctx, bid) if err != nil { @@ -219,7 +219,7 @@ func (k Keeper) AutoRepay(ctx sdk.Context, nft types.NftIdentifier, bids types.N } // send interest to bidder - err = k.SendInterestToBidder(ctx, bid, repaidResult.RepaidInterestAmount) + err = k.SendInterestToBidder(ctx, bid, repaidInfo.RepaidInterestAmount) if err != nil { return err } diff --git a/x/nftbackedloan/keeper/msg_server.go b/x/nftbackedloan/keeper/msg_server.go index db651fdd5..7e9ac25e5 100644 --- a/x/nftbackedloan/keeper/msg_server.go +++ b/x/nftbackedloan/keeper/msg_server.go @@ -71,22 +71,13 @@ func (k msgServer) CancelBid(c context.Context, msg *types.MsgCancelBid) (*types func (k msgServer) SellingDecision(c context.Context, msg *types.MsgSellingDecision) (*types.MsgSellingDecisionResponse, error) { ctx := sdk.UnwrapSDKContext(c) - err := k.keeper.SellingDecision(ctx, msg) + err := k.keeper.SetSellingDecision(ctx, msg) if err != nil { return nil, err } return &types.MsgSellingDecisionResponse{}, nil } -// func (k msgServer) EndNftListing(c context.Context, msg *types.MsgEndNftListing) (*types.MsgEndNftListingResponse, error) { -// ctx := sdk.UnwrapSDKContext(c) -// err := k.keeper.EndNftListing(ctx, msg) -// if err != nil { -// return nil, err -// } -// return &types.MsgEndNftListingResponse{}, nil -// } - func (k msgServer) PayRemainder(c context.Context, msg *types.MsgPayRemainder) (*types.MsgPayRemainderResponse, error) { ctx := sdk.UnwrapSDKContext(c) err := k.keeper.PayRemainder(ctx, msg) diff --git a/x/nftbackedloan/keeper/nft_listing.go b/x/nftbackedloan/keeper/nft_listing.go index 76fcf89fe..4ee0b8ea9 100644 --- a/x/nftbackedloan/keeper/nft_listing.go +++ b/x/nftbackedloan/keeper/nft_listing.go @@ -117,26 +117,6 @@ func (k Keeper) DeleteNftListing(ctx sdk.Context, listing types.NftListing) { } } -// func (k Keeper) GetActiveNftListingsEndingAt(ctx sdk.Context, endTime time.Time) []types.NftListing { -// store := ctx.KVStore(k.storeKey) -// timeKey := getTimeKey(types.KeyPrefixEndTimeNftListing, endTime) -// it := store.Iterator([]byte(types.KeyPrefixEndTimeNftListing), storetypes.InclusiveEndBytes(timeKey)) -// defer it.Close() - -// listings := []types.NftListing{} -// for ; it.Valid(); it.Next() { -// nftIdBytes := it.Value() -// listing, err := k.GetNftListingByIdBytes(ctx, nftIdBytes) -// if err != nil { -// fmt.Println("failed to get listing by id bytes: %w", err) -// continue -// } - -// listings = append(listings, listing) -// } -// return listings -// } - func (k Keeper) GetFullPaymentNftListingsEndingAt(ctx sdk.Context, endTime time.Time) []types.NftListing { store := ctx.KVStore(k.storeKey) timeKey := getTimeKey(types.KeyPrefixFullPaymentPeriodListing, endTime) @@ -194,7 +174,7 @@ func (k Keeper) GetAllNftListings(ctx sdk.Context) []types.NftListing { } func (k Keeper) ListNft(ctx sdk.Context, msg *types.MsgListNft) error { - errorMsg := validateListNftMsg(k, ctx, msg) + errorMsg := ValidateListNftMsg(k, ctx, msg) if errorMsg != nil { return errorMsg } @@ -214,14 +194,6 @@ func (k Keeper) ListNft(ctx sdk.Context, msg *types.MsgListNft) error { MinimumBiddingPeriod: msg.MinimumBiddingPeriod, } - // Send ownership to market module - // moduleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) - // err := k.nftKeeper.Transfer(ctx, msg.NftId.ClassId, msg.NftId.NftId, moduleAddr) - // if err != nil { - // k.DeleteNftListing(ctx, listing) - // return err - // } - // disable NFT transfer data, found := k.nftKeeper.GetNftData(ctx, msg.NftId.ClassId, msg.NftId.NftId) if !found { @@ -279,22 +251,11 @@ func (k Keeper) CancelNftListing(ctx sdk.Context, msg *types.MsgCancelNftListing bids := k.GetBidsByNft(ctx, msg.NftId.IdBytes()) for _, bid := range bids { - if bid.IsBorrowing() { + if bid.IsBorrowed() { return types.ErrCannotCancelBorrowedListing } } - // sender, err := sdk.AccAddressFromBech32(msg.Sender) - // if err != nil { - // return err - // } - - // Send ownership to original owner - // err = k.nftKeeper.Transfer(ctx, msg.NftId.ClassId, msg.NftId.NftId, sender) - // if err != nil { - // return err - // } - // enable NFT transfer data, found := k.nftKeeper.GetNftData(ctx, msg.NftId.ClassId, msg.NftId.NftId) if !found { @@ -332,13 +293,13 @@ func (k Keeper) HandleFullPaymentsPeriodEndings(ctx sdk.Context) { for _, listing := range listings { bids := types.NftBids(k.GetBidsByNft(ctx, listing.NftId.IdBytes())) if listing.State == types.ListingState_SELLING_DECISION { - err := k.SellingDecisionProcess(ctx, bids, listing, params) + err := k.RunSellingDecisionProcess(ctx, bids, listing, params) if err != nil { fmt.Println("failed to selling decision process: %w", err) continue } } else if listing.State == types.ListingState_LIQUIDATION { - err := k.LiquidationProcess(ctx, bids, listing, params) + err := k.RunLiquidationProcess(ctx, bids, listing, params) if err != nil { fmt.Println("failed to liquidation process: %w", err) continue @@ -369,7 +330,6 @@ func (k Keeper) DeliverSuccessfulBids(ctx sdk.Context) { continue } - // borrowedAmount := k.GetDebtByNft(ctx, listing.IdBytes()) listerProfit := sdk.ZeroInt() repayAmount := bid.Borrow.Amount.Add(bid.CompoundInterest(listing.LiquidatedAt)) bidderPaidAmount := bid.Price diff --git a/x/nftbackedloan/keeper/sell.go b/x/nftbackedloan/keeper/sell.go index aea274297..cbf373465 100644 --- a/x/nftbackedloan/keeper/sell.go +++ b/x/nftbackedloan/keeper/sell.go @@ -9,7 +9,7 @@ import ( "github.com/UnUniFi/chain/x/nftbackedloan/types" ) -func (k Keeper) SellingDecision(ctx sdk.Context, msg *types.MsgSellingDecision) error { +func (k Keeper) SetSellingDecision(ctx sdk.Context, msg *types.MsgSellingDecision) error { // check listing already exists listing, err := k.GetNftListingByIdBytes(ctx, msg.NftId.IdBytes()) if err != nil { @@ -40,7 +40,7 @@ func (k Keeper) SellingDecision(ctx sdk.Context, msg *types.MsgSellingDecision) // check no borrowing bid for _, bid := range bids { - if bid.IsBorrowing() { + if bid.IsBorrowed() { return types.ErrCannotSellingBorrowedListing } } @@ -86,13 +86,13 @@ func (k Keeper) SellingDecision(ctx sdk.Context, msg *types.MsgSellingDecision) return nil } -func (k Keeper) SellingDecisionProcess(ctx sdk.Context, bids types.NftBids, listing types.NftListing, params types.Params) error { +func (k Keeper) RunSellingDecisionProcess(ctx sdk.Context, bids types.NftBids, listing types.NftListing, params types.Params) error { highestBid, err := bids.GetHighestBid() if err != nil { return err } // if winner bidder did not pay remainder, nft is listed again after deleting winner bidder - if !highestBid.IsPaidPrice() { + if !highestBid.IsPaidSalePrice() { borrowedAmount := highestBid.Borrow.Amount forfeitedDeposit, err := k.SafeCloseBidCollectDeposit(ctx, highestBid) if err != nil { diff --git a/x/nftbackedloan/keeper/sell_test.go b/x/nftbackedloan/keeper/sell_test.go index 836324ecd..19444295f 100644 --- a/x/nftbackedloan/keeper/sell_test.go +++ b/x/nftbackedloan/keeper/sell_test.go @@ -155,7 +155,7 @@ func (suite *KeeperTestSuite) TestSellingDecision() { suite.Require().NoError(err) } - err = suite.app.NftbackedloanKeeper.SellingDecision(suite.ctx, &types.MsgSellingDecision{ + err = suite.app.NftbackedloanKeeper.SetSellingDecision(suite.ctx, &types.MsgSellingDecision{ Sender: tc.executor.String(), NftId: nftIdentifier, }) diff --git a/x/nftbackedloan/keeper/utils.go b/x/nftbackedloan/keeper/utils.go index 7e034dcf7..1095bb4d8 100644 --- a/x/nftbackedloan/keeper/utils.go +++ b/x/nftbackedloan/keeper/utils.go @@ -18,15 +18,15 @@ func Contains(a []string, x string) bool { return false } -func validateListNftMsg(k Keeper, ctx sdk.Context, msg *types.MsgListNft) error { +func ValidateListNftMsg(k Keeper, ctx sdk.Context, msg *types.MsgListNft) error { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return err } - return checkListNft(k, ctx, sender, msg.NftId, msg.BidDenom, msg.MinimumDepositRate) + return CheckListNft(k, ctx, sender, msg.NftId, msg.BidDenom, msg.MinimumDepositRate) } -func checkListNft(k Keeper, ctx sdk.Context, sender sdk.AccAddress, nftId types.NftIdentifier, bidToken string, minimumDepositRate sdk.Dec) 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 { diff --git a/x/nftbackedloan/types/bid.go b/x/nftbackedloan/types/bid.go index cd5f815d4..cdc8b7fcc 100644 --- a/x/nftbackedloan/types/bid.go +++ b/x/nftbackedloan/types/bid.go @@ -37,7 +37,7 @@ func (m NftBid) GetIdToByte() []byte { return NftBidBytes(m.Id.NftId.ClassId, m.Id.NftId.NftId, m.Id.Bidder) } -func (m NftBid) IsBorrowing() bool { +func (m NftBid) IsBorrowed() bool { return m.Borrow.Amount.IsPositive() } @@ -68,64 +68,58 @@ func (m NftBid) CalcCompoundInterest(lendCoin sdk.Coin, startTime time.Time, end return sdk.NewCoin(lendCoin.Denom, result.RoundInt()) } -type RepayResult struct { - RepaidAmount sdk.Coin - RepaidInterestAmount sdk.Coin - RemainingBorrowAmount sdk.Coin - LastRepaidAt time.Time -} - -func (m NftBid) RepaidResult(repayAmount sdk.Coin, payTime time.Time) RepayResult { - interest := m.CalcCompoundInterest(m.Borrow.Amount, m.Borrow.LastRepaidAt, payTime) +func (m NftBid) RepayInfo(repayAmount sdk.Coin, repaymentTime time.Time) RepayInfo { + interest := m.CalcCompoundInterest(m.Borrow.Amount, m.Borrow.LastRepaidAt, repaymentTime) total := m.Borrow.Amount.Add(interest) if repayAmount.IsGTE(total) { remainingAmount := sdk.NewCoin(m.Borrow.Amount.Denom, sdk.ZeroInt()) - return RepayResult{ - RepaidAmount: total, - RepaidInterestAmount: interest, - RemainingBorrowAmount: remainingAmount, - LastRepaidAt: payTime, + return RepayInfo{ + RepaidAmount: total, + RepaidInterestAmount: interest, + RemainingAmount: remainingAmount, + LastRepaidAt: repaymentTime, } } else { remainingAmount := total.Sub(repayAmount) - return RepayResult{ - RepaidAmount: repayAmount, - RepaidInterestAmount: interest, - RemainingBorrowAmount: remainingAmount, - LastRepaidAt: payTime, + return RepayInfo{ + RepaidAmount: repayAmount, + RepaidInterestAmount: interest, + RemainingAmount: remainingAmount, + LastRepaidAt: repaymentTime, } } } -func (m NftBid) FullRepaidResult(payTime time.Time) RepayResult { - interest := m.CalcCompoundInterest(m.Borrow.Amount, m.Borrow.LastRepaidAt, payTime) +func (m NftBid) RepayInfoInFull(repaymentTime time.Time) RepayInfo { + m.RepayInfo(m.Borrow.Amount, repaymentTime) + interest := m.CalcCompoundInterest(m.Borrow.Amount, m.Borrow.LastRepaidAt, repaymentTime) total := m.Borrow.Amount.Add(interest) remainingAmount := sdk.NewCoin(m.Borrow.Amount.Denom, sdk.ZeroInt()) - return RepayResult{ - RepaidAmount: total, - RepaidInterestAmount: interest, - RemainingBorrowAmount: remainingAmount, - LastRepaidAt: payTime, + return RepayInfo{ + RepaidAmount: total, + RepaidInterestAmount: interest, + RemainingAmount: remainingAmount, + LastRepaidAt: repaymentTime, } } -func (m NftBid) FullPaidAmount() sdk.Coin { +func (m NftBid) BidderPaidAmount() sdk.Coin { return m.PaidAmount.Add(m.Deposit) } -func (m NftBid) IsPaidPrice() bool { - fullPaidAmount := m.FullPaidAmount() +func (m NftBid) IsPaidSalePrice() bool { + fullPaidAmount := m.BidderPaidAmount() return fullPaidAmount.Equal(m.Price) } func (m NftBid) CanCancel() bool { - return !m.IsBorrowing() + return !m.IsBorrowed() } func (m NftBid) CanReBid() bool { - return !m.IsBorrowing() + return !m.IsBorrowed() } func (m NftBid) IsNil() bool { @@ -215,7 +209,7 @@ func (m NftBids) RemoveBids(excludeBids NftBids) NftBids { return newArr } -func (m NftBids) TotalBorrowAmount() sdk.Coin { +func (m NftBids) TotalBorrowedAmount() sdk.Coin { if len(m) == 0 { return sdk.Coin{} } diff --git a/x/nftbackedloan/types/bid_test.go b/x/nftbackedloan/types/bid_test.go index d8195b1fc..2dec38208 100644 --- a/x/nftbackedloan/types/bid_test.go +++ b/x/nftbackedloan/types/bid_test.go @@ -10,7 +10,7 @@ import ( "github.com/UnUniFi/chain/x/nftbackedloan/types" ) -func TestIsBorrowing(t *testing.T) { +func TestIsBorrowed(t *testing.T) { testCases := []struct { name string bid types.NftBid @@ -54,7 +54,7 @@ func TestIsBorrowing(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - result := tc.bid.IsBorrowing() + result := tc.bid.IsBorrowed() require.Equal(t, tc.expResult, result) }) } @@ -126,15 +126,15 @@ func TestCalcCompoundInterest(t *testing.T) { } } -func TestRepaidResult(t *testing.T) { +func TestRepayInfo(t *testing.T) { now := time.Now() nextYear := time.Now().Add(time.Hour * 24 * 365) testCases := []struct { - name string - bid types.NftBid - repayAmount sdk.Coin - payTime time.Time - expResult types.RepayResult + name string + bid types.NftBid + repayAmount sdk.Coin + repaymentTime time.Time + expResult types.RepayInfo }{ { "Repay partial", @@ -154,12 +154,12 @@ func TestRepaidResult(t *testing.T) { }, sdk.NewCoin("uguu", sdk.NewInt(200000)), nextYear, - types.RepayResult{ + types.RepayInfo{ RepaidAmount: sdk.NewCoin("uguu", sdk.NewInt(200000)), RepaidInterestAmount: sdk.NewCoin("uguu", sdk.NewInt(105171)), // 1105171 - 200000 = 905171 - RemainingBorrowAmount: sdk.NewCoin("uguu", sdk.NewInt(905171)), - LastRepaidAt: nextYear, + RemainingAmount: sdk.NewCoin("uguu", sdk.NewInt(905171)), + LastRepaidAt: nextYear, }, }, { @@ -180,24 +180,24 @@ func TestRepaidResult(t *testing.T) { }, sdk.NewCoin("uguu", sdk.NewInt(1200000)), nextYear, - types.RepayResult{ - RepaidAmount: sdk.NewCoin("uguu", sdk.NewInt(1105171)), - RepaidInterestAmount: sdk.NewCoin("uguu", sdk.NewInt(105171)), - RemainingBorrowAmount: sdk.NewCoin("uguu", sdk.NewInt(0)), - LastRepaidAt: nextYear, + types.RepayInfo{ + RepaidAmount: sdk.NewCoin("uguu", sdk.NewInt(1105171)), + RepaidInterestAmount: sdk.NewCoin("uguu", sdk.NewInt(105171)), + RemainingAmount: sdk.NewCoin("uguu", sdk.NewInt(0)), + LastRepaidAt: nextYear, }, }, } for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - result := tc.bid.RepaidResult(tc.repayAmount, tc.payTime) + result := tc.bid.RepayInfo(tc.repayAmount, tc.repaymentTime) require.Equal(t, tc.expResult, result) }) } } -func TestIsPaidPrice(t *testing.T) { +func TestIsPaidSalePrice(t *testing.T) { testCases := []struct { name string bid types.NftBid @@ -239,13 +239,13 @@ func TestIsPaidPrice(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - result := tc.bid.IsPaidPrice() + result := tc.bid.IsPaidSalePrice() require.Equal(t, tc.expResult, result) }) } } -func TestTotalBorrowAmount(t *testing.T) { +func TestTotalBorrowedAmount(t *testing.T) { testCases := []struct { name string bids types.NftBids @@ -271,7 +271,7 @@ func TestTotalBorrowAmount(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - result := tc.bids.TotalBorrowAmount() + result := tc.bids.TotalBorrowedAmount() require.Equal(t, tc.expResult, result) }) } diff --git a/x/nftbackedloan/types/loan.go b/x/nftbackedloan/types/loan.go index e26efc6f4..e36c7e331 100644 --- a/x/nftbackedloan/types/loan.go +++ b/x/nftbackedloan/types/loan.go @@ -73,7 +73,7 @@ func LiquidationBid(bidsSortedByDeposit []NftBid, listing NftListing, time time. continue } // if liquidation is available, the bid is win or collect - if bid.IsPaidPrice() { + if bid.IsPaidSalePrice() { winnerBid = bid } else { forfeitedDeposit = forfeitedDeposit.Add(bid.Deposit) @@ -108,7 +108,7 @@ func ForfeitedBidsAndRefundBids(bidsSortedByDeposit []NftBid, winnerBid NftBid) refundBids = append(refundBids, bid) continue } - if bid.IsPaidPrice() { + if bid.IsPaidSalePrice() { refundBids = append(refundBids, bid) } else { forfeitedBids = append(forfeitedBids, bid) @@ -176,7 +176,7 @@ func ExistRepayAmountAtLiquidation(bids []NftBid, listing NftListing, liquidatio } existRepayAmount := types.NewCoin(listing.BidDenom, sdk.NewInt(0)) for _, nftBid := range bids { - if nftBid.IsPaidPrice() { + if nftBid.IsPaidSalePrice() { existInterest := nftBid.CalcCompoundInterest(nftBid.Borrow.Amount, nftBid.Borrow.LastRepaidAt, liquidationTime) existRepayAmount = existRepayAmount.Add(nftBid.Borrow.Amount).Add(existInterest) } diff --git a/x/nftbackedloan/types/nftbackedloan.pb.go b/x/nftbackedloan/types/nftbackedloan.pb.go index a247585e8..897771452 100644 --- a/x/nftbackedloan/types/nftbackedloan.pb.go +++ b/x/nftbackedloan/types/nftbackedloan.pb.go @@ -667,6 +667,74 @@ func (m *Liquidations) GetNextLiquidation() []Liquidation { return nil } +type RepayInfo struct { + RepaidAmount types.Coin `protobuf:"bytes,1,opt,name=repaid_amount,json=repaidAmount,proto3" json:"repaid_amount"` + RepaidInterestAmount types.Coin `protobuf:"bytes,2,opt,name=repaid_interest_amount,json=repaidInterestAmount,proto3" json:"repaid_interest_amount"` + RemainingAmount types.Coin `protobuf:"bytes,3,opt,name=remaining_amount,json=remainingAmount,proto3" json:"remaining_amount"` + LastRepaidAt time.Time `protobuf:"bytes,4,opt,name=last_repaid_at,json=lastRepaidAt,proto3,stdtime" json:"last_repaid_at"` +} + +func (m *RepayInfo) Reset() { *m = RepayInfo{} } +func (m *RepayInfo) String() string { return proto.CompactTextString(m) } +func (*RepayInfo) ProtoMessage() {} +func (*RepayInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_9e729891a263bcae, []int{9} +} +func (m *RepayInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RepayInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RepayInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RepayInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_RepayInfo.Merge(m, src) +} +func (m *RepayInfo) XXX_Size() int { + return m.Size() +} +func (m *RepayInfo) XXX_DiscardUnknown() { + xxx_messageInfo_RepayInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_RepayInfo proto.InternalMessageInfo + +func (m *RepayInfo) GetRepaidAmount() types.Coin { + if m != nil { + return m.RepaidAmount + } + return types.Coin{} +} + +func (m *RepayInfo) GetRepaidInterestAmount() types.Coin { + if m != nil { + return m.RepaidInterestAmount + } + return types.Coin{} +} + +func (m *RepayInfo) GetRemainingAmount() types.Coin { + if m != nil { + return m.RemainingAmount + } + return types.Coin{} +} + +func (m *RepayInfo) GetLastRepaidAt() time.Time { + if m != nil { + return m.LastRepaidAt + } + return time.Time{} +} + func init() { proto.RegisterEnum("ununifi.nftbackedloan.ListingState", ListingState_name, ListingState_value) proto.RegisterType((*NftIdentifier)(nil), "ununifi.nftbackedloan.NftIdentifier") @@ -678,6 +746,7 @@ func init() { proto.RegisterType((*NftBid)(nil), "ununifi.nftbackedloan.NftBid") proto.RegisterType((*Liquidation)(nil), "ununifi.nftbackedloan.Liquidation") proto.RegisterType((*Liquidations)(nil), "ununifi.nftbackedloan.Liquidations") + proto.RegisterType((*RepayInfo)(nil), "ununifi.nftbackedloan.RepayInfo") } func init() { @@ -685,79 +754,83 @@ func init() { } var fileDescriptor_9e729891a263bcae = []byte{ - // 1153 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x5f, 0x6f, 0x1b, 0x45, - 0x10, 0xcf, 0x25, 0xb1, 0x9d, 0x8c, 0xd3, 0xe4, 0xba, 0xa4, 0xad, 0x13, 0x8a, 0x13, 0x1d, 0xa8, - 0x2a, 0xa0, 0x9e, 0xd5, 0x20, 0x84, 0x5a, 0x2a, 0x84, 0x2f, 0x4e, 0xdb, 0x2b, 0x91, 0x5b, 0xec, - 0x5a, 0x05, 0x84, 0x74, 0x5a, 0xdf, 0xad, 0x9d, 0x55, 0xef, 0x76, 0xdd, 0xbb, 0xbd, 0xb6, 0xf9, - 0x16, 0x7d, 0x83, 0x6f, 0xc1, 0x0b, 0x2f, 0x7c, 0x83, 0x3e, 0x56, 0xbc, 0x80, 0x78, 0x28, 0xa8, - 0xfd, 0x06, 0x7c, 0x02, 0xb4, 0x7f, 0xce, 0x76, 0xa2, 0x06, 0x87, 0x8a, 0x27, 0x7b, 0x6e, 0x66, - 0x7e, 0xbf, 0x99, 0xdd, 0x99, 0xdf, 0x1d, 0x7c, 0x98, 0xb3, 0x9c, 0xd1, 0x01, 0x6d, 0xb0, 0x81, - 0xe8, 0xe3, 0xf0, 0x21, 0x89, 0x62, 0x8e, 0xd9, 0x51, 0xcb, 0x1d, 0xa5, 0x5c, 0x70, 0x74, 0xce, - 0x84, 0xba, 0x47, 0x9c, 0x9b, 0xeb, 0x43, 0x3e, 0xe4, 0x2a, 0xa2, 0x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5, 0x86, 0x52, 0xfe, 0x95, 0x04, 0x79, 0x4a, 0x83, 0x03, 0x9c, 0x1d, 0xd4, 0x16, - 0x34, 0x41, 0x9e, 0xd2, 0xdb, 0x38, 0x3b, 0x70, 0x7e, 0xa9, 0x00, 0xb4, 0x07, 0x42, 0x96, 0x43, - 0xd9, 0x10, 0x35, 0xdf, 0xa6, 0x5d, 0x6f, 0xf1, 0xf9, 0xcb, 0xad, 0xb9, 0xa2, 0xe9, 0x75, 0x28, - 0xf1, 0x27, 0x6c, 0xdc, 0xb3, 0x36, 0xd0, 0x35, 0x28, 0x65, 0x02, 0x0b, 0xa2, 0xf8, 0x57, 0x77, - 0xde, 0x3f, 0x01, 0xd7, 0xd4, 0xd1, 0x95, 0xa1, 0x1d, 0x9d, 0x81, 0xde, 0x85, 0xe5, 0x3e, 0x8d, - 0x82, 0x88, 0x30, 0x9e, 0xd4, 0x16, 0x15, 0xe8, 0x52, 0x9f, 0x46, 0x2d, 0x69, 0x23, 0x06, 0xeb, - 0x09, 0x65, 0x34, 0xc9, 0x93, 0x20, 0x22, 0x23, 0x9e, 0x51, 0x11, 0xa4, 0x92, 0xa6, 0x24, 0xe3, - 0xbc, 0x1b, 0xb2, 0xb0, 0x3f, 0x5e, 0x6e, 0x5d, 0x1a, 0x52, 0x71, 0x90, 0xf7, 0xdd, 0x90, 0x27, - 0x66, 0x54, 0xcc, 0xcf, 0x95, 0x2c, 0x7a, 0xd8, 0x10, 0x87, 0x23, 0x92, 0xb9, 0x2d, 0x12, 0xfe, - 0xfa, 0xf3, 0x15, 0x30, 0x93, 0xd4, 0x22, 0x61, 0x07, 0x19, 0xe4, 0x96, 0x06, 0xee, 0xc8, 0x62, - 0xbe, 0x01, 0xc8, 0x04, 0x4e, 0x05, 0x89, 0x02, 0x2c, 0x6a, 0x65, 0x75, 0x48, 0x9b, 0xae, 0x9e, - 0x65, 0xb7, 0x98, 0x65, 0xf7, 0x7e, 0x31, 0xec, 0xde, 0x7b, 0xb2, 0x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0xdb, 0x5e, 0x40, - 0x6b, 0x50, 0xdd, 0xf7, 0xbf, 0xee, 0xf9, 0xad, 0xe6, 0x7d, 0xf9, 0x60, 0x11, 0x21, 0x58, 0xed, - 0xf6, 0x76, 0x77, 0xf7, 0xba, 0xdd, 0x9b, 0xbd, 0xfd, 0xc0, 0xf3, 0x5b, 0x76, 0xc9, 0xbb, 0xfd, - 0xfc, 0x55, 0xdd, 0x7a, 0xf1, 0xaa, 0x6e, 0xfd, 0xf5, 0xaa, 0x6e, 0x3d, 0x7b, 0x5d, 0x9f, 0x7b, - 0xf1, 0xba, 0x3e, 0xf7, 0xfb, 0xeb, 0xfa, 0xdc, 0x77, 0xee, 0xd4, 0x84, 0xf7, 0x58, 0x8f, 0xd1, - 0x9b, 0xb4, 0x11, 0x1e, 0x60, 0xca, 0x1a, 0x4f, 0x8f, 0x7d, 0x93, 0xaa, 0x69, 0xef, 0x97, 0xd5, - 0xe5, 0x7c, 0xf2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x26, 0xa5, 0x54, 0xb9, 0x0a, 0x00, + // 1217 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x3a, 0xb1, 0x9d, 0x3c, 0xa7, 0xc9, 0x76, 0x48, 0x5b, 0x27, 0x14, 0x27, 0x5a, 0x50, + 0x55, 0x40, 0x5d, 0xab, 0x41, 0x08, 0xb5, 0x54, 0x08, 0x3b, 0x4e, 0xdb, 0x2d, 0x91, 0x5b, 0xec, + 0x5a, 0x05, 0x84, 0xb4, 0x1a, 0xef, 0x8e, 0x9d, 0x51, 0x77, 0x67, 0xdc, 0xdd, 0xd9, 0xb6, 0xf9, + 0x16, 0xbd, 0xc1, 0xb7, 0xe0, 0xc2, 0x85, 0x1b, 0xc7, 0x1e, 0x2b, 0x2e, 0x20, 0x0e, 0x05, 0xb5, + 0xdf, 0x80, 0x4f, 0x80, 0xe6, 0xcf, 0x3a, 0x4e, 0xd4, 0x60, 0x37, 0xe2, 0x94, 0xcc, 0xbe, 0xf7, + 0xfb, 0xfd, 0xde, 0x9b, 0x7d, 0xef, 0xe7, 0x85, 0x0f, 0x33, 0x96, 0x31, 0x3a, 0xa0, 0x75, 0x36, + 0x10, 0x7d, 0x1c, 0x3c, 0x24, 0x61, 0xc4, 0x31, 0x3b, 0x7a, 0x72, 0x47, 0x09, 0x17, 0x1c, 0x9d, + 0x33, 0xa9, 0xee, 0x91, 0xe0, 0xc6, 0xda, 0x90, 0x0f, 0xb9, 0xca, 0xa8, 0xcb, 0xff, 0x74, 0xf2, + 0xc6, 0xe6, 0x90, 0xf3, 0x61, 0x44, 0xea, 0xea, 0xd4, 0xcf, 0x06, 0x75, 0x41, 0x63, 0x92, 0x0a, + 0x1c, 0x8f, 0x4c, 0x42, 0xed, 0x78, 0x42, 0x98, 0x25, 0x58, 0x50, 0xce, 0xf2, 0x78, 0xc0, 0xd3, + 0x98, 0xa7, 0xf5, 0x3e, 0x4e, 0x49, 0xfd, 0xf1, 0xd5, 0x3e, 0x11, 0xf8, 0x6a, 0x3d, 0xe0, 0x34, + 0x8f, 0xaf, 0xeb, 0xb8, 0xaf, 0x95, 0xf5, 0x41, 0x87, 0x9c, 0x06, 0x9c, 0x69, 0x0f, 0x84, 0x17, + 0x12, 0x26, 0xe8, 0x80, 0x92, 0x04, 0xad, 0xc3, 0x62, 0x10, 0xe1, 0x34, 0xf5, 0x69, 0x58, 0xb5, + 0xb6, 0xac, 0xcb, 0x4b, 0x9d, 0xb2, 0x3a, 0x7b, 0x21, 0x3a, 0x07, 0x25, 0x36, 0x10, 0x32, 0x50, + 0x50, 0x81, 0x22, 0x93, 0x48, 0xe7, 0x7b, 0x28, 0x36, 0x69, 0xe8, 0x85, 0xe8, 0xf3, 0x71, 0x5c, + 0x02, 0x2b, 0xdb, 0x1f, 0xb8, 0x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 0xfe, 0x78, 0x5d, 0x9b, 0xfb, 0xce, 0x9d, 0x30, 0x89, 0x1e, 0xeb, 0x31, + 0x7a, 0x93, 0xd6, 0x83, 0x7d, 0x4c, 0x59, 0xfd, 0xe9, 0xb1, 0xcf, 0x7a, 0x65, 0x18, 0xfd, 0x92, + 0xea, 0xf3, 0x93, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xee, 0x71, 0x47, 0xc2, 0xfc, 0x0b, 0x00, 0x00, } @@ -1285,6 +1358,67 @@ func (m *Liquidations) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *RepayInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RepayInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RepayInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n21, err21 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastRepaidAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastRepaidAt):]) + if err21 != nil { + return 0, err21 + } + i -= n21 + i = encodeVarintNftbackedloan(dAtA, i, uint64(n21)) + i-- + dAtA[i] = 0x22 + { + size, err := m.RemainingAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintNftbackedloan(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.RepaidInterestAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintNftbackedloan(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.RepaidAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintNftbackedloan(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintNftbackedloan(dAtA []byte, offset int, v uint64) int { offset -= sovNftbackedloan(v) base := offset @@ -1482,6 +1616,23 @@ func (m *Liquidations) Size() (n int) { return n } +func (m *RepayInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.RepaidAmount.Size() + n += 1 + l + sovNftbackedloan(uint64(l)) + l = m.RepaidInterestAmount.Size() + n += 1 + l + sovNftbackedloan(uint64(l)) + l = m.RemainingAmount.Size() + n += 1 + l + sovNftbackedloan(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastRepaidAt) + n += 1 + l + sovNftbackedloan(uint64(l)) + return n +} + func sovNftbackedloan(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3085,6 +3236,188 @@ func (m *Liquidations) Unmarshal(dAtA []byte) error { } return nil } +func (m *RepayInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNftbackedloan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RepayInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RepayInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RepaidAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNftbackedloan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthNftbackedloan + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthNftbackedloan + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RepaidAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RepaidInterestAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNftbackedloan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthNftbackedloan + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthNftbackedloan + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RepaidInterestAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RemainingAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNftbackedloan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthNftbackedloan + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthNftbackedloan + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RemainingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastRepaidAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNftbackedloan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthNftbackedloan + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthNftbackedloan + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.LastRepaidAt, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipNftbackedloan(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNftbackedloan + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipNftbackedloan(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0