Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update files and apis for tokens with treasuryNft #9

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ As of latest update, we consider `circulating = maxSupply - treasury - burn` and

In cases where `circulatingOnChain` is provided directly according to the asset's quantity on-chain or through external APIs, the `circulating` is the value of `circulatingOnChain`.

For tokens providing with `treasuryNft`, the `circulating` is the quantity of the address containing the assets. In default, the amount is retrieved from the oldest address from the blockchain's point of view.
For tokens providing with `treasuryOnChain`, the `circulating` is the quantity of the address containing the assets. In default, the amount is retrieved from the oldest address from the blockchain's point of view.

## How to add my token

### Requirements

As token verification prerequisites, ensure your token has:

- A pool with at least **1000 ADA TVL**,
- A post of your policy ID on Twitter or your policy ID displayed on your landing page,
- A logo added in the [Cardano Token Registry](https://github.com/cardano-foundation/cardano-token-registry) or CIP-68 metadata.

For tokens to be verified:

1. Create a transaction transfer **100 ADA** to Minswap wallet receiving token verification fee below. This fee appears as the cost for lifetime maintain this repository.
2. Metadata includes: **the last 4 numbers of asset's policyId and asset's ticker** (for example, Verify 70c6 MIN).
3. Attach the transaction hash to a comment in the yaml file pull request (instructions below).


Minswap wallet receiving token verification fee: `addr1q85g6fkwzr2cf984qdmntqthl3yxnw4pst4mpgeyygdlnehqlcgwvr6c9vmajz96vnmmset3earqt5wl0keg0kw60eysdgwnej`

Any token that has been verified does **not** meet the requirements in the future would still be unverified.
Expand Down Expand Up @@ -50,7 +53,7 @@ socialLinks:
verified: true # default true, if a token violate verification policy then switch to false

# the following fields are not required
# for `big number`, it's a big number with no decimals. For example, if your token has a max supply of 50,000,000 tokens and 6 decimals, the value needs to be 50000000 × 10^6 = 50000000000000
# for `big number`, it's a big number with no decimals. For example, if your token has a max supply of 50,000,000 tokens with 6 decimals, the value needs to be 50000000 × 10^6 = 50000000000000
# for `URIs`, currently only URI which returns a big number (no decimals) are supported
maxSupply: big number
# or
Expand All @@ -77,10 +80,10 @@ circulatingOnChain:
- https://...
- assetId

treasuryNft: assetId
treasuryOnChain: addr...
```

Alternatively, create an issue with above information and our team will update accordingly. The pull request will be processed faster.
Alternatively, create an issue with above information and our team will update accordingly. However, please note that the pull request will be processed faster.
Our team will verify and approve in first-in-first-out order.

## Usage
Expand Down
5 changes: 0 additions & 5 deletions src/adapters/blockFrostAdapter.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,4 @@ export class BlockFrostAdapter implements Adapter {
const assetInfo = await this.blockFrost.assetsById(assetId);
return BigInt(assetInfo?.quantity);
}

async getAmountInFirstAddressHoldingAsset(tokenId: string, nftId: string): Promise<bigint> {
const addresses = await this.blockFrost.assetsAddresses(nftId);
return await this.getAmountInAddress(addresses[0]["address"], tokenId);
}
}
9 changes: 0 additions & 9 deletions src/adapters/types.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,4 @@ export type Adapter = {
* @param assetId The concatenation of token's policy ID and the hex-coded token name.
*/
getOnchainAmountOfAsset(assetId: string): Promise<bigint>;

/**
* Get the amount held in the address holding a specific asset by the asset's ID.
* After obtaining a list of addresses possessing a specific asset in blockchain's point of view ascending order, this retrieve the amount associated with the first address returned.
* This function currently supports Shen and DJED.
* @param tokenId The token's policy ID.
* @param nftId The concatenation of token's policy ID and hex-coded token name.
*/
getAmountInFirstAddressHoldingAsset(tokenId: string, nftId: string): Promise<bigint>;
};
8 changes: 4 additions & 4 deletions src/apis/marketcapApi.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ export class MarketCapAPI {
return nullResponse;
}

if (!tokenInfo.circulatingOnChain && !tokenInfo.burn && !tokenInfo.treasury && !tokenInfo.treasuryNft) {
if (!tokenInfo.circulatingOnChain && !tokenInfo.burn && !tokenInfo.treasury && !tokenInfo.treasuryOnChain) {
return {
total: formatNumber(total, decimals),
};
}

if (tokenInfo.treasuryNft) {
const treasuryRaw = tokenInfo.treasuryNft;
if (tokenInfo.treasuryOnChain) {
const treasuryRaw = tokenInfo.treasuryOnChain;

const treasury = await this.adapter.getAmountInFirstAddressHoldingAsset(tokenId, treasuryRaw);
const treasury = await this.adapter.getAmountInAddress(treasuryRaw, tokenId);
return {
total: formatNumber(total - treasury, decimals),
circulating: formatNumber(total - treasury, decimals),
Expand Down
2 changes: 1 addition & 1 deletion src/apis/tokenApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class TokenAPI {
public async getToken(tokenId: string) {
try {
const __dirname = import.meta.dirname;
const filePath = path.join(__dirname, `${TOKENS_DIR}/${tokenId}.yaml`);
const filePath = path.join(__dirname, `../${TOKENS_DIR}/${tokenId}.yaml`);
const tokenFileData = fs.readFileSync(filePath, "utf-8");
const tokenData: TokenMetadata = {
tokenId,
Expand Down
2 changes: 1 addition & 1 deletion src/tokenSchema.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const tokenSchema: JSONSchemaType<TokenMetadata> = {
},
nullable: true,
},
treasuryNft: {
treasuryOnChain: {
type: "string",
nullable: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ socialLinks:

verified: true

maxSupply: '1000000000000000000'
maxSupply: "1000000000000000000"

decimals: 6

treasuryNft: 8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a6564537461626c65436f696e4e4654

treasuryOnChain: addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ socialLinks:

verified: true

maxSupply: '1000000000000000000'
maxSupply: "1000000000000000000"

decimals: 6

treasuryNft: 8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a6564537461626c65436f696e4e4654

treasuryOnChain: addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l