watcher-ts/packages/uni-info-watcher/src/entity/PoolDayData.ts
Ashwin Phatak ecfa3ed386
Handle swap event (#138)
* Create Swap entity.

* Update day and hour interval data in Swap event handler.

Co-authored-by: nabarun <nabarun@deepstacksoft.com>
2021-07-15 10:45:35 +05:30

74 lines
1.8 KiB
TypeScript

import Decimal from 'decimal.js';
import { Entity, PrimaryColumn, Column, ManyToOne } from 'typeorm';
import { decimalTransformer } from '@vulcanize/util';
import { Pool } from './Pool';
@Entity()
export class PoolDayData {
@PrimaryColumn('varchar')
id!: string;
@PrimaryColumn('integer')
blockNumber!: number;
@Column('integer')
date!: number;
@ManyToOne(() => Pool)
pool!: Pool;
@Column('numeric', { transformer: decimalTransformer })
high!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
low!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
open!: Decimal;
@Column('numeric', { transformer: decimalTransformer })
close!: Decimal;
@Column('numeric', { default: BigInt(0) })
sqrtPrice!: bigint
@Column('bigint', { nullable: true })
tick!: bigint | null
@Column('numeric', { default: BigInt(0) })
liquidity!: bigint
@Column('numeric', { default: BigInt(0) })
feeGrowthGlobal0X128!: bigint
@Column('numeric', { default: BigInt(0) })
feeGrowthGlobal1X128!: bigint
@Column('numeric', { default: 0, transformer: decimalTransformer })
token0Price!: Decimal
@Column('numeric', { default: 0, transformer: decimalTransformer })
token1Price!: Decimal
@Column('numeric', { default: 0, transformer: decimalTransformer })
tvlUSD!: Decimal
@Column('numeric', { default: BigInt(0) })
txCount!: bigint
@Column('numeric', { default: 0, transformer: decimalTransformer })
volumeToken0!: Decimal
@Column('numeric', { default: 0, transformer: decimalTransformer })
volumeToken1!: Decimal
@Column('numeric', { default: 0, transformer: decimalTransformer })
volumeUSD!: Decimal
@Column('numeric', { default: 0, transformer: decimalTransformer })
feesUSD!: Decimal
// TODO: Add remaining fields when they are used.
}