@icgio/icg-utils 1.7.41 → 1.7.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/crypto-rates.js +29 -11
- package/lib/dex-rate/dex-rate.js +22 -0
- package/lib/dex-rate/router-abi.js +328 -0
- package/lib/dex-rate/token-abi.js +148 -0
- package/package.json +2 -1
package/lib/crypto-rates.js
CHANGED
|
@@ -12,6 +12,8 @@ const sort_keys = require('./utils.js').sort_keys
|
|
|
12
12
|
|
|
13
13
|
const Limiter = require('./rate-limiter.js')
|
|
14
14
|
|
|
15
|
+
const dex_rate = require('./dex-rate/dex-rate.js')
|
|
16
|
+
|
|
15
17
|
let limiter = new Limiter({
|
|
16
18
|
max_concurrent: 1,
|
|
17
19
|
interval_concurrent: 3000,
|
|
@@ -62,6 +64,7 @@ let get_coins_map_coinmarketcap = (cb) => {
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko') => {
|
|
67
|
+
let result = {}
|
|
65
68
|
function get_crypto_rates_base(cb, pair_or_pairs_or_cur_curs, type) {
|
|
66
69
|
if (type === 'pair') {
|
|
67
70
|
let pair = pair_or_pairs_or_cur_curs
|
|
@@ -90,7 +93,6 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
90
93
|
console.error(err)
|
|
91
94
|
return
|
|
92
95
|
}
|
|
93
|
-
let result = {}
|
|
94
96
|
for (let cur_id in body) {
|
|
95
97
|
let temp = body[cur_id]
|
|
96
98
|
temp.USD = temp.usd
|
|
@@ -131,7 +133,6 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
131
133
|
console.error(err)
|
|
132
134
|
return
|
|
133
135
|
}
|
|
134
|
-
let result = {}
|
|
135
136
|
for (let cur_id in body) {
|
|
136
137
|
let temp = body[cur_id]
|
|
137
138
|
temp.USD = temp.usd
|
|
@@ -156,7 +157,6 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
156
157
|
console.error(err)
|
|
157
158
|
return
|
|
158
159
|
}
|
|
159
|
-
let result = {}
|
|
160
160
|
for (let cur in body.data) {
|
|
161
161
|
let rates = body.data[cur]
|
|
162
162
|
let temp = {}
|
|
@@ -179,8 +179,7 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
179
179
|
cb(result)
|
|
180
180
|
})
|
|
181
181
|
} else {
|
|
182
|
-
let
|
|
183
|
-
quote_cur = 'USD',
|
|
182
|
+
let quote_cur = 'USD',
|
|
184
183
|
page = 1,
|
|
185
184
|
per_page_nums = 250
|
|
186
185
|
let get_coingecko_rate_page = (page, cb) => {
|
|
@@ -194,9 +193,11 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
194
193
|
|
|
195
194
|
symbol = symbol.toUpperCase()
|
|
196
195
|
|
|
197
|
-
if (symbol === 'BAT' && coin.id !== 'basic-attention-token')
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
if (symbol === 'BAT' && coin.id !== 'basic-attention-token') {
|
|
197
|
+
continue
|
|
198
|
+
} else if (symbol === 'SBTC' && coin.id !== 'super-bitcoin') {
|
|
199
|
+
continue
|
|
200
|
+
}
|
|
200
201
|
result[symbol] = {
|
|
201
202
|
USD: parseFloat(coin.current_price),
|
|
202
203
|
USDT: parseFloat(coin.current_price),
|
|
@@ -235,18 +236,35 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
238
|
coins_map = source === 'coingecko' ? process_coins_map_coingecko(coins_map_raw_coingecko) : process_coins_map_coinmarketcap(coins_map_raw_coinmarketcap)
|
|
238
|
-
|
|
239
|
+
if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'FREN')) {
|
|
240
|
+
let curs = _.without(pair_or_pairs_or_cur_curs, 'FREN')
|
|
241
|
+
dex_rate().then((res) => {
|
|
242
|
+
result = {
|
|
243
|
+
FREN: {
|
|
244
|
+
USD: res.FRENUSDT,
|
|
245
|
+
USDT: res.FRENUSDT,
|
|
246
|
+
},
|
|
247
|
+
}
|
|
248
|
+
get_crypto_rates_base(cb, curs, type)
|
|
249
|
+
})
|
|
250
|
+
} else {
|
|
251
|
+
get_crypto_rates_base(cb, pair_or_pairs_or_cur_curs, type)
|
|
252
|
+
}
|
|
239
253
|
}
|
|
240
254
|
|
|
241
255
|
// get_crypto_rates(
|
|
242
256
|
// (res) => {
|
|
243
257
|
// console.log(res)
|
|
244
258
|
// },
|
|
245
|
-
// ['BTC', 'ETH'
|
|
259
|
+
// ['BTC', 'ETH'],
|
|
246
260
|
// 'curs',
|
|
247
|
-
// '
|
|
261
|
+
// 'coingecko'
|
|
248
262
|
// )
|
|
249
263
|
|
|
264
|
+
// dex_rate().then((res) => {
|
|
265
|
+
// console.log(res)
|
|
266
|
+
// })
|
|
267
|
+
|
|
250
268
|
// get_coins_map_coingecko((res) => {
|
|
251
269
|
// console.log(res.body)
|
|
252
270
|
// })
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const _ = require('lodash')
|
|
2
|
+
|
|
3
|
+
const Web3 = require('web3')
|
|
4
|
+
const toBN = Web3.utils.toBN
|
|
5
|
+
const web3_bsc = new Web3('https://bsc-dataseed.binance.org/')
|
|
6
|
+
|
|
7
|
+
const router_abi = require('./router-abi.js')
|
|
8
|
+
const token_abi = require('./token-abi.js')
|
|
9
|
+
|
|
10
|
+
const router_contract = new web3_bsc.eth.Contract(router_abi, '0x10ED43C718714eb63d5aA57B78B54704E256024E')
|
|
11
|
+
const USDT_address = '0x55d398326f99059fF775485246999027B3197955'
|
|
12
|
+
const FREN_address = '0xe6a768464b042a6d029394db1fdef360cb60bbeb'
|
|
13
|
+
const WBNB_address = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c'
|
|
14
|
+
|
|
15
|
+
let FRENUSDT_rate = async function () {
|
|
16
|
+
let rate = _.last(await router_contract.methods.getAmountsOut(toBN(1e18), [FREN_address, WBNB_address, USDT_address]).call()) / 1e18
|
|
17
|
+
return {
|
|
18
|
+
FRENUSDT: rate,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = FRENUSDT_rate
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
module.exports = [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{ internalType: 'address', name: '_factory', type: 'address' },
|
|
5
|
+
{ internalType: 'address', name: '_WETH', type: 'address' },
|
|
6
|
+
],
|
|
7
|
+
stateMutability: 'nonpayable',
|
|
8
|
+
type: 'constructor',
|
|
9
|
+
},
|
|
10
|
+
{ inputs: [], name: 'WETH', outputs: [{ internalType: 'address', name: '', type: 'address' }], stateMutability: 'view', type: 'function' },
|
|
11
|
+
{
|
|
12
|
+
inputs: [
|
|
13
|
+
{ internalType: 'address', name: 'tokenA', type: 'address' },
|
|
14
|
+
{ internalType: 'address', name: 'tokenB', type: 'address' },
|
|
15
|
+
{ internalType: 'uint256', name: 'amountADesired', type: 'uint256' },
|
|
16
|
+
{ internalType: 'uint256', name: 'amountBDesired', type: 'uint256' },
|
|
17
|
+
{ internalType: 'uint256', name: 'amountAMin', type: 'uint256' },
|
|
18
|
+
{ internalType: 'uint256', name: 'amountBMin', type: 'uint256' },
|
|
19
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
20
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
21
|
+
],
|
|
22
|
+
name: 'addLiquidity',
|
|
23
|
+
outputs: [
|
|
24
|
+
{ internalType: 'uint256', name: 'amountA', type: 'uint256' },
|
|
25
|
+
{ internalType: 'uint256', name: 'amountB', type: 'uint256' },
|
|
26
|
+
{ internalType: 'uint256', name: 'liquidity', type: 'uint256' },
|
|
27
|
+
],
|
|
28
|
+
stateMutability: 'nonpayable',
|
|
29
|
+
type: 'function',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
inputs: [
|
|
33
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
34
|
+
{ internalType: 'uint256', name: 'amountTokenDesired', type: 'uint256' },
|
|
35
|
+
{ internalType: 'uint256', name: 'amountTokenMin', type: 'uint256' },
|
|
36
|
+
{ internalType: 'uint256', name: 'amountETHMin', type: 'uint256' },
|
|
37
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
38
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
39
|
+
],
|
|
40
|
+
name: 'addLiquidityETH',
|
|
41
|
+
outputs: [
|
|
42
|
+
{ internalType: 'uint256', name: 'amountToken', type: 'uint256' },
|
|
43
|
+
{ internalType: 'uint256', name: 'amountETH', type: 'uint256' },
|
|
44
|
+
{ internalType: 'uint256', name: 'liquidity', type: 'uint256' },
|
|
45
|
+
],
|
|
46
|
+
stateMutability: 'payable',
|
|
47
|
+
type: 'function',
|
|
48
|
+
},
|
|
49
|
+
{ inputs: [], name: 'factory', outputs: [{ internalType: 'address', name: '', type: 'address' }], stateMutability: 'view', type: 'function' },
|
|
50
|
+
{
|
|
51
|
+
inputs: [
|
|
52
|
+
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
|
|
53
|
+
{ internalType: 'uint256', name: 'reserveIn', type: 'uint256' },
|
|
54
|
+
{ internalType: 'uint256', name: 'reserveOut', type: 'uint256' },
|
|
55
|
+
],
|
|
56
|
+
name: 'getAmountIn',
|
|
57
|
+
outputs: [{ internalType: 'uint256', name: 'amountIn', type: 'uint256' }],
|
|
58
|
+
stateMutability: 'pure',
|
|
59
|
+
type: 'function',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
inputs: [
|
|
63
|
+
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
|
|
64
|
+
{ internalType: 'uint256', name: 'reserveIn', type: 'uint256' },
|
|
65
|
+
{ internalType: 'uint256', name: 'reserveOut', type: 'uint256' },
|
|
66
|
+
],
|
|
67
|
+
name: 'getAmountOut',
|
|
68
|
+
outputs: [{ internalType: 'uint256', name: 'amountOut', type: 'uint256' }],
|
|
69
|
+
stateMutability: 'pure',
|
|
70
|
+
type: 'function',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
inputs: [
|
|
74
|
+
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
|
|
75
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
76
|
+
],
|
|
77
|
+
name: 'getAmountsIn',
|
|
78
|
+
outputs: [{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }],
|
|
79
|
+
stateMutability: 'view',
|
|
80
|
+
type: 'function',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
inputs: [
|
|
84
|
+
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
|
|
85
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
86
|
+
],
|
|
87
|
+
name: 'getAmountsOut',
|
|
88
|
+
outputs: [{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }],
|
|
89
|
+
stateMutability: 'view',
|
|
90
|
+
type: 'function',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
inputs: [
|
|
94
|
+
{ internalType: 'uint256', name: 'amountA', type: 'uint256' },
|
|
95
|
+
{ internalType: 'uint256', name: 'reserveA', type: 'uint256' },
|
|
96
|
+
{ internalType: 'uint256', name: 'reserveB', type: 'uint256' },
|
|
97
|
+
],
|
|
98
|
+
name: 'quote',
|
|
99
|
+
outputs: [{ internalType: 'uint256', name: 'amountB', type: 'uint256' }],
|
|
100
|
+
stateMutability: 'pure',
|
|
101
|
+
type: 'function',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
inputs: [
|
|
105
|
+
{ internalType: 'address', name: 'tokenA', type: 'address' },
|
|
106
|
+
{ internalType: 'address', name: 'tokenB', type: 'address' },
|
|
107
|
+
{ internalType: 'uint256', name: 'liquidity', type: 'uint256' },
|
|
108
|
+
{ internalType: 'uint256', name: 'amountAMin', type: 'uint256' },
|
|
109
|
+
{ internalType: 'uint256', name: 'amountBMin', type: 'uint256' },
|
|
110
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
111
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
112
|
+
],
|
|
113
|
+
name: 'removeLiquidity',
|
|
114
|
+
outputs: [
|
|
115
|
+
{ internalType: 'uint256', name: 'amountA', type: 'uint256' },
|
|
116
|
+
{ internalType: 'uint256', name: 'amountB', type: 'uint256' },
|
|
117
|
+
],
|
|
118
|
+
stateMutability: 'nonpayable',
|
|
119
|
+
type: 'function',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
inputs: [
|
|
123
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
124
|
+
{ internalType: 'uint256', name: 'liquidity', type: 'uint256' },
|
|
125
|
+
{ internalType: 'uint256', name: 'amountTokenMin', type: 'uint256' },
|
|
126
|
+
{ internalType: 'uint256', name: 'amountETHMin', type: 'uint256' },
|
|
127
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
128
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
129
|
+
],
|
|
130
|
+
name: 'removeLiquidityETH',
|
|
131
|
+
outputs: [
|
|
132
|
+
{ internalType: 'uint256', name: 'amountToken', type: 'uint256' },
|
|
133
|
+
{ internalType: 'uint256', name: 'amountETH', type: 'uint256' },
|
|
134
|
+
],
|
|
135
|
+
stateMutability: 'nonpayable',
|
|
136
|
+
type: 'function',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
inputs: [
|
|
140
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
141
|
+
{ internalType: 'uint256', name: 'liquidity', type: 'uint256' },
|
|
142
|
+
{ internalType: 'uint256', name: 'amountTokenMin', type: 'uint256' },
|
|
143
|
+
{ internalType: 'uint256', name: 'amountETHMin', type: 'uint256' },
|
|
144
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
145
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
146
|
+
],
|
|
147
|
+
name: 'removeLiquidityETHSupportingFeeOnTransferTokens',
|
|
148
|
+
outputs: [{ internalType: 'uint256', name: 'amountETH', type: 'uint256' }],
|
|
149
|
+
stateMutability: 'nonpayable',
|
|
150
|
+
type: 'function',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
inputs: [
|
|
154
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
155
|
+
{ internalType: 'uint256', name: 'liquidity', type: 'uint256' },
|
|
156
|
+
{ internalType: 'uint256', name: 'amountTokenMin', type: 'uint256' },
|
|
157
|
+
{ internalType: 'uint256', name: 'amountETHMin', type: 'uint256' },
|
|
158
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
159
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
160
|
+
{ internalType: 'bool', name: 'approveMax', type: 'bool' },
|
|
161
|
+
{ internalType: 'uint8', name: 'v', type: 'uint8' },
|
|
162
|
+
{ internalType: 'bytes32', name: 'r', type: 'bytes32' },
|
|
163
|
+
{ internalType: 'bytes32', name: 's', type: 'bytes32' },
|
|
164
|
+
],
|
|
165
|
+
name: 'removeLiquidityETHWithPermit',
|
|
166
|
+
outputs: [
|
|
167
|
+
{ internalType: 'uint256', name: 'amountToken', type: 'uint256' },
|
|
168
|
+
{ internalType: 'uint256', name: 'amountETH', type: 'uint256' },
|
|
169
|
+
],
|
|
170
|
+
stateMutability: 'nonpayable',
|
|
171
|
+
type: 'function',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
inputs: [
|
|
175
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
176
|
+
{ internalType: 'uint256', name: 'liquidity', type: 'uint256' },
|
|
177
|
+
{ internalType: 'uint256', name: 'amountTokenMin', type: 'uint256' },
|
|
178
|
+
{ internalType: 'uint256', name: 'amountETHMin', type: 'uint256' },
|
|
179
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
180
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
181
|
+
{ internalType: 'bool', name: 'approveMax', type: 'bool' },
|
|
182
|
+
{ internalType: 'uint8', name: 'v', type: 'uint8' },
|
|
183
|
+
{ internalType: 'bytes32', name: 'r', type: 'bytes32' },
|
|
184
|
+
{ internalType: 'bytes32', name: 's', type: 'bytes32' },
|
|
185
|
+
],
|
|
186
|
+
name: 'removeLiquidityETHWithPermitSupportingFeeOnTransferTokens',
|
|
187
|
+
outputs: [{ internalType: 'uint256', name: 'amountETH', type: 'uint256' }],
|
|
188
|
+
stateMutability: 'nonpayable',
|
|
189
|
+
type: 'function',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
inputs: [
|
|
193
|
+
{ internalType: 'address', name: 'tokenA', type: 'address' },
|
|
194
|
+
{ internalType: 'address', name: 'tokenB', type: 'address' },
|
|
195
|
+
{ internalType: 'uint256', name: 'liquidity', type: 'uint256' },
|
|
196
|
+
{ internalType: 'uint256', name: 'amountAMin', type: 'uint256' },
|
|
197
|
+
{ internalType: 'uint256', name: 'amountBMin', type: 'uint256' },
|
|
198
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
199
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
200
|
+
{ internalType: 'bool', name: 'approveMax', type: 'bool' },
|
|
201
|
+
{ internalType: 'uint8', name: 'v', type: 'uint8' },
|
|
202
|
+
{ internalType: 'bytes32', name: 'r', type: 'bytes32' },
|
|
203
|
+
{ internalType: 'bytes32', name: 's', type: 'bytes32' },
|
|
204
|
+
],
|
|
205
|
+
name: 'removeLiquidityWithPermit',
|
|
206
|
+
outputs: [
|
|
207
|
+
{ internalType: 'uint256', name: 'amountA', type: 'uint256' },
|
|
208
|
+
{ internalType: 'uint256', name: 'amountB', type: 'uint256' },
|
|
209
|
+
],
|
|
210
|
+
stateMutability: 'nonpayable',
|
|
211
|
+
type: 'function',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
inputs: [
|
|
215
|
+
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
|
|
216
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
217
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
218
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
219
|
+
],
|
|
220
|
+
name: 'swapETHForExactTokens',
|
|
221
|
+
outputs: [{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }],
|
|
222
|
+
stateMutability: 'payable',
|
|
223
|
+
type: 'function',
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
inputs: [
|
|
227
|
+
{ internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
|
|
228
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
229
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
230
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
231
|
+
],
|
|
232
|
+
name: 'swapExactETHForTokens',
|
|
233
|
+
outputs: [{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }],
|
|
234
|
+
stateMutability: 'payable',
|
|
235
|
+
type: 'function',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
inputs: [
|
|
239
|
+
{ internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
|
|
240
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
241
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
242
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
243
|
+
],
|
|
244
|
+
name: 'swapExactETHForTokensSupportingFeeOnTransferTokens',
|
|
245
|
+
outputs: [],
|
|
246
|
+
stateMutability: 'payable',
|
|
247
|
+
type: 'function',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
inputs: [
|
|
251
|
+
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
|
|
252
|
+
{ internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
|
|
253
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
254
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
255
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
256
|
+
],
|
|
257
|
+
name: 'swapExactTokensForETH',
|
|
258
|
+
outputs: [{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }],
|
|
259
|
+
stateMutability: 'nonpayable',
|
|
260
|
+
type: 'function',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
inputs: [
|
|
264
|
+
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
|
|
265
|
+
{ internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
|
|
266
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
267
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
268
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
269
|
+
],
|
|
270
|
+
name: 'swapExactTokensForETHSupportingFeeOnTransferTokens',
|
|
271
|
+
outputs: [],
|
|
272
|
+
stateMutability: 'nonpayable',
|
|
273
|
+
type: 'function',
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
inputs: [
|
|
277
|
+
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
|
|
278
|
+
{ internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
|
|
279
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
280
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
281
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
282
|
+
],
|
|
283
|
+
name: 'swapExactTokensForTokens',
|
|
284
|
+
outputs: [{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }],
|
|
285
|
+
stateMutability: 'nonpayable',
|
|
286
|
+
type: 'function',
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
inputs: [
|
|
290
|
+
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
|
|
291
|
+
{ internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
|
|
292
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
293
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
294
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
295
|
+
],
|
|
296
|
+
name: 'swapExactTokensForTokensSupportingFeeOnTransferTokens',
|
|
297
|
+
outputs: [],
|
|
298
|
+
stateMutability: 'nonpayable',
|
|
299
|
+
type: 'function',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
inputs: [
|
|
303
|
+
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
|
|
304
|
+
{ internalType: 'uint256', name: 'amountInMax', type: 'uint256' },
|
|
305
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
306
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
307
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
308
|
+
],
|
|
309
|
+
name: 'swapTokensForExactETH',
|
|
310
|
+
outputs: [{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }],
|
|
311
|
+
stateMutability: 'nonpayable',
|
|
312
|
+
type: 'function',
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
inputs: [
|
|
316
|
+
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
|
|
317
|
+
{ internalType: 'uint256', name: 'amountInMax', type: 'uint256' },
|
|
318
|
+
{ internalType: 'address[]', name: 'path', type: 'address[]' },
|
|
319
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
320
|
+
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
|
|
321
|
+
],
|
|
322
|
+
name: 'swapTokensForExactTokens',
|
|
323
|
+
outputs: [{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' }],
|
|
324
|
+
stateMutability: 'nonpayable',
|
|
325
|
+
type: 'function',
|
|
326
|
+
},
|
|
327
|
+
{ stateMutability: 'payable', type: 'receive' },
|
|
328
|
+
]
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
module.exports = [
|
|
2
|
+
{ inputs: [], payable: false, stateMutability: 'nonpayable', type: 'constructor' },
|
|
3
|
+
{
|
|
4
|
+
anonymous: false,
|
|
5
|
+
inputs: [
|
|
6
|
+
{ indexed: true, internalType: 'address', name: 'owner', type: 'address' },
|
|
7
|
+
{ indexed: true, internalType: 'address', name: 'spender', type: 'address' },
|
|
8
|
+
{ indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' },
|
|
9
|
+
],
|
|
10
|
+
name: 'Approval',
|
|
11
|
+
type: 'event',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
anonymous: false,
|
|
15
|
+
inputs: [
|
|
16
|
+
{ indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' },
|
|
17
|
+
{ indexed: true, internalType: 'address', name: 'newOwner', type: 'address' },
|
|
18
|
+
],
|
|
19
|
+
name: 'OwnershipTransferred',
|
|
20
|
+
type: 'event',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
anonymous: false,
|
|
24
|
+
inputs: [
|
|
25
|
+
{ indexed: true, internalType: 'address', name: 'from', type: 'address' },
|
|
26
|
+
{ indexed: true, internalType: 'address', name: 'to', type: 'address' },
|
|
27
|
+
{ indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' },
|
|
28
|
+
],
|
|
29
|
+
name: 'Transfer',
|
|
30
|
+
type: 'event',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
constant: true,
|
|
34
|
+
inputs: [
|
|
35
|
+
{ internalType: 'address', name: 'owner', type: 'address' },
|
|
36
|
+
{ internalType: 'address', name: 'spender', type: 'address' },
|
|
37
|
+
],
|
|
38
|
+
name: 'allowance',
|
|
39
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
40
|
+
payable: false,
|
|
41
|
+
stateMutability: 'view',
|
|
42
|
+
type: 'function',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
constant: false,
|
|
46
|
+
inputs: [
|
|
47
|
+
{ internalType: 'address', name: 'spender', type: 'address' },
|
|
48
|
+
{ internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
49
|
+
],
|
|
50
|
+
name: 'approve',
|
|
51
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
52
|
+
payable: false,
|
|
53
|
+
stateMutability: 'nonpayable',
|
|
54
|
+
type: 'function',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
constant: true,
|
|
58
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
59
|
+
name: 'balanceOf',
|
|
60
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
61
|
+
payable: false,
|
|
62
|
+
stateMutability: 'view',
|
|
63
|
+
type: 'function',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
constant: false,
|
|
67
|
+
inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }],
|
|
68
|
+
name: 'burn',
|
|
69
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
70
|
+
payable: false,
|
|
71
|
+
stateMutability: 'nonpayable',
|
|
72
|
+
type: 'function',
|
|
73
|
+
},
|
|
74
|
+
{ constant: true, inputs: [], name: 'decimals', outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], payable: false, stateMutability: 'view', type: 'function' },
|
|
75
|
+
{
|
|
76
|
+
constant: false,
|
|
77
|
+
inputs: [
|
|
78
|
+
{ internalType: 'address', name: 'spender', type: 'address' },
|
|
79
|
+
{ internalType: 'uint256', name: 'subtractedValue', type: 'uint256' },
|
|
80
|
+
],
|
|
81
|
+
name: 'decreaseAllowance',
|
|
82
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
83
|
+
payable: false,
|
|
84
|
+
stateMutability: 'nonpayable',
|
|
85
|
+
type: 'function',
|
|
86
|
+
},
|
|
87
|
+
{ constant: true, inputs: [], name: 'getOwner', outputs: [{ internalType: 'address', name: '', type: 'address' }], payable: false, stateMutability: 'view', type: 'function' },
|
|
88
|
+
{
|
|
89
|
+
constant: false,
|
|
90
|
+
inputs: [
|
|
91
|
+
{ internalType: 'address', name: 'spender', type: 'address' },
|
|
92
|
+
{ internalType: 'uint256', name: 'addedValue', type: 'uint256' },
|
|
93
|
+
],
|
|
94
|
+
name: 'increaseAllowance',
|
|
95
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
96
|
+
payable: false,
|
|
97
|
+
stateMutability: 'nonpayable',
|
|
98
|
+
type: 'function',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
constant: false,
|
|
102
|
+
inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }],
|
|
103
|
+
name: 'mint',
|
|
104
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
105
|
+
payable: false,
|
|
106
|
+
stateMutability: 'nonpayable',
|
|
107
|
+
type: 'function',
|
|
108
|
+
},
|
|
109
|
+
{ constant: true, inputs: [], name: 'name', outputs: [{ internalType: 'string', name: '', type: 'string' }], payable: false, stateMutability: 'view', type: 'function' },
|
|
110
|
+
{ constant: true, inputs: [], name: 'owner', outputs: [{ internalType: 'address', name: '', type: 'address' }], payable: false, stateMutability: 'view', type: 'function' },
|
|
111
|
+
{ constant: false, inputs: [], name: 'renounceOwnership', outputs: [], payable: false, stateMutability: 'nonpayable', type: 'function' },
|
|
112
|
+
{ constant: true, inputs: [], name: 'symbol', outputs: [{ internalType: 'string', name: '', type: 'string' }], payable: false, stateMutability: 'view', type: 'function' },
|
|
113
|
+
{ constant: true, inputs: [], name: 'totalSupply', outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], payable: false, stateMutability: 'view', type: 'function' },
|
|
114
|
+
{
|
|
115
|
+
constant: false,
|
|
116
|
+
inputs: [
|
|
117
|
+
{ internalType: 'address', name: 'recipient', type: 'address' },
|
|
118
|
+
{ internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
119
|
+
],
|
|
120
|
+
name: 'transfer',
|
|
121
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
122
|
+
payable: false,
|
|
123
|
+
stateMutability: 'nonpayable',
|
|
124
|
+
type: 'function',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
constant: false,
|
|
128
|
+
inputs: [
|
|
129
|
+
{ internalType: 'address', name: 'sender', type: 'address' },
|
|
130
|
+
{ internalType: 'address', name: 'recipient', type: 'address' },
|
|
131
|
+
{ internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
132
|
+
],
|
|
133
|
+
name: 'transferFrom',
|
|
134
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
135
|
+
payable: false,
|
|
136
|
+
stateMutability: 'nonpayable',
|
|
137
|
+
type: 'function',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
constant: false,
|
|
141
|
+
inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }],
|
|
142
|
+
name: 'transferOwnership',
|
|
143
|
+
outputs: [],
|
|
144
|
+
payable: false,
|
|
145
|
+
stateMutability: 'nonpayable',
|
|
146
|
+
type: 'function',
|
|
147
|
+
},
|
|
148
|
+
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-utils",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.42",
|
|
4
4
|
"description": "Utils package.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"needle": "^3.2.0",
|
|
31
31
|
"nodemailer": "^4.7.0",
|
|
32
32
|
"qrcode-terminal": "^0.12.0",
|
|
33
|
+
"web3": "^1.10.0",
|
|
33
34
|
"websocket": "^1.0.33",
|
|
34
35
|
"winston": "^2.4.5",
|
|
35
36
|
"ws": "^8.13.0"
|