@exodus/ethereum-lib 2.13.4 → 2.13.6

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.
@@ -1,37 +1,280 @@
1
1
  // Everstake Validator
2
- // https://etherscan.io/address/0xf30cf4ed712d3734161fdaab5b1dbb49fd2d0e5c#code
2
+ // https://etherscan.io/address/0xf98864da30a5bd657b13e70a57f5718abf7bab31#code
3
3
 
4
4
  export default [
5
5
  {
6
- inputs: [{ internalType: 'address', name: '_registry', type: 'address' }],
7
- payable: false,
8
- stateMutability: 'nonpayable',
9
- type: 'constructor',
6
+ anonymous: false,
7
+ inputs: [
8
+ { indexed: true, internalType: 'address', name: 'owner', type: 'address' },
9
+ { indexed: true, internalType: 'address', name: 'spender', type: 'address' },
10
+ { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' },
11
+ ],
12
+ name: 'Approval',
13
+ type: 'event',
10
14
  },
11
15
  {
12
16
  anonymous: false,
13
17
  inputs: [
14
- { indexed: false, internalType: 'address', name: '_new', type: 'address' },
15
- { indexed: false, internalType: 'address', name: '_old', type: 'address' },
18
+ { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' },
19
+ { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' },
16
20
  ],
17
- name: 'OwnerUpdate',
21
+ name: 'OwnershipTransferred',
18
22
  type: 'event',
19
23
  },
20
24
  {
21
25
  anonymous: false,
22
26
  inputs: [
23
- { indexed: true, internalType: 'address', name: '_new', type: 'address' },
24
- { indexed: true, internalType: 'address', name: '_old', type: 'address' },
27
+ { indexed: true, internalType: 'address', name: 'from', type: 'address' },
28
+ { indexed: true, internalType: 'address', name: 'to', type: 'address' },
29
+ { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' },
25
30
  ],
26
- name: 'ProxyUpdated',
31
+ name: 'Transfer',
27
32
  type: 'event',
28
33
  },
29
- { payable: true, stateMutability: 'payable', type: 'fallback' },
30
34
  {
31
35
  constant: true,
32
36
  inputs: [],
33
- name: 'implementation',
34
- outputs: [{ internalType: 'address', name: '', type: 'address' }],
37
+ name: 'activeAmount',
38
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
39
+ payable: false,
40
+ stateMutability: 'view',
41
+ type: 'function',
42
+ },
43
+ {
44
+ constant: true,
45
+ inputs: [
46
+ { internalType: 'address', name: 'owner', type: 'address' },
47
+ { internalType: 'address', name: 'spender', type: 'address' },
48
+ ],
49
+ name: 'allowance',
50
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
51
+ payable: false,
52
+ stateMutability: 'view',
53
+ type: 'function',
54
+ },
55
+ {
56
+ constant: false,
57
+ inputs: [
58
+ { internalType: 'address', name: 'spender', type: 'address' },
59
+ { internalType: 'uint256', name: 'value', type: 'uint256' },
60
+ ],
61
+ name: 'approve',
62
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
63
+ payable: false,
64
+ stateMutability: 'nonpayable',
65
+ type: 'function',
66
+ },
67
+ {
68
+ constant: true,
69
+ inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
70
+ name: 'balanceOf',
71
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
72
+ payable: false,
73
+ stateMutability: 'view',
74
+ type: 'function',
75
+ },
76
+ {
77
+ constant: false,
78
+ inputs: [
79
+ { internalType: 'uint256', name: '_amount', type: 'uint256' },
80
+ { internalType: 'uint256', name: '_minSharesToMint', type: 'uint256' },
81
+ ],
82
+ name: 'buyVoucher',
83
+ outputs: [{ internalType: 'uint256', name: 'amountToDeposit', type: 'uint256' }],
84
+ payable: false,
85
+ stateMutability: 'nonpayable',
86
+ type: 'function',
87
+ },
88
+ {
89
+ constant: true,
90
+ inputs: [],
91
+ name: 'commissionRate_deprecated',
92
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
93
+ payable: false,
94
+ stateMutability: 'view',
95
+ type: 'function',
96
+ },
97
+ {
98
+ constant: false,
99
+ inputs: [
100
+ { internalType: 'address', name: 'spender', type: 'address' },
101
+ { internalType: 'uint256', name: 'subtractedValue', type: 'uint256' },
102
+ ],
103
+ name: 'decreaseAllowance',
104
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
105
+ payable: false,
106
+ stateMutability: 'nonpayable',
107
+ type: 'function',
108
+ },
109
+ {
110
+ constant: true,
111
+ inputs: [],
112
+ name: 'delegation',
113
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
114
+ payable: false,
115
+ stateMutability: 'view',
116
+ type: 'function',
117
+ },
118
+ {
119
+ constant: false,
120
+ inputs: [
121
+ { internalType: 'address', name: 'token', type: 'address' },
122
+ { internalType: 'address payable', name: 'destination', type: 'address' },
123
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
124
+ ],
125
+ name: 'drain',
126
+ outputs: [],
127
+ payable: false,
128
+ stateMutability: 'nonpayable',
129
+ type: 'function',
130
+ },
131
+ {
132
+ constant: true,
133
+ inputs: [],
134
+ name: 'eventsHub',
135
+ outputs: [{ internalType: 'contract EventsHub', name: '', type: 'address' }],
136
+ payable: false,
137
+ stateMutability: 'view',
138
+ type: 'function',
139
+ },
140
+ {
141
+ constant: true,
142
+ inputs: [],
143
+ name: 'exchangeRate',
144
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
145
+ payable: false,
146
+ stateMutability: 'view',
147
+ type: 'function',
148
+ },
149
+ {
150
+ constant: true,
151
+ inputs: [{ internalType: 'address', name: 'user', type: 'address' }],
152
+ name: 'getLiquidRewards',
153
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
154
+ payable: false,
155
+ stateMutability: 'view',
156
+ type: 'function',
157
+ },
158
+ {
159
+ constant: true,
160
+ inputs: [],
161
+ name: 'getRewardPerShare',
162
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
163
+ payable: false,
164
+ stateMutability: 'view',
165
+ type: 'function',
166
+ },
167
+ {
168
+ constant: true,
169
+ inputs: [{ internalType: 'address', name: 'user', type: 'address' }],
170
+ name: 'getTotalStake',
171
+ outputs: [
172
+ { internalType: 'uint256', name: '', type: 'uint256' },
173
+ { internalType: 'uint256', name: '', type: 'uint256' },
174
+ ],
175
+ payable: false,
176
+ stateMutability: 'view',
177
+ type: 'function',
178
+ },
179
+ {
180
+ constant: false,
181
+ inputs: [
182
+ { internalType: 'address', name: 'spender', type: 'address' },
183
+ { internalType: 'uint256', name: 'addedValue', type: 'uint256' },
184
+ ],
185
+ name: 'increaseAllowance',
186
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
187
+ payable: false,
188
+ stateMutability: 'nonpayable',
189
+ type: 'function',
190
+ },
191
+ {
192
+ constant: true,
193
+ inputs: [{ internalType: 'address', name: '', type: 'address' }],
194
+ name: 'initalRewardPerShare',
195
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
196
+ payable: false,
197
+ stateMutability: 'view',
198
+ type: 'function',
199
+ },
200
+ {
201
+ constant: false,
202
+ inputs: [
203
+ { internalType: 'uint256', name: '_validatorId', type: 'uint256' },
204
+ { internalType: 'address', name: '_stakingLogger', type: 'address' },
205
+ { internalType: 'address', name: '_stakeManager', type: 'address' },
206
+ ],
207
+ name: 'initialize',
208
+ outputs: [],
209
+ payable: false,
210
+ stateMutability: 'nonpayable',
211
+ type: 'function',
212
+ },
213
+ {
214
+ constant: true,
215
+ inputs: [],
216
+ name: 'isOwner',
217
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
218
+ payable: false,
219
+ stateMutability: 'view',
220
+ type: 'function',
221
+ },
222
+ {
223
+ constant: true,
224
+ inputs: [],
225
+ name: 'lastCommissionUpdate_deprecated',
226
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
227
+ payable: false,
228
+ stateMutability: 'view',
229
+ type: 'function',
230
+ },
231
+ {
232
+ constant: false,
233
+ inputs: [],
234
+ name: 'lock',
235
+ outputs: [],
236
+ payable: false,
237
+ stateMutability: 'nonpayable',
238
+ type: 'function',
239
+ },
240
+ {
241
+ constant: true,
242
+ inputs: [],
243
+ name: 'locked',
244
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
245
+ payable: false,
246
+ stateMutability: 'view',
247
+ type: 'function',
248
+ },
249
+ {
250
+ constant: false,
251
+ inputs: [
252
+ { internalType: 'address', name: 'user', type: 'address' },
253
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
254
+ ],
255
+ name: 'migrateIn',
256
+ outputs: [],
257
+ payable: false,
258
+ stateMutability: 'nonpayable',
259
+ type: 'function',
260
+ },
261
+ {
262
+ constant: false,
263
+ inputs: [
264
+ { internalType: 'address', name: 'user', type: 'address' },
265
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
266
+ ],
267
+ name: 'migrateOut',
268
+ outputs: [],
269
+ payable: false,
270
+ stateMutability: 'nonpayable',
271
+ type: 'function',
272
+ },
273
+ {
274
+ constant: true,
275
+ inputs: [],
276
+ name: 'minAmount',
277
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
35
278
  payable: false,
36
279
  stateMutability: 'view',
37
280
  type: 'function',
@@ -45,13 +288,132 @@ export default [
45
288
  stateMutability: 'view',
46
289
  type: 'function',
47
290
  },
291
+ {
292
+ constant: false,
293
+ inputs: [],
294
+ name: 'renounceOwnership',
295
+ outputs: [],
296
+ payable: false,
297
+ stateMutability: 'nonpayable',
298
+ type: 'function',
299
+ },
300
+ {
301
+ constant: false,
302
+ inputs: [],
303
+ name: 'restake',
304
+ outputs: [
305
+ { internalType: 'uint256', name: '', type: 'uint256' },
306
+ { internalType: 'uint256', name: '', type: 'uint256' },
307
+ ],
308
+ payable: false,
309
+ stateMutability: 'nonpayable',
310
+ type: 'function',
311
+ },
48
312
  {
49
313
  constant: true,
50
314
  inputs: [],
51
- name: 'proxyType',
52
- outputs: [{ internalType: 'uint256', name: 'proxyTypeId', type: 'uint256' }],
315
+ name: 'rewardPerShare',
316
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
317
+ payable: false,
318
+ stateMutability: 'view',
319
+ type: 'function',
320
+ },
321
+ {
322
+ constant: false,
323
+ inputs: [
324
+ { internalType: 'uint256', name: 'claimAmount', type: 'uint256' },
325
+ { internalType: 'uint256', name: 'maximumSharesToBurn', type: 'uint256' },
326
+ ],
327
+ name: 'sellVoucher',
328
+ outputs: [],
329
+ payable: false,
330
+ stateMutability: 'nonpayable',
331
+ type: 'function',
332
+ },
333
+ {
334
+ constant: false,
335
+ inputs: [
336
+ { internalType: 'uint256', name: 'claimAmount', type: 'uint256' },
337
+ { internalType: 'uint256', name: 'maximumSharesToBurn', type: 'uint256' },
338
+ ],
339
+ name: 'sellVoucher_new',
340
+ outputs: [],
341
+ payable: false,
342
+ stateMutability: 'nonpayable',
343
+ type: 'function',
344
+ },
345
+ {
346
+ constant: false,
347
+ inputs: [
348
+ { internalType: 'uint256', name: 'validatorStake', type: 'uint256' },
349
+ { internalType: 'uint256', name: 'delegatedAmount', type: 'uint256' },
350
+ { internalType: 'uint256', name: 'totalAmountToSlash', type: 'uint256' },
351
+ ],
352
+ name: 'slash',
353
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
354
+ payable: false,
355
+ stateMutability: 'nonpayable',
356
+ type: 'function',
357
+ },
358
+ {
359
+ constant: true,
360
+ inputs: [],
361
+ name: 'stakeManager',
362
+ outputs: [{ internalType: 'contract IStakeManager', name: '', type: 'address' }],
363
+ payable: false,
364
+ stateMutability: 'view',
365
+ type: 'function',
366
+ },
367
+ {
368
+ constant: true,
369
+ inputs: [],
370
+ name: 'stakingLogger',
371
+ outputs: [{ internalType: 'contract StakingInfo', name: '', type: 'address' }],
372
+ payable: false,
373
+ stateMutability: 'view',
374
+ type: 'function',
375
+ },
376
+ {
377
+ constant: true,
378
+ inputs: [],
379
+ name: 'totalStake_deprecated',
380
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
381
+ payable: false,
382
+ stateMutability: 'view',
383
+ type: 'function',
384
+ },
385
+ {
386
+ constant: true,
387
+ inputs: [],
388
+ name: 'totalSupply',
389
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
390
+ payable: false,
391
+ stateMutability: 'view',
392
+ type: 'function',
393
+ },
394
+ {
395
+ constant: false,
396
+ inputs: [
397
+ { internalType: 'address', name: 'to', type: 'address' },
398
+ { internalType: 'uint256', name: 'value', type: 'uint256' },
399
+ ],
400
+ name: 'transfer',
401
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
402
+ payable: false,
403
+ stateMutability: 'nonpayable',
404
+ type: 'function',
405
+ },
406
+ {
407
+ constant: false,
408
+ inputs: [
409
+ { internalType: 'address', name: 'from', type: 'address' },
410
+ { internalType: 'address', name: 'to', type: 'address' },
411
+ { internalType: 'uint256', name: 'value', type: 'uint256' },
412
+ ],
413
+ name: 'transferFrom',
414
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
53
415
  payable: false,
54
- stateMutability: 'pure',
416
+ stateMutability: 'nonpayable',
55
417
  type: 'function',
56
418
  },
57
419
  {
@@ -64,24 +426,129 @@ export default [
64
426
  type: 'function',
65
427
  },
66
428
  {
67
- constant: false,
429
+ constant: true,
430
+ inputs: [{ internalType: 'address', name: '', type: 'address' }],
431
+ name: 'unbondNonces',
432
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
433
+ payable: false,
434
+ stateMutability: 'view',
435
+ type: 'function',
436
+ },
437
+ {
438
+ constant: true,
439
+ inputs: [{ internalType: 'address', name: '', type: 'address' }],
440
+ name: 'unbonds',
441
+ outputs: [
442
+ { internalType: 'uint256', name: 'shares', type: 'uint256' },
443
+ { internalType: 'uint256', name: 'withdrawEpoch', type: 'uint256' },
444
+ ],
445
+ payable: false,
446
+ stateMutability: 'view',
447
+ type: 'function',
448
+ },
449
+ {
450
+ constant: true,
68
451
  inputs: [
69
- { internalType: 'address', name: '_newProxyTo', type: 'address' },
70
- { internalType: 'bytes', name: 'data', type: 'bytes' },
452
+ { internalType: 'address', name: '', type: 'address' },
453
+ { internalType: 'uint256', name: '', type: 'uint256' },
454
+ ],
455
+ name: 'unbonds_new',
456
+ outputs: [
457
+ { internalType: 'uint256', name: 'shares', type: 'uint256' },
458
+ { internalType: 'uint256', name: 'withdrawEpoch', type: 'uint256' },
71
459
  ],
72
- name: 'updateAndCall',
460
+ payable: false,
461
+ stateMutability: 'view',
462
+ type: 'function',
463
+ },
464
+ {
465
+ constant: false,
466
+ inputs: [],
467
+ name: 'unlock',
468
+ outputs: [],
469
+ payable: false,
470
+ stateMutability: 'nonpayable',
471
+ type: 'function',
472
+ },
473
+ {
474
+ constant: false,
475
+ inputs: [],
476
+ name: 'unstakeClaimTokens',
73
477
  outputs: [],
74
- payable: true,
75
- stateMutability: 'payable',
478
+ payable: false,
479
+ stateMutability: 'nonpayable',
480
+ type: 'function',
481
+ },
482
+ {
483
+ constant: false,
484
+ inputs: [{ internalType: 'uint256', name: 'unbondNonce', type: 'uint256' }],
485
+ name: 'unstakeClaimTokens_new',
486
+ outputs: [],
487
+ payable: false,
488
+ stateMutability: 'nonpayable',
76
489
  type: 'function',
77
490
  },
78
491
  {
79
492
  constant: false,
80
- inputs: [{ internalType: 'address', name: '_newProxyTo', type: 'address' }],
81
- name: 'updateImplementation',
493
+ inputs: [{ internalType: 'bool', name: '_delegation', type: 'bool' }],
494
+ name: 'updateDelegation',
82
495
  outputs: [],
83
496
  payable: false,
84
497
  stateMutability: 'nonpayable',
85
498
  type: 'function',
86
499
  },
500
+ {
501
+ constant: true,
502
+ inputs: [],
503
+ name: 'validatorId',
504
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
505
+ payable: false,
506
+ stateMutability: 'view',
507
+ type: 'function',
508
+ },
509
+ {
510
+ constant: true,
511
+ inputs: [],
512
+ name: 'validatorRewards_deprecated',
513
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
514
+ payable: false,
515
+ stateMutability: 'view',
516
+ type: 'function',
517
+ },
518
+ {
519
+ constant: true,
520
+ inputs: [],
521
+ name: 'withdrawExchangeRate',
522
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
523
+ payable: false,
524
+ stateMutability: 'view',
525
+ type: 'function',
526
+ },
527
+ {
528
+ constant: true,
529
+ inputs: [],
530
+ name: 'withdrawPool',
531
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
532
+ payable: false,
533
+ stateMutability: 'view',
534
+ type: 'function',
535
+ },
536
+ {
537
+ constant: false,
538
+ inputs: [],
539
+ name: 'withdrawRewards',
540
+ outputs: [],
541
+ payable: false,
542
+ stateMutability: 'nonpayable',
543
+ type: 'function',
544
+ },
545
+ {
546
+ constant: true,
547
+ inputs: [],
548
+ name: 'withdrawShares',
549
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
550
+ payable: false,
551
+ stateMutability: 'view',
552
+ type: 'function',
553
+ },
87
554
  ]
package/src/constants.js CHANGED
@@ -35,14 +35,3 @@ export const ETHEREUM_LIKE_TOKEN_TYPES = [
35
35
  'FTM_ERC20',
36
36
  ]
37
37
  export const BUMP_RATE = 1.2
38
- export const TX_METHOD = {
39
- MaticStaking: {
40
- Stake: 'stake_matic',
41
- Unstake: 'unstake_matic',
42
- WithdrawRewards: 'withdraw_rewards_matic',
43
- },
44
- }
45
-
46
- export const MATIC_VALIDATOR = {
47
- EverStake: '0xf30cf4ed712d3734161fdaab5b1dbb49fd2d0e5c',
48
- }
@@ -20,6 +20,8 @@ export default function createContract(address, contractName) {
20
20
  return new SolidityContract(ABI.kyberv2, address)
21
21
  case 'maticValidatorShare':
22
22
  return new SolidityContract(ABI.maticValidatorShare, address)
23
+ case 'maticStakingManager':
24
+ return new SolidityContract(ABI.maticStakingManager, address)
23
25
  default:
24
26
  return SolidityContract.erc20(address)
25
27
  }
@@ -6,7 +6,6 @@ import { FeeMarketEIP1559Transaction, Transaction } from '@exodus/ethereumjs-tx'
6
6
  import { uniq } from 'lodash'
7
7
 
8
8
  export { default as calculateExtraEth } from './calculate-extra-eth'
9
- export { getMaticStaking } from './matic-staking'
10
9
 
11
10
  const base10 = baseX('0123456789')
12
11
  const base16 = baseX('0123456789abcdef')
@@ -81,7 +80,8 @@ export const isApproveTx = (tx) => tx?.data?.data?.startsWith(APPROVE_METHOD_ID)
81
80
 
82
81
  export const isFeePaymentTx = (tx) => tx?.data?.data?.startsWith(FEE_PAYMENT_PREFIX)
83
82
 
84
- export const isRpcBalanceAsset = (asset) => ['bsc', 'matic', 'babydoge_bsc'].includes(asset.name)
83
+ export const isRpcBalanceAsset = (asset) =>
84
+ ['bsc', 'matic', 'babydoge_bsc', 'steth'].includes(asset.name)
85
85
 
86
86
  export const getAssetAddresses = (asset) => {
87
87
  // It seems to be two schemas of assets. The original and the transformed by the client.
@@ -1,34 +0,0 @@
1
- import assert from 'assert'
2
- import { MATIC_VALIDATOR, TX_METHOD } from '../constants'
3
- import createContract from '../create-contract'
4
-
5
- const maticValidatorShareContract = createContract(MATIC_VALIDATOR.EverStake, 'maticValidatorShare')
6
-
7
- const getBuyVoucherTxData = ({ contract, amount }) => {
8
- return contract.buyVoucher(amount.toBase().toString({ unit: false }), 0)
9
- }
10
-
11
- const getSellVoucherTxData = ({ contract, amount }) => {
12
- return contract.sellVoucher_new(
13
- amount.toBase().toString({ unit: false }),
14
- amount.toBase().toString({ unit: false })
15
- )
16
- }
17
-
18
- const getWidthrawRewardsTxData = ({ contract }) => {
19
- return contract.withdrawRewards()
20
- }
21
-
22
- const getTxDataMapping = {
23
- [TX_METHOD.MaticStaking.Stake]: getBuyVoucherTxData,
24
- [TX_METHOD.MaticStaking.Unstake]: getSellVoucherTxData,
25
- [TX_METHOD.MaticStaking.WithdrawRewards]: getWidthrawRewardsTxData,
26
- }
27
-
28
- export function getMaticStaking({ method, amount }) {
29
- assert(method, 'Missing methid')
30
- if (getTxDataMapping[method]) {
31
- return getTxDataMapping[method]({ maticValidatorShareContract, amount })
32
- }
33
- throw new Error(`calculateTxInputData > Unsupport method ${method}`)
34
- }