exchange

package
v0.0.0-...-14d11d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FactoryAddress = "0x858E3312ed3A876947EA49d572A7C42DE08af7EE"
	ZeroAddress    = "0x0000000000000000000000000000000000000000"
)
View Source
const (
	WBNB_ADDRESS   = "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"
	BUSD_WBNB_PAIR = "0x58f876857a02d6762e0101bb5c46a8c1ed44dc16" // created block 589414
	USDT_WBNB_PAIR = "0x16b9a82891338f9ba80e2d6970fdda79d1eb0dae" // created block 648115
)

Variables

View Source
var (
	FactoryAddressBytes = eth.MustNewAddress(FactoryAddress).Bytes()
	ZeroAddressBytes    = eth.MustNewAddress(ZeroAddress).Bytes()
)

Aliases for numerical functions

View Source
var Definition = &subgraph.Definition{
	PackageName:         "exchange",
	HighestParallelStep: 4,
	StartBlock:          6809737,
	IncludeFilter:       "",
	Entities: entity.NewRegistry(
		&PancakeFactory{},
		&Bundle{},
		&Token{},
		&Pair{},
		&Transaction{},
		&Mint{},
		&Burn{},
		&Swap{},
		&PancakeDayData{},
		&PairHourData{},
		&PairDayData{},
		&TokenDayData{},
		&DynamicDataSourceXXX{},
	),
	DDL: ddl,
	Manifest: `specVersion: 0.0.2
description: PancakeSwap is a decentralized protocol for automated token exchange on Binance Smart Chain. (Handle Redos)
repository: https://github.com/pancakeswap
schema:
  file: ./exchange.graphql
dataSources:
  - kind: ethereum/contract
    name: Factory
    network: bsc
    source:
      address: '0x858E3312ed3A876947EA49d572A7C42DE08af7EE'
      abi: Factory
      startBlock: 7664646
    mapping:
      kind: ethereum/events
      apiVersion: 0.0.8
      language: wasm/assemblyscript
      file: ../src/exchange/factory.ts
      entities:
        - Pair
        - Token
      abis:
        - name: Factory
          file: ../abis/Factory.json
        - name: BEP20
          file: ../abis/BEP20.json
        - name: BEP20NameBytes
          file: ../abis/BEP20NameBytes.json
        - name: BEP20SymbolBytes
          file: ../abis/BEP20SymbolBytes.json
      eventHandlers:
        - event: PairCreated(indexed address,indexed address,address,uint256)
          handler: handlePairCreated
templates:
  - kind: ethereum/contract
    name: Pair
    network: bsc
    source:
      abi: Pair
    mapping:
      kind: ethereum/events
      apiVersion: 0.0.4
      language: wasm/assemblyscript
      file: ../src/exchange/core.ts
      entities:
        - Pair
        - Token
      abis:
        - name: Factory
          file: ../abis/Factory.json
        - name: Pair
          file: ../abis/Pair.json
      eventHandlers:
        - event: Mint(indexed address,uint256,uint256)
          handler: handleMint
        - event: Burn(indexed address,uint256,uint256,indexed address)
          handler: handleBurn
        - event: Swap(indexed address,uint256,uint256,uint256,uint256,indexed address)
          handler: handleSwap
        - event: Transfer(indexed address,indexed address,uint256)
          handler: handleTransfer
        - event: Sync(uint112,uint112)
          handler: handleSync
`,
	GraphQLSchema: `type PancakeFactory @entity {
  id: ID!

  "Total of pairs"
  totalPairs: BigInt! @parallel(step: 1, type: SUM)

  "Total of transactions"
  totalTransactions: BigInt! @parallel(step: 4, type: SUM)

  # total volume
  totalVolumeUSD: BigDecimal! @parallel(step: 4, type: SUM)
  totalVolumeBNB: BigDecimal! @parallel(step: 4, type: SUM)

  # untracked values - less confident USD scores
  untrackedVolumeUSD: BigDecimal! @parallel(step: 4, type: SUM)

  # total liquidity
  totalLiquidityUSD: BigDecimal! @parallel(step: 4)
  totalLiquidityBNB: BigDecimal! @parallel(step: 4)
}

type Bundle @entity {
  id: ID!

  "BNB price, in USD"
  bnbPrice: BigDecimal! @parallel(step: 4)
}

type Token @entity {
  id: ID!

  "Name"
  name: String! @parallel(step: 1)
  "Symbol"
  symbol: String! @parallel(step: 1)
  "Decimals"
  decimals: BigInt! @parallel(step: 1)

  # token specific volume
  tradeVolume: BigDecimal!        @parallel(step: 4, type: SUM)
  tradeVolumeUSD: BigDecimal!     @parallel(step: 4, type: SUM) @sql(index: false)
  untrackedVolumeUSD: BigDecimal! @parallel(step: 4, type: SUM)

  # transactions across all pairs
  totalTransactions: BigInt!  @parallel(step: 4, type: SUM)

  # liquidity across all pairs
  totalLiquidity: BigDecimal!  @parallel(step: 4, type: SUM)

  # derived prices
  derivedBNB: BigDecimal @parallel(step: 2)
  derivedUSD: BigDecimal @parallel(step: 2)

  # derived fields
  tokenDayData: [TokenDayData!]! @derivedFrom(field: "token")
  pairDayDataBase: [PairDayData!]! @derivedFrom(field: "token0")
  pairDayDataQuote: [PairDayData!]! @derivedFrom(field: "token1")
  pairBase: [Pair!]! @derivedFrom(field: "token0")
  pairQuote: [Pair!]! @derivedFrom(field: "token1")
}

type Pair @entity {
  id: ID!

  name: String! @parallel(step: 1)

  # mirrored from the smart contract
  token0: Token! @parallel(step: 1)
  token1: Token! @parallel(step: 1)
  reserve0: BigDecimal!  @parallel(step: 2)
  reserve1: BigDecimal!  @parallel(step: 2)
  totalSupply: BigDecimal! @parallel(step: 4, type: SUM)

  # derived liquidity
  reserveBNB: BigDecimal!  @parallel(step: 3)
  reserveUSD: BigDecimal!  @parallel(step: 3) @sql(index: false)
  trackedReserveBNB: BigDecimal! @sql(index: false) # used for separating per pair reserves and global
  # Price in terms of the asset pair
  token0Price: BigDecimal! @parallel(step: 2)
  token1Price: BigDecimal! @parallel(step: 2)

  # lifetime volume stats
  volumeToken0: BigDecimal!  @parallel(step: 4, type: SUM)
  volumeToken1: BigDecimal! @parallel(step: 4, type: SUM)
  volumeUSD: BigDecimal! @parallel(step: 4, type: SUM) @sql(index: false)
  untrackedVolumeUSD: BigDecimal! @parallel(step: 4, type: SUM)
  totalTransactions: BigInt! @parallel(step: 4, type: SUM)

  block: BigInt! @parallel(step: 1)
  timestamp: BigInt! @parallel(step: 1)

  # derived fields
  pairHourData: [PairHourData!]! @derivedFrom(field: "pair")
  mints: [Mint!]! @derivedFrom(field: "pair")
  burns: [Burn!]! @derivedFrom(field: "pair")
  swaps: [Swap!]! @derivedFrom(field: "pair")
}

type Transaction @entity @cache(skip_db_lookup: true) {
  id: ID!

  block: BigInt! @parallel(step: 4)
  timestamp: BigInt! @parallel(step: 4)
  # This is not the reverse of Mint.transaction; it is only used to
  # track incomplete mints (similar for burns and swaps)
  mints: [Mint]!
  burns: [Burn]!
  swaps: [Swap]!
}

type Mint @entity {
  # transaction hash + "-" + index in mints Transaction array
  id: ID!
  transaction: Transaction! @parallel(step: 4)
  timestamp: BigInt!  @parallel(step: 4) # need this to pull recent txns for specific token or pair
  pair: Pair! @parallel(step: 4)
  token0: Token! @parallel(step: 4)
  token1: Token! @parallel(step: 4)

  # populated from the primary Transfer event
  to: String! @parallel(step: 4)
  liquidity: BigDecimal! @parallel(step: 4)

  # populated from the Mint event
  sender: String @parallel(step: 4)
  amount0: BigDecimal @parallel(step: 4)
  amount1: BigDecimal @parallel(step: 4)
  logIndex: BigInt @parallel(step: 4)
  # derived amount based on available prices of tokens
  amountUSD: BigDecimal @parallel(step: 4)

  # optional fee fields, if a Transfer event is fired in _mintFee
  feeTo: String @parallel(step: 4)
  feeLiquidity: BigDecimal @parallel(step: 4)
}

type Burn @entity {
  # transaction hash + "-" + index in mints Transaction array
  id: ID!
  transaction: Transaction! @parallel(step: 4)
  timestamp: BigInt! @parallel(step: 4) # need this to pull recent txns for specific token or pair
  pair: Pair! @parallel(step: 4)
  token0: Token! @parallel(step: 4)
  token1: Token! @parallel(step: 4)

  # populated from the primary Transfer event
  liquidity: BigDecimal! @parallel(step: 4)

  # populated from the Burn event
  sender: String @parallel(step: 4)
  amount0: BigDecimal @parallel(step: 4)
  amount1: BigDecimal @parallel(step: 4)
  to: String @parallel(step: 4)
  logIndex: BigInt @parallel(step: 4)
  # derived amount based on available prices of tokens
  amountUSD: BigDecimal @parallel(step: 4)

  # mark uncomplete in BNB case
  needsComplete: Boolean! @parallel(step: 4)

  # optional fee fields, if a Transfer event is fired in _mintFee
  feeTo: String @parallel(step: 4)
  feeLiquidity: BigDecimal @parallel(step: 4)
}

type Swap @entity {
  # transaction hash + "-" + index in swaps Transaction array
  id: ID!
  transaction: Transaction!  @parallel(step: 4)
  timestamp: BigInt!  @parallel(step: 4) # need this to pull recent txns for specific token or pair
  pair: Pair!  @parallel(step: 4)
  token0: Token! @parallel(step: 4)
  token1: Token! @parallel(step: 4)

  # populated from the Swap event
  sender: String! @parallel(step: 4)
  from: String! @parallel(step: 4) # the EOA that initiated the txn
  amount0In: BigDecimal! @parallel(step: 4)
  amount1In: BigDecimal! @parallel(step: 4)
  amount0Out: BigDecimal! @parallel(step: 4)
  amount1Out: BigDecimal! @parallel(step: 4)
  to: String! @parallel(step: 4)
  logIndex: BigInt @parallel(step: 4)

  # derived info
  amountUSD: BigDecimal! @parallel(step: 4)
}

type PancakeDayData @entity {
  id: ID! # timestamp rounded to current day by dividing by 86400

  date: Int!  @parallel(step: 4)

  dailyVolumeBNB: BigDecimal! @parallel(step: 4, type: SUM)
  dailyVolumeUSD: BigDecimal! @parallel(step: 4, type: SUM)
  dailyVolumeUntracked: BigDecimal! @parallel(step: 4, type: SUM)

  totalVolumeBNB: BigDecimal! @parallel(step: 4, type: SUM)
  totalLiquidityBNB: BigDecimal! @parallel(step: 4)
  totalVolumeUSD: BigDecimal!  @parallel(step: 4, type: SUM)# Accumulate at each trade, not just calculated off whatever totalVolume is. making it more accurate as it is a live conversion
  totalLiquidityUSD: BigDecimal! @parallel(step: 4)

  totalTransactions: BigInt! @parallel(step: 4)
}

type PairHourData @entity {
  id: ID!

  hourStartUnix: Int! @parallel(step: 4) # unix timestamp for start of hour
  pair: Pair! @parallel(step: 4)

  # reserves
  reserve0: BigDecimal! @parallel(step: 4)
  reserve1: BigDecimal! @parallel(step: 4)

  # total supply for LP historical returns
  totalSupply: BigDecimal! @parallel(step: 4, type: SUM)

  # derived liquidity
  reserveUSD: BigDecimal!

  # volume stats
  hourlyVolumeToken0: BigDecimal!  @parallel(step: 4, type: SUM)
  hourlyVolumeToken1: BigDecimal!  @parallel(step: 4, type: SUM)
  hourlyVolumeUSD: BigDecimal!  @parallel(step: 4, type: SUM)
  hourlyTxns: BigInt!  @parallel(step: 4, type: SUM)
}

type PairDayData @entity {
  id: ID!

  date: Int! @parallel(step: 4)
  pairAddress: Pair! @parallel(step: 4)
  token0: Token! @parallel(step: 4)
  token1: Token! @parallel(step: 4)

  # reserves
  reserve0: BigDecimal! @parallel(step: 4)
  reserve1: BigDecimal! @parallel(step: 4)

  # total supply for LP historical returns
  totalSupply: BigDecimal! @parallel(step: 4, type: SUM)

  # derived liquidity
  reserveUSD: BigDecimal! @parallel(step: 4)

  # volume stats
  dailyVolumeToken0: BigDecimal! @parallel(step: 4, type: SUM)
  dailyVolumeToken1: BigDecimal! @parallel(step: 4, type: SUM)
  dailyVolumeUSD: BigDecimal! @parallel(step: 4, type: SUM)
  dailyTxns: BigInt! @parallel(step: 4, type: SUM)
}

type TokenDayData @entity {
  id: ID!

  date: Int! @parallel(step: 4)
  token: Token! @parallel(step: 4)

  # volume stats
  dailyVolumeToken: BigDecimal! @parallel(step: 4, type: SUM)
  dailyVolumeBNB: BigDecimal! @parallel(step: 4, type: SUM)
  dailyVolumeUSD: BigDecimal! @parallel(step: 4, type: SUM)
  dailyTxns: BigInt! @parallel(step: 4, type: SUM)

  # liquidity stats
  totalLiquidityToken: BigDecimal! @parallel(step: 4)
  totalLiquidityBNB: BigDecimal! @parallel(step: 4)
  totalLiquidityUSD: BigDecimal! @parallel(step: 4)

  # price stats
  priceUSD: BigDecimal! @parallel(step: 4)
}
`,
	Abis: map[string]string{
		"BEP20": `[
  {
    "constant": true,
    "inputs": [],
    "name": "name",
    "outputs": [
      {
        "name": "",
        "type": "string"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      {
        "name": "_spender",
        "type": "address"
      },
      {
        "name": "_value",
        "type": "uint256"
      }
    ],
    "name": "approve",
    "outputs": [
      {
        "name": "",
        "type": "bool"
      }
    ],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "totalSupply",
    "outputs": [
      {
        "name": "",
        "type": "uint256"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      {
        "name": "_from",
        "type": "address"
      },
      {
        "name": "_to",
        "type": "address"
      },
      {
        "name": "_value",
        "type": "uint256"
      }
    ],
    "name": "transferFrom",
    "outputs": [
      {
        "name": "",
        "type": "bool"
      }
    ],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "decimals",
    "outputs": [
      {
        "name": "",
        "type": "uint8"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [
      {
        "name": "_owner",
        "type": "address"
      }
    ],
    "name": "balanceOf",
    "outputs": [
      {
        "name": "balance",
        "type": "uint256"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "symbol",
    "outputs": [
      {
        "name": "",
        "type": "string"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      {
        "name": "_to",
        "type": "address"
      },
      {
        "name": "_value",
        "type": "uint256"
      }
    ],
    "name": "transfer",
    "outputs": [
      {
        "name": "",
        "type": "bool"
      }
    ],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [
      {
        "name": "_owner",
        "type": "address"
      },
      {
        "name": "_spender",
        "type": "address"
      }
    ],
    "name": "allowance",
    "outputs": [
      {
        "name": "",
        "type": "uint256"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "payable": true,
    "stateMutability": "payable",
    "type": "fallback"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "name": "owner",
        "type": "address"
      },
      {
        "indexed": true,
        "name": "spender",
        "type": "address"
      },
      {
        "indexed": false,
        "name": "value",
        "type": "uint256"
      }
    ],
    "name": "Approval",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "name": "from",
        "type": "address"
      },
      {
        "indexed": true,
        "name": "to",
        "type": "address"
      },
      {
        "indexed": false,
        "name": "value",
        "type": "uint256"
      }
    ],
    "name": "Transfer",
    "type": "event"
  }
]
`,
		"BEP20NameBytes": `[
  {
    "constant": true,
    "inputs": [],
    "name": "name",
    "outputs": [
      {
        "internalType": "bytes32",
        "name": "",
        "type": "bytes32"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  }
]
`,
		"BEP20SymbolBytes": `[
  {
    "constant": true,
    "inputs": [],
    "name": "symbol",
    "outputs": [
      {
        "internalType": "bytes32",
        "name": "",
        "type": "bytes32"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  }
]
`,
		"Factory": `[
  {
    "inputs": [{ "internalType": "address", "name": "_feeToSetter", "type": "address" }],
    "payable": false,
    "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"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "INIT_CODE_PAIR_HASH",
    "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "name": "allPairs",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "allPairsLength",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      { "internalType": "address", "name": "tokenA", "type": "address" },
      { "internalType": "address", "name": "tokenB", "type": "address" }
    ],
    "name": "createPair",
    "outputs": [{ "internalType": "address", "name": "pair", "type": "address" }],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "feeTo",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "feeToSetter",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [
      { "internalType": "address", "name": "", "type": "address" },
      { "internalType": "address", "name": "", "type": "address" }
    ],
    "name": "getPair",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [{ "internalType": "address", "name": "_feeTo", "type": "address" }],
    "name": "setFeeTo",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [{ "internalType": "address", "name": "_feeToSetter", "type": "address" }],
    "name": "setFeeToSetter",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  }
]
`,
		"Pair": `[
  { "inputs": [], "payable": false, "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"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "DOMAIN_SEPARATOR",
    "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "MINIMUM_LIQUIDITY",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "PERMIT_TYPEHASH",
    "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [
      { "internalType": "address", "name": "", "type": "address" },
      { "internalType": "address", "name": "", "type": "address" }
    ],
    "name": "allowance",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      { "internalType": "address", "name": "spender", "type": "address" },
      { "internalType": "uint256", "name": "value", "type": "uint256" }
    ],
    "name": "approve",
    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "name": "balanceOf",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
    "name": "burn",
    "outputs": [
      { "internalType": "uint256", "name": "amount0", "type": "uint256" },
      { "internalType": "uint256", "name": "amount1", "type": "uint256" }
    ],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "decimals",
    "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "factory",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "getReserves",
    "outputs": [
      { "internalType": "uint112", "name": "_reserve0", "type": "uint112" },
      { "internalType": "uint112", "name": "_reserve1", "type": "uint112" },
      { "internalType": "uint32", "name": "_blockTimestampLast", "type": "uint32" }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      { "internalType": "address", "name": "_token0", "type": "address" },
      { "internalType": "address", "name": "_token1", "type": "address" }
    ],
    "name": "initialize",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "kLast",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
    "name": "mint",
    "outputs": [{ "internalType": "uint256", "name": "liquidity", "type": "uint256" }],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "name",
    "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "name": "nonces",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "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": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "price0CumulativeLast",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "price1CumulativeLast",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
    "name": "skim",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": false,
    "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": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "symbol",
    "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [],
    "name": "sync",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "token0",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "token1",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "totalSupply",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      { "internalType": "address", "name": "to", "type": "address" },
      { "internalType": "uint256", "name": "value", "type": "uint256" }
    ],
    "name": "transfer",
    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": false,
    "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" }],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  }
]
`,
	},
	New: func(base subgraph.Base) subgraph.Subgraph {
		return &Subgraph{
			Base:               base,
			DynamicDataSources: map[string]*DynamicDataSourceXXX{},
		}
	},
	MergeFunc: func(step int, cached, new entity.Interface) entity.Interface {
		switch new.(type) {
		case interface {
			Merge(step int, new *PancakeFactory)
		}:
			var c *PancakeFactory
			if cached == nil {
				return new.(*PancakeFactory)
			}
			c = cached.(*PancakeFactory)
			el := new.(*PancakeFactory)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *Bundle)
		}:
			var c *Bundle
			if cached == nil {
				return new.(*Bundle)
			}
			c = cached.(*Bundle)
			el := new.(*Bundle)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *Token)
		}:
			var c *Token
			if cached == nil {
				return new.(*Token)
			}
			c = cached.(*Token)
			el := new.(*Token)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *Pair)
		}:
			var c *Pair
			if cached == nil {
				return new.(*Pair)
			}
			c = cached.(*Pair)
			el := new.(*Pair)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *Transaction)
		}:
			var c *Transaction
			if cached == nil {
				return new.(*Transaction)
			}
			c = cached.(*Transaction)
			el := new.(*Transaction)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *Mint)
		}:
			var c *Mint
			if cached == nil {
				return new.(*Mint)
			}
			c = cached.(*Mint)
			el := new.(*Mint)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *Burn)
		}:
			var c *Burn
			if cached == nil {
				return new.(*Burn)
			}
			c = cached.(*Burn)
			el := new.(*Burn)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *Swap)
		}:
			var c *Swap
			if cached == nil {
				return new.(*Swap)
			}
			c = cached.(*Swap)
			el := new.(*Swap)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *PancakeDayData)
		}:
			var c *PancakeDayData
			if cached == nil {
				return new.(*PancakeDayData)
			}
			c = cached.(*PancakeDayData)
			el := new.(*PancakeDayData)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *PairHourData)
		}:
			var c *PairHourData
			if cached == nil {
				return new.(*PairHourData)
			}
			c = cached.(*PairHourData)
			el := new.(*PairHourData)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *PairDayData)
		}:
			var c *PairDayData
			if cached == nil {
				return new.(*PairDayData)
			}
			c = cached.(*PairDayData)
			el := new.(*PairDayData)
			el.Merge(step, c)
			return el
		case interface {
			Merge(step int, new *TokenDayData)
		}:
			var c *TokenDayData
			if cached == nil {
				return new.(*TokenDayData)
			}
			c = cached.(*TokenDayData)
			el := new.(*TokenDayData)
			el.Merge(step, c)
			return el
		case *DynamicDataSourceXXX:
			return new
		}
		panic("unsupported merge type")
	},
}
View Source
var MINIMUM_LIQUIDITY_THRESHOLD_BNB = big.NewFloat(10)

