-
Notifications
You must be signed in to change notification settings - Fork 8
/
test_prices.js
32 lines (25 loc) · 899 Bytes
/
test_prices.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// import { ChainId, Token, WETH, Fetcher, Trade, Route, TokenAmount, TradeType } from '@uniswap/sdk'
const {
ChainId,
Fetcher,
WETH,
Route,
Trade,
TokenAmount,
TradeType,
Percent,
Pair,
Token
} = require('@uniswap/sdk');
const ethers = require('ethers');
async function a() {
const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18)
// note that you may want/need to handle this async code differently,
// for example if top-level await is not an option
const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId])
const route = new Route([pair], WETH[DAI.chainId])
const trade = new Trade(route, new TokenAmount(WETH[DAI.chainId], '100000000000000000'), TradeType.EXACT_INPUT)
console.log(trade.executionPrice.toSignificant(6))
console.log(trade.nextMidPrice.toSignificant(6))
}
a()