shufflecom-calculations 6.7.2 → 6.8.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.
@@ -0,0 +1,5 @@
1
+ export declare enum WalletProduct {
2
+ CRYPTO_DEPOSIT = "CRYPTO_DEPOSIT",
3
+ BUNDLE_PACKAGE = "BUNDLE_PACKAGE",
4
+ GOLD_COIN_PACKAGE = "GOLD_COIN_PACKAGE"
5
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletProduct = void 0;
4
+ var WalletProduct;
5
+ (function (WalletProduct) {
6
+ WalletProduct["CRYPTO_DEPOSIT"] = "CRYPTO_DEPOSIT";
7
+ WalletProduct["BUNDLE_PACKAGE"] = "BUNDLE_PACKAGE";
8
+ WalletProduct["GOLD_COIN_PACKAGE"] = "GOLD_COIN_PACKAGE";
9
+ })(WalletProduct || (exports.WalletProduct = WalletProduct = {}));
10
+ //# sourceMappingURL=wallet-product.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-product.type.js","sourceRoot":"","sources":["../../src/types/wallet-product.type.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kDAAiC,CAAA;IACjC,kDAAiC,CAAA;IACjC,wDAAuC,CAAA;AACzC,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shufflecom-calculations",
3
- "version": "6.7.2",
3
+ "version": "6.8.0",
4
4
  "description": "",
5
5
  "types": "lib/index.d.ts",
6
6
  "main": "lib/index.js",
@@ -19,5 +19,5 @@
19
19
  },
20
20
  "author": "",
21
21
  "license": "ISC",
22
- "gitHead": "3784c9535594ada13ca83abbb5b4fa8aeb7d821f"
22
+ "gitHead": "aa6d35e33a97dff5bb25838a0999b5afd4f97fa2"
23
23
  }
package/src/index.ts CHANGED
@@ -8,7 +8,8 @@ export { ChatMessageType, ChatMessage } from './utils/chat-message.type';
8
8
  export { DatesCalculator } from './utils/dates-calculator';
9
9
  export { VipBonusIssuanceStatus } from './utils/vip-bonus.type';
10
10
  export { deriveBonusIssuances } from './utils/derive-vip-bonus';
11
- export { derivePurchaseBonusMultiplier } from './utils/derive-purchase-bonus-multiplier';
11
+ export { derivePurchaseBonusMultiplier } from './sweep-stakes/derive-purchase-bonus-multiplier';
12
+ export { SweepStakePurchasePackageCalculator, SWEEP_STAKE_PURCHASE_PACKAGES } from './sweep-stakes/sweep-stakes-package';
12
13
  export { convertBs58ToUuid, convertUuidToBs58 } from './utils/uuid-converter';
13
14
  export { Dice, DiceDirection } from './games/dice';
14
15
  export { Roulette } from './games/roulette';
@@ -0,0 +1,49 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { WalletProduct } from '../types/wallet-product.type';
3
+
4
+ export const SC_GC_BUNDLE_RATE = 10_000;
5
+
6
+ type SweepStakePurchasePackages = {
7
+ usdAmount: number;
8
+ product: WalletProduct.BUNDLE_PACKAGE | WalletProduct.GOLD_COIN_PACKAGE;
9
+ };
10
+
11
+ export const SWEEP_STAKE_PURCHASE_PACKAGES: SweepStakePurchasePackages[] = [
12
+ { usdAmount: 5, product: WalletProduct.BUNDLE_PACKAGE },
13
+ { usdAmount: 10, product: WalletProduct.BUNDLE_PACKAGE },
14
+ { usdAmount: 20, product: WalletProduct.BUNDLE_PACKAGE },
15
+ { usdAmount: 50, product: WalletProduct.BUNDLE_PACKAGE },
16
+ { usdAmount: 100, product: WalletProduct.BUNDLE_PACKAGE },
17
+ { usdAmount: 250, product: WalletProduct.BUNDLE_PACKAGE },
18
+ { usdAmount: 500, product: WalletProduct.BUNDLE_PACKAGE },
19
+ { usdAmount: 1000, product: WalletProduct.BUNDLE_PACKAGE },
20
+ { usdAmount: 30, product: WalletProduct.GOLD_COIN_PACKAGE },
21
+ ];
22
+
23
+ export class SweepStakePurchasePackageCalculator {
24
+ static usdToGc(usdAmount: BigNumber.Value): BigNumber {
25
+ return new BigNumber(usdAmount).times(SC_GC_BUNDLE_RATE);
26
+ }
27
+
28
+ static getPackageValue({ usdAmount, product }: { usdAmount: BigNumber.Value; product: WalletProduct }): { gc: BigNumber; sc: BigNumber } {
29
+ switch (product) {
30
+ case WalletProduct.BUNDLE_PACKAGE:
31
+ return {
32
+ gc: SweepStakePurchasePackageCalculator.usdToGc(usdAmount),
33
+ sc: new BigNumber(usdAmount),
34
+ };
35
+ case WalletProduct.GOLD_COIN_PACKAGE:
36
+ return {
37
+ gc: SweepStakePurchasePackageCalculator.usdToGc(usdAmount),
38
+ sc: new BigNumber(0),
39
+ };
40
+ case WalletProduct.CRYPTO_DEPOSIT:
41
+ return {
42
+ gc: new BigNumber(0),
43
+ sc: new BigNumber(0),
44
+ };
45
+ default:
46
+ return product satisfies never;
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,5 @@
1
+ export enum WalletProduct {
2
+ CRYPTO_DEPOSIT = 'CRYPTO_DEPOSIT',
3
+ BUNDLE_PACKAGE = 'BUNDLE_PACKAGE',
4
+ GOLD_COIN_PACKAGE = 'GOLD_COIN_PACKAGE',
5
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"derive-purchase-bonus-multiplier.js","sourceRoot":"","sources":["../../src/utils/derive-purchase-bonus-multiplier.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAIrC,MAAM,eAAe,GAA6C;IAChE,GAAG,EAAE,KAAM;IACX,GAAG,EAAE,GAAG;CACT,CAAC;AAgBF,SAAgB,6BAA6B,CAC3C,WAAqC,EACrC,EAAE,WAAW,EAAE,YAAY,EAA8F;IAEzH,MAAM,OAAO,GAAG,IAAI,sBAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,sB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