Functions

func DecodeEvent

func DecodeEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (interface{}, error)

func IsFactoryPairCreatedEvent

func IsFactoryPairCreatedEvent(log *eth.Log) bool

func IsPairApprovalEvent

func IsPairApprovalEvent(log *eth.Log) bool

func IsPairBurnEvent

func IsPairBurnEvent(log *eth.Log) bool

func IsPairMintEvent

func IsPairMintEvent(log *eth.Log) bool

func IsPairSwapEvent

func IsPairSwapEvent(log *eth.Log) bool

func IsPairSyncEvent

func IsPairSyncEvent(log *eth.Log) bool

func IsPairTransferEvent

func IsPairTransferEvent(log *eth.Log) bool

func TestEvents

func TestEvents(t *testing.T, s *Subgraph, events []interface{})

Types

type Bundle

type Bundle struct {
	entity.Base
	BnbPrice entity.Float `db:"bnb_price" csv:"bnb_price"`
}

Bundle

func NewBundle

func NewBundle(id string) *Bundle

func (*Bundle) Merge

func (next *Bundle) Merge(step int, cached *Bundle)

func (*Bundle) SkipDBLookup

func (_ *Bundle) SkipDBLookup() bool

type Burn

type Burn struct {
	entity.Base
	Transaction   string        `db:"transaction" csv:"transaction"`
	Timestamp     entity.Int    `db:"timestamp" csv:"timestamp"`
	Pair          string        `db:"pair" csv:"pair"`
	Token0        string        `db:"token_0" csv:"token_0"`
	Token1        string        `db:"token_1" csv:"token_1"`
	Liquidity     entity.Float  `db:"liquidity" csv:"liquidity"`
	Sender        *string       `db:"sender,nullable" csv:"sender"`
	Amount0       *entity.Float `db:"amount_0,nullable" csv:"amount_0"`
	Amount1       *entity.Float `db:"amount_1,nullable" csv:"amount_1"`
	To            *string       `db:"to,nullable" csv:"to"`
	LogIndex      *entity.Int   `db:"log_index,nullable" csv:"log_index"`
	AmountUSD     *entity.Float `db:"amount_usd,nullable" csv:"amount_usd"`
	NeedsComplete entity.Bool   `db:"needs_complete" csv:"needs_complete"`
	FeeTo         *string       `db:"fee_to,nullable" csv:"fee_to"`
	FeeLiquidity  *entity.Float `db:"fee_liquidity,nullable" csv:"fee_liquidity"`
}

