@dripfi/drip-sdk 1.4.17 → 1.4.18
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 +68 -72
- package/dist/types/MyPerqData.d.ts +1 -0
- package/dist/types/index.d.ts +1 -2
- package/package.json +1 -1
- package/dist/types/Vault.d.ts +0 -35
- package/dist/types/Vault.js +0 -2
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
|
-
|
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
|
-
|
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
|
-
|
53
|
+
## Modules
|
54
54
|
|
55
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
124
|
+
### User
|
125
125
|
|
126
126
|
Access user methods through `sdk.user`:
|
127
127
|
|
128
|
-
| Method
|
129
|
-
|
|
130
|
-
| `linkSuiWalletWithEthWallet(suiWalletAddress: string): Promise<boolean>`
|
131
|
-
| `
|
132
|
-
| `
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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,
|
203
|
+
### `swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, onChainProjectId: number): Promise<string>`
|
201
204
|
|
202
|
-
I want to deposit 1.
|
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
|
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
|
-
|
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>`
|
218
|
-
|
219
|
-
```typescript
|
220
|
-
const userBalanceObject = await getUserBalance();
|
221
|
-
const balance = userBalanceObject.userbalance;
|
222
|
-
```
|
223
|
-
|
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)
|
214
|
+
I want to deposit 100 DAI in a USDC vault:
|
229
215
|
|
230
216
|
```typescript
|
231
|
-
|
232
|
-
const vaultToWithdrawFrom = vaults[0];
|
217
|
+
DAI_TOKEN_ADDRESS = "0x6b175474e89094c44da98b954eedeac495271d0f" --> DAI contract address example
|
233
218
|
|
234
|
-
|
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
|
-
>
|
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
|
-
### `
|
228
|
+
### `migrateDepositToOtherProject(tokenAddress: string, vaultAddress: string, onChainProjectId: number, targetOnChainProjectId, amount: string): Promise<string>`
|
249
229
|
|
250
|
-
|
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
|
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
|
-
### `
|
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
|
276
|
-
Fetch vaults returned by getAllVault() and pass the vault you want to withdraw from, and the amount to withdraw (
|
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
|
280
|
-
|
281
|
-
|
282
|
-
|
258
|
+
const txHash = await lite.withdraw(
|
259
|
+
vaultToWithdrawFrom.depositToken.tokenAddress,
|
260
|
+
vaultToWithdrawFrom.vaultAddress,
|
261
|
+
vaultToWithdrawFrom.onChainProjectId,
|
262
|
+
'100',
|
263
|
+
);
|
283
264
|
```
|
284
265
|
|
285
|
-
|
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
|
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
|
-
|
281
|
+
## Types
|
292
282
|
|
293
283
|
```typescript
|
294
284
|
type Asset = {
|
@@ -397,6 +387,7 @@ type LoyaltyCard = {
|
|
397
387
|
type MyPerqBalance = {
|
398
388
|
currentlyDeposited: number;
|
399
389
|
earnedRewards: number;
|
390
|
+
earnedRewardsUsd: number;
|
400
391
|
rewardsPerHour: number;
|
401
392
|
};
|
402
393
|
|
@@ -420,6 +411,11 @@ type BasePayload<T> = {
|
|
420
411
|
payload: T;
|
421
412
|
};
|
422
413
|
|
414
|
+
type LinkedPodWallets = {
|
415
|
+
suiWalletAddr: string;
|
416
|
+
nearWalletAddr: string;
|
417
|
+
};
|
418
|
+
|
423
419
|
type NonceEnrichedPayload<T> = T & {
|
424
420
|
deadline: number;
|
425
421
|
signature: string;
|
@@ -640,7 +636,7 @@ type Earnings = {
|
|
640
636
|
};
|
641
637
|
```
|
642
638
|
|
643
|
-
|
639
|
+
## Abis
|
644
640
|
|
645
641
|
- PERQ_SWAP_AND_RECYCLER_ABI
|
646
642
|
|
package/dist/types/index.d.ts
CHANGED
@@ -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,
|
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
package/dist/types/Vault.d.ts
DELETED
@@ -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;
|
package/dist/types/Vault.js
DELETED