Skip to content
/ api Public
forked from ston-fi/api

JS client for Ston.fi Http API

License

Notifications You must be signed in to change notification settings

serbiant/api

 
 

Repository files navigation

STON.fi API

License npm version

TypeScript wrapper on top of the Ston.fi Http API

Installation

NPM

npm install @ston-fi/api

Yarn

yarn add @ston-fi/api

PNPM

pnpm install @ston-fi/api

Configuration

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();

Usage

// * 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({ /** */ });

Roadmap

  • add missed methods. You can find the list of currently available methods here.
  • and js-dock for each method
  • add more options in configuration
    • ? interceptors via ofetch
    • ? retry via ofetch
    • ? request abort controller
    • ? controlled case "camel" | "snake"

About

JS client for Ston.fi Http API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 87.2%
  • Shell 12.8%