Burn

func NewBurn

func NewBurn(id string) *Burn

func (*Burn) IsFinal

func (*Burn) IsFinal(uint64, time.Time) bool

func (*Burn) Merge

func (next *Burn) Merge(step int, cached *Burn)

func (*Burn) SkipDBLookup

func (_ *Burn) SkipDBLookup() bool

type DDL

type DDL struct {
	// contains filtered or unexported fields
}

func (*DDL) CreateIndexes

func (d *DDL) CreateIndexes(handleStatement func(table string, statement string) error) error

func (*DDL) CreateTables

func (d *DDL) CreateTables(handleStatement func(table string, statement string) error) error

func (*DDL) DropIndexes

func (d *DDL) DropIndexes(handleStatement func(table string, statement string) error) error

func (*DDL) InitiateSchema

func (d *DDL) InitiateSchema(handleStatement func(statement string) error) error

type DynamicDataSourceXXX

type DynamicDataSourceXXX struct {
	entity.Base

	Context string `db:"context" csv:"context"`
	ABI     string `db:"abi" csv:"abi"`
}

func NewDynamicDataSource

func NewDynamicDataSource(id string, abi string, context string) *DynamicDataSourceXXX

type FactoryPairCreatedEvent

type FactoryPairCreatedEvent struct {
	*entity.BaseEvent
	LogAddress eth.Address
	LogIndex   int

	// Fields
	Token0 eth.Address `eth:",indexed"`
	Token1 eth.Address `eth:",indexed"`
	Pair   eth.Address `eth:""`
}

