Skip to content

Commit

Permalink
Merge pull request #11 from stabilitydao/dev
Browse files Browse the repository at this point in the history
0.8.0: assets
  • Loading branch information
a17 authored Jun 27, 2024
2 parents 382ee8d + 08cd0f7 commit 22b7322
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 9 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ Third-party addresses.
import {almFactories} from '@stabilitydao/stability'
```

### Assets

Asset addresses, description, website, color.

#### Methods

* `getAsset(chainId: string, tokenAddress: 0x${string}): Asset|undefined`

## Develop

```shell
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stabilitydao/stability",
"version": "0.7.2",
"version": "0.8.0",
"description": "Stability Integration Library",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand Down
114 changes: 114 additions & 0 deletions src/assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
export type Asset = {
addresses: {[chainId:string]: `0x${string}`|`0x${string}`[]},
symbol: string,
description: string,
website: string,
color: string,
}

export const assets: Asset[] = [
{
addresses: {
"137": ["0x2791bca1f2de4661ed88a30c99a7a9449aa84174", "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",],
"8453": ["0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",],
},
symbol: 'USDC',
description:
"USDC is a fully-reserved stablecoin, which is a type of cryptocurrency, or digital asset.",
website: "https://www.circle.com/en/usdc",
color: "#3b87df",
},
{
addresses: {
"137": "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
"8453": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
},
symbol: "USDT",
description:
"Tether (USDT) is a cryptocurrency with a value meant to mirror the value of the U.S. dollar.",
website: "https://tether.to/en/",
color: "#5bc7af",
},
{
addresses: {
"137": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
"8453": "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
},
symbol: "DAI",
description:
"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.",
website: "https://makerdao.com/",
color: "#f3ba42",
},
{
addresses: {
"137": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
},
symbol: "WMATIC",
description:
"WMATIC is a wrapped version of MATIC that enables it to be easily used within DeFi.",
website: "https://polygon.technology/",
color: "#9663ee",
},
{
addresses: {
"137": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
"8453": "0x4200000000000000000000000000000000000006",
},
symbol: "WETH",
description:
"WETH is an ERC-20 token that represents 1 Ether (ETH)",
website: "https://weth.io/",
color: "#6372a2",
},
{
addresses: {
"137": "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6",
},
symbol: "WBTC",
description:
"WBTC is an ERC-20 token on the EVM blockchains that is pegged to Bitcoin (BTC). WBTC is backed one-to-one with Bitcoin.",
website: "https://wbtc.network/",
color: "#f0a051",
},
{
addresses: {
"137": "0xc4ce1d6f5d98d65ee25cf85e9f2e9dcfee6cb5d6",
"8453": "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93",
},
symbol: "crvUSD",
description:
"crvUSD is a collateralized-debt-position (CDP) stablecoin pegged to the US Dollar",
website: "https://crvusd.curve.fi/",
color: "#397949",
},
{
addresses: {
"8453": "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22",
},
symbol: "cbETH",
description: "Coinbase Wrapped Staked ETH (“cbETH”) is a utility token that represents ETH staked through Coinbase.",
website: "https://www.coinbase.com/cbeth",
color: "#2151f5",
},
]

export const getAsset = (chainId: string, tokenAddress: `0x${string}`): Asset|undefined => {
for (const asset of assets) {
const chainAddresses = asset.addresses[chainId]
if (chainAddresses) {
if (Array.isArray(chainAddresses)) {
for (const address of chainAddresses) {
if (address.toLowerCase() == tokenAddress.toLowerCase()) {
return asset
}
}
} else {
if (chainAddresses.toLowerCase() == tokenAddress.toLowerCase()) {
return asset
}
}
}
}
return undefined
}
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {subgraphs} from "./subgraphs";
import type {ApiMainReply, ApiAggSwapData} from "./api.types"
import tokenlist from "./stability.tokenlist.json"
import {almFactories} from "./addresses";
import {assets, Asset, getAsset} from "./assets";

