UNPKG

@frakt-protocol/frakt-sdk

Version:

Frakt SDK for interacting with frakt.xyz protocols

30 lines (29 loc) 1.66 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchPoolDataByMint = void 0; const raydium_sdk_1 = require("@raydium-io/raydium-sdk"); const constants_1 = require("../constants"); const fetchPoolDataByMint = ({ connection, tokensMap }) => __awaiter(void 0, void 0, void 0, function* () { const allRaydiumConfigs = yield raydium_sdk_1.Liquidity.fetchAllPoolKeys(connection); return allRaydiumConfigs.reduce((acc, raydiumPoolConfig) => { const { id, baseMint, quoteMint } = raydiumPoolConfig; const tokenInfo = tokensMap.get(baseMint.toBase58()); if (tokenInfo && quoteMint.toBase58() === raydium_sdk_1.WSOL.mint && !constants_1.BLOCKED_POOLS_IDS.includes(id.toBase58())) { acc.set(baseMint.toBase58(), { tokenInfo, poolConfig: raydiumPoolConfig, }); } return acc; }, new Map()); }); exports.fetchPoolDataByMint = fetchPoolDataByMint;