@dripfi/drip-sdk 1.1.15 → 1.1.17
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 +5 -0
- package/dist/DripApi.js +56 -0
- package/dist/DripConfig.d.ts +4 -1
- package/dist/DripConfig.js +5 -2
- package/dist/DripSdk.d.ts +11 -1
- package/dist/DripSdk.js +81 -0
- package/dist/contracts/BaseDripContract.d.ts +7 -0
- package/dist/contracts/BaseDripContract.js +15 -0
- package/dist/contracts/DripTokenContract.d.ts +7 -0
- package/dist/contracts/DripTokenContract.js +39 -0
- package/dist/contracts/DripTokenRecyclerContract.d.ts +6 -0
- package/dist/contracts/DripTokenRecyclerContract.js +31 -0
- package/dist/contracts/abi/DripTokenAbi.json +203 -0
- package/dist/contracts/abi/TokenRecyclerAbi.json +1 -0
- package/dist/test.js +39 -4
- package/dist/types/ELoyaltyCardTier.d.ts +10 -0
- package/dist/types/ELoyaltyCardTier.js +13 -0
- package/dist/types/LoyaltyCard.d.ts +9 -0
- package/dist/types/LoyaltyCard.js +2 -0
- package/package.json +1 -1
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;
|
package/dist/DripConfig.d.ts
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
import { ContractAddresses, SDKConfig } from '@spool.fi/spool-v2-sdk';
|
2
2
|
import { Signer } from 'ethers';
|
3
|
+
export declare const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
|
3
4
|
export declare class DripConfig {
|
4
5
|
internalConfig: SDKConfig;
|
5
6
|
dripRoute: string;
|
6
7
|
swapAndDepositContractAddress: string | undefined;
|
7
8
|
smartVaultManagerAddress: string | undefined;
|
8
|
-
|
9
|
+
dripTokenAddress: string;
|
10
|
+
dripTokenRecyclerAddress: string;
|
11
|
+
constructor(subgraphUrl: string, priceFeedApiUrl: string, rewardsUrl: string, fastRedeemApi: string, contracts: Record<number, ContractAddresses>, dripRoute: string, dripTokenAddress?: string, dripTokenRecyclerAddress?: string);
|
9
12
|
getSwapAndDepositContractAddress(signer: Signer): Promise<string>;
|
10
13
|
getSmartVaultManagerAddress(signer: Signer): Promise<string>;
|
11
14
|
}
|
package/dist/DripConfig.js
CHANGED
@@ -9,12 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.DripConfig = void 0;
|
12
|
+
exports.DripConfig = exports.NULL_ADDRESS = void 0;
|
13
13
|
const spool_v2_sdk_1 = require("@spool.fi/spool-v2-sdk");
|
14
|
+
exports.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 : exports.NULL_ADDRESS;
|
20
|
+
this.dripTokenRecyclerAddress = dripTokenRecyclerAddress ? dripTokenRecyclerAddress : exports.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 } 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,13 @@ 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<string>;
|
45
|
+
upgradeLoyaltyCard(): Promise<LoyaltyCard>;
|
46
|
+
getNextLoyaltyCard(headers?: Headers): Promise<LoyaltyCard>;
|
47
|
+
getOwnedLoyaltyCards(headers?: Headers): Promise<LoyaltyCard>;
|
48
|
+
getAllLoyaltyCards(headers?: Headers): Promise<LoyaltyCard[]>;
|
49
|
+
approveTokenForRecycler(tokenAddress: string, amount: string): Promise<void>;
|
40
50
|
approveTokenForSwapAndDeposit(tokenAddress: string, amount: string): Promise<void>;
|
41
51
|
approveTokenForDeposit(tokenAddress: string, amount: string): Promise<void>;
|
42
52
|
private generateRedeemBagStruct;
|
package/dist/DripSdk.js
CHANGED
@@ -15,9 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const web3_token_1 = __importDefault(require("web3-token"));
|
16
16
|
const spool_v2_sdk_1 = require("@spool.fi/spool-v2-sdk");
|
17
17
|
const ethers_1 = require("ethers");
|
18
|
+
const DripConfig_1 = require("./DripConfig");
|
18
19
|
const utils_1 = require("./utils");
|
19
20
|
const DripApi_1 = __importDefault(require("./DripApi"));
|
20
21
|
const js_cookie_1 = __importDefault(require("js-cookie"));
|
22
|
+
const DripTokenContract_1 = __importDefault(require("./contracts/DripTokenContract"));
|
23
|
+
const DripTokenRecyclerContract_1 = __importDefault(require("./contracts/DripTokenRecyclerContract"));
|
21
24
|
class DripSdk {
|
22
25
|
constructor(dripConfig, signer) {
|
23
26
|
this.signer = signer;
|
@@ -26,6 +29,8 @@ class DripSdk {
|
|
26
29
|
this.spoolSdk = new spool_v2_sdk_1.SpoolSdk(dripConfig.internalConfig, signer);
|
27
30
|
}
|
28
31
|
this.dripApi = new DripApi_1.default(dripConfig.dripRoute);
|
32
|
+
this.dripTokenContract = new DripTokenContract_1.default(dripConfig.dripTokenAddress, signer);
|
33
|
+
this.dripTokenRecyclerContract = new DripTokenRecyclerContract_1.default(dripConfig.dripTokenRecyclerAddress, signer);
|
29
34
|
}
|
30
35
|
getAllVaults() {
|
31
36
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -50,6 +55,8 @@ class DripSdk {
|
|
50
55
|
updateSigner(newSigner) {
|
51
56
|
this.signer = newSigner;
|
52
57
|
this.spoolSdk = new spool_v2_sdk_1.SpoolSdk(this.dripConfig.internalConfig, newSigner);
|
58
|
+
this.dripTokenContract.updateSigner(newSigner);
|
59
|
+
this.dripTokenRecyclerContract.updateSigner(newSigner);
|
53
60
|
}
|
54
61
|
isUserAuthenticated() {
|
55
62
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -324,6 +331,80 @@ class DripSdk {
|
|
324
331
|
return yield this.dripApi.fetchVaultsClaimableData(authData.address, authData.token, headers);
|
325
332
|
});
|
326
333
|
}
|
334
|
+
getBeansBalance(walletAddress, headers) {
|
335
|
+
return __awaiter(this, void 0, void 0, function* () {
|
336
|
+
const authData = yield this.isUserAuthenticated();
|
337
|
+
if (!authData.isAuthenticated) {
|
338
|
+
throw Error(`User not authenticated: ${authData.message}`);
|
339
|
+
}
|
340
|
+
return this.dripApi.fetchBeansBalance(walletAddress, authData.token, headers);
|
341
|
+
});
|
342
|
+
}
|
343
|
+
recycleTokens(amount) {
|
344
|
+
return __awaiter(this, void 0, void 0, function* () {
|
345
|
+
const authData = yield this.isUserAuthenticated();
|
346
|
+
if (!authData.isAuthenticated) {
|
347
|
+
throw Error(`User not authenticated: ${authData.message}`);
|
348
|
+
}
|
349
|
+
if (this.dripConfig.dripTokenRecyclerAddress === DripConfig_1.NULL_ADDRESS) {
|
350
|
+
throw Error('Recycler contract address not defined');
|
351
|
+
}
|
352
|
+
const recycleTx = yield this.dripTokenRecyclerContract.recycle(amount);
|
353
|
+
const receipt = yield recycleTx.wait();
|
354
|
+
return receipt.transactionHash;
|
355
|
+
});
|
356
|
+
}
|
357
|
+
upgradeLoyaltyCard() {
|
358
|
+
return __awaiter(this, void 0, void 0, function* () {
|
359
|
+
const authData = yield this.isUserAuthenticated();
|
360
|
+
if (!authData.isAuthenticated) {
|
361
|
+
throw Error(`User not authenticated: ${authData.message}`);
|
362
|
+
}
|
363
|
+
return this.dripApi.upgradeLoyaltyCard(authData.token);
|
364
|
+
});
|
365
|
+
}
|
366
|
+
getNextLoyaltyCard(headers) {
|
367
|
+
return __awaiter(this, void 0, void 0, function* () {
|
368
|
+
const authData = yield this.isUserAuthenticated();
|
369
|
+
if (!authData.isAuthenticated) {
|
370
|
+
throw Error(`User not authenticated: ${authData.message}`);
|
371
|
+
}
|
372
|
+
return this.dripApi.fetchNextLoyaltyCard(authData.token, headers);
|
373
|
+
});
|
374
|
+
}
|
375
|
+
getOwnedLoyaltyCards(headers) {
|
376
|
+
return __awaiter(this, void 0, void 0, function* () {
|
377
|
+
const authData = yield this.isUserAuthenticated();
|
378
|
+
if (!authData.isAuthenticated) {
|
379
|
+
throw Error(`User not authenticated: ${authData.message}`);
|
380
|
+
}
|
381
|
+
return this.dripApi.fetchOwnedLoyaltyCards(authData.token, headers);
|
382
|
+
});
|
383
|
+
}
|
384
|
+
getAllLoyaltyCards(headers) {
|
385
|
+
return __awaiter(this, void 0, void 0, function* () {
|
386
|
+
const authData = yield this.isUserAuthenticated();
|
387
|
+
if (!authData.isAuthenticated) {
|
388
|
+
throw Error(`User not authenticated: ${authData.message}`);
|
389
|
+
}
|
390
|
+
return this.dripApi.fetchAllLoyaltyCards(authData.token, headers);
|
391
|
+
});
|
392
|
+
}
|
393
|
+
approveTokenForRecycler(tokenAddress, amount) {
|
394
|
+
return __awaiter(this, void 0, void 0, function* () {
|
395
|
+
if (!this.signer) {
|
396
|
+
throw Error('No signer provided');
|
397
|
+
}
|
398
|
+
if (this.dripConfig.dripTokenRecyclerAddress === DripConfig_1.NULL_ADDRESS) {
|
399
|
+
throw Error('Recycler contract address not defined');
|
400
|
+
}
|
401
|
+
const decimals = yield this.getERC20Precission(tokenAddress);
|
402
|
+
const amountToApprove = ethers_1.ethers.utils.parseUnits(amount.toString(), decimals);
|
403
|
+
const erc20Instance = spool_v2_sdk_1.ERC20__factory.connect(tokenAddress, this.signer);
|
404
|
+
const approveTx = yield erc20Instance.approve(this.dripConfig.dripTokenRecyclerAddress, amountToApprove);
|
405
|
+
yield approveTx.wait();
|
406
|
+
});
|
407
|
+
}
|
327
408
|
approveTokenForSwapAndDeposit(tokenAddress, amount) {
|
328
409
|
return __awaiter(this, void 0, void 0, function* () {
|
329
410
|
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
|
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(
|
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 =
|
52
|
-
|
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}`);
|
@@ -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;
|