balance-analytics-sdk
v0.1.5
Published
<p> <img title="Lazerpay" src= "https://res.cloudinary.com/njokuscript/image/upload/v1646279538/lazerpay_logo_no-bg_trkkye.png"/> </p> # Balance analytics SDK
Downloads
10
Readme
How to use
npm install balance-analytics-sdk
const BalanceSDK = require('balance-analytics-sdk');
Get Balance
This describes to allow you return the historic balance of a wallet over a given range
const BalanceSDK = require('balance-analytics-sdk');
// pass in a web3 instance
const balance = new BalanceSDK(web3);
const tokenArray = [
{ name: 'BUSD', address: '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56' },
{ name: 'USDT', address: '0x55d398326f99059fF775485246999027B3197955' },
{ name: 'USDC', address: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d' },
{ name: 'DAI', address: '0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3' },
];
const result = await balance.getBalanceData(
walletAddress, // address of the wallet
'days', // Period, required. Valid value: years, quarters, months, weeks, days, hours, minutes
'2022-05-10T12:00:00Z', // Start date, required. Any valid moment.js value: string, milliseconds, Date() object, moment() object.
'2022-05-13T12:00:00Z', // End date, required. Any valid moment.js value: string, milliseconds, Date() object, moment() object.
tokenArray // token array should be an array of token object that contains name and address
);
console.log(result, 'here');
The response returned an array of objects containing balance data for a wallet
[
{
date: '2022-05-10T12:00:00Z',
block: 17681830,
timestamp: 1652184001,
balance: {
BUSD: 66.20957186155707,
USDT: 2958.6,
USDC: 5.224089082746472,
DAI: 0
}
},
{
date: '2022-05-11T12:00:00Z',
block: 17709840,
timestamp: 1652270402,
balance: {
BUSD: 50.999571861557065,
USDT: 2758.6,
USDC: 5.224089082746472,
DAI: 0
}
},
{
date: '2022-05-12T12:00:00Z',
block: 17738087,
timestamp: 1652356802,
balance: {
BUSD: 40.89957186155707,
USDT: 6058.599999999999,
USDC: 5.224089082746472,
DAI: 0
}
},
{
date: '2022-05-13T12:00:00Z',
block: 17766225,
timestamp: 1652443201,
balance: {
BUSD: 40.89957186155707,
USDT: 4438.599999999999,
USDC: 5.224089082746472,
DAI: 0
}
}
]
}