@dripfi/drip-sdk 1.4.2 → 1.4.3-yelay-lite
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/PerqApi.d.ts +3 -1
- package/dist/PerqApi.js +20 -0
- package/dist/PerqSdk.d.ts +11 -4
- package/dist/PerqSdk.js +67 -17
- package/dist/types/DeployedProject.d.ts +2 -0
- package/dist/types/PerqConfig.d.ts +1 -0
- package/dist/types/PerqConfig.js +2 -0
- package/dist/types/YelayLiteVault.d.ts +11 -0
- package/dist/types/YelayLiteVault.js +2 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +2 -2
package/dist/PerqApi.d.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
import { BigNumber } from 'ethers';
|
2
|
-
import { Vault, SwapInfo, QLFastRedeem, UserRewards, VaultStats, MyPerqData, LoyaltyCard, BeansBalance, PerqToBeansSwapInfo, BeanEntry, NonceEnrichedSignedPayload, NonceEnrichedPayload, UpgradeLoyaltyCardPayload } from './types';
|
2
|
+
import { Vault, SwapInfo, QLFastRedeem, UserRewards, VaultStats, MyPerqData, LoyaltyCard, BeansBalance, PerqToBeansSwapInfo, BeanEntry, NonceEnrichedSignedPayload, NonceEnrichedPayload, UpgradeLoyaltyCardPayload, YelayLiteVault } 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>;
|
7
9
|
fetchTokenPrice(tokenName: string): Promise<number>;
|
8
10
|
getExpectedSwapResult(fromTokenAddress: string, toTokenAddress: string, amount: string, decimals: number): Promise<string>;
|
9
11
|
getUserBoostedNfts(walletAddress: string, vaultAddress: string): Promise<string[]>;
|
package/dist/PerqApi.js
CHANGED
@@ -18,6 +18,26 @@ 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
|
+
}
|
21
41
|
async fetchTokenPrice(tokenName) {
|
22
42
|
const res = await fetch(`${this.route}/api-be/api/tokenPrice?tokenName=${tokenName}`);
|
23
43
|
if (res.ok) {
|
package/dist/PerqSdk.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
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';
|
1
|
+
import { BigNumber, Signer, ethers } from 'ethers';
|
2
|
+
import { Vault, UserRewards, VaultStats, UserVaultBalance, LoyaltyCard, NonceEnrichedSignedPayload, MyPerqData, BeansBalance, BeanEntry, PerqToBeansSwapInfo, VestingInfo, YelayLiteVault, PerqConfig } from './types';
|
4
3
|
export default class PerqSdk {
|
5
4
|
private perqApi;
|
6
5
|
private perqConfig;
|
@@ -10,12 +9,16 @@ export default class PerqSdk {
|
|
10
9
|
private perqVestingContract;
|
11
10
|
private spoolSdk?;
|
12
11
|
private signer?;
|
13
|
-
|
12
|
+
private yelayLiteSdk?;
|
13
|
+
constructor(perqConfig: PerqConfig, provider?: ethers.providers.JsonRpcProvider);
|
14
|
+
getAllYelayLiteVaults(): Promise<YelayLiteVault[]>;
|
14
15
|
getAllVaults(): Promise<Vault[]>;
|
15
16
|
getVaultDetails(vaultAddress: string): Promise<Vault>;
|
17
|
+
getYelayLiteVaultDetails(vaultAddress: string, yliteProjectId: number): Promise<YelayLiteVault>;
|
16
18
|
getVaultStats(): Promise<VaultStats>;
|
17
19
|
getTokenPrice(tokenName: string): Promise<number>;
|
18
20
|
updateSigner(newSigner: Signer): Promise<void>;
|
21
|
+
yelayLiteDeposit(tokenAddress: string, vaultAddress: string, yliteProjectId: number, amount: string): Promise<string>;
|
19
22
|
newDeposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>;
|
20
23
|
deposit(tokenAddress: string, vaultAddress: string, amount: string): Promise<string>;
|
21
24
|
private doDeposit;
|
@@ -27,12 +30,14 @@ export default class PerqSdk {
|
|
27
30
|
getRewardsPerHour(vaultAddress: string): Promise<number>;
|
28
31
|
getRewards(): Promise<UserRewards>;
|
29
32
|
getMyPerqBalance(): Promise<MyPerqData[]>;
|
33
|
+
getYelayLiteUserVaultBalance(vaultAddress: string, yliteProjectId: number): Promise<BigNumber>;
|
30
34
|
getUserVaultBalance(vaultAddress: string): Promise<UserVaultBalance>;
|
31
35
|
fastWithdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>;
|
32
36
|
swapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>;
|
33
37
|
newSwapAndDeposit(fromTokenAddress: string, toTokenAddress: string, fromTokenAmount: string, vaultAddress: string, ethAmount?: string): Promise<string>;
|
34
38
|
private doSwapAndDeposit;
|
35
39
|
withdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>;
|
40
|
+
yelayLiteWithdraw(tokenAddress: string, vaultAddress: string, yliteProjectId: number, amount: string): Promise<string>;
|
36
41
|
claimWithdraws(vaultAddress: string): Promise<string>;
|
37
42
|
getBeansBalance(): Promise<BeansBalance>;
|
38
43
|
getBeansHistory(): Promise<BeanEntry[]>;
|
@@ -48,6 +53,8 @@ export default class PerqSdk {
|
|
48
53
|
approveTokenForDeposit(tokenAddress: string, amount: string): Promise<string>;
|
49
54
|
getPerqTokenContractAddress(): string;
|
50
55
|
getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
|
56
|
+
getAllowance(tokenAddress: string, spender: string): Promise<BigNumber>;
|
57
|
+
approveAllowance(tokenAddress: string, amount: string, spenderAddress: string): Promise<string>;
|
51
58
|
transferErc20Token(tokenAddress: string, amount: string, receiver: string): Promise<string>;
|
52
59
|
wrapEther(amount: string, tokenAddress: string): Promise<string>;
|
53
60
|
getVestingStart(): Promise<string>;
|
package/dist/PerqSdk.js
CHANGED
@@ -9,6 +9,7 @@ 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");
|
12
13
|
class PerqSdk {
|
13
14
|
perqApi;
|
14
15
|
perqConfig;
|
@@ -18,17 +19,26 @@ class PerqSdk {
|
|
18
19
|
perqVestingContract;
|
19
20
|
spoolSdk;
|
20
21
|
signer;
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
yelayLiteSdk;
|
23
|
+
constructor(perqConfig, provider) {
|
24
|
+
const newSigner = provider?.getSigner();
|
25
|
+
if (provider && newSigner) {
|
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);
|
24
32
|
}
|
25
33
|
this.perqConfig = perqConfig;
|
26
|
-
this.signer = signer;
|
27
34
|
this.perqApi = new PerqApi_1.default(perqConfig.route);
|
28
|
-
this.perqTokenContract = new contracts_1.PerqTokenContract(perqConfig.perqTokenAddress,
|
29
|
-
this.perqTokenRecyclerContract = new contracts_1.PerqTokenRecyclerContract(perqConfig.perqTokenRecyclerAddress,
|
30
|
-
this.perqSwapAndRecyclerContract = new contracts_1.PerqSwapAndRecyclerContract(perqConfig.perqSwapAndRecyclerAddress,
|
31
|
-
this.perqVestingContract = new contracts_1.PerqVestingContract(perqConfig.perqVestingAddress,
|
35
|
+
this.perqTokenContract = new contracts_1.PerqTokenContract(perqConfig.perqTokenAddress, newSigner);
|
36
|
+
this.perqTokenRecyclerContract = new contracts_1.PerqTokenRecyclerContract(perqConfig.perqTokenRecyclerAddress, newSigner);
|
37
|
+
this.perqSwapAndRecyclerContract = new contracts_1.PerqSwapAndRecyclerContract(perqConfig.perqSwapAndRecyclerAddress, newSigner);
|
38
|
+
this.perqVestingContract = new contracts_1.PerqVestingContract(perqConfig.perqVestingAddress, newSigner);
|
39
|
+
}
|
40
|
+
async getAllYelayLiteVaults() {
|
41
|
+
return this.perqApi.fetchAllYelayLiteVaults();
|
32
42
|
}
|
33
43
|
async getAllVaults() {
|
34
44
|
return this.perqApi.fetchAllVaults();
|
@@ -36,6 +46,9 @@ class PerqSdk {
|
|
36
46
|
async getVaultDetails(vaultAddress) {
|
37
47
|
return this.perqApi.fetchVaultDetails(vaultAddress);
|
38
48
|
}
|
49
|
+
async getYelayLiteVaultDetails(vaultAddress, yliteProjectId) {
|
50
|
+
return this.perqApi.fetchYelayLiteVaultDetails(vaultAddress, yliteProjectId);
|
51
|
+
}
|
39
52
|
async getVaultStats() {
|
40
53
|
return this.perqApi.fetchVaultStats();
|
41
54
|
}
|
@@ -50,6 +63,23 @@ class PerqSdk {
|
|
50
63
|
this.perqSwapAndRecyclerContract.updateSigner(newSigner);
|
51
64
|
this.perqVestingContract.updateSigner(newSigner);
|
52
65
|
}
|
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
|
+
}
|
53
83
|
async newDeposit(tokenAddress, vaultAddress, amount) {
|
54
84
|
return this.doDeposit(tokenAddress, vaultAddress, amount, false);
|
55
85
|
}
|
@@ -126,6 +156,14 @@ class PerqSdk {
|
|
126
156
|
const myPerqBalance = this.perqApi.fetchMyPerqData(userAddress);
|
127
157
|
return myPerqBalance;
|
128
158
|
}
|
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
|
+
}
|
129
167
|
async getUserVaultBalance(vaultAddress) {
|
130
168
|
if (!this.signer) {
|
131
169
|
throw Error('No signer provided');
|
@@ -232,6 +270,18 @@ class PerqSdk {
|
|
232
270
|
const redeemTxReceipt = await redeemTx.wait();
|
233
271
|
return redeemTxReceipt.transactionHash;
|
234
272
|
}
|
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
|
+
}
|
235
285
|
async claimWithdraws(vaultAddress) {
|
236
286
|
const userAddress = await this.signer.getAddress();
|
237
287
|
if (!this.signer) {
|
@@ -279,15 +329,6 @@ class PerqSdk {
|
|
279
329
|
if (this.perqConfig.perqSwapAndRecyclerAddress === ethers_1.ethers.constants.AddressZero) {
|
280
330
|
throw Error('Recycler contract address not defined');
|
281
331
|
}
|
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
|
-
});
|
291
332
|
const swapAndRecycleTx = await this.perqSwapAndRecyclerContract.swapAndRecycle(beneficiary, path, amountInWithDecimals, minAmountOutWithDecimals, price, deadline, signature);
|
292
333
|
const receipt = await swapAndRecycleTx.wait();
|
293
334
|
return receipt.transactionHash;
|
@@ -336,6 +377,15 @@ class PerqSdk {
|
|
336
377
|
async getSwapPerqForBeansInfo() {
|
337
378
|
return this.perqApi.getSwapPerqForBeansInfo();
|
338
379
|
}
|
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
|
+
}
|
339
389
|
async transferErc20Token(tokenAddress, amount, receiver) {
|
340
390
|
if (!this.signer) {
|
341
391
|
throw Error('No signer provided');
|
package/dist/types/PerqConfig.js
CHANGED
@@ -11,6 +11,7 @@ exports.PRODUCTION = {
|
|
11
11
|
perqVestingAddress: '0x5e19C155C30bDEB83FCFE20a3b6f6Eda34B746c5',
|
12
12
|
swapAndDepositContractAddress: '0xd8534197bd587f8226d12e0c864ef2cae6f82f5c',
|
13
13
|
smartVaultManagerContractAddress: '0x23daf34e2b9af02a74dc19cb52af727b19403874',
|
14
|
+
yelayLiteBackendUrl: '',
|
14
15
|
};
|
15
16
|
exports.DEVELOPMENT = {
|
16
17
|
route: 'https://dev.perq.finance',
|
@@ -21,4 +22,5 @@ exports.DEVELOPMENT = {
|
|
21
22
|
perqVestingAddress: '0x1d3B9E32a7139718f94BE32c797682fFf2D1bE60',
|
22
23
|
swapAndDepositContractAddress: '0x5fb08e00de169f041711206a0995410884080177',
|
23
24
|
smartVaultManagerContractAddress: '0x2638d6c0b4ef6dee04050fa0b07ca62500435747',
|
25
|
+
yelayLiteBackendUrl: 'https://lite.dev.yelay.io',
|
24
26
|
};
|
package/dist/types/index.d.ts
CHANGED
@@ -24,4 +24,5 @@ import VaultStats from './VaultStats';
|
|
24
24
|
import VaultType from './VaultType';
|
25
25
|
import VestingInfo from './VestingInfo';
|
26
26
|
import YelayVersion from './YelayVersion';
|
27
|
-
|
27
|
+
import YelayLiteVault from './YelayLiteVault';
|
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, };
|
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-yelay-lite",
|
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.15",
|
18
18
|
"ethers": "^5.7.2"
|
19
19
|
},
|
20
20
|
"author": "",
|