@dripfi/drip-sdk 1.3.0 → 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 +41 -40
- package/dist/DripApi.d.ts +3 -2
- package/dist/DripApi.js +17 -0
- package/dist/DripSdk.d.ts +3 -2
- package/dist/DripSdk.js +17 -4
- package/dist/types/SignedPayload.d.ts +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -73,9 +73,13 @@ const dripSdk = new DripSdk(chain, signer);
|
|
73
73
|
| `getMyPerqBalance(): Promise<MyPerqData>` | YES | This function retrieves the user's Perq balance data.
|
74
74
|
| `getVaultsClaimableData(): Promise<VaultClaimData> ` | YES | This function fetches claimable data for the user's vaults.
|
75
75
|
| `upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>` | YES | This function upgrades the user's loyalty card.
|
76
|
-
| `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | YES | This function fetches the
|
76
|
+
| `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | YES | This function fetches the next loyalty card for the authenticated user based on the currently owned one
|
77
77
|
| `getAllLoyaltyCards(): Promise<LoyaltyCard[]>` | YES | This function fetches all available loyalty cards.
|
78
78
|
|
79
|
+
|
80
|
+
> [!IMPORTANT]
|
81
|
+
> **You must authenticate once for every wallet you want to use**
|
82
|
+
|
79
83
|
---
|
80
84
|
|
81
85
|
# Examples
|
@@ -205,7 +209,7 @@ type Vault = {
|
|
205
209
|
depositToken: VaultDepositToken
|
206
210
|
type: VaultType
|
207
211
|
rewards: VaultReward[]
|
208
|
-
rewardType: RewardType
|
212
|
+
rewardType: RewardType
|
209
213
|
liveUntil: string
|
210
214
|
liveFrom: string
|
211
215
|
liveUntilFormatted: string
|
@@ -219,15 +223,9 @@ type Vault = {
|
|
219
223
|
coingeckoId?: string
|
220
224
|
depositTokenId: string
|
221
225
|
expectedTge?: string
|
222
|
-
tokenPrice: number
|
223
|
-
change24h: number
|
224
|
-
volume24h: number
|
225
|
-
projectFeatured: boolean
|
226
|
-
avgTvl: string
|
227
|
-
peakTvl: string
|
228
|
-
amountOfDepositors: number
|
229
|
-
boostedTvl: number
|
230
|
-
projectVAPY?: number
|
226
|
+
tokenPrice: number,
|
227
|
+
change24h: number,
|
228
|
+
volume24h: number,
|
231
229
|
};
|
232
230
|
|
233
231
|
type VaultType = 'launch' | 'earn' | 'airdrop'
|
@@ -368,35 +366,38 @@ enum ELoyaltyCardTier {
|
|
368
366
|
|
369
367
|
export type MyPerqData = {
|
370
368
|
[key: string]: {
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
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 }};
|
400
398
|
}
|
401
399
|
};
|
400
|
+
|
401
|
+
|
402
|
+
|
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 {
|
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:
|
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 {
|
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
|
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 = {
|
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(
|
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,5 +1,12 @@
|
|
1
|
-
export type
|
1
|
+
export type BasePayload<T> = {
|
2
|
+
payload: T;
|
3
|
+
};
|
4
|
+
export type NonceEnrichedPayload<T> = T & {
|
5
|
+
deadline: number;
|
6
|
+
signature: string;
|
7
|
+
};
|
8
|
+
export type NonceEnrichedSignedPayload<T> = {
|
2
9
|
signature: string;
|
3
10
|
signerAddress: string;
|
4
|
-
payload: T
|
11
|
+
payload: NonceEnrichedPayload<T>;
|
5
12
|
};
|