# -*- 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_WITH_TOKENS_QUERY = Template( """ { ${fpmms_field}( where: { creator: "${creator}", id_gt: "${fpmm_id}", isPendingArbitration: false, currentAnswer: null, openingTimestamp_gt:${current_timestamp}, outcomeTokenAmounts_not: ["0","0"] }, orderBy: ${id_field} orderDirection: asc first: ${first} ){ ${id_field} ${question_field} { ${outcomes_field} ${answer_timestamp_field} answers{ answer } } ${title_field} ${opening_timestamp_field} ${creation_timestamp_field} ${liquidity_field} ${liquidity_measure_field} ${token_amounts_field} } } """ ) omen_trader_votes_query = Template( """ { fpmmTrades( where: { type: Buy, fpmm_: { creator: "${fpmm_creator}", id: "${fpmm_id}", }, 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 condition { id } } } } """ )