Infinity Staking Implementation

To add liquidity to a pool we will use the addLiquidity function of the sdk.

Syntax

export function stakeToken(
  xfai: Xfai,
  amountIn: BigNumber,
  minShare: BigNumber,
  options: StakeOptions & {
    inft: undefined | INFT;
  },
): Promise<PopulatedTransaction>

Parameters

  • xfai: An instance of the Xfai class.

  • amountIn: The amount of token you want to stake

  • minShare: The minimum amount of INFT shares you want to receive for staking the specified amount of token

  • options: This parameter allows you to specify additional transaction options such as INFT ID (used for boosting), deadline, slippage and more. Review the available options and set them according to your needs.

Return Value

A promise that return the PopulatedTransaction object.

Examples

Double sided

import {stakeToken, sendPopulatedTx, getSwapAmounts, getINFTState, calculateShare, negativeSlippage, quote, Token, Xfai } from '@xfai-labs/sdk';

const xfai = new Xfai(...);

const underlyingTokenAmount = Bignumber.from(10).pow(18);

// Now that we have calculagted underlyingTokenAmount we use it to calculate minShares
const slippage = BasisPoint.from(5); // 0.5% slippage

const inftState = await getINFTState(xfai); // inft state containing info about total shares issues and XFIT locked

const minShares = calculateShare(inftState, negativeSlippage(underlyingTokenAmount, slippage));


const populatedTx = await stakeToken(xfai, tokenInput, minShares, {
  deadline: Math.floor(Date.now() / 1000) + 60 * 20,
  inft: INFT(5) // used to specify the inft
});

// sign and send the transaction
sendPopulatedTx(xfai, populatedTx);

Last updated