1pub mod msgs {
2 use cosmwasm_schema::{cw_serde, QueryResponses};
3
4 use crate::pool::msgs::LoanInfoResponse;
5
6 use super::definitions::{Config, LoanBaseInfo, LoanKey};
7
8 #[cw_serde]
9 pub struct InstantiateMsg {
10 pub owner: String,
11 }
12
13 #[cw_serde]
14 pub enum ExecuteMsg {
15 RegisterPool { address: String },
16 AddLoanPosition(AddLoanPositionMsg),
17 RemoveLoanPosition(RemoveLoanPositionMsg),
18 RemoveLoanPositions(RemoveLoanPositionsMsg),
19 UpdateConfig(UpdateConfigMsg),
20 }
21
22 #[cw_serde]
23 #[derive(QueryResponses)]
24 pub enum QueryMsg {
25 #[returns(UserLoansBaseInfoResponse)]
26 UsersLoansBaseInfo {
27 user: String,
28 limit: Option<u32>,
29 start_after: Option<LoanKey>,
30 },
31
32 #[returns(UserLoansBaseFullResponse)]
33 UsersLoansFullInfo {
34 user: String,
35 limit: Option<u32>,
36 start_after: Option<LoanKey>,
37 },
38
39 #[returns(Config)]
40 Config {},
41 }
42
43 #[cw_serde]
44 pub struct MigrateMsg {}
45
46 #[cw_serde]
47 pub struct AddLoanPositionMsg {
48 pub owner: String,
49 pub id: u64,
50 }
51
52 #[cw_serde]
53 pub struct RemoveLoanPositionMsg {
54 pub id: u64,
55 }
56 #[cw_serde]
57 pub struct RemoveLoanPositionsMsg {
58 pub ids: Vec<u64>,
59 }
60
61 #[cw_serde]
62 pub struct UpdateConfigMsg {
63 pub owner: Option<String>,
64 pub factory: Option<String>,
65 }
66
67 #[cw_serde]
68 pub struct UserLoansBaseInfoResponse {
69 pub loans: Vec<(LoanKey, LoanBaseInfo)>,
70 }
71
72 impl From<Vec<(LoanKey, LoanBaseInfo)>> for UserLoansBaseInfoResponse {
73 fn from(value: Vec<(LoanKey, LoanBaseInfo)>) -> Self {
74 UserLoansBaseInfoResponse { loans: value }
75 }
76 }
77
78 #[cw_serde]
79 pub struct UserLoansBaseFullResponse {
80 pub loans: Vec<(LoanKey, LoanInfoResponse)>,
81 }
82
83 impl From<Vec<(LoanKey, LoanInfoResponse)>> for UserLoansBaseFullResponse {
84 fn from(value: Vec<(LoanKey, LoanInfoResponse)>) -> Self {
85 UserLoansBaseFullResponse { loans: value }
86 }
87 }
88}
89
90pub mod definitions {
91 use cosmwasm_schema::cw_serde;
92 use cosmwasm_std::Addr;
93
94 use crate::traits::AssertOwner;
95
96 pub type LoanKey = (Addr, u64);
97
98 #[cw_serde]
99 pub struct Config {
100 pub owner: Addr,
101 pub factory: Addr,
102 }
103
104 impl AssertOwner for Config {
105 fn get_admin(&self) -> Addr {
106 self.owner.clone()
107 }
108 }
109
110 #[cw_serde]
111 pub struct LoanBaseInfo {
112 pub owner: Addr,
113 pub id: u64,
114 }
115}