Skip to content

Commit

Permalink
Merge pull request #1 from maestro-org/feature/migrate-maestro-client
Browse files Browse the repository at this point in the history
feat: basic migration
  • Loading branch information
Vardominator authored Feb 15, 2024
2 parents e9825cb + b5c1b26 commit 26bbf83
Show file tree
Hide file tree
Showing 106 changed files with 753 additions and 668 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ console.log(minInfo);
2. Import the function into `src/index.ts` and add the corresponding entry in `supplyFetchers` map with the key being the concatenation of your token's policyID and assetName
3. Test your function:

```bash
# only if you use Blockfrost
export BLOCKFROST_PROJECT_ID=<your_blockfrost_key>
ONLY_TEST=<your_policy_id_concat_with_asset_name> npm test
```
```bash
# only if you use Blockfrost
export MAESTRO_API_KEY=<your_maestro_key>
ONLY_TEST=<your_policy_id_concat_with_asset_name> npm test
```

4. Run format: `npm run format`

Expand All @@ -48,18 +48,18 @@ ONLY_TEST=<your_policy_id_concat_with_asset_name> npm test
1. MIN token fetcher: [src/tokens/min.ts](src/tokens/min.ts)
2. Add entry to `index.ts`:

```ts
import minFetcher from "./tokens/min";
```ts
import minFetcher from "./tokens/min";

export const supplyFetchers: Record<string, SupplyFetcher> = {
"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e": minFetcher,
...
};
```
export const supplyFetchers: Record<string, SupplyFetcher> = {
"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e": minFetcher,
...
};
```

3. Run test:

