@exodus/ethereum-api 6.3.30 → 6.3.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "6.3.30",
3
+ "version": "6.3.32",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "@exodus/asset-lib": "^3.7.1",
18
18
  "@exodus/crypto": "^1.0.0-rc.0",
19
- "@exodus/ethereum-lib": "^4.0.0",
19
+ "@exodus/ethereum-lib": "^4.0.1",
20
20
  "@exodus/ethereumjs-util": "^7.1.0-exodus.6",
21
21
  "@exodus/fetch": "^1.3.0-beta.4",
22
22
  "@exodus/simple-retry": "^0.0.6",
@@ -34,5 +34,5 @@
34
34
  "devDependencies": {
35
35
  "@exodus/models": "^8.10.4"
36
36
  },
37
- "gitHead": "44bf590d6ecef38d828b466687ad579c7528ea84"
37
+ "gitHead": "8eb47087d7253d18f372baad9fbd8b4b42cb2f1a"
38
38
  }
@@ -1,4 +1,5 @@
1
- import { isRpcBalanceAsset } from '@exodus/ethereum-lib'
1
+ import { getEthereumBalances, isRpcBalanceAsset } from '@exodus/ethereum-lib'
2
+
2
3
  import { get } from 'lodash'
3
4
 
4
5
  const fixBalance = ({ txLog, balance }) => {
@@ -35,6 +36,15 @@ const getBalance = ({ asset, accountState, txLog }) => {
35
36
 
36
37
  const shouldFixBalance = isRpcBalanceAsset(asset)
37
38
 
39
+ if (['ethereum', 'ethereumgoerli'].includes(asset.name)) {
40
+ const { balance: ethereumBalance } = getEthereumBalances({
41
+ asset,
42
+ liquidBalance: balance,
43
+ accountState,
44
+ })
45
+ return ethereumBalance
46
+ }
47
+
38
48
  return shouldFixBalance ? fixBalance({ txLog, balance }) : balance
39
49
  }
40
50
 
@@ -21,6 +21,7 @@ export class EthereumStaking {
21
21
  DELEGATE: '0x3a29dbae', // stake(uint256 source)
22
22
  UNSTAKE: '0x76ec871c', // unstake(uint256 amount)
23
23
  UNSTAKE_PENDING: '0xed0723d4', // unstakePending(uint256 amount)
24
+ CLAIM_UNSTAKE: '0x33986ffa', // claimWithdrawRequest(uint256 amount)
24
25
  }
25
26
 
26
27
  constructor(
@@ -94,6 +95,16 @@ export class EthereumStaking {
94
95
  return this.asset.currency.baseUnit(userBalance)
95
96
  }
96
97
 
98
+ /** Return user pending deposited balance. Balance which deposited into validator but not active yet. Pending deposited balance can't be unstake till validator activation */
99
+ async pendingDepositedBalanceOf(address) {
100
+ const userBalance = await this.callReadFunctionContract(
101
+ this.contractAccounting,
102
+ 'pendingDepositedBalanceOf',
103
+ address
104
+ )
105
+ return this.asset.currency.baseUnit(userBalance)
106
+ }
107
+
97
108
  /** Return user active origin deposited balance */
98
109
  async depositedBalanceOf(address) {
99
110
  const depositedBalance = await this.callReadFunctionContract(
@@ -146,7 +146,9 @@ export function createEthereumStakingService({
146
146
  let amount, data, fee
147
147
  try {
148
148
  ;({ amount, data } = await delegateOperation(args))
149
- ;({ fee } = await estimateTxFee(delegatorAddress, staking.poolAddress, amount, data))
149
+ const address =
150
+ operation === 'claimUndelegatedBalance' ? staking.accountingAddress : staking.poolAddress
151
+ ;({ fee } = await estimateTxFee(delegatorAddress, address, amount, data))
150
152
  } catch (e) {
151
153
  // If the operation is to unstake and failed retry with unstakePending
152
154
  if (operation === 'undelegate') {
@@ -236,14 +238,21 @@ export async function getEthereumStakingInfo({ address, asset }) {
236
238
  const delegator = address.toLowerCase()
237
239
  const staking = new EthereumStaking(asset)
238
240
 
239
- const [activeStakedBalance, pendingBalance, withdrawRequest, rewardsBalance] = await Promise.all([
241
+ const [
242
+ activeStakedBalance,
243
+ pendingBalance,
244
+ pendingDepositedBalance,
245
+ withdrawRequest,
246
+ rewardsBalance,
247
+ ] = await Promise.all([
240
248
  staking.autocompoundBalanceOf(delegator),
241
249
  staking.pendingBalanceOf(delegator),
250
+ staking.pendingDepositedBalanceOf(delegator),
242
251
  staking.withdrawRequest(delegator),
243
252
  staking.getLiquidRewards(delegator),
244
253
  ])
245
254
 
246
- const delegatedBalance = activeStakedBalance.add(pendingBalance)
255
+ const delegatedBalance = activeStakedBalance.add(pendingBalance).add(pendingDepositedBalance)
247
256
  const minDelegateAmount = currency.defaultUnit(0.1)
248
257
 
249
258
  const {
@@ -262,8 +271,10 @@ export async function getEthereumStakingInfo({ address, asset }) {
262
271
  return {
263
272
  rewardsBalance,
264
273
  isDelegating,
274
+ activeStakedBalance, // balance staked into the validator
265
275
  delegatedBalance, // balance staked into the validator + pending
266
276
  pendingBalance, // balance waiting to be staked
277
+ pendingDepositedBalance, // balance deposited into validator but not active yet
267
278
  minDelegateAmount,
268
279
  unclaimedUndelegatedBalance,
269
280
  canClaimUndelegatedBalance,
@@ -1,6 +1,6 @@
1
1
  import { EthereumStaking } from './api'
2
2
 
3
- const { DELEGATE, UNSTAKE, UNSTAKE_PENDING } = EthereumStaking.METHODS_IDS
3
+ const { DELEGATE, UNSTAKE, UNSTAKE_PENDING, CLAIM_UNSTAKE } = EthereumStaking.METHODS_IDS
4
4
 
5
5
  const STAKING_MANAGER_CONTRACTS = [
6
6
  EthereumStaking.addresses.ethereum.EVERSTAKE_ADDRESS_CONTRACT_POOL.toLowerCase(),
@@ -13,6 +13,9 @@ export const isEthereumDelegate = (tx) =>
13
13
  isEthereumStakingTx(tx) &&
14
14
  STAKING_MANAGER_CONTRACTS.includes(tx.to) &&
15
15
  tx.data?.methodId === DELEGATE
16
- export const isEthereumUndelegate = (tx) => isEthereumStakingTx(tx) && tx.data?.methodId === UNSTAKE
17
- export const isEthereumClaimUndelegate = (tx) =>
16
+ export const isEthereumUndelegatePending = (tx) =>
18
17
  isEthereumStakingTx(tx) && tx.data?.methodId === UNSTAKE_PENDING
18
+ export const isEthereumUndelegate = (tx) =>
19
+ (isEthereumStakingTx(tx) && tx.data?.methodId === UNSTAKE) || isEthereumUndelegatePending(tx)
20
+ export const isEthereumClaimUndelegate = (tx) =>
21
+ isEthereumStakingTx(tx) && tx.data?.methodId === CLAIM_UNSTAKE