TypeScript wrapper on top of the Ston.fi Http API
npm install @ston-fi/api
yarn add @ston-fi/api
pnpm install @ston-fi/api
Zero config required, you can just create an instance
Optional configuration are also possible by providing an object of type StonApiClientOptions
to the constructor
import { StonApiClient } from '@ston-fi/api';
const client = new StonApiClient();
// * assets
// get list of all DEX assets
const assets = await client.getAssets();
// get asset info by it address
const asset = await client.getAsset('EQ...');
// get list of all DEX assets with balances for a given wallet
const walletAssets = await client.getWalletAssets('UQ...');
// get asset info by it address with balance for a given wallet
const walletAsset = await client.getWalletAsset({ assetAddress: 'EQ...', walletAddress: 'UQ...' });
// * operations
// get list of operations during specified period of time for a given wallet
const operations = await client.getWalletOperations({
since: '2024-06-01T12:00:00', // YYYY-MM-DDTHH:MM:SS
until: '2024-08-06T21:00:00',
walletAddress: 'UQ...',
opType: 'SendLiquidity' // optional; see type definition
})
// get list of ALL operations during specified period of time on the platform
const operations = await client.getAllOperations({
since: '2024-08-05T12:00:00', // YYYY-MM-DDTHH:MM:SS
until: '2024-08-06T21:00:00'
})
// * pools
// get list of all DEX pools
const pools = await client.getPools();
// get pool info by it address
const pool = await client.getPool('EQ...');
// get list of all DEX pools with balances for a given wallet
const walletPools = await client.getWalletPools('UQ...');
// get pool info by it address with balance for a given wallet
const walletPool = await client.getWalletPool({ poolAddress: 'EQ...', walletAddress: 'UQ...' });
// * farms
// get list of all DEX farms
const farms = await client.getFarms();
// get farm info by it address
const farm = await client.getFarm('EQ...');
// get list of all DEX farms with balances for a given wallet
const walletFarms = await client.getWalletFarms('UQ...');
// get farm info by it address with balance for a given wallet
const walletFarm = await client.getWalletFarm({ farmAddress: 'EQ...', walletAddress: 'UQ...' });
// get list of all DEX farms for a given pool
const poolFarms = await client.getFarmsByPool('EQ...');
// * swaps
// get list of tuples with all possible swap pairs on the DEX
const pairs = await client.getSwapPairs();
// simulate direct swap between two assets (sell asset for another)
const swapDirectSimulation = await client.simulateSwap({ /** */ });
// simulate reverse swap between two assets (buy asset for another)
const swapReverseSimulation = await client.simulateReverseSwap({ /** */ });
// get swap status by it id and some additional info (e.g. wallet address, etc.)
const swapStatus = await client.getSwapStatus({ /** */ });