@@ -51,6 +51,8 @@ export default class CFDAPI {
51
51
* @param leverage The leverage (between 0.01 and 5.00)
52
52
* @param isBuyer Creator wants to be contract buyer or seller
53
53
* @param creatorProxy Proxy of creator of the new CFD
54
+ * @param {Number } gasLimit How much gas we are willing to spent
55
+ * @param {Number } gasPrice Price of the gas
54
56
*
55
57
* @return Promise resolving to a new cfd contract instance on
56
58
* success or a promise failure if the tx failed
@@ -61,7 +63,9 @@ export default class CFDAPI {
61
63
notionalAmountDai ,
62
64
leverage ,
63
65
isBuyer ,
64
- creatorProxy
66
+ creatorProxy ,
67
+ gasLimit ,
68
+ gasPrice
65
69
) {
66
70
assertBigNumberOrString ( strikePrice )
67
71
assertBigNumberOrString ( notionalAmountDai )
@@ -85,7 +89,9 @@ export default class CFDAPI {
85
89
strikePrice : strikePriceBN ,
86
90
notional : notionalBN . toFixed ( ) ,
87
91
isBuyer,
88
- value
92
+ value,
93
+ gasLimit,
94
+ gasPrice
89
95
} )
90
96
}
91
97
@@ -99,6 +105,8 @@ export default class CFDAPI {
99
105
* @param leverage The leverage (between 0.01 and 5.00)
100
106
* @param isBuyer Creator wants to be contract buyer or seller
101
107
* @param creatorProxy Proxy of creator of the new CFD
108
+ * @param {Number } gasLimit How much gas we are willing to spent
109
+ * @param {Number } gasPrice Price of the gas
102
110
*
103
111
* @return Promise resolving to a new cfd contract instance on
104
112
* success or a promise failure if the tx failed
@@ -109,7 +117,9 @@ export default class CFDAPI {
109
117
notionalAmountDai ,
110
118
leverage ,
111
119
isBuyer ,
112
- creatorProxy
120
+ creatorProxy ,
121
+ gasLimit ,
122
+ gasPrice
113
123
) {
114
124
assertBigNumberOrString ( strikePrice )
115
125
assertBigNumberOrString ( notionalAmountDai )
@@ -141,7 +151,9 @@ export default class CFDAPI {
141
151
strikePrice : strikePriceBN ,
142
152
notional : notionalBN . toFixed ( ) ,
143
153
isBuyer,
144
- valueETH
154
+ valueETH,
155
+ gasLimit,
156
+ gasPrice
145
157
} )
146
158
}
147
159
@@ -151,11 +163,11 @@ export default class CFDAPI {
151
163
* @return Promise resolving to success with tx details or reject depending
152
164
* on the outcome.
153
165
*/
154
- async deposit ( cfdAddress , depositAccountProxy , amount ) {
166
+ async deposit ( cfdAddress , depositAccountProxy , amount , gasLimit , gasPrice ) {
155
167
const cfd = getContract ( cfdAddress , this . web3 )
156
168
const value = safeValue ( amount )
157
169
158
- await this . proxyApi . proxyDeposit ( depositAccountProxy , cfd , value )
170
+ await this . proxyApi . proxyDeposit ( depositAccountProxy , cfd , value , gasLimit , gasPrice )
159
171
}
160
172
161
173
/**
@@ -221,10 +233,12 @@ export default class CFDAPI {
221
233
* @param cfdAddress Address of a deployed CFD
222
234
* @param accountProxy Proxy account making the request
223
235
* @param desiredStrikePrice User wants this strike price value for his CFD
236
+ * @param {Number } gasLimit How much gas we are willing to spent
237
+ * @param {Number } gasPrice Price of the gas
224
238
* @return Promise resolving to success with tx details or reject depending
225
239
* on the outcome.
226
240
*/
227
- async changeStrikePriceCFD ( cfdAddress , accountProxy , desiredStrikePrice ) {
241
+ async changeStrikePriceCFD ( cfdAddress , accountProxy , desiredStrikePrice , gasLimit , gasPrice ) {
228
242
const cfd = getContract ( cfdAddress , this . web3 )
229
243
230
244
if (
@@ -246,7 +260,9 @@ export default class CFDAPI {
246
260
return this . proxyApi . proxyChangeStrikePrice (
247
261
accountProxy ,
248
262
cfd ,
249
- desiredStrikePriceBN
263
+ desiredStrikePriceBN ,
264
+ gasLimit ,
265
+ gasPrice
250
266
)
251
267
}
252
268
@@ -257,14 +273,18 @@ export default class CFDAPI {
257
273
* @param desiredStrikePrice Sellers wants to sell at this strike price.
258
274
* @param timeLimit Sale expired after this time (UNIX epoch seconds).
259
275
* Defaults to 0 for no limit.
276
+ * @param {Number } gasLimit How much gas we are willing to spent
277
+ * @param {Number } gasPrice Price of the gas
260
278
* @return Promise resolving to success with tx details or reject depending
261
279
* on the outcome.
262
280
*/
263
281
async sellCFD (
264
282
cfdAddress ,
265
283
sellerAccountProxy ,
266
284
desiredStrikePrice ,
267
- timeLimit = 0
285
+ timeLimit = 0 ,
286
+ gasLimit ,
287
+ gasPrice
268
288
) {
269
289
const cfd = getContract ( cfdAddress , this . web3 )
270
290
@@ -290,7 +310,9 @@ export default class CFDAPI {
290
310
sellerAccountProxy ,
291
311
cfd ,
292
312
desiredStrikePriceBN ,
293
- timeLimit
313
+ timeLimit ,
314
+ gasLimit ,
315
+ gasPrice
294
316
)
295
317
}
296
318
@@ -300,75 +322,87 @@ export default class CFDAPI {
300
322
* @param buyerAccountProxy, The proxy address of the account who is buying
301
323
* @param valueToBuy, The amount the user has to pay (DAI)
302
324
* @param isBuyerSide, Boolean if the user is buyer or seller
325
+ * @param {Number } gasLimit How much gas we are willing to spent
326
+ * @param {Number } gasPrice Price of the gas
303
327
* @return Promise resolving to success with tx details or reject depending
304
328
* on the outcome.
305
329
*/
306
- async buyCFD ( cfdAddress , buyerAccountProxy , valueToBuy , isBuyerSide ) {
330
+ async buyCFD ( cfdAddress , buyerAccountProxy , valueToBuy , isBuyerSide , gasLimit , gasPrice ) {
307
331
const cfd = getContract ( cfdAddress , this . web3 )
308
332
const valueToBuyBN = new BigNumber ( valueToBuy )
309
333
const value = safeValue ( valueToBuyBN )
310
- return this . proxyApi . proxyBuy ( buyerAccountProxy , cfd , isBuyerSide , value )
334
+ return this . proxyApi . proxyBuy ( buyerAccountProxy , cfd , isBuyerSide , value , gasLimit , gasPrice )
311
335
}
312
336
313
337
/**
314
338
* Tansfer the position in a contract to another account.
315
339
* @param cfdAddress, Address of the deployed CFD
316
340
* @param fromAccountProxy, Account who is transferring the position
317
341
* @param toAccount, Account who the position gets transferred too
342
+ * @param {Number } gasLimit How much gas we are willing to spent
343
+ * @param {Number } gasPrice Price of the gas
318
344
* @return Promise resolving to success with tx details or reject depending
319
345
* on the outcome.
320
346
*/
321
- async transferPosition ( cfdAddress , fromAccountProxy , toAccount ) {
347
+ async transferPosition ( cfdAddress , fromAccountProxy , toAccount , gasLimit , gasPrice ) {
322
348
const cfd = getContract ( cfdAddress , this . web3 )
323
- return this . proxyApi . proxyTransferPosition ( fromAccountProxy , cfd , toAccount )
349
+ return this . proxyApi . proxyTransferPosition ( fromAccountProxy , cfd , toAccount , gasLimit , gasPrice )
324
350
}
325
351
326
352
/**
327
353
* Invoke liquidateMutual functionality.
328
354
* @param cfdAddress, Address of the deployed CFD
329
355
* @param accountProxy, The proxy address of the account who is terminating
356
+ * @param {Number } gasLimit How much gas we are willing to spent
357
+ * @param {Number } gasPrice Price of the gas
330
358
* @return Promise resolving to success with tx details or reject depending
331
359
* on the outcome.
332
360
*/
333
- async liquidateMutual ( cfdAddress , accountProxy ) {
361
+ async liquidateMutual ( cfdAddress , accountProxy , gasLimit , gasPrice ) {
334
362
const cfd = getContract ( cfdAddress , this . web3 )
335
- return this . proxyApi . proxyLiquidateMutual ( accountProxy , cfd )
363
+ return this . proxyApi . proxyLiquidateMutual ( accountProxy , cfd , gasLimit , gasPrice )
336
364
}
337
365
338
366
/**
339
367
* Party cancels liquidateMutual (before second party calls to agree)
340
368
* @param cfdAddress, Address of the deployed CFD
341
369
* @param accountProxy, The proxy address of the account who is terminating
370
+ * @param {Number } gasLimit How much gas we are willing to spent
371
+ * @param {Number } gasPrice Price of the gas
342
372
* @return Promise resolving to success with tx details or reject depending
343
373
* on the outcome.
344
374
*/
345
- async liquidateMutualCancel ( cfdAddress , accountProxy ) {
375
+ async liquidateMutualCancel ( cfdAddress , accountProxy , gasLimit , gasPrice ) {
346
376
const cfd = getContract ( cfdAddress , this . web3 )
347
- return this . proxyApi . proxyLiquidateMutualCancel ( accountProxy , cfd )
377
+ return this . proxyApi . proxyLiquidateMutualCancel ( accountProxy , cfd , gasLimit , gasPrice )
348
378
}
349
379
350
380
/**
351
381
* Force liquidation a contract
352
382
* @param cfdAddress, Address of the deployed CFD
353
383
* @param accountProxy, The proxy address of the account who is terminating
384
+ * @param {Number } gasLimit How much gas we are willing to spent
385
+ * @param {Number } gasPrice Price of the gas
354
386
* @return Promise resolving to success with tx details or reject depending
355
387
* on the outcome.
356
388
*/
357
- async forceTerminate ( cfdAddress , accountProxy ) {
389
+ async forceTerminate ( cfdAddress , accountProxy , gasLimit , gasPrice ) {
358
390
const cfd = getContract ( cfdAddress , this . web3 )
359
- return this . proxyApi . proxyForceTerminate ( accountProxy , cfd )
391
+ return this . proxyApi . proxyForceTerminate ( accountProxy , cfd , gasLimit , gasPrice )
360
392
}
361
393
362
394
/**
363
395
* Cancel a newly created contract (must be non initialized)
364
396
* @param cfdAddress, Address of the deployed CFD
365
397
* @param accountProxy, The address of the proxy account who is canceling
398
+ * @param {Number } gasLimit How much gas we are willing to spent
399
+ * @param {Number } gasPrice Price of the gas
366
400
* @return Promise resolving to success with tx details or reject depending
367
401
* on the outcome.
368
402
*/
369
- async cancelNew ( cfdAddress , accountProxy ) {
403
+ async cancelNew ( cfdAddress , accountProxy , gasLimit , gasPrice ) {
370
404
const cfd = getContract ( cfdAddress , this . web3 )
371
- return this . proxyApi . proxyCancelNew ( accountProxy , cfd )
405
+ return this . proxyApi . proxyCancelNew ( accountProxy , cfd , gasLimit , gasPrice )
372
406
}
373
407
374
408
/**
@@ -378,21 +412,23 @@ export default class CFDAPI {
378
412
* @return Promise resolving to success with tx details or reject depending
379
413
* on the outcome.
380
414
*/
381
- async cancelSale ( cfdAddress , accountProxy ) {
415
+ async cancelSale ( cfdAddress , accountProxy , gasLimit , gasPrice ) {
382
416
const cfd = getContract ( cfdAddress , this . web3 )
383
- return this . proxyApi . proxySellCancel ( accountProxy , cfd )
417
+ return this . proxyApi . proxySellCancel ( accountProxy , cfd , gasLimit , gasPrice )
384
418
}
385
419
386
420
/**
387
421
* Upgrade a contract to the latest deployed version
388
422
* @param cfdAddress, Address of the deployed CFD
389
423
* @param accountProxy, The address of the account who is upgrading
424
+ * @param {Number } gasLimit How much gas we are willing to spent
425
+ * @param {Number } gasPrice Price of the gas
390
426
* @return Promise resolving to success with tx details or reject depending
391
427
* on the outcome.
392
428
*/
393
- async upgradeCFD ( cfdAddress , accountProxy ) {
429
+ async upgradeCFD ( cfdAddress , accountProxy , gasLimit , gasPrice ) {
394
430
const cfd = getContract ( cfdAddress , this . web3 )
395
- return this . proxyApi . proxyUpgrade ( accountProxy , cfd )
431
+ return this . proxyApi . proxyUpgrade ( accountProxy , cfd , gasLimit , gasPrice )
396
432
}
397
433
398
434
/**
@@ -442,10 +478,12 @@ export default class CFDAPI {
442
478
* @param cfdAddress Address of a deployed CFD
443
479
* @param selleraccountProxy Account settling the position.
444
480
* @param desiredStrikePrice Sellers wants to sell at this strike price.
481
+ * @param {Number } gasLimit How much gas we are willing to spent
482
+ * @param {Number } gasPrice Price of the gas
445
483
* @return Promise resolving to success with tx details or reject depending
446
484
* on the outcome.
447
485
*/
448
- async changeSaleCFD ( cfdAddress , sellerAccountProxy , desiredStrikePrice ) {
486
+ async changeSaleCFD ( cfdAddress , sellerAccountProxy , desiredStrikePrice , gasLimit , gasPrice ) {
449
487
const cfd = getContract ( cfdAddress , this . web3 )
450
488
451
489
if (
@@ -469,7 +507,9 @@ export default class CFDAPI {
469
507
return this . proxyApi . proxySellUpdate (
470
508
sellerAccountProxy ,
471
509
cfd ,
472
- desiredStrikePriceBN
510
+ desiredStrikePriceBN ,
511
+ gasLimit ,
512
+ gasPrice
473
513
)
474
514
}
475
515
@@ -478,8 +518,10 @@ export default class CFDAPI {
478
518
* @param cfdAddress, Address of the deployed CFD
479
519
* @param accountProxy, The address of the account who is topuping
480
520
* @param valueToAdd, The amount the user wants to add (DAI)
521
+ * @param {Number } gasLimit How much gas we are willing to spent
522
+ * @param {Number } gasPrice Price of the gas
481
523
*/
482
- async topup ( cfdAddress , accountProxy , valueToAdd ) {
524
+ async topup ( cfdAddress , accountProxy , valueToAdd , gasLimit , gasPrice ) {
483
525
const cfd = getContract ( cfdAddress , this . web3 )
484
526
485
527
if (
@@ -495,16 +537,18 @@ export default class CFDAPI {
495
537
}
496
538
497
539
const value = safeValue ( valueToAdd )
498
- return this . proxyApi . proxyTopup ( accountProxy , cfd , value )
540
+ return this . proxyApi . proxyTopup ( accountProxy , cfd , value , gasLimit , gasPrice )
499
541
}
500
542
501
543
/**
502
544
* Withdraw the amount from a CFD
503
545
* @param cfdAddress, Address of the deployed CFD
504
546
* @param accountProxy, The address of the account who is withdrawing
505
547
* @param valueToWithdraw, The amount the user wants to withdraw (DAI)
548
+ * @param {Number } gasLimit How much gas we are willing to spent
549
+ * @param {Number } gasPrice Price of the gas
506
550
*/
507
- async withdraw ( cfdAddress , accountProxy , valueToWithdraw ) {
551
+ async withdraw ( cfdAddress , accountProxy , valueToWithdraw , gasLimit , gasPrice ) {
508
552
const cfd = getContract ( cfdAddress , this . web3 )
509
553
if (
510
554
( await cfd . methods
@@ -519,7 +563,7 @@ export default class CFDAPI {
519
563
}
520
564
521
565
const value = safeValue ( valueToWithdraw )
522
- return this . proxyApi . proxyWithdraw ( accountProxy , cfd , value )
566
+ return this . proxyApi . proxyWithdraw ( accountProxy , cfd , value , gasLimit , gasPrice )
523
567
}
524
568
525
569
/**
0 commit comments