Author SHA1 Message Date
neeraj 339d6a0076 Upgrade package version 2024-06-06 19:01:06 +05:30
neeraj 76dab080e7 Update README and config 2024-06-06 18:54:52 +05:30
neeraj 760f1ddad9 Generate sushiswap legacy watcher 2024-06-06 18:54:52 +05:30
138 changed files with 9984 additions and 1575 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "azimuth-watcher-ts",
"name": "sushiswap-watcher-ts",
"private": true,
"license": "AGPL-3.0",
"workspaces": {
@@ -1,291 +0,0 @@
{
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_bentoBox",
"type": "address"
},
{
"internalType": "address[]",
"name": "priviledgedUserList",
"type": "address[]"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "tokenIn",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "tokenOut",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOutMin",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"name": "Route",
"type": "event"
},
{
"inputs": [],
"name": "bentoBox",
"outputs": [
{
"internalType": "contract IBentoBoxMinimal",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pause",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenIn",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"internalType": "address",
"name": "tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountOutMin",
"type": "uint256"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "bytes",
"name": "route",
"type": "bytes"
}
],
"name": "processRoute",
"outputs": [
{
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "resume",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "bool",
"name": "priviledge",
"type": "bool"
}
],
"name": "setPriviledge",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "transferValueTo",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountValueTransfer",
"type": "uint256"
},
{
"internalType": "address",
"name": "tokenIn",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"internalType": "address",
"name": "tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountOutMin",
"type": "uint256"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "bytes",
"name": "route",
"type": "bytes"
}
],
"name": "transferValueAndprocessRoute",
"outputs": [
{
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "int256",
"name": "amount0Delta",
"type": "int256"
},
{
"internalType": "int256",
"name": "amount1Delta",
"type": "int256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "uniswapV3SwapCallback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
]
}
@@ -1,37 +0,0 @@
query events($blockHash: String!, $contractAddress: String!, $name: String){
events(blockHash: $blockHash, contractAddress: $contractAddress, name: $name){
block{
cid
hash
number
timestamp
parentHash
}
tx{
hash
index
from
to
}
contract
eventIndex
event{
... on OwnershipTransferredEvent {
previousOwner
newOwner
}
... on RouteEvent {
from
to
tokenIn
tokenOut
amountIn
amountOutMin
amountOut
}
}
proof{
data
}
}
}
@@ -1,37 +0,0 @@
query eventsInRange($fromBlockNumber: Int!, $toBlockNumber: Int!){
eventsInRange(fromBlockNumber: $fromBlockNumber, toBlockNumber: $toBlockNumber){
block{
cid
hash
number
timestamp
parentHash
}
tx{
hash
index
from
to
}
contract
eventIndex
event{
... on OwnershipTransferredEvent {
previousOwner
newOwner
}
... on RouteEvent {
from
to
tokenIn
tokenOut
amountIn
amountOutMin
amountOut
}
}
proof{
data
}
}
}
@@ -1,15 +0,0 @@
import fs from 'fs';
import path from 'path';
export const events = fs.readFileSync(path.join(__dirname, 'events.gql'), 'utf8');
export const eventsInRange = fs.readFileSync(path.join(__dirname, 'eventsInRange.gql'), 'utf8');
export const routeProcessor = fs.readFileSync(path.join(__dirname, 'routeProcessor.gql'), 'utf8');
export const routeProcessors = fs.readFileSync(path.join(__dirname, 'routeProcessors.gql'), 'utf8');
export const route = fs.readFileSync(path.join(__dirname, 'route.gql'), 'utf8');
export const routes = fs.readFileSync(path.join(__dirname, 'routes.gql'), 'utf8');
export const user = fs.readFileSync(path.join(__dirname, 'user.gql'), 'utf8');
export const users = fs.readFileSync(path.join(__dirname, 'users.gql'), 'utf8');
export const _meta = fs.readFileSync(path.join(__dirname, '_meta.gql'), 'utf8');
export const getStateByCID = fs.readFileSync(path.join(__dirname, 'getStateByCID.gql'), 'utf8');
export const getState = fs.readFileSync(path.join(__dirname, 'getState.gql'), 'utf8');
export const getSyncStatus = fs.readFileSync(path.join(__dirname, 'getSyncStatus.gql'), 'utf8');
@@ -1,13 +0,0 @@
query route($id: ID!, $block: Block_height){
route(id: $id, block: $block){
id
from
to
tokenIn
tokenOut
amountIn
amountOutMin
amountOut
timestamp
}
}
@@ -1,7 +0,0 @@
query routeProcessor($id: ID!, $block: Block_height){
routeProcessor(id: $id, block: $block){
id
routeCount
userCount
}
}
@@ -1,7 +0,0 @@
query routeProcessors($block: Block_height, $where: RouteProcessor_filter, $orderBy: RouteProcessor_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
routeProcessors(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
routeCount
userCount
}
}
@@ -1,13 +0,0 @@
query routes($block: Block_height, $where: Route_filter, $orderBy: Route_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
routes(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
from
to
tokenIn
tokenOut
amountIn
amountOutMin
amountOut
timestamp
}
}
@@ -1,6 +0,0 @@
query user($id: ID!, $block: Block_height){
user(id: $id, block: $block){
id
routeCount
}
}
@@ -1,37 +0,0 @@
subscription onEvent{
onEvent{
block{
cid
hash
number
timestamp
parentHash
}
tx{
hash
index
from
to
}
contract
eventIndex
event{
... on OwnershipTransferredEvent {
previousOwner
newOwner
}
... on RouteEvent {
from
to
tokenIn
tokenOut
amountIn
amountOutMin
amountOut
}
}
proof{
data
}
}
}
@@ -1,380 +0,0 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import assert from 'assert';
import debug from 'debug';
import { GraphQLResolveInfo } from 'graphql';
import { ExpressContext } from 'apollo-server-express';
import winston from 'winston';
import {
gqlTotalQueryCount,
gqlQueryCount,
gqlQueryDuration,
getResultState,
IndexerInterface,
GraphQLBigInt,
GraphQLBigDecimal,
BlockHeight,
OrderDirection,
jsonBigIntStringReplacer,
EventWatcher,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
setGQLCacheHints
} from '@cerc-io/util';
import { Indexer } from './indexer';
import { RouteProcessor } from './entity/RouteProcessor';
import { Route } from './entity/Route';
import { User } from './entity/User';
const log = debug('vulcanize:resolver');
const executeAndRecordMetrics = async (
indexer: Indexer,
gqlLogger: winston.Logger,
opName: string,
expressContext: ExpressContext,
operation: () => Promise<any>
) => {
gqlTotalQueryCount.inc(1);
gqlQueryCount.labels(opName).inc(1);
const endTimer = gqlQueryDuration.labels(opName).startTimer();
try {
const [result, syncStatus] = await Promise.all([
operation(),
indexer.getSyncStatus()
]);
gqlLogger.info({
opName,
query: expressContext.req.body.query,
variables: expressContext.req.body.variables,
latestIndexedBlockNumber: syncStatus?.latestIndexedBlockNumber,
urlPath: expressContext.req.path,
apiKey: expressContext.req.header('x-api-key'),
origin: expressContext.req.headers.origin
});
return result;
} catch (error) {
gqlLogger.error({
opName,
error,
query: expressContext.req.body.query,
variables: expressContext.req.body.variables,
urlPath: expressContext.req.path,
apiKey: expressContext.req.header('x-api-key'),
origin: expressContext.req.headers.origin
});
} finally {
endTimer();
}
};
export const createResolvers = async (
indexerArg: IndexerInterface,
eventWatcher: EventWatcher,
gqlLogger: winston.Logger
): Promise<any> => {
const indexer = indexerArg as Indexer;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const gqlCacheConfig = indexer.serverConfig.gql.cache;
return {
BigInt: GraphQLBigInt,
BigDecimal: GraphQLBigDecimal,
Event: {
__resolveType: (obj: any) => {
assert(obj.__typename);
return obj.__typename;
}
},
Subscription: {
onEvent: {
subscribe: () => eventWatcher.getEventIterator()
}
},
Mutation: {
watchContract: async (_: any, { address, kind, checkpoint, startingBlock = 1 }: { address: string, kind: string, checkpoint: boolean, startingBlock: number }): Promise<boolean> => {
log('watchContract', address, kind, checkpoint, startingBlock);
await indexer.watchContract(address, kind, checkpoint, startingBlock);
return true;
}
},
Query: {
routeProcessor: async (
_: any,
{ id, block = {} }: { id: string, block: BlockHeight },
expressContext: ExpressContext,
info: GraphQLResolveInfo
) => {
log('routeProcessor', id, JSON.stringify(block, jsonBigIntStringReplacer));
// Set cache-control hints
// setGQLCacheHints(info, block, gqlCacheConfig);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'routeProcessor',
expressContext,
async () => indexer.getSubgraphEntity(RouteProcessor, id, block, info)
);
},
routeProcessors: async (
_: any,
{ block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
expressContext: ExpressContext,
info: GraphQLResolveInfo
) => {
log('routeProcessors', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
// Set cache-control hints
// setGQLCacheHints(info, block, gqlCacheConfig);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'routeProcessors',
expressContext,
async () => indexer.getSubgraphEntities(
RouteProcessor,
block,
where,
{ limit: first, skip, orderBy, orderDirection },
info
)
);
},
route: async (
_: any,
{ id, block = {} }: { id: string, block: BlockHeight },
expressContext: ExpressContext,
info: GraphQLResolveInfo
) => {
log('route', id, JSON.stringify(block, jsonBigIntStringReplacer));
// Set cache-control hints
// setGQLCacheHints(info, block, gqlCacheConfig);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'route',
expressContext,
async () => indexer.getSubgraphEntity(Route, id, block, info)
);
},
routes: async (
_: any,
{ block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
expressContext: ExpressContext,
info: GraphQLResolveInfo
) => {
log('routes', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
// Set cache-control hints
// setGQLCacheHints(info, block, gqlCacheConfig);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'routes',
expressContext,
async () => indexer.getSubgraphEntities(
Route,
block,
where,
{ limit: first, skip, orderBy, orderDirection },
info
)
);
},
user: async (
_: any,
{ id, block = {} }: { id: string, block: BlockHeight },
expressContext: ExpressContext,
info: GraphQLResolveInfo
) => {
log('user', id, JSON.stringify(block, jsonBigIntStringReplacer));
// Set cache-control hints
// setGQLCacheHints(info, block, gqlCacheConfig);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'user',
expressContext,
async () => indexer.getSubgraphEntity(User, id, block, info)
);
},
users: async (
_: any,
{ block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
expressContext: ExpressContext,
info: GraphQLResolveInfo
) => {
log('users', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
// Set cache-control hints
// setGQLCacheHints(info, block, gqlCacheConfig);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'users',
expressContext,
async () => indexer.getSubgraphEntities(
User,
block,
where,
{ limit: first, skip, orderBy, orderDirection },
info
)
);
},
events: async (
_: any,
{ blockHash, contractAddress, name }: { blockHash: string, contractAddress: string, name?: string },
expressContext: ExpressContext
) => {
log('events', blockHash, contractAddress, name);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'events',
expressContext,
async () => {
const block = await indexer.getBlockProgress(blockHash);
if (!block || !block.isComplete) {
throw new Error(`Block hash ${blockHash} number ${block?.blockNumber} not processed yet`);
}
const events = await indexer.getEventsByFilter(blockHash, contractAddress, name);
return events.map(event => indexer.getResultEvent(event));
}
);
},
eventsInRange: async (
_: any,
{ fromBlockNumber, toBlockNumber }: { fromBlockNumber: number, toBlockNumber: number },
expressContext: ExpressContext
) => {
log('eventsInRange', fromBlockNumber, toBlockNumber);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'eventsInRange',
expressContext,
async () => {
const syncStatus = await indexer.getSyncStatus();
if (!syncStatus) {
throw new Error('No blocks processed yet');
}
if ((fromBlockNumber < syncStatus.initialIndexedBlockNumber) || (toBlockNumber > syncStatus.latestProcessedBlockNumber)) {
throw new Error(`Block range should be between ${syncStatus.initialIndexedBlockNumber} and ${syncStatus.latestProcessedBlockNumber}`);
}
const events = await indexer.getEventsInRange(fromBlockNumber, toBlockNumber);
return events.map(event => indexer.getResultEvent(event));
}
);
},
getStateByCID: async (
_: any,
{ cid }: { cid: string },
expressContext: ExpressContext
) => {
log('getStateByCID', cid);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'getStateByCID',
expressContext,
async () => {
const state = await indexer.getStateByCID(cid);
return state && state.block.isComplete ? getResultState(state) : undefined;
}
);
},
getState: async (
_: any,
{ blockHash, contractAddress, kind }: { blockHash: string, contractAddress: string, kind: string },
expressContext: ExpressContext
) => {
log('getState', blockHash, contractAddress, kind);
return executeAndRecordMetrics(
indexer,
gqlLogger,
'getState',
expressContext,
async () => {
const state = await indexer.getPrevState(blockHash, contractAddress, kind);
return state && state.block.isComplete ? getResultState(state) : undefined;
}
);
},
_meta: async (
_: any,
{ block = {} }: { block: BlockHeight },
expressContext: ExpressContext
) => {
log('_meta');
return executeAndRecordMetrics(
indexer,
gqlLogger,
'_meta',
expressContext,
async () => indexer.getMetaData(block)
);
},
getSyncStatus: async (
_: any,
__: Record<string, never>,
expressContext: ExpressContext
) => {
log('getSyncStatus');
return executeAndRecordMetrics(
indexer,
gqlLogger,
'getSyncStatus',
expressContext,
async () => indexer.getSyncStatus()
);
}
}
};
};
@@ -1,309 +0,0 @@
directive @cacheControl(maxAge: Int, inheritMaxAge: Boolean, scope: CacheControlScope) on FIELD_DEFINITION | OBJECT | INTERFACE | UNION
enum CacheControlScope {
PUBLIC
PRIVATE
}
scalar BigInt
scalar BigDecimal
scalar Bytes
type Proof {
data: String!
}
type _Block_ {
cid: String
hash: String!
number: Int!
timestamp: Int!
parentHash: String!
}
type _Transaction_ {
hash: String!
index: Int!
from: String!
to: String!
}
type ResultEvent {
block: _Block_!
tx: _Transaction_!
contract: String!
eventIndex: Int!
event: Event!
proof: Proof
}
union Event = OwnershipTransferredEvent | RouteEvent
type OwnershipTransferredEvent {
previousOwner: String!
newOwner: String!
}
type RouteEvent {
from: String!
to: String!
tokenIn: String!
tokenOut: String!
amountIn: BigInt!
amountOutMin: BigInt!
amountOut: BigInt!
}
input Block_height {
hash: Bytes
number: Int
}
input BlockChangedFilter {
number_gte: Int!
}
enum OrderDirection {
asc
desc
}
enum RouteProcessor_orderBy {
id
routeCount
userCount
}
input RouteProcessor_filter {
id: ID
id_not: ID
id_gt: ID
id_lt: ID
id_gte: ID
id_lte: ID
id_in: [ID!]
id_not_in: [ID!]
routeCount: BigInt
routeCount_not: BigInt
routeCount_gt: BigInt
routeCount_lt: BigInt
routeCount_gte: BigInt
routeCount_lte: BigInt
routeCount_in: [BigInt!]
routeCount_not_in: [BigInt!]
userCount: BigInt
userCount_not: BigInt
userCount_gt: BigInt
userCount_lt: BigInt
userCount_gte: BigInt
userCount_lte: BigInt
userCount_in: [BigInt!]
userCount_not_in: [BigInt!]
_change_block: BlockChangedFilter
and: [RouteProcessor_filter]
or: [RouteProcessor_filter]
}
enum Route_orderBy {
id
from
to
tokenIn
tokenOut
amountIn
amountOutMin
amountOut
timestamp
}
input Route_filter {
id: ID
id_not: ID
id_gt: ID
id_lt: ID
id_gte: ID
id_lte: ID
id_in: [ID!]
id_not_in: [ID!]
from: Bytes
from_not: Bytes
from_gt: Bytes
from_lt: Bytes
from_gte: Bytes
from_lte: Bytes
from_in: [Bytes!]
from_not_in: [Bytes!]
from_contains: Bytes
from_not_contains: Bytes
to: Bytes
to_not: Bytes
to_gt: Bytes
to_lt: Bytes
to_gte: Bytes
to_lte: Bytes
to_in: [Bytes!]
to_not_in: [Bytes!]
to_contains: Bytes
to_not_contains: Bytes
tokenIn: Bytes
tokenIn_not: Bytes
tokenIn_gt: Bytes
tokenIn_lt: Bytes
tokenIn_gte: Bytes
tokenIn_lte: Bytes
tokenIn_in: [Bytes!]
tokenIn_not_in: [Bytes!]
tokenIn_contains: Bytes
tokenIn_not_contains: Bytes
tokenOut: Bytes
tokenOut_not: Bytes
tokenOut_gt: Bytes
tokenOut_lt: Bytes
tokenOut_gte: Bytes
tokenOut_lte: Bytes
tokenOut_in: [Bytes!]
tokenOut_not_in: [Bytes!]
tokenOut_contains: Bytes
tokenOut_not_contains: Bytes
amountIn: BigInt
amountIn_not: BigInt
amountIn_gt: BigInt
amountIn_lt: BigInt
amountIn_gte: BigInt
amountIn_lte: BigInt
amountIn_in: [BigInt!]
amountIn_not_in: [BigInt!]
amountOutMin: BigInt
amountOutMin_not: BigInt
amountOutMin_gt: BigInt
amountOutMin_lt: BigInt
amountOutMin_gte: BigInt
amountOutMin_lte: BigInt
amountOutMin_in: [BigInt!]
amountOutMin_not_in: [BigInt!]
amountOut: BigInt
amountOut_not: BigInt
amountOut_gt: BigInt
amountOut_lt: BigInt
amountOut_gte: BigInt
amountOut_lte: BigInt
amountOut_in: [BigInt!]
amountOut_not_in: [BigInt!]
timestamp: BigInt
timestamp_not: BigInt
timestamp_gt: BigInt
timestamp_lt: BigInt
timestamp_gte: BigInt
timestamp_lte: BigInt
timestamp_in: [BigInt!]
timestamp_not_in: [BigInt!]
_change_block: BlockChangedFilter
and: [Route_filter]
or: [Route_filter]
}
enum User_orderBy {
id
routeCount
}
input User_filter {
id: ID
id_not: ID
id_gt: ID
id_lt: ID
id_gte: ID
id_lte: ID
id_in: [ID!]
id_not_in: [ID!]
routeCount: BigInt
routeCount_not: BigInt
routeCount_gt: BigInt
routeCount_lt: BigInt
routeCount_gte: BigInt
routeCount_lte: BigInt
routeCount_in: [BigInt!]
routeCount_not_in: [BigInt!]
_change_block: BlockChangedFilter
and: [User_filter]
or: [User_filter]
}
type _MetaBlock_ {
hash: Bytes
number: Int!
timestamp: Int
}
type _Meta_ {
block: _MetaBlock_!
deployment: String!
hasIndexingErrors: Boolean!
}
type ResultState {
block: _Block_!
contractAddress: String!
cid: String!
kind: String!
data: String!
}
type SyncStatus {
latestIndexedBlockHash: String!
latestIndexedBlockNumber: Int!
latestCanonicalBlockHash: String!
latestCanonicalBlockNumber: Int!
initialIndexedBlockHash: String!
initialIndexedBlockNumber: Int!
latestProcessedBlockHash: String!
latestProcessedBlockNumber: Int!
}
type Query {
events(blockHash: String!, contractAddress: String!, name: String): [ResultEvent!]
eventsInRange(fromBlockNumber: Int!, toBlockNumber: Int!): [ResultEvent!]
routeProcessor(id: ID!, block: Block_height): RouteProcessor
routeProcessors(block: Block_height, where: RouteProcessor_filter, orderBy: RouteProcessor_orderBy, orderDirection: OrderDirection, first: Int = 100, skip: Int = 0): [RouteProcessor!]!
route(id: ID!, block: Block_height): Route
routes(block: Block_height, where: Route_filter, orderBy: Route_orderBy, orderDirection: OrderDirection, first: Int = 100, skip: Int = 0): [Route!]!
user(id: ID!, block: Block_height): User
users(block: Block_height, where: User_filter, orderBy: User_orderBy, orderDirection: OrderDirection, first: Int = 100, skip: Int = 0): [User!]!
_meta(block: Block_height): _Meta_
getStateByCID(cid: String!): ResultState
getState(blockHash: String!, contractAddress: String!, kind: String): ResultState
getSyncStatus: SyncStatus
}
type RouteProcessor {
id: ID!
routeCount: BigInt!
userCount: BigInt!
}
type Route {
id: ID!
from: Bytes!
to: Bytes!
tokenIn: Bytes!
tokenOut: Bytes!
amountIn: BigInt!
amountOutMin: BigInt!
amountOut: BigInt!
timestamp: BigInt!
}
type User {
id: ID!
routeCount: BigInt!
}
type Mutation {
watchContract(address: String!, kind: String!, checkpoint: Boolean!, startingBlock: Int): Boolean!
}
type Subscription {
onEvent: ResultEvent!
}
@@ -1,3 +0,0 @@
//
// Copyright 2021 Vulcanize, Inc.
//
@@ -1,289 +0,0 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_bentoBox",
"type": "address"
},
{
"internalType": "address[]",
"name": "priviledgedUserList",
"type": "address[]"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "tokenIn",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "tokenOut",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOutMin",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"name": "Route",
"type": "event"
},
{
"inputs": [],
"name": "bentoBox",
"outputs": [
{
"internalType": "contract IBentoBoxMinimal",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pause",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenIn",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"internalType": "address",
"name": "tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountOutMin",
"type": "uint256"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "bytes",
"name": "route",
"type": "bytes"
}
],
"name": "processRoute",
"outputs": [
{
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "resume",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "bool",
"name": "priviledge",
"type": "bool"
}
],
"name": "setPriviledge",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "transferValueTo",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountValueTransfer",
"type": "uint256"
},
{
"internalType": "address",
"name": "tokenIn",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"internalType": "address",
"name": "tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "amountOutMin",
"type": "uint256"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "bytes",
"name": "route",
"type": "bytes"
}
],
"name": "transferValueAndprocessRoute",
"outputs": [
{
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "int256",
"name": "amount0Delta",
"type": "int256"
},
{
"internalType": "int256",
"name": "amount1Delta",
"type": "int256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "uniswapV3SwapCallback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
]
@@ -1,38 +0,0 @@
type RouteProcessor @entity {
# route processor address
id: ID!
# amount of routes processed
routeCount: BigInt!
# amount of users
userCount: BigInt!
}
type Route @entity {
# tx hash - tx index
id: ID!
# from address
from: Bytes!
# to address
to: Bytes!
# tokenIn address
tokenIn: Bytes!
# tokenOut address
tokenOut: Bytes!
# amount of tokenIn
amountIn: BigInt!
# min amount of tokenOut
amountOutMin: BigInt!
# amount of tokenOut
amountOut: BigInt!
# timestamp
timestamp: BigInt!
}
type User @entity {
# user address
id: ID!
# amount of routes processed
routeCount: BigInt!
# list of routes processed
#routes: [Route!]! @derivedFrom(field: "from")
}
@@ -1,24 +0,0 @@
specVersion: 0.0.4
schema:
file: schema.graphql
dataSources:
- kind: ethereum/contract
name: RouteProcessor
network: mainnet
source:
address: "0x1f2fcf1d036b375b384012e61d3aa33f8c256bbe"
startBlock: 3685230
abi: RouteProcessor
mapping:
kind: ethereum/events
apiVersion: 0.0.6
language: wasm/assemblyscript
file: RouteProcessor/RouteProcessor.wasm
entities: []
abis:
- name: RouteProcessor
file: RouteProcessor/abis/RouteProcessor3.json
eventHandlers:
- event: Route(indexed address,address,indexed address,indexed
address,uint256,uint256,uint256)
handler: handleRoute
@@ -1,8 +1,8 @@
# route-processor-watcher
# sushiswap-watcher
## Source
* Subgraph: sushiswap-subgraphs v0.1.2-watcher
* Subgraph: sushiswap-subgraphs release-v0.1.0-watcher
## Setup
@@ -16,7 +16,7 @@
```bash
sudo su - postgres
createdb route-processor-watcher
createdb sushiswap-watcher
```
* If the watcher is an `active` watcher:
@@ -24,19 +24,19 @@
Create database for the job queue and enable the `pgcrypto` extension on them (https://github.com/timgit/pg-boss/blob/master/docs/usage.md#intro):
```
createdb route-processor-watcher-job-queue
createdb sushiswap-watcher-job-queue
```
```
postgres@tesla:~$ psql -U postgres -h localhost route-processor-watcher-job-queue
postgres@tesla:~$ psql -U postgres -h localhost sushiswap-watcher-job-queue
Password for user postgres:
psql (12.7 (Ubuntu 12.7-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
route-processor-watcher-job-queue=# CREATE EXTENSION pgcrypto;
sushiswap-watcher-job-queue=# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
route-processor-watcher-job-queue=# exit
sushiswap-watcher-job-queue=# exit
```
* In the [config file](./environments/local.toml):
@@ -56,7 +56,7 @@
type = "postgres"
host = "localhost"
port = 5432
database = "route-processor-watcher"
database = "sushiswap-watcher"
username = "postgres"
password = "postgres"
synchronize = true
@@ -86,7 +86,7 @@
deleteOnStart = false
[jobQueue]
dbConnectionString = "postgres://postgres:postgres@localhost/route-processor-watcher-job-queue"
dbConnectionString = "postgres://postgres:postgres@localhost/sushiswap-watcher-job-queue"
maxCompletionLagInSecs = 300
jobDelayInMilliSecs = 100
eventsInBatch = 50
@@ -1,7 +1,7 @@
{
"name": "@cerc-io/route-processor-watcher",
"name": "@cerc-io/sushiswap-watcher",
"version": "0.1.0",
"description": "route-processor-watcher",
"description": "sushiswap-watcher",
"private": true,
"main": "dist/index.js",
"scripts": {
@@ -39,11 +39,11 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.93",
"@cerc-io/ipld-eth-client": "^0.2.93",
"@cerc-io/solidity-mapper": "^0.2.93",
"@cerc-io/util": "^0.2.93",
"@cerc-io/graph-node": "^0.2.93",
"@cerc-io/cli": "^0.2.94",
"@cerc-io/ipld-eth-client": "^0.2.94",
"@cerc-io/solidity-mapper": "^0.2.94",
"@cerc-io/util": "^0.2.94",
"@cerc-io/graph-node": "^0.2.94",
"@ethersproject/providers": "^5.4.4",
"debug": "^4.3.1",
"decimal.js": "^10.3.1",
@@ -0,0 +1,217 @@
{
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_feeToSetter",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "token0",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "token1",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "pair",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "PairCreated",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "allPairs",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "allPairsLength",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenA",
"type": "address"
},
{
"internalType": "address",
"name": "tokenB",
"type": "address"
}
],
"name": "createPair",
"outputs": [
{
"internalType": "address",
"name": "pair",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "feeTo",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "feeToSetter",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "getPair",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "migrator",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pairCodeHash",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_feeTo",
"type": "address"
}
],
"name": "setFeeTo",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_feeToSetter",
"type": "address"
}
],
"name": "setFeeToSetter",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_migrator",
"type": "address"
}
],
"name": "setMigrator",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
}
@@ -0,0 +1,660 @@
{
"abi": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount0",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount1",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
}
],
"name": "Burn",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount0",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount1",
"type": "uint256"
}
],
"name": "Mint",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount0In",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount1In",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount0Out",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount1Out",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
}
],
"name": "Swap",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint112",
"name": "reserve0",
"type": "uint112"
},
{
"indexed": false,
"internalType": "uint112",
"name": "reserve1",
"type": "uint112"
}
],
"name": "Sync",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [],
"name": "DOMAIN_SEPARATOR",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MINIMUM_LIQUIDITY",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "PERMIT_TYPEHASH",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
}
],
"name": "burn",
"outputs": [
{
"internalType": "uint256",
"name": "amount0",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount1",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "factory",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getReserves",
"outputs": [
{
"internalType": "uint112",
"name": "_reserve0",
"type": "uint112"
},
{
"internalType": "uint112",
"name": "_reserve1",
"type": "uint112"
},
{
"internalType": "uint32",
"name": "_blockTimestampLast",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token0",
"type": "address"
},
{
"internalType": "address",
"name": "_token1",
"type": "address"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "kLast",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
}
],
"name": "mint",
"outputs": [
{
"internalType": "uint256",
"name": "liquidity",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "nonces",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
},
{
"internalType": "uint8",
"name": "v",
"type": "uint8"
},
{
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}
],
"name": "permit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "price0CumulativeLast",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "price1CumulativeLast",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
}
],
"name": "skim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount0Out",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount1Out",
"type": "uint256"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "swap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "sync",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "token0",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "token1",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
}
@@ -21,11 +21,28 @@ import { SyncStatus } from './entity/SyncStatus';
import { StateSyncStatus } from './entity/StateSyncStatus';
import { BlockProgress } from './entity/BlockProgress';
import { State } from './entity/State';
import { RouteProcessor } from './entity/RouteProcessor';
import { Route } from './entity/Route';
import { Factory } from './entity/Factory';
import { Bundle } from './entity/Bundle';
import { Token } from './entity/Token';
import { TokenPrice } from './entity/TokenPrice';
import { _TokenPair } from './entity/_TokenPair';
import { _WhitelistedTokenPair } from './entity/_WhitelistedTokenPair';
import { Pair } from './entity/Pair';
import { User } from './entity/User';
import { LiquidityPosition } from './entity/LiquidityPosition';
import { Mint } from './entity/Mint';
import { Burn } from './entity/Burn';
import { Swap } from './entity/Swap';
import { Transaction } from './entity/Transaction';
import { LiquidityPositionSnapshot } from './entity/LiquidityPositionSnapshot';
import { PairHourSnapshot } from './entity/PairHourSnapshot';
import { PairDaySnapshot } from './entity/PairDaySnapshot';
import { TokenHourSnapshot } from './entity/TokenHourSnapshot';
import { TokenDaySnapshot } from './entity/TokenDaySnapshot';
import { FactoryHourSnapshot } from './entity/FactoryHourSnapshot';
import { FactoryDaySnapshot } from './entity/FactoryDaySnapshot';
export const SUBGRAPH_ENTITIES = new Set([RouteProcessor, Route, User]);
export const SUBGRAPH_ENTITIES = new Set([Factory, Bundle, Token, TokenPrice, _TokenPair, _WhitelistedTokenPair, Pair, User, LiquidityPosition, Mint, Burn, Swap, Transaction, LiquidityPositionSnapshot, PairHourSnapshot, PairDaySnapshot, TokenHourSnapshot, TokenDaySnapshot, FactoryHourSnapshot, FactoryDaySnapshot]);
export const ENTITIES = [...SUBGRAPH_ENTITIES];
// Map: Entity to suitable query type.
export const ENTITY_QUERY_TYPE_MAP = new Map<new() => any, ENTITY_QUERY_TYPE>([]);
@@ -0,0 +1,29 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class Bundle {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('numeric', { transformer: decimalTransformer })
nativePrice!: Decimal;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,65 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class Burn {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
transaction!: string;
@Column('numeric', { transformer: bigintTransformer })
timestamp!: bigint;
@Column('varchar')
pair!: string;
@Column('numeric', { transformer: decimalTransformer })
liquidity!: Decimal;
@Column('varchar', { nullable: true })
sender!: string | null;
@Column('numeric', { nullable: true, transformer: decimalTransformer })
amount0!: Decimal | null;
@Column('numeric', { nullable: true, transformer: decimalTransformer })
amount1!: Decimal | null;
@Column('varchar', { nullable: true })
to!: string | null;
@Column('numeric', { nullable: true, transformer: bigintTransformer })
logIndex!: bigint | null;
@Column('numeric', { nullable: true, transformer: decimalTransformer })
amountUSD!: Decimal | null;
@Column('boolean')
complete!: boolean;
@Column('varchar', { nullable: true })
feeTo!: string | null;
@Column('numeric', { nullable: true, transformer: decimalTransformer })
feeLiquidity!: Decimal | null;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,60 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { PairType } from '../types';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class Factory {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column({ type: 'enum', enum: PairType })
type!: PairType;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
pairCount!: bigint;
@Column('numeric', { transformer: bigintTransformer })
transactionCount!: bigint;
@Column('numeric', { transformer: bigintTransformer })
tokenCount!: bigint;
@Column('numeric', { transformer: bigintTransformer })
userCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,53 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class FactoryDaySnapshot {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
factory!: string;
@Column('integer')
date!: number;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
transactionCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,53 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class FactoryHourSnapshot {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
factory!: string;
@Column('integer')
date!: number;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
transactionCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -7,7 +7,7 @@ import { bigintTransformer } from '@cerc-io/util';
@Entity()
@Index(['blockNumber'])
export class RouteProcessor {
export class LiquidityPosition {
@PrimaryColumn('varchar')
id!: string;
@@ -17,11 +17,20 @@ export class RouteProcessor {
@Column('integer')
blockNumber!: number;
@Column('numeric', { transformer: bigintTransformer })
routeCount!: bigint;
@Column('varchar')
pair!: string;
@Column('varchar')
user!: string;
@Column('numeric', { transformer: bigintTransformer })
userCount!: bigint;
balance!: bigint;
@Column('numeric', { transformer: bigintTransformer })
createdAtBlock!: bigint;
@Column('numeric', { transformer: bigintTransformer })
createdAtTimestamp!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@@ -0,0 +1,62 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class LiquidityPositionSnapshot {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
liquidityPosition!: string;
@Column('integer')
timestamp!: number;
@Column('integer')
block!: number;
@Column('varchar')
user!: string;
@Column('varchar')
pair!: string;
@Column('numeric', { transformer: decimalTransformer })
token0PriceUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
token1PriceUSD!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
reserve0!: bigint;
@Column('numeric', { transformer: bigintTransformer })
reserve1!: bigint;
@Column('numeric', { transformer: decimalTransformer })
reserveUSD!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
liquidityTokenTotalSupply!: bigint;
@Column('numeric', { transformer: bigintTransformer })
liquidityTokenBalance!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,62 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class Mint {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
transaction!: string;
@Column('numeric', { transformer: bigintTransformer })
timestamp!: bigint;
@Column('varchar')
pair!: string;
@Column('varchar')
to!: string;
@Column('numeric', { transformer: decimalTransformer })
liquidity!: Decimal;
@Column('varchar', { nullable: true })
sender!: string | null;
@Column('numeric', { nullable: true, transformer: decimalTransformer })
amount0!: Decimal | null;
@Column('numeric', { nullable: true, transformer: decimalTransformer })
amount1!: Decimal | null;
@Column('numeric', { nullable: true, transformer: bigintTransformer })
logIndex!: bigint | null;
@Column('numeric', { nullable: true, transformer: decimalTransformer })
amountUSD!: Decimal | null;
@Column('varchar', { nullable: true })
feeTo!: string | null;
@Column('numeric', { nullable: true, transformer: decimalTransformer })
feeLiquidity!: Decimal | null;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,105 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { PairType } from '../types';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class Pair {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column({ type: 'enum', enum: PairType })
type!: PairType;
@Column('numeric', { transformer: bigintTransformer })
swapFee!: bigint;
@Column('boolean')
twapEnabled!: boolean;
@Column('varchar')
name!: string;
@Column('varchar')
token0!: string;
@Column('varchar')
token1!: string;
@Column('varchar')
source!: string;
@Column('numeric', { transformer: bigintTransformer })
createdAtBlock!: bigint;
@Column('numeric', { transformer: bigintTransformer })
createdAtTimestamp!: bigint;
@Column('numeric', { transformer: bigintTransformer })
reserve0!: bigint;
@Column('numeric', { transformer: bigintTransformer })
reserve1!: bigint;
@Column('numeric', { transformer: bigintTransformer })
liquidity!: bigint;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
trackedLiquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
token0Price!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
token1Price!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeToken0!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeToken1!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
apr!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
aprUpdatedAtTimestamp!: bigint;
@Column('numeric', { transformer: bigintTransformer })
txCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,68 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class PairDaySnapshot {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
pair!: string;
@Column('integer')
date!: number;
@Column('numeric', { transformer: decimalTransformer })
cumulativeVolumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeToken0!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeToken1!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidity!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
apr!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
transactionCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,68 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class PairHourSnapshot {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
pair!: string;
@Column('integer')
date!: number;
@Column('numeric', { transformer: decimalTransformer })
cumulativeVolumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeToken0!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeToken1!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidity!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
apr!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
transactionCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,59 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class Swap {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
transaction!: string;
@Column('numeric', { transformer: bigintTransformer })
timestamp!: bigint;
@Column('varchar')
pair!: string;
@Column('varchar')
sender!: string;
@Column('varchar')
tokenIn!: string;
@Column('varchar')
tokenOut!: string;
@Column('numeric', { transformer: decimalTransformer })
amountIn!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
amountOut!: Decimal;
@Column('varchar')
to!: string;
@Column('numeric', { nullable: true, transformer: bigintTransformer })
logIndex!: bigint | null;
@Column('numeric', { transformer: decimalTransformer })
amountUSD!: Decimal;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,80 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class Token {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
price!: string;
@Column('varchar')
symbol!: string;
@Column('boolean')
symbolSuccess!: boolean;
@Column('varchar')
name!: string;
@Column('boolean')
nameSuccess!: boolean;
@Column('numeric', { transformer: bigintTransformer })
decimals!: bigint;
@Column('boolean')
decimalsSuccess!: boolean;
@Column('numeric', { transformer: bigintTransformer })
liquidity!: bigint;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volume!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
txCount!: bigint;
@Column('numeric', { transformer: bigintTransformer })
pairCount!: bigint;
@Column('numeric', { transformer: bigintTransformer })
whitelistedPairCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,65 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class TokenDaySnapshot {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('integer')
date!: number;
@Column('varchar')
token!: string;
@Column('numeric', { transformer: decimalTransformer })
liquidity!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volume!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
priceNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
priceUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
transactionCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,65 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class TokenHourSnapshot {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('integer')
date!: number;
@Column('varchar')
token!: string;
@Column('numeric', { transformer: decimalTransformer })
liquidity!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
liquidityUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volume!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
volumeUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
priceNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
priceUSD!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
feesUSD!: Decimal;
@Column('numeric', { transformer: bigintTransformer })
transactionCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,41 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';
@Entity()
@Index(['blockNumber'])
export class TokenPrice {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
token!: string;
@Column('numeric', { transformer: decimalTransformer })
derivedNative!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
lastUsdPrice!: Decimal;
@Column('varchar', { nullable: true })
pricedOffToken!: string | null;
@Column('varchar', { nullable: true })
pricedOffPair!: string | null;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -7,7 +7,7 @@ import { bigintTransformer } from '@cerc-io/util';
@Entity()
@Index(['blockNumber'])
export class Route {
export class Transaction {
@PrimaryColumn('varchar')
id!: string;
@@ -17,29 +17,26 @@ export class Route {
@Column('integer')
blockNumber!: number;
@Column('varchar')
from!: string;
@Column('varchar')
to!: string;
@Column('varchar')
tokenIn!: string;
@Column('varchar')
tokenOut!: string;
@Column('numeric', { transformer: bigintTransformer })
gasLimit!: bigint;
@Column('numeric', { transformer: bigintTransformer })
amountIn!: bigint;
gasPrice!: bigint;
@Column('varchar', { array: true })
mints!: string[];
@Column('varchar', { array: true })
burns!: string[];
@Column('varchar', { array: true })
swaps!: string[];
@Column('numeric', { transformer: bigintTransformer })
amountOutMin!: bigint;
createdAtBlock!: bigint;
@Column('numeric', { transformer: bigintTransformer })
amountOut!: bigint;
@Column('numeric', { transformer: bigintTransformer })
timestamp!: bigint;
createdAtTimestamp!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@@ -18,7 +18,7 @@ export class User {
blockNumber!: number;
@Column('numeric', { transformer: bigintTransformer })
routeCount!: bigint;
lpSnapshotsCount!: bigint;
@Column('boolean', { default: false })
isPruned!: boolean;
@@ -0,0 +1,30 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
@Entity()
@Index(['blockNumber'])
export class _TokenPair {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
pair!: string;
@Column('varchar')
token!: string;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,30 @@
//
// Copyright 2021 Vulcanize, Inc.
//
import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
@Entity()
@Index(['blockNumber'])
export class _WhitelistedTokenPair {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('varchar', { length: 66 })
blockHash!: string;
@Column('integer')
blockNumber!: number;
@Column('varchar')
pair!: string;
@Column('varchar')
token!: string;
@Column('boolean', { default: false })
isPruned!: boolean;
@Column('boolean', { default: false })
isRemoved!: boolean;
}
@@ -0,0 +1,52 @@
query _TokenPair($id: ID!, $block: Block_height){
_TokenPair(id: $id, block: $block){
id
pair{
id
type
swapFee
twapEnabled
name
source
createdAtBlock
createdAtTimestamp
reserve0
reserve1
liquidity
liquidityUSD
liquidityNative
trackedLiquidityNative
token0Price
token1Price
volumeNative
volumeUSD
volumeToken0
volumeToken1
feesNative
feesUSD
apr
aprUpdatedAtTimestamp
txCount
}
token{
id
symbol
symbolSuccess
name
nameSuccess
decimals
decimalsSuccess
liquidity
liquidityNative
liquidityUSD
volume
volumeNative
volumeUSD
feesNative
feesUSD
txCount
pairCount
whitelistedPairCount
}
}
}
@@ -0,0 +1,52 @@
query _TokenPairs($block: Block_height, $where: _TokenPair_filter, $orderBy: _TokenPair_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
_TokenPairs(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
pair{
id
type
swapFee
twapEnabled
name
source
createdAtBlock
createdAtTimestamp
reserve0
reserve1
liquidity
liquidityUSD
liquidityNative
trackedLiquidityNative
token0Price
token1Price
volumeNative
volumeUSD
volumeToken0
volumeToken1
feesNative
feesUSD
apr
aprUpdatedAtTimestamp
txCount
}
token{
id
symbol
symbolSuccess
name
nameSuccess
decimals
decimalsSuccess
liquidity
liquidityNative
liquidityUSD
volume
volumeNative
volumeUSD
feesNative
feesUSD
txCount
pairCount
whitelistedPairCount
}
}
}
@@ -0,0 +1,52 @@
query _WhitelistedTokenPair($id: ID!, $block: Block_height){
_WhitelistedTokenPair(id: $id, block: $block){
id
pair{
id
type
swapFee
twapEnabled
name
source
createdAtBlock
createdAtTimestamp
reserve0
reserve1
liquidity
liquidityUSD
liquidityNative
trackedLiquidityNative
token0Price
token1Price
volumeNative
volumeUSD
volumeToken0
volumeToken1
feesNative
feesUSD
apr
aprUpdatedAtTimestamp
txCount
}
token{
id
symbol
symbolSuccess
name
nameSuccess
decimals
decimalsSuccess
liquidity
liquidityNative
liquidityUSD
volume
volumeNative
volumeUSD
feesNative
feesUSD
txCount
pairCount
whitelistedPairCount
}
}
}
@@ -0,0 +1,52 @@
query _WhitelistedTokenPairs($block: Block_height, $where: _WhitelistedTokenPair_filter, $orderBy: _WhitelistedTokenPair_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
_WhitelistedTokenPairs(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
pair{
id
type
swapFee
twapEnabled
name
source
createdAtBlock
createdAtTimestamp
reserve0
reserve1
liquidity
liquidityUSD
liquidityNative
trackedLiquidityNative
token0Price
token1Price
volumeNative
volumeUSD
volumeToken0
volumeToken1
feesNative
feesUSD
apr
aprUpdatedAtTimestamp
txCount
}
token{
id
symbol
symbolSuccess
name
nameSuccess
decimals
decimalsSuccess
liquidity
liquidityNative
liquidityUSD
volume
volumeNative
volumeUSD
feesNative
feesUSD
txCount
pairCount
whitelistedPairCount
}
}
}
@@ -0,0 +1,6 @@
query bundle($id: ID!, $block: Block_height){
bundle(id: $id, block: $block){
id
nativePrice
}
}
@@ -0,0 +1,6 @@
query bundles($block: Block_height, $where: Bundle_filter, $orderBy: Bundle_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
bundles(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
nativePrice
}
}
@@ -0,0 +1,50 @@
query burn($id: ID!, $block: Block_height){
burn(id: $id, block: $block){
id
transaction{
id
gasLimit
gasPrice
createdAtBlock
createdAtTimestamp
}
timestamp
pair{
id
type
swapFee
twapEnabled
name
source
createdAtBlock
createdAtTimestamp
reserve0
reserve1
liquidity
liquidityUSD
liquidityNative
trackedLiquidityNative
token0Price
token1Price
volumeNative
volumeUSD
volumeToken0
volumeToken1
feesNative
feesUSD
apr
aprUpdatedAtTimestamp
txCount
}
liquidity
sender
amount0
amount1
to
logIndex
amountUSD
complete
feeTo
feeLiquidity
}
}
@@ -0,0 +1,50 @@
query burns($block: Block_height, $where: Burn_filter, $orderBy: Burn_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
burns(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
transaction{
id
gasLimit
gasPrice
createdAtBlock
createdAtTimestamp
}
timestamp
pair{
id
type
swapFee
twapEnabled
name
source
createdAtBlock
createdAtTimestamp
reserve0
reserve1
liquidity
liquidityUSD
liquidityNative
trackedLiquidityNative
token0Price
token1Price
volumeNative
volumeUSD
volumeToken0
volumeToken1
feesNative
feesUSD
apr
aprUpdatedAtTimestamp
txCount
}
liquidity
sender
amount0
amount1
to
logIndex
amountUSD
complete
feeTo
feeLiquidity
}
}
@@ -0,0 +1,63 @@
query events($blockHash: String!, $contractAddress: String!, $name: String){
events(blockHash: $blockHash, contractAddress: $contractAddress, name: $name){
block{
cid
hash
number
timestamp
parentHash
}
tx{
hash
index
from
to
}
contract
eventIndex
event{
... on PairCreatedEvent {
token0
token1
pair
null
}
... on ApprovalEvent {
owner
spender
value
}
... on BurnEvent {
sender
amount0
amount1
to
}
... on MintEvent {
sender
amount0
amount1
}
... on SwapEvent {
sender
amount0In
amount1In
amount0Out
amount1Out
to
}
... on SyncEvent {
reserve0
reserve1
}
... on TransferEvent {
from
to
value
}
}
proof{
data
}
}
}
@@ -0,0 +1,63 @@
query eventsInRange($fromBlockNumber: Int!, $toBlockNumber: Int!){
eventsInRange(fromBlockNumber: $fromBlockNumber, toBlockNumber: $toBlockNumber){
block{
cid
hash
number
timestamp
parentHash
}
tx{
hash
index
from
to
}
contract
eventIndex
event{
... on PairCreatedEvent {
token0
token1
pair
null
}
... on ApprovalEvent {
owner
spender
value
}
... on BurnEvent {
sender
amount0
amount1
to
}
... on MintEvent {
sender
amount0
amount1
}
... on SwapEvent {
sender
amount0In
amount1In
amount0Out
amount1Out
to
}
... on SyncEvent {
reserve0
reserve1
}
... on TransferEvent {
from
to
value
}
}
proof{
data
}
}
}
@@ -0,0 +1,16 @@
query factories($block: Block_height, $where: Factory_filter, $orderBy: Factory_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
factories(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
type
volumeUSD
volumeNative
liquidityUSD
liquidityNative
feesUSD
feesNative
pairCount
transactionCount
tokenCount
userCount
}
}
@@ -0,0 +1,16 @@
query factory($id: ID!, $block: Block_height){
factory(id: $id, block: $block){
id
type
volumeUSD
volumeNative
liquidityUSD
liquidityNative
feesUSD
feesNative
pairCount
transactionCount
tokenCount
userCount
}
}
@@ -0,0 +1,27 @@
query factoryDaySnapshot($id: ID!, $block: Block_height){
factoryDaySnapshot(id: $id, block: $block){
id
factory{
id
type
volumeUSD
volumeNative
liquidityUSD
liquidityNative
feesUSD
feesNative
pairCount
transactionCount
tokenCount
userCount
}
date
volumeUSD
volumeNative
liquidityNative
liquidityUSD
feesNative
feesUSD
transactionCount
}
}
@@ -0,0 +1,27 @@
query factoryDaySnapshots($block: Block_height, $where: FactoryDaySnapshot_filter, $orderBy: FactoryDaySnapshot_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
factoryDaySnapshots(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
factory{
id
type
volumeUSD
volumeNative
liquidityUSD
liquidityNative
feesUSD
feesNative
pairCount
transactionCount
tokenCount
userCount
}
date
volumeUSD
volumeNative
liquidityNative
liquidityUSD
feesNative
feesUSD
transactionCount
}
}
@@ -0,0 +1,27 @@
query factoryHourSnapshot($id: ID!, $block: Block_height){
factoryHourSnapshot(id: $id, block: $block){
id
factory{
id
type
volumeUSD
volumeNative
liquidityUSD
liquidityNative
feesUSD
feesNative
pairCount
transactionCount
tokenCount
userCount
}
date
volumeUSD
volumeNative
liquidityNative
liquidityUSD
feesNative
feesUSD
transactionCount
}
}
@@ -0,0 +1,27 @@
query factoryHourSnapshots($block: Block_height, $where: FactoryHourSnapshot_filter, $orderBy: FactoryHourSnapshot_orderBy, $orderDirection: OrderDirection, $first: Int, $skip: Int){
factoryHourSnapshots(block: $block, where: $where, orderBy: $orderBy, orderDirection: $orderDirection, first: $first, skip: $skip){
id
factory{
id
type
volumeUSD
volumeNative
liquidityUSD
liquidityNative
feesUSD
feesNative
pairCount
transactionCount
tokenCount
userCount
}
date
volumeUSD
volumeNative
liquidityNative
liquidityUSD
feesNative
feesUSD
transactionCount
}
}
@@ -0,0 +1,49 @@
import fs from 'fs';
import path from 'path';
export const events = fs.readFileSync(path.join(__dirname, 'events.gql'), 'utf8');
export const eventsInRange = fs.readFileSync(path.join(__dirname, 'eventsInRange.gql'), 'utf8');
export const factory = fs.readFileSync(path.join(__dirname, 'factory.gql'), 'utf8');
export const factories = fs.readFileSync(path.join(__dirname, 'factories.gql'), 'utf8');
export const bundle = fs.readFileSync(path.join(__dirname, 'bundle.gql'), 'utf8');
export const bundles = fs.readFileSync(path.join(__dirname, 'bundles.gql'), 'utf8');
export const token = fs.readFileSync(path.join(__dirname, 'token.gql'), 'utf8');
export const tokens = fs.readFileSync(path.join(__dirname, 'tokens.gql'), 'utf8');
export const tokenPrice = fs.readFileSync(path.join(__dirname, 'tokenPrice.gql'), 'utf8');
export const tokenPrices = fs.readFileSync(path.join(__dirname, 'tokenPrices.gql'), 'utf8');
export const _TokenPair = fs.readFileSync(path.join(__dirname, '_TokenPair.gql'), 'utf8');
export const _TokenPairs = fs.readFileSync(path.join(__dirname, '_TokenPairs.gql'), 'utf8');
export const _WhitelistedTokenPair = fs.readFileSync(path.join(__dirname, '_WhitelistedTokenPair.gql'), 'utf8');
export const _WhitelistedTokenPairs = fs.readFileSync(path.join(__dirname, '_WhitelistedTokenPairs.gql'), 'utf8');
export const pair = fs.readFileSync(path.join(__dirname, 'pair.gql'), 'utf8');
export const pairs = fs.readFileSync(path.join(__dirname, 'pairs.gql'), 'utf8');
export const user = fs.readFileSync(path.join(__dirname, 'user.gql'), 'utf8');
export const users = fs.readFileSync(path.join(__dirname, 'users.gql'), 'utf8');
export const liquidityPosition = fs.readFileSync(path.join(__dirname, 'liquidityPosition.gql'), 'utf8');
export const liquidityPositions = fs.readFileSync(path.join(__dirname, 'liquidityPositions.gql'), 'utf8');
export const mint = fs.readFileSync(path.join(__dirname, 'mint.gql'), 'utf8');
export const mints = fs.readFileSync(path.join(__dirname, 'mints.gql'), 'utf8');
export const burn = fs.readFileSync(path.join(__dirname, 'burn.gql'), 'utf8');
export const burns = fs.readFileSync(path.join(__dirname, 'burns.gql'), 'utf8');
export const swap = fs.readFileSync(path.join(__dirname, 'swap.gql'), 'utf8');
export const swaps = fs.readFileSync(path.join(__dirname, 'swaps.gql'), 'utf8');
export const transaction = fs.readFileSync(path.join(__dirname, 'transaction.gql'), 'utf8');
export const transactions = fs.readFileSync(path.join(__dirname, 'transactions.gql'), 'utf8');
export const liquidityPositionSnapshot = fs.readFileSync(path.join(__dirname, 'liquidityPositionSnapshot.gql'), 'utf8');
export const liquidityPositionSnapshots = fs.readFileSync(path.join(__dirname, 'liquidityPositionSnapshots.gql'), 'utf8');
export const pairHourSnapshot = fs.readFileSync(path.join(__dirname, 'pairHourSnapshot.gql'), 'utf8');
export const pairHourSnapshots = fs.readFileSync(path.join(__dirname, 'pairHourSnapshots.gql'), 'utf8');
export const pairDaySnapshot = fs.readFileSync(path.join(__dirname, 'pairDaySnapshot.gql'), 'utf8');
export const pairDaySnapshots = fs.readFileSync(path.join(__dirname, 'pairDaySnapshots.gql'), 'utf8');
export const tokenHourSnapshot = fs.readFileSync(path.join(__dirname, 'tokenHourSnapshot.gql'), 'utf8');
export const tokenHourSnapshots = fs.readFileSync(path.join(__dirname, 'tokenHourSnapshots.gql'), 'utf8');
export const tokenDaySnapshot = fs.readFileSync(path.join(__dirname, 'tokenDaySnapshot.gql'), 'utf8');
export const tokenDaySnapshots = fs.readFileSync(path.join(__dirname, 'tokenDaySnapshots.gql'), 'utf8');
export const factoryHourSnapshot = fs.readFileSync(path.join(__dirname, 'factoryHourSnapshot.gql'), 'utf8');
export const factoryHourSnapshots = fs.readFileSync(path.join(__dirname, 'factoryHourSnapshots.gql'), 'utf8');
export const factoryDaySnapshot = fs.readFileSync(path.join(__dirname, 'factoryDaySnapshot.gql'), 'utf8');
export const factoryDaySnapshots = fs.readFileSync(path.join(__dirname, 'factoryDaySnapshots.gql'), 'utf8');
export const _meta = fs.readFileSync(path.join(__dirname, '_meta.gql'), 'utf8');
export const getStateByCID = fs.readFileSync(path.join(__dirname, 'getStateByCID.gql'), 'utf8');
export const getState = fs.readFileSync(path.join(__dirname, 'getState.gql'), 'utf8');
export const getSyncStatus = fs.readFileSync(path.join(__dirname, 'getSyncStatus.gql'), 'utf8');
@@ -0,0 +1,39 @@
query liquidityPosition($id: ID!, $block: Block_height){
liquidityPosition(id: $id, block: $block){
id
pair{
id
type
swapFee
twapEnabled
name
source
createdAtBlock
createdAtTimestamp
reserve0
reserve1
liquidity
liquidityUSD
liquidityNative
trackedLiquidityNative
token0Price
token1Price
volumeNative
volumeUSD
volumeToken0
volumeToken1
feesNative
feesUSD
apr
aprUpdatedAtTimestamp
txCount
}
user{
id
lpSnapshotsCount
}
balance
createdAtBlock
createdAtTimestamp
}
}
@@ -0,0 +1,51 @@
query liquidityPositionSnapshot($id: ID!, $block: Block_height){
liquidityPositionSnapshot(id: $id, block: $block){
id
liquidityPosition{
id
balance
createdAtBlock
createdAtTimestamp
}
timestamp
block
user{
id
lpSnapshotsCount
}
pair{
id
type
swapFee
twapEnabled
name
source
createdAtBlock
createdAtTimestamp
reserve0
reserve1
liquidity
liquidityUSD
liquidityNative
trackedLiquidityNative
token0Price
token1Price
volumeNative
volumeUSD
volumeToken0
volumeToken1
feesNative
feesUSD
apr
aprUpdatedAtTimestamp
txCount
}
token0PriceUSD
token1PriceUSD
reserve0
reserve1
reserveUSD
liquidityTokenTotalSupply
liquidityTokenBalance
}
}

Some files were not shown because too many files have changed in this diff Show More