shufflecom-calculations 2.3.4 → 3.0.1
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/lib/airdrop/airdrop-calculator.d.ts +44 -0
- package/lib/airdrop/airdrop-calculator.js +96 -0
- package/lib/airdrop/airdrop-calculator.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/vip-level-base.type.d.ts +19 -0
- package/lib/types/vip-level-base.type.js +84 -0
- package/lib/types/vip-level-base.type.js.map +1 -0
- package/lib/types/vip-level.type.d.ts +57 -0
- package/lib/types/vip-level.type.js +62 -0
- package/lib/types/vip-level.type.js.map +1 -0
- package/lib/utils/sports-competition-fixture.types.d.ts +1 -0
- package/lib/utils/sports-competition-fixture.types.js.map +1 -1
- package/package.json +2 -2
- package/src/airdrop/airdrop-calculator.spec.ts +327 -0
- package/src/airdrop/airdrop-calculator.ts +140 -0
- package/src/index.ts +1 -0
- package/src/types/vip-level-base.type.ts +81 -0
- package/src/types/vip-level.type.ts +57 -0
- package/src/utils/sports-competition-fixture.types.ts +1 -0
- package/lib/utils/airdrop.d.ts +0 -26
- package/lib/utils/airdrop.js +0 -51
- package/lib/utils/airdrop.js.map +0 -1
- package/src/utils/airdrop.spec.ts +0 -162
- package/src/utils/airdrop.ts +0 -92
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { VipLevel } from './vip-level.type';
|
|
2
|
+
export declare enum VipLevelBase {
|
|
3
|
+
UNRANKED = "UNRANKED",
|
|
4
|
+
WOOD = "WOOD",
|
|
5
|
+
BRONZE = "BRONZE",
|
|
6
|
+
SILVER = "SILVER",
|
|
7
|
+
GOLD = "GOLD",
|
|
8
|
+
PLATINUM = "PLATINUM",
|
|
9
|
+
JADE = "JADE",
|
|
10
|
+
SAPPHIRE = "SAPPHIRE",
|
|
11
|
+
RUBY = "RUBY",
|
|
12
|
+
DIAMOND = "DIAMOND",
|
|
13
|
+
OPAL = "OPAL",
|
|
14
|
+
DRAGON = "DRAGON",
|
|
15
|
+
MYTHIC = "MYTHIC",
|
|
16
|
+
DARK = "DARK",
|
|
17
|
+
LEGEND = "LEGEND"
|
|
18
|
+
}
|
|
19
|
+
export declare const getVipLevelBase: (vipLevel: VipLevel) => VipLevelBase;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVipLevelBase = exports.VipLevelBase = void 0;
|
|
4
|
+
const vip_level_type_1 = require("./vip-level.type");
|
|
5
|
+
var VipLevelBase;
|
|
6
|
+
(function (VipLevelBase) {
|
|
7
|
+
VipLevelBase["UNRANKED"] = "UNRANKED";
|
|
8
|
+
VipLevelBase["WOOD"] = "WOOD";
|
|
9
|
+
VipLevelBase["BRONZE"] = "BRONZE";
|
|
10
|
+
VipLevelBase["SILVER"] = "SILVER";
|
|
11
|
+
VipLevelBase["GOLD"] = "GOLD";
|
|
12
|
+
VipLevelBase["PLATINUM"] = "PLATINUM";
|
|
13
|
+
VipLevelBase["JADE"] = "JADE";
|
|
14
|
+
VipLevelBase["SAPPHIRE"] = "SAPPHIRE";
|
|
15
|
+
VipLevelBase["RUBY"] = "RUBY";
|
|
16
|
+
VipLevelBase["DIAMOND"] = "DIAMOND";
|
|
17
|
+
VipLevelBase["OPAL"] = "OPAL";
|
|
18
|
+
VipLevelBase["DRAGON"] = "DRAGON";
|
|
19
|
+
VipLevelBase["MYTHIC"] = "MYTHIC";
|
|
20
|
+
VipLevelBase["DARK"] = "DARK";
|
|
21
|
+
VipLevelBase["LEGEND"] = "LEGEND";
|
|
22
|
+
})(VipLevelBase || (exports.VipLevelBase = VipLevelBase = {}));
|
|
23
|
+
const vipLevelToBaseMapping = {
|
|
24
|
+
[vip_level_type_1.VipLevel.UNRANKED]: VipLevelBase.UNRANKED,
|
|
25
|
+
[vip_level_type_1.VipLevel.WOOD]: VipLevelBase.WOOD,
|
|
26
|
+
[vip_level_type_1.VipLevel.BRONZE_1]: VipLevelBase.BRONZE,
|
|
27
|
+
[vip_level_type_1.VipLevel.BRONZE_2]: VipLevelBase.BRONZE,
|
|
28
|
+
[vip_level_type_1.VipLevel.BRONZE_3]: VipLevelBase.BRONZE,
|
|
29
|
+
[vip_level_type_1.VipLevel.BRONZE_4]: VipLevelBase.BRONZE,
|
|
30
|
+
[vip_level_type_1.VipLevel.BRONZE_5]: VipLevelBase.BRONZE,
|
|
31
|
+
[vip_level_type_1.VipLevel.SILVER_1]: VipLevelBase.SILVER,
|
|
32
|
+
[vip_level_type_1.VipLevel.SILVER_2]: VipLevelBase.SILVER,
|
|
33
|
+
[vip_level_type_1.VipLevel.SILVER_3]: VipLevelBase.SILVER,
|
|
34
|
+
[vip_level_type_1.VipLevel.SILVER_4]: VipLevelBase.SILVER,
|
|
35
|
+
[vip_level_type_1.VipLevel.SILVER_5]: VipLevelBase.SILVER,
|
|
36
|
+
[vip_level_type_1.VipLevel.GOLD_1]: VipLevelBase.GOLD,
|
|
37
|
+
[vip_level_type_1.VipLevel.GOLD_2]: VipLevelBase.GOLD,
|
|
38
|
+
[vip_level_type_1.VipLevel.GOLD_3]: VipLevelBase.GOLD,
|
|
39
|
+
[vip_level_type_1.VipLevel.GOLD_4]: VipLevelBase.GOLD,
|
|
40
|
+
[vip_level_type_1.VipLevel.GOLD_5]: VipLevelBase.GOLD,
|
|
41
|
+
[vip_level_type_1.VipLevel.PLATINUM_1]: VipLevelBase.PLATINUM,
|
|
42
|
+
[vip_level_type_1.VipLevel.PLATINUM_2]: VipLevelBase.PLATINUM,
|
|
43
|
+
[vip_level_type_1.VipLevel.PLATINUM_3]: VipLevelBase.PLATINUM,
|
|
44
|
+
[vip_level_type_1.VipLevel.PLATINUM_4]: VipLevelBase.PLATINUM,
|
|
45
|
+
[vip_level_type_1.VipLevel.PLATINUM_5]: VipLevelBase.PLATINUM,
|
|
46
|
+
[vip_level_type_1.VipLevel.JADE_1]: VipLevelBase.JADE,
|
|
47
|
+
[vip_level_type_1.VipLevel.JADE_2]: VipLevelBase.JADE,
|
|
48
|
+
[vip_level_type_1.VipLevel.JADE_3]: VipLevelBase.JADE,
|
|
49
|
+
[vip_level_type_1.VipLevel.JADE_4]: VipLevelBase.JADE,
|
|
50
|
+
[vip_level_type_1.VipLevel.JADE_5]: VipLevelBase.JADE,
|
|
51
|
+
[vip_level_type_1.VipLevel.SAPPHIRE_1]: VipLevelBase.SAPPHIRE,
|
|
52
|
+
[vip_level_type_1.VipLevel.SAPPHIRE_2]: VipLevelBase.SAPPHIRE,
|
|
53
|
+
[vip_level_type_1.VipLevel.SAPPHIRE_3]: VipLevelBase.SAPPHIRE,
|
|
54
|
+
[vip_level_type_1.VipLevel.SAPPHIRE_4]: VipLevelBase.SAPPHIRE,
|
|
55
|
+
[vip_level_type_1.VipLevel.SAPPHIRE_5]: VipLevelBase.SAPPHIRE,
|
|
56
|
+
[vip_level_type_1.VipLevel.RUBY_1]: VipLevelBase.RUBY,
|
|
57
|
+
[vip_level_type_1.VipLevel.RUBY_2]: VipLevelBase.RUBY,
|
|
58
|
+
[vip_level_type_1.VipLevel.RUBY_3]: VipLevelBase.RUBY,
|
|
59
|
+
[vip_level_type_1.VipLevel.RUBY_4]: VipLevelBase.RUBY,
|
|
60
|
+
[vip_level_type_1.VipLevel.RUBY_5]: VipLevelBase.RUBY,
|
|
61
|
+
[vip_level_type_1.VipLevel.DIAMOND_1]: VipLevelBase.DIAMOND,
|
|
62
|
+
[vip_level_type_1.VipLevel.DIAMOND_2]: VipLevelBase.DIAMOND,
|
|
63
|
+
[vip_level_type_1.VipLevel.DIAMOND_3]: VipLevelBase.DIAMOND,
|
|
64
|
+
[vip_level_type_1.VipLevel.DIAMOND_4]: VipLevelBase.DIAMOND,
|
|
65
|
+
[vip_level_type_1.VipLevel.DIAMOND_5]: VipLevelBase.DIAMOND,
|
|
66
|
+
[vip_level_type_1.VipLevel.OPAL_1]: VipLevelBase.OPAL,
|
|
67
|
+
[vip_level_type_1.VipLevel.OPAL_2]: VipLevelBase.OPAL,
|
|
68
|
+
[vip_level_type_1.VipLevel.OPAL_3]: VipLevelBase.OPAL,
|
|
69
|
+
[vip_level_type_1.VipLevel.OPAL_4]: VipLevelBase.OPAL,
|
|
70
|
+
[vip_level_type_1.VipLevel.OPAL_5]: VipLevelBase.OPAL,
|
|
71
|
+
[vip_level_type_1.VipLevel.DRAGON_1]: VipLevelBase.DRAGON,
|
|
72
|
+
[vip_level_type_1.VipLevel.DRAGON_2]: VipLevelBase.DRAGON,
|
|
73
|
+
[vip_level_type_1.VipLevel.DRAGON_3]: VipLevelBase.DRAGON,
|
|
74
|
+
[vip_level_type_1.VipLevel.DRAGON_4]: VipLevelBase.DRAGON,
|
|
75
|
+
[vip_level_type_1.VipLevel.DRAGON_5]: VipLevelBase.DRAGON,
|
|
76
|
+
[vip_level_type_1.VipLevel.MYTHIC]: VipLevelBase.MYTHIC,
|
|
77
|
+
[vip_level_type_1.VipLevel.DARK]: VipLevelBase.DARK,
|
|
78
|
+
[vip_level_type_1.VipLevel.LEGEND]: VipLevelBase.LEGEND,
|
|
79
|
+
};
|
|
80
|
+
const getVipLevelBase = (vipLevel) => {
|
|
81
|
+
return vipLevelToBaseMapping[vipLevel];
|
|
82
|
+
};
|
|
83
|
+
exports.getVipLevelBase = getVipLevelBase;
|
|
84
|
+
//# sourceMappingURL=vip-level-base.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vip-level-base.type.js","sourceRoot":"","sources":["../../src/types/vip-level-base.type.ts"],"names":[],"mappings":";;;AAAA,qDAA4C;AAE5C,IAAY,YAgBX;AAhBD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,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AAE,YAAY,CAAC,MAAM;CACE,CAAC;AAEpC,MAAM,eAAe,GAAG,CAAC,QAAkB,EAAgB,EAAE;IAClE,OAAO,qBAAqB,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare enum VipLevel {
|
|
2
|
+
UNRANKED = "UNRANKED",
|
|
3
|
+
WOOD = "WOOD",
|
|
4
|
+
BRONZE_1 = "BRONZE_1",
|
|
5
|
+
BRONZE_2 = "BRONZE_2",
|
|
6
|
+
BRONZE_3 = "BRONZE_3",
|
|
7
|
+
BRONZE_4 = "BRONZE_4",
|
|
8
|
+
BRONZE_5 = "BRONZE_5",
|
|
9
|
+
SILVER_1 = "SILVER_1",
|
|
10
|
+
SILVER_2 = "SILVER_2",
|
|
11
|
+
SILVER_3 = "SILVER_3",
|
|
12
|
+
SILVER_4 = "SILVER_4",
|
|
13
|
+
SILVER_5 = "SILVER_5",
|
|
14
|
+
GOLD_1 = "GOLD_1",
|
|
15
|
+
GOLD_2 = "GOLD_2",
|
|
16
|
+
GOLD_3 = "GOLD_3",
|
|
17
|
+
GOLD_4 = "GOLD_4",
|
|
18
|
+
GOLD_5 = "GOLD_5",
|
|
19
|
+
PLATINUM_1 = "PLATINUM_1",
|
|
20
|
+
PLATINUM_2 = "PLATINUM_2",
|
|
21
|
+
PLATINUM_3 = "PLATINUM_3",
|
|
22
|
+
PLATINUM_4 = "PLATINUM_4",
|
|
23
|
+
PLATINUM_5 = "PLATINUM_5",
|
|
24
|
+
JADE_1 = "JADE_1",
|
|
25
|
+
JADE_2 = "JADE_2",
|
|
26
|
+
JADE_3 = "JADE_3",
|
|
27
|
+
JADE_4 = "JADE_4",
|
|
28
|
+
JADE_5 = "JADE_5",
|
|
29
|
+
SAPPHIRE_1 = "SAPPHIRE_1",
|
|
30
|
+
SAPPHIRE_2 = "SAPPHIRE_2",
|
|
31
|
+
SAPPHIRE_3 = "SAPPHIRE_3",
|
|
32
|
+
SAPPHIRE_4 = "SAPPHIRE_4",
|
|
33
|
+
SAPPHIRE_5 = "SAPPHIRE_5",
|
|
34
|
+
RUBY_1 = "RUBY_1",
|
|
35
|
+
RUBY_2 = "RUBY_2",
|
|
36
|
+
RUBY_3 = "RUBY_3",
|
|
37
|
+
RUBY_4 = "RUBY_4",
|
|
38
|
+
RUBY_5 = "RUBY_5",
|
|
39
|
+
DIAMOND_1 = "DIAMOND_1",
|
|
40
|
+
DIAMOND_2 = "DIAMOND_2",
|
|
41
|
+
DIAMOND_3 = "DIAMOND_3",
|
|
42
|
+
DIAMOND_4 = "DIAMOND_4",
|
|
43
|
+
DIAMOND_5 = "DIAMOND_5",
|
|
44
|
+
OPAL_1 = "OPAL_1",
|
|
45
|
+
OPAL_2 = "OPAL_2",
|
|
46
|
+
OPAL_3 = "OPAL_3",
|
|
47
|
+
OPAL_4 = "OPAL_4",
|
|
48
|
+
OPAL_5 = "OPAL_5",
|
|
49
|
+
DRAGON_1 = "DRAGON_1",
|
|
50
|
+
DRAGON_2 = "DRAGON_2",
|
|
51
|
+
DRAGON_3 = "DRAGON_3",
|
|
52
|
+
DRAGON_4 = "DRAGON_4",
|
|
53
|
+
DRAGON_5 = "DRAGON_5",
|
|
54
|
+
MYTHIC = "MYTHIC",
|
|
55
|
+
DARK = "DARK",
|
|
56
|
+
LEGEND = "LEGEND"
|
|
57
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VipLevel = void 0;
|
|
4
|
+
var VipLevel;
|
|
5
|
+
(function (VipLevel) {
|
|
6
|
+
VipLevel["UNRANKED"] = "UNRANKED";
|
|
7
|
+
VipLevel["WOOD"] = "WOOD";
|
|
8
|
+
VipLevel["BRONZE_1"] = "BRONZE_1";
|
|
9
|
+
VipLevel["BRONZE_2"] = "BRONZE_2";
|
|
10
|
+
VipLevel["BRONZE_3"] = "BRONZE_3";
|
|
11
|
+
VipLevel["BRONZE_4"] = "BRONZE_4";
|
|
12
|
+
VipLevel["BRONZE_5"] = "BRONZE_5";
|
|
13
|
+
VipLevel["SILVER_1"] = "SILVER_1";
|
|
14
|
+
VipLevel["SILVER_2"] = "SILVER_2";
|
|
15
|
+
VipLevel["SILVER_3"] = "SILVER_3";
|
|
16
|
+
VipLevel["SILVER_4"] = "SILVER_4";
|
|
17
|
+
VipLevel["SILVER_5"] = "SILVER_5";
|
|
18
|
+
VipLevel["GOLD_1"] = "GOLD_1";
|
|
19
|
+
VipLevel["GOLD_2"] = "GOLD_2";
|
|
20
|
+
VipLevel["GOLD_3"] = "GOLD_3";
|
|
21
|
+
VipLevel["GOLD_4"] = "GOLD_4";
|
|
22
|
+
VipLevel["GOLD_5"] = "GOLD_5";
|
|
23
|
+
VipLevel["PLATINUM_1"] = "PLATINUM_1";
|
|
24
|
+
VipLevel["PLATINUM_2"] = "PLATINUM_2";
|
|
25
|
+
VipLevel["PLATINUM_3"] = "PLATINUM_3";
|
|
26
|
+
VipLevel["PLATINUM_4"] = "PLATINUM_4";
|
|
27
|
+
VipLevel["PLATINUM_5"] = "PLATINUM_5";
|
|
28
|
+
VipLevel["JADE_1"] = "JADE_1";
|
|
29
|
+
VipLevel["JADE_2"] = "JADE_2";
|
|
30
|
+
VipLevel["JADE_3"] = "JADE_3";
|
|
31
|
+
VipLevel["JADE_4"] = "JADE_4";
|
|
32
|
+
VipLevel["JADE_5"] = "JADE_5";
|
|
33
|
+
VipLevel["SAPPHIRE_1"] = "SAPPHIRE_1";
|
|
34
|
+
VipLevel["SAPPHIRE_2"] = "SAPPHIRE_2";
|
|
35
|
+
VipLevel["SAPPHIRE_3"] = "SAPPHIRE_3";
|
|
36
|
+
VipLevel["SAPPHIRE_4"] = "SAPPHIRE_4";
|
|
37
|
+
VipLevel["SAPPHIRE_5"] = "SAPPHIRE_5";
|
|
38
|
+
VipLevel["RUBY_1"] = "RUBY_1";
|
|
39
|
+
VipLevel["RUBY_2"] = "RUBY_2";
|
|
40
|
+
VipLevel["RUBY_3"] = "RUBY_3";
|
|
41
|
+
VipLevel["RUBY_4"] = "RUBY_4";
|
|
42
|
+
VipLevel["RUBY_5"] = "RUBY_5";
|
|
43
|
+
VipLevel["DIAMOND_1"] = "DIAMOND_1";
|
|
44
|
+
VipLevel["DIAMOND_2"] = "DIAMOND_2";
|
|
45
|
+
VipLevel["DIAMOND_3"] = "DIAMOND_3";
|
|
46
|
+
VipLevel["DIAMOND_4"] = "DIAMOND_4";
|
|
47
|
+
VipLevel["DIAMOND_5"] = "DIAMOND_5";
|
|
48
|
+
VipLevel["OPAL_1"] = "OPAL_1";
|
|
49
|
+
VipLevel["OPAL_2"] = "OPAL_2";
|
|
50
|
+
VipLevel["OPAL_3"] = "OPAL_3";
|
|
51
|
+
VipLevel["OPAL_4"] = "OPAL_4";
|
|
52
|
+
VipLevel["OPAL_5"] = "OPAL_5";
|
|
53
|
+
VipLevel["DRAGON_1"] = "DRAGON_1";
|
|
54
|
+
VipLevel["DRAGON_2"] = "DRAGON_2";
|
|
55
|
+
VipLevel["DRAGON_3"] = "DRAGON_3";
|
|
56
|
+
VipLevel["DRAGON_4"] = "DRAGON_4";
|
|
57
|
+
VipLevel["DRAGON_5"] = "DRAGON_5";
|
|
58
|
+
VipLevel["MYTHIC"] = "MYTHIC";
|
|
59
|
+
VipLevel["DARK"] = "DARK";
|
|
60
|
+
VipLevel["LEGEND"] = "LEGEND";
|
|
61
|
+
})(VipLevel || (exports.VipLevel = VipLevel = {}));
|
|
62
|
+
//# sourceMappingURL=vip-level.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vip-level.type.js","sourceRoot":"","sources":["../../src/types/vip-level.type.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAwDX;AAxDD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,yBAAa,CAAA;IACb,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;IACvB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;IACrB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,6BAAiB,CAAA;AACnB,CAAC,EAxDW,QAAQ,wBAAR,QAAQ,QAwDnB"}
|
|
@@ -106,6 +106,7 @@ export declare class SportsFixtureInfo {
|
|
|
106
106
|
status: SportsFixtureStatus;
|
|
107
107
|
bannerType: SportsFixtureBannerType;
|
|
108
108
|
defaultMarketsInfo: DefaultMarketInfo;
|
|
109
|
+
pinned?: boolean;
|
|
109
110
|
}
|
|
110
111
|
export declare class SportsFixtureInfoWithCompetition extends SportsFixtureInfo {
|
|
111
112
|
competition: SportsCompetitionWithCategoryInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sports-competition-fixture.types.js","sourceRoot":"","sources":["../../src/utils/sports-competition-fixture.types.ts"],"names":[],"mappings":";;;AAcA,MAAa,iBAAiB;CAG7B;AAHD,8CAGC;AAED,MAAa,UAAU;CAGtB;AAHD,gCAGC;AAED,MAAa,cAAc;CAO1B;AAPD,wCAOC;AAED,MAAa,cAAc;CAyD1B;AAzDD,wCAyDC;AAED,MAAa,iCAAiC;CAY7C;AAZD,8EAYC;AAED,MAAa,iBAAiB;
|
|
1
|
+
{"version":3,"file":"sports-competition-fixture.types.js","sourceRoot":"","sources":["../../src/utils/sports-competition-fixture.types.ts"],"names":[],"mappings":";;;AAcA,MAAa,iBAAiB;CAG7B;AAHD,8CAGC;AAED,MAAa,UAAU;CAGtB;AAHD,gCAGC;AAED,MAAa,cAAc;CAO1B;AAPD,wCAOC;AAED,MAAa,cAAc;CAyD1B;AAzDD,wCAyDC;AAED,MAAa,iCAAiC;CAY7C;AAZD,8EAYC;AAED,MAAa,iBAAiB;CAoB7B;AApBD,8CAoBC;AAED,MAAa,gCAAiC,SAAQ,iBAAiB;CAEtE;AAFD,4EAEC;AAED,MAAa,0CAA2C,SAAQ,gCAAgC;CAE/F;AAFD,gGAEC;AAED,MAAa,2BAA2B;CAGvC;AAHD,kEAGC;AAED,MAAa,0CAA0C;CAGtD;AAHD,gGAGC;AAED,MAAa,iCAAkC,SAAQ,iCAAiC;CAGvF;AAHD,8EAGC;AAED,MAAa,+BAA+B;CAG3C;AAHD,0EAGC;AAED,MAAa,4BAA6B,SAAQ,+BAA+B;CAEhF;AAFD,oEAEC;AAED,MAAa,+BAA+B;CAG3C;AAHD,0EAGC;AAED,MAAa,wBAAwB;CAKpC;AALD,4DAKC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shufflecom-calculations",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
},
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "ISC",
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "7ad2e6c6a3bb6b01485fe004cca9c7bdbce629ca"
|
|
18
18
|
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { VipLevel } from '../types/vip-level.type';
|
|
3
|
+
import { AirdropCalculator } from './airdrop-calculator';
|
|
4
|
+
|
|
5
|
+
describe('Airdrop Calculator', () => {
|
|
6
|
+
describe('getRankMultiplier', () => {
|
|
7
|
+
const testCases = [
|
|
8
|
+
{
|
|
9
|
+
description: 'Bronze and below',
|
|
10
|
+
vipLevels: [VipLevel.UNRANKED, VipLevel.WOOD, VipLevel.BRONZE_1, VipLevel.BRONZE_2, VipLevel.BRONZE_3, VipLevel.BRONZE_4, VipLevel.BRONZE_5],
|
|
11
|
+
expected: 1.0,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
description: 'Silver',
|
|
15
|
+
vipLevels: [VipLevel.SILVER_1, VipLevel.SILVER_2, VipLevel.SILVER_3, VipLevel.SILVER_4, VipLevel.SILVER_5],
|
|
16
|
+
expected: 1.01,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
description: 'Gold',
|
|
20
|
+
vipLevels: [VipLevel.GOLD_1, VipLevel.GOLD_2, VipLevel.GOLD_3, VipLevel.GOLD_4, VipLevel.GOLD_5],
|
|
21
|
+
expected: 1.02,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
description: 'Platinum',
|
|
25
|
+
vipLevels: [VipLevel.PLATINUM_1, VipLevel.PLATINUM_2, VipLevel.PLATINUM_3, VipLevel.PLATINUM_4, VipLevel.PLATINUM_5],
|
|
26
|
+
expected: 1.03,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
description: 'Jade',
|
|
30
|
+
vipLevels: [VipLevel.JADE_1, VipLevel.JADE_2, VipLevel.JADE_3, VipLevel.JADE_4, VipLevel.JADE_5],
|
|
31
|
+
expected: 1.04,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: 'Sapphire',
|
|
35
|
+
vipLevels: [VipLevel.SAPPHIRE_1, VipLevel.SAPPHIRE_2, VipLevel.SAPPHIRE_3, VipLevel.SAPPHIRE_4, VipLevel.SAPPHIRE_5],
|
|
36
|
+
expected: 1.05,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
description: 'Ruby',
|
|
40
|
+
vipLevels: [VipLevel.RUBY_1, VipLevel.RUBY_2, VipLevel.RUBY_3, VipLevel.RUBY_4, VipLevel.RUBY_5],
|
|
41
|
+
expected: 1.06,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
description: 'Diamond',
|
|
45
|
+
vipLevels: [VipLevel.DIAMOND_1, VipLevel.DIAMOND_2, VipLevel.DIAMOND_3, VipLevel.DIAMOND_4, VipLevel.DIAMOND_5],
|
|
46
|
+
expected: 1.07,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
description: 'Opal',
|
|
50
|
+
vipLevels: [VipLevel.OPAL_1, VipLevel.OPAL_2, VipLevel.OPAL_3, VipLevel.OPAL_4, VipLevel.OPAL_5],
|
|
51
|
+
expected: 1.08,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
description: 'Dragon',
|
|
55
|
+
vipLevels: [VipLevel.DRAGON_1, VipLevel.DRAGON_2, VipLevel.DRAGON_3, VipLevel.DRAGON_4, VipLevel.DRAGON_5],
|
|
56
|
+
expected: 1.09,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
description: 'Mythic and up',
|
|
60
|
+
vipLevels: [VipLevel.MYTHIC, VipLevel.DARK, VipLevel.LEGEND],
|
|
61
|
+
expected: 1.1,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
for (const { description, vipLevels, expected } of testCases) {
|
|
66
|
+
it(`should return ${expected} for ${description} ranks`, () => {
|
|
67
|
+
for (const vipLevel of vipLevels) {
|
|
68
|
+
const result = AirdropCalculator.getRankMultiplier(vipLevel);
|
|
69
|
+
expect(result.raw).toEqual(expected);
|
|
70
|
+
expect(result.bps).toEqual(new BigNumber(expected).multipliedBy(10_000).toNumber());
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('getTokenAllocationInfo', () => {
|
|
77
|
+
it('should return zeros for empty allocations array', () => {
|
|
78
|
+
const result = AirdropCalculator.getTokenAllocationInfo({
|
|
79
|
+
tokenAllocations: [],
|
|
80
|
+
tokensClaimed: new BigNumber(0),
|
|
81
|
+
usdTotalWagered: new BigNumber(0),
|
|
82
|
+
hasKyc2: false,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(result.totalAllocation.toString()).toBe('0');
|
|
86
|
+
expect(result.tokensClaimable.toString()).toBe('0');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should only add to totalAllocation when allocations have no usdWageredSnapshot', () => {
|
|
90
|
+
const result = AirdropCalculator.getTokenAllocationInfo({
|
|
91
|
+
tokenAllocations: [
|
|
92
|
+
{ allocatedAmount: new BigNumber(100), eventId: 1 },
|
|
93
|
+
{ allocatedAmount: new BigNumber(200), eventId: 2 },
|
|
94
|
+
{ allocatedAmount: new BigNumber(300), eventId: 3 },
|
|
95
|
+
],
|
|
96
|
+
tokensClaimed: new BigNumber(0),
|
|
97
|
+
usdTotalWagered: new BigNumber(1000),
|
|
98
|
+
hasKyc2: false,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(result.totalAllocation.toString()).toBe('600');
|
|
102
|
+
expect(result.tokensClaimable.toString()).toBe('0');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should return zero totalAllocation when all allocatedAmounts are zero', () => {
|
|
106
|
+
const result = AirdropCalculator.getTokenAllocationInfo({
|
|
107
|
+
tokenAllocations: [
|
|
108
|
+
{ allocatedAmount: new BigNumber(0), eventId: 1 },
|
|
109
|
+
{ allocatedAmount: new BigNumber(0), eventId: 2 },
|
|
110
|
+
{ allocatedAmount: new BigNumber(0), eventId: 3 },
|
|
111
|
+
],
|
|
112
|
+
tokensClaimed: new BigNumber(0),
|
|
113
|
+
usdTotalWagered: new BigNumber(1000),
|
|
114
|
+
hasKyc2: false,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
expect(result.totalAllocation.toString()).toBe('0');
|
|
118
|
+
expect(result.tokensClaimable.toString()).toBe('0');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('with snapshot allocations', () => {
|
|
122
|
+
const defaultAllocations = [
|
|
123
|
+
{ allocatedAmount: new BigNumber(1000), usdWageredSnapshot: new BigNumber(1000), eventId: 3 },
|
|
124
|
+
{ allocatedAmount: new BigNumber(1000), usdWageredSnapshot: new BigNumber(500), eventId: 1 },
|
|
125
|
+
{ allocatedAmount: new BigNumber(0), usdWageredSnapshot: new BigNumber(1000), eventId: 2 },
|
|
126
|
+
{ allocatedAmount: new BigNumber(2000), usdWageredSnapshot: new BigNumber(1500), eventId: 4 },
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
const expectedTotalAllocation = '4000';
|
|
130
|
+
|
|
131
|
+
// Sorted latest→earliest: E4(snap=$1500, 2000t), E3(snap=$1000, 1000t), E2(snap=$1000, 0t, skipped), E1(snap=$500, 1000t)
|
|
132
|
+
//
|
|
133
|
+
// Each event's available wager = (usdTotalWagered - mySnapshot) - wagerConsumedSoFar
|
|
134
|
+
// Excess from a later event spills to earlier events via wagerConsumedSoFar.
|
|
135
|
+
//
|
|
136
|
+
// Full unlock thresholds:
|
|
137
|
+
// rate=$20: E4 needs $36,000 → E3 needs $18,000 → E1 needs $18,000 → min usdTotalWagered=$72,500
|
|
138
|
+
// rate=$10: E4 needs $18,000 → E3 needs $9,000 → E1 needs $9,000 → min usdTotalWagered=$36,500
|
|
139
|
+
|
|
140
|
+
describe('non-KYC2 (rate: 20)', () => {
|
|
141
|
+
const fullyUnlockedWager = new BigNumber(72_500);
|
|
142
|
+
const partialWager = new BigNumber(37_500);
|
|
143
|
+
|
|
144
|
+
const testCasesNoKyc2 = [
|
|
145
|
+
{
|
|
146
|
+
description: 'fully unlocked - all allocations fully vested',
|
|
147
|
+
tokensClaimed: new BigNumber(0),
|
|
148
|
+
usdTotalWagered: fullyUnlockedWager,
|
|
149
|
+
expected: {
|
|
150
|
+
totalAllocation: expectedTotalAllocation,
|
|
151
|
+
tokensClaimable: expectedTotalAllocation,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
description: 'not fully unlocked should only have claimable up to vested amount',
|
|
156
|
+
tokensClaimed: new BigNumber(0),
|
|
157
|
+
usdTotalWagered: partialWager,
|
|
158
|
+
expected: {
|
|
159
|
+
totalAllocation: expectedTotalAllocation,
|
|
160
|
+
tokensClaimable: '2250',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
description: 'should deduct claimed tokens from claimable amount',
|
|
165
|
+
tokensClaimed: new BigNumber(199),
|
|
166
|
+
usdTotalWagered: partialWager,
|
|
167
|
+
expected: {
|
|
168
|
+
totalAllocation: expectedTotalAllocation,
|
|
169
|
+
tokensClaimable: '2051',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
for (const { description, tokensClaimed, usdTotalWagered, expected } of testCasesNoKyc2) {
|
|
175
|
+
it(`should calculate ${description}`, () => {
|
|
176
|
+
const result = AirdropCalculator.getTokenAllocationInfo({
|
|
177
|
+
tokenAllocations: defaultAllocations,
|
|
178
|
+
tokensClaimed,
|
|
179
|
+
usdTotalWagered,
|
|
180
|
+
hasKyc2: false,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
expect(result.totalAllocation.toString()).toBe(expected.totalAllocation);
|
|
184
|
+
expect(result.tokensClaimable.toString()).toBe(expected.tokensClaimable);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe('KYC2 (rate: 10)', () => {
|
|
190
|
+
const fullyUnlockedWager = new BigNumber(36_500);
|
|
191
|
+
const partialWager = new BigNumber(27510);
|
|
192
|
+
|
|
193
|
+
const testCasesWithKyc2 = [
|
|
194
|
+
{
|
|
195
|
+
description: 'fully unlocked - all allocations fully vested',
|
|
196
|
+
tokensClaimed: new BigNumber(0),
|
|
197
|
+
usdTotalWagered: fullyUnlockedWager,
|
|
198
|
+
expected: {
|
|
199
|
+
totalAllocation: expectedTotalAllocation,
|
|
200
|
+
tokensClaimable: expectedTotalAllocation,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
description: 'not fully unlocked should only have claimable up to vested amount',
|
|
205
|
+
tokensClaimed: new BigNumber(0),
|
|
206
|
+
usdTotalWagered: partialWager,
|
|
207
|
+
expected: {
|
|
208
|
+
totalAllocation: expectedTotalAllocation,
|
|
209
|
+
tokensClaimable: '3101',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
description: 'should deduct claimed tokens from claimable amount',
|
|
214
|
+
tokensClaimed: new BigNumber(199),
|
|
215
|
+
usdTotalWagered: partialWager,
|
|
216
|
+
expected: {
|
|
217
|
+
totalAllocation: expectedTotalAllocation,
|
|
218
|
+
tokensClaimable: '2902',
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
];
|
|
222
|
+
|
|
223
|
+
for (const { description, tokensClaimed, usdTotalWagered, expected } of testCasesWithKyc2) {
|
|
224
|
+
it(`should calculate ${description}`, () => {
|
|
225
|
+
const result = AirdropCalculator.getTokenAllocationInfo({
|
|
226
|
+
tokenAllocations: defaultAllocations,
|
|
227
|
+
tokensClaimed,
|
|
228
|
+
usdTotalWagered,
|
|
229
|
+
hasKyc2: true,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
expect(result.totalAllocation.toFixed()).toBe(expected.totalAllocation);
|
|
233
|
+
expect(result.tokensClaimable.toFixed()).toBe(expected.tokensClaimable);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
describe('Storage multiplier', () => {
|
|
239
|
+
// Same thresholds as KYC2 suite (rate=$10), scaled by storageMultiplier
|
|
240
|
+
const storageMultiplier = new BigNumber(10).pow(17);
|
|
241
|
+
const fullyUnlockedWager = new BigNumber(36_500).multipliedBy(storageMultiplier);
|
|
242
|
+
const partialWager = new BigNumber(18_990).multipliedBy(storageMultiplier);
|
|
243
|
+
|
|
244
|
+
const testCasesWithKyc2 = [
|
|
245
|
+
{
|
|
246
|
+
description: 'fully unlocked - all allocations fully vested',
|
|
247
|
+
tokensClaimed: new BigNumber(0),
|
|
248
|
+
usdTotalWagered: fullyUnlockedWager,
|
|
249
|
+
expected: {
|
|
250
|
+
totalAllocation: new BigNumber(expectedTotalAllocation).multipliedBy(storageMultiplier).toFixed(),
|
|
251
|
+
tokensClaimable: new BigNumber(expectedTotalAllocation).multipliedBy(storageMultiplier).toFixed(),
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
description: 'not fully unlocked should only have claimable up to vested amount',
|
|
256
|
+
tokensClaimed: new BigNumber(0),
|
|
257
|
+
usdTotalWagered: partialWager,
|
|
258
|
+
expected: {
|
|
259
|
+
totalAllocation: new BigNumber(expectedTotalAllocation).multipliedBy(storageMultiplier).toFixed(),
|
|
260
|
+
tokensClaimable: new BigNumber('2249').multipliedBy(storageMultiplier).toFixed(),
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
description: 'should deduct claimed tokens from claimable amount',
|
|
265
|
+
tokensClaimed: new BigNumber(199).multipliedBy(storageMultiplier),
|
|
266
|
+
usdTotalWagered: partialWager,
|
|
267
|
+
expected: {
|
|
268
|
+
totalAllocation: new BigNumber(expectedTotalAllocation).multipliedBy(storageMultiplier).toFixed(),
|
|
269
|
+
tokensClaimable: new BigNumber('2050').multipliedBy(storageMultiplier).toFixed(),
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
for (const { description, tokensClaimed, usdTotalWagered, expected } of testCasesWithKyc2) {
|
|
275
|
+
it(`should calculate ${description}`, () => {
|
|
276
|
+
const result = AirdropCalculator.getTokenAllocationInfo({
|
|
277
|
+
tokenAllocations: defaultAllocations.map(allo => {
|
|
278
|
+
return {
|
|
279
|
+
allocatedAmount: allo.allocatedAmount.multipliedBy(storageMultiplier),
|
|
280
|
+
usdWageredSnapshot: allo.usdWageredSnapshot.multipliedBy(storageMultiplier),
|
|
281
|
+
eventId: allo.eventId,
|
|
282
|
+
};
|
|
283
|
+
}),
|
|
284
|
+
tokensClaimed,
|
|
285
|
+
usdTotalWagered,
|
|
286
|
+
hasKyc2: true,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
expect(result.totalAllocation.toFixed()).toBe(expected.totalAllocation);
|
|
290
|
+
expect(result.tokensClaimable.toFixed()).toBe(expected.tokensClaimable);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
describe('multi-event overlap regression', () => {
|
|
296
|
+
// E1(snap=$1,000, 100t), E2(snap=$2,000, 200t), usdTotalWagered=$2,500
|
|
297
|
+
// rate=$20 → E1 vests 85, E2 vests 20 = 105 total
|
|
298
|
+
// rate=$10 → E1 vests 100 (capped), E2 vests 70 = 170 total
|
|
299
|
+
const overlapAllocations = [
|
|
300
|
+
{ allocatedAmount: new BigNumber(100), usdWageredSnapshot: new BigNumber(1000), eventId: 1 },
|
|
301
|
+
{ allocatedAmount: new BigNumber(200), usdWageredSnapshot: new BigNumber(2000), eventId: 2 },
|
|
302
|
+
];
|
|
303
|
+
const overlapWager = new BigNumber(2500);
|
|
304
|
+
|
|
305
|
+
it('non-KYC2: should not double-count wager consumed by earlier events', () => {
|
|
306
|
+
const result = AirdropCalculator.getTokenAllocationInfo({
|
|
307
|
+
tokenAllocations: overlapAllocations,
|
|
308
|
+
tokensClaimed: new BigNumber(0),
|
|
309
|
+
usdTotalWagered: overlapWager,
|
|
310
|
+
hasKyc2: false,
|
|
311
|
+
});
|
|
312
|
+
expect(result.tokensClaimable.toString()).toBe('105');
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('KYC2: should correctly attribute wager to each event window', () => {
|
|
316
|
+
const result = AirdropCalculator.getTokenAllocationInfo({
|
|
317
|
+
tokenAllocations: overlapAllocations,
|
|
318
|
+
tokensClaimed: new BigNumber(0),
|
|
319
|
+
usdTotalWagered: overlapWager,
|
|
320
|
+
hasKyc2: true,
|
|
321
|
+
});
|
|
322
|
+
expect(result.tokensClaimable.toString()).toBe('170');
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
});
|