UNPKG

coingecko-tokens

Version:

Aggregated list of Token Lists from CoinGecko

1 lines 10 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.geckoTokens=t():e.geckoTokens=t()}(self,()=>(()=>{var e={277:()=>{},358:()=>{},363:()=>{},680:(e,t,i)=>{"use strict";i.d(t,{S:()=>d,w:()=>a});var n=i(363),o=i.n(n),s=i(764),r=i.n(s);const a=globalThis?.Ajv||(()=>{const e=o();return e.addFormats=r(),e})(),d=new a({allErrors:!0,allowUnionTypes:!0});a.addFormats(d)},745:(e,t,i)=>{"use strict";i.d(t,{uo:()=>a,iM:()=>c,Tr:()=>m,of:()=>d,KM:()=>p});var n,o=i(277),s={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://uniswap.org/tokenlist.schema.json",title:"Uniswap Token List",description:"Schema for lists of tokens compatible with the Uniswap Interface",definitions:{Version:{type:"object",description:"The version of the list, used in change detection",examples:[{major:1,minor:0,patch:0}],additionalProperties:!1,properties:{major:{type:"integer",description:"The major version of the list. Must be incremented when tokens are removed from the list or token addresses are changed.",minimum:0,examples:[1,2]},minor:{type:"integer",description:"The minor version of the list. Must be incremented when tokens are added to the list.",minimum:0,examples:[0,1]},patch:{type:"integer",description:"The patch version of the list. Must be incremented for any changes to the list.",minimum:0,examples:[0,1]}},required:["major","minor","patch"]},TagIdentifier:{type:"string",description:"The unique identifier of a tag",minLength:1,maxLength:10,pattern:"^[\\w]+$",examples:["compound","stablecoin"]},ExtensionIdentifier:{type:"string",description:"The name of a token extension property",minLength:1,maxLength:40,pattern:"^[\\w]+$",examples:["color","is_fee_on_transfer","aliases"]},ExtensionMap:{type:"object",description:"An object containing any arbitrary or vendor-specific token metadata",maxProperties:10,propertyNames:{$ref:"#/definitions/ExtensionIdentifier"},additionalProperties:{$ref:"#/definitions/ExtensionValue"},examples:[{color:"#000000",is_verified_by_me:!0},{"x-bridged-addresses-by-chain":{1:{bridgeAddress:"0x4200000000000000000000000000000000000010",tokenAddress:"0x4200000000000000000000000000000000000010"}}}]},ExtensionPrimitiveValue:{anyOf:[{type:"string",minLength:1,maxLength:42,examples:["#00000"]},{type:"boolean",examples:[!0]},{type:"number",examples:[15]},{type:"null"}]},ExtensionValue:{anyOf:[{$ref:"#/definitions/ExtensionPrimitiveValue"},{type:"object",maxProperties:10,propertyNames:{$ref:"#/definitions/ExtensionIdentifier"},additionalProperties:{$ref:"#/definitions/ExtensionValueInner0"}}]},ExtensionValueInner0:{anyOf:[{$ref:"#/definitions/ExtensionPrimitiveValue"},{type:"object",maxProperties:10,propertyNames:{$ref:"#/definitions/ExtensionIdentifier"},additionalProperties:{$ref:"#/definitions/ExtensionValueInner1"}}]},ExtensionValueInner1:{anyOf:[{$ref:"#/definitions/ExtensionPrimitiveValue"}]},TagDefinition:{type:"object",description:"Definition of a tag that can be associated with a token via its identifier",additionalProperties:!1,properties:{name:{type:"string",description:"The name of the tag",pattern:"^[ \\w]+$",minLength:1,maxLength:20},description:{type:"string",description:"A user-friendly description of the tag",pattern:"^[ \\w\\.,:]+$",minLength:1,maxLength:200}},required:["name","description"],examples:[{name:"Stablecoin",description:"A token with value pegged to another asset"}]},TokenInfo:{type:"object",description:"Metadata for a single token in a token list",additionalProperties:!1,properties:{chainId:{type:"integer",description:"The chain ID of the Ethereum network where this token is deployed",minimum:1,examples:[1,42]},address:{type:"string",description:"The checksummed address of the token on the specified chain ID",pattern:"^0x[a-fA-F0-9]{40}$",examples:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]},decimals:{type:"integer",description:"The number of decimals for the token balance",minimum:0,maximum:255,examples:[18]},name:{type:"string",description:"The name of the token",minLength:0,maxLength:60,anyOf:[{const:""},{pattern:"^[ \\S+]+$"}],examples:["USD Coin"]},symbol:{type:"string",description:"The symbol for the token",minLength:0,maxLength:20,anyOf:[{const:""},{pattern:"^\\S+$"}],examples:["USDC"]},logoURI:{type:"string",description:"A URI to the token logo asset; if not set, interface will attempt to find a logo based on the token address; suggest SVG or PNG of size 64x64",format:"uri",examples:["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]},tags:{type:"array",description:"An array of tag identifiers associated with the token; tags are defined at the list level",items:{$ref:"#/definitions/TagIdentifier"},maxItems:10,examples:["stablecoin","compound"]},extensions:{$ref:"#/definitions/ExtensionMap"}},required:["chainId","address","decimals","name","symbol"]}},type:"object",properties:{name:{type:"string",description:"The name of the token list",minLength:1,maxLength:30,pattern:"^[\\w ]+$",examples:["My Token List"]},timestamp:{type:"string",format:"date-time",description:"The timestamp of this list version; i.e. when this immutable version of the list was created"},version:{$ref:"#/definitions/Version"},tokens:{type:"array",description:"The list of tokens included in the list",items:{$ref:"#/definitions/TokenInfo"},minItems:1,maxItems:1e4},tokenMap:{type:"object",description:"A mapping of key 'chainId_tokenAddress' to its corresponding token object",minProperties:1,maxProperties:1e4,propertyNames:{type:"string"},additionalProperties:{$ref:"#/definitions/TokenInfo"},examples:[{"4_0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984":{name:"Uniswap",address:"0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",symbol:"UNI",decimals:18,chainId:4,logoURI:"ipfs://QmXttGpZrECX5qCyXbBQiqgQNytVGeZW5Anewvh2jc4psg"}}]},keywords:{type:"array",description:"Keywords associated with the contents of the list; may be used in list discoverability",items:{type:"string",description:"A keyword to describe the contents of the list",minLength:1,maxLength:20,pattern:"^[\\w ]+$",examples:["compound","lending","personal tokens"]},maxItems:20,uniqueItems:!0},tags:{type:"object",description:"A mapping of tag identifiers to their name and description",propertyNames:{$ref:"#/definitions/TagIdentifier"},additionalProperties:{$ref:"#/definitions/TagDefinition"},maxProperties:20,examples:[{stablecoin:{name:"Stablecoin",description:"A token with value pegged to another asset"}}]},logoURI:{type:"string",description:"A URI for the logo of the token list; prefer SVG or PNG of size 256x256",format:"uri",examples:["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]}},required:["name","timestamp","version","tokens"]};!function(e){e[e.NONE=0]="NONE",e[e.PATCH=1]="PATCH",e[e.MINOR=2]="MINOR",e[e.MAJOR=3]="MAJOR"}(n||(n={}));var r=i(680);const a=globalThis?.ethers||o.ethers,d=r.S.compile(s),p=(()=>{const e=JSON.parse(JSON.stringify(s));return delete e.type,delete e.properties,delete e.required,e.$id="Uniswap Token Schema",e.$ref="#/definitions/TokenInfo",r.S.compile(e)})();async function m(e,t){const i=JSON.parse(JSON.stringify(t));if(i.tokens.length>1&&(i.tokens.length=1),!d(i))throw new Error(`${e} validation failed: ${JSON.stringify(d.errors,null,2)}`);if(i.tokens=t.tokens.filter(e=>p(e)).map(e=>(e.address=a.getAddress(e.address),e)),!d(i))throw new Error(`${e} validation failed: ${JSON.stringify(d.errors,null,2)}`);return i}async function c(e,t){const i=await fetch(e,{...t||{},method:"GET",signal:t?.signal||AbortSignal.timeout(6e4)});if(!i.ok)throw new Error(i.statusText);const n=await i.json();if(t?.rebuildList)return m(e,n);if(!d(n))throw new Error(`${e} validation failed: ${JSON.stringify(d.errors,null,2)}`);return n}},764:()=>{},844:(e,t,i)=>{"use strict";i.d(t,{$t:()=>o,M9:()=>d,_v:()=>r,a5:()=>s,tS:()=>a});var n=i(745);const o="https://tokens-uniswap-org.ipns.dweb.link",s="https://tokens.coingecko.com",r=["uniswap","binance-smart-chain","arbitrum-one","optimistic-ethereum","polygon-pos","avalanche","xdai","base","unichain","ethereum-classic"];function a(e){return Promise.all(r.map(t=>(0,n.iM)(`${s}/${t}/all.json`,e)))}function d(e){return(0,n.iM)(o,e)}},850:(e,t,i)=>{"use strict";i.d(t,{_:()=>n,q:()=>o});const n="https://api.coingecko.com/api/v3/coins/markets";async function o(){const e=[];for(let t=1;t<5;++t)e.push(new URLSearchParams({vs_currency:"usd",order:"market_cap_desc",per_page:String(250),page:String(t)}).toString());const t=(await Promise.all(e.map(async e=>{const t=await fetch(`${n}?${e}`,{method:"GET",signal:AbortSignal.timeout(6e4)});if(!t.ok)throw new Error(t.statusText);return t.json()}))).flat();return{topTokens:t,topTokenSet:new Set(t.map(e=>e.symbol?.toLowerCase()||"").flat())}}}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,i),s.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";i.r(n),i.d(n,{Ajv:()=>e.w,COINGECKO_API:()=>s._,COINGECKO_CHAINS:()=>t._v,COINGECKO_TOKEN_API:()=>t.a5,UNISWAP_TOKEN_LIST:()=>t.$t,ajv:()=>e.S,ethers:()=>o.uo,getCoingekoLists:()=>t.tS,getTokenList:()=>o.iM,getTopTokens:()=>s.q,getUniswapList:()=>t.M9,rebuildTokenList:()=>o.Tr,tokenListValidator:()=>o.of,tokenValidator:()=>o.KM});var e=i(680),t=i(844),o=i(745),s=i(850),r=i(358),a={};for(const e in r)["default","Ajv","ajv","COINGECKO_CHAINS","COINGECKO_TOKEN_API","UNISWAP_TOKEN_LIST","getCoingekoLists","getUniswapList","ethers","getTokenList","rebuildTokenList","tokenListValidator","tokenValidator","COINGECKO_API","getTopTokens"].indexOf(e)<0&&(a[e]=()=>r[e]);i.d(n,a)})(),n})());