Bladeren bron

增加clobid和slug

flyzto 3 weken geleden
bovenliggende
commit
f2dc6b1001
3 gewijzigde bestanden met toevoegingen van 20 en 7 verwijderingen
  1. 15 6
      polymarket/libs/parseMarkets.js
  2. 1 0
      polymarket/main.js
  3. 4 1
      server/models/Partner.js

+ 15 - 6
polymarket/libs/parseMarkets.js

@@ -101,7 +101,10 @@ export const parseOdds = (markets) => {
     if (key === 'moneyline') {
       Object.keys(marketData).forEach(side => {
         const askYes = marketData[side].outcomes['Yes']['best_ask'];
+        const tokenYes = marketData[side].outcomes['Yes']['id'];
         const askNo = marketData[side].outcomes['No']['best_ask'];
+        const tokenNo = marketData[side].outcomes['No']['id'];
+        const slug = marketData[side].market.slug;
         if (askYes <= 0.1 || askNo <= 0.1) {
           return;
         }
@@ -123,36 +126,42 @@ export const parseOdds = (markets) => {
             iorKeyNo = 'ior_moc';
             break;
         }
-        odds[iorKeyYes] = { v: iorYes, ask: askYes };
-        odds[iorKeyNo] = { v: iorNo, ask: askNo };
+        odds[iorKeyYes] = { v: iorYes, ask: askYes, token: tokenYes, slug };
+        odds[iorKeyNo] = { v: iorNo, ask: askNo, token: tokenNo, slug };
       });
     }
     else if (key === 'spreads') {
       Object.keys(marketData).forEach(handicap => {
         const ratio = +handicap;
         const askHome = marketData[handicap].outcomes['Home']['best_ask'];
+        const tokenHome = marketData[handicap].outcomes['Home']['id'];
         const askAway = marketData[handicap].outcomes['Away']['best_ask'];
+        const tokenAway = marketData[handicap].outcomes['Away']['id'];
+        const slug = marketData[handicap].market.slug;
         if (askHome <= 0.1 || askAway <= 0.1) {
           return;
         }
         const iorHome = fixFloat(1 / askHome);
         const iorAway = fixFloat(1 / askAway);
-        odds[`ior_r${ratioAccept(ratio)}h_${ratioString(ratio)}`] = { v: iorHome, ask: askHome };
-        odds[`ior_r${ratioAccept(-ratio)}c_${ratioString(ratio)}`] = { v: iorAway, ask: askAway };
+        odds[`ior_r${ratioAccept(ratio)}h_${ratioString(ratio)}`] = { v: iorHome, ask: askHome, token: tokenHome, slug };
+        odds[`ior_r${ratioAccept(-ratio)}c_${ratioString(ratio)}`] = { v: iorAway, ask: askAway, token: tokenAway, slug };
       });
     }
     else if (key === 'totals') {
       Object.keys(marketData).forEach(handicap => {
         const ratio = +handicap;
         const askOver = marketData[handicap].outcomes['Over']['best_ask'];
+        const tokenOver = marketData[handicap].outcomes['Over']['id'];
         const askUnder = marketData[handicap].outcomes['Under']['best_ask'];
+        const tokenUnder = marketData[handicap].outcomes['Under']['id'];
+        const slug = marketData[handicap].market.slug;
         if (askOver <= 0.1 || askUnder <= 0.1) {
           return;
         }
         const iorOver = fixFloat(1 / askOver);
         const iorUnder = fixFloat(1 / askUnder);
-        odds[`ior_ouc_${ratioString(ratio)}`] = { v: iorOver, ask: askOver };
-        odds[`ior_ouh_${ratioString(ratio)}`] = { v: iorUnder, ask: askUnder };
+        odds[`ior_ouc_${ratioString(ratio)}`] = { v: iorOver, ask: askOver, token: tokenOver, slug };
+        odds[`ior_ouh_${ratioString(ratio)}`] = { v: iorUnder, ask: askUnder, token: tokenUnder, slug };
       });
     }
   });

+ 1 - 0
polymarket/main.js

@@ -247,6 +247,7 @@ const syncMarketsData = () => {
  */
 const getGamesEvents = () => {
   const { marketsData, lastChangeTime } = GLOBAL_DATA;
+  Logs.outDev('getGamesEvents', marketsData, lastChangeTime);
   const games = Object.values(marketsData).map(item => {
     const { marketsData, ...rest } = item;
     const odds = parseOdds(marketsData);

+ 4 - 1
server/models/Partner.js

@@ -49,7 +49,10 @@ export const requestData = async (action, data) => {
 }
 
 export const updateSolutions = async (solutions) => {
-  return requestData('opps.soccer', { solutions });
+  if (process.env.NODE_ENV == 'development') {
+    return Promise.resolve({ message: 'development mode' });
+  }
+  return requestData('opps.soccer', solutions);
 }
 
 export default { updateSolutions };