@getsafle/pancakeswap-controller

1.0.1 • Public • Published

pancakeswap-dex-controller

This SDK houses the functions to interact with the Pancakeswap Contracts.

Installation

To install this SDK,

npm install --save @getsafle/pancakeswap-controller

Initialization

Initialize the constructor,

const Pancakeswap = require('@getsafle/pancakeswap-controller');

const controller = new Pancakeswap(chain);

Get supported tokens

This function will give us the list of all tokens supported by Pancakeswap.

await controller.getSupportedTokens()

Get Exchange Rate


This will give us the exchange rate of 2 tokens. Amount of fromContractAddress the user will receive for fromQuantity of toContractAddress.

await controller.getExchangeRate({ toContractAddress, toContractDecimal, fromContractAddress, fromContractDecimal, fromQuantity, slippageTolerance, walletAddress })

Get Estimated gas


This will give us the estimated amount of gas needed to do the swap.

await controller.getEstimatedGas({ toContractAddress, toContractDecimal, fromContractAddress, fromContractDecimal, fromQuantity, slippageTolerance, walletAddress })

Get Raw Transaction


This will give us the raw transaction to swap the tokens on pancakeswap.

await controller.getRawTransaction({ walletAddress, toContractAddress, toContractDecimal, fromContractAddress, fromContractDecimal, toQuantity, fromQuantity, slippageTolerance })

Get Approval Transaction


This function will call the approval smart contract function to approve spending fromQuantity for the fromContractAddress from the walletAddress.

await controller.approvalRawTransaction({ fromContractAddress, walletAddress, fromQuantity })

Readme

Keywords

none

Package Sidebar

Install

npm i @getsafle/pancakeswap-controller

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

40.6 kB

Total Files

12

Last publish

Collaborators

  • subhanshugupta
  • apoorv31
  • shubham.3008
  • sidth