be-components 2.4.7 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/lib/commonjs/LocationTracker/LocationStatus.js.map +1 -1
  2. package/lib/commonjs/LocationTracker/api/index.js +14 -0
  3. package/lib/commonjs/LocationTracker/api/index.js.map +1 -1
  4. package/lib/commonjs/MarketComponents/components/TeamEventMarket/index.js +91 -3
  5. package/lib/commonjs/MarketComponents/components/TeamEventMarket/index.js.map +1 -1
  6. package/lib/commonjs/MarketMaker/api/index.js +1307 -0
  7. package/lib/commonjs/MarketMaker/api/index.js.map +1 -0
  8. package/lib/commonjs/MarketMaker/components/Contest.js +150 -0
  9. package/lib/commonjs/MarketMaker/components/Contest.js.map +1 -0
  10. package/lib/commonjs/MarketMaker/components/ContestMarkets.js +300 -0
  11. package/lib/commonjs/MarketMaker/components/ContestMarkets.js.map +1 -0
  12. package/lib/commonjs/MarketMaker/components/ContestSelector.js +111 -0
  13. package/lib/commonjs/MarketMaker/components/ContestSelector.js.map +1 -0
  14. package/lib/commonjs/MarketMaker/components/Dashboard.js +164 -0
  15. package/lib/commonjs/MarketMaker/components/Dashboard.js.map +1 -0
  16. package/lib/commonjs/MarketMaker/components/FundActions.js +232 -0
  17. package/lib/commonjs/MarketMaker/components/FundActions.js.map +1 -0
  18. package/lib/commonjs/MarketMaker/components/FundOwnershipList.js +94 -0
  19. package/lib/commonjs/MarketMaker/components/FundOwnershipList.js.map +1 -0
  20. package/lib/commonjs/MarketMaker/components/FundSelector.js +99 -0
  21. package/lib/commonjs/MarketMaker/components/FundSelector.js.map +1 -0
  22. package/lib/commonjs/MarketMaker/components/FundingRequestList.js +112 -0
  23. package/lib/commonjs/MarketMaker/components/FundingRequestList.js.map +1 -0
  24. package/lib/commonjs/MarketMaker/components/ManageFundForm.js +122 -0
  25. package/lib/commonjs/MarketMaker/components/ManageFundForm.js.map +1 -0
  26. package/lib/commonjs/MarketMaker/components/MarketSelector.js +81 -0
  27. package/lib/commonjs/MarketMaker/components/MarketSelector.js.map +1 -0
  28. package/lib/commonjs/MarketMaker/components/SetMarketForm.js +305 -0
  29. package/lib/commonjs/MarketMaker/components/SetMarketForm.js.map +1 -0
  30. package/lib/commonjs/MarketMaker/components/WeightProgress.js +40 -0
  31. package/lib/commonjs/MarketMaker/components/WeightProgress.js.map +1 -0
  32. package/lib/commonjs/MarketMaker/index.js +452 -0
  33. package/lib/commonjs/MarketMaker/index.js.map +1 -0
  34. package/lib/commonjs/SocialComponents/api/index.js +0 -1
  35. package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
  36. package/lib/commonjs/index.js +7 -0
  37. package/lib/commonjs/index.js.map +1 -1
  38. package/lib/commonjs/types.d.js +4 -0
  39. package/lib/module/LocationTracker/LocationStatus.js.map +1 -1
  40. package/lib/module/LocationTracker/api/index.js +14 -0
  41. package/lib/module/LocationTracker/api/index.js.map +1 -1
  42. package/lib/module/MarketComponents/components/TeamEventMarket/index.js +91 -3
  43. package/lib/module/MarketComponents/components/TeamEventMarket/index.js.map +1 -1
  44. package/lib/module/MarketMaker/api/index.js +1301 -0
  45. package/lib/module/MarketMaker/api/index.js.map +1 -0
  46. package/lib/module/MarketMaker/components/Contest.js +143 -0
  47. package/lib/module/MarketMaker/components/Contest.js.map +1 -0
  48. package/lib/module/MarketMaker/components/ContestMarkets.js +291 -0
  49. package/lib/module/MarketMaker/components/ContestMarkets.js.map +1 -0
  50. package/lib/module/MarketMaker/components/ContestSelector.js +102 -0
  51. package/lib/module/MarketMaker/components/ContestSelector.js.map +1 -0
  52. package/lib/module/MarketMaker/components/Dashboard.js +155 -0
  53. package/lib/module/MarketMaker/components/Dashboard.js.map +1 -0
  54. package/lib/module/MarketMaker/components/FundActions.js +223 -0
  55. package/lib/module/MarketMaker/components/FundActions.js.map +1 -0
  56. package/lib/module/MarketMaker/components/FundOwnershipList.js +87 -0
  57. package/lib/module/MarketMaker/components/FundOwnershipList.js.map +1 -0
  58. package/lib/module/MarketMaker/components/FundSelector.js +92 -0
  59. package/lib/module/MarketMaker/components/FundSelector.js.map +1 -0
  60. package/lib/module/MarketMaker/components/FundingRequestList.js +105 -0
  61. package/lib/module/MarketMaker/components/FundingRequestList.js.map +1 -0
  62. package/lib/module/MarketMaker/components/ManageFundForm.js +113 -0
  63. package/lib/module/MarketMaker/components/ManageFundForm.js.map +1 -0
  64. package/lib/module/MarketMaker/components/MarketSelector.js +74 -0
  65. package/lib/module/MarketMaker/components/MarketSelector.js.map +1 -0
  66. package/lib/module/MarketMaker/components/SetMarketForm.js +297 -0
  67. package/lib/module/MarketMaker/components/SetMarketForm.js.map +1 -0
  68. package/lib/module/MarketMaker/components/WeightProgress.js +33 -0
  69. package/lib/module/MarketMaker/components/WeightProgress.js.map +1 -0
  70. package/lib/module/MarketMaker/index.js +442 -0
  71. package/lib/module/MarketMaker/index.js.map +1 -0
  72. package/lib/module/SocialComponents/api/index.js +0 -1
  73. package/lib/module/SocialComponents/api/index.js.map +1 -1
  74. package/lib/module/index.js +2 -1
  75. package/lib/module/index.js.map +1 -1
  76. package/lib/module/types.d.js +1 -1
  77. package/lib/typescript/src/LocationTracker/LocationStatus.d.ts.map +1 -1
  78. package/lib/typescript/src/LocationTracker/api/index.d.ts.map +1 -1
  79. package/lib/typescript/src/MarketComponents/components/TeamEventMarket/index.d.ts +2 -2
  80. package/lib/typescript/src/MarketComponents/components/TeamEventMarket/index.d.ts.map +1 -1
  81. package/lib/typescript/src/MarketComponents/index.d.ts +2 -2
  82. package/lib/typescript/src/MarketComponents/index.d.ts.map +1 -1
  83. package/lib/typescript/src/MarketMaker/api/index.d.ts +131 -0
  84. package/lib/typescript/src/MarketMaker/api/index.d.ts.map +1 -0
  85. package/lib/typescript/src/MarketMaker/components/Contest.d.ts +25 -0
  86. package/lib/typescript/src/MarketMaker/components/Contest.d.ts.map +1 -0
  87. package/lib/typescript/src/MarketMaker/components/ContestMarkets.d.ts +26 -0
  88. package/lib/typescript/src/MarketMaker/components/ContestMarkets.d.ts.map +1 -0
  89. package/lib/typescript/src/MarketMaker/components/ContestSelector.d.ts +19 -0
  90. package/lib/typescript/src/MarketMaker/components/ContestSelector.d.ts.map +1 -0
  91. package/lib/typescript/src/MarketMaker/components/Dashboard.d.ts +25 -0
  92. package/lib/typescript/src/MarketMaker/components/Dashboard.d.ts.map +1 -0
  93. package/lib/typescript/src/MarketMaker/components/FundActions.d.ts +12 -0
  94. package/lib/typescript/src/MarketMaker/components/FundActions.d.ts.map +1 -0
  95. package/lib/typescript/src/MarketMaker/components/FundOwnershipList.d.ts +9 -0
  96. package/lib/typescript/src/MarketMaker/components/FundOwnershipList.d.ts.map +1 -0
  97. package/lib/typescript/src/MarketMaker/components/FundSelector.d.ts +13 -0
  98. package/lib/typescript/src/MarketMaker/components/FundSelector.d.ts.map +1 -0
  99. package/lib/typescript/src/MarketMaker/components/FundingRequestList.d.ts +11 -0
  100. package/lib/typescript/src/MarketMaker/components/FundingRequestList.d.ts.map +1 -0
  101. package/lib/typescript/src/MarketMaker/components/ManageFundForm.d.ts +10 -0
  102. package/lib/typescript/src/MarketMaker/components/ManageFundForm.d.ts.map +1 -0
  103. package/lib/typescript/src/MarketMaker/components/MarketSelector.d.ts +12 -0
  104. package/lib/typescript/src/MarketMaker/components/MarketSelector.d.ts.map +1 -0
  105. package/lib/typescript/src/MarketMaker/components/SetMarketForm.d.ts +15 -0
  106. package/lib/typescript/src/MarketMaker/components/SetMarketForm.d.ts.map +1 -0
  107. package/lib/typescript/src/MarketMaker/components/WeightProgress.d.ts +10 -0
  108. package/lib/typescript/src/MarketMaker/components/WeightProgress.d.ts.map +1 -0
  109. package/lib/typescript/src/MarketMaker/index.d.ts +7 -0
  110. package/lib/typescript/src/MarketMaker/index.d.ts.map +1 -0
  111. package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
  112. package/lib/typescript/src/index.d.ts +2 -1
  113. package/lib/typescript/src/index.d.ts.map +1 -1
  114. package/package.json +1 -1
  115. package/src/LocationTracker/LocationStatus.tsx +0 -1
  116. package/src/LocationTracker/api/index.tsx +16 -0
  117. package/src/MarketComponents/components/TeamEventMarket/index.tsx +54 -4
  118. package/src/MarketMaker/api/index.ts +1023 -0
  119. package/src/MarketMaker/components/Contest.tsx +106 -0
  120. package/src/MarketMaker/components/ContestMarkets.tsx +174 -0
  121. package/src/MarketMaker/components/ContestSelector.tsx +84 -0
  122. package/src/MarketMaker/components/Dashboard.tsx +112 -0
  123. package/src/MarketMaker/components/FundActions.tsx +149 -0
  124. package/src/MarketMaker/components/FundOwnershipList.tsx +54 -0
  125. package/src/MarketMaker/components/FundSelector.tsx +65 -0
  126. package/src/MarketMaker/components/FundingRequestList.tsx +71 -0
  127. package/src/MarketMaker/components/ManageFundForm.tsx +83 -0
  128. package/src/MarketMaker/components/MarketSelector.tsx +50 -0
  129. package/src/MarketMaker/components/SetMarketForm.tsx +213 -0
  130. package/src/MarketMaker/components/WeightProgress.tsx +25 -0
  131. package/src/MarketMaker/index.tsx +378 -0
  132. package/src/SocialComponents/api/index.ts +0 -1
  133. package/src/index.tsx +2 -1
  134. package/src/types.d.ts +135 -0
