Fetch the swap price from PancakeSwap.

Implements

Constructors

Properties

inTokenAddress: string

The input token address.

inTokenAmount: number

The amount of tokens to swap.

outTokenAddress: string

The output token address.

provider: string

The RPC provider to use for the swap.

slippage: number

The allowable slippage in percent for the swap.

Methods

  • Converts this PancakeswapExchangeRateTask to JSON.

    Returns {
        [k: string]: any;
    }

    JSON object

    • [k: string]: any
  • Decodes a PancakeswapExchangeRateTask message from the specified reader or buffer.

    Parameters

    • reader: Uint8Array | Reader

      Reader or buffer to decode from

    • Optional length: number

      Message length if known beforehand

    Returns PancakeswapExchangeRateTask

    PancakeswapExchangeRateTask

    Throws

    If the payload is not a reader or valid buffer

    Throws

    If required fields are missing

  • Decodes a PancakeswapExchangeRateTask message from the specified reader or buffer, length delimited.

    Parameters

    • reader: Uint8Array | Reader

      Reader or buffer to decode from

    Returns PancakeswapExchangeRateTask

    PancakeswapExchangeRateTask

    Throws

    If the payload is not a reader or valid buffer

    Throws

    If required fields are missing

  • Encodes the specified PancakeswapExchangeRateTask message. Does not implicitly verify messages.

    Parameters

    • message: IPancakeswapExchangeRateTask

      PancakeswapExchangeRateTask message or plain object to encode

    • Optional writer: Writer

      Writer to encode to

    Returns Writer

    Writer

  • Encodes the specified PancakeswapExchangeRateTask message, length delimited. Does not implicitly verify messages.

    Parameters

    • message: IPancakeswapExchangeRateTask

      PancakeswapExchangeRateTask message or plain object to encode

    • Optional writer: Writer

      Writer to encode to

    Returns Writer

    Writer

  • Creates a PancakeswapExchangeRateTask message from a plain object. Also converts values to their respective internal types.

    Parameters

    • object: {
          [k: string]: any;
      }

      Plain object

      • [k: string]: any

    Returns PancakeswapExchangeRateTask

    PancakeswapExchangeRateTask

  • Gets the default type url for PancakeswapExchangeRateTask

    Parameters

    • Optional typeUrlPrefix: string

      your custom typeUrlPrefix(default "type.googleapis.com")

    Returns string

    The default type url

  • Creates a plain object from a PancakeswapExchangeRateTask message. Also converts values to other types if specified.

    Parameters

    Returns {
        [k: string]: any;
    }

    Plain object

    • [k: string]: any
  • Verifies a PancakeswapExchangeRateTask message.

    Parameters

    • message: {
          [k: string]: any;
      }

      Plain object to verify

      • [k: string]: any

    Returns string

    null if valid, otherwise the reason why it is not