@dripfi/drip-sdk 1.4.9-yelay-lite → 1.4.10
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 +206 -45
- package/dist/PerqApi.d.ts +20 -21
- package/dist/PerqApi.js +103 -88
- package/dist/PerqSdk.d.ts +35 -80
- package/dist/PerqSdk.js +50 -598
- package/dist/abi/ERC20.json +222 -0
- package/dist/contracts/ERC20TokenContract.d.ts +10 -0
- package/dist/contracts/ERC20TokenContract.js +34 -0
- package/dist/contracts/PerqSwapAndRecyclerContract.d.ts +3 -2
- package/dist/contracts/PerqSwapAndRecyclerContract.js +2 -2
- package/dist/contracts/PerqTokenRecyclerContract.d.ts +3 -2
- package/dist/contracts/PerqTokenRecyclerContract.js +2 -2
- package/dist/contracts/PerqVestingContract.d.ts +3 -2
- package/dist/contracts/PerqVestingContract.js +2 -2
- package/dist/subpackages/LitePackage.d.ts +16 -0
- package/dist/subpackages/LitePackage.js +102 -0
- package/dist/subpackages/LoyaltyCardsPackage.d.ts +12 -0
- package/dist/subpackages/LoyaltyCardsPackage.js +34 -0
- package/dist/subpackages/PoolsPackage.d.ts +16 -0
- package/dist/subpackages/PoolsPackage.js +52 -0
- package/dist/subpackages/RecyclerPackage.d.ts +13 -0
- package/dist/subpackages/RecyclerPackage.js +87 -0
- package/dist/subpackages/SignHandlerPackage.d.ts +8 -0
- package/dist/subpackages/SignHandlerPackage.js +33 -0
- package/dist/subpackages/TokenUtilsPackage.d.ts +13 -0
- package/dist/subpackages/TokenUtilsPackage.js +66 -0
- package/dist/subpackages/UserPackage.d.ts +10 -0
- package/dist/subpackages/UserPackage.js +36 -0
- package/dist/subpackages/V2Package.d.ts +24 -0
- package/dist/subpackages/V2Package.js +207 -0
- package/dist/subpackages/VestingPackage.d.ts +14 -0
- package/dist/subpackages/VestingPackage.js +112 -0
- package/dist/types/ChainId.d.ts +5 -0
- package/dist/types/ChainId.js +7 -0
- package/dist/types/DeployedProject.d.ts +1 -0
- package/dist/types/DetailedProjectData.d.ts +8 -7
- package/dist/types/Earnings.d.ts +11 -0
- package/dist/types/LinkWalletPayload.d.ts +4 -2
- package/dist/types/LinkedPodWallets.d.ts +5 -0
- package/dist/types/MigrationOption.d.ts +6 -0
- package/dist/types/MigrationOption.js +2 -0
- package/dist/types/MyPerqData.d.ts +4 -8
- package/dist/types/PerqConfig.d.ts +5 -4
- package/dist/types/PerqConfig.js +12 -12
- package/dist/types/ReducedProjectData.d.ts +2 -1
- package/dist/types/VaultData.d.ts +15 -11
- package/dist/types/index.d.ts +5 -3
- package/package.json +2 -2
- package/dist/types/VaultRewardData.d.ts +0 -9
- package/dist/types/YelayLiteVault.d.ts +0 -11
- /package/dist/types/{VaultRewardData.js → Earnings.js} +0 -0
- /package/dist/types/{YelayLiteVault.js → LinkedPodWallets.js} +0 -0
package/dist/PerqApi.js
CHANGED
@@ -4,12 +4,12 @@ const ethers_1 = require("ethers");
|
|
4
4
|
const PERQ_TOKEN_DECIMALS = 18;
|
5
5
|
const WETH_TOKEN_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
6
6
|
class PerqApi {
|
7
|
-
|
8
|
-
constructor(
|
9
|
-
this.
|
7
|
+
perqSdk;
|
8
|
+
constructor(perqSdk) {
|
9
|
+
this.perqSdk = perqSdk;
|
10
10
|
}
|
11
|
-
async
|
12
|
-
const res = await fetch(`${this.route}/api-be/api/vault
|
11
|
+
async fetchAllPools() {
|
12
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/vault`);
|
13
13
|
if (res.ok) {
|
14
14
|
const data = (await res.json());
|
15
15
|
return data;
|
@@ -18,8 +18,18 @@ class PerqApi {
|
|
18
18
|
throw Error(`${await res.text()}`);
|
19
19
|
}
|
20
20
|
}
|
21
|
-
async
|
22
|
-
const res = await fetch(`${this.route}/api-be/api/vault
|
21
|
+
async fetchPoolV2Details(vaultAddress) {
|
22
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/vault/${vaultAddress}`);
|
23
|
+
if (res.ok) {
|
24
|
+
const data = (await res.json());
|
25
|
+
return data;
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
throw Error(`${await res.text()}`);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
async fetchPoolLiteDetails(vaultAddress, onChainProjectId) {
|
32
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/vault/${vaultAddress}?onChainProjectId=${onChainProjectId}`);
|
23
33
|
if (res.ok) {
|
24
34
|
const data = (await res.json());
|
25
35
|
return data;
|
@@ -29,7 +39,7 @@ class PerqApi {
|
|
29
39
|
}
|
30
40
|
}
|
31
41
|
async fetchAllProjects() {
|
32
|
-
const res = await fetch(`${this.route}/api-be/api/projects`);
|
42
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/projects`);
|
33
43
|
if (res.ok) {
|
34
44
|
const data = await res.json();
|
35
45
|
return data;
|
@@ -39,7 +49,7 @@ class PerqApi {
|
|
39
49
|
}
|
40
50
|
}
|
41
51
|
async fetchProjetctDetails(projectName) {
|
42
|
-
const res = await fetch(`${this.route}/api-be/api/projects/${projectName}`);
|
52
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/projects/${projectName}`);
|
43
53
|
if (res.ok) {
|
44
54
|
const data = await res.json();
|
45
55
|
return data;
|
@@ -49,7 +59,7 @@ class PerqApi {
|
|
49
59
|
}
|
50
60
|
}
|
51
61
|
async fetchTokenPrice(tokenName) {
|
52
|
-
const res = await fetch(`${this.route}/api-be/api/tokenPrice?tokenName=${tokenName}`);
|
62
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/tokenPrice?tokenName=${tokenName}`);
|
53
63
|
if (res.ok) {
|
54
64
|
const data = await res.json();
|
55
65
|
return data.usdPricePerToken;
|
@@ -58,14 +68,15 @@ class PerqApi {
|
|
58
68
|
throw Error(`${await res.text()}`);
|
59
69
|
}
|
60
70
|
}
|
61
|
-
async getExpectedSwapResult(fromTokenAddress, toTokenAddress, amount, decimals) {
|
71
|
+
async getExpectedSwapResult(fromTokenAddress, toTokenAddress, amount, decimals, chainId) {
|
62
72
|
const parsedAmount = ethers_1.ethers.utils.parseUnits(amount, decimals);
|
63
73
|
const queryParams = new URLSearchParams({
|
64
74
|
from: fromTokenAddress,
|
65
75
|
to: toTokenAddress,
|
66
76
|
amount: parsedAmount.toString(),
|
77
|
+
chainId: chainId,
|
67
78
|
});
|
68
|
-
const res = await fetch(`${this.route}/api-be/api/1inch/swap?${queryParams}`);
|
79
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/1inch/swap?${queryParams}`);
|
69
80
|
if (res.ok) {
|
70
81
|
const data = await res.json();
|
71
82
|
return data;
|
@@ -75,7 +86,7 @@ class PerqApi {
|
|
75
86
|
}
|
76
87
|
}
|
77
88
|
async getUserBoostedNfts(walletAddress, vaultAddress) {
|
78
|
-
const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/nftBoost/${vaultAddress}`);
|
89
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/nftBoost/${vaultAddress}`);
|
79
90
|
if (res.ok) {
|
80
91
|
const data = await res.json();
|
81
92
|
return data;
|
@@ -84,8 +95,8 @@ class PerqApi {
|
|
84
95
|
throw Error(`${await res.text()}`);
|
85
96
|
}
|
86
97
|
}
|
87
|
-
async
|
88
|
-
const res = await fetch(`${this.route}/api-be/api/vaultStats`);
|
98
|
+
async fetchPoolStats() {
|
99
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/vaultStats`);
|
89
100
|
if (res.ok) {
|
90
101
|
const data = await res.json();
|
91
102
|
return data;
|
@@ -95,7 +106,7 @@ class PerqApi {
|
|
95
106
|
}
|
96
107
|
}
|
97
108
|
async fetchRewardsPerHour(walletAddress, vaultAddress) {
|
98
|
-
const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/rewardsPerHour/${vaultAddress}`);
|
109
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/rewardsPerHour/${vaultAddress}`);
|
99
110
|
if (res.ok) {
|
100
111
|
const data = await res.json();
|
101
112
|
return data.rewardsPerHour;
|
@@ -104,12 +115,11 @@ class PerqApi {
|
|
104
115
|
throw Error(`${await res.text()}`);
|
105
116
|
}
|
106
117
|
}
|
107
|
-
async getSwapInfo(fromTokenAddress, toTokenAddress, amount, fromAddress) {
|
118
|
+
async getSwapInfo(fromTokenAddress, toTokenAddress, amount, fromAddress, chainId) {
|
108
119
|
if (fromTokenAddress === toTokenAddress && fromTokenAddress === WETH_TOKEN_ADDRESS) {
|
109
120
|
return [];
|
110
121
|
}
|
111
|
-
|
112
|
-
const url = `${this.route}/oneinch?getRequest=/swap/v6.0/1/swap?fromTokenAddress=${fromTokenAddress}%26toTokenAddress=${toTokenAddress}%26amount=${amount.toString()}%26fromAddress=${fromAddress}%26slippage=0.1%26disableEstimate=true%26allowPartialFill=false%26includeTokensInfo=true`;
|
122
|
+
const url = `${this.perqSdk.perqConfig.route}/oneinch?getRequest=/swap/v6.0/${chainId}/swap?fromTokenAddress=${fromTokenAddress}%26toTokenAddress=${toTokenAddress}%26amount=${amount.toString()}%26fromAddress=${fromAddress}%26slippage=0.1%26disableEstimate=true%26allowPartialFill=false%26includeTokensInfo=true`;
|
113
123
|
const res = await fetch(url);
|
114
124
|
if (res.ok) {
|
115
125
|
const data = (await res.json());
|
@@ -125,28 +135,8 @@ class PerqApi {
|
|
125
135
|
throw Error(`${await res.text()}`);
|
126
136
|
}
|
127
137
|
}
|
128
|
-
async
|
129
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/
|
130
|
-
if (res.ok) {
|
131
|
-
const data = (await res.json());
|
132
|
-
return data;
|
133
|
-
}
|
134
|
-
else {
|
135
|
-
throw Error(`${await res.text()}`);
|
136
|
-
}
|
137
|
-
}
|
138
|
-
async fetchUserBalance(vaultAddress, walletAddress) {
|
139
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/balance/${vaultAddress}`);
|
140
|
-
if (res.ok) {
|
141
|
-
const data = (await res.json());
|
142
|
-
return data;
|
143
|
-
}
|
144
|
-
else {
|
145
|
-
throw Error(`${await res.text()}`);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
async fetchEnrichedUserWNFTForVault(vaultAddress, walletAddress) {
|
149
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/wNft/${vaultAddress}`);
|
138
|
+
async fetchEnrichedUserWNFTForPool(vaultAddress, walletAddress) {
|
139
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/spool/user/${walletAddress}/wNft/${vaultAddress}`);
|
150
140
|
if (res.ok) {
|
151
141
|
const data = await res.json();
|
152
142
|
return data;
|
@@ -155,38 +145,8 @@ class PerqApi {
|
|
155
145
|
throw Error(`${await res.text()}`);
|
156
146
|
}
|
157
147
|
}
|
158
|
-
async fetchAllUserWNFTForVault(vaultAddress, walletAddress) {
|
159
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/allWnft/${vaultAddress}`);
|
160
|
-
if (res.ok) {
|
161
|
-
const data = (await res.json());
|
162
|
-
return data;
|
163
|
-
}
|
164
|
-
else {
|
165
|
-
throw Error(`${await res.text()}`);
|
166
|
-
}
|
167
|
-
}
|
168
|
-
async fetchAllUserDNFTForVault(vaultAddress, walletAddress) {
|
169
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/allDnft/${vaultAddress}`);
|
170
|
-
if (res.ok) {
|
171
|
-
const data = (await res.json());
|
172
|
-
return data;
|
173
|
-
}
|
174
|
-
else {
|
175
|
-
throw Error(`${await res.text()}`);
|
176
|
-
}
|
177
|
-
}
|
178
148
|
async fetchAssetPerSvtAtBlock(vaultAddress, blocknumber) {
|
179
|
-
const res = await fetch(`${this.route}/api-be/api/spool/assetBalance/${blocknumber}/${vaultAddress}`);
|
180
|
-
if (res.ok) {
|
181
|
-
const data = (await res.json());
|
182
|
-
return data;
|
183
|
-
}
|
184
|
-
else {
|
185
|
-
throw Error(`${await res.text()}`);
|
186
|
-
}
|
187
|
-
}
|
188
|
-
async fetchFastWithdrawNFTs(vaultAddress, walletAddress) {
|
189
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/fastWithdrawNft/${vaultAddress}`);
|
149
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/spool/assetBalance/${blocknumber}/${vaultAddress}`);
|
190
150
|
if (res.ok) {
|
191
151
|
const data = (await res.json());
|
192
152
|
return data;
|
@@ -196,7 +156,7 @@ class PerqApi {
|
|
196
156
|
}
|
197
157
|
}
|
198
158
|
async fetchUserRewards(walletAddress) {
|
199
|
-
const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/rewards`);
|
159
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/rewards`);
|
200
160
|
if (res.ok) {
|
201
161
|
const data = await res.json();
|
202
162
|
return data;
|
@@ -206,7 +166,7 @@ class PerqApi {
|
|
206
166
|
}
|
207
167
|
}
|
208
168
|
async fetchAllLoyaltyCards() {
|
209
|
-
const res = await fetch(`${this.route}/api-be/api/loyaltyCards/all`);
|
169
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/loyaltyCards/all`);
|
210
170
|
if (res.ok) {
|
211
171
|
const data = await res.json();
|
212
172
|
return data.map((card) => ({
|
@@ -222,7 +182,7 @@ class PerqApi {
|
|
222
182
|
}
|
223
183
|
}
|
224
184
|
async fetchOwnedLoyaltyCard(walletAddress) {
|
225
|
-
const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/loyaltyCards/owned`);
|
185
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/loyaltyCards/owned`);
|
226
186
|
if (res.status === 204) {
|
227
187
|
return {};
|
228
188
|
}
|
@@ -241,7 +201,7 @@ class PerqApi {
|
|
241
201
|
}
|
242
202
|
}
|
243
203
|
async fetchBeansBalance(walletAddress) {
|
244
|
-
const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/beans/balance`);
|
204
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/beans/balance`);
|
245
205
|
if (res.ok) {
|
246
206
|
const data = await res.json();
|
247
207
|
const beansBalance = {
|
@@ -256,7 +216,7 @@ class PerqApi {
|
|
256
216
|
}
|
257
217
|
async upgradeLoyaltyCard(signedPayload) {
|
258
218
|
const { signerAddress } = signedPayload;
|
259
|
-
const res = await fetch(`${this.route}/api-be/api/user/${signerAddress}/loyaltyCards/upgrade`, {
|
219
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${signerAddress}/loyaltyCards/upgrade`, {
|
260
220
|
method: 'POST',
|
261
221
|
headers: {
|
262
222
|
'Content-Type': 'application/json',
|
@@ -278,7 +238,7 @@ class PerqApi {
|
|
278
238
|
}
|
279
239
|
}
|
280
240
|
async fetchMyPerqData(userAddress) {
|
281
|
-
const res = await fetch(`${this.route}/api-be/api/user/${userAddress}/myperq`);
|
241
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${userAddress}/myperq`);
|
282
242
|
if (res.ok) {
|
283
243
|
const data = await res.json();
|
284
244
|
return data;
|
@@ -288,7 +248,7 @@ class PerqApi {
|
|
288
248
|
}
|
289
249
|
}
|
290
250
|
async getSwapPerqForBeansInfo() {
|
291
|
-
const res = await fetch(`${this.route}/api-be/api/swap/price`, {});
|
251
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/swap/price`, {});
|
292
252
|
if (res.ok) {
|
293
253
|
const data = await res.json();
|
294
254
|
return data;
|
@@ -298,7 +258,7 @@ class PerqApi {
|
|
298
258
|
}
|
299
259
|
}
|
300
260
|
async fetchBeansHistory(walletAddress) {
|
301
|
-
const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/beans/history`);
|
261
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/beans/history`);
|
302
262
|
if (res.ok) {
|
303
263
|
const data = await res.json();
|
304
264
|
const result = data.map((element) => {
|
@@ -322,7 +282,7 @@ class PerqApi {
|
|
322
282
|
}
|
323
283
|
}
|
324
284
|
async linkSuiWalletWithEthWallet(signedPayload) {
|
325
|
-
const res = await fetch(`${this.route}/api-be/api/user/suiWallet`, {
|
285
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/suiWallet`, {
|
326
286
|
method: 'POST',
|
327
287
|
headers: {
|
328
288
|
'Content-Type': 'application/json',
|
@@ -336,8 +296,23 @@ class PerqApi {
|
|
336
296
|
throw Error(`${await res.text()}`);
|
337
297
|
}
|
338
298
|
}
|
339
|
-
async
|
340
|
-
const res = await fetch(`${this.route}/api-be/api/user/
|
299
|
+
async linkNearWalletWithEthWallet(signedPayload) {
|
300
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/nearWallet`, {
|
301
|
+
method: 'POST',
|
302
|
+
headers: {
|
303
|
+
'Content-Type': 'application/json',
|
304
|
+
},
|
305
|
+
body: JSON.stringify(signedPayload),
|
306
|
+
});
|
307
|
+
if (res.ok) {
|
308
|
+
return true;
|
309
|
+
}
|
310
|
+
else {
|
311
|
+
throw Error(`${await res.text()}`);
|
312
|
+
}
|
313
|
+
}
|
314
|
+
async getPodWallets(walletAddress) {
|
315
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/podWallets/${walletAddress}`);
|
341
316
|
if (res.ok) {
|
342
317
|
const data = await res.json();
|
343
318
|
return data.suiWalletAddr;
|
@@ -347,7 +322,7 @@ class PerqApi {
|
|
347
322
|
}
|
348
323
|
}
|
349
324
|
async getNonceEnrichedPayload(payload) {
|
350
|
-
const res = await fetch(`${this.route}/api-be/api/nonce`, {
|
325
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/nonce`, {
|
351
326
|
method: 'POST',
|
352
327
|
headers: {
|
353
328
|
'Content-Type': 'application/json',
|
@@ -361,10 +336,50 @@ class PerqApi {
|
|
361
336
|
// Return the enriched payload without the extra nesting
|
362
337
|
return enrichedPayload.payload;
|
363
338
|
}
|
364
|
-
async
|
365
|
-
const
|
366
|
-
|
367
|
-
|
339
|
+
async fetchV2PoolUserBalance(userAddress, vaultAddress) {
|
340
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/v2/balance/${userAddress}/${vaultAddress}`);
|
341
|
+
if (res.ok) {
|
342
|
+
return await res.json();
|
343
|
+
}
|
344
|
+
else {
|
345
|
+
throw Error(`${await res.text()}`);
|
346
|
+
}
|
347
|
+
}
|
348
|
+
async fetchLitePoolUserBalance(userAddress, vaultAddress, onChainProjectId) {
|
349
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/lite/balance/${userAddress}/${vaultAddress}/${onChainProjectId}`);
|
350
|
+
if (res.ok) {
|
351
|
+
const data = await res.json();
|
352
|
+
return {
|
353
|
+
hasWithdrawsToClaim: false,
|
354
|
+
userBalance: data.userBalance,
|
355
|
+
pendingUserBalance: '0',
|
356
|
+
pendingWithdrawalBalance: '0',
|
357
|
+
claimableBalance: '0',
|
358
|
+
};
|
359
|
+
}
|
360
|
+
else {
|
361
|
+
throw Error(`${await res.text()}`);
|
362
|
+
}
|
363
|
+
}
|
364
|
+
async fetchEarnings(userAddress, projectName) {
|
365
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${userAddress}/earnings/${projectName}`);
|
366
|
+
if (res.ok) {
|
367
|
+
const data = await res.json();
|
368
|
+
return data;
|
369
|
+
}
|
370
|
+
else {
|
371
|
+
throw Error(`${await res.text()}`);
|
372
|
+
}
|
373
|
+
}
|
374
|
+
async fetchMigrationOptions(vaultAddress, onChainProjectId) {
|
375
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/migration/options/${vaultAddress}/${onChainProjectId}`);
|
376
|
+
if (res.ok) {
|
377
|
+
const data = await res.json();
|
378
|
+
return data;
|
379
|
+
}
|
380
|
+
else {
|
381
|
+
throw Error(`${await res.text()}`);
|
382
|
+
}
|
368
383
|
}
|
369
384
|
}
|
370
385
|
exports.default = PerqApi;
|
package/dist/PerqSdk.d.ts
CHANGED
@@ -1,82 +1,37 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import
|
4
|
-
import
|
1
|
+
import { Signer, ethers } from 'ethers';
|
2
|
+
import { PerqConfig } from './types';
|
3
|
+
import PerqApi from './PerqApi';
|
4
|
+
import { PerqSwapAndRecyclerContract, PerqTokenRecyclerContract, PerqVestingContract } from './contracts';
|
5
|
+
import VestingPackage from './subpackages/VestingPackage';
|
6
|
+
import LitePackage from './subpackages/LitePackage';
|
7
|
+
import V2Package from './subpackages/V2Package';
|
8
|
+
import RecyclerPackage from './subpackages/RecyclerPackage';
|
9
|
+
import LoyaltyCardsPackage from './subpackages/LoyaltyCardsPackage';
|
10
|
+
import { YelayLiteSdk } from '@yelay-lite/sdk';
|
11
|
+
import TokenUtilsPackage from './subpackages/TokenUtilsPackage';
|
12
|
+
import UserPackage from './subpackages/UserPackage';
|
13
|
+
import SignHandlerPackage from './subpackages/SignHandlerPackage';
|
14
|
+
import PoolsPackage from './subpackages/PoolsPackage';
|
15
|
+
import { SpoolSdk } from '@spool.fi/spool-v2-sdk';
|
16
|
+
import { PerqSupportedChainId } from './types/PerqConfig';
|
5
17
|
export default class PerqSdk {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
deposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>;
|
26
|
-
private doDeposit;
|
27
|
-
getTokenAllowanceForCurrency(tokenAddress: string): Promise<string>;
|
28
|
-
getSwapAndDepositTokenAllowanceForCurrency(tokenAddress: string): Promise<string>;
|
29
|
-
getTokenAllowanceForRecycler(tokenAddress: string): Promise<BigNumber>;
|
30
|
-
getTokenAllowanceForSwapAndRecycler(tokenAddress: string): Promise<BigNumber>;
|
31
|
-
getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number): Promise<string>;
|
32
|
-
getUserBoostedNfts(vaultAddress: string): Promise<string[]>;
|
33
|
-
getRewardsPerHour(vaultAddress: string): Promise<number>;
|
34
|
-
getRewards(): Promise<UserRewards>;
|
35
|
-
getMyPerqBalance(): Promise<MyPerqData[]>;
|
36
|
-
getYelayLiteUserVaultBalance(vaultAddress: string, yliteProjectId: number): Promise<BigNumber>;
|
37
|
-
getUserVaultBalance(vaultAddress: string): Promise<UserVaultBalance>;
|
38
|
-
fastWithdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>;
|
39
|
-
swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>;
|
40
|
-
newSwapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>;
|
41
|
-
private doSwapAndDeposit;
|
42
|
-
withdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>;
|
43
|
-
yelayLiteWithdraw(tokenAddress: string, vaultAddress: string, yliteProjectId: number, amount: string): Promise<string>;
|
44
|
-
claimWithdraws(vaultAddress: string): Promise<string>;
|
45
|
-
getBeansBalance(): Promise<BeansBalance>;
|
46
|
-
getBeansHistory(): Promise<BeanEntry[]>;
|
47
|
-
recycleTokens(tokenAddress: string | undefined, amountToRecycle: string, beneficiary: string | undefined, price: string, deadline: string, signature: string): Promise<string>;
|
48
|
-
swapAndRecycleETH(beneficiary: string, path: string[], minAmountOutWithDecimals: string, amountOfEth: string, price: string, deadline: string, signature: string): Promise<string>;
|
49
|
-
swapAndRecycleERC20(beneficiary: string, path: string[], minAmountOutWithDecimals: string, amountInWithDecimals: string, price: string, deadline: string, signature: string): Promise<string>;
|
50
|
-
upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>;
|
51
|
-
getOwnedLoyaltyCard(): Promise<LoyaltyCard>;
|
52
|
-
getAllLoyaltyCards(): Promise<LoyaltyCard[]>;
|
53
|
-
approveTokenForRecycler(tokenAddress: string, amount: string): Promise<string>;
|
54
|
-
approveTokenForSwapAndRecycler(tokenAddress: string, amount: string): Promise<string>;
|
55
|
-
approveTokenForSwapAndDeposit(tokenAddress: string, amount: string): Promise<string>;
|
56
|
-
approveTokenForDeposit(tokenAddress: string, amount: string): Promise<string>;
|
57
|
-
getPerqTokenContractAddress(): string;
|
58
|
-
getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
|
59
|
-
getAllowance(tokenAddress: string, spender: string): Promise<BigNumber>;
|
60
|
-
approveAllowance(tokenAddress: string, amount: string, spenderAddress: string): Promise<string>;
|
61
|
-
transferErc20Token(tokenAddress: string, amount: string, receiver: string): Promise<string>;
|
62
|
-
wrapEther(amount: string, tokenAddress: string): Promise<string>;
|
63
|
-
getVestingStart(): Promise<string>;
|
64
|
-
getVestingEnd(): Promise<string>;
|
65
|
-
getVestedAmount(beneficiary: string): Promise<string>;
|
66
|
-
getReleasableAmount(beneficiary: string): Promise<string>;
|
67
|
-
getReleasableTotalAmount(beneficiary: string): Promise<string>;
|
68
|
-
getAllVestingInfo(beneficiaryAddress: string): Promise<VestingInfo>;
|
69
|
-
claimVestedPerq(amount: string): Promise<string>;
|
70
|
-
burnVestedPerq(amount: string, price: string, deadline: string, signature: string): Promise<string>;
|
71
|
-
linkSuiWalletWithEthWallet(suiWalletAddress: string): Promise<boolean>;
|
72
|
-
getLinkedSuiWallet(): Promise<string>;
|
73
|
-
signPayload<T>(payload: T): Promise<NonceEnrichedSignedPayload<T>>;
|
74
|
-
private getEnrichedPayload;
|
75
|
-
private generateRedeemBagStruct;
|
76
|
-
private getERC20Precission;
|
77
|
-
private getTokenAllowanceForDeposit;
|
78
|
-
private getTokenAllowanceForSwapAndDeposit;
|
79
|
-
getERC20TokenAllowance(spender: string, tokenAddress: string): Promise<BigNumber>;
|
80
|
-
approveToken(tokenAddress: string, amount: string, spender: string): Promise<string>;
|
81
|
-
yelayLiteWrapAndDepositEth(vaultAddress: string, yliteProjectId: number, amount: string): Promise<any>;
|
18
|
+
perqApi: PerqApi;
|
19
|
+
signer?: Signer;
|
20
|
+
lite: LitePackage;
|
21
|
+
v2: V2Package;
|
22
|
+
vesting: VestingPackage;
|
23
|
+
recycler: RecyclerPackage;
|
24
|
+
loyaltyCards: LoyaltyCardsPackage;
|
25
|
+
tokenUtils: TokenUtilsPackage;
|
26
|
+
user: UserPackage;
|
27
|
+
signHandler: SignHandlerPackage;
|
28
|
+
pools: PoolsPackage;
|
29
|
+
perqConfig: PerqConfig;
|
30
|
+
yelayLiteSdk?: YelayLiteSdk;
|
31
|
+
spoolSdk?: SpoolSdk;
|
32
|
+
perqVestingContract: PerqVestingContract;
|
33
|
+
perqTokenRecyclerContract: PerqTokenRecyclerContract;
|
34
|
+
perqSwapAndRecyclerContract: PerqSwapAndRecyclerContract;
|
35
|
+
constructor(perqConfig: PerqConfig, chainId: PerqSupportedChainId, provider?: ethers.providers.JsonRpcProvider);
|
36
|
+
updateSigner(newSigner: Signer, chainId: PerqSupportedChainId): Promise<void>;
|
82
37
|
}
|