@dripfi/drip-sdk 1.2.2 → 1.2.3

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/DripApi.d.ts CHANGED
@@ -8,6 +8,7 @@ import { UserBalance } from './types/UserBalance';
8
8
  import { VaultClaimData } from './types/VaultClaimData';
9
9
  import MyPerqData from './types/MyPerqData';
10
10
  import { BeansBalance } from './types/BeansBalance';
11
+ import { PerqToBeansSwapInfo } from './types/PerqToBeansSwapInfo';
11
12
  export declare const IMPERSONATOR_HEADER = "impersonatorAddress";
12
13
  export default class DripApi {
13
14
  route: string;
@@ -57,4 +58,5 @@ export default class DripApi {
57
58
  }>;
58
59
  fetchMyPerqData(userAddress: string, token: string, headers?: Headers): Promise<MyPerqData>;
59
60
  getLoyaltyCardBoost(rewardId: string, token: string, headers?: Headers): Promise<number>;
61
+ getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
60
62
  }
package/dist/DripApi.js CHANGED
@@ -485,5 +485,17 @@ class DripApi {
485
485
  }
486
486
  });
487
487
  }
488
+ getSwapPerqForBeansInfo() {
489
+ return __awaiter(this, void 0, void 0, function* () {
490
+ const res = yield fetch(`${this.route}/api-be/api/swap/price`, {});
491
+ if (res.ok) {
492
+ const data = yield res.json();
493
+ return data;
494
+ }
495
+ else {
496
+ throw Error(`${yield res.text()}`);
497
+ }
498
+ });
499
+ }
488
500
  }
489
501
  exports.default = DripApi;
@@ -19,8 +19,8 @@ var Chain;
19
19
  Chain["SEPOLIA"] = "sepolia";
20
20
  })(Chain || (exports.Chain = Chain = {}));
21
21
  const SUBGRAPH_URL_SEPOLIA = 'https://subgraph.satsuma-prod.com/49eb322da234/solidant/spool-v2-sepolia/api';
22
- const RECYCLER_ADDRESS_SEPOLIA = '0x463aea273644AfF560da07c7c09f3142b87E12f1';
23
- const DRIP_TOKEN_ADDRESS_SEPOLIA = '0xc9C66052327523d6A7a2ee5D50CF07e4415e27c7';
22
+ const RECYCLER_ADDRESS_SEPOLIA = '0x07F2264E199D62afe07E8288eC9D36d155fc3f24';
23
+ const DRIP_TOKEN_ADDRESS_SEPOLIA = '0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E';
24
24
  const SUBGRAPH_URL_MAINNET = 'https://subgraph.satsuma-prod.com/49eb322da234/solidant/spool-v2/api';
25
25
  // const RECYCLER_ADDRESS_MAINNET = '';
26
26
  // const DRIP_TOKEN_ADDRESS_MAINNET = '';
package/dist/DripSdk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Signer } from 'ethers';
1
+ import { BigNumber, Signer } from 'ethers';
2
2
  import { AuthenticationStatus } from './types/AuthenticationStatus';
3
3
  import { UserRewards } from './types/UserRewards';
4
4
  import { VaultStats } from './types/VaultStats';
@@ -10,6 +10,7 @@ import { LoyaltyCard } from './types/LoyaltyCard';
10
10
  import MyPerqData from './types/MyPerqData';
11
11
  import { Chain } from './DripConfig';
12
12
  import { BeansBalance } from './types/BeansBalance';
