@@ -163,7 +163,7 @@ export async function getUserPositions() {
163
163
const filter = contract . filters . PositionUpdated ( null , _address ) ;
164
164
const _events = await contract . queryFilter ( filter , - 100 ) ;
165
165
166
- // console.log('_events', _events);
166
+ console . log ( '_events' , _events ) ;
167
167
168
168
let _details = { } ;
169
169
for ( const ev of _events ) {
@@ -197,55 +197,55 @@ export async function getUserPositions() {
197
197
198
198
// graph
199
199
200
- const response = await fetch ( graph_url , {
201
- method : 'POST' ,
202
- headers : {
203
- 'Content-Type' : 'application/json' ,
204
- } ,
205
- body : JSON . stringify ( {
206
- query : `
207
- query {
208
- positions(
209
- orderBy: createdAtTimestamp,
210
- orderDirection: desc,
211
- first:50,
212
- where: {user: "${ _address } "}
213
- ) {
214
- id,
215
- productId,
216
- currency,
217
- margin,
218
- fee,
219
- size,
220
- leverage,
221
- price,
222
- isLong,
223
- createdAtTimestamp
224
- }
225
- }
226
- `
227
- } )
228
- } ) ;
229
-
230
- const json = await response . json ( ) ;
231
-
232
- let _positions = json . data && json . data . positions ;
233
-
234
- let _keys = _positions . map ( ( e ) => { return e . id ; } ) ;
235
-
236
- let _raw_positions = await getPositions ( _keys ) ;
237
-
238
- // make sure graph positions actually exist in the contract for times the graph hasn't yet updated
239
- let actual_positions = [ ] ;
240
- let i = 0 ;
241
- for ( const p of _positions ) {
242
- if ( _raw_positions [ i ] && _raw_positions [ i ] . size && _raw_positions [ i ] . size . toString ( ) * 1 > 0 ) {
243
- actual_positions . push ( p ) ;
244
- }
245
- i ++ ;
246
- }
247
-
248
- let graph_positions = formatPositions ( actual_positions ) ;
200
+ // const response = await fetch(graph_url, {
201
+ // method: 'POST',
202
+ // headers: {
203
+ // 'Content-Type': 'application/json',
204
+ // },
205
+ // body: JSON.stringify({
206
+ // query: `
207
+ // query {
208
+ // positions(
209
+ // orderBy: createdAtTimestamp,
210
+ // orderDirection: desc,
211
+ // first:50,
212
+ // where: {user: "${_address}" }
213
+ // ) {
214
+ // id,
215
+ // productId,
216
+ // currency,
217
+ // margin,
218
+ // fee,
219
+ // size,
220
+ // leverage,
221
+ // price,
222
+ // isLong,
223
+ // createdAtTimestamp
224
+ // }
225
+ // }
226
+ // `
227
+ // })
228
+ // });
229
+
230
+ // const json = await response.json();
231
+
232
+ // let _positions = json.data && json.data.positions;
233
+
234
+ // let _keys = _positions.map((e) => {return e.id;});
235
+
236
+ // let _raw_positions = await getPositions(_keys);
237
+
238
+ // // make sure graph positions actually exist in the contract for times the graph hasn't yet updated
239
+ // let actual_positions = [];
240
+ // let i = 0;
241
+ // for (const p of _positions) {
242
+ // if (_raw_positions[i] && _raw_positions[i].size && _raw_positions[i].size.toString() * 1 > 0) {
243
+ // actual_positions.push(p);
244
+ // }
245
+ // i++;
246
+ // }
247
+
248
+ // let graph_positions = formatPositions(actual_positions);
249
249
250
250
// console.log('graph_positions', graph_positions);
251
251
@@ -257,12 +257,12 @@ export async function getUserPositions() {
257
257
added_key [ item . key ] = true ;
258
258
}
259
259
}
260
- for ( const item of graph_positions ) {
261
- if ( ! added_key [ item . key ] ) {
262
- unique_positions . push ( item ) ;
263
- added_key [ item . key ] = true ;
264
- }
265
- }
260
+ // for (const item of graph_positions) {
261
+ // if (!added_key[item.key]) {
262
+ // unique_positions.push(item);
263
+ // added_key[item.key] = true;
264
+ // }
265
+ // }
266
266
267
267
positions . set ( unique_positions ) ;
268
268
setActiveProducts ( ) ;
0 commit comments