@dripfi/drip-sdk 1.3.2 → 1.3.4

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 CHANGED
@@ -10,6 +10,7 @@ The Drip SDK is a TypeScript library designed to interact with the Drip protocol
10
10
  - [Methods](#methods)
11
11
  - [Examples](#examples)
12
12
  - [Types](#types)
13
+ - [Abis](#abis)
13
14
 
14
15
  # Installation
15
16
 
@@ -73,13 +74,9 @@ const dripSdk = new DripSdk(chain, signer);
73
74
  | `getMyPerqBalance(): Promise<MyPerqData>` | YES | This function retrieves the user's Perq balance data.
74
75
  | `getVaultsClaimableData(): Promise<VaultClaimData> ` | YES | This function fetches claimable data for the user's vaults.
75
76
  | `upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>` | YES | This function upgrades the user's loyalty card.
76
- | `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | YES | This function fetches the next loyalty card for the authenticated user based on the currently owned one
77
+ | `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | YES | This function fetches the currently owned loyalty card of the connected wallet.
77
78
  | `getAllLoyaltyCards(): Promise<LoyaltyCard[]>` | YES | This function fetches all available loyalty cards.
78
79
 
79
-
80
- > [!IMPORTANT]
81
- > **You must authenticate once for every wallet you want to use**
82
-
83
80
  ---
84
81
 
85
82
  # Examples
@@ -209,7 +206,7 @@ type Vault = {
209
206
  depositToken: VaultDepositToken
210
207
  type: VaultType
211
208
  rewards: VaultReward[]
212
- rewardType: RewardType
209
+ rewardType: RewardType
213
210
  liveUntil: string
214
211
  liveFrom: string
215
212
  liveUntilFormatted: string
@@ -223,9 +220,15 @@ type Vault = {
223
220
  coingeckoId?: string
224
221
  depositTokenId: string
225
222
  expectedTge?: string
226
- tokenPrice: number,
227
- change24h: number,
228
- volume24h: number,
223
+ tokenPrice: number
224
+ change24h: number
225
+ volume24h: number
226
+ projectFeatured: boolean
227
+ avgTvl: string
228
+ peakTvl: string
229
+ amountOfDepositors: number
230
+ boostedTvl: number
231
+ projectVAPY?: number
229
232
  };
230
233
 
231
234
  type VaultType = 'launch' | 'earn' | 'airdrop'
@@ -366,38 +369,49 @@ enum ELoyaltyCardTier {
366
369
 
367
370
  export type MyPerqData = {
368
371
  [key: string]: {
369
- vaultAddress: string,
370
- projectName: string,
371
- projectType: string,
372
- projectFeatured: boolean,
373
- liveUntil: string,
374
- coingeckoId?: string,
375
- depositTokenId: 'WETH' | 'USDC' | 'DAI',
376
- type: 'earn' | 'launch' | 'airdrop',
377
- rewardType: 'points' | 'token' | 'pnode shards',
378
- amountOfTokens?: number
379
- vaultName: string,
380
- protocols: string[],
381
- apy: number,
382
- tvr: number,
383
- tokenPrice: number,
384
- change24h: number,
385
- volume24h: number,
386
- rewards: CacheVaultRewards[]
387
- strategies: Strategy[],
388
- boosters: NFTBoost[],
389
- depositToken: DepositToken
390
- avgTvl: string
391
- peakTvl: string
392
- pendingDeposits: number;
393
- currentlyDeposited: number;
394
- pendingWithdraws: number;
395
- claimable: number;
396
- ethPrice: number;
397
- tokenRewards: {[token_address: string]: Asset & { amount: number, rewardsPerHour: number }};
372
+ vaultAddress: string,
373
+ projectName: string,
374
+ projectType: string,
375
+ projectFeatured: boolean,
376
+ liveUntil: string,
377
+ coingeckoId?: string,
378
+ depositTokenId: 'WETH' | 'USDC' | 'DAI',
379
+ type: 'earn' | 'launch' | 'airdrop',
380
+ rewardType: 'points' | 'token' | 'pnode shards',
381
+ amountOfTokens?: number
382
+ vaultName: string,
383
+ protocols: string[],
384
+ apy: number,
385
+ tvr: number,
386
+ tokenPrice: number,
387
+ change24h: number,
388
+ volume24h: number,
389
+ rewards: CacheVaultRewards[]
390
+ strategies: Strategy[],
391
+ boosters: NFTBoost[],
392
+ depositToken: DepositToken
393
+ avgTvl: string
394
+ peakTvl: string
395
+ pendingDeposits: number;
396
+ currentlyDeposited: number;
397
+ pendingWithdraws: number;
398
+ claimable: number;
399
+ ethPrice: number;
400
+ tokenRewards: {[token_address: string]: Asset & { amount: number, rewardsPerHour: number }};
398
401
  }
399
402
  };
403
+ ```
400
404
 
405
+ # Abis
406
+
407
+ - DRIP_SWAP_AND_RECYCLER_ABI
408
+
409
+ - WETH_TOKEN_ABI
410
+
411
+ - DRIP_TOKEN_ABI
412
+
413
+ - TOKEN_RECYCLER_ABI
414
+
415
+ - PERQ_VESTING_ABI
401
416
 
402
417
 
403
- ```
package/dist/DripApi.d.ts CHANGED
@@ -42,4 +42,8 @@ export default class DripApi {
42
42
  getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
43
43
  fetchBeansHistory(walletAddress: string): Promise<BeanEntry[]>;
44
44
  getNonceEnrichedPayload<T>(payload: T): Promise<NonceEnrichedPayload<T>>;
45
+ fetchUserVaultDeposits(userAddress: string, vaultAddress: string): Promise<{
46
+ pending: number;
47
+ deposited: number;
48
+ }>;
45
49
  }
package/dist/DripApi.js CHANGED
@@ -395,5 +395,12 @@ class DripApi {
395
395
  return enrichedPayload.payload;
396
396
  });
397
397
  }
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;
403
+ });
404
+ }
398
405
  }
399
406
  exports.default = DripApi;
package/dist/DripSdk.js CHANGED
@@ -167,21 +167,41 @@ class DripSdk {
167
167
  }
168
168
  getUserVaultBalance(vaultAddress) {
169
169
  return __awaiter(this, void 0, void 0, function* () {
170
+ if (!this.signer) {
171
+ throw Error('No signer provided');
172
+ }
170
173
  const userAddress = yield this.signer.getAddress();
171
- const vault = yield this.getVaultDetails(vaultAddress);
172
- const dnfts = yield this.dripApi.fetchAllUserDNFTForVault(vaultAddress, userAddress);
173
- const wnfts = yield this.dripApi.fetchAllUserWNFTForVault(vaultAddress, userAddress);
174
+ // Parallel fetch of vault, deposits and wnfts
175
+ const [vault, userVaultBalance, userWnftsForVault] = yield Promise.all([
176
+ this.getVaultDetails(vaultAddress),
177
+ this.dripApi.fetchUserVaultDeposits(userAddress, vaultAddress),
178
+ this.dripApi.fetchAllUserWNFTForVault(vaultAddress, userAddress),
179
+ ]);
174
180
  const decimals = yield this.getERC20Precission(vault.depositToken.tokenAddress);
175
- const [estimatedPendingWithdrawalBalance, estimatedWithdrawableBalance] = yield this.calculateAllWithdrawalBalances(wnfts, vaultAddress, decimals);
176
- const hasWithdrawsToClaim = this.checkIfUserHasWithdrawsToClaim(wnfts);
177
- const pendingDeposits = this.calculatePendingDeposits(dnfts, decimals);
178
- const userBalance = this.calculateAllDeposits(dnfts, decimals).sub(pendingDeposits);
181
+ // Calculate withdrawals
182
+ let pendingWithdraws = ethers_1.BigNumber.from(0);
183
+ let claimable = ethers_1.BigNumber.from(0);
184
+ for (const wnft of userWnftsForVault) {
185
+ if (!wnft.isBurned && wnft.svtWithdrawn) {
186
+ const currentBlockNumber = wnft.blockNumber - 1;
187
+ const assetsPerSvtAtBlock = yield this.dripApi.fetchAssetPerSvtAtBlock(vaultAddress, currentBlockNumber);
188
+ const estimatedValueOfNFT = ethers_1.BigNumber.from(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(wnft.svtWithdrawn).mul(assetsPerSvtAtBlock), 36).split('.')[0]);
189
+ if (wnft.isDHWFinished) {
190
+ // Processed and claimable
191
+ claimable = claimable.add(estimatedValueOfNFT);
192
+ }
193
+ else {
194
+ // Not processed, pending withdrawal
195
+ pendingWithdraws = pendingWithdraws.add(estimatedValueOfNFT);
196
+ }
197
+ }
198
+ }
179
199
  return {
180
- hasWithdrawsToClaim,
181
- userBalance: ethers_1.ethers.utils.formatUnits(userBalance, decimals),
182
- pendingUserBalance: ethers_1.ethers.utils.formatUnits(pendingDeposits, decimals),
183
- pendingWithdrawalBalance: ethers_1.ethers.utils.formatUnits(estimatedPendingWithdrawalBalance, decimals),
184
- withdrawableBalance: ethers_1.ethers.utils.formatUnits(estimatedWithdrawableBalance, decimals),
200
+ hasWithdrawsToClaim: claimable.gt(0),
201
+ userBalance: userVaultBalance.deposited.toString(),
202
+ pendingUserBalance: userVaultBalance.pending.toString(),
203
+ pendingWithdrawalBalance: ethers_1.ethers.utils.formatUnits(pendingWithdraws, decimals),
204
+ withdrawableBalance: ethers_1.ethers.utils.formatUnits(claimable, decimals),
185
205
  };
186
206
  });
187
207
  }
@@ -1,368 +1,4 @@
1
1
  [
2
- {
3
- "inputs": [
4
- {
5
- "internalType": "contract IUniswapV2Router02",
6
- "name": "swapRouter_",
7
- "type": "address"
8
- },
9
- {
10
- "internalType": "contract ITokenRecycler",
11
- "name": "tokenRecycler_",
12
- "type": "address"
13
- },
14
- {
15
- "internalType": "address",
16
- "name": "admin_",
17
- "type": "address"
18
- }
19
- ],
20
- "stateMutability": "nonpayable",
21
- "type": "constructor"
22
- },
23
- {
24
- "inputs": [],
25
- "name": "AccessControlBadConfirmation",
26
- "type": "error"
27
- },
28
- {
29
- "inputs": [
30
- {
31
- "internalType": "address",
32
- "name": "account",
33
- "type": "address"
34
- },
35
- {
36
- "internalType": "bytes32",
37
- "name": "neededRole",
38
- "type": "bytes32"
39
- }
40
- ],
41
- "name": "AccessControlUnauthorizedAccount",
42
- "type": "error"
43
- },
44
- {
45
- "inputs": [
46
- {
47
- "internalType": "address",
48
- "name": "target",
49
- "type": "address"
50
- }
51
- ],
52
- "name": "AddressEmptyCode",
53
- "type": "error"
54
- },
55
- {
56
- "inputs": [
57
- {
58
- "internalType": "address",
59
- "name": "account",
60
- "type": "address"
61
- }
62
- ],
63
- "name": "AddressInsufficientBalance",
64
- "type": "error"
65
- },
66
- {
67
- "inputs": [],
68
- "name": "FailedInnerCall",
69
- "type": "error"
70
- },
71
- {
72
- "inputs": [],
73
- "name": "ReentrancyGuardReentrantCall",
74
- "type": "error"
75
- },
76
- {
77
- "inputs": [
78
- {
79
- "internalType": "address",
80
- "name": "token",
81
- "type": "address"
82
- }
83
- ],
84
- "name": "SafeERC20FailedOperation",
85
- "type": "error"
86
- },
87
- {
88
- "anonymous": false,
89
- "inputs": [
90
- {
91
- "indexed": true,
92
- "internalType": "bytes32",
93
- "name": "role",
94
- "type": "bytes32"
95
- },
96
- {
97
- "indexed": true,
98
- "internalType": "bytes32",
99
- "name": "previousAdminRole",
100
- "type": "bytes32"
101
- },
102
- {
103
- "indexed": true,
104
- "internalType": "bytes32",
105
- "name": "newAdminRole",
106
- "type": "bytes32"
107
- }
108
- ],
109
- "name": "RoleAdminChanged",
110
- "type": "event"
111
- },
112
- {
113
- "anonymous": false,
114
- "inputs": [
115
- {
116
- "indexed": true,
117
- "internalType": "bytes32",
118
- "name": "role",
119
- "type": "bytes32"
120
- },
121
- {
122
- "indexed": true,
123
- "internalType": "address",
124
- "name": "account",
125
- "type": "address"
126
- },
127
- {
128
- "indexed": true,
129
- "internalType": "address",
130
- "name": "sender",
131
- "type": "address"
132
- }
133
- ],
134
- "name": "RoleGranted",
135
- "type": "event"
136
- },
137
- {
138
- "anonymous": false,
139
- "inputs": [
140
- {
141
- "indexed": true,
142
- "internalType": "bytes32",
143
- "name": "role",
144
- "type": "bytes32"
145
- },
146
- {
147
- "indexed": true,
148
- "internalType": "address",
149
- "name": "account",
150
- "type": "address"
151
- },
152
- {
153
- "indexed": true,
154
- "internalType": "address",
155
- "name": "sender",
156
- "type": "address"
157
- }
158
- ],
159
- "name": "RoleRevoked",
160
- "type": "event"
161
- },
162
- {
163
- "anonymous": false,
164
- "inputs": [
165
- {
166
- "indexed": true,
167
- "internalType": "address",
168
- "name": "sender",
169
- "type": "address"
170
- },
171
- {
172
- "indexed": true,
173
- "internalType": "address",
174
- "name": "rewardBeneficiary",
175
- "type": "address"
176
- },
177
- {
178
- "indexed": false,
179
- "internalType": "address[]",
180
- "name": "path",
181
- "type": "address[]"
182
- },
183
- {
184
- "indexed": false,
185
- "internalType": "uint256[]",
186
- "name": "swapAmounts",
187
- "type": "uint256[]"
188
- },
189
- {
190
- "indexed": false,
191
- "internalType": "uint256",
192
- "name": "minAmountOut",
193
- "type": "uint256"
194
- },
195
- {
196
- "indexed": false,
197
- "internalType": "uint256",
198
- "name": "deadline",
199
- "type": "uint256"
200
- },
201
- {
202
- "indexed": false,
203
- "internalType": "uint256",
204
- "name": "rewardAmount",
205
- "type": "uint256"
206
- }
207
- ],
208
- "name": "SwappedAndRecycled",
209
- "type": "event"
210
- },
211
- {
212
- "inputs": [],
213
- "name": "ADMIN_ROLE",
214
- "outputs": [
215
- {
216
- "internalType": "bytes32",
217
- "name": "",
218
- "type": "bytes32"
219
- }
220
- ],
221
- "stateMutability": "view",
222
- "type": "function"
223
- },
224
- {
225
- "inputs": [],
226
- "name": "DEFAULT_ADMIN_ROLE",
227
- "outputs": [
228
- {
229
- "internalType": "bytes32",
230
- "name": "",
231
- "type": "bytes32"
232
- }
233
- ],
234
- "stateMutability": "view",
235
- "type": "function"
236
- },
237
- {
238
- "inputs": [
239
- {
240
- "internalType": "bytes32",
241
- "name": "role",
242
- "type": "bytes32"
243
- }
244
- ],
245
- "name": "getRoleAdmin",
246
- "outputs": [
247
- {
248
- "internalType": "bytes32",
249
- "name": "",
250
- "type": "bytes32"
251
- }
252
- ],
253
- "stateMutability": "view",
254
- "type": "function"
255
- },
256
- {
257
- "inputs": [
258
- {
259
- "internalType": "bytes32",
260
- "name": "role",
261
- "type": "bytes32"
262
- },
263
- {
264
- "internalType": "address",
265
- "name": "account",
266
- "type": "address"
267
- }
268
- ],
269
- "name": "grantRole",
270
- "outputs": [],
271
- "stateMutability": "nonpayable",
272
- "type": "function"
273
- },
274
- {
275
- "inputs": [
276
- {
277
- "internalType": "bytes32",
278
- "name": "role",
279
- "type": "bytes32"
280
- },
281
- {
282
- "internalType": "address",
283
- "name": "account",
284
- "type": "address"
285
- }
286
- ],
287
- "name": "hasRole",
288
- "outputs": [
289
- {
290
- "internalType": "bool",
291
- "name": "",
292
- "type": "bool"
293
- }
294
- ],
295
- "stateMutability": "view",
296
- "type": "function"
297
- },
298
- {
299
- "inputs": [],
300
- "name": "recycledToken",
301
- "outputs": [
302
- {
303
- "internalType": "contract IERC20",
304
- "name": "",
305
- "type": "address"
306
- }
307
- ],
308
- "stateMutability": "view",
309
- "type": "function"
310
- },
311
- {
312
- "inputs": [
313
- {
314
- "internalType": "bytes32",
315
- "name": "role",
316
- "type": "bytes32"
317
- },
318
- {
319
- "internalType": "address",
320
- "name": "callerConfirmation",
321
- "type": "address"
322
- }
323
- ],
324
- "name": "renounceRole",
325
- "outputs": [],
326
- "stateMutability": "nonpayable",
327
- "type": "function"
328
- },
329
- {
330
- "inputs": [
331
- {
332
- "internalType": "bytes32",
333
- "name": "role",
334
- "type": "bytes32"
335
- },
336
- {
337
- "internalType": "address",
338
- "name": "account",
339
- "type": "address"
340
- }
341
- ],
342
- "name": "revokeRole",
343
- "outputs": [],
344
- "stateMutability": "nonpayable",
345
- "type": "function"
346
- },
347
- {
348
- "inputs": [
349
- {
350
- "internalType": "bytes4",
351
- "name": "interfaceId",
352
- "type": "bytes4"
353
- }
354
- ],
355
- "name": "supportsInterface",
356
- "outputs": [
357
- {
358
- "internalType": "bool",
359
- "name": "",
360
- "type": "bool"
361
- }
362
- ],
363
- "stateMutability": "view",
364
- "type": "function"
365
- },
366
2
  {
367
3
  "inputs": [
368
4
  {
@@ -455,62 +91,5 @@
455
91
  ],
456
92
  "stateMutability": "payable",
457
93
  "type": "function"
458
- },
459
- {
460
- "inputs": [],
461
- "name": "swapRouter",
462
- "outputs": [
463
- {
464
- "internalType": "contract IUniswapV2Router02",
465
- "name": "",
466
- "type": "address"
467
- }
468
- ],
469
- "stateMutability": "view",
470
- "type": "function"
471
- },
472
- {
473
- "inputs": [],
474
- "name": "tokenRecycler",
475
- "outputs": [
476
- {
477
- "internalType": "contract ITokenRecycler",
478
- "name": "",
479
- "type": "address"
480
- }
481
- ],
482
- "stateMutability": "view",
483
- "type": "function"
484
- },
485
- {
486
- "inputs": [
487
- {
488
- "internalType": "uint256",
489
- "name": "amount_",
490
- "type": "uint256"
491
- }
492
- ],
493
- "name": "withdrawETH",
494
- "outputs": [],
495
- "stateMutability": "nonpayable",
496
- "type": "function"
497
- },
498
- {
499
- "inputs": [
500
- {
501
- "internalType": "contract IERC20",
502
- "name": "token_",
503
- "type": "address"
504
- },
505
- {
506
- "internalType": "uint256",
507
- "name": "amount_",
508
- "type": "uint256"
509
- }
510
- ],
511
- "name": "withdrawToken",
512
- "outputs": [],
513
- "stateMutability": "nonpayable",
514
- "type": "function"
515
94
  }
516
95
  ]