@dripfi/drip-sdk 1.3.5 → 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 +12 -0
- package/README.md +1 -1
- package/dist/DripSdk.d.ts +0 -5
- package/dist/DripSdk.js +5 -70
- package/dist/types/UserVaultBalance.d.ts +1 -1
- package/package.json +2 -2
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
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
|
-
|
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) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dripfi/drip-sdk",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.7",
|
4
4
|
"description": "Drip SDK",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"test": "echo \"Error: no test specified\" && exit 1"
|
12
12
|
},
|
13
13
|
"dependencies": {
|
14
|
-
"@spool.fi/spool-v2-sdk": "2.0.
|
14
|
+
"@spool.fi/spool-v2-sdk": "2.0.44",
|
15
15
|
"ethers": "^5.7.2"
|
16
16
|
},
|
17
17
|
"author": "",
|