@goat-sdk/plugin-dexscreener
Version:
<div align="center"> <a href="https://github.com/goat-sdk/goat">
2 lines (1 loc) • 2.63 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); var _class;var _chunkTUDAFAYXjs = require('./chunk-TUDAFAYX.js');var _core = require('@goat-sdk/core');function l(a,e,r,t){var o=arguments.length,s=o<3?e:t===null?t=Object.getOwnPropertyDescriptor(e,r):t,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(a,e,r,t);else for(var p=a.length-1;p>=0;p--)(c=a[p])&&(s=(o<3?c(s):o>3?c(e,r,s):c(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s}_chunkTUDAFAYXjs.a.call(void 0, l,"_ts_decorate");function n(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)}_chunkTUDAFAYXjs.a.call(void 0, n,"_ts_metadata");var i= (_class =class{constructor() { _class.prototype.__init.call(this); }static{_chunkTUDAFAYXjs.a.call(void 0, this,"DexscreenerService")}__init() {this.baseUrl="https://api.dexscreener.com/latest/dex"}async fetchDexscreener(e,r){try{let t=await fetch(e);if(!t.ok)throw new Error(`HTTP status ${t.status}`);return await t.json()}catch(t){throw new Error(`Failed to ${r}: ${t}`)}}async getPairsByChainAndPair(e){let r=`${this.baseUrl}/pairs/${e.chainId}/${e.pairId}`;return this.fetchDexscreener(r,"fetch pairs")}async searchPairs(e){let r=`${this.baseUrl}/search?q=${encodeURIComponent(e.query)}`;return this.fetchDexscreener(r,"search pairs")}async get_token_pairs_by_token_address(e){if(e.tokenAddresses.length>30)throw new Error("Maximum of 30 token addresses allowed per request");let r=e.tokenAddresses.join(","),t=`${this.baseUrl}/tokens/${r}`;return this.fetchDexscreener(t,"get token pairs")}}, _class);l([_core.Tool.call(void 0, {name:"dexscreener_get_pairs_by_chain_and_pair",description:"Fetch pairs by chainId and pairId from Dexscreener"}),n("design:type",Function),n("design:paramtypes",[typeof _chunkTUDAFAYXjs.b>"u"?Object:_chunkTUDAFAYXjs.b]),n("design:returntype",Promise)],i.prototype,"getPairsByChainAndPair",null);l([_core.Tool.call(void 0, {name:"dexscreener_search_pairs",description:"Search for DEX pairs matching a query string on Dexscreener"}),n("design:type",Function),n("design:paramtypes",[typeof _chunkTUDAFAYXjs.c>"u"?Object:_chunkTUDAFAYXjs.c]),n("design:returntype",Promise)],i.prototype,"searchPairs",null);l([_core.Tool.call(void 0, {name:"dexscreener_get_token_pairs_by_token_address",description:"Get all DEX pairs for given token addresses (up to 30) from Dexscreener"}),n("design:type",Function),n("design:paramtypes",[typeof _chunkTUDAFAYXjs.d>"u"?Object:_chunkTUDAFAYXjs.d]),n("design:returntype",Promise)],i.prototype,"get_token_pairs_by_token_address",null);exports.a = i;