@dripfi/drip-sdk 1.3.6 → 1.3.8

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/DripApi.js CHANGED
@@ -1,406 +1,344 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  const ethers_1 = require("ethers");
13
4
  const DripConfig_1 = require("./DripConfig");
14
5
  const WETH_TOKEN_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
15
6
  class DripApi {
7
+ route;
16
8
  constructor(route) {
17
9
  this.route = route;
18
10
  }
19
- fetchAllVaults() {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const res = yield fetch(`${this.route}/api-be/api/vault`);
22
- if (res.ok) {
23
- const data = (yield res.json());
24
- return data;
25
- }
26
- else {
27
- throw Error(`${yield res.text()}`);
28
- }
29
- });
11
+ async fetchAllVaults() {
12
+ const res = await fetch(`${this.route}/api-be/api/vault`);
13
+ if (res.ok) {
14
+ const data = (await res.json());
15
+ return data;
16
+ }
17
+ else {
18
+ throw Error(`${await res.text()}`);
19
+ }
30
20
  }
31
- fetchTokenPrice(tokenName) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const res = yield fetch(`${this.route}/api-be/api/tokenPrice?tokenName=${tokenName}`);
34
- if (res.ok) {
35
- const data = yield res.json();
36
- return data.usdPricePerToken;
37
- }
38
- else {
39
- throw Error(`${yield res.text()}`);
40
- }
41
- });
21
+ async fetchTokenPrice(tokenName) {
22
+ const res = await fetch(`${this.route}/api-be/api/tokenPrice?tokenName=${tokenName}`);
23
+ if (res.ok) {
24
+ const data = await res.json();
25
+ return data.usdPricePerToken;
26
+ }
27
+ else {
28
+ throw Error(`${await res.text()}`);
29
+ }
42
30
  }
43
- getExpectedSwapResult(fromTokenAddress, toTokenAddress, amount, decimals) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const parsedAmount = ethers_1.ethers.utils.parseUnits(amount, decimals);
46
- const queryParams = new URLSearchParams({
47
- from: fromTokenAddress,
48
- to: toTokenAddress,
49
- amount: parsedAmount.toString(),
50
- });
51
- const res = yield fetch(`${this.route}/api-be/api/1inch/swap?${queryParams}`);
52
- if (res.ok) {
53
- const data = yield res.json();
54
- return data;
55
- }
56
- else {
57
- throw Error(`${yield res.text()}`);
58
- }
59
- });
60
- }
61
- getUserBalance(walletAddress) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const res = yield fetch(`${this.route}/api-be/api/user/${walletAddress}/deposits`);
64
- if (res.ok) {
65
- const data = yield res.json();
66
- return data;
67
- }
68
- else {
69
- throw Error(`${yield res.text()}`);
70
- }
31
+ async getExpectedSwapResult(fromTokenAddress, toTokenAddress, amount, decimals) {
32
+ const parsedAmount = ethers_1.ethers.utils.parseUnits(amount, decimals);
33
+ const queryParams = new URLSearchParams({
34
+ from: fromTokenAddress,
35
+ to: toTokenAddress,
36
+ amount: parsedAmount.toString(),
71
37
  });
38
+ const res = await fetch(`${this.route}/api-be/api/1inch/swap?${queryParams}`);
39
+ if (res.ok) {
40
+ const data = await res.json();
41
+ return data;
42
+ }
43
+ else {
44
+ throw Error(`${await res.text()}`);
45
+ }
72
46
  }
73
- getUserBoostedNfts(walletAddress, vaultAddress) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const res = yield fetch(`${this.route}/api-be/api/user/${walletAddress}/nftBoost/${vaultAddress}`);
76
- if (res.ok) {
77
- const data = yield res.json();
78
- return data;
79
- }
80
- else {
81
- throw Error(`${yield res.text()}`);
82
- }
83
- });
47
+ async getUserBalance(walletAddress) {
48
+ const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/deposits`);
49
+ if (res.ok) {
50
+ const data = await res.json();
51
+ return data;
52
+ }
53
+ else {
54
+ throw Error(`${await res.text()}`);
55
+ }
84
56
  }
85
- fetchVaultStats() {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- const res = yield fetch(`${this.route}/api-be/api/vaultStats`);
88
- if (res.ok) {
89
- const data = yield res.json();
90
- return data;
91
- }
92
- else {
93
- throw Error(`${yield res.text()}`);
94
- }
95
- });
57
+ async getUserBoostedNfts(walletAddress, vaultAddress) {
58
+ const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/nftBoost/${vaultAddress}`);
59
+ if (res.ok) {
60
+ const data = await res.json();
61
+ return data;
62
+ }
63
+ else {
64
+ throw Error(`${await res.text()}`);
65
+ }
96
66
  }
