Staking Order Create

Get a list of staked keys, complete with addresses, interest rates, durations, plans, and staking amounts.

Contract function

stakingOrderCreate

Contract address

0x9b727dcaC7b331f95786D3b01fA79191Ab527DA3

Parameters

token: staking key address
orderId: id order
ratio: pool staking ratio
duration: time staking
isLock: lock staking
amount: amount staking

Sample code

public stakingOrderCreate = async (
    params: IOrderStaking
  ): Promise<ethers.ContractTransaction> => {
    try {
      await this.getBTCApprove({
        spender_address: ALPHA_KEY_FACTORY_ADDRESS,
        token_amount: 1,
        need_approve: true,
      });
      const orderId = BigNumber.from(ethers.utils.randomBytes(32));
      await this.estimateTCGa   sFee({ type: ETypes.buy });
      const afk = this.contract.getAlphaKeysFactoryContract();
      const tx = await afk
        .connect(this.wallet)
        .stakingOrderCreate(
          params.tokenAddress,
          ethers.utils.hexlify(orderId),
          params.ratio,
          params.duration,
          params.isLock,
          parseEther(params.amount)
        );
      await tx.wait();
      await delay(1000);
      await this.tradeAPI.scanTrxAlpha({ tx_hash: tx.hash });
      return tx;
    } catch (error) {
      console.log('stakingOrderCreate error', error);
      errorLogger.report({
        action: errorLogger.ERROR_LOGGER_TYPE.STAKING,
        address: this.wallet.address,
        error: JSON.stringify(error),
        info: JSON.stringify({
          step: 'create staking order',
          params,
        }),
      });
      throw error;
    }
  };

Last updated