@dripfi/drip-sdk 1.4.26 → 1.4.28-slot-machine
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/README.md +9 -0
- package/dist/PerqApi.d.ts +3 -0
- package/dist/PerqApi.js +37 -0
- package/dist/PerqSdk.d.ts +2 -1
- package/dist/PerqSdk.js +3 -0
- package/dist/abi/SlotBurnTokenAbi.json +86 -0
- package/dist/abi/index.d.ts +57 -0
- package/dist/abi/index.js +2 -0
- package/dist/contracts/SlotBurnTokenContract.d.ts +8 -0
- package/dist/contracts/SlotBurnTokenContract.js +26 -0
- package/dist/contracts/index.d.ts +2 -1
- package/dist/contracts/index.js +3 -1
- package/dist/subpackages/LoyaltyCardsPackage.d.ts +4 -0
- package/dist/subpackages/LoyaltyCardsPackage.js +46 -0
- package/dist/subpackages/PoolsPackage.d.ts +5 -0
- package/dist/subpackages/PoolsPackage.js +6 -0
- package/dist/types/LoyaltyCard.d.ts +2 -0
- package/dist/types/MyPerqData.d.ts +2 -0
- package/dist/types/OverallStats.d.ts +7 -0
- package/dist/types/OverallStats.js +2 -0
- package/dist/types/PerqConfig.d.ts +1 -0
- package/dist/types/PerqConfig.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -120,6 +120,7 @@ Access pools methods through `sdk.pools`:
|
|
120
120
|
| `getAllProjects(): Promise<ReducedProjectData[]>` | Fetches all available projects. |
|
121
121
|
| `getProjectDetails(projectName: string): Promise<DetailedProjectData>` | Fetches the details of a specific project. |
|
122
122
|
| `getPoolStats(): Promise<VaultStats>` | Fetches the statistics of a pool. |
|
123
|
+
| `getOverallStats(): Promise<OverallStats>` | Fetches different stats |
|
123
124
|
| `getRewardsPerHour(vaultAddress: string): Promise<number>` | Calculates the rewards per hour for a specific pool. |
|
124
125
|
| `getUserBoostedNfts(vaultAddress: string): Promise<string[]>` | Fetches the user's boosted NFTs for a specific pool. |
|
125
126
|
| `getRewards(): Promise<UserRewards>` | Fetches the user's rewards. |
|
@@ -683,6 +684,14 @@ type Earnings = {
|
|
683
684
|
earningPerHour: string;
|
684
685
|
};
|
685
686
|
};
|
687
|
+
|
688
|
+
type OverallStats = {
|
689
|
+
activeProjects: number;
|
690
|
+
totalTvl: number;
|
691
|
+
totalYieldUsd: number;
|
692
|
+
totalUsers: number;
|
693
|
+
};
|
694
|
+
|
686
695
|
```
|
687
696
|
|
688
697
|
## Abis
|
package/dist/PerqApi.d.ts
CHANGED
@@ -5,6 +5,7 @@ import PerqSdk from './PerqSdk';
|
|
5
5
|
import MigrationOption from './types/MigrationOption';
|
6
6
|
import ProjectHistoricalTvl from './types/ProjectHistoricalTvl';
|
7
7
|
import ClaimSpecialEditionLoyaltyCardPayload from './types/ClaimSpecialEditionLoyaltyCardPayload';
|
8
|
+
import OverallStats from './types/OverallStats';
|
8
9
|
export default class PerqApi {
|
9
10
|
private perqSdk;
|
10
11
|
constructor(perqSdk: PerqSdk);
|
@@ -17,6 +18,7 @@ export default class PerqApi {
|
|
17
18
|
getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number, chainId: string): Promise<string>;
|
18
19
|
getUserBoostedNfts(walletAddress: string, vaultAddress: string): Promise<string[]>;
|
19
20
|
fetchPoolStats(): Promise<VaultStats>;
|
21
|
+
fetchOverallStats(): Promise<OverallStats>;
|
20
22
|
fetchRewardsPerHour(walletAddress: string, vaultAddress: string): Promise<number>;
|
21
23
|
getSwapInfo(fromTokenAddress: string, toTokenAddress: string, amount: BigNumber, fromAddress: string, chainId: number): Promise<SwapInfo[]>;
|
22
24
|
fetchEnrichedUserWNFTForPool(vaultAddress: string, walletAddress: string): Promise<any[]>;
|
@@ -25,6 +27,7 @@ export default class PerqApi {
|
|
25
27
|
fetchAllLoyaltyCards(): Promise<LoyaltyCard[]>;
|
26
28
|
fetchAllSpecialEditionLoyaltyCards(): Promise<SpecialEditionLoyaltyCard[]>;
|
27
29
|
fetchOwnedLoyaltyCard(walletAddress: string): Promise<LoyaltyCard>;
|
30
|
+
fetchNextLoyaltyCard(walletAddress: string): Promise<LoyaltyCard>;
|
28
31
|
fetchOwnedSpecialEditionLoyaltyCards(walletAddress: string): Promise<SpecialEditionLoyaltyCard[]>;
|
29
32
|
fetchBeansBalance(walletAddress: string): Promise<BeansBalance>;
|
30
33
|
upgradeLoyaltyCard(signedPayload: NonceEnrichedSignedPayload<UpgradeLoyaltyCardPayload>): Promise<LoyaltyCard>;
|
package/dist/PerqApi.js
CHANGED
@@ -105,6 +105,16 @@ class PerqApi {
|
|
105
105
|
throw Error(`${await res.text()}`);
|
106
106
|
}
|
107
107
|
}
|
108
|
+
async fetchOverallStats() {
|
109
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/overallStats`);
|
110
|
+
if (res.ok) {
|
111
|
+
const data = await res.json();
|
112
|
+
return data;
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
throw Error(`${await res.text()}`);
|
116
|
+
}
|
117
|
+
}
|
108
118
|
async fetchRewardsPerHour(walletAddress, vaultAddress) {
|
109
119
|
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/rewardsPerHour/${vaultAddress}`);
|
110
120
|
if (res.ok) {
|
@@ -175,6 +185,8 @@ class PerqApi {
|
|
175
185
|
level: card.level,
|
176
186
|
cost: parseFloat(ethers_1.ethers.utils.formatUnits(card.cost.toString(), PERQ_TOKEN_DECIMALS)),
|
177
187
|
boost: card.boost,
|
188
|
+
chanceToUpgrade: card.chanceToUpgrade,
|
189
|
+
minBurnPerSpin: card.minBurnPerSpin,
|
178
190
|
}));
|
179
191
|
}
|
180
192
|
else {
|
@@ -204,6 +216,29 @@ class PerqApi {
|
|
204
216
|
level: data.level,
|
205
217
|
cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), PERQ_TOKEN_DECIMALS)),
|
206
218
|
boost: data.boost,
|
219
|
+
chanceToUpgrade: data.chanceToUpgrade,
|
220
|
+
minBurnPerSpin: data.minBurnPerSpin,
|
221
|
+
};
|
222
|
+
}
|
223
|
+
else {
|
224
|
+
throw Error(`${await res.text()}`);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
async fetchNextLoyaltyCard(walletAddress) {
|
228
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/loyaltyCards/next`);
|
229
|
+
if (res.status === 204) {
|
230
|
+
return {};
|
231
|
+
}
|
232
|
+
if (res.ok) {
|
233
|
+
const data = await res.json();
|
234
|
+
return {
|
235
|
+
id: data.id,
|
236
|
+
tier: data.tier,
|
237
|
+
level: data.level,
|
238
|
+
cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), PERQ_TOKEN_DECIMALS)),
|
239
|
+
boost: data.boost,
|
240
|
+
chanceToUpgrade: data.chanceToUpgrade,
|
241
|
+
minBurnPerSpin: data.minBurnPerSpin,
|
207
242
|
};
|
208
243
|
}
|
209
244
|
else {
|
@@ -251,6 +286,8 @@ class PerqApi {
|
|
251
286
|
level: data.level,
|
252
287
|
cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), PERQ_TOKEN_DECIMALS)),
|
253
288
|
boost: data.boost,
|
289
|
+
chanceToUpgrade: data.chanceToUpgrade,
|
290
|
+
minBurnPerSpin: data.minBurnPerSpin,
|
254
291
|
};
|
255
292
|
}
|
256
293
|
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
|
+
]
|
package/dist/abi/index.d.ts
CHANGED
@@ -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
|
-
|
6
|
+
import SlotBurnTokenContract from './SlotBurnTokenContract';
|
7
|
+
export { BasePerqContract, PerqSwapAndRecyclerContract, PerqTokenRecyclerContract, PerqTokenContract, PerqVestingContract, SlotBurnTokenContract, };
|
package/dist/contracts/index.js
CHANGED
@@ -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;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import PerqSdk from '../PerqSdk';
|
2
2
|
import { DetailedProjectData, MyPerqData, ReducedProjectData, UserRewards, VaultData, VaultStats } from '../types';
|
3
|
+
import OverallStats from '../types/OverallStats';
|
3
4
|
export default class PoolsPackage {
|
4
5
|
private perqSdk;
|
5
6
|
constructor(perqSdk: PerqSdk);
|
@@ -9,6 +10,10 @@ export default class PoolsPackage {
|
|
9
10
|
getPoolDetails(vaultAddress: string, onChainProjectId: number): Promise<VaultData>;
|
10
11
|
getAllProjects(): Promise<ReducedProjectData[]>;
|
11
12
|
getProjectDetails(projectName: string): Promise<DetailedProjectData>;
|
13
|
+
getOverallStats(): Promise<OverallStats>;
|
14
|
+
/**
|
15
|
+
* @deprecated Use `getOverallStats()` instead.
|
16
|
+
*/
|
12
17
|
getPoolStats(): Promise<VaultStats>;
|
13
18
|
getRewardsPerHour(vaultAddress: string): Promise<number>;
|
14
19
|
getUserBoostedNfts(vaultAddress: string): Promise<string[]>;
|
@@ -32,6 +32,12 @@ class PoolsPackage {
|
|
32
32
|
async getProjectDetails(projectName) {
|
33
33
|
return this.perqSdk.perqApi.fetchProjetctDetails(projectName);
|
34
34
|
}
|
35
|
+
async getOverallStats() {
|
36
|
+
return this.perqSdk.perqApi.fetchOverallStats();
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* @deprecated Use `getOverallStats()` instead.
|
40
|
+
*/
|
35
41
|
async getPoolStats() {
|
36
42
|
return this.perqSdk.perqApi.fetchPoolStats();
|
37
43
|
}
|
package/dist/types/PerqConfig.js
CHANGED
@@ -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
|
};
|