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

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

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

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

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

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

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

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

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

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

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

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

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