Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
// A small share is kept for the operator, note 1,000,000 represents all rebates
// going to the operator
const operatorSharePpm = new BigNumber(900000); // 90 %
const stakingPoolReceipt = await stakingContract
.createStakingPool(operatorSharePpm, true)
.awaitTransactionSuccessAsync({
from: maker,
});
const createStakingPoolLog = stakingPoolReceipt.logs[0];
const poolId = (createStakingPoolLog as any).args.poolId;
await printUtils.awaitTransactionMinedSpinnerAsync(`Create Pool ${poolId}`, stakingPoolReceipt.transactionHash);
// Approve the ZRX token for Staking using the ERC20Proxy
const zrxTokenContract = new ERC20TokenContract(zrxTokenAddress, providerEngine, { from: maker });
await zrxTokenContract
.approve(contractWrappers.contractAddresses.erc20Proxy, UNLIMITED_ALLOWANCE_IN_BASE_UNITS)
.sendTransactionAsync();
// Stake 1000 ZRX
const stakeAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(100), DECIMALS);
// Transfer the ZRX to the Staking Contract
txHash = await stakingContract.stake(stakeAmount).sendTransactionAsync({ from: maker });
await printUtils.awaitTransactionMinedSpinnerAsync('Stake ZRX', txHash);
// Move the staked ZRX to delegate the Staking Pool
txHash = await stakingContract
.moveStake(
{ status: StakeStatus.Undelegated, poolId: NIL_POOL_ID },
{ status: StakeStatus.Delegated, poolId },
stakeAmount,
)
public async getZrxBalanceAsync(owner: string): Promise {
utils.assert(this._contractWrappers !== undefined, 'ContractWrappers must be instantiated.');
const contractAddresses = getContractAddressesForNetworkOrThrow(this.networkId);
const tokenAddress: string = contractAddresses.zrxToken;
const erc20Token = new ERC20TokenContract(tokenAddress, this._contractWrappers.getProvider());
try {
const amount = await erc20Token.balanceOf.callAsync(owner);
return amount;
} catch (error) {
return ZERO;
}
}
private async _onConnectWalletClickAsync(): Promise {