@dripfi/drip-sdk 1.3.1 → 1.3.2

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,7 +10,6 @@ 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)
14
13
 
15
14
  # Installation
16
15
 
@@ -74,9 +73,13 @@ const dripSdk = new DripSdk(chain, signer);
74
73
  | `getMyPerqBalance(): Promise<MyPerqData>` | YES | This function retrieves the user's Perq balance data.
75
74
  | `getVaultsClaimableData(): Promise<VaultClaimData> ` | YES | This function fetches claimable data for the user's vaults.
76
75
  | `upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>` | YES | This function upgrades the user's loyalty card.
77
- | `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | YES | This function fetches the currently owned loyalty card of the connected wallet.
76
+ | `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | YES | This function fetches the next loyalty card for the authenticated user based on the currently owned one
78
77
  | `getAllLoyaltyCards(): Promise<LoyaltyCard[]>` | YES | This function fetches all available loyalty cards.
79
78
 
79
+
80
+ > [!IMPORTANT]
81
+ > **You must authenticate once for every wallet you want to use**
82
+
80
83
  ---
81
84
 
82
85
  # Examples
@@ -206,7 +209,7 @@ type Vault = {
206
209
  depositToken: VaultDepositToken
207
210
  type: VaultType
208
211
  rewards: VaultReward[]
209
- rewardType: RewardType
212
+ rewardType: RewardType
210
213
  liveUntil: string
211
214
  liveFrom: string
212
215
  liveUntilFormatted: string
@@ -220,15 +223,9 @@ type Vault = {
220
223
  coingeckoId?: string
221
224
  depositTokenId: string
222
225
  expectedTge?: string
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
226
+ tokenPrice: number,
227
+ change24h: number,
228
+ volume24h: number,
232
229
  };
233
230
 
234
231
  type VaultType = 'launch' | 'earn' | 'airdrop'
@@ -369,49 +366,38 @@ enum ELoyaltyCardTier {
369
366
 
370
367
  export type MyPerqData = {
371
368
  [key: string]: {
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 }};
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 }};
401
398
  }
402
399
  };
403
- ```
404
-
405
- # Abis
406
400
 
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
416
401
 
417
402
 
403
+ ```
package/dist/DripApi.d.ts CHANGED
@@ -11,7 +11,7 @@ import { LoyaltyCard } from './types/LoyaltyCard';
11
11
  import { BeansBalance } from './types/BeansBalance';
12
12
  import { PerqToBeansSwapInfo } from './types/PerqToBeansSwapInfo';
13
13
  import BeanEntry from './types/BeanEntry';
14
- import { SignedPayload } from './types/SignedPayload';
14
+ import { NonceEnrichedSignedPayload, NonceEnrichedPayload } from './types/SignedPayload';
15
15
  import { UpgradeLoyaltyCardPayload } from './types/UpgradeLoyaltyCardPayload';
16
16
  export default class DripApi {
17
17
  route: string;
@@ -37,8 +37,9 @@ export default class DripApi {
37
37
  fetchAllLoyaltyCards(): Promise<LoyaltyCard[]>;
38
38
  fetchOwnedLoyaltyCard(walletAddress: string): Promise<LoyaltyCard>;
39
39
  fetchBeansBalance(walletAddress: string): Promise<BeansBalance>;
40
- upgradeLoyaltyCard(signedPayload: SignedPayload<UpgradeLoyaltyCardPayload>): Promise<LoyaltyCard>;
40
+ upgradeLoyaltyCard(signedPayload: NonceEnrichedSignedPayload<UpgradeLoyaltyCardPayload>): Promise<LoyaltyCard>;
41
41
  fetchMyPerqData(userAddress: string): Promise<MyPerqData>;
42
42
  getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
43
43
  fetchBeansHistory(walletAddress: string): Promise<BeanEntry[]>;
44
+ getNonceEnrichedPayload<T>(payload: T): Promise<NonceEnrichedPayload<T>>;
44
45
  }
package/dist/DripApi.js CHANGED
@@ -378,5 +378,22 @@ class DripApi {
378
378
  }
379
379
  });
