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 is intended to be for reusable asset names and basic asset properties across Exodus projects.
It's currently used in desktop, mobile, and pricing server. It will be backported to Exotrack.
Install
yarn add @exodus/assets-base
Usage
import assets from '@exodus/assets-base'
for (const [key, val] of Object.entries(assets)) {
console.log(`${key}: ${val.properName}`)
}
ERC-20 Attributes Documentation
The assets/base/src/erc20-tokens/tokens.js
file is where we define our supported ERC-20 assets (note that these properties also apply to (mostly) all other assets in asset-base.js
). This file consists of a list of objects that more/less follow this object definition:
{
name: 'aeron',
properName: 'Aeron (old)',
decimals: 8,
ticker: 'ARN',
addresses: {
current: '0xBA5F11b16B155792Cf3B2E6880E8706859A8AEB6',
},
old: true,
}
These attributes are defined as follows:
Attribute | Definition | Desktop Usage | Mobile Usage | Pricing Server/Exchange Usage |
---|
name | The unique identifier of the asset which is used by code in both wallets to reference specific assets. Nuances are documented here. | :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. |
properName | The name of the asset, as displayed to the user in our wallets. | :point_left: | :point_left: | n/a |
decimals | Many token contracts support fractional tokens. 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 |
ticker | A secondary unique identifier for assets. It is used for anything that requires the asset's symbol (eg: Bitcoin -> BTC). | This is used by desktop and mapped to a legacy property in that codebase called displayUnit . | 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. |
addresses | These 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 |
old (optional) | This flag exists to handle cases in which an asset has upgraded to it's own mainnet or the underlying contract has been upgraded. In these cases, there would be two assets with similar tickers and this flag would be used to imply the differentiation between the two. Details on how this works can be found here. | :point_left: | :point_left: | :point_left: |
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
doesn't have that requirement. However, the requests to the pricing server and the exchange use ticker
. So when you have two identical tickers
, things get messy.
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.
To solve this, we added a hack which introduced the old
property. The old
property was meant to imply that there is an identifical ticker
for a newer asset. So for the exchange, we skip over the old assets and activate the ones without the old
property.