This is an npm module that provides helper functions for working with the Stellar blockchain.
To use this module, you need to have Node.js installed. Then, you can install the module using npm:
npm install stellar-blockchain-helper
First, require the module in your code:
const { loadAccountPools, loadPoolDetails } = require('stellar-blockchain-helper');
This function loads the liquidity pool balances for a given Stellar wallet address.
Parameters
- account (
type: String
): Stellar wallet address.
Returns
Promise
: A promise that resolves to anarray
of liquidity pool balances.
This function loads the details of a liquidity pool.
Parameters
- balance (
type: JSON Object
): Account balance object.
Returns
Promise
: A promise that resolves to aJSON object
containing the pool details.
Fetch account pool balances
const account = 'GA5GP75JXAMWQZWQI56X46EGYSCTQEG7AC2FB6UGMLCZNBQV3LNE4EKX';
loadAccountPools(account)
.then(pools => {
if (pools) {
console.log('Liquidity Pools:', pools);
} else {
console.log('No liquidity pools found.');
}
})
.catch(error => {
console.error('Error:', error);
});
Fetch & convert account shares into tokens based off the liquidity pool
const poolObject = {
liquidity_pool_id: '1234567890',
balance: 1000
};
loadPoolDetails(poolObject)
.then(pool => {
if (pool) {
console.log('Pool Details:', pool);
} else {
console.log('Failed to load pool details.');
}
})
.catch(error => {
console.error('Error:', error);
});
- Stellar SDK (to communicate with the stellar network)
- dotenv (load local .env files)
- jest (for running unit testing)
This module is licensed under the MIT License. See the LICENSE file for details.