Staking Open
The key owner initiates key staking.
Contract function
stakingOpen
Contract address
0x9b727dcaC7b331f95786D3b01fA79191Ab527DA3
Parameters
ratio: pool staking ratio
duration: time staking
locked: is staking lock
lockAmount: amount staking
buyPriceAfterFeeMax: btc price to buy key
Sample code
public stakingOpen = async (
params: IOpenStaking
): Promise<ethers.ContractTransaction> => {
let step = 0;
try {
console.log('stakingOpen params', params);
await this.getBTCApprove({
spender_address: ALPHA_KEY_FACTORY_ADDRESS,
token_amount: 1,
need_approve: true,
});
step = 1;
await this.estimateTCGasFee({ type: ETypes.buy });
step = 2;
const afk = this.contract.getAlphaKeysFactoryContract();
step = 3;
const tx = await afk
.connect(this.wallet)
.stakingOpen(
params.ratio,
params.duration,
params.isLock,
params.amountKeysInteger,
parseEther(params.btcAmount)
);
step = 4;
await tx.wait();
await delay(1000);
step = 5;
await this.tradeAPI.scanTrxAlpha({ tx_hash: tx.hash });
return tx;
} catch (error) {
errorLogger.report({
action: errorLogger.ERROR_LOGGER_TYPE.STAKING,
address: this.wallet.address || '',
error: JSON.stringify(error),
info: JSON.stringify({
step: 'create staking',
params,
step_error: step,
}),
});
console.log('stakingOpen error', error);
throw error;
}
};
Last updated