Skip to content

Commit

Permalink
remove constructor helper
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed May 21, 2021
1 parent 72b250b commit 92c052e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/entities/fractions/currencyAmount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('CurrencyAmount', () => {

describe('#ether', () => {
it('produces ether amount', () => {
const amount = CurrencyAmount.ether(1, 100)
const amount = CurrencyAmount.fromRawAmount(Ether.onChain(1), 100)
expect(amount.quotient).toEqual(JSBI.BigInt(100))
expect(amount.currency).toEqual(Ether.onChain(1))
})
Expand Down
13 changes: 1 addition & 12 deletions src/entities/fractions/currencyAmount.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import invariant from 'tiny-invariant'
import JSBI from 'jsbi'
import { Currency } from '../currency'
import { Ether } from '../ether'
import { NativeCurrency } from '../nativeCurrency'
import { Token } from '../token'
import { Fraction } from './fraction'
import _Big from 'big.js'
Expand All @@ -17,7 +15,7 @@ export class CurrencyAmount<T extends Currency> extends Fraction {
public readonly decimalScale: JSBI

/**
* Returns a new currency amount instance from the
* Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
* @param currency the currency in the amount
* @param rawAmount the raw token or ether amount
*/
Expand All @@ -39,15 +37,6 @@ export class CurrencyAmount<T extends Currency> extends Fraction {
return new CurrencyAmount(currency, numerator, denominator)
}

/**
* Helper that calls the constructor with the Ether currency
* @param chainId the chain on which the ether exists
* @param rawAmount ether amount in wei
*/
public static ether(chainId: number, rawAmount: BigintIsh): CurrencyAmount<NativeCurrency> {
return CurrencyAmount.fromRawAmount(Ether.onChain(chainId), rawAmount)
}

protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh) {
super(numerator, denominator)
invariant(JSBI.lessThanOrEqual(this.quotient, MaxUint256), 'AMOUNT')
Expand Down
2 changes: 1 addition & 1 deletion src/utils/computePriceImpact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('#computePriceImpact', () => {
expect(
computePriceImpact(
new Price(Ether.onChain(1), t0, 10, 100),
CurrencyAmount.ether(1, 10),
CurrencyAmount.fromRawAmount(Ether.onChain(1), 10),
CurrencyAmount.fromRawAmount(t0, 100)
)
).toEqual(new Percent(0, 10000))
Expand Down

0 comments on commit 92c052e

Please sign in to comment.