func NewFactoryPairCreatedEvent

func NewFactoryPairCreatedEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (*FactoryPairCreatedEvent, error)

type Mint

type Mint struct {
	entity.Base
	Transaction  string        `db:"transaction" csv:"transaction"`
	Timestamp    entity.Int    `db:"timestamp" csv:"timestamp"`
	Pair         string        `db:"pair" csv:"pair"`
	Token0       string        `db:"token_0" csv:"token_0"`
	Token1       string        `db:"token_1" csv:"token_1"`
	To           string        `db:"to" csv:"to"`
	Liquidity    entity.Float  `db:"liquidity" csv:"liquidity"`
	Sender       *string       `db:"sender,nullable" csv:"sender"`
	Amount0      *entity.Float `db:"amount_0,nullable" csv:"amount_0"`
	Amount1      *entity.Float `db:"amount_1,nullable" csv:"amount_1"`
	LogIndex     *entity.Int   `db:"log_index,nullable" csv:"log_index"`
	AmountUSD    *entity.Float `db:"amount_usd,nullable" csv:"amount_usd"`
	FeeTo        *string       `db:"fee_to,nullable" csv:"fee_to"`
	FeeLiquidity *entity.Float `db:"fee_liquidity,nullable" csv:"fee_liquidity"`
}

