Skip to content

Commit 22b7322

Browse files
authored
Merge pull request #11 from stabilitydao/dev
0.8.0: assets
2 parents 382ee8d + 08cd0f7 commit 22b7322

9 files changed

+175
-9
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ Third-party addresses.
7474
import {almFactories} from '@stabilitydao/stability'
7575
```
7676

77+
### Assets
78+
79+
Asset addresses, description, website, color.
80+
81+
#### Methods
82+
83+
* `getAsset(chainId: string, tokenAddress: 0x${string}): Asset|undefined`
84+
7785
## Develop
7886

7987
```shell

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stabilitydao/stability",
3-
"version": "0.7.2",
3+
"version": "0.8.0",
44
"description": "Stability Integration Library",
55
"main": "out/index.js",
66
"types": "out/index.d.ts",

src/assets.ts

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
export type Asset = {
2+
addresses: {[chainId:string]: `0x${string}`|`0x${string}`[]},
3+
symbol: string,
4+
description: string,
5+
website: string,
6+
color: string,
7+
}
8+
9+
export const assets: Asset[] = [
10+
{
11+
addresses: {
12+
"137": ["0x2791bca1f2de4661ed88a30c99a7a9449aa84174", "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",],
13+
"8453": ["0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",],
14+
},
15+
symbol: 'USDC',
16+
description:
17+
"USDC is a fully-reserved stablecoin, which is a type of cryptocurrency, or digital asset.",
18+
website: "https://www.circle.com/en/usdc",
19+
color: "#3b87df",
20+
},
21+
{
22+
addresses: {
23+
"137": "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
24+
"8453": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
25+
},
26+
symbol: "USDT",
27+
description:
28+
"Tether (USDT) is a cryptocurrency with a value meant to mirror the value of the U.S. dollar.",
29+
website: "https://tether.to/en/",
30+
color: "#5bc7af",
31+
},
32+
{
33+
addresses: {
34+
"137": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
35+
"8453": "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
36+
},
37+
symbol: "DAI",
38+
description:
39+
"DAI is an algorithmic stablecoin issued by MakerDAO, an Ethereum-based protocol, that seeks to maintain an exact ratio of one-to-one with the U.S. dollar.",
40+
website: "https://makerdao.com/",
41+
color: "#f3ba42",
42+
},
43+
{
44+
addresses: {
45+
"137": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
46+
},
47+
symbol: "WMATIC",
48+
description:
49+
"WMATIC is a wrapped version of MATIC that enables it to be easily used within DeFi.",
50+
website: "https://polygon.technology/",
51+
color: "#9663ee",
52+
},
53+
{
54+
addresses: {
55+
"137": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
56+
"8453": "0x4200000000000000000000000000000000000006",
57+
},
58+
symbol: "WETH",
59+
description:
60+
"WETH is an ERC-20 token that represents 1 Ether (ETH)",
61+
website: "https://weth.io/",
62+
color: "#6372a2",
63+
},
64+
{
65+
addresses: {
66+
"137": "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6",
67+
},
68+
symbol: "WBTC",
69+
description:
70+
"WBTC is an ERC-20 token on the EVM blockchains that is pegged to Bitcoin (BTC). WBTC is backed one-to-one with Bitcoin.",
71+
website: "https://wbtc.network/",
72+
color: "#f0a051",
73+
},
74+
{
75+
addresses: {
76+
"137": "0xc4ce1d6f5d98d65ee25cf85e9f2e9dcfee6cb5d6",
77+
"8453": "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93",
78+
},
79+
symbol: "crvUSD",
80+
description:
81+
"crvUSD is a collateralized-debt-position (CDP) stablecoin pegged to the US Dollar",
82+
website: "https://crvusd.curve.fi/",
83+
color: "#397949",
84+
},
85+
{
86+
addresses: {
87+
"8453": "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22",
88+
},
89+
symbol: "cbETH",
90+
description: "Coinbase Wrapped Staked ETH (“cbETH”) is a utility token that represents ETH staked through Coinbase.",
91+
website: "https://www.coinbase.com/cbeth",
92+
color: "#2151f5",
93+
},
94+
]
95+
96+
export const getAsset = (chainId: string, tokenAddress: `0x${string}`): Asset|undefined => {
97+
for (const asset of assets) {
98+
const chainAddresses = asset.addresses[chainId]
99+
if (chainAddresses) {
100+
if (Array.isArray(chainAddresses)) {
101+
for (const address of chainAddresses) {
102+
if (address.toLowerCase() == tokenAddress.toLowerCase()) {
103+
return asset
104+
}
105+
}
106+
} else {
107+
if (chainAddresses.toLowerCase() == tokenAddress.toLowerCase()) {
108+
return asset
109+
}
110+
}
111+
}
112+
}
113+
return undefined
114+
}

src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {subgraphs} from "./subgraphs";
2020
import type {ApiMainReply, ApiAggSwapData} from "./api.types"
2121
import tokenlist from "./stability.tokenlist.json"
2222
import {almFactories} from "./addresses";
23+
import {assets, Asset, getAsset} from "./assets";
2324