export {
deployments,
Expand All @@ -45,4 +46,7 @@ export {
getStrategyShortId,
getIntegrationStatus,
getSupportedNetworkIds,
assets,
Asset,
getAsset,
}
31 changes: 27 additions & 4 deletions src/stability.tokenlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "Stability Token List",
"logoURI": "https://stability.farm/logo.svg",
"keywords": [],
"timestamp": "2024-06-10T00:00:00+00:00",
"timestamp": "2024-06-28T00:00:00+00:00",
"version": {
"major": 1,
"minor": 2,
"minor": 3,
"patch": 0
},
"tags": {
Expand All @@ -20,6 +20,10 @@
"lst": {
"name": "Liquid Staking",
"description": "Liquid staking token"
},
"wNative": {
"name": "Wrapped native coin",
"description": "WETH9 or similar contract for wrapping native coin to ERC20 token"
}
},
"tokens": [
Expand Down Expand Up @@ -65,7 +69,8 @@
"symbol": "WMATIC",
"name": "Wrapped Matic",
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/polygon.jpg"
"logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/polygon.jpg",
"tags": ["wNative"]
},
{
"chainId": 137,
Expand Down Expand Up @@ -117,7 +122,7 @@
"name": "Wrapped Ether",
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/eth.jpg",
"tags": ["bridged"]
"tags": ["wNative"]
},
{
"chainId": 8453,
Expand Down Expand Up @@ -163,6 +168,24 @@
"decimals": 6,
"logoURI": "https://basescan.org/token/images/usdbc_ofc_32.png",
"tags": ["stablecoin", "bridged"]
},
{
"chainId": 8453,
"address": "0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93",
"symbol": "crvUSD",
"name": "Curve.Fi USD",
"decimals": 18,
"logoURI": "https://polygonscan.com/token/images/crvusd_32.png",
"tags": ["stablecoin", "bridged"]
},
{
"chainId": 8453,
"address": "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
"symbol": "DAI",
"name": "Dai Stablecoin",
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/dai.jpg",
"tags": ["stablecoin", "bridged"]
}
]
}
9 changes: 9 additions & 0 deletions tests/assets.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {getAsset} from "../src";

describe('testing assets', () => {
test('getAsset', () => {
expect(getAsset("137", "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619")?.symbol).toBe('WETH')
expect(getAsset("555", "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619")?.symbol).toBe(undefined)
expect(getAsset("8453", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913")?.symbol).toBe('USDC')
})
})
5 changes: 4 additions & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
deployments,
integrations,
StrategyShortId,
tokenlist, subgraphs, almFactories,
tokenlist, subgraphs, almFactories, assets,
} from "../src";

describe('index', () => {
Expand All @@ -31,4 +31,7 @@ describe('index', () => {
expect(Object.keys(almFactories).length).toBeGreaterThan(0)
expect(almFactories["137"].ichi.retro).toBe("0xb2f44D8545315cDd0bAaB4AC7233218b932a5dA7")
})
test('assets', () => {
expect(assets.length).toBeGreaterThan(0)
})
})
6 changes: 5 additions & 1 deletion tools/overview-full.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {deployments, integrations, IntegrationStatus, networks, strategies, subgraphs} from "../src";
import {assets, deployments, integrations, IntegrationStatus, networks, strategies, subgraphs} from "../src";
import {Table} from "console-table-printer";
import {version} from '../package.json';
import {hex, bold} from 'ansis';
Expand All @@ -20,6 +20,10 @@ console.log(bold`=== Tokenlist ${tokenlist.version.major}.${tokenlist.version.mi
console.log(`${tokenlist.tokens.map(t => `[${t.chainId}] ${t.symbol}`).join(', ')}`)
console.log('')
// @ts-ignore
console.log(bold`=== Assets: ${assets.length}`)
console.log(`${assets.map(a => `${a.symbol}`).join(', ')}`)
console.log('')
// @ts-ignore
console.log(bold`=== Subgraph endpoints: ${Object.keys(subgraphs).length} ===`)
console.log(`${Object.keys(subgraphs).map(chainId => `[${chainId}] ${subgraphs[chainId]}`).join("\n")}`)
console.log('')
Expand Down
5 changes: 3 additions & 2 deletions tools/overview.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {integrations, networks, strategies, deployments, subgraphs} from "../src";
import {integrations, networks, strategies, deployments, subgraphs, assets} from "../src";
import {version} from '../package.json';
import tokenlist from '../src/stability.tokenlist.json'

console.log(`== Stability Integration Library v${version} ==`)
console.log(`## Stability Integration Library v${version}`)
console.log(`Deployments: ${Object.keys(deployments).length}`)
console.log(`Networks: ${Object.keys(networks).length}`)
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.`)
console.log(`Assets: ${assets.length}`)
console.log(`Subgraph endpoints: ${Object.keys(subgraphs).length}`)
console.log(`Strategies: ${Object.keys(strategies).length}`)
let protocolsTotal = 0
Expand Down

0 comments on commit 22b7322

Please sign in to comment.