Mint

func NewMint

func NewMint(id string) *Mint

func (*Mint) IsFinal

func (*Mint) IsFinal(uint64, time.Time) bool

func (*Mint) Merge

func (next *Mint) Merge(step int, cached *Mint)

func (*Mint) SkipDBLookup

func (_ *Mint) SkipDBLookup() bool

type Pair

type Pair struct {
	entity.Base
	Name               string       `db:"name" csv:"name"`
	Token0             string       `db:"token_0" csv:"token_0"`
	Token1             string       `db:"token_1" csv:"token_1"`
	Reserve0           entity.Float `db:"reserve_0" csv:"reserve_0"`
	Reserve1           entity.Float `db:"reserve_1" csv:"reserve_1"`
	TotalSupply        entity.Float `db:"total_supply" csv:"total_supply"`
	ReserveBNB         entity.Float `db:"reserve_bnb" csv:"reserve_bnb"`
	ReserveUSD         entity.Float `db:"reserve_usd" csv:"reserve_usd"`
	TrackedReserveBNB  entity.Float `db:"tracked_reserve_bnb" csv:"tracked_reserve_bnb"`
	Token0Price        entity.Float `db:"token_0_price" csv:"token_0_price"`
	Token1Price        entity.Float `db:"token_1_price" csv:"token_1_price"`
	VolumeToken0       entity.Float `db:"volume_token_0" csv:"volume_token_0"`
	VolumeToken1       entity.Float `db:"volume_token_1" csv:"volume_token_1"`
	VolumeUSD          entity.Float `db:"volume_usd" csv:"volume_usd"`
	UntrackedVolumeUSD entity.Float `db:"untracked_volume_usd" csv:"untracked_volume_usd"`
	TotalTransactions  entity.Int   `db:"total_transactions" csv:"total_transactions"`
	Block              entity.Int   `db:"block" csv:"block"`
	Timestamp          entity.Int   `db:"timestamp" csv:"timestamp"`
}

Pair

func NewPair

func NewPair(id string) *Pair

func (*Pair) Merge

func (next *Pair) Merge(step int, cached *Pair)

func (*Pair) Sanitize

func (p *Pair) Sanitize()

func (*Pair) SkipDBLookup

func (_ *Pair) SkipDBLookup() bool

type PairApprovalEvent

