@dripfi/drip-sdk 1.4.3 → 1.4.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/CHANGELOG.md +6 -0
- package/dist/PerqSdk.js +28 -27
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -78,3 +78,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
78
78
|
### Fixed
|
79
79
|
|
80
80
|
- Instantiation of the `SpoolSDK`
|
81
|
+
|
82
|
+
## [1.4.3] - 2025-02-02
|
83
|
+
|
84
|
+
### Fixed
|
85
|
+
|
86
|
+
- Calculation of users vault balance in vaults with extracted strategies by using the `getUserBalanceBreakdown` method in the `SpoolSDK`
|
package/dist/PerqSdk.js
CHANGED
@@ -130,37 +130,38 @@ class PerqSdk {
|
|
130
130
|
if (!this.signer) {
|
131
131
|
throw Error('No signer provided');
|
132
132
|
}
|
133
|
-
const userAddress = await this.signer.getAddress();
|
134
|
-
|
135
|
-
|
136
|
-
this.
|
137
|
-
this.perqApi.fetchUserVaultDeposits(userAddress, vaultAddress),
|
138
|
-
this.perqApi.fetchAllUserWNFTForVault(vaultAddress, userAddress),
|
133
|
+
const [userAddress, vault] = await Promise.all([this.signer.getAddress(), this.getVaultDetails(vaultAddress)]);
|
134
|
+
const [decimals, userBalanceBreakdown] = await Promise.all([
|
135
|
+
this.getERC20Precission(vault.depositToken.tokenAddress),
|
136
|
+
this.spoolSdk?.getUserBalanceBreakdown({ userAddress, vaultAddress }),
|
139
137
|
]);
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
const estimatedValueOfNFT = ethers_1.BigNumber.from(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(wnft.svtWithdrawn).mul(assetsPerSvtAtBlock), 36).split('.')[0]);
|
149
|
-
if (wnft.isDHWFinished) {
|
150
|
-
// Processed and claimable
|
151
|
-
claimable = claimable.add(estimatedValueOfNFT);
|
152
|
-
}
|
153
|
-
else {
|
154
|
-
// Not processed, pending withdrawal
|
155
|
-
pendingWithdraws = pendingWithdraws.add(estimatedValueOfNFT);
|
156
|
-
}
|
157
|
-
}
|
138
|
+
if (!userBalanceBreakdown) {
|
139
|
+
return {
|
140
|
+
hasWithdrawsToClaim: false,
|
141
|
+
userBalance: '0',
|
142
|
+
pendingUserBalance: '0',
|
143
|
+
pendingWithdrawalBalance: '0',
|
144
|
+
claimableBalance: '0',
|
145
|
+
};
|
158
146
|
}
|
147
|
+
let claimable = ethers_1.BigNumber.from(0);
|
148
|
+
for (const wnft of userBalanceBreakdown.claimableWNFTs) {
|
149
|
+
const currentBlockNumber = wnft.blockNumber - 1;
|
150
|
+
const assetsPerSvtAtBlock = await this.perqApi.fetchAssetPerSvtAtBlock(vaultAddress, currentBlockNumber);
|
151
|
+
const estimatedValueOfNFT = ethers_1.BigNumber.from(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(wnft.svtWithdrawn).mul(assetsPerSvtAtBlock), 36).split('.')[0]);
|
152
|
+
claimable = claimable.add(estimatedValueOfNFT);
|
153
|
+
}
|
154
|
+
const currentBalance = Object.values(userBalanceBreakdown.withdrawableAssets)
|
155
|
+
.reduce((acc, curr) => acc + curr, 0)
|
156
|
+
.toString();
|
157
|
+
const pendingDepositBalance = Object.values(userBalanceBreakdown.pendingAssets)
|
158
|
+
.reduce((acc, curr) => acc + curr, 0)
|
159
|
+
.toString();
|
159
160
|
return {
|
160
161
|
hasWithdrawsToClaim: claimable.gt(0),
|
161
|
-
userBalance:
|
162
|
-
pendingUserBalance:
|
163
|
-
pendingWithdrawalBalance:
|
162
|
+
userBalance: currentBalance,
|
163
|
+
pendingUserBalance: pendingDepositBalance,
|
164
|
+
pendingWithdrawalBalance: userBalanceBreakdown.pendingWithdrawal || '0',
|
164
165
|
claimableBalance: ethers_1.ethers.utils.formatUnits(claimable, decimals) || '0',
|
165
166
|
};
|
166
167
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dripfi/drip-sdk",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.4",
|
4
4
|
"description": "Drip SDK",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"pretty": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json}\""
|
14
14
|
},
|
15
15
|
"dependencies": {
|
16
|
-
"@spool.fi/spool-v2-sdk": "2.0.
|
16
|
+
"@spool.fi/spool-v2-sdk": "2.0.50",
|
17
17
|
"@yelay-lite/sdk": "0.0.11",
|
18
18
|
"ethers": "^5.7.2"
|
19
19
|
},
|