```bash
export BLOCKFROST_PROJECT_ID=<your_blockfrost_key>
export MAESTRO_API_KEY=<your_maestro_key>
ONLY_TEST=29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e npm test
```
45 changes: 31 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"homepage": "https://github.com/minswap/market-cap#readme",
"dependencies": {
"@blockfrost/blockfrost-js": "^5.2.0",
"@maestro-org/typescript-sdk": "^1.5.1",
"axios": "^1.3.3"
},
"lint-staged": {
Expand Down Expand Up @@ -67,4 +68,4 @@
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
}
}
}
9 changes: 4 additions & 5 deletions src/tokens/aada.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const AADA = "8fef2d34078659493ce161a6c7fba4b56afefa8535296a5743f6958741414441";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 29_500_000;
const treasuryRaw = await getAmountInAddresses(blockFrost, AADA, [
const treasuryRaw = await fetcher.getAmountInAddresses(AADA, [
"stake1u98ak0va7tgd23rl62tphdare6z602e0vx5m0fw4gdr65kq875eec",
"stake1uyt8x8wwvn5ze8aw6eqs35w2znyh4xnn9xsu3jxjk503nxcmdkjuz",
"stake1u9hqmm7neuayxpm9962kk09x27yu5kmcx6h9f98tc4r2mzsyaeh40",
Expand Down
23 changes: 13 additions & 10 deletions src/tokens/agix.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAxiosInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const axios = getAxiosInstance(options);
const circulating = await axios(
"https://tokensupply.singularitynet.io/tokensupply?tokensymbol=agix&q=circulatingsupply"
).then((res) => res.data.toString());
const total = await axios(
"https://tokensupply.singularitynet.io/tokensupply?tokensymbol=agix&q=totalsupply"
).then((res) => res.data.toString());
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const circulating = await fetcher
.axios(
"https://tokensupply.singularitynet.io/tokensupply?tokensymbol=agix&q=circulatingsupply"
)
.then((res) => res.data.toString());
const total = await fetcher
.axios(
"https://tokensupply.singularitynet.io/tokensupply?tokensymbol=agix&q=totalsupply"
)
.then((res) => res.data.toString());
return {
circulating,
total,
Expand Down
9 changes: 4 additions & 5 deletions src/tokens/angels.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const ANGELS =
"285b65ae63d4fad36321384ec61edfd5187b8194fff89b5abe9876da414e47454c53";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 496_000;
const treasuryRaw = await getAmountInAddresses(blockFrost, ANGELS, [
const treasuryRaw = await fetcher.getAmountInAddresses(ANGELS, [
"stake1uykqzz8gny3g5ar9upqhuvgjy7uw0fcxyp66cj8sgm9uyjq7h2xtc",
"addr1qxpfunlur9rcr7zzvzqeha5mahfjc09zwc03u9uj6z6qdkeef44f0ar7f54mp0dkw0erpjddyq3ar4vhx6ye8acjg4eqr7jmz9",
]);
Expand Down
10 changes: 4 additions & 6 deletions src/tokens/ashib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const ASHIB =
"afc910d7a306d20c12903979d4935ae4307241d03245743548e767834153484942";
Expand All @@ -8,12 +8,10 @@ const TREASURY_ADDRESSES = [
"addr1q8dhkxncaznxd66tq5npvuqxl87zdw0glpazysxckl9gxfecnrdy6frmvrk2szfx2wsg9wa3z3wzctfmgaw7hcts7g6quzkakx", // treasury 2
];

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 109e9; // 109 billion
const treasury =
Number(await getAmountInAddresses(blockFrost, ASHIB, TREASURY_ADDRESSES)) /
1e6;
Number(await fetcher.getAmountInAddresses(ASHIB, TREASURY_ADDRESSES)) / 1e6;
return {
circulating: (total - treasury).toString(),
total: total.toString(),
Expand Down
11 changes: 5 additions & 6 deletions src/tokens/awoo.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const AWOO = "09f5f55fcad17503e6b7acc81de7c80f84b76e76d17085f0e32f1ce241574f4f";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 69_000_000;
const treasuryRaw = await getAmountInAddresses(blockFrost, AWOO, [
const treasuryRaw = await fetcher.getAmountInAddresses(AWOO, [
"stake1uy2s0etue4vgt6gz66t84zzgf8r6fgggc0prf4hsay3rvfcam00kg", // $unbothered
"stake1uxh23dnmd2lzvxqr06vvuxtsgh4l4dxnrrcvj2fx6f53rkc70lmqh", // $uwstaking
]);

const burnRaw = await getAmountInAddresses(blockFrost, AWOO, [
const burnRaw = await fetcher.getAmountInAddresses(AWOO, [
"addr1w8qmxkacjdffxah0l3qg8hq2pmvs58q8lcy42zy9kda2ylc6dy5r4", //$burnawoo
]);

Expand Down
9 changes: 4 additions & 5 deletions src/tokens/bank.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const BANK = "2b28c81dbba6d67e4b5a997c6be1212cba9d60d33f82444ab8b1f21842414e4b";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 2.5e12;
const treasuryRaw = await getAmountInAddresses(blockFrost, BANK, [
const treasuryRaw = await fetcher.getAmountInAddresses(BANK, [
"stake1uxq7mehxxywwzf0cczf7tq4surcphjdd53ngw5ev6qxf7hstnt9qf", // $bankercoinada
]);
const treasury = Number(treasuryRaw);
Expand Down
9 changes: 4 additions & 5 deletions src/tokens/book.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const BOOK = "51a5e236c4de3af2b8020442e2a26f454fda3b04cb621c1294a0ef34424f4f4b";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 10_000_000_000;
const treasuryRaw = await getAmountInAddresses(blockFrost, BOOK, [
const treasuryRaw = await fetcher.getAmountInAddresses(BOOK, [
"addr1v8dyqna76l9uh3sg93hvp8h40c8h0ecsw0yfa5dtq5hgvzc5572e2", // swap send in
"addr1w99gfdcmxwe2ahe9ncjekntn2fhcpusj55874g4m7f4c7kqy3rq23", // swap contract
"addr1w9223trzcvg75wwlaeprls9zwcf8nu8l5y92t9kk2all2jqk6sg93", // lock contract
Expand Down
9 changes: 4 additions & 5 deletions src/tokens/cblp.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const CBLP = "ee0633e757fdd1423220f43688c74678abde1cead7ce265ba8a24fcd43424c50";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 1e9;
const treasuryRaw = await getAmountInAddresses(blockFrost, CBLP, [
const treasuryRaw = await fetcher.getAmountInAddresses(CBLP, [
"stake1u80gm88pyu78rr2ee3p7mn482xza6thtnvg3k3c0y43syrsdzm0lw", // $yam_treasury
"stake1uy02585lgl0j9pfzz2jxqmdckar2jqlpwre899j9304l3ysezxnjj", // $yam_community
"stake1uxxghepgwfmtq9spaxf46ucxvns54pyvcqtrpk4888dtqdqhth0sj", // $yam_misc
Expand Down
9 changes: 4 additions & 5 deletions src/tokens/cbtc.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const CBTC = "4190b2941d9be04acc69c39739bd5acc66d60ccab480d8e20bc87e3763425443";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const total = await blockFrost.assetsById(CBTC).then((res) => res.quantity);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = await fetcher.getSupplyFromAssetMetadata(CBTC);
const totalWithDecimals = Number(total) / 1e8;
return {
circulating: totalWithDecimals.toString(),
Expand Down
10 changes: 4 additions & 6 deletions src/tokens/cgi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const CGI = "2d587111358801114f04df83dc0015de0a740b462b75cce5170fc935434749";
const TREASURY_ADDRESSES = [
Expand All @@ -11,12 +11,10 @@ const TREASURY_ADDRESSES = [
"addr1qxfrkchfzp49gurm2wgkww4jfm83u5jwk9uc2hs5lpx7y4t89dn2kukqy676lyr87myqllk7vm9s6e37ggwns420fmzqfzmt3m", // farming
];

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 5e6; // 5 million
const treasury =
Number(await getAmountInAddresses(blockFrost, CGI, TREASURY_ADDRESSES)) /
1e6;
Number(await fetcher.getAmountInAddresses(CGI, TREASURY_ADDRESSES)) / 1e6;
return {
circulating: (total - treasury).toString(),
total: total.toString(),
Expand Down
9 changes: 4 additions & 5 deletions src/tokens/chry.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const CHRY = "75fcc276057db5fc48eae0e11453c773c8a54604c3086bf9d95ac1b743485259";
const TREASURY_ADDRESSES = [
"stake1uxluurkaazlqyqfqn22acl6lprea52avn6da0q88yk46zfqrc93qj",
"stake1u8ffzkegp8h48mare3g3ntf3xmjce3jqptsdtj38ee3yh3c9t4uum", // team tokens held at SEALS' Vending Machine
];

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 88e6; // 88 million
const treasury = Number(
await getAmountInAddresses(blockFrost, CHRY, TREASURY_ADDRESSES)
await fetcher.getAmountInAddresses(CHRY, TREASURY_ADDRESSES)
);

return {
Expand Down
9 changes: 4 additions & 5 deletions src/tokens/clap.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { defaultFetcherOptions, SupplyFetcher } from "../types";
import { getAmountInAddresses, getBlockFrostInstance } from "../utils";
import { SupplyFetcher } from "../types";
import { defaultFetcher } from "../utils";

const CLAP = "db30c7905f598ed0154de14f970de0f61f0cb3943ed82c891968480a434c4150";

const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => {
const blockFrost = getBlockFrostInstance(options);
const fetcher: SupplyFetcher = async (fetcher = defaultFetcher) => {
const total = 1e9; // 1 billion
const treasuryRaw = await getAmountInAddresses(blockFrost, CLAP, [
const treasuryRaw = await fetcher.getAmountInAddresses(CLAP, [
"addr1qxkcc74fpfvdenelc7m4zxtezrgvnhmd7z78jlkgr4gy9x9cjxt7rq9rfwqqh3wv24adfv2hex0ttwu3zh7e276xmcesgw34jc",
]);
const treasury = Number(treasuryRaw) / 1e3;
Expand Down
Loading

0 comments on commit 26bbf83

Please sign in to comment.