@dripfi/drip-sdk 1.4.3-yelay-lite-1 → 1.4.3-yelay-lite-2
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/PerqApi.d.ts +3 -10
- package/dist/PerqApi.js +24 -54
- package/dist/PerqSdk.js +4 -57
- package/dist/types/PerqConfig.js +2 -2
- package/package.json +2 -2
package/dist/PerqApi.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { BigNumber } from 'ethers';
|
2
|
-
import { SwapInfo,
|
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
4
|
export default class PerqApi {
|
5
5
|
route: string;
|
@@ -15,13 +15,8 @@ export default class PerqApi {
|
|
15
15
|
fetchVaultStats(): Promise<VaultStats>;
|
16
16
|
fetchRewardsPerHour(walletAddress: string, vaultAddress: string): Promise<number>;
|
17
17
|
getSwapInfo(fromTokenAddress: string, toTokenAddress: string, amount: BigNumber, fromAddress: string, chainId: number): Promise<SwapInfo[]>;
|
18
|
-
fetchUserSVTBalance(vaultAddress: string, walletAddress: string): Promise<BigNumber>;
|
19
|
-
fetchUserBalance(vaultAddress: string, walletAddress: string): Promise<Record<string, string>>;
|
20
18
|
fetchEnrichedUserWNFTForVault(vaultAddress: string, walletAddress: string): Promise<any[]>;
|
21
|
-
fetchAllUserWNFTForVault(vaultAddress: string, walletAddress: string): Promise<any[]>;
|
22
|
-
fetchAllUserDNFTForVault(vaultAddress: string, walletAddress: string): Promise<any[]>;
|
23
19
|
fetchAssetPerSvtAtBlock(vaultAddress: string, blocknumber: number): Promise<BigNumber>;
|
24
|
-
fetchFastWithdrawNFTs(vaultAddress: string, walletAddress: string): Promise<QLFastRedeem[]>;
|
25
20
|
fetchUserRewards(walletAddress: string): Promise<UserRewards>;
|
26
21
|
fetchAllLoyaltyCards(): Promise<LoyaltyCard[]>;
|
27
22
|
fetchOwnedLoyaltyCard(walletAddress: string): Promise<LoyaltyCard>;
|
@@ -33,8 +28,6 @@ export default class PerqApi {
|
|
33
28
|
linkSuiWalletWithEthWallet(signedPayload: NonceEnrichedSignedPayload<LinkWalletPayload>): Promise<boolean>;
|
34
29
|
getLinkedSuiWallet(walletAddress: string): Promise<string>;
|
35
30
|
getNonceEnrichedPayload<T>(payload: T): Promise<NonceEnrichedPayload<T>>;
|
36
|
-
|
37
|
-
|
38
|
-
deposited: number;
|
39
|
-
}>;
|
31
|
+
fetchV2VaultUserBalance(userAddress: string, vaultAddress: string): Promise<UserVaultBalance>;
|
32
|
+
fetchLiteVaultUserBalance(userAddress: string, vaultAddress: string, onChainProjectId: number): Promise<UserVaultBalance>;
|
40
33
|
}
|
package/dist/PerqApi.js
CHANGED
@@ -135,26 +135,6 @@ class PerqApi {
|
|
135
135
|
throw Error(`${await res.text()}`);
|
136
136
|
}
|
137
137
|
}
|
138
|
-
async fetchUserSVTBalance(vaultAddress, walletAddress) {
|
139
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/svtBalance/${vaultAddress}`);
|
140
|
-
if (res.ok) {
|
141
|
-
const data = (await res.json());
|
142
|
-
return data;
|
143
|
-
}
|
144
|
-
else {
|
145
|
-
throw Error(`${await res.text()}`);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
async fetchUserBalance(vaultAddress, walletAddress) {
|
149
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/balance/${vaultAddress}`);
|
150
|
-
if (res.ok) {
|
151
|
-
const data = (await res.json());
|
152
|
-
return data;
|
153
|
-
}
|
154
|
-
else {
|
155
|
-
throw Error(`${await res.text()}`);
|
156
|
-
}
|
157
|
-
}
|
158
138
|
async fetchEnrichedUserWNFTForVault(vaultAddress, walletAddress) {
|
159
139
|
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/wNft/${vaultAddress}`);
|
160
140
|
if (res.ok) {
|
@@ -165,26 +145,6 @@ class PerqApi {
|
|
165
145
|
throw Error(`${await res.text()}`);
|
166
146
|
}
|
167
147
|
}
|
168
|
-
async fetchAllUserWNFTForVault(vaultAddress, walletAddress) {
|
169
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/allWnft/${vaultAddress}`);
|
170
|
-
if (res.ok) {
|
171
|
-
const data = (await res.json());
|
172
|
-
return data;
|
173
|
-
}
|
174
|
-
else {
|
175
|
-
throw Error(`${await res.text()}`);
|
176
|
-
}
|
177
|
-
}
|
178
|
-
async fetchAllUserDNFTForVault(vaultAddress, walletAddress) {
|
179
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/allDnft/${vaultAddress}`);
|
180
|
-
if (res.ok) {
|
181
|
-
const data = (await res.json());
|
182
|
-
return data;
|
183
|
-
}
|
184
|
-
else {
|
185
|
-
throw Error(`${await res.text()}`);
|
186
|
-
}
|
187
|
-
}
|
188
148
|
async fetchAssetPerSvtAtBlock(vaultAddress, blocknumber) {
|
189
149
|
const res = await fetch(`${this.route}/api-be/api/spool/assetBalance/${blocknumber}/${vaultAddress}`);
|
190
150
|
if (res.ok) {
|
@@ -195,16 +155,6 @@ class PerqApi {
|
|
195
155
|
throw Error(`${await res.text()}`);
|
196
156
|
}
|
197
157
|
}
|
198
|
-
async fetchFastWithdrawNFTs(vaultAddress, walletAddress) {
|
199
|
-
const res = await fetch(`${this.route}/api-be/api/spool/user/${walletAddress}/fastWithdrawNft/${vaultAddress}`);
|
200
|
-
if (res.ok) {
|
201
|
-
const data = (await res.json());
|
202
|
-
return data;
|
203
|
-
}
|
204
|
-
else {
|
205
|
-
throw Error(`${await res.text()}`);
|
206
|
-
}
|
207
|
-
}
|
208
158
|
async fetchUserRewards(walletAddress) {
|
209
159
|
const res = await fetch(`${this.route}/api-be/api/user/${walletAddress}/rewards`);
|
210
160
|
if (res.ok) {
|
@@ -371,10 +321,30 @@ class PerqApi {
|
|
371
321
|
// Return the enriched payload without the extra nesting
|
372
322
|
return enrichedPayload.payload;
|
373
323
|
}
|
374
|
-
async
|
375
|
-
const
|
376
|
-
|
377
|
-
|
324
|
+
async fetchV2VaultUserBalance(userAddress, vaultAddress) {
|
325
|
+
const res = await fetch(`${this.route}/api-be/api/user/v2/balance/${userAddress}/${vaultAddress}`);
|
326
|
+
if (res.ok) {
|
327
|
+
return await res.json();
|
328
|
+
}
|
329
|
+
else {
|
330
|
+
throw Error(`${await res.text()}`);
|
331
|
+
}
|
332
|
+
}
|
333
|
+
async fetchLiteVaultUserBalance(userAddress, vaultAddress, onChainProjectId) {
|
334
|
+
const res = await fetch(`${this.route}/api-be/api/user/lite/balance/${userAddress}/${vaultAddress}/${onChainProjectId}`);
|
335
|
+
if (res.ok) {
|
336
|
+
const data = await res.json();
|
337
|
+
return {
|
338
|
+
hasWithdrawsToClaim: false,
|
339
|
+
userBalance: data.userBalance,
|
340
|
+
pendingUserBalance: '0',
|
341
|
+
pendingWithdrawalBalance: '0',
|
342
|
+
claimableBalance: '0',
|
343
|
+
};
|
344
|
+
}
|
345
|
+
else {
|
346
|
+
throw Error(`${await res.text()}`);
|
347
|
+
}
|
378
348
|
}
|
379
349
|
}
|
380
350
|
exports.default = PerqApi;
|
package/dist/PerqSdk.js
CHANGED
@@ -165,68 +165,15 @@ class PerqSdk {
|
|
165
165
|
if (!this.signer) {
|
166
166
|
throw Error('No signer provided');
|
167
167
|
}
|
168
|
-
|
169
|
-
|
170
|
-
}
|
171
|
-
try {
|
172
|
-
const [userAddress, vault] = await Promise.all([
|
173
|
-
this.signer.getAddress(),
|
174
|
-
this.getLiteVaultDetails(vaultAddress, onChainProjectId),
|
175
|
-
]);
|
176
|
-
const [balance, decimals] = await Promise.all([
|
177
|
-
this.yelayLiteSdk.vaults.balanceOf(vaultAddress, onChainProjectId, userAddress),
|
178
|
-
this.getERC20Precission(vault.depositToken.tokenAddress),
|
179
|
-
]);
|
180
|
-
return {
|
181
|
-
userBalance: ethers_1.ethers.utils.formatUnits(balance.toString(), decimals),
|
182
|
-
pendingUserBalance: '0',
|
183
|
-
pendingWithdrawalBalance: '0',
|
184
|
-
claimableBalance: '0',
|
185
|
-
hasWithdrawsToClaim: false,
|
186
|
-
};
|
187
|
-
}
|
188
|
-
catch (error) {
|
189
|
-
throw new Error(`Failed to get YelayLite user vault balance: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
190
|
-
}
|
168
|
+
const userAddress = await this.signer.getAddress();
|
169
|
+
return await this.perqApi.fetchLiteVaultUserBalance(userAddress.toLowerCase(), vaultAddress.toLowerCase(), onChainProjectId);
|
191
170
|
}
|
192
171
|
async getUserVaultBalance(vaultAddress) {
|
193
172
|
if (!this.signer) {
|
194
173
|
throw Error('No signer provided');
|
195
174
|
}
|
196
|
-
const
|
197
|
-
|
198
|
-
this.getERC20Precission(vault.depositToken.tokenAddress),
|
199
|
-
this.spoolSdk?.getUserBalanceBreakdown({ userAddress, vaultAddress }),
|
200
|
-
]);
|
201
|
-
if (!userBalanceBreakdown) {
|
202
|
-
return {
|
203
|
-
hasWithdrawsToClaim: false,
|
204
|
-
userBalance: '0',
|
205
|
-
pendingUserBalance: '0',
|
206
|
-
pendingWithdrawalBalance: '0',
|
207
|
-
claimableBalance: '0',
|
208
|
-
};
|
209
|
-
}
|
210
|
-
let claimable = ethers_1.BigNumber.from(0);
|
211
|
-
for (const wnft of userBalanceBreakdown.claimableWNFTs) {
|
212
|
-
const currentBlockNumber = wnft.blockNumber - 1;
|
213
|
-
const assetsPerSvtAtBlock = await this.perqApi.fetchAssetPerSvtAtBlock(vaultAddress, currentBlockNumber);
|
214
|
-
const estimatedValueOfNFT = ethers_1.BigNumber.from(ethers_1.ethers.utils.formatUnits(ethers_1.BigNumber.from(wnft.svtWithdrawn).mul(assetsPerSvtAtBlock), 36).split('.')[0]);
|
215
|
-
claimable = claimable.add(estimatedValueOfNFT);
|
216
|
-
}
|
217
|
-
const currentBalance = Object.values(userBalanceBreakdown.withdrawableAssets)
|
218
|
-
.reduce((acc, curr) => acc + curr, 0)
|
219
|
-
.toString();
|
220
|
-
const pendingDepositBalance = Object.values(userBalanceBreakdown.pendingAssets)
|
221
|
-
.reduce((acc, curr) => acc + curr, 0)
|
222
|
-
.toString();
|
223
|
-
return {
|
224
|
-
hasWithdrawsToClaim: claimable.gt(0),
|
225
|
-
userBalance: currentBalance,
|
226
|
-
pendingUserBalance: pendingDepositBalance,
|
227
|
-
pendingWithdrawalBalance: userBalanceBreakdown.pendingWithdrawal || '0',
|
228
|
-
claimableBalance: ethers_1.ethers.utils.formatUnits(claimable, decimals) || '0',
|
229
|
-
};
|
175
|
+
const userAddress = await this.signer.getAddress();
|
176
|
+
return await this.perqApi.fetchV2VaultUserBalance(userAddress.toLowerCase(), vaultAddress.toLowerCase());
|
230
177
|
}
|
231
178
|
async fastWithdraw(vaultAddress, amountToWithdraw) {
|
232
179
|
if (!this.signer) {
|
package/dist/types/PerqConfig.js
CHANGED
@@ -13,7 +13,7 @@ exports.PRODUCTION = {
|
|
13
13
|
perqVestingAddress: '0x5e19c155c30bdeb83fcfe20a3b6f6eda34b746c5',
|
14
14
|
swapAndDepositContractAddress: '0xd8534197bd587f8226d12e0c864ef2cae6f82f5c',
|
15
15
|
ethereumSwapperAddress: '0x33e52c206d584550193e642c8982f2fff6339994',
|
16
|
-
baseSwapperAddress:
|
16
|
+
baseSwapperAddress: sdk_1.sdkConfig[chains_1.BASE_CHAIN_ID].contractAddresses.Swapper,
|
17
17
|
smartVaultManagerContractAddress: '0x23daf34e2b9af02a74dc19cb52af727b19403874',
|
18
18
|
yelayLiteSdkConfig: sdk_1.sdkConfig[chains_1.BASE_CHAIN_ID],
|
19
19
|
};
|
@@ -26,7 +26,7 @@ exports.DEVELOPMENT = {
|
|
26
26
|
perqVestingAddress: '0x1d3b9e32a7139718f94be32c797682fff2d1be60',
|
27
27
|
swapAndDepositContractAddress: '0x5fb08e00de169f041711206a0995410884080177',
|
28
28
|
ethereumSwapperAddress: '0xe411921ee9eedfefd7b9ae15bf232bd36949fcbbc',
|
29
|
-
baseSwapperAddress:
|
29
|
+
baseSwapperAddress: sdk_1.devSdkConfig[chains_1.BASE_CHAIN_ID].contractAddresses.Swapper,
|
30
30
|
smartVaultManagerContractAddress: '0x2638d6c0b4ef6dee04050fa0b07ca62500435747',
|
31
31
|
yelayLiteSdkConfig: sdk_1.devSdkConfig[chains_1.BASE_CHAIN_ID],
|
32
32
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dripfi/drip-sdk",
|
3
|
-
"version": "1.4.3-yelay-lite-
|
3
|
+
"version": "1.4.3-yelay-lite-2",
|
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
|
-
"@yelay-lite/sdk": "0.0.
|
16
|
+
"@yelay-lite/sdk": "0.0.34",
|
17
17
|
"@spool.fi/spool-v2-sdk": "2.0.53",
|
18
18
|
"ethers": "^5.7.2"
|
19
19
|
},
|