Skip to content

Commit

Permalink
fix(staking): hardcode tx overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Jul 28, 2021
1 parent 839585d commit 5ed6eda
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/api/classes/stakingpool.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ___
Name | Type | Default value |
------ | ------ | ------ |
`stake` | BigNumber \| number | - |
`transactionSpeed` | [TransactionSpeed](../enums/transactionspeed.md) | TransactionSpeed.AVERAGE |
`transactionSpeed` | [TransactionSpeed](../enums/transactionspeed.md) | TransactionSpeed.FAST |

**Returns:** Promise\<void>

Expand All @@ -112,7 +112,7 @@ Withdraw request unavailable until minimum staking period ends

Name | Type | Default value |
------ | ------ | ------ |
`transactionSpeed` | [TransactionSpeed](../enums/transactionspeed.md) | TransactionSpeed.AVERAGE |
`transactionSpeed` | [TransactionSpeed](../enums/transactionspeed.md) | TransactionSpeed.FAST |

**Returns:** Promise\<void>

Expand Down Expand Up @@ -140,7 +140,7 @@ ___

Name | Type | Default value |
------ | ------ | ------ |
`transactionSpeed` | [TransactionSpeed](../enums/transactionspeed.md) | TransactionSpeed.AVERAGE |
`transactionSpeed` | [TransactionSpeed](../enums/transactionspeed.md) | TransactionSpeed.FAST |

**Returns:** Promise\<void>

Expand Down
8 changes: 4 additions & 4 deletions docs/api/enums/transactionspeed.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

### Enumeration members

* [AVERAGE](transactionspeed.md#average)
* [BASE](transactionspeed.md#base)
* [FAST](transactionspeed.md#fast)

## Enumeration members

### AVERAGE
### BASE

**AVERAGE**: = BASE\_TRANSACTION\_SPEED
**BASE**: = 0

___

### FAST

**FAST**: = BASE\_TRANSACTION\_SPEED + 3
**FAST**: = 1
7 changes: 7 additions & 0 deletions docs/api/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
* [id](globals.md#id)
* [keccak256](globals.md#keccak256)
* [owners](globals.md#owners)
* [parseUnits](globals.md#parseunits)
* [proof\_type\_hash](globals.md#proof_type_hash)
* [recoverPublicKey](globals.md#recoverpublickey)
* [sha3](globals.md#sha3)
Expand Down Expand Up @@ -354,6 +355,12 @@ ___

___

### parseUnits

**parseUnits**: parseUnits

___

### proof\_type\_hash

`Const` **proof\_type\_hash**: string = utils.id("Proof(address subject,bytes32 role,uint256 version,uint256 expiry,address issuer)")
Expand Down
17 changes: 12 additions & 5 deletions src/staking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { ERROR_MESSAGES } from "../errors";
import { chainConfigs } from "../iam/chainConfig";
import { emptyAddress } from "../utils/constants";

const { namehash, BigNumber } = utils;
const { namehash, BigNumber, parseUnits } = utils;

export enum StakeStatus { NONSTAKING = 0, STAKING = 1, WITHDRAWING = 2 }
export enum TransactionSpeed { BASE = 10, FAST = BASE + 3 }
export enum TransactionSpeed { BASE = 0, FAST = 1 }

export type Service = {
/** organization ENS name */
Expand Down Expand Up @@ -116,6 +116,13 @@ export class StakingPoolService {
* Abstraction over staking pool smart contract
*/
export class StakingPool {
private overrides = {
[TransactionSpeed.BASE]: {},
[TransactionSpeed.FAST]: {
gasPrice: parseUnits("0.01", "gwei"),
gasLimit: 490000
}
}
private pool: StakingPoolContract;
constructor(private patron: Required<Signer>, address: string) {
this.pool = new StakingPool__factory(patron).attach(address);
Expand All @@ -138,7 +145,7 @@ export class StakingPool {
}
await (await this.pool.putStake({
value: stake,
gasPrice: (await this.pool.provider.getGasPrice()).mul(transactionSpeed).div(TransactionSpeed.BASE)
...this.overrides[transactionSpeed]
})).wait();
}

Expand Down Expand Up @@ -183,7 +190,7 @@ export class StakingPool {
*/
async requestWithdraw(transactionSpeed = TransactionSpeed.FAST): Promise<void> {
await (await this.pool.requestWithdraw({
gasPrice: (await this.pool.provider.getGasPrice()).mul(transactionSpeed).div(TransactionSpeed.BASE)
...this.overrides[transactionSpeed]
})).wait();
}

Expand All @@ -210,7 +217,7 @@ export class StakingPool {
*/
async withdraw(transactionSpeed = TransactionSpeed.FAST): Promise<void> {
await (await this.pool.withdraw({
gasPrice: (await this.pool.provider.getGasPrice()).mul(transactionSpeed).div(TransactionSpeed.BASE)
...this.overrides[transactionSpeed]
})).wait();
}

Expand Down

0 comments on commit 5ed6eda

Please sign in to comment.