@dripfi/drip-sdk 1.4.9 → 1.4.10
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/README.md +206 -45
- package/dist/PerqApi.d.ts +22 -20
- package/dist/PerqApi.js +127 -92
- package/dist/PerqSdk.d.ts +35 -70
- package/dist/PerqSdk.js +51 -534
- package/dist/abi/ERC20.json +222 -0
- package/dist/contracts/ERC20TokenContract.d.ts +10 -0
- package/dist/contracts/ERC20TokenContract.js +34 -0
- package/dist/contracts/PerqSwapAndRecyclerContract.d.ts +3 -2
- package/dist/contracts/PerqSwapAndRecyclerContract.js +2 -2
- package/dist/contracts/PerqTokenRecyclerContract.d.ts +3 -2
- package/dist/contracts/PerqTokenRecyclerContract.js +2 -2
- package/dist/contracts/PerqVestingContract.d.ts +3 -2
- package/dist/contracts/PerqVestingContract.js +2 -2
- package/dist/subpackages/LitePackage.d.ts +16 -0
- package/dist/subpackages/LitePackage.js +102 -0
- package/dist/subpackages/LoyaltyCardsPackage.d.ts +12 -0
- package/dist/subpackages/LoyaltyCardsPackage.js +34 -0
- package/dist/subpackages/PoolsPackage.d.ts +16 -0
- package/dist/subpackages/PoolsPackage.js +52 -0
- package/dist/subpackages/RecyclerPackage.d.ts +13 -0
- package/dist/subpackages/RecyclerPackage.js +87 -0
- package/dist/subpackages/SignHandlerPackage.d.ts +8 -0
- package/dist/subpackages/SignHandlerPackage.js +33 -0
- package/dist/subpackages/TokenUtilsPackage.d.ts +13 -0
- package/dist/subpackages/TokenUtilsPackage.js +66 -0
- package/dist/subpackages/UserPackage.d.ts +10 -0
- package/dist/subpackages/UserPackage.js +36 -0
- package/dist/subpackages/V2Package.d.ts +24 -0
- package/dist/subpackages/V2Package.js +207 -0
- package/dist/subpackages/VestingPackage.d.ts +14 -0
- package/dist/subpackages/VestingPackage.js +112 -0
- package/dist/types/ChainId.d.ts +5 -0
- package/dist/types/ChainId.js +7 -0
- package/dist/types/DeployedProject.d.ts +3 -0
- package/dist/types/DetailedProjectData.d.ts +34 -0
- package/dist/types/DetailedProjectData.js +2 -0
- package/dist/types/Earnings.d.ts +11 -0
- package/dist/types/Earnings.js +2 -0
- package/dist/types/LinkWalletPayload.d.ts +4 -2
- package/dist/types/LinkedPodWallets.d.ts +5 -0
- package/dist/types/LinkedPodWallets.js +2 -0
- package/dist/types/MigrationOption.d.ts +6 -0
- package/dist/types/MigrationOption.js +2 -0
- package/dist/types/MyPerqData.d.ts +10 -10
- package/dist/types/PerqConfig.d.ts +5 -3
- package/dist/types/PerqConfig.js +12 -10
- package/dist/types/ReducedProjectData.d.ts +21 -0
- package/dist/types/ReducedProjectData.js +2 -0
- package/dist/types/VaultData.d.ts +33 -0
- package/dist/types/VaultData.js +2 -0
- package/dist/types/index.d.ts +8 -2
- package/package.json +2 -2
@@ -0,0 +1,222 @@
|
|
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": false,
|
18
|
+
"inputs": [
|
19
|
+
{
|
20
|
+
"name": "_spender",
|
21
|
+
"type": "address"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "_value",
|
25
|
+
"type": "uint256"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"name": "approve",
|
29
|
+
"outputs": [
|
30
|
+
{
|
31
|
+
"name": "",
|
32
|
+
"type": "bool"
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"payable": false,
|
36
|
+
"stateMutability": "nonpayable",
|
37
|
+
"type": "function"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"constant": true,
|
41
|
+
"inputs": [],
|
42
|
+
"name": "totalSupply",
|
43
|
+
"outputs": [
|
44
|
+
{
|
45
|
+
"name": "",
|
46
|
+
"type": "uint256"
|
47
|
+
}
|
48
|
+
],
|
49
|
+
"payable": false,
|
50
|
+
"stateMutability": "view",
|
51
|
+
"type": "function"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"constant": false,
|
55
|
+
"inputs": [
|
56
|
+
{
|
57
|
+
"name": "_from",
|
58
|
+
"type": "address"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"name": "_to",
|
62
|
+
"type": "address"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "_value",
|
66
|
+
"type": "uint256"
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"name": "transferFrom",
|
70
|
+
"outputs": [
|
71
|
+
{
|
72
|
+
"name": "",
|
73
|
+
"type": "bool"
|
74
|
+
}
|
75
|
+
],
|
76
|
+
"payable": false,
|
77
|
+
"stateMutability": "nonpayable",
|
78
|
+
"type": "function"
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"constant": true,
|
82
|
+
"inputs": [],
|
83
|
+
"name": "decimals",
|
84
|
+
"outputs": [
|
85
|
+
{
|
86
|
+
"name": "",
|
87
|
+
"type": "uint8"
|
88
|
+
}
|
89
|
+
],
|
90
|
+
"payable": false,
|
91
|
+
"stateMutability": "view",
|
92
|
+
"type": "function"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"constant": true,
|
96
|
+
"inputs": [
|
97
|
+
{
|
98
|
+
"name": "_owner",
|
99
|
+
"type": "address"
|
100
|
+
}
|
101
|
+
],
|
102
|
+
"name": "balanceOf",
|
103
|
+
"outputs": [
|
104
|
+
{
|
105
|
+
"name": "balance",
|
106
|
+
"type": "uint256"
|
107
|
+
}
|
108
|
+
],
|
109
|
+
"payable": false,
|
110
|
+
"stateMutability": "view",
|
111
|
+
"type": "function"
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"constant": true,
|
115
|
+
"inputs": [],
|
116
|
+
"name": "symbol",
|
117
|
+
"outputs": [
|
118
|
+
{
|
119
|
+
"name": "",
|
120
|
+
"type": "string"
|
121
|
+
}
|
122
|
+
],
|
123
|
+
"payable": false,
|
124
|
+
"stateMutability": "view",
|
125
|
+
"type": "function"
|
126
|
+
},
|
127
|
+
{
|
128
|
+
"constant": false,
|
129
|
+
"inputs": [
|
130
|
+
{
|
131
|
+
"name": "_to",
|
132
|
+
"type": "address"
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"name": "_value",
|
136
|
+
"type": "uint256"
|
137
|
+
}
|
138
|
+
],
|
139
|
+
"name": "transfer",
|
140
|
+
"outputs": [
|
141
|
+
{
|
142
|
+
"name": "",
|
143
|
+
"type": "bool"
|
144
|
+
}
|
145
|
+
],
|
146
|
+
"payable": false,
|
147
|
+
"stateMutability": "nonpayable",
|
148
|
+
"type": "function"
|
149
|
+
},
|
150
|
+
{
|
151
|
+
"constant": true,
|
152
|
+
"inputs": [
|
153
|
+
{
|
154
|
+
"name": "_owner",
|
155
|
+
"type": "address"
|
156
|
+
},
|
157
|
+
{
|
158
|
+
"name": "_spender",
|
159
|
+
"type": "address"
|
160
|
+
}
|
161
|
+
],
|
162
|
+
"name": "allowance",
|
163
|
+
"outputs": [
|
164
|
+
{
|
165
|
+
"name": "",
|
166
|
+
"type": "uint256"
|
167
|
+
}
|
168
|
+
],
|
169
|
+
"payable": false,
|
170
|
+
"stateMutability": "view",
|
171
|
+
"type": "function"
|
172
|
+
},
|
173
|
+
{
|
174
|
+
"payable": true,
|
175
|
+
"stateMutability": "payable",
|
176
|
+
"type": "fallback"
|
177
|
+
},
|
178
|
+
{
|
179
|
+
"anonymous": false,
|
180
|
+
"inputs": [
|
181
|
+
{
|
182
|
+
"indexed": true,
|
183
|
+
"name": "owner",
|
184
|
+
"type": "address"
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"indexed": true,
|
188
|
+
"name": "spender",
|
189
|
+
"type": "address"
|
190
|
+
},
|
191
|
+
{
|
192
|
+
"indexed": false,
|
193
|
+
"name": "value",
|
194
|
+
"type": "uint256"
|
195
|
+
}
|
196
|
+
],
|
197
|
+
"name": "Approval",
|
198
|
+
"type": "event"
|
199
|
+
},
|
200
|
+
{
|
201
|
+
"anonymous": false,
|
202
|
+
"inputs": [
|
203
|
+
{
|
204
|
+
"indexed": true,
|
205
|
+
"name": "from",
|
206
|
+
"type": "address"
|
207
|
+
},
|
208
|
+
{
|
209
|
+
"indexed": true,
|
210
|
+
"name": "to",
|
211
|
+
"type": "address"
|
212
|
+
},
|
213
|
+
{
|
214
|
+
"indexed": false,
|
215
|
+
"name": "value",
|
216
|
+
"type": "uint256"
|
217
|
+
}
|
218
|
+
],
|
219
|
+
"name": "Transfer",
|
220
|
+
"type": "event"
|
221
|
+
}
|
222
|
+
]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { BigNumber, BigNumberish, ethers, Signer } from 'ethers';
|
2
|
+
export default class ERC20TokenContract {
|
3
|
+
address: string;
|
4
|
+
contract: ethers.Contract;
|
5
|
+
constructor(address: string, signer: Signer);
|
6
|
+
getPrecission(): Promise<number>;
|
7
|
+
getAllowance(owner: string, spender: string): Promise<BigNumber>;
|
8
|
+
approveToken(spender: string, parsedAmount: BigNumberish): Promise<string>;
|
9
|
+
transfer(receiver: string, parsedAmount: string): Promise<string>;
|
10
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const ethers_1 = require("ethers");
|
7
|
+
const ERC20_json_1 = __importDefault(require("../abi/ERC20.json"));
|
8
|
+
class ERC20TokenContract {
|
9
|
+
address;
|
10
|
+
contract;
|
11
|
+
constructor(address, signer) {
|
12
|
+
this.address = address;
|
13
|
+
this.contract = new ethers_1.ethers.Contract(address, ERC20_json_1.default, signer);
|
14
|
+
}
|
15
|
+
async getPrecission() {
|
16
|
+
const decimals = await this.contract.decimals();
|
17
|
+
return decimals;
|
18
|
+
}
|
19
|
+
async getAllowance(owner, spender) {
|
20
|
+
const allowance = await this.contract.allowance(owner, spender);
|
21
|
+
return allowance;
|
22
|
+
}
|
23
|
+
async approveToken(spender, parsedAmount) {
|
24
|
+
const tx = await this.contract.approve(spender, parsedAmount);
|
25
|
+
const txHash = (await tx.wait()).hash;
|
26
|
+
return txHash;
|
27
|
+
}
|
28
|
+
async transfer(receiver, parsedAmount) {
|
29
|
+
const tx = await this.contract.transfer(receiver, parsedAmount);
|
30
|
+
const txHash = (await tx.wait()).hash;
|
31
|
+
return txHash;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
exports.default = ERC20TokenContract;
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import { ContractTransaction
|
1
|
+
import { ContractTransaction } from 'ethers';
|
2
2
|
import BasePerqContract from './BasePerqContract';
|
3
|
+
import PerqSdk from '../PerqSdk';
|
3
4
|
export default class PerqSwapAndRecyclerContract extends BasePerqContract {
|
4
|
-
constructor(
|
5
|
+
constructor(perqSdk: PerqSdk);
|
5
6
|
swapAndRecycle(beneficiary: string | undefined, path: string[], amountInWithDecimals: string, minAmountOutWithDecimals: string, price: string, deadline: string, signature: string): Promise<ContractTransaction>;
|
6
7
|
swapETHAndRecycle(beneficiary: string | undefined, path: string[], minAmountOutWithDecimals: string, amountInEth: string, price: string, deadline: string, signature: string): Promise<ContractTransaction>;
|
7
8
|
}
|
@@ -7,8 +7,8 @@ const ethers_1 = require("ethers");
|
|
7
7
|
const PerqSwapAndRecyclerAbi_json_1 = __importDefault(require("../abi/PerqSwapAndRecyclerAbi.json"));
|
8
8
|
const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
|
9
9
|
class PerqSwapAndRecyclerContract extends BasePerqContract_1.default {
|
10
|
-
constructor(
|
11
|
-
super(
|
10
|
+
constructor(perqSdk) {
|
11
|
+
super(perqSdk.perqConfig.perqSwapAndRecyclerAddress, new ethers_1.ethers.utils.Interface(PerqSwapAndRecyclerAbi_json_1.default), perqSdk.signer);
|
12
12
|
}
|
13
13
|
async swapAndRecycle(beneficiary = ethers_1.ethers.constants.AddressZero, path, amountInWithDecimals, minAmountOutWithDecimals, price, deadline, signature) {
|
14
14
|
if (!this.contract.signer) {
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import { ContractTransaction
|
1
|
+
import { ContractTransaction } from 'ethers';
|
2
2
|
import BasePerqContract from './BasePerqContract';
|
3
|
+
import PerqSdk from '../PerqSdk';
|
3
4
|
export default class PerqTokenRecyclerContract extends BasePerqContract {
|
4
|
-
constructor(
|
5
|
+
constructor(perqSdk: PerqSdk);
|
5
6
|
recycle(amountToRecycle: string, beneficiary: string | undefined, price: string, deadline: string, signature: string): Promise<ContractTransaction>;
|
6
7
|
}
|
@@ -7,8 +7,8 @@ const ethers_1 = require("ethers");
|
|
7
7
|
const TokenRecyclerAbi_json_1 = __importDefault(require("../abi/TokenRecyclerAbi.json"));
|
8
8
|
const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
|
9
9
|
class PerqTokenRecyclerContract extends BasePerqContract_1.default {
|
10
|
-
constructor(
|
11
|
-
super(
|
10
|
+
constructor(perqSdk) {
|
11
|
+
super(perqSdk.perqConfig.perqTokenRecyclerAddress, new ethers_1.ethers.utils.Interface(TokenRecyclerAbi_json_1.default), perqSdk.signer);
|
12
12
|
}
|
13
13
|
async recycle(amountToRecycle, beneficiary = ethers_1.ethers.constants.AddressZero, price, deadline, signature) {
|
14
14
|
if (!this.contract.signer) {
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import { BigNumber, ContractTransaction
|
1
|
+
import { BigNumber, ContractTransaction } from 'ethers';
|
2
2
|
import BasePerqContract from './BasePerqContract';
|
3
|
+
import PerqSdk from '../PerqSdk';
|
3
4
|
export default class PerqVestingContract extends BasePerqContract {
|
4
|
-
constructor(
|
5
|
+
constructor(perqSdk: PerqSdk);
|
5
6
|
start(): Promise<BigNumber>;
|
6
7
|
end(): Promise<BigNumber>;
|
7
8
|
vested(beneficiary: string): Promise<BigNumber>;
|
@@ -7,8 +7,8 @@ const ethers_1 = require("ethers");
|
|
7
7
|
const PerqVestingAbi_json_1 = __importDefault(require("../abi/PerqVestingAbi.json"));
|
8
8
|
const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
|
9
9
|
class PerqVestingContract extends BasePerqContract_1.default {
|
10
|
-
constructor(
|
11
|
-
super(
|
10
|
+
constructor(perqSdk) {
|
11
|
+
super(perqSdk.perqConfig.perqVestingAddress, new ethers_1.ethers.utils.Interface(PerqVestingAbi_json_1.default), perqSdk.signer);
|
12
12
|
}
|
13
13
|
async start() {
|
14
14
|
if (!this.contract.signer) {
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import PerqSdk from '../PerqSdk';
|
2
|
+
import MigrationOption from '../types/MigrationOption';
|
3
|
+
export default class LitePackage {
|
4
|
+
perqSdk: PerqSdk;
|
5
|
+
constructor(perqSdk: PerqSdk);
|
6
|
+
private validateChain;
|
7
|
+
deposit(tokenAddress: string, vaultAddress: string, onChainProjectId: number, amount: string): Promise<string>;
|
8
|
+
getSwapAndDepositAllowance(tokenAddress: string): Promise<string>;
|
9
|
+
approveSwapAndDeposit(tokenAddress: string, amount: string): Promise<string>;
|
10
|
+
swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, amount: string, vaultAddress: string, onChainProjectId: number): Promise<string>;
|
11
|
+
withdraw(tokenAddress: string, vaultAddress: string, onChainProjectId: number, amount: string): Promise<string>;
|
12
|
+
wrapAndDepositEth(vaultAddress: string, onChainProjectId: number, amount: string): Promise<any>;
|
13
|
+
getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number): Promise<string>;
|
14
|
+
getMigrationOptions(vaultAddress: string, onChainProjectId: number): Promise<MigrationOption[]>;
|
15
|
+
migrateDepositToOtherProject(tokenAddress: string, vaultAddress: string, fromProjectId: number, toProjectId: number, amount: string): Promise<string>;
|
16
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const ethers_1 = require("ethers");
|
7
|
+
const ERC20TokenContract_1 = __importDefault(require("../contracts/ERC20TokenContract"));
|
8
|
+
const ChainId_1 = require("../types/ChainId");
|
9
|
+
const WETH_DECIMAL_PRECISION = 18;
|
10
|
+
class LitePackage {
|
11
|
+
perqSdk;
|
12
|
+
constructor(perqSdk) {
|
13
|
+
this.perqSdk = perqSdk;
|
14
|
+
}
|
15
|
+
async validateChain(signer, vaultAddress, onChainProjectId) {
|
16
|
+
const vault = await this.perqSdk.perqApi.fetchPoolLiteDetails(vaultAddress, onChainProjectId);
|
17
|
+
const currentChainId = await signer.getChainId();
|
18
|
+
if (vault.chainId !== currentChainId) {
|
19
|
+
throw Error(`Wrong chain, current chain: ${currentChainId} does not match vault chain: ${vault.chainId}`);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
async deposit(tokenAddress, vaultAddress, onChainProjectId, amount) {
|
23
|
+
if (!this.perqSdk.signer) {
|
24
|
+
throw Error('No signer provided');
|
25
|
+
}
|
26
|
+
this.validateChain(this.perqSdk.signer, vaultAddress, onChainProjectId);
|
27
|
+
const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
|
28
|
+
const decimals = await tokenContract.getPrecission();
|
29
|
+
const parsedAmountToDeposit = ethers_1.ethers.utils.parseUnits(amount, decimals);
|
30
|
+
const res = await this.perqSdk.yelayLiteSdk.vaults.deposit(vaultAddress, onChainProjectId, BigInt(parsedAmountToDeposit.toString()));
|
31
|
+
return res.hash;
|
32
|
+
}
|
33
|
+
async getSwapAndDepositAllowance(tokenAddress) {
|
34
|
+
const res = await this.perqSdk.yelayLiteSdk.vaults.vaultWrapperAllowance(tokenAddress);
|
35
|
+
return res.toString();
|
36
|
+
}
|
37
|
+
async approveSwapAndDeposit(tokenAddress, amount) {
|
38
|
+
if (!this.perqSdk.signer) {
|
39
|
+
throw Error('No signer provided');
|
40
|
+
}
|
41
|
+
const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
|
42
|
+
const decimals = await tokenContract.getPrecission();
|
43
|
+
const parsedAmountToApprove = ethers_1.ethers.utils.parseUnits(amount, decimals);
|
44
|
+
const res = await this.perqSdk.yelayLiteSdk.vaults.approveVaultWrapper(tokenAddress, parsedAmountToApprove.toBigInt());
|
45
|
+
return res.hash;
|
46
|
+
}
|
47
|
+
async swapAndDeposit(fromTokenAddress, toTokenAddress, amount, vaultAddress, onChainProjectId) {
|
48
|
+
if (!this.perqSdk.signer) {
|
49
|
+
throw Error('No signer provided');
|
50
|
+
}
|
51
|
+
this.validateChain(this.perqSdk.signer, vaultAddress, onChainProjectId);
|
52
|
+
const tokenContract = new ERC20TokenContract_1.default(fromTokenAddress, this.perqSdk.signer);
|
53
|
+
const decimals = await tokenContract.getPrecission();
|
54
|
+
const parsedAmountToSwapAndDeposit = ethers_1.ethers.utils.parseUnits(amount, decimals);
|
55
|
+
const swapInfo = await this.perqSdk.perqApi.getSwapInfo(fromTokenAddress, toTokenAddress, parsedAmountToSwapAndDeposit, this.perqSdk.yelayLiteSdk.swapperAddress, ChainId_1.BASE_CHAIN_ID);
|
56
|
+
const swapArgsStruct = {
|
57
|
+
tokenIn: swapInfo[0].token,
|
58
|
+
swapTarget: swapInfo[0].swapTarget,
|
59
|
+
swapCallData: swapInfo[0].swapCallData,
|
60
|
+
};
|
61
|
+
const res = await this.perqSdk.yelayLiteSdk.vaults.swapAndDeposit(vaultAddress.toLowerCase(), onChainProjectId, parsedAmountToSwapAndDeposit.toBigInt(), swapArgsStruct);
|
62
|
+
return res.hash;
|
63
|
+
}
|
64
|
+
async withdraw(tokenAddress, vaultAddress, onChainProjectId, amount) {
|
65
|
+
if (!this.perqSdk.signer) {
|
66
|
+
throw Error('No signer provided');
|
67
|
+
}
|
68
|
+
this.validateChain(this.perqSdk.signer, vaultAddress, onChainProjectId);
|
69
|
+
const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
|
70
|
+
const decimals = await tokenContract.getPrecission();
|
71
|
+
const parsedAmountToWithdraw = ethers_1.ethers.utils.parseUnits(amount, decimals);
|
72
|
+
const res = await this.perqSdk.yelayLiteSdk.vaults.redeem(vaultAddress, onChainProjectId, BigInt(parsedAmountToWithdraw.toString()));
|
73
|
+
return res.hash;
|
74
|
+
}
|
75
|
+
async wrapAndDepositEth(vaultAddress, onChainProjectId, amount) {
|
76
|
+
if (!this.perqSdk.signer) {
|
77
|
+
throw Error('No signer provided');
|
78
|
+
}
|
79
|
+
this.validateChain(this.perqSdk.signer, vaultAddress, onChainProjectId);
|
80
|
+
const parsedAmount = ethers_1.ethers.utils.parseUnits(amount, WETH_DECIMAL_PRECISION);
|
81
|
+
const res = await this.perqSdk.yelayLiteSdk.vaults.depositEth(vaultAddress, onChainProjectId, BigInt(parsedAmount.toString()));
|
82
|
+
return res.hash;
|
83
|
+
}
|
84
|
+
async getExpectedSwapResult(fromTokenAddress, toTokenAddress, amount, decimals) {
|
85
|
+
return this.perqSdk.perqApi.getExpectedSwapResult(fromTokenAddress, toTokenAddress, amount, decimals, ChainId_1.BASE_CHAIN_ID.toString());
|
86
|
+
}
|
87
|
+
async getMigrationOptions(vaultAddress, onChainProjectId) {
|
88
|
+
return this.perqSdk.perqApi.fetchMigrationOptions(vaultAddress, onChainProjectId);
|
89
|
+
}
|
90
|
+
async migrateDepositToOtherProject(tokenAddress, vaultAddress, fromProjectId, toProjectId, amount) {
|
91
|
+
if (!this.perqSdk.signer) {
|
92
|
+
throw Error('No signer provided');
|
93
|
+
}
|
94
|
+
this.validateChain(this.perqSdk.signer, vaultAddress, fromProjectId);
|
95
|
+
const tokenContract = new ERC20TokenContract_1.default(tokenAddress, this.perqSdk.signer);
|
96
|
+
const decimals = await tokenContract.getPrecission();
|
97
|
+
const parsedAmountToDeposit = ethers_1.ethers.utils.parseUnits(amount, decimals);
|
98
|
+
const res = await this.perqSdk.yelayLiteSdk.vaults.migrate(vaultAddress, fromProjectId, toProjectId, BigInt(parsedAmountToDeposit.toString()));
|
99
|
+
return res.hash;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
exports.default = LitePackage;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { BeansBalance, BeanEntry, PerqToBeansSwapInfo, LoyaltyCard } from '../types';
|
2
|
+
import PerqSdk from '../PerqSdk';
|
3
|
+
export default class LoyaltyPackage {
|
4
|
+
private perqSdk;
|
5
|
+
constructor(perqSdk: PerqSdk);
|
6
|
+
getBeansBalance(): Promise<BeansBalance>;
|
7
|
+
getBeansHistory(): Promise<BeanEntry[]>;
|
8
|
+
getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
|
9
|
+
upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>;
|
10
|
+
getOwnedLoyaltyCard(): Promise<LoyaltyCard>;
|
11
|
+
getAllLoyaltyCards(): Promise<LoyaltyCard[]>;
|
12
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
class LoyaltyPackage {
|
4
|
+
perqSdk;
|
5
|
+
constructor(perqSdk) {
|
6
|
+
this.perqSdk = perqSdk;
|
7
|
+
}
|
8
|
+
async getBeansBalance() {
|
9
|
+
const userAddress = await this.perqSdk.signer.getAddress();
|
10
|
+
return this.perqSdk.perqApi.fetchBeansBalance(userAddress);
|
11
|
+
}
|
12
|
+
async getBeansHistory() {
|
13
|
+
const userAddress = await this.perqSdk.signer.getAddress();
|
14
|
+
return this.perqSdk.perqApi.fetchBeansHistory(userAddress);
|
15
|
+
}
|
16
|
+
async getSwapPerqForBeansInfo() {
|
17
|
+
return this.perqSdk.perqApi.getSwapPerqForBeansInfo();
|
18
|
+
}
|
19
|
+
async upgradeLoyaltyCard(index) {
|
20
|
+
const payload = {
|
21
|
+
index,
|
22
|
+
};
|
23
|
+
const signedPayload = await this.perqSdk.signHandler.signPayload(payload);
|
24
|
+
return this.perqSdk.perqApi.upgradeLoyaltyCard(signedPayload);
|
25
|
+
}
|
26
|
+
async getOwnedLoyaltyCard() {
|
27
|
+
const signerAddress = await this.perqSdk.signer.getAddress();
|
28
|
+
return this.perqSdk.perqApi.fetchOwnedLoyaltyCard(signerAddress);
|
29
|
+
}
|
30
|
+
async getAllLoyaltyCards() {
|
31
|
+
return this.perqSdk.perqApi.fetchAllLoyaltyCards();
|
32
|
+
}
|
33
|
+
}
|
34
|
+
exports.default = LoyaltyPackage;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import PerqSdk from '../PerqSdk';
|
2
|
+
import { DetailedProjectData, MyPerqData, ReducedProjectData, UserRewards, UserVaultBalance, VaultData, VaultStats } from '../types';
|
3
|
+
export default class PoolsPackage {
|
4
|
+
private perqSdk;
|
5
|
+
constructor(perqSdk: PerqSdk);
|
6
|
+
getUserPoolBalance(vaultAddress: string, onChainProjectId: number): Promise<UserVaultBalance>;
|
7
|
+
getAllPools(): Promise<VaultData[]>;
|
8
|
+
getMyPerqBalance(): Promise<MyPerqData[]>;
|
9
|
+
getPoolDetails(vaultAddress: string, onChainProjectId: number): Promise<VaultData>;
|
10
|
+
getAllProjects(): Promise<ReducedProjectData[]>;
|
11
|
+
getProjectDetails(projectName: string): Promise<DetailedProjectData>;
|
12
|
+
getPoolStats(): Promise<VaultStats>;
|
13
|
+
getRewardsPerHour(vaultAddress: string): Promise<number>;
|
14
|
+
getUserBoostedNfts(vaultAddress: string): Promise<string[]>;
|
15
|
+
getRewards(): Promise<UserRewards>;
|
16
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
class PoolsPackage {
|
4
|
+
perqSdk;
|
5
|
+
constructor(perqSdk) {
|
6
|
+
this.perqSdk = perqSdk;
|
7
|
+
}
|
8
|
+
async getUserPoolBalance(vaultAddress, onChainProjectId) {
|
9
|
+
if (!this.perqSdk.signer) {
|
10
|
+
throw Error('No signer provided');
|
11
|
+
}
|
12
|
+
const userAddress = await this.perqSdk.signer.getAddress();
|
13
|
+
return await this.perqSdk.perqApi.fetchLitePoolUserBalance(userAddress.toLowerCase(), vaultAddress.toLowerCase(), onChainProjectId);
|
14
|
+
}
|
15
|
+
async getAllPools() {
|
16
|
+
return this.perqSdk.perqApi.fetchAllPools();
|
17
|
+
}
|
18
|
+
async getMyPerqBalance() {
|
19
|
+
if (!this.perqSdk.signer) {
|
20
|
+
throw Error('No signer provided');
|
21
|
+
}
|
22
|
+
const userAddress = await this.perqSdk.signer.getAddress();
|
23
|
+
const myPerqBalance = this.perqSdk.perqApi.fetchMyPerqData(userAddress);
|
24
|
+
return myPerqBalance;
|
25
|
+
}
|
26
|
+
async getPoolDetails(vaultAddress, onChainProjectId) {
|
27
|
+
return this.perqSdk.perqApi.fetchPoolLiteDetails(vaultAddress, onChainProjectId);
|
28
|
+
}
|
29
|
+
async getAllProjects() {
|
30
|
+
return this.perqSdk.perqApi.fetchAllProjects();
|
31
|
+
}
|
32
|
+
async getProjectDetails(projectName) {
|
33
|
+
return this.perqSdk.perqApi.fetchProjetctDetails(projectName);
|
34
|
+
}
|
35
|
+
async getPoolStats() {
|
36
|
+
return this.perqSdk.perqApi.fetchPoolStats();
|
37
|
+
}
|
38
|
+
async getRewardsPerHour(vaultAddress) {
|
39
|
+
const userAddress = await this.perqSdk.signer.getAddress();
|
40
|
+
return this.perqSdk.perqApi.fetchRewardsPerHour(userAddress, vaultAddress);
|
41
|
+
}
|
42
|
+
async getUserBoostedNfts(vaultAddress) {
|
43
|
+
const userAddress = await this.perqSdk.signer.getAddress();
|
44
|
+
return this.perqSdk.perqApi.getUserBoostedNfts(userAddress, vaultAddress);
|
45
|
+
}
|
46
|
+
async getRewards() {
|
47
|
+
const userAddress = await this.perqSdk.signer.getAddress();
|
48
|
+
const userRewards = this.perqSdk.perqApi.fetchUserRewards(userAddress);
|
49
|
+
return userRewards;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
exports.default = PoolsPackage;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { BigNumber } from 'ethers';
|
2
|
+
import PerqSdk from '../PerqSdk';
|
3
|
+
export default class RecyclerPackage {
|
4
|
+
private perqSdk;
|
5
|
+
constructor(perqSdk: PerqSdk);
|
6
|
+
getTokenAllowanceForRecycler(tokenAddress: string): Promise<BigNumber>;
|
7
|
+
getTokenAllowanceForSwapAndRecycler(tokenAddress: string): Promise<BigNumber>;
|
8
|
+
recycleTokens(tokenAddress: string | undefined, amountToRecycle: string, beneficiary: string | undefined, price: string, deadline: string, signature: string): Promise<string>;
|
9
|
+
swapAndRecycleETH(beneficiary: string, path: string[], minAmountOutWithDecimals: string, amountOfEth: string, price: string, deadline: string, signature: string): Promise<string>;
|
10
|
+
swapAndRecycleERC20(beneficiary: string, path: string[], minAmountOutWithDecimals: string, amountInWithDecimals: string, price: string, deadline: string, signature: string): Promise<string>;
|
11
|
+
approveTokenForRecycler(tokenAddress: string, amount: string): Promise<string>;
|
12
|
+
approveTokenForSwapAndRecycler(tokenAddress: string, amount: string): Promise<string>;
|
13
|
+
}
|