UNPKG

@goat-sdk/plugin-dexscreener

Version:

<div align="center"> <a href="https://github.com/goat-sdk/goat">

2 lines (1 loc) 2.21 kB
import{a as d,b as f,c as h,d as u}from"./chunk-6QNDAOUQ.mjs";import{Tool as y}from"@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}d(l,"_ts_decorate");function n(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)}d(n,"_ts_metadata");var i=class{static{d(this,"DexscreenerService")}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")}};l([y({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 f>"u"?Object:f]),n("design:returntype",Promise)],i.prototype,"getPairsByChainAndPair",null);l([y({name:"dexscreener_search_pairs",description:"Search for DEX pairs matching a query string on Dexscreener"}),n("design:type",Function),n("design:paramtypes",[typeof h>"u"?Object:h]),n("design:returntype",Promise)],i.prototype,"searchPairs",null);l([y({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 u>"u"?Object:u]),n("design:returntype",Promise)],i.prototype,"get_token_pairs_by_token_address",null);export{i as a};