@dripfi/drip-sdk 1.4.25 → 1.4.26-slot-machine-2

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/PerqApi.d.ts CHANGED
@@ -25,6 +25,7 @@ export default class PerqApi {
25
25
  fetchAllLoyaltyCards(): Promise<LoyaltyCard[]>;
26
26
  fetchAllSpecialEditionLoyaltyCards(): Promise<SpecialEditionLoyaltyCard[]>;
27
27
  fetchOwnedLoyaltyCard(walletAddress: string): Promise<LoyaltyCard>;
28
+ fetchNextLoyaltyCard(walletAddress: string): Promise<LoyaltyCard>;
28
29
  fetchOwnedSpecialEditionLoyaltyCards(walletAddress: string): Promise<SpecialEditionLoyaltyCard[]>;
29
30
  fetchBeansBalance(walletAddress: string): Promise<BeansBalance>;
30
31
  upgradeLoyaltyCard(signedPayload: NonceEnrichedSignedPayload<UpgradeLoyaltyCardPayload>): Promise<LoyaltyCard>;
package/dist/PerqApi.js CHANGED
@@ -175,6 +175,8 @@ class PerqApi {
175
175
  level: card.level,
176
176
  cost: parseFloat(ethers_1.ethers.utils.formatUnits(card.cost.toString(), PERQ_TOKEN_DECIMALS)),
177
177
  boost: card.boost,
178
+ chanceToUpgrade: card.chanceToUpgrade,
179
+ minBurnPerSpin: card.minBurnPerSpin,
178
180
  }));
179
181
  }
180
182
  else {
@@ -204,6 +206,29 @@ class PerqApi {
204
206
  level: data.level,
205
207
  cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), PERQ_TOKEN_DECIMALS)),
206
208
  boost: data.boost,
