-
Notifications
You must be signed in to change notification settings - Fork 14
/
demo.html
44 lines (36 loc) · 1.52 KB
/
demo.html
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
33
34
35
36
37
38
39
40
41
42
43
44
<html>
<body>
<script src="https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/decimal.min.js"
integrity="sha256-gyWhSVGau68+skcMqGaBZnm/lpoD7rswg/fGVZoOw2k="
crossorigin="anonymous"></script>
<script src="js/ens.js"></script>
<script src="js/sushiswap.js"></script>
<script>
async function go() {
// Connect to wallet
web3 = new Web3(window.ethereum);
let addresses = await window.ethereum.enable();
// Create SushiSwapJs
let sushiswap = new API(web3);
sushiswap.auto_update(async function () {
// Retieve all info for the first wallet address
await sushiswap.getInfo(addresses[0]);
await sushiswap.getMakerInfo();
// Display all info nicely in html
document.getElementById("base").textContent
= JSON.stringify(sushiswap.base, null, 2);
document.getElementById("pools").textContent
= JSON.stringify(sushiswap.pools, null, 2);
document.getElementById("maker").textContent
= JSON.stringify(sushiswap.makerPairs, null, 2);
}, true);
}
</script>
<h1>SushiSwapJs</h1>
<pre id="base"></pre>
<pre id="pools"></pre>
<pre id="maker"></pre>
<button onclick="go()">Go!</button>
</body>
</html>