@dripfi/drip-sdk 1.4.2-yelay-lite → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/PerqApi.d.ts +1 -3
- package/dist/PerqApi.js +0 -20
- package/dist/PerqSdk.d.ts +4 -11
- package/dist/PerqSdk.js +17 -67
- package/dist/types/PerqConfig.d.ts +0 -1
- package/dist/types/PerqConfig.js +0 -2
- package/dist/types/index.d.ts +1 -2
- package/package.json +2 -2
- package/dist/types/YelayLiteVault.d.ts +0 -11
- package/dist/types/YelayLiteVault.js +0 -2
package/CHANGELOG.md
CHANGED
package/dist/PerqApi.d.ts
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
import { BigNumber } from 'ethers';
|
2
|
-
import { Vault, SwapInfo, QLFastRedeem, UserRewards, VaultStats, MyPerqData, LoyaltyCard, BeansBalance, PerqToBeansSwapInfo, BeanEntry, NonceEnrichedSignedPayload, NonceEnrichedPayload, UpgradeLoyaltyCardPayload
|
2
|
+
import { Vault, SwapInfo, QLFastRedeem, UserRewards, VaultStats, MyPerqData, LoyaltyCard, BeansBalance, PerqToBeansSwapInfo, BeanEntry, NonceEnrichedSignedPayload, NonceEnrichedPayload, UpgradeLoyaltyCardPayload } from './types';
|
3
3
|
export default class PerqApi {
|
4
4
|
route: string;
|
5
5
|
constructor(route: string);
|
6
6
|
fetchAllVaults(): Promise<Vault[]>;
|
7
|
-
fetchAllYelayLiteVaults(): Promise<YelayLiteVault[]>;
|
8
|
-
fetchYelayLiteVaultDetails(vaultAddress: string, yliteProjectId: number): Promise<YelayLiteVault>;
|
9
7
|
fetchTokenPrice(tokenName: string): Promise<number>;
|
10
8
|
getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number): Promise<string>;
|
11
9
|
getUserBoostedNfts(walletAddress: string, vaultAddress: string): Promise<string[]>;
|
package/dist/PerqApi.js
CHANGED
@@ -18,26 +18,6 @@ class PerqApi {
|
|
18
18
|
throw Error(`${await res.text()}`);
|
19
19
|
}
|
20
20
|
}
|
21
|
-
async fetchAllYelayLiteVaults() {
|
22
|
-
const res = await fetch(`${this.route}/api-be/api/vault/yelay-lite`);
|
23
|
-
if (res.ok) {
|
24
|
-
const vaults = await res.json();
|
25
|
-
return vaults;
|
26
|
-
}
|
27
|
-
else {
|
28
|
-
throw Error(`${await res.text()}`);
|
29
|
-
}
|
30
|
-
}
|
31
|
-
async fetchYelayLiteVaultDetails(vaultAddress, yliteProjectId) {
|
32
|
-
const res = await fetch(`${this.route}/api-be/api/vault/yelay-lite/${vaultAddress}/${yliteProjectId}`);
|
33
|
-
if (res.ok) {
|
34
|
-
const data = (await res.json());
|
35
|
-
return data;
|
36
|
-
}
|
37
|
-
else {
|
38
|
-
throw Error(`${await res.text()}`);
|
39
|
-
}
|
40
|
-
}
|
41
21
|
async fetchTokenPrice(tokenName) {
|
42
22
|
const res = await fetch(`${this.route}/api-be/api/tokenPrice?tokenName=${tokenName}`);
|
43
23
|
if (res.ok) {
|
package/dist/PerqSdk.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
import { BigNumber, Signer
|
2
|
-
import { Vault, UserRewards, VaultStats, UserVaultBalance, LoyaltyCard, NonceEnrichedSignedPayload, MyPerqData, BeansBalance, BeanEntry, PerqToBeansSwapInfo, VestingInfo
|
1
|
+
import { BigNumber, Signer } from 'ethers';
|
2
|
+
import { Vault, UserRewards, VaultStats, UserVaultBalance, LoyaltyCard, NonceEnrichedSignedPayload, MyPerqData, BeansBalance, BeanEntry, PerqToBeansSwapInfo, VestingInfo } from './types';
|
3
|
+
import { PerqConfig } from './types/index';
|
3
4
|
export default class PerqSdk {
|
4
5
|
private perqApi;
|
5
6
|
private perqConfig;
|
@@ -9,16 +10,12 @@ export default class PerqSdk {
|
|
9
10
|
private perqVestingContract;
|
10
11
|
private spoolSdk?;
|
11
12
|
private signer?;
|
12
|
-
|
13
|
-
constructor(perqConfig: PerqConfig, provider?: ethers.providers.JsonRpcProvider);
|
14
|
-
getAllYelayLiteVaults(): Promise<YelayLiteVault[]>;
|
13
|
+
constructor(perqConfig: PerqConfig, signer?: Signer);
|
15
14
|
getAllVaults(): Promise<Vault[]>;
|
16
15
|
getVaultDetails(vaultAddress: string): Promise<Vault>;
|
17
|
-
getYelayLiteVaultDetails(vaultAddress: string, yliteProjectId: number): Promise<YelayLiteVault>;
|
18
16
|
getVaultStats(): Promise<VaultStats>;
|
19
17
|
getTokenPrice(tokenName: string): Promise<number>;
|
20
18
|
updateSigner(newSigner: Signer): Promise<void>;
|
21
|
-
yelayLiteDeposit(tokenAddress: string, vaultAddress: string, yliteProjectId: number, amount: string): Promise<string>;
|
22
19
|
newDeposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>;
|
23
20
|
deposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>;
|
24
21
|
private doDeposit;
|
@@ -30,14 +27,12 @@ export default class PerqSdk {
|
|
30
27
|
getRewardsPerHour(vaultAddress: string): Promise<number>;
|
31
28
|
getRewards(): Promise<UserRewards>;
|
32
29
|
getMyPerqBalance(): Promise<MyPerqData[]>;
|
33
|
-
getYelayLiteUserVaultBalance(vaultAddress: string, yliteProjectId: number): Promise<BigNumber>;
|
34
30
|
getUserVaultBalance(vaultAddress: string): Promise<UserVaultBalance>;
|
35
31
|
fastWithdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>;
|
36
32
|
swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>;
|
37
33
|
newSwapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>;
|
38
34
|
private doSwapAndDeposit;
|
39
35
|
withdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>;
|
40
|
-
yelayLiteWithdraw(tokenAddress: string, vaultAddress: string, yliteProjectId: number, amount: string): Promise<string>;
|
41
36
|
claimWithdraws(vaultAddress: string): Promise<string>;
|
42
37
|
getBeansBalance(): Promise<BeansBalance>;
|
43
38
|
getBeansHistory(): Promise<BeanEntry[]>;
|
@@ -53,8 +48,6 @@ export default class PerqSdk {
|
|
53
48
|
approveTokenForDeposit(tokenAddress: string, amount: string): Promise<string>;
|
54
49
|
getPerqTokenContractAddress(): string;
|
55
50
|
getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
|
56
|
-
getAllowance(tokenAddress: string, spender: string): Promise<BigNumber>;
|
57
|
-
approveAllowance(tokenAddress: string, amount: string, spenderAddress: string): Promise<string>;
|
58
51
|
transferErc20Token(tokenAddress: string, amount: string, receiver: string): Promise<string>;
|
59
52
|
wrapEther(amount: string, tokenAddress: string): Promise<string>;
|
60
53
|
getVestingStart(): Promise<string>;
|
package/dist/PerqSdk.js
CHANGED
@@ -9,7 +9,6 @@ const spool_v2_sdk_1 = require("@spool.fi/spool-v2-sdk");
|
|
9
9
|
const PerqApi_1 = __importDefault(require("./PerqApi"));
|
10
10
|
const contracts_1 = require("./contracts");
|
11
11
|
const WethTokenAbi_json_1 = __importDefault(require("./abi/WethTokenAbi.json"));
|
12
|
-
const sdk_1 = require("@yelay-lite/sdk");
|
13
12
|
class PerqSdk {
|
14
13
|
perqApi;
|
15
14
|
perqConfig;
|
@@ -19,26 +18,17 @@ class PerqSdk {
|
|
19
18
|
perqVestingContract;
|
20
19
|
spoolSdk;
|
21
20
|
signer;
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
this.signer = newSigner;
|
27
|
-
this.yelayLiteSdk = new sdk_1.YelayLiteSdk({
|
28
|
-
backendUrl: perqConfig.yelayLiteBackendUrl,
|
29
|
-
provider: provider,
|
30
|
-
});
|
31
|
-
this.spoolSdk = new spool_v2_sdk_1.SpoolSdk(perqConfig.spoolSdkConfig, newSigner);
|
21
|
+
constructor(perqConfig, signer) {
|
22
|
+
this.signer = signer;
|
23
|
+
if (this.signer) {
|
24
|
+
this.spoolSdk = new spool_v2_sdk_1.SpoolSdk(perqConfig.spoolSdkConfig, this.signer);
|
32
25
|
}
|
33
26
|
this.perqConfig = perqConfig;
|
34
27
|
this.perqApi = new PerqApi_1.default(perqConfig.route);
|
35
|
-
this.perqTokenContract = new contracts_1.PerqTokenContract(perqConfig.perqTokenAddress,
|
36
|
-
this.perqTokenRecyclerContract = new contracts_1.PerqTokenRecyclerContract(perqConfig.perqTokenRecyclerAddress,
|
37
|
-
this.perqSwapAndRecyclerContract = new contracts_1.PerqSwapAndRecyclerContract(perqConfig.perqSwapAndRecyclerAddress,
|
38
|
-
this.perqVestingContract = new contracts_1.PerqVestingContract(perqConfig.perqVestingAddress,
|
39
|
-
}
|
40
|
-
async getAllYelayLiteVaults() {
|
41
|
-
return this.perqApi.fetchAllYelayLiteVaults();
|
28
|
+
this.perqTokenContract = new contracts_1.PerqTokenContract(perqConfig.perqTokenAddress, signer);
|
29
|
+
this.perqTokenRecyclerContract = new contracts_1.PerqTokenRecyclerContract(perqConfig.perqTokenRecyclerAddress, signer);
|
30
|
+
this.perqSwapAndRecyclerContract = new contracts_1.PerqSwapAndRecyclerContract(perqConfig.perqSwapAndRecyclerAddress, signer);
|
31
|
+
this.perqVestingContract = new contracts_1.PerqVestingContract(perqConfig.perqVestingAddress, signer);
|
42
32
|
}
|
43
33
|
async getAllVaults() {
|
44
34
|
return this.perqApi.fetchAllVaults();
|
@@ -46,9 +36,6 @@ class PerqSdk {
|
|
46
36
|
async getVaultDetails(vaultAddress) {
|
47
37
|
return this.perqApi.fetchVaultDetails(vaultAddress);
|
48
38
|
}
|
49
|
-
async getYelayLiteVaultDetails(vaultAddress, yliteProjectId) {
|
50
|
-
return this.perqApi.fetchYelayLiteVaultDetails(vaultAddress, yliteProjectId);
|
51
|
-
}
|
52
39
|
async getVaultStats() {
|
53
40
|
return this.perqApi.fetchVaultStats();
|
54
41
|
}
|
@@ -63,23 +50,6 @@ class PerqSdk {
|
|
63
50
|
this.perqSwapAndRecyclerContract.updateSigner(newSigner);
|
64
51
|
this.perqVestingContract.updateSigner(newSigner);
|
65
52
|
}
|
66
|
-
async yelayLiteDeposit(tokenAddress, vaultAddress, yliteProjectId, amount) {
|
67
|
-
if (!this.signer) {
|
68
|
-
throw Error('No signer provided');
|
69
|
-
}
|
70
|
-
const decimals = await this.getERC20Precission(tokenAddress);
|
71
|
-
const amountWithDecimals = parseFloat(parseFloat(amount).toFixed(decimals));
|
72
|
-
const currentTokenAllowance = parseFloat(ethers_1.ethers.utils.formatUnits(await this.getAllowance(tokenAddress, vaultAddress), decimals));
|
73
|
-
if (amountWithDecimals > currentTokenAllowance) {
|
74
|
-
await this.approveToken(tokenAddress, amountWithDecimals.toString(), vaultAddress);
|
75
|
-
}
|
76
|
-
const amountToDeposit = ethers_1.ethers.utils.parseUnits(amountWithDecimals.toString(), decimals);
|
77
|
-
const res = await this.yelayLiteSdk.deposit(this.signer, vaultAddress, yliteProjectId, BigInt(amountToDeposit.toString()));
|
78
|
-
if (!res.success || !res.hash) {
|
79
|
-
throw Error('Error depositing into vault');
|
80
|
-
}
|
81
|
-
return res.hash;
|
82
|
-
}
|
83
53
|
async newDeposit(tokenAddress, vaultAddress, amount) {
|
84
54
|
return this.doDeposit(tokenAddress, vaultAddress, amount, false);
|
85
55
|
}
|
@@ -156,14 +126,6 @@ class PerqSdk {
|
|
156
126
|
const myPerqBalance = this.perqApi.fetchMyPerqData(userAddress);
|
157
127
|
return myPerqBalance;
|
158
128
|
}
|
159
|
-
async getYelayLiteUserVaultBalance(vaultAddress, yliteProjectId) {
|
160
|
-
if (!this.signer) {
|
161
|
-
throw Error('No signer provided');
|
162
|
-
}
|
163
|
-
const userAddress = await this.signer.getAddress();
|
164
|
-
const balance = await this.yelayLiteSdk.balanceOf(vaultAddress, yliteProjectId, userAddress);
|
165
|
-
return balance;
|
166
|
-
}
|
167
129
|
async getUserVaultBalance(vaultAddress) {
|
168
130
|
if (!this.signer) {
|
169
131
|
throw Error('No signer provided');
|
@@ -270,18 +232,6 @@ class PerqSdk {
|
|
270
232
|
const redeemTxReceipt = await redeemTx.wait();
|
271
233
|
return redeemTxReceipt.transactionHash;
|
272
234
|
}
|
273
|
-
async yelayLiteWithdraw(tokenAddress, vaultAddress, yliteProjectId, amount) {
|
274
|
-
if (!this.signer) {
|
275
|
-
throw Error('No signer provided');
|
276
|
-
}
|
277
|
-
const decimals = await this.getERC20Precission(tokenAddress);
|
278
|
-
const amountToWithdraw = ethers_1.ethers.utils.parseUnits(amount, decimals);
|
279
|
-
const res = await this.yelayLiteSdk.redeem(this.signer, vaultAddress, yliteProjectId, BigInt(amountToWithdraw.toString()));
|
280
|
-
if (!res.success || !res.hash) {
|
281
|
-
throw Error('Error withdrawing from vault');
|
282
|
-
}
|
283
|
-
return res.hash;
|
284
|
-
}
|
285
235
|
async claimWithdraws(vaultAddress) {
|
286
236
|
const userAddress = await this.signer.getAddress();
|
287
237
|
if (!this.signer) {
|
@@ -329,6 +279,15 @@ class PerqSdk {
|
|
329
279
|
if (this.perqConfig.perqSwapAndRecyclerAddress === ethers_1.ethers.constants.AddressZero) {
|
330
280
|
throw Error('Recycler contract address not defined');
|
331
281
|
}
|
282
|
+
console.log('swap and recycle ERC-20 with this: ', {
|
283
|
+
beneficiary,
|
284
|
+
path,
|
285
|
+
amountInWithDecimals,
|
286
|
+
minAmountOutWithDecimals,
|
287
|
+
price,
|
288
|
+
deadline,
|
289
|
+
signature,
|
290
|
+
});
|
332
291
|
const swapAndRecycleTx = await this.perqSwapAndRecyclerContract.swapAndRecycle(beneficiary, path, amountInWithDecimals, minAmountOutWithDecimals, price, deadline, signature);
|
333
292
|
const receipt = await swapAndRecycleTx.wait();
|
334
293
|
return receipt.transactionHash;
|
@@ -377,15 +336,6 @@ class PerqSdk {
|
|
377
336
|
async getSwapPerqForBeansInfo() {
|
378
337
|
return this.perqApi.getSwapPerqForBeansInfo();
|
379
338
|
}
|
380
|
-
async getAllowance(tokenAddress, spender) {
|
381
|
-
const allowance = await this.getERC20TokenAllowance(spender, tokenAddress);
|
382
|
-
return allowance;
|
383
|
-
}
|
384
|
-
async approveAllowance(tokenAddress, amount, spenderAddress) {
|
385
|
-
const decimals = await this.getERC20Precission(tokenAddress);
|
386
|
-
const amountWithDecimals = parseFloat(parseFloat(amount).toFixed(decimals));
|
387
|
-
return await this.approveToken(tokenAddress, amountWithDecimals.toString(), spenderAddress);
|
388
|
-
}
|
389
339
|
async transferErc20Token(tokenAddress, amount, receiver) {
|
390
340
|
if (!this.signer) {
|
391
341
|
throw Error('No signer provided');
|
package/dist/types/PerqConfig.js
CHANGED
@@ -11,7 +11,6 @@ exports.PRODUCTION = {
|
|
11
11
|
perqVestingAddress: '0x5e19C155C30bDEB83FCFE20a3b6f6Eda34B746c5',
|
12
12
|
swapAndDepositContractAddress: '0xd8534197bd587f8226d12e0c864ef2cae6f82f5c',
|
13
13
|
smartVaultManagerContractAddress: '0x23daf34e2b9af02a74dc19cb52af727b19403874',
|
14
|
-
yelayLiteBackendUrl: '',
|
15
14
|
};
|
16
15
|
exports.DEVELOPMENT = {
|
17
16
|
route: 'https://dev.perq.finance',
|
@@ -22,5 +21,4 @@ exports.DEVELOPMENT = {
|
|
22
21
|
perqVestingAddress: '0x1d3B9E32a7139718f94BE32c797682fFf2D1bE60',
|
23
22
|
swapAndDepositContractAddress: '0x5fb08e00de169f041711206a0995410884080177',
|
24
23
|
smartVaultManagerContractAddress: '0x2638d6c0b4ef6dee04050fa0b07ca62500435747',
|
25
|
-
yelayLiteBackendUrl: 'https://lite.dev.yelay.io',
|
26
24
|
};
|
package/dist/types/index.d.ts
CHANGED
@@ -24,5 +24,4 @@ import VaultStats from './VaultStats';
|
|
24
24
|
import VaultType from './VaultType';
|
25
25
|
import VestingInfo from './VestingInfo';
|
26
26
|
import YelayVersion from './YelayVersion';
|
27
|
-
|
28
|
-
export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, ELoyaltyCardTier, LoyaltyCard, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, RewardType, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, UserVaultBalance, Vault, VaultReward, VaultStats, VaultType, VestingInfo, YelayVersion, YelayLiteVault, };
|
27
|
+
export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, ELoyaltyCardTier, LoyaltyCard, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, RewardType, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, UserVaultBalance, Vault, VaultReward, VaultStats, VaultType, VestingInfo, YelayVersion, };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dripfi/drip-sdk",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.3",
|
4
4
|
"description": "Drip SDK",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -14,7 +14,7 @@
|
|
14
14
|
},
|
15
15
|
"dependencies": {
|
16
16
|
"@spool.fi/spool-v2-sdk": "2.0.44",
|
17
|
-
"@yelay-lite/sdk": "0.0.
|
17
|
+
"@yelay-lite/sdk": "0.0.11",
|
18
18
|
"ethers": "^5.7.2"
|
19
19
|
},
|
20
20
|
"author": "",
|