@dripfi/drip-sdk 1.3.3 → 1.3.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.
package/dist/DripApi.d.ts CHANGED
@@ -42,4 +42,8 @@ export default class DripApi {
42
42
  getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
43
43
  fetchBeansHistory(walletAddress: string): Promise<BeanEntry[]>;
44
44
  getNonceEnrichedPayload<T>(payload: T): Promise<NonceEnrichedPayload<T>>;
45
+ fetchUserVaultDeposits(userAddress: string, vaultAddress: string): Promise<{
46
+ pending: number;
47
+ deposited: number;
48
+ }>;
45
49
  }
package/dist/DripApi.js CHANGED
@@ -395,5 +395,12 @@ class DripApi {
395
395
  return enrichedPayload.payload;
396
396
  });
397
397
  }
398
+ fetchUserVaultDeposits(userAddress, vaultAddress) {
399
+ return __awaiter(this, void 0, void 0, function* () {
400
+ const response = yield fetch(`${this.route}/api-be/api/user/${userAddress}/deposits/${vaultAddress}`);
401
+ const data = yield response.json();
402
+ return data;
403
+ });
404
+ }
398
405
  }
399
406
  exports.default = DripApi;
package/dist/DripSdk.js CHANGED
@@ -171,29 +171,13 @@ class DripSdk {
171
171
  throw Error('No signer provided');
172
172
  }
173
173
  const userAddress = yield this.signer.getAddress();
174
- // Parallel fetch of vault, user dnfts and user wnfts
175
- const [vault, userDnftsForVault, userWnftsForVault] = yield Promise.all([
174
+ // Parallel fetch of vault, deposits and wnfts
175
+ const [vault, userVaultBalance, userWnftsForVault] = yield Promise.all([
176
176
  this.getVaultDetails(vaultAddress),
177
- this.dripApi.fetchAllUserDNFTForVault(vaultAddress, userAddress),
177
+ this.dripApi.fetchUserVaultDeposits(userAddress, vaultAddress),
178
178
  this.dripApi.fetchAllUserWNFTForVault(vaultAddress, userAddress),
179
179
  ]);
180
180
  const decimals = yield this.getERC20Precission(vault.depositToken.tokenAddress);
181
- // Calculate deposits
182
- let pendingDeposits = ethers_1.BigNumber.from(0);
183
- let currentlyDeposited = ethers_1.BigNumber.from(0);
184
- for (const dnft of userDnftsForVault) {
185
- if (dnft.assets && dnft.assets[0]) {
186
- const amount = ethers_1.ethers.utils.parseUnits(dnft.assets[0].toString(), decimals);
187
- if (!dnft.isDHWFinished) {
188
- // Pending deposits (not yet processed)
189
- pendingDeposits = pendingDeposits.add(amount);
190
- }
191
- else {
192
- // Processed deposits
193
- currentlyDeposited = currentlyDeposited.add(amount);
194
- }
195
- }
196
- }
197
181
  // Calculate withdrawals
198
182
  let pendingWithdraws = ethers_1.BigNumber.from(0);
199
183
  let claimable = ethers_1.BigNumber.from(0);
@@ -214,8 +198,8 @@ class DripSdk {
214
198
  }
215
199
  return {
216
200
  hasWithdrawsToClaim: claimable.gt(0),
217
- userBalance: ethers_1.ethers.utils.formatUnits(currentlyDeposited, decimals),
218
- pendingUserBalance: ethers_1.ethers.utils.formatUnits(pendingDeposits, decimals),
201
+ userBalance: userVaultBalance.deposited.toString(),
202
+ pendingUserBalance: userVaultBalance.pending.toString(),
219
203
  pendingWithdrawalBalance: ethers_1.ethers.utils.formatUnits(pendingWithdraws, decimals),
220
204
  withdrawableBalance: ethers_1.ethers.utils.formatUnits(claimable, decimals),
221
205
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dripfi/drip-sdk",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Drip SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",