-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
146 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
# Minswap tokens | ||
The merge of deprecated verified-tokens and market cap repositories, which contains a list of tokens, exposes APIs for transparent access to circulating supply and total supply. | ||
|
||
## Requirements | ||
For tokens to be verified, ensure your token has a pool with at least **1000 ADA TVL** and follow the structures stated in the instructions below. Any token that has been verified does not meet the requirements in the future would still be unverified. | ||
|
||
## How to add my token | ||
Create a pull request adding yaml file according to the following structure in the `src/tokens`: | ||
```yaml | ||
# 1 token = 1 yaml file | ||
# filename: policyId + tokenName (like cardano-token-registry) | ||
# merge verified-tokens and market-cap into 1 new repo, then archive those 2 old repos (to avoid breaking changes with integrators) | ||
# filename/assetId: policyId + hex-coded token name | ||
|
||
projectName: Minswap | ||
project: Minswap | ||
# among DeFi, RealFi, GameFi, Meme, Bridge, Metaverse, Wallet, NFT, Oracle, AI, Launchpad, DAO, Stablecoin, Social, Media, Risk Ratings, Index Vaults, DePIN, Other | ||
categories: | ||
- DeFi | ||
- DAO | ||
- DeFi | ||
- DAO | ||
|
||
decimals: 0 | ||
# not required, among website, twitter, discord, telegram, coinMarketCap, coinGecko | ||
socialLinks: | ||
website: https:// | ||
discord: ... | ||
|
||
unverified: true # default false, if a token violate verification policy then turn on | ||
verified: true # default true, if a token violate verification policy then switch to false | ||
|
||
maxSupply: 500000000 | ||
# the following fields are not required | ||
maxSupply: 500000000 # either number or string | ||
# or | ||
maxSupply: https://... | ||
|
||
treasuryWallets: | ||
- addr... | ||
- addr... | ||
- https://... | ||
|
||
burnWallets: | ||
- addr... | ||
- https://... | ||
|
||
# total = max - burn | ||
# circulating = max - burn - treasury | ||
treasury: | ||
- addr... | ||
- stake... | ||
- https://... | ||
- assetId | ||
|
||
burn: | ||
- addr... | ||
- stake... | ||
- https://... | ||
- assetId | ||
|
||
circulatingOnChain: | ||
- addr... | ||
- stake... | ||
- https://... | ||
- assetId | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { load } from "js-yaml"; | ||
|
||
import { DEFAULT_TOKEN_DIR } from "@/const"; | ||
import type { GetTokenOptions, TokenMetadata } from "@/types"; | ||
import path from "node:path"; | ||
import fs from "node:fs"; | ||
|
||
export class TokenAPI { | ||
/** | ||
* Get token's metadata by its ID. | ||
* @param tokenId The concatenation of token policy ID and hex-coded token name. | ||
* @returns The token metadata followed the token schema. | ||
*/ | ||
public async getToken(tokenId: string) { | ||
try { | ||
const __dirname = import.meta.dirname; | ||
const filePath = path.join( | ||
__dirname, | ||
`${DEFAULT_TOKEN_DIR}/${tokenId}.yaml` | ||
); | ||
const tokenFileData = fs.readFileSync(filePath, "utf-8"); | ||
const tokenData: TokenMetadata = { | ||
tokenId, | ||
...(load(tokenFileData) as Omit<TokenMetadata, "tokenId">), | ||
}; | ||
return tokenData; | ||
} catch (e) { | ||
console.error(e); | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Get all tokens' metadata by its ID. | ||
* @param options Only verified or only tokens with market cap. | ||
* @returns The list of all tokens' metadata. | ||
*/ | ||
public async getTokens(options?: GetTokenOptions) { | ||
const __dirname = import.meta.dirname; | ||
const directory = path.join(__dirname, `${DEFAULT_TOKEN_DIR}`); | ||
const tokenList: TokenMetadata[] = []; | ||
const files = fs.readdirSync(directory); | ||
for (const file of files) { | ||
const tokenString = file.split(".")[0]; | ||
const token = await this.getToken(tokenString); | ||
if (!token) { | ||
continue; | ||
} | ||
const matchedVerify = | ||
!options?.verifiedOnly || (options?.verifiedOnly && token.verified); | ||
const matchedMarketCap = | ||
!options?.hasMarketCapOnly || | ||
(options?.hasMarketCapOnly && !!token.maxSupply); | ||
if (matchedVerify && matchedMarketCap) { | ||
tokenList.push(token); | ||
} | ||
} | ||
return tokenList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.