Skip to content

Commit

Permalink
clean up tick a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Mar 25, 2021
1 parent 9f780f5 commit ccf4ce9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 40 deletions.
2 changes: 2 additions & 0 deletions src/entities/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './pool'
export * from './route'
export * from './trade'
export * from './tick'
export * from './tickList'
12 changes: 0 additions & 12 deletions src/entities/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,6 @@ export class Pool {
return this.token0.chainId
}

public get feeLevel(): FeeAmount {
return this.fee
}

public get inRangeLiquidity(): BigintIsh {
return this.liquidity.toString()
}

public get tickList(): TickList {
return this.ticks
}

public getOutputAmount(inputAmount: TokenAmount): [TokenAmount, Pool] {
invariant(this.involvesToken(inputAmount.token), 'TOKEN')
throw new Error('todo')
Expand Down
35 changes: 12 additions & 23 deletions src/entities/tick.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { BigintIsh } from '@uniswap/sdk-core'
import JSBI from 'jsbi'
import invariant from 'tiny-invariant'
import { BigintIsh } from '@uniswap/sdk-core'
import { MAX_TICK, MIN_TICK } from '../constants'

interface TickConstructorArgs {
feeGrowthOutside0X128: BigintIsh
Expand All @@ -10,37 +12,24 @@ interface TickConstructorArgs {
}

export class Tick {
private readonly i: number
private readonly feeGrowthOutside0X128: JSBI
private readonly feeGrowthOutside1X128: JSBI
private readonly liquidityGross: JSBI
private readonly liquidityNet: JSBI
public readonly index: number
public readonly feeGrowthOutside0X128: JSBI
public readonly feeGrowthOutside1X128: JSBI
public readonly liquidityGross: JSBI
public readonly liquidityNet: JSBI

constructor({
index,
feeGrowthOutside0X128,
feeGrowthOutside1X128,
index,
liquidityGross,
liquidityNet
}: TickConstructorArgs) {
invariant(index >= MIN_TICK && index <= MAX_TICK, 'TICK')
this.index = index
this.feeGrowthOutside0X128 = JSBI.BigInt(feeGrowthOutside0X128)
this.feeGrowthOutside1X128 = JSBI.BigInt(feeGrowthOutside1X128)
this.i = index
this.liquidityGross = JSBI.BigInt(liquidityGross)
this.liquidityNet = JSBI.BigInt(liquidityNet)
}

public get todo(): void {
console.log(
this.feeGrowthOutside0X128,
this.feeGrowthOutside1X128,
this.index,
this.liquidityGross,
this.liquidityNet
)
return
}

public get index(): number {
return this.i
}
}
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './errors'
export * from './entities'
export * from './router'
export * from './utils'
export * from './nonfungiblePositionManager'

export * from './constants'
export * from './errors'
export * from './nonfungiblePositionManager'
export * from './swapRouter'
4 changes: 2 additions & 2 deletions src/router.ts → src/swapRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export interface TradeOptions {
}

/**
* Represents the Uniswap V2 Router, and has static methods for helping execute trades.
* Represents the Uniswap V2 SwapRouter, and has static methods for helping execute trades.
*/
export abstract class Router {
export abstract class SwapRouter {
/**
* Cannot be constructed.
*/
Expand Down

0 comments on commit ccf4ce9

Please sign in to comment.