@dripfi/drip-sdk 1.2.2 → 1.2.4
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 +3 -1
- package/dist/DripApi.js +14 -6
- package/dist/DripConfig.js +2 -2
- package/dist/DripSdk.d.ts +6 -3
- package/dist/DripSdk.js +22 -12
- package/dist/contracts/DripTokenRecyclerContract.d.ts +1 -1
- package/dist/contracts/DripTokenRecyclerContract.js +3 -3
- package/dist/contracts/abi/TokenRecyclerAbi.json +60 -31
- package/dist/test.js +2 -2
- package/dist/types/PerqToBeansSwapInfo.d.ts +7 -0
- package/dist/types/PerqToBeansSwapInfo.js +2 -0
- package/package.json +1 -1
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;
|
@@ -32,7 +33,7 @@ export default class DripApi {
|
|
32
33
|
fetchFastWithdrawNFTs(vaultAddress: string, walletAddress: string, token: string, headers?: Headers): Promise<QLFastRedeem[]>;
|
33
34
|
fetchUserRewards(walletAddress: string, token: string, headers?: Headers): Promise<UserRewards>;
|
34
35
|
fetchVaultsClaimableData(walletAddress: string, token: string, headers?: Headers): Promise<VaultClaimData>;
|
35
|
-
fetchAllLoyaltyCards(
|
36
|
+
fetchAllLoyaltyCards(): Promise<any>;
|
36
37
|
fetchOwnedLoyaltyCards(token: string, headers?: Headers): Promise<{
|
37
38
|
id: any;
|
38
39
|
tier: any;
|
@@ -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
@@ -356,13 +356,9 @@ class DripApi {
|
|
356
356
|
}
|
357
357
|
});
|
358
358
|
}
|
359
|
-
fetchAllLoyaltyCards(
|
359
|
+
fetchAllLoyaltyCards() {
|
360
360
|
return __awaiter(this, void 0, void 0, function* () {
|
361
|
-
const
|
362
|
-
reqHeaders.append(AUTHORIZATION_HEADER, token);
|
363
|
-
const res = yield fetch(`${this.route}/api-be/api/loyaltyCards`, {
|
364
|
-
headers: reqHeaders,
|
365
|
-
});
|
361
|
+
const res = yield fetch(`${this.route}/api-be/api/loyaltyCards`);
|
366
362
|
const data = yield res.json();
|
367
363
|
const mappedData = data.map((element) => {
|
368
364
|
return {
|
@@ -485,5 +481,17 @@ class DripApi {
|
|
485
481
|
}
|
486
482
|
});
|
487
483
|
}
|
484
|
+
getSwapPerqForBeansInfo() {
|
485
|
+
return __awaiter(this, void 0, void 0, function* () {
|
486
|
+
const res = yield fetch(`${this.route}/api-be/api/swap/price`, {});
|
487
|
+
if (res.ok) {
|
488
|
+
const data = yield res.json();
|
489
|
+
return data;
|
490
|
+
}
|
491
|
+
else {
|
492
|
+
throw Error(`${yield res.text()}`);
|
493
|
+
}
|
494
|
+
});
|
495
|
+
}
|
488
496
|
}
|
489
497
|
exports.default = DripApi;
|
package/dist/DripConfig.js
CHANGED
@@ -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 = '
|
23
|
-
const DRIP_TOKEN_ADDRESS_SEPOLIA = '
|
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,16 +46,17 @@ 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(
|
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>;
|
51
|
-
getAllLoyaltyCards(
|
53
|
+
getAllLoyaltyCards(): Promise<LoyaltyCard[]>;
|
52
54
|
getLoyaltyCardBoost(rewardId: string, headers?: Headers): Promise<number>;
|
53
55
|
approveTokenForRecycler(tokenAddress: string, amount: string): Promise<string>;
|
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(
|
357
|
-
return __awaiter(this,
|
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(
|
366
|
-
const amountWithDecimals =
|
367
|
-
const recycleTx = yield this.dripTokenRecyclerContract.recycle(
|
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
|
});
|
@@ -396,13 +405,9 @@ class DripSdk {
|
|
396
405
|
return this.dripApi.fetchOwnedLoyaltyCards(authData.token, headers);
|
397
406
|
});
|
398
407
|
}
|
399
|
-
getAllLoyaltyCards(
|
408
|
+
getAllLoyaltyCards() {
|
400
409
|
return __awaiter(this, void 0, void 0, function* () {
|
401
|
-
|
402
|
-
if (!authData.isAuthenticated) {
|
403
|
-
throw Error(`User not authenticated: ${authData.message}`);
|
404
|
-
}
|
405
|
-
return this.dripApi.fetchAllLoyaltyCards(authData.token, headers);
|
410
|
+
return this.dripApi.fetchAllLoyaltyCards();
|
406
411
|
});
|
407
412
|
}
|
408
413
|
getLoyaltyCardBoost(rewardId, headers) {
|
@@ -422,7 +427,7 @@ class DripSdk {
|
|
422
427
|
if (this.dripConfig.dripTokenRecyclerAddress === DripConfig_1.NULL_ADDRESS) {
|
423
428
|
throw Error('Recycler contract address not defined');
|
424
429
|
}
|
425
|
-
return yield this.approveToken(tokenAddress, amount
|
430
|
+
return yield this.approveToken(tokenAddress, amount, this.dripConfig.dripTokenRecyclerAddress);
|
426
431
|
});
|
427
432
|
}
|
428
433
|
approveTokenForSwapAndDeposit(tokenAddress, amount) {
|
@@ -446,6 +451,11 @@ class DripSdk {
|
|
446
451
|
getDripTokenContractAddress() {
|
447
452
|
return this.dripConfig.dripTokenAddress;
|
448
453
|
}
|
454
|
+
getSwapPerqForBeansInfo() {
|
455
|
+
return __awaiter(this, void 0, void 0, function* () {
|
456
|
+
return this.dripApi.getSwapPerqForBeansInfo();
|
457
|
+
});
|
458
|
+
}
|
449
459
|
generateRedeemBagStruct(vault, signerAddress, amountToWithdraw) {
|
450
460
|
return __awaiter(this, void 0, void 0, function* () {
|
451
461
|
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(
|
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(
|
24
|
-
return __awaiter(this,
|
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(
|
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": "
|
16
|
+
"name": "oracle",
|
17
17
|
"type": "address"
|
18
18
|
},
|
19
19
|
{
|
20
|
-
"internalType": "
|
21
|
-
"name": "
|
22
|
-
"type": "
|
20
|
+
"internalType": "address",
|
21
|
+
"name": "beneficiaryAddress_",
|
22
|
+
"type": "address"
|
23
23
|
},
|
24
24
|
{
|
25
25
|
"internalType": "uint256",
|
26
|
-
"name": "
|
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: '
|
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: '
|
61
|
+
DripTokenAddress: '0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E', // Sepolia contract address
|
62
62
|
DripTokenRecyclerAddress: '0xe943A1320402fcf41cDc04275e842654165dAB78' // Sepolia contract address
|
63
63
|
}
|
64
64
|
};
|