@dripfi/drip-sdk 1.2.10 → 1.2.12
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 +89 -2
- package/dist/DripConfig.js +7 -7
- package/dist/DripSdk.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -51,7 +51,7 @@ const dripSdk = new DripSdk(chain, signer);
|
|
51
51
|
| `isUserAuthenticated(): Promise<AuthenticationStatus>` | NO | Checks if the user is authenticated and returns authentication status along with relevant information. |
|
52
52
|
| `authenticate(): Promise<boolean>` | NO | Initiates the user authentication process and returns a boolean indicating success. |
|
53
53
|
| `deposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>` | NO | The deposit function allows you to deposit tokens into a specific vault. Returns txHash. |
|
54
|
-
| `getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number): Promise<string>`|
|
54
|
+
| `getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number): Promise<string>`| NO | Returns the expected amount of tokens to get from a swap |
|
55
55
|
| `getUserBalance(): Promise<UserBalance>` | YES | Returns overall user balance information |
|
56
56
|
| `getUserBoostedNfts(vaultAddress: string): Promise<string[]>` | YES | Returns an array of boosted nfts addresses owned by the user |
|
57
57
|
| `getRewardsPerHour(vaultAddress: string): Promise<string[]>` | YES | Returns an estimated amount of tokens the user will receive in 1 hour as reward. It considers boost nfts the user owns for the estimation. |
|
@@ -61,6 +61,26 @@ const dripSdk = new DripSdk(chain, signer);
|
|
61
61
|
| `swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>` | YES | The swapAndDeposit function allows you to deposit a different token or ether and it will take care of swapping to the correct token before making the deposit. Returns txHash. |
|
62
62
|
| `withdraw(vault: Vault, amountToWithdraw?: string): Promise<string>` | YES | Withdraws tokens from a vault. After withdrawing, you must wait for the withdrawal to be processed by the 'DoHardWork' function, and then you can claim those tokens using claimWithdraws(). Returns txHash. |
|
63
63
|
| `claimWithdraws(vaultAddress: string): Promise<string>` | YES | After the withdrawal has been processed by the 'DoHardWork' function, the 'claimWithdraws' function transfers the withdrawn tokens to their personal account. Returns txHash. |
|
64
|
+
| `getTokenAllowanceForCurrency(tokenAddress: string): Promise<string>` | NO | This function retrieves the token allowance for a specific currency. |
|
65
|
+
| `getTokenAllowanceForRecycler(tokenAddress: string): Promise<BigNumber>` | NO | This function retrieves the token allowance for the recycler contract. |
|
66
|
+
| `getTokenAllowanceForSwapAndRecycler(tokenAddress: string): Promise<BigNumber>` | NO | This function retrieves the token allowance for the swap and recycler contract. |
|
67
|
+
| `getUserBoostedNfts(vaultAddress: string, headers?: Headers): Promise<string[]>` | YES | This function retrieves an array of boosted NFT addresses owned by the user. |
|
68
|
+
| `getRewardsPerHour(vaultAddress: string): Promise<number> ` | YES | This function returns an estimated amount of tokens the user will receive in one hour as a reward for the given vault |
|
69
|
+
| `newDeposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>` | YES | This function allows for a new deposit without checking for allowance.
|
70
|
+
| `newSwapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string> ` | YES | This function allows for a new swap and deposit without checking for allowance. |
|
71
|
+
| `getAllVestingInfo(beneficiaryAddress: string): Promise<VestingInfo>` | YES | This function retrieves all vesting information for a specified beneficiary. |
|
72
|
+
| `getVestingStart(): Promise<string>` | YES | This function retrieves the start time of the vesting period. |
|
73
|
+
| `getVestingEnd(): Promise<string>` | YES | This function retrieves the end time of the vesting period.
|
74
|
+
| `getBeansHistory(): Promise<BeanEntry[]> ` | YES | This function retrieves the user's beans history of tx
|
75
|
+
| `getBeansBalance(headers?: Headers): Promise<BeansBalance> ` | YES | This function retrieves the user's beans balance.
|
76
|
+
| `getMyPerqBalance(headers?: Headers): Promise<MyPerqData>` | YES | This function retrieves the user's Perq balance data.
|
77
|
+
| `getVaultsClaimableData(headers?: Headers): Promise<VaultClaimData> ` | YES | This function fetches claimable data for the user's vaults.
|
78
|
+
| `upgradeLoyaltyCard(): Promise<LoyaltyCard>` | YES | This function upgrades the user's loyalty card.
|
79
|
+
| `getNextLoyaltyCard(headers?: Headers): Promise<LoyaltyCard> ` | YES | This function fetches the next loyalty card for the authenticated user based on the currently owned one
|
80
|
+
| `getOwnedLoyaltyCards(headers?: Headers): Promise<LoyaltyCard>` | YES | This function fetches the next loyalty card for the authenticated user based on the currently owned one
|
81
|
+
| `getAllLoyaltyCards(): Promise<LoyaltyCard[]>` | YES | This function fetches all available loyalty cards.
|
82
|
+
| `getLoyaltyCardBoost(rewardId: string, headers?: Headers): Promise<number>` | YES | This function retrieves the boost value for a specific loyalty card.
|
83
|
+
|
64
84
|
|
65
85
|
|
66
86
|
> [!IMPORTANT]
|
@@ -324,6 +344,73 @@ type VaultStats = {
|
|
324
344
|
totalUsers: number
|
325
345
|
activeVaults: number
|
326
346
|
};
|
327
|
-
|
347
|
+
|
348
|
+
type BeanEntry = {
|
349
|
+
address: string
|
350
|
+
reason: string
|
351
|
+
recycledAmount: string
|
352
|
+
beansAmount: string
|
353
|
+
beansSum: string
|
354
|
+
amountDepositedInUsd: string
|
355
|
+
createdAt: string
|
356
|
+
chainId: number
|
357
|
+
nonce: number
|
358
|
+
};
|
359
|
+
|
360
|
+
export type BeansBalance = {
|
361
|
+
balance: string
|
362
|
+
bonusesClaimed: string[]
|
363
|
+
};
|
364
|
+
|
365
|
+
enum Chain {
|
366
|
+
MAINNET = 'mainnet',
|
367
|
+
SEPOLIA = 'sepolia'
|
368
|
+
}
|
369
|
+
|
370
|
+
enum ELoyaltyCardTier {
|
371
|
+
White = 'White',
|
372
|
+
Ivory = 'Ivory',
|
373
|
+
Dune = 'Dune',
|
374
|
+
Amber = 'Amber',
|
375
|
+
Sienna = 'Sienna',
|
376
|
+
Umber = 'Umber',
|
377
|
+
Black = 'Black'
|
378
|
+
}
|
379
|
+
|
380
|
+
export type MyPerqData = {
|
381
|
+
[key: string]: {
|
382
|
+
vaultAddress: string,
|
383
|
+
projectName: string,
|
384
|
+
projectType: string,
|
385
|
+
projectFeatured: boolean,
|
386
|
+
liveUntil: string,
|
387
|
+
coingeckoId?: string,
|
388
|
+
depositTokenId: 'WETH' | 'USDC' | 'DAI',
|
389
|
+
type: 'earn' | 'launch' | 'airdrop',
|
390
|
+
rewardType: 'points' | 'token' | 'pnode shards',
|
391
|
+
amountOfTokens?: number
|
392
|
+
vaultName: string,
|
393
|
+
protocols: string[],
|
394
|
+
apy: number,
|
395
|
+
tvr: number,
|
396
|
+
tokenPrice: number,
|
397
|
+
change24h: number,
|
398
|
+
volume24h: number,
|
399
|
+
rewards: CacheVaultRewards[]
|
400
|
+
strategies: Strategy[],
|
401
|
+
boosters: NFTBoost[],
|
402
|
+
depositToken: DepositToken
|
403
|
+
avgTvl: string
|
404
|
+
peakTvl: string
|
405
|
+
pendingDeposits: number;
|
406
|
+
currentlyDeposited: number;
|
407
|
+
pendingWithdraws: number;
|
408
|
+
claimable: number;
|
409
|
+
ethPrice: number;
|
410
|
+
tokenRewards: {[token_address: string]: Asset & { amount: number, rewardsPerHour: number }};
|
411
|
+
}
|
412
|
+
};
|
413
|
+
|
414
|
+
|
328
415
|
|
329
416
|
```
|
package/dist/DripConfig.js
CHANGED
@@ -23,12 +23,12 @@ const RECYCLER_ADDRESS_SEPOLIA = '0x07F2264E199D62afe07E8288eC9D36d155fc3f24';
|
|
23
23
|
const SWAP_AND_RECYCLER_ADDRESS_SEPOLIA = '0xA4ed357FF233731860Ec8D0446FD95756d564014';
|
24
24
|
const VESTING_ADDRESS_SEPOLIA = '0x1d3B9E32a7139718f94BE32c797682fFf2D1bE60';
|
25
25
|
const DRIP_TOKEN_ADDRESS_SEPOLIA = '0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E';
|
26
|
+
const DEV_BACKEND_ROUTE = 'https://dev.drip.fi.io';
|
26
27
|
const SUBGRAPH_URL_MAINNET = 'https://subgraph.satsuma-prod.com/49eb322da234/solidant/spool-v2/api';
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
const RECYCLER_ADDRESS_MAINNET = '0x2FdcdB17799557Dce6f26921f12B7FA1DbcD79FA';
|
29
|
+
const SWAP_AND_RECYCLER_ADDRESS_MAINNET = '0x15ED53964E6a5EcbEBAb80A0Fc68c2297b0eaA8D';
|
30
|
+
const VESTING_ADDRESS_MAINNET = '0x5e19C155C30bDEB83FCFE20a3b6f6Eda34B746c5';
|
30
31
|
const DRIP_TOKEN_ADDRESS_MAINNET = '0x2a414884a549ef5716bc1a4e648d3dc03f08b2cf';
|
31
|
-
const DEV_BACKEND_ROUTE = 'https://dev.drip.fi.io';
|
32
32
|
const PROD_BACKEND_ROUTE = 'https://perq.finance';
|
33
33
|
class DripConfig {
|
34
34
|
constructor(chain, dripRoute) {
|
@@ -37,9 +37,9 @@ class DripConfig {
|
|
37
37
|
this.internalConfig = (0, spool_v2_sdk_1.getMainnetConfig)(SUBGRAPH_URL_MAINNET);
|
38
38
|
this.dripRoute = dripRoute !== undefined ? dripRoute : PROD_BACKEND_ROUTE;
|
39
39
|
this.dripTokenAddress = DRIP_TOKEN_ADDRESS_MAINNET;
|
40
|
-
this.dripTokenRecyclerAddress =
|
41
|
-
this.dripSwapAndRecyclerAddress =
|
42
|
-
this.perqVestingAddress =
|
40
|
+
this.dripTokenRecyclerAddress = RECYCLER_ADDRESS_MAINNET;
|
41
|
+
this.dripSwapAndRecyclerAddress = SWAP_AND_RECYCLER_ADDRESS_MAINNET;
|
42
|
+
this.perqVestingAddress = VESTING_ADDRESS_MAINNET;
|
43
43
|
break;
|
44
44
|
case Chain.SEPOLIA:
|
45
45
|
this.internalConfig = (0, spool_v2_sdk_1.getSepoliaConfig)(SUBGRAPH_URL_SEPOLIA);
|
package/dist/DripSdk.js
CHANGED
@@ -424,7 +424,7 @@ class DripSdk {
|
|
424
424
|
if (this.dripConfig.dripSwapAndRecyclerAddress === DripConfig_1.NULL_ADDRESS) {
|
425
425
|
throw Error('Recycler contract address not defined');
|
426
426
|
}
|
427
|
-
console.log(
|
427
|
+
console.log('swap and recycle ERC-20 with this: ', {
|
428
428
|
beneficiary,
|
429
429
|
path,
|
430
430
|
amountInWithDecimals,
|
@@ -532,7 +532,8 @@ class DripSdk {
|
|
532
532
|
if (!this.signer) {
|
533
533
|
throw Error('No signer provided');
|
534
534
|
}
|
535
|
-
|
535
|
+
//TODO: Temporary fix for Base L2 Deposits getting decimals does crash for some reason
|
536
|
+
const decimals = tokenAddress === '0x4200000000000000000000000000000000000006' ? 18 : yield this.getERC20Precission(tokenAddress);
|
536
537
|
const erc20Instance = spool_v2_sdk_1.ERC20__factory.connect(tokenAddress, this.signer);
|
537
538
|
const approveTx = yield erc20Instance.transfer(receiver, ethers_1.ethers.utils.parseUnits(amount, decimals));
|
538
539
|
const receipt = yield approveTx.wait();
|