Commit de55240e authored by Noah Zinsmeister's avatar Noah Zinsmeister

v2.0.0-beta.22

parent 3f22df66
{ {
"name": "@uniswap/sdk", "name": "@uniswap/sdk",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"version": "2.0.0-beta.21", "version": "2.0.0-beta.22",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"files": [ "files": [
......
...@@ -19,19 +19,6 @@ function getSlippage(midPrice: Price, inputAmount: TokenAmount, outputAmount: To ...@@ -19,19 +19,6 @@ function getSlippage(midPrice: Price, inputAmount: TokenAmount, outputAmount: To
return new Percent(slippage.numerator, slippage.denominator) 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 { export class Trade {
public readonly route: Route public readonly route: Route
public readonly tradeType: TradeType public readonly tradeType: TradeType
...@@ -40,7 +27,6 @@ export class Trade { ...@@ -40,7 +27,6 @@ export class Trade {
public readonly executionPrice: Price public readonly executionPrice: Price
public readonly nextMidPrice: Price public readonly nextMidPrice: Price
public readonly slippage: Percent public readonly slippage: Percent
public readonly midPricePercentChange: Percent
constructor(route: Route, amount: TokenAmount, tradeType: TradeType) { constructor(route: Route, amount: TokenAmount, tradeType: TradeType) {
invariant(amount.token.equals(tradeType === TradeType.EXACT_INPUT ? route.input : route.output), 'TOKEN') invariant(amount.token.equals(tradeType === TradeType.EXACT_INPUT ? route.input : route.output), 'TOKEN')
...@@ -74,6 +60,5 @@ export class Trade { ...@@ -74,6 +60,5 @@ export class Trade {
const nextMidPrice = Price.fromRoute(new Route(nextPairs, route.input)) const nextMidPrice = Price.fromRoute(new Route(nextPairs, route.input))
this.nextMidPrice = nextMidPrice this.nextMidPrice = nextMidPrice
this.slippage = getSlippage(route.midPrice, inputAmount, outputAmount) this.slippage = getSlippage(route.midPrice, inputAmount, outputAmount)
this.midPricePercentChange = getPercentChange(route.midPrice, nextMidPrice)
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment