Build applications on-top of the Xend Finance Smart Contract Protocols.
These are guidelines to contributing to this SDK project. We can literally not wait to see your pull requests.
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
Follow this youtube link for an example of how you can setup this SDK for local development.
You can use Xend Finance in as many scenario's you can come up with, but there are 2 examples
- Use one general address for all your transactions
- Create a new address for each of your users and use for their transactions
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;
}
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;
}
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;
}
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)
}
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 |
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"
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": "",
}
}
Name | Parameters | Description |
---|---|---|
getClientAddress |
address of account used to initialize SDK | |
apys |
will only return values if you are on mainnet |
Name | Parameters | Description |
---|---|---|
flexibleDeposit |
depositAmount | |
fixedDeposit |
||
fixedInfo |
||
flexibleInfo |
||
withdrawFixed |
recordId | |
withdrawFlexible |
amount | |
walletBalance |
Name | Parameters | Description |
---|---|---|
create |
||
walletBalance |
Name | Parameters | Description |
---|---|---|
create |
||
walletBalance |
Name | Parameters | Description |
---|---|---|
deposit |
||
withdraw |