mirror of
https://github.com/ZigZagExchange/zksync-lite-market-maker.git
synced 2025-12-18 23:54:22 +01:00
Merge pull request #30 from TrooperCrypto/master
CLIENT_ID is handled by backend now
This commit is contained in:
12
README.md
12
README.md
@@ -91,11 +91,12 @@ Example:
|
|||||||
###### Chainlink
|
###### 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:
|
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:
|
||||||
```
|
```
|
||||||
....
|
"ETH-USDC": {
|
||||||
"infuraUrl": "https://mainnet.infura.io/v3/xxxxxxxx",
|
"infuraUrl": "https://mainnet.infura.io/v3/xxxxxxxx",
|
||||||
"zigzagChainId": 1,
|
"zigzagChainId": 1,
|
||||||
"zigzagWsUrl": "wss://zigzag-exchange.herokuapp.com",
|
"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:<address>", like this:
|
You can get the available market contracts [here.](https://docs.chain.link/docs/ethereum-addresses/)Add those to you pair config as "chainlink:<address>", 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",
|
"side": "d",
|
||||||
"priceFeedPrimary": "constant:1",
|
"priceFeedPrimary": "constant:1",
|
||||||
"priceFeedSecondary": null,
|
"priceFeedSecondary": null,
|
||||||
|
....
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -488,9 +488,6 @@ async function setupPriceFeeds() {
|
|||||||
for (let market in MM_CONFIG.pairs) {
|
for (let market in MM_CONFIG.pairs) {
|
||||||
const pairConfig = MM_CONFIG.pairs[market];
|
const pairConfig = MM_CONFIG.pairs[market];
|
||||||
if(!pairConfig.active) { continue; }
|
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:
|
// This is needed to make the price feed backwards compatalbe with old constant mode:
|
||||||
// "DYDX-USDC": {
|
// "DYDX-USDC": {
|
||||||
// "mode": "constant",
|
// "mode": "constant",
|
||||||
@@ -499,6 +496,8 @@ async function setupPriceFeeds() {
|
|||||||
const initPrice = pairConfig.initPrice;
|
const initPrice = pairConfig.initPrice;
|
||||||
pairConfig['priceFeedPrimary'] = "constant:" + initPrice.toString();
|
pairConfig['priceFeedPrimary'] = "constant:" + initPrice.toString();
|
||||||
}
|
}
|
||||||
|
const primaryPriceFeed = pairConfig.priceFeedPrimary;
|
||||||
|
const secondaryPriceFeed = pairConfig.priceFeedSecondary;
|
||||||
[primaryPriceFeed, secondaryPriceFeed].forEach(priceFeed => {
|
[primaryPriceFeed, secondaryPriceFeed].forEach(priceFeed => {
|
||||||
if(!priceFeed) { return; }
|
if(!priceFeed) { return; }
|
||||||
const [provider, id] = priceFeed.split(':');
|
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);
|
if(cryptowatch.length) await cryptowatchWsSetup(cryptowatch);
|
||||||
|
|
||||||
console.log(PRICE_FEEDS);
|
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) {
|
function indicateLiquidity (pairs = MM_CONFIG.pairs) {
|
||||||
for(const marketId in pairs) {
|
for(const marketId in pairs) {
|
||||||
const mmConfig = pairs[marketId];
|
const mmConfig = pairs[marketId];
|
||||||
@@ -657,7 +655,7 @@ function indicateLiquidity (pairs = MM_CONFIG.pairs) {
|
|||||||
liquidity.push(["s", sellPrice, maxSellSize / splits, expires]);
|
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 {
|
try {
|
||||||
zigzagws.send(JSON.stringify(msg));
|
zigzagws.send(JSON.stringify(msg));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -668,7 +666,7 @@ function indicateLiquidity (pairs = MM_CONFIG.pairs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cancelLiquidity (chainId, marketId) {
|
function cancelLiquidity (chainId, marketId) {
|
||||||
const msg = { op: "indicateliq2", args: [chainId, marketId, [], CLIENT_ID] };
|
const msg = { op: "indicateliq2", args: [chainId, marketId, []] };
|
||||||
try {
|
try {
|
||||||
zigzagws.send(JSON.stringify(msg));
|
zigzagws.send(JSON.stringify(msg));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user