Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@exodus/assets-base

Package Overview
Dependencies
Maintainers
0
Versions
270
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/assets-base

Base level package for supporting Exodus assets.

  • 12.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8K
decreased by-49.04%
Maintainers
0
Weekly downloads
 
Created
Source

Exodus Assets Base

[![npm][npm-image]][npm-url] [npm-image]: https://img.shields.io/npm/v/@exodus/assets-base.svg?style=flat-square [npm-url]: https://www.npmjs.com/package/@exodus/assets-base

This package aggregates all built-in asset metadata packages for use across all Exodus projects. Please limit the usage of this package to testing or places where it makes sense. It only makes sense when Custom Tokens or other dynamic asset features are not needed.

Scripts

Install

yarn add @exodus/assets-base

Get Token Metadata

Token names for chains that support Custom Tokens are no longer chose, they need to be generated. Asset names for Custom Tokens are generated by the Custom Tokens Registry. Here we provide the ct script for generating the asset names for inclusion into asset metadata libraries as built-in assets.

ct
yarn ct --network:<network> tokenAddress1 tokenAddress2 ....

Where <network> one of solana, ethereum, bsc, matic... It will print out the token metadata that should become part of assets-base tokens definitions file.

batch-token-generator
  • Have a CMC API KEY set as env variable CMC_PRO_API_KEY
  • Define input.yml (see asset-lis-sol-example.yml example) and
yarn batch-token-generator <path-to-input.yml>

The script will output data to be pasted into asset metadata packages. The output may be out-of-date.

Usage

import assets from '@exodus/assets-base'

for (const [key, val] of Object.entries(assets)) {
  console.log(`${key}: ${val.properName}`) // bitcoin: Bitcoin
}

"Base" asset vs "Tokens"

From a technical point of view, a "token" is an asset:

  • such that asset.name !== asset.baseAsset.name: it is a "non-primary" asset of the chain
  • that has a specific assetType property: ETHEREUM_ERC20, BINANCE_TOKEN, SOLANA_TOKEN.

In some cases a token can be a "gas" token(feeAsset): the asset used to pay for fees on the given network (e.g ontologygas, vethor, tfuel).

At UX level:

  • tokens that are not "gas" tokens are displayed using a chain badge (ERC20s, BEP20, tron tokens, solana tokens)
  • tokens that are "gas" tokens (gas for neo chain, ontologygas for ontology chain, vethor for vechain...) don't use a chain badge.

Asset Attributes Documentation

Assets are defined in the asset metadata packages. We have one asset metadata package per chain. Example: @exodus/ethereum-meta for the Ethereum chain. These packages export objects with the following (partial) list of properties:

{
  name: 'aeron_ethereum_deadbeef',
  baseAssetName: 'ethereum',
  feeAssetName: 'ethereum',
  assetType: 'ETHEREUM_ERC20',
  decimals: 8,
  ticker: 'ARN',
  tickerAlias: 'ARNv1',
  tickerAliases: ['ARNv1'],
  units: [ base: 0, [ticker]: 18 ]
  displayName: 'Aeron',
  displayTicker: 'ARN',
  displayNetworkName: 'Ethereum',
  displayNetworkTicker: 'ETH',
  addresses: { current: '0xBA5F11b16B155792Cf3B2E6880E8706859A8AEB6' },
}

These attributes are defined as follows:

AttributeDefinitionDesktop UsageMobile UsagePricing Server/Exchange Usage
nameThe unique identifier of the asset which is used by code in all wallets to reference specific assets.:point_left::point_left:name is notably, not used when making requests to the pricing and exchange servers; in those cases, ticker is used. See the ticker section below for details.
displayNameThe name of the asset, as displayed to the user in our wallets.:point_left::point_left:n/a
decimalsMany assets support fractional values. They accomplish this by using a scaling factor denoted by the value of decimals. This value indicates how many zeroes there are to the right of the decimal point the fixed-point representation of a token.:point_left::point_left:n/a
baseAssetName (optional)The base asset name. This field only applies to tokens. The base asset of tokens is the primary asset of a blockchain. If this field is not defined it MUST fall back to name. This makes primary assets on chains without tokens their own base asset. E.g. the baseAssetName of ERC20 tokens on the Ethereum network is ethereum. E.g. the baseAssetName of bitcoin is bitcoin.This field is mapped into an asset object to be accessed as asset.baseAssetThis field is mapped into an asset object to be accessed as asset.baseAssetn/a
feeAssetName (optional)The fee asset name. This is intended to be set by assets where the fee asset is not the primary network asset. If not defined, this MUST fall back to baseAssetName. E.g. the feeAssetName on the Vechain network is vethor. isThis field is mapped into an asset object to be accessed as asset.feeAssetThis field is mapped into an asset object to be accessed as asset.feeAssetn/a
assetTypeA type parameter so assets can be grouped. Used for grouping tokens of the same base asset. E.g. all Ethereum ERC20 tokens have a type value ETHEREUM_ERC20:point_left::point_left:n/a
tickerA secondary unique identifier for assets. It is used for anything that requires the asset's symbol (eg: Bitcoin -> BTC).On desktop it is not required to be unique in the code, however we should treat it as unique because of mobile and exchange usage.In mobile, this attribute is used as a unique identifier to reference an asset.In both cases, this attribute is used as an idenfiifer to reference a specific asset when interfacing with the exchange and pricing servers. Note that it is possible for two assets to have the same ticker - in these cases, the old attribute is used to differentiate between the two.
displayTicker (optional)The ticker we display to the user. This field MUST fall back to the value of ticker if not defined. It MAY only be used for display purposes.:point_left::point_left:n/a
tickerAlias (optional)This property is specific to Ethereum-like tokens (but may be ported to others). It updates the Unit object to recognize tickerAlias as the same unit as ticker.:point_left::point_left:n/a
tickerAliases (optional)This property is specific to Ethereum-like tokens (but may be ported to others). It behaves the same as tickerAlias except that it is an array of aliases.:point_left::point_left:n/a
unitsAn array used to build the UnitType for this asset/token. The keys are the unit names and the values are the number of decimals. Thus the base value (integer) has zero (0) decimals. The number of keys and their names in the array are arbitrary but the ordering is not. The keys need to be ordered by the decimals number starting with zero and encreasing. By convention the last key should be the same as the ticker. Example for an asset with 8 decimals: [ base: 0, micro: 2, [ticker]: 8 ]:point_left::point_left:n/a
displayNetworkName (optional)The name of the network/blockchain of this asset. If not defined it MUST fall-back to the properName of the asset's baseAsset. It MAY only be used for display purposes.:point_left::point_left:n/a
displayNetworkTicker (optional)The short name of the network/blockchain of this asset. If not defined it MUST fall back to properTicker of the asset's baseAsset. It MAY only be used for display purposes.:point_left::point_left:n/a
addressesThese are the contract addresses. They are used to detect transactions/balances/send. Without them then you wouldn't know how to look up which token this is on the ETH blockchain.:point_left::point_left:n/a

Some notes on the above from @faris:

name is required to be unique. No two assets can have the same name. This is how assets are referenced.

ticker is required to be unique. The requests to the pricing server and the exchange use ticker (updated by @feri).

For the exchange specifically, if two assets have the same ticker, the wrong asset could activate on the exchange screen in the wallet. This would happen with mainnet swaps. For instance, the old EOS would activate instead of the new EOS.

FAQs

Package last updated on 03 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc