@xyo-network/crypto-nft-collection-diviner-score-plugin 2.75.15 → 2.75.16
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.
- package/dist/docs.json +12 -12
- package/package.json +15 -15
- package/dist/browser/Diviner.cjs +0 -143
- package/dist/browser/Diviner.cjs.map +0 -1
- package/dist/browser/Diviner.js +0 -126
- package/dist/browser/Diviner.js.map +0 -1
- package/dist/browser/Plugin.cjs +0 -159
- package/dist/browser/Plugin.cjs.map +0 -1
- package/dist/browser/Plugin.js +0 -142
- package/dist/browser/Plugin.js.map +0 -1
- package/dist/browser/lib/index.cjs +0 -115
- package/dist/browser/lib/index.cjs.map +0 -1
- package/dist/browser/lib/index.js +0 -92
- package/dist/browser/lib/index.js.map +0 -1
- package/dist/browser/lib/rating/analyzeNftCollection.cjs +0 -115
- package/dist/browser/lib/rating/analyzeNftCollection.cjs.map +0 -1
- package/dist/browser/lib/rating/analyzeNftCollection.js +0 -92
- package/dist/browser/lib/rating/analyzeNftCollection.js.map +0 -1
- package/dist/browser/lib/rating/criteria/index.cjs +0 -101
- package/dist/browser/lib/rating/criteria/index.cjs.map +0 -1
- package/dist/browser/lib/rating/criteria/index.js +0 -78
- package/dist/browser/lib/rating/criteria/index.js.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/index.cjs +0 -97
- package/dist/browser/lib/rating/criteria/scoring/index.cjs.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/index.js +0 -74
- package/dist/browser/lib/rating/criteria/scoring/index.js.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.cjs +0 -76
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.cjs.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.js +0 -53
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.js.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/metadata.cjs +0 -76
- package/dist/browser/lib/rating/criteria/scoring/metadata/metadata.cjs.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/metadata.js +0 -53
- package/dist/browser/lib/rating/criteria/scoring/metadata/metadata.js.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.cjs +0 -42
- package/dist/browser/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.cjs.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.js +0 -21
- package/dist/browser/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.js.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.cjs +0 -46
- package/dist/browser/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.cjs.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.js +0 -25
- package/dist/browser/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.js.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/total.cjs +0 -44
- package/dist/browser/lib/rating/criteria/scoring/total.cjs.map +0 -1
- package/dist/browser/lib/rating/criteria/scoring/total.js +0 -23
- package/dist/browser/lib/rating/criteria/scoring/total.js.map +0 -1
- package/dist/browser/lib/rating/index.cjs +0 -115
- package/dist/browser/lib/rating/index.cjs.map +0 -1
- package/dist/browser/lib/rating/index.js +0 -92
- package/dist/browser/lib/rating/index.js.map +0 -1
- package/dist/node/Diviner.js +0 -147
- package/dist/node/Diviner.js.map +0 -1
- package/dist/node/Diviner.mjs +0 -126
- package/dist/node/Diviner.mjs.map +0 -1
- package/dist/node/Plugin.js +0 -163
- package/dist/node/Plugin.js.map +0 -1
- package/dist/node/Plugin.mjs +0 -142
- package/dist/node/Plugin.mjs.map +0 -1
- package/dist/node/lib/index.js +0 -119
- package/dist/node/lib/index.js.map +0 -1
- package/dist/node/lib/index.mjs +0 -92
- package/dist/node/lib/index.mjs.map +0 -1
- package/dist/node/lib/rating/analyzeNftCollection.js +0 -119
- package/dist/node/lib/rating/analyzeNftCollection.js.map +0 -1
- package/dist/node/lib/rating/analyzeNftCollection.mjs +0 -92
- package/dist/node/lib/rating/analyzeNftCollection.mjs.map +0 -1
- package/dist/node/lib/rating/criteria/index.js +0 -105
- package/dist/node/lib/rating/criteria/index.js.map +0 -1
- package/dist/node/lib/rating/criteria/index.mjs +0 -78
- package/dist/node/lib/rating/criteria/index.mjs.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/index.js +0 -103
- package/dist/node/lib/rating/criteria/scoring/index.js.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/index.mjs +0 -74
- package/dist/node/lib/rating/criteria/scoring/index.mjs.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/index.js +0 -81
- package/dist/node/lib/rating/criteria/scoring/metadata/index.js.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/index.mjs +0 -53
- package/dist/node/lib/rating/criteria/scoring/metadata/index.mjs.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/metadata.js +0 -81
- package/dist/node/lib/rating/criteria/scoring/metadata/metadata.js.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/metadata.mjs +0 -53
- package/dist/node/lib/rating/criteria/scoring/metadata/metadata.mjs.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.js +0 -46
- package/dist/node/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.js.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.mjs +0 -21
- package/dist/node/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.mjs.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.js +0 -50
- package/dist/node/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.js.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.mjs +0 -25
- package/dist/node/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.mjs.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/total.js +0 -48
- package/dist/node/lib/rating/criteria/scoring/total.js.map +0 -1
- package/dist/node/lib/rating/criteria/scoring/total.mjs +0 -23
- package/dist/node/lib/rating/criteria/scoring/total.mjs.map +0 -1
- package/dist/node/lib/rating/index.js +0 -119
- package/dist/node/lib/rating/index.js.map +0 -1
- package/dist/node/lib/rating/index.mjs +0 -92
- package/dist/node/lib/rating/index.mjs.map +0 -1
package/dist/docs.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/index.ts",
|
|
17
17
|
"line": 9,
|
|
18
18
|
"character": 0,
|
|
19
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
19
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/index.ts#L9"
|
|
20
20
|
}
|
|
21
21
|
],
|
|
22
22
|
"target": 1
|
|
@@ -4268,7 +4268,7 @@
|
|
|
4268
4268
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts",
|
|
4269
4269
|
"line": 29,
|
|
4270
4270
|
"character": 18,
|
|
4271
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
4271
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts#L29"
|
|
4272
4272
|
}
|
|
4273
4273
|
],
|
|
4274
4274
|
"type": {
|
|
@@ -7920,7 +7920,7 @@
|
|
|
7920
7920
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts",
|
|
7921
7921
|
"line": 31,
|
|
7922
7922
|
"character": 21,
|
|
7923
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
7923
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts#L31"
|
|
7924
7924
|
}
|
|
7925
7925
|
],
|
|
7926
7926
|
"signatures": [
|
|
@@ -7935,7 +7935,7 @@
|
|
|
7935
7935
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts",
|
|
7936
7936
|
"line": 31,
|
|
7937
7937
|
"character": 37,
|
|
7938
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
7938
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts#L31"
|
|
7939
7939
|
}
|
|
7940
7940
|
],
|
|
7941
7941
|
"parameters": [
|
|
@@ -17629,7 +17629,7 @@
|
|
|
17629
17629
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts",
|
|
17630
17630
|
"line": 26,
|
|
17631
17631
|
"character": 13,
|
|
17632
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
17632
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts#L26"
|
|
17633
17633
|
}
|
|
17634
17634
|
],
|
|
17635
17635
|
"typeParameters": [
|
|
@@ -17684,7 +17684,7 @@
|
|
|
17684
17684
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/lib/rating/analyzeNftCollection.ts",
|
|
17685
17685
|
"line": 8,
|
|
17686
17686
|
"character": 12,
|
|
17687
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
17687
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/lib/rating/analyzeNftCollection.ts#L8"
|
|
17688
17688
|
}
|
|
17689
17689
|
],
|
|
17690
17690
|
"type": {
|
|
@@ -17718,7 +17718,7 @@
|
|
|
17718
17718
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts",
|
|
17719
17719
|
"line": 18,
|
|
17720
17720
|
"character": 12,
|
|
17721
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
17721
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Diviner.ts#L18"
|
|
17722
17722
|
}
|
|
17723
17723
|
],
|
|
17724
17724
|
"type": {
|
|
@@ -17764,7 +17764,7 @@
|
|
|
17764
17764
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/lib/rating/analyzeNftCollection.ts",
|
|
17765
17765
|
"line": 6,
|
|
17766
17766
|
"character": 12,
|
|
17767
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
17767
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/lib/rating/analyzeNftCollection.ts#L6"
|
|
17768
17768
|
}
|
|
17769
17769
|
],
|
|
17770
17770
|
"type": {
|
|
@@ -17809,7 +17809,7 @@
|
|
|
17809
17809
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Plugin.ts",
|
|
17810
17810
|
"line": 7,
|
|
17811
17811
|
"character": 13,
|
|
17812
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
17812
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Plugin.ts#L7"
|
|
17813
17813
|
}
|
|
17814
17814
|
],
|
|
17815
17815
|
"signatures": [
|
|
@@ -17824,7 +17824,7 @@
|
|
|
17824
17824
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Plugin.ts",
|
|
17825
17825
|
"line": 7,
|
|
17826
17826
|
"character": 47,
|
|
17827
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
17827
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/Plugin.ts#L7"
|
|
17828
17828
|
}
|
|
17829
17829
|
],
|
|
17830
17830
|
"type": {
|
|
@@ -19550,7 +19550,7 @@
|
|
|
19550
19550
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/lib/rating/analyzeNftCollection.ts",
|
|
19551
19551
|
"line": 12,
|
|
19552
19552
|
"character": 13,
|
|
19553
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
19553
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/lib/rating/analyzeNftCollection.ts#L12"
|
|
19554
19554
|
}
|
|
19555
19555
|
],
|
|
19556
19556
|
"signatures": [
|
|
@@ -19565,7 +19565,7 @@
|
|
|
19565
19565
|
"fileName": "plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/lib/rating/analyzeNftCollection.ts",
|
|
19566
19566
|
"line": 12,
|
|
19567
19567
|
"character": 36,
|
|
19568
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
19568
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/b1d6f519bacda/packages/plugins/packages/payloadset/packages/crypto/packages/nft/packages/collection/diviner/src/lib/rating/analyzeNftCollection.ts#L12"
|
|
19569
19569
|
}
|
|
19570
19570
|
],
|
|
19571
19571
|
"parameters": [
|
package/package.json
CHANGED
|
@@ -10,22 +10,22 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xyo-network/abstract-diviner": "~2.75.
|
|
14
|
-
"@xyo-network/core": "~2.75.
|
|
15
|
-
"@xyo-network/crypto-nft-collection-payload-plugin": "~2.75.
|
|
16
|
-
"@xyo-network/crypto-nft-payload-plugin": "~2.75.
|
|
17
|
-
"@xyo-network/crypto-nft-score-model": "~2.75.
|
|
18
|
-
"@xyo-network/diviner-model": "~2.75.
|
|
19
|
-
"@xyo-network/module-model": "~2.75.
|
|
20
|
-
"@xyo-network/payload-model": "~2.75.
|
|
21
|
-
"@xyo-network/payloadset-plugin": "~2.75.
|
|
13
|
+
"@xyo-network/abstract-diviner": "~2.75.16",
|
|
14
|
+
"@xyo-network/core": "~2.75.16",
|
|
15
|
+
"@xyo-network/crypto-nft-collection-payload-plugin": "~2.75.16",
|
|
16
|
+
"@xyo-network/crypto-nft-payload-plugin": "~2.75.16",
|
|
17
|
+
"@xyo-network/crypto-nft-score-model": "~2.75.16",
|
|
18
|
+
"@xyo-network/diviner-model": "~2.75.16",
|
|
19
|
+
"@xyo-network/module-model": "~2.75.16",
|
|
20
|
+
"@xyo-network/payload-model": "~2.75.16",
|
|
21
|
+
"@xyo-network/payloadset-plugin": "~2.75.16"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@xylabs/jest-helpers": "^2.12.
|
|
25
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
26
|
-
"@xylabs/tsconfig": "^3.
|
|
27
|
-
"@xyo-network/account": "~2.75.
|
|
28
|
-
"@xyo-network/payload-wrapper": "~2.75.
|
|
24
|
+
"@xylabs/jest-helpers": "^2.12.23",
|
|
25
|
+
"@xylabs/ts-scripts-yarn3": "^3.1.3",
|
|
26
|
+
"@xylabs/tsconfig": "^3.1.3",
|
|
27
|
+
"@xyo-network/account": "~2.75.16",
|
|
28
|
+
"@xyo-network/payload-wrapper": "~2.75.16",
|
|
29
29
|
"ethers": "^5.7.2",
|
|
30
30
|
"jest": "^29.7.0",
|
|
31
31
|
"typescript": "^5.2.2"
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
76
|
-
"version": "2.75.
|
|
76
|
+
"version": "2.75.16"
|
|
77
77
|
}
|
package/dist/browser/Diviner.cjs
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/Diviner.ts
|
|
21
|
-
var Diviner_exports = {};
|
|
22
|
-
__export(Diviner_exports, {
|
|
23
|
-
NftCollectionScoreDiviner: () => NftCollectionScoreDiviner
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(Diviner_exports);
|
|
26
|
-
var import_abstract_diviner = require("@xyo-network/abstract-diviner");
|
|
27
|
-
var import_core = require("@xyo-network/core");
|
|
28
|
-
var import_crypto_nft_collection_payload_plugin = require("@xyo-network/crypto-nft-collection-payload-plugin");
|
|
29
|
-
|
|
30
|
-
// src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts
|
|
31
|
-
var import_crypto_nft_score_model = require("@xyo-network/crypto-nft-score-model");
|
|
32
|
-
var maxScore = 10;
|
|
33
|
-
var scoreIndividualAttributes = (info) => {
|
|
34
|
-
const { attributes } = info.metrics.metadata;
|
|
35
|
-
const entries = Object.entries(attributes);
|
|
36
|
-
if (entries.length === 0)
|
|
37
|
-
return [0, maxScore];
|
|
38
|
-
const scores = Object.entries(attributes).map(([_trait, { values }]) => {
|
|
39
|
-
return Object.entries(values).map(([_traitValue, metrics]) => {
|
|
40
|
-
const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore);
|
|
41
|
-
return [rarity, maxScore];
|
|
42
|
-
});
|
|
43
|
-
}).flat();
|
|
44
|
-
const total = scores.reduce(([a, b], [c, d]) => [a + c, b + d], [0, 0]);
|
|
45
|
-
return (0, import_crypto_nft_score_model.normalize)(total, maxScore);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts
|
|
49
|
-
var import_crypto_nft_score_model2 = require("@xyo-network/crypto-nft-score-model");
|
|
50
|
-
var maxScore2 = 10;
|
|
51
|
-
var defaultMu = 0.15;
|
|
52
|
-
var defaultSigma = 0.1;
|
|
53
|
-
var gaussianProbabilityDensity = (x, mu = defaultMu, sigma = defaultSigma) => {
|
|
54
|
-
const sqrtTwoPi = Math.sqrt(2 * Math.PI);
|
|
55
|
-
const denominator = sigma * sqrtTwoPi;
|
|
56
|
-
const power = -0.5 * Math.pow((x - mu) / sigma, 2);
|
|
57
|
-
return 1 / denominator * Math.exp(power);
|
|
58
|
-
};
|
|
59
|
-
var maxProbabilityDensity = gaussianProbabilityDensity(defaultMu);
|
|
60
|
-
var scoreTotalAttributes = (info) => {
|
|
61
|
-
const { attributes } = info.metrics.metadata;
|
|
62
|
-
const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {
|
|
63
|
-
return acc * metrics.binomial.p;
|
|
64
|
-
}, 1);
|
|
65
|
-
const probabilityDensity = gaussianProbabilityDensity(jointProbability);
|
|
66
|
-
const score = [probabilityDensity, maxProbabilityDensity];
|
|
67
|
-
return (0, import_crypto_nft_score_model2.normalize)(score, maxScore2);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// src/lib/rating/criteria/scoring/metadata/metadata.ts
|
|
71
|
-
var attributeScoringCriteria = {
|
|
72
|
-
"Metadata Attributes Individual": { score: scoreIndividualAttributes, weight: 2 },
|
|
73
|
-
"Metadata Attributes Total": { score: scoreTotalAttributes, weight: 2 }
|
|
74
|
-
};
|
|
75
|
-
var scoreMetadata = {
|
|
76
|
-
...attributeScoringCriteria
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// src/lib/rating/criteria/scoring/total.ts
|
|
80
|
-
var import_crypto_nft_score_model3 = require("@xyo-network/crypto-nft-score-model");
|
|
81
|
-
var median = 810308398217352e-7;
|
|
82
|
-
var defaultMu2 = Math.log(median);
|
|
83
|
-
var defaultSigma2 = 3;
|
|
84
|
-
var mode = Math.exp(defaultMu2 - Math.pow(defaultSigma2, 2));
|
|
85
|
-
var logNormalProbabilityDensity = (x, mu = defaultMu2, sigma = defaultSigma2) => {
|
|
86
|
-
if (x <= 0)
|
|
87
|
-
return 0;
|
|
88
|
-
const logX = Math.log(x);
|
|
89
|
-
return 1 / (x * sigma * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2));
|
|
90
|
-
};
|
|
91
|
-
var maxProbabilityDensity2 = logNormalProbabilityDensity(mode);
|
|
92
|
-
var maxScore3 = 10;
|
|
93
|
-
var scoreTotal = (nft) => {
|
|
94
|
-
const density = logNormalProbabilityDensity(nft.total);
|
|
95
|
-
const score = [density, maxProbabilityDensity2];
|
|
96
|
-
return (0, import_crypto_nft_score_model3.normalize)(score, maxScore3);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// src/lib/rating/criteria/index.ts
|
|
100
|
-
var scoringCriteria = {
|
|
101
|
-
...scoreMetadata,
|
|
102
|
-
Total: { score: scoreTotal, weight: 2 }
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// src/lib/rating/analyzeNftCollection.ts
|
|
106
|
-
var analyzeNftCollection = async (nft) => {
|
|
107
|
-
const result = Object.fromEntries(
|
|
108
|
-
await Promise.all(
|
|
109
|
-
Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {
|
|
110
|
-
const rawScore = await score(nft);
|
|
111
|
-
const weighted = rawScore.map((v) => v * weight);
|
|
112
|
-
return [key, weighted];
|
|
113
|
-
})
|
|
114
|
-
)
|
|
115
|
-
);
|
|
116
|
-
return result;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
// src/Diviner.ts
|
|
120
|
-
var toNftCollectionScore = (nftCollectionInfo, scores) => {
|
|
121
|
-
const { name, symbol, address, chainId, type } = nftCollectionInfo;
|
|
122
|
-
const metadata = { address, chainId, name, symbol, type };
|
|
123
|
-
return { ...metadata, schema: import_crypto_nft_collection_payload_plugin.NftCollectionScoreSchema, scores };
|
|
124
|
-
};
|
|
125
|
-
var NftCollectionScoreDiviner = class extends import_abstract_diviner.AbstractDiviner {
|
|
126
|
-
static configSchemas = [import_crypto_nft_collection_payload_plugin.NftCollectionScoreDivinerConfigSchema];
|
|
127
|
-
divineHandler = async (payloads) => {
|
|
128
|
-
const nftCollectionInfos = payloads?.filter(import_crypto_nft_collection_payload_plugin.isNftCollectionInfo) ?? [];
|
|
129
|
-
const results = await Promise.all(
|
|
130
|
-
nftCollectionInfos.map(async (nftCollectionInfo) => {
|
|
131
|
-
const [score, sourceHash] = await Promise.all([
|
|
132
|
-
// Get score
|
|
133
|
-
toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),
|
|
134
|
-
// Hash sources
|
|
135
|
-
import_core.PayloadHasher.hashAsync(nftCollectionInfo)
|
|
136
|
-
]);
|
|
137
|
-
return { ...score, schema: import_crypto_nft_collection_payload_plugin.NftCollectionScoreSchema, sources: [sourceHash] };
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
return results;
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
//# sourceMappingURL=Diviner.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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"],"sourcesContent":["import { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { PayloadHasher } from '@xyo-network/core'\nimport {\n isNftCollectionInfo,\n NftCollectionInfo,\n NftCollectionMetadata,\n NftCollectionScore,\n NftCollectionScoreDivinerConfig,\n NftCollectionScoreDivinerConfigSchema,\n NftCollectionScoreSchema,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { analyzeNftCollection, NftCollectionAnalysis } from './lib'\n\nexport type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>\n\nconst toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {\n const { name, symbol, address, chainId, type } = nftCollectionInfo\n const metadata: NftCollectionMetadata = { address, chainId, name, symbol, type }\n return { ...metadata, schema: NftCollectionScoreSchema, scores }\n}\n\nexport class NftCollectionScoreDiviner<\n TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override configSchemas = [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 PayloadHasher.hashAsync(nftCollectionInfo),\n ])\n return { ...score, schema: NftCollectionScoreSchema, sources: [sourceHash] } as NftCollectionScore\n }),\n )\n return results\n }\n}\n","import { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { normalize, Score } 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)\n .map(([_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 .flat()\n const total = scores.reduce<Score>(([a, b], [c, d]) => [a + c, b + d], [0, 0])\n return normalize(total, maxScore)\n}\n","import { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { normalize, Score } 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 { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreIndividualAttributes } from './scoreIndividualAttributes'\nimport { scoreTotalAttributes } from './scoreTotalAttributes'\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> } = {\n ...attributeScoringCriteria,\n}\n","import { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { normalize, Score } 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 = 81030839.8217352\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 { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreMetadata, scoreTotal } from './scoring'\n\nexport const scoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n ...scoreMetadata,\n Total: { score: scoreTotal, weight: 2 },\n}\n","import { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { Score } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoringCriteria } from './criteria'\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAgC;AAChC,kBAA8B;AAC9B,kDAQO;;;ACTP,oCAAiC;AAEjC,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;AAAG,WAAO,CAAC,GAAG,QAAQ;AAC7C,QAAM,SAAS,OAAO,QAAQ,UAAU,EACrC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM;AAC7B,WAAO,OAAO,QAAQ,MAAM,EAAE,IAAW,CAAC,CAAC,aAAa,OAAO,MAAM;AACnE,YAAM,SAAS,KAAK,IAAI,KAAK,OAAO,IAAI,QAAQ,SAAS,KAAK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,UAAU,QAAQ,sEAA0B,OAAO;AACjE;AAEO,IAAM,4BAAN,cAEG,wCAAyB;AAAA,EACjC,OAAgB,gBAAgB,CAAC,iFAAqC;AAAA,EAEnD,gBAAgB,OAAO,aAA6C;AACrF,UAAM,qBAAqB,UAAU,OAAO,+DAAmB,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,0BAAc,UAAU,iBAAiB;AAAA,QAC3C,CAAC;AACD,eAAO,EAAE,GAAG,OAAO,QAAQ,sEAA0B,SAAS,CAAC,UAAU,EAAE;AAAA,MAC7E,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;","names":["import_crypto_nft_score_model","maxScore","import_crypto_nft_score_model","defaultMu","defaultSigma","maxProbabilityDensity","maxScore"]}
|
package/dist/browser/Diviner.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// src/Diviner.ts
|
|
2
|
-
import { AbstractDiviner } from "@xyo-network/abstract-diviner";
|
|
3
|
-
import { PayloadHasher } from "@xyo-network/core";
|
|
4
|
-
import {
|
|
5
|
-
isNftCollectionInfo,
|
|
6
|
-
NftCollectionScoreDivinerConfigSchema,
|
|
7
|
-
NftCollectionScoreSchema
|
|
8
|
-
} from "@xyo-network/crypto-nft-collection-payload-plugin";
|
|
9
|
-
|
|
10
|
-
// src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts
|
|
11
|
-
import { normalize } from "@xyo-network/crypto-nft-score-model";
|
|
12
|
-
var maxScore = 10;
|
|
13
|
-
var scoreIndividualAttributes = (info) => {
|
|
14
|
-
const { attributes } = info.metrics.metadata;
|
|
15
|
-
const entries = Object.entries(attributes);
|
|
16
|
-
if (entries.length === 0)
|
|
17
|
-
return [0, maxScore];
|
|
18
|
-
const scores = Object.entries(attributes).map(([_trait, { values }]) => {
|
|
19
|
-
return Object.entries(values).map(([_traitValue, metrics]) => {
|
|
20
|
-
const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore);
|
|
21
|
-
return [rarity, maxScore];
|
|
22
|
-
});
|
|
23
|
-
}).flat();
|
|
24
|
-
const total = scores.reduce(([a, b], [c, d]) => [a + c, b + d], [0, 0]);
|
|
25
|
-
return normalize(total, maxScore);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts
|
|
29
|
-
import { normalize as normalize2 } from "@xyo-network/crypto-nft-score-model";
|
|
30
|
-
var maxScore2 = 10;
|
|
31
|
-
var defaultMu = 0.15;
|
|
32
|
-
var defaultSigma = 0.1;
|
|
33
|
-
var gaussianProbabilityDensity = (x, mu = defaultMu, sigma = defaultSigma) => {
|
|
34
|
-
const sqrtTwoPi = Math.sqrt(2 * Math.PI);
|
|
35
|
-
const denominator = sigma * sqrtTwoPi;
|
|
36
|
-
const power = -0.5 * Math.pow((x - mu) / sigma, 2);
|
|
37
|
-
return 1 / denominator * Math.exp(power);
|
|
38
|
-
};
|
|
39
|
-
var maxProbabilityDensity = gaussianProbabilityDensity(defaultMu);
|
|
40
|
-
var scoreTotalAttributes = (info) => {
|
|
41
|
-
const { attributes } = info.metrics.metadata;
|
|
42
|
-
const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {
|
|
43
|
-
return acc * metrics.binomial.p;
|
|
44
|
-
}, 1);
|
|
45
|
-
const probabilityDensity = gaussianProbabilityDensity(jointProbability);
|
|
46
|
-
const score = [probabilityDensity, maxProbabilityDensity];
|
|
47
|
-
return normalize2(score, maxScore2);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// src/lib/rating/criteria/scoring/metadata/metadata.ts
|
|
51
|
-
var attributeScoringCriteria = {
|
|
52
|
-
"Metadata Attributes Individual": { score: scoreIndividualAttributes, weight: 2 },
|
|
53
|
-
"Metadata Attributes Total": { score: scoreTotalAttributes, weight: 2 }
|
|
54
|
-
};
|
|
55
|
-
var scoreMetadata = {
|
|
56
|
-
...attributeScoringCriteria
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// src/lib/rating/criteria/scoring/total.ts
|
|
60
|
-
import { normalize as normalize3 } from "@xyo-network/crypto-nft-score-model";
|
|
61
|
-
var median = 810308398217352e-7;
|
|
62
|
-
var defaultMu2 = Math.log(median);
|
|
63
|
-
var defaultSigma2 = 3;
|
|
64
|
-
var mode = Math.exp(defaultMu2 - Math.pow(defaultSigma2, 2));
|
|
65
|
-
var logNormalProbabilityDensity = (x, mu = defaultMu2, sigma = defaultSigma2) => {
|
|
66
|
-
if (x <= 0)
|
|
67
|
-
return 0;
|
|
68
|
-
const logX = Math.log(x);
|
|
69
|
-
return 1 / (x * sigma * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2));
|
|
70
|
-
};
|
|
71
|
-
var maxProbabilityDensity2 = logNormalProbabilityDensity(mode);
|
|
72
|
-
var maxScore3 = 10;
|
|
73
|
-
var scoreTotal = (nft) => {
|
|
74
|
-
const density = logNormalProbabilityDensity(nft.total);
|
|
75
|
-
const score = [density, maxProbabilityDensity2];
|
|
76
|
-
return normalize3(score, maxScore3);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// src/lib/rating/criteria/index.ts
|
|
80
|
-
var scoringCriteria = {
|
|
81
|
-
...scoreMetadata,
|
|
82
|
-
Total: { score: scoreTotal, weight: 2 }
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// src/lib/rating/analyzeNftCollection.ts
|
|
86
|
-
var analyzeNftCollection = async (nft) => {
|
|
87
|
-
const result = Object.fromEntries(
|
|
88
|
-
await Promise.all(
|
|
89
|
-
Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {
|
|
90
|
-
const rawScore = await score(nft);
|
|
91
|
-
const weighted = rawScore.map((v) => v * weight);
|
|
92
|
-
return [key, weighted];
|
|
93
|
-
})
|
|
94
|
-
)
|
|
95
|
-
);
|
|
96
|
-
return result;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// src/Diviner.ts
|
|
100
|
-
var toNftCollectionScore = (nftCollectionInfo, scores) => {
|
|
101
|
-
const { name, symbol, address, chainId, type } = nftCollectionInfo;
|
|
102
|
-
const metadata = { address, chainId, name, symbol, type };
|
|
103
|
-
return { ...metadata, schema: NftCollectionScoreSchema, scores };
|
|
104
|
-
};
|
|
105
|
-
var NftCollectionScoreDiviner = class extends AbstractDiviner {
|
|
106
|
-
static configSchemas = [NftCollectionScoreDivinerConfigSchema];
|
|
107
|
-
divineHandler = async (payloads) => {
|
|
108
|
-
const nftCollectionInfos = payloads?.filter(isNftCollectionInfo) ?? [];
|
|
109
|
-
const results = await Promise.all(
|
|
110
|
-
nftCollectionInfos.map(async (nftCollectionInfo) => {
|
|
111
|
-
const [score, sourceHash] = await Promise.all([
|
|
112
|
-
// Get score
|
|
113
|
-
toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),
|
|
114
|
-
// Hash sources
|
|
115
|
-
PayloadHasher.hashAsync(nftCollectionInfo)
|
|
116
|
-
]);
|
|
117
|
-
return { ...score, schema: NftCollectionScoreSchema, sources: [sourceHash] };
|
|
118
|
-
})
|
|
119
|
-
);
|
|
120
|
-
return results;
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
export {
|
|
124
|
-
NftCollectionScoreDiviner
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=Diviner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"],"sourcesContent":["import { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { PayloadHasher } from '@xyo-network/core'\nimport {\n isNftCollectionInfo,\n NftCollectionInfo,\n NftCollectionMetadata,\n NftCollectionScore,\n NftCollectionScoreDivinerConfig,\n NftCollectionScoreDivinerConfigSchema,\n NftCollectionScoreSchema,\n} from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { DivinerParams } from '@xyo-network/diviner-model'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { analyzeNftCollection, NftCollectionAnalysis } from './lib'\n\nexport type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>\n\nconst toNftCollectionScore = (nftCollectionInfo: NftCollectionInfo, scores: NftCollectionAnalysis): NftCollectionScore => {\n const { name, symbol, address, chainId, type } = nftCollectionInfo\n const metadata: NftCollectionMetadata = { address, chainId, name, symbol, type }\n return { ...metadata, schema: NftCollectionScoreSchema, scores }\n}\n\nexport class NftCollectionScoreDiviner<\n TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override configSchemas = [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 PayloadHasher.hashAsync(nftCollectionInfo),\n ])\n return { ...score, schema: NftCollectionScoreSchema, sources: [sourceHash] } as NftCollectionScore\n }),\n )\n return results\n }\n}\n","import { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { normalize, Score } 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)\n .map(([_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 .flat()\n const total = scores.reduce<Score>(([a, b], [c, d]) => [a + c, b + d], [0, 0])\n return normalize(total, maxScore)\n}\n","import { NftCollectionAttributeMetrics } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { normalize, Score } 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 { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreIndividualAttributes } from './scoreIndividualAttributes'\nimport { scoreTotalAttributes } from './scoreTotalAttributes'\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> } = {\n ...attributeScoringCriteria,\n}\n","import { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { normalize, Score } 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 = 81030839.8217352\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 { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { WeightedScoringCriteria } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoreMetadata, scoreTotal } from './scoring'\n\nexport const scoringCriteria: { [key: string]: WeightedScoringCriteria<NftCollectionInfo> } = {\n ...scoreMetadata,\n Total: { score: scoreTotal, weight: 2 },\n}\n","import { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'\nimport { Score } from '@xyo-network/crypto-nft-score-model'\n\nimport { scoringCriteria } from './criteria'\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 NftCollectionAnal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
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/Plugin.ts
|
|
21
|
-
var Plugin_exports = {};
|
|
22
|
-
__export(Plugin_exports, {
|
|
23
|
-
NftCollectionScoreDivinerPlugin: () => NftCollectionScoreDivinerPlugin
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(Plugin_exports);
|
|
26
|
-
var import_crypto_nft_payload_plugin = require("@xyo-network/crypto-nft-payload-plugin");
|
|
27
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
|
28
|
-
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
29
|
-
|
|
30
|
-
// src/Diviner.ts
|
|
31
|
-
var import_abstract_diviner = require("@xyo-network/abstract-diviner");
|
|
32
|
-
var import_core = require("@xyo-network/core");
|
|
33
|
-
var import_crypto_nft_collection_payload_plugin = require("@xyo-network/crypto-nft-collection-payload-plugin");
|
|
34
|
-
|
|
35
|
-
// src/lib/rating/criteria/scoring/metadata/scoreIndividualAttributes.ts
|
|
36
|
-
var import_crypto_nft_score_model = require("@xyo-network/crypto-nft-score-model");
|
|
37
|
-
var maxScore = 10;
|
|
38
|
-
var scoreIndividualAttributes = (info) => {
|
|
39
|
-
const { attributes } = info.metrics.metadata;
|
|
40
|
-
const entries = Object.entries(attributes);
|
|
41
|
-
if (entries.length === 0)
|
|
42
|
-
return [0, maxScore];
|
|
43
|
-
const scores = Object.entries(attributes).map(([_trait, { values }]) => {
|
|
44
|
-
return Object.entries(values).map(([_traitValue, metrics]) => {
|
|
45
|
-
const rarity = Math.min(Math.round((1 - metrics.binomial.p) * maxScore), maxScore);
|
|
46
|
-
return [rarity, maxScore];
|
|
47
|
-
});
|
|
48
|
-
}).flat();
|
|
49
|
-
const total = scores.reduce(([a, b], [c, d]) => [a + c, b + d], [0, 0]);
|
|
50
|
-
return (0, import_crypto_nft_score_model.normalize)(total, maxScore);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// src/lib/rating/criteria/scoring/metadata/scoreTotalAttributes.ts
|
|
54
|
-
var import_crypto_nft_score_model2 = require("@xyo-network/crypto-nft-score-model");
|
|
55
|
-
var maxScore2 = 10;
|
|
56
|
-
var defaultMu = 0.15;
|
|
57
|
-
var defaultSigma = 0.1;
|
|
58
|
-
var gaussianProbabilityDensity = (x, mu = defaultMu, sigma = defaultSigma) => {
|
|
59
|
-
const sqrtTwoPi = Math.sqrt(2 * Math.PI);
|
|
60
|
-
const denominator = sigma * sqrtTwoPi;
|
|
61
|
-
const power = -0.5 * Math.pow((x - mu) / sigma, 2);
|
|
62
|
-
return 1 / denominator * Math.exp(power);
|
|
63
|
-
};
|
|
64
|
-
var maxProbabilityDensity = gaussianProbabilityDensity(defaultMu);
|
|
65
|
-
var scoreTotalAttributes = (info) => {
|
|
66
|
-
const { attributes } = info.metrics.metadata;
|
|
67
|
-
const jointProbability = Object.entries(attributes).reduce((acc, [_trait, { metrics }]) => {
|
|
68
|
-
return acc * metrics.binomial.p;
|
|
69
|
-
}, 1);
|
|
70
|
-
const probabilityDensity = gaussianProbabilityDensity(jointProbability);
|
|
71
|
-
const score = [probabilityDensity, maxProbabilityDensity];
|
|
72
|
-
return (0, import_crypto_nft_score_model2.normalize)(score, maxScore2);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// src/lib/rating/criteria/scoring/metadata/metadata.ts
|
|
76
|
-
var attributeScoringCriteria = {
|
|
77
|
-
"Metadata Attributes Individual": { score: scoreIndividualAttributes, weight: 2 },
|
|
78
|
-
"Metadata Attributes Total": { score: scoreTotalAttributes, weight: 2 }
|
|
79
|
-
};
|
|
80
|
-
var scoreMetadata = {
|
|
81
|
-
...attributeScoringCriteria
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// src/lib/rating/criteria/scoring/total.ts
|
|
85
|
-
var import_crypto_nft_score_model3 = require("@xyo-network/crypto-nft-score-model");
|
|
86
|
-
var median = 810308398217352e-7;
|
|
87
|
-
var defaultMu2 = Math.log(median);
|
|
88
|
-
var defaultSigma2 = 3;
|
|
89
|
-
var mode = Math.exp(defaultMu2 - Math.pow(defaultSigma2, 2));
|
|
90
|
-
var logNormalProbabilityDensity = (x, mu = defaultMu2, sigma = defaultSigma2) => {
|
|
91
|
-
if (x <= 0)
|
|
92
|
-
return 0;
|
|
93
|
-
const logX = Math.log(x);
|
|
94
|
-
return 1 / (x * sigma * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((logX - mu) / sigma, 2));
|
|
95
|
-
};
|
|
96
|
-
var maxProbabilityDensity2 = logNormalProbabilityDensity(mode);
|
|
97
|
-
var maxScore3 = 10;
|
|
98
|
-
var scoreTotal = (nft) => {
|
|
99
|
-
const density = logNormalProbabilityDensity(nft.total);
|
|
100
|
-
const score = [density, maxProbabilityDensity2];
|
|
101
|
-
return (0, import_crypto_nft_score_model3.normalize)(score, maxScore3);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/lib/rating/criteria/index.ts
|
|
105
|
-
var scoringCriteria = {
|
|
106
|
-
...scoreMetadata,
|
|
107
|
-
Total: { score: scoreTotal, weight: 2 }
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// src/lib/rating/analyzeNftCollection.ts
|
|
111
|
-
var analyzeNftCollection = async (nft) => {
|
|
112
|
-
const result = Object.fromEntries(
|
|
113
|
-
await Promise.all(
|
|
114
|
-
Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {
|
|
115
|
-
const rawScore = await score(nft);
|
|
116
|
-
const weighted = rawScore.map((v) => v * weight);
|
|
117
|
-
return [key, weighted];
|
|
118
|
-
})
|
|
119
|
-
)
|
|
120
|
-
);
|
|
121
|
-
return result;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// src/Diviner.ts
|
|
125
|
-
var toNftCollectionScore = (nftCollectionInfo, scores) => {
|
|
126
|
-
const { name, symbol, address, chainId, type } = nftCollectionInfo;
|
|
127
|
-
const metadata = { address, chainId, name, symbol, type };
|
|
128
|
-
return { ...metadata, schema: import_crypto_nft_collection_payload_plugin.NftCollectionScoreSchema, scores };
|
|
129
|
-
};
|
|
130
|
-
var NftCollectionScoreDiviner = class extends import_abstract_diviner.AbstractDiviner {
|
|
131
|
-
static configSchemas = [import_crypto_nft_collection_payload_plugin.NftCollectionScoreDivinerConfigSchema];
|
|
132
|
-
divineHandler = async (payloads) => {
|
|
133
|
-
const nftCollectionInfos = payloads?.filter(import_crypto_nft_collection_payload_plugin.isNftCollectionInfo) ?? [];
|
|
134
|
-
const results = await Promise.all(
|
|
135
|
-
nftCollectionInfos.map(async (nftCollectionInfo) => {
|
|
136
|
-
const [score, sourceHash] = await Promise.all([
|
|
137
|
-
// Get score
|
|
138
|
-
toNftCollectionScore(nftCollectionInfo, await analyzeNftCollection(nftCollectionInfo)),
|
|
139
|
-
// Hash sources
|
|
140
|
-
import_core.PayloadHasher.hashAsync(nftCollectionInfo)
|
|
141
|
-
]);
|
|
142
|
-
return { ...score, schema: import_crypto_nft_collection_payload_plugin.NftCollectionScoreSchema, sources: [sourceHash] };
|
|
143
|
-
})
|
|
144
|
-
);
|
|
145
|
-
return results;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// src/Plugin.ts
|
|
150
|
-
var NftCollectionScoreDivinerPlugin = () => (0, import_payloadset_plugin.createPayloadSetDivinerPlugin)(
|
|
151
|
-
{ required: { [import_crypto_nft_payload_plugin.NftSchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
|
|
152
|
-
{
|
|
153
|
-
diviner: async (params) => {
|
|
154
|
-
const result = await NftCollectionScoreDiviner.create(params);
|
|
155
|
-
return result;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
//# sourceMappingURL=Plugin.cjs.map
|