From 7499d832b398c0b58050f935e61e501955743f73 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 22 Feb 2023 09:48:29 +0100 Subject: [PATCH 1/5] tsconfig fix for ts-node scripts Signed-off-by: microwavedcola1 --- package.json | 2 +- tsconfig.json | 13 +++++++-- yarn.lock | 79 +++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 85 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 57714d6cc..85a9173c1 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "mocha": "^9.1.3", "prettier": "^2.0.5", "ts-mocha": "^10.0.0", - "ts-node": "^9.1.1", + "ts-node": "^10.9.1", "typedoc": "^0.22.5", "typescript": "^4.8.4" }, diff --git a/tsconfig.json b/tsconfig.json index 3c6de7205..40e34fdb8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,5 +9,14 @@ "skipLibCheck": true, "strictNullChecks": true }, - "include": ["ts/client/src"] -} + "ts-node": { + // these options are overrides used only by ts-node + // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable + "compilerOptions": { + "module": "commonjs" + } + }, + "include": [ + "ts/client/src" + ] +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 03cbd6c69..05963c938 100644 --- a/yarn.lock +++ b/yarn.lock @@ -66,6 +66,13 @@ bn.js "^5.1.2" buffer-layout "^1.2.0" +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + "@eslint/eslintrc@^0.4.3": version "0.4.3" resolved "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz" @@ -116,6 +123,24 @@ resolved "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@jridgewell/resolve-uri@^3.0.3": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" + integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.14" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" + integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== + +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@noble/ed25519@^1.7.0": version "1.7.3" resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.3.tgz#57e1677bf6885354b466c38e2b620c62f45a7123" @@ -331,6 +356,26 @@ "@project-serum/anchor" "^0.24.2" big.js "^6.1.1" +"@tsconfig/node10@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" + integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e" + integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ== + "@tsconfig/recommended@^1.0.1": version "1.0.1" resolved "https://registry.npmjs.org/@tsconfig/recommended/-/recommended-1.0.1.tgz" @@ -497,11 +542,21 @@ acorn-jsx@^5.3.1: resolved "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== +acorn-walk@^8.1.1: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + acorn@^7.4.0: version "7.4.1" resolved "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== +acorn@^8.4.1: + version "8.8.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" + integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== + agent-base@6: version "6.0.2" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" @@ -2077,7 +2132,7 @@ snake-case@^3.0.4: dot-case "^3.0.4" tslib "^2.0.3" -source-map-support@^0.5.17, source-map-support@^0.5.6: +source-map-support@^0.5.6: version "0.5.21" resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== @@ -2228,16 +2283,23 @@ ts-node@7.0.1: source-map-support "^0.5.6" yn "^2.0.0" -ts-node@^9.1.1: - version "9.1.1" - resolved "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz" - integrity sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg== +ts-node@^10.9.1: + version "10.9.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" + integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" arg "^4.1.0" create-require "^1.1.0" diff "^4.0.1" make-error "^1.1.1" - source-map-support "^0.5.17" + v8-compile-cache-lib "^3.0.1" yn "3.1.1" tsconfig-paths@^3.5.0: @@ -2324,6 +2386,11 @@ uuid@^8.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + v8-compile-cache@^2.0.3: version "2.3.0" resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz" From 92560f240f50d7b2d2dbe5f81466a7bbb0b319fd Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 22 Feb 2023 08:57:10 +0100 Subject: [PATCH 2/5] --wip-- [skip ci] --- ts/client/scripts/token-spec.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 ts/client/scripts/token-spec.ts diff --git a/ts/client/scripts/token-spec.ts b/ts/client/scripts/token-spec.ts new file mode 100644 index 000000000..115ff1ec5 --- /dev/null +++ b/ts/client/scripts/token-spec.ts @@ -0,0 +1,7 @@ + + +async function main() { + +} + +main(); From c0cfc50e7e4424c58d6eb18c7fd8af542e7b807c Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 22 Feb 2023 09:21:50 +0100 Subject: [PATCH 3/5] --wip-- [skip ci] --- ts/client/scripts/token-spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ts/client/scripts/token-spec.ts b/ts/client/scripts/token-spec.ts index 115ff1ec5..ae1801a6e 100644 --- a/ts/client/scripts/token-spec.ts +++ b/ts/client/scripts/token-spec.ts @@ -1,7 +1,6 @@ +const { MB_CLUSTER_URL, MB_PAYER_KEYPAIR, MB_PAYER3_KEYPAIR } = process.env; -async function main() { - -} +async function main() {} main(); From 15390043c0aeeb76814c6500e9a7954d089ad807 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 22 Feb 2023 09:45:19 +0100 Subject: [PATCH 4/5] --wip-- [skip ci] --- ts/client/scripts/token-spec.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ts/client/scripts/token-spec.ts b/ts/client/scripts/token-spec.ts index ae1801a6e..bea761c39 100644 --- a/ts/client/scripts/token-spec.ts +++ b/ts/client/scripts/token-spec.ts @@ -1,6 +1,32 @@ -const { MB_CLUSTER_URL, MB_PAYER_KEYPAIR, MB_PAYER3_KEYPAIR } = process.env; +import { AnchorProvider } from '@coral-xyz/anchor'; +import { getMint } from '@solana/spl-token'; +import { Connection, PublicKey } from '@solana/web3.js'; +const { MB_CLUSTER_URL, MB_PAYER_KEYPAIR, MB_PAYER3_KEYPAIR, MINT } = + process.env; -async function main() {} +async function main() { + const mintPk = new PublicKey( + MINT ?? 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a', + ); + + const options = AnchorProvider.defaultOptions(); + const connection = new Connection(MB_CLUSTER_URL!, options); + const mint = await getMint(connection, mintPk); + + // does the mint have an authority? + console.log(`Mint has freezeAuthority - ${mint.freezeAuthority != null}`); + console.log(`Mint has mintAuthority - ${mint.mintAuthority != null}`); + + // how does the token holder distribution look like? + const res = await connection.getTokenLargestAccounts(mintPk); + console.log(res); + + // are their amm pools? how is their tvl? + // 11111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&priceImpactLimit=0.01' | jq + // what was the volume traded yday + // how does the oracle look like? + // how was the price volatility yday? +} main(); From e5b7b6fdb1f6caab6720291dac36209dfed5d3ae Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 22 Feb 2023 10:25:22 +0100 Subject: [PATCH 5/5] --wip-- [skip ci] --- ts/client/scripts/token-spec.ts | 50 +++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/ts/client/scripts/token-spec.ts b/ts/client/scripts/token-spec.ts index bea761c39..29c3634cd 100644 --- a/ts/client/scripts/token-spec.ts +++ b/ts/client/scripts/token-spec.ts @@ -1,13 +1,17 @@ import { AnchorProvider } from '@coral-xyz/anchor'; import { getMint } from '@solana/spl-token'; import { Connection, PublicKey } from '@solana/web3.js'; +import fetch from 'node-fetch'; const { MB_CLUSTER_URL, MB_PAYER_KEYPAIR, MB_PAYER3_KEYPAIR, MINT } = process.env; async function main() { const mintPk = new PublicKey( - MINT ?? 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a', + MINT ?? + // 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a', // rlb + // 'MangoCzJ36AjZyKwVj3VnYU4GTonjfVEnJmvvWaxLac', // mngo + 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // usdc ); const options = AnchorProvider.defaultOptions(); @@ -18,14 +22,54 @@ async function main() { console.log(`Mint has freezeAuthority - ${mint.freezeAuthority != null}`); console.log(`Mint has mintAuthority - ${mint.mintAuthority != null}`); + const supplyUi = Number(mint.supply) / Math.pow(10, mint.decimals); + // how does the token holder distribution look like? const res = await connection.getTokenLargestAccounts(mintPk); - console.log(res); + console.log(`Top 20 token distribution`); + for (const account of res.value) { + console.log( + `- ${account.address.toBase58().padStart(45)} - ${( + (account.uiAmount! * 100) / + supplyUi + ).toFixed(2)}%`, + ); + } // are their amm pools? how is their tvl? - // 11111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&priceImpactLimit=0.01' | jq + // maybe birdeye can provide this? + + // give stats on max,min swap that can be performed at various slippage + // mngo cloud router doesnt work for most mints, maybe use jup api? + const wsolMint = 'So11111111111111111111111111111111111111112'; + async function swap( + priceImpact: number, + inputMint: string, + outputMint: string, + ): Promise { + const response = await fetch( + `https://api.mngo.cloud/router/v1/depth?inputMint=${inputMint}&outputMint=${outputMint}&priceImpactLimit=${priceImpact}`, + ); + const res = await response.json(); + console.log( + `at price impact of ${(priceImpact * 100) + .toString() + .padStart( + 3, + )}%, ${res.maxInput.toLocaleString()} ${inputMint} can be swapped to ${res.minOutput.toLocaleString()} ${outputMint}`, + ); + } + for (const priceImpact of [0.01, 0.1, 0.2]) { + swap(priceImpact, wsolMint, mintPk.toBase58()); + swap(priceImpact, mintPk.toBase58(), wsolMint); + } + // what was the volume traded yday + // get from jup api? + // how does the oracle look like? + + // how was the price volatility yday? }