97
- fetchVaultDetails(vaultAddress) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- const res = yield fetch(`${this.route}/api-be/api/vault/${vaultAddress}`);
100
- if (res.ok) {
101
- const data = (yield res.json());
102
- return data;
103
- }
104
- else {
105
- throw Error(`${yield res.text()}`);
106
- }
107
- });
67
+ async fetchVaultStats() {
68
+ const res = await fetch(`${this.route}/api-be/api/vaultStats`);
69
+ if (res.ok) {
70
+ const data = await res.json();
71
+ return data;
72
+ }
73
+ else {
74
+ throw Error(`${await res.text()}`);
75
+ }
108
76
  }
109
- fetchRewardsPerHour(walletAddress, vaultAddress) {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- const res = yield fetch(`${this.route}/api-be/api/user/${walletAddress}/rewardsPerHour/${vaultAddress}`);
112
- if (res.ok) {
113
- const data = yield res.json();
114
- return data.rewardsPerHour;
115
- }
116
- else {
117
- throw Error(`${yield res.text()}`);
118
- }
119
- });
77
+ async fetchVaultDetails(vaultAddress) {
78
+ const res = await fetch(`${this.route}/api-be/api/vault/${vaultAddress}`);
79
+ if (res.ok) {
80
+ const data = (await res.json());
81
+ return data;
82
+ }
83
+ else {
84
+ throw Error(`${await res.text()}`);
85
+ }
120
86
  }
121
- getSwapInfo(fromTokenAddress, toTokenAddress, amount, fromAddress) {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- if (fromTokenAddress === toTokenAddress && fromTokenAddress === WETH_TOKEN_ADDRESS) {
124
- return [];
125
- }
126
- const url = `${this.route}/oneinch?getRequest=/swap/v5.2/1/swap?fromTokenAddress=${fromTokenAddress}%26toTokenAddress=${toTokenAddress}%26amount=${amount.toString()}%26fromAddress=${fromAddress}%26slippage=0.1%26disableEstimate=true%26allowPartialFill=false%26includeTokensInfo=true`;
127
- const res = yield fetch(url);
128
- if (res.ok) {
129
- const data = (yield res.json());
130
- return [
131
- {
132
- swapTarget: data.tx.to,
133
- token: data.fromToken.address,
134
- swapCallData: data.tx.data,
135
- },
136
- ];
137
- }
138
- else {
139
- throw Error(`${yield res.text()}`);
140
- }
141
- });
87
+ async fetchRewardsPerHour(walletAddress, vaultAddress) {
88
+ const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/rewardsPerHour/${vaultAddress}`);
89
+ if (res.ok) {
90
+ const data = await res.json();
91
+ return data.rewardsPerHour;
92
+ }
93
+ else {
94
+ throw Error(`${await res.text()}`);
95
+ }
142
96
  }
143
- fetchUserSVTBalance(vaultAddress, walletAddress) {
144
- return __awaiter(this, void 0, void 0, function* () {
145
- const res = yield fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/svtBalance/${vaultAddress}`);
146
- if (res.ok) {
147
- const data = (yield res.json());
148
- return data;
149
- }
150
- else {
151
- throw Error(`${yield res.text()}`);
152
- }
153
- });
97
+ async getSwapInfo(fromTokenAddress, toTokenAddress, amount, fromAddress) {
98
+ if (fromTokenAddress === toTokenAddress && fromTokenAddress === WETH_TOKEN_ADDRESS) {
99
+ return [];
100
+ }
101
+ const url = `${this.route}/oneinch?getRequest=/swap/v5.2/1/swap?fromTokenAddress=${fromTokenAddress}%26toTokenAddress=${toTokenAddress}%26amount=${amount.toString()}%26fromAddress=${fromAddress}%26slippage=0.1%26disableEstimate=true%26allowPartialFill=false%26includeTokensInfo=true`;
102
+ const res = await fetch(url);
103
+ if (res.ok) {
104
+ const data = (await res.json());
105
+ return [
106
+ {
107
+ swapTarget: data.tx.to,
108
+ token: data.fromToken.address,
109
+ swapCallData: data.tx.data,
110
+ },
111
+ ];
112
+ }
113
+ else {
114
+ throw Error(`${await res.text()}`);
115
+ }
154
116
  }
