diff --git a/README.md b/README.md index 9c51279..6d9fc46 100644 --- a/README.md +++ b/README.md @@ -91,11 +91,12 @@ Example: ###### Chainlink With chainlink you have access to price oracles via blockchain. The requests are read calls to a smart contract. The public ethers provider might be too slow for a higher number of pairs or at times of high demand. Therefore, it might be needed to have access to an Infura account (100000 Requests/Day for free). There you can get an endpoint for your market maker (like https://mainnet.infura.io/v3/...), You can add this with the `infuraUrl` field in `config.json`, like this: ``` -.... -"infuraUrl": "https://mainnet.infura.io/v3/xxxxxxxx", -"zigzagChainId": 1, -"zigzagWsUrl": "wss://zigzag-exchange.herokuapp.com", -.... +"ETH-USDC": { + "infuraUrl": "https://mainnet.infura.io/v3/xxxxxxxx", + "zigzagChainId": 1, + "zigzagWsUrl": "wss://zigzag-exchange.herokuapp.com", + .... +} ``` You can get the available market contracts [here.](https://docs.chain.link/docs/ethereum-addresses/)Add those to you pair config as "chainlink:
", like this: ``` @@ -114,6 +115,7 @@ With constant mode, you can set a fixed price to market make. The bot will not c "side": "d", "priceFeedPrimary": "constant:1", "priceFeedSecondary": null, + .... } ``` diff --git a/marketmaker.js b/marketmaker.js index 76ee416..56cb96f 100644 --- a/marketmaker.js +++ b/marketmaker.js @@ -488,9 +488,6 @@ async function setupPriceFeeds() { for (let market in MM_CONFIG.pairs) { const pairConfig = MM_CONFIG.pairs[market]; if(!pairConfig.active) { continue; } - const primaryPriceFeed = pairConfig.priceFeedPrimary; - const secondaryPriceFeed = pairConfig.priceFeedSecondary; - // This is needed to make the price feed backwards compatalbe with old constant mode: // "DYDX-USDC": { // "mode": "constant", @@ -499,6 +496,8 @@ async function setupPriceFeeds() { const initPrice = pairConfig.initPrice; pairConfig['priceFeedPrimary'] = "constant:" + initPrice.toString(); } + const primaryPriceFeed = pairConfig.priceFeedPrimary; + const secondaryPriceFeed = pairConfig.priceFeedSecondary; [primaryPriceFeed, secondaryPriceFeed].forEach(priceFeed => { if(!priceFeed) { return; } const [provider, id] = priceFeed.split(':'); @@ -518,7 +517,7 @@ async function setupPriceFeeds() { } }); } - if(chainlinkSetup.length) await chainlinkSetup(chainlink); + if(chainlink.length) await chainlinkSetup(chainlink); if(cryptowatch.length) await cryptowatchWsSetup(cryptowatch); console.log(PRICE_FEEDS); @@ -607,7 +606,6 @@ async function chainlinkUpdate() { })); } -const CLIENT_ID = (Math.random() * 100000).toString(16); function indicateLiquidity (pairs = MM_CONFIG.pairs) { for(const marketId in pairs) { const mmConfig = pairs[marketId]; @@ -657,7 +655,7 @@ function indicateLiquidity (pairs = MM_CONFIG.pairs) { liquidity.push(["s", sellPrice, maxSellSize / splits, expires]); } } - const msg = { op: "indicateliq2", args: [CHAIN_ID, marketId, liquidity, CLIENT_ID] }; + const msg = { op: "indicateliq2", args: [CHAIN_ID, marketId, liquidity] }; try { zigzagws.send(JSON.stringify(msg)); } catch (e) { @@ -668,7 +666,7 @@ function indicateLiquidity (pairs = MM_CONFIG.pairs) { } function cancelLiquidity (chainId, marketId) { - const msg = { op: "indicateliq2", args: [chainId, marketId, [], CLIENT_ID] }; + const msg = { op: "indicateliq2", args: [chainId, marketId, []] }; try { zigzagws.send(JSON.stringify(msg)); } catch (e) {