Skip to content

Commit b45128c

Browse files
author
Julien
committed
Add a function to remove a market + Fix issues with deleted markets + Update gas limit values
1 parent 5333585 commit b45128c

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

src/infura/api-infura.js

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,21 @@ const getMarketsFromEventLogs = (
3333
return undefined
3434
}
3535
const bytesId = market.raw.topics[1]
36-
const strId = await self.marketIdBytesToStr(bytesId)
37-
return self.priceFeeds.methods
38-
.isMarketActive(bytesId)
39-
.call()
40-
.then(active => {
41-
return { bytesId, strId, active }
42-
})
36+
try {
37+
const strId = await self.marketIdBytesToStr(bytesId)
38+
return self.priceFeeds.methods
39+
.isMarketActive(bytesId)
40+
.call()
41+
.then(active => {
42+
return { bytesId, strId, active }
43+
})
44+
} catch(err) {
45+
return undefined
46+
}
4347
})
44-
).then(onSuccessCallback)
48+
).then((mappedMarkets) => {
49+
onSuccessCallback(mappedMarkets.filter((m) => m != undefined))
50+
})
4551
},
4652
err => {
4753
onErrorCallback(err)
@@ -117,6 +123,32 @@ export default class API {
117123
})
118124
}
119125

126+
/**
127+
* Remove a kyber market feed.
128+
* @param marketId Market ID for market (eg. "0x1234...")
129+
* @return Promise resolving to the transaction receipt
130+
*/
131+
async removeMarketKyber(marketId) {
132+
const self = this
133+
return new Promise(function(resolve, reject) {
134+
// Add the market
135+
self.priceFeedsKyber.methods
136+
.removeMarket(marketId)
137+
.send({
138+
from: self.config.ownerAccountAddr,
139+
gas: addMarketGasLimit
140+
})
141+
.once('receipt', function(receipt) {
142+
// Transaction has been mined
143+
resolve(receipt)
144+
})
145+
.on('error', function(error) {
146+
// Error
147+
reject(error)
148+
})
149+
})
150+
}
151+
120152
/**
121153
* Pop the next value in the queue, and start the transaction
122154
*/

src/infura/proxy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export default class Proxy {
308308
return this.proxyTx(proxy, 'sellCancel', [cfd.options.address], gasLimit, gasPrice, privateKey)
309309
}
310310

311-
async proxyBuy(proxy, cfd, buyBuyerSide, buyValue, gasLimit = 500000, gasPrice = undefined, privateKey = undefined) {
311+
async proxyBuy(proxy, cfd, buyBuyerSide, buyValue, gasLimit = 800000, gasPrice = undefined, privateKey = undefined) {
312312
return this.proxyTx(proxy, 'buy', [
313313
cfd.options.address,
314314
this.daiToken.options.address,
@@ -325,7 +325,7 @@ export default class Proxy {
325325
], gasLimit, gasPrice, privateKey)
326326
}
327327

328-
async proxyWithdraw(proxy, cfd, value, gasLimit = 350000, gasPrice = undefined, privateKey = undefined) {
328+
async proxyWithdraw(proxy, cfd, value, gasLimit = 700000, gasPrice = undefined, privateKey = undefined) {
329329
return this.proxyTx(proxy, 'withdraw', [
330330
cfd.options.address,
331331
value.toString()
@@ -336,15 +336,15 @@ export default class Proxy {
336336
return this.proxyTx(proxy, 'cancelNew', [cfd.options.address], gasLimit, gasPrice, privateKey)
337337
}
338338

339-
async proxyLiquidateMutual(proxy, cfd, gasLimit = 500000, gasPrice = undefined, privateKey = undefined) {
339+
async proxyLiquidateMutual(proxy, cfd, gasLimit = 700000, gasPrice = undefined, privateKey = undefined) {
340340
return this.proxyTx(proxy, 'liquidateMutual', [cfd.options.address], gasLimit, gasPrice, privateKey)
341341
}
342342

343343
async proxyLiquidateMutualCancel(proxy, cfd, gasLimit = 150000, gasPrice = undefined, privateKey = undefined) {
344344
return this.proxyTx(proxy, 'liquidateMutualCancel', [cfd.options.address], gasLimit, gasPrice, privateKey)
345345
}
346346

347-
async proxyForceTerminate(proxy, cfd, gasLimit = 400000, gasPrice = undefined, privateKey = undefined) {
347+
async proxyForceTerminate(proxy, cfd, gasLimit = 700000, gasPrice = undefined, privateKey = undefined) {
348348
return this.proxyTx(proxy, 'forceTerminate', [cfd.options.address], gasLimit, gasPrice, privateKey)
349349
}
350350

0 commit comments

Comments
 (0)