-
Notifications
You must be signed in to change notification settings - Fork 1
/
Connector.js
142 lines (132 loc) · 3.17 KB
/
Connector.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import React, { Component } from 'react';
import logo from '../logo.png';
import Web3 from 'web3';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
account: ''
}
}
async componentWillMount() {
await this.loadWeb3()
await this.loadBlockchainData()
}
async loadWeb3() {
if (window.ethereum) {
window.web3 = new Web3(window.ethereum)
await window.ethereum.enable()
}
else if (window.web3) {
window.web3 = new Web3(window.web3.currentProvider)
}
else {
window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')
}
}
async loadBlockchainData() {
const web3 = window.web3
var kyber_compound_leverage = {
"constant": false,
"inputs": [
{
"name": "src",
"type": "address"
},
{
"name": "dest",
"type": "address"
},
{
"name": "srcAmt",
"type": "uint256"
},
{
"name": "maxDestAmt",
"type": "uint256"
},
{
"name": "slippageRate",
"type": "uint256"
},
{
"name": "maxAmount",
"type": "uint256"
},
{
"name": "markets",
"type": "address[]"
}
],
"name": "leverage",
"outputs": [
{
"name": "destAmt",
"type": "uint256"
}
],
"payable": true,
"stateMutability": "payable",
"type": "function"
};
var kyber_compound_leverage_args = [
'0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa',
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
"100000000000000000000",
"10000000000000000",
1,
"100000000000000000000000000000000000000",
["0xe7bc397dbd069fc7d0109c0636d06888bb50668c", "0xf92fbe0d3c0dcdae407923b2ac17ec223b1084e4"]
]
const leverageData = await web3.eth.abi.encodeFunctionCall(kyber_compound_leverage, kyber_compound_leverage_args)
console.log(leverageData)
var kyber_compound_save = {
"constant": false,
"inputs": [
{
"name": "src",
"type": "address"
},
{
"name": "dest",
"type": "address"
},
{
"name": "srcAmt",
"type": "uint256"
},
{
"name": "maxDestAmt",
"type": "uint256"
},
{
"name": "markets",
"type": "address[]"
}
],
"name": "save",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
};
var kyber_compound_save_args = [
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
'0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa',
"100",
"1000000",
["0xe7bc397dbd069fc7d0109c0636d06888bb50668c", "0xf92fbe0d3c0dcdae407923b2ac17ec223b1084e4"]
]
const saveData = await web3.eth.abi.encodeFunctionCall(kyber_compound_save, kyber_compound_save_args)
console.log(saveData)
}
render() {
return (
<div>
Compound Connector
</div>
);
}
}
export default App;