Skip to content

Commit cba94b2

Browse files
committed
remove loan hash lock
1 parent d94d37a commit cba94b2

File tree

22 files changed

+1245
-3435
lines changed

22 files changed

+1245
-3435
lines changed

api/side/lending/lending.pulsar.go

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

api/side/lending/query.pulsar.go

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

api/side/lending/tx.pulsar.go

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

api/side/lending/tx_grpc.pb.go

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

proto/side/lending/lending.proto

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,59 +78,55 @@ enum LoanStatus {
7878
Unspecified = 0;
7979
// Loan Requested
8080
Requested = 1;
81-
// Loan Approved
82-
Approved = 2;
81+
// Loan Open
82+
Open = 2;
8383
// Loan Rejected
8484
Rejected = 3;
8585
// Loan Cancelled
8686
Cancelled = 4;
87-
// Loan Open
88-
Open = 5;
8987
// Loan Repaid
90-
Repaid = 6;
88+
Repaid = 5;
9189
// Loan Defaulted
92-
Defaulted = 7;
90+
Defaulted = 6;
9391
// Loan Liquidated
94-
Liquidated = 8;
92+
Liquidated = 7;
9593
// Loan Closed
96-
Closed = 9;
94+
Closed = 8;
9795
}
9896

9997
message Loan {
10098
string vault_address = 1; // id
10199
string borrower = 2;
102100
string borrowerPubKey = 3;
103101
string agency = 4;
104-
string hash_loan_secret = 5;
105-
int64 maturity_time = 6;
106-
int64 final_timeout = 7;
102+
int64 maturity_time = 5;
103+
int64 final_timeout = 6;
107104

108-
cosmos.base.v1beta1.Coin borrow_amount = 8;
109-
string fees = 9 [
105+
cosmos.base.v1beta1.Coin borrow_amount = 7;
106+
string fees = 8 [
110107
(gogoproto.customtype) = "cosmossdk.io/math.Int",
111108
(gogoproto.nullable) = false
112109
];
113-
string interests = 10 [
110+
string interests = 9 [
114111
(gogoproto.customtype) = "cosmossdk.io/math.Int",
115112
(gogoproto.nullable) = false
116113
];
117114

118-
string term = 11 [
115+
string term = 10 [
119116
(gogoproto.customtype) = "cosmossdk.io/math.Int",
120117
(gogoproto.nullable) = false
121118
];
122-
uint64 event_id = 12;
123-
uint64 attestation_id = 13;
124-
repeated string deposit_txs = 14;
125-
string collateral_amount = 15 [
119+
uint64 event_id = 11;
120+
uint64 attestation_id = 12;
121+
repeated string deposit_txs = 13;
122+
string collateral_amount = 14 [
126123
(gogoproto.customtype) = "cosmossdk.io/math.Int",
127124
(gogoproto.nullable) = false
128125
];
129-
string pool_id = 16;
130-
uint64 auction_id = 17;
131-
string loan_secret = 18;
132-
google.protobuf.Timestamp create_at = 19 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
133-
LoanStatus status = 20;
126+
string pool_id = 15;
127+
uint64 auction_id = 16;
128+
google.protobuf.Timestamp create_at = 17 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
129+
LoanStatus status = 18;
134130
}
135131

136132
message DLCMeta {

proto/side/lending/query.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ message QueryLiquidationCetResponse {
112112
message QueryCollateralAddressRequest{
113113
string borrower_pubkey = 1;
114114
string agency_pubkey = 2;
115-
string hash_of_loan_secret = 3;
116-
uint64 maturity_time = 4;
115+
uint64 maturity_time = 3;
117116
}
118117

119118
message QueryCollateralAddressResponse{

proto/side/lending/tx.proto

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ service Msg {
2222
rpc Approve(MsgApprove) returns (MsgApproveResponse);
2323
rpc Cancel(MsgCancel) returns (MsgCancelResponse);
2424
rpc SubmitCancellationSignatures(MsgSubmitCancellationSignatures) returns (MsgSubmitCancellationSignaturesResponse);
25-
rpc Redeem(MsgRedeem) returns (MsgRedeemResponse);
2625
rpc Repay(MsgRepay) returns (MsgRepayResponse);
2726
rpc SubmitRepaymentAdaptorSignatures(MsgSubmitRepaymentAdaptorSignatures) returns (MsgSubmitRepaymentAdaptorSignaturesResponse);
2827
rpc SubmitLiquidationCetSignatures(MsgSubmitLiquidationCetSignatures) returns (MsgSubmitLiquidationCetSignaturesResponse);
@@ -76,15 +75,6 @@ message MsgRepay{
7675

7776
message MsgRepayResponse{}
7877

79-
message MsgRedeem {
80-
option (cosmos.msg.v1.signer) = "borrower";
81-
string borrower = 1;
82-
string loan_id = 2;
83-
string loan_secret = 3;
84-
}
85-
86-
message MsgRedeemResponse{}
87-
8878
message MsgAddLiquidity {
8979
option (cosmos.msg.v1.signer) = "lender";
9080

@@ -113,11 +103,10 @@ message MsgApply {
113103

114104
string borrower = 1;
115105
string borrower_pubkey = 2;
116-
string loan_secret_hash = 3;
117-
int64 maturity_time = 4;
118-
string pool_id = 5;
119-
cosmos.base.v1beta1.Coin borrow_amount = 6;
120-
uint64 agency_id = 7;
106+
int64 maturity_time = 3;
107+
string pool_id = 4;
108+
cosmos.base.v1beta1.Coin borrow_amount = 5;
109+
uint64 agency_id = 6;
121110
}
122111

123112
message MsgApplyResponse {

x/lending/client/cli/query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func CmdQueryPools() *cobra.Command {
130130

131131
func CmdQueryCollateralAddress() *cobra.Command {
132132
cmd := &cobra.Command{
133-
Use: "collateral-address [btc public key] [hash of loan secret] [maturity time]",
133+
Use: "collateral-address [borrower public key] [agency public key] [maturity time]",
134134
Short: "Query the collateral address by the specified loan params",
135135
Args: cobra.ExactArgs(3),
136136
RunE: func(cmd *cobra.Command, args []string) error {
@@ -147,9 +147,9 @@ func CmdQueryCollateralAddress() *cobra.Command {
147147
}
148148

149149
res, err := queryClient.CollateralAddress(cmd.Context(), &types.QueryCollateralAddressRequest{
150-
BorrowerPubkey: args[0],
151-
HashOfLoanSecret: args[1],
152-
MaturityTime: maturityTime,
150+
BorrowerPubkey: args[0],
151+
AgencyPubkey: args[1],
152+
MaturityTime: maturityTime,
153153
})
154154
if err != nil {
155155
return err

x/lending/client/cli/tx.go

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func GetTxCmd() *cobra.Command {
4040
cmd.AddCommand(CmdApprove())
4141
cmd.AddCommand(CmdCancel())
4242
cmd.AddCommand(CmdSubmitCancellationSignatures())
43-
cmd.AddCommand(CmdRedeem())
4443
cmd.AddCommand(CmdRepay())
4544
cmd.AddCommand(CmdSubmitRepaymentAdaptorSignatures())
4645
cmd.AddCommand(CmdSubmitLiquidationCetSignatures())
@@ -121,36 +120,35 @@ func CmdRemoveLiquidity() *cobra.Command {
121120

122121
func CmdApply() *cobra.Command {
123122
cmd := &cobra.Command{
124-
Use: "apply [btc public key] [secret hash] [maturity time] [pool id] [borrow amount] [agency id]",
123+
Use: "apply [btc public key] [maturity time] [pool id] [borrow amount] [agency id]",
125124
Short: "Apply loan with the related params",
126-
Args: cobra.ExactArgs(6),
125+
Args: cobra.ExactArgs(5),
127126
RunE: func(cmd *cobra.Command, args []string) (err error) {
128127
clientCtx, err := client.GetClientTxContext(cmd)
129128
if err != nil {
130129
return err
131130
}
132131

133-
maturityTime, err := strconv.ParseInt(args[2], 10, 64)
132+
maturityTime, err := strconv.ParseInt(args[1], 10, 64)
134133
if err != nil {
135134
return err
136135
}
137136

138-
borrowAmount, err := sdk.ParseCoinNormalized(args[4])
137+
borrowAmount, err := sdk.ParseCoinNormalized(args[3])
139138
if err != nil {
140139
return err
141140
}
142141

143-
agencyId, err := strconv.ParseUint(args[5], 10, 64)
142+
agencyId, err := strconv.ParseUint(args[4], 10, 64)
144143
if err != nil {
145144
return err
146145
}
147146

148147
msg := types.NewMsgApply(
149148
clientCtx.GetFromAddress().String(),
150149
args[0],
151-
args[1],
152150
maturityTime,
153-
args[3],
151+
args[2],
154152
borrowAmount,
155153
agencyId,
156154
)
@@ -300,36 +298,6 @@ func CmdSubmitCancellationSignatures() *cobra.Command {
300298
return cmd
301299
}
302300

303-
func CmdRedeem() *cobra.Command {
304-
cmd := &cobra.Command{
305-
Use: "redeem [loan id] [loan secret]",
306-
Short: "Redeem the borrowed coin with the loan secret",
307-
Args: cobra.ExactArgs(2),
308-
RunE: func(cmd *cobra.Command, args []string) (err error) {
309-
clientCtx, err := client.GetClientTxContext(cmd)
310-
if err != nil {
311-
return err
312-
}
313-
314-
msg := types.NewMsgRedeem(
315-
clientCtx.GetFromAddress().String(),
316-
args[0],
317-
args[1],
318-
)
319-
320-
if err := msg.ValidateBasic(); err != nil {
321-
return err
322-
}
323-
324-
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
325-
},
326-
}
327-
328-
flags.AddTxFlagsToCmd(cmd)
329-
330-
return cmd
331-
}
332-
333301
func CmdRepay() *cobra.Command {
334302
cmd := &cobra.Command{
335303
Use: "repay [loan id] [adaptor point]",

0 commit comments

Comments
 (0)