Skip to content

1sec: price ICP-native assets instead of dropping them#501

Open
tarun-khatri wants to merge 1 commit into
DefiLlama:masterfrom
tarun-khatri:fix-1sec-icp-token-decimals
Open

1sec: price ICP-native assets instead of dropping them#501
tarun-khatri wants to merge 1 commit into
DefiLlama:masterfrom
tarun-khatri:fix-1sec-icp-token-decimals

Conversation

@tarun-khatri

Copy link
Copy Markdown
Contributor

1sec's four ICP-native assets (ICP, BOB, CHAT, GLDT) are contributing $0 to bridge volume on ethereum, arbitrum and base.

Why

aggregate.ts skips a token outright when it has neither a decimals override nor a decimals value from the price API:

const transformedDecimals = transformTokenDecimals[priceChain]?.[tokenL] ?? null;
tokenKey = transformTokens[priceChain]?.[tokenL] ?? `${priceChain}:${tokenL}`;
...
if (transformedDecimals === null && decimals === undefined) {
  console.log(`Skipping token ${tokenKey} - no decimals available`);
}

These four are mapped to coingecko: ids, and a coingecko key returns a price but no decimals field:

coingecko:internet-computer                        price=$2.1536   decimals=undefined
coingecko:bob-3                                    price=$0.0735   decimals=undefined
coingecko:openchat                                 price=$0.0486   decimals=undefined
coingecko:gold-dao                                 price=$0.0035   decimals=undefined
ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 price=$0.9998  decimals=6

None of the four had an entry in transformTokenDecimals, and there was no base block there at all — so every transfer of them was dropped.

Separately, the openchat key was malformed

1sec adapter (src/adapters/1sec/index.ts):  0xDb95092C454235E7e666c4E226dBBbCdeb499d25   (42 chars)
tokenMappings key:                          0xdb95092c454235e7e666c4e226dbbbbcdeb499d25  (43 chars)

One extra b. It could never match the real address, so CHAT fell through to <chain>:0xdb95..., which returns no price on ethereum, arbitrum or base — also $0.

Decimals verified on-chain

decimals() called directly on each contract:

token ethereum arbitrum base symbol
ICP 8 8 8 ICP
BOB 8 8 8 BOB
CHAT 8 8 8 CHAT
GLDT 8 8 8 GLDT

Effect

Resolving transformTokens / transformTokenDecimals for all 12 token-chain combinations:

before:  12 / 12  ->  $0   (9 skipped for missing decimals, 3 unmatched by the typo)
after:   12 / 12  ->  counted, /1e8

Currently outstanding supply of these assets, all presently valued at $0 by the aggregator:

token chain supply USD
ICP ethereum 487,602.58 $1,049,888
ICP base 247,263.78 $532,400
BOB base 64,263.15 $4,725
others ~$130
total $1,587,146

tsc --noEmit exits 0.

The four ICP-native assets are mapped to coingecko ids, and the coins API
returns no decimals for a coingecko key. aggregate.ts skips a token when
neither a decimals override nor an API decimals value is available, so all
four were contributing $0 on ethereum, arbitrum and base.

All four report decimals() = 8 on-chain on every one of those chains.

The openchat key also carried an extra character (41 hex digits instead of
40), so it never matched the real token and fell through to a chain:address
key that has no price.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant