Skip to content

The Xend FInance SDK enables existing application to build on Xend Finance without understanding the complexities of the blockchain

License

Notifications You must be signed in to change notification settings

xendfinance/nodejs-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

Xend Finance SDK

Build applications on-top of the Xend Finance Smart Contract Protocols.

Contributing

These are guidelines to contributing to this SDK project. We can literally not wait to see your pull requests.

Installation

Using npm:

npm install @xend-finance/web-sdk

Using yarn:

yarn add @xend-finance/web-sdk

Xend Finance has different saving strategies that helps you save your money in stable currencies;

  • Personal Savings
  • Esusu
  • Cooperative Savings
  • Yield Aggregator(xAuto,xVault)

You can make use of one or all of these strategies

Setup Video

Follow this youtube link for an example of how you can setup this SDK for local development.

Scenario

You can use Xend Finance in as many scenario's you can come up with, but there are 2 examples

  1. Use one general address for all your transactions
  2. Create a new address for each of your users and use for their transactions

Example Personal Flexible Deposit

import XF from '@xend-finance/web-sdk';


const makeDeposit = async () => {
  const { Personal } = await XF(chainId, privateKey, { env:"mainnet" });

  const depositAmount = "100";

  const response = await Personal.flexibleDeposit(depositAmount);

  return response;
}

Example xAuto Deposit

import XF from '@xend-finance/web-sdk';


const makeDeposit = async () => {
  const { xAuto } = await XF(chainId, privateKey, { env:"mainnet" });

  const depositAmount = "100";
  let approval = await xAuto.approve("USDC", depositAmount);

	if (approval && approval.status) {

  const response = await xAuto.deposit("USDC",depositAmount);
  }

  return response;
}

Example xAuto Deposit BNB

import XF from '@xend-finance/web-sdk';


const makeDeposit = async () => {
  const { xAuto } = await XF(chainId, privateKey, { env:"mainnet" });

  const depositAmount = "100";

  const response = await xAuto.depositNative("BNB",depositAmount);

  return response;
}

Withdraw xAuto | xVault

import XF from '@xend-finance/web-sdk';
const withdraw = async () => {
const { xAuto,xVault } = await XF(chainId, privateKey, { env:"mainnet" });

const receiptXauto = await xAuto.withdraw("USDC", totalBUSDAdmount)
const receiptXvault = await xVault.withdraw("BUSD", totalBUSDAdmount)


}

Parameters

These parameters are used to create an instance of any of the saving strategies exported from the SDK

Name Description
chainId Chain ID of the network in use. 56 represents the BSC Mainnet, 1 is for Ethererum Mainnet, 97 is for BSC Testnet
privateKey Private key of address
options Optional

Options

When any of Xend Finance strategy is initialized without options, the SDK defaults to use the addresses for the testnet.

Properties Values Description
env local, testnet, mainnet Required
protocols Array of protocols objects This can only be used when the env is local.
protocolName Used in the case of multiple protocols available

Note: whenever you use the options argument you have to provide value for the env property even if it is "testnet"

Protocol Type

This is the structure of a protocol to be used by the SDK and will be helpful when using the SDK on your local machine with an instance of tools like ganache.

{
  "name":"",
  "code":"",
  "addresses": {
    "PROTOCOL_ADAPTER": "",
    "PROTOCOL_SERVICE": "",
    "GROUPS": "",
    "CYCLES": "",
    "ESUSU_SERVICE": "",
    "ESUSU_STORAGE": "",
    "ESUSU_ADAPTER": "",
    "COOPERATIVE": "",
    "PERSONAL": "",
    "CLIENT_RECORD": "",
    "XEND_TOKEN": "",
    "TOKEN": "",
    "PROTOCOL_CURRENCY": "",
  }
}

Some Available Methods

General

Name Parameters Description
getClientAddress address of account used to initialize SDK
apys will only return values if you are on mainnet

Personal Savings

Name Parameters Description
flexibleDeposit depositAmount
fixedDeposit
fixedInfo
flexibleInfo
withdrawFixed recordId
withdrawFlexible amount
walletBalance

Esusu

Name Parameters Description
create
walletBalance

Cooperative Savings

Name Parameters Description
create
walletBalance

xAuto ,xVault

​​Name Parameters Description
deposit
withdraw

🔗 Social Media Links

gitbook linkedin twitter discord telegram

About

The Xend FInance SDK enables existing application to build on Xend Finance without understanding the complexities of the blockchain

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •