@dripfi/drip-sdk 1.4.7 → 1.4.9
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 +13 -0
- package/dist/PerqApi.d.ts +3 -1
- package/dist/PerqApi.js +28 -2
- package/dist/PerqSdk.d.ts +2 -0
- package/dist/PerqSdk.js +15 -10
- package/dist/types/LinkWalletPayload.d.ts +4 -0
- package/dist/types/LinkWalletPayload.js +2 -0
- package/dist/types/PerqConfig.d.ts +1 -0
- package/dist/types/PerqConfig.js +2 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -96,3 +96,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
96
96
|
### Added
|
97
97
|
|
98
98
|
- Added method `getSwapAndDepositTokenAllowanceForCurrency` to the `PerqSdk`
|
99
|
+
|
100
|
+
## [1.4.8] - 2025-02-14
|
101
|
+
|
102
|
+
### Changed
|
103
|
+
|
104
|
+
- Updated `PerqApi` to use the new 1inch API endpoint
|
105
|
+
|
106
|
+
## [1.4.9] - 2025-02-14
|
107
|
+
|
108
|
+
### Added
|
109
|
+
|
110
|
+
- Added method `linkSuiWalletWithEthWallet` to the `PerqSdk`
|
111
|
+
- Added method `getLinkedSuiWallet` to the `PerqSdk`
|
package/dist/PerqApi.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
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, LinkWalletPayload } from './types';
|
3
3
|
export default class PerqApi {
|
4
4
|
route: string;
|
5
5
|
constructor(route: string);
|
@@ -26,6 +26,8 @@ export default class PerqApi {
|
|
26
26
|
fetchMyPerqData(userAddress: string): Promise<MyPerqData[]>;
|
27
27
|
getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
|
28
28
|
fetchBeansHistory(walletAddress: string): Promise<BeanEntry[]>;
|
29
|
+
linkSuiWalletWithEthWallet(signedPayload: NonceEnrichedSignedPayload<LinkWalletPayload>): Promise<boolean>;
|
30
|
+
getLinkedSuiWallet(walletAddress: string): Promise<string>;
|
29
31
|
getNonceEnrichedPayload<T>(payload: T): Promise<NonceEnrichedPayload<T>>;
|
30
32
|
fetchUserVaultDeposits(userAddress: string, vaultAddress: string): Promise<{
|
31
33
|
pending: number;
|
package/dist/PerqApi.js
CHANGED
@@ -88,14 +88,15 @@ class PerqApi {
|
|
88
88
|
if (fromTokenAddress === toTokenAddress && fromTokenAddress === WETH_TOKEN_ADDRESS) {
|
89
89
|
return [];
|
90
90
|
}
|
91
|
-
|
91
|
+
//TODO: Replace the /1/ in this string with dynamic chainId
|
92
|
+
const url = `${this.route}/oneinch?getRequest=/swap/v6.0/1/swap?fromTokenAddress=${fromTokenAddress}%26toTokenAddress=${toTokenAddress}%26amount=${amount.toString()}%26fromAddress=${fromAddress}%26slippage=0.1%26disableEstimate=true%26allowPartialFill=false%26includeTokensInfo=true`;
|
92
93
|
const res = await fetch(url);
|
93
94
|
if (res.ok) {
|
94
95
|
const data = (await res.json());
|
95
96
|
return [
|
96
97
|
{
|
97
98
|
swapTarget: data.tx.to,
|
98
|
-
token: data.
|
99
|
+
token: data.srcToken.address,
|
99
100
|
swapCallData: data.tx.data,
|
100
101
|
},
|
101
102
|
];
|
@@ -300,6 +301,31 @@ class PerqApi {
|
|
300
301
|
throw Error(`${await res.text()}`);
|
301
302
|
}
|
302
303
|
}
|
304
|
+
async linkSuiWalletWithEthWallet(signedPayload) {
|
305
|
+
const res = await fetch(`${this.route}/api-be/api/user/suiWallet`, {
|
306
|
+
method: 'POST',
|
307
|
+
headers: {
|
308
|
+
'Content-Type': 'application/json',
|
309
|
+
},
|
310
|
+
body: JSON.stringify(signedPayload),
|
311
|
+
});
|
312
|
+
if (res.ok) {
|
313
|
+
return true;
|
314
|
+
}
|
315
|
+
else {
|
316
|
+
throw Error(`${await res.text()}`);
|
317
|
+
}
|
318
|
+
}
|
319
|
+
async getLinkedSuiWallet(walletAddress) {
|
320
|
+
const res = await fetch(`${this.route}/api-be/api/user/suiWallet/${walletAddress}`);
|
321
|
+
if (res.ok) {
|
322
|
+
const data = await res.json();
|
323
|
+
return data.suiWalletAddr;
|
324
|
+
}
|
325
|
+
else {
|
326
|
+
throw Error(`${await res.text()}`);
|
327
|
+
}
|
328
|
+
}
|
303
329
|
async getNonceEnrichedPayload(payload) {
|
304
330
|
const res = await fetch(`${this.route}/api-be/api/nonce`, {
|
305
331
|
method: 'POST',
|
package/dist/PerqSdk.d.ts
CHANGED
@@ -59,6 +59,8 @@ export default class PerqSdk {
|
|
59
59
|
getAllVestingInfo(beneficiaryAddress: string): Promise<VestingInfo>;
|
60
60
|
claimVestedPerq(amount: string): Promise<string>;
|
61
61
|
burnVestedPerq(amount: string, price: string, deadline: string, signature: string): Promise<string>;
|
62
|
+
linkSuiWalletWithEthWallet(suiWalletAddress: string): Promise<boolean>;
|
63
|
+
getLinkedSuiWallet(): Promise<string>;
|
62
64
|
signPayload<T>(payload: T): Promise<NonceEnrichedSignedPayload<T>>;
|
63
65
|
private getEnrichedPayload;
|
64
66
|
private generateRedeemBagStruct;
|
package/dist/PerqSdk.js
CHANGED
@@ -210,7 +210,7 @@ class PerqSdk {
|
|
210
210
|
}
|
211
211
|
}
|
212
212
|
const fromToken = ethers_1.ethers.utils.parseUnits(amountWithDecimals.toString(), decimals);
|
213
|
-
const swapInfo = await this.perqApi.getSwapInfo(fromTokenAddress, toTokenAddress, fromToken,
|
213
|
+
const swapInfo = await this.perqApi.getSwapInfo(fromTokenAddress, toTokenAddress, fromToken, this.perqConfig.swapperAddress);
|
214
214
|
const swapDepositBagStruct = {
|
215
215
|
inTokens: [fromTokenAddress],
|
216
216
|
inAmounts: [fromToken],
|
@@ -287,15 +287,6 @@ class PerqSdk {
|
|
287
287
|
if (this.perqConfig.perqSwapAndRecyclerAddress === ethers_1.ethers.constants.AddressZero) {
|
288
288
|
throw Error('Recycler contract address not defined');
|
289
289
|
}
|
290
|
-
console.log('swap and recycle ERC-20 with this: ', {
|
291
|
-
beneficiary,
|
292
|
-
path,
|
293
|
-
amountInWithDecimals,
|
294
|
-
minAmountOutWithDecimals,
|
295
|
-
price,
|
296
|
-
deadline,
|
297
|
-
signature,
|
298
|
-
});
|
299
290
|
const swapAndRecycleTx = await this.perqSwapAndRecyclerContract.swapAndRecycle(beneficiary, path, amountInWithDecimals, minAmountOutWithDecimals, price, deadline, signature);
|
300
291
|
const receipt = await swapAndRecycleTx.wait();
|
301
292
|
return receipt.transactionHash;
|
@@ -467,6 +458,20 @@ class PerqSdk {
|
|
467
458
|
throw new Error('Failed to get total releasable amount: Unknown error');
|
468
459
|
}
|
469
460
|
}
|
461
|
+
async linkSuiWalletWithEthWallet(suiWalletAddress) {
|
462
|
+
const payload = {
|
463
|
+
suiWalletAddr: suiWalletAddress,
|
464
|
+
};
|
465
|
+
const signedPayload = await this.signPayload(payload);
|
466
|
+
return this.perqApi.linkSuiWalletWithEthWallet(signedPayload);
|
467
|
+
}
|
468
|
+
async getLinkedSuiWallet() {
|
469
|
+
if (!this.signer) {
|
470
|
+
throw new Error('No signer provided');
|
471
|
+
}
|
472
|
+
const walletAddr = await this.signer.getAddress();
|
473
|
+
return this.perqApi.getLinkedSuiWallet(walletAddr);
|
474
|
+
}
|
470
475
|
async signPayload(payload) {
|
471
476
|
if (!this.signer) {
|
472
477
|
throw new Error('No signer provided');
|
package/dist/types/PerqConfig.js
CHANGED
@@ -10,6 +10,7 @@ exports.PRODUCTION = {
|
|
10
10
|
perqSwapAndRecyclerAddress: '0x15ED53964E6a5EcbEBAb80A0Fc68c2297b0eaA8D',
|
11
11
|
perqVestingAddress: '0x5e19C155C30bDEB83FCFE20a3b6f6Eda34B746c5',
|
12
12
|
swapAndDepositContractAddress: '0xd8534197bd587f8226d12e0c864ef2cae6f82f5c',
|
13
|
+
swapperAddress: '0x33e52c206d584550193e642c8982f2fff6339994',
|
13
14
|
smartVaultManagerContractAddress: '0x23daf34e2b9af02a74dc19cb52af727b19403874',
|
14
15
|
};
|
15
16
|
exports.DEVELOPMENT = {
|
@@ -20,5 +21,6 @@ exports.DEVELOPMENT = {
|
|
20
21
|
perqSwapAndRecyclerAddress: '0xA4ed357FF233731860Ec8D0446FD95756d564014',
|
21
22
|
perqVestingAddress: '0x1d3B9E32a7139718f94BE32c797682fFf2D1bE60',
|
22
23
|
swapAndDepositContractAddress: '0x5fb08e00de169f041711206a0995410884080177',
|
24
|
+
swapperAddress: '0xE411921ee9EeDfEFd7b9Ae15bF232bd36949Fcbc',
|
23
25
|
smartVaultManagerContractAddress: '0x2638d6c0b4ef6dee04050fa0b07ca62500435747',
|
24
26
|
};
|
package/dist/types/index.d.ts
CHANGED
@@ -5,6 +5,7 @@ import DeployedProject, { ProjectBacker } from './DeployedProject';
|
|
5
5
|
import DeployedVault from './DeployedVault';
|
6
6
|
import DepositToken from './DepositToken';
|
7
7
|
import ELoyaltyCardTier from './ELoyaltyCardTier';
|
8
|
+
import LinkWalletPayload from './LinkWalletPayload';
|
8
9
|
import LoyaltyCard from './LoyaltyCard';
|
9
10
|
import MyPerqData from './MyPerqData';
|
10
11
|
import NFTBoost from './NFTBoost';
|
@@ -24,4 +25,4 @@ import VaultStats from './VaultStats';
|
|
24
25
|
import VaultType from './VaultType';
|
25
26
|
import VestingInfo from './VestingInfo';
|
26
27
|
import YelayVersion from './YelayVersion';
|
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, };
|
28
|
+
export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, ELoyaltyCardTier, LinkWalletPayload, LoyaltyCard, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, RewardType, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, UserVaultBalance, Vault, VaultReward, VaultStats, VaultType, VestingInfo, YelayVersion, };
|