//
// Copyright 2021 Vulcanize, Inc.
//

import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';

@Entity()
@Index(['blockNumber'])
export class Bucket {
  @PrimaryColumn('varchar')
    id!: string;

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

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

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

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

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

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

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

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

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

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

  @Column('varchar', { array: true })
    lends!: string[];

  @Column('varchar', { array: true })
    positionLends!: string[];

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

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