@dripfi/drip-sdk 1.4.17 → 1.4.19

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
@@ -19,7 +19,7 @@ The Drip SDK is a TypeScript library designed to interact with the Perq protocol
19
19
  - [Types](#types)
20
20
  - [Abis](#abis)
21
21
 
22
- # Installation
22
+ ## Installation
23
23
 
24
24
  To use the Drip SDK in your project, you can install it via npm or yarn:
25
25
 
@@ -27,7 +27,7 @@ To use the Drip SDK in your project, you can install it via npm or yarn:
27
27
  npm i @dripfi/drip-sdk
28
28
  ```
29
29
 
30
- # Usage
30
+ ## Usage
31
31
 
32
32
  ```typescript
33
33
  import PerqSdk from '@drip/sdk';
@@ -50,9 +50,9 @@ const provider: ethers.providers.JsonRpcProvider = /* your Web3Provider instance
50
50
  const perqSdk = new PerqSdk(perqConfig, perqSupportedChainId, provider?: ethers.providers.JsonRpcProvider);
51
51
  ```
52
52
 
53
- # Modules
53
+ ## Modules
54
54
 
55
- ## Core SDK
55
+ ### Core SDK
56
56
 
57
57
  Core methods available directly on the SDK instance:
58
58
 
@@ -60,7 +60,7 @@ Core methods available directly on the SDK instance:
60
60
  | ------------------------------------------------ | ------------------------------------------------------------ |
61
61
  | `updateSigner(newSigner: Signer): Promise<void>` | Updates the signer for the SDK instance and all its modules. |
62
62
 
63
- ## Lite Vaults
63
+ ### Lite Vaults
64
64
 
65
65
  Access Lite vault methods through `sdk.lite`:
66
66
 
@@ -76,7 +76,7 @@ Access Lite vault methods through `sdk.lite`:
76
76
  | `approveSwapAndDeposit(tokenAddress: string, amount: string): Promise<string>` | Approves a token for swap and deposit operations. |
77
77
  | `getExpectedSwapResult(fromTokenAddress: string,toTokenAddress: string,amount: string,decimals: number, chainId: PerqSupportedChainId): Promise<string>` | Calculates the expected result of a swap operation on a specific chain. |
78
78
 
79
- ## Loyalty Cards
79
+ ### Loyalty Cards
80
80
 
81
81
  Access loyalty card methods through `sdk.loyaltyCards`:
82
82
 
@@ -89,7 +89,7 @@ Access loyalty card methods through `sdk.loyaltyCards`:
89
89
  | `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | Gets user's owned loyalty card. |
90
90
  | `getAllLoyaltyCards(): Promise<LoyaltyCard[]>` | Gets all available loyalty cards. |
91
91
 
92
- ## Vesting
92
+ ### Vesting
93
93
 
94
94
  Access vesting methods through `sdk.vesting`:
95
95
 
@@ -104,7 +104,7 @@ Access vesting methods through `sdk.vesting`:
104
104
  | `claimVestedPerq(amount: string): Promise<string>` | Claims vested Perq. |
105
105
  | `burnVestedPerq(amount: string, price: string, deadline: string, signature: string): Promise<string>` | Burns vested Perq. |
106
106
 
107
- ## Pools
107
+ ### Pools
108
108
 
109
109
  Access pools methods through `sdk.pools`:
110
110
 
@@ -121,17 +121,18 @@ Access pools methods through `sdk.pools`:
121
121
  | `getUserBoostedNfts(vaultAddress: string): Promise<string[]>` | Fetches the user's boosted NFTs for a specific pool. |
122
122
  | `getRewards(): Promise<UserRewards>` | Fetches the user's rewards. |
123
123
 
124
- ## User
124
+ ### User
125
125
 
126
126
  Access user methods through `sdk.user`:
127
127
 
128
- | Method | Description |
129
- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
130
- | `linkSuiWalletWithEthWallet(suiWalletAddress: string): Promise<boolean>` | Links a Sui wallet with an Ethereum wallet. |
131
- | `getLinkedSuiWallet(): Promise<string>` | Retrieves the Sui wallet address linked to the user's Ethereum wallet. |
132
- | `getEarnings(projectName: string): Promise<Earnings>` | Retrieves the user earnings for each project's vaults |
128
+ | Method | Description |
129
+ | -------------------------------------------------------------------------- | ----------------------------------------------------------- |
130
+ | `linkSuiWalletWithEthWallet(suiWalletAddress: string): Promise<boolean>` | Links a Sui wallet with an Ethereum wallet. |
131
+ | `linkNearWalletWithEthWallet(nearWalletAddress: string): Promise<boolean>` | Links a Near wallet with an Ethereum wallet. |
132
+ | `getLinkedPodWallets(): Promise<LinkedPodWallets>` | Retrieves all wallets linked to the user's Ethereum wallet. |
133
+ | `getEarnings(projectName: string): Promise<Earnings>` | Retrieves the user earnings for each project's vaults |
133
134
 
134
- ## Recycler
135
+ ### Recycler
135
136
 
136
137
  Access recycler methods through `sdk.recycler`:
137
138
 
@@ -145,10 +146,12 @@ Access recycler methods through `sdk.recycler`:
145
146
  | `approveTokenForRecycler(tokenAddress: string, amount: string): Promise<string>` | Approves a token for use with the recycler contract. |
146
147
  | `approveTokenForSwapAndRecycler(tokenAddress: string, amount: string): Promise<string>` | Approves a token for use with the swap and recycler contract. |
147
148
 
148
- ## Token Utils
149
+ ### Token Utils
149
150
 
150
151
  Access token utils methods through `sdk.tokenUtils`:
152
+
151
153
  | Method | Description |
154
+
152
155
  | -------------------------------------------------------------------- | -------------------------------------- |
153
156
  | `getTokenPrice(tokenName: string): Promise<number>` | Fetches the current price of a given token."perq", "weth" "eth" and "wbtc" are supported |
154
157
  | `getAllowance(tokenAddress: string, spender: string): Promise<string>` | Retrieves the current allowance for a token. |
@@ -158,7 +161,7 @@ Access token utils methods through `sdk.tokenUtils`:
158
161
  | `getERC20TokenAllowance(spender: string, tokenAddress: string): Promise<BigNumber>` | Retrieves the allowance for a specific ERC20 token. |
159
162
  | `getPerqTokenContractAddress(): string` | Returns the contract address of the Perq token. |
160
163
 
161
- ## Sign Handler
164
+ ### Sign Handler
162
165
 
163
166
  Access signing methods through `sdk.signHandler`:
164
167
 
@@ -166,7 +169,7 @@ Access signing methods through `sdk.signHandler`:
166
169
  | -------------------------------------------------------------------- | -------------------------------------- |
167
170
  | `signPayload<T>(payload: T): Promise<NonceEnrichedSignedPayload<T>>` | Signs a payload with nonce enrichment. |
168
171
 
169
- # Examples
172
+ ## Examples
170
173
 
171
174
  ### `deposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>`
172
175
 
@@ -191,78 +194,54 @@ const txHash = await deposit(USDC_TOKEN_ADDRESS, VAULT_ADDRESS, '100')
191
194
 
192
195
  > [!NOTE]
193
196
  > Allowance is calculated by the deposit method, based on the current allowance and the required
194
-
197
+ >
195
198
  > [!IMPORTANT]
196
199
  > Amount should be formatted, not parsed. In the example we want to deposit 100 USDC so we just input that value instead of adding 6 decimals (100000000)
197
200
 
198
201
  ---
199
202
 
200
- ### `swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>`
203
+ ### `swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, onChainProjectId: number): Promise<string>`
201
204
 
202
- I want to deposit 1.5ETH in a WETH vault:
205
+ I want to deposit 1.5 ETH in a WETH vault:
203
206
 
204
207
  ```typescript
205
- WETH_TOKEN_ADDRESS = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" --> WETH contract address in tenderly environment
208
+ WETH_TOKEN_ADDRESS = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" --> WETH contract address example
206
209
 
210
+ // For depositing ETH into WETH pool you have to provide the WETH tokens address as a toTokenAddress as ETH itself doesn't have an address
207
211
  const txHash = await swapAndDeposit(WETH_TOKEN_ADDRESS, WETH_TOKEN_ADDRESS, '0', vaultAddress, '1.5')
208
212
  ```
209
213
 
210
- you can get vault token address from the vault.depositToken.tokenAddress
211
-
212
- > [!IMPORTANT]
213
- > ethAmount and fromTokenAmount should be formatted, not parsed. In the example we want to deposit 1.5 WETH so we just input that value instead of adding 18 decimals (1500000000000000000)
214
-
215
- ---
216
-
217
- ### `withdraw(vault: Vault, amountToWithdraw?: string): Promise<string>`
214
+ I want to deposit 100 DAI in a USDC vault:
218
215
 
219
216
  ```typescript
220
- const userBalanceObject = await getUserBalance();
221
- const balance = userBalanceObject.userbalance;
222
- ```
217
+ DAI_TOKEN_ADDRESS = "0x6b175474e89094c44da98b954eedeac495271d0f" --> DAI contract address example
223
218
 
224
- > [!NOTE]
225
- > If i check balance, that is the max amount I can withdraw
226
-
227
- I want to withdraw 100 USDC from the 1st vault fetched. ---> Let's assume the first vault is a USDC vault for simplicity
228
- Fetch vaults returned by getAllVault() and pass the vault you want to withdraw from, and the amount to withdraw (100 in this example)
229
-
230
- ```typescript
231
- const vaults = await getAllVaults();
232
- const vaultToWithdrawFrom = vaults[0];
233
-
234
- const txHash = await withdraw(vaultToWithdrawFrom, '100');
235
- ```
236
-
237
- if you want to withdraw all funds in the vault, don't specify the amountToWithdraw:
238
-
239
- ```typescript
240
- const txHash = await withdraw(vaultToWithdrawFrom);
219
+ // Assuming you already have the data of the vault
220
+ const txHash = await swapAndDeposit(DAI_TOKEN_ADDRESS, vault.depositToken.tokenAdrress, '100', vault.vaultAddress, vault.onChainProjectId)
241
221
  ```
242
222
 
243
223
  > [!IMPORTANT]
244
- > you will have to claim your withdraws after DHW is processed to transfer the withdrawn funds to your wallet
224
+ > ethAmount and fromTokenAmount should be formatted, not parsed. In the example we want to deposit 1.5 WETH so we just input that value instead of adding 18 decimals (1500000000000000000)
245
225
 
246
226
  ---
247
227
 
248
- ### `claimWithdraws(vaultAddress: string): Promise<string>`
228
+ ### `migrateDepositToOtherProject(tokenAddress: string, vaultAddress: string, onChainProjectId: number, targetOnChainProjectId, amount: string): Promise<string>`
249
229
 
250
- ```typescript
251
- const userBalanceObject = await getUserBalance();
252
- const hasWithdrawsToClaim = userBalanceObject.hasWithdrawsToClaim;
253
- ```
254
-
255
- if hasWithdrawsToClaim is true you have available funds to transfer to your address
230
+ I want to migrate 50 USDC from projectA to projectB. ---> Let's assume we already fetched the data for these projects and selected the USDC pool of projectA which is called selectedPool in this example
256
231
 
257
232
  ```typescript
258
- const txHash = await claimWithdraws();
233
+ const txHash = await lite.migrateDepositToOtherProject(
234
+ selectedPool.depositToken.tokenAddress,
235
+ selectedPool.vaultAddress,
236
+ selectedPool.onChainProjectId,
237
+ projectB.onChainProjectId || -1,
238
+ '50',
239
+ );
259
240
  ```
260
241
 
261
- It will transfer all available funds withdrawn with withdraw() function, to your address
262
-
263
242
  ---
264
243
 
265
- ### `fastWithdraw(vault: Vault, amountToWithdraw?: string): Promise<string>`
244
+ ### `withdraw(tokenAddress: string, vaultAddress: string, onChainProjectId: number, amount: string): Promise<string>`
266
245
 
267
246
  ```typescript
268
247
  const userBalanceObject = await getUserBalance();
@@ -272,23 +251,34 @@ const balance = userBalanceObject.userbalance;
272
251
  > [!NOTE]
273
252
  > If i check balance, that is the max amount I can withdraw
274
253
 
275
- I want to withdraw 3.55 WETH from the 1st vault fetched. ---> Let's assume the first vault is a WETH vault for simplicity
276
- Fetch vaults returned by getAllVault() and pass the vault you want to withdraw from, and the amount to withdraw (3.55 in this example)
254
+ I want to withdraw 100 USDC from the 1st vault fetched. ---> Let's assume the first vault is a USDC vault for simplicity
255
+ Fetch vaults returned by getAllVault() and pass the vault you want to withdraw from, and the amount to withdraw (100 in this example)
277
256
 
278
257
  ```typescript
279
- const vaults = await getAllVaults();
280
- const vaultToWithdrawFrom = vaults[0];
281
-
282
- const txHash = await fastWithdraw(vaultToWithdrawFrom, '3.55');
258
+ const txHash = await lite.withdraw(
259
+ vaultToWithdrawFrom.depositToken.tokenAddress,
260
+ vaultToWithdrawFrom.vaultAddress,
261
+ vaultToWithdrawFrom.onChainProjectId,
262
+ '100',
263
+ );
283
264
  ```
284
265
 
285
- if you want to withdraw all funds in the vault, don't specify the amountToWithdraw, like:
266
+ I want to withdraw 3.55 WETH from the 1st vault fetched. ---> Let's assume the first vault is a WETH vault for simplicity
267
+ Fetch vaults returned by getAllVault() and pass the vault you want to withdraw from, and the amount to withdraw (3.55 in this example)
286
268
 
287
269
  ```typescript
288
- const txHash = await fastWithdraw(vaultToWithdrawFrom);
270
+ const vaults = await sdk.pools.getAllPools();
271
+ const vaultToWithdrawFrom = vaults[0];
272
+
273
+ const txHash = await lite.withdraw(
274
+ vaultToWithdrawFrom.depositToken.tokenAddress,
275
+ vaultToWithdrawFrom.vaultAddress,
276
+ vaultToWithdrawFrom.onChainProjectId,
277
+ '3.55',
278
+ );
289
279
  ```
290
280
 
291
- # Types
281
+ ## Types
292
282
 
293
283
  ```typescript
294
284
  type Asset = {
@@ -376,6 +366,28 @@ type DepositToken = {
376
366
  tokenAddress: string;
377
367
  };
378
368
 
369
+ type VaultTvl = {
370
+ average: number;
371
+ averageUsd: number;
372
+ peak: number;
373
+ peakUsd: number;
374
+ current: number;
375
+ currentUsd: number;
376
+ historical: {
377
+ [timestamp: number]: {
378
+ amount: number;
379
+ amountUsd: number;
380
+ };
381
+ };
382
+ };
383
+
384
+ type ProjectTvl = {
385
+ averageUsd: number;
386
+ peakUsd: number;
387
+ currentUsd: number;
388
+ historical: { [timestamp: number]: number };
389
+ };
390
+
379
391
  enum ELoyaltyCardTier {
380
392
  White = 'White',
381
393
  Ivory = 'Ivory',
@@ -397,6 +409,7 @@ type LoyaltyCard = {
397
409
  type MyPerqBalance = {
398
410
  currentlyDeposited: number;
399
411
  earnedRewards: number;
412
+ earnedRewardsUsd: number;
400
413
  rewardsPerHour: number;
401
414
  };
402
415
 
@@ -420,6 +433,11 @@ type BasePayload<T> = {
420
433
  payload: T;
421
434
  };
422
435
 
436
+ type LinkedPodWallets = {
437
+ suiWalletAddr: string;
438
+ nearWalletAddr: string;
439
+ };
440
+
423
441
  type NonceEnrichedPayload<T> = T & {
424
442
  deadline: number;
425
443
  signature: string;
@@ -504,6 +522,7 @@ type UserRewards = {
504
522
  };
505
523
 
506
524
  type VaultData = {
525
+ tvl?: VaultTvl;
507
526
  depositToken: DepositToken;
508
527
  vaultAddress: string;
509
528
  projectName: string;
@@ -512,14 +531,10 @@ type VaultData = {
512
531
  liveFrom: string;
513
532
  liveUntil: string;
514
533
  apy: number;
515
- tvlUsd: number;
516
- avgTvl: number;
517
534
  tokenPrice: number;
518
535
  change24h: number;
519
536
  volume24h: number;
520
- peakTvl: number;
521
537
  onChainProjectId: number;
522
- combinedTvl: number;
523
538
  isActive: boolean;
524
539
  owners: string[];
525
540
  coingeckoId?: string;
@@ -640,7 +655,7 @@ type Earnings = {
640
655
  };
641
656
  ```
642
657
 
643
- # Abis
658
+ ## Abis
644
659
 
645
660
  - PERQ_SWAP_AND_RECYCLER_ABI
646
661
 
@@ -3,7 +3,9 @@ import VaultType from './VaultType';
3
3
  type MyPerqBalance = {
4
4
  currentlyDeposited: number;
5
5
  earnedRewards: number;
6
+ earnedRewardsUsd: number;
6
7
  rewardsPerHour: number;
8
+ rewardsPerHourUsd: number;
7
9
  };
8
10
  type MyPerqData = VaultData & MyPerqBalance & {
9
11
  ethPrice: number;
@@ -0,0 +1,9 @@
1
+ type ProjectTvl = {
2
+ averageUsd: number;
3
+ peakUsd: number;
4
+ currentUsd: number;
5
+ historical: {
6
+ [timestamp: number]: number;
7
+ };
8
+ };
9
+ export default ProjectTvl;
@@ -1,6 +1,8 @@
1
1
  import DepositToken from './DepositToken';
2
+ import ProjectTvl from './ProjectTvl';
2
3
  import VaultType from './VaultType';
3
4
  export type ReducedProjectData = {
5
+ tvl?: ProjectTvl;
4
6
  projectName: string;
5
7
  logo: string;
6
8
  bannerImage: string;
@@ -11,10 +13,7 @@ export type ReducedProjectData = {
11
13
  distributionType: VaultType;
12
14
  liveUntil: string;
13
15
  liveFrom: string;
14
- tvlUsd: number;
15
- tvl: number;
16
16
  vAPY: number;
17
- peakTVL: number;
18
17
  chainIds: number[];
19
18
  isFeatured: boolean;
20
19
  currencies: DepositToken[];
@@ -3,7 +3,9 @@ import DepositToken from './DepositToken';
3
3
  import Strategy from './Strategy';
4
4
  import StretchGoal from './StretchGoal';
5
5
  import VaultReward from './VaultReward';
6
+ import VaultTvl from './VaultTvl';
6
7
  type VaultData = {
8
+ tvl?: VaultTvl;
7
9
  depositToken: DepositToken;
8
10
  vaultAddress: string;
9
11
  projectName: string;
@@ -12,14 +14,10 @@ type VaultData = {
12
14
  liveFrom: string;
13
15
  liveUntil: string;
14
16
  apy: number;
15
- tvlUsd: number;
16
- avgTvl: number;
17
17
  tokenPrice: number;
18
18
  change24h: number;
19
19
  volume24h: number;
20
- peakTvl: number;
21
20
  onChainProjectId: number;
22
- combinedTvl: number;
23
21
  isActive: boolean;
24
22
  owners: string[];
25
23
  coingeckoId?: string;
@@ -0,0 +1,15 @@
1
+ type VaultTvl = {
2
+ average: number;
3
+ averageUsd: number;
4
+ peak: number;
5
+ peakUsd: number;
6
+ current: number;
7
+ currentUsd: number;
8
+ historical: {
9
+ [timestamp: number]: {
10
+ amount: number;
11
+ amountUsd: number;
12
+ };
13
+ };
14
+ };
15
+ export default VaultTvl;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -20,7 +20,6 @@ import StretchGoal from './StretchGoal';
20
20
  import SwapInfo from './SwapInfo';
21
21
  import UpgradeLoyaltyCardPayload from './UpgradeLoyaltyCardPayload';
22
22
  import UserRewards from './UserRewards';
23
- import Vault from './Vault';
24
23
  import VaultData from './VaultData';
25
24
  import VaultReward, { RewardType } from './VaultReward';
26
25
  import VaultStats from './VaultStats';
@@ -30,4 +29,4 @@ import YelayVersion from './YelayVersion';
30
29
  import Earnings from './Earnings';
31
30
  import LinkedPodWallets from './LinkedPodWallets';
32
31
  import MigrationOption from './MigrationOption';
33
- export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, DetailedProjectData, ELoyaltyCardTier, NearWalletPayload, SuiWalletPayload, LinkedPodWallets, LoyaltyCard, MigrationOption, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, ReducedProjectData, RewardType, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, Vault, VaultData, VaultReward, VaultStats, VaultType, VestingInfo, YelayVersion, Earnings, };
32
+ export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, DetailedProjectData, ELoyaltyCardTier, NearWalletPayload, SuiWalletPayload, LinkedPodWallets, LoyaltyCard, MigrationOption, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, ReducedProjectData, RewardType, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, VaultData, VaultReward, VaultStats, VaultType, VestingInfo, YelayVersion, Earnings, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dripfi/drip-sdk",
3
- "version": "1.4.17",
3
+ "version": "1.4.19",
4
4
  "description": "Drip SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,35 +0,0 @@
1
- import { DepositToken, VaultType, NFTBoost, Strategy, DeployedProject, VaultReward, RewardType } from './index';
2
- type Vault = {
3
- vaultName: string;
4
- vaultAddress: string;
5
- apy: number;
6
- tvr: number;
7
- protocols: string[];
8
- depositToken: DepositToken;
9
- type: VaultType;
10
- rewards: VaultReward[];
11
- rewardType: RewardType;
12
- liveUntil: string;
13
- liveFrom: string;
14
- liveUntilFormatted: string;
15
- hasPoolEnded: boolean;
16
- boosters: NFTBoost[];
17
- strategies: Strategy[];
18
- tgePrice?: number;
19
- maxAmountOfTokens?: number;
20
- project: DeployedProject;
21
- projectId: number;
22
- coingeckoId?: string;
23
- depositTokenId: string;
24
- expectedTge?: string;
25
- tokenPrice: number;
26
- change24h: number;
27
- volume24h: number;
28
- projectFeatured: boolean;
29
- avgTvl: string;
30
- peakTvl: string;
31
- amountOfDepositors: number;
32
- boostedTvl: number;
33
- projectVAPY?: number;
34
- };
35
- export default Vault;
File without changes