@dripfi/drip-sdk 1.3.6 → 1.3.7

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/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+ All notable changes to the Drip SDK will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [1.3.7] - 2025-01-15
8
+ ### Added
9
+ - Changelog was added
10
+
11
+ ### Changed
12
+ - renamed the property `withdrawableBalance` to `claimableBalance` in the type `UserVaultBalance`
package/README.md CHANGED
@@ -321,7 +321,7 @@ type UserVaultBalance = {
321
321
  userBalance: string
322
322
  pendingUserBalance: string
323
323
  pendingWithdrawalBalance: string
324
- withdrawableBalance: string
324
+ claimableBalance: string
325
325
  };
326
326
 
327
327
 
package/dist/DripSdk.d.ts CHANGED
@@ -76,11 +76,6 @@ export default class DripSdk {
76
76
  private getEnrichedPayload;
77
77
  private generateRedeemBagStruct;
78
78
  private getERC20Precission;
79
- private calculatePendingDeposits;
80
- private calculateAllDeposits;
81
- private calculateBalanceForDNFT;
82
- private checkIfUserHasWithdrawsToClaim;
83
- private calculateAllWithdrawalBalances;
84
79
  private getTokenAllowanceForDeposit;
85
80
  private getTokenAllowanceForSwapAndDeposit;
86
81
  private getERC20TokenAllowance;
package/dist/DripSdk.js CHANGED
@@ -167,6 +167,7 @@ class DripSdk {
167
167
  }
168
168
  getUserVaultBalance(vaultAddress) {
169
169
  return __awaiter(this, void 0, void 0, function* () {
170
+ var _a, _b;
170
171
  if (!this.signer) {
171
172
  throw Error('No signer provided');
172
173
  }
@@ -198,10 +199,10 @@ class DripSdk {
198
199
  }
199
200
  return {
200
201
  hasWithdrawsToClaim: claimable.gt(0),
201
- userBalance: userVaultBalance.deposited.toString(),
202
- pendingUserBalance: userVaultBalance.pending.toString(),
203
- pendingWithdrawalBalance: ethers_1.ethers.utils.formatUnits(pendingWithdraws, decimals),
204
- withdrawableBalance: ethers_1.ethers.utils.formatUnits(claimable, decimals),
202
+ userBalance: ((_a = userVaultBalance.deposited) === null || _a === void 0 ? void 0 : _a.toString()) || '0',
203
+ pendingUserBalance: ((_b = userVaultBalance.pending) === null || _b === void 0 ? void 0 : _b.toString()) || '0',
204
+ pendingWithdrawalBalance: ethers_1.ethers.utils.formatUnits(pendingWithdraws, decimals) || '0',
205
+ claimableBalance: ethers_1.ethers.utils.formatUnits(claimable, decimals) || '0',
205
206
  };
206
207
  });
207
208
  }
@@ -635,72 +636,6 @@ class DripSdk {
635
636
  return decimals;
636
637
  });
637
638
  }
638
- calculatePendingDeposits(dnfts, decimals) {
639
- let pendingDeposits = ethers_1.BigNumber.from(0);
640
- for (const nft of dnfts) {
641
- if (nft['assets'] && nft['assets'][0] && !nft.isDHWFinished) {
642
- pendingDeposits = pendingDeposits.add(ethers_1.ethers.utils.parseUnits(nft['assets'][0].toString(), decimals));
643
- }
644
- }
645
- return pendingDeposits;
646
- }
647
- calculateAllDeposits(dnfts, decimals) {
648
- let deposits = ethers_1.BigNumber.from(0);
649
- for (const nft of dnfts) {
650
- deposits = deposits.add(this.calculateBalanceForDNFT(nft, decimals));
651
- }
652
- return deposits;
653
- }
654
- calculateBalanceForDNFT(dnft, decimals) {
655
- const assets = ethers_1.BigNumber.from(ethers_1.ethers.utils.parseUnits(dnft.assets[0].toString(), decimals));
656
- const shares = ethers_1.BigNumber.from(dnft.shares);
657
- if (shares.eq(0)) {
658
- return ethers_1.BigNumber.from(0);
659
- }
660
- return assets.mul(shares).div(1000000);
661
- }
662
- checkIfUserHasWithdrawsToClaim(withdrawNFTS) {
663
- const nftIds = withdrawNFTS
664
- //! Shares come as Strings instead of BigNumber from our Backend
665
- .filter((item) => !item.isBurned && ethers_1.BigNumber.from(item.shares).gt(ethers_1.BigNumber.from('0')) && item.isDHWFinished)
666
- .map((item) => item.nftId.toString());
667
- const nftAmounts = withdrawNFTS
668
- .filter((item) => !item.isBurned && ethers_1.BigNumber.from(item.shares).gt(ethers_1.BigNumber.from('0')) && item.isDHWFinished)
669
- .map((item) => item.shares.toString());
670
- return nftIds.length !== 0 || nftAmounts.length !== 0;
671
- }
672
- calculateAllWithdrawalBalances(wnfts, vaultAddress, decimals) {
673
- return __awaiter(this, void 0, void 0, function* () {
674
- if (!this.signer) {
675
- throw Error('No signer provided');
676
- }
677
- let estimatedPendingWithdrawalBalance = ethers_1.BigNumber.from(0);
678
- let estimatedWithdrawableBalance = ethers_1.BigNumber.from(0);
679
- let withdrawals = 0;
680
- for (const wnft of wnfts) {
681
- // Handle burned NFTs (already withdrawn by the user)
682
- if (wnft.assets && wnft.assets[0] && wnft.isBurned) {
683
- withdrawals += wnft.assets[0].amount;
684
- continue;
685
- }
686
- const currentBlockNumber = wnft.blockNumber - 1;
687
- const assetsPerSvtAtBlock = yield this.dripApi.fetchAssetPerSvtAtBlock(vaultAddress.toLowerCase(), currentBlockNumber);
688
- const estimatedValueOfNFT = ethers_1.BigNumber.from(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(wnft.svtWithdrawn).mul(assetsPerSvtAtBlock), 36).split('.')[0].toString());
689
- if (wnft.isDHWFinished) {
690
- // Processed and Withdrawable
691
- estimatedWithdrawableBalance = estimatedWithdrawableBalance.add(estimatedValueOfNFT);
692
- }
693
- else {
694
- // Not processed, no DHW was ran => pending
695
- estimatedPendingWithdrawalBalance = estimatedPendingWithdrawalBalance.add(estimatedValueOfNFT);
696
- }
697
- }
698
- // return all values as BigNumber
699
- withdrawals = +withdrawals.toFixed(decimals);
700
- const estimatedWithdrawals = ethers_1.ethers.utils.parseUnits(withdrawals.toString(), decimals);
701
- return [estimatedPendingWithdrawalBalance, estimatedWithdrawableBalance, estimatedWithdrawals];
702
- });
703
- }
704
639
  getTokenAllowanceForDeposit(tokenAddress) {
705
640
  return __awaiter(this, void 0, void 0, function* () {
706
641
  if (!this.signer) {
@@ -3,5 +3,5 @@ export type UserVaultBalance = {
3
3
  userBalance: string;
4
4
  pendingUserBalance: string;
5
5
  pendingWithdrawalBalance: string;
6
- withdrawableBalance: string;
6
+ claimableBalance: string;
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dripfi/drip-sdk",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Drip SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",