@dripfi/drip-sdk 1.4.3-yelay-lite-2 → 1.4.3-yelay-lite-4

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.
Files changed (42) hide show
  1. package/README.md +220 -44
  2. package/dist/PerqApi.d.ts +10 -9
  3. package/dist/PerqApi.js +36 -36
  4. package/dist/PerqSdk.d.ts +32 -83
  5. package/dist/PerqSdk.js +47 -581
  6. package/dist/abi/ERC20.json +222 -0
  7. package/dist/contracts/ERC20TokenContract.d.ts +10 -0
  8. package/dist/contracts/ERC20TokenContract.js +34 -0
  9. package/dist/contracts/PerqSwapAndRecyclerContract.d.ts +3 -2
  10. package/dist/contracts/PerqSwapAndRecyclerContract.js +2 -2
  11. package/dist/contracts/PerqTokenRecyclerContract.d.ts +3 -2
  12. package/dist/contracts/PerqTokenRecyclerContract.js +2 -2
  13. package/dist/contracts/PerqVestingContract.d.ts +3 -2
  14. package/dist/contracts/PerqVestingContract.js +2 -2
  15. package/dist/subpackages/LitePackage.d.ts +13 -0
  16. package/dist/subpackages/LitePackage.js +88 -0
  17. package/dist/subpackages/LoyaltyCardsPackage.d.ts +12 -0
  18. package/dist/subpackages/LoyaltyCardsPackage.js +34 -0
  19. package/dist/subpackages/PoolsPackage.d.ts +16 -0
  20. package/dist/subpackages/PoolsPackage.js +52 -0
  21. package/dist/subpackages/RecyclerPackage.d.ts +13 -0
  22. package/dist/subpackages/RecyclerPackage.js +87 -0
  23. package/dist/subpackages/SignHandlerPackage.d.ts +8 -0
  24. package/dist/subpackages/SignHandlerPackage.js +33 -0
  25. package/dist/subpackages/TokenUtilsPackage.d.ts +13 -0
  26. package/dist/subpackages/TokenUtilsPackage.js +66 -0
  27. package/dist/subpackages/UserPackage.d.ts +7 -0
  28. package/dist/subpackages/UserPackage.js +23 -0
  29. package/dist/subpackages/V2Package.d.ts +24 -0
  30. package/dist/subpackages/V2Package.js +207 -0
  31. package/dist/subpackages/VestingPackage.d.ts +14 -0
  32. package/dist/subpackages/VestingPackage.js +112 -0
  33. package/dist/types/ChainId.d.ts +5 -0
  34. package/dist/types/ChainId.js +7 -0
  35. package/dist/types/DetailedProjectData.d.ts +8 -7
  36. package/dist/types/VaultData.d.ts +2 -0
  37. package/dist/types/index.d.ts +1 -2
  38. package/dist/utils/chains.d.ts +1 -0
  39. package/dist/utils/chains.js +2 -1
  40. package/package.json +2 -2
  41. package/dist/types/YelayLiteVault.d.ts +0 -11
  42. package/dist/types/YelayLiteVault.js +0 -2
package/README.md CHANGED
@@ -8,7 +8,14 @@ The Drip SDK is a TypeScript library designed to interact with the Perq protocol
8
8
 