13
+ import { PerqToBeansSwapInfo } from './types/PerqToBeansSwapInfo';
13
14
  export default class DripSdk {
14
15
  private dripApi;
15
16
  private dripTokenContract;
@@ -29,6 +30,7 @@ export default class DripSdk {
29
30
  deposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>;
30
31
  private doDeposit;
31
32
  getTokenAllowanceForCurrency(tokenAddress: string): Promise<string>;
33
+ getTokenAllowanceForRecycler(tokenAddress: string): Promise<BigNumber>;
32
34
  getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number): Promise<string>;
33
35
  getUserBalance(headers?: Headers): Promise<UserBalance>;
34
36
  getUserBoostedNfts(vaultAddress: string, headers?: Headers): Promise<string[]>;
@@ -44,7 +46,7 @@ export default class DripSdk {
44
46
  claimWithdraws(vaultAddress: string): Promise<string>;
45
47
  getVaultsClaimableData(headers?: Headers): Promise<VaultClaimData>;
46
48
  getBeansBalance(headers?: Headers): Promise<BeansBalance>;
47
- recycleTokens(amount: string, beneficiary?: string): Promise<string>;
49
+ recycleTokens(tokenAddress: string | undefined, amountToRecycle: string, beneficiary: string | undefined, price: string, deadline: string, signature: string): Promise<string>;
48
50
  upgradeLoyaltyCard(): Promise<LoyaltyCard>;
49
51
  getNextLoyaltyCard(headers?: Headers): Promise<LoyaltyCard>;
50
52
  getOwnedLoyaltyCards(headers?: Headers): Promise<LoyaltyCard>;
@@ -54,6 +56,7 @@ export default class DripSdk {
54
56
  approveTokenForSwapAndDeposit(tokenAddress: string, amount: string): Promise<string>;
55
57
  approveTokenForDeposit(tokenAddress: string, amount: string): Promise<string>;
56
58
  getDripTokenContractAddress(): string;
59
+ getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
57
60
  private generateRedeemBagStruct;
58
61
  private getERC20Precission;
59
62
  private calculatePendingDeposits;
package/dist/DripSdk.js CHANGED
@@ -155,6 +155,15 @@ class DripSdk {
155
155
  return currentTokenAllowance.toString();
156
156
  });
157
157
  }
158
+ getTokenAllowanceForRecycler(tokenAddress) {
159
+ return __awaiter(this, void 0, void 0, function* () {
160
+ if (!this.signer) {
161
+ throw Error('No signer provided');
162
+ }
163
+ const allowance = yield this.getERC20TokenAllowance(this.dripTokenRecyclerContract.getContractAddress(), tokenAddress);
164
+ return allowance;
165
+ });
166
+ }
158
167
  getExpectedSwapResult(fromTokenAddress, toTokenAddress, amount, decimals) {
159
168
  return __awaiter(this, void 0, void 0, function* () {
160
169
  const userAddress = yield this.signer.getAddress();
@@ -353,8 +362,8 @@ class DripSdk {
353
362
  return this.dripApi.fetchBeansBalance(authData.token, headers);
354
363
  });
355
364
  }
356
- recycleTokens(amount, beneficiary) {
357
- return __awaiter(this, void 0, void 0, function* () {
365
+ recycleTokens() {
366
+ return __awaiter(this, arguments, void 0, function* (tokenAddress = this.dripConfig.dripTokenAddress, amountToRecycle, beneficiary = DripConfig_1.NULL_ADDRESS, price, deadline, signature) {
358
367
  const authData = yield this.isUserAuthenticated();
359
368
  if (!authData.isAuthenticated) {
360
369
  throw Error(`User not authenticated: ${authData.message}`);
@@ -362,9 +371,9 @@ class DripSdk {
362
371
  if (this.dripConfig.dripTokenRecyclerAddress === DripConfig_1.NULL_ADDRESS) {
363
372
  throw Error('Recycler contract address not defined');
364
373
  }
365
- const decimals = yield this.getERC20Precission(this.dripConfig.dripTokenAddress);
366
- const amountWithDecimals = parseFloat(parseFloat(amount).toFixed(decimals));
367
- const recycleTx = yield this.dripTokenRecyclerContract.recycle(ethers_1.ethers.utils.parseUnits(amountWithDecimals.toString(), decimals).toString(), beneficiary);
374
+ const decimals = yield this.getERC20Precission(tokenAddress);
375
+ const amountWithDecimals = ethers_1.ethers.utils.parseUnits(amountToRecycle, decimals).toString();
376
+ const recycleTx = yield this.dripTokenRecyclerContract.recycle(amountWithDecimals, beneficiary, price, deadline, signature);
368
377
  const receipt = yield recycleTx.wait();
369
378
  return receipt.transactionHash;
370
379
  });
@@ -422,7 +431,7 @@ class DripSdk {
422
431
  if (this.dripConfig.dripTokenRecyclerAddress === DripConfig_1.NULL_ADDRESS) {
423
432
  throw Error('Recycler contract address not defined');
424
433
  }
425
- return yield this.approveToken(tokenAddress, amount.toString(), this.dripConfig.dripTokenRecyclerAddress);
434
+ return yield this.approveToken(tokenAddress, amount, this.dripConfig.dripTokenRecyclerAddress);
426
435
  });
427
436
  }
428
437
  approveTokenForSwapAndDeposit(tokenAddress, amount) {
@@ -446,6 +455,11 @@ class DripSdk {
446
455
  getDripTokenContractAddress() {
447
456
  return this.dripConfig.dripTokenAddress;
448
457
  }
458
+ getSwapPerqForBeansInfo() {
459
+ return __awaiter(this, void 0, void 0, function* () {
460
+ return this.dripApi.getSwapPerqForBeansInfo();
461
+ });
462
+ }
449
463
  generateRedeemBagStruct(vault, signerAddress, amountToWithdraw) {
450
464
  return __awaiter(this, void 0, void 0, function* () {
451
465
  if (!this.spoolSdk) {
@@ -2,5 +2,5 @@ import { ContractTransaction, ethers } from 'ethers';
2
2
  import BaseDripContract from './BaseDripContract';
3
3
  export default class DripTokenRecyclerContract extends BaseDripContract {
4
4
  constructor(address: string, signer?: ethers.Signer);
5
- recycle(amount: string, rewardBeneficiary?: string): Promise<ContractTransaction>;
5
+ recycle(amountToRecycle: string, beneficiary: string | undefined, price: string, deadline: string, signature: string): Promise<ContractTransaction>;
6
6
  }
@@ -20,12 +20,12 @@ class DripTokenRecyclerContract extends BaseDripContract_1.default {
20
20
  constructor(address, signer) {
21
21
  super(address, new ethers_1.ethers.utils.Interface(TokenRecyclerAbi_json_1.default), signer);
22
22
  }
23
- recycle(amount, rewardBeneficiary) {
24
- return __awaiter(this, void 0, void 0, function* () {
23
+ recycle(amountToRecycle_1) {
24
+ return __awaiter(this, arguments, void 0, function* (amountToRecycle, beneficiary = DripConfig_1.NULL_ADDRESS, price, deadline, signature) {
25
25
  if (!this.contract.signer) {
26
26
  throw Error('No signer provided');
27
27
  }
28
- return yield this.contract.recycle(amount, rewardBeneficiary ? rewardBeneficiary : DripConfig_1.NULL_ADDRESS);
28
+ return yield this.contract.recycle(amountToRecycle, beneficiary, price, deadline, signature);
29
29
  });
30
30
  }
31
31
  }
@@ -13,17 +13,17 @@
13
13
  },
14
14
  {
15
15
  "internalType": "address",
16
- "name": "beneficiaryAddress_",
16
+ "name": "oracle",
17
17
  "type": "address"
18
18
  },
19
19
  {
20
- "internalType": "uint256",
21
- "name": "beneficiaryShare_",
22
- "type": "uint256"
20
+ "internalType": "address",
21
+ "name": "beneficiaryAddress_",
22
+ "type": "address"
23
23
  },
24
24
  {
25
25
  "internalType": "uint256",
26
- "name": "recycledTokenToRewardRatio_",
26
+ "name": "beneficiaryShare_",
27
27
  "type": "uint256"
28
28
  }
29
29
  ],
@@ -73,6 +73,33 @@
73
73
  "name": "AddressInsufficientBalance",
74
74
  "type": "error"
75
75
  },
76
+ {
77
+ "inputs": [],
78
+ "name": "ECDSAInvalidSignature",
79
+ "type": "error"
80
+ },
81
+ {
82
+ "inputs": [
83
+ {
84
+ "internalType": "uint256",
85
+ "name": "length",
86
+ "type": "uint256"
87
+ }
88
+ ],
89
+ "name": "ECDSAInvalidSignatureLength",
90
+ "type": "error"
91
+ },
92
+ {
93
+ "inputs": [
94
+ {
95
+ "internalType": "bytes32",
96
+ "name": "s",
97
+ "type": "bytes32"
98
+ }
99
+ ],
100
+ "name": "ECDSAInvalidSignatureS",
101
+ "type": "error"
102
+ },
76
103
  {
77
104
  "inputs": [],
78
105
  "name": "FailedInnerCall",
@@ -234,6 +261,19 @@
234
261
  "stateMutability": "view",
235
262
  "type": "function"
236
263
  },
264
+ {
265
+ "inputs": [],
266
+ "name": "ORACLE_ROLE",
267
+ "outputs": [
268
+ {
269
+ "internalType": "bytes32",
270
+ "name": "",
271
+ "type": "bytes32"
272
+ }
273
+ ],
274
+ "stateMutability": "view",
275
+ "type": "function"
276
+ },
237
277
  {
238
278
  "inputs": [
239
279
  {
@@ -351,6 +391,21 @@
351
391
  "internalType": "address",
352
392
  "name": "rewardBeneficiary",
353
393
  "type": "address"
394
+ },
395
+ {
396
+ "internalType": "uint256",
397
+ "name": "price",
398
+ "type": "uint256"
399
+ },
400
+ {
401
+ "internalType": "uint256",
402
+ "name": "deadline",
403
+ "type": "uint256"
404
+ },
405
+ {
406
+ "internalType": "bytes",
407
+ "name": "signature",
408
+ "type": "bytes"
354
409
  }
355
410
  ],
356
411
  "name": "recycle",
@@ -377,19 +432,6 @@
377
432
  "stateMutability": "view",
378
433
  "type": "function"
379
434
  },
380
- {
381
- "inputs": [],
382
- "name": "recycledTokenToRewardRatio",
383
- "outputs": [
384
- {
385
- "internalType": "uint256",
386
- "name": "",
387
- "type": "uint256"
388
- }
389
- ],
390
- "stateMutability": "view",
391
- "type": "function"
392
- },
393
435
  {
394
436
  "inputs": [
395
437
  {
@@ -465,19 +507,6 @@
465
507
  "stateMutability": "nonpayable",
466
508
  "type": "function"
467
509
  },
468
- {
469
- "inputs": [
470
- {
471
- "internalType": "uint256",
472
- "name": "recycledTokenToRewardRatio_",
473
- "type": "uint256"
474
- }
475
- ],
476
- "name": "setRecycledTokenToRewardRatio",
477
- "outputs": [],
478
- "stateMutability": "nonpayable",
479
- "type": "function"
480
- },
481
510
  {
482
511
  "inputs": [
483
512
  {
package/dist/test.js CHANGED
@@ -37,7 +37,7 @@ const testConfigParams = {
37
37
  }
38
38
  },
39
39
  dripContracts: {
40
- DripTokenAddress: '0xc9C66052327523d6A7a2ee5D50CF07e4415e27c7', // Sepolia contract address
40
+ DripTokenAddress: '0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E', // Sepolia contract address
41
41
  DripTokenRecyclerAddress: '0xe943A1320402fcf41cDc04275e842654165dAB78' // Sepolia contract address
42
42
  }
43
43
  };
@@ -58,7 +58,7 @@ const configParams = {
58
58
  },
59
59
  },
60
60
  dripContracts: {
61
- DripTokenAddress: '0xc9C66052327523d6A7a2ee5D50CF07e4415e27c7', // Sepolia contract address
61
+ DripTokenAddress: '0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E', // Sepolia contract address
62
62
  DripTokenRecyclerAddress: '0xe943A1320402fcf41cDc04275e842654165dAB78' // Sepolia contract address
63
63
  }
64
64
  };
@@ -0,0 +1,7 @@
1
+ export type PerqToBeansSwapInfo = {
2
+ perqPrice: number;
3
+ price: number;
4
+ priceInFloat: number;
5
+ deadline: number;
6
+ signature: string;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dripfi/drip-sdk",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Drip SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",