//
// 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 Pair {
  @PrimaryColumn('varchar')
    id!: string;

  @PrimaryColumn('varchar', { length: 66 })
    blockHash!: string;

  @Column('integer')
    blockNumber!: number;

  @Column('varchar')
    token0!: string;

  @Column('varchar')
    token1!: string;

  @Column('numeric', { transformer: decimalTransformer })
    reserve0!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    reserve1!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    totalSupply!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    reserveETH!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    reserveUSD!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    trackedReserveETH!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    token0Price!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    token1Price!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    volumeToken0!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    volumeToken1!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    volumeUSD!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    untrackedVolumeUSD!: Decimal;

  @Column('numeric', { transformer: bigintTransformer })
    txCount!: bigint;

  @Column('numeric', { transformer: bigintTransformer })
    createdAtTimestamp!: bigint;

  @Column('numeric', { transformer: bigintTransformer })
    createdAtBlockNumber!: bigint;

  @Column('numeric', { transformer: bigintTransformer })
    liquidityProviderCount!: bigint;

  @Column('boolean', { default: false })
    isPruned!: boolean;

  @Column('boolean', { default: false })
    isRemoved!: boolean;
}
