Spaces:
Runtime error
Runtime error
# -*- coding: utf-8 -*- | |
# ------------------------------------------------------------------------------ | |
# | |
# Copyright 2024 Valory AG | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
# ------------------------------------------------------------------------------ | |
from string import Template | |
FPMMS_FIELD = "fixedProductMarketMakers" | |
QUERY_FIELD = "query" | |
ERROR_FIELD = "errors" | |
DATA_FIELD = "data" | |
ID_FIELD = "id" | |
ANSWER_FIELD = "currentAnswer" | |
QUESTION_FIELD = "question" | |
OUTCOMES_FIELD = "outcomes" | |
TITLE_FIELD = "title" | |
ANSWER_TIMESTAMP_FIELD = "currentAnswerTimestamp" | |
OPENING_TIMESTAMP_FIELD = "openingTimestamp" | |
RESOLUTION_TIMESTAMP_FIELD = "resolutionTimestamp" | |
CREATION_TIMESTAMP_FIELD = "creationTimestamp" | |
LIQUIDITY_FIELD = "liquidityParameter" | |
LIQUIDIY_MEASURE_FIELD = "liquidityMeasure" | |
TOKEN_AMOUNTS_FIELD = "outcomeTokenAmounts" | |
FPMMS_QUERY = Template( | |
""" | |
{ | |
${fpmms_field}( | |
where: { | |
creator: "${creator}", | |
id_gt: "${fpmm_id}", | |
isPendingArbitration: false | |
}, | |
orderBy: ${id_field} | |
first: ${first} | |
){ | |
${id_field} | |
${answer_field} | |
${question_field} { | |
${outcomes_field} | |
} | |
${title_field} | |
} | |
} | |
""" | |
) | |
omen_xdai_trades_query = Template( | |
""" | |
{ | |
fpmmTrades( | |
where: { | |
type: Buy, | |
fpmm_: { | |
creator: "${fpmm_creator}" | |
creationTimestamp_gte: "${fpmm_creationTimestamp_gte}", | |
creationTimestamp_lt: "${fpmm_creationTimestamp_lte}" | |
}, | |
creationTimestamp_gte: "${creationTimestamp_gte}", | |
creationTimestamp_lte: "${creationTimestamp_lte}" | |
id_gt: "${id_gt}" | |
} | |
first: ${first} | |
orderBy: id | |
orderDirection: asc | |
) { | |
id | |
title | |
collateralToken | |
outcomeTokenMarginalPrice | |
oldOutcomeTokenMarginalPrice | |
type | |
creator { | |
id | |
} | |
creationTimestamp | |
collateralAmount | |
collateralAmountUSD | |
feeAmount | |
outcomeIndex | |
outcomeTokensTraded | |
transactionHash | |
fpmm { | |
id | |
outcomes | |
title | |
answerFinalizedTimestamp | |
currentAnswer | |
isPendingArbitration | |
arbitrationOccurred | |
openingTimestamp | |
condition { | |
id | |
} | |
} | |
} | |
} | |
""" | |
) | |
conditional_tokens_gc_user_query = Template( | |
""" | |
{ | |
user(id: "${id}") { | |
userPositions( | |
first: ${first} | |
where: { | |
id_gt: "${userPositions_id_gt}" | |
} | |
orderBy: id | |
) { | |
balance | |
id | |
position { | |
id | |
conditionIds | |
} | |
totalBalance | |
wrappedBalance | |
} | |
} | |
} | |
""" | |
) | |
TRADES_QUERY = """ | |
query fpmms_query($fpmm: String, $id_gt: ID) { | |
fpmmTrades( | |
where: {fpmm: $fpmm, id_gt: $id_gt, type: Buy} | |
orderBy: id | |
orderDirection: asc | |
first: 1000 | |
) { | |
collateralAmount | |
outcomeIndex | |
outcomeTokensTraded | |
id | |
oldOutcomeTokenMarginalPrice | |
outcomeTokenMarginalPrice | |
type | |
collateralAmountUSD | |
creationTimestamp | |
feeAmount | |
} | |
} | |
""" | |