@exodus/ethereum-api 6.3.16 → 6.3.18-alpha.0

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.16",
3
+ "version": "6.3.18-alpha.0",
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": "^3.3.33",
19
+ "@exodus/ethereum-lib": "^3.3.34",
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",
@@ -33,6 +33,5 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@exodus/models": "^8.10.4"
36
- },
37
- "gitHead": "4a98199d02033b9d822b2065f3725a3bd4a1b83d"
36
+ }
38
37
  }
@@ -130,19 +130,19 @@ export class EthereumStaking {
130
130
 
131
131
  // === POOL ===
132
132
 
133
- async stake({ amount }) {
133
+ async stake({ amount, source = '2' }) {
134
134
  if (amount.gte(this.minAmount)) {
135
135
  return {
136
136
  to: this.poolAddress,
137
137
  amount,
138
- data: bufferToHex(this.buildTxData(this.contractPool, 'stake', '0')), // tx data field
138
+ data: bufferToHex(this.buildTxData(this.contractPool, 'stake', source)), // tx data field
139
139
  }
140
140
  } else {
141
141
  throw new Error(`Min Amount ${this.minAmount}`)
142
142
  }
143
143
  }
144
144
 
145
- async unstake({ address, amount, isAllowedInterchange = false, source = '0' }) {
145
+ async unstake({ address, amount, isAllowedInterchange = false, source = '2' }) {
146
146
  const amountWei = amount.toBaseString()
147
147
  const balance = await this.autocompoundBalanceOf(address)
148
148
 
@@ -55,9 +55,10 @@ export function createEthereumStakingService({
55
55
 
56
56
  let txId
57
57
  if (!pendingAmount.isZero) {
58
+ const inactiveAmountToUnstake = pendingAmount.lte(amount) ? pendingAmount : amount
58
59
  const { to, data } = await staking.unstakePending({
59
60
  address: delegatorAddress,
60
- amount,
61
+ amount: inactiveAmountToUnstake,
61
62
  })
62
63
 
63
64
  let { gasPrice, gasLimit, fee } = await estimateTxFee(
@@ -79,10 +80,10 @@ export function createEthereumStakingService({
79
80
 
80
81
  // need also to unstake
81
82
  if (amount.gt(pendingAmount)) {
82
- const amountToUnstake = amount.sub(pendingAmount)
83
+ const activeAmountToUnstake = amount.sub(pendingAmount)
83
84
  const { to, data } = await staking.unstake({
84
85
  address: delegatorAddress,
85
- amount: amountToUnstake,
86
+ amount: activeAmountToUnstake,
86
87
  })
87
88
 
88
89
  let { gasPrice, gasLimit, fee } = await estimateTxFee(delegatorAddress, to, null, data)
@@ -258,7 +259,8 @@ export async function getEthereumStakingInfo({ address, asset }) {
258
259
  return {
259
260
  rewardsBalance,
260
261
  isDelegating,
261
- delegatedBalance,
262
+ delegatedBalance, // balance staked into the validator + pending
263
+ pendingBalance, // balance waiting to be staked
262
264
  minDelegateAmount,
263
265
  unclaimedUndelegatedBalance,
264
266
  canClaimUndelegatedBalance,
package/LICENSE.md DELETED
File without changes