type PairApprovalEvent struct {
	*entity.BaseEvent
	LogAddress eth.Address
	LogIndex   int

	// Fields
	Owner   eth.Address `eth:",indexed"`
	Spender eth.Address `eth:",indexed"`
	Value   *big.Int    `eth:""`
}

func NewPairApprovalEvent

func NewPairApprovalEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (*PairApprovalEvent, error)

type PairBurnEvent

type PairBurnEvent struct {
	*entity.BaseEvent
	LogAddress eth.Address
	LogIndex   int

	// Fields
	Sender  eth.Address `eth:",indexed"`
	Amount0 *big.Int    `eth:""`
	Amount1 *big.Int    `eth:""`
	To      eth.Address `eth:",indexed"`
}

func NewPairBurnEvent

func NewPairBurnEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (*PairBurnEvent, error)

type PairContext

type PairContext struct {
	Token0 eth.Address `json:"token_0"`
	Token1 eth.Address `json:"token_1"`
}

type PairDayData

type PairDayData struct {
	entity.Base
	Date              int64        `db:"date" csv:"date"`
	PairAddress       string       `db:"pair_address" csv:"pair_address"`
	Token0            string       `db:"token_0" csv:"token_0"`
	Token1            string       `db:"token_1" csv:"token_1"`
	Reserve0          entity.Float `db:"reserve_0" csv:"reserve_0"`
	Reserve1          entity.Float `db:"reserve_1" csv:"reserve_1"`
	TotalSupply       entity.Float `db:"total_supply" csv:"total_supply"`
	ReserveUSD        entity.Float `db:"reserve_usd" csv:"reserve_usd"`
	DailyVolumeToken0 entity.Float `db:"daily_volume_token_0" csv:"daily_volume_token_0"`
	DailyVolumeToken1 entity.Float `db:"daily_volume_token_1" csv:"daily_volume_token_1"`
	DailyVolumeUSD    entity.Float `db:"daily_volume_usd" csv:"daily_volume_usd"`
	DailyTxns         entity.Int   `db:"daily_txns" csv:"daily_txns"`
}

PairDayData

func NewPairDayData

func NewPairDayData(id string) *PairDayData

func (*PairDayData) IsFinal

func (p *PairDayData) IsFinal(blockNum uint64, blockTime time.Time) bool

func (*PairDayData) Merge

func (next *PairDayData) Merge(step int, cached *PairDayData)

func (*PairDayData) SkipDBLookup

func (_ *PairDayData) SkipDBLookup() bool

type PairHourData

type PairHourData struct {
	entity.Base
	HourStartUnix      int64        `db:"hour_start_unix" csv:"hour_start_unix"`
	Pair               string       `db:"pair" csv:"pair"`
	Reserve0           entity.Float `db:"reserve_0" csv:"reserve_0"`
	Reserve1           entity.Float `db:"reserve_1" csv:"reserve_1"`
	TotalSupply        entity.Float `db:"total_supply" csv:"total_supply"`
	ReserveUSD         entity.Float `db:"reserve_usd" csv:"reserve_usd"`
	HourlyVolumeToken0 entity.Float `db:"hourly_volume_token_0" csv:"hourly_volume_token_0"`
	HourlyVolumeToken1 entity.Float `db:"hourly_volume_token_1" csv:"hourly_volume_token_1"`
	HourlyVolumeUSD    entity.Float `db:"hourly_volume_usd" csv:"hourly_volume_usd"`
	HourlyTxns         entity.Int   `db:"hourly_txns" csv:"hourly_txns"`
}

PairHourData

func NewPairHourData

func NewPairHourData(id string) *PairHourData

func (*PairHourData) IsFinal

func (p *PairHourData) IsFinal(blockNum uint64, blockTime time.Time) bool

func (*PairHourData) Merge

func (next *PairHourData) Merge(step int, cached *PairHourData)

func (*PairHourData) SkipDBLookup

func (_ *PairHourData) SkipDBLookup() bool

type PairMintEvent

type PairMintEvent struct {
	*entity.BaseEvent
	LogAddress eth.Address
	LogIndex   int

	// Fields
	Sender  eth.Address `eth:",indexed"`
	Amount0 *big.Int    `eth:""`
	Amount1 *big.Int    `eth:""`
}

func NewPairMintEvent

func NewPairMintEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (*PairMintEvent, error)

type PairSwapEvent

type PairSwapEvent struct {
	*entity.BaseEvent
	LogAddress eth.Address
	LogIndex   int

	// Fields
	Sender     eth.Address `eth:",indexed"`
	Amount0In  *big.Int    `eth:""`
	Amount1In  *big.Int    `eth:""`
	Amount0Out *big.Int    `eth:""`
	Amount1Out *big.Int    `eth:""`
	To         eth.Address `eth:",indexed"`
}

func NewPairSwapEvent

func NewPairSwapEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (*PairSwapEvent, error)

type PairSyncEvent

type PairSyncEvent struct {
	*entity.BaseEvent
	LogAddress eth.Address
	LogIndex   int

	// Fields
	Reserve0 *big.Int `eth:""`
	Reserve1 *big.Int `eth:""`
}

func NewPairSyncEvent

func NewPairSyncEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (*PairSyncEvent, error)

type PairTransferEvent

type PairTransferEvent struct {
	*entity.BaseEvent
	LogAddress eth.Address
	LogIndex   int

	// Fields
	From  eth.Address `eth:",indexed"`
	To    eth.Address `eth:",indexed"`
	Value *big.Int    `eth:""`
}

func NewPairTransferEvent

func NewPairTransferEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (*PairTransferEvent, error)

type PancakeDayData

type PancakeDayData struct {
	entity.Base
	Date                 int64        `db:"date" csv:"date"`
	DailyVolumeBNB       entity.Float `db:"daily_volume_bnb" csv:"daily_volume_bnb"`
	DailyVolumeUSD       entity.Float `db:"daily_volume_usd" csv:"daily_volume_usd"`
	DailyVolumeUntracked entity.Float `db:"daily_volume_untracked" csv:"daily_volume_untracked"`
	TotalVolumeBNB       entity.Float `db:"total_volume_bnb" csv:"total_volume_bnb"`
	TotalLiquidityBNB    entity.Float `db:"total_liquidity_bnb" csv:"total_liquidity_bnb"`
	TotalVolumeUSD       entity.Float `db:"total_volume_usd" csv:"total_volume_usd"`
	TotalLiquidityUSD    entity.Float `db:"total_liquidity_usd" csv:"total_liquidity_usd"`
	TotalTransactions    entity.Int   `db:"total_transactions" csv:"total_transactions"`
}

