-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpopulate.py
More file actions
188 lines (163 loc) · 4.72 KB
/
populate.py
File metadata and controls
188 lines (163 loc) · 4.72 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
# ---------------------------------------------------------------------------- #
# signup and login
admin = login_admin()
alice = signup_user(
username="alice",
password="alice",
email="alice@example.com",
first_name="Alice",
last_name="Smith",
ethereum_key=argv[3],
)
bob = signup_user(
username="bob",
password="bob",
email="bob@example.com",
first_name="Bob",
last_name="Smith",
ethereum_key=argv[4],
)
charlie = signup_user(
username="charlie",
password="charlie",
email="charlie@example.com",
first_name="Charlie",
last_name="Smith",
ethereum_key=argv[5],
)
dough = signup_user(
username="dough",
password="dough",
email="dough@example.com",
first_name="Dough",
last_name="Smith",
ethereum_key=argv[6],
)
eve = signup_user(
username="eve",
password="eve",
email="eve@example.com",
first_name="Eve",
last_name="Smith",
ethereum_key=argv[7],
)
# ---------------------------------------------------------------------------- #
# set up Alice's loan (ends up in phase Funding)
alice_loan_id = alice.post(
path="/api/loans/new/",
request={
"school": "University of Alice",
"course": "Alice Engineering",
"requested_value_atto_dai": str(10_000 * oneDai),
"destination": "Portugal",
"description": "Hi, I am Alice.",
"recipient_address": str(alice.key.address),
},
response_transform=lambda r: r["loan"],
)
admin.put(
path=f"/api/loans/validate/{alice_loan_id}/",
request={
"days_to_expiration": "30",
"funding_fee_atto_dai_per_dai": str(3 * oneDai // 100),
"payment_fee_atto_dai_per_dai": str(5 * oneDai // 100),
},
)
dough.transact(
path="/api/loans/transactions/provide_funds/",
request={
"loan_id": alice_loan_id,
"value_atto_dai": str(5_000 * oneDai),
},
)
# ---------------------------------------------------------------------------- #
# set up Bob's loan (ends up in phase Active)
bob_loan_id = bob.post(
path="/api/loans/new/",
request={
"school": "University of Bob",
"course": "Bob Engineering",
"requested_value_atto_dai": str(10_000 * oneDai),
"destination": "Portugal",
"description": "Hi, I am Bob.",
"recipient_address": str(bob.key.address),
},
response_transform=lambda r: r["loan"],
)
admin.put(
path=f"/api/loans/validate/{bob_loan_id}/",
request={
"days_to_expiration": "30",
"funding_fee_atto_dai_per_dai": str(3 * oneDai // 100),
"payment_fee_atto_dai_per_dai": str(5 * oneDai // 100),
},
)
dough.transact(
path="/api/loans/transactions/provide_funds/",
request={
"loan_id": bob_loan_id,
"value_atto_dai": str(5_000 * oneDai),
},
)
eve.transact(
path="/api/loans/transactions/provide_funds/",
request={
"loan_id": bob_loan_id,
"value_atto_dai": str(5_000 * oneDai),
},
)
# ---------------------------------------------------------------------------- #
# set up Charlie's loan (ends up in phase Finalized)
charlie_loan_id = charlie.post(
path="/api/loans/new/",
request={
"school": "University of Charlie",
"course": "Charlie Engineering",
"requested_value_atto_dai": str(10_000 * oneDai),
"destination": "Portugal",
"description": "Hi, I am Charlie.",
"recipient_address": str(charlie.key.address),
},
response_transform=lambda r: r["loan"],
)
admin.put(
path=f"/api/loans/validate/{charlie_loan_id}/",
request={
"days_to_expiration": "30",
"funding_fee_atto_dai_per_dai": str(3 * oneDai // 100),
"payment_fee_atto_dai_per_dai": str(5 * oneDai // 100),
},
)
dough.transact(
path="/api/loans/transactions/provide_funds/",
request={
"loan_id": charlie_loan_id,
"value_atto_dai": str(5_000 * oneDai),
},
)
eve.transact(
path="/api/loans/transactions/provide_funds/",
request={
"loan_id": charlie_loan_id,
"value_atto_dai": str(5_000 * oneDai),
},
)
charlie.transact(
path="/api/loans/transactions/make_payment/",
request={
"loan_id": charlie_loan_id,
"value_atto_dai": str(12_000 * oneDai),
},
)
admin.put(path=f"/api/loans/finalize/{charlie_loan_id}/", request={})
# ---------------------------------------------------------------------------- #
# create sell position by Dough of tokens of Bob's loan
dough.transact(
path="/api/market/transactions/create_sell_position/",
request={
"loan_id": bob_loan_id,
"amount_tokens": 2500,
"price_atto_dai_per_token": str(15 * oneDai // 10),
},
)
# ---------------------------------------------------------------------------- #