@dripfi/drip-sdk 1.1.26 → 1.1.28

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/DripSdk.d.ts CHANGED
@@ -54,7 +54,6 @@ export default class DripSdk {
54
54
  approveTokenForSwapAndDeposit(tokenAddress: string, amount: string): Promise<string>;
55
55
  approveTokenForDeposit(tokenAddress: string, amount: string): Promise<string>;
56
56
  private generateRedeemBagStruct;
57
- private getAllSvts;
58
57
  private getERC20Precission;
59
58
  private calculatePendingDeposits;
60
59
  private calculateAllDeposits;
package/dist/DripSdk.js CHANGED
@@ -229,14 +229,17 @@ class DripSdk {
229
229
  fastWithdraw(vaultAddress, amountToWithdraw) {
230
230
  return __awaiter(this, void 0, void 0, function* () {
231
231
  var _a, _b;
232
+ if (!this.signer) {
233
+ throw Error('No signer provided');
234
+ }
232
235
  const userAddress = yield this.signer.getAddress();
233
- const authData = yield this.isUserAuthenticated();
236
+ // const authData = await this.isUserAuthenticated();
234
237
  // if (!authData.isAuthenticated) {throw Error(`User not authenticated: ${authData.message}`);}
235
238
  if (!this.signer) {
236
239
  throw Error('No signer provided');
237
240
  }
238
241
  const vault = yield this.getVaultDetails(vaultAddress);
239
- const redeemBagStruct = yield this.generateRedeemBagStruct(authData.token, vault, userAddress, amountToWithdraw);
242
+ const redeemBagStruct = yield this.generateRedeemBagStruct(vault, userAddress, amountToWithdraw);
240
243
  const currentBlockNumber = yield ((_a = this.signer.provider) === null || _a === void 0 ? void 0 : _a.getBlockNumber());
241
244
  if (!currentBlockNumber) {
242
245
  throw Error('Error fetching block number');
@@ -292,14 +295,17 @@ class DripSdk {
292
295
  }
293
296
  withdraw(vaultAddress, amountToWithdraw) {
294
297
  return __awaiter(this, void 0, void 0, function* () {
298
+ if (!this.signer) {
299
+ throw Error('No signer provided');
300
+ }
295
301
  const userAddress = yield this.signer.getAddress();
296
- const authData = yield this.isUserAuthenticated();
302
+ // const authData = await this.isUserAuthenticated();
297
303
  // if (!authData.isAuthenticated) {throw Error(`User not authenticated: ${authData.message}`);}
298
304
  if (!this.signer) {
299
305
  throw Error('No signer provided');
300
306
  }
301
307
  const vault = yield this.getVaultDetails(vaultAddress);
302
- const redeemBagStruct = yield this.generateRedeemBagStruct(authData.token, vault, userAddress, amountToWithdraw);
308
+ const redeemBagStruct = yield this.generateRedeemBagStruct(vault, userAddress, amountToWithdraw);
303
309
  const redeemTx = yield this.spoolSdk.redeem(redeemBagStruct, userAddress, false);
304
310
  const redeemTxReceipt = yield redeemTx.wait();
305
311
  return redeemTxReceipt.transactionHash;
@@ -428,62 +434,25 @@ class DripSdk {
428
434
  return yield this.approveToken(tokenAddress, amount, smartVaultManagerAddress);
429
435
  });
430
436
  }
431
- generateRedeemBagStruct(token, vault, signerAddress, amountToWithdraw) {
432
- return __awaiter(this, void 0, void 0, function* () {
433
- const decimals = yield this.getERC20Precission(vault.depositToken.tokenAddress.toLowerCase());
434
- const withdrawAll = !amountToWithdraw;
435
- const initialAmountToWithdraw = ethers_1.ethers.utils.parseUnits(amountToWithdraw || '0', decimals);
436
- let totalAmountToWithdraw = initialAmountToWithdraw;
437
- let dnfts = yield this.dripApi.fetchEnrichedUserDNFTForVault(vault.vaultAddress.toLowerCase(), signerAddress, token);
438
- if (dnfts.length === 0) {
439
- throw Error('User has no deposits');
440
- }
441
- dnfts = yield this.getAllSvts(vault.vaultAddress.toLowerCase(), signerAddress, dnfts, token);
442
- let shares = ethers_1.BigNumber.from(0);
443
- const nftIds = [];
444
- const nftAmounts = [];
445
- let index = 0;
446
- while (dnfts[index] && (totalAmountToWithdraw.gt(0) || withdrawAll)) {
447
- const dnft = dnfts[index];
448
- const userBalance = this.calculateBalanceForDNFT(dnft, decimals);
449
- if (userBalance.gt(0)) {
450
- const amountToWithdraw = totalAmountToWithdraw;
451
- const userSvts = dnft.svts;
452
- let svtsToWithdraw = ethers_1.BigNumber.from(0);
453
- let nftAmount = ethers_1.BigNumber.from(0);
454
- if (amountToWithdraw.gte(userBalance) || withdrawAll) {
455
- nftAmount = dnft.shares;
456
- svtsToWithdraw = userSvts;
457
- if (!withdrawAll) {
458
- totalAmountToWithdraw = totalAmountToWithdraw.sub(userBalance);
459
- }
460
- }
461
- else {
462
- nftAmount = amountToWithdraw.mul(dnft.shares).div(userBalance);
463
- svtsToWithdraw = nftAmount.mul(userSvts).div(dnft.shares);
464
- totalAmountToWithdraw = totalAmountToWithdraw.sub(amountToWithdraw);
465
- }
466
- shares = shares.add(svtsToWithdraw);
467
- nftIds.push(dnft.nftId);
468
- nftAmounts.push(nftAmount);
469
- }
470
- index++;
471
- }
472
- return {
473
- smartVault: vault.vaultAddress.toLowerCase(),
474
- shares: shares,
475
- nftIds,
476
- nftAmounts,
477
- };
478
- });
479
- }
480
- getAllSvts(vaultAddress, userAddress, dnfts, token) {
437
+ generateRedeemBagStruct(vault, signerAddress, amountToWithdraw) {
481
438
  return __awaiter(this, void 0, void 0, function* () {
482
- const svts = yield this.dripApi.fetchUserSVTFromNfts(vaultAddress, userAddress, dnfts.map((element) => parseInt(element.nftId)), token);
483
- const result = dnfts.map((element, index) => {
484
- return { nftId: element.nftId, assets: element.assets, shares: element.shares, svts: svts[index] };
485
- });
486
- return result;
439
+ if (!this.spoolSdk) {
440
+ throw Error('No spool sdk provided');
441
+ }
442
+ const isFullWithdraw = !amountToWithdraw;
443
+ if (isFullWithdraw) {
444
+ return this.spoolSdk.views.userInfo.getMaxRedeemBag({
445
+ userAddress: signerAddress.toLowerCase(),
446
+ vaultAddress: vault.vaultAddress,
447
+ });
448
+ }
449
+ else {
450
+ return this.spoolSdk.views.userInfo.getMinimumBurnRedeemBag({
451
+ userAddress: signerAddress.toLowerCase(),
452
+ vaultAddress: vault.vaultAddress,
453
+ assetsToWithdraw: [Number(amountToWithdraw)]
454
+ });
455
+ }
487
456
  });
488
457
  }
489
458
  getERC20Precission(tokenAddress) {
package/dist/test.js CHANGED
@@ -17,17 +17,9 @@ const ethers_1 = require("ethers");
17
17
  const DripConfig_1 = require("./DripConfig");
18
18
  const DripSdk_1 = __importDefault(require("./DripSdk"));
19
19
  // This is script to test locally the drip sdk methods
20
- // OLD RECYCLER ADDRESS
21
- // RECYCLER_ADDRESS='0xe943A1320402fcf41cDc04275e842654165dAB78'
22
- // DRIP_TOKEN_ADDRESS='0xc9C66052327523d6A7a2ee5D50CF07e4415e27c7'
23
- // NEW RECYCLER ADDRESS:
24
- // RECYCLER_ADDRESS=0x463aea273644AfF560da07c7c09f3142b87E12f1
25
- // TOKEN_ADDRESS: 0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E
26
- const RECYCLER_ADDRESS = '0x463aea273644AfF560da07c7c09f3142b87E12f1';
27
- const DRIP_TOKEN_ADDRESS = '0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E';
28
20
  const account2 = '0x9E9B6899Ea314dD553A99f4F49440d2CeD2b2848'; // privKey 92eb90257aa76cc56ead18dd52dd3433689712ebe7356a70308b760bfcbdd787
29
- const privKey = '6ffc226f7b7769e27124317372c9dbb579a324e67e97bf07131bf2f59ec0f4fe';
30
- // const privKey: string = '92eb90257aa76cc56ead18dd52dd3433689712ebe7356a70308b760bfcbdd787';
21
+ // const privKey: string = '6ffc226f7b7769e27124317372c9dbb579a324e67e97bf07131bf2f59ec0f4fe';
22
+ const privKey = '92eb90257aa76cc56ead18dd52dd3433689712ebe7356a70308b760bfcbdd787';
31
23
  const testConfigParams = {
32
24
  subgraphUrl: 'https://subgraph.satsuma-prod.com/49eb322da234/solidant/spool-v2-sepolia/api',
33
25
  priceFeedApiUrl: 'https://pricefeed.dev.spool.fi/',
@@ -45,8 +37,8 @@ const testConfigParams = {
45
37
  }
46
38
  },
47
39
  dripContracts: {
48
- DripTokenAddress: DRIP_TOKEN_ADDRESS, // Sepolia contract address
49
- DripTokenRecyclerAddress: RECYCLER_ADDRESS // Sepolia contract address
40
+ DripTokenAddress: '0xc9C66052327523d6A7a2ee5D50CF07e4415e27c7', // Sepolia contract address
41
+ DripTokenRecyclerAddress: '0xe943A1320402fcf41cDc04275e842654165dAB78' // Sepolia contract address
50
42
  }
51
43
  };
52
44
  const configParams = {
@@ -66,8 +58,8 @@ const configParams = {
66
58
  },
67
59
  },
68
60
  dripContracts: {
69
- DripTokenAddress: '0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E', // Sepolia contract address
70
- DripTokenRecyclerAddress: '0x463aea273644AfF560da07c7c09f3142b87E12f1' // Sepolia contract address
61
+ DripTokenAddress: '0xc9C66052327523d6A7a2ee5D50CF07e4415e27c7', // Sepolia contract address
62
+ DripTokenRecyclerAddress: '0xe943A1320402fcf41cDc04275e842654165dAB78' // Sepolia contract address
71
63
  }
72
64
  };
73
65
  const provider = new ethers_1.ethers.providers.StaticJsonRpcProvider('https://rpc.ankr.com/eth_sepolia', 11155111);
@@ -84,9 +76,6 @@ const dripSdk = new DripSdk_1.default(new DripConfig_1.DripConfig(testConfigPara
84
76
  function main() {
85
77
  return __awaiter(this, void 0, void 0, function* () {
86
78
  try {
87
- // const res = await dripSdk.approveTokenForRecycler(DRIP_TOKEN_ADDRESS.toLowerCase(), '100000000000000000000');
88
- const res = yield dripSdk.recycleTokens('100000000000000000000');
89
- console.log(res);
90
79
  // const res = await dripSdk.deposit(usdcTokenAddress,usdcVaultPerq, '1000');
91
80
  // const res = await dripSdk.withdraw(usdcVaultPerq, '1');
92
81
  // await dripSdk.authenticate()
@@ -2,6 +2,7 @@ import { StretchGoal } from './StretchGoal';
2
2
  export type DeployedProject = {
3
3
  id: number | undefined;
4
4
  projectName: string;
5
+ owners: string[];
5
6
  logo: string;
6
7
  telegramLink: string;
7
8
  twitterLink: string;
@@ -23,20 +24,17 @@ export type DeployedProject = {
23
24
  networks: string[];
24
25
  content: string;
25
26
  tgeDate?: string;
27
+ tgePrice?: number;
28
+ vAPY?: number;
26
29
  wikiLink: string;
27
30
  youTubeLink: string;
28
31
  tikTokLink: string;
29
- isMoonMathDisabled: boolean;
30
- isFastWithdrawDisabled: boolean;
32
+ stretchGoals: StretchGoal[];
31
33
  projectInfoText: string;
32
34
  projectRewardText: string;
33
- stretchGoals: StretchGoal[];
34
- owners: string[];
35
35
  coingeckoId?: string;
36
36
  projectType: string;
37
37
  isFeatured: boolean;
38
- tgePrice?: number;
39
- vAPY?: number;
40
38
  };
41
39
  export type ProjectBacker = {
42
40
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dripfi/drip-sdk",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
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": "1.0.14",
14
+ "@spool.fi/spool-v2-sdk": "1.0.27",
15
15
  "ethers": "^5.7.2",
16
16
  "js-cookie": "^3.0.5",
17
17
  "web3-token": "^1.0.6"