PancakeDayData

func NewPancakeDayData

func NewPancakeDayData(id string) *PancakeDayData

func (*PancakeDayData) IsFinal

func (e *PancakeDayData) IsFinal(blockNum uint64, blockTime time.Time) bool

func (*PancakeDayData) Merge

func (next *PancakeDayData) Merge(step int, cached *PancakeDayData)

func (*PancakeDayData) SkipDBLookup

func (_ *PancakeDayData) SkipDBLookup() bool

type PancakeFactory

type PancakeFactory struct {
	entity.Base
	TotalPairs         entity.Int   `db:"total_pairs" csv:"total_pairs"`
	TotalTransactions  entity.Int   `db:"total_transactions" csv:"total_transactions"`
	TotalVolumeUSD     entity.Float `db:"total_volume_usd" csv:"total_volume_usd"`
	TotalVolumeBNB     entity.Float `db:"total_volume_bnb" csv:"total_volume_bnb"`
	UntrackedVolumeUSD entity.Float `db:"untracked_volume_usd" csv:"untracked_volume_usd"`
	TotalLiquidityUSD  entity.Float `db:"total_liquidity_usd" csv:"total_liquidity_usd"`
	TotalLiquidityBNB  entity.Float `db:"total_liquidity_bnb" csv:"total_liquidity_bnb"`
}

PancakeFactory

func NewPancakeFactory

func NewPancakeFactory(id string) *PancakeFactory

func (*PancakeFactory) Merge

func (next *PancakeFactory) Merge(step int, cached *PancakeFactory)

func (*PancakeFactory) SkipDBLookup

func (_ *PancakeFactory) SkipDBLookup() bool

type Subgraph

type Subgraph struct {
	subgraph.Base

	CurrentBlockDynamicDataSources map[string]*DynamicDataSourceXXX
	DynamicDataSources             map[string]*DynamicDataSourceXXX
}

func NewTestSubgraph

func NewTestSubgraph(int subgraph.Intrinsics) *Subgraph

func (*Subgraph) CreatePairTemplate

func (s *Subgraph) CreatePairTemplate(address eth.Address, obj interface{}) error

func (*Subgraph) CreatePairTemplateWithTokens

func (s *Subgraph) CreatePairTemplateWithTokens(addr eth.Address, token0, token1 eth.Address) error

func (*Subgraph) FindBnbPerToken

func (s *Subgraph) FindBnbPerToken(tokenAddress string) (*big.Float, error)

func (*Subgraph) GetBnbPriceInUSD

func (s *Subgraph) GetBnbPriceInUSD() (*big.Float, error)

func (*Subgraph) HandleBlock

func (s *Subgraph) HandleBlock(block *pbcodec.Block) error

func (*Subgraph) HandleEvent

func (s *Subgraph) HandleEvent(ev interface{}) error

func (*Subgraph) HandleFactoryPairCreatedEvent

func (s *Subgraph) HandleFactoryPairCreatedEvent(ev *FactoryPairCreatedEvent) error

func (*Subgraph) HandlePairBurnEvent

func (s *Subgraph) HandlePairBurnEvent(ev *PairBurnEvent) error

func (*Subgraph) HandlePairMintEvent

func (s *Subgraph) HandlePairMintEvent(ev *PairMintEvent) error

func (*Subgraph) HandlePairSwapEvent

func (s *Subgraph) HandlePairSwapEvent(ev *PairSwapEvent) error

func (*Subgraph) HandlePairSyncEvent

func (s *Subgraph) HandlePairSyncEvent(event *PairSyncEvent) error

func (*Subgraph) HandlePairTransferEvent

func (s *Subgraph) HandlePairTransferEvent(ev *PairTransferEvent) error

func (*Subgraph) Init

func (s *Subgraph) Init() error

func (*Subgraph) IsCurrentDynamicDataSource

func (s *Subgraph) IsCurrentDynamicDataSource(address string) bool

func (*Subgraph) IsDynamicDataSource

func (s *Subgraph) IsDynamicDataSource(address string) bool

func (*Subgraph) LoadDynamicDataSources

func (s *Subgraph) LoadDynamicDataSources(blockNum uint64) error

func (*Subgraph) LogStatus

func (s *Subgraph) LogStatus()

func (*Subgraph) UpdatePairDayData

func (s *Subgraph) UpdatePairDayData(pairAddress eth.Address) (*PairDayData, error)

func (*Subgraph) UpdatePairHourData

func (s *Subgraph) UpdatePairHourData(pairAddress eth.Address) (*PairHourData, error)

func (*Subgraph) UpdatePancakeDayData

func (s *Subgraph) UpdatePancakeDayData() (*PancakeDayData, error)

func (*Subgraph) UpdateTokenDayData

func (s *Subgraph) UpdateTokenDayData(pairAddress eth.Address, token *Token, bundle *Bundle) (*TokenDayData, error)

type Swap

type Swap struct {
	entity.Base
	Transaction string       `db:"transaction" csv:"transaction"`
	Timestamp   entity.Int   `db:"timestamp" csv:"timestamp"`
	Pair        string       `db:"pair" csv:"pair"`
	Token0      string       `db:"token_0" csv:"token_0"`
	Token1      string       `db:"token_1" csv:"token_1"`
	Sender      string       `db:"sender" csv:"sender"`
	From        string       `db:"from" csv:"from"`
	Amount0In   entity.Float `db:"amount_0_in" csv:"amount_0_in"`
	Amount1In   entity.Float `db:"amount_1_in" csv:"amount_1_in"`
	Amount0Out  entity.Float `db:"amount_0_out" csv:"amount_0_out"`
	Amount1Out  entity.Float `db:"amount_1_out" csv:"amount_1_out"`
	To          string       `db:"to" csv:"to"`
	LogIndex    *entity.Int  `db:"log_index,nullable" csv:"log_index"`
	AmountUSD   entity.Float `db:"amount_usd" csv:"amount_usd"`
}

