Skip to content

Commit 9c73822

Browse files
0xjockejjgonecrypto
authored andcommitted
SIP-217 add asset details for futures markets (Synthetixio#1750)
* Add assets details to futuresmarket. - This will enable consumers to know what catergory the market belong too, ie. is forex etc * Make asset key consistent. I'm sure there's a reason why this is the case, but I'll add this commit for some discussion * Revert "Make asset key consistent." This reverts commit 0b743c8. * Add logic to adjust futures market with incorrect asset key format
1 parent 6369471 commit 9c73822

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,19 @@ const getFuturesMarkets = ({
438438
if (!fs.existsSync(pathToFuturesMarketsList)) {
439439
return [];
440440
}
441-
return JSON.parse(fs.readFileSync(pathToFuturesMarketsList));
441+
const futuresMarkets = JSON.parse(fs.readFileSync(pathToFuturesMarketsList)) || [];
442+
return futuresMarkets.map(futuresMarket => {
443+
/**
444+
* We expect the asset key to not start with an 's'. ie. AVAX rather than sAVAX
445+
* Unfortunately due to some historical reasons 'sBTC', 'sETH' and 'sLINK' does not follow this format
446+
* We adjust for that here.
447+
*/
448+
const marketsWithIncorrectAssetKey = ['sBTC', 'sETH', 'sLINK'];
449+
const assetKeyNeedsAdjustment = marketsWithIncorrectAssetKey.includes(futuresMarket.asset);
450+
const assetKey = assetKeyNeedsAdjustment ? futuresMarket.asset.slice(1) : futuresMarket.asset;
451+
// mixin the asset details
452+
return Object.assign({}, assets[assetKey], futuresMarket);
453+
});
442454
};
443455

444456
/**

0 commit comments

Comments
 (0)