@@ -0,0 +1,378 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import { MarketMakerApi, MarketMaketHelpers } from './api';
4
+ import type { BestAvailableResponseProps, EventProps, ExternalPriceProps, FundingRequestProps, FundOrderProps, FundOwnershipProps, FundProps, LeagueProps, MarketProps, MatchProps, OrderProps, PublicPlayerProps, TournamentProps, TradeProps } from '../types';
5
+ //import { view_styles } from '../constants/styles';
6
+ import Colors from '../constants/colors';
7
+ import ContestSelector from './components/ContestSelector';
8
+ import Dashboard from './components/Dashboard';
9
+ import MarketSelector from './components/MarketSelector';
10
+ import SetMarketForm from './components/SetMarketForm';
11
+ import FundSelector from './components/FundSelector';
12
+ import { usePlayerLocation } from '../LocationTracker/LocationStatus';
13
+ import ManageFundForm from './components/ManageFundForm';
14
+ import FundingRequestList from './components/FundingRequestList';
15
+ import FundOwnershipList from './components/FundOwnershipList';
16
+
17
+ type MarketMakerProps = {
18
+ player_id:string
19
+ }
20
+
21
+ const MarketMaker = ({ player_id }:MarketMakerProps) => {
22
+ const [ module_data, setModuleData ] = useState<{
23
+ loaded:boolean,
24
+ loading:boolean,
25
+ funds:FundProps[],
26
+ markets:MarketProps[],
27
+ leagues:LeagueProps[],
28
+ events:EventProps[],
29
+ tournaments:TournamentProps[],
30
+ matches:MatchProps[],
31
+ }>({
32
+ loaded: false,
33
+ loading:false,
34
+ funds:[],
35
+ leagues:[],
36
+ markets:[],
37
+ events:[],
38
+ tournaments:[],
39
+ matches:[]
40
+ });
41
+ const { loaded, leagues, events, markets, funds } = module_data;
42
+
43
+ const [ editing_fund, setEditingFund ] = useState<FundProps | undefined>(undefined);
44
+
45
+ const [ set_market_form_data, setMarketFormData ] = useState<{
46
+ set_market_form_key:string,
47
+ set_market_orders:OrderProps[],
48
+ set_market_market?:MarketProps,
49
+ set_market_form_visible:boolean,
50
+ set_market_prices: ExternalPriceProps[]
51
+ }>({
52
+ set_market_form_key: '',
53
+ set_market_form_visible: false,
54
+ set_market_orders:[],
55
+ set_market_prices:[]
56
+ });
57
+ const { set_market_form_key, set_market_orders, set_market_form_visible, set_market_market, set_market_prices } = set_market_form_data;
58
+
59
+ const [ dash_data, setDashData ] = useState<{
60
+ fund?:FundProps,
61
+ loaded:boolean,
62
+ loading:boolean,
63
+ external_name?:string,
64
+ players:PublicPlayerProps[],
65
+ best_available:BestAvailableResponseProps,
66
+ funding_requests:FundingRequestProps[],
67
+ fund_ownerships:FundOwnershipProps[],
68
+ selected_markets:MarketProps[],
69
+ orders:OrderProps[],
70
+ fund_orders:FundOrderProps[],
71
+ selected_events:EventProps[],
72
+ trades:TradeProps[],
73
+ external_prices:ExternalPriceProps[],
74
+ selected_tournaments:TournamentProps[],
75
+ selected_matches:MatchProps[]
76
+ }>({
77
+ loaded:false,
78
+ loading:false,
79
+ external_name: 'Consensus',
80
+ players:[],
81
+ funding_requests:[],
82
+ fund_ownerships:[],
83
+ fund_orders:[],
84
+ selected_markets:[],
85
+ best_available: { events: [], tournaments: [], matches: [] },
86
+ orders:[],
87
+ trades:[],
88
+ external_prices: [],
89
+ selected_events:[],
90
+ selected_matches:[],
91
+ selected_tournaments:[]
92
+ });
93
+ const { fund, selected_events, players, fund_orders, fund_ownerships, funding_requests, external_name, selected_matches, selected_tournaments, selected_markets, trades, external_prices, best_available, orders } = dash_data;
94
+ const { available_orders } = MarketMaketHelpers.getMarketDataFromBestAvailable(best_available);
95
+ const selectable_markets = MarketMaketHelpers.getSelectableMarkets(selected_events, selected_tournaments, selected_matches, markets);
96
+
97
+ const { location, getLocation } = usePlayerLocation({ player_id });
98
+ useEffect(() => {
99
+ MarketMakerApi.setEnvironment();
100
+ if(!player_id){ return }
101
+ loadModule();
102
+ getLocation()
103
+ },[player_id]);
104
+
105
+ useEffect(() => {
106
+ if(!fund?.fund_id || !loaded){ return }
107
+ getDashData(fund.fund_id);
108
+ },[fund]);
109
+
110
+ const loadModule = async() => {
111
+ setModuleData({ ...module_data, loading:true });
112
+ setDashData({ ...dash_data, loading:true });
113
+ const bulk_funds = await MarketMakerApi.getMyActiveFunds(0);
114
+ const evs = await MarketMakerApi.getActiveEvents();
115
+ const mks = await MarketMakerApi.getMarkets();
116
+ const ls = await MarketMakerApi.getLeagues();
117
+ setModuleData({
118
+ ...module_data,
119
+ events:evs,
120
+ funds:bulk_funds,
121
+ loaded:true,
122
+ loading:false,
123
+ markets:mks,
124
+ leagues:ls,
125
+ });
126
+ if(bulk_funds[0]){ setDashData({ ...dash_data, fund: bulk_funds[0] }) }
127
+ }
128
+
129
+ const getDashData = async(fund_id:string) => {
130
+ //Now load Dash data
131
+ const ba = await MarketMakerApi.getBestAvailableOrders();
132
+ const fund_response = await MarketMakerApi.getFundById(fund_id);
133
+ if(!fund_response){
134
+ alert('Failed to get details for selected fund');
135
+ return setDashData({ ...dash_data, loading:false });
136
+ }
137
+ const fr_requests = await MarketMakerApi.getFundingRequestsByFundId(fund_id);
138
+ const my_action_data = await getDataForMyAction(fund_response.orders, markets);
139
+ //Based on my action -- lets auto select events and grab all that data!!
140
+ let ep = await MarketMakerApi.getPricesByEvents('team', my_action_data.events.map(e => e.event_id))
141
+ let player_ids = [ ...new Set(fr_requests.map(r => r.player_id).concat(fund_response.fund_ownerships.map(o => o.player_id)).map(id => id))]
142
+ let plays = await MarketMakerApi.getPlayersByIds(player_ids)
143
+
144
+ setDashData({
145
+ ...dash_data,
146
+ loaded:true,
147
+ loading:false,
148
+ best_available: ba,
149
+ funding_requests:fr_requests,
150
+ players:plays,
151
+ fund_ownerships: fund_response.fund_ownerships,
152
+ orders:fund_response.orders,
153
+ fund_orders: fund_response.fund_orders,
154
+ selected_events: my_action_data.events,
155
+ trades: my_action_data.trades,
156
+ external_prices: ep,
157
+ selected_markets: my_action_data.markets
158
+ })
159
+ }
160
+
161
+ const getDataForMyAction = async(orders:OrderProps[], markets:MarketProps[]) => {
162
+ const ev_ids = orders.filter(o => o.event_type == 'team').map(o => o.event_id);
163
+ const mks = markets.filter(m => orders.map(o => o.market_id.toString()).includes(m.market_id.toString()))
164
+ const evs = await MarketMakerApi.getEventsByEventIds(ev_ids);
165
+ const ts = await MarketMakerApi.getLatestTradesByEvents('team', ev_ids)
166
+ return { events:evs, trades:ts, markets:mks }
167
+ }
168
+
169
+ const handleSelectEvent = async(e:EventProps) => {
170
+ if(dash_data.loading){ return }//No mashy
171
+ setDashData({ ...dash_data, loading: true });
172
+ const prices = await MarketMakerApi.getPricesByEvent(e.event_id, 'team');
173
+ const tds = await MarketMakerApi.getLatestTradesByEvents('team', [e.event_id]);
174
+ setDashData({
175
+ ...dash_data,
176
+ loading:false,
177
+ selected_events: selected_events.concat(e),
178
+ trades: trades.filter(t => t.event_id != e.event_id).concat(tds),
179
+ external_prices: external_prices.filter(p => p.event_id != e.event_id).concat(prices)
180
+ })
181
+ }
182
+
183
+ const handleDeselectEvent = (e:EventProps) => {
184
+ if(dash_data.loading){ return }//No mashy
185
+ setDashData({
186
+ ...dash_data,
187
+ loading:false,
188
+ selected_events: selected_events.filter(se => se.event_id != e.event_id),
189
+ trades: trades.filter(t => t.event_id != e.event_id)
190
+ })
191
+ }
192
+
193
+
194
+ return (
195
+ <View style={{ flex:1, backgroundColor:Colors.shades.white }}>
196
+ <View style={{ flexDirection:'row' }}>
197
+ <View>
198
+ <FundSelector
199
+ funds={funds}
200
+ maxHeight={300}
201
+ selected_fund_id={dash_data.fund?.fund_id}
202
+ onEditFund={(f) => {
203
+ setEditingFund(f)
204
+ }}
205
+ onCreateFund={(f) => {
206
+ setDashData({
207
+ ...dash_data,
208
+ fund:f
209
+ })
210
+ setEditingFund(f);
211
+ }}
212
+ onSelectFund={(f) => {
213
+ setDashData({
214
+ ...dash_data,
215
+ fund:f
216
+ })
217
+ }}
218
+ />
219
+ {fund ?
220
+ <FundOwnershipList
221
+ fund_ownerships={fund_ownerships}
222
+ players={players}
223
+ />
224
+ :<></>}
225
+ {fund?
226
+ <FundingRequestList
227
+ funding_requests={funding_requests}
228
+ players={players}
229
+ onApproveRequest={async(fr_id) => {
230
+ const app_response = await MarketMakerApi.approveRequest(fr_id)
231
+ if(!app_response){ return alert('Unable to process') }
232
+ setDashData({
233
+ ...dash_data,
234
+ fund: app_response.fund,
235
+ fund_ownerships: app_response.fund_ownerships,
236
+ funding_requests: funding_requests.filter(fr => fr.funding_request_id != fr_id)
237
+ })
238
+ }}
239
+ onDeclineRequest={async(fr_id) => {
240
+ const app_response = await MarketMakerApi.declineRequest(fr_id)
241
+ if(!app_response){ return alert('Unable to process') }
242
+ setDashData({
243
+ ...dash_data,
244
+ funding_requests: funding_requests.filter(fr => fr.funding_request_id != fr_id)
245
+ })
246
+ }}
247
+ />
248
+ :<></>}
249
+ <ContestSelector
250
+ maxHeight={300}
251
+ leagues={leagues.filter(l => l.status == 'active')}
252
+ events={events}
253
+ onSelectEvent={(e) => handleSelectEvent(e)}
254
+ onDeselectEvent={(e) => handleDeselectEvent(e)}
255
+ onSelectMatch={(m) => console.log(m)}
256
+ onSelectTournament={(t) => console.log(t)}
257
+ tournaments={[]}
258
+ matches={[]}
259
+ selected_events={selected_events.map(e => e.event_id)}
260
+ selected_matches={[]}
261
+ selected_tournaments={[]}
262
+ />
263
+ <MarketSelector
264
+ maxHeight={300}
265
+ markets={selectable_markets.sort((a,b) => parseInt(a.market_id) - parseInt(b.market_id))}
266
+ onSelectMarket={(m) => setDashData({ ...dash_data, selected_markets: dash_data.selected_markets.concat(m) })}
267
+ onDeselectMarket={(m) => setDashData({ ...dash_data, selected_markets: dash_data.selected_markets.filter(se => se.market_id != m.market_id) })}
268
+ selected_markets={selected_markets.map(m => m.market_id)}
269
+ />
270
+ </View>
271
+ <View style={{ flexGrow:1 }}>
272
+ <Dashboard
273
+ loaded={dash_data.loaded}
274
+ leagues={leagues}
275
+ fund={fund}
276
+ events={selected_events}
277
+ tournaments={selected_tournaments}
278
+ matches={selected_matches}
279
+ markets={selected_markets}
280
+ best_available_orders={available_orders}
281
+ trades={trades}
282
+ prices={external_prices}
283
+ external_name={external_name}
284
+ orders={orders}
285
+ fund_orders={fund_orders}
286
+ onDepositFund={async(amount) => {
287
+ if(!fund){ return alert('Unable to process') }
288
+ const dep_resp = await MarketMakerApi.depositRequest(fund.fund_id, amount);
289
+ console.log(dep_resp)
290
+ }}
291
+ onLayoffCapital={async(amount) => {
292
+ if(!fund){ return alert('Unable to process') }
293
+ const layoff_resp = await MarketMakerApi.layoffCapital(fund.fund_id, amount);
294
+ if(!layoff_resp){ return alert('Unable to process') }
295
+ setDashData({
296
+ ...dash_data,
297
+ fund: layoff_resp.fund,
298
+ orders: layoff_resp.orders
299
+ })
300
+ }}
301
+ onWorkCapital={async(amount) => {
302
+ if(!fund){ return alert('Unable to process') }
303
+ const work_response = await MarketMakerApi.workCapital(fund.fund_id, amount);
304
+ if(!work_response){ return alert('Unable to process') }
305
+ setDashData({
306
+ ...dash_data,
307
+ fund: work_response.fund,
308
+ orders: work_response.orders
309
+ })
310
+ }}
311
+ onClearMarket={async(order_ids) => {
312
+ const new_orders = await MarketMakerApi.cancelOrders(order_ids)
313
+ setDashData({
314
+ ...dash_data,
315
+ orders: orders.filter(o => !new_orders.find(no => no.order_id == o.order_id))
316
+ })
317
+ }}
318
+ onSetMarket={(orders, market, prices) => {
319
+ if(!location.region || !location.coordinates){ return alert('Location could not be verified to process orders') }
320
+ orders = orders.map(o => {
321
+ return { ...o, location: location.coordinates, region: location.region }
322
+ })
323
+ setMarketFormData({
324
+ ...set_market_form_data,
325
+ set_market_form_visible:true,
326
+ set_market_market:market,
327
+ set_market_orders: orders,
328
+ set_market_form_key: `${Math.random()}`,
329
+ set_market_prices: prices
330
+ })
331
+ }}
332
+ />
333
+ {fund && set_market_form_visible && set_market_market ?
334
+ <View style={{ position:'absolute', bottom:0, left:0, right:0, top:0, backgroundColor:Colors.shades.black_faded, justifyContent:'center', alignItems:'center' }}>
335
+ <SetMarketForm
336
+ fund={fund}
337
+ form_key={set_market_form_key}
338
+ market={set_market_market}
339
+ orders={set_market_orders}
340
+ prices={set_market_prices}
341
+ spread_pct='5'
342
+ onSetMarket={async(fund_orders) => {
343
+ if(!fund){ return alert('Unable to process') }
344
+ const new_os = await MarketMakerApi.addOrdersToFund(fund.fund_id, fund_orders)
345
+ console.log(new_os)
346
+ if(new_os.length == 0){ return alert('Unable to process') }
347
+ setDashData({
348
+ ...dash_data,
349
+ orders: orders.concat(new_os)
350
+ })
351
+ setMarketFormData({ set_market_form_visible: false, set_market_orders:[], set_market_form_key:'', set_market_prices:[] })
352
+ }}
353
+ onClose={() => setMarketFormData({ set_market_form_visible: false, set_market_orders:[], set_market_form_key:'', set_market_prices:[] })}
354
+ />
355
+ </View>
356
+ :<></>}
357
+ {editing_fund ?
358
+ <View style={{ position:'absolute', bottom:0, left:0, right:0, top:0, backgroundColor:Colors.shades.black_faded, justifyContent:'center', alignItems:'center' }}>
359
+ <ManageFundForm
360
+ fund={editing_fund}
361
+ onClose={() => setEditingFund(undefined)}
362
+ onFundUpdate={(f) => {
363
+ setEditingFund(undefined);
364
+ setDashData({
365
+ ...dash_data,
366
+ fund: f
367
+ })
368
+ }}
369
+ />
370
+ </View>
371
+ :<></>}
372
+ </View>
373
+ </View>
374
+ </View>
375
+ )
376
+ }
377
+
378
+ export default MarketMaker
@@ -134,7 +134,6 @@ const SocialComponentApi = {
134
134
  startPodcastEpisode: async(podcast_episode_id:string):Promise<undefined | { player_podcast:PlayerPodcastProps, player_podcast_episode:PlayerPodcastEpisodeProps }> => {
135
135
  try {
136
136
  const resp = await axios.post(`${SOCIAL_SVC_API}/v1/podcasts/episode/start`, { podcast_episode_id });
137
- console.log(resp.data)
138
137
  return resp.data
139
138
  } catch (e) {
140
139
  console.log(e)
package/src/index.tsx CHANGED
@@ -29,7 +29,7 @@ import MarketComponents from './MarketComponents';
29
29
  import EventComponents from './EventComponents';
30
30
  import Share from './Share';
31
31
  import LocationTracker from "./LocationTracker";
32
-
32
+ import MarketMaker from "./MarketMaker";
33
33
 
34
34
  export {
35
35
  Authenticator,
@@ -54,6 +54,7 @@ export {
54
54
  PollCampaign,
55
55
  PollCampaignApi,
56
56
  PollApi,
57
+ MarketMaker,
57
58
  CompetitionModule,
58
59
  SeasonManager,
59
60
  CreateCompetitionForm,
package/src/types.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { Moment } from "moment-mini";
2
+
1
3
  export interface PublicPlayerProps {
2
4
  player_id:string,
3
5
  username:string,
@@ -163,6 +165,16 @@ export interface PlayerPodcastProps {
163
165
  last_update_datetime:any
164
166
  }
165
167
 
168
+ export interface SortedContestProps {
169
+ league_id?:string,
170
+ contest_type: 'team'|'tournament'|'match',
171
+ id:string,
172
+ title:string,
173
+ markets:MarketProps[],
174
+ time_detail:string,
175
+ scheduled_datetime:Moment
176
+ }
177
+
166
178
  export interface PlayerPodcastEpisodeProps {
167
179
  player_podcast_episode_id:string,
168
180
  player_id:string,
@@ -1854,6 +1866,33 @@ export interface GeneratedLinkProps {
1854
1866
  last_update_datetime?:any
1855
1867
  }
1856
1868
 
1869
+
1870
+ export interface PositionProps {
1871
+ position_id:string; //Primary key of the order
1872
+ order_id: string //Id of the order in which the position was created from
1873
+ stake: number; //Amount still available to be matched
1874
+ winnings: number; //Amount already fulfilled
1875
+ net_winnings:number; //Winnings minus commission charged,
1876
+ potential_winnings: number //Potential winnings calculated by open_amt and odds / prob
1877
+ in_sale_order:number //The amount that is currently active in a sale order
1878
+ delayed_cash: number //Amount of cash that is awaiting the result. If the result is a draw, this money is not sent back
1879
+ cash_rcvd: number; //Amount of cash received from sales
1880
+ routing_premium?:number; //If we charged for routing this order
1881
+ original_stake: number; //Original amount of stake when the position was created
1882
+ create_datetime?: any; //Create time of the order
1883
+ last_update_datetime?: any; //Last update time of te order
1884
+ odds: number; //American odds of the order
1885
+ result_ind?:'win'|'lose'|'draw';
1886
+ probability: number; //Implied probability of the order
1887
+ parlay_id?:string; //If the positions is created as the other side of a parlay, then this is the associated parlay id that needs to be reviewed for a win / loss
1888
+ status: 'inprogress' | 'closed'; //Current status of the order,
1889
+ legacy_id?:string,
1890
+ resolution_datetime?:any,
1891
+ purchased_grade?:number,
1892
+ commission:number,
1893
+ hedged_positions?:HedgedPositionProps[]
1894
+ }
1895
+
1857
1896
  export interface OrderProps {
1858
1897
  order_id:string; //Primary key of the order
1859
1898
  player_id:string; //Id of the player creating the order
@@ -1873,6 +1912,8 @@ export interface OrderProps {
1873
1912
  market_id: string; //Id of the market that this order is (i.e., Spread, Total, stat, etc)
1874
1913
  market?: MarketProps; //Market object of the ID
1875
1914
  title: string; //Title of the order
1915
+ working_pct?:number;
1916
+ fulfill_action?:'replenish'|'drain',
1876
1917
  event_id: string; //Id of the event associated with the order
1877
1918
  event_type: 'team' | 'tournament'|'match'; //Is the event a team event or individual (i.e., golf tournament / UFC)
1878
1919
  position_ids: string[]; //Array of positions that were created due to trades
@@ -1917,8 +1958,102 @@ export interface OrderProps {
1917
1958
  no_bet_reason?:string
1918
1959
  }
1919
1960
 
1961
+ export interface HedgeProps {
1962
+ hedge_id:string,
1963
+ hedged_amt:number,
1964
+ player_id:string,
1965
+ event_id:string,
1966
+ event_type:string,
1967
+ market_id:string,
1968
+ var_1:number,
1969
+ stake_reduction:number,
1970
+ cash_rcvd:number,
1971
+ market_type:string,
1972
+ delayed_cash_no_draw:number,
1973
+ hedged_positions?:HedgedPositionProps[],
1974
+ delayed_cash_draw:number,
1975
+ status:string,
1976
+ create_datetime:any,
1977
+ last_udpate_datetime: any
1978
+ }
1979
+
1980
+ export interface HedgedPositionProps {
1981
+ hedged_position_id:string,
1982
+ hedge_id:string,
1983
+ position_id:string,
1984
+ original_stake:number,
1985
+ new_stake:number,
1986
+ delayed_cash_draw:number,
1987
+ delayed_cash_no_draw:number,
1988
+ original_potential_winnings:number,
1989
+ new_potential_winnings:number,
1990
+ status:string,
1991
+ create_datetime:any,
1992
+ last_update_datetime:any
1993
+ }
1920
1994
 
1921
1995
 
1996
+ export interface FundProps {
1997
+ fund_id:string,
1998
+ player_id:string,
1999
+ status: 'active'|'inactive'|'archived',
2000
+ name: string,
2001
+ invested_capital:number,
2002
+ minimum_investment:number,
2003
+ available_capital:number,
2004
+ working_capital: number, //Fulfilled amount
2005
+ deployed_capital: number,
2006
+ market_type: 'FOR_MONEY'|'FREE'
2007
+ create_datetime: any,
2008
+ last_update_datetime:any
2009
+ }
2010
+
2011
+ export interface FundTransactionProps {
2012
+ fund_transaction_id:string,
2013
+ fund_id:string,
2014
+ sender_id:string,
2015
+ sender_type:string,
2016
+ receiver_id:string,
2017
+ receiver_type:string,
2018
+ transaction_datetime:any,
2019
+ description:string,
2020
+ amount:number,
2021
+ amount_type:any,
2022
+ create_datetime:any,
2023
+ last_update_datetime:any
2024
+ }
2025
+
2026
+ export interface FundingRequestProps {
2027
+ funding_request_id:string,
2028
+ fund_id:string,
2029
+ player_id:string,
2030
+ status:'requested'|'declined'|'approved'|'withdrawn',
2031
+ amount:number,
2032
+ create_datetime:any,
2033
+ last_update_datetime:any
2034
+ }
2035
+
2036
+ export interface FundOwnershipProps {
2037
+ fund_ownership_id:string,
2038
+ fund_id:string,
2039
+ player_id:string,
2040
+ total_invested:number,
2041
+ ownership_pct:number,
2042
+ status:'active'|'inactive',
2043
+ create_datetime:any,
2044
+ last_update_datetime:any
2045
+ }
2046
+
2047
+ export interface FundOrderProps {
2048
+ fund_order_id:string,
2049
+ fund_id:string,
2050
+ order_id:string,
2051
+ working_pct:number,
2052
+ fulfill_action: 'replenish'|'drain'
2053
+ create_datetime:any,
2054
+ last_update_datetime:any
2055
+ }
2056
+
1922
2057
  //SOCIAL COMPONENTS
1923
2058
 
1924
2059
  export interface PlayerLinkProps {