-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yaml
175 lines (175 loc) · 5.36 KB
/
main.yaml
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
170
171
172
173
174
175
cidl: "0.9"
info:
name: informal_lender
title: Informal Lender
summary: |-
With this contract an informal lender can lend money through the blockchain.
For simplicity, the money will be SOL currency.
version: 0.1.0
license:
name: MIT
identifier: MIT
solana:
seeds:
Broker:
items:
- name: broker
Loan:
items:
- name: loan
- name: client
type: sol:pubkey
- name: index
type: u32
types:
Broker:
summary: |-
Broker is an account that can only exist once per contract.
It stores all the require information to lend money.
fields:
- name: delegate
type: sol:pubkey
description: Only this delegate can modify the Broker account
- name: capital
type: u128
description: The amount of money staked
- name: lended
type: u128
description: The amount of money lended
- name: revenue
type: u128
description: The amount of money earn
- name: fee
type: u8
description: The percentage a client needs to pay when paying a loan
Loan:
summary: |-
Loan is an account that will exist as many times is required
per client it stores a request to a Loan and if the loan is approved
it stores the amount payed.
fields:
- name: client
type: sol:pubkey
description: The client that owns this loan
- name: amount
type: u64
description: The amount of money the client borrow
- name: payed
type: u64
description: The amount of money this client has payed
- name: kyc_url
type: string
description: URL to the client's KYC document require by law
attributes: [ cap=96 ]
- name: fee
type: u8
description: The fee this client needs to pay for this loan when making payments
- name: approved
type: bool
description: Flag state if the loan was approved by the broker or not
methods:
- name: create_broker
summary: |-
After deploying the contract this must be the first instruction
to call. It will configure the broker account.
signers:
- name: fee_payer
type: sol:account
attributes: [ sol:writable ]
- input: delegate
inputs:
- name: delegate
type: sol:account
description: This will be the account that has permission to update the broker and approved request.
attributes: [ sol:writable ]
- name: broker
type: sol:account<Broker, seeds.Broker>
attributes: [ sol:init ]
- name: amount
type: u64
description: The amount to be added to the capital. It will be debited from the delegate account
- name: fee
type: u8
- name: add_capital_to_broker
summary: Through this instruction any one can add capital to the broker
signers:
- name: fee_payer
type: sol:account
attributes: [ sol:writable ]
- input: delegate
inputs:
- name: delegate
type: sol:account
attributes: [ sol:writable ]
- name: broker
type: sol:account<Broker, seeds.Broker>
attributes: [ sol:writable ]
- name: amount
type: u64
description: The amount to be added to the capital. It will be debited from the delegate account
- name: request_loan
summary: This instruction is used by a client to request a loan
signers:
- name: fee_payer
type: sol:account
attributes: [ sol:writable ]
- input: client
inputs:
- name: client
type: sol:account
- name: loan
type: sol:account<Loan, seeds.Loan(client=client)>
attributes: [ sol:init ]
- name: broker
type: sol:account<Broker, seeds.Broker>
- name: amount
type: u64
description: The request amount to borrow
- name: kyc_url
type: string
- name: approve_loan
summary: |-
Through this instruction the delegate can approve a loan.
Upon approval, the funds will be transfer from the broker
account to the client's account.
signers:
- name: fee_payer
type: sol:account
attributes: [ sol:writable ]
- input: delegate
inputs:
- name: delegate
type: sol:account
- name: loan
type: sol:account<Loan, seeds.Loan(client=client)>
attributes: [ sol:writable ]
- name: broker
type: sol:account<Broker, seeds.Broker>
attributes: [ sol:writable ]
- name: client
type: sol:account
attributes: [ sol:writable ]
- name: pay_loan
summary: |-
A client can pay a loan through this instruction. When paying
the contract will calculate the interest based on the loan approved
fee. Additioanlly, it will transfer money from the client's account
to the broker account
signers:
- name: fee_payer
type: sol:account
attributes: [ sol:writable ]
- input: client
inputs:
- name: client
type: sol:account
attributes: [ sol:writable ]
- name: loan
type: sol:account<Loan, seeds.Loan(client=client)>
attributes: [ sol:writable ]
- name: broker
type: sol:account<Broker, seeds.Broker>
attributes: [ sol:writable ]
- name: amount
type: u64
description: The amount to pay to the loan