//
// 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;
}
