Skip to content

Repository files navigation

Omniston svg

License: MITnpm version

@ston-fi/api — TypeScript client for 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

import{StonApiClient}from"@ston-fi/api";constclient=newStonApiClient();

Optional configuration are also possible by providing an object of type StonApiClientOptions to the constructor

Usage

// * routers// get list of all available routersconstrouters=awaitclient.getRouters();// get router by addressconstrouter=awaitclient.getRouter("EQ...");// * assets// get list of all DEX assetsconstassets=awaitclient.getAssets();// get asset info by it addressconstasset=awaitclient.getAsset("EQ...");// get list of all DEX assets based on query conditionconstassets=awaitclient.queryAssets({condition: [AssetTag.Essential,AssetTag.Popular,AssetTag.WalletHasBalance,].join(" | "),walletAddress: "UQ...",});// search assets across of all DEX assets based on search string and query conditionconstmatchedAssets=awaitclient.queryAssets({searchTerms: ["USD"],condition: [AssetTag.LiquidityVeryHigh,AssetTag.LiquidityHigh].join(" | "),walletAddress: "UQ...",});// get list of all DEX assets with balances for a given walletconstwalletAssets=awaitclient.getWalletAssets("UQ...");// get asset info by it address with balance for a given walletconstwalletAsset=awaitclient.getWalletAsset({assetAddress: "EQ...",walletAddress: "UQ...",});// * pools// get list of all DEX poolsconstpools=awaitclient.getPools();// get list of all DEX pools based on query conditionconstpools=awaitclient.queryPools({condition: `${AssetTag.LiquidityVeryHigh} | ${AssetTag.LiquidityHigh} | ${AssetTag.Popular}`,walletAddress: "UQ...",});// get list of pools with the given asset pairconstpools=awaitclient.getPoolsByAssetPair({asset0Address: "EQ...",asset1Address: "EQ...",});// get pool info by it addressconstpool=awaitclient.getPool("EQ...");// get list of all DEX pools with balances for a given walletconstwalletPools=awaitclient.getWalletPools("UQ...");// get pool info by it address with balance for a given walletconstwalletPool=awaitclient.getWalletPool({poolAddress: "EQ...",walletAddress: "UQ...",});// * farms// get list of all DEX farmsconstfarms=awaitclient.getFarms();// get farm info by it addressconstfarm=awaitclient.getFarm("EQ...");// get list of all DEX farms with balances for a given walletconstwalletFarms=awaitclient.getWalletFarms("UQ...");// get farm info by it address with balance for a given walletconstwalletFarm=awaitclient.getWalletFarm({farmAddress: "EQ...",walletAddress: "UQ...",});// get list of all DEX farms for a given poolconstpoolFarms=awaitclient.getFarmsByPool("EQ...");// * swaps// get list of tuples with all possible swap pairs on the DEXconstpairs=awaitclient.getSwapPairs();// simulate direct swap between two assets (sell asset for another)constswapDirectSimulation=awaitclient.simulateSwap({/** */});// simulate reverse swap between two assets (buy asset for another)constswapReverseSimulation=awaitclient.simulateReverseSwap({/** */});// get swap status by it id and some additional info (e.g. wallet address, etc.)constswapStatus=awaitclient.getSwapStatus({/** */});// * liquidity provision// Simulate new pool creation with a ratio based on provided token amountsconstinitialLiquidityProvision=awaitclient.simulateLiquidityProvision({provisionType: LiquidityProvisionType.Initial,slippageTolerance: "0.001",tokenA: "EQ...",tokenB: "EQ...",tokenAUnits: "1000",tokenBUnits: "1000",});// Simulate adding liquidity to an existing pool at the current pool ratio// Only one amount is required; Corresponding second amount will be calculated during the simulationconstbalancedLiquidityProvision=awaitclient.simulateLiquidityProvision({provisionType: LiquidityProvisionType.Balanced,poolAddress: "EQ...",slippageTolerance: "0.001",tokenA: "EQ...",tokenB: "EQ...",tokenAUnits: "1000",});// Simulate adding liquidity with an arbitrary ratio based on provided token amounts// During provisioning, your funds will be swapped to match the required pool ratioconstarbitraryLiquidityProvision=awaitclient.simulateLiquidityProvision({provisionType: LiquidityProvisionType.Arbitrary,poolAddress: "EQ...",slippageTolerance: "0.001",tokenA: "EQ...",tokenB: "EQ...",tokenAUnits: "1000",tokenBUnits: "2000",});// Simulate single side adding liquidity// Is a special case of arbitrary liquidity provision when the ratio is 100 to 0constarbitrarySinglesideLiquidityProvision=awaitclient.simulateLiquidityProvision({provisionType: LiquidityProvisionType.Arbitrary,tokenA: "EQ...",tokenB: "EQ...",poolAddress: "EQ...",slippageTolerance: "0.001",tokenAUnits: "1000",tokenBUnits: "0",// require explicit zero value});// * stake// get list of ALL wallet stake NFT's & stakes summaryconstwalletStakes=awaitclient.getWalletStakes({walletAddress: "UQAQnxLqlX2B6w4jQzzzPWA8eyWZVZBz6Y0D_8noARLOaEAn",});// get global stats about the Ston.fi stakingconststakingStats=awaitclient.getStakingStats();// * operations// get list of ALL operations during specified period of time on the platformconstoperations=awaitclient.getOperations({since: newDate("2024-08-05T12:00:00"),until: newDate("2024-08-06T21:00:00"),});// get list of operations during specified period of time for a given walletconstoperations=awaitclient.getWalletOperations({since: newDate("2024-06-01T12:00:00"),until: newDate("2024-08-06T21:00:00"),walletAddress: "UQ...",opType: OperationType.Swap,// optional; Only operations with the specified types. All operations if the opType is not specified});

About

JS client for Ston.fi Http API

Resources

Stars

86 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages