@dripfi/drip-sdk 1.1.14 → 1.1.16

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
@@ -30,4 +30,9 @@ export default class DripApi {
30
30
  fetchFastWithdrawNFTs(vaultAddress: string, walletAddress: string, token: string, headers?: Headers): Promise<QLFastRedeem[]>;
31
31
  fetchUserRewards(walletAddress: string, token: string, headers?: Headers): Promise<UserRewards>;
32
32
  fetchVaultsClaimableData(walletAddress: string, token: string, headers?: Headers): Promise<VaultClaimData>;
33
+ fetchAllLoyaltyCards(token: string, headers?: Headers): Promise<any>;
34
+ fetchOwnedLoyaltyCards(token: string, headers?: Headers): Promise<any>;
35
+ fetchNextLoyaltyCard(token: string, headers?: Headers): Promise<any>;
36
+ fetchBeansBalance(walletAddress: string, token: string, headers?: Headers): Promise<any>;
37
+ upgradeLoyaltyCard(token: string, headers?: Headers): Promise<any>;
33
38
  }
package/dist/DripApi.js CHANGED
@@ -355,5 +355,61 @@ class DripApi {
355
355
  }
356
356
  });
357
357
  }
358
+ fetchAllLoyaltyCards(token, headers) {
359
+ return __awaiter(this, void 0, void 0, function* () {
360
+ const reqHeaders = headers ? headers : new Headers();
361
+ reqHeaders.append(AUTHORIZATION_HEADER, token);
362
+ const res = yield fetch(`${this.route}/api-be/api/loyaltyCards`, {
363
+ headers: reqHeaders,
364
+ });
365
+ const data = yield res.json();
366
+ return data;
367
+ });
368
+ }
369
+ fetchOwnedLoyaltyCards(token, headers) {
370
+ return __awaiter(this, void 0, void 0, function* () {
371
+ const reqHeaders = headers ? headers : new Headers();
372
+ reqHeaders.append(AUTHORIZATION_HEADER, token);
373
+ const res = yield fetch(`${this.route}/api-be/api/loyaltyCards/owned`, {
374
+ headers: reqHeaders,
375
+ });
376
+ const data = yield res.json();
377
+ return data;
378
+ });
379
+ }
380
+ fetchNextLoyaltyCard(token, headers) {
381
+ return __awaiter(this, void 0, void 0, function* () {
382
+ const reqHeaders = headers ? headers : new Headers();
383
+ reqHeaders.append(AUTHORIZATION_HEADER, token);
384
+ const res = yield fetch(`${this.route}/api-be/api/loyaltyCards/next`, {
385
+ headers: reqHeaders,
386
+ });
387
+ const data = yield res.json();
388
+ return data;
389
+ });
390
+ }
391
+ fetchBeansBalance(walletAddress, token, headers) {
392
+ return __awaiter(this, void 0, void 0, function* () {
393
+ const reqHeaders = headers ? headers : new Headers();
394
+ reqHeaders.append(AUTHORIZATION_HEADER, token);
395
+ const res = yield fetch(`${this.route}/api-be/api/beans/balance`, {
396
+ headers: reqHeaders,
397
+ });
398
+ const data = yield res.json();
399
+ return data;
400
+ });
401
+ }
402
+ upgradeLoyaltyCard(token, headers) {
403
+ return __awaiter(this, void 0, void 0, function* () {
404
+ const reqHeaders = headers ? headers : new Headers();
405
+ reqHeaders.append(AUTHORIZATION_HEADER, token);
406
+ const res = yield fetch(`${this.route}/api-be/api/loyaltyCards/upgrade`, {
407
+ method: 'POST',
408
+ headers: reqHeaders,
409
+ });
410
+ const data = yield res.json();
411
+ return data;
412
+ });
413
+ }
358
414
  }
359
415
  exports.default = DripApi;
@@ -5,7 +5,9 @@ export declare class DripConfig {
5
5
  dripRoute: string;
6
6
  swapAndDepositContractAddress: string | undefined;
7
7
  smartVaultManagerAddress: string | undefined;
8
- constructor(subgraphUrl: string, priceFeedApiUrl: string, rewardsUrl: string, fastRedeemApi: string, contracts: Record<number, ContractAddresses>, dripRoute: string);
8
+ dripTokenAddress: string;
9
+ dripTokenRecyclerAddress: string;
10
+ constructor(subgraphUrl: string, priceFeedApiUrl: string, rewardsUrl: string, fastRedeemApi: string, contracts: Record<number, ContractAddresses>, dripRoute: string, dripTokenAddress?: string, dripTokenRecyclerAddress?: string);
9
11
  getSwapAndDepositContractAddress(signer: Signer): Promise<string>;
10
12
  getSmartVaultManagerAddress(signer: Signer): Promise<string>;
11
13
  }
@@ -11,10 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.DripConfig = void 0;
13
13
  const spool_v2_sdk_1 = require("@spool.fi/spool-v2-sdk");
14
+ const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
14
15
  class DripConfig {
15
- constructor(subgraphUrl, priceFeedApiUrl, rewardsUrl, fastRedeemApi, contracts, dripRoute) {
16
+ constructor(subgraphUrl, priceFeedApiUrl, rewardsUrl, fastRedeemApi, contracts, dripRoute, dripTokenAddress, dripTokenRecyclerAddress) {
16
17
  this.internalConfig = new spool_v2_sdk_1.SDKConfig(subgraphUrl, priceFeedApiUrl, rewardsUrl, fastRedeemApi, contracts);
17
18
  this.dripRoute = dripRoute;
19
+ this.dripTokenAddress = dripTokenAddress ? dripTokenAddress : NULL_ADDRESS;
20
+ this.dripTokenRecyclerAddress = dripTokenRecyclerAddress ? dripTokenRecyclerAddress : NULL_ADDRESS;
18
21
  }
19
22
  getSwapAndDepositContractAddress(signer) {
20
23
  return __awaiter(this, void 0, void 0, function* () {
package/dist/DripSdk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Signer } from 'ethers';
1
+ import { BigNumber, Signer, ethers } from 'ethers';
2
2
  import { DripConfig } from './DripConfig';
3
3
  import { AuthenticationStatus } from './types/AuthenticationStatus';
4
4
  import { UserRewards } from './types/UserRewards';
@@ -7,8 +7,11 @@ import { UserBalance } from './types/UserBalance';
7
7
  import { UserVaultBalance } from './types/UserVaultBalance';
8
8
  import { VaultClaimData } from './types/VaultClaimData';
9
9
  import { Vault } from './types/Vault';
10
+ import { LoyaltyCard } from './types/LoyaltyCard';
10
11
  export default class DripSdk {
11
12
  private dripApi;
13
+ private dripTokenContract;
14
+ private dripTokenRecyclerContract;
12
15
  private spoolSdk?;
13
16
  private signer?;
14
17
  private dripConfig;
@@ -37,6 +40,12 @@ export default class DripSdk {
37
40
  withdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>;
38
41
  claimWithdraws(vaultAddress: string): Promise<string>;
39
42
  getVaultsClaimableData(headers?: Headers): Promise<VaultClaimData>;
43
+ getBeansBalance(walletAddress: string, headers?: Headers): Promise<any>;
44
+ recycleTokens(amount: BigNumber): Promise<ethers.ContractTransaction>;
45
+ upgradeLoyaltyCard(): Promise<LoyaltyCard>;
46
+ getNextLoyaltyCard(headers?: Headers): Promise<LoyaltyCard>;
47
+ getOwnedLoyaltyCards(headers?: Headers): Promise<LoyaltyCard>;
48
+ getAllLoyaltyCards(headers?: Headers): Promise<LoyaltyCard[]>;
40
49
  approveTokenForSwapAndDeposit(tokenAddress: string, amount: string): Promise<void>;
41
50
  approveTokenForDeposit(tokenAddress: string, amount: string): Promise<void>;
42
51
  private generateRedeemBagStruct;
package/dist/DripSdk.js CHANGED
@@ -18,6 +18,8 @@ const ethers_1 = require("ethers");
18
18
  const utils_1 = require("./utils");
19
19
  const DripApi_1 = __importDefault(require("./DripApi"));
20
20
  const js_cookie_1 = __importDefault(require("js-cookie"));
21
+ const DripTokenContract_1 = __importDefault(require("./contracts/DripTokenContract"));
22
+ const DripTokenRecyclerContract_1 = __importDefault(require("./contracts/DripTokenRecyclerContract"));
21
23
  class DripSdk {
22
24
  constructor(dripConfig, signer) {
23
25
  this.signer = signer;
@@ -26,6 +28,8 @@ class DripSdk {
26
28
  this.spoolSdk = new spool_v2_sdk_1.SpoolSdk(dripConfig.internalConfig, signer);
27
29
  }
28
30
  this.dripApi = new DripApi_1.default(dripConfig.dripRoute);
31
+ this.dripTokenContract = new DripTokenContract_1.default(dripConfig.dripTokenAddress, signer);
32
+ this.dripTokenRecyclerContract = new DripTokenRecyclerContract_1.default(dripConfig.dripTokenRecyclerAddress, signer);
29
33
  }
30
34
  getAllVaults() {
31
35
  return __awaiter(this, void 0, void 0, function* () {
@@ -50,6 +54,8 @@ class DripSdk {
50
54
  updateSigner(newSigner) {
51
55
  this.signer = newSigner;
52
56
  this.spoolSdk = new spool_v2_sdk_1.SpoolSdk(this.dripConfig.internalConfig, newSigner);
57
+ this.dripTokenContract.updateSigner(newSigner);
58
+ this.dripTokenRecyclerContract.updateSigner(newSigner);
53
59
  }
54
60
  isUserAuthenticated() {
55
61
  return __awaiter(this, void 0, void 0, function* () {
@@ -324,6 +330,68 @@ class DripSdk {
324
330
  return yield this.dripApi.fetchVaultsClaimableData(authData.address, authData.token, headers);
325
331
  });
326
332
  }
333
+ getBeansBalance(walletAddress, headers) {
334
+ return __awaiter(this, void 0, void 0, function* () {
335
+ const authData = yield this.isUserAuthenticated();
336
+ if (!authData.isAuthenticated) {
337
+ throw Error(`User not authenticated: ${authData.message}`);
338
+ }
339
+ return this.dripApi.fetchBeansBalance(walletAddress, authData.token, headers);
340
+ });
341
+ }
342
+ recycleTokens(amount) {
343
+ return __awaiter(this, void 0, void 0, function* () {
344
+ const authData = yield this.isUserAuthenticated();
345
+ if (!authData.isAuthenticated) {
346
+ throw Error(`User not authenticated: ${authData.message}`);
347
+ }
348
+ const recyclerContractAddress = this.dripTokenRecyclerContract.getContractAddress();
349
+ const allowance = yield this.dripTokenContract.getAllowance(recyclerContractAddress);
350
+ if (amount.gt(allowance)) {
351
+ const approveTx = yield this.dripTokenContract.approve(recyclerContractAddress, amount);
352
+ yield approveTx.wait();
353
+ }
354
+ const recycleTx = yield this.dripTokenRecyclerContract.recycle(amount);
355
+ yield recycleTx.wait();
356
+ return recycleTx;
357
+ });
358
+ }
359
+ upgradeLoyaltyCard() {
360
+ return __awaiter(this, void 0, void 0, function* () {
361
+ const authData = yield this.isUserAuthenticated();
362
+ if (!authData.isAuthenticated) {
363
+ throw Error(`User not authenticated: ${authData.message}`);
364
+ }
365
+ return this.dripApi.upgradeLoyaltyCard(authData.token);
366
+ });
367
+ }
368
+ getNextLoyaltyCard(headers) {
369
+ return __awaiter(this, void 0, void 0, function* () {
370
+ const authData = yield this.isUserAuthenticated();
371
+ if (!authData.isAuthenticated) {
372
+ throw Error(`User not authenticated: ${authData.message}`);
373
+ }
374
+ return this.dripApi.fetchNextLoyaltyCard(authData.token, headers);
375
+ });
376
+ }
377
+ getOwnedLoyaltyCards(headers) {
378
+ return __awaiter(this, void 0, void 0, function* () {
379
+ const authData = yield this.isUserAuthenticated();
380
+ if (!authData.isAuthenticated) {
381
+ throw Error(`User not authenticated: ${authData.message}`);
382
+ }
383
+ return this.dripApi.fetchOwnedLoyaltyCards(authData.token, headers);
384
+ });
385
+ }
386
+ getAllLoyaltyCards(headers) {
387
+ return __awaiter(this, void 0, void 0, function* () {
388
+ const authData = yield this.isUserAuthenticated();
389
+ if (!authData.isAuthenticated) {
390
+ throw Error(`User not authenticated: ${authData.message}`);
391
+ }
392
+ return this.dripApi.fetchAllLoyaltyCards(authData.token, headers);
393
+ });
394
+ }
327
395
  approveTokenForSwapAndDeposit(tokenAddress, amount) {
328
396
  return __awaiter(this, void 0, void 0, function* () {
329
397
  if (!this.signer) {
@@ -0,0 +1,7 @@
1
+ import { ethers } from 'ethers';
2
+ export default abstract class BaseDripContract {
3
+ protected contract: ethers.Contract;
4
+ constructor(address: string, abi: ethers.ContractInterface, signer?: ethers.Signer);
5
+ updateSigner(newSigner: ethers.Signer): void;
6
+ getContractAddress(): string;
7
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ethers_1 = require("ethers");
4
+ class BaseDripContract {
5
+ constructor(address, abi, signer) {
6
+ this.contract = new ethers_1.ethers.Contract(address, abi, signer);
7
+ }
8
+ updateSigner(newSigner) {
9
+ this.contract = this.contract.connect(newSigner);
10
+ }
11
+ getContractAddress() {
12
+ return this.contract.address;
13
+ }
14
+ }
15
+ exports.default = BaseDripContract;
@@ -0,0 +1,7 @@
1
+ import { BigNumber, ContractTransaction, ethers } from 'ethers';
2
+ import BaseDripContract from './BaseDripContract';
3
+ export default class DripTokenContract extends BaseDripContract {
4
+ constructor(address: string, signer?: ethers.Signer);
5
+ getAllowance(spender: string): Promise<BigNumber>;
6
+ approve(spender: string, amount: BigNumber): Promise<ContractTransaction>;
7
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ethers_1 = require("ethers");
16
+ const DripTokenAbi_json_1 = __importDefault(require("./abi/DripTokenAbi.json"));
17
+ const BaseDripContract_1 = __importDefault(require("./BaseDripContract"));
18
+ class DripTokenContract extends BaseDripContract_1.default {
19
+ constructor(address, signer) {
20
+ super(address, new ethers_1.ethers.utils.Interface(DripTokenAbi_json_1.default), signer);
21
+ }
22
+ getAllowance(spender) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ if (!this.contract.signer) {
25
+ throw Error('No signer provided');
26
+ }
27
+ return yield this.contract.allowance(yield this.contract.signer.getAddress(), spender);
28
+ });
29
+ }
30
+ approve(spender, amount) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ if (!this.contract.signer) {
33
+ throw Error('No signer provided');
34
+ }
35
+ return yield this.contract.approve(spender, amount.toString());
36
+ });
37
+ }
38
+ }
39
+ exports.default = DripTokenContract;
@@ -0,0 +1,6 @@
1
+ import { BigNumber, ContractTransaction, ethers } from 'ethers';
2
+ import BaseDripContract from './BaseDripContract';
3
+ export default class DripTokenRecyclerContract extends BaseDripContract {
4
+ constructor(address: string, signer?: ethers.Signer);
5
+ recycle(amount: BigNumber): Promise<ContractTransaction>;
6
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ethers_1 = require("ethers");
16
+ const TokenRecyclerAbi_json_1 = __importDefault(require("./abi/TokenRecyclerAbi.json"));
17
+ const BaseDripContract_1 = __importDefault(require("./BaseDripContract"));
18
+ class DripTokenRecyclerContract extends BaseDripContract_1.default {
19
+ constructor(address, signer) {
20
+ super(address, new ethers_1.ethers.utils.Interface(TokenRecyclerAbi_json_1.default), signer);
21
+ }
22
+ recycle(amount) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ if (!this.contract.signer) {
25
+ throw Error('No signer provided');
26
+ }
27
+ return yield this.contract.recycle(amount.toString());
28
+ });
29
+ }
30
+ }
31
+ exports.default = DripTokenRecyclerContract;
@@ -0,0 +1,203 @@
1
+ [
2
+ {
3
+ "constant": true,
4
+ "inputs": [],
5
+ "name": "name",
6
+ "outputs": [
7
+ {
8
+ "name": "",
9
+ "type": "string"
10
+ }
11
+ ],
12
+ "payable": false,
13
+ "stateMutability": "view",
14
+ "type": "function"
15
+ },
16
+ {
17
+ "constant": true,
18
+ "inputs": [],
19
+ "name": "symbol",
20
+ "outputs": [
21
+ {
22
+ "name": "",
23
+ "type": "string"
24
+ }
25
+ ],
26
+ "payable": false,
27
+ "stateMutability": "view",
28
+ "type": "function"
29
+ },
30
+ {
31
+ "constant": true,
32
+ "inputs": [],
33
+ "name": "decimals",
34
+ "outputs": [
35
+ {
36
+ "name": "",
37
+ "type": "uint8"
38
+ }
39
+ ],
40
+ "payable": false,
41
+ "stateMutability": "view",
42
+ "type": "function"
43
+ },
44
+ {
45
+ "constant": true,
46
+ "inputs": [
47
+ {
48
+ "name": "account",
49
+ "type": "address"
50
+ }
51
+ ],
52
+ "name": "balanceOf",
53
+ "outputs": [
54
+ {
55
+ "name": "",
56
+ "type": "uint256"
57
+ }
58
+ ],
59
+ "payable": false,
60
+ "stateMutability": "view",
61
+ "type": "function"
62
+ },
63
+ {
64
+ "constant": false,
65
+ "inputs": [
66
+ {
67
+ "name": "to",
68
+ "type": "address"
69
+ },
70
+ {
71
+ "name": "value",
72
+ "type": "uint256"
73
+ }
74
+ ],
75
+ "name": "transfer",
76
+ "outputs": [
77
+ {
78
+ "name": "",
79
+ "type": "bool"
80
+ }
81
+ ],
82
+ "payable": false,
83
+ "stateMutability": "nonpayable",
84
+ "type": "function"
85
+ },
86
+ {
87
+ "constant": true,
88
+ "inputs": [
89
+ {
90
+ "name": "owner",
91
+ "type": "address"
92
+ },
93
+ {
94
+ "name": "spender",
95
+ "type": "address"
96
+ }
97
+ ],
98
+ "name": "allowance",
99
+ "outputs": [
100
+ {
101
+ "name": "",
102
+ "type": "uint256"
103
+ }
104
+ ],
105
+ "payable": false,
106
+ "stateMutability": "view",
107
+ "type": "function"
108
+ },
109
+ {
110
+ "constant": false,
111
+ "inputs": [
112
+ {
113
+ "name": "spender",
114
+ "type": "address"
115
+ },
116
+ {
117
+ "name": "value",
118
+ "type": "uint256"
119
+ }
120
+ ],
121
+ "name": "approve",
122
+ "outputs": [
123
+ {
124
+ "name": "",
125
+ "type": "bool"
126
+ }
127
+ ],
128
+ "payable": false,
129
+ "stateMutability": "nonpayable",
130
+ "type": "function"
131
+ },
132
+ {
133
+ "constant": false,
134
+ "inputs": [
135
+ {
136
+ "name": "from",
137
+ "type": "address"
138
+ },
139
+ {
140
+ "name": "to",
141
+ "type": "address"
142
+ },
143
+ {
144
+ "name": "value",
145
+ "type": "uint256"
146
+ }
147
+ ],
148
+ "name": "transferFrom",
149
+ "outputs": [
150
+ {
151
+ "name": "",
152
+ "type": "bool"
153
+ }
154
+ ],
155
+ "payable": false,
156
+ "stateMutability": "nonpayable",
157
+ "type": "function"
158
+ },
159
+ {
160
+ "anonymous": false,
161
+ "inputs": [
162
+ {
163
+ "indexed": true,
164
+ "name": "owner",
165
+ "type": "address"
166
+ },
167
+ {
168
+ "indexed": true,
169
+ "name": "spender",
170
+ "type": "address"
171
+ },
172
+ {
173
+ "indexed": false,
174
+ "name": "value",
175
+ "type": "uint256"
176
+ }
177
+ ],
178
+ "name": "Approval",
179
+ "type": "event"
180
+ },
181
+ {
182
+ "anonymous": false,
183
+ "inputs": [
184
+ {
185
+ "indexed": true,
186
+ "name": "from",
187
+ "type": "address"
188
+ },
189
+ {
190
+ "indexed": true,
191
+ "name": "to",
192
+ "type": "address"
193
+ },
194
+ {
195
+ "indexed": false,
196
+ "name": "value",
197
+ "type": "uint256"
198
+ }
199
+ ],
200
+ "name": "Transfer",
201
+ "type": "event"
202
+ }
203
+ ]
@@ -0,0 +1 @@
1
+ [{ "inputs": [{ "internalType": "contract IERC20", "name": "token", "type": "address" }, { "internalType": "address", "name": "admin", "type": "address" }, { "internalType": "address", "name": "beneficiaryAddress_", "type": "address" }, { "internalType": "uint256", "name": "beneficiaryShare_", "type": "uint256" }, { "internalType": "uint256", "name": "recycledTokenToRewardRatio_", "type": "uint256" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "AccessControlBadConfirmation", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }, { "internalType": "bytes32", "name": "neededRole", "type": "bytes32" }], "name": "AccessControlUnauthorizedAccount", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "target", "type": "address" }], "name": "AddressEmptyCode", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "AddressInsufficientBalance", "type": "error" }, { "inputs": [], "name": "FailedInnerCall", "type": "error" }, { "inputs": [], "name": "ReentrancyGuardReentrantCall", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "token", "type": "address" }], "name": "SafeERC20FailedOperation", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "recycledAmount", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "rewardAmount", "type": "uint256" }], "name": "Recycled", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" }], "name": "RoleAdminChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "RoleGranted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "RoleRevoked", "type": "event" }, { "inputs": [], "name": "ADMIN_ROLE", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "BENEFICIARY_SHARE_PRECISION", "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "DEFAULT_ADMIN_ROLE", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "addressToReward", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "beneficiaryAddress", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "beneficiaryShare", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], "name": "getRoleAdmin", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "grantRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "hasRole", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "recycle", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "recycledToken", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "recycledTokenToRewardRatio", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "callerConfirmation", "type": "address" }], "name": "renounceRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "revokeRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "rewardDecimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "beneficiaryAddress_", "type": "address" }], "name": "setBeneficiaryAddress", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "beneficiaryShare_", "type": "uint256" }], "name": "setBeneficiaryShare", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "recycledTokenToRewardRatio_", "type": "uint256" }], "name": "setRecycledTokenToRewardRatio", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }], "name": "supportsInterface", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "withdrawETH", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "contract IERC20", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "withdrawToken", "outputs": [], "stateMutability": "nonpayable", "type": "function" }]
package/dist/test.js CHANGED
@@ -17,7 +17,30 @@ 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
- const privKey = '6ffc226f7b7769e27124317372c9dbb579a324e67e97bf07131bf2f59ec0f4fe';
20
+ const account2 = "0x9E9B6899Ea314dD553A99f4F49440d2CeD2b2848"; // privKey 92eb90257aa76cc56ead18dd52dd3433689712ebe7356a70308b760bfcbdd787
21
+ // const privKey: string = '6ffc226f7b7769e27124317372c9dbb579a324e67e97bf07131bf2f59ec0f4fe';
22
+ const privKey = '92eb90257aa76cc56ead18dd52dd3433689712ebe7356a70308b760bfcbdd787';
23
+ const testConfigParams = {
24
+ subgraphUrl: 'https://subgraph.satsuma-prod.com/49eb322da234/solidant/spool-v2-sepolia/api',
25
+ priceFeedApiUrl: 'https://pricefeed.dev.spool.fi/',
26
+ rewardsUrl: 'https://rewards.dev.spool.fi/sepolia',
27
+ fastRedeemApi: 'https://fastwithdraw.dev.spool.fi/sepolia',
28
+ spoolContracts: {
29
+ 11155111: {
30
+ ISmartVaultManager: '0x2638d6c0b4EF6Dee04050fA0B07CA62500435747',
31
+ IDepositSwap: '0x5FB08e00DE169f041711206A0995410884080177',
32
+ ISmartVaultFactory: '0x86BB0376929218ba1cb825cE2ebE801bFCcD8149',
33
+ IDepositManager: '0xfA37dd47F3596681C39D3a1b55474595BB591dc9',
34
+ IRewardManager: '0xcE7F66BD505a80129Ef25b06207Ac49620A55522',
35
+ IStrategyRegistry: '0xf978853Db777d00b1130Ea21d8d98E8710b0Bc56',
36
+ ISpoolLens: '0x33Df6cf08Fbb10047e318989fE687294CD45A7B4',
37
+ }
38
+ },
39
+ dripContracts: {
40
+ DripTokenAddress: '0xc9C66052327523d6A7a2ee5D50CF07e4415e27c7', // Sepolia contract address
41
+ DripTokenRecyclerAddress: '0xe943A1320402fcf41cDc04275e842654165dAB78' // Sepolia contract address
42
+ }
43
+ };
21
44
  const configParams = {
22
45
  subgraphUrl: 'https://subgraph.satsuma-prod.com/49eb322da234/solidant/spool-v2-sepolia/api',
23
46
  priceFeedApiUrl: 'https://pricefeed.dev.spool.fi/',
@@ -34,6 +57,10 @@ const configParams = {
34
57
  ISpoolLens: '0x33Df6cf08Fbb10047e318989fE687294CD45A7B4',
35
58
  },
36
59
  },