9
9
  - [Installation](#installation)
10
10
  - [Usage](#usage)
11
- - [Methods](#methods)
11
+ - [Modules](#modules)
12
+ - [Core SDK](#core-sdk)
13
+ - [V2 Vaults](#v2-vaults)
14
+ - [Lite Vaults](#lite-vaults)
15
+ - [Loyalty Cards](#loyalty-cards)
16
+ - [Vesting](#vesting)
17
+ - [Recycler](#recycler)
18
+ - [Sign Handler](#sign-handler)
12
19
  - [Examples](#examples)
13
20
  - [Types](#types)
14
21
  - [Abis](#abis)
@@ -31,52 +38,160 @@ import { PerqConfig } from '@dripfi/drip-sdk';
31
38
  Initialize the SDK with your Drip configuration and an optional signer:
32
39
 
33
40
  ```typescript
34
-
35
41
  const perqConfig: PerqConfig = PRODUCTION // if targeting ethereum mainnet
36
42
 
37
43
  const perqConfig: PerqConfig = DEVELOPMENT // if targeting sepolia testnet
38
44
 
39
- const signer: ethers.Signer = /* your Signer instance */;
45
+ const provider: ethers.providers.JsonRpcProvider = /* your Web3Provider instance */;
40
46
 
41
- const perqSdk = new PerqSdk(perqConfig, signer);
47
+ const perqSdk = new PerqSdk(perqConfig, provider);
42
48
  ```
43
49
 
44
- # Methods
45
-
46
- | Name | Description |
47
- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
48
- | `getAllVaults(): Promise<Vault[]>` | Fetches details of all Perq Vaults. |
49
- | `getVaultDetails(vaultAddress: string): Promise<Vault>` | Fetches details of a specific Perq Vault identified by its address. |
50
- | `getVaultStats(): Promise<VaultStats>` | Returns some overall Perq stats |
51
- | `getTokenPrice(tokenName: string): Promise<number>` | Returns the price for the given token (only works for weth at the moment) |
52
- | `updateSigner(newSigner: Signer): Promise<void>` | Updates the signer for the SDK instance. |
53
- | `deposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>` | 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>` | Returns the expected amount of tokens to get from a swap |
55
- | `getRewardsPerHour(vaultAddress: string): Promise<string[]>` | 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. |
56
- | `getRewards(): Promise<UserRewards>` | Fetches the current user's rewards points for each vault. |
57
- | `getUserVaultBalance(): Promise<UserVaultBalance>` | Fetches the user's balance for a specific Perq Vault. |
58
- | `fastWithdraw(vault: Vault, amountToWithdraw?: string): Promise<string>` | For users who prefer not to wait for withdrawals to be processed, there is a Fast Withdrawal method. While this approach is more gas-intensive, as users bear the cost of executing the withdrawal process themselves, it allows for instant access to the withdrawn tokens. When utilizing Fast Withdrawal, users immediately receive the tokens, eliminating the need to initiate the 'claimWithdrawal' process separately. Returns txHash. |
59
- | `swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>` | 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. |
60
- | `withdraw(vault: Vault, amountToWithdraw?: string): Promise<string>` | 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. |
61
- | `claimWithdraws(vaultAddress: string): Promise<string>` | After the withdrawal has been processed by the 'DoHardWork' function, the 'claimWithdraws' function transfers the withdrawn tokens to their personal account. Returns txHash. |
62
- | `getTokenAllowanceForCurrency(tokenAddress: string): Promise<string>` | Retrieves the token allowance for a specific currency. |
63
- | `getTokenAllowanceForRecycler(tokenAddress: string): Promise<BigNumber>` | Retrieves the token allowance for the recycler contract. |
64
- | `getTokenAllowanceForSwapAndRecycler(tokenAddress: string): Promise<BigNumber>` | Retrieves the token allowance for the swap and recycler contract. |
65
- | `getUserBoostedNfts(vaultAddress: string): Promise<string[]>` | Retrieves an array of boosted NFT addresses owned by the user. |
66
- | `getRewardsPerHour(vaultAddress: string): Promise<number> ` | Returns an estimated amount of tokens the user will receive in one hour as a reward for the given vault |
67
- | `newDeposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>` | Allows for a new deposit without checking for allowance. |
68
- | `newSwapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string> ` | Allows for a new swap and deposit without checking for allowance. |
69
- | `getAllVestingInfo(beneficiaryAddress: string): Promise<VestingInfo>` | Retrieves all vesting information for a specified beneficiary. |
70
- | `getVestingStart(): Promise<string>` | Retrieves the start time of the vesting period. |
71
- | `getVestingEnd(): Promise<string>` | Retrieves the end time of the vesting period. |
72
- | `getBeansHistory(): Promise<BeanEntry[]> ` | Retrieves the user's beans history of tx |
73
- | `getBeansBalance(): Promise<BeansBalance> ` | Retrieves the user's beans balance. |
74
- | `getMyPerqBalance(): Promise<MyPerqData>` | Retrieves the user's Perq balance data. |
75
- | `upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>` | Upgrades the user's loyalty card. |
76
- | `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | Fetches the currently owned loyalty card of the connected wallet. |
77
- | `getAllLoyaltyCards(): Promise<LoyaltyCard[]>` | Fetches all available loyalty cards. |
50
+ # Modules
51
+
52
+ ## Core SDK
53
+
54
+ Core methods available directly on the SDK instance:
78
55
 
79
- ---
56
+ | Method | Description |
57
+ | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
58
+ | `updateSigner(newSigner: Signer): Promise<void>` | Updates the signer for the SDK instance and all its modules. |
59
+
60
+ ## V2 Vaults
61
+
62
+ Access V2 vault methods through `sdk.v2`:
63
+
64
+ | Method | Description |
65
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
66
+ | `getPoolDetails(vaultAddress: string): Promise<VaultData>` | Fetches details of a specific Perq V2 Vault.
67
+ | `newDeposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>` | Deposits without allowance check. |
68
+ | `deposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>` | Deposits with allowance check. |
69
+ | `fastWithdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>` | Fast withdrawal from vault. |
70
+ | `withdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>` | Standard withdrawal from vault. |
71
+ | `swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>` | Swaps and deposits with allowance check. |
72
+ | `newSwapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>` | Swaps and deposits without allowance check. |
73
+ | `getUserPoolBalance(vaultAddress: string): Promise<UserVaultBalance>` | Gets user's balance in a vault. |
74
+ | `claimWithdraws(vaultAddress: string): Promise<string>` | Claims all pending withdrawals for the user. |
75
+ | `getSwapAndDepositTokenAllowanceForCurrency(tokenAddress: string): Promise<string>` | Fetches the token allowance for swap and deposit operations. |
76
+ | `getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number): Promise<string>` | Calculates the expected result of a swap operation. |
77
+ | `approveTokenForSwapAndDeposit(tokenAddress: string, amount: string): Promise<string>` | Approves a token for swap and deposit operations. |
78
+ | `approveTokenForDeposit(tokenAddress: string, amount: string): Promise<string>` | Approves a token for deposit operations. |
79
+ | `getTokenAllowanceForCurrency(tokenAddress: string): Promise<string>` | Fetches the token allowance for a specific currency for deposit operation |
80
+ ## Lite Vaults
81
+
82
+ Access Lite vault methods through `sdk.lite`:
83
+
84
+ | Method | Description |
85
+ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
86
+ | `getAllVaults(): Promise<VaultData[]>` | Fetches all Lite vaults. |
87
+ | `getVaultDetails(vaultAddress: string, onChainProjectId: number): Promise<VaultData>` | Fetches Lite vault details. |
88
+ | `deposit(tokenAddress: string, vaultAddress: string, onChainProjectId: number, amount: string): Promise<string>` | Deposits into Lite vault. |
89
+ | `withdraw(tokenAddress: string, vaultAddress: string, onChainProjectId: number, amount: string): Promise<string>` | Withdraws from Lite vault. |
90
+ | `swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, amount: string, vaultAddress: string, onChainProjectId: number): Promise<string>` | Swaps and deposits into Lite vault. |
91
+ | `wrapAndDepositEth(vaultAddress: string, onChainProjectId: number, amount: string): Promise<string>`| Wraps ETH and deposits. |
92
+ | `getAllProjects(): Promise<ReducedProjectData[]>`| Gets all projects.|
93
+ | `getProjectDetails(projectName: string): Promise<DetailedProjectData>`| Gets project details. |
94
+ | `getSwapAndDepositAllowance(tokenAddress: string): Promise<string>`| Fetches the allowance for swap and deposit operations. |
95
+ | `approveSwapAndDeposit(tokenAddress: string, amount: string): Promise<string>` | Approves a token for swap and deposit operations. |
96
+ | `getExpectedSwapResult(fromTokenAddress: string,toTokenAddress: string,amount: string,decimals: number): Promise<string>`| Calculates the expected result of a swap operation. |
97
+
98
+ ## Loyalty Cards
99
+
100
+ Access loyalty card methods through `sdk.loyaltyCards`:
101
+
102
+ | Method | Description |
103
+ | --------------------------------------------------------- | --------------------------------- |
104
+ | `getBeansBalance(): Promise<BeansBalance>` | Gets user's beans balance. |
105
+ | `getBeansHistory(): Promise<BeanEntry[]>` | Gets user's beans history. |
106
+ | `getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>` | Gets swap info for Perq to beans. |
107
+ | `upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>` | Upgrades loyalty card. |
108
+ | `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | Gets user's owned loyalty card. |
109
+ | `getAllLoyaltyCards(): Promise<LoyaltyCard[]>` | Gets all available loyalty cards. |
110
+
111
+ ## Vesting
112
+
113
+ Access vesting methods through `sdk.vesting`:
114
+
115
+ | Method | Description |
116
+ | ----------------------------------------------------------------------------------------------------- | ----------------------------- |
117
+ | `getVestingStart(): Promise<string>` | Gets vesting start time. |
118
+ | `getVestingEnd(): Promise<string>` | Gets vesting end time. |
119
+ | `getVestedAmount(beneficiary: string): Promise<string>` | Gets vested amount. |
120
+ | `getReleasableAmount(beneficiary: string): Promise<string>` | Gets releasable amount. |
121
+ | `getReleasableTotalAmount(beneficiary: string): Promise<string>` | Gets total releasable amount. |
122
+ | `getAllVestingInfo(beneficiaryAddress: string): Promise<VestingInfo>` | Gets all vesting info. |
123
+ | `claimVestedPerq(amount: string): Promise<string>` | Claims vested Perq. |
124
+ | `burnVestedPerq(amount: string, price: string, deadline: string, signature: string): Promise<string>` | Burns vested Perq. |
125
+
126
+
127
+ ## Pools
128
+
129
+ Access pools methods through `sdk.pools`:
130
+
131
+ | Method | Description |
132
+ | -------------------------------------------------------------------- | -------------------------------------- |
133
+ | `getUserPoolBalance(vaultAddress: string, onChainProjectId: number): Promise<UserVaultBalance>` | Fetches the user's balance in a specific pool. |
134
+ | `getAllPools(): Promise<VaultData[]>` | Fetches all available pools. |
135
+ | `getMyPerqBalance(): Promise<MyPerqData[]>` | Fetches the user's Perq balance. |
136
+ | `getPoolDetails(vaultAddress: string, onChainProjectId: number): Promise<VaultData>` | Fetches the details of a specific pool. |
137
+ | `getAllProjects(): Promise<ReducedProjectData[]>` | Fetches all available projects. |
138
+ | `getProjectDetails(projectName: string): Promise<DetailedProjectData>` | Fetches the details of a specific project. |
139
+ | `getPoolStats(): Promise<VaultStats>` | Fetches the statistics of a pool. |
140
+ | `getRewardsPerHour(vaultAddress: string): Promise<number>` | Calculates the rewards per hour for a specific pool. |
141
+ | `getUserBoostedNfts(vaultAddress: string): Promise<string[]>` | Fetches the user's boosted NFTs for a specific pool. |
142
+ | `getRewards(): Promise<UserRewards>` | Fetches the user's rewards. |
143
+
144
+
145
+ ## User
146
+
147
+ Access user methods through `sdk.user`:
148
+
149
+
150
+ | Method | Description |
151
+ | -------------------------------------------------------------------- | -------------------------------------- |
152
+ | `linkSuiWalletWithEthWallet(suiWalletAddress: string): Promise<boolean>` | Links a Sui wallet with an Ethereum wallet. |
153
+ | `getLinkedSuiWallet(): Promise<string>` | Retrieves the Sui wallet address linked to the user's Ethereum wallet. |
154
+
155
+
156
+ ## Recycler
157
+
158
+ Access recycler methods through `sdk.recycler`:
159
+
160
+
161
+ | Method | Description |
162
+ | -------------------------------------------------------------------- | -------------------------------------- |
163
+ | `getTokenAllowanceForRecycler(tokenAddress: string): Promise<BigNumber>` | Retrieves the token allowance for the recycler contract. |
164
+ | `getTokenAllowanceForSwapAndRecycler(tokenAddress: string): Promise<BigNumber>` | Retrieves the token allowance for the swap and recycler contract. |
165
+ | `async recycleTokens(tokenAddress: string = this.perqSdk.perqConfig.perqTokenAddress,amountToRecycle: string,beneficiary: string = ethers.constants.AddressZero,price: string,deadline: string,signature: string): Promise<string>` | Initiates the recycling of tokens for a given beneficiary, price, and deadline. |
166
+ | `swapAndRecycleETH(beneficiary: string,path: string[],minAmountOutWithDecimals: string,amountOfEth: string,price: string,deadline: string,signature: string): Promise<string>` | Executes a swap and recycling operation for ETH. |
167
+ | `swapAndRecycleERC20(beneficiary: string,path: string[],minAmountOutWithDecimals: string,amountInWithDecimals: string,price: string, deadline: string,signature: string): Promise<string>` | Executes a swap and recycling operation for ERC20 tokens. |
168
+ | `approveTokenForRecycler(tokenAddress: string, amount: string): Promise<string>` | Approves a token for use with the recycler contract. |
169
+ | `approveTokenForSwapAndRecycler(tokenAddress: string, amount: string): Promise<string>` | Approves a token for use with the swap and recycler contract. |
170
+
171
+ ## Token Utils
172
+
173
+ Access token utils methods through `sdk.tokenUtils`:
174
+ | Method | Description |
175
+ | -------------------------------------------------------------------- | -------------------------------------- |
176
+ | `getTokenPrice(tokenName: string): Promise<number>` | Fetches the current price of a given token."perq", "weth" "eth" and "wbtc" are supported |
177
+ | `getAllowance(tokenAddress: string, spender: string): Promise<string>` | Retrieves the current allowance for a token. |
178
+ | `approveAllowance(tokenAddress: string, amount: string, spenderAddress: string): Promise<string>` | Approves a specific amount of tokens for use by a spender. |
179
+ | `transferErc20Token(tokenAddress: string, amount: string, receiver: string): Promise<string>` | Transfers a specified amount of ERC20 tokens to a receiver. |
180
+ | `wrapEther(amount: string, tokenAddress: string): Promise<string>` | Wraps a specified amount of Ether into a WETH token. |
181
+ | `getERC20TokenAllowance(spender: string, tokenAddress: string): Promise<BigNumber>` | Retrieves the allowance for a specific ERC20 token. |
182
+ | `getPerqTokenContractAddress(): string` | Returns the contract address of the Perq token. |
183
+
184
+
185
+
186
+
187
+
188
+ ## Sign Handler
189
+
190
+ Access signing methods through `sdk.signHandler`:
191
+
192
+ | Method | Description |
193
+ | -------------------------------------------------------------------- | -------------------------------------- |
194
+ | `signPayload<T>(payload: T): Promise<NonceEnrichedSignedPayload<T>>` | Signs a payload with nonce enrichment. |
80
195
 
81
196
  # Examples
82
197
 
@@ -225,11 +340,6 @@ type BeansBalance = {
225
340
  bonusesClaimed: string[];
226
341
  };
227
342
 
228
- enum Chain {
229
- MAINNET = 'mainnet',
230
- SEPOLIA = 'sepolia',
231
- }
232
-
233
343
  type DeployedProject = {
234
344
  id: number | undefined;
235
345
  projectName: string;
@@ -348,12 +458,15 @@ type NonceEnrichedSignedPayload<T> = {
348
458
  type PerqConfig = {
349
459
  route: string;
350
460
  spoolSdkConfig: SDKConfig;
461
+ yelayLiteSdkConfig: sdkConfig,
351
462
  perqTokenAddress: string;
352
463
  perqTokenRecyclerAddress: string;
353
464
  perqSwapAndRecyclerAddress: string;
354
465
  perqVestingAddress: string;
355
466
  swapAndDepositContractAddress: string;
356
467
  smartVaultManagerContractAddress: string;
468
+ ethereumSwapperAddress: string,
469
+ baseSwapperAddress: string,
357
470
  };
358
471
 
359
472
  type PerqToBeansSwapInfo = {
@@ -423,6 +536,33 @@ type UserVaultBalance = {
423
536
  claimableBalance: string;
424
537
  };
425
538
 
539
+ type VaultData = {
540
+ depositToken: DepositToken;
541
+ vaultAddress: string;
542
+ projectName: string;
543
+ projectLogo: string;
544
+ projectType: string;
545
+ liveFrom: string;
546
+ liveUntil: string;
547
+ tvlUsd: number;
548
+ avgTvl: number;
549
+ tokenPrice: number;
550
+ change24h: number;
551
+ volume24h: number;
552
+ peakTvl: number;
553
+ onChainProjectId: number;
554
+ combinedTvl: number;
555
+ isActive: boolean;
556
+ owners: string[];
557
+ coingeckoId?: string;
558
+ expectedTge?: string;
559
+ chainId: ChainId;
560
+ poolType: VaultType;
561
+ strategies: Strategy[];
562
+ rewards: VaultReward[];
563
+ stretchGoals: StretchGoal[];
564
+ };
565
+
426
566
  type Vault = {
427
567
  vaultName: string;
428
568
  vaultAddress: string;
@@ -488,6 +628,42 @@ type VestingInfo = {
488
628
  };
489
629
 
490
630
  type YelayVersion = 'v2' | 'lite';
631
+
632
+ // Additional Types:
633
+
634
+ type DetailedProjectData = {
635
+ // Project details
636
+ id: number;
637
+ projectName: string;
638
+ description: string;
639
+ // ... other project details
640
+ };
641
+
642
+ type ReducedProjectData = {
643
+ id: number;
644
+ projectName: string;
645
+ // ... reduced project information
646
+ };
647
+
648
+ type RewardType = 'token' | 'points';
649
+
650
+ type SDKConfig = {
651
+ chainId: number;
652
+ rpcUrl: string;
653
+ // ... other SDK configuration
654
+ };
655
+
656
+ const BASE_CHAIN_ID = 8453;
657
+ const ETHEREUM_CHAIN_ID = 1;
658
+ const ETHEREUM_SEPOLIA_CHAIN_ID = 11155111;
659
+ const ARBITRUM_CHAIN_ID = 42161;
660
+
661
+ type ChainId =
662
+ | typeof BASE_CHAIN_ID
663
+ | typeof ETHEREUM_CHAIN_ID
664
+ | typeof ETHEREUM_SEPOLIA_CHAIN_ID
665
+ | typeof ARBITRUM_CHAIN_ID;
666
+
491
667
  ```
492
668
 
493
669
  # Abis
package/dist/PerqApi.d.ts CHANGED
@@ -1,21 +1,22 @@
1
1
  import { BigNumber } from 'ethers';
2
2
  import { SwapInfo, UserRewards, VaultStats, MyPerqData, LoyaltyCard, BeansBalance, PerqToBeansSwapInfo, BeanEntry, NonceEnrichedSignedPayload, NonceEnrichedPayload, UpgradeLoyaltyCardPayload, ReducedProjectData, DetailedProjectData, LinkWalletPayload, UserVaultBalance } from './types';
3
3
  import CachedVaultData from './types/VaultData';
4
+ import PerqSdk from './PerqSdk';
4
5
  export default class PerqApi {
5
- route: string;
6
- constructor(route: string);
7
- fetchAllVaults(): Promise<CachedVaultData[]>;
8
- fetchVaultV2Details(vaultAddress: string): Promise<CachedVaultData>;
9
- fetchVaultLiteDetails(vaultAddress: string, onChainProjectId: number): Promise<CachedVaultData>;
6
+ private perqSdk;
7
+ constructor(perqSdk: PerqSdk);
8
+ fetchAllPools(): Promise<CachedVaultData[]>;
9
+ fetchPoolV2Details(vaultAddress: string): Promise<CachedVaultData>;
10
+ fetchPoolLiteDetails(vaultAddress: string, onChainProjectId: number): Promise<CachedVaultData>;
10
11
  fetchAllProjects(): Promise<ReducedProjectData[]>;
11
12
  fetchProjetctDetails(projectName: string): Promise<DetailedProjectData>;
12
13
  fetchTokenPrice(tokenName: string): Promise<number>;
13
14
  getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number, chainId: string): Promise<string>;
14
15
  getUserBoostedNfts(walletAddress: string, vaultAddress: string): Promise<string[]>;
15
- fetchVaultStats(): Promise<VaultStats>;
16
+ fetchPoolStats(): Promise<VaultStats>;
16
17
  fetchRewardsPerHour(walletAddress: string, vaultAddress: string): Promise<number>;
17
18
  getSwapInfo(fromTokenAddress: string, toTokenAddress: string, amount: BigNumber, fromAddress: string, chainId: number): Promise<SwapInfo[]>;
18
- fetchEnrichedUserWNFTForVault(vaultAddress: string, walletAddress: string): Promise<any[]>;
19
+ fetchEnrichedUserWNFTForPool(vaultAddress: string, walletAddress: string): Promise<any[]>;
19
20
  fetchAssetPerSvtAtBlock(vaultAddress: string, blocknumber: number): Promise<BigNumber>;
20
21
  fetchUserRewards(walletAddress: string): Promise<UserRewards>;
21
22
  fetchAllLoyaltyCards(): Promise<LoyaltyCard[]>;
@@ -28,6 +29,6 @@ export default class PerqApi {
28
29
  linkSuiWalletWithEthWallet(signedPayload: NonceEnrichedSignedPayload<LinkWalletPayload>): Promise<boolean>;
29
30
  getLinkedSuiWallet(walletAddress: string): Promise<string>;
30
31
  getNonceEnrichedPayload<T>(payload: T): Promise<NonceEnrichedPayload<T>>;
31
- fetchV2VaultUserBalance(userAddress: string, vaultAddress: string): Promise<UserVaultBalance>;
32
- fetchLiteVaultUserBalance(userAddress: string, vaultAddress: string, onChainProjectId: number): Promise<UserVaultBalance>;
32
+ fetchV2PoolUserBalance(userAddress: string, vaultAddress: string): Promise<UserVaultBalance>;
33
+ fetchLitePoolUserBalance(userAddress: string, vaultAddress: string, onChainProjectId: number): Promise<UserVaultBalance>;
33
34
  }
package/dist/PerqApi.js CHANGED
@@ -4,12 +4,12 @@ const ethers_1 = require("ethers");
4
4
  const PERQ_TOKEN_DECIMALS = 18;
5
5
  const WETH_TOKEN_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
6
6
  class PerqApi {
7
- route;
8
- constructor(route) {
9
- this.route = route;
7
+ perqSdk;
8
+ constructor(perqSdk) {
9
+ this.perqSdk = perqSdk;
10
10
  }
11
- async fetchAllVaults() {
12
- const res = await fetch(`${this.route}/api-be/api/vault`);
11
+ async fetchAllPools() {
12
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/vault`);
13
13
  if (res.ok) {
14
14
  const data = (await res.json());
15
15
  return data;
@@ -18,8 +18,8 @@ class PerqApi {
18
18
  throw Error(`${await res.text()}`);
19
19
  }
20
20
  }
21
- async fetchVaultV2Details(vaultAddress) {
22
- const res = await fetch(`${this.route}/api-be/api/vault/${vaultAddress}`);
21
+ async fetchPoolV2Details(vaultAddress) {
22
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/vault/${vaultAddress}`);
23
23
  if (res.ok) {
24
24
  const data = (await res.json());
25
25
  return data;
@@ -28,8 +28,8 @@ class PerqApi {
28
28
  throw Error(`${await res.text()}`);
29
29
  }
30
30
  }
31
- async fetchVaultLiteDetails(vaultAddress, onChainProjectId) {
32
- const res = await fetch(`${this.route}/api-be/api/vault/${vaultAddress}?onChainProjectId=${onChainProjectId}`);
31
+ async fetchPoolLiteDetails(vaultAddress, onChainProjectId) {
32
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/vault/${vaultAddress}?onChainProjectId=${onChainProjectId}`);
33
33
  if (res.ok) {
34
34
  const data = (await res.json());
35
35
  return data;
@@ -39,7 +39,7 @@ class PerqApi {
39
39
  }
40
40
  }
41
41
  async fetchAllProjects() {
42
- const res = await fetch(`${this.route}/api-be/api/projects`);
42
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/projects`);
43
43
  if (res.ok) {
44
44
  const data = await res.json();
45
45
  return data;
@@ -49,7 +49,7 @@ class PerqApi {
49
49
  }
50
50
  }
51
51
  async fetchProjetctDetails(projectName) {
52
- const res = await fetch(`${this.route}/api-be/api/projects/${projectName}`);
52
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/projects/${projectName}`);
53
53
  if (res.ok) {
54
54
  const data = await res.json();
55
55
  return data;
@@ -59,7 +59,7 @@ class PerqApi {
59
59
  }
60
60
  }
61
61
  async fetchTokenPrice(tokenName) {
62
- const res = await fetch(`${this.route}/api-be/api/tokenPrice?tokenName=${tokenName}`);
62
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/tokenPrice?tokenName=${tokenName}`);
63
63
  if (res.ok) {
64
64
  const data = await res.json();
65
65
  return data.usdPricePerToken;
@@ -76,7 +76,7 @@ class PerqApi {
76
76
  amount: parsedAmount.toString(),
77
77
  chainId: chainId,
78
78
  });
79
- const res = await fetch(`${this.route}/api-be/api/1inch/swap?${queryParams}`);
79
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/1inch/swap?${queryParams}`);
80
80
  if (res.ok) {
81
81
  const data = await res.json();
82
82
  return data;
@@ -86,7 +86,7 @@ class PerqApi {
86
86
  }
87
87
  }
88
88
  async getUserBoostedNfts(walletAddress, vaultAddress) {
89
- const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/nftBoost/${vaultAddress}`);
89
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/nftBoost/${vaultAddress}`);
90
90
  if (res.ok) {
91
91
  const data = await res.json();
92
92
  return data;
@@ -95,8 +95,8 @@ class PerqApi {
95
95
  throw Error(`${await res.text()}`);
96
96
  }
97
97
  }
98
- async fetchVaultStats() {
99
- const res = await fetch(`${this.route}/api-be/api/vaultStats`);
98
+ async fetchPoolStats() {
99
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/vaultStats`);
100
100
  if (res.ok) {
101
101
  const data = await res.json();
102
102
  return data;
@@ -106,7 +106,7 @@ class PerqApi {
106
106
  }
107
107
  }
108
108
  async fetchRewardsPerHour(walletAddress, vaultAddress) {
109
- const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/rewardsPerHour/${vaultAddress}`);
109
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/rewardsPerHour/${vaultAddress}`);
110
110
  if (res.ok) {
111
111
  const data = await res.json();
112
112
  return data.rewardsPerHour;
@@ -119,7 +119,7 @@ class PerqApi {
119
119
  if (fromTokenAddress === toTokenAddress && fromTokenAddress === WETH_TOKEN_ADDRESS) {
120
120
  return [];
121
121
  }
122
- const url = `${this.route}/oneinch?getRequest=/swap/v6.0/${chainId}/swap?fromTokenAddress=${fromTokenAddress}%26toTokenAddress=${toTokenAddress}%26amount=${amount.toString()}%26fromAddress=${fromAddress}%26slippage=0.1%26disableEstimate=true%26allowPartialFill=false%26includeTokensInfo=true`;
122
+ const url = `${this.perqSdk.perqConfig.route}/oneinch?getRequest=/swap/v6.0/${chainId}/swap?fromTokenAddress=${fromTokenAddress}%26toTokenAddress=${toTokenAddress}%26amount=${amount.toString()}%26fromAddress=${fromAddress}%26slippage=0.1%26disableEstimate=true%26allowPartialFill=false%26includeTokensInfo=true`;
123
123
  const res = await fetch(url);
124
124
  if (res.ok) {
125
125
  const data = (await res.json());
@@ -135,8 +135,8 @@ class PerqApi {
135
135
  throw Error(`${await res.text()}`);
136
136
  }
137
137
  }
138
- async fetchEnrichedUserWNFTForVault(vaultAddress, walletAddress) {
139
- const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/wNft/${vaultAddress}`);
138
+ async fetchEnrichedUserWNFTForPool(vaultAddress, walletAddress) {
139
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/spool/user/${walletAddress}/wNft/${vaultAddress}`);
140
140
  if (res.ok) {
141
141
  const data = await res.json();
142
142
  return data;
@@ -146,7 +146,7 @@ class PerqApi {
146
146
  }
147
147
  }
148
148
  async fetchAssetPerSvtAtBlock(vaultAddress, blocknumber) {
149
- const res = await fetch(`${this.route}/api-be/api/spool/assetBalance/${blocknumber}/${vaultAddress}`);
149
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/spool/assetBalance/${blocknumber}/${vaultAddress}`);
150
150
  if (res.ok) {
151
151
  const data = (await res.json());
152
152
  return data;
@@ -156,7 +156,7 @@ class PerqApi {
156
156
  }
157
157
  }
158
158
  async fetchUserRewards(walletAddress) {
159
- const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/rewards`);
159
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/rewards`);
160
160
  if (res.ok) {
161
161
  const data = await res.json();
162
162
  return data;
@@ -166,7 +166,7 @@ class PerqApi {
166
166
  }
167
167
  }
168
168
  async fetchAllLoyaltyCards() {
169
- const res = await fetch(`${this.route}/api-be/api/loyaltyCards/all`);
169
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/loyaltyCards/all`);
170
170
  if (res.ok) {
171
171
  const data = await res.json();
172
172
  return data.map((card) => ({
@@ -182,7 +182,7 @@ class PerqApi {
182
182
  }
183
183
  }
184
184
  async fetchOwnedLoyaltyCard(walletAddress) {
185
- const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/loyaltyCards/owned`);
185
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/loyaltyCards/owned`);
186
186
  if (res.status === 204) {
187
187
  return {};
188
188
  }
@@ -201,7 +201,7 @@ class PerqApi {
201
201
  }
202
202
  }
203
203
  async fetchBeansBalance(walletAddress) {
204
- const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/beans/balance`);
204
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/beans/balance`);
205
205
  if (res.ok) {
206
206
  const data = await res.json();
207
207
  const beansBalance = {
@@ -216,7 +216,7 @@ class PerqApi {
216
216
  }
217
217
  async upgradeLoyaltyCard(signedPayload) {
218
218
  const { signerAddress } = signedPayload;
219
- const res = await fetch(`${this.route}/api-be/api/user/${signerAddress}/loyaltyCards/upgrade`, {
219
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${signerAddress}/loyaltyCards/upgrade`, {
220
220
  method: 'POST',
221
221
  headers: {
222
222
  'Content-Type': 'application/json',
@@ -238,7 +238,7 @@ class PerqApi {
238
238
  }
239
239
  }
240
240
  async fetchMyPerqData(userAddress) {
241
- const res = await fetch(`${this.route}/api-be/api/user/${userAddress}/myperq`);
241
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${userAddress}/myperq`);
242
242
  if (res.ok) {
243
243
  const data = await res.json();
244
244
  return data;
@@ -248,7 +248,7 @@ class PerqApi {
248
248
  }
249
249
  }
250
250
  async getSwapPerqForBeansInfo() {
251
- const res = await fetch(`${this.route}/api-be/api/swap/price`, {});
251
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/swap/price`, {});
252
252
  if (res.ok) {
253
253
  const data = await res.json();
254
254
  return data;
@@ -258,7 +258,7 @@ class PerqApi {
258
258
  }
259
259
  }
260
260
  async fetchBeansHistory(walletAddress) {
261
- const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/beans/history`);
261
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/beans/history`);
262
262
  if (res.ok) {
263
263
  const data = await res.json();
264
264
  const result = data.map((element) => {
@@ -282,7 +282,7 @@ class PerqApi {
282
282
  }
283
283
  }
284
284
  async linkSuiWalletWithEthWallet(signedPayload) {
285
- const res = await fetch(`${this.route}/api-be/api/user/suiWallet`, {
285
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/suiWallet`, {
286
286
  method: 'POST',
287
287
  headers: {
288
288
  'Content-Type': 'application/json',
@@ -297,7 +297,7 @@ class PerqApi {
297
297
  }
298
298
  }
299
299
  async getLinkedSuiWallet(walletAddress) {
300
- const res = await fetch(`${this.route}/api-be/api/user/suiWallet/${walletAddress}`);
300
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/suiWallet/${walletAddress}`);
301
301
  if (res.ok) {
302
302
  const data = await res.json();
303
303
  return data.suiWalletAddr;
@@ -307,7 +307,7 @@ class PerqApi {
307
307
  }
308
308
  }
309
309
  async getNonceEnrichedPayload(payload) {
310
- const res = await fetch(`${this.route}/api-be/api/nonce`, {
310
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/nonce`, {
311
311
  method: 'POST',
312
312
  headers: {
313
313
  'Content-Type': 'application/json',
@@ -321,8 +321,8 @@ class PerqApi {
321
321
  // Return the enriched payload without the extra nesting
322
322
  return enrichedPayload.payload;
323
323
  }
324
- async fetchV2VaultUserBalance(userAddress, vaultAddress) {
325
- const res = await fetch(`${this.route}/api-be/api/user/v2/balance/${userAddress}/${vaultAddress}`);
324
+ async fetchV2PoolUserBalance(userAddress, vaultAddress) {
325
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/v2/balance/${userAddress}/${vaultAddress}`);
326
326
  if (res.ok) {
327
327
  return await res.json();
328
328
  }
@@ -330,8 +330,8 @@ class PerqApi {
330
330
  throw Error(`${await res.text()}`);
331
331
  }
332
332
  }
333
- async fetchLiteVaultUserBalance(userAddress, vaultAddress, onChainProjectId) {
334
- const res = await fetch(`${this.route}/api-be/api/user/lite/balance/${userAddress}/${vaultAddress}/${onChainProjectId}`);
333
+ async fetchLitePoolUserBalance(userAddress, vaultAddress, onChainProjectId) {
334
+ const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/lite/balance/${userAddress}/${vaultAddress}/${onChainProjectId}`);
335
335
  if (res.ok) {
336
336
  const data = await res.json();
337
337
  return {