@curvefi/api 2.14.0 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/constants/abis/wsteth/swap.json +865 -0
- package/lib/constants/coins/arbitrum.js +1 -0
- package/lib/constants/coins/optimism.js +1 -0
- package/lib/constants/pools/arbitrum.js +25 -0
- package/lib/constants/pools/optimism.js +26 -0
- package/lib/pools/PoolTemplate.d.ts +1 -0
- package/lib/pools/PoolTemplate.js +78 -10
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +33 -23
- package/lib/pools/mixins/withdrawBonusMixins.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "TokenExchange",
|
|
4
|
+
"inputs": [
|
|
5
|
+
{
|
|
6
|
+
"name": "buyer",
|
|
7
|
+
"type": "address",
|
|
8
|
+
"indexed": true
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "sold_id",
|
|
12
|
+
"type": "int128",
|
|
13
|
+
"indexed": false
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "tokens_sold",
|
|
17
|
+
"type": "uint256",
|
|
18
|
+
"indexed": false
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "bought_id",
|
|
22
|
+
"type": "int128",
|
|
23
|
+
"indexed": false
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "tokens_bought",
|
|
27
|
+
"type": "uint256",
|
|
28
|
+
"indexed": false
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"anonymous": false,
|
|
32
|
+
"type": "event"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "AddLiquidity",
|
|
36
|
+
"inputs": [
|
|
37
|
+
{
|
|
38
|
+
"name": "provider",
|
|
39
|
+
"type": "address",
|
|
40
|
+
"indexed": true
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "token_amounts",
|
|
44
|
+
"type": "uint256[2]",
|
|
45
|
+
"indexed": false
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "fees",
|
|
49
|
+
"type": "uint256[2]",
|
|
50
|
+
"indexed": false
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "invariant",
|
|
54
|
+
"type": "uint256",
|
|
55
|
+
"indexed": false
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "token_supply",
|
|
59
|
+
"type": "uint256",
|
|
60
|
+
"indexed": false
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"anonymous": false,
|
|
64
|
+
"type": "event"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "RemoveLiquidity",
|
|
68
|
+
"inputs": [
|
|
69
|
+
{
|
|
70
|
+
"name": "provider",
|
|
71
|
+
"type": "address",
|
|
72
|
+
"indexed": true
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "token_amounts",
|
|
76
|
+
"type": "uint256[2]",
|
|
77
|
+
"indexed": false
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "fees",
|
|
81
|
+
"type": "uint256[2]",
|
|
82
|
+
"indexed": false
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "token_supply",
|
|
86
|
+
"type": "uint256",
|
|
87
|
+
"indexed": false
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"anonymous": false,
|
|
91
|
+
"type": "event"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "RemoveLiquidityOne",
|
|
95
|
+
"inputs": [
|
|
96
|
+
{
|
|
97
|
+
"name": "provider",
|
|
98
|
+
"type": "address",
|
|
99
|
+
"indexed": true
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "token_amount",
|
|
103
|
+
"type": "uint256",
|
|
104
|
+
"indexed": false
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "coin_amount",
|
|
108
|
+
"type": "uint256",
|
|
109
|
+
"indexed": false
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"anonymous": false,
|
|
113
|
+
"type": "event"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"name": "RemoveLiquidityImbalance",
|
|
117
|
+
"inputs": [
|
|
118
|
+
{
|
|
119
|
+
"name": "provider",
|
|
120
|
+
"type": "address",
|
|
121
|
+
"indexed": true
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "token_amounts",
|
|
125
|
+
"type": "uint256[2]",
|
|
126
|
+
"indexed": false
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "fees",
|
|
130
|
+
"type": "uint256[2]",
|
|
131
|
+
"indexed": false
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "invariant",
|
|
135
|
+
"type": "uint256",
|
|
136
|
+
"indexed": false
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "token_supply",
|
|
140
|
+
"type": "uint256",
|
|
141
|
+
"indexed": false
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"anonymous": false,
|
|
145
|
+
"type": "event"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"name": "CommitNewAdmin",
|
|
149
|
+
"inputs": [
|
|
150
|
+
{
|
|
151
|
+
"name": "deadline",
|
|
152
|
+
"type": "uint256",
|
|
153
|
+
"indexed": true
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "admin",
|
|
157
|
+
"type": "address",
|
|
158
|
+
"indexed": true
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"anonymous": false,
|
|
162
|
+
"type": "event"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "NewAdmin",
|
|
166
|
+
"inputs": [
|
|
167
|
+
{
|
|
168
|
+
"name": "admin",
|
|
169
|
+
"type": "address",
|
|
170
|
+
"indexed": true
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"anonymous": false,
|
|
174
|
+
"type": "event"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "CommitNewFee",
|
|
178
|
+
"inputs": [
|
|
179
|
+
{
|
|
180
|
+
"name": "deadline",
|
|
181
|
+
"type": "uint256",
|
|
182
|
+
"indexed": true
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "fee",
|
|
186
|
+
"type": "uint256",
|
|
187
|
+
"indexed": false
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"name": "admin_fee",
|
|
191
|
+
"type": "uint256",
|
|
192
|
+
"indexed": false
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"anonymous": false,
|
|
196
|
+
"type": "event"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "NewFee",
|
|
200
|
+
"inputs": [
|
|
201
|
+
{
|
|
202
|
+
"name": "fee",
|
|
203
|
+
"type": "uint256",
|
|
204
|
+
"indexed": false
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "admin_fee",
|
|
208
|
+
"type": "uint256",
|
|
209
|
+
"indexed": false
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
"anonymous": false,
|
|
213
|
+
"type": "event"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "RampA",
|
|
217
|
+
"inputs": [
|
|
218
|
+
{
|
|
219
|
+
"name": "old_A",
|
|
220
|
+
"type": "uint256",
|
|
221
|
+
"indexed": false
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "new_A",
|
|
225
|
+
"type": "uint256",
|
|
226
|
+
"indexed": false
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "initial_time",
|
|
230
|
+
"type": "uint256",
|
|
231
|
+
"indexed": false
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"name": "future_time",
|
|
235
|
+
"type": "uint256",
|
|
236
|
+
"indexed": false
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"anonymous": false,
|
|
240
|
+
"type": "event"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "StopRampA",
|
|
244
|
+
"inputs": [
|
|
245
|
+
{
|
|
246
|
+
"name": "A",
|
|
247
|
+
"type": "uint256",
|
|
248
|
+
"indexed": false
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"name": "t",
|
|
252
|
+
"type": "uint256",
|
|
253
|
+
"indexed": false
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
"anonymous": false,
|
|
257
|
+
"type": "event"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"stateMutability": "nonpayable",
|
|
261
|
+
"type": "constructor",
|
|
262
|
+
"inputs": [
|
|
263
|
+
{
|
|
264
|
+
"name": "_owner",
|
|
265
|
+
"type": "address"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"name": "_coins",
|
|
269
|
+
"type": "address[2]"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"name": "_pool_token",
|
|
273
|
+
"type": "address"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "_A",
|
|
277
|
+
"type": "uint256"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"name": "_fee",
|
|
281
|
+
"type": "uint256"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"name": "_admin_fee",
|
|
285
|
+
"type": "uint256"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"name": "_oracle",
|
|
289
|
+
"type": "address"
|
|
290
|
+
}
|
|
291
|
+
],
|
|
292
|
+
"outputs": []
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"stateMutability": "view",
|
|
296
|
+
"type": "function",
|
|
297
|
+
"name": "A",
|
|
298
|
+
"inputs": [],
|
|
299
|
+
"outputs": [
|
|
300
|
+
{
|
|
301
|
+
"name": "",
|
|
302
|
+
"type": "uint256"
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"stateMutability": "view",
|
|
308
|
+
"type": "function",
|
|
309
|
+
"name": "A_precise",
|
|
310
|
+
"inputs": [],
|
|
311
|
+
"outputs": [
|
|
312
|
+
{
|
|
313
|
+
"name": "",
|
|
314
|
+
"type": "uint256"
|
|
315
|
+
}
|
|
316
|
+
]
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"stateMutability": "view",
|
|
320
|
+
"type": "function",
|
|
321
|
+
"name": "get_virtual_price",
|
|
322
|
+
"inputs": [],
|
|
323
|
+
"outputs": [
|
|
324
|
+
{
|
|
325
|
+
"name": "",
|
|
326
|
+
"type": "uint256"
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"stateMutability": "view",
|
|
332
|
+
"type": "function",
|
|
333
|
+
"name": "calc_token_amount",
|
|
334
|
+
"inputs": [
|
|
335
|
+
{
|
|
336
|
+
"name": "amounts",
|
|
337
|
+
"type": "uint256[2]"
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"name": "is_deposit",
|
|
341
|
+
"type": "bool"
|
|
342
|
+
}
|
|
343
|
+
],
|
|
344
|
+
"outputs": [
|
|
345
|
+
{
|
|
346
|
+
"name": "",
|
|
347
|
+
"type": "uint256"
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"stateMutability": "payable",
|
|
353
|
+
"type": "function",
|
|
354
|
+
"name": "add_liquidity",
|
|
355
|
+
"inputs": [
|
|
356
|
+
{
|
|
357
|
+
"name": "amounts",
|
|
358
|
+
"type": "uint256[2]"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"name": "min_mint_amount",
|
|
362
|
+
"type": "uint256"
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
"outputs": [
|
|
366
|
+
{
|
|
367
|
+
"name": "",
|
|
368
|
+
"type": "uint256"
|
|
369
|
+
}
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"stateMutability": "view",
|
|
374
|
+
"type": "function",
|
|
375
|
+
"name": "get_dy",
|
|
376
|
+
"inputs": [
|
|
377
|
+
{
|
|
378
|
+
"name": "i",
|
|
379
|
+
"type": "int128"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"name": "j",
|
|
383
|
+
"type": "int128"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"name": "dx",
|
|
387
|
+
"type": "uint256"
|
|
388
|
+
}
|
|
389
|
+
],
|
|
390
|
+
"outputs": [
|
|
391
|
+
{
|
|
392
|
+
"name": "",
|
|
393
|
+
"type": "uint256"
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"stateMutability": "view",
|
|
399
|
+
"type": "function",
|
|
400
|
+
"name": "get_dx",
|
|
401
|
+
"inputs": [
|
|
402
|
+
{
|
|
403
|
+
"name": "i",
|
|
404
|
+
"type": "int128"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"name": "j",
|
|
408
|
+
"type": "int128"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"name": "dy",
|
|
412
|
+
"type": "uint256"
|
|
413
|
+
}
|
|
414
|
+
],
|
|
415
|
+
"outputs": [
|
|
416
|
+
{
|
|
417
|
+
"name": "",
|
|
418
|
+
"type": "uint256"
|
|
419
|
+
}
|
|
420
|
+
]
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"stateMutability": "payable",
|
|
424
|
+
"type": "function",
|
|
425
|
+
"name": "exchange",
|
|
426
|
+
"inputs": [
|
|
427
|
+
{
|
|
428
|
+
"name": "i",
|
|
429
|
+
"type": "int128"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"name": "j",
|
|
433
|
+
"type": "int128"
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
"name": "dx",
|
|
437
|
+
"type": "uint256"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"name": "min_dy",
|
|
441
|
+
"type": "uint256"
|
|
442
|
+
}
|
|
443
|
+
],
|
|
444
|
+
"outputs": [
|
|
445
|
+
{
|
|
446
|
+
"name": "",
|
|
447
|
+
"type": "uint256"
|
|
448
|
+
}
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
"stateMutability": "nonpayable",
|
|
453
|
+
"type": "function",
|
|
454
|
+
"name": "remove_liquidity",
|
|
455
|
+
"inputs": [
|
|
456
|
+
{
|
|
457
|
+
"name": "_amount",
|
|
458
|
+
"type": "uint256"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"name": "min_amounts",
|
|
462
|
+
"type": "uint256[2]"
|
|
463
|
+
}
|
|
464
|
+
],
|
|
465
|
+
"outputs": [
|
|
466
|
+
{
|
|
467
|
+
"name": "",
|
|
468
|
+
"type": "uint256[2]"
|
|
469
|
+
}
|
|
470
|
+
]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"stateMutability": "nonpayable",
|
|
474
|
+
"type": "function",
|
|
475
|
+
"name": "remove_liquidity_imbalance",
|
|
476
|
+
"inputs": [
|
|
477
|
+
{
|
|
478
|
+
"name": "amounts",
|
|
479
|
+
"type": "uint256[2]"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"name": "max_burn_amount",
|
|
483
|
+
"type": "uint256"
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
"outputs": [
|
|
487
|
+
{
|
|
488
|
+
"name": "",
|
|
489
|
+
"type": "uint256"
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
"stateMutability": "view",
|
|
495
|
+
"type": "function",
|
|
496
|
+
"name": "calc_withdraw_one_coin",
|
|
497
|
+
"inputs": [
|
|
498
|
+
{
|
|
499
|
+
"name": "_token_amount",
|
|
500
|
+
"type": "uint256"
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"name": "i",
|
|
504
|
+
"type": "int128"
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
"outputs": [
|
|
508
|
+
{
|
|
509
|
+
"name": "",
|
|
510
|
+
"type": "uint256"
|
|
511
|
+
}
|
|
512
|
+
]
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
"stateMutability": "nonpayable",
|
|
516
|
+
"type": "function",
|
|
517
|
+
"name": "remove_liquidity_one_coin",
|
|
518
|
+
"inputs": [
|
|
519
|
+
{
|
|
520
|
+
"name": "_token_amount",
|
|
521
|
+
"type": "uint256"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"name": "i",
|
|
525
|
+
"type": "int128"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"name": "_min_amount",
|
|
529
|
+
"type": "uint256"
|
|
530
|
+
}
|
|
531
|
+
],
|
|
532
|
+
"outputs": [
|
|
533
|
+
{
|
|
534
|
+
"name": "",
|
|
535
|
+
"type": "uint256"
|
|
536
|
+
}
|
|
537
|
+
]
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"stateMutability": "nonpayable",
|
|
541
|
+
"type": "function",
|
|
542
|
+
"name": "ramp_A",
|
|
543
|
+
"inputs": [
|
|
544
|
+
{
|
|
545
|
+
"name": "_future_A",
|
|
546
|
+
"type": "uint256"
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
"name": "_future_time",
|
|
550
|
+
"type": "uint256"
|
|
551
|
+
}
|
|
552
|
+
],
|
|
553
|
+
"outputs": []
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
"stateMutability": "nonpayable",
|
|
557
|
+
"type": "function",
|
|
558
|
+
"name": "stop_ramp_A",
|
|
559
|
+
"inputs": [],
|
|
560
|
+
"outputs": []
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"stateMutability": "nonpayable",
|
|
564
|
+
"type": "function",
|
|
565
|
+
"name": "commit_new_fee",
|
|
566
|
+
"inputs": [
|
|
567
|
+
{
|
|
568
|
+
"name": "new_fee",
|
|
569
|
+
"type": "uint256"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"name": "new_admin_fee",
|
|
573
|
+
"type": "uint256"
|
|
574
|
+
}
|
|
575
|
+
],
|
|
576
|
+
"outputs": []
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
"stateMutability": "nonpayable",
|
|
580
|
+
"type": "function",
|
|
581
|
+
"name": "apply_new_fee",
|
|
582
|
+
"inputs": [],
|
|
583
|
+
"outputs": []
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
"stateMutability": "nonpayable",
|
|
587
|
+
"type": "function",
|
|
588
|
+
"name": "revert_new_parameters",
|
|
589
|
+
"inputs": [],
|
|
590
|
+
"outputs": []
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
"stateMutability": "nonpayable",
|
|
594
|
+
"type": "function",
|
|
595
|
+
"name": "commit_transfer_ownership",
|
|
596
|
+
"inputs": [
|
|
597
|
+
{
|
|
598
|
+
"name": "_owner",
|
|
599
|
+
"type": "address"
|
|
600
|
+
}
|
|
601
|
+
],
|
|
602
|
+
"outputs": []
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
"stateMutability": "nonpayable",
|
|
606
|
+
"type": "function",
|
|
607
|
+
"name": "apply_transfer_ownership",
|
|
608
|
+
"inputs": [],
|
|
609
|
+
"outputs": []
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
"stateMutability": "nonpayable",
|
|
613
|
+
"type": "function",
|
|
614
|
+
"name": "revert_transfer_ownership",
|
|
615
|
+
"inputs": [],
|
|
616
|
+
"outputs": []
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
"stateMutability": "view",
|
|
620
|
+
"type": "function",
|
|
621
|
+
"name": "admin_balances",
|
|
622
|
+
"inputs": [
|
|
623
|
+
{
|
|
624
|
+
"name": "i",
|
|
625
|
+
"type": "uint256"
|
|
626
|
+
}
|
|
627
|
+
],
|
|
628
|
+
"outputs": [
|
|
629
|
+
{
|
|
630
|
+
"name": "",
|
|
631
|
+
"type": "uint256"
|
|
632
|
+
}
|
|
633
|
+
]
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
"stateMutability": "nonpayable",
|
|
637
|
+
"type": "function",
|
|
638
|
+
"name": "withdraw_admin_fees",
|
|
639
|
+
"inputs": [],
|
|
640
|
+
"outputs": []
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"stateMutability": "nonpayable",
|
|
644
|
+
"type": "function",
|
|
645
|
+
"name": "donate_admin_fees",
|
|
646
|
+
"inputs": [],
|
|
647
|
+
"outputs": []
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"stateMutability": "nonpayable",
|
|
651
|
+
"type": "function",
|
|
652
|
+
"name": "kill_me",
|
|
653
|
+
"inputs": [],
|
|
654
|
+
"outputs": []
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
"stateMutability": "nonpayable",
|
|
658
|
+
"type": "function",
|
|
659
|
+
"name": "unkill_me",
|
|
660
|
+
"inputs": [],
|
|
661
|
+
"outputs": []
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
"stateMutability": "view",
|
|
665
|
+
"type": "function",
|
|
666
|
+
"name": "oracle",
|
|
667
|
+
"inputs": [],
|
|
668
|
+
"outputs": [
|
|
669
|
+
{
|
|
670
|
+
"name": "",
|
|
671
|
+
"type": "address"
|
|
672
|
+
}
|
|
673
|
+
]
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
"stateMutability": "view",
|
|
677
|
+
"type": "function",
|
|
678
|
+
"name": "coins",
|
|
679
|
+
"inputs": [
|
|
680
|
+
{
|
|
681
|
+
"name": "arg0",
|
|
682
|
+
"type": "uint256"
|
|
683
|
+
}
|
|
684
|
+
],
|
|
685
|
+
"outputs": [
|
|
686
|
+
{
|
|
687
|
+
"name": "",
|
|
688
|
+
"type": "address"
|
|
689
|
+
}
|
|
690
|
+
]
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
"stateMutability": "view",
|
|
694
|
+
"type": "function",
|
|
695
|
+
"name": "balances",
|
|
696
|
+
"inputs": [
|
|
697
|
+
{
|
|
698
|
+
"name": "arg0",
|
|
699
|
+
"type": "uint256"
|
|
700
|
+
}
|
|
701
|
+
],
|
|
702
|
+
"outputs": [
|
|
703
|
+
{
|
|
704
|
+
"name": "",
|
|
705
|
+
"type": "uint256"
|
|
706
|
+
}
|
|
707
|
+
]
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
"stateMutability": "view",
|
|
711
|
+
"type": "function",
|
|
712
|
+
"name": "fee",
|
|
713
|
+
"inputs": [],
|
|
714
|
+
"outputs": [
|
|
715
|
+
{
|
|
716
|
+
"name": "",
|
|
717
|
+
"type": "uint256"
|
|
718
|
+
}
|
|
719
|
+
]
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
"stateMutability": "view",
|
|
723
|
+
"type": "function",
|
|
724
|
+
"name": "admin_fee",
|
|
725
|
+
"inputs": [],
|
|
726
|
+
"outputs": [
|
|
727
|
+
{
|
|
728
|
+
"name": "",
|
|
729
|
+
"type": "uint256"
|
|
730
|
+
}
|
|
731
|
+
]
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
"stateMutability": "view",
|
|
735
|
+
"type": "function",
|
|
736
|
+
"name": "owner",
|
|
737
|
+
"inputs": [],
|
|
738
|
+
"outputs": [
|
|
739
|
+
{
|
|
740
|
+
"name": "",
|
|
741
|
+
"type": "address"
|
|
742
|
+
}
|
|
743
|
+
]
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
"stateMutability": "view",
|
|
747
|
+
"type": "function",
|
|
748
|
+
"name": "lp_token",
|
|
749
|
+
"inputs": [],
|
|
750
|
+
"outputs": [
|
|
751
|
+
{
|
|
752
|
+
"name": "",
|
|
753
|
+
"type": "address"
|
|
754
|
+
}
|
|
755
|
+
]
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
"stateMutability": "view",
|
|
759
|
+
"type": "function",
|
|
760
|
+
"name": "initial_A",
|
|
761
|
+
"inputs": [],
|
|
762
|
+
"outputs": [
|
|
763
|
+
{
|
|
764
|
+
"name": "",
|
|
765
|
+
"type": "uint256"
|
|
766
|
+
}
|
|
767
|
+
]
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
"stateMutability": "view",
|
|
771
|
+
"type": "function",
|
|
772
|
+
"name": "future_A",
|
|
773
|
+
"inputs": [],
|
|
774
|
+
"outputs": [
|
|
775
|
+
{
|
|
776
|
+
"name": "",
|
|
777
|
+
"type": "uint256"
|
|
778
|
+
}
|
|
779
|
+
]
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"stateMutability": "view",
|
|
783
|
+
"type": "function",
|
|
784
|
+
"name": "initial_A_time",
|
|
785
|
+
"inputs": [],
|
|
786
|
+
"outputs": [
|
|
787
|
+
{
|
|
788
|
+
"name": "",
|
|
789
|
+
"type": "uint256"
|
|
790
|
+
}
|
|
791
|
+
]
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
"stateMutability": "view",
|
|
795
|
+
"type": "function",
|
|
796
|
+
"name": "future_A_time",
|
|
797
|
+
"inputs": [],
|
|
798
|
+
"outputs": [
|
|
799
|
+
{
|
|
800
|
+
"name": "",
|
|
801
|
+
"type": "uint256"
|
|
802
|
+
}
|
|
803
|
+
]
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"stateMutability": "view",
|
|
807
|
+
"type": "function",
|
|
808
|
+
"name": "admin_actions_deadline",
|
|
809
|
+
"inputs": [],
|
|
810
|
+
"outputs": [
|
|
811
|
+
{
|
|
812
|
+
"name": "",
|
|
813
|
+
"type": "uint256"
|
|
814
|
+
}
|
|
815
|
+
]
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"stateMutability": "view",
|
|
819
|
+
"type": "function",
|
|
820
|
+
"name": "transfer_ownership_deadline",
|
|
821
|
+
"inputs": [],
|
|
822
|
+
"outputs": [
|
|
823
|
+
{
|
|
824
|
+
"name": "",
|
|
825
|
+
"type": "uint256"
|
|
826
|
+
}
|
|
827
|
+
]
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"stateMutability": "view",
|
|
831
|
+
"type": "function",
|
|
832
|
+
"name": "future_fee",
|
|
833
|
+
"inputs": [],
|
|
834
|
+
"outputs": [
|
|
835
|
+
{
|
|
836
|
+
"name": "",
|
|
837
|
+
"type": "uint256"
|
|
838
|
+
}
|
|
839
|
+
]
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
"stateMutability": "view",
|
|
843
|
+
"type": "function",
|
|
844
|
+
"name": "future_admin_fee",
|
|
845
|
+
"inputs": [],
|
|
846
|
+
"outputs": [
|
|
847
|
+
{
|
|
848
|
+
"name": "",
|
|
849
|
+
"type": "uint256"
|
|
850
|
+
}
|
|
851
|
+
]
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
"stateMutability": "view",
|
|
855
|
+
"type": "function",
|
|
856
|
+
"name": "future_owner",
|
|
857
|
+
"inputs": [],
|
|
858
|
+
"outputs": [
|
|
859
|
+
{
|
|
860
|
+
"name": "",
|
|
861
|
+
"type": "address"
|
|
862
|
+
}
|
|
863
|
+
]
|
|
864
|
+
}
|
|
865
|
+
]
|
|
@@ -16,6 +16,7 @@ exports.COINS_ARBITRUM = (0, utils_1.lowerCaseValues)({
|
|
|
16
16
|
// --- ETH ---
|
|
17
17
|
"eth": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
18
18
|
"weth": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
|
19
|
+
"wsteth": "0x5979D7b546E38E414F7E9822514be443A4800529",
|
|
19
20
|
});
|
|
20
21
|
exports.cTokensArbitrum = []; //.map((a) => a.toLowerCase());
|
|
21
22
|
exports.yTokensArbitrum = []; //.map((a) => a.toLowerCase());
|
|
@@ -14,6 +14,7 @@ exports.COINS_OPTIMISM = (0, utils_1.lowerCaseValues)({
|
|
|
14
14
|
'eth': '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
15
15
|
'weth': '0x4200000000000000000000000000000000000006',
|
|
16
16
|
'seth': '0xe405de8f52ba7559f9df3c368500b6e6ae6cee49',
|
|
17
|
+
'wsteth': '0x1f32b1c2345538c0c6f582fcb022739c4a194ebb',
|
|
17
18
|
});
|
|
18
19
|
exports.cTokensOptimism = []; //.map((a) => a.toLowerCase());
|
|
19
20
|
exports.yTokensOptimism = []; //.map((a) => a.toLowerCase());
|
|
@@ -12,6 +12,7 @@ var swap_json_3 = __importDefault(require("../abis/eursusd2/swap.json"));
|
|
|
12
12
|
var zap_json_1 = __importDefault(require("../abis/eursusd2/zap.json"));
|
|
13
13
|
var swap_json_4 = __importDefault(require("../abis/ren-arbitrum/swap.json"));
|
|
14
14
|
var gauge_child_json_1 = __importDefault(require("../abis/gauge_child.json"));
|
|
15
|
+
var swap_json_5 = __importDefault(require("../abis/wsteth/swap.json"));
|
|
15
16
|
exports.POOLS_DATA_ARBITRUM = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
16
17
|
'2pool': {
|
|
17
18
|
name: "2pool",
|
|
@@ -122,4 +123,28 @@ exports.POOLS_DATA_ARBITRUM = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
122
123
|
gauge_abi: gauge_child_json_1.default,
|
|
123
124
|
deposit_abi: zap_json_1.default,
|
|
124
125
|
},
|
|
126
|
+
wsteth: {
|
|
127
|
+
name: "wsteth",
|
|
128
|
+
full_name: "wsteth",
|
|
129
|
+
symbol: "wsteth",
|
|
130
|
+
reference_asset: 'ETH',
|
|
131
|
+
is_plain: true,
|
|
132
|
+
swap_address: '0x6eB2dc694eB516B16Dc9FBc678C60052BbdD7d80',
|
|
133
|
+
token_address: '0xDbcD16e622c95AcB2650b38eC799f76BFC557a0b',
|
|
134
|
+
gauge_address: '0x098EF55011B6B8c99845128114A9D9159777d697',
|
|
135
|
+
underlying_coins: ['ETH', 'wstETH'],
|
|
136
|
+
wrapped_coins: ['ETH', 'wstETH'],
|
|
137
|
+
underlying_coin_addresses: [
|
|
138
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
139
|
+
'0x5979D7b546E38E414F7E9822514be443A4800529',
|
|
140
|
+
],
|
|
141
|
+
wrapped_coin_addresses: [
|
|
142
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
143
|
+
'0x5979D7b546E38E414F7E9822514be443A4800529',
|
|
144
|
+
],
|
|
145
|
+
underlying_decimals: [18, 18],
|
|
146
|
+
wrapped_decimals: [18, 18],
|
|
147
|
+
swap_abi: swap_json_5.default,
|
|
148
|
+
gauge_abi: gauge_child_json_1.default,
|
|
149
|
+
},
|
|
125
150
|
});
|
|
@@ -5,7 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.POOLS_DATA_OPTIMISM = void 0;
|
|
7
7
|
var swap_json_1 = __importDefault(require("../abis/3pool-optimism/swap.json"));
|
|
8
|
+
var swap_json_2 = __importDefault(require("../abis/wsteth/swap.json"));
|
|
8
9
|
var gauge_rewards_only_json_1 = __importDefault(require("../abis/gauge_rewards_only.json"));
|
|
10
|
+
var gauge_child_json_1 = __importDefault(require("../abis/gauge_child.json"));
|
|
9
11
|
var utils_1 = require("../utils");
|
|
10
12
|
exports.POOLS_DATA_OPTIMISM = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
11
13
|
'3pool': {
|
|
@@ -34,4 +36,28 @@ exports.POOLS_DATA_OPTIMISM = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
34
36
|
swap_abi: swap_json_1.default,
|
|
35
37
|
gauge_abi: gauge_rewards_only_json_1.default,
|
|
36
38
|
},
|
|
39
|
+
wsteth: {
|
|
40
|
+
name: "wsteth",
|
|
41
|
+
full_name: "wsteth",
|
|
42
|
+
symbol: "wsteth",
|
|
43
|
+
reference_asset: 'ETH',
|
|
44
|
+
is_plain: true,
|
|
45
|
+
swap_address: '0xB90B9B1F91a01Ea22A182CD84C1E22222e39B415',
|
|
46
|
+
token_address: '0xEfDE221f306152971D8e9f181bFe998447975810',
|
|
47
|
+
gauge_address: '0xD53cCBfED6577d8dc82987e766e75E3cb73a8563',
|
|
48
|
+
underlying_coins: ['ETH', 'wstETH'],
|
|
49
|
+
wrapped_coins: ['ETH', 'wstETH'],
|
|
50
|
+
underlying_coin_addresses: [
|
|
51
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
52
|
+
'0x1f32b1c2345538c0c6f582fcb022739c4a194ebb',
|
|
53
|
+
],
|
|
54
|
+
wrapped_coin_addresses: [
|
|
55
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
56
|
+
'0x1f32b1c2345538c0c6f582fcb022739c4a194ebb',
|
|
57
|
+
],
|
|
58
|
+
underlying_decimals: [18, 18],
|
|
59
|
+
wrapped_decimals: [18, 18],
|
|
60
|
+
swap_abi: swap_json_2.default,
|
|
61
|
+
gauge_abi: gauge_child_json_1.default,
|
|
62
|
+
},
|
|
37
63
|
});
|
|
@@ -99,6 +99,7 @@ export declare class PoolTemplate {
|
|
|
99
99
|
private _calcLpTokenAmount;
|
|
100
100
|
private calcLpTokenAmount;
|
|
101
101
|
private calcLpTokenAmountWrapped;
|
|
102
|
+
cryptoSeedAmounts(amount1: number | string): Promise<string[]>;
|
|
102
103
|
depositBalancedAmounts(): Promise<string[]>;
|
|
103
104
|
depositExpected(amounts: (number | string)[]): Promise<string>;
|
|
104
105
|
depositBonus(amounts: (number | string)[]): Promise<string>;
|
|
@@ -365,7 +365,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
365
365
|
if (isDeposit === void 0) { isDeposit = true; }
|
|
366
366
|
if (useUnderlying === void 0) { useUnderlying = true; }
|
|
367
367
|
return __awaiter(_this, void 0, void 0, function () {
|
|
368
|
-
var _rates_1, N_coins,
|
|
368
|
+
var _rates_1, e_1, lpContract, _lpTotalSupply, decimals_1, amounts, seedAmounts_1, N_coins, decimals_2, calcContractAddress, calcContract, poolContract, lpContract, calls, res, _c, _totalSupply, _fee, _lpTokenAmount, balances, _d, totalSupplyBN, feeBN, lpTokenAmountBN, balancesBN, amountsBN, feesBN, i, _fees, _lpTokenFee, e_2, lpContract, _lpTotalSupply, decimals_3, amounts_1, _amounts18Decimals;
|
|
369
369
|
return __generator(this, function (_e) {
|
|
370
370
|
switch (_e.label) {
|
|
371
371
|
case 0:
|
|
@@ -378,12 +378,36 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
378
378
|
});
|
|
379
379
|
_e.label = 2;
|
|
380
380
|
case 2:
|
|
381
|
-
if (!this.isCrypto) return [3 /*break*/,
|
|
381
|
+
if (!this.isCrypto) return [3 /*break*/, 8];
|
|
382
|
+
_e.label = 3;
|
|
383
|
+
case 3:
|
|
384
|
+
_e.trys.push([3, 5, , 8]);
|
|
382
385
|
return [4 /*yield*/, this._pureCalcLpTokenAmount(_amounts, isDeposit, useUnderlying)];
|
|
383
|
-
case
|
|
384
|
-
case
|
|
386
|
+
case 4: return [2 /*return*/, _e.sent()];
|
|
387
|
+
case 5:
|
|
388
|
+
e_1 = _e.sent();
|
|
389
|
+
lpContract = curve_1.curve.contracts[this.lpToken].contract;
|
|
390
|
+
return [4 /*yield*/, lpContract.totalSupply(curve_1.curve.constantOptions)];
|
|
391
|
+
case 6:
|
|
392
|
+
_lpTotalSupply = _e.sent();
|
|
393
|
+
if (_lpTotalSupply.gt(0))
|
|
394
|
+
throw e_1; // Already seeded
|
|
395
|
+
if (this.isMeta && useUnderlying)
|
|
396
|
+
throw Error("Initial deposit for crypto meta pools must be in wrapped coins");
|
|
397
|
+
decimals_1 = useUnderlying ? this.underlyingDecimals : this.wrappedDecimals;
|
|
398
|
+
amounts = _amounts.map(function (_a, i) { return ethers_1.ethers.utils.formatUnits(_a, decimals_1[i]); });
|
|
399
|
+
return [4 /*yield*/, this.cryptoSeedAmounts(amounts[0])];
|
|
400
|
+
case 7:
|
|
401
|
+
seedAmounts_1 = _e.sent();
|
|
402
|
+
amounts.forEach(function (a, i) {
|
|
403
|
+
if (!(0, utils_1.BN)(a).eq((0, utils_1.BN)(seedAmounts_1[i])))
|
|
404
|
+
throw Error("Amounts must be = ".concat(seedAmounts_1));
|
|
405
|
+
});
|
|
406
|
+
return [2 /*return*/, (0, utils_1.parseUnits)(Math.sqrt(Number(amounts[0]) * Number(amounts[1])))];
|
|
407
|
+
case 8:
|
|
408
|
+
_e.trys.push([8, 11, , 13]);
|
|
385
409
|
N_coins = useUnderlying ? this.underlyingCoins.length : this.wrappedCoins.length;
|
|
386
|
-
|
|
410
|
+
decimals_2 = useUnderlying ? this.underlyingDecimals : this.wrappedDecimals;
|
|
387
411
|
calcContractAddress = this.isMeta && useUnderlying ? this.zap : this.address;
|
|
388
412
|
calcContract = curve_1.curve.contracts[calcContractAddress].multicallContract;
|
|
389
413
|
poolContract = curve_1.curve.contracts[this.address].multicallContract;
|
|
@@ -403,13 +427,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
403
427
|
curve_1.curve.multicallProvider.all(calls),
|
|
404
428
|
useUnderlying ? this.stats.underlyingBalances() : this.stats.wrappedBalances(),
|
|
405
429
|
])];
|
|
406
|
-
case
|
|
430
|
+
case 9:
|
|
407
431
|
res = _e.sent();
|
|
408
432
|
_c = res[0], _totalSupply = _c[0], _fee = _c[1], _lpTokenAmount = _c[2];
|
|
409
433
|
balances = res[1];
|
|
410
434
|
_d = [(0, utils_1.toBN)(_totalSupply), (0, utils_1.toBN)(_fee, 10).times(N_coins).div(4 * (N_coins - 1)), (0, utils_1.toBN)(_lpTokenAmount)], totalSupplyBN = _d[0], feeBN = _d[1], lpTokenAmountBN = _d[2];
|
|
411
435
|
balancesBN = balances.map(function (b) { return (0, utils_1.BN)(b); });
|
|
412
|
-
amountsBN = _amounts.map(function (_a, i) { return (0, utils_1.toBN)(_a,
|
|
436
|
+
amountsBN = _amounts.map(function (_a, i) { return (0, utils_1.toBN)(_a, decimals_2[i]); });
|
|
413
437
|
feesBN = Array(N_coins).fill((0, utils_1.BN)(0));
|
|
414
438
|
if (totalSupplyBN.gt(0)) {
|
|
415
439
|
for (i = 0; i < N_coins; i++) {
|
|
@@ -418,13 +442,34 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
418
442
|
feesBN[i] = feesBN[i].times(-1);
|
|
419
443
|
}
|
|
420
444
|
}
|
|
421
|
-
_fees = feesBN.map(function (fBN, i) { return (0, utils_1.fromBN)(fBN,
|
|
445
|
+
_fees = feesBN.map(function (fBN, i) { return (0, utils_1.fromBN)(fBN, decimals_2[i]); });
|
|
422
446
|
return [4 /*yield*/, this._pureCalcLpTokenAmount(_fees, !isDeposit, useUnderlying)];
|
|
423
|
-
case
|
|
447
|
+
case 10:
|
|
424
448
|
_lpTokenFee = _e.sent();
|
|
425
449
|
if (isDeposit)
|
|
426
450
|
_lpTokenFee = _lpTokenFee.mul(-1);
|
|
427
451
|
return [2 /*return*/, _lpTokenAmount.add(_lpTokenFee)];
|
|
452
|
+
case 11:
|
|
453
|
+
e_2 = _e.sent();
|
|
454
|
+
if (!isDeposit)
|
|
455
|
+
throw e_2; // Seeding is only for deposit
|
|
456
|
+
lpContract = curve_1.curve.contracts[this.lpToken].contract;
|
|
457
|
+
return [4 /*yield*/, lpContract.totalSupply(curve_1.curve.constantOptions)];
|
|
458
|
+
case 12:
|
|
459
|
+
_lpTotalSupply = _e.sent();
|
|
460
|
+
if (_lpTotalSupply.gt(0))
|
|
461
|
+
throw e_2; // Already seeded
|
|
462
|
+
decimals_3 = useUnderlying ? this.underlyingDecimals : this.wrappedDecimals;
|
|
463
|
+
amounts_1 = _amounts.map(function (_a, i) { return ethers_1.ethers.utils.formatUnits(_a, decimals_3[i]); });
|
|
464
|
+
amounts_1.forEach(function (a) {
|
|
465
|
+
if (a !== amounts_1[0])
|
|
466
|
+
throw Error("Initial deposit amounts must be the same");
|
|
467
|
+
});
|
|
468
|
+
if (_amounts[0].lte(0))
|
|
469
|
+
throw Error("Initial deposit amounts must be >0");
|
|
470
|
+
_amounts18Decimals = amounts_1.map(function (a) { return (0, utils_1.parseUnits)(a); });
|
|
471
|
+
return [2 /*return*/, _amounts18Decimals.reduce(function (_a, _b) { return _a.add(_b); })];
|
|
472
|
+
case 13: return [2 /*return*/];
|
|
428
473
|
}
|
|
429
474
|
});
|
|
430
475
|
});
|
|
@@ -877,7 +922,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
877
922
|
_this.wrappedCoinAddresses.map(function (c) { return c.toLowerCase(); });
|
|
878
923
|
var idx = lowerCaseCoinAddresses.indexOf(coinAddress.toLowerCase());
|
|
879
924
|
if (idx === -1) {
|
|
880
|
-
throw Error("There is no ".concat(coin, "
|
|
925
|
+
throw Error("There is no ".concat(coin, " among ").concat(_this.name, " pool ").concat(useUnderlying ? 'underlying' : 'wrapped', " coins"));
|
|
881
926
|
}
|
|
882
927
|
return idx;
|
|
883
928
|
};
|
|
@@ -1168,6 +1213,29 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1168
1213
|
});
|
|
1169
1214
|
};
|
|
1170
1215
|
// ---------------- DEPOSIT ----------------
|
|
1216
|
+
PoolTemplate.prototype.cryptoSeedAmounts = function (amount1) {
|
|
1217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1218
|
+
var decimals, amount1BN, priceScaleBN, _c;
|
|
1219
|
+
return __generator(this, function (_d) {
|
|
1220
|
+
switch (_d.label) {
|
|
1221
|
+
case 0:
|
|
1222
|
+
if (!this.isCrypto)
|
|
1223
|
+
throw Error("cryptoSeedAmounts method doesn't exist for stable pools");
|
|
1224
|
+
decimals = this.isMeta ? this.wrappedDecimals : this.underlyingDecimals;
|
|
1225
|
+
if (decimals.length > 2)
|
|
1226
|
+
throw Error("cryptoSeedAmounts method doesn't exist for pools with N coins > 2");
|
|
1227
|
+
amount1BN = (0, utils_1.BN)(amount1);
|
|
1228
|
+
if (amount1BN.lte(0))
|
|
1229
|
+
throw Error("Initial deposit amounts must be > 0");
|
|
1230
|
+
_c = utils_1.toBN;
|
|
1231
|
+
return [4 /*yield*/, curve_1.curve.contracts[this.address].contract.price_scale(curve_1.curve.constantOptions)];
|
|
1232
|
+
case 1:
|
|
1233
|
+
priceScaleBN = _c.apply(void 0, [_d.sent()]);
|
|
1234
|
+
return [2 /*return*/, [amount1BN.toFixed(decimals[0]), amount1BN.div(priceScaleBN).toFixed(decimals[1])]];
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
});
|
|
1238
|
+
};
|
|
1171
1239
|
PoolTemplate.prototype.depositBalancedAmounts = function () {
|
|
1172
1240
|
return __awaiter(this, void 0, void 0, function () {
|
|
1173
1241
|
return __generator(this, function (_c) {
|
|
@@ -35,36 +35,44 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
42
|
exports.depositWrappedBalancedAmountsCryptoMixin = exports.depositWrappedBalancedAmountsMixin = exports.depositBalancedAmountsCryptoMixin = exports.depositBalancedAmountsMixin = void 0;
|
|
43
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
44
|
+
var utils_1 = require("../../utils");
|
|
40
45
|
function _depositBalancedAmounts(poolBalances, walletBalances, decimals) {
|
|
41
|
-
var
|
|
42
|
-
var
|
|
46
|
+
var poolBalancesBN = poolBalances.map(utils_1.BN);
|
|
47
|
+
var walletBalancesBN = walletBalances.map(utils_1.BN);
|
|
48
|
+
var poolTotalLiquidityBN = poolBalancesBN.reduce(function (a, b) { return a.plus(b); });
|
|
49
|
+
var poolBalancesRatiosBN = poolBalancesBN.map(function (b) { return b.div(poolTotalLiquidityBN); });
|
|
43
50
|
// Cross factors for each wallet balance used as reference to see the
|
|
44
51
|
// max that can be used according to the lowest relative wallet balance
|
|
45
|
-
var
|
|
46
|
-
var
|
|
52
|
+
var balancedAmountsForEachScenarioBN = walletBalancesBN.map(function (_, i) { return (walletBalancesBN.map(function (_, j) { return (poolBalancesRatiosBN[j].times(walletBalancesBN[i]).div(poolBalancesRatiosBN[i])); })); });
|
|
53
|
+
var firstCoinBalanceForEachScenarioBN = balancedAmountsForEachScenarioBN.map(function (_a) {
|
|
47
54
|
var a = _a[0];
|
|
48
55
|
return a;
|
|
49
56
|
});
|
|
50
|
-
var
|
|
51
|
-
return
|
|
57
|
+
var scenarioWithLowestBalancesBN = firstCoinBalanceForEachScenarioBN.map(String).indexOf(bignumber_js_1.default.min.apply(bignumber_js_1.default, firstCoinBalanceForEachScenarioBN).toString());
|
|
58
|
+
return balancedAmountsForEachScenarioBN[scenarioWithLowestBalancesBN].map(function (a, i) { return a.toFixed(decimals[i]); });
|
|
52
59
|
}
|
|
53
60
|
// @ts-ignore
|
|
54
61
|
exports.depositBalancedAmountsMixin = {
|
|
55
62
|
depositBalancedAmounts: function () {
|
|
56
63
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var poolBalances, walletBalances, _a, _b;
|
|
64
|
+
var poolBalances, walletBalances, _a, _b, balancedAmountsBN;
|
|
58
65
|
return __generator(this, function (_c) {
|
|
59
66
|
switch (_c.label) {
|
|
60
67
|
case 0: return [4 /*yield*/, this.stats.underlyingBalances()];
|
|
61
68
|
case 1:
|
|
62
|
-
poolBalances =
|
|
69
|
+
poolBalances = _c.sent();
|
|
63
70
|
_b = (_a = Object).values;
|
|
64
71
|
return [4 /*yield*/, this.walletUnderlyingCoinBalances()];
|
|
65
72
|
case 2:
|
|
66
|
-
walletBalances = _b.apply(_a, [_c.sent()])
|
|
67
|
-
|
|
73
|
+
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
74
|
+
balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
75
|
+
return [2 /*return*/, balancedAmountsBN.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)(b), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
68
76
|
}
|
|
69
77
|
});
|
|
70
78
|
});
|
|
@@ -75,23 +83,23 @@ exports.depositBalancedAmountsCryptoMixin = {
|
|
|
75
83
|
depositBalancedAmounts: function () {
|
|
76
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
77
85
|
var poolBalances, walletBalances, _a, _b, prices, poolBalancesUSD, walletBalancesUSD, balancedAmountsUSD;
|
|
86
|
+
var _this = this;
|
|
78
87
|
return __generator(this, function (_c) {
|
|
79
88
|
switch (_c.label) {
|
|
80
89
|
case 0: return [4 /*yield*/, this.stats.underlyingBalances()];
|
|
81
90
|
case 1:
|
|
82
|
-
poolBalances =
|
|
91
|
+
poolBalances = _c.sent();
|
|
83
92
|
_b = (_a = Object).values;
|
|
84
93
|
return [4 /*yield*/, this.walletUnderlyingCoinBalances()];
|
|
85
94
|
case 2:
|
|
86
|
-
walletBalances = _b.apply(_a, [_c.sent()])
|
|
95
|
+
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
87
96
|
return [4 /*yield*/, this._underlyingPrices()];
|
|
88
97
|
case 3:
|
|
89
98
|
prices = _c.sent();
|
|
90
|
-
poolBalancesUSD = poolBalances.map(function (b, i) { return b
|
|
91
|
-
walletBalancesUSD = walletBalances.map(function (b, i) { return b
|
|
99
|
+
poolBalancesUSD = poolBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
100
|
+
walletBalancesUSD = walletBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
92
101
|
balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.underlyingDecimals);
|
|
93
|
-
|
|
94
|
-
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return String(Math.min(Number(b) / prices[i], poolBalances[i])); })];
|
|
102
|
+
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)((0, utils_1.BN)(b).div(prices[i]).toFixed(_this.underlyingDecimals[i])), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
95
103
|
}
|
|
96
104
|
});
|
|
97
105
|
});
|
|
@@ -101,17 +109,18 @@ exports.depositBalancedAmountsCryptoMixin = {
|
|
|
101
109
|
exports.depositWrappedBalancedAmountsMixin = {
|
|
102
110
|
depositWrappedBalancedAmounts: function () {
|
|
103
111
|
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var poolBalances, walletBalances, _a, _b;
|
|
112
|
+
var poolBalances, walletBalances, _a, _b, balancedAmountsBN;
|
|
105
113
|
return __generator(this, function (_c) {
|
|
106
114
|
switch (_c.label) {
|
|
107
115
|
case 0: return [4 /*yield*/, this.stats.wrappedBalances()];
|
|
108
116
|
case 1:
|
|
109
|
-
poolBalances =
|
|
117
|
+
poolBalances = _c.sent();
|
|
110
118
|
_b = (_a = Object).values;
|
|
111
119
|
return [4 /*yield*/, this.walletWrappedCoinBalances()];
|
|
112
120
|
case 2:
|
|
113
|
-
walletBalances = _b.apply(_a, [_c.sent()])
|
|
114
|
-
|
|
121
|
+
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
122
|
+
balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
123
|
+
return [2 /*return*/, balancedAmountsBN.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)(b), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
115
124
|
}
|
|
116
125
|
});
|
|
117
126
|
});
|
|
@@ -122,6 +131,7 @@ exports.depositWrappedBalancedAmountsCryptoMixin = {
|
|
|
122
131
|
depositWrappedBalancedAmounts: function () {
|
|
123
132
|
return __awaiter(this, void 0, void 0, function () {
|
|
124
133
|
var poolBalances, walletBalances, _a, _b, prices, poolBalancesUSD, walletBalancesUSD, balancedAmountsUSD;
|
|
134
|
+
var _this = this;
|
|
125
135
|
return __generator(this, function (_c) {
|
|
126
136
|
switch (_c.label) {
|
|
127
137
|
case 0: return [4 /*yield*/, this.stats.wrappedBalances()];
|
|
@@ -134,10 +144,10 @@ exports.depositWrappedBalancedAmountsCryptoMixin = {
|
|
|
134
144
|
return [4 /*yield*/, this._wrappedPrices()];
|
|
135
145
|
case 3:
|
|
136
146
|
prices = _c.sent();
|
|
137
|
-
poolBalancesUSD = poolBalances.map(function (b, i) { return b
|
|
138
|
-
walletBalancesUSD = walletBalances.map(function (b, i) { return b
|
|
147
|
+
poolBalancesUSD = poolBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
148
|
+
walletBalancesUSD = walletBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
139
149
|
balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.wrappedDecimals);
|
|
140
|
-
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return
|
|
150
|
+
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)((0, utils_1.BN)(b).div(prices[i]).toFixed(_this.wrappedDecimals[i])), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
141
151
|
}
|
|
142
152
|
});
|
|
143
153
|
});
|
|
@@ -141,7 +141,7 @@ exports.withdrawOneCoinWrappedBonusMixin = {
|
|
|
141
141
|
return [4 /*yield*/, this.withdrawOneCoinWrappedExpected(lpTokenAmount, coin)];
|
|
142
142
|
case 3:
|
|
143
143
|
coinAmount = _d.apply(void 0, [_e.sent()]);
|
|
144
|
-
totalValue = coinAmount * prices[this._getCoinIdx(coin)];
|
|
144
|
+
totalValue = coinAmount * prices[this._getCoinIdx(coin, false)];
|
|
145
145
|
return [4 /*yield*/, this.withdrawWrappedExpected(lpTokenAmount)];
|
|
146
146
|
case 4:
|
|
147
147
|
balancedAmounts = _e.sent();
|
|
@@ -197,8 +197,8 @@ exports.withdrawOneCoinWrappedCryptoBonusMixin = {
|
|
|
197
197
|
_e.label = 2;
|
|
198
198
|
case 2: return [4 /*yield*/, this._wrappedPrices()];
|
|
199
199
|
case 3:
|
|
200
|
-
prices = (_e.sent()).map(function (p, i) { return i ===
|
|
201
|
-
coinPrice = prices[this._getCoinIdx(coin)];
|
|
200
|
+
prices = (_e.sent()).map(function (p, i, arr) { return i === arr.length - 1 ? p * vp : p; });
|
|
201
|
+
coinPrice = prices[this._getCoinIdx(coin, false)];
|
|
202
202
|
_d = Number;
|
|
203
203
|
return [4 /*yield*/, this.withdrawOneCoinWrappedExpected(lpTokenAmount, coin)];
|
|
204
204
|
case 4:
|