155
- fetchUserBalance(vaultAddress, walletAddress) {
156
- return __awaiter(this, void 0, void 0, function* () {
157
- const res = yield fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/balance/${vaultAddress}`);
158
- if (res.ok) {
159
- const data = (yield res.json());
160
- return data;
161
- }
162
- else {
163
- throw Error(`${yield res.text()}`);
164
- }
165
- });
117
+ async fetchUserSVTBalance(vaultAddress, walletAddress) {
118
+ const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/svtBalance/${vaultAddress}`);
119
+ if (res.ok) {
120
+ const data = (await res.json());
121
+ return data;
122
+ }
123
+ else {
124
+ throw Error(`${await res.text()}`);
125
+ }
166
126
  }
167
- fetchEnrichedUserWNFTForVault(vaultAddress, walletAddress) {
168
- return __awaiter(this, void 0, void 0, function* () {
169
- const res = yield fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/wNft/${vaultAddress}`);
170
- if (res.ok) {
171
- const data = yield res.json();
172
- return data;
173
- }
174
- else {
175
- throw Error(`${yield res.text()}`);
176
- }
177
- });
127
+ async fetchUserBalance(vaultAddress, walletAddress) {
128
+ const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/balance/${vaultAddress}`);
129
+ if (res.ok) {
130
+ const data = (await res.json());
131
+ return data;
132
+ }
133
+ else {
134
+ throw Error(`${await res.text()}`);
135
+ }
178
136
  }
179
- fetchAllUserWNFTForVault(vaultAddress, walletAddress) {
180
- return __awaiter(this, void 0, void 0, function* () {
181
- const res = yield fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/allWnft/${vaultAddress}`);
182
- if (res.ok) {
183
- const data = (yield res.json());
184
- return data;
185
- }
186
- else {
187
- throw Error(`${yield res.text()}`);
188
- }
189
- });
137
+ async fetchEnrichedUserWNFTForVault(vaultAddress, walletAddress) {
138
+ const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/wNft/${vaultAddress}`);
139
+ if (res.ok) {
140
+ const data = await res.json();
141
+ return data;
142
+ }
143
+ else {
144
+ throw Error(`${await res.text()}`);
145
+ }
190
146
  }
191
- fetchAllUserDNFTForVault(vaultAddress, walletAddress) {
192
- return __awaiter(this, void 0, void 0, function* () {
193
- const res = yield fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/allDnft/${vaultAddress}`);
194
- if (res.ok) {
195
- const data = (yield res.json());
196
- return data;
197
- }
198
- else {
199
- throw Error(`${yield res.text()}`);
200
- }
201
- });
147
+ async fetchAllUserWNFTForVault(vaultAddress, walletAddress) {
148
+ const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/allWnft/${vaultAddress}`);
149
+ if (res.ok) {
150
+ const data = (await res.json());
151
+ return data;
152
+ }
153
+ else {
154
+ throw Error(`${await res.text()}`);
155
+ }
202
156
  }
203
- fetchAssetPerSvtAtBlock(vaultAddress, blocknumber) {
204
- return __awaiter(this, void 0, void 0, function* () {
205
- const res = yield fetch(`${this.route}/api-be/api/spool/assetBalance/${blocknumber}/${vaultAddress}`);
206
- if (res.ok) {
207
- const data = (yield res.json());
208
- return data;
209
- }
210
- else {
211
- throw Error(`${yield res.text()}`);
212
- }
213
- });
157
+ async fetchAllUserDNFTForVault(vaultAddress, walletAddress) {
158
+ const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/allDnft/${vaultAddress}`);
159
+ if (res.ok) {
160
+ const data = (await res.json());
161
+ return data;
162
+ }
163
+ else {
164
+ throw Error(`${await res.text()}`);
165
+ }
214
166
  }
215
- fetchFastWithdrawNFTs(vaultAddress, walletAddress) {
216
- return __awaiter(this, void 0, void 0, function* () {
217
- const res = yield fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/fastWithdrawNft/${vaultAddress}`);
218
- if (res.ok) {
219
- const data = (yield res.json());
220
- return data;
221
- }
222
- else {
223
- throw Error(`${yield res.text()}`);
224
- }
225
- });
167
+ async fetchAssetPerSvtAtBlock(vaultAddress, blocknumber) {
168
+ const res = await fetch(`${this.route}/api-be/api/spool/assetBalance/${blocknumber}/${vaultAddress}`);
169
+ if (res.ok) {
170
+ const data = (await res.json());
171
+ return data;
172
+ }
173
+ else {
174
+ throw Error(`${await res.text()}`);
175
+ }
226
176
  }
227
- fetchUserRewards(walletAddress) {
228
- return __awaiter(this, void 0, void 0, function* () {
229
- const res = yield fetch(`${this.route}/api-be/api/user/${walletAddress}/rewards`);
230
- if (res.ok) {
231
- const data = yield res.json();
232
- return data;
233
- }
234
- else {
235
- throw Error(`${yield res.text()}`);
236
- }
237
- });
177
+ async fetchFastWithdrawNFTs(vaultAddress, walletAddress) {
178
+ const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/fastWithdrawNft/${vaultAddress}`);
179
+ if (res.ok) {
180
+ const data = (await res.json());
181
+ return data;
182
+ }
183
+ else {
184
+ throw Error(`${await res.text()}`);
185
+ }
238
186
  }
239
- fetchVaultsClaimableData(walletAddress) {
240
- return __awaiter(this, void 0, void 0, function* () {
241
- const res = yield fetch(`${this.route}/api-be/api/user/${walletAddress}/claimableVaults`);
242
- if (res.ok) {
243
- const data = yield res.json();
244
- return data;
245
- }
246
- else {
247
- throw Error(`${yield res.text()}`);
248
- }
249
- });
187
+ async fetchUserRewards(walletAddress) {
188
+ const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/rewards`);
189
+ if (res.ok) {
190
+ const data = await res.json();
191
+ return data;
192
+ }
193
+ else {
194
+ throw Error(`${await res.text()}`);
195
+ }
250
196
  }
251
- fetchAllLoyaltyCards() {
252
- return __awaiter(this, void 0, void 0, function* () {
253
- const res = yield fetch(`${this.route}/api-be/api/loyaltyCards/all`);
254
- if (res.ok) {
255
- const data = yield res.json();
256
- return data.map((card) => ({
257
- id: card.id,
258
- tier: card.tier,
259
- level: card.level,
260
- cost: parseFloat(ethers_1.ethers.utils.formatUnits(card.cost.toString(), DripConfig_1.PERQ_TOKEN_DECIMALS)),
261
- boost: card.boost
262
- }));
263
- }
264
- else {
265
- throw Error(`${yield res.text()}`);
266
- }
267
- });
197
+ async fetchVaultsClaimableData(walletAddress) {
198
+ const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/claimableVaults`);
199
+ if (res.ok) {
200
+ const data = await res.json();
201
+ return data;
202
+ }
203
+ else {
204
+ throw Error(`${await res.text()}`);
205
+ }
268
206
  }
269
- fetchOwnedLoyaltyCard(walletAddress) {
270
- return __awaiter(this, void 0, void 0, function* () {
271
- const res = yield fetch(`${this.route}/api-be/api/user/${walletAddress}/loyaltyCards/owned`);
272
- if (res.status === 204) {
273
- return {};
274
- }
275
- if (res.ok) {
276
- const data = yield res.json();
277
- return {
278
- id: data.id,
279
- tier: data.tier,
280
- level: data.level,
281
- cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), DripConfig_1.PERQ_TOKEN_DECIMALS)),
282
- boost: data.boost
283
- };
284
- }
285
- else {
286
- throw Error(`${yield res.text()}`);
287
- }
288
- });
207
+ async fetchAllLoyaltyCards() {
208
+ const res = await fetch(`${this.route}/api-be/api/loyaltyCards/all`);
209
+ if (res.ok) {
210
+ const data = await res.json();
211
+ return data.map((card) => ({
212
+ id: card.id,
213
+ tier: card.tier,
214
+ level: card.level,
215
+ cost: parseFloat(ethers_1.ethers.utils.formatUnits(card.cost.toString(), DripConfig_1.PERQ_TOKEN_DECIMALS)),
216
+ boost: card.boost,
217
+ }));
218
+ }
219
+ else {
220
+ throw Error(`${await res.text()}`);
221
+ }
289
222
  }
290
- fetchBeansBalance(walletAddress) {
291
- return __awaiter(this, void 0, void 0, function* () {
292
- const res = yield fetch(`${this.route}/api-be/api/user/${walletAddress}/beans/balance`);
293
- if (res.ok) {
294
- const data = yield res.json();
295
- const beansBalance = {
296
- balance: ethers_1.ethers.utils.formatUnits(data.balance, DripConfig_1.PERQ_TOKEN_DECIMALS),
297
- bonusesClaimed: data.bonusesClaimed
298
- };
299
- return beansBalance;
300
- }
301
- else {
302
- throw Error(`${yield res.text()}`);
303
- }
304
- });
223
+ async fetchOwnedLoyaltyCard(walletAddress) {
224
+ const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/loyaltyCards/owned`);
225
+ if (res.status === 204) {
226
+ return {};
227
+ }
228
+ if (res.ok) {
229
+ const data = await res.json();
230
+ return {
231
+ id: data.id,
232
+ tier: data.tier,
233
+ level: data.level,
234
+ cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), DripConfig_1.PERQ_TOKEN_DECIMALS)),
235
+ boost: data.boost,
236
+ };
237
+ }
238
+ else {
239
+ throw Error(`${await res.text()}`);
240
+ }
305
241
  }
