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

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

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

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

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

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

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

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

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

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

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

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

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

  @Column('boolean')
    isReward!: boolean;

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

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

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

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

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

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