Skip to content

Commit 144052a

Browse files
committed
change liquidation event query params
1 parent 990ca1b commit 144052a

File tree

6 files changed

+410
-468
lines changed

6 files changed

+410
-468
lines changed

api/side/lending/query.pulsar.go

Lines changed: 283 additions & 320 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/static/openapi.yml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

proto/side/lending/query.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ message QueryPoolsResponse {
7777
}
7878

7979
message QueryLiquidationEventRequest{
80-
cosmos.base.v1beta1.Coin borrow_amount = 1;
81-
cosmos.base.v1beta1.Coin collateral_acmount =2;
80+
string collateral_amount = 1;
81+
string borrow_amount = 2;
8282
}
8383

8484
message QueryLiquidationEventResponse {

x/lending/client/cli/query.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
"github.com/cosmos/cosmos-sdk/client"
1515
"github.com/cosmos/cosmos-sdk/client/flags"
16-
sdk "github.com/cosmos/cosmos-sdk/types"
1716

1817
"github.com/sideprotocol/side/x/lending/types"
1918
)
@@ -182,19 +181,9 @@ func CmdQueryLiquidationEvent() *cobra.Command {
182181

183182
queryClient := types.NewQueryClient(clientCtx)
184183

185-
collateralAmount, err := sdk.ParseCoinNormalized(args[0])
186-
if err != nil {
187-
return err
188-
}
189-
190-
borrowedAmount, err := sdk.ParseCoinNormalized(args[1])
191-
if err != nil {
192-
return err
193-
}
194-
195184
res, err := queryClient.LiquidationEvent(cmd.Context(), &types.QueryLiquidationEventRequest{
196-
BorrowAmount: &borrowedAmount,
197-
CollateralAcmount: &collateralAmount,
185+
CollateralAmount: args[0],
186+
BorrowAmount: args[1],
198187
})
199188
if err != nil {
200189
return err

x/lending/keeper/queries.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,19 @@ func (k Keeper) LiquidationEvent(goCtx context.Context, req *types.QueryLiquidat
6363
return nil, status.Error(codes.InvalidArgument, "invalid request")
6464
}
6565

66+
collateralAmount, err := sdk.ParseCoinNormalized(req.CollateralAmount)
67+
if err != nil {
68+
return nil, status.Error(codes.InvalidArgument, err.Error())
69+
}
70+
71+
borrowedAmount, err := sdk.ParseCoinNormalized(req.BorrowAmount)
72+
if err != nil {
73+
return nil, status.Error(codes.InvalidArgument, err.Error())
74+
}
75+
6676
ctx := sdk.UnwrapSDKContext(goCtx)
6777

68-
liquidationPrice := types.GetLiquidationPrice(req.CollateralAcmount.Amount, req.BorrowAmount.Amount, k.GetParams(ctx).LiquidationThresholdPercent)
78+
liquidationPrice := types.GetLiquidationPrice(collateralAmount.Amount, borrowedAmount.Amount, k.GetParams(ctx).LiquidationThresholdPercent)
6979

7080
event := k.dlcKeeper.GetEventByPrice(ctx, liquidationPrice)
7181
if event == nil {

0 commit comments

Comments
 (0)