380
380
  }
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
389
+ });
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
+ });
397
+ }
381
398
  }
382
399
  exports.default = DripApi;
package/dist/DripSdk.d.ts CHANGED
@@ -12,7 +12,7 @@ import { BeansBalance } from './types/BeansBalance';
12
12
  import { PerqToBeansSwapInfo } from './types/PerqToBeansSwapInfo';
13
13
  import BeanEntry from './types/BeanEntry';
14
14
  import { VestingInfo } from './types/VestingInfo';
15
- import { SignedPayload } from './types/SignedPayload';
15
+ import { NonceEnrichedSignedPayload } from './types/SignedPayload';
16
16
  export default class DripSdk {
17
17
  private dripApi;
18
18
  private dripTokenContract;
@@ -72,7 +72,8 @@ export default class DripSdk {
72
72
  getAllVestingInfo(beneficiaryAddress: string): Promise<VestingInfo>;
73
73
  claimVestedPerq(amount: string): Promise<string>;
74
74
  burnVestedPerq(amount: string, price: string, deadline: string, signature: string): Promise<string>;
75
- signPayload<T extends Record<string, unknown>>(payload: T): Promise<SignedPayload<T>>;
75
+ signPayload<T>(payload: T): Promise<NonceEnrichedSignedPayload<T>>;
76
+ private getEnrichedPayload;
76
77
  private generateRedeemBagStruct;
77
78
  private getERC20Precission;
78
79
  private calculatePendingDeposits;
package/dist/DripSdk.js CHANGED
@@ -347,7 +347,9 @@ class DripSdk {
347
347
  }
348
348
  upgradeLoyaltyCard(index) {
349
349
  return __awaiter(this, void 0, void 0, function* () {
350
- const payload = { index };
350
+ const payload = {
351
+ index
352
+ };
351
353
  const signedPayload = yield this.signPayload(payload);
352
354
  return this.dripApi.upgradeLoyaltyCard(signedPayload);
353
355
  });
@@ -557,20 +559,31 @@ class DripSdk {
557
559
  signPayload(payload) {
558
560
  return __awaiter(this, void 0, void 0, function* () {
559
561
  if (!this.signer) {
560
- throw Error('No signer provided');
562
+ throw new Error('No signer provided');
561
563
  }
564
+ // Wrap the payload in a Basepayload to enrich it later on
565
+ const basePayload = {
566
+ payload
567
+ };
562
568
  const signerAddress = yield this.signer.getAddress();
569
+ // Get enriched payload with nonce before signing
570
+ const enrichedPayload = yield this.getEnrichedPayload(basePayload);
563
571
  // Create message to sign
564
- const message = JSON.stringify(payload);
572
+ const message = JSON.stringify(enrichedPayload);
565
573
  // Sign the message
566
574
  const signature = yield this.signer.signMessage(message);
567
575
  return {
568
576
  signature,
569
577
  signerAddress,
570
- payload,
578
+ payload: enrichedPayload,
571
579
  };
572
580
  });
573
581
  }
582
+ getEnrichedPayload(payload) {
583
+ return __awaiter(this, void 0, void 0, function* () {
584
+ return this.dripApi.getNonceEnrichedPayload(payload.payload);
585
+ });
586
+ }
574
587
  generateRedeemBagStruct(vault, signerAddress, amountToWithdraw) {
575
588
  return __awaiter(this, void 0, void 0, function* () {
576
589
  if (!this.spoolSdk) {
@@ -1,4 +1,368 @@
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
+ },
2
366
  {
3
367
  "inputs": [
4
368
  {
@@ -91,5 +455,62 @@
91
455
  ],
92
456
  "stateMutability": "payable",
93
457
  "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"
94
515
  }
95
516
  ]