How to use the @0x/contract-wrappers.StakingContract function in @0x/contract-wrappers

To help you get started, we’ve selected a few @0x/contract-wrappers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-starter-project / src / scenarios / create_staking_pool.ts View on Github external
export async function scenarioAsync(): Promise {
    await runMigrationsOnceIfRequiredAsync();
    let txHash;
    PrintUtils.printScenario('Create Staking Pool');
    // account information, balances, general contract logs
    const web3Wrapper = new Web3Wrapper(providerEngine);
    const [maker, otherMaker] = await web3Wrapper.getAvailableAddressesAsync();
    const contractWrappers = new ContractWrappers(providerEngine, { chainId: NETWORK_CONFIGS.chainId });
    const zrxTokenAddress = contractWrappers.contractAddresses.zrxToken;
    const printUtils = new PrintUtils(web3Wrapper, contractWrappers, { maker }, { ZRX: zrxTokenAddress });

    // Staking Proxy is a delegate contract. We initialize a Staking Contract (ABI) pointing to the delegate proxy
    // at stakingProxyContractAddress
    const stakingContract = new StakingContract(contractWrappers.contractAddresses.stakingProxy, providerEngine, {
        from: maker,
    });

    // 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