Swap

func NewSwap

func NewSwap(id string) *Swap

func (*Swap) IsFinal

func (e *Swap) IsFinal(blockNum uint64, blockTime time.Time) bool

func (*Swap) Merge

func (next *Swap) Merge(step int, cached *Swap)

func (*Swap) SkipDBLookup

func (_ *Swap) SkipDBLookup() bool

type TestCase

type TestCase struct {
	StoreData []*TypedEntity `yaml:"storeData" json:"storeData"`
	Events    []*TypedEvent  `yaml:"events" json:"events"`
}

type TestIntrinsics

type TestIntrinsics struct {
	// contains filtered or unexported fields
}

func NewTestIntrinsics

func NewTestIntrinsics(testCase *TestCase) *TestIntrinsics

func (*TestIntrinsics) Block

func (i *TestIntrinsics) Block() subgraph.BlockRef

func (*TestIntrinsics) Load

func (i *TestIntrinsics) Load(e entity.Interface) error

func (*TestIntrinsics) LoadAllDistinct

func (i *TestIntrinsics) LoadAllDistinct(e entity.Interface, blockNum uint64) ([]entity.Interface, error)

func (*TestIntrinsics) RPC

func (i *TestIntrinsics) RPC(calls []*subgraph.RPCCall) ([]*subgraph.RPCResponse, error)

func (*TestIntrinsics) Remove

func (i *TestIntrinsics) Remove(e entity.Interface) error

func (*TestIntrinsics) Save

func (i *TestIntrinsics) Save(e entity.Interface) error

func (*TestIntrinsics) Step

func (i *TestIntrinsics) Step() int

func (*TestIntrinsics) StepAbove

func (i *TestIntrinsics) StepAbove(step int) bool

func (*TestIntrinsics) StepBelow

func (i *TestIntrinsics) StepBelow(step int) bool

type Token

type Token struct {
	entity.Base
	Name               string        `db:"name" csv:"name"`
	Symbol             string        `db:"symbol" csv:"symbol"`
	Decimals           entity.Int    `db:"decimals" csv:"decimals"`
	TradeVolume        entity.Float  `db:"trade_volume" csv:"trade_volume"`
	TradeVolumeUSD     entity.Float  `db:"trade_volume_usd" csv:"trade_volume_usd"`
	UntrackedVolumeUSD entity.Float  `db:"untracked_volume_usd" csv:"untracked_volume_usd"`
	TotalTransactions  entity.Int    `db:"total_transactions" csv:"total_transactions"`
	TotalLiquidity     entity.Float  `db:"total_liquidity" csv:"total_liquidity"`
	DerivedBNB         *entity.Float `db:"derived_bnb,nullable" csv:"derived_bnb"`
	DerivedUSD         *entity.Float `db:"derived_usd,nullable" csv:"derived_usd"`
}

Token

func NewToken

func NewToken(id string) *Token

func (*Token) Merge

func (next *Token) Merge(step int, cached *Token)

func (*Token) Sanitize

func (t *Token) Sanitize()

func (*Token) SkipDBLookup

func (_ *Token) SkipDBLookup() bool

type TokenDayData

type TokenDayData struct {
	entity.Base
	Date                int64        `db:"date" csv:"date"`
	Token               string       `db:"token" csv:"token"`
	DailyVolumeToken    entity.Float `db:"daily_volume_token" csv:"daily_volume_token"`
	DailyVolumeBNB      entity.Float `db:"daily_volume_bnb" csv:"daily_volume_bnb"`
	DailyVolumeUSD      entity.Float `db:"daily_volume_usd" csv:"daily_volume_usd"`
	DailyTxns           entity.Int   `db:"daily_txns" csv:"daily_txns"`
	TotalLiquidityToken entity.Float `db:"total_liquidity_token" csv:"total_liquidity_token"`
	TotalLiquidityBNB   entity.Float `db:"total_liquidity_bnb" csv:"total_liquidity_bnb"`
	TotalLiquidityUSD   entity.Float `db:"total_liquidity_usd" csv:"total_liquidity_usd"`
	PriceUSD            entity.Float `db:"price_usd" csv:"price_usd"`
}

TokenDayData

func NewTokenDayData

func NewTokenDayData(id string) *TokenDayData

func (*TokenDayData) IsFinal

func (p *TokenDayData) IsFinal(blockNum uint64, blockTime time.Time) bool

func (*TokenDayData) Merge

func (next *TokenDayData) Merge(step int, cached *TokenDayData)

func (*TokenDayData) SkipDBLookup

func (_ *TokenDayData) SkipDBLookup() bool

type Transaction

type Transaction struct {
	entity.Base
	Block     entity.Int              `db:"block" csv:"block"`
	Timestamp entity.Int              `db:"timestamp" csv:"timestamp"`
	Mints     entity.LocalStringArray `db:"mints,nullable" csv:"mints"`
	Burns     entity.LocalStringArray `db:"burns,nullable" csv:"burns"`
	Swaps     entity.LocalStringArray `db:"swaps,nullable" csv:"swaps"`
}

Transaction

func NewTransaction

func NewTransaction(id string) *Transaction

func (*Transaction) IsFinal

func (e *Transaction) IsFinal(blockNum uint64, blockTime time.Time) bool

func (*Transaction) Merge

func (next *Transaction) Merge(step int, cached *Transaction)

func (*Transaction) SkipDBLookup

func (_ *Transaction) SkipDBLookup() bool

type TypedEntity

type TypedEntity struct {
	Type   string
	Entity entity.Interface
}

func (*TypedEntity) UnmarshalJSON

func (t *TypedEntity) UnmarshalJSON(data []byte) error

type TypedEvent

type TypedEvent struct {
	Type  string
	Event interface{}
}

func (*TypedEvent) UnmarshalJSON

func (t *TypedEvent) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL