Merge pull request #93 from ZigZagExchange/dev

stage master - add Invert price feed
This commit is contained in:
Trooper
2022-06-27 20:30:17 +02:00
committed by GitHub
2 changed files with 21 additions and 3 deletions

View File

@@ -193,6 +193,20 @@ With constant mode, you can set a fixed price to market make. The bot will not c
}
```
###### Invert price feed
For some pairs, you might just find a price feed for the inverse of the pair. If you want to mm for ZZ-USDC and only find a USDC-ZZ price feed. In those cases, you need to invert the fee. This will only work if the secondary price feed is inverted as well or set to null.
Example:
```
"ETH-USDC": {
"side": "d",
"priceFeedPrimary": "uniswapv3:0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419",
"priceFeedSecondary": null,
"invert": true,
....
}
```
## Pair Options
These pair options can be set for each pair individual. You can even use more then on option per pair (though they might cancel each other out).

View File

@@ -301,7 +301,9 @@ function genQuote(chainId, marketId, side, baseQuantity) {
if (mmSide !== 'd' && mmSide === side) {
throw new Error("badside");
}
const primaryPrice = PRICE_FEEDS[mmConfig.priceFeedPrimary];
const primaryPrice = (mmConfig.invert)
? (1 / PRICE_FEEDS[mmConfig.priceFeedPrimary])
: PRICE_FEEDS[mmConfig.priceFeedPrimary];
if (!primaryPrice) throw new Error("badprice");
const SPREAD = mmConfig.minSpread + (baseQuantity * mmConfig.slippageRate);
let quoteQuantity;
@@ -722,7 +724,9 @@ function indicateLiquidity (pairs = MM_CONFIG.pairs) {
const marketInfo = MARKETS[marketId];
if (!marketInfo) continue;
const midPrice = PRICE_FEEDS[mmConfig.priceFeedPrimary];
const midPrice = (mmConfig.invert)
? (1 / PRICE_FEEDS[mmConfig.priceFeedPrimary])
: PRICE_FEEDS[mmConfig.priceFeedPrimary];
if (!midPrice) continue;
const expires = (Date.now() / 1000 | 0) + 10; // 10s expiry