306
- upgradeLoyaltyCard(signedPayload) {
307
- return __awaiter(this, void 0, void 0, function* () {
308
- const { signerAddress } = signedPayload;
309
- const res = yield fetch(`${this.route}/api-be/api/user/${signerAddress}/loyaltyCards/upgrade`, {
310
- method: 'POST',
311
- headers: {
312
- 'Content-Type': 'application/json'
313
- },
314
- body: JSON.stringify(signedPayload)
315
- });
316
- if (res.ok) {
317
- const data = yield res.json();
318
- return {
319
- id: data.id,
320
- tier: data.tier,
321
- level: data.level,
322
- cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), DripConfig_1.PERQ_TOKEN_DECIMALS)),
323
- boost: data.boost
324
- };
325
- }
326
- else {
327
- throw Error(`${yield res.text()}`);
328
- }
329
- });
242
+ async fetchBeansBalance(walletAddress) {
243
+ const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/beans/balance`);
244
+ if (res.ok) {
245
+ const data = await res.json();
246
+ const beansBalance = {
247
+ balance: ethers_1.ethers.utils.formatUnits(data.balance, DripConfig_1.PERQ_TOKEN_DECIMALS),
248
+ bonusesClaimed: data.bonusesClaimed,
249
+ };
250
+ return beansBalance;
251
+ }
252
+ else {
253
+ throw Error(`${await res.text()}`);
254
+ }
330
255
  }
331
- fetchMyPerqData(userAddress) {
332
- return __awaiter(this, void 0, void 0, function* () {
333
- const res = yield fetch(`${this.route}/api-be/api/user/${userAddress}/myperq`);
334
- if (res.ok) {
335
- const data = yield res.json();
336
- return data;
337
- }
338
- else {
339
- throw Error(`${yield res.text()}`);
340
- }
256
+ async upgradeLoyaltyCard(signedPayload) {
257
+ const { signerAddress } = signedPayload;
258
+ const res = await fetch(`${this.route}/api-be/api/user/${signerAddress}/loyaltyCards/upgrade`, {
259
+ method: 'POST',
260
+ headers: {
261
+ 'Content-Type': 'application/json',
262
+ },
263
+ body: JSON.stringify(signedPayload),
341
264
  });
265
+ if (res.ok) {
266
+ const data = await res.json();
267
+ return {
268
+ id: data.id,
269
+ tier: data.tier,
270
+ level: data.level,
271
+ cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), DripConfig_1.PERQ_TOKEN_DECIMALS)),
272
+ boost: data.boost,
273
+ };
274
+ }
275
+ else {
276
+ throw Error(`${await res.text()}`);
277
+ }
342
278
  }
343
- getSwapPerqForBeansInfo() {
344
- return __awaiter(this, void 0, void 0, function* () {
345
- const res = yield fetch(`${this.route}/api-be/api/swap/price`, {});
346
- if (res.ok) {
347
- const data = yield res.json();
348
- return data;
349
- }
350
- else {
351
- throw Error(`${yield res.text()}`);
352
- }
353
- });
279
+ async fetchMyPerqData(userAddress) {
280
+ const res = await fetch(`${this.route}/api-be/api/user/${userAddress}/myperq`);
281
+ if (res.ok) {
282
+ const data = await res.json();
283
+ return data;
284
+ }
285
+ else {
286
+ throw Error(`${await res.text()}`);
287
+ }
354
288
  }
355
- fetchBeansHistory(walletAddress) {
356
- return __awaiter(this, void 0, void 0, function* () {
357
- const res = yield fetch(`${this.route}/api-be/api/user/${walletAddress}/beans/history`);
358
- if (res.ok) {
359
- const data = yield res.json();
360
- const result = data.map((element) => {
361
- const newBeanEntry = {
362
- address: element.address,
363
- reason: element.reason,
364
- recycledAmount: element.recycledAmount,
365
- beansAmount: element.beansAmount,
366
- beansSum: element.beansSum,
367
- amountDepositedInUsd: element.amountDepositedInUsd,
368
- chainId: element.chainId,
369
- nonce: element.nonce,
370
- createdAt: element.createdAt
371
- };
372
- return newBeanEntry;
373
- });
374
- return result;
375
- }
376
- else {
377
- throw Error(`${yield res.text()}`);
378
- }
379
- });
289
+ async getSwapPerqForBeansInfo() {
290
+ const res = await fetch(`${this.route}/api-be/api/swap/price`, {});
291
+ if (res.ok) {
292
+ const data = await res.json();
293
+ return data;
294
+ }
295
+ else {
296
+ throw Error(`${await res.text()}`);
297
+ }
380
298
  }
381
- getNonceEnrichedPayload(payload) {
382
- return __awaiter(this, void 0, void 0, function* () {
383
- const res = yield fetch(`${this.route}/api-be/api/nonce`, {
384
- method: 'POST',
385
- headers: {
386
- 'Content-Type': 'application/json',
387
- },
388
- body: JSON.stringify({ payload }), // Wrap in payload property for BE
299
+ async fetchBeansHistory(walletAddress) {
300
+ const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/beans/history`);
301
+ if (res.ok) {
302
+ const data = await res.json();
303
+ const result = data.map((element) => {
304
+ const newBeanEntry = {
305
+ address: element.address,
306
+ reason: element.reason,
307
+ recycledAmount: element.recycledAmount,
308
+ beansAmount: element.beansAmount,
309
+ beansSum: element.beansSum,
310
+ amountDepositedInUsd: element.amountDepositedInUsd,
311
+ chainId: element.chainId,
312
+ nonce: element.nonce,
313
+ createdAt: element.createdAt,
314
+ };
315
+ return newBeanEntry;
389
316
  });
390
- if (!res.ok) {
391
- throw new Error('Failed to get nonce-enriched payload');
392
- }
393
- const enrichedPayload = yield res.json();
394
- // Return the enriched payload without the extra nesting
395
- return enrichedPayload.payload;
396
- });
317
+ return result;
318
+ }
319
+ else {
320
+ throw Error(`${await res.text()}`);
321
+ }
397
322
  }
398
- fetchUserVaultDeposits(userAddress, vaultAddress) {
399
- return __awaiter(this, void 0, void 0, function* () {
400
- const response = yield fetch(`${this.route}/api-be/api/user/${userAddress}/deposits/${vaultAddress}`);
401
- const data = yield response.json();
402
- return data;
323
+ async getNonceEnrichedPayload(payload) {
324
+ const res = await fetch(`${this.route}/api-be/api/nonce`, {
325
+ method: 'POST',
326
+ headers: {
327
+ 'Content-Type': 'application/json',
328
+ },
329
+ body: JSON.stringify({ payload }), // Wrap in payload property for BE
403
330
  });
331
+ if (!res.ok) {
332
+ throw new Error('Failed to get nonce-enriched payload');
333
+ }
334
+ const enrichedPayload = await res.json();
335
+ // Return the enriched payload without the extra nesting
336
+ return enrichedPayload.payload;
337
+ }
338
+ async fetchUserVaultDeposits(userAddress, vaultAddress) {
339
+ const response = await fetch(`${this.route}/api-be/api/user/${userAddress}/deposits/${vaultAddress}`);
340
+ const data = await response.json();
341
+ return data;
404
342
  }
405
343
  }
406
344
  exports.default = DripApi;