-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
169 lines (160 loc) · 3.87 KB
/
schema.graphql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
type Asset @entity {
"""
{{ clientId }}-{{ key }}-{{ tokenAddress }}-{{ dayId }} for MicroCredit
"""
id: ID!
# asset
asset: Bytes!
# amount (normalized)
amount: BigDecimal!
}
"""
MicroCredit Borrower
"""
type Borrower @entity {
"""
borrower id
"""
id: ID!
# client id (see the list)
clientId: Int!
# borrower loans
loans: [Loan!]! @derivedFrom(field: "borrower")
# number of loans
loansCount: Int!
# last loan status - 0: pending, 1: active, 2: repaid, 3: canceled
lastLoanStatus: Int!
# below are all loan fields duplicated, for query list purposes!
# loan amount
lastLoanAmount: BigDecimal!
# loan period (maturation date)
lastLoanPeriod: Int!
# loan interest (in % / day)
lastLoanDailyInterest: BigDecimal!
# timestamp when the loan was added
lastLoanAdded: Int!
# timestamp if loan was claimed, otherwise null
lastLoanClaimed: Int
# amount repaid (normalized)
lastLoanRepaid: BigDecimal!
# timestamp of last repayment (null if no repayments)
lastLoanLastRepayment: Int
# amount paid on last repayment (normalized)
lastLoanLastRepaymentAmount: BigDecimal
# debt after the last repayment (normalized)
lastLoanLastDebt: BigDecimal
# manager adding the loan
lastLoanAddedBy: LoanManager!
# number of repayments
lastLoanRepayments: Int!
# repayments of all loans
repayments: [Repayment!]! @derivedFrom(field: "borrower")
# number of repayments ever
repaymentsCount: Int!
# timestamp of when the entity was last updated
entityLastUpdated: Int!
}
"""
Loan entity
"""
type Loan @entity {
# loan id {{ userAdreress }}-{{ loanId }}
id: ID!
# loan index
index: Int!
# borrower address
borrower: Borrower!
# loan amount
amount: BigDecimal!
# loan period (maturation date)
period: Int!
# loan interest (in % / day)
dailyInterest: BigDecimal!
# timestamp when the loan was added
added: Int!
# timestamp if loan was claimed, otherwise null
claimed: Int
# amount repaid (normalized)
repaid: BigDecimal!
# timestamp of last repayment (null if no repayments)
lastRepayment: Int
# amount paid on last repayment (normalized)
lastRepaymentAmount: BigDecimal
# number of repayments
repaymentsCount: Int!
# debt after the last repayment (normalized)
lastDebt: BigDecimal
# manager adding the loan
addedBy: LoanManager!
}
type Repayment @entity {
# repayment id {{ borrower }}-{{ loanId }}-{{ repaymentId }}
id: ID!
# borrower
borrower: Borrower!
# loan
loan: Loan!
# amount paid (normalized)
amount: BigDecimal!
# timestamp
timestamp: Int!
# debt after the repayment (normalized)
debt: BigDecimal!
}
type AverageValue @entity {
# day id
id: ID!
# average value
value: BigDecimal!
# number of values
count: Int!
}
"""
MicroCredit global data
For efficiency reasons, all values are nullable
"""
type MicroCredit @entity {
# id: {{ clientId }}-0 is for global data, otherwise, {{ clientId }}-{{ dayId }}
id: ID!
# client id (see the list)
clientId: Int!
# amount borrowed in each currency
borrowed: [Asset!]
# debt amount in each currency
debt: [Asset!]
# amount repaid in each currency
repaid: [Asset!]
# interest in each currency
interest: [Asset!]
# average loan amount
avgLoanAmount: [AverageValue!]
# average loan period
avgLoanPeriod: [AverageValue!]
# number of loans ever
loans: Int!
# number of loans fully repaid
repaidLoans: Int!
# estimated liquidity available in each currency
liquidity: [Asset!]
}
"""
MicroCredit Loan Manager
"""
type LoanManager @entity {
"""
manager id
"""
id: ID!
# client id (see the list)
clientId: Int!
# manager state
state: Int!
# number of borrowers being managed
borrowers: Int!
# number of loans ever managed (current + repaid)
loans: Int!
# limit that the loan manager can lend
loanLimitAmount: BigDecimal!
# amount currently lent
currentlyLentAmount: BigDecimal!
}