60
+ dripContracts: {
61
+ DripTokenAddress: '0xc9C66052327523d6A7a2ee5D50CF07e4415e27c7', // Sepolia contract address
62
+ DripTokenRecyclerAddress: '0xe943A1320402fcf41cDc04275e842654165dAB78' // Sepolia contract address
63
+ }
37
64
  };
38
65
  const provider = new ethers_1.ethers.providers.StaticJsonRpcProvider('https://rpc.ankr.com/eth_sepolia', 11155111);
39
66
  exports.signer = new ethers_1.ethers.Wallet(privKey, provider);
@@ -43,13 +70,21 @@ const daiVaultPerq = '0x1977efe478ba17da8be6e93fdfadbd3055d30111'; // DAI PERQ S
43
70
  const usdcVaultPerq = '0xf9795bfbf7c40981c372d0fb25a87e0b694c4fcd'; // USDC PERQ SEPOLIA
44
71
  const daiTokenAddress = '0x2a3a3872c242c35093a8fc48dac838c4b2d24a03'; // DAI TOKEN
45
72
  const usdcTokenAddress = '0xa6b92fcd4ee124353c8a6acf1edb574f46f3f8df'; // USDC TOKEN
46
- const dripSdk = new DripSdk_1.default(new DripConfig_1.DripConfig(configParams.subgraphUrl, configParams.priceFeedApiUrl, configParams.rewardsUrl, configParams.fastRedeemApi, configParams.contracts, 'https://dev.dripfi.io'), exports.signer);
73
+ const dripSdk = new DripSdk_1.default(new DripConfig_1.DripConfig(testConfigParams.subgraphUrl, testConfigParams.priceFeedApiUrl, testConfigParams.rewardsUrl, testConfigParams.fastRedeemApi, testConfigParams.spoolContracts, 'https://localhost:3000', testConfigParams.dripContracts.DripTokenAddress, testConfigParams.dripContracts.DripTokenRecyclerAddress), exports.signer);
74
+ // 0x689Baa4821865Cb328F5E847fB6133DEB315A832
75
+ // 0x9E9B6899Ea314dD553A99f4F49440d2CeD2b2848
47
76
  function main() {
48
77
  return __awaiter(this, void 0, void 0, function* () {
49
78
  try {
50
79
  // const res = await dripSdk.deposit(usdcTokenAddress,usdcVaultPerq, '1000');
51
- const res = yield dripSdk.withdraw(usdcVaultPerq, '1');
52
- console.log(res);
80
+ // const res = await dripSdk.withdraw(usdcVaultPerq, '1');
81
+ // await dripSdk.authenticate()
82
+ // const res = await dripSdk.getDripTokenBalance(account2)
83
+ // const res = await dripSdk.getNextLoyaltyCard()
84
+ // const res = await dripSdk.getOwnedLoyaltyCards()
85
+ // const res = await dripSdk.getBeansBalance()
86
+ // const res = await dripSdk.recycleTokens()
87
+ // const res = await dripSdk.upgradeLoyaltyCard()
53
88
  }
54
89
  catch (error) {
55
90
  console.log(`Main error: ${error}`);
@@ -35,6 +35,7 @@ export type DeployedProject = {
35
35
  coingeckoId?: string;
36
36
  projectType: string;
37
37
  isFeatured: boolean;
38
+ tgePrice?: number;
38
39
  };
39
40
  export type ProjectBacker = {
40
41
  name: string;
@@ -0,0 +1,10 @@
1
+ declare enum ELoyaltyCardTier {
2
+ White = "White",
3
+ Blue = "Blue",
4
+ Bronze = "Bronze",
5
+ Silver = "Silver",
6
+ Gold = "Gold",
7
+ Platinum = "Platinum",
8
+ Black = "Black"
9
+ }
10
+ export default ELoyaltyCardTier;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ELoyaltyCardTier;
4
+ (function (ELoyaltyCardTier) {
5
+ ELoyaltyCardTier["White"] = "White";
6
+ ELoyaltyCardTier["Blue"] = "Blue";
7
+ ELoyaltyCardTier["Bronze"] = "Bronze";
8
+ ELoyaltyCardTier["Silver"] = "Silver";
9
+ ELoyaltyCardTier["Gold"] = "Gold";
10
+ ELoyaltyCardTier["Platinum"] = "Platinum";
11
+ ELoyaltyCardTier["Black"] = "Black";
12
+ })(ELoyaltyCardTier || (ELoyaltyCardTier = {}));
13
+ exports.default = ELoyaltyCardTier;
@@ -0,0 +1,9 @@
1
+ import { BigNumber } from 'ethers';
2
+ import ELoyaltyCardTier from './ELoyaltyCardTier';
3
+ export type LoyaltyCard = {
4
+ id: string;
5
+ tier: ELoyaltyCardTier;
6
+ level: number;
7
+ cost: BigNumber;
8
+ boost: number;
9
+ };
@@ -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.1.14",
3
+ "version": "1.1.16",
4
4
  "description": "Drip SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",