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

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

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

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

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

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

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

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

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

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

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

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

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

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

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