@xyo-network/crypto-nft-collection-diviner-score-plugin 5.1.4 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,+BAA+B,EAChC,MAAM,mDAAmD,CAAA;AAM1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAKjE,MAAM,MAAM,+BAA+B,GAAG,aAAa,CAAC,eAAe,CAAC,+BAA+B,CAAC,CAAC,CAAA;AAc7G,qBAAa,yBAAyB,CACpC,OAAO,SAAS,+BAA+B,GAAG,+BAA+B,CACjF,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAkE;IAClH,gBAAyB,mBAAmB,EAAE,MAAM,CAAwC;IAE5F,UAAmB,aAAa,GAAU,WAAW,OAAO,EAAE,KAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAgBlF;CACF"}
1
+ {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,+BAA+B,EAChC,MAAM,mDAAmD,CAAA;AAM1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAKjE,MAAM,MAAM,+BAA+B,GAAG,aAAa,CAAC,eAAe,CAAC,+BAA+B,CAAC,CAAC,CAAA;AAe7G,qBAAa,yBAAyB,CACpC,OAAO,SAAS,+BAA+B,GAAG,+BAA+B,CACjF,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAkE;IAClH,gBAAyB,mBAAmB,EAAE,MAAM,CAAwC;IAE5F,UAAmB,aAAa,GAAU,WAAW,OAAO,EAAE,KAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAgBlF;CACF"}
@@ -95,6 +95,7 @@ var analyzeNftCollection = async (nft) => {
95
95
  // src/Diviner.ts
96
96
  var toNftCollectionScore = (nftCollectionInfo, scores) => {
97
97
  const {
98
+ // eslint-disable-next-line sonarjs/deprecation
98
99
  name,
99
100
  symbol,
100
101
  address,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner.ts","../../src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/metadata.ts","../../src/lib/rating/criteria/scoring/total.ts","../../src/lib/rating/criteria/index.ts","../../src/lib/rating/analyzeNftCollection.ts","../../src/Plugin.ts"],"sourcesContent":["import type {\n NftCollectionInfo,\n NftCollectionMetadata,\n NftCollectionScore,\n NftCollectionScoreDivinerConfig,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport {\n isNftCollectionInfo,\n NftCollectionScoreDivinerConfigSchema,\n NftCollectionScoreSchema,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { NftCollectionAnalysis } from './lib/index.ts'\nimport { analyzeNftCollection } from './lib/index.ts'\n\nexport type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>\n\nconst toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {\n const {\n name, symbol, address, chainId, type,\n } = nftCollectionInfo\n const metadata: NftCollectionMetadata = {\n address, chainId, name, symbol, type,\n }\n return {\n ...metadata, schema: NftCollectionScoreSchema, scores,\n }\n}\n\nexport class NftCollectionScoreDiviner<\n TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, NftCollectionScoreDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = NftCollectionScoreDivinerConfigSchema\n\n protected override divineHandler = async (payloads?: Payload[]): Promise<Payload[]> => {\n const nftCollectionInfos = payloads?.filter(isNftCollectionInfo) ?? []\n const results = await Promise.all(\n nftCollectionInfos.map<Promise<NftCollectionScore>>(async (nftCollectionInfo) => {\n const [score, sourceHash] = await Promise.all([\n // Get score\n toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),\n // Hash sources\n PayloadBuilder.dataHash(nftCollectionInfo),\n ])\n return {\n ...score, schema: NftCollectionScoreSchema, sources: [sourceHash],\n } as NftCollectionScore\n }),\n )\n return results\n }\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\nexport const scoreIndividualAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n const entries = Object.entries(attributes)\n if (entries.length === 0) return [0, maxScore]\n const scores = Object.entries(attributes).flatMap(([_trait, { values }]) => {\n return Object.entries(values).map<Score>(([_traitValue, metrics]) => {\n const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore)\n return [rarity, maxScore]\n })\n })\n // eslint-disable-next-line unicorn/no-array-reduce\n const total = scores.reduce<Score>(([a, b], [c, d]) => [a + c, b + d], [0, 0])\n return normalize(total, maxScore)\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\n/**\n * Mean: What value is the distribution centered around\n */\nconst defaultMu = 0.15\n\n/**\n * Standard Deviation: How spread out is the distribution\n */\nconst defaultSigma = 0.1\n\n/**\n * Calculates the Gaussian probability density\n * @param x\n * @param mu Mean\n * @param sigma Standard Deviation\n * @returns\n */\nconst gaussianProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n const sqrtTwoPi = Math.sqrt(2 * Math.PI)\n const denominator = sigma * sqrtTwoPi\n const power = -0.5 * Math.pow((x - mu) / sigma, 2)\n return (1 / denominator) * Math.exp(power)\n}\n\n/**\n * For a Gaussian distribution, the peak of the distribution is the mean\n */\nconst maxProbabilityDensity = gaussianProbabilityDensity(defaultMu)\n\n/**\n * We're working on some assumptions here:\n *\n * - If you have a 100% chance of getting a trait, everyone get's a trophy\n * - If you have a 50% chance of getting a trait, it's not rare\n * - If you have a 0% chance of getting a trait, it's not fun\n *\n * So we're looking for something Pareto-ish (somewhere between\n * 80/20 or 90/10) as that's a good & sustainable model for the\n * distribution of many traits in real life.\n * However, we also don't want to maximally reward collections\n * that have a lot of single attributes distributed uniformly\n * (basically a 0% trait probably) as that's perfectly entropic\n * but not very interesting (some overlap is desirable).\n * So we're using a Gaussian distribution to model the\n * probability density of the joint probability of all traits\n * centered around 15%.\n * @param info\n * @returns\n */\nexport const scoreTotalAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n // This has somewhat of a filtering function by causing anything with 100% probability to\n // add no value to the end score\n const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {\n return acc * metrics.binomial.p\n }, 1)\n const probabilityDensity = gaussianProbabilityDensity(jointProbability)\n const score: Score = [probabilityDensity, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreIndividualAttributes } from './scoreIndividualAttributes.ts'\nimport { scoreTotalAttributes } from './scoreTotalAttributes.ts'\n\nexport const attributeScoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n 'Metadata Attributes Individual': { score: scoreIndividualAttributes, weight: 2 },\n 'Metadata Attributes Total': { score: scoreTotalAttributes, weight: 2 },\n}\n\nexport const scoreMetadata: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = { ...attributeScoringCriteria }\n","import type { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\n/**\n * This \"magic\" value was obtained using Solver in Excel\n * to find the median, with mu/sigma fixed, which maximizes\n * the distribution (the mode for lognormal) at 10,000\n */\nconst median = 81_030_839.821_735_2\nconst defaultMu = Math.log(median)\nconst defaultSigma = 3\nconst mode = Math.exp(defaultMu - Math.pow(defaultSigma, 2))\n/**\n * Calculates the log-normal probability density\n * @param x the value at which you want to calculate the probability density\n * @param mu mean of the associated normal distribution\n * @param sigma standard deviation of the associated normal distribution\n * @returns\n */\nconst logNormalProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n if (x <= 0) return 0\n const logX = Math.log(x)\n return (1 / (x * sigma * Math.sqrt(2 * Math.PI))) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2))\n}\n\n/**\n * For a lognormal distribution, the peak of the distribution is the mode\n */\nconst maxProbabilityDensity = logNormalProbabilityDensity(mode)\n\nconst maxScore = 10\n\n/**\n * We're working on some assumptions here:\n * - If there's < 1000 NFTs in your collection it starts becoming too niche\n * - If there's > 20,000 NFTs in your collection it starts becoming too broad\n * So there's a sweet spot somewhere between 2000 and 10,000\n * where a collection has enough NFTs to be interesting, but\n * not so many that it's teetering on a diluted money grab.\n * To model that we're using a log-normal distribution optimized\n * to maximally reward collections in the aforementioned range\n * @param nft\n * @returns\n */\nexport const scoreTotal = (nft: NftCollectionCount): Score => {\n const density = logNormalProbabilityDensity(nft.total)\n const score: Score = [density, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreMetadata, scoreTotal } from './scoring/index.ts'\n\nexport const scoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n ...scoreMetadata,\n Total: { score: scoreTotal, weight: 2 },\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoringCriteria } from './criteria/index.ts'\n\nexport type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey\n\nexport type NftCollectionAnalysis = {\n [key in ScoringCriteriaKey]: Score\n}\n\nexport const analyzeNftCollection = async (\n /**\n * The NFT to evaluate\n */\n nft: NftCollectionInfo,\n): Promise<NftCollectionAnalysis> => {\n const result = Object.fromEntries(\n await Promise.all(\n Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {\n const rawScore = await score(nft)\n const weighted = rawScore.map(v => v * weight) as Score\n return [key, weighted] as const\n }),\n ),\n ) as NftCollectionAnalysis\n return result\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { NftCollectionScoreDiviner } from './Diviner.ts'\n\nexport const NftCollectionScoreDivinerPlugin = () =>\n createPayloadSetDivinerPlugin<NftCollectionScoreDiviner>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n diviner: async (params) => {\n const result = await NftCollectionScoreDiviner.create(params)\n return result\n },\n },\n )\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAGhC,SAAS,sBAAsB;;;ACZ/B,SAAS,iBAAiB;AAE1B,IAAM,WAAW;AAEV,IAAM,4BAA4B,CAAC,SAA+C;AACvF,QAAM,EAAE,WAAW,IAAI,KAAK,QAAQ;AACpC,QAAM,UAAU,OAAO,QAAQ,UAAU;AACzC,MAAI,QAAQ,WAAW,EAAG,QAAO,CAAC,GAAG,QAAQ;AAC7C,QAAM,SAAS,OAAO,QAAQ,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM;AAC1E,WAAO,OAAO,QAAQ,MAAM,EAAE,IAAW,CAAC,CAAC,aAAa,OAAO,MAAM;AACnE,YAAM,SAAS,KAAK,IAAI,KAAK,OAAO,IAAI,QAAQ,SAAS,KAAK,QAAQ,GAAG,QAAQ;AACjF,aAAO,CAAC,QAAQ,QAAQ;AAAA,IAC1B,CAAC;AAAA,EACH,CAAC;AAED,QAAM,QAAQ,OAAO,OAAc,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC7E,SAAO,UAAU,OAAO,QAAQ;AAClC;;;ACjBA,SAAS,aAAAA,kBAAiB;AAE1B,IAAMC,YAAW;AAKjB,IAAM,YAAY;AAKlB,IAAM,eAAe;AASrB,IAAM,6BAA6B,CAAC,GAAW,KAAa,WAAW,QAAgB,iBAAyB;AAC9G,QAAM,YAAY,KAAK,KAAK,IAAI,KAAK,EAAE;AACvC,QAAM,cAAc,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mB,MAAM,qBAAqB,iBAAiB,CAAC;AAAA;AAAA,UAErF,eAAe,SAAS,iBAAiB;AAAA,QAC3C,CAAC;AACD,eAAO;AAAA,UACL,GAAG;AAAA,UAAO,QAAQ;AAAA,UAA0B,SAAS,CAAC,UAAU;AAAA,QAClE;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;;;AOzDA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAIvC,IAAM,kCAAkC,MAC7C;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,0BAA0B,OAAO,MAAM;AAC5D,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["normalize","maxScore","normalize","defaultMu","defaultSigma","maxProbabilityDensity","maxScore"]}
1
+ {"version":3,"sources":["../../src/Diviner.ts","../../src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/metadata.ts","../../src/lib/rating/criteria/scoring/total.ts","../../src/lib/rating/criteria/index.ts","../../src/lib/rating/analyzeNftCollection.ts","../../src/Plugin.ts"],"sourcesContent":["import type {\n NftCollectionInfo,\n NftCollectionMetadata,\n NftCollectionScore,\n NftCollectionScoreDivinerConfig,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport {\n isNftCollectionInfo,\n NftCollectionScoreDivinerConfigSchema,\n NftCollectionScoreSchema,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { NftCollectionAnalysis } from './lib/index.ts'\nimport { analyzeNftCollection } from './lib/index.ts'\n\nexport type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>\n\nconst toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {\n const {\n // eslint-disable-next-line sonarjs/deprecation\n name, symbol, address, chainId, type,\n } = nftCollectionInfo\n const metadata: NftCollectionMetadata = {\n address, chainId, name, symbol, type,\n }\n return {\n ...metadata, schema: NftCollectionScoreSchema, scores,\n }\n}\n\nexport class NftCollectionScoreDiviner<\n TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, NftCollectionScoreDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = NftCollectionScoreDivinerConfigSchema\n\n protected override divineHandler = async (payloads?: Payload[]): Promise<Payload[]> => {\n const nftCollectionInfos = payloads?.filter(isNftCollectionInfo) ?? []\n const results = await Promise.all(\n nftCollectionInfos.map<Promise<NftCollectionScore>>(async (nftCollectionInfo) => {\n const [score, sourceHash] = await Promise.all([\n // Get score\n toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),\n // Hash sources\n PayloadBuilder.dataHash(nftCollectionInfo),\n ])\n return {\n ...score, schema: NftCollectionScoreSchema, sources: [sourceHash],\n } as NftCollectionScore\n }),\n )\n return results\n }\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\nexport const scoreIndividualAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n const entries = Object.entries(attributes)\n if (entries.length === 0) return [0, maxScore]\n const scores = Object.entries(attributes).flatMap(([_trait, { values }]) => {\n return Object.entries(values).map<Score>(([_traitValue, metrics]) => {\n const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore)\n return [rarity, maxScore]\n })\n })\n // eslint-disable-next-line unicorn/no-array-reduce\n const total = scores.reduce<Score>(([a, b], [c, d]) => [a + c, b + d], [0, 0])\n return normalize(total, maxScore)\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\n/**\n * Mean: What value is the distribution centered around\n */\nconst defaultMu = 0.15\n\n/**\n * Standard Deviation: How spread out is the distribution\n */\nconst defaultSigma = 0.1\n\n/**\n * Calculates the Gaussian probability density\n * @param x\n * @param mu Mean\n * @param sigma Standard Deviation\n * @returns\n */\nconst gaussianProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n const sqrtTwoPi = Math.sqrt(2 * Math.PI)\n const denominator = sigma * sqrtTwoPi\n const power = -0.5 * Math.pow((x - mu) / sigma, 2)\n return (1 / denominator) * Math.exp(power)\n}\n\n/**\n * For a Gaussian distribution, the peak of the distribution is the mean\n */\nconst maxProbabilityDensity = gaussianProbabilityDensity(defaultMu)\n\n/**\n * We're working on some assumptions here:\n *\n * - If you have a 100% chance of getting a trait, everyone get's a trophy\n * - If you have a 50% chance of getting a trait, it's not rare\n * - If you have a 0% chance of getting a trait, it's not fun\n *\n * So we're looking for something Pareto-ish (somewhere between\n * 80/20 or 90/10) as that's a good & sustainable model for the\n * distribution of many traits in real life.\n * However, we also don't want to maximally reward collections\n * that have a lot of single attributes distributed uniformly\n * (basically a 0% trait probably) as that's perfectly entropic\n * but not very interesting (some overlap is desirable).\n * So we're using a Gaussian distribution to model the\n * probability density of the joint probability of all traits\n * centered around 15%.\n * @param info\n * @returns\n */\nexport const scoreTotalAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n // This has somewhat of a filtering function by causing anything with 100% probability to\n // add no value to the end score\n const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {\n return acc * metrics.binomial.p\n }, 1)\n const probabilityDensity = gaussianProbabilityDensity(jointProbability)\n const score: Score = [probabilityDensity, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreIndividualAttributes } from './scoreIndividualAttributes.ts'\nimport { scoreTotalAttributes } from './scoreTotalAttributes.ts'\n\nexport const attributeScoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n 'Metadata Attributes Individual': { score: scoreIndividualAttributes, weight: 2 },\n 'Metadata Attributes Total': { score: scoreTotalAttributes, weight: 2 },\n}\n\nexport const scoreMetadata: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = { ...attributeScoringCriteria }\n","import type { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\n/**\n * This \"magic\" value was obtained using Solver in Excel\n * to find the median, with mu/sigma fixed, which maximizes\n * the distribution (the mode for lognormal) at 10,000\n */\nconst median = 81_030_839.821_735_2\nconst defaultMu = Math.log(median)\nconst defaultSigma = 3\nconst mode = Math.exp(defaultMu - Math.pow(defaultSigma, 2))\n/**\n * Calculates the log-normal probability density\n * @param x the value at which you want to calculate the probability density\n * @param mu mean of the associated normal distribution\n * @param sigma standard deviation of the associated normal distribution\n * @returns\n */\nconst logNormalProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n if (x <= 0) return 0\n const logX = Math.log(x)\n return (1 / (x * sigma * Math.sqrt(2 * Math.PI))) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2))\n}\n\n/**\n * For a lognormal distribution, the peak of the distribution is the mode\n */\nconst maxProbabilityDensity = logNormalProbabilityDensity(mode)\n\nconst maxScore = 10\n\n/**\n * We're working on some assumptions here:\n * - If there's < 1000 NFTs in your collection it starts becoming too niche\n * - If there's > 20,000 NFTs in your collection it starts becoming too broad\n * So there's a sweet spot somewhere between 2000 and 10,000\n * where a collection has enough NFTs to be interesting, but\n * not so many that it's teetering on a diluted money grab.\n * To model that we're using a log-normal distribution optimized\n * to maximally reward collections in the aforementioned range\n * @param nft\n * @returns\n */\nexport const scoreTotal = (nft: NftCollectionCount): Score => {\n const density = logNormalProbabilityDensity(nft.total)\n const score: Score = [density, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreMetadata, scoreTotal } from './scoring/index.ts'\n\nexport const scoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n ...scoreMetadata,\n Total: { score: scoreTotal, weight: 2 },\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoringCriteria } from './criteria/index.ts'\n\nexport type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey\n\nexport type NftCollectionAnalysis = {\n [key in ScoringCriteriaKey]: Score\n}\n\nexport const analyzeNftCollection = async (\n /**\n * The NFT to evaluate\n */\n nft: NftCollectionInfo,\n): Promise<NftCollectionAnalysis> => {\n const result = Object.fromEntries(\n await Promise.all(\n Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {\n const rawScore = await score(nft)\n const weighted = rawScore.map(v => v * weight) as Score\n return [key, weighted] as const\n }),\n ),\n ) as NftCollectionAnalysis\n return result\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { NftCollectionScoreDiviner } from './Diviner.ts'\n\nexport const NftCollectionScoreDivinerPlugin = () =>\n createPayloadSetDivinerPlugin<NftCollectionScoreDiviner>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n diviner: async (params) => {\n const result = await NftCollectionScoreDiviner.create(params)\n return result\n },\n },\n )\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAGhC,SAAS,sBAAsB;;;ACZ/B,SAAS,iBAAiB;AAE1B,IAAM,WAAW;AAEV,IAAM,4BAA4B,CAAC,SAA+C;AACvF,QAAM,EAAE,WAAW,IAAI,KAAK,QAAQ;AACpC,QAAM,UAAU,OAAO,QAAQ,UAAU;AACzC,MAAI,QAAQ,WAAW,EAAG,QAAO,CAAC,GAAG,QAAQ;AAC7C,QAAM,SAAS,OAAO,QAAQ,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM;AAC1E,WAAO,OAAO,QAAQ,MAAM,EAAE,IAAW,CAAC,CAAC,aAAa,OAAO,MAAM;AACnE,YAAM,SAAS,KAAK,IAAI,KAAK,OAAO,IAAI,QAAQ,SAAS,KAAK,QAAQ,GAAG,QAAQ;AACjF,aAAO,CAAC,QAAQ,QAAQ;AAAA,IAC1B,CAAC;AAAA,EACH,CAAC;AAED,QAAM,QAAQ,OAAO,OAAc,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC7E,SAAO,UAAU,OAAO,QAAQ;AAClC;;;ACjBA,SAAS,aAAAA,kBAAiB;AAE1B,IAAMC,YAAW;AAKjB,IAAM,YAAY;AAKlB,IAAM,eAAe;AASrB,IAAM,6BAA6B,CAAC,GAAW,KAAa,WAAW,QAAgB,iBAAyB;AAC9G,QAAM,YAAY,KAAK,KAA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QAAQ,IAAI;AAAA;AAAA,UAE5C,qBAAqB,mBAAmB,MAAM,qBAAqB,iBAAiB,CAAC;AAAA;AAAA,UAErF,eAAe,SAAS,iBAAiB;AAAA,QAC3C,CAAC;AACD,eAAO;AAAA,UACL,GAAG;AAAA,UAAO,QAAQ;AAAA,UAA0B,SAAS,CAAC,UAAU;AAAA,QAClE;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;;;AO1DA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAIvC,IAAM,kCAAkC,MAC7C;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,0BAA0B,OAAO,MAAM;AAC5D,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["normalize","maxScore","normalize","defaultMu","defaultSigma","maxProbabilityDensity","maxScore"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,+BAA+B,EAChC,MAAM,mDAAmD,CAAA;AAM1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAKjE,MAAM,MAAM,+BAA+B,GAAG,aAAa,CAAC,eAAe,CAAC,+BAA+B,CAAC,CAAC,CAAA;AAc7G,qBAAa,yBAAyB,CACpC,OAAO,SAAS,+BAA+B,GAAG,+BAA+B,CACjF,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAkE;IAClH,gBAAyB,mBAAmB,EAAE,MAAM,CAAwC;IAE5F,UAAmB,aAAa,GAAU,WAAW,OAAO,EAAE,KAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAgBlF;CACF"}
1
+ {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,+BAA+B,EAChC,MAAM,mDAAmD,CAAA;AAM1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAKjE,MAAM,MAAM,+BAA+B,GAAG,aAAa,CAAC,eAAe,CAAC,+BAA+B,CAAC,CAAC,CAAA;AAe7G,qBAAa,yBAAyB,CACpC,OAAO,SAAS,+BAA+B,GAAG,+BAA+B,CACjF,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAkE;IAClH,gBAAyB,mBAAmB,EAAE,MAAM,CAAwC;IAE5F,UAAmB,aAAa,GAAU,WAAW,OAAO,EAAE,KAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAgBlF;CACF"}
@@ -95,6 +95,7 @@ var analyzeNftCollection = async (nft) => {
95
95
  // src/Diviner.ts
96
96
  var toNftCollectionScore = (nftCollectionInfo, scores) => {
97
97
  const {
98
+ // eslint-disable-next-line sonarjs/deprecation
98
99
  name,
99
100
  symbol,
100
101
  address,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner.ts","../../src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/metadata.ts","../../src/lib/rating/criteria/scoring/total.ts","../../src/lib/rating/criteria/index.ts","../../src/lib/rating/analyzeNftCollection.ts","../../src/Plugin.ts"],"sourcesContent":["import type {\n NftCollectionInfo,\n NftCollectionMetadata,\n NftCollectionScore,\n NftCollectionScoreDivinerConfig,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport {\n isNftCollectionInfo,\n NftCollectionScoreDivinerConfigSchema,\n NftCollectionScoreSchema,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { NftCollectionAnalysis } from './lib/index.ts'\nimport { analyzeNftCollection } from './lib/index.ts'\n\nexport type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>\n\nconst toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {\n const {\n name, symbol, address, chainId, type,\n } = nftCollectionInfo\n const metadata: NftCollectionMetadata = {\n address, chainId, name, symbol, type,\n }\n return {\n ...metadata, schema: NftCollectionScoreSchema, scores,\n }\n}\n\nexport class NftCollectionScoreDiviner<\n TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, NftCollectionScoreDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = NftCollectionScoreDivinerConfigSchema\n\n protected override divineHandler = async (payloads?: Payload[]): Promise<Payload[]> => {\n const nftCollectionInfos = payloads?.filter(isNftCollectionInfo) ?? []\n const results = await Promise.all(\n nftCollectionInfos.map<Promise<NftCollectionScore>>(async (nftCollectionInfo) => {\n const [score, sourceHash] = await Promise.all([\n // Get score\n toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),\n // Hash sources\n PayloadBuilder.dataHash(nftCollectionInfo),\n ])\n return {\n ...score, schema: NftCollectionScoreSchema, sources: [sourceHash],\n } as NftCollectionScore\n }),\n )\n return results\n }\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\nexport const scoreIndividualAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n const entries = Object.entries(attributes)\n if (entries.length === 0) return [0, maxScore]\n const scores = Object.entries(attributes).flatMap(([_trait, { values }]) => {\n return Object.entries(values).map<Score>(([_traitValue, metrics]) => {\n const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore)\n return [rarity, maxScore]\n })\n })\n // eslint-disable-next-line unicorn/no-array-reduce\n const total = scores.reduce<Score>(([a, b], [c, d]) => [a + c, b + d], [0, 0])\n return normalize(total, maxScore)\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\n/**\n * Mean: What value is the distribution centered around\n */\nconst defaultMu = 0.15\n\n/**\n * Standard Deviation: How spread out is the distribution\n */\nconst defaultSigma = 0.1\n\n/**\n * Calculates the Gaussian probability density\n * @param x\n * @param mu Mean\n * @param sigma Standard Deviation\n * @returns\n */\nconst gaussianProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n const sqrtTwoPi = Math.sqrt(2 * Math.PI)\n const denominator = sigma * sqrtTwoPi\n const power = -0.5 * Math.pow((x - mu) / sigma, 2)\n return (1 / denominator) * Math.exp(power)\n}\n\n/**\n * For a Gaussian distribution, the peak of the distribution is the mean\n */\nconst maxProbabilityDensity = gaussianProbabilityDensity(defaultMu)\n\n/**\n * We're working on some assumptions here:\n *\n * - If you have a 100% chance of getting a trait, everyone get's a trophy\n * - If you have a 50% chance of getting a trait, it's not rare\n * - If you have a 0% chance of getting a trait, it's not fun\n *\n * So we're looking for something Pareto-ish (somewhere between\n * 80/20 or 90/10) as that's a good & sustainable model for the\n * distribution of many traits in real life.\n * However, we also don't want to maximally reward collections\n * that have a lot of single attributes distributed uniformly\n * (basically a 0% trait probably) as that's perfectly entropic\n * but not very interesting (some overlap is desirable).\n * So we're using a Gaussian distribution to model the\n * probability density of the joint probability of all traits\n * centered around 15%.\n * @param info\n * @returns\n */\nexport const scoreTotalAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n // This has somewhat of a filtering function by causing anything with 100% probability to\n // add no value to the end score\n const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {\n return acc * metrics.binomial.p\n }, 1)\n const probabilityDensity = gaussianProbabilityDensity(jointProbability)\n const score: Score = [probabilityDensity, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreIndividualAttributes } from './scoreIndividualAttributes.ts'\nimport { scoreTotalAttributes } from './scoreTotalAttributes.ts'\n\nexport const attributeScoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n 'Metadata Attributes Individual': { score: scoreIndividualAttributes, weight: 2 },\n 'Metadata Attributes Total': { score: scoreTotalAttributes, weight: 2 },\n}\n\nexport const scoreMetadata: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = { ...attributeScoringCriteria }\n","import type { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\n/**\n * This \"magic\" value was obtained using Solver in Excel\n * to find the median, with mu/sigma fixed, which maximizes\n * the distribution (the mode for lognormal) at 10,000\n */\nconst median = 81_030_839.821_735_2\nconst defaultMu = Math.log(median)\nconst defaultSigma = 3\nconst mode = Math.exp(defaultMu - Math.pow(defaultSigma, 2))\n/**\n * Calculates the log-normal probability density\n * @param x the value at which you want to calculate the probability density\n * @param mu mean of the associated normal distribution\n * @param sigma standard deviation of the associated normal distribution\n * @returns\n */\nconst logNormalProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n if (x <= 0) return 0\n const logX = Math.log(x)\n return (1 / (x * sigma * Math.sqrt(2 * Math.PI))) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2))\n}\n\n/**\n * For a lognormal distribution, the peak of the distribution is the mode\n */\nconst maxProbabilityDensity = logNormalProbabilityDensity(mode)\n\nconst maxScore = 10\n\n/**\n * We're working on some assumptions here:\n * - If there's < 1000 NFTs in your collection it starts becoming too niche\n * - If there's > 20,000 NFTs in your collection it starts becoming too broad\n * So there's a sweet spot somewhere between 2000 and 10,000\n * where a collection has enough NFTs to be interesting, but\n * not so many that it's teetering on a diluted money grab.\n * To model that we're using a log-normal distribution optimized\n * to maximally reward collections in the aforementioned range\n * @param nft\n * @returns\n */\nexport const scoreTotal = (nft: NftCollectionCount): Score => {\n const density = logNormalProbabilityDensity(nft.total)\n const score: Score = [density, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreMetadata, scoreTotal } from './scoring/index.ts'\n\nexport const scoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n ...scoreMetadata,\n Total: { score: scoreTotal, weight: 2 },\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoringCriteria } from './criteria/index.ts'\n\nexport type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey\n\nexport type NftCollectionAnalysis = {\n [key in ScoringCriteriaKey]: Score\n}\n\nexport const analyzeNftCollection = async (\n /**\n * The NFT to evaluate\n */\n nft: NftCollectionInfo,\n): Promise<NftCollectionAnalysis> => {\n const result = Object.fromEntries(\n await Promise.all(\n Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {\n const rawScore = await score(nft)\n const weighted = rawScore.map(v => v * weight) as Score\n return [key, weighted] as const\n }),\n ),\n ) as NftCollectionAnalysis\n return result\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { NftCollectionScoreDiviner } from './Diviner.ts'\n\nexport const NftCollectionScoreDivinerPlugin = () =>\n createPayloadSetDivinerPlugin<NftCollectionScoreDiviner>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n diviner: async (params) => {\n const result = await NftCollectionScoreDiviner.create(params)\n return result\n },\n },\n )\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAGhC,SAAS,sBAAsB;;;ACZ/B,SAAS,iBAAiB;AAE1B,IAAM,WAAW;AAEV,IAAM,4BAA4B,CAAC,SAA+C;AACvF,QAAM,EAAE,WAAW,IAAI,KAAK,QAAQ;AACpC,QAAM,UAAU,OAAO,QAAQ,UAAU;AACzC,MAAI,QAAQ,WAAW,EAAG,QAAO,CAAC,GAAG,QAAQ;AAC7C,QAAM,SAAS,OAAO,QAAQ,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM;AAC1E,WAAO,OAAO,QAAQ,MAAM,EAAE,IAAW,CAAC,CAAC,aAAa,OAAO,MAAM;AACnE,YAAM,SAAS,KAAK,IAAI,KAAK,OAAO,IAAI,QAAQ,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S;AAAA,IAAS;AAAA,IAAM;AAAA,IAAQ;AAAA,EAClC;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IAAU,QAAQ;AAAA,IAA0B;AAAA,EACjD;AACF;AAEO,IAAM,4BAAN,cAEG,gBAAyB;AAAA,EACjC,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,qCAAqC;AAAA,EACjH,OAAyB,sBAA8B;AAAA,EAEpC,gBAAgB,OAAO,aAA6C;AACrF,UAAM,qBAAqB,UAAU,OAAO,mBAAmB,KAAK,CAAC;AACrE,UAAM,UAAU,MAAM,QAAQ;AAAA,MAC5B,mBAAmB,IAAiC,OAAO,sBAAsB;AAC/E,cAAM,CAAC,OAAO,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA;AAAA,UAE5C,qBAAqB,mBAAmB,MAAM,qBAAqB,iBAAiB,CAAC;AAAA;AAAA,UAErF,eAAe,SAAS,iBAAiB;AAAA,QAC3C,CAAC;AACD,eAAO;AAAA,UACL,GAAG;AAAA,UAAO,QAAQ;AAAA,UAA0B,SAAS,CAAC,UAAU;AAAA,QAClE;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;;;AOzDA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAIvC,IAAM,kCAAkC,MAC7C;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,0BAA0B,OAAO,MAAM;AAC5D,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["normalize","maxScore","normalize","defaultMu","defaultSigma","maxProbabilityDensity","maxScore"]}
1
+ {"version":3,"sources":["../../src/Diviner.ts","../../src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/metadata.ts","../../src/lib/rating/criteria/scoring/total.ts","../../src/lib/rating/criteria/index.ts","../../src/lib/rating/analyzeNftCollection.ts","../../src/Plugin.ts"],"sourcesContent":["import type {\n NftCollectionInfo,\n NftCollectionMetadata,\n NftCollectionScore,\n NftCollectionScoreDivinerConfig,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport {\n isNftCollectionInfo,\n NftCollectionScoreDivinerConfigSchema,\n NftCollectionScoreSchema,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { NftCollectionAnalysis } from './lib/index.ts'\nimport { analyzeNftCollection } from './lib/index.ts'\n\nexport type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>\n\nconst toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {\n const {\n // eslint-disable-next-line sonarjs/deprecation\n name, symbol, address, chainId, type,\n } = nftCollectionInfo\n const metadata: NftCollectionMetadata = {\n address, chainId, name, symbol, type,\n }\n return {\n ...metadata, schema: NftCollectionScoreSchema, scores,\n }\n}\n\nexport class NftCollectionScoreDiviner<\n TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, NftCollectionScoreDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = NftCollectionScoreDivinerConfigSchema\n\n protected override divineHandler = async (payloads?: Payload[]): Promise<Payload[]> => {\n const nftCollectionInfos = payloads?.filter(isNftCollectionInfo) ?? []\n const results = await Promise.all(\n nftCollectionInfos.map<Promise<NftCollectionScore>>(async (nftCollectionInfo) => {\n const [score, sourceHash] = await Promise.all([\n // Get score\n toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),\n // Hash sources\n PayloadBuilder.dataHash(nftCollectionInfo),\n ])\n return {\n ...score, schema: NftCollectionScoreSchema, sources: [sourceHash],\n } as NftCollectionScore\n }),\n )\n return results\n }\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\nexport const scoreIndividualAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n const entries = Object.entries(attributes)\n if (entries.length === 0) return [0, maxScore]\n const scores = Object.entries(attributes).flatMap(([_trait, { values }]) => {\n return Object.entries(values).map<Score>(([_traitValue, metrics]) => {\n const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore)\n return [rarity, maxScore]\n })\n })\n // eslint-disable-next-line unicorn/no-array-reduce\n const total = scores.reduce<Score>(([a, b], [c, d]) => [a + c, b + d], [0, 0])\n return normalize(total, maxScore)\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\n/**\n * Mean: What value is the distribution centered around\n */\nconst defaultMu = 0.15\n\n/**\n * Standard Deviation: How spread out is the distribution\n */\nconst defaultSigma = 0.1\n\n/**\n * Calculates the Gaussian probability density\n * @param x\n * @param mu Mean\n * @param sigma Standard Deviation\n * @returns\n */\nconst gaussianProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n const sqrtTwoPi = Math.sqrt(2 * Math.PI)\n const denominator = sigma * sqrtTwoPi\n const power = -0.5 * Math.pow((x - mu) / sigma, 2)\n return (1 / denominator) * Math.exp(power)\n}\n\n/**\n * For a Gaussian distribution, the peak of the distribution is the mean\n */\nconst maxProbabilityDensity = gaussianProbabilityDensity(defaultMu)\n\n/**\n * We're working on some assumptions here:\n *\n * - If you have a 100% chance of getting a trait, everyone get's a trophy\n * - If you have a 50% chance of getting a trait, it's not rare\n * - If you have a 0% chance of getting a trait, it's not fun\n *\n * So we're looking for something Pareto-ish (somewhere between\n * 80/20 or 90/10) as that's a good & sustainable model for the\n * distribution of many traits in real life.\n * However, we also don't want to maximally reward collections\n * that have a lot of single attributes distributed uniformly\n * (basically a 0% trait probably) as that's perfectly entropic\n * but not very interesting (some overlap is desirable).\n * So we're using a Gaussian distribution to model the\n * probability density of the joint probability of all traits\n * centered around 15%.\n * @param info\n * @returns\n */\nexport const scoreTotalAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n // This has somewhat of a filtering function by causing anything with 100% probability to\n // add no value to the end score\n const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {\n return acc * metrics.binomial.p\n }, 1)\n const probabilityDensity = gaussianProbabilityDensity(jointProbability)\n const score: Score = [probabilityDensity, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreIndividualAttributes } from './scoreIndividualAttributes.ts'\nimport { scoreTotalAttributes } from './scoreTotalAttributes.ts'\n\nexport const attributeScoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n 'Metadata Attributes Individual': { score: scoreIndividualAttributes, weight: 2 },\n 'Metadata Attributes Total': { score: scoreTotalAttributes, weight: 2 },\n}\n\nexport const scoreMetadata: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = { ...attributeScoringCriteria }\n","import type { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\n/**\n * This \"magic\" value was obtained using Solver in Excel\n * to find the median, with mu/sigma fixed, which maximizes\n * the distribution (the mode for lognormal) at 10,000\n */\nconst median = 81_030_839.821_735_2\nconst defaultMu = Math.log(median)\nconst defaultSigma = 3\nconst mode = Math.exp(defaultMu - Math.pow(defaultSigma, 2))\n/**\n * Calculates the log-normal probability density\n * @param x the value at which you want to calculate the probability density\n * @param mu mean of the associated normal distribution\n * @param sigma standard deviation of the associated normal distribution\n * @returns\n */\nconst logNormalProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n if (x <= 0) return 0\n const logX = Math.log(x)\n return (1 / (x * sigma * Math.sqrt(2 * Math.PI))) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2))\n}\n\n/**\n * For a lognormal distribution, the peak of the distribution is the mode\n */\nconst maxProbabilityDensity = logNormalProbabilityDensity(mode)\n\nconst maxScore = 10\n\n/**\n * We're working on some assumptions here:\n * - If there's < 1000 NFTs in your collection it starts becoming too niche\n * - If there's > 20,000 NFTs in your collection it starts becoming too broad\n * So there's a sweet spot somewhere between 2000 and 10,000\n * where a collection has enough NFTs to be interesting, but\n * not so many that it's teetering on a diluted money grab.\n * To model that we're using a log-normal distribution optimized\n * to maximally reward collections in the aforementioned range\n * @param nft\n * @returns\n */\nexport const scoreTotal = (nft: NftCollectionCount): Score => {\n const density = logNormalProbabilityDensity(nft.total)\n const score: Score = [density, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreMetadata, scoreTotal } from './scoring/index.ts'\n\nexport const scoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n ...scoreMetadata,\n Total: { score: scoreTotal, weight: 2 },\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoringCriteria } from './criteria/index.ts'\n\nexport type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey\n\nexport type NftCollectionAnalysis = {\n [key in ScoringCriteriaKey]: Score\n}\n\nexport const analyzeNftCollection = async (\n /**\n * The NFT to evaluate\n */\n nft: NftCollectionInfo,\n): Promise<NftCollectionAnalysis> => {\n const result = Object.fromEntries(\n await Promise.all(\n Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {\n const rawScore = await score(nft)\n const weighted = rawScore.map(v => v * weight) as Score\n return [key, weighted] as const\n }),\n ),\n ) as NftCollectionAnalysis\n return result\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { NftCollectionScoreDiviner } from './Diviner.ts'\n\nexport const NftCollectionScoreDivinerPlugin = () =>\n createPayloadSetDivinerPlugin<NftCollectionScoreDiviner>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n diviner: async (params) => {\n const result = await NftCollectionScoreDiviner.create(params)\n return result\n },\n },\n )\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAGhC,SAAS,sBAAsB;;;ACZ/B,SAAS,iBAAiB;AAE1B,IAAM,WAAW;AAEV,IAAM,4BAA4B,CAAC,SAA+C;AACvF,QAAM,EAAE,WAAW,IAAI,KAAK,QAAQ;AACpC,QAAM,UAAU,OAAO,QAAQ,UAAU;AACzC,MAAI,QAAQ,WAAW,EAAG,QAAO,CAAC,GAAG,QAAQ;AAC7C,QAAM,SAAS,OAAO,QAAQ,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM;AAC1E,WAAO,OAAO,QAAQ,MAAM,EAAE,IAAW,CAAC,CAAC,aAAa,OAAO,MAAM;AACnE,YAAM,SAAS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AAI;AACJ,QAAM,WAAkC;AAAA,IACtC;AAAA,IAAS;AAAA,IAAS;AAAA,IAAM;AAAA,IAAQ;AAAA,EAClC;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IAAU,QAAQ;AAAA,IAA0B;AAAA,EACjD;AACF;AAEO,IAAM,4BAAN,cAEG,gBAAyB;AAAA,EACjC,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,qCAAqC;AAAA,EACjH,OAAyB,sBAA8B;AAAA,EAEpC,gBAAgB,OAAO,aAA6C;AACrF,UAAM,qBAAqB,UAAU,OAAO,mBAAmB,KAAK,CAAC;AACrE,UAAM,UAAU,MAAM,QAAQ;AAAA,MAC5B,mBAAmB,IAAiC,OAAO,sBAAsB;AAC/E,cAAM,CAAC,OAAO,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA;AAAA,UAE5C,qBAAqB,mBAAmB,MAAM,qBAAqB,iBAAiB,CAAC;AAAA;AAAA,UAErF,eAAe,SAAS,iBAAiB;AAAA,QAC3C,CAAC;AACD,eAAO;AAAA,UACL,GAAG;AAAA,UAAO,QAAQ;AAAA,UAA0B,SAAS,CAAC,UAAU;AAAA,QAClE;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;;;AO1DA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAIvC,IAAM,kCAAkC,MAC7C;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,0BAA0B,OAAO,MAAM;AAC5D,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["normalize","maxScore","normalize","defaultMu","defaultSigma","maxProbabilityDensity","maxScore"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AAAA,OAA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AAE,MAAM,EAAE,CAAkE;IAClH,gBAAyB,mBAAmB,EAAE,MAAM,CAAwC;IAE5F,UAAmB,aAAa,GAAU,WAAW,OAAO,EAAE,KAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAgBlF;CACF"}
@@ -95,6 +95,7 @@ var analyzeNftCollection = async (nft) => {
95
95
  // src/Diviner.ts
96
96
  var toNftCollectionScore = (nftCollectionInfo, scores) => {
97
97
  const {
98
+ // eslint-disable-next-line sonarjs/deprecation
98
99
  name,
99
100
  symbol,
100
101
  address,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner.ts","../../src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/metadata.ts","../../src/lib/rating/criteria/scoring/total.ts","../../src/lib/rating/criteria/index.ts","../../src/lib/rating/analyzeNftCollection.ts","../../src/Plugin.ts"],"sourcesContent":["import type {\n NftCollectionInfo,\n NftCollectionMetadata,\n NftCollectionScore,\n NftCollectionScoreDivinerConfig,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport {\n isNftCollectionInfo,\n NftCollectionScoreDivinerConfigSchema,\n NftCollectionScoreSchema,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { NftCollectionAnalysis } from './lib/index.ts'\nimport { analyzeNftCollection } from './lib/index.ts'\n\nexport type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>\n\nconst toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {\n const {\n name, symbol, address, chainId, type,\n } = nftCollectionInfo\n const metadata: NftCollectionMetadata = {\n address, chainId, name, symbol, type,\n }\n return {\n ...metadata, schema: NftCollectionScoreSchema, scores,\n }\n}\n\nexport class NftCollectionScoreDiviner<\n TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, NftCollectionScoreDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = NftCollectionScoreDivinerConfigSchema\n\n protected override divineHandler = async (payloads?: Payload[]): Promise<Payload[]> => {\n const nftCollectionInfos = payloads?.filter(isNftCollectionInfo) ?? []\n const results = await Promise.all(\n nftCollectionInfos.map<Promise<NftCollectionScore>>(async (nftCollectionInfo) => {\n const [score, sourceHash] = await Promise.all([\n // Get score\n toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),\n // Hash sources\n PayloadBuilder.dataHash(nftCollectionInfo),\n ])\n return {\n ...score, schema: NftCollectionScoreSchema, sources: [sourceHash],\n } as NftCollectionScore\n }),\n )\n return results\n }\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\nexport const scoreIndividualAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n const entries = Object.entries(attributes)\n if (entries.length === 0) return [0, maxScore]\n const scores = Object.entries(attributes).flatMap(([_trait, { values }]) => {\n return Object.entries(values).map<Score>(([_traitValue, metrics]) => {\n const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore)\n return [rarity, maxScore]\n })\n })\n // eslint-disable-next-line unicorn/no-array-reduce\n const total = scores.reduce<Score>(([a, b], [c, d]) => [a + c, b + d], [0, 0])\n return normalize(total, maxScore)\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\n/**\n * Mean: What value is the distribution centered around\n */\nconst defaultMu = 0.15\n\n/**\n * Standard Deviation: How spread out is the distribution\n */\nconst defaultSigma = 0.1\n\n/**\n * Calculates the Gaussian probability density\n * @param x\n * @param mu Mean\n * @param sigma Standard Deviation\n * @returns\n */\nconst gaussianProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n const sqrtTwoPi = Math.sqrt(2 * Math.PI)\n const denominator = sigma * sqrtTwoPi\n const power = -0.5 * Math.pow((x - mu) / sigma, 2)\n return (1 / denominator) * Math.exp(power)\n}\n\n/**\n * For a Gaussian distribution, the peak of the distribution is the mean\n */\nconst maxProbabilityDensity = gaussianProbabilityDensity(defaultMu)\n\n/**\n * We're working on some assumptions here:\n *\n * - If you have a 100% chance of getting a trait, everyone get's a trophy\n * - If you have a 50% chance of getting a trait, it's not rare\n * - If you have a 0% chance of getting a trait, it's not fun\n *\n * So we're looking for something Pareto-ish (somewhere between\n * 80/20 or 90/10) as that's a good & sustainable model for the\n * distribution of many traits in real life.\n * However, we also don't want to maximally reward collections\n * that have a lot of single attributes distributed uniformly\n * (basically a 0% trait probably) as that's perfectly entropic\n * but not very interesting (some overlap is desirable).\n * So we're using a Gaussian distribution to model the\n * probability density of the joint probability of all traits\n * centered around 15%.\n * @param info\n * @returns\n */\nexport const scoreTotalAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n // This has somewhat of a filtering function by causing anything with 100% probability to\n // add no value to the end score\n const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {\n return acc * metrics.binomial.p\n }, 1)\n const probabilityDensity = gaussianProbabilityDensity(jointProbability)\n const score: Score = [probabilityDensity, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreIndividualAttributes } from './scoreIndividualAttributes.ts'\nimport { scoreTotalAttributes } from './scoreTotalAttributes.ts'\n\nexport const attributeScoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n 'Metadata Attributes Individual': { score: scoreIndividualAttributes, weight: 2 },\n 'Metadata Attributes Total': { score: scoreTotalAttributes, weight: 2 },\n}\n\nexport const scoreMetadata: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = { ...attributeScoringCriteria }\n","import type { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\n/**\n * This \"magic\" value was obtained using Solver in Excel\n * to find the median, with mu/sigma fixed, which maximizes\n * the distribution (the mode for lognormal) at 10,000\n */\nconst median = 81_030_839.821_735_2\nconst defaultMu = Math.log(median)\nconst defaultSigma = 3\nconst mode = Math.exp(defaultMu - Math.pow(defaultSigma, 2))\n/**\n * Calculates the log-normal probability density\n * @param x the value at which you want to calculate the probability density\n * @param mu mean of the associated normal distribution\n * @param sigma standard deviation of the associated normal distribution\n * @returns\n */\nconst logNormalProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n if (x <= 0) return 0\n const logX = Math.log(x)\n return (1 / (x * sigma * Math.sqrt(2 * Math.PI))) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2))\n}\n\n/**\n * For a lognormal distribution, the peak of the distribution is the mode\n */\nconst maxProbabilityDensity = logNormalProbabilityDensity(mode)\n\nconst maxScore = 10\n\n/**\n * We're working on some assumptions here:\n * - If there's < 1000 NFTs in your collection it starts becoming too niche\n * - If there's > 20,000 NFTs in your collection it starts becoming too broad\n * So there's a sweet spot somewhere between 2000 and 10,000\n * where a collection has enough NFTs to be interesting, but\n * not so many that it's teetering on a diluted money grab.\n * To model that we're using a log-normal distribution optimized\n * to maximally reward collections in the aforementioned range\n * @param nft\n * @returns\n */\nexport const scoreTotal = (nft: NftCollectionCount): Score => {\n const density = logNormalProbabilityDensity(nft.total)\n const score: Score = [density, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreMetadata, scoreTotal } from './scoring/index.ts'\n\nexport const scoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n ...scoreMetadata,\n Total: { score: scoreTotal, weight: 2 },\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoringCriteria } from './criteria/index.ts'\n\nexport type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey\n\nexport type NftCollectionAnalysis = {\n [key in ScoringCriteriaKey]: Score\n}\n\nexport const analyzeNftCollection = async (\n /**\n * The NFT to evaluate\n */\n nft: NftCollectionInfo,\n): Promise<NftCollectionAnalysis> => {\n const result = Object.fromEntries(\n await Promise.all(\n Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {\n const rawScore = await score(nft)\n const weighted = rawScore.map(v => v * weight) as Score\n return [key, weighted] as const\n }),\n ),\n ) as NftCollectionAnalysis\n return result\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { NftCollectionScoreDiviner } from './Diviner.ts'\n\nexport const NftCollectionScoreDivinerPlugin = () =>\n createPayloadSetDivinerPlugin<NftCollectionScoreDiviner>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n diviner: async (params) => {\n const result = await NftCollectionScoreDiviner.create(params)\n return result\n },\n },\n )\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;A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;AACF;;;AOzDA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAIvC,IAAM,kCAAkC,MAC7C;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,0BAA0B,OAAO,MAAM;AAC5D,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["normalize","maxScore","normalize","defaultMu","defaultSigma","maxProbabilityDensity","maxScore"]}
1
+ {"version":3,"sources":["../../src/Diviner.ts","../../src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts","../../src/lib/rating/criteria/scoring/metadata/metadata.ts","../../src/lib/rating/criteria/scoring/total.ts","../../src/lib/rating/criteria/index.ts","../../src/lib/rating/analyzeNftCollection.ts","../../src/Plugin.ts"],"sourcesContent":["import type {\n NftCollectionInfo,\n NftCollectionMetadata,\n NftCollectionScore,\n NftCollectionScoreDivinerConfig,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport {\n isNftCollectionInfo,\n NftCollectionScoreDivinerConfigSchema,\n NftCollectionScoreSchema,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerParams } from '@xyo-network/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { NftCollectionAnalysis } from './lib/index.ts'\nimport { analyzeNftCollection } from './lib/index.ts'\n\nexport type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>\n\nconst toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {\n const {\n // eslint-disable-next-line sonarjs/deprecation\n name, symbol, address, chainId, type,\n } = nftCollectionInfo\n const metadata: NftCollectionMetadata = {\n address, chainId, name, symbol, type,\n }\n return {\n ...metadata, schema: NftCollectionScoreSchema, scores,\n }\n}\n\nexport class NftCollectionScoreDiviner<\n TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, NftCollectionScoreDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = NftCollectionScoreDivinerConfigSchema\n\n protected override divineHandler = async (payloads?: Payload[]): Promise<Payload[]> => {\n const nftCollectionInfos = payloads?.filter(isNftCollectionInfo) ?? []\n const results = await Promise.all(\n nftCollectionInfos.map<Promise<NftCollectionScore>>(async (nftCollectionInfo) => {\n const [score, sourceHash] = await Promise.all([\n // Get score\n toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),\n // Hash sources\n PayloadBuilder.dataHash(nftCollectionInfo),\n ])\n return {\n ...score, schema: NftCollectionScoreSchema, sources: [sourceHash],\n } as NftCollectionScore\n }),\n )\n return results\n }\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\nexport const scoreIndividualAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n const entries = Object.entries(attributes)\n if (entries.length === 0) return [0, maxScore]\n const scores = Object.entries(attributes).flatMap(([_trait, { values }]) => {\n return Object.entries(values).map<Score>(([_traitValue, metrics]) => {\n const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore)\n return [rarity, maxScore]\n })\n })\n // eslint-disable-next-line unicorn/no-array-reduce\n const total = scores.reduce<Score>(([a, b], [c, d]) => [a + c, b + d], [0, 0])\n return normalize(total, maxScore)\n}\n","import type { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\nconst maxScore = 10\n\n/**\n * Mean: What value is the distribution centered around\n */\nconst defaultMu = 0.15\n\n/**\n * Standard Deviation: How spread out is the distribution\n */\nconst defaultSigma = 0.1\n\n/**\n * Calculates the Gaussian probability density\n * @param x\n * @param mu Mean\n * @param sigma Standard Deviation\n * @returns\n */\nconst gaussianProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n const sqrtTwoPi = Math.sqrt(2 * Math.PI)\n const denominator = sigma * sqrtTwoPi\n const power = -0.5 * Math.pow((x - mu) / sigma, 2)\n return (1 / denominator) * Math.exp(power)\n}\n\n/**\n * For a Gaussian distribution, the peak of the distribution is the mean\n */\nconst maxProbabilityDensity = gaussianProbabilityDensity(defaultMu)\n\n/**\n * We're working on some assumptions here:\n *\n * - If you have a 100% chance of getting a trait, everyone get's a trophy\n * - If you have a 50% chance of getting a trait, it's not rare\n * - If you have a 0% chance of getting a trait, it's not fun\n *\n * So we're looking for something Pareto-ish (somewhere between\n * 80/20 or 90/10) as that's a good & sustainable model for the\n * distribution of many traits in real life.\n * However, we also don't want to maximally reward collections\n * that have a lot of single attributes distributed uniformly\n * (basically a 0% trait probably) as that's perfectly entropic\n * but not very interesting (some overlap is desirable).\n * So we're using a Gaussian distribution to model the\n * probability density of the joint probability of all traits\n * centered around 15%.\n * @param info\n * @returns\n */\nexport const scoreTotalAttributes = (info: NftCollectionAttributeMetrics): Score => {\n const { attributes } = info.metrics.metadata\n // This has somewhat of a filtering function by causing anything with 100% probability to\n // add no value to the end score\n const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {\n return acc * metrics.binomial.p\n }, 1)\n const probabilityDensity = gaussianProbabilityDensity(jointProbability)\n const score: Score = [probabilityDensity, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreIndividualAttributes } from './scoreIndividualAttributes.ts'\nimport { scoreTotalAttributes } from './scoreTotalAttributes.ts'\n\nexport const attributeScoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n 'Metadata Attributes Individual': { score: scoreIndividualAttributes, weight: 2 },\n 'Metadata Attributes Total': { score: scoreTotalAttributes, weight: 2 },\n}\n\nexport const scoreMetadata: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = { ...attributeScoringCriteria }\n","import type { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\nimport { normalize } from '@xyo-network/crypto-nft-score-model'\n\n/**\n * This \"magic\" value was obtained using Solver in Excel\n * to find the median, with mu/sigma fixed, which maximizes\n * the distribution (the mode for lognormal) at 10,000\n */\nconst median = 81_030_839.821_735_2\nconst defaultMu = Math.log(median)\nconst defaultSigma = 3\nconst mode = Math.exp(defaultMu - Math.pow(defaultSigma, 2))\n/**\n * Calculates the log-normal probability density\n * @param x the value at which you want to calculate the probability density\n * @param mu mean of the associated normal distribution\n * @param sigma standard deviation of the associated normal distribution\n * @returns\n */\nconst logNormalProbabilityDensity = (x: number, mu: number = defaultMu, sigma: number = defaultSigma): number => {\n if (x <= 0) return 0\n const logX = Math.log(x)\n return (1 / (x * sigma * Math.sqrt(2 * Math.PI))) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2))\n}\n\n/**\n * For a lognormal distribution, the peak of the distribution is the mode\n */\nconst maxProbabilityDensity = logNormalProbabilityDensity(mode)\n\nconst maxScore = 10\n\n/**\n * We're working on some assumptions here:\n * - If there's < 1000 NFTs in your collection it starts becoming too niche\n * - If there's > 20,000 NFTs in your collection it starts becoming too broad\n * So there's a sweet spot somewhere between 2000 and 10,000\n * where a collection has enough NFTs to be interesting, but\n * not so many that it's teetering on a diluted money grab.\n * To model that we're using a log-normal distribution optimized\n * to maximally reward collections in the aforementioned range\n * @param nft\n * @returns\n */\nexport const scoreTotal = (nft: NftCollectionCount): Score => {\n const density = logNormalProbabilityDensity(nft.total)\n const score: Score = [density, maxProbabilityDensity]\n return normalize(score, maxScore)\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreMetadata, scoreTotal } from './scoring/index.ts'\n\nexport const scoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n ...scoreMetadata,\n Total: { score: scoreTotal, weight: 2 },\n}\n","import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport type { Score } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoringCriteria } from './criteria/index.ts'\n\nexport type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey\n\nexport type NftCollectionAnalysis = {\n [key in ScoringCriteriaKey]: Score\n}\n\nexport const analyzeNftCollection = async (\n /**\n * The NFT to evaluate\n */\n nft: NftCollectionInfo,\n): Promise<NftCollectionAnalysis> => {\n const result = Object.fromEntries(\n await Promise.all(\n Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {\n const rawScore = await score(nft)\n const weighted = rawScore.map(v => v * weight) as Score\n return [key, weighted] as const\n }),\n ),\n ) as NftCollectionAnalysis\n return result\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { NftCollectionScoreDiviner } from './Diviner.ts'\n\nexport const NftCollectionScoreDivinerPlugin = () =>\n createPayloadSetDivinerPlugin<NftCollectionScoreDiviner>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n diviner: async (params) => {\n const result = await NftCollectionScoreDiviner.create(params)\n return result\n },\n },\n )\n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AA,MACF,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;;;AO1DA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAIvC,IAAM,kCAAkC,MAC7C;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,0BAA0B,OAAO,MAAM;AAC5D,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["normalize","maxScore","normalize","defaultMu","defaultSigma","maxProbabilityDensity","maxScore"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/crypto-nft-collection-diviner-score-plugin",
3
- "version": "5.1.4",
3
+ "version": "5.2.0",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -36,25 +36,25 @@
36
36
  "!**/*.test.*"
37
37
  ],
38
38
  "dependencies": {
39
- "@xyo-network/crypto-nft-collection-payload-plugin": "~5.1.4",
40
- "@xyo-network/crypto-nft-payload-plugin": "~5.1.4",
41
- "@xyo-network/crypto-nft-score-model": "~5.1.4",
42
- "@xyo-network/diviner-abstract": "~5.1.23",
43
- "@xyo-network/diviner-model": "~5.1.23",
44
- "@xyo-network/module-model": "~5.1.23",
45
- "@xyo-network/payload-builder": "~5.1.23",
46
- "@xyo-network/payload-model": "~5.1.23",
47
- "@xyo-network/payloadset-plugin": "~5.1.23"
39
+ "@xyo-network/crypto-nft-collection-payload-plugin": "~5.2.0",
40
+ "@xyo-network/crypto-nft-payload-plugin": "~5.2.0",
41
+ "@xyo-network/crypto-nft-score-model": "~5.2.0",
42
+ "@xyo-network/diviner-abstract": "~5.2.1",
43
+ "@xyo-network/diviner-model": "~5.2.1",
44
+ "@xyo-network/module-model": "~5.2.1",
45
+ "@xyo-network/payload-builder": "~5.2.1",
46
+ "@xyo-network/payload-model": "~5.2.1",
47
+ "@xyo-network/payloadset-plugin": "~5.2.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@xylabs/ts-scripts-yarn3": "~7.2.8",
51
51
  "@xylabs/tsconfig": "~7.2.8",
52
- "@xylabs/vitest-extended": "~5.0.33",
53
- "@xyo-network/account": "~5.1.23",
54
- "@xyo-network/payload-wrapper": "~5.1.23",
52
+ "@xylabs/vitest-extended": "~5.0.39",
53
+ "@xyo-network/account": "~5.2.1",
54
+ "@xyo-network/payload-wrapper": "~5.2.1",
55
55
  "ethers": "~6.15.0",
56
- "typescript": "~5.9.2",
57
- "vitest": "~3.2.4"
56
+ "typescript": "~5.9.3",
57
+ "vitest": "~4.0.10"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
package/src/Diviner.ts CHANGED
@@ -22,6 +22,7 @@ export type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftC
22
22
 
23
23
  const toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {
24
24
  const {
25
+ // eslint-disable-next-line sonarjs/deprecation
25
26
  name, symbol, address, chainId, type,
26
27
  } = nftCollectionInfo
27
28
  const metadata: NftCollectionMetadata = {