-
Notifications
You must be signed in to change notification settings - Fork 0
/
synthetic.feature
268 lines (263 loc) · 10.7 KB
/
synthetic.feature
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
Feature: Synthetic Protocol
Scenario: Synthetic liquidity pool
Given accounts
| Name | Amount |
| Pool | $10 000 |
| Alice | $10 000 |
And synthetic create liquidity pool
And synthetic deposit liquidity
| Name | Amount | Result |
| Pool | $10 000 | Ok |
| Alice | $5 000 | Ok |
| Alice | $6 000 | BalanceTooLow |
Then synthetic liquidity is $15000
Scenario: Synthetic buy and sell
Given accounts
| Name | Amount |
| Pool | $10 000 |
| Alice | $10 000 |
And synthetic create liquidity pool
And synthetic deposit liquidity
| Name | Amount | Result |
| Pool | $10 000 | Ok |
And synthetic set min additional collateral ratio to 10%
And synthetic set additional collateral ratio
| Currency | Ratio |
| FEUR | 10% |
And synthetic set spread
| Currency | Ratio |
| FEUR | $0.03 |
And oracle price
| Currency | Price |
| FEUR | $3 |
When synthetic buy
| Name | Currency | Amount |
| Alice | FEUR | $5000 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | $5000 | FEUR | 1650_165016501650165017 |
Then synthetic liquidity is 9554_455445544554455444
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
Then synthetic module balance is 5445_544554455445544556
When synthetic sell
| Name | Currency | Amount |
| Alice | FEUR | $800 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | $7376 | FEUR | 8501_65016501650165017 |
Then synthetic liquidity is 9818_455445544554455444
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
Scenario: Synthetic trader take profit
Given accounts
| Name | Amount |
| Pool | $10 000 |
| Alice | $10 000 |
And synthetic create liquidity pool
And synthetic deposit liquidity
| Name | Amount | Result |
| Pool | $10 000 | Ok |
And synthetic set min additional collateral ratio to 10%
And synthetic set additional collateral ratio
| Currency | Ratio |
| FEUR | 10% |
And synthetic set spread
| Currency | Ratio |
| FEUR | $0.03 |
And oracle price
| Currency | Price |
| FEUR | $3 |
When synthetic buy
| Name | Currency | Amount |
| Alice | FEUR | $5000 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | $5000 | FEUR | 1650_165016501650165017 |
Then synthetic liquidity is 9554_455445544554455444
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
Then synthetic module balance is 5445_544554455445544556
And oracle price
| Currency | Price |
| FEUR | $3.1 |
When synthetic sell
| Name | Currency | Amount |
| Alice | FEUR | 1650_165016501650165017 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | 10066_006600660066006602 | FEUR | 0 |
Then synthetic module balance is 0
Then synthetic liquidity is 9933_993399339933993398
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 0 | false |
Scenario: Synthetic trader stop lost
Given accounts
| Name | Amount |
| Pool | $10 000 |
| Alice | $10 000 |
And synthetic create liquidity pool
And synthetic deposit liquidity
| Name | Amount | Result |
| Pool | $10 000 | Ok |
And synthetic set min additional collateral ratio to 10%
And synthetic set additional collateral ratio
| Currency | Ratio |
| FEUR | 10% |
And synthetic set spread
| Currency | Ratio |
| FEUR | $0.03 |
And oracle price
| Currency | Price |
| FEUR | $3 |
When synthetic buy
| Name | Currency | Amount |
| Alice | FEUR | $5000 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | $5000 | FEUR | 1650_165016501650165017 |
Then synthetic liquidity is 9554_455445544554455444
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
Then synthetic module balance is 5445_544554455445544556
And oracle price
| Currency | Price |
| FEUR | $2 |
When synthetic sell
| Name | Currency | Amount |
| Alice | FEUR | 1650_165016501650165017 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | 8250_825082508250825083 | FEUR | 0 |
Then synthetic module balance is 0
Then synthetic liquidity is 11749_174917491749174917
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 0 | false |
Scenario: Synthetic multiple users multiple currencies
Given accounts
| Name | Amount |
| Pool | $40 000 |
| Alice | $10 000 |
| BOB | $10 000 |
And synthetic create liquidity pool
And synthetic deposit liquidity
| Name | Amount | Result |
| Pool | $40 000 | Ok |
And synthetic set min additional collateral ratio to 10%
And synthetic set additional collateral ratio
| Currency | Ratio |
| FEUR | 10% |
And synthetic set spread
| Currency | Ratio |
| FEUR | $0.03 |
| FJPY | $0.04 |
And oracle price
| Currency | Price |
| FEUR | $3 |
| FJPY | $4 |
When synthetic buy
| Name | Currency | Amount |
| Alice | FEUR | $5000 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | $5000 | FEUR | 1650_165016501650165017 |
Then synthetic liquidity is 3955_4455445544554455444
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
| FJPY | 0 | false |
Then synthetic module balance is 5445_544554455445544556
When synthetic buy
| Name | Currency | Amount |
| BOB | FJPY | $5000 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| BOB | $5000 | FJPY | 1237_623762376237623762 |
Then synthetic liquidity is 3910_8910891089108910891
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
| FJPY | 1_100000000000000000 | true |
Then synthetic module balance is 10891_089108910891089109
And oracle price
| Currency | Price |
| FEUR | $2 |
| FJPY | $5 |
When synthetic buy
| Name | Currency | Amount |
| Alice | FJPY | $2000 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | $3000 | FJPY | 3968_25396825396825397 |
Then synthetic liquidity is 3892_6371208549426371208
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_650000000000000000 | true |
| FJPY | 0_933413461538461538 | false |
Then synthetic module balance is 13073_628791450573628792
When synthetic buy
| Name | Currency | Amount |
| BOB | FEUR | $2000 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| BOB | $3000 | FEUR | 9852_21674876847290640 |
Then synthetic module balance is 1524_1116476179637668200
Then synthetic liquidity is 3875_8883523820362331800
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_444386181369524985 | true |
| FJPY | 0_933413461538461538 | false |
When synthetic sell
| Name | Currency | Amount |
| Alice | FEUR | $100 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | 3197_000000000000000000 | FEUR | 1550_165016501650165017 |
Then synthetic module balance is 1320_5934958027822486681
Then synthetic liquidity is 4059_7065041972177513319
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
| FJPY | 0_933413461538461538 | false |
When synthetic sell
| Name | Currency | Amount |
| BOB | FJPY | $100 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| BOB | 3496_000000000000000000 | FJPY | 1137_623762376237623762 |
Then synthetic module balance is 1270_9934958027822486681
Then synthetic liquidity is 4059_7065041972177513319
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
| FJPY | 0_929595378801069267 | false |
When synthetic sell
| Name | Currency | Amount |
| Alice | FJPY | $100 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| Alice | 3693_000000000000000000 | FJPY | 296_825396825396825397 |
Then synthetic module balance is 1221_3934958027822486681
Then synthetic liquidity is 4059_7065041972177513319
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
| FJPY | 0_925244954751626969 | false |
When synthetic sell
| Name | Currency | Amount |
| BOB | FEUR | $100 |
Then synthetic balances are
| Name | Free | Currency | Synthetic |
| BOB | 3693_000000000000000000 | FEUR | 8852_21674876847290640 |
Then synthetic module balance is 1199_3934958027822486681
Then synthetic liquidity is 4062_0065041972177513319
Then synthetic pool info are
| Currency | Collateral Ratio | Is Safe |
| FEUR | 1_100000000000000000 | true |
| FJPY | 0_925244954751626969 | false |