Skip to content

Commit

Permalink
v2.0.0-beta.22
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahZinsmeister committed Mar 30, 2020
1 parent 3f22df6 commit de55240
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@uniswap/sdk",
"license": "GPL-3.0-or-later",
"version": "2.0.0-beta.21",
"version": "2.0.0-beta.22",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down
15 changes: 0 additions & 15 deletions src/entities/trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ function getSlippage(midPrice: Price, inputAmount: TokenAmount, outputAmount: To
return new Percent(slippage.numerator, slippage.denominator)
}

function getPercentChange(referenceRate: Price, newRate: Price): Percent {
// calculate (referenceRate - newRate) / referenceRate
const difference = new Fraction(
JSBI.subtract(
JSBI.multiply(referenceRate.adjusted.numerator, newRate.adjusted.denominator),
JSBI.multiply(newRate.adjusted.numerator, referenceRate.adjusted.denominator)
),
JSBI.multiply(referenceRate.adjusted.denominator, newRate.adjusted.denominator)
)
const percentChange = difference.multiply(referenceRate.adjusted.invert())
return new Percent(percentChange.numerator, percentChange.denominator)
}

export class Trade {
public readonly route: Route
public readonly tradeType: TradeType
Expand All @@ -40,7 +27,6 @@ export class Trade {
public readonly executionPrice: Price
public readonly nextMidPrice: Price
public readonly slippage: Percent
public readonly midPricePercentChange: Percent

constructor(route: Route, amount: TokenAmount, tradeType: TradeType) {
invariant(amount.token.equals(tradeType === TradeType.EXACT_INPUT ? route.input : route.output), 'TOKEN')
Expand Down Expand Up @@ -74,6 +60,5 @@ export class Trade {
const nextMidPrice = Price.fromRoute(new Route(nextPairs, route.input))
this.nextMidPrice = nextMidPrice
this.slippage = getSlippage(route.midPrice, inputAmount, outputAmount)
this.midPricePercentChange = getPercentChange(route.midPrice, nextMidPrice)
}
}

0 comments on commit de55240

Please sign in to comment.