2425
export {
2526
deployments,
@@ -45,4 +46,7 @@ export {
4546
getStrategyShortId,
4647
getIntegrationStatus,
4748
getSupportedNetworkIds,
49+
assets,
50+
Asset,
51+
getAsset,
4852
}

src/stability.tokenlist.json

+27-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"name": "Stability Token List",
33
"logoURI": "https://stability.farm/logo.svg",
44
"keywords": [],
5-
"timestamp": "2024-06-10T00:00:00+00:00",
5+
"timestamp": "2024-06-28T00:00:00+00:00",
66
"version": {
77
"major": 1,
8-
"minor": 2,
8+
"minor": 3,
99
"patch": 0
1010
},
1111
"tags": {
@@ -20,6 +20,10 @@
2020
"lst": {
2121
"name": "Liquid Staking",
2222
"description": "Liquid staking token"
23+
},
24+
"wNative": {
25+
"name": "Wrapped native coin",
26+
"description": "WETH9 or similar contract for wrapping native coin to ERC20 token"
2327
}
2428
},
2529
"tokens": [
@@ -65,7 +69,8 @@
6569
"symbol": "WMATIC",
6670
"name": "Wrapped Matic",
6771
"decimals": 18,
68-
"logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/polygon.jpg"
72+
"logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/polygon.jpg",
73+
"tags": ["wNative"]
6974
},
7075
{
7176
"chainId": 137,
@@ -117,7 +122,7 @@
117122
"name": "Wrapped Ether",
118123
"decimals": 18,
119124
"logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/eth.jpg",
120-
"tags": ["bridged"]
125+
"tags": ["wNative"]
121126
},
122127
{
123128
"chainId": 8453,
@@ -163,6 +168,24 @@
163168
"decimals": 6,
164169
"logoURI": "https://basescan.org/token/images/usdbc_ofc_32.png",
165170
"tags": ["stablecoin", "bridged"]
171+
},
172+
{
173+
"chainId": 8453,
174+
"address": "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93",
175+
"symbol": "crvUSD",
176+
"name": "Curve.Fi USD",
177+
"decimals": 18,
178+
"logoURI": "https://polygonscan.com/token/images/crvusd_32.png",
179+
"tags": ["stablecoin", "bridged"]
180+
},
181+
{
182+
"chainId": 8453,
183+
"address": "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
184+
"symbol": "DAI",
185+
"name": "Dai Stablecoin",
186+
"decimals": 18,
187+
"logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/dai.jpg",
188+
"tags": ["stablecoin", "bridged"]
166189
}
167190
]
168191
}

tests/assets.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {getAsset} from "../src";
2+
3+
describe('testing assets', () => {
4+
test('getAsset', () => {
5+
expect(getAsset("137", "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619")?.symbol).toBe('WETH')
6+
expect(getAsset("555", "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619")?.symbol).toBe(undefined)
7+
expect(getAsset("8453", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913")?.symbol).toBe('USDC')
8+
})
9+
})

tests/index.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
deployments,
66
integrations,
77
StrategyShortId,
8-
tokenlist, subgraphs, almFactories,
8+
tokenlist, subgraphs, almFactories, assets,
99
} from "../src";
1010

1111
describe('index', () => {
@@ -31,4 +31,7 @@ describe('index', () => {
3131
expect(Object.keys(almFactories).length).toBeGreaterThan(0)
3232
expect(almFactories["137"].ichi.retro).toBe("0xb2f44D8545315cDd0bAaB4AC7233218b932a5dA7")
3333
})
34+
test('assets', () => {
35+
expect(assets.length).toBeGreaterThan(0)
36+
})
3437
})

tools/overview-full.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {deployments, integrations, IntegrationStatus, networks, strategies, subgraphs} from "../src";
1+
import {assets, deployments, integrations, IntegrationStatus, networks, strategies, subgraphs} from "../src";
22
import {Table} from "console-table-printer";
33
import {version} from '../package.json';
44
import {hex, bold} from 'ansis';
@@ -20,6 +20,10 @@ console.log(bold`=== Tokenlist ${tokenlist.version.major}.${tokenlist.version.mi
2020
console.log(`${tokenlist.tokens.map(t => `[${t.chainId}] ${t.symbol}`).join(', ')}`)
2121
console.log('')
2222
// @ts-ignore
23+
console.log(bold`=== Assets: ${assets.length}`)
24+
console.log(`${assets.map(a => `${a.symbol}`).join(', ')}`)
25+
console.log('')
26+
// @ts-ignore
2327
console.log(bold`=== Subgraph endpoints: ${Object.keys(subgraphs).length} ===`)
2428
console.log(`${Object.keys(subgraphs).map(chainId => `[${chainId}] ${subgraphs[chainId]}`).join("\n")}`)
2529
console.log('')

tools/overview.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import {integrations, networks, strategies, deployments, subgraphs} from "../src";
1+
import {integrations, networks, strategies, deployments, subgraphs, assets} from "../src";
22
import {version} from '../package.json';
33
import tokenlist from '../src/stability.tokenlist.json'
44

5-
console.log(`== Stability Integration Library v${version} ==`)
5+
console.log(`## Stability Integration Library v${version}`)
66
console.log(`Deployments: ${Object.keys(deployments).length}`)
77
console.log(`Networks: ${Object.keys(networks).length}`)
88
console.log(`Tokenlist ${tokenlist.version.major}.${tokenlist.version.minor}.${tokenlist.version.patch}: ${tokenlist.tokens.length} tokens for ${tokenlist.tokens.map(t => t.chainId).filter((value, index, array) => array.indexOf(value) === index).length} networks.`)
9+
console.log(`Assets: ${assets.length}`)
910
console.log(`Subgraph endpoints: ${Object.keys(subgraphs).length}`)
1011
console.log(`Strategies: ${Object.keys(strategies).length}`)
1112
let protocolsTotal = 0

0 commit comments

Comments
 (0)