📜 Get DEX ProgramId
Dex ProgramId
A utility function implement to get the DEX (Decentralise Exchange) programID and we will need to import some functions from@saros-finance/dlmm-sdk which are:
getDexProgramId.tsx
TypeScript
import {
LiquidityBookServices,
MODE,
} from "@saros - finance / dlmm - sdk";Configurations
After importing the related function now we need to initialize our Liquidity book service using mainnet or devnet mode.
getDexProgramId.tsx
TypeScript
const liquidityBookServices = new LiquidityBookServices({
mode: MODE.MAINNET,
});Usage
getDexProgramId.tsx
TypeScript
const getDexProgramId = async () => {
try {
const dexId = await liquidityBookService.getDexProgramId();
return dexId;
} catch (error) {
if (error instanceof Error) {
console.error(error.message);
}
}
}