209
+ chanceToUpgrade: data.chanceToUpgrade,
210
+ minBurnPerSpin: data.minBurnPerSpin,
211
+ };
212
+ }
213
+ else {
214
+ throw Error(`${await res.text()}`);
215
+ }
216
+ }
217
+ async fetchNextLoyaltyCard(walletAddress) {
218
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/loyaltyCards/next`);
219
+ if (res.status === 204) {
220
+ return {};
221
+ }
222
+ if (res.ok) {
223
+ const data = await res.json();
224
+ return {
225
+ id: data.id,
226
+ tier: data.tier,
227
+ level: data.level,
228
+ cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), PERQ_TOKEN_DECIMALS)),
229
+ boost: data.boost,
230
+ chanceToUpgrade: data.chanceToUpgrade,
231
+ minBurnPerSpin: data.minBurnPerSpin,
207
232
  };
208
233
  }
209
234
  else {
@@ -251,6 +276,8 @@ class PerqApi {
251
276
  level: data.level,
252
277
  cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), PERQ_TOKEN_DECIMALS)),
253
278
  boost: data.boost,
279
+ chanceToUpgrade: data.chanceToUpgrade,
280
+ minBurnPerSpin: data.minBurnPerSpin,
254
281
  };
255
282
  }
256
283
  else {
package/dist/PerqSdk.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Signer, ethers } from 'ethers';
2
2
  import { PerqConfig } from './types';
3
3
  import PerqApi from './PerqApi';
4
- import { PerqSwapAndRecyclerContract, PerqTokenRecyclerContract, PerqVestingContract } from './contracts';
4
+ import { PerqSwapAndRecyclerContract, PerqTokenRecyclerContract, PerqVestingContract, SlotBurnTokenContract } from './contracts';
5
5
  import VestingPackage from './subpackages/VestingPackage';
6
6
  import LitePackage from './subpackages/LitePackage';
7
7
  import RecyclerPackage from './subpackages/RecyclerPackage';
@@ -28,6 +28,7 @@ export default class PerqSdk {
28
28
  perqVestingContract: PerqVestingContract;
29
29
  perqTokenRecyclerContract: PerqTokenRecyclerContract;
30
30
  perqSwapAndRecyclerContract: PerqSwapAndRecyclerContract;
31
+ slotBurnTokenContract: SlotBurnTokenContract;
31
32
  constructor(perqConfig: PerqConfig, chainId: PerqSupportedChainId, provider?: ethers.providers.JsonRpcProvider);
32
33
  updateSigner(newSigner: Signer, chainId: PerqSupportedChainId): Promise<void>;
33
34
  }
package/dist/PerqSdk.js CHANGED
@@ -30,6 +30,7 @@ class PerqSdk {
30
30
  perqVestingContract;
31
31
  perqTokenRecyclerContract;
32
32
  perqSwapAndRecyclerContract;
33
+ slotBurnTokenContract;
33
34
  constructor(perqConfig, chainId, provider) {
34
35
  this.perqConfig = perqConfig;
35
36
  const newSigner = provider?.getSigner();
@@ -49,6 +50,7 @@ class PerqSdk {
49
50
  this.perqVestingContract = new contracts_1.PerqVestingContract(this);
50
51
  this.perqTokenRecyclerContract = new contracts_1.PerqTokenRecyclerContract(this);
51
52
  this.perqSwapAndRecyclerContract = new contracts_1.PerqSwapAndRecyclerContract(this);
53
+ this.slotBurnTokenContract = new contracts_1.SlotBurnTokenContract(this);
52
54
  }
53
55
  async updateSigner(newSigner, chainId) {
54
56
  this.signer = newSigner;
@@ -56,6 +58,7 @@ class PerqSdk {
56
58
  this.perqVestingContract = new contracts_1.PerqVestingContract(this);
57
59
  this.perqTokenRecyclerContract = new contracts_1.PerqTokenRecyclerContract(this);
58
60
  this.perqSwapAndRecyclerContract = new contracts_1.PerqSwapAndRecyclerContract(this);
61
+ this.slotBurnTokenContract = new contracts_1.SlotBurnTokenContract(this);
59
62
  }
60
63
  }
61
64
  exports.default = PerqSdk;
@@ -0,0 +1,86 @@
1
+ [
2
+ {
3
+ "inputs": [{ "internalType": "address", "name": "admin", "type": "address" }],
4
+ "stateMutability": "nonpayable",
5
+ "type": "constructor"
6
+ },
7
+ {
8
+ "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }],
9
+ "name": "OwnableInvalidOwner",
10
+ "type": "error"
11
+ },
12
+ {
13
+ "inputs": [{ "internalType": "address", "name": "account", "type": "address" }],
14
+ "name": "OwnableUnauthorizedAccount",
15
+ "type": "error"
16
+ },
17
+ {
18
+ "inputs": [{ "internalType": "address", "name": "token", "type": "address" }],
19
+ "name": "SafeERC20FailedOperation",
20
+ "type": "error"
21
+ },
22
+ {
23
+ "anonymous": false,
24
+ "inputs": [
25
+ { "indexed": true, "internalType": "address", "name": "depositor", "type": "address" },
26
+ { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
27
+ ],
28
+ "name": "Deposit",
29
+ "type": "event"
30
+ },
31
+ {
32
+ "anonymous": false,
33
+ "inputs": [
34
+ { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
35
+ { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
36
+ ],
37
+ "name": "OwnershipTransferred",
38
+ "type": "event"
39
+ },
40
+ {
41
+ "anonymous": false,
42
+ "inputs": [
43
+ { "indexed": true, "internalType": "address", "name": "to", "type": "address" },
44
+ { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
45
+ ],
46
+ "name": "Withdraw",
47
+ "type": "event"
48
+ },
49
+ {
50
+ "inputs": [],
51
+ "name": "WRAPPED_SONIC",
52
+ "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }],
53
+ "stateMutability": "view",
54
+ "type": "function"
55
+ },
56
+ {
57
+ "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
58
+ "name": "deposit",
59
+ "outputs": [],
60
+ "stateMutability": "nonpayable",
61
+ "type": "function"
62
+ },
63
+ { "inputs": [], "name": "depositNative", "outputs": [], "stateMutability": "payable", "type": "function" },
64
+ {
65
+ "inputs": [],
66
+ "name": "owner",
67
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
68
+ "stateMutability": "view",
69
+ "type": "function"
70
+ },
71
+ { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
72
+ {
73
+ "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
74
+ "name": "transferOwnership",
75
+ "outputs": [],
76
+ "stateMutability": "nonpayable",
77
+ "type": "function"
78
+ },
79
+ {
80
+ "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
81
+ "name": "withdraw",
82
+ "outputs": [],
83
+ "stateMutability": "nonpayable",
84
+ "type": "function"
85
+ }
86
+ ]
@@ -71,5 +71,62 @@ declare const _default: {
71
71
  stateMutability: string;
72
72
  type: string;
73
73
  }[];
74
+ readonly SLOT_BURN_TOKEN_ABI: ({
75
+ inputs: {
76
+ internalType: string;
77
+ name: string;
78
+ type: string;
79
+ }[];
80
+ stateMutability: string;
81
+ type: string;
82
+ name?: undefined;
83
+ anonymous?: undefined;
84
+ outputs?: undefined;
85
+ } | {
86
+ inputs: {
87
+ internalType: string;
88
+ name: string;
89
+ type: string;
90
+ }[];
91
+ name: string;
92
+ type: string;
93
+ stateMutability?: undefined;
94
+ anonymous?: undefined;
95
+ outputs?: undefined;
96
+ } | {
97
+ anonymous: boolean;
98
+ inputs: {
99
+ indexed: boolean;
100
+ internalType: string;
101
+ name: string;
102
+ type: string;
103
+ }[];
104
+ name: string;
105
+ type: string;
106
+ stateMutability?: undefined;
107
+ outputs?: undefined;
108
+ } | {
109
+ inputs: never[];
110
+ name: string;
111
+ outputs: {
112
+ internalType: string;
113
+ name: string;
114
+ type: string;
115
+ }[];
116
+ stateMutability: string;
117
+ type: string;
118
+ anonymous?: undefined;
119
+ } | {
120
+ inputs: {
121
+ internalType: string;
122
+ name: string;
123
+ type: string;
124
+ }[];
125
+ name: string;
126
+ outputs: never[];
127
+ stateMutability: string;
128
+ type: string;
129
+ anonymous?: undefined;
130
+ })[];
74
131
  };
75
132
  export default _default;
package/dist/abi/index.js CHANGED
@@ -8,10 +8,12 @@ const WethTokenAbi_json_1 = __importDefault(require("./WethTokenAbi.json"));
8
8
  const PerqTokenAbi_json_1 = __importDefault(require("./PerqTokenAbi.json"));
9
9
  const TokenRecyclerAbi_json_1 = __importDefault(require("./TokenRecyclerAbi.json"));
10
10
  const PerqVestingAbi_json_1 = __importDefault(require("./PerqVestingAbi.json"));
11
+ const SlotBurnTokenAbi_json_1 = __importDefault(require("./SlotBurnTokenAbi.json"));
11
12
  exports.default = {
12
13
  PERQ_SWAP_AND_RECYCLER_ABI: PerqSwapAndRecyclerAbi_json_1.default,
13
14
  WETH_TOKEN_ABI: WethTokenAbi_json_1.default,
14
15
  PERQ_TOKEN_ABI: PerqTokenAbi_json_1.default,
15
16
  TOKEN_RECYCLER_ABI: TokenRecyclerAbi_json_1.default,
16
17
  PERQ_VESTING_ABI: PerqVestingAbi_json_1.default,
18
+ SLOT_BURN_TOKEN_ABI: SlotBurnTokenAbi_json_1.default,
17
19
  };
@@ -0,0 +1,8 @@
1
+ import { ContractTransaction } from 'ethers';
2
+ import BasePerqContract from './BasePerqContract';
3
+ import PerqSdk from '../PerqSdk';
4
+ export default class SlotBurnTokenContract extends BasePerqContract {
5
+ constructor(perqSdk: PerqSdk);
6
+ deposit(amount: string): Promise<ContractTransaction>;
7
+ depositNative(amount: string): Promise<ContractTransaction>;
8
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ethers_1 = require("ethers");
7
+ const SlotBurnTokenAbi_json_1 = __importDefault(require("../abi/SlotBurnTokenAbi.json"));
8
+ const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
9
+ class SlotBurnTokenContract extends BasePerqContract_1.default {
10
+ constructor(perqSdk) {
11
+ super(perqSdk.perqConfig.slotBurnTokenAddress, new ethers_1.ethers.utils.Interface(SlotBurnTokenAbi_json_1.default), perqSdk.signer);
12
+ }
13
+ async deposit(amount) {
14
+ if (!this.contract.signer) {
15
+ throw Error('No signer provided');
16
+ }
17
+ return await this.contract.deposit(amount.toString());
18
+ }
19
+ async depositNative(amount) {
20
+ if (!this.contract.signer) {
21
+ throw Error('No signer provided');
22
+ }
23
+ return await this.contract.depositNative({ value: amount.toString() });
24
+ }
25
+ }
26
+ exports.default = SlotBurnTokenContract;
@@ -3,4 +3,5 @@ import PerqSwapAndRecyclerContract from './PerqSwapAndRecyclerContract';
3
3
  import PerqTokenRecyclerContract from './PerqTokenRecyclerContract';
4
4
  import PerqTokenContract from './PerqTokenContract';
5
5
  import PerqVestingContract from './PerqVestingContract';
6
- export { BasePerqContract, PerqSwapAndRecyclerContract, PerqTokenRecyclerContract, PerqTokenContract, PerqVestingContract, };
6
+ import SlotBurnTokenContract from './SlotBurnTokenContract';
7
+ export { BasePerqContract, PerqSwapAndRecyclerContract, PerqTokenRecyclerContract, PerqTokenContract, PerqVestingContract, SlotBurnTokenContract, };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PerqVestingContract = exports.PerqTokenContract = exports.PerqTokenRecyclerContract = exports.PerqSwapAndRecyclerContract = exports.BasePerqContract = void 0;
6
+ exports.SlotBurnTokenContract = exports.PerqVestingContract = exports.PerqTokenContract = exports.PerqTokenRecyclerContract = exports.PerqSwapAndRecyclerContract = exports.BasePerqContract = void 0;
7
7
  const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
8
8
  exports.BasePerqContract = BasePerqContract_1.default;
9
9
  const PerqSwapAndRecyclerContract_1 = __importDefault(require("./PerqSwapAndRecyclerContract"));
@@ -14,3 +14,5 @@ const PerqTokenContract_1 = __importDefault(require("./PerqTokenContract"));
14
14
  exports.PerqTokenContract = PerqTokenContract_1.default;
15
15
  const PerqVestingContract_1 = __importDefault(require("./PerqVestingContract"));
16
16
  exports.PerqVestingContract = PerqVestingContract_1.default;
17
+ const SlotBurnTokenContract_1 = __importDefault(require("./SlotBurnTokenContract"));
18
+ exports.SlotBurnTokenContract = SlotBurnTokenContract_1.default;
@@ -8,8 +8,12 @@ export default class LoyaltyPackage {
8
8
  getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
9
9
  upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>;
10
10
  getOwnedLoyaltyCard(): Promise<LoyaltyCard>;
11
+ getNextLoyaltyCard(): Promise<LoyaltyCard>;
11
12
  getAllLoyaltyCards(): Promise<LoyaltyCard[]>;
12
13
  claimSpecialEditionCard(cardId: string): Promise<SpecialEditionLoyaltyCard>;
13
14
  getOwnedSpecialEditionCards(): Promise<SpecialEditionLoyaltyCard[]>;
14
15
  getAllSpecialEditionCards(): Promise<SpecialEditionLoyaltyCard[]>;
16
+ approveForSlotSpin(tokenAddress: string, amount: string): Promise<string>;
17
+ runSlotSpin(isDepositNative: boolean): Promise<LoyaltyCard | null>;
18
+ private seededRandom;
15
19
  }
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ethers_1 = require("ethers");
7
+ const ERC20TokenContract_1 = __importDefault(require("../contracts/ERC20TokenContract"));
3
8
  class LoyaltyPackage {
4
9
  perqSdk;
5
10
  constructor(perqSdk) {
@@ -27,6 +32,10 @@ class LoyaltyPackage {
27
32
  const signerAddress = await this.perqSdk.signer.getAddress();
28
33
  return this.perqSdk.perqApi.fetchOwnedLoyaltyCard(signerAddress);
29
34
  }
35
+ async getNextLoyaltyCard() {
36
+ const signerAddress = await this.perqSdk.signer.getAddress();
37
+ return this.perqSdk.perqApi.fetchNextLoyaltyCard(signerAddress);
38
+ }
30
39
  async getAllLoyaltyCards() {
31
40
  return this.perqSdk.perqApi.fetchAllLoyaltyCards();
32
41
  }
@@ -44,5 +53,42 @@ class LoyaltyPackage {
44
53
  async getAllSpecialEditionCards() {
45
54
  return this.perqSdk.perqApi.fetchAllSpecialEditionLoyaltyCards();
46
55
  }
56
+ async approveForSlotSpin(tokenAddress, amount) {
57
+ if (!this.perqSdk.signer) {
58
+ throw Error('No signer provided');
59
+ }
60
+ const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
61
+ const decimals = await tokenContract.getPrecission();
62
+ const parsedAmountToApprove = ethers_1.ethers.utils.parseUnits(amount, decimals);
63
+ const slotBurnTokenContractAddress = this.perqSdk.slotBurnTokenContract.getContractAddress();
64
+ return await tokenContract.approveToken(slotBurnTokenContractAddress, parsedAmountToApprove.toBigInt());
65
+ }
66
+ async runSlotSpin(isDepositNative) {
67
+ const signerAddress = await this.perqSdk.signer.getAddress();
68
+ const nextLoyaltyCard = await this.perqSdk.perqApi.fetchNextLoyaltyCard(signerAddress);
69
+ const amountForSpin = nextLoyaltyCard.minBurnPerSpin;
70
+ const loyaltyCardOwnedChancesToWin = nextLoyaltyCard.chanceToUpgrade;
71
+ const formattedAmountForSpin = ethers_1.ethers.utils.parseUnits(amountForSpin.toString(), 18);
72
+ const depositResult = isDepositNative
73
+ ? await this.perqSdk.slotBurnTokenContract.depositNative(formattedAmountForSpin.toString())
74
+ : await this.perqSdk.slotBurnTokenContract.deposit(formattedAmountForSpin.toString());
75
+ const txHash = depositResult.hash;
76
+ const randomValue = this.seededRandom(txHash);
77
+ const upgradeWon = randomValue * 100 <= loyaltyCardOwnedChancesToWin && loyaltyCardOwnedChancesToWin !== 0;
78
+ return upgradeWon ? nextLoyaltyCard : null;
79
+ }
80
+ seededRandom(input) {
81
+ // Convert input string to bytes
82
+ const inputBytes = ethers_1.ethers.utils.toUtf8Bytes(input);
83
+ // Hash using keccak256
84
+ const hash = ethers_1.ethers.utils.keccak256(inputBytes);
85
+ // Convert to a Buffer from hex string (strip 0x)
86
+ const hashBuffer = new Uint8Array(ethers_1.ethers.utils.arrayify(hash));
87
+ const dataView = new DataView(hashBuffer.buffer);
88
+ // Read first 8 bytes as BigUInt64
89
+ const num = dataView.getBigUint64(0);
90
+ // Normalize to [0, 1)
91
+ return Number(num % BigInt(1e12)) / 1e12;
92
+ }
47
93
  }
48
94
  exports.default = LoyaltyPackage;
@@ -5,5 +5,7 @@ type LoyaltyCard = {
5
5
  level: number;
6
6
  cost: number;
7
7
  boost: number;
8
+ chanceToUpgrade: number;
9
+ minBurnPerSpin: number;
8
10
  };
9
11
  export default LoyaltyCard;
@@ -12,5 +12,6 @@ type MyPerqData = VaultData & MyPerqBalance & {
12
12
  btcPrice: number;
13
13
  distributionType: VaultType;
14
14
  projectTvl: number;
15
+ projectPeakTvlUsd: number;
15
16
  };
16
17
  export default MyPerqData;
@@ -5,6 +5,7 @@ type PerqConfig = {
5
5
  perqTokenAddress: string;
6
6
  perqTokenRecyclerAddress: string;
7
7
  perqSwapAndRecyclerAddress: string;
8
+ slotBurnTokenAddress: string;
8
9
  perqVestingAddress: string;
9
10
  swapAndDepositContractAddress: string;
10
11
  ethereumSwapperAddress: string;
@@ -12,6 +12,7 @@ exports.PRODUCTION = {
12
12
  swapAndDepositContractAddress: '0xd8534197bd587f8226d12e0c864ef2cae6f82f5c',
13
13
  ethereumSwapperAddress: '0x33e52c206d584550193e642c8982f2fff6339994',
14
14
  smartVaultManagerContractAddress: '0x23daf34e2b9af02a74dc19cb52af727b19403874',
15
+ slotBurnTokenAddress: '0xf9baae6b27093099f9821bdc7f4e29c770e8abe7',
15
16
  };
16
17
  exports.DEVELOPMENT = {
17
18
  route: 'https://dev.perq.finance',
@@ -22,4 +23,5 @@ exports.DEVELOPMENT = {
22
23
  swapAndDepositContractAddress: '0x5fb08e00de169f041711206a0995410884080177',
23
24
  ethereumSwapperAddress: '0xe411921ee9eedfefd7b9ae15bf232bd36949fcbbc',
24
25
  smartVaultManagerContractAddress: '0x2638d6c0b4ef6dee04050fa0b07ca62500435747',
26
+ slotBurnTokenAddress: '0xf9baae6b27093099f9821bdc7f4e29c770e8abe7',
25
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dripfi/drip-sdk",
3
- "version": "1.4.25",
3
+ "version": "1.4.26-slot-machine-2",
4
4
  "description": "Drip SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",