@dripfi/drip-sdk 1.3.7 → 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/.prettierrc +10 -0
- package/.vscode/settings.json +11 -16
- package/dist/DripApi.d.ts +1 -1
- package/dist/DripApi.js +303 -365
- package/dist/DripConfig.js +26 -31
- package/dist/DripSdk.d.ts +1 -1
- package/dist/DripSdk.js +480 -593
- package/dist/contracts/BaseDripContract.js +1 -0
- package/dist/contracts/DripSwapAndRecyclerContract.js +11 -24
- package/dist/contracts/DripTokenContract.js +10 -23
- package/dist/contracts/DripTokenRecyclerContract.js +5 -16
- package/dist/contracts/PerqVestingContract.js +41 -64
- package/dist/index.d.ts +1 -1
- package/dist/test.js +18 -29
- package/dist/types/MyPerqData.d.ts +11 -39
- package/eslint.config.mjs +43 -0
- package/package.json +27 -23
- package/.eslintrc.json +0 -38
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
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
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
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
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
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
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
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
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
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
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
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
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
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
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
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
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
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
|
-
|
307
|
-
|
308
|
-
|
309
|
-
const
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
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
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
}
|
338
|
-
|
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
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
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
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
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
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
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
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
return enrichedPayload.payload;
|
396
|
-
});
|
317
|
+
return result;
|
318
|
+
}
|
319
|
+
else {
|
320
|
+
throw Error(`${await res.text()}`);
|
321
|
+
}
